aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/Kconfig7
-rw-r--r--arch/alpha/Kconfig3
-rw-r--r--arch/alpha/include/asm/atomic.h4
-rw-r--r--arch/alpha/include/asm/fpu.h2
-rw-r--r--arch/alpha/include/asm/ptrace.h5
-rw-r--r--arch/alpha/include/asm/socket.h2
-rw-r--r--arch/alpha/include/asm/uaccess.h34
-rw-r--r--arch/alpha/include/asm/unistd.h5
-rw-r--r--arch/alpha/include/asm/word-at-a-time.h55
-rw-r--r--arch/alpha/kernel/alpha_ksyms.c3
-rw-r--r--arch/alpha/kernel/entry.S161
-rw-r--r--arch/alpha/kernel/osf_sys.c49
-rw-r--r--arch/alpha/kernel/pci.c17
-rw-r--r--arch/alpha/kernel/process.c19
-rw-r--r--arch/alpha/kernel/smc37c669.c12
-rw-r--r--arch/alpha/kernel/systbls.S4
-rw-r--r--arch/alpha/lib/Makefile2
-rw-r--r--arch/alpha/lib/ev6-strncpy_from_user.S424
-rw-r--r--arch/alpha/lib/ev67-strlen_user.S107
-rw-r--r--arch/alpha/lib/strlen_user.S91
-rw-r--r--arch/alpha/lib/strncpy_from_user.S339
-rw-r--r--arch/alpha/mm/fault.c36
-rw-r--r--arch/alpha/oprofile/common.c1
-rw-r--r--arch/arm/Kconfig92
-rw-r--r--arch/arm/Kconfig.debug35
-rw-r--r--arch/arm/Makefile5
-rw-r--r--arch/arm/boot/compressed/atags_to_fdt.c62
-rw-r--r--arch/arm/boot/dts/aks-cdu.dts113
-rw-r--r--arch/arm/boot/dts/am335x-bone.dts20
-rw-r--r--arch/arm/boot/dts/am335x-evm.dts20
-rw-r--r--arch/arm/boot/dts/am33xx.dtsi163
-rw-r--r--arch/arm/boot/dts/am3517-evm.dts32
-rw-r--r--arch/arm/boot/dts/armada-370-db.dts42
-rw-r--r--arch/arm/boot/dts/armada-370-xp.dtsi68
-rw-r--r--arch/arm/boot/dts/armada-370.dtsi35
-rw-r--r--arch/arm/boot/dts/armada-xp-db.dts50
-rw-r--r--arch/arm/boot/dts/armada-xp.dtsi55
-rw-r--r--arch/arm/boot/dts/at91sam9260.dtsi37
-rw-r--r--arch/arm/boot/dts/at91sam9263.dtsi31
-rw-r--r--arch/arm/boot/dts/at91sam9g25ek.dts2
-rw-r--r--arch/arm/boot/dts/at91sam9g45.dtsi39
-rw-r--r--arch/arm/boot/dts/at91sam9n12.dtsi30
-rw-r--r--arch/arm/boot/dts/at91sam9x5.dtsi39
-rw-r--r--arch/arm/boot/dts/db8500.dtsi107
-rw-r--r--arch/arm/boot/dts/ea3250.dts174
-rw-r--r--arch/arm/boot/dts/evk-pro3.dts41
-rw-r--r--arch/arm/boot/dts/exynos4210-origen.dts12
-rw-r--r--arch/arm/boot/dts/exynos4210-smdkv310.dts38
-rw-r--r--arch/arm/boot/dts/exynos4210.dtsi47
-rw-r--r--arch/arm/boot/dts/exynos5250-smdk5250.dts38
-rw-r--r--arch/arm/boot/dts/exynos5250.dtsi36
-rw-r--r--arch/arm/boot/dts/ge863-pro3.dtsi52
-rw-r--r--arch/arm/boot/dts/highbank.dts103
-rw-r--r--arch/arm/boot/dts/imx23-evk.dts66
-rw-r--r--arch/arm/boot/dts/imx23-olinuxino.dts44
-rw-r--r--arch/arm/boot/dts/imx23-stmp378x_devb.dts78
-rw-r--r--arch/arm/boot/dts/imx23.dtsi219
-rw-r--r--arch/arm/boot/dts/imx27-3ds.dts41
-rw-r--r--arch/arm/boot/dts/imx27.dtsi18
-rw-r--r--arch/arm/boot/dts/imx28-apx4devkit.dts198
-rw-r--r--arch/arm/boot/dts/imx28-cfa10036.dts52
-rw-r--r--arch/arm/boot/dts/imx28-evk.dts164
-rw-r--r--arch/arm/boot/dts/imx28-m28evk.dts210
-rw-r--r--arch/arm/boot/dts/imx28-tx28.dts97
-rw-r--r--arch/arm/boot/dts/imx28.dtsi427
-rw-r--r--arch/arm/boot/dts/imx31-bug.dts31
-rw-r--r--arch/arm/boot/dts/imx31.dtsi88
-rw-r--r--arch/arm/boot/dts/imx51-babbage.dts6
-rw-r--r--arch/arm/boot/dts/imx51.dtsi20
-rw-r--r--arch/arm/boot/dts/imx53-ard.dts22
-rw-r--r--arch/arm/boot/dts/imx53.dtsi35
-rw-r--r--arch/arm/boot/dts/imx6q-arm2.dts6
-rw-r--r--arch/arm/boot/dts/imx6q-sabrelite.dts34
-rw-r--r--arch/arm/boot/dts/imx6q.dtsi120
-rw-r--r--arch/arm/boot/dts/kirkwood-dns320.dts64
-rw-r--r--arch/arm/boot/dts/kirkwood-dns325.dts70
-rw-r--r--arch/arm/boot/dts/kirkwood-dnskw.dtsi69
-rw-r--r--arch/arm/boot/dts/kirkwood-dreamplug.dts52
-rw-r--r--arch/arm/boot/dts/kirkwood-goflexnet.dts99
-rw-r--r--arch/arm/boot/dts/kirkwood-ib62x0.dts40
-rw-r--r--arch/arm/boot/dts/kirkwood-iconnect.dts48
-rw-r--r--arch/arm/boot/dts/kirkwood-lschlv2.dts20
-rw-r--r--arch/arm/boot/dts/kirkwood-lsxhl.dts20
-rw-r--r--arch/arm/boot/dts/kirkwood-lsxl.dtsi95
-rw-r--r--arch/arm/boot/dts/kirkwood-ts219-6281.dts21
-rw-r--r--arch/arm/boot/dts/kirkwood-ts219-6282.dts21
-rw-r--r--arch/arm/boot/dts/kirkwood-ts219.dtsi78
-rw-r--r--arch/arm/boot/dts/kirkwood.dtsi66
-rw-r--r--arch/arm/boot/dts/lpc32xx.dtsi79
-rw-r--r--arch/arm/boot/dts/omap2420-h4.dts20
-rw-r--r--arch/arm/boot/dts/omap3-beagle.dts4
-rw-r--r--arch/arm/boot/dts/omap3-evm.dts28
-rw-r--r--arch/arm/boot/dts/omap3.dtsi5
-rw-r--r--arch/arm/boot/dts/omap4-panda.dts43
-rw-r--r--arch/arm/boot/dts/omap4-pandaES.dts24
-rw-r--r--arch/arm/boot/dts/omap4-sdp.dts72
-rw-r--r--arch/arm/boot/dts/omap4-var_som.dts96
-rw-r--r--arch/arm/boot/dts/omap4.dtsi23
-rw-r--r--arch/arm/boot/dts/omap5-evm.dts20
-rw-r--r--arch/arm/boot/dts/omap5.dtsi184
-rw-r--r--arch/arm/boot/dts/phy3250.dts61
-rw-r--r--arch/arm/boot/dts/r8a7740.dtsi21
-rw-r--r--arch/arm/boot/dts/sh7377.dtsi21
-rw-r--r--arch/arm/boot/dts/snowball.dts21
-rw-r--r--arch/arm/boot/dts/socfpga.dtsi147
-rw-r--r--arch/arm/boot/dts/socfpga_cyclone5.dts34
-rw-r--r--arch/arm/boot/dts/tegra20-harmony.dts (renamed from arch/arm/boot/dts/tegra-harmony.dts)1
-rw-r--r--arch/arm/boot/dts/tegra20-paz00.dts (renamed from arch/arm/boot/dts/tegra-paz00.dts)1
-rw-r--r--arch/arm/boot/dts/tegra20-seaboard.dts (renamed from arch/arm/boot/dts/tegra-seaboard.dts)88
-rw-r--r--arch/arm/boot/dts/tegra20-trimslice.dts (renamed from arch/arm/boot/dts/tegra-trimslice.dts)2
-rw-r--r--arch/arm/boot/dts/tegra20-ventana.dts (renamed from arch/arm/boot/dts/tegra-ventana.dts)1
-rw-r--r--arch/arm/boot/dts/tegra20-whistler.dts301
-rw-r--r--arch/arm/boot/dts/tegra20.dtsi46
-rw-r--r--arch/arm/boot/dts/tegra30-cardhu.dts (renamed from arch/arm/boot/dts/tegra-cardhu.dts)1
-rw-r--r--arch/arm/boot/dts/tegra30.dtsi46
-rw-r--r--arch/arm/boot/dts/twl6030.dtsi3
-rw-r--r--arch/arm/boot/dts/vexpress-v2m-rs1.dtsi11
-rw-r--r--arch/arm/boot/dts/vexpress-v2m.dtsi11
-rw-r--r--arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts36
-rw-r--r--arch/arm/boot/dts/vexpress-v2p-ca15_a7.dts188
-rw-r--r--arch/arm/common/dmabounce.c1
-rw-r--r--arch/arm/configs/armadillo800eva_defconfig27
-rw-r--r--arch/arm/configs/exynos_defconfig92
-rw-r--r--arch/arm/configs/imx_v4_v5_defconfig51
-rw-r--r--arch/arm/configs/imx_v6_v7_defconfig62
-rw-r--r--arch/arm/configs/kzm9d_defconfig89
-rw-r--r--arch/arm/configs/kzm9g_defconfig8
-rw-r--r--arch/arm/configs/lpc32xx_defconfig26
-rw-r--r--arch/arm/configs/mvebu_defconfig46
-rw-r--r--arch/arm/configs/mxs_defconfig8
-rw-r--r--arch/arm/configs/omap2plus_defconfig4
-rw-r--r--arch/arm/configs/socfpga_defconfig83
-rw-r--r--arch/arm/configs/tct_hammer_defconfig2
-rw-r--r--arch/arm/configs/tegra_defconfig14
-rw-r--r--arch/arm/configs/u8500_defconfig1
-rw-r--r--arch/arm/include/asm/arch_timer.h3
-rw-r--r--arch/arm/include/asm/cacheflush.h8
-rw-r--r--arch/arm/include/asm/delay.h32
-rw-r--r--arch/arm/include/asm/dma-mapping.h29
-rw-r--r--arch/arm/include/asm/kmap_types.h26
-rw-r--r--arch/arm/include/asm/locks.h274
-rw-r--r--arch/arm/include/asm/mach/irq.h2
-rw-r--r--arch/arm/include/asm/memory.h2
-rw-r--r--arch/arm/include/asm/mutex.h119
-rw-r--r--arch/arm/include/asm/perf_event.h17
-rw-r--r--arch/arm/include/asm/pgtable.h40
-rw-r--r--arch/arm/include/asm/pmu.h3
-rw-r--r--arch/arm/include/asm/sched_clock.h2
-rw-r--r--arch/arm/include/asm/setup.h4
-rw-r--r--arch/arm/include/asm/spinlock.h76
-rw-r--r--arch/arm/include/asm/spinlock_types.h17
-rw-r--r--arch/arm/include/asm/timex.h10
-rw-r--r--arch/arm/include/asm/uaccess.h27
-rw-r--r--arch/arm/include/asm/unistd.h1
-rw-r--r--arch/arm/include/asm/word-at-a-time.h96
-rw-r--r--arch/arm/kernel/arch_timer.c13
-rw-r--r--arch/arm/kernel/armksyms.c7
-rw-r--r--arch/arm/kernel/bios32.c4
-rw-r--r--arch/arm/kernel/entry-armv.S111
-rw-r--r--arch/arm/kernel/entry-common.S44
-rw-r--r--arch/arm/kernel/fiq.c9
-rw-r--r--arch/arm/kernel/ftrace.c17
-rw-r--r--arch/arm/kernel/head.S59
-rw-r--r--arch/arm/kernel/irq.c10
-rw-r--r--arch/arm/kernel/perf_event.c15
-rw-r--r--arch/arm/kernel/perf_event_v6.c2
-rw-r--r--arch/arm/kernel/perf_event_v7.c5
-rw-r--r--arch/arm/kernel/perf_event_xscale.c2
-rw-r--r--arch/arm/kernel/process.c2
-rw-r--r--arch/arm/kernel/ptrace.c35
-rw-r--r--arch/arm/kernel/sched_clock.c24
-rw-r--r--arch/arm/kernel/setup.c6
-rw-r--r--arch/arm/kernel/signal.c114
-rw-r--r--arch/arm/kernel/signal.h2
-rw-r--r--arch/arm/kernel/smp.c5
-rw-r--r--arch/arm/kernel/topology.c241
-rw-r--r--arch/arm/kernel/traps.c88
-rw-r--r--arch/arm/lib/Makefile26
-rw-r--r--arch/arm/lib/delay-loop.S (renamed from arch/arm/lib/delay.S)20
-rw-r--r--arch/arm/lib/delay.c71
-rw-r--r--arch/arm/lib/io-acorn.S3
-rw-r--r--arch/arm/lib/io-readsw-armv3.S106
-rw-r--r--arch/arm/lib/io-writesw-armv3.S126
-rw-r--r--arch/arm/lib/strncpy_from_user.S43
-rw-r--r--arch/arm/lib/strnlen_user.S40
-rw-r--r--arch/arm/lib/uaccess.S564
-rw-r--r--arch/arm/mach-at91/Kconfig6
-rw-r--r--arch/arm/mach-at91/Makefile.boot2
-rw-r--r--arch/arm/mach-at91/at91rm9200.c1
-rw-r--r--arch/arm/mach-at91/at91rm9200_devices.c84
-rw-r--r--arch/arm/mach-at91/at91rm9200_time.c2
-rw-r--r--arch/arm/mach-at91/at91sam9260.c1
-rw-r--r--arch/arm/mach-at91/at91sam9260_devices.c98
-rw-r--r--arch/arm/mach-at91/at91sam9261.c1
-rw-r--r--arch/arm/mach-at91/at91sam9261_devices.c74
-rw-r--r--arch/arm/mach-at91/at91sam9263.c1
-rw-r--r--arch/arm/mach-at91/at91sam9263_devices.c90
-rw-r--r--arch/arm/mach-at91/at91sam926x_time.c2
-rw-r--r--arch/arm/mach-at91/at91sam9g45.c14
-rw-r--r--arch/arm/mach-at91/at91sam9g45_devices.c242
-rw-r--r--arch/arm/mach-at91/at91sam9rl.c1
-rw-r--r--arch/arm/mach-at91/at91sam9rl_devices.c82
-rw-r--r--arch/arm/mach-at91/at91sam9x5.c40
-rw-r--r--arch/arm/mach-at91/at91x40.c2
-rw-r--r--arch/arm/mach-at91/board-1arm.c2
-rw-r--r--arch/arm/mach-at91/board-afeb-9260v1.c2
-rw-r--r--arch/arm/mach-at91/board-cam60.c2
-rw-r--r--arch/arm/mach-at91/board-carmeva.c2
-rw-r--r--arch/arm/mach-at91/board-cpu9krea.c2
-rw-r--r--arch/arm/mach-at91/board-cpuat91.c2
-rw-r--r--arch/arm/mach-at91/board-csb337.c2
-rw-r--r--arch/arm/mach-at91/board-csb637.c2
-rw-r--r--arch/arm/mach-at91/board-dt.c2
-rw-r--r--arch/arm/mach-at91/board-eb01.c2
-rw-r--r--arch/arm/mach-at91/board-eb9200.c2
-rw-r--r--arch/arm/mach-at91/board-ecbat91.c2
-rw-r--r--arch/arm/mach-at91/board-eco920.c2
-rw-r--r--arch/arm/mach-at91/board-flexibity.c2
-rw-r--r--arch/arm/mach-at91/board-foxg20.c2
-rw-r--r--arch/arm/mach-at91/board-gsia18s.c2
-rw-r--r--arch/arm/mach-at91/board-kafa.c2
-rw-r--r--arch/arm/mach-at91/board-kb9202.c2
-rw-r--r--arch/arm/mach-at91/board-neocore926.c2
-rw-r--r--arch/arm/mach-at91/board-pcontrol-g20.c2
-rw-r--r--arch/arm/mach-at91/board-picotux200.c2
-rw-r--r--arch/arm/mach-at91/board-qil-a9260.c2
-rw-r--r--arch/arm/mach-at91/board-rm9200dk.c2
-rw-r--r--arch/arm/mach-at91/board-rm9200ek.c2
-rw-r--r--arch/arm/mach-at91/board-rsi-ews.c2
-rw-r--r--arch/arm/mach-at91/board-sam9-l9260.c2
-rw-r--r--arch/arm/mach-at91/board-sam9260ek.c2
-rw-r--r--arch/arm/mach-at91/board-sam9261ek.c2
-rw-r--r--arch/arm/mach-at91/board-sam9263ek.c2
-rw-r--r--arch/arm/mach-at91/board-sam9g20ek.c3
-rw-r--r--arch/arm/mach-at91/board-sam9m10g45ek.c2
-rw-r--r--arch/arm/mach-at91/board-sam9rlek.c2
-rw-r--r--arch/arm/mach-at91/board-snapper9260.c2
-rw-r--r--arch/arm/mach-at91/board-stamp9g20.c3
-rw-r--r--arch/arm/mach-at91/board-usb-a926x.c4
-rw-r--r--arch/arm/mach-at91/board-yl-9200.c2
-rw-r--r--arch/arm/mach-at91/clock.c12
-rw-r--r--arch/arm/mach-at91/generic.h2
-rw-r--r--arch/arm/mach-at91/gpio.c9
-rw-r--r--arch/arm/mach-at91/include/mach/at91_aic.h36
-rw-r--r--arch/arm/mach-at91/include/mach/at91_spi.h81
-rw-r--r--arch/arm/mach-at91/include/mach/at91_ssc.h106
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9g45.h2
-rw-r--r--arch/arm/mach-at91/include/mach/entry-macro.S27
-rw-r--r--arch/arm/mach-at91/irq.c414
-rw-r--r--arch/arm/mach-at91/pm.c1
-rw-r--r--arch/arm/mach-clps711x/common.c6
-rw-r--r--arch/arm/mach-clps711x/include/mach/memory.h37
-rw-r--r--arch/arm/mach-clps711x/p720t.c34
-rw-r--r--arch/arm/mach-davinci/Kconfig7
-rw-r--r--arch/arm/mach-davinci/Makefile1
-rw-r--r--arch/arm/mach-davinci/board-neuros-osd2.c39
-rw-r--r--arch/arm/mach-davinci/cp_intc.c75
-rw-r--r--arch/arm/mach-davinci/devices-da8xx.c1
-rw-r--r--arch/arm/mach-davinci/include/mach/cp_intc.h1
-rw-r--r--arch/arm/mach-davinci/include/mach/dm365.h1
-rw-r--r--arch/arm/mach-davinci/include/mach/dm646x.h1
-rw-r--r--arch/arm/mach-davinci/include/mach/entry-macro.S8
-rw-r--r--arch/arm/mach-davinci/pm_domain.c64
-rw-r--r--arch/arm/mach-dove/common.c5
-rw-r--r--arch/arm/mach-dove/irq.c58
-rw-r--r--arch/arm/mach-ep93xx/core.c96
-rw-r--r--arch/arm/mach-ep93xx/edb93xx.c28
-rw-r--r--arch/arm/mach-ep93xx/include/mach/platform.h3
-rw-r--r--arch/arm/mach-ep93xx/soc.h1
-rw-r--r--arch/arm/mach-exynos/Kconfig7
-rw-r--r--arch/arm/mach-exynos/clock-exynos4.c108
-rw-r--r--arch/arm/mach-exynos/clock-exynos4.h3
-rw-r--r--arch/arm/mach-exynos/clock-exynos4210.c37
-rw-r--r--arch/arm/mach-exynos/clock-exynos4212.c41
-rw-r--r--arch/arm/mach-exynos/clock-exynos5.c95
-rw-r--r--arch/arm/mach-exynos/common.c28
-rw-r--r--arch/arm/mach-exynos/include/mach/irqs.h4
-rw-r--r--arch/arm/mach-exynos/include/mach/map.h3
-rw-r--r--arch/arm/mach-exynos/include/mach/regs-pmu.h5
-rw-r--r--arch/arm/mach-exynos/include/mach/regs-usb-phy.h20
-rw-r--r--arch/arm/mach-exynos/include/mach/spi-clocks.h16
-rw-r--r--arch/arm/mach-exynos/mach-exynos4-dt.c6
-rw-r--r--arch/arm/mach-exynos/mach-exynos5-dt.c6
-rw-r--r--arch/arm/mach-exynos/mach-nuri.c8
-rw-r--r--arch/arm/mach-exynos/mach-origen.c48
-rw-r--r--arch/arm/mach-exynos/mach-smdk4x12.c83
-rw-r--r--arch/arm/mach-exynos/mach-smdkv310.c25
-rw-r--r--arch/arm/mach-exynos/mach-universal_c210.c4
-rw-r--r--arch/arm/mach-exynos/pm_domains.c2
-rw-r--r--arch/arm/mach-exynos/pmu.c18
-rw-r--r--arch/arm/mach-exynos/setup-spi.c33
-rw-r--r--arch/arm/mach-exynos/setup-usb-phy.c60
-rw-r--r--arch/arm/mach-gemini/irq.c1
-rw-r--r--arch/arm/mach-highbank/Makefile2
-rw-r--r--arch/arm/mach-highbank/clock.c62
-rw-r--r--arch/arm/mach-highbank/highbank.c7
-rw-r--r--arch/arm/mach-imx/Kconfig21
-rw-r--r--arch/arm/mach-imx/Makefile11
-rw-r--r--arch/arm/mach-imx/clk-imx27.c12
-rw-r--r--arch/arm/mach-imx/clk-imx31.c25
-rw-r--r--arch/arm/mach-imx/clk-imx51-imx53.c26
-rw-r--r--arch/arm/mach-imx/clk-imx6q.c31
-rw-r--r--arch/arm/mach-imx/devices-imx21.h4
-rw-r--r--arch/arm/mach-imx/devices-imx25.h4
-rw-r--r--arch/arm/mach-imx/devices-imx27.h6
-rw-r--r--arch/arm/mach-imx/devices-imx31.h10
-rw-r--r--arch/arm/mach-imx/devices-imx35.h12
-rw-r--r--arch/arm/mach-imx/devices-imx51.h2
-rw-r--r--arch/arm/mach-imx/devices-imx53.h2
-rw-r--r--arch/arm/mach-imx/ehci-imx25.c24
-rw-r--r--arch/arm/mach-imx/ehci-imx35.c24
-rw-r--r--arch/arm/mach-imx/ehci-imx5.c31
-rw-r--r--arch/arm/mach-imx/eukrea_mbimx27-baseboard.c3
-rw-r--r--arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c6
-rw-r--r--arch/arm/mach-imx/headsmp.S (renamed from arch/arm/mach-imx/head-v7.S)0
-rw-r--r--arch/arm/mach-imx/hotplug.c23
-rw-r--r--arch/arm/mach-imx/imx27-dt.c30
-rw-r--r--arch/arm/mach-imx/imx31-dt.c63
-rw-r--r--arch/arm/mach-imx/imx51-dt.c27
-rw-r--r--arch/arm/mach-imx/imx53-dt.c28
-rw-r--r--arch/arm/mach-imx/mach-apf9328.c7
-rw-r--r--arch/arm/mach-imx/mach-armadillo5x0.c18
-rw-r--r--arch/arm/mach-imx/mach-cpuimx27.c24
-rw-r--r--arch/arm/mach-imx/mach-cpuimx35.c13
-rw-r--r--arch/arm/mach-imx/mach-cpuimx51sd.c13
-rw-r--r--arch/arm/mach-imx/mach-eukrea_cpuimx25.c12
-rw-r--r--arch/arm/mach-imx/mach-imx27_visstrim_m10.c9
-rw-r--r--arch/arm/mach-imx/mach-imx27ipcam.c2
-rw-r--r--arch/arm/mach-imx/mach-imx6q.c78
-rw-r--r--arch/arm/mach-imx/mach-kzm_arm11_01.c20
-rw-r--r--arch/arm/mach-imx/mach-mx1ads.c1
-rw-r--r--arch/arm/mach-imx/mach-mx21ads.c16
-rw-r--r--arch/arm/mach-imx/mach-mx25_3ds.c4
-rw-r--r--arch/arm/mach-imx/mach-mx27_3ds.c17
-rw-r--r--arch/arm/mach-imx/mach-mx27ads.c14
-rw-r--r--arch/arm/mach-imx/mach-mx31_3ds.c28
-rw-r--r--arch/arm/mach-imx/mach-mx31ads.c63
-rw-r--r--arch/arm/mach-imx/mach-mx31lilly.c10
-rw-r--r--arch/arm/mach-imx/mach-mx31lite.c11
-rw-r--r--arch/arm/mach-imx/mach-mx31moboard.c12
-rw-r--r--arch/arm/mach-imx/mach-mx35_3ds.c29
-rw-r--r--arch/arm/mach-imx/mach-mx51_3ds.c5
-rw-r--r--arch/arm/mach-imx/mach-mx51_babbage.c10
-rw-r--r--arch/arm/mach-imx/mach-mx53_ard.c8
-rw-r--r--arch/arm/mach-imx/mach-mx53_evk.c3
-rw-r--r--arch/arm/mach-imx/mach-mx53_loco.c3
-rw-r--r--arch/arm/mach-imx/mach-mx53_smd.c3
-rw-r--r--arch/arm/mach-imx/mach-mxt_td60.c6
-rw-r--r--arch/arm/mach-imx/mach-pca100.c17
-rw-r--r--arch/arm/mach-imx/mach-pcm037.c36
-rw-r--r--arch/arm/mach-imx/mach-pcm038.c8
-rw-r--r--arch/arm/mach-imx/mach-pcm043.c16
-rw-r--r--arch/arm/mach-imx/mach-qong.c12
-rw-r--r--arch/arm/mach-imx/mach-scb9328.c7
-rw-r--r--arch/arm/mach-imx/mach-vpr200.c12
-rw-r--r--arch/arm/mach-imx/mm-imx1.c1
-rw-r--r--arch/arm/mach-imx/mm-imx21.c1
-rw-r--r--arch/arm/mach-imx/mm-imx25.c11
-rw-r--r--arch/arm/mach-imx/mm-imx27.c1
-rw-r--r--arch/arm/mach-imx/mm-imx3.c8
-rw-r--r--arch/arm/mach-imx/mm-imx5.c66
-rw-r--r--arch/arm/mach-imx/mx31lilly-db.c11
-rw-r--r--arch/arm/mach-imx/mx31lite-db.c9
-rw-r--r--arch/arm/mach-imx/mx51_efika.c3
-rw-r--r--arch/arm/mach-imx/pcm970-baseboard.c13
-rw-r--r--arch/arm/mach-imx/pm-imx5.c111
-rw-r--r--arch/arm/mach-integrator/core.c56
-rw-r--r--arch/arm/mach-integrator/include/mach/clkdev.h26
-rw-r--r--arch/arm/mach-integrator/integrator_ap.c10
-rw-r--r--arch/arm/mach-integrator/integrator_cp.c69
-rw-r--r--arch/arm/mach-kirkwood/Kconfig29
-rw-r--r--arch/arm/mach-kirkwood/Makefile3
-rw-r--r--arch/arm/mach-kirkwood/Makefile.boot5
-rw-r--r--arch/arm/mach-kirkwood/board-dnskw.c143
-rw-r--r--arch/arm/mach-kirkwood/board-dreamplug.c80
-rw-r--r--arch/arm/mach-kirkwood/board-dt.c29
-rw-r--r--arch/arm/mach-kirkwood/board-goflexnet.c71
-rw-r--r--arch/arm/mach-kirkwood/board-ib62x0.c72
-rw-r--r--arch/arm/mach-kirkwood/board-iconnect.c56
-rw-r--r--arch/arm/mach-kirkwood/board-lsxl.c135
-rw-r--r--arch/arm/mach-kirkwood/board-ts219.c82
-rw-r--r--arch/arm/mach-kirkwood/common.c83
-rw-r--r--arch/arm/mach-kirkwood/common.h17
-rw-r--r--arch/arm/mach-kirkwood/db88f6281-bp-setup.c1
-rw-r--r--arch/arm/mach-kirkwood/irq.c38
-rw-r--r--arch/arm/mach-lpc32xx/Kconfig32
-rw-r--r--arch/arm/mach-lpc32xx/Makefile.boot1
-rw-r--r--arch/arm/mach-lpc32xx/clock.c123
-rw-r--r--arch/arm/mach-lpc32xx/common.c10
-rw-r--r--arch/arm/mach-lpc32xx/include/mach/gpio.h2
-rw-r--r--arch/arm/mach-lpc32xx/include/mach/platform.h14
-rw-r--r--arch/arm/mach-lpc32xx/phy3250.c163
-rw-r--r--arch/arm/mach-lpc32xx/serial.c90
-rw-r--r--arch/arm/mach-mmp/gplugd.c1
-rw-r--r--arch/arm/mach-mmp/sram.c2
-rw-r--r--arch/arm/mach-msm/platsmp.c2
-rw-r--r--arch/arm/mach-mv78xx0/addr-map.c2
-rw-r--r--arch/arm/mach-mv78xx0/common.c6
-rw-r--r--arch/arm/mach-mv78xx0/irq.c22
-rw-r--r--arch/arm/mach-mvebu/Kconfig16
-rw-r--r--arch/arm/mach-mvebu/Makefile2
-rw-r--r--arch/arm/mach-mvebu/Makefile.boot3
-rw-r--r--arch/arm/mach-mvebu/armada-370-xp.c63
-rw-r--r--arch/arm/mach-mvebu/common.h23
-rw-r--r--arch/arm/mach-mvebu/include/mach/armada-370-xp.h22
-rw-r--r--arch/arm/mach-mvebu/include/mach/debug-macro.S24
-rw-r--r--arch/arm/mach-mvebu/include/mach/timex.h13
-rw-r--r--arch/arm/mach-mvebu/include/mach/uncompress.h43
-rw-r--r--arch/arm/mach-mvebu/irq-armada-370-xp.c133
-rw-r--r--arch/arm/mach-mvebu/system-controller.c105
-rw-r--r--arch/arm/mach-mxs/Kconfig7
-rw-r--r--arch/arm/mach-mxs/Makefile3
-rw-r--r--arch/arm/mach-mxs/Makefile.boot9
-rw-r--r--arch/arm/mach-mxs/devices-mx23.h2
-rw-r--r--arch/arm/mach-mxs/devices-mx28.h2
-rw-r--r--arch/arm/mach-mxs/devices/platform-mxsfb.c2
-rw-r--r--arch/arm/mach-mxs/include/mach/mxsfb.h49
-rw-r--r--arch/arm/mach-mxs/mach-mxs.c211
-rw-r--r--arch/arm/mach-mxs/module-tx28.c2
-rw-r--r--arch/arm/mach-netx/fb.c23
-rw-r--r--arch/arm/mach-nomadik/Makefile2
-rw-r--r--arch/arm/mach-nomadik/board-nhk8815.c67
-rw-r--r--arch/arm/mach-nomadik/clock.c75
-rw-r--r--arch/arm/mach-nomadik/clock.h15
-rw-r--r--arch/arm/mach-nomadik/cpu-8815.c126
-rw-r--r--arch/arm/mach-nomadik/i2c-8815nhk.c38
-rw-r--r--arch/arm/mach-nomadik/include/mach/irqs.h85
-rw-r--r--arch/arm/mach-omap1/board-ams-delta.c2
-rw-r--r--arch/arm/mach-omap1/board-generic.c4
-rw-r--r--arch/arm/mach-omap1/board-h2-mmc.c1
-rw-r--r--arch/arm/mach-omap1/board-h2.c2
-rw-r--r--arch/arm/mach-omap1/board-h3-mmc.c1
-rw-r--r--arch/arm/mach-omap1/board-h3.c2
-rw-r--r--arch/arm/mach-omap1/board-htcherald.c2
-rw-r--r--arch/arm/mach-omap1/board-innovator.c2
-rw-r--r--arch/arm/mach-omap1/board-nokia770.c3
-rw-r--r--arch/arm/mach-omap1/board-osk.c2
-rw-r--r--arch/arm/mach-omap1/board-palmte.c2
-rw-r--r--arch/arm/mach-omap1/board-palmtt.c2
-rw-r--r--arch/arm/mach-omap1/board-palmz71.c5
-rw-r--r--arch/arm/mach-omap1/board-sx1.c2
-rw-r--r--arch/arm/mach-omap1/board-voiceblue.c3
-rw-r--r--arch/arm/mach-omap1/clock_data.c3
-rw-r--r--arch/arm/mach-omap1/include/mach/usb.h165
-rw-r--r--arch/arm/mach-omap1/timer.c3
-rw-r--r--arch/arm/mach-omap1/usb.c116
-rw-r--r--arch/arm/mach-omap2/Kconfig27
-rw-r--r--arch/arm/mach-omap2/Makefile59
-rw-r--r--arch/arm/mach-omap2/am35xx-emac.c90
-rw-r--r--arch/arm/mach-omap2/board-2430sdp.c14
-rw-r--r--arch/arm/mach-omap2/board-4430sdp.c3
-rw-r--r--arch/arm/mach-omap2/board-apollon.c20
-rw-r--r--arch/arm/mach-omap2/board-cm-t35.c89
-rw-r--r--arch/arm/mach-omap2/board-generic.c58
-rw-r--r--arch/arm/mach-omap2/board-h4.c13
-rw-r--r--arch/arm/mach-omap2/board-igep0020.c2
-rw-r--r--arch/arm/mach-omap2/board-n8x0.c1
-rw-r--r--arch/arm/mach-omap2/board-omap3beagle.c2
-rw-r--r--arch/arm/mach-omap2/board-omap3evm.c77
-rw-r--r--arch/arm/mach-omap2/board-omap3logic.c3
-rw-r--r--arch/arm/mach-omap2/board-omap4panda.c5
-rw-r--r--arch/arm/mach-omap2/clock.c18
-rw-r--r--arch/arm/mach-omap2/clock.h14
-rw-r--r--arch/arm/mach-omap2/clock2420_data.c43
-rw-r--r--arch/arm/mach-omap2/clock2430_data.c49
-rw-r--r--arch/arm/mach-omap2/clock33xx_data.c1105
-rw-r--r--arch/arm/mach-omap2/clock3xxx_data.c100
-rw-r--r--arch/arm/mach-omap2/clock44xx_data.c128
-rw-r--r--arch/arm/mach-omap2/clock_common_data.c77
-rw-r--r--arch/arm/mach-omap2/clockdomain.h4
-rw-r--r--arch/arm/mach-omap2/clockdomain33xx.c74
-rw-r--r--arch/arm/mach-omap2/clockdomain44xx.c10
-rw-r--r--arch/arm/mach-omap2/clockdomains2420_data.c2
-rw-r--r--arch/arm/mach-omap2/clockdomains2430_data.c2
-rw-r--r--arch/arm/mach-omap2/clockdomains33xx_data.c196
-rw-r--r--arch/arm/mach-omap2/clockdomains3xxx_data.c159
-rw-r--r--arch/arm/mach-omap2/clockdomains44xx_data.c2
-rw-r--r--arch/arm/mach-omap2/clockdomains_common_data.c24
-rw-r--r--arch/arm/mach-omap2/cm-regbits-33xx.h687
-rw-r--r--arch/arm/mach-omap2/cm-regbits-34xx.h4
-rw-r--r--arch/arm/mach-omap2/cm33xx.c313
-rw-r--r--arch/arm/mach-omap2/cm33xx.h420
-rw-r--r--arch/arm/mach-omap2/cminst44xx.c14
-rw-r--r--arch/arm/mach-omap2/cminst44xx.h25
-rw-r--r--arch/arm/mach-omap2/common-board-devices.c22
-rw-r--r--arch/arm/mach-omap2/common.c34
-rw-r--r--arch/arm/mach-omap2/common.h27
-rw-r--r--arch/arm/mach-omap2/control.c43
-rw-r--r--arch/arm/mach-omap2/control.h46
-rw-r--r--arch/arm/mach-omap2/cpuidle34xx.c79
-rw-r--r--arch/arm/mach-omap2/cpuidle44xx.c156
-rw-r--r--arch/arm/mach-omap2/devices.c112
-rw-r--r--arch/arm/mach-omap2/display.c25
-rw-r--r--arch/arm/mach-omap2/dpll3xxx.c26
-rw-r--r--arch/arm/mach-omap2/drm.c61
-rw-r--r--arch/arm/mach-omap2/dsp.c4
-rw-r--r--arch/arm/mach-omap2/gpmc.c3
-rw-r--r--arch/arm/mach-omap2/hdq1w.c26
-rw-r--r--arch/arm/mach-omap2/hsmmc.c1
-rw-r--r--arch/arm/mach-omap2/id.c46
-rw-r--r--arch/arm/mach-omap2/include/mach/am35xx.h2
-rw-r--r--arch/arm/mach-omap2/include/mach/ctrl_module_core_44xx.h1
-rw-r--r--arch/arm/mach-omap2/include/mach/debug-macro.S25
-rw-r--r--arch/arm/mach-omap2/include/mach/omap-wakeupgen.h7
-rw-r--r--arch/arm/mach-omap2/io.c59
-rw-r--r--arch/arm/mach-omap2/iomap.h27
-rw-r--r--arch/arm/mach-omap2/irq.c23
-rw-r--r--arch/arm/mach-omap2/mailbox.c2
-rw-r--r--arch/arm/mach-omap2/msdi.c73
-rw-r--r--arch/arm/mach-omap2/mux.h1
-rw-r--r--arch/arm/mach-omap2/omap-headsmp.S21
-rw-r--r--arch/arm/mach-omap2/omap-hotplug.c24
-rw-r--r--arch/arm/mach-omap2/omap-iommu.c6
-rw-r--r--arch/arm/mach-omap2/omap-mpuss-lowpower.c6
-rw-r--r--arch/arm/mach-omap2/omap-smp.c54
-rw-r--r--arch/arm/mach-omap2/omap-wakeupgen.c114
-rw-r--r--arch/arm/mach-omap2/omap4-common.c14
-rw-r--r--arch/arm/mach-omap2/omap4-sar-layout.h12
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c541
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_2420_data.c10
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_2430_data.c16
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c8
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_3xxx_data.c188
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_44xx_data.c13
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_common_data.c10
-rw-r--r--arch/arm/mach-omap2/omap_l3_noc.h22
-rw-r--r--arch/arm/mach-omap2/opp.c3
-rw-r--r--arch/arm/mach-omap2/opp4xxx_data.c2
-rw-r--r--arch/arm/mach-omap2/pm.h19
-rw-r--r--arch/arm/mach-omap2/pm34xx.c67
-rw-r--r--arch/arm/mach-omap2/powerdomain.c22
-rw-r--r--arch/arm/mach-omap2/powerdomain.h27
-rw-r--r--arch/arm/mach-omap2/powerdomain33xx.c229
-rw-r--r--arch/arm/mach-omap2/powerdomains33xx_data.c185
-rw-r--r--arch/arm/mach-omap2/powerdomains3xxx_data.c139
-rw-r--r--arch/arm/mach-omap2/prcm-common.h14
-rw-r--r--arch/arm/mach-omap2/prcm.c25
-rw-r--r--arch/arm/mach-omap2/prm-regbits-33xx.h357
-rw-r--r--arch/arm/mach-omap2/prm2xxx_3xxx.c48
-rw-r--r--arch/arm/mach-omap2/prm2xxx_3xxx.h68
-rw-r--r--arch/arm/mach-omap2/prm33xx.c135
-rw-r--r--arch/arm/mach-omap2/prm33xx.h129
-rw-r--r--arch/arm/mach-omap2/prm44xx.c63
-rw-r--r--arch/arm/mach-omap2/prm44xx.h2
-rw-r--r--arch/arm/mach-omap2/prm_common.c70
-rw-r--r--arch/arm/mach-omap2/sleep44xx.S8
-rw-r--r--arch/arm/mach-omap2/smartreflex-class3.c29
-rw-r--r--arch/arm/mach-omap2/smartreflex.c1165
-rw-r--r--arch/arm/mach-omap2/smartreflex.h256
-rw-r--r--arch/arm/mach-omap2/sr_device.c41
-rw-r--r--arch/arm/mach-omap2/timer.c97
-rw-r--r--arch/arm/mach-omap2/twl-common.c14
-rw-r--r--arch/arm/mach-omap2/usb-fs.c359
-rw-r--r--arch/arm/mach-omap2/voltage.h22
-rw-r--r--arch/arm/mach-omap2/voltagedomains33xx_data.c43
-rw-r--r--arch/arm/mach-orion5x/common.c3
-rw-r--r--arch/arm/mach-orion5x/irq.c22
-rw-r--r--arch/arm/mach-picoxcell/Makefile1
-rw-r--r--arch/arm/mach-picoxcell/common.c3
-rw-r--r--arch/arm/mach-picoxcell/common.h2
-rw-r--r--arch/arm/mach-picoxcell/time.c121
-rw-r--r--arch/arm/mach-prima2/include/mach/gpio.h13
-rw-r--r--arch/arm/mach-prima2/include/mach/irqs.h2
-rw-r--r--arch/arm/mach-prima2/timer.c6
-rw-r--r--arch/arm/mach-pxa/eseries.h14
-rw-r--r--arch/arm/mach-pxa/hx4700.c56
-rw-r--r--arch/arm/mach-pxa/include/mach/regs-ost.h22
-rw-r--r--arch/arm/mach-pxa/lubbock.c2
-rw-r--r--arch/arm/mach-pxa/magician.c5
-rw-r--r--arch/arm/mach-pxa/raumfeld.c2
-rw-r--r--arch/arm/mach-pxa/reset.c7
-rw-r--r--arch/arm/mach-pxa/time.c52
-rw-r--r--arch/arm/mach-pxa/trizeps4.c4
-rw-r--r--arch/arm/mach-rpc/irq.c2
-rw-r--r--arch/arm/mach-s3c24xx/Kconfig4
-rw-r--r--arch/arm/mach-s3c24xx/clock-s3c2416.c3
-rw-r--r--arch/arm/mach-s3c24xx/clock-s3c2443.c2
-rw-r--r--arch/arm/mach-s3c24xx/common-s3c2443.c4
-rw-r--r--arch/arm/mach-s3c24xx/common-smdk.c20
-rw-r--r--arch/arm/mach-s3c24xx/common.c1
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/bast-pmu.h40
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/dma.h3
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/gpio-nrs.h21
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/gta02.h69
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/regs-gpio.h17
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/regs-gpioj.h70
-rw-r--r--arch/arm/mach-s3c24xx/mach-gta02.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-mini2440.c4
-rw-r--r--arch/arm/mach-s3c24xx/mach-qt2410.c6
-rw-r--r--arch/arm/mach-s3c24xx/mach-rx1950.c1
-rw-r--r--arch/arm/mach-s3c24xx/pm-s3c2410.c12
-rw-r--r--arch/arm/mach-s3c24xx/pm-s3c2412.c1
-rw-r--r--arch/arm/mach-s3c24xx/s3c2412.c1
-rw-r--r--arch/arm/mach-s3c24xx/s3c244x.c1
-rw-r--r--arch/arm/mach-s3c24xx/setup-spi.c10
-rw-r--r--arch/arm/mach-s3c24xx/setup-ts.c6
-rw-r--r--arch/arm/mach-s3c64xx/clock.c20
-rw-r--r--arch/arm/mach-s3c64xx/include/mach/crag6410.h4
-rw-r--r--arch/arm/mach-s3c64xx/include/mach/dma.h1
-rw-r--r--arch/arm/mach-s3c64xx/include/mach/pm-core.h4
-rw-r--r--arch/arm/mach-s3c64xx/include/mach/spi-clocks.h18
-rw-r--r--arch/arm/mach-s3c64xx/mach-crag6410-module.c11
-rw-r--r--arch/arm/mach-s3c64xx/mach-crag6410.c71
-rw-r--r--arch/arm/mach-s3c64xx/mach-smdk6410.c1
-rw-r--r--arch/arm/mach-s3c64xx/setup-spi.c19
-rw-r--r--arch/arm/mach-s5p64x0/clock-s5p6440.c12
-rw-r--r--arch/arm/mach-s5p64x0/clock-s5p6450.c12
-rw-r--r--arch/arm/mach-s5p64x0/dma.c2
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/spi-clocks.h20
-rw-r--r--arch/arm/mach-s5p64x0/setup-spi.c21
-rw-r--r--arch/arm/mach-s5pc100/clock.c30
-rw-r--r--arch/arm/mach-s5pc100/dma.c2
-rw-r--r--arch/arm/mach-s5pc100/include/mach/spi-clocks.h18
-rw-r--r--arch/arm/mach-s5pc100/setup-spi.c30
-rw-r--r--arch/arm/mach-s5pv210/Kconfig2
-rw-r--r--arch/arm/mach-s5pv210/clock.c14
-rw-r--r--arch/arm/mach-s5pv210/include/mach/spi-clocks.h17
-rw-r--r--arch/arm/mach-s5pv210/mach-aquila.c7
-rw-r--r--arch/arm/mach-s5pv210/mach-goni.c11
-rw-r--r--arch/arm/mach-s5pv210/mach-smdkv210.c10
-rw-r--r--arch/arm/mach-s5pv210/setup-spi.c21
-rw-r--r--arch/arm/mach-sa1100/assabet.c2
-rw-r--r--arch/arm/mach-sa1100/cpu-sa1100.c1
-rw-r--r--arch/arm/mach-sa1100/cpu-sa1110.c1
-rw-r--r--arch/arm/mach-sa1100/include/mach/SA-1100.h16
-rw-r--r--arch/arm/mach-sa1100/include/mach/gpio.h1
-rw-r--r--arch/arm/mach-sa1100/include/mach/hardware.h6
-rw-r--r--arch/arm/mach-sa1100/include/mach/uncompress.h2
-rw-r--r--arch/arm/mach-sa1100/irq.c1
-rw-r--r--arch/arm/mach-sa1100/jornada720_ssp.c1
-rw-r--r--arch/arm/mach-sa1100/leds-cerf.c1
-rw-r--r--arch/arm/mach-sa1100/leds-hackkit.c1
-rw-r--r--arch/arm/mach-sa1100/leds-lart.c1
-rw-r--r--arch/arm/mach-sa1100/pm.c1
-rw-r--r--arch/arm/mach-sa1100/sleep.S8
-rw-r--r--arch/arm/mach-sa1100/time.c48
-rw-r--r--arch/arm/mach-shmobile/Kconfig13
-rw-r--r--arch/arm/mach-shmobile/Makefile2
-rw-r--r--arch/arm/mach-shmobile/board-ag5evm.c82
-rw-r--r--arch/arm/mach-shmobile/board-ap4evb.c62
-rw-r--r--arch/arm/mach-shmobile/board-armadillo800eva.c466
-rw-r--r--arch/arm/mach-shmobile/board-bonito.c10
-rw-r--r--arch/arm/mach-shmobile/board-g4evm.c52
-rw-r--r--arch/arm/mach-shmobile/board-kota2.c30
-rw-r--r--arch/arm/mach-shmobile/board-kzm9d.c10
-rw-r--r--arch/arm/mach-shmobile/board-kzm9g.c320
-rw-r--r--arch/arm/mach-shmobile/board-mackerel.c86
-rw-r--r--arch/arm/mach-shmobile/board-marzen.c12
-rw-r--r--arch/arm/mach-shmobile/clock-r8a7740.c150
-rw-r--r--arch/arm/mach-shmobile/clock-r8a7779.c2
-rw-r--r--arch/arm/mach-shmobile/clock-sh7367.c2
-rw-r--r--arch/arm/mach-shmobile/clock-sh7372.c2
-rw-r--r--arch/arm/mach-shmobile/clock-sh7377.c2
-rw-r--r--arch/arm/mach-shmobile/clock-sh73a0.c12
-rw-r--r--arch/arm/mach-shmobile/include/mach/common.h1
-rw-r--r--arch/arm/mach-shmobile/include/mach/dma-register.h84
-rw-r--r--arch/arm/mach-shmobile/include/mach/gpio.h32
-rw-r--r--arch/arm/mach-shmobile/include/mach/pm-rmobile.h44
-rw-r--r--arch/arm/mach-shmobile/include/mach/r8a7740.h33
-rw-r--r--arch/arm/mach-shmobile/include/mach/sh7372.h45
-rw-r--r--arch/arm/mach-shmobile/include/mach/sh73a0.h7
-rw-r--r--arch/arm/mach-shmobile/intc-r8a7740.c13
-rw-r--r--arch/arm/mach-shmobile/intc-sh73a0.c4
-rw-r--r--arch/arm/mach-shmobile/pfc-r8a7740.c24
-rw-r--r--arch/arm/mach-shmobile/pm-r8a7740.c54
-rw-r--r--arch/arm/mach-shmobile/pm-rmobile.c167
-rw-r--r--arch/arm/mach-shmobile/pm-sh7372.c297
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7740.c360
-rw-r--r--arch/arm/mach-shmobile/setup-sh7372.c209
-rw-r--r--arch/arm/mach-shmobile/setup-sh7377.c47
-rw-r--r--arch/arm/mach-shmobile/setup-sh73a0.c152
-rw-r--r--arch/arm/mach-socfpga/Makefile5
-rw-r--r--arch/arm/mach-socfpga/Makefile.boot1
-rw-r--r--arch/arm/mach-socfpga/include/mach/debug-macro.S16
-rw-r--r--arch/arm/mach-socfpga/include/mach/timex.h (renamed from arch/arm/mach-at91/include/mach/irqs.h)33
-rw-r--r--arch/arm/mach-socfpga/include/mach/uncompress.h9
-rw-r--r--arch/arm/mach-socfpga/socfpga.c62
-rw-r--r--arch/arm/mach-spear3xx/spear300.c26
-rw-r--r--arch/arm/mach-spear3xx/spear310.c26
-rw-r--r--arch/arm/mach-spear3xx/spear320.c26
-rw-r--r--arch/arm/mach-spear3xx/spear3xx.c3
-rw-r--r--arch/arm/mach-spear6xx/spear6xx.c51
-rw-r--r--arch/arm/mach-tegra/Kconfig39
-rw-r--r--arch/arm/mach-tegra/Makefile18
-rw-r--r--arch/arm/mach-tegra/Makefile.boot13
-rw-r--r--arch/arm/mach-tegra/apbio.c194
-rw-r--r--arch/arm/mach-tegra/apbio.h19
-rw-r--r--arch/arm/mach-tegra/board-dt-tegra20.c75
-rw-r--r--arch/arm/mach-tegra/board-dt-tegra30.c11
-rw-r--r--arch/arm/mach-tegra/board-harmony-pcie.c15
-rw-r--r--arch/arm/mach-tegra/board-harmony-power.c60
-rw-r--r--arch/arm/mach-tegra/board-paz00.c7
-rw-r--r--arch/arm/mach-tegra/board-seaboard-pinmux.c197
-rw-r--r--arch/arm/mach-tegra/board-seaboard.c306
-rw-r--r--arch/arm/mach-tegra/board-seaboard.h47
-rw-r--r--arch/arm/mach-tegra/board.h9
-rw-r--r--arch/arm/mach-tegra/common.c3
-rw-r--r--arch/arm/mach-tegra/cpu-tegra.c6
-rw-r--r--arch/arm/mach-tegra/cpuidle.c6
-rw-r--r--arch/arm/mach-tegra/dma.c4
-rw-r--r--arch/arm/mach-tegra/pcie.c6
-rw-r--r--arch/arm/mach-tegra/powergate.c4
-rw-r--r--arch/arm/mach-tegra/sleep.S29
-rw-r--r--arch/arm/mach-tegra/tegra2_clocks.c58
-rw-r--r--arch/arm/mach-tegra/tegra30_clocks.c28
-rw-r--r--arch/arm/mach-tegra/timer.c4
-rw-r--r--arch/arm/mach-tegra/usb_phy.c16
-rw-r--r--arch/arm/mach-u300/Makefile2
-rw-r--r--arch/arm/mach-u300/clock.c1504
-rw-r--r--arch/arm/mach-u300/clock.h50
-rw-r--r--arch/arm/mach-u300/core.c21
-rw-r--r--arch/arm/mach-u300/timer.c2
-rw-r--r--arch/arm/mach-ux500/board-mop500-msp.c10
-rw-r--r--arch/arm/mach-ux500/board-mop500-sdi.c4
-rw-r--r--arch/arm/mach-ux500/board-mop500.c111
-rw-r--r--arch/arm/mach-ux500/board-mop500.h3
-rw-r--r--arch/arm/mach-ux500/cpu-db8500.c11
-rw-r--r--arch/arm/mach-ux500/devices-common.h24
-rw-r--r--arch/arm/mach-ux500/include/mach/setup.h3
-rw-r--r--arch/arm/mach-vexpress/Kconfig5
-rw-r--r--arch/arm/mach-vexpress/Makefile.boot3
-rw-r--r--arch/arm/mach-vexpress/ct-ca9x4.c64
-rw-r--r--arch/arm/mach-vexpress/include/mach/clkdev.h15
-rw-r--r--arch/arm/mach-vexpress/include/mach/debug-macro.S41
-rw-r--r--arch/arm/mach-vexpress/include/mach/motherboard.h28
-rw-r--r--arch/arm/mach-vexpress/include/mach/uncompress.h14
-rw-r--r--arch/arm/mach-vexpress/v2m.c296
-rw-r--r--arch/arm/mach-vt8500/Makefile4
-rw-r--r--arch/arm/mach-vt8500/bv07.c3
-rw-r--r--arch/arm/mach-vt8500/include/mach/restart.h17
-rw-r--r--arch/arm/mach-vt8500/include/mach/system.h13
-rw-r--r--arch/arm/mach-vt8500/pwm.c265
-rw-r--r--arch/arm/mach-vt8500/restart.c54
-rw-r--r--arch/arm/mach-vt8500/wm8505_7in.c4
-rw-r--r--arch/arm/mm/context.c35
-rw-r--r--arch/arm/mm/dma-mapping.c665
-rw-r--r--arch/arm/mm/flush.c2
-rw-r--r--arch/arm/mm/init.c2
-rw-r--r--arch/arm/mm/ioremap.c2
-rw-r--r--arch/arm/mm/mm.h3
-rw-r--r--arch/arm/mm/mmu.c8
-rw-r--r--arch/arm/mm/proc-v6.S6
-rw-r--r--arch/arm/mm/proc-v7-2level.S5
-rw-r--r--arch/arm/mm/tlb-v7.S12
-rw-r--r--arch/arm/oprofile/common.c45
-rw-r--r--arch/arm/plat-mxc/3ds_debugboard.c50
-rw-r--r--arch/arm/plat-mxc/Kconfig6
-rw-r--r--arch/arm/plat-mxc/Makefile2
-rw-r--r--arch/arm/plat-mxc/avic.c35
-rw-r--r--arch/arm/plat-mxc/cpuidle.c80
-rw-r--r--arch/arm/plat-mxc/devices/platform-ipu-core.c5
-rw-r--r--arch/arm/plat-mxc/devices/platform-mxc_rtc.c5
-rw-r--r--arch/arm/plat-mxc/devices/platform-spi_imx.c2
-rw-r--r--arch/arm/plat-mxc/include/mach/3ds_debugboard.h2
-rw-r--r--arch/arm/plat-mxc/include/mach/common.h7
-rw-r--r--arch/arm/plat-mxc/include/mach/cpuidle.h22
-rw-r--r--arch/arm/plat-mxc/include/mach/devices-common.h4
-rw-r--r--arch/arm/plat-mxc/include/mach/hardware.h27
-rw-r--r--arch/arm/plat-mxc/include/mach/i2c.h2
-rw-r--r--arch/arm/plat-mxc/include/mach/iomux-mx3.h3
-rw-r--r--arch/arm/plat-mxc/include/mach/iomux-mx51.h14
-rw-r--r--arch/arm/plat-mxc/include/mach/iomux-v1.h7
-rw-r--r--arch/arm/plat-mxc/include/mach/ipu.h4
-rw-r--r--arch/arm/plat-mxc/include/mach/irqs.h44
-rw-r--r--arch/arm/plat-mxc/include/mach/mx1.h111
-rw-r--r--arch/arm/plat-mxc/include/mach/mx21.h107
-rw-r--r--arch/arm/plat-mxc/include/mach/mx25.h72
-rw-r--r--arch/arm/plat-mxc/include/mach/mx27.h127
-rw-r--r--arch/arm/plat-mxc/include/mach/mx2x.h87
-rw-r--r--arch/arm/plat-mxc/include/mach/mx31.h118
-rw-r--r--arch/arm/plat-mxc/include/mach/mx35.h109
-rw-r--r--arch/arm/plat-mxc/include/mach/mx3x.h77
-rw-r--r--arch/arm/plat-mxc/include/mach/mx50.h187
-rw-r--r--arch/arm/plat-mxc/include/mach/mx51.h209
-rw-r--r--arch/arm/plat-mxc/include/mach/mx53.h217
-rw-r--r--arch/arm/plat-mxc/include/mach/mxc_ehci.h16
-rw-r--r--arch/arm/plat-mxc/pwm.c306
-rw-r--r--arch/arm/plat-mxc/time.c3
-rw-r--r--arch/arm/plat-mxc/tzic.c35
-rw-r--r--arch/arm/plat-nomadik/include/plat/i2c.h39
-rw-r--r--arch/arm/plat-omap/Kconfig35
-rw-r--r--arch/arm/plat-omap/Makefile6
-rw-r--r--arch/arm/plat-omap/common.c9
-rw-r--r--arch/arm/plat-omap/counter_32k.c16
-rw-r--r--arch/arm/plat-omap/dma.c59
-rw-r--r--arch/arm/plat-omap/dmtimer.c170
-rw-r--r--arch/arm/plat-omap/include/plat/board.h38
-rw-r--r--arch/arm/plat-omap/include/plat/clkdev_omap.h1
-rw-r--r--arch/arm/plat-omap/include/plat/clock.h2
-rw-r--r--arch/arm/plat-omap/include/plat/cpu.h60
-rw-r--r--arch/arm/plat-omap/include/plat/dmtimer.h22
-rw-r--r--arch/arm/plat-omap/include/plat/dsp.h3
-rw-r--r--arch/arm/plat-omap/include/plat/hardware.h1
-rw-r--r--arch/arm/plat-omap/include/plat/mmc.h2
-rw-r--r--arch/arm/plat-omap/include/plat/multi.h18
-rw-r--r--arch/arm/plat-omap/include/plat/mux.h2
-rw-r--r--arch/arm/plat-omap/include/plat/omap-secure.h5
-rw-r--r--arch/arm/plat-omap/include/plat/omap54xx.h32
-rw-r--r--arch/arm/plat-omap/include/plat/omap730.h102
-rw-r--r--arch/arm/plat-omap/include/plat/omap850.h102
-rw-r--r--arch/arm/plat-omap/include/plat/omap_hwmod.h21
-rw-r--r--arch/arm/plat-omap/include/plat/sdrc.h2
-rw-r--r--arch/arm/plat-omap/include/plat/serial.h14
-rw-r--r--arch/arm/plat-omap/include/plat/uncompress.h16
-rw-r--r--arch/arm/plat-omap/include/plat/usb.h196
-rw-r--r--arch/arm/plat-omap/include/plat/voltage.h21
-rw-r--r--arch/arm/plat-omap/mailbox.c13
-rw-r--r--arch/arm/plat-omap/sram.c17
-rw-r--r--arch/arm/plat-omap/usb.c145
-rw-r--r--arch/arm/plat-orion/common.c9
-rw-r--r--arch/arm/plat-orion/gpio.c166
-rw-r--r--arch/arm/plat-orion/include/plat/common.h6
-rw-r--r--arch/arm/plat-orion/include/plat/gpio.h16
-rw-r--r--arch/arm/plat-orion/include/plat/irq.h3
-rw-r--r--arch/arm/plat-orion/irq.c40
-rw-r--r--arch/arm/plat-pxa/Makefile1
-rw-r--r--arch/arm/plat-pxa/pwm.c304
-rw-r--r--arch/arm/plat-s3c24xx/dma.c2
-rw-r--r--arch/arm/plat-s3c24xx/irq.c2
-rw-r--r--arch/arm/plat-samsung/Kconfig15
-rw-r--r--arch/arm/plat-samsung/Makefile12
-rw-r--r--arch/arm/plat-samsung/devs.c89
-rw-r--r--arch/arm/plat-samsung/dma-ops.c76
-rw-r--r--arch/arm/plat-samsung/include/plat/cpu.h4
-rw-r--r--arch/arm/plat-samsung/include/plat/devs.h1
-rw-r--r--arch/arm/plat-samsung/include/plat/dma-ops.h20
-rw-r--r--arch/arm/plat-samsung/include/plat/fb.h1
-rw-r--r--arch/arm/plat-samsung/include/plat/gpio-cfg.h2
-rw-r--r--arch/arm/plat-samsung/include/plat/hdmi.h16
-rw-r--r--arch/arm/plat-samsung/include/plat/pd.h30
-rw-r--r--arch/arm/plat-samsung/include/plat/s3c64xx-spi.h39
-rw-r--r--arch/arm/plat-samsung/pd.c95
-rw-r--r--arch/arm/plat-samsung/pm.c2
-rw-r--r--arch/arm/plat-samsung/pwm.c420
-rw-r--r--arch/arm/plat-samsung/s3c-dma-ops.c39
-rw-r--r--arch/arm/plat-spear/include/plat/keyboard.h2
-rw-r--r--arch/arm/plat-spear/include/plat/pl080.h6
-rw-r--r--arch/arm/plat-spear/pl080.c10
-rw-r--r--arch/arm/plat-versatile/Kconfig3
-rw-r--r--arch/arm/plat-versatile/Makefile2
-rw-r--r--arch/arm/plat-versatile/platsmp.c2
-rw-r--r--arch/arm/vfp/entry.S16
-rw-r--r--arch/arm/vfp/vfphw.S26
-rw-r--r--arch/arm/vfp/vfpmodule.c10
-rw-r--r--arch/avr32/Kconfig1
-rw-r--r--arch/avr32/boards/atstk1000/atstk1002.c2
-rw-r--r--arch/avr32/include/asm/kmap_types.h24
-rw-r--r--arch/avr32/include/asm/unistd.h1
-rw-r--r--arch/avr32/mm/fault.c33
-rw-r--r--arch/blackfin/Kconfig27
-rw-r--r--arch/blackfin/configs/BF609-EZKIT_defconfig2
-rw-r--r--arch/blackfin/include/asm/bfin-global.h8
-rw-r--r--arch/blackfin/include/asm/bfin_crc.h14
-rw-r--r--arch/blackfin/include/asm/bfin_serial.h2
-rw-r--r--arch/blackfin/include/asm/bfin_simple_timer.h6
-rw-r--r--arch/blackfin/include/asm/bfin_twi.h10
-rw-r--r--arch/blackfin/include/asm/context.S9
-rw-r--r--arch/blackfin/include/asm/dpmc.h2
-rw-r--r--arch/blackfin/include/asm/gpio.h2
-rw-r--r--arch/blackfin/include/asm/irq.h10
-rw-r--r--arch/blackfin/include/asm/mem_init.h212
-rw-r--r--arch/blackfin/include/asm/traps.h2
-rw-r--r--arch/blackfin/include/asm/unistd.h1
-rw-r--r--arch/blackfin/kernel/Makefile1
-rw-r--r--arch/blackfin/kernel/bfin_dma.c4
-rw-r--r--arch/blackfin/kernel/cplb-nompu/cplbinit.c8
-rw-r--r--arch/blackfin/kernel/dma-mapping.c10
-rw-r--r--arch/blackfin/kernel/pwm.c100
-rw-r--r--arch/blackfin/kernel/setup.c1
-rw-r--r--arch/blackfin/mach-bf527/boards/ezkit.c4
-rw-r--r--arch/blackfin/mach-bf537/boards/stamp.c2
-rw-r--r--arch/blackfin/mach-bf548/boards/ezkit.c4
-rw-r--r--arch/blackfin/mach-bf548/include/mach/gpio.h2
-rw-r--r--arch/blackfin/mach-bf561/boards/ezkit.c3
-rw-r--r--arch/blackfin/mach-bf609/Kconfig8
-rw-r--r--arch/blackfin/mach-bf609/Makefile4
-rw-r--r--arch/blackfin/mach-bf609/boards/ezkit.c304
-rw-r--r--arch/blackfin/mach-bf609/clock.c3
-rw-r--r--arch/blackfin/mach-bf609/dpm.S157
-rw-r--r--arch/blackfin/mach-bf609/hibernate.S65
-rw-r--r--arch/blackfin/mach-bf609/include/mach/anomaly.h141
-rw-r--r--arch/blackfin/mach-bf609/include/mach/defBF60x_base.h1
-rw-r--r--arch/blackfin/mach-bf609/include/mach/gpio.h2
-rw-r--r--arch/blackfin/mach-bf609/include/mach/irq.h4
-rw-r--r--arch/blackfin/mach-bf609/include/mach/pm.h9
-rw-r--r--arch/blackfin/mach-bf609/ints-priority.c156
-rw-r--r--arch/blackfin/mach-bf609/pm.c130
-rw-r--r--arch/blackfin/mach-common/clocks-init.c139
-rw-r--r--arch/blackfin/mach-common/cpufreq.c5
-rw-r--r--arch/blackfin/mach-common/entry.S7
-rw-r--r--arch/blackfin/mach-common/ints-priority.c331
-rw-r--r--arch/blackfin/mach-common/pm.c8
-rw-r--r--arch/c6x/Kconfig1
-rw-r--r--arch/c6x/boot/dts/evmc6678.dts83
-rw-r--r--arch/c6x/boot/dts/tms320c6678.dtsi146
-rw-r--r--arch/c6x/configs/evmc6678_defconfig42
-rw-r--r--arch/c6x/include/asm/cache.h16
-rw-r--r--arch/c6x/include/asm/irq.h2
-rw-r--r--arch/c6x/kernel/irq.c21
-rw-r--r--arch/c6x/kernel/setup.c4
-rw-r--r--arch/c6x/kernel/signal.c2
-rw-r--r--arch/c6x/kernel/soc.c2
-rw-r--r--arch/c6x/platforms/Kconfig4
-rw-r--r--arch/c6x/platforms/megamod-pic.c28
-rw-r--r--arch/c6x/platforms/plldata.c65
-rw-r--r--arch/cris/Kconfig1
-rw-r--r--arch/cris/arch-v32/drivers/pci/bios.c5
-rw-r--r--arch/cris/include/asm/unistd.h1
-rw-r--r--arch/frv/Kconfig1
-rw-r--r--arch/frv/include/asm/cpumask.h6
-rw-r--r--arch/frv/include/asm/highmem.h34
-rw-r--r--arch/frv/include/asm/kmap_types.h24
-rw-r--r--arch/frv/include/asm/unistd.h1
-rw-r--r--arch/frv/kernel/kernel_thread.S2
-rw-r--r--arch/frv/mb93090-mb00/pci-dma.c4
-rw-r--r--arch/frv/mb93090-mb00/pci-vdk.c4
-rw-r--r--arch/frv/mm/cache-page.c8
-rw-r--r--arch/frv/mm/highmem.c20
-rw-r--r--arch/h8300/Kconfig1
-rw-r--r--arch/h8300/include/asm/unistd.h1
-rw-r--r--arch/hexagon/include/asm/Kbuild2
-rw-r--r--arch/hexagon/kernel/smp.c2
-rw-r--r--arch/ia64/Kconfig3
-rw-r--r--arch/ia64/configs/generic_defconfig1
-rw-r--r--arch/ia64/configs/gensparse_defconfig1
-rw-r--r--arch/ia64/include/asm/atomic.h4
-rw-r--r--arch/ia64/include/asm/iommu.h2
-rw-r--r--arch/ia64/include/asm/kvm.h1
-rw-r--r--arch/ia64/include/asm/machvec.h2
-rw-r--r--arch/ia64/include/asm/machvec_dig.h2
-rw-r--r--arch/ia64/include/asm/machvec_dig_vtd.h2
-rw-r--r--arch/ia64/include/asm/machvec_hpsim.h2
-rw-r--r--arch/ia64/include/asm/machvec_hpzx1.h2
-rw-r--r--arch/ia64/include/asm/machvec_hpzx1_swiotlb.h2
-rw-r--r--arch/ia64/include/asm/machvec_sn2.h2
-rw-r--r--arch/ia64/include/asm/machvec_uv.h2
-rw-r--r--arch/ia64/include/asm/machvec_xen.h2
-rw-r--r--arch/ia64/include/asm/processor.h2
-rw-r--r--arch/ia64/kernel/acpi.c5
-rw-r--r--arch/ia64/kernel/ia64_ksyms.c2
-rw-r--r--arch/ia64/kernel/irq_ia64.c1
-rw-r--r--arch/ia64/kernel/pci-dma.c1
-rw-r--r--arch/ia64/kernel/perfmon.c1
-rw-r--r--arch/ia64/kernel/smpboot.c2
-rw-r--r--arch/ia64/kvm/Kconfig2
-rw-r--r--arch/ia64/kvm/vmm.c6
-rw-r--r--arch/ia64/mm/fault.c46
-rw-r--r--arch/ia64/pci/fixup.c4
-rw-r--r--arch/ia64/pci/pci.c13
-rw-r--r--arch/m32r/Kconfig1
-rw-r--r--arch/m32r/include/asm/smp.h5
-rw-r--r--arch/m32r/include/asm/unistd.h1
-rw-r--r--arch/m68k/Kconfig14
-rw-r--r--arch/m68k/Kconfig.bus7
-rw-r--r--arch/m68k/Kconfig.cpu37
-rw-r--r--arch/m68k/Makefile2
-rw-r--r--arch/m68k/apollo/config.c16
-rw-r--r--arch/m68k/include/asm/Kbuild25
-rw-r--r--arch/m68k/include/asm/MC68332.h152
-rw-r--r--arch/m68k/include/asm/apollodma.h248
-rw-r--r--arch/m68k/include/asm/apollohw.h2
-rw-r--r--arch/m68k/include/asm/bitsperlong.h1
-rw-r--r--arch/m68k/include/asm/cacheflush_mm.h41
-rw-r--r--arch/m68k/include/asm/cputime.h6
-rw-r--r--arch/m68k/include/asm/delay.h2
-rw-r--r--arch/m68k/include/asm/device.h7
-rw-r--r--arch/m68k/include/asm/dma.h8
-rw-r--r--arch/m68k/include/asm/emergency-restart.h6
-rw-r--r--arch/m68k/include/asm/errno.h6
-rw-r--r--arch/m68k/include/asm/futex.h6
-rw-r--r--arch/m68k/include/asm/gpio.h179
-rw-r--r--arch/m68k/include/asm/io_mm.h50
-rw-r--r--arch/m68k/include/asm/ioctl.h1
-rw-r--r--arch/m68k/include/asm/ipcbuf.h1
-rw-r--r--arch/m68k/include/asm/irq_regs.h1
-rw-r--r--arch/m68k/include/asm/kdebug.h1
-rw-r--r--arch/m68k/include/asm/kmap_types.h6
-rw-r--r--arch/m68k/include/asm/kvm_para.h1
-rw-r--r--arch/m68k/include/asm/local.h6
-rw-r--r--arch/m68k/include/asm/local64.h1
-rw-r--r--arch/m68k/include/asm/m520xsim.h14
-rw-r--r--arch/m68k/include/asm/m523xsim.h1
-rw-r--r--arch/m68k/include/asm/m525xsim.h194
-rw-r--r--arch/m68k/include/asm/m527xsim.h1
-rw-r--r--arch/m68k/include/asm/m528xsim.h2
-rw-r--r--arch/m68k/include/asm/m532xsim.h17
-rw-r--r--arch/m68k/include/asm/m5441xsim.h276
-rw-r--r--arch/m68k/include/asm/m54xxacr.h4
-rw-r--r--arch/m68k/include/asm/m54xxpci.h138
-rw-r--r--arch/m68k/include/asm/m54xxsim.h3
-rw-r--r--arch/m68k/include/asm/mac_mouse.h23
-rw-r--r--arch/m68k/include/asm/mcf8390.h (renamed from arch/m68k/include/asm/mcfne.h)137
-rw-r--r--arch/m68k/include/asm/mcfclk.h43
-rw-r--r--arch/m68k/include/asm/mcfgpio.h343
-rw-r--r--arch/m68k/include/asm/mcfmbus.h77
-rw-r--r--arch/m68k/include/asm/mcfsim.h5
-rw-r--r--arch/m68k/include/asm/mcftimer.h2
-rw-r--r--arch/m68k/include/asm/mcfuart.h4
-rw-r--r--arch/m68k/include/asm/mman.h1
-rw-r--r--arch/m68k/include/asm/mutex.h9
-rw-r--r--arch/m68k/include/asm/pci.h6
-rw-r--r--arch/m68k/include/asm/percpu.h6
-rw-r--r--arch/m68k/include/asm/pinmux.h30
-rw-r--r--arch/m68k/include/asm/resource.h6
-rw-r--r--arch/m68k/include/asm/sbus.h45
-rw-r--r--arch/m68k/include/asm/scatterlist.h6
-rw-r--r--arch/m68k/include/asm/sections.h8
-rw-r--r--arch/m68k/include/asm/shm.h31
-rw-r--r--arch/m68k/include/asm/siginfo.h6
-rw-r--r--arch/m68k/include/asm/statfs.h6
-rw-r--r--arch/m68k/include/asm/topology.h6
-rw-r--r--arch/m68k/include/asm/types.h22
-rw-r--r--arch/m68k/include/asm/unaligned.h4
-rw-r--r--arch/m68k/include/asm/unistd.h1
-rw-r--r--arch/m68k/include/asm/xor.h1
-rw-r--r--arch/m68k/kernel/Makefile1
-rw-r--r--arch/m68k/kernel/dma.c5
-rw-r--r--arch/m68k/kernel/entry.S452
-rw-r--r--arch/m68k/kernel/entry_mm.S419
-rw-r--r--arch/m68k/kernel/entry_no.S130
-rw-r--r--arch/m68k/kernel/module.c4
-rw-r--r--arch/m68k/kernel/pcibios.c109
-rw-r--r--arch/m68k/kernel/setup_no.c11
-rw-r--r--arch/m68k/kernel/sys_m68k.c8
-rw-r--r--arch/m68k/kernel/vmlinux-nommu.lds2
-rw-r--r--arch/m68k/kernel/vmlinux-std.lds2
-rw-r--r--arch/m68k/kernel/vmlinux-sun3.lds2
-rw-r--r--arch/m68k/lib/muldi3.c2
-rw-r--r--arch/m68k/mm/init_mm.c2
-rw-r--r--arch/m68k/mm/init_no.c2
-rw-r--r--arch/m68k/mm/memory.c2
-rw-r--r--arch/m68k/platform/68328/head-de2.S8
-rw-r--r--arch/m68k/platform/68328/head-pilot.S10
-rw-r--r--arch/m68k/platform/68328/head-ram.S4
-rw-r--r--arch/m68k/platform/68328/head-rom.S6
-rw-r--r--arch/m68k/platform/68360/head-ram.S6
-rw-r--r--arch/m68k/platform/68360/head-rom.S8
-rw-r--r--arch/m68k/platform/coldfire/Makefile7
-rw-r--r--arch/m68k/platform/coldfire/clk.c108
-rw-r--r--arch/m68k/platform/coldfire/device.c57
-rw-r--r--arch/m68k/platform/coldfire/gpio.c172
-rw-r--r--arch/m68k/platform/coldfire/head.S16
-rw-r--r--arch/m68k/platform/coldfire/intc-525x.c91
-rw-r--r--arch/m68k/platform/coldfire/intc-simr.c26
-rw-r--r--arch/m68k/platform/coldfire/m5206.c9
-rw-r--r--arch/m68k/platform/coldfire/m520x.c103
-rw-r--r--arch/m68k/platform/coldfire/m523x.c22
-rw-r--r--arch/m68k/platform/coldfire/m5249.c10
-rw-r--r--arch/m68k/platform/coldfire/m525x.c66
-rw-r--r--arch/m68k/platform/coldfire/m5272.c11
-rw-r--r--arch/m68k/platform/coldfire/m527x.c43
-rw-r--r--arch/m68k/platform/coldfire/m528x.c33
-rw-r--r--arch/m68k/platform/coldfire/m5307.c9
-rw-r--r--arch/m68k/platform/coldfire/m532x.c154
-rw-r--r--arch/m68k/platform/coldfire/m5407.c9
-rw-r--r--arch/m68k/platform/coldfire/m5441x.c261
-rw-r--r--arch/m68k/platform/coldfire/m54xx.c7
-rw-r--r--arch/m68k/platform/coldfire/mcf8390.c38
-rw-r--r--arch/m68k/platform/coldfire/pci.c327
-rw-r--r--arch/m68k/platform/coldfire/pinmux.c28
-rw-r--r--arch/m68k/platform/coldfire/pit.c4
-rw-r--r--arch/m68k/platform/coldfire/timers.c2
-rw-r--r--arch/m68k/sun3/prom/init.c48
-rw-r--r--arch/microblaze/Kconfig1
-rw-r--r--arch/microblaze/include/asm/sections.h4
-rw-r--r--arch/microblaze/include/asm/unistd.h1
-rw-r--r--arch/microblaze/kernel/microblaze_ksyms.c3
-rw-r--r--arch/microblaze/kernel/setup.c4
-rw-r--r--arch/microblaze/kernel/vmlinux.lds.S1
-rw-r--r--arch/microblaze/pci/pci-common.c15
-rw-r--r--arch/mips/Kbuild.platforms1
-rw-r--r--arch/mips/Kconfig43
-rw-r--r--arch/mips/alchemy/board-mtx1.c6
-rw-r--r--arch/mips/alchemy/common/platform.c10
-rw-r--r--arch/mips/alchemy/devboards/Makefile2
-rw-r--r--arch/mips/alchemy/devboards/bcsr.c5
-rw-r--r--arch/mips/alchemy/devboards/pb1100.c4
-rw-r--r--arch/mips/alchemy/devboards/pb1500.c4
-rw-r--r--arch/mips/alchemy/devboards/platform.c30
-rw-r--r--arch/mips/alchemy/devboards/prom.c69
-rw-r--r--arch/mips/ar7/platform.c4
-rw-r--r--arch/mips/ath79/dev-usb.c2
-rw-r--r--arch/mips/ath79/gpio.c6
-rw-r--r--arch/mips/bcm63xx/Kconfig4
-rw-r--r--arch/mips/bcm63xx/Makefile3
-rw-r--r--arch/mips/bcm63xx/boards/board_bcm963xx.c107
-rw-r--r--arch/mips/bcm63xx/clk.c26
-rw-r--r--arch/mips/bcm63xx/cpu.c63
-rw-r--r--arch/mips/bcm63xx/dev-dsp.c2
-rw-r--r--arch/mips/bcm63xx/dev-flash.c123
-rw-r--r--arch/mips/bcm63xx/dev-rng.c40
-rw-r--r--arch/mips/bcm63xx/dev-spi.c123
-rw-r--r--arch/mips/bcm63xx/dev-wdt.c2
-rw-r--r--arch/mips/bcm63xx/irq.c21
-rw-r--r--arch/mips/bcm63xx/prom.c4
-rw-r--r--arch/mips/bcm63xx/setup.c13
-rw-r--r--arch/mips/boot/compressed/Makefile4
-rw-r--r--arch/mips/boot/compressed/uart-16550.c5
-rw-r--r--arch/mips/cavium-octeon/.gitignore2
-rw-r--r--arch/mips/cavium-octeon/Makefile16
-rw-r--r--arch/mips/cavium-octeon/executive/cvmx-fpa.c183
-rw-r--r--arch/mips/cavium-octeon/executive/cvmx-helper-fpa.c243
-rw-r--r--arch/mips/cavium-octeon/octeon-irq.c436
-rw-r--r--arch/mips/cavium-octeon/octeon-memcpy.S16
-rw-r--r--arch/mips/cavium-octeon/octeon-platform.c699
-rw-r--r--arch/mips/cavium-octeon/octeon_3xxx.dts571
-rw-r--r--arch/mips/cavium-octeon/octeon_68xx.dts625
-rw-r--r--arch/mips/cavium-octeon/serial.c134
-rw-r--r--arch/mips/cavium-octeon/setup.c45
-rw-r--r--arch/mips/configs/ls1b_defconfig109
-rw-r--r--arch/mips/configs/nlm_xlr_defconfig4
-rw-r--r--arch/mips/dec/prom/memory.c2
-rw-r--r--arch/mips/include/asm/clock.h11
-rw-r--r--arch/mips/include/asm/cpu.h3
-rw-r--r--arch/mips/include/asm/mach-ath79/ar71xx_regs.h3
-rw-r--r--arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h1
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h150
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h12
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h91
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h2
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h8
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h293
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/ioremap.h1
-rw-r--r--arch/mips/include/asm/mach-cavium-octeon/irq.h55
-rw-r--r--arch/mips/include/asm/mach-jz4740/jz4740_nand.h4
-rw-r--r--arch/mips/include/asm/mach-loongson/loongson.h4
-rw-r--r--arch/mips/include/asm/mach-loongson1/irq.h73
-rw-r--r--arch/mips/include/asm/mach-loongson1/loongson1.h44
-rw-r--r--arch/mips/include/asm/mach-loongson1/platform.h23
-rw-r--r--arch/mips/include/asm/mach-loongson1/prom.h24
-rw-r--r--arch/mips/include/asm/mach-loongson1/regs-clk.h33
-rw-r--r--arch/mips/include/asm/mach-loongson1/regs-wdt.h22
-rw-r--r--arch/mips/include/asm/mach-loongson1/war.h25
-rw-r--r--arch/mips/include/asm/mach-netlogic/cpu-feature-overrides.h1
-rw-r--r--arch/mips/include/asm/mach-tx49xx/mangle-port.h2
-rw-r--r--arch/mips/include/asm/mipsmtregs.h13
-rw-r--r--arch/mips/include/asm/module.h3
-rw-r--r--arch/mips/include/asm/netlogic/xlp-hal/cpucontrol.h4
-rw-r--r--arch/mips/include/asm/netlogic/xlp-hal/iomap.h5
-rw-r--r--arch/mips/include/asm/netlogic/xlp-hal/pcibus.h76
-rw-r--r--arch/mips/include/asm/netlogic/xlp-hal/pic.h4
-rw-r--r--arch/mips/include/asm/netlogic/xlp-hal/usb.h64
-rw-r--r--arch/mips/include/asm/netlogic/xlp-hal/xlp.h17
-rw-r--r--arch/mips/include/asm/netlogic/xlr/bridge.h104
-rw-r--r--arch/mips/include/asm/netlogic/xlr/flash.h55
-rw-r--r--arch/mips/include/asm/netlogic/xlr/gpio.h59
-rw-r--r--arch/mips/include/asm/octeon/cvmx-helper-fpa.h64
-rw-r--r--arch/mips/include/asm/octeon/cvmx-helper.h2
-rw-r--r--arch/mips/include/asm/octeon/octeon.h5
-rw-r--r--arch/mips/include/asm/prom.h3
-rw-r--r--arch/mips/include/asm/r4k-timer.h8
-rw-r--r--arch/mips/include/asm/smtc.h6
-rw-r--r--arch/mips/include/asm/uaccess.h6
-rw-r--r--arch/mips/include/asm/uasm.h100
-rw-r--r--arch/mips/include/asm/unistd.h1
-rw-r--r--arch/mips/jz4740/board-qi_lb60.c1
-rw-r--r--arch/mips/jz4740/platform.c20
-rw-r--r--arch/mips/jz4740/reset.c49
-rw-r--r--arch/mips/kernel/cpu-probe.c299
-rw-r--r--arch/mips/kernel/cpufreq/Makefile2
-rw-r--r--arch/mips/kernel/cpufreq/loongson2_cpufreq.c21
-rw-r--r--arch/mips/kernel/kspd.c2
-rw-r--r--arch/mips/kernel/module.c43
-rw-r--r--arch/mips/kernel/perf_event_mipsxx.c5
-rw-r--r--arch/mips/kernel/prom.c29
-rw-r--r--arch/mips/kernel/smp.c8
-rw-r--r--arch/mips/kernel/smtc.c76
-rw-r--r--arch/mips/kernel/sync-r4k.c26
-rw-r--r--arch/mips/kernel/traps.c1
-rw-r--r--arch/mips/lantiq/clk.c5
-rw-r--r--arch/mips/lantiq/prom.c22
-rw-r--r--arch/mips/lantiq/xway/sysctrl.c49
-rw-r--r--arch/mips/lib/Makefile2
-rw-r--r--arch/mips/lib/memcpy-inatomic.S451
-rw-r--r--arch/mips/lib/memcpy.S11
-rw-r--r--arch/mips/loongson/Kconfig1
-rw-r--r--arch/mips/loongson/lemote-2f/Makefile2
-rw-r--r--arch/mips/loongson/lemote-2f/clock.c (renamed from arch/mips/kernel/cpufreq/loongson2_clock.c)46
-rw-r--r--arch/mips/loongson1/Kconfig22
-rw-r--r--arch/mips/loongson1/Makefile11
-rw-r--r--arch/mips/loongson1/Platform7
-rw-r--r--arch/mips/loongson1/common/Makefile5
-rw-r--r--arch/mips/loongson1/common/clock.c181
-rw-r--r--arch/mips/loongson1/common/irq.c147
-rw-r--r--arch/mips/loongson1/common/platform.c124
-rw-r--r--arch/mips/loongson1/common/prom.c87
-rw-r--r--arch/mips/loongson1/common/reset.c45
-rw-r--r--arch/mips/loongson1/common/setup.c29
-rw-r--r--arch/mips/loongson1/ls1b/Makefile5
-rw-r--r--arch/mips/loongson1/ls1b/board.c33
-rw-r--r--arch/mips/mm/uasm.c62
-rw-r--r--arch/mips/mti-malta/malta-pci.c13
-rw-r--r--arch/mips/netlogic/common/earlycons.c2
-rw-r--r--arch/mips/netlogic/common/smpboot.S157
-rw-r--r--arch/mips/netlogic/xlp/Makefile2
-rw-r--r--arch/mips/netlogic/xlp/nlm_hal.c52
-rw-r--r--arch/mips/netlogic/xlp/of.c34
-rw-r--r--arch/mips/netlogic/xlp/platform.c2
-rw-r--r--arch/mips/netlogic/xlp/setup.c16
-rw-r--r--arch/mips/netlogic/xlp/usb-init.c124
-rw-r--r--arch/mips/netlogic/xlr/Makefile2
-rw-r--r--arch/mips/netlogic/xlr/platform-flash.c220
-rw-r--r--arch/mips/netlogic/xlr/platform.c140
-rw-r--r--arch/mips/netlogic/xlr/setup.c2
-rw-r--r--arch/mips/oprofile/common.c1
-rw-r--r--arch/mips/oprofile/op_model_mipsxx.c10
-rw-r--r--arch/mips/pci/Makefile1
-rw-r--r--arch/mips/pci/fixup-cobalt.c8
-rw-r--r--arch/mips/pci/fixup-malta.c14
-rw-r--r--arch/mips/pci/fixup-rc32434.c2
-rw-r--r--arch/mips/pci/ops-bcm63xx.c63
-rw-r--r--arch/mips/pci/pci-ar724x.c22
-rw-r--r--arch/mips/pci/pci-bcm63xx.c133
-rw-r--r--arch/mips/pci/pci-bcm63xx.h5
-rw-r--r--arch/mips/pci/pci-xlp.c248
-rw-r--r--arch/mips/pci/pci-xlr.c4
-rw-r--r--arch/mips/pci/pci.c6
-rw-r--r--arch/mips/pmc-sierra/yosemite/ht.c11
-rw-r--r--arch/mips/pnx833x/stb22x/board.c4
-rw-r--r--arch/mips/powertv/powertv_setup.c6
-rw-r--r--arch/mips/sgi-ip27/ip27-memory.c1
-rw-r--r--arch/mips/txx9/Kconfig1
-rw-r--r--arch/mips/txx9/generic/pci.c12
-rw-r--r--arch/mips/txx9/generic/setup.c12
-rw-r--r--arch/mips/txx9/generic/setup_tx4939.c2
-rw-r--r--arch/mips/txx9/rbtx4939/setup.c11
-rw-r--r--arch/mn10300/Kconfig1
-rw-r--r--arch/mn10300/include/asm/ipc.h1
-rw-r--r--arch/mn10300/include/asm/unistd.h1
-rw-r--r--arch/mn10300/kernel/smp.c2
-rw-r--r--arch/openrisc/include/asm/Kbuild2
-rw-r--r--arch/parisc/include/asm/atomic.h4
-rw-r--r--arch/parisc/include/asm/compat_rt_sigframe.h6
-rw-r--r--arch/parisc/kernel/pci.c5
-rw-r--r--arch/parisc/kernel/process.c2
-rw-r--r--arch/parisc/kernel/smp.c2
-rw-r--r--arch/parisc/kernel/sys_parisc.c8
-rw-r--r--arch/powerpc/Kconfig4
-rw-r--r--arch/powerpc/Kconfig.debug9
-rw-r--r--arch/powerpc/Makefile1
-rw-r--r--arch/powerpc/boot/Makefile57
-rw-r--r--arch/powerpc/boot/dts/bsc9131rdb.dts34
-rw-r--r--arch/powerpc/boot/dts/bsc9131rdb.dtsi142
-rw-r--r--arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi193
-rw-r--r--arch/powerpc/boot/dts/fsl/bsc9131si-pre.dtsi (renamed from arch/powerpc/boot/dts/fsl/p3060si-pre.dtsi)84
-rw-r--r--arch/powerpc/boot/dts/fsl/p1021si-post.dtsi16
-rw-r--r--arch/powerpc/boot/dts/fsl/p3060si-post.dtsi302
-rw-r--r--arch/powerpc/boot/dts/fsl/p4080si-post.dtsi7
-rw-r--r--arch/powerpc/boot/dts/mgcoge.dts23
-rw-r--r--arch/powerpc/boot/dts/mpc8536ds.dtsi8
-rw-r--r--arch/powerpc/boot/dts/mpc8544ds.dtsi9
-rw-r--r--arch/powerpc/boot/dts/mpc8572ds.dtsi17
-rw-r--r--arch/powerpc/boot/dts/mpc8572ds_camp_core0.dts8
-rw-r--r--arch/powerpc/boot/dts/mpc8572ds_camp_core1.dts11
-rw-r--r--arch/powerpc/boot/dts/p1010rdb.dtsi12
-rw-r--r--arch/powerpc/boot/dts/p1021rdb-pc.dtsi (renamed from arch/powerpc/boot/dts/p1021rdb.dtsi)2
-rw-r--r--arch/powerpc/boot/dts/p1021rdb-pc_32b.dts (renamed from arch/powerpc/boot/dts/p1021rdb.dts)4
-rw-r--r--arch/powerpc/boot/dts/p1021rdb-pc_36b.dts (renamed from arch/powerpc/boot/dts/p1021rdb_36b.dts)4
-rw-r--r--arch/powerpc/boot/dts/p1022ds.dtsi20
-rw-r--r--arch/powerpc/boot/dts/p1024rdb.dtsi228
-rw-r--r--arch/powerpc/boot/dts/p1024rdb_32b.dts87
-rw-r--r--arch/powerpc/boot/dts/p1024rdb_36b.dts87
-rw-r--r--arch/powerpc/boot/dts/p1025rdb.dtsi40
-rw-r--r--arch/powerpc/boot/dts/p2020ds.dtsi10
-rw-r--r--arch/powerpc/boot/dts/p2020rdb-pc_32b.dts4
-rw-r--r--arch/powerpc/boot/dts/p2020rdb-pc_36b.dts4
-rw-r--r--arch/powerpc/boot/dts/p2020rdb.dts2
-rw-r--r--arch/powerpc/boot/dts/p2041rdb.dts41
-rw-r--r--arch/powerpc/boot/dts/p3041ds.dts2
-rw-r--r--arch/powerpc/boot/dts/p3060qds.dts242
-rw-r--r--arch/powerpc/boot/dts/sbc8560.dts406
-rw-r--r--arch/powerpc/boot/flatdevtree_env.h27
-rw-r--r--arch/powerpc/configs/83xx/kmeter1_defconfig22
-rw-r--r--arch/powerpc/configs/85xx/p1023rds_defconfig31
-rw-r--r--arch/powerpc/configs/85xx/sbc8560_defconfig65
-rw-r--r--arch/powerpc/configs/chroma_defconfig4
-rw-r--r--arch/powerpc/configs/corenet32_smp_defconfig25
-rw-r--r--arch/powerpc/configs/corenet64_smp_defconfig67
-rw-r--r--arch/powerpc/configs/mgcoge_defconfig12
-rw-r--r--arch/powerpc/configs/mpc83xx_defconfig18
-rw-r--r--arch/powerpc/configs/mpc85xx_defconfig31
-rw-r--r--arch/powerpc/configs/mpc85xx_smp_defconfig31
-rw-r--r--arch/powerpc/configs/ppc64_defconfig8
-rw-r--r--arch/powerpc/configs/pseries_defconfig7
-rw-r--r--arch/powerpc/include/asm/asm-compat.h2
-rw-r--r--arch/powerpc/include/asm/code-patching.h4
-rw-r--r--arch/powerpc/include/asm/cputable.h2
-rw-r--r--arch/powerpc/include/asm/device.h3
-rw-r--r--arch/powerpc/include/asm/dma-mapping.h8
-rw-r--r--arch/powerpc/include/asm/epapr_hcalls.h2
-rw-r--r--arch/powerpc/include/asm/exception-64s.h4
-rw-r--r--arch/powerpc/include/asm/hw_irq.h2
-rw-r--r--arch/powerpc/include/asm/immap_qe.h4
-rw-r--r--arch/powerpc/include/asm/io.h8
-rw-r--r--arch/powerpc/include/asm/iommu.h18
-rw-r--r--arch/powerpc/include/asm/kmap_types.h31
-rw-r--r--arch/powerpc/include/asm/kvm_book3s_64.h7
-rw-r--r--arch/powerpc/include/asm/kvm_book3s_asm.h1
-rw-r--r--arch/powerpc/include/asm/kvm_host.h7
-rw-r--r--arch/powerpc/include/asm/kvm_ppc.h15
-rw-r--r--arch/powerpc/include/asm/mmu.h7
-rw-r--r--arch/powerpc/include/asm/mpic_msgr.h1
-rw-r--r--arch/powerpc/include/asm/pci-bridge.h1
-rw-r--r--arch/powerpc/include/asm/perf_event.h5
-rw-r--r--arch/powerpc/include/asm/ppc-opcode.h118
-rw-r--r--arch/powerpc/include/asm/ppc_asm.h121
-rw-r--r--arch/powerpc/include/asm/processor.h3
-rw-r--r--arch/powerpc/include/asm/qe.h1
-rw-r--r--arch/powerpc/include/asm/reg.h8
-rw-r--r--arch/powerpc/include/asm/thread_info.h6
-rw-r--r--arch/powerpc/include/asm/trace.h45
-rw-r--r--arch/powerpc/include/asm/unistd.h1
-rw-r--r--arch/powerpc/include/asm/vdso.h2
-rw-r--r--arch/powerpc/include/asm/vio.h2
-rw-r--r--arch/powerpc/kernel/Makefile1
-rw-r--r--arch/powerpc/kernel/asm-offsets.c2
-rw-r--r--arch/powerpc/kernel/cpu_setup_a2.S6
-rw-r--r--arch/powerpc/kernel/dbell.c2
-rw-r--r--arch/powerpc/kernel/dma-iommu.c10
-rw-r--r--arch/powerpc/kernel/dma-swiotlb.c1
-rw-r--r--arch/powerpc/kernel/dma.c46
-rw-r--r--arch/powerpc/kernel/entry_32.S34
-rw-r--r--arch/powerpc/kernel/entry_64.S60
-rw-r--r--arch/powerpc/kernel/epapr_hcalls.S25
-rw-r--r--arch/powerpc/kernel/epapr_paravirt.c52
-rw-r--r--arch/powerpc/kernel/exceptions-64e.S10
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S6
-rw-r--r--arch/powerpc/kernel/fpu.S16
-rw-r--r--arch/powerpc/kernel/ftrace.c92
-rw-r--r--arch/powerpc/kernel/head_fsl_booke.S25
-rw-r--r--arch/powerpc/kernel/hw_breakpoint.c4
-rw-r--r--arch/powerpc/kernel/idle_6xx.S4
-rw-r--r--arch/powerpc/kernel/idle_book3e.S2
-rw-r--r--arch/powerpc/kernel/idle_e500.S4
-rw-r--r--arch/powerpc/kernel/idle_power4.S2
-rw-r--r--arch/powerpc/kernel/idle_power7.S2
-rw-r--r--arch/powerpc/kernel/iommu.c291
-rw-r--r--arch/powerpc/kernel/kgdb.c27
-rw-r--r--arch/powerpc/kernel/kvm.c30
-rw-r--r--arch/powerpc/kernel/kvm_emul.S12
-rw-r--r--arch/powerpc/kernel/misc_32.S4
-rw-r--r--arch/powerpc/kernel/misc_64.S9
-rw-r--r--arch/powerpc/kernel/pci-common.c28
-rw-r--r--arch/powerpc/kernel/pci_64.c2
-rw-r--r--arch/powerpc/kernel/pci_of_scan.c3
-rw-r--r--arch/powerpc/kernel/process.c12
-rw-r--r--arch/powerpc/kernel/rtas_flash.c2
-rw-r--r--arch/powerpc/kernel/setup-common.c27
-rw-r--r--arch/powerpc/kernel/setup_32.c24
-rw-r--r--arch/powerpc/kernel/smp.c16
-rw-r--r--arch/powerpc/kernel/syscalls.c8
-rw-r--r--arch/powerpc/kernel/sysfs.c10
-rw-r--r--arch/powerpc/kernel/time.c9
-rw-r--r--arch/powerpc/kernel/traps.c3
-rw-r--r--arch/powerpc/kernel/vdso.c28
-rw-r--r--arch/powerpc/kernel/vdso32/Makefile4
-rw-r--r--arch/powerpc/kernel/vdso32/getcpu.S45
-rw-r--r--arch/powerpc/kernel/vdso32/vdso32.lds.S3
-rw-r--r--arch/powerpc/kernel/vdso64/Makefile2
-rw-r--r--arch/powerpc/kernel/vdso64/getcpu.S45
-rw-r--r--arch/powerpc/kernel/vdso64/vdso64.lds.S1
-rw-r--r--arch/powerpc/kernel/vio.c48
-rw-r--r--arch/powerpc/kvm/book3s_32_mmu_host.c3
-rw-r--r--arch/powerpc/kvm/book3s_64_mmu_host.c2
-rw-r--r--arch/powerpc/kvm/book3s_64_mmu_hv.c123
-rw-r--r--arch/powerpc/kvm/book3s_hv.c40
-rw-r--r--arch/powerpc/kvm/book3s_hv_builtin.c5
-rw-r--r--arch/powerpc/kvm/book3s_hv_rm_mmu.c15
-rw-r--r--arch/powerpc/kvm/book3s_hv_rmhandlers.S239
-rw-r--r--arch/powerpc/kvm/book3s_interrupts.S80
-rw-r--r--arch/powerpc/kvm/book3s_rmhandlers.S2
-rw-r--r--arch/powerpc/kvm/book3s_segment.S2
-rw-r--r--arch/powerpc/kvm/booke.c26
-rw-r--r--arch/powerpc/kvm/booke_emulate.c28
-rw-r--r--arch/powerpc/kvm/booke_interrupts.S328
-rw-r--r--arch/powerpc/kvm/bookehv_interrupts.S308
-rw-r--r--arch/powerpc/kvm/e500_emulate.c3
-rw-r--r--arch/powerpc/kvm/e500_tlb.c11
-rw-r--r--arch/powerpc/kvm/e500mc.c8
-rw-r--r--arch/powerpc/kvm/emulate.c16
-rw-r--r--arch/powerpc/kvm/powerpc.c18
-rw-r--r--arch/powerpc/lib/Makefile5
-rw-r--r--arch/powerpc/lib/checksum_64.S27
-rw-r--r--arch/powerpc/lib/code-patching.c14
-rw-r--r--arch/powerpc/lib/copypage_64.S4
-rw-r--r--arch/powerpc/lib/copypage_power7.S165
-rw-r--r--arch/powerpc/lib/copyuser_power7.S130
-rw-r--r--arch/powerpc/lib/crtsavres.S5
-rw-r--r--arch/powerpc/lib/hweight_64.S14
-rw-r--r--arch/powerpc/lib/ldstfp.S12
-rw-r--r--arch/powerpc/lib/memcpy_64.S4
-rw-r--r--arch/powerpc/lib/memcpy_power7.S647
-rw-r--r--arch/powerpc/lib/string.S2
-rw-r--r--arch/powerpc/lib/string_64.S202
-rw-r--r--arch/powerpc/lib/vmx-helper.c (renamed from arch/powerpc/lib/copyuser_power7_vmx.c)27
-rw-r--r--arch/powerpc/mm/hash_low_32.S8
-rw-r--r--arch/powerpc/mm/hash_low_64.S156
-rw-r--r--arch/powerpc/mm/mem.c1
-rw-r--r--arch/powerpc/mm/numa.c9
-rw-r--r--arch/powerpc/mm/tlb_low_64e.S10
-rw-r--r--arch/powerpc/mm/tlb_nohash_low.S16
-rw-r--r--arch/powerpc/net/bpf_jit.h106
-rw-r--r--arch/powerpc/net/bpf_jit_comp.c4
-rw-r--r--arch/powerpc/perf/callchain.c6
-rw-r--r--arch/powerpc/perf/core-book3s.c101
-rw-r--r--arch/powerpc/platforms/44x/currituck.c2
-rw-r--r--arch/powerpc/platforms/82xx/km82xx.c5
-rw-r--r--arch/powerpc/platforms/83xx/km83xx.c100
-rw-r--r--arch/powerpc/platforms/85xx/Kconfig43
-rw-r--r--arch/powerpc/platforms/85xx/Makefile4
-rw-r--r--arch/powerpc/platforms/85xx/bsc913x_rdb.c67
-rw-r--r--arch/powerpc/platforms/85xx/corenet_ds.c2
-rw-r--r--arch/powerpc/platforms/85xx/ge_imp3a.c2
-rw-r--r--arch/powerpc/platforms/85xx/mpc8536_ds.c2
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_ds.c97
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_mds.c2
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_rdb.c22
-rw-r--r--arch/powerpc/platforms/85xx/p1022_ds.c230
-rw-r--r--arch/powerpc/platforms/85xx/p3060_qds.c77
-rw-r--r--arch/powerpc/platforms/85xx/qemu_e500.c72
-rw-r--r--arch/powerpc/platforms/85xx/sbc8560.c254
-rw-r--r--arch/powerpc/platforms/85xx/tqm85xx.c2
-rw-r--r--arch/powerpc/platforms/86xx/gef_ppc9a.c2
-rw-r--r--arch/powerpc/platforms/86xx/gef_sbc310.c2
-rw-r--r--arch/powerpc/platforms/86xx/gef_sbc610.c2
-rw-r--r--arch/powerpc/platforms/86xx/mpc86xx_hpcn.c2
-rw-r--r--arch/powerpc/platforms/Kconfig9
-rw-r--r--arch/powerpc/platforms/Kconfig.cputype4
-rw-r--r--arch/powerpc/platforms/cell/beat_hvCall.S28
-rw-r--r--arch/powerpc/platforms/cell/iommu.c4
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c123
-rw-r--r--arch/powerpc/platforms/cell/spufs/syscalls.c2
-rw-r--r--arch/powerpc/platforms/powernv/opal-takeover.S10
-rw-r--r--arch/powerpc/platforms/powernv/pci-ioda.c8
-rw-r--r--arch/powerpc/platforms/powernv/smp.c10
-rw-r--r--arch/powerpc/platforms/pseries/eeh_event.c6
-rw-r--r--arch/powerpc/platforms/pseries/eeh_pseries.c4
-rw-r--r--arch/powerpc/platforms/pseries/hvCall.S78
-rw-r--r--arch/powerpc/platforms/pseries/iommu.c115
-rw-r--r--arch/powerpc/platforms/pseries/mobility.c8
-rw-r--r--arch/powerpc/platforms/pseries/pci_dlpar.c2
-rw-r--r--arch/powerpc/platforms/pseries/processor_idle.c36
-rw-r--r--arch/powerpc/platforms/pseries/reconfig.c16
-rw-r--r--arch/powerpc/platforms/pseries/smp.c1
-rw-r--r--arch/powerpc/sysdev/6xx-suspend.S2
-rw-r--r--arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h4
-rw-r--r--arch/powerpc/sysdev/fsl_85xx_l2ctlr.c39
-rw-r--r--arch/powerpc/sysdev/fsl_pci.c78
-rw-r--r--arch/powerpc/sysdev/fsl_pci.h8
-rw-r--r--arch/powerpc/sysdev/mpic.c4
-rw-r--r--arch/powerpc/sysdev/mpic_msgr.c3
-rw-r--r--arch/powerpc/sysdev/mv64x60_pci.c2
-rw-r--r--arch/powerpc/sysdev/qe_lib/qe.c3
-rw-r--r--arch/powerpc/sysdev/xics/icp-hv.c8
-rw-r--r--arch/powerpc/sysdev/xics/icp-native.c2
-rw-r--r--arch/powerpc/sysdev/xics/xics-common.c3
-rw-r--r--arch/powerpc/xmon/xmon.c84
-rw-r--r--arch/s390/Kconfig4
-rw-r--r--arch/s390/appldata/appldata.h2
-rw-r--r--arch/s390/appldata/appldata_base.c132
-rw-r--r--arch/s390/appldata/appldata_mem.c4
-rw-r--r--arch/s390/appldata/appldata_net_sum.c4
-rw-r--r--arch/s390/appldata/appldata_os.c4
-rw-r--r--arch/s390/crypto/aes_s390.c2
-rw-r--r--arch/s390/crypto/crypt_s390.h2
-rw-r--r--arch/s390/crypto/crypto_des.h18
-rw-r--r--arch/s390/crypto/des_s390.c2
-rw-r--r--arch/s390/crypto/prng.c2
-rw-r--r--arch/s390/crypto/sha1_s390.c2
-rw-r--r--arch/s390/crypto/sha256_s390.c2
-rw-r--r--arch/s390/defconfig7
-rw-r--r--arch/s390/hypfs/hypfs.h3
-rw-r--r--arch/s390/hypfs/hypfs_dbfs.c2
-rw-r--r--arch/s390/hypfs/hypfs_diag.c1
-rw-r--r--arch/s390/hypfs/hypfs_vm.c2
-rw-r--r--arch/s390/hypfs/inode.c2
-rw-r--r--arch/s390/include/asm/airq.h4
-rw-r--r--arch/s390/include/asm/appldata.h4
-rw-r--r--arch/s390/include/asm/atomic.h8
-rw-r--r--arch/s390/include/asm/bitops.h10
-rw-r--r--arch/s390/include/asm/bugs.h4
-rw-r--r--arch/s390/include/asm/cache.h4
-rw-r--r--arch/s390/include/asm/ccwdev.h2
-rw-r--r--arch/s390/include/asm/ccwgroup.h2
-rw-r--r--arch/s390/include/asm/checksum.h10
-rw-r--r--arch/s390/include/asm/chpid.h2
-rw-r--r--arch/s390/include/asm/chsc.h2
-rw-r--r--arch/s390/include/asm/cio.h3
-rw-r--r--arch/s390/include/asm/cpcmd.h4
-rw-r--r--arch/s390/include/asm/cpu.h2
-rw-r--r--arch/s390/include/asm/cputime.h12
-rw-r--r--arch/s390/include/asm/crw.h2
-rw-r--r--arch/s390/include/asm/current.h4
-rw-r--r--arch/s390/include/asm/dasd.h3
-rw-r--r--arch/s390/include/asm/debug.h4
-rw-r--r--arch/s390/include/asm/delay.h4
-rw-r--r--arch/s390/include/asm/dma.h2
-rw-r--r--arch/s390/include/asm/ebcdic.h3
-rw-r--r--arch/s390/include/asm/elf.h5
-rw-r--r--arch/s390/include/asm/errno.h2
-rw-r--r--arch/s390/include/asm/etr.h2
-rw-r--r--arch/s390/include/asm/extmem.h4
-rw-r--r--arch/s390/include/asm/hardirq.h4
-rw-r--r--arch/s390/include/asm/idals.h5
-rw-r--r--arch/s390/include/asm/io.h4
-rw-r--r--arch/s390/include/asm/irqflags.h2
-rw-r--r--arch/s390/include/asm/kexec.h4
-rw-r--r--arch/s390/include/asm/kprobes.h2
-rw-r--r--arch/s390/include/asm/kvm.h2
-rw-r--r--arch/s390/include/asm/kvm_host.h4
-rw-r--r--arch/s390/include/asm/kvm_para.h2
-rw-r--r--arch/s390/include/asm/kvm_virtio.h2
-rw-r--r--arch/s390/include/asm/lowcore.h9
-rw-r--r--arch/s390/include/asm/mathemu.h3
-rw-r--r--arch/s390/include/asm/mman.h2
-rw-r--r--arch/s390/include/asm/mmu_context.h18
-rw-r--r--arch/s390/include/asm/monwriter.h4
-rw-r--r--arch/s390/include/asm/nmi.h2
-rw-r--r--arch/s390/include/asm/page.h4
-rw-r--r--arch/s390/include/asm/pgalloc.h4
-rw-r--r--arch/s390/include/asm/pgtable.h4
-rw-r--r--arch/s390/include/asm/posix_types.h5
-rw-r--r--arch/s390/include/asm/processor.h16
-rw-r--r--arch/s390/include/asm/ptrace.h4
-rw-r--r--arch/s390/include/asm/qdio.h4
-rw-r--r--arch/s390/include/asm/qeth.h4
-rw-r--r--arch/s390/include/asm/reset.h2
-rw-r--r--arch/s390/include/asm/resource.h2
-rw-r--r--arch/s390/include/asm/rwsem.h4
-rw-r--r--arch/s390/include/asm/sclp.h4
-rw-r--r--arch/s390/include/asm/scsw.h2
-rw-r--r--arch/s390/include/asm/setup.h6
-rw-r--r--arch/s390/include/asm/shmparam.h2
-rw-r--r--arch/s390/include/asm/sigcontext.h4
-rw-r--r--arch/s390/include/asm/siginfo.h2
-rw-r--r--arch/s390/include/asm/signal.h2
-rw-r--r--arch/s390/include/asm/sigp.h32
-rw-r--r--arch/s390/include/asm/smp.h3
-rw-r--r--arch/s390/include/asm/socket.h2
-rw-r--r--arch/s390/include/asm/sparsemem.h2
-rw-r--r--arch/s390/include/asm/spinlock.h4
-rw-r--r--arch/s390/include/asm/stat.h2
-rw-r--r--arch/s390/include/asm/statfs.h2
-rw-r--r--arch/s390/include/asm/string.h4
-rw-r--r--arch/s390/include/asm/swab.h4
-rw-r--r--arch/s390/include/asm/syscall.h10
-rw-r--r--arch/s390/include/asm/sysinfo.h2
-rw-r--r--arch/s390/include/asm/tape390.h3
-rw-r--r--arch/s390/include/asm/termios.h2
-rw-r--r--arch/s390/include/asm/thread_info.h4
-rw-r--r--arch/s390/include/asm/timer.h51
-rw-r--r--arch/s390/include/asm/timex.h4
-rw-r--r--arch/s390/include/asm/types.h2
-rw-r--r--arch/s390/include/asm/uaccess.h6
-rw-r--r--arch/s390/include/asm/ucontext.h2
-rw-r--r--arch/s390/include/asm/unistd.h3
-rw-r--r--arch/s390/include/asm/user.h2
-rw-r--r--arch/s390/include/asm/vtimer.h33
-rw-r--r--arch/s390/include/asm/vtoc.h4
-rw-r--r--arch/s390/include/asm/zcrypt.h2
-rw-r--r--arch/s390/kernel/asm-offsets.c12
-rw-r--r--arch/s390/kernel/base.S5
-rw-r--r--arch/s390/kernel/bitmap.c2
-rw-r--r--arch/s390/kernel/compat_exec_domain.c2
-rw-r--r--arch/s390/kernel/compat_linux.c6
-rw-r--r--arch/s390/kernel/compat_signal.c4
-rw-r--r--arch/s390/kernel/compat_wrapper.S7
-rw-r--r--arch/s390/kernel/cpcmd.c4
-rw-r--r--arch/s390/kernel/crash.c4
-rw-r--r--arch/s390/kernel/debug.c71
-rw-r--r--arch/s390/kernel/dis.c7
-rw-r--r--arch/s390/kernel/early.c3
-rw-r--r--arch/s390/kernel/ebcdic.c3
-rw-r--r--arch/s390/kernel/entry.S49
-rw-r--r--arch/s390/kernel/entry.h4
-rw-r--r--arch/s390/kernel/entry64.S52
-rw-r--r--arch/s390/kernel/head.S2
-rw-r--r--arch/s390/kernel/head31.S4
-rw-r--r--arch/s390/kernel/head64.S4
-rw-r--r--arch/s390/kernel/head_kdump.S6
-rw-r--r--arch/s390/kernel/ipl.c28
-rw-r--r--arch/s390/kernel/irq.c2
-rw-r--r--arch/s390/kernel/kprobes.c2
-rw-r--r--arch/s390/kernel/lgr.c15
-rw-r--r--arch/s390/kernel/machine_kexec.c4
-rw-r--r--arch/s390/kernel/mcount.S2
-rw-r--r--arch/s390/kernel/mcount64.S2
-rw-r--r--arch/s390/kernel/module.c5
-rw-r--r--arch/s390/kernel/nmi.c2
-rw-r--r--arch/s390/kernel/os_info.c2
-rw-r--r--arch/s390/kernel/process.c4
-rw-r--r--arch/s390/kernel/processor.c6
-rw-r--r--arch/s390/kernel/ptrace.c9
-rw-r--r--arch/s390/kernel/reipl.S7
-rw-r--r--arch/s390/kernel/reipl64.S5
-rw-r--r--arch/s390/kernel/relocate_kernel.S7
-rw-r--r--arch/s390/kernel/relocate_kernel64.S9
-rw-r--r--arch/s390/kernel/sclp.S2
-rw-r--r--arch/s390/kernel/setup.c41
-rw-r--r--arch/s390/kernel/signal.c4
-rw-r--r--arch/s390/kernel/smp.c116
-rw-r--r--arch/s390/kernel/stacktrace.c4
-rw-r--r--arch/s390/kernel/swsusp_asm64.S13
-rw-r--r--arch/s390/kernel/sys_s390.c13
-rw-r--r--arch/s390/kernel/time.c3
-rw-r--r--arch/s390/kernel/topology.c2
-rw-r--r--arch/s390/kernel/traps.c20
-rw-r--r--arch/s390/kernel/vdso.c9
-rw-r--r--arch/s390/kernel/vmlinux.lds.S2
-rw-r--r--arch/s390/kernel/vtime.c370
-rw-r--r--arch/s390/kvm/diag.c4
-rw-r--r--arch/s390/kvm/gaccess.h4
-rw-r--r--arch/s390/kvm/intercept.c4
-rw-r--r--arch/s390/kvm/interrupt.c2
-rw-r--r--arch/s390/kvm/kvm-s390.c5
-rw-r--r--arch/s390/kvm/kvm-s390.h4
-rw-r--r--arch/s390/kvm/priv.c2
-rw-r--r--arch/s390/kvm/sigp.c121
-rw-r--r--arch/s390/lib/delay.c4
-rw-r--r--arch/s390/lib/div64.c4
-rw-r--r--arch/s390/lib/spinlock.c3
-rw-r--r--arch/s390/lib/string.c3
-rw-r--r--arch/s390/lib/uaccess.h2
-rw-r--r--arch/s390/lib/uaccess_mvcos.c4
-rw-r--r--arch/s390/lib/uaccess_pt.c2
-rw-r--r--arch/s390/lib/uaccess_std.c4
-rw-r--r--arch/s390/math-emu/math.c4
-rw-r--r--arch/s390/mm/cmm.c2
-rw-r--r--arch/s390/mm/extmem.c3
-rw-r--r--arch/s390/mm/fault.c39
-rw-r--r--arch/s390/mm/hugetlbpage.c2
-rw-r--r--arch/s390/mm/init.c4
-rw-r--r--arch/s390/mm/mmap.c14
-rw-r--r--arch/s390/mm/pgtable.c9
-rw-r--r--arch/s390/mm/vmem.c2
-rw-r--r--arch/s390/oprofile/backtrace.c8
-rw-r--r--arch/s390/oprofile/hwsampler.c4
-rw-r--r--arch/s390/oprofile/init.c6
-rw-r--r--arch/s390/oprofile/op_counter.h6
-rw-r--r--arch/sh/Kconfig3
-rw-r--r--arch/sh/boards/Kconfig18
-rw-r--r--arch/sh/boards/board-apsh4a3a.c10
-rw-r--r--arch/sh/boards/board-apsh4ad0a.c10
-rw-r--r--arch/sh/boards/board-magicpanelr2.c10
-rw-r--r--arch/sh/boards/board-polaris.c12
-rw-r--r--arch/sh/boards/board-sh2007.c12
-rw-r--r--arch/sh/boards/board-sh7757lcr.c14
-rw-r--r--arch/sh/boards/mach-ap325rxa/setup.c21
-rw-r--r--arch/sh/boards/mach-dreamcast/irq.c32
-rw-r--r--arch/sh/boards/mach-ecovec24/setup.c125
-rw-r--r--arch/sh/boards/mach-kfr2r09/setup.c12
-rw-r--r--arch/sh/boards/mach-migor/setup.c13
-rw-r--r--arch/sh/boards/mach-rsk/setup.c10
-rw-r--r--arch/sh/boards/mach-sdk7786/setup.c10
-rw-r--r--arch/sh/boards/mach-se/7343/irq.c129
-rw-r--r--arch/sh/boards/mach-se/7343/setup.c10
-rw-r--r--arch/sh/boards/mach-se/7722/irq.c131
-rw-r--r--arch/sh/boards/mach-se/7722/setup.c6
-rw-r--r--arch/sh/boards/mach-se/7724/irq.c36
-rw-r--r--arch/sh/boards/mach-se/7724/setup.c15
-rw-r--r--arch/sh/boards/mach-x3proto/gpio.c57
-rw-r--r--arch/sh/cchips/hd6446x/hd64461.c33
-rw-r--r--arch/sh/configs/apsh4ad0a_defconfig2
-rw-r--r--arch/sh/configs/sdk7786_defconfig4
-rw-r--r--arch/sh/configs/se7206_defconfig2
-rw-r--r--arch/sh/configs/shx3_defconfig2
-rw-r--r--arch/sh/configs/urquell_defconfig4
-rw-r--r--arch/sh/drivers/dma/dma-sh.c2
-rw-r--r--arch/sh/drivers/pci/fixups-dreamcast.c2
-rw-r--r--arch/sh/drivers/pci/fixups-sdk7786.c4
-rw-r--r--arch/sh/drivers/pci/pci.c7
-rw-r--r--arch/sh/include/asm/bug.h4
-rw-r--r--arch/sh/include/asm/kdebug.h2
-rw-r--r--arch/sh/include/asm/sections.h1
-rw-r--r--arch/sh/include/asm/siu.h1
-rw-r--r--arch/sh/include/asm/unistd.h1
-rw-r--r--arch/sh/include/cpu-sh2a/cpu/sh7269.h36
-rw-r--r--arch/sh/include/cpu-sh4/cpu/sh7757.h2
-rw-r--r--arch/sh/include/mach-se/mach/se7343.h7
-rw-r--r--arch/sh/include/mach-se/mach/se7722.h10
-rw-r--r--arch/sh/kernel/cpu/sh2a/pinmux-sh7269.c195
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7724.c4
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7722.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7757.c14
-rw-r--r--arch/sh/kernel/cpu/sh5/unwind.c63
-rw-r--r--arch/sh/kernel/dumpstack.c58
-rw-r--r--arch/sh/kernel/irq.c10
-rw-r--r--arch/sh/kernel/setup.c2
-rw-r--r--arch/sh/kernel/sh_ksyms_32.c1
-rw-r--r--arch/sh/kernel/traps.c71
-rw-r--r--arch/sh/kernel/traps_32.c121
-rw-r--r--arch/sh/kernel/traps_64.c589
-rw-r--r--arch/sh/kernel/vmlinux.lds.S1
-rw-r--r--arch/sh/lib/mcount.S8
-rw-r--r--arch/sh/lib64/Makefile2
-rw-r--r--arch/sh/lib64/dbg.c248
-rw-r--r--arch/sh/mm/fault.c8
-rw-r--r--arch/sh/mm/tlb-sh5.c2
-rw-r--r--arch/sparc/Kconfig1
-rw-r--r--arch/sparc/include/asm/fixmap.h110
-rw-r--r--arch/sparc/include/asm/highmem.h3
-rw-r--r--arch/sparc/include/asm/leon.h1
-rw-r--r--arch/sparc/include/asm/mmu_context_32.h8
-rw-r--r--arch/sparc/include/asm/page_32.h3
-rw-r--r--arch/sparc/include/asm/pgalloc_32.h29
-rw-r--r--arch/sparc/include/asm/pgtable_32.h44
-rw-r--r--arch/sparc/include/asm/unistd.h1
-rw-r--r--arch/sparc/include/asm/vaddrs.h22
-rw-r--r--arch/sparc/kernel/head_32.S2
-rw-r--r--arch/sparc/kernel/ldc.c6
-rw-r--r--arch/sparc/kernel/leon_kernel.c16
-rw-r--r--arch/sparc/kernel/leon_pci.c8
-rw-r--r--arch/sparc/kernel/of_device_64.c2
-rw-r--r--arch/sparc/kernel/pci.c102
-rw-r--r--arch/sparc/kernel/pci_impl.h1
-rw-r--r--arch/sparc/kernel/pcic.c13
-rw-r--r--arch/sparc/kernel/process_32.c4
-rw-r--r--arch/sparc/kernel/setup_32.c1
-rw-r--r--arch/sparc/kernel/smp_64.c7
-rw-r--r--arch/sparc/kernel/sys_sparc_64.c29
-rw-r--r--arch/sparc/lib/NG2memcpy.S72
-rw-r--r--arch/sparc/lib/U1memcpy.S4
-rw-r--r--arch/sparc/lib/copy_page.S56
-rw-r--r--arch/sparc/mm/fault_32.c18
-rw-r--r--arch/sparc/mm/highmem.c42
-rw-r--r--arch/sparc/mm/init_32.c58
-rw-r--r--arch/sparc/mm/init_64.c28
-rw-r--r--arch/sparc/mm/srmmu.c332
-rw-r--r--arch/sparc/net/bpf_jit_comp.c4
-rw-r--r--arch/sparc/prom/init_32.c7
-rw-r--r--arch/sparc/prom/init_64.c4
-rw-r--r--arch/tile/Kconfig42
-rw-r--r--arch/tile/Makefile2
-rw-r--r--arch/tile/configs/tilegx_defconfig4
-rw-r--r--arch/tile/configs/tilepro_defconfig4
-rw-r--r--arch/tile/gxio/Kconfig28
-rw-r--r--arch/tile/gxio/Makefile9
-rw-r--r--arch/tile/gxio/dma_queue.c176
-rw-r--r--arch/tile/gxio/iorpc_globals.c89
-rw-r--r--arch/tile/gxio/iorpc_mpipe.c529
-rw-r--r--arch/tile/gxio/iorpc_mpipe_info.c85
-rw-r--r--arch/tile/gxio/iorpc_trio.c327
-rw-r--r--arch/tile/gxio/iorpc_usb_host.c99
-rw-r--r--arch/tile/gxio/kiorpc.c61
-rw-r--r--arch/tile/gxio/mpipe.c545
-rw-r--r--arch/tile/gxio/trio.c49
-rw-r--r--arch/tile/gxio/usb_host.c91
-rw-r--r--arch/tile/include/arch/mpipe.h359
-rw-r--r--arch/tile/include/arch/mpipe_constants.h42
-rw-r--r--arch/tile/include/arch/mpipe_def.h39
-rw-r--r--arch/tile/include/arch/mpipe_shm.h509
-rw-r--r--arch/tile/include/arch/mpipe_shm_def.h23
-rw-r--r--arch/tile/include/arch/trio.h72
-rw-r--r--arch/tile/include/arch/trio_constants.h36
-rw-r--r--arch/tile/include/arch/trio_def.h41
-rw-r--r--arch/tile/include/arch/trio_pcie_intfc.h229
-rw-r--r--arch/tile/include/arch/trio_pcie_intfc_def.h32
-rw-r--r--arch/tile/include/arch/trio_pcie_rc.h156
-rw-r--r--arch/tile/include/arch/trio_pcie_rc_def.h24
-rw-r--r--arch/tile/include/arch/trio_shm.h125
-rw-r--r--arch/tile/include/arch/trio_shm_def.h19
-rw-r--r--arch/tile/include/arch/usb_host.h26
-rw-r--r--arch/tile/include/arch/usb_host_def.h19
-rw-r--r--arch/tile/include/asm/Kbuild2
-rw-r--r--arch/tile/include/asm/cache.h12
-rw-r--r--arch/tile/include/asm/checksum.h18
-rw-r--r--arch/tile/include/asm/device.h33
-rw-r--r--arch/tile/include/asm/dma-mapping.h146
-rw-r--r--arch/tile/include/asm/fixmap.h14
-rw-r--r--arch/tile/include/asm/homecache.h19
-rw-r--r--arch/tile/include/asm/io.h144
-rw-r--r--arch/tile/include/asm/kmap_types.h31
-rw-r--r--arch/tile/include/asm/memprof.h33
-rw-r--r--arch/tile/include/asm/page.h7
-rw-r--r--arch/tile/include/asm/pci.h151
-rw-r--r--arch/tile/include/gxio/common.h40
-rw-r--r--arch/tile/include/gxio/dma_queue.h161
-rw-r--r--arch/tile/include/gxio/iorpc_globals.h38
-rw-r--r--arch/tile/include/gxio/iorpc_mpipe.h136
-rw-r--r--arch/tile/include/gxio/iorpc_mpipe_info.h46
-rw-r--r--arch/tile/include/gxio/iorpc_trio.h97
-rw-r--r--arch/tile/include/gxio/iorpc_usb_host.h46
-rw-r--r--arch/tile/include/gxio/kiorpc.h29
-rw-r--r--arch/tile/include/gxio/mpipe.h1736
-rw-r--r--arch/tile/include/gxio/trio.h298
-rw-r--r--arch/tile/include/gxio/usb_host.h87
-rw-r--r--arch/tile/include/hv/drv_mpipe_intf.h602
-rw-r--r--arch/tile/include/hv/drv_trio_intf.h195
-rw-r--r--arch/tile/include/hv/drv_usb_host_intf.h39
-rw-r--r--arch/tile/include/hv/iorpc.h714
-rw-r--r--arch/tile/kernel/Makefile5
-rw-r--r--arch/tile/kernel/pci-dma.c536
-rw-r--r--arch/tile/kernel/pci.c17
-rw-r--r--arch/tile/kernel/pci_gx.c1543
-rw-r--r--arch/tile/kernel/setup.c45
-rw-r--r--arch/tile/kernel/smpboot.c10
-rw-r--r--arch/tile/kernel/usb.c69
-rw-r--r--arch/tile/lib/checksum.c15
-rw-r--r--arch/tile/mm/highmem.c2
-rw-r--r--arch/tile/mm/homecache.c156
-rw-r--r--arch/tile/mm/init.c70
-rw-r--r--arch/tile/mm/pgtable.c7
-rw-r--r--arch/um/defconfig10
-rw-r--r--arch/um/drivers/chan_kern.c4
-rw-r--r--arch/um/drivers/line.c231
-rw-r--r--arch/um/drivers/line.h12
-rw-r--r--arch/um/drivers/mconsole_kern.c3
-rw-r--r--arch/um/drivers/net_kern.c2
-rw-r--r--arch/um/drivers/port_kern.c6
-rw-r--r--arch/um/drivers/random.c3
-rw-r--r--arch/um/drivers/ssl.c42
-rw-r--r--arch/um/drivers/stdio_console.c21
-rw-r--r--arch/um/drivers/ubd_kern.c2
-rw-r--r--arch/um/drivers/xterm_kern.c3
-rw-r--r--arch/um/include/asm/kmap_types.h18
-rw-r--r--arch/um/include/asm/ptrace-generic.h2
-rw-r--r--arch/um/include/shared/as-layout.h3
-rw-r--r--arch/um/include/shared/irq_user.h3
-rw-r--r--arch/um/include/shared/kern_util.h13
-rw-r--r--arch/um/kernel/irq.c2
-rw-r--r--arch/um/kernel/process.c13
-rw-r--r--arch/um/kernel/ptrace.c71
-rw-r--r--arch/um/kernel/sigio.c3
-rw-r--r--arch/um/kernel/skas/syscall.c6
-rw-r--r--arch/um/kernel/time.c2
-rw-r--r--arch/um/kernel/trap.c39
-rw-r--r--arch/um/os-Linux/internal.h2
-rw-r--r--arch/um/os-Linux/signal.c26
-rw-r--r--arch/um/os-Linux/skas/process.c16
-rw-r--r--arch/um/os-Linux/time.c4
-rw-r--r--arch/unicore32/Kconfig1
-rw-r--r--arch/unicore32/kernel/pci.c2
-rw-r--r--arch/x86/Kconfig4
-rw-r--r--arch/x86/Kconfig.debug19
-rw-r--r--arch/x86/Makefile7
-rw-r--r--arch/x86/boot/Makefile2
-rw-r--r--arch/x86/boot/compressed/cmdline.c4
-rw-r--r--arch/x86/boot/compressed/early_serial_console.c4
-rw-r--r--arch/x86/boot/compressed/eboot.c198
-rw-r--r--arch/x86/boot/compressed/head_32.S10
-rw-r--r--arch/x86/boot/compressed/head_64.S10
-rw-r--r--arch/x86/boot/compressed/misc.c31
-rw-r--r--arch/x86/boot/compressed/misc.h27
-rw-r--r--arch/x86/boot/header.S11
-rw-r--r--arch/x86/crypto/Makefile14
-rw-r--r--arch/x86/crypto/ablk_helper.c149
-rw-r--r--arch/x86/crypto/aes_glue.c2
-rw-r--r--arch/x86/crypto/aesni-intel_glue.c110
-rw-r--r--arch/x86/crypto/camellia_glue.c355
-rw-r--r--arch/x86/crypto/glue_helper.c307
-rw-r--r--arch/x86/crypto/serpent-avx-x86_64-asm_64.S704
-rw-r--r--arch/x86/crypto/serpent_avx_glue.c636
-rw-r--r--arch/x86/crypto/serpent_sse2_glue.c513
-rw-r--r--arch/x86/crypto/sha1_ssse3_asm.S2
-rw-r--r--arch/x86/crypto/sha1_ssse3_glue.c6
-rw-r--r--arch/x86/crypto/twofish-avx-x86_64-asm_64.S300
-rw-r--r--arch/x86/crypto/twofish_avx_glue.c624
-rw-r--r--arch/x86/crypto/twofish_glue_3way.c409
-rw-r--r--arch/x86/include/asm/alternative.h74
-rw-r--r--arch/x86/include/asm/amd_nb.h21
-rw-r--r--arch/x86/include/asm/apic.h66
-rw-r--r--arch/x86/include/asm/bitops.h7
-rw-r--r--arch/x86/include/asm/bootparam.h1
-rw-r--r--arch/x86/include/asm/cpufeature.h2
-rw-r--r--arch/x86/include/asm/crypto/ablk_helper.h31
-rw-r--r--arch/x86/include/asm/crypto/aes.h (renamed from arch/x86/include/asm/aes.h)0
-rw-r--r--arch/x86/include/asm/crypto/glue_helper.h115
-rw-r--r--arch/x86/include/asm/crypto/serpent-avx.h32
-rw-r--r--arch/x86/include/asm/crypto/serpent-sse2.h (renamed from arch/x86/include/asm/serpent.h)4
-rw-r--r--arch/x86/include/asm/crypto/twofish.h46
-rw-r--r--arch/x86/include/asm/emergency-restart.h2
-rw-r--r--arch/x86/include/asm/entry_arch.h9
-rw-r--r--arch/x86/include/asm/floppy.h2
-rw-r--r--arch/x86/include/asm/hypervisor.h1
-rw-r--r--arch/x86/include/asm/iommu.h1
-rw-r--r--arch/x86/include/asm/irq_vectors.h11
-rw-r--r--arch/x86/include/asm/kvm.h1
-rw-r--r--arch/x86/include/asm/kvm_emulate.h6
-rw-r--r--arch/x86/include/asm/kvm_host.h35
-rw-r--r--arch/x86/include/asm/kvm_para.h7
-rw-r--r--arch/x86/include/asm/mce.h8
-rw-r--r--arch/x86/include/asm/msr.h46
-rw-r--r--arch/x86/include/asm/nmi.h20
-rw-r--r--arch/x86/include/asm/olpc.h19
-rw-r--r--arch/x86/include/asm/paravirt.h46
-rw-r--r--arch/x86/include/asm/paravirt_types.h5
-rw-r--r--arch/x86/include/asm/pci_x86.h15
-rw-r--r--arch/x86/include/asm/percpu.h17
-rw-r--r--arch/x86/include/asm/perf_event.h35
-rw-r--r--arch/x86/include/asm/pgtable-2level.h4
-rw-r--r--arch/x86/include/asm/pgtable-3level.h6
-rw-r--r--arch/x86/include/asm/pgtable_64.h8
-rw-r--r--arch/x86/include/asm/pgtable_types.h6
-rw-r--r--arch/x86/include/asm/processor-flags.h2
-rw-r--r--arch/x86/include/asm/processor.h13
-rw-r--r--arch/x86/include/asm/realmode.h3
-rw-r--r--arch/x86/include/asm/reboot.h4
-rw-r--r--arch/x86/include/asm/smp.h21
-rw-r--r--arch/x86/include/asm/spinlock.h3
-rw-r--r--arch/x86/include/asm/tlb.h9
-rw-r--r--arch/x86/include/asm/tlbflush.h49
-rw-r--r--arch/x86/include/asm/uaccess_64.h11
-rw-r--r--arch/x86/include/asm/unistd.h1
-rw-r--r--arch/x86/include/asm/uprobes.h2
-rw-r--r--arch/x86/include/asm/uv/uv.h5
-rw-r--r--arch/x86/include/asm/uv/uv_bau.h28
-rw-r--r--arch/x86/include/asm/vmx.h6
-rw-r--r--arch/x86/include/asm/x2apic.h18
-rw-r--r--arch/x86/include/asm/x86_init.h13
-rw-r--r--arch/x86/include/asm/xen/hypercall.h8
-rw-r--r--arch/x86/kernel/acpi/sleep.c4
-rw-r--r--arch/x86/kernel/acpi/sleep.h2
-rw-r--r--arch/x86/kernel/acpi/wakeup_32.S4
-rw-r--r--arch/x86/kernel/acpi/wakeup_64.S4
-rw-r--r--arch/x86/kernel/alternative.c23
-rw-r--r--arch/x86/kernel/amd_nb.c11
-rw-r--r--arch/x86/kernel/apic/apic.c42
-rw-r--r--arch/x86/kernel/apic/apic_flat_64.c76
-rw-r--r--arch/x86/kernel/apic/apic_noop.c9
-rw-r--r--arch/x86/kernel/apic/apic_numachip.c50
-rw-r--r--arch/x86/kernel/apic/bigsmp_32.c48
-rw-r--r--arch/x86/kernel/apic/es7000_32.c51
-rw-r--r--arch/x86/kernel/apic/io_apic.c360
-rw-r--r--arch/x86/kernel/apic/numaq_32.c30
-rw-r--r--arch/x86/kernel/apic/probe_32.c23
-rw-r--r--arch/x86/kernel/apic/probe_64.c11
-rw-r--r--arch/x86/kernel/apic/summit_32.c68
-rw-r--r--arch/x86/kernel/apic/x2apic_cluster.c82
-rw-r--r--arch/x86/kernel/apic/x2apic_phys.c39
-rw-r--r--arch/x86/kernel/apic/x2apic_uv_x.c45
-rw-r--r--arch/x86/kernel/apm_32.c29
-rw-r--r--arch/x86/kernel/cpu/Makefile6
-rw-r--r--arch/x86/kernel/cpu/amd.c39
-rw-r--r--arch/x86/kernel/cpu/bugs.c20
-rw-r--r--arch/x86/kernel/cpu/common.c35
-rw-r--r--arch/x86/kernel/cpu/cpu.h9
-rw-r--r--arch/x86/kernel/cpu/hypervisor.c3
-rw-r--r--arch/x86/kernel/cpu/intel.c176
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce-severity.c7
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c75
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce_amd.c286
-rw-r--r--arch/x86/kernel/cpu/mtrr/cleanup.c6
-rw-r--r--arch/x86/kernel/cpu/mtrr/generic.c6
-rw-r--r--arch/x86/kernel/cpu/perf_event.c196
-rw-r--r--arch/x86/kernel/cpu/perf_event.h46
-rw-r--r--arch/x86/kernel/cpu/perf_event_amd.c103
-rw-r--r--arch/x86/kernel/cpu/perf_event_amd_ibs.c4
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c236
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_ds.c19
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_uncore.c2915
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_uncore.h619
-rw-r--r--arch/x86/kernel/cpu/perf_event_p4.c16
-rw-r--r--arch/x86/kernel/cpu/perf_event_p6.c4
-rw-r--r--arch/x86/kernel/cpu/sched.c55
-rw-r--r--arch/x86/kernel/dumpstack.c5
-rw-r--r--arch/x86/kernel/dumpstack_32.c25
-rw-r--r--arch/x86/kernel/dumpstack_64.c21
-rw-r--r--arch/x86/kernel/e820.c2
-rw-r--r--arch/x86/kernel/entry_64.S38
-rw-r--r--arch/x86/kernel/irq.c7
-rw-r--r--arch/x86/kernel/irqinit.c73
-rw-r--r--arch/x86/kernel/kdebugfs.c6
-rw-r--r--arch/x86/kernel/kvm.c64
-rw-r--r--arch/x86/kernel/microcode_amd.c7
-rw-r--r--arch/x86/kernel/microcode_core.c66
-rw-r--r--arch/x86/kernel/module.c34
-rw-r--r--arch/x86/kernel/nmi.c47
-rw-r--r--arch/x86/kernel/nmi_selftest.c7
-rw-r--r--arch/x86/kernel/paravirt.c2
-rw-r--r--arch/x86/kernel/pci-calgary_64.c34
-rw-r--r--arch/x86/kernel/pci-dma.c11
-rw-r--r--arch/x86/kernel/process.c34
-rw-r--r--arch/x86/kernel/process_64.c12
-rw-r--r--arch/x86/kernel/quirks.c2
-rw-r--r--arch/x86/kernel/reboot.c74
-rw-r--r--arch/x86/kernel/setup.c6
-rw-r--r--arch/x86/kernel/setup_percpu.c2
-rw-r--r--arch/x86/kernel/signal.c5
-rw-r--r--arch/x86/kernel/smpboot.c114
-rw-r--r--arch/x86/kernel/traps.c19
-rw-r--r--arch/x86/kernel/tsc.c50
-rw-r--r--arch/x86/kernel/uprobes.c3
-rw-r--r--arch/x86/kernel/vm86_32.c6
-rw-r--r--arch/x86/kernel/vsmp_64.c44
-rw-r--r--arch/x86/kernel/vsyscall_64.c17
-rw-r--r--arch/x86/kernel/x8664_ksyms_64.c1
-rw-r--r--arch/x86/kernel/x86_init.c6
-rw-r--r--arch/x86/kernel/xsave.c12
-rw-r--r--arch/x86/kvm/cpuid.c46
-rw-r--r--arch/x86/kvm/cpuid.h9
-rw-r--r--arch/x86/kvm/emulate.c301
-rw-r--r--arch/x86/kvm/i8259.c34
-rw-r--r--arch/x86/kvm/lapic.c194
-rw-r--r--arch/x86/kvm/lapic.h11
-rw-r--r--arch/x86/kvm/mmu.c364
-rw-r--r--arch/x86/kvm/mmutrace.h45
-rw-r--r--arch/x86/kvm/paging_tmpl.h3
-rw-r--r--arch/x86/kvm/pmu.c22
-rw-r--r--arch/x86/kvm/svm.c12
-rw-r--r--arch/x86/kvm/trace.h46
-rw-r--r--arch/x86/kvm/vmx.c209
-rw-r--r--arch/x86/kvm/x86.c132
-rw-r--r--arch/x86/lib/msr-reg-export.c4
-rw-r--r--arch/x86/lib/msr-reg.S10
-rw-r--r--arch/x86/mm/hugetlbpage.c21
-rw-r--r--arch/x86/mm/init.c2
-rw-r--r--arch/x86/mm/init_32.c11
-rw-r--r--arch/x86/mm/srat.c15
-rw-r--r--arch/x86/mm/tlb.c401
-rw-r--r--arch/x86/net/bpf_jit_comp.c4
-rw-r--r--arch/x86/oprofile/op_model_amd.c4
-rw-r--r--arch/x86/pci/acpi.c109
-rw-r--r--arch/x86/pci/amd_bus.c7
-rw-r--r--arch/x86/pci/bus_numa.c22
-rw-r--r--arch/x86/pci/bus_numa.h3
-rw-r--r--arch/x86/pci/common.c2
-rw-r--r--arch/x86/pci/mmconfig-shared.c372
-rw-r--r--arch/x86/pci/mmconfig_32.c30
-rw-r--r--arch/x86/pci/mmconfig_64.c52
-rw-r--r--arch/x86/pci/mrst.c2
-rw-r--r--arch/x86/platform/olpc/olpc-xo1-pm.c16
-rw-r--r--arch/x86/platform/olpc/olpc-xo1-sci.c1
-rw-r--r--arch/x86/platform/olpc/olpc-xo15-sci.c7
-rw-r--r--arch/x86/platform/olpc/olpc.c190
-rw-r--r--arch/x86/platform/uv/tlb_uv.c459
-rw-r--r--arch/x86/platform/uv/uv_irq.c9
-rw-r--r--arch/x86/realmode/rm/Makefile4
-rw-r--r--arch/x86/realmode/rm/header.S4
-rw-r--r--arch/x86/realmode/rm/reboot.S (renamed from arch/x86/realmode/rm/reboot_32.S)30
-rw-r--r--arch/x86/syscalls/syscall_64.tbl8
-rw-r--r--arch/x86/um/asm/ptrace.h6
-rw-r--r--arch/x86/vdso/vdso32-setup.c6
-rw-r--r--arch/x86/xen/enlighten.c112
-rw-r--r--arch/x86/xen/mmu.c69
-rw-r--r--arch/x86/xen/p2m.c94
-rw-r--r--arch/x86/xen/setup.c32
-rw-r--r--arch/x86/xen/smp.c2
-rw-r--r--arch/xtensa/Kconfig1
-rw-r--r--arch/xtensa/include/asm/cpumask.h16
-rw-r--r--arch/xtensa/include/asm/rmap.h16
-rw-r--r--arch/xtensa/kernel/pci.c8
-rw-r--r--arch/xtensa/kernel/syscall.c2
-rw-r--r--arch/xtensa/mm/fault.c29
2043 files changed, 65702 insertions, 32499 deletions
diff --git a/arch/Kconfig b/arch/Kconfig
index 8c3d957fa8e..72f2fa189cc 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -248,7 +248,14 @@ config HAVE_CMPXCHG_LOCAL
248config HAVE_CMPXCHG_DOUBLE 248config HAVE_CMPXCHG_DOUBLE
249 bool 249 bool
250 250
251config ARCH_WANT_IPC_PARSE_VERSION
252 bool
253
254config ARCH_WANT_COMPAT_IPC_PARSE_VERSION
255 bool
256
251config ARCH_WANT_OLD_COMPAT_IPC 257config ARCH_WANT_OLD_COMPAT_IPC
258 select ARCH_WANT_COMPAT_IPC_PARSE_VERSION
252 bool 259 bool
253 260
254config HAVE_ARCH_SECCOMP_FILTER 261config HAVE_ARCH_SECCOMP_FILTER
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 3de74c9f961..9944dedee5b 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -14,9 +14,12 @@ config ALPHA
14 select AUTO_IRQ_AFFINITY if SMP 14 select AUTO_IRQ_AFFINITY if SMP
15 select GENERIC_IRQ_SHOW 15 select GENERIC_IRQ_SHOW
16 select ARCH_WANT_OPTIONAL_GPIOLIB 16 select ARCH_WANT_OPTIONAL_GPIOLIB
17 select ARCH_WANT_IPC_PARSE_VERSION
17 select ARCH_HAVE_NMI_SAFE_CMPXCHG 18 select ARCH_HAVE_NMI_SAFE_CMPXCHG
18 select GENERIC_SMP_IDLE_THREAD 19 select GENERIC_SMP_IDLE_THREAD
19 select GENERIC_CMOS_UPDATE 20 select GENERIC_CMOS_UPDATE
21 select GENERIC_STRNCPY_FROM_USER
22 select GENERIC_STRNLEN_USER
20 help 23 help
21 The Alpha is a 64-bit general-purpose processor designed and 24 The Alpha is a 64-bit general-purpose processor designed and
22 marketed by the Digital Equipment Corporation of blessed memory, 25 marketed by the Digital Equipment Corporation of blessed memory,
diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
index 3bb7ffeae3b..c2cbe4fc391 100644
--- a/arch/alpha/include/asm/atomic.h
+++ b/arch/alpha/include/asm/atomic.h
@@ -14,8 +14,8 @@
14 */ 14 */
15 15
16 16
17#define ATOMIC_INIT(i) ( (atomic_t) { (i) } ) 17#define ATOMIC_INIT(i) { (i) }
18#define ATOMIC64_INIT(i) ( (atomic64_t) { (i) } ) 18#define ATOMIC64_INIT(i) { (i) }
19 19
20#define atomic_read(v) (*(volatile int *)&(v)->counter) 20#define atomic_read(v) (*(volatile int *)&(v)->counter)
21#define atomic64_read(v) (*(volatile long *)&(v)->counter) 21#define atomic64_read(v) (*(volatile long *)&(v)->counter)
diff --git a/arch/alpha/include/asm/fpu.h b/arch/alpha/include/asm/fpu.h
index db00f7885fa..e477bcd5b94 100644
--- a/arch/alpha/include/asm/fpu.h
+++ b/arch/alpha/include/asm/fpu.h
@@ -1,7 +1,9 @@
1#ifndef __ASM_ALPHA_FPU_H 1#ifndef __ASM_ALPHA_FPU_H
2#define __ASM_ALPHA_FPU_H 2#define __ASM_ALPHA_FPU_H
3 3
4#ifdef __KERNEL__
4#include <asm/special_insns.h> 5#include <asm/special_insns.h>
6#endif
5 7
6/* 8/*
7 * Alpha floating-point control register defines: 9 * Alpha floating-point control register defines:
diff --git a/arch/alpha/include/asm/ptrace.h b/arch/alpha/include/asm/ptrace.h
index fd698a174f2..b87755a1955 100644
--- a/arch/alpha/include/asm/ptrace.h
+++ b/arch/alpha/include/asm/ptrace.h
@@ -76,7 +76,10 @@ struct switch_stack {
76#define task_pt_regs(task) \ 76#define task_pt_regs(task) \
77 ((struct pt_regs *) (task_stack_page(task) + 2*PAGE_SIZE) - 1) 77 ((struct pt_regs *) (task_stack_page(task) + 2*PAGE_SIZE) - 1)
78 78
79#define force_successful_syscall_return() (task_pt_regs(current)->r0 = 0) 79#define current_pt_regs() \
80 ((struct pt_regs *) ((char *)current_thread_info() + 2*PAGE_SIZE) - 1)
81
82#define force_successful_syscall_return() (current_pt_regs()->r0 = 0)
80 83
81#endif 84#endif
82 85
diff --git a/arch/alpha/include/asm/socket.h b/arch/alpha/include/asm/socket.h
index dcb221a4b5b..7d2f75be932 100644
--- a/arch/alpha/include/asm/socket.h
+++ b/arch/alpha/include/asm/socket.h
@@ -76,9 +76,11 @@
76/* Instruct lower device to use last 4-bytes of skb data as FCS */ 76/* Instruct lower device to use last 4-bytes of skb data as FCS */
77#define SO_NOFCS 43 77#define SO_NOFCS 43
78 78
79#ifdef __KERNEL__
79/* O_NONBLOCK clashes with the bits used for socket types. Therefore we 80/* O_NONBLOCK clashes with the bits used for socket types. Therefore we
80 * have to define SOCK_NONBLOCK to a different value here. 81 * have to define SOCK_NONBLOCK to a different value here.
81 */ 82 */
82#define SOCK_NONBLOCK 0x40000000 83#define SOCK_NONBLOCK 0x40000000
84#endif /* __KERNEL__ */
83 85
84#endif /* _ASM_SOCKET_H */ 86#endif /* _ASM_SOCKET_H */
diff --git a/arch/alpha/include/asm/uaccess.h b/arch/alpha/include/asm/uaccess.h
index b49ec2f8d6e..766fdfde2b7 100644
--- a/arch/alpha/include/asm/uaccess.h
+++ b/arch/alpha/include/asm/uaccess.h
@@ -433,36 +433,12 @@ clear_user(void __user *to, long len)
433#undef __module_address 433#undef __module_address
434#undef __module_call 434#undef __module_call
435 435
436/* Returns: -EFAULT if exception before terminator, N if the entire 436#define user_addr_max() \
437 buffer filled, else strlen. */ 437 (segment_eq(get_fs(), USER_DS) ? TASK_SIZE : ~0UL)
438 438
439extern long __strncpy_from_user(char *__to, const char __user *__from, long __to_len); 439extern long strncpy_from_user(char *dest, const char __user *src, long count);
440 440extern __must_check long strlen_user(const char __user *str);
441extern inline long 441extern __must_check long strnlen_user(const char __user *str, long n);
442strncpy_from_user(char *to, const char __user *from, long n)
443{
444 long ret = -EFAULT;
445 if (__access_ok((unsigned long)from, 0, get_fs()))
446 ret = __strncpy_from_user(to, from, n);
447 return ret;
448}
449
450/* Returns: 0 if bad, string length+1 (memory size) of string if ok */
451extern long __strlen_user(const char __user *);
452
453extern inline long strlen_user(const char __user *str)
454{
455 return access_ok(VERIFY_READ,str,0) ? __strlen_user(str) : 0;
456}
457
458/* Returns: 0 if exception before NUL or reaching the supplied limit (N),
459 * a value greater than N if the limit would be exceeded, else strlen. */
460extern long __strnlen_user(const char __user *, long);
461
462extern inline long strnlen_user(const char __user *str, long n)
463{
464 return access_ok(VERIFY_READ,str,0) ? __strnlen_user(str, n) : 0;
465}
466 442
467/* 443/*
468 * About the exception table: 444 * About the exception table:
diff --git a/arch/alpha/include/asm/unistd.h b/arch/alpha/include/asm/unistd.h
index d1f23b722df..a31a78eac9b 100644
--- a/arch/alpha/include/asm/unistd.h
+++ b/arch/alpha/include/asm/unistd.h
@@ -465,12 +465,13 @@
465#define __NR_setns 501 465#define __NR_setns 501
466#define __NR_accept4 502 466#define __NR_accept4 502
467#define __NR_sendmmsg 503 467#define __NR_sendmmsg 503
468#define __NR_process_vm_readv 504
469#define __NR_process_vm_writev 505
468 470
469#ifdef __KERNEL__ 471#ifdef __KERNEL__
470 472
471#define NR_SYSCALLS 504 473#define NR_SYSCALLS 506
472 474
473#define __ARCH_WANT_IPC_PARSE_VERSION
474#define __ARCH_WANT_OLD_READDIR 475#define __ARCH_WANT_OLD_READDIR
475#define __ARCH_WANT_STAT64 476#define __ARCH_WANT_STAT64
476#define __ARCH_WANT_SYS_GETHOSTNAME 477#define __ARCH_WANT_SYS_GETHOSTNAME
diff --git a/arch/alpha/include/asm/word-at-a-time.h b/arch/alpha/include/asm/word-at-a-time.h
new file mode 100644
index 00000000000..6b340d0f152
--- /dev/null
+++ b/arch/alpha/include/asm/word-at-a-time.h
@@ -0,0 +1,55 @@
1#ifndef _ASM_WORD_AT_A_TIME_H
2#define _ASM_WORD_AT_A_TIME_H
3
4#include <asm/compiler.h>
5
6/*
7 * word-at-a-time interface for Alpha.
8 */
9
10/*
11 * We do not use the word_at_a_time struct on Alpha, but it needs to be
12 * implemented to humour the generic code.
13 */
14struct word_at_a_time {
15 const unsigned long unused;
16};
17
18#define WORD_AT_A_TIME_CONSTANTS { 0 }
19
20/* Return nonzero if val has a zero */
21static inline unsigned long has_zero(unsigned long val, unsigned long *bits, const struct word_at_a_time *c)
22{
23 unsigned long zero_locations = __kernel_cmpbge(0, val);
24 *bits = zero_locations;
25 return zero_locations;
26}
27
28static inline unsigned long prep_zero_mask(unsigned long val, unsigned long bits, const struct word_at_a_time *c)
29{
30 return bits;
31}
32
33#define create_zero_mask(bits) (bits)
34
35static inline unsigned long find_zero(unsigned long bits)
36{
37#if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67)
38 /* Simple if have CIX instructions */
39 return __kernel_cttz(bits);
40#else
41 unsigned long t1, t2, t3;
42 /* Retain lowest set bit only */
43 bits &= -bits;
44 /* Binary search for lowest set bit */
45 t1 = bits & 0xf0;
46 t2 = bits & 0xcc;
47 t3 = bits & 0xaa;
48 if (t1) t1 = 4;
49 if (t2) t2 = 2;
50 if (t3) t3 = 1;
51 return t1 + t2 + t3;
52#endif
53}
54
55#endif /* _ASM_WORD_AT_A_TIME_H */
diff --git a/arch/alpha/kernel/alpha_ksyms.c b/arch/alpha/kernel/alpha_ksyms.c
index d96e742d4dc..15fa821d09c 100644
--- a/arch/alpha/kernel/alpha_ksyms.c
+++ b/arch/alpha/kernel/alpha_ksyms.c
@@ -52,7 +52,6 @@ EXPORT_SYMBOL(alpha_write_fp_reg_s);
52 52
53/* entry.S */ 53/* entry.S */
54EXPORT_SYMBOL(kernel_thread); 54EXPORT_SYMBOL(kernel_thread);
55EXPORT_SYMBOL(kernel_execve);
56 55
57/* Networking helper routines. */ 56/* Networking helper routines. */
58EXPORT_SYMBOL(csum_tcpudp_magic); 57EXPORT_SYMBOL(csum_tcpudp_magic);
@@ -74,8 +73,6 @@ EXPORT_SYMBOL(alpha_fp_emul);
74 */ 73 */
75EXPORT_SYMBOL(__copy_user); 74EXPORT_SYMBOL(__copy_user);
76EXPORT_SYMBOL(__do_clear_user); 75EXPORT_SYMBOL(__do_clear_user);
77EXPORT_SYMBOL(__strncpy_from_user);
78EXPORT_SYMBOL(__strnlen_user);
79 76
80/* 77/*
81 * SMP-specific symbols. 78 * SMP-specific symbols.
diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S
index 6d159cee5f2..ec0da0567ab 100644
--- a/arch/alpha/kernel/entry.S
+++ b/arch/alpha/kernel/entry.S
@@ -663,58 +663,6 @@ kernel_thread:
663 br ret_to_kernel 663 br ret_to_kernel
664.end kernel_thread 664.end kernel_thread
665 665
666/*
667 * kernel_execve(path, argv, envp)
668 */
669 .align 4
670 .globl kernel_execve
671 .ent kernel_execve
672kernel_execve:
673 /* We can be called from a module. */
674 ldgp $gp, 0($27)
675 lda $sp, -(32+SIZEOF_PT_REGS+8)($sp)
676 .frame $sp, 32+SIZEOF_PT_REGS+8, $26, 0
677 stq $26, 0($sp)
678 stq $16, 8($sp)
679 stq $17, 16($sp)
680 stq $18, 24($sp)
681 .prologue 1
682
683 lda $16, 32($sp)
684 lda $17, 0
685 lda $18, SIZEOF_PT_REGS
686 bsr $26, memset !samegp
687
688 /* Avoid the HAE being gratuitously wrong, which would cause us
689 to do the whole turn off interrupts thing and restore it. */
690 ldq $2, alpha_mv+HAE_CACHE
691 stq $2, 152+32($sp)
692
693 ldq $16, 8($sp)
694 ldq $17, 16($sp)
695 ldq $18, 24($sp)
696 lda $19, 32($sp)
697 bsr $26, do_execve !samegp
698
699 ldq $26, 0($sp)
700 bne $0, 1f /* error! */
701
702 /* Move the temporary pt_regs struct from its current location
703 to the top of the kernel stack frame. See copy_thread for
704 details for a normal process. */
705 lda $16, 0x4000 - SIZEOF_PT_REGS($8)
706 lda $17, 32($sp)
707 lda $18, SIZEOF_PT_REGS
708 bsr $26, memmove !samegp
709
710 /* Take that over as our new stack frame and visit userland! */
711 lda $sp, 0x4000 - SIZEOF_PT_REGS($8)
712 br $31, ret_from_sys_call
713
7141: lda $sp, 32+SIZEOF_PT_REGS+8($sp)
715 ret
716.end kernel_execve
717
718 666
719/* 667/*
720 * Special system calls. Most of these are special in that they either 668 * Special system calls. Most of these are special in that they either
@@ -797,115 +745,6 @@ sys_rt_sigreturn:
797.end sys_rt_sigreturn 745.end sys_rt_sigreturn
798 746
799 .align 4 747 .align 4
800 .globl sys_sethae
801 .ent sys_sethae
802sys_sethae:
803 .prologue 0
804 stq $16, 152($sp)
805 ret
806.end sys_sethae
807
808 .align 4
809 .globl osf_getpriority
810 .ent osf_getpriority
811osf_getpriority:
812 lda $sp, -16($sp)
813 stq $26, 0($sp)
814 .prologue 0
815
816 jsr $26, sys_getpriority
817
818 ldq $26, 0($sp)
819 blt $0, 1f
820
821 /* Return value is the unbiased priority, i.e. 20 - prio.
822 This does result in negative return values, so signal
823 no error by writing into the R0 slot. */
824 lda $1, 20
825 stq $31, 16($sp)
826 subl $1, $0, $0
827 unop
828
8291: lda $sp, 16($sp)
830 ret
831.end osf_getpriority
832
833 .align 4
834 .globl sys_getxuid
835 .ent sys_getxuid
836sys_getxuid:
837 .prologue 0
838 ldq $2, TI_TASK($8)
839 ldq $3, TASK_CRED($2)
840 ldl $0, CRED_UID($3)
841 ldl $1, CRED_EUID($3)
842 stq $1, 80($sp)
843 ret
844.end sys_getxuid
845
846 .align 4
847 .globl sys_getxgid
848 .ent sys_getxgid
849sys_getxgid:
850 .prologue 0
851 ldq $2, TI_TASK($8)
852 ldq $3, TASK_CRED($2)
853 ldl $0, CRED_GID($3)
854 ldl $1, CRED_EGID($3)
855 stq $1, 80($sp)
856 ret
857.end sys_getxgid
858
859 .align 4
860 .globl sys_getxpid
861 .ent sys_getxpid
862sys_getxpid:
863 .prologue 0
864 ldq $2, TI_TASK($8)
865
866 /* See linux/kernel/timer.c sys_getppid for discussion
867 about this loop. */
868 ldq $3, TASK_GROUP_LEADER($2)
869 ldq $4, TASK_REAL_PARENT($3)
870 ldl $0, TASK_TGID($2)
8711: ldl $1, TASK_TGID($4)
872#ifdef CONFIG_SMP
873 mov $4, $5
874 mb
875 ldq $3, TASK_GROUP_LEADER($2)
876 ldq $4, TASK_REAL_PARENT($3)
877 cmpeq $4, $5, $5
878 beq $5, 1b
879#endif
880 stq $1, 80($sp)
881 ret
882.end sys_getxpid
883
884 .align 4
885 .globl sys_alpha_pipe
886 .ent sys_alpha_pipe
887sys_alpha_pipe:
888 lda $sp, -16($sp)
889 stq $26, 0($sp)
890 .prologue 0
891
892 mov $31, $17
893 lda $16, 8($sp)
894 jsr $26, do_pipe_flags
895
896 ldq $26, 0($sp)
897 bne $0, 1f
898
899 /* The return values are in $0 and $20. */
900 ldl $1, 12($sp)
901 ldl $0, 8($sp)
902
903 stq $1, 80+16($sp)
9041: lda $sp, 16($sp)
905 ret
906.end sys_alpha_pipe
907
908 .align 4
909 .globl sys_execve 748 .globl sys_execve
910 .ent sys_execve 749 .ent sys_execve
911sys_execve: 750sys_execve:
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 98a103621af..bc1acdda7a5 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -1404,3 +1404,52 @@ SYSCALL_DEFINE3(osf_writev, unsigned long, fd,
1404} 1404}
1405 1405
1406#endif 1406#endif
1407
1408SYSCALL_DEFINE2(osf_getpriority, int, which, int, who)
1409{
1410 int prio = sys_getpriority(which, who);
1411 if (prio >= 0) {
1412 /* Return value is the unbiased priority, i.e. 20 - prio.
1413 This does result in negative return values, so signal
1414 no error */
1415 force_successful_syscall_return();
1416 prio = 20 - prio;
1417 }
1418 return prio;
1419}
1420
1421SYSCALL_DEFINE0(getxuid)
1422{
1423 current_pt_regs()->r20 = sys_geteuid();
1424 return sys_getuid();
1425}
1426
1427SYSCALL_DEFINE0(getxgid)
1428{
1429 current_pt_regs()->r20 = sys_getegid();
1430 return sys_getgid();
1431}
1432
1433SYSCALL_DEFINE0(getxpid)
1434{
1435 current_pt_regs()->r20 = sys_getppid();
1436 return sys_getpid();
1437}
1438
1439SYSCALL_DEFINE0(alpha_pipe)
1440{
1441 int fd[2];
1442 int res = do_pipe_flags(fd, 0);
1443 if (!res) {
1444 /* The return values are in $0 and $20. */
1445 current_pt_regs()->r20 = fd[1];
1446 res = fd[0];
1447 }
1448 return res;
1449}
1450
1451SYSCALL_DEFINE1(sethae, unsigned long, val)
1452{
1453 current_pt_regs()->hae = val;
1454 return 0;
1455}
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 1a629636cc1..9816d5a4d17 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -59,15 +59,13 @@ struct pci_controller *pci_isa_hose;
59 * Quirks. 59 * Quirks.
60 */ 60 */
61 61
62static void __init 62static void __devinit quirk_isa_bridge(struct pci_dev *dev)
63quirk_isa_bridge(struct pci_dev *dev)
64{ 63{
65 dev->class = PCI_CLASS_BRIDGE_ISA << 8; 64 dev->class = PCI_CLASS_BRIDGE_ISA << 8;
66} 65}
67DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82378, quirk_isa_bridge); 66DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82378, quirk_isa_bridge);
68 67
69static void __init 68static void __devinit quirk_cypress(struct pci_dev *dev)
70quirk_cypress(struct pci_dev *dev)
71{ 69{
72 /* The Notorious Cy82C693 chip. */ 70 /* The Notorious Cy82C693 chip. */
73 71
@@ -106,8 +104,7 @@ quirk_cypress(struct pci_dev *dev)
106DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693, quirk_cypress); 104DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693, quirk_cypress);
107 105
108/* Called for each device after PCI setup is done. */ 106/* Called for each device after PCI setup is done. */
109static void __init 107static void __devinit pcibios_fixup_final(struct pci_dev *dev)
110pcibios_fixup_final(struct pci_dev *dev)
111{ 108{
112 unsigned int class = dev->class >> 8; 109 unsigned int class = dev->class >> 8;
113 110
@@ -198,12 +195,6 @@ pcibios_init(void)
198 195
199subsys_initcall(pcibios_init); 196subsys_initcall(pcibios_init);
200 197
201char * __devinit
202pcibios_setup(char *str)
203{
204 return str;
205}
206
207#ifdef ALPHA_RESTORE_SRM_SETUP 198#ifdef ALPHA_RESTORE_SRM_SETUP
208static struct pdev_srm_saved_conf *srm_saved_configs; 199static struct pdev_srm_saved_conf *srm_saved_configs;
209 200
@@ -359,7 +350,7 @@ common_init_pci(void)
359 hose, &resources); 350 hose, &resources);
360 hose->bus = bus; 351 hose->bus = bus;
361 hose->need_domain_info = need_domain_info; 352 hose->need_domain_info = need_domain_info;
362 next_busno = bus->subordinate + 1; 353 next_busno = bus->busn_res.end + 1;
363 /* Don't allow 8-bit bus number overflow inside the hose - 354 /* Don't allow 8-bit bus number overflow inside the hose -
364 reserve some space for bridges. */ 355 reserve some space for bridges. */
365 if (next_busno > 224) { 356 if (next_busno > 224) {
diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index 153d3fce3e8..d6fde98b74b 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -455,3 +455,22 @@ get_wchan(struct task_struct *p)
455 } 455 }
456 return pc; 456 return pc;
457} 457}
458
459int kernel_execve(const char *path, const char *const argv[], const char *const envp[])
460{
461 /* Avoid the HAE being gratuitously wrong, which would cause us
462 to do the whole turn off interrupts thing and restore it. */
463 struct pt_regs regs = {.hae = alpha_mv.hae_cache};
464 int err = do_execve(path, argv, envp, &regs);
465 if (!err) {
466 struct pt_regs *p = current_pt_regs();
467 /* copy regs to normal position and off to userland we go... */
468 *p = regs;
469 __asm__ __volatile__ (
470 "mov %0, $sp;"
471 "br $31, ret_from_sys_call"
472 : : "r"(p));
473 }
474 return err;
475}
476EXPORT_SYMBOL(kernel_execve);
diff --git a/arch/alpha/kernel/smc37c669.c b/arch/alpha/kernel/smc37c669.c
index 0435921d41c..c803fc76ae4 100644
--- a/arch/alpha/kernel/smc37c669.c
+++ b/arch/alpha/kernel/smc37c669.c
@@ -933,18 +933,6 @@ void SMC37c669_display_device_info(
933 * 933 *
934 *-- 934 *--
935 */ 935 */
936#if 0
937/* $INCLUDE_OPTIONS$ */
938#include "cp$inc:platform_io.h"
939/* $INCLUDE_OPTIONS_END$ */
940#include "cp$src:common.h"
941#include "cp$inc:prototypes.h"
942#include "cp$src:kernel_def.h"
943#include "cp$src:msg_def.h"
944#include "cp$src:smcc669_def.h"
945/* Platform-specific includes */
946#include "cp$src:platform.h"
947#endif
948 936
949#ifndef TRUE 937#ifndef TRUE
950#define TRUE 1 938#define TRUE 1
diff --git a/arch/alpha/kernel/systbls.S b/arch/alpha/kernel/systbls.S
index 87835235f11..2ac6b45c3e0 100644
--- a/arch/alpha/kernel/systbls.S
+++ b/arch/alpha/kernel/systbls.S
@@ -111,7 +111,7 @@ sys_call_table:
111 .quad sys_socket 111 .quad sys_socket
112 .quad sys_connect 112 .quad sys_connect
113 .quad sys_accept 113 .quad sys_accept
114 .quad osf_getpriority /* 100 */ 114 .quad sys_osf_getpriority /* 100 */
115 .quad sys_send 115 .quad sys_send
116 .quad sys_recv 116 .quad sys_recv
117 .quad sys_sigreturn 117 .quad sys_sigreturn
@@ -522,6 +522,8 @@ sys_call_table:
522 .quad sys_setns 522 .quad sys_setns
523 .quad sys_accept4 523 .quad sys_accept4
524 .quad sys_sendmmsg 524 .quad sys_sendmmsg
525 .quad sys_process_vm_readv
526 .quad sys_process_vm_writev /* 505 */
525 527
526 .size sys_call_table, . - sys_call_table 528 .size sys_call_table, . - sys_call_table
527 .type sys_call_table, @object 529 .type sys_call_table, @object
diff --git a/arch/alpha/lib/Makefile b/arch/alpha/lib/Makefile
index c0a83ab62b7..59660743237 100644
--- a/arch/alpha/lib/Makefile
+++ b/arch/alpha/lib/Makefile
@@ -31,8 +31,6 @@ lib-y = __divqu.o __remqu.o __divlu.o __remlu.o \
31 $(ev6-y)memchr.o \ 31 $(ev6-y)memchr.o \
32 $(ev6-y)copy_user.o \ 32 $(ev6-y)copy_user.o \
33 $(ev6-y)clear_user.o \ 33 $(ev6-y)clear_user.o \
34 $(ev6-y)strncpy_from_user.o \
35 $(ev67-y)strlen_user.o \
36 $(ev6-y)csum_ipv6_magic.o \ 34 $(ev6-y)csum_ipv6_magic.o \
37 $(ev6-y)clear_page.o \ 35 $(ev6-y)clear_page.o \
38 $(ev6-y)copy_page.o \ 36 $(ev6-y)copy_page.o \
diff --git a/arch/alpha/lib/ev6-strncpy_from_user.S b/arch/alpha/lib/ev6-strncpy_from_user.S
deleted file mode 100644
index d2e28178cac..00000000000
--- a/arch/alpha/lib/ev6-strncpy_from_user.S
+++ /dev/null
@@ -1,424 +0,0 @@
1/*
2 * arch/alpha/lib/ev6-strncpy_from_user.S
3 * 21264 version contributed by Rick Gorton <rick.gorton@alpha-processor.com>
4 *
5 * Just like strncpy except in the return value:
6 *
7 * -EFAULT if an exception occurs before the terminator is copied.
8 * N if the buffer filled.
9 *
10 * Otherwise the length of the string is returned.
11 *
12 * Much of the information about 21264 scheduling/coding comes from:
13 * Compiler Writer's Guide for the Alpha 21264
14 * abbreviated as 'CWG' in other comments here
15 * ftp.digital.com/pub/Digital/info/semiconductor/literature/dsc-library.html
16 * Scheduling notation:
17 * E - either cluster
18 * U - upper subcluster; U0 - subcluster U0; U1 - subcluster U1
19 * L - lower subcluster; L0 - subcluster L0; L1 - subcluster L1
20 * A bunch of instructions got moved and temp registers were changed
21 * to aid in scheduling. Control flow was also re-arranged to eliminate
22 * branches, and to provide longer code sequences to enable better scheduling.
23 * A total rewrite (using byte load/stores for start & tail sequences)
24 * is desirable, but very difficult to do without a from-scratch rewrite.
25 * Save that for the future.
26 */
27
28
29#include <asm/errno.h>
30#include <asm/regdef.h>
31
32
33/* Allow an exception for an insn; exit if we get one. */
34#define EX(x,y...) \
35 99: x,##y; \
36 .section __ex_table,"a"; \
37 .long 99b - .; \
38 lda $31, $exception-99b($0); \
39 .previous
40
41
42 .set noat
43 .set noreorder
44 .text
45
46 .globl __strncpy_from_user
47 .ent __strncpy_from_user
48 .frame $30, 0, $26
49 .prologue 0
50
51 .align 4
52__strncpy_from_user:
53 and a0, 7, t3 # E : find dest misalignment
54 beq a2, $zerolength # U :
55
56 /* Are source and destination co-aligned? */
57 mov a0, v0 # E : save the string start
58 xor a0, a1, t4 # E :
59 EX( ldq_u t1, 0(a1) ) # L : Latency=3 load first quadword
60 ldq_u t0, 0(a0) # L : load first (partial) aligned dest quadword
61
62 addq a2, t3, a2 # E : bias count by dest misalignment
63 subq a2, 1, a3 # E :
64 addq zero, 1, t10 # E :
65 and t4, 7, t4 # E : misalignment between the two
66
67 and a3, 7, t6 # E : number of tail bytes
68 sll t10, t6, t10 # E : t10 = bitmask of last count byte
69 bne t4, $unaligned # U :
70 lda t2, -1 # E : build a mask against false zero
71
72 /*
73 * We are co-aligned; take care of a partial first word.
74 * On entry to this basic block:
75 * t0 == the first destination word for masking back in
76 * t1 == the first source word.
77 */
78
79 srl a3, 3, a2 # E : a2 = loop counter = (count - 1)/8
80 addq a1, 8, a1 # E :
81 mskqh t2, a1, t2 # U : detection in the src word
82 nop
83
84 /* Create the 1st output word and detect 0's in the 1st input word. */
85 mskqh t1, a1, t3 # U :
86 mskql t0, a1, t0 # U : assemble the first output word
87 ornot t1, t2, t2 # E :
88 nop
89
90 cmpbge zero, t2, t8 # E : bits set iff null found
91 or t0, t3, t0 # E :
92 beq a2, $a_eoc # U :
93 bne t8, $a_eos # U : 2nd branch in a quad. Bad.
94
95 /* On entry to this basic block:
96 * t0 == a source quad not containing a null.
97 * a0 - current aligned destination address
98 * a1 - current aligned source address
99 * a2 - count of quadwords to move.
100 * NOTE: Loop improvement - unrolling this is going to be
101 * a huge win, since we're going to stall otherwise.
102 * Fix this later. For _really_ large copies, look
103 * at using wh64 on a look-ahead basis. See the code
104 * in clear_user.S and copy_user.S.
105 * Presumably, since (a0) and (a1) do not overlap (by C definition)
106 * Lots of nops here:
107 * - Separate loads from stores
108 * - Keep it to 1 branch/quadpack so the branch predictor
109 * can train.
110 */
111$a_loop:
112 stq_u t0, 0(a0) # L :
113 addq a0, 8, a0 # E :
114 nop
115 subq a2, 1, a2 # E :
116
117 EX( ldq_u t0, 0(a1) ) # L :
118 addq a1, 8, a1 # E :
119 cmpbge zero, t0, t8 # E : Stall 2 cycles on t0
120 beq a2, $a_eoc # U :
121
122 beq t8, $a_loop # U :
123 nop
124 nop
125 nop
126
127 /* Take care of the final (partial) word store. At this point
128 * the end-of-count bit is set in t8 iff it applies.
129 *
130 * On entry to this basic block we have:
131 * t0 == the source word containing the null
132 * t8 == the cmpbge mask that found it.
133 */
134$a_eos:
135 negq t8, t12 # E : find low bit set
136 and t8, t12, t12 # E :
137
138 /* We're doing a partial word store and so need to combine
139 our source and original destination words. */
140 ldq_u t1, 0(a0) # L :
141 subq t12, 1, t6 # E :
142
143 or t12, t6, t8 # E :
144 zapnot t0, t8, t0 # U : clear src bytes > null
145 zap t1, t8, t1 # U : clear dst bytes <= null
146 or t0, t1, t0 # E :
147
148 stq_u t0, 0(a0) # L :
149 br $finish_up # L0 :
150 nop
151 nop
152
153 /* Add the end-of-count bit to the eos detection bitmask. */
154 .align 4
155$a_eoc:
156 or t10, t8, t8
157 br $a_eos
158 nop
159 nop
160
161
162/* The source and destination are not co-aligned. Align the destination
163 and cope. We have to be very careful about not reading too much and
164 causing a SEGV. */
165
166 .align 4
167$u_head:
168 /* We know just enough now to be able to assemble the first
169 full source word. We can still find a zero at the end of it
170 that prevents us from outputting the whole thing.
171
172 On entry to this basic block:
173 t0 == the first dest word, unmasked
174 t1 == the shifted low bits of the first source word
175 t6 == bytemask that is -1 in dest word bytes */
176
177 EX( ldq_u t2, 8(a1) ) # L : load second src word
178 addq a1, 8, a1 # E :
179 mskql t0, a0, t0 # U : mask trailing garbage in dst
180 extqh t2, a1, t4 # U :
181
182 or t1, t4, t1 # E : first aligned src word complete
183 mskqh t1, a0, t1 # U : mask leading garbage in src
184 or t0, t1, t0 # E : first output word complete
185 or t0, t6, t6 # E : mask original data for zero test
186
187 cmpbge zero, t6, t8 # E :
188 beq a2, $u_eocfin # U :
189 bne t8, $u_final # U : bad news - 2nd branch in a quad
190 lda t6, -1 # E : mask out the bits we have
191
192 mskql t6, a1, t6 # U : already seen
193 stq_u t0, 0(a0) # L : store first output word
194 or t6, t2, t2 # E :
195 cmpbge zero, t2, t8 # E : find nulls in second partial
196
197 addq a0, 8, a0 # E :
198 subq a2, 1, a2 # E :
199 bne t8, $u_late_head_exit # U :
200 nop
201
202 /* Finally, we've got all the stupid leading edge cases taken care
203 of and we can set up to enter the main loop. */
204
205 extql t2, a1, t1 # U : position hi-bits of lo word
206 EX( ldq_u t2, 8(a1) ) # L : read next high-order source word
207 addq a1, 8, a1 # E :
208 cmpbge zero, t2, t8 # E :
209
210 beq a2, $u_eoc # U :
211 bne t8, $u_eos # U :
212 nop
213 nop
214
215 /* Unaligned copy main loop. In order to avoid reading too much,
216 the loop is structured to detect zeros in aligned source words.
217 This has, unfortunately, effectively pulled half of a loop
218 iteration out into the head and half into the tail, but it does
219 prevent nastiness from accumulating in the very thing we want
220 to run as fast as possible.
221
222 On entry to this basic block:
223 t1 == the shifted high-order bits from the previous source word
224 t2 == the unshifted current source word
225
226 We further know that t2 does not contain a null terminator. */
227
228 /*
229 * Extra nops here:
230 * separate load quads from store quads
231 * only one branch/quad to permit predictor training
232 */
233
234 .align 4
235$u_loop:
236 extqh t2, a1, t0 # U : extract high bits for current word
237 addq a1, 8, a1 # E :
238 extql t2, a1, t3 # U : extract low bits for next time
239 addq a0, 8, a0 # E :
240
241 or t0, t1, t0 # E : current dst word now complete
242 EX( ldq_u t2, 0(a1) ) # L : load high word for next time
243 subq a2, 1, a2 # E :
244 nop
245
246 stq_u t0, -8(a0) # L : save the current word
247 mov t3, t1 # E :
248 cmpbge zero, t2, t8 # E : test new word for eos
249 beq a2, $u_eoc # U :
250
251 beq t8, $u_loop # U :
252 nop
253 nop
254 nop
255
256 /* We've found a zero somewhere in the source word we just read.
257 If it resides in the lower half, we have one (probably partial)
258 word to write out, and if it resides in the upper half, we
259 have one full and one partial word left to write out.
260
261 On entry to this basic block:
262 t1 == the shifted high-order bits from the previous source word
263 t2 == the unshifted current source word. */
264 .align 4
265$u_eos:
266 extqh t2, a1, t0 # U :
267 or t0, t1, t0 # E : first (partial) source word complete
268 cmpbge zero, t0, t8 # E : is the null in this first bit?
269 nop
270
271 bne t8, $u_final # U :
272 stq_u t0, 0(a0) # L : the null was in the high-order bits
273 addq a0, 8, a0 # E :
274 subq a2, 1, a2 # E :
275
276 .align 4
277$u_late_head_exit:
278 extql t2, a1, t0 # U :
279 cmpbge zero, t0, t8 # E :
280 or t8, t10, t6 # E :
281 cmoveq a2, t6, t8 # E :
282
283 /* Take care of a final (probably partial) result word.
284 On entry to this basic block:
285 t0 == assembled source word
286 t8 == cmpbge mask that found the null. */
287 .align 4
288$u_final:
289 negq t8, t6 # E : isolate low bit set
290 and t6, t8, t12 # E :
291 ldq_u t1, 0(a0) # L :
292 subq t12, 1, t6 # E :
293
294 or t6, t12, t8 # E :
295 zapnot t0, t8, t0 # U : kill source bytes > null
296 zap t1, t8, t1 # U : kill dest bytes <= null
297 or t0, t1, t0 # E :
298
299 stq_u t0, 0(a0) # E :
300 br $finish_up # U :
301 nop
302 nop
303
304 .align 4
305$u_eoc: # end-of-count
306 extqh t2, a1, t0 # U :
307 or t0, t1, t0 # E :
308 cmpbge zero, t0, t8 # E :
309 nop
310
311 .align 4
312$u_eocfin: # end-of-count, final word
313 or t10, t8, t8 # E :
314 br $u_final # U :
315 nop
316 nop
317
318 /* Unaligned copy entry point. */
319 .align 4
320$unaligned:
321
322 srl a3, 3, a2 # U : a2 = loop counter = (count - 1)/8
323 and a0, 7, t4 # E : find dest misalignment
324 and a1, 7, t5 # E : find src misalignment
325 mov zero, t0 # E :
326
327 /* Conditionally load the first destination word and a bytemask
328 with 0xff indicating that the destination byte is sacrosanct. */
329
330 mov zero, t6 # E :
331 beq t4, 1f # U :
332 ldq_u t0, 0(a0) # L :
333 lda t6, -1 # E :
334
335 mskql t6, a0, t6 # E :
336 nop
337 nop
338 nop
339
340 .align 4
3411:
342 subq a1, t4, a1 # E : sub dest misalignment from src addr
343 /* If source misalignment is larger than dest misalignment, we need
344 extra startup checks to avoid SEGV. */
345 cmplt t4, t5, t12 # E :
346 extql t1, a1, t1 # U : shift src into place
347 lda t2, -1 # E : for creating masks later
348
349 beq t12, $u_head # U :
350 mskqh t2, t5, t2 # U : begin src byte validity mask
351 cmpbge zero, t1, t8 # E : is there a zero?
352 nop
353
354 extql t2, a1, t2 # U :
355 or t8, t10, t5 # E : test for end-of-count too
356 cmpbge zero, t2, t3 # E :
357 cmoveq a2, t5, t8 # E : Latency=2, extra map slot
358
359 nop # E : goes with cmov
360 andnot t8, t3, t8 # E :
361 beq t8, $u_head # U :
362 nop
363
364 /* At this point we've found a zero in the first partial word of
365 the source. We need to isolate the valid source data and mask
366 it into the original destination data. (Incidentally, we know
367 that we'll need at least one byte of that original dest word.) */
368
369 ldq_u t0, 0(a0) # L :
370 negq t8, t6 # E : build bitmask of bytes <= zero
371 mskqh t1, t4, t1 # U :
372 and t6, t8, t12 # E :
373
374 subq t12, 1, t6 # E :
375 or t6, t12, t8 # E :
376 zapnot t2, t8, t2 # U : prepare source word; mirror changes
377 zapnot t1, t8, t1 # U : to source validity mask
378
379 andnot t0, t2, t0 # E : zero place for source to reside
380 or t0, t1, t0 # E : and put it there
381 stq_u t0, 0(a0) # L :
382 nop
383
384 .align 4
385$finish_up:
386 zapnot t0, t12, t4 # U : was last byte written null?
387 and t12, 0xf0, t3 # E : binary search for the address of the
388 cmovne t4, 1, t4 # E : Latency=2, extra map slot
389 nop # E : with cmovne
390
391 and t12, 0xcc, t2 # E : last byte written
392 and t12, 0xaa, t1 # E :
393 cmovne t3, 4, t3 # E : Latency=2, extra map slot
394 nop # E : with cmovne
395
396 bic a0, 7, t0
397 cmovne t2, 2, t2 # E : Latency=2, extra map slot
398 nop # E : with cmovne
399 nop
400
401 cmovne t1, 1, t1 # E : Latency=2, extra map slot
402 nop # E : with cmovne
403 addq t0, t3, t0 # E :
404 addq t1, t2, t1 # E :
405
406 addq t0, t1, t0 # E :
407 addq t0, t4, t0 # add one if we filled the buffer
408 subq t0, v0, v0 # find string length
409 ret # L0 :
410
411 .align 4
412$zerolength:
413 nop
414 nop
415 nop
416 clr v0
417
418$exception:
419 nop
420 nop
421 nop
422 ret
423
424 .end __strncpy_from_user
diff --git a/arch/alpha/lib/ev67-strlen_user.S b/arch/alpha/lib/ev67-strlen_user.S
deleted file mode 100644
index 57e0d77b81a..00000000000
--- a/arch/alpha/lib/ev67-strlen_user.S
+++ /dev/null
@@ -1,107 +0,0 @@
1/*
2 * arch/alpha/lib/ev67-strlen_user.S
3 * 21264 version contributed by Rick Gorton <rick.gorton@api-networks.com>
4 *
5 * Return the length of the string including the NULL terminator
6 * (strlen+1) or zero if an error occurred.
7 *
8 * In places where it is critical to limit the processing time,
9 * and the data is not trusted, strnlen_user() should be used.
10 * It will return a value greater than its second argument if
11 * that limit would be exceeded. This implementation is allowed
12 * to access memory beyond the limit, but will not cross a page
13 * boundary when doing so.
14 *
15 * Much of the information about 21264 scheduling/coding comes from:
16 * Compiler Writer's Guide for the Alpha 21264
17 * abbreviated as 'CWG' in other comments here
18 * ftp.digital.com/pub/Digital/info/semiconductor/literature/dsc-library.html
19 * Scheduling notation:
20 * E - either cluster
21 * U - upper subcluster; U0 - subcluster U0; U1 - subcluster U1
22 * L - lower subcluster; L0 - subcluster L0; L1 - subcluster L1
23 * Try not to change the actual algorithm if possible for consistency.
24 */
25
26#include <asm/regdef.h>
27
28
29/* Allow an exception for an insn; exit if we get one. */
30#define EX(x,y...) \
31 99: x,##y; \
32 .section __ex_table,"a"; \
33 .long 99b - .; \
34 lda v0, $exception-99b(zero); \
35 .previous
36
37
38 .set noreorder
39 .set noat
40 .text
41
42 .globl __strlen_user
43 .ent __strlen_user
44 .frame sp, 0, ra
45
46 .align 4
47__strlen_user:
48 ldah a1, 32767(zero) # do not use plain strlen_user() for strings
49 # that might be almost 2 GB long; you should
50 # be using strnlen_user() instead
51 nop
52 nop
53 nop
54
55 .globl __strnlen_user
56
57 .align 4
58__strnlen_user:
59 .prologue 0
60 EX( ldq_u t0, 0(a0) ) # L : load first quadword (a0 may be misaligned)
61 lda t1, -1(zero) # E :
62
63 insqh t1, a0, t1 # U :
64 andnot a0, 7, v0 # E :
65 or t1, t0, t0 # E :
66 subq a0, 1, a0 # E : get our +1 for the return
67
68 cmpbge zero, t0, t1 # E : t1 <- bitmask: bit i == 1 <==> i-th byte == 0
69 subq a1, 7, t2 # E :
70 subq a0, v0, t0 # E :
71 bne t1, $found # U :
72
73 addq t2, t0, t2 # E :
74 addq a1, 1, a1 # E :
75 nop # E :
76 nop # E :
77
78 .align 4
79$loop: ble t2, $limit # U :
80 EX( ldq t0, 8(v0) ) # L :
81 nop # E :
82 nop # E :
83
84 cmpbge zero, t0, t1 # E :
85 subq t2, 8, t2 # E :
86 addq v0, 8, v0 # E : addr += 8
87 beq t1, $loop # U :
88
89$found: cttz t1, t2 # U0 :
90 addq v0, t2, v0 # E :
91 subq v0, a0, v0 # E :
92 ret # L0 :
93
94$exception:
95 nop
96 nop
97 nop
98 ret
99
100 .align 4 # currently redundant
101$limit:
102 nop
103 nop
104 subq a1, t2, v0
105 ret
106
107 .end __strlen_user
diff --git a/arch/alpha/lib/strlen_user.S b/arch/alpha/lib/strlen_user.S
deleted file mode 100644
index 508a18e9647..00000000000
--- a/arch/alpha/lib/strlen_user.S
+++ /dev/null
@@ -1,91 +0,0 @@
1/*
2 * arch/alpha/lib/strlen_user.S
3 *
4 * Return the length of the string including the NUL terminator
5 * (strlen+1) or zero if an error occurred.
6 *
7 * In places where it is critical to limit the processing time,
8 * and the data is not trusted, strnlen_user() should be used.
9 * It will return a value greater than its second argument if
10 * that limit would be exceeded. This implementation is allowed
11 * to access memory beyond the limit, but will not cross a page
12 * boundary when doing so.
13 */
14
15#include <asm/regdef.h>
16
17
18/* Allow an exception for an insn; exit if we get one. */
19#define EX(x,y...) \
20 99: x,##y; \
21 .section __ex_table,"a"; \
22 .long 99b - .; \
23 lda v0, $exception-99b(zero); \
24 .previous
25
26
27 .set noreorder
28 .set noat
29 .text
30
31 .globl __strlen_user
32 .ent __strlen_user
33 .frame sp, 0, ra
34
35 .align 3
36__strlen_user:
37 ldah a1, 32767(zero) # do not use plain strlen_user() for strings
38 # that might be almost 2 GB long; you should
39 # be using strnlen_user() instead
40
41 .globl __strnlen_user
42
43 .align 3
44__strnlen_user:
45 .prologue 0
46
47 EX( ldq_u t0, 0(a0) ) # load first quadword (a0 may be misaligned)
48 lda t1, -1(zero)
49 insqh t1, a0, t1
50 andnot a0, 7, v0
51 or t1, t0, t0
52 subq a0, 1, a0 # get our +1 for the return
53 cmpbge zero, t0, t1 # t1 <- bitmask: bit i == 1 <==> i-th byte == 0
54 subq a1, 7, t2
55 subq a0, v0, t0
56 bne t1, $found
57
58 addq t2, t0, t2
59 addq a1, 1, a1
60
61 .align 3
62$loop: ble t2, $limit
63 EX( ldq t0, 8(v0) )
64 subq t2, 8, t2
65 addq v0, 8, v0 # addr += 8
66 cmpbge zero, t0, t1
67 beq t1, $loop
68
69$found: negq t1, t2 # clear all but least set bit
70 and t1, t2, t1
71
72 and t1, 0xf0, t2 # binary search for that set bit
73 and t1, 0xcc, t3
74 and t1, 0xaa, t4
75 cmovne t2, 4, t2
76 cmovne t3, 2, t3
77 cmovne t4, 1, t4
78 addq t2, t3, t2
79 addq v0, t4, v0
80 addq v0, t2, v0
81 nop # dual issue next two on ev4 and ev5
82 subq v0, a0, v0
83$exception:
84 ret
85
86 .align 3 # currently redundant
87$limit:
88 subq a1, t2, v0
89 ret
90
91 .end __strlen_user
diff --git a/arch/alpha/lib/strncpy_from_user.S b/arch/alpha/lib/strncpy_from_user.S
deleted file mode 100644
index 73ee21160ff..00000000000
--- a/arch/alpha/lib/strncpy_from_user.S
+++ /dev/null
@@ -1,339 +0,0 @@
1/*
2 * arch/alpha/lib/strncpy_from_user.S
3 * Contributed by Richard Henderson (rth@tamu.edu)
4 *
5 * Just like strncpy except in the return value:
6 *
7 * -EFAULT if an exception occurs before the terminator is copied.
8 * N if the buffer filled.
9 *
10 * Otherwise the length of the string is returned.
11 */
12
13
14#include <asm/errno.h>
15#include <asm/regdef.h>
16
17
18/* Allow an exception for an insn; exit if we get one. */
19#define EX(x,y...) \
20 99: x,##y; \
21 .section __ex_table,"a"; \
22 .long 99b - .; \
23 lda $31, $exception-99b($0); \
24 .previous
25
26
27 .set noat
28 .set noreorder
29 .text
30
31 .globl __strncpy_from_user
32 .ent __strncpy_from_user
33 .frame $30, 0, $26
34 .prologue 0
35
36 .align 3
37$aligned:
38 /* On entry to this basic block:
39 t0 == the first destination word for masking back in
40 t1 == the first source word. */
41
42 /* Create the 1st output word and detect 0's in the 1st input word. */
43 lda t2, -1 # e1 : build a mask against false zero
44 mskqh t2, a1, t2 # e0 : detection in the src word
45 mskqh t1, a1, t3 # e0 :
46 ornot t1, t2, t2 # .. e1 :
47 mskql t0, a1, t0 # e0 : assemble the first output word
48 cmpbge zero, t2, t8 # .. e1 : bits set iff null found
49 or t0, t3, t0 # e0 :
50 beq a2, $a_eoc # .. e1 :
51 bne t8, $a_eos # .. e1 :
52
53 /* On entry to this basic block:
54 t0 == a source word not containing a null. */
55
56$a_loop:
57 stq_u t0, 0(a0) # e0 :
58 addq a0, 8, a0 # .. e1 :
59 EX( ldq_u t0, 0(a1) ) # e0 :
60 addq a1, 8, a1 # .. e1 :
61 subq a2, 1, a2 # e0 :
62 cmpbge zero, t0, t8 # .. e1 (stall)
63 beq a2, $a_eoc # e1 :
64 beq t8, $a_loop # e1 :
65
66 /* Take care of the final (partial) word store. At this point
67 the end-of-count bit is set in t8 iff it applies.
68
69 On entry to this basic block we have:
70 t0 == the source word containing the null
71 t8 == the cmpbge mask that found it. */
72
73$a_eos:
74 negq t8, t12 # e0 : find low bit set
75 and t8, t12, t12 # e1 (stall)
76
77 /* For the sake of the cache, don't read a destination word
78 if we're not going to need it. */
79 and t12, 0x80, t6 # e0 :
80 bne t6, 1f # .. e1 (zdb)
81
82 /* We're doing a partial word store and so need to combine
83 our source and original destination words. */
84 ldq_u t1, 0(a0) # e0 :
85 subq t12, 1, t6 # .. e1 :
86 or t12, t6, t8 # e0 :
87 unop #
88 zapnot t0, t8, t0 # e0 : clear src bytes > null
89 zap t1, t8, t1 # .. e1 : clear dst bytes <= null
90 or t0, t1, t0 # e1 :
91
921: stq_u t0, 0(a0)
93 br $finish_up
94
95 /* Add the end-of-count bit to the eos detection bitmask. */
96$a_eoc:
97 or t10, t8, t8
98 br $a_eos
99
100 /*** The Function Entry Point ***/
101 .align 3
102__strncpy_from_user:
103 mov a0, v0 # save the string start
104 beq a2, $zerolength
105
106 /* Are source and destination co-aligned? */
107 xor a0, a1, t1 # e0 :
108 and a0, 7, t0 # .. e1 : find dest misalignment
109 and t1, 7, t1 # e0 :
110 addq a2, t0, a2 # .. e1 : bias count by dest misalignment
111 subq a2, 1, a2 # e0 :
112 and a2, 7, t2 # e1 :
113 srl a2, 3, a2 # e0 : a2 = loop counter = (count - 1)/8
114 addq zero, 1, t10 # .. e1 :
115 sll t10, t2, t10 # e0 : t10 = bitmask of last count byte
116 bne t1, $unaligned # .. e1 :
117
118 /* We are co-aligned; take care of a partial first word. */
119
120 EX( ldq_u t1, 0(a1) ) # e0 : load first src word
121 addq a1, 8, a1 # .. e1 :
122
123 beq t0, $aligned # avoid loading dest word if not needed
124 ldq_u t0, 0(a0) # e0 :
125 br $aligned # .. e1 :
126
127
128/* The source and destination are not co-aligned. Align the destination
129 and cope. We have to be very careful about not reading too much and
130 causing a SEGV. */
131
132 .align 3
133$u_head:
134 /* We know just enough now to be able to assemble the first
135 full source word. We can still find a zero at the end of it
136 that prevents us from outputting the whole thing.
137
138 On entry to this basic block:
139 t0 == the first dest word, unmasked
140 t1 == the shifted low bits of the first source word
141 t6 == bytemask that is -1 in dest word bytes */
142
143 EX( ldq_u t2, 8(a1) ) # e0 : load second src word
144 addq a1, 8, a1 # .. e1 :
145 mskql t0, a0, t0 # e0 : mask trailing garbage in dst
146 extqh t2, a1, t4 # e0 :
147 or t1, t4, t1 # e1 : first aligned src word complete
148 mskqh t1, a0, t1 # e0 : mask leading garbage in src
149 or t0, t1, t0 # e0 : first output word complete
150 or t0, t6, t6 # e1 : mask original data for zero test
151 cmpbge zero, t6, t8 # e0 :
152 beq a2, $u_eocfin # .. e1 :
153 bne t8, $u_final # e1 :
154
155 lda t6, -1 # e1 : mask out the bits we have
156 mskql t6, a1, t6 # e0 : already seen
157 stq_u t0, 0(a0) # e0 : store first output word
158 or t6, t2, t2 # .. e1 :
159 cmpbge zero, t2, t8 # e0 : find nulls in second partial
160 addq a0, 8, a0 # .. e1 :
161 subq a2, 1, a2 # e0 :
162 bne t8, $u_late_head_exit # .. e1 :
163
164 /* Finally, we've got all the stupid leading edge cases taken care
165 of and we can set up to enter the main loop. */
166
167 extql t2, a1, t1 # e0 : position hi-bits of lo word
168 EX( ldq_u t2, 8(a1) ) # .. e1 : read next high-order source word
169 addq a1, 8, a1 # e0 :
170 cmpbge zero, t2, t8 # e1 (stall)
171 beq a2, $u_eoc # e1 :
172 bne t8, $u_eos # e1 :
173
174 /* Unaligned copy main loop. In order to avoid reading too much,
175 the loop is structured to detect zeros in aligned source words.
176 This has, unfortunately, effectively pulled half of a loop
177 iteration out into the head and half into the tail, but it does
178 prevent nastiness from accumulating in the very thing we want
179 to run as fast as possible.
180
181 On entry to this basic block:
182 t1 == the shifted high-order bits from the previous source word
183 t2 == the unshifted current source word
184
185 We further know that t2 does not contain a null terminator. */
186
187 .align 3
188$u_loop:
189 extqh t2, a1, t0 # e0 : extract high bits for current word
190 addq a1, 8, a1 # .. e1 :
191 extql t2, a1, t3 # e0 : extract low bits for next time
192 addq a0, 8, a0 # .. e1 :
193 or t0, t1, t0 # e0 : current dst word now complete
194 EX( ldq_u t2, 0(a1) ) # .. e1 : load high word for next time
195 stq_u t0, -8(a0) # e0 : save the current word
196 mov t3, t1 # .. e1 :
197 subq a2, 1, a2 # e0 :
198 cmpbge zero, t2, t8 # .. e1 : test new word for eos
199 beq a2, $u_eoc # e1 :
200 beq t8, $u_loop # e1 :
201
202 /* We've found a zero somewhere in the source word we just read.
203 If it resides in the lower half, we have one (probably partial)
204 word to write out, and if it resides in the upper half, we
205 have one full and one partial word left to write out.
206
207 On entry to this basic block:
208 t1 == the shifted high-order bits from the previous source word
209 t2 == the unshifted current source word. */
210$u_eos:
211 extqh t2, a1, t0 # e0 :
212 or t0, t1, t0 # e1 : first (partial) source word complete
213
214 cmpbge zero, t0, t8 # e0 : is the null in this first bit?
215 bne t8, $u_final # .. e1 (zdb)
216
217 stq_u t0, 0(a0) # e0 : the null was in the high-order bits
218 addq a0, 8, a0 # .. e1 :
219 subq a2, 1, a2 # e1 :
220
221$u_late_head_exit:
222 extql t2, a1, t0 # .. e0 :
223 cmpbge zero, t0, t8 # e0 :
224 or t8, t10, t6 # e1 :
225 cmoveq a2, t6, t8 # e0 :
226 nop # .. e1 :
227
228 /* Take care of a final (probably partial) result word.
229 On entry to this basic block:
230 t0 == assembled source word
231 t8 == cmpbge mask that found the null. */
232$u_final:
233 negq t8, t6 # e0 : isolate low bit set
234 and t6, t8, t12 # e1 :
235
236 and t12, 0x80, t6 # e0 : avoid dest word load if we can
237 bne t6, 1f # .. e1 (zdb)
238
239 ldq_u t1, 0(a0) # e0 :
240 subq t12, 1, t6 # .. e1 :
241 or t6, t12, t8 # e0 :
242 zapnot t0, t8, t0 # .. e1 : kill source bytes > null
243 zap t1, t8, t1 # e0 : kill dest bytes <= null
244 or t0, t1, t0 # e1 :
245
2461: stq_u t0, 0(a0) # e0 :
247 br $finish_up
248
249$u_eoc: # end-of-count
250 extqh t2, a1, t0
251 or t0, t1, t0
252 cmpbge zero, t0, t8
253
254$u_eocfin: # end-of-count, final word
255 or t10, t8, t8
256 br $u_final
257
258 /* Unaligned copy entry point. */
259 .align 3
260$unaligned:
261
262 EX( ldq_u t1, 0(a1) ) # e0 : load first source word
263
264 and a0, 7, t4 # .. e1 : find dest misalignment
265 and a1, 7, t5 # e0 : find src misalignment
266
267 /* Conditionally load the first destination word and a bytemask
268 with 0xff indicating that the destination byte is sacrosanct. */
269
270 mov zero, t0 # .. e1 :
271 mov zero, t6 # e0 :
272 beq t4, 1f # .. e1 :
273 ldq_u t0, 0(a0) # e0 :
274 lda t6, -1 # .. e1 :
275 mskql t6, a0, t6 # e0 :
2761:
277 subq a1, t4, a1 # .. e1 : sub dest misalignment from src addr
278
279 /* If source misalignment is larger than dest misalignment, we need
280 extra startup checks to avoid SEGV. */
281
282 cmplt t4, t5, t12 # e1 :
283 extql t1, a1, t1 # .. e0 : shift src into place
284 lda t2, -1 # e0 : for creating masks later
285 beq t12, $u_head # e1 :
286
287 mskqh t2, t5, t2 # e0 : begin src byte validity mask
288 cmpbge zero, t1, t8 # .. e1 : is there a zero?
289 extql t2, a1, t2 # e0 :
290 or t8, t10, t5 # .. e1 : test for end-of-count too
291 cmpbge zero, t2, t3 # e0 :
292 cmoveq a2, t5, t8 # .. e1 :
293 andnot t8, t3, t8 # e0 :
294 beq t8, $u_head # .. e1 (zdb)
295
296 /* At this point we've found a zero in the first partial word of
297 the source. We need to isolate the valid source data and mask
298 it into the original destination data. (Incidentally, we know
299 that we'll need at least one byte of that original dest word.) */
300
301 ldq_u t0, 0(a0) # e0 :
302 negq t8, t6 # .. e1 : build bitmask of bytes <= zero
303 mskqh t1, t4, t1 # e0 :
304 and t6, t8, t12 # .. e1 :
305 subq t12, 1, t6 # e0 :
306 or t6, t12, t8 # e1 :
307
308 zapnot t2, t8, t2 # e0 : prepare source word; mirror changes
309 zapnot t1, t8, t1 # .. e1 : to source validity mask
310
311 andnot t0, t2, t0 # e0 : zero place for source to reside
312 or t0, t1, t0 # e1 : and put it there
313 stq_u t0, 0(a0) # e0 :
314
315$finish_up:
316 zapnot t0, t12, t4 # was last byte written null?
317 cmovne t4, 1, t4
318
319 and t12, 0xf0, t3 # binary search for the address of the
320 and t12, 0xcc, t2 # last byte written
321 and t12, 0xaa, t1
322 bic a0, 7, t0
323 cmovne t3, 4, t3
324 cmovne t2, 2, t2
325 cmovne t1, 1, t1
326 addq t0, t3, t0
327 addq t1, t2, t1
328 addq t0, t1, t0
329 addq t0, t4, t0 # add one if we filled the buffer
330
331 subq t0, v0, v0 # find string length
332 ret
333
334$zerolength:
335 clr v0
336$exception:
337 ret
338
339 .end __strncpy_from_user
diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
index 5eecab1a84e..0c4132dd350 100644
--- a/arch/alpha/mm/fault.c
+++ b/arch/alpha/mm/fault.c
@@ -89,6 +89,8 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
89 const struct exception_table_entry *fixup; 89 const struct exception_table_entry *fixup;
90 int fault, si_code = SEGV_MAPERR; 90 int fault, si_code = SEGV_MAPERR;
91 siginfo_t info; 91 siginfo_t info;
92 unsigned int flags = (FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
93 (cause > 0 ? FAULT_FLAG_WRITE : 0));
92 94
93 /* As of EV6, a load into $31/$f31 is a prefetch, and never faults 95 /* As of EV6, a load into $31/$f31 is a prefetch, and never faults
94 (or is suppressed by the PALcode). Support that for older CPUs 96 (or is suppressed by the PALcode). Support that for older CPUs
@@ -114,6 +116,7 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
114 goto vmalloc_fault; 116 goto vmalloc_fault;
115#endif 117#endif
116 118
119retry:
117 down_read(&mm->mmap_sem); 120 down_read(&mm->mmap_sem);
118 vma = find_vma(mm, address); 121 vma = find_vma(mm, address);
119 if (!vma) 122 if (!vma)
@@ -144,8 +147,11 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
144 /* If for any reason at all we couldn't handle the fault, 147 /* If for any reason at all we couldn't handle the fault,
145 make sure we exit gracefully rather than endlessly redo 148 make sure we exit gracefully rather than endlessly redo
146 the fault. */ 149 the fault. */
147 fault = handle_mm_fault(mm, vma, address, cause > 0 ? FAULT_FLAG_WRITE : 0); 150 fault = handle_mm_fault(mm, vma, address, flags);
148 up_read(&mm->mmap_sem); 151
152 if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
153 return;
154
149 if (unlikely(fault & VM_FAULT_ERROR)) { 155 if (unlikely(fault & VM_FAULT_ERROR)) {
150 if (fault & VM_FAULT_OOM) 156 if (fault & VM_FAULT_OOM)
151 goto out_of_memory; 157 goto out_of_memory;
@@ -153,10 +159,26 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
153 goto do_sigbus; 159 goto do_sigbus;
154 BUG(); 160 BUG();
155 } 161 }
156 if (fault & VM_FAULT_MAJOR) 162
157 current->maj_flt++; 163 if (flags & FAULT_FLAG_ALLOW_RETRY) {
158 else 164 if (fault & VM_FAULT_MAJOR)
159 current->min_flt++; 165 current->maj_flt++;
166 else
167 current->min_flt++;
168 if (fault & VM_FAULT_RETRY) {
169 flags &= ~FAULT_FLAG_ALLOW_RETRY;
170
171 /* No need to up_read(&mm->mmap_sem) as we would
172 * have already released it in __lock_page_or_retry
173 * in mm/filemap.c.
174 */
175
176 goto retry;
177 }
178 }
179
180 up_read(&mm->mmap_sem);
181
160 return; 182 return;
161 183
162 /* Something tried to access memory that isn't in our memory map. 184 /* Something tried to access memory that isn't in our memory map.
@@ -186,12 +208,14 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
186 /* We ran out of memory, or some other thing happened to us that 208 /* We ran out of memory, or some other thing happened to us that
187 made us unable to handle the page fault gracefully. */ 209 made us unable to handle the page fault gracefully. */
188 out_of_memory: 210 out_of_memory:
211 up_read(&mm->mmap_sem);
189 if (!user_mode(regs)) 212 if (!user_mode(regs))
190 goto no_context; 213 goto no_context;
191 pagefault_out_of_memory(); 214 pagefault_out_of_memory();
192 return; 215 return;
193 216
194 do_sigbus: 217 do_sigbus:
218 up_read(&mm->mmap_sem);
195 /* Send a sigbus, regardless of whether we were in kernel 219 /* Send a sigbus, regardless of whether we were in kernel
196 or user mode. */ 220 or user mode. */
197 info.si_signo = SIGBUS; 221 info.si_signo = SIGBUS;
diff --git a/arch/alpha/oprofile/common.c b/arch/alpha/oprofile/common.c
index a0a5d27aa21..b8ce18f485d 100644
--- a/arch/alpha/oprofile/common.c
+++ b/arch/alpha/oprofile/common.c
@@ -12,6 +12,7 @@
12#include <linux/smp.h> 12#include <linux/smp.h>
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <asm/ptrace.h> 14#include <asm/ptrace.h>
15#include <asm/special_insns.h>
15 16
16#include "op_impl.h" 17#include "op_impl.h"
17 18
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a91009c6187..2f88d8d9770 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -6,11 +6,12 @@ config ARM
6 select HAVE_DMA_API_DEBUG 6 select HAVE_DMA_API_DEBUG
7 select HAVE_IDE if PCI || ISA || PCMCIA 7 select HAVE_IDE if PCI || ISA || PCMCIA
8 select HAVE_DMA_ATTRS 8 select HAVE_DMA_ATTRS
9 select HAVE_DMA_CONTIGUOUS if (CPU_V6 || CPU_V6K || CPU_V7) 9 select HAVE_DMA_CONTIGUOUS if MMU
10 select HAVE_MEMBLOCK 10 select HAVE_MEMBLOCK
11 select RTC_LIB 11 select RTC_LIB
12 select SYS_SUPPORTS_APM_EMULATION 12 select SYS_SUPPORTS_APM_EMULATION
13 select GENERIC_ATOMIC64 if (CPU_V6 || !CPU_32v6K || !AEABI) 13 select GENERIC_ATOMIC64 if (CPU_V6 || !CPU_32v6K || !AEABI)
14 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
14 select HAVE_OPROFILE if (HAVE_PERF_EVENTS) 15 select HAVE_OPROFILE if (HAVE_PERF_EVENTS)
15 select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL 16 select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL
16 select HAVE_ARCH_KGDB 17 select HAVE_ARCH_KGDB
@@ -37,7 +38,7 @@ config ARM
37 select HARDIRQS_SW_RESEND 38 select HARDIRQS_SW_RESEND
38 select GENERIC_IRQ_PROBE 39 select GENERIC_IRQ_PROBE
39 select GENERIC_IRQ_SHOW 40 select GENERIC_IRQ_SHOW
40 select GENERIC_IRQ_PROBE 41 select ARCH_WANT_IPC_PARSE_VERSION
41 select HARDIRQS_SW_RESEND 42 select HARDIRQS_SW_RESEND
42 select CPU_PM if (SUSPEND || CPU_IDLE) 43 select CPU_PM if (SUSPEND || CPU_IDLE)
43 select GENERIC_PCI_IOMAP 44 select GENERIC_PCI_IOMAP
@@ -45,6 +46,9 @@ config ARM
45 select GENERIC_SMP_IDLE_THREAD 46 select GENERIC_SMP_IDLE_THREAD
46 select KTIME_SCALAR 47 select KTIME_SCALAR
47 select GENERIC_CLOCKEVENTS_BROADCAST if SMP 48 select GENERIC_CLOCKEVENTS_BROADCAST if SMP
49 select GENERIC_STRNCPY_FROM_USER
50 select GENERIC_STRNLEN_USER
51 select DCACHE_WORD_ACCESS if (CPU_V6 || CPU_V6K || CPU_V7) && !CPU_BIG_ENDIAN
48 help 52 help
49 The ARM series is a line of low-power-consumption RISC chip designs 53 The ARM series is a line of low-power-consumption RISC chip designs
50 licensed by ARM Ltd and targeted at embedded applications and 54 licensed by ARM Ltd and targeted at embedded applications and
@@ -121,11 +125,6 @@ config TRACE_IRQFLAGS_SUPPORT
121 bool 125 bool
122 default y 126 default y
123 127
124config GENERIC_LOCKBREAK
125 bool
126 default y
127 depends on SMP && PREEMPT
128
129config RWSEM_GENERIC_SPINLOCK 128config RWSEM_GENERIC_SPINLOCK
130 bool 129 bool
131 default y 130 default y
@@ -250,12 +249,31 @@ choice
250 prompt "ARM system type" 249 prompt "ARM system type"
251 default ARCH_VERSATILE 250 default ARCH_VERSATILE
252 251
252config ARCH_SOCFPGA
253 bool "Altera SOCFPGA family"
254 select ARCH_WANT_OPTIONAL_GPIOLIB
255 select ARM_AMBA
256 select ARM_GIC
257 select CACHE_L2X0
258 select CLKDEV_LOOKUP
259 select COMMON_CLK
260 select CPU_V7
261 select DW_APB_TIMER
262 select DW_APB_TIMER_OF
263 select GENERIC_CLOCKEVENTS
264 select GPIO_PL061 if GPIOLIB
265 select HAVE_ARM_SCU
266 select SPARSE_IRQ
267 select USE_OF
268 help
269 This enables support for Altera SOCFPGA Cyclone V platform
270
253config ARCH_INTEGRATOR 271config ARCH_INTEGRATOR
254 bool "ARM Ltd. Integrator family" 272 bool "ARM Ltd. Integrator family"
255 select ARM_AMBA 273 select ARM_AMBA
256 select ARCH_HAS_CPUFREQ 274 select ARCH_HAS_CPUFREQ
257 select CLKDEV_LOOKUP 275 select COMMON_CLK
258 select HAVE_MACH_CLKDEV 276 select CLK_VERSATILE
259 select HAVE_TCM 277 select HAVE_TCM
260 select ICST 278 select ICST
261 select GENERIC_CLOCKEVENTS 279 select GENERIC_CLOCKEVENTS
@@ -277,6 +295,7 @@ config ARCH_REALVIEW
277 select GENERIC_CLOCKEVENTS 295 select GENERIC_CLOCKEVENTS
278 select ARCH_WANT_OPTIONAL_GPIOLIB 296 select ARCH_WANT_OPTIONAL_GPIOLIB
279 select PLAT_VERSATILE 297 select PLAT_VERSATILE
298 select PLAT_VERSATILE_CLOCK
280 select PLAT_VERSATILE_CLCD 299 select PLAT_VERSATILE_CLCD
281 select ARM_TIMER_SP804 300 select ARM_TIMER_SP804
282 select GPIO_PL061 if GPIOLIB 301 select GPIO_PL061 if GPIOLIB
@@ -295,6 +314,7 @@ config ARCH_VERSATILE
295 select ARCH_WANT_OPTIONAL_GPIOLIB 314 select ARCH_WANT_OPTIONAL_GPIOLIB
296 select NEED_MACH_IO_H if PCI 315 select NEED_MACH_IO_H if PCI
297 select PLAT_VERSATILE 316 select PLAT_VERSATILE
317 select PLAT_VERSATILE_CLOCK
298 select PLAT_VERSATILE_CLCD 318 select PLAT_VERSATILE_CLCD
299 select PLAT_VERSATILE_FPGA_IRQ 319 select PLAT_VERSATILE_FPGA_IRQ
300 select ARM_TIMER_SP804 320 select ARM_TIMER_SP804
@@ -307,7 +327,7 @@ config ARCH_VEXPRESS
307 select ARM_AMBA 327 select ARM_AMBA
308 select ARM_TIMER_SP804 328 select ARM_TIMER_SP804
309 select CLKDEV_LOOKUP 329 select CLKDEV_LOOKUP
310 select HAVE_MACH_CLKDEV 330 select COMMON_CLK
311 select GENERIC_CLOCKEVENTS 331 select GENERIC_CLOCKEVENTS
312 select HAVE_CLK 332 select HAVE_CLK
313 select HAVE_PATA_PLATFORM 333 select HAVE_PATA_PLATFORM
@@ -315,6 +335,7 @@ config ARCH_VEXPRESS
315 select NO_IOPORT 335 select NO_IOPORT
316 select PLAT_VERSATILE 336 select PLAT_VERSATILE
317 select PLAT_VERSATILE_CLCD 337 select PLAT_VERSATILE_CLCD
338 select REGULATOR_FIXED_VOLTAGE if REGULATOR
318 help 339 help
319 This enables support for the ARM Ltd Versatile Express boards. 340 This enables support for the ARM Ltd Versatile Express boards.
320 341
@@ -349,6 +370,7 @@ config ARCH_HIGHBANK
349 select ARM_TIMER_SP804 370 select ARM_TIMER_SP804
350 select CACHE_L2X0 371 select CACHE_L2X0
351 select CLKDEV_LOOKUP 372 select CLKDEV_LOOKUP
373 select COMMON_CLK
352 select CPU_V7 374 select CPU_V7
353 select GENERIC_CLOCKEVENTS 375 select GENERIC_CLOCKEVENTS
354 select HAVE_ARM_SCU 376 select HAVE_ARM_SCU
@@ -389,6 +411,7 @@ config ARCH_PRIMA2
389 bool "CSR SiRFSoC PRIMA2 ARM Cortex A9 Platform" 411 bool "CSR SiRFSoC PRIMA2 ARM Cortex A9 Platform"
390 select CPU_V7 412 select CPU_V7
391 select NO_IOPORT 413 select NO_IOPORT
414 select ARCH_REQUIRE_GPIOLIB
392 select GENERIC_CLOCKEVENTS 415 select GENERIC_CLOCKEVENTS
393 select CLKDEV_LOOKUP 416 select CLKDEV_LOOKUP
394 select GENERIC_IRQ_CHIP 417 select GENERIC_IRQ_CHIP
@@ -447,6 +470,8 @@ config ARCH_MXC
447 select CLKSRC_MMIO 470 select CLKSRC_MMIO
448 select GENERIC_IRQ_CHIP 471 select GENERIC_IRQ_CHIP
449 select MULTI_IRQ_HANDLER 472 select MULTI_IRQ_HANDLER
473 select SPARSE_IRQ
474 select USE_OF
450 help 475 help
451 Support for Freescale MXC/iMX-based family of processors 476 Support for Freescale MXC/iMX-based family of processors
452 477
@@ -533,6 +558,18 @@ config ARCH_IXP4XX
533 help 558 help
534 Support for Intel's IXP4XX (XScale) family of processors. 559 Support for Intel's IXP4XX (XScale) family of processors.
535 560
561config ARCH_MVEBU
562 bool "Marvell SOCs with Device Tree support"
563 select GENERIC_CLOCKEVENTS
564 select MULTI_IRQ_HANDLER
565 select SPARSE_IRQ
566 select CLKSRC_MMIO
567 select GENERIC_IRQ_CHIP
568 select IRQ_DOMAIN
569 select COMMON_CLK
570 help
571 Support for the Marvell SoC Family with device tree support
572
536config ARCH_DOVE 573config ARCH_DOVE
537 bool "Marvell Dove" 574 bool "Marvell Dove"
538 select CPU_V7 575 select CPU_V7
@@ -567,6 +604,7 @@ config ARCH_LPC32XX
567 select CLKDEV_LOOKUP 604 select CLKDEV_LOOKUP
568 select GENERIC_CLOCKEVENTS 605 select GENERIC_CLOCKEVENTS
569 select USE_OF 606 select USE_OF
607 select HAVE_PWM
570 help 608 help
571 Support for the NXP LPC32XX family of processors 609 Support for the NXP LPC32XX family of processors
572 610
@@ -647,6 +685,7 @@ config ARCH_TEGRA
647 select MIGHT_HAVE_CACHE_L2X0 685 select MIGHT_HAVE_CACHE_L2X0
648 select NEED_MACH_IO_H if PCI 686 select NEED_MACH_IO_H if PCI
649 select ARCH_HAS_CPUFREQ 687 select ARCH_HAS_CPUFREQ
688 select USE_OF
650 help 689 help
651 This enables support for NVIDIA Tegra based systems (Tegra APX, 690 This enables support for NVIDIA Tegra based systems (Tegra APX,
652 Tegra 6xx and Tegra 2 series). 691 Tegra 6xx and Tegra 2 series).
@@ -658,6 +697,7 @@ config ARCH_PICOXCELL
658 select ARM_VIC 697 select ARM_VIC
659 select CPU_V6K 698 select CPU_V6K
660 select DW_APB_TIMER 699 select DW_APB_TIMER
700 select DW_APB_TIMER_OF
661 select GENERIC_CLOCKEVENTS 701 select GENERIC_CLOCKEVENTS
662 select GENERIC_GPIO 702 select GENERIC_GPIO
663 select HAVE_TCM 703 select HAVE_TCM
@@ -888,7 +928,7 @@ config ARCH_U300
888 select ARM_VIC 928 select ARM_VIC
889 select GENERIC_CLOCKEVENTS 929 select GENERIC_CLOCKEVENTS
890 select CLKDEV_LOOKUP 930 select CLKDEV_LOOKUP
891 select HAVE_MACH_CLKDEV 931 select COMMON_CLK
892 select GENERIC_GPIO 932 select GENERIC_GPIO
893 select ARCH_REQUIRE_GPIOLIB 933 select ARCH_REQUIRE_GPIOLIB
894 help 934 help
@@ -913,7 +953,7 @@ config ARCH_NOMADIK
913 select ARM_AMBA 953 select ARM_AMBA
914 select ARM_VIC 954 select ARM_VIC
915 select CPU_ARM926T 955 select CPU_ARM926T
916 select CLKDEV_LOOKUP 956 select COMMON_CLK
917 select GENERIC_CLOCKEVENTS 957 select GENERIC_CLOCKEVENTS
918 select PINCTRL 958 select PINCTRL
919 select MIGHT_HAVE_CACHE_L2X0 959 select MIGHT_HAVE_CACHE_L2X0
@@ -936,6 +976,7 @@ config ARCH_DAVINCI
936 976
937config ARCH_OMAP 977config ARCH_OMAP
938 bool "TI OMAP" 978 bool "TI OMAP"
979 depends on MMU
939 select HAVE_CLK 980 select HAVE_CLK
940 select ARCH_REQUIRE_GPIOLIB 981 select ARCH_REQUIRE_GPIOLIB
941 select ARCH_HAS_CPUFREQ 982 select ARCH_HAS_CPUFREQ
@@ -964,7 +1005,6 @@ config ARCH_VT8500
964 select ARCH_HAS_CPUFREQ 1005 select ARCH_HAS_CPUFREQ
965 select GENERIC_CLOCKEVENTS 1006 select GENERIC_CLOCKEVENTS
966 select ARCH_REQUIRE_GPIOLIB 1007 select ARCH_REQUIRE_GPIOLIB
967 select HAVE_PWM
968 help 1008 help
969 Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip. 1009 Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip.
970 1010
@@ -987,6 +1027,8 @@ endchoice
987# Kconfigs may be included either alphabetically (according to the 1027# Kconfigs may be included either alphabetically (according to the
988# plat- suffix) or along side the corresponding mach-* source. 1028# plat- suffix) or along side the corresponding mach-* source.
989# 1029#
1030source "arch/arm/mach-mvebu/Kconfig"
1031
990source "arch/arm/mach-at91/Kconfig" 1032source "arch/arm/mach-at91/Kconfig"
991 1033
992source "arch/arm/mach-bcmring/Kconfig" 1034source "arch/arm/mach-bcmring/Kconfig"
@@ -1021,8 +1063,6 @@ source "arch/arm/mach-kirkwood/Kconfig"
1021 1063
1022source "arch/arm/mach-ks8695/Kconfig" 1064source "arch/arm/mach-ks8695/Kconfig"
1023 1065
1024source "arch/arm/mach-lpc32xx/Kconfig"
1025
1026source "arch/arm/mach-msm/Kconfig" 1066source "arch/arm/mach-msm/Kconfig"
1027 1067
1028source "arch/arm/mach-mv78xx0/Kconfig" 1068source "arch/arm/mach-mv78xx0/Kconfig"
@@ -1105,6 +1145,7 @@ config PLAT_ORION
1105 bool 1145 bool
1106 select CLKSRC_MMIO 1146 select CLKSRC_MMIO
1107 select GENERIC_IRQ_CHIP 1147 select GENERIC_IRQ_CHIP
1148 select IRQ_DOMAIN
1108 select COMMON_CLK 1149 select COMMON_CLK
1109 1150
1110config PLAT_PXA 1151config PLAT_PXA
@@ -1581,6 +1622,7 @@ config ARCH_NR_GPIO
1581 default 1024 if ARCH_SHMOBILE || ARCH_TEGRA 1622 default 1024 if ARCH_SHMOBILE || ARCH_TEGRA
1582 default 355 if ARCH_U8500 1623 default 355 if ARCH_U8500
1583 default 264 if MACH_H4700 1624 default 264 if MACH_H4700
1625 default 512 if SOC_OMAP5
1584 default 0 1626 default 0
1585 help 1627 help
1586 Maximum number of GPIOs in the system. 1628 Maximum number of GPIOs in the system.
@@ -1961,6 +2003,25 @@ config ARM_ATAG_DTB_COMPAT
1961 bootloaders, this option allows zImage to extract the information 2003 bootloaders, this option allows zImage to extract the information
1962 from the ATAG list and store it at run time into the appended DTB. 2004 from the ATAG list and store it at run time into the appended DTB.
1963 2005
2006choice
2007 prompt "Kernel command line type" if ARM_ATAG_DTB_COMPAT
2008 default ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER
2009
2010config ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER
2011 bool "Use bootloader kernel arguments if available"
2012 help
2013 Uses the command-line options passed by the boot loader instead of
2014 the device tree bootargs property. If the boot loader doesn't provide
2015 any, the device tree bootargs property will be used.
2016
2017config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND
2018 bool "Extend with bootloader kernel arguments"
2019 help
2020 The command-line arguments provided by the boot loader will be
2021 appended to the the device tree bootargs property.
2022
2023endchoice
2024
1964config CMDLINE 2025config CMDLINE
1965 string "Default kernel command string" 2026 string "Default kernel command string"
1966 default "" 2027 default ""
@@ -2083,6 +2144,7 @@ source "drivers/cpufreq/Kconfig"
2083config CPU_FREQ_IMX 2144config CPU_FREQ_IMX
2084 tristate "CPUfreq driver for i.MX CPUs" 2145 tristate "CPUfreq driver for i.MX CPUs"
2085 depends on ARCH_MXC && CPU_FREQ 2146 depends on ARCH_MXC && CPU_FREQ
2147 select CPU_FREQ_TABLE
2086 help 2148 help
2087 This enables the CPUfreq driver for i.MX CPUs. 2149 This enables the CPUfreq driver for i.MX CPUs.
2088 2150
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 01a13414121..f15f82bf3a5 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -310,6 +310,32 @@ choice
310 The uncompressor code port configuration is now handled 310 The uncompressor code port configuration is now handled
311 by CONFIG_S3C_LOWLEVEL_UART_PORT. 311 by CONFIG_S3C_LOWLEVEL_UART_PORT.
312 312
313 config DEBUG_VEXPRESS_UART0_DETECT
314 bool "Autodetect UART0 on Versatile Express Cortex-A core tiles"
315 depends on ARCH_VEXPRESS && CPU_CP15_MMU
316 help
317 This option enables a simple heuristic which tries to determine
318 the motherboard's memory map variant (original or RS1) and then
319 choose the relevant UART0 base address.
320
321 Note that this will only work with standard A-class core tiles,
322 and may fail with non-standard SMM or custom software models.
323
324 config DEBUG_VEXPRESS_UART0_CA9
325 bool "Use PL011 UART0 at 0x10009000 (V2P-CA9 core tile)"
326 depends on ARCH_VEXPRESS
327 help
328 This option selects UART0 at 0x10009000. Except for custom models,
329 this applies only to the V2P-CA9 tile.
330
331 config DEBUG_VEXPRESS_UART0_RS1
332 bool "Use PL011 UART0 at 0x1c090000 (RS1 complaint tiles)"
333 depends on ARCH_VEXPRESS
334 help
335 This option selects UART0 at 0x1c090000. This applies to most
336 of the tiles using the RS1 memory map, including all new A-class
337 core tiles, FPGA-based SMMs and software models.
338
313 config DEBUG_LL_UART_NONE 339 config DEBUG_LL_UART_NONE
314 bool "No low-level debugging UART" 340 bool "No low-level debugging UART"
315 help 341 help
@@ -369,4 +395,13 @@ config ARM_KPROBES_TEST
369 help 395 help
370 Perform tests of kprobes API and instruction set simulation. 396 Perform tests of kprobes API and instruction set simulation.
371 397
398config PID_IN_CONTEXTIDR
399 bool "Write the current PID to the CONTEXTIDR register"
400 depends on CPU_COPY_V6
401 help
402 Enabling this option causes the kernel to write the current PID to
403 the PROCID field of the CONTEXTIDR register, at the expense of some
404 additional instructions during context switch. Say Y here only if you
405 are planning to use hardware trace tools with this kernel.
406
372endmenu 407endmenu
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 0298b00fe24..30eae87ead6 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -10,6 +10,9 @@
10# 10#
11# Copyright (C) 1995-2001 by Russell King 11# Copyright (C) 1995-2001 by Russell King
12 12
13# Ensure linker flags are correct
14LDFLAGS :=
15
13LDFLAGS_vmlinux :=-p --no-undefined -X 16LDFLAGS_vmlinux :=-p --no-undefined -X
14ifeq ($(CONFIG_CPU_ENDIAN_BE8),y) 17ifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
15LDFLAGS_vmlinux += --be8 18LDFLAGS_vmlinux += --be8
@@ -157,6 +160,7 @@ machine-$(CONFIG_ARCH_MV78XX0) := mv78xx0
157machine-$(CONFIG_ARCH_IMX_V4_V5) := imx 160machine-$(CONFIG_ARCH_IMX_V4_V5) := imx
158machine-$(CONFIG_ARCH_IMX_V6_V7) := imx 161machine-$(CONFIG_ARCH_IMX_V6_V7) := imx
159machine-$(CONFIG_ARCH_MXS) := mxs 162machine-$(CONFIG_ARCH_MXS) := mxs
163machine-$(CONFIG_ARCH_MVEBU) := mvebu
160machine-$(CONFIG_ARCH_NETX) := netx 164machine-$(CONFIG_ARCH_NETX) := netx
161machine-$(CONFIG_ARCH_NOMADIK) := nomadik 165machine-$(CONFIG_ARCH_NOMADIK) := nomadik
162machine-$(CONFIG_ARCH_OMAP1) := omap1 166machine-$(CONFIG_ARCH_OMAP1) := omap1
@@ -186,6 +190,7 @@ machine-$(CONFIG_ARCH_VEXPRESS) := vexpress
186machine-$(CONFIG_ARCH_VT8500) := vt8500 190machine-$(CONFIG_ARCH_VT8500) := vt8500
187machine-$(CONFIG_ARCH_W90X900) := w90x900 191machine-$(CONFIG_ARCH_W90X900) := w90x900
188machine-$(CONFIG_FOOTBRIDGE) := footbridge 192machine-$(CONFIG_FOOTBRIDGE) := footbridge
193machine-$(CONFIG_ARCH_SOCFPGA) := socfpga
189machine-$(CONFIG_MACH_SPEAR1310) := spear13xx 194machine-$(CONFIG_MACH_SPEAR1310) := spear13xx
190machine-$(CONFIG_MACH_SPEAR1340) := spear13xx 195machine-$(CONFIG_MACH_SPEAR1340) := spear13xx
191machine-$(CONFIG_MACH_SPEAR300) := spear3xx 196machine-$(CONFIG_MACH_SPEAR300) := spear3xx
diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c
index 797f04bedb4..aabc02a6848 100644
--- a/arch/arm/boot/compressed/atags_to_fdt.c
+++ b/arch/arm/boot/compressed/atags_to_fdt.c
@@ -1,6 +1,12 @@
1#include <asm/setup.h> 1#include <asm/setup.h>
2#include <libfdt.h> 2#include <libfdt.h>
3 3
4#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND)
5#define do_extend_cmdline 1
6#else
7#define do_extend_cmdline 0
8#endif
9
4static int node_offset(void *fdt, const char *node_path) 10static int node_offset(void *fdt, const char *node_path)
5{ 11{
6 int offset = fdt_path_offset(fdt, node_path); 12 int offset = fdt_path_offset(fdt, node_path);
@@ -36,6 +42,48 @@ static int setprop_cell(void *fdt, const char *node_path,
36 return fdt_setprop_cell(fdt, offset, property, val); 42 return fdt_setprop_cell(fdt, offset, property, val);
37} 43}
38 44
45static const void *getprop(const void *fdt, const char *node_path,
46 const char *property, int *len)
47{
48 int offset = fdt_path_offset(fdt, node_path);
49
50 if (offset == -FDT_ERR_NOTFOUND)
51 return NULL;
52
53 return fdt_getprop(fdt, offset, property, len);
54}
55
56static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline)
57{
58 char cmdline[COMMAND_LINE_SIZE];
59 const char *fdt_bootargs;
60 char *ptr = cmdline;
61 int len = 0;
62
63 /* copy the fdt command line into the buffer */
64 fdt_bootargs = getprop(fdt, "/chosen", "bootargs", &len);
65 if (fdt_bootargs)
66 if (len < COMMAND_LINE_SIZE) {
67 memcpy(ptr, fdt_bootargs, len);
68 /* len is the length of the string
69 * including the NULL terminator */
70 ptr += len - 1;
71 }
72
73 /* and append the ATAG_CMDLINE */
74 if (fdt_cmdline) {
75 len = strlen(fdt_cmdline);
76 if (ptr - cmdline + len + 2 < COMMAND_LINE_SIZE) {
77 *ptr++ = ' ';
78 memcpy(ptr, fdt_cmdline, len);
79 ptr += len;
80 }
81 }
82 *ptr = '\0';
83
84 setprop_string(fdt, "/chosen", "bootargs", cmdline);
85}
86
39/* 87/*
40 * Convert and fold provided ATAGs into the provided FDT. 88 * Convert and fold provided ATAGs into the provided FDT.
41 * 89 *
@@ -72,8 +120,18 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)
72 120
73 for_each_tag(atag, atag_list) { 121 for_each_tag(atag, atag_list) {
74 if (atag->hdr.tag == ATAG_CMDLINE) { 122 if (atag->hdr.tag == ATAG_CMDLINE) {
75 setprop_string(fdt, "/chosen", "bootargs", 123 /* Append the ATAGS command line to the device tree
76 atag->u.cmdline.cmdline); 124 * command line.
125 * NB: This means that if the same parameter is set in
126 * the device tree and in the tags, the one from the
127 * tags will be chosen.
128 */
129 if (do_extend_cmdline)
130 merge_fdt_bootargs(fdt,
131 atag->u.cmdline.cmdline);
132 else
133 setprop_string(fdt, "/chosen", "bootargs",
134 atag->u.cmdline.cmdline);
77 } else if (atag->hdr.tag == ATAG_MEM) { 135 } else if (atag->hdr.tag == ATAG_MEM) {
78 if (memcount >= sizeof(mem_reg_property)/4) 136 if (memcount >= sizeof(mem_reg_property)/4)
79 continue; 137 continue;
diff --git a/arch/arm/boot/dts/aks-cdu.dts b/arch/arm/boot/dts/aks-cdu.dts
new file mode 100644
index 00000000000..29b9f15e759
--- /dev/null
+++ b/arch/arm/boot/dts/aks-cdu.dts
@@ -0,0 +1,113 @@
1/*
2 * aks-cdu.dts - Device Tree file for AK signal CDU
3 *
4 * Copyright (C) 2012 AK signal Brno a.s.
5 * 2012 Jiri Prchal <jiri.prchal@aksignal.cz>
6 *
7 * Licensed under GPLv2 or later.
8 */
9
10/dts-v1/;
11
12/include/ "ge863-pro3.dtsi"
13
14/ {
15 chosen {
16 bootargs = "console=ttyS0,115200 ubi.mtd=4 root=ubi0:rootfs rootfstype=ubifs";
17 };
18
19 ahb {
20 apb {
21 usart0: serial@fffb0000 {
22 status = "okay";
23 };
24
25 usart1: serial@fffb4000 {
26 status = "okay";
27 linux,rs485-enabled-at-boot-time;
28 rs485-rts-delay = <0 0>;
29 };
30
31 usart2: serial@fffb8000 {
32 status = "okay";
33 linux,rs485-enabled-at-boot-time;
34 rs485-rts-delay = <0 0>;
35 };
36
37 usart3: serial@fffd0000 {
38 status = "okay";
39 linux,rs485-enabled-at-boot-time;
40 rs485-rts-delay = <0 0>;
41 };
42
43 macb0: ethernet@fffc4000 {
44 phy-mode = "rmii";
45 status = "okay";
46 };
47
48 usb1: gadget@fffa4000 {
49 atmel,vbus-gpio = <&pioC 15 0>;
50 status = "okay";
51 };
52 };
53
54 usb0: ohci@00500000 {
55 num-ports = <2>;
56 status = "okay";
57 };
58
59 nand0: nand@40000000 {
60 nand-bus-width = <8>;
61 nand-ecc-mode = "soft";
62 nand-on-flash-bbt;
63 status = "okay";
64
65 bootstrap@0 {
66 label = "bootstrap";
67 reg = <0x0 0x40000>;
68 };
69
70 uboot@40000 {
71 label = "uboot";
72 reg = <0x40000 0x80000>;
73 };
74 ubootenv@c0000 {
75 label = "ubootenv";
76 reg = <0xc0000 0x40000>;
77 };
78 kernel@100000 {
79 label = "kernel";
80 reg = <0x100000 0x400000>;
81 };
82 rootfs@500000 {
83 label = "rootfs";
84 reg = <0x500000 0x7b00000>;
85 };
86 };
87 };
88
89 leds {
90 compatible = "gpio-leds";
91
92 red {
93 gpios = <&pioC 10 0>;
94 linux,default-trigger = "none";
95 };
96
97 green {
98 gpios = <&pioA 5 1>;
99 linux,default-trigger = "none";
100 default-state = "on";
101 };
102
103 yellow {
104 gpios = <&pioB 20 1>;
105 linux,default-trigger = "none";
106 };
107
108 blue {
109 gpios = <&pioB 21 1>;
110 linux,default-trigger = "none";
111 };
112 };
113};
diff --git a/arch/arm/boot/dts/am335x-bone.dts b/arch/arm/boot/dts/am335x-bone.dts
new file mode 100644
index 00000000000..a9af4db7234
--- /dev/null
+++ b/arch/arm/boot/dts/am335x-bone.dts
@@ -0,0 +1,20 @@
1/*
2 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
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/dts-v1/;
9
10/include/ "am33xx.dtsi"
11
12/ {
13 model = "TI AM335x BeagleBone";
14 compatible = "ti,am335x-bone", "ti,am33xx";
15
16 memory {
17 device_type = "memory";
18 reg = <0x80000000 0x10000000>; /* 256 MB */
19 };
20};
diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts
new file mode 100644
index 00000000000..d6a97d9eff7
--- /dev/null
+++ b/arch/arm/boot/dts/am335x-evm.dts
@@ -0,0 +1,20 @@
1/*
2 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
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/dts-v1/;
9
10/include/ "am33xx.dtsi"
11
12/ {
13 model = "TI AM335x EVM";
14 compatible = "ti,am335x-evm", "ti,am33xx";
15
16 memory {
17 device_type = "memory";
18 reg = <0x80000000 0x10000000>; /* 256 MB */
19 };
20};
diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
new file mode 100644
index 00000000000..bd0cff3f808
--- /dev/null
+++ b/arch/arm/boot/dts/am33xx.dtsi
@@ -0,0 +1,163 @@
1/*
2 * Device Tree Source for AM33XX SoC
3 *
4 * Copyright (C) 2012 Texas Instruments Incorporated - 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
11/include/ "skeleton.dtsi"
12
13/ {
14 compatible = "ti,am33xx";
15
16 aliases {
17 serial0 = &uart1;
18 serial1 = &uart2;
19 serial2 = &uart3;
20 serial3 = &uart4;
21 serial4 = &uart5;
22 serial5 = &uart6;
23 };
24
25 cpus {
26 cpu@0 {
27 compatible = "arm,cortex-a8";
28 };
29 };
30
31 /*
32 * The soc node represents the soc top level view. It is uses for IPs
33 * that are not memory mapped in the MPU view or for the MPU itself.
34 */
35 soc {
36 compatible = "ti,omap-infra";
37 mpu {
38 compatible = "ti,omap3-mpu";
39 ti,hwmods = "mpu";
40 };
41 };
42
43 /*
44 * XXX: Use a flat representation of the AM33XX interconnect.
45 * The real AM33XX interconnect network is quite complex.Since
46 * that will not bring real advantage to represent that in DT
47 * for the moment, just use a fake OCP bus entry to represent
48 * the whole bus hierarchy.
49 */
50 ocp {
51 compatible = "simple-bus";
52 #address-cells = <1>;
53 #size-cells = <1>;
54 ranges;
55 ti,hwmods = "l3_main";
56
57 intc: interrupt-controller@48200000 {
58 compatible = "ti,omap2-intc";
59 interrupt-controller;
60 #interrupt-cells = <1>;
61 ti,intc-size = <128>;
62 reg = <0x48200000 0x1000>;
63 };
64
65 gpio1: gpio@44e07000 {
66 compatible = "ti,omap4-gpio";
67 ti,hwmods = "gpio1";
68 gpio-controller;
69 #gpio-cells = <2>;
70 interrupt-controller;
71 #interrupt-cells = <1>;
72 };
73
74 gpio2: gpio@4804C000 {
75 compatible = "ti,omap4-gpio";
76 ti,hwmods = "gpio2";
77 gpio-controller;
78 #gpio-cells = <2>;
79 interrupt-controller;
80 #interrupt-cells = <1>;
81 };
82
83 gpio3: gpio@481AC000 {
84 compatible = "ti,omap4-gpio";
85 ti,hwmods = "gpio3";
86 gpio-controller;
87 #gpio-cells = <2>;
88 interrupt-controller;
89 #interrupt-cells = <1>;
90 };
91
92 gpio4: gpio@481AE000 {
93 compatible = "ti,omap4-gpio";
94 ti,hwmods = "gpio4";
95 gpio-controller;
96 #gpio-cells = <2>;
97 interrupt-controller;
98 #interrupt-cells = <1>;
99 };
100
101 uart1: serial@44E09000 {
102 compatible = "ti,omap3-uart";
103 ti,hwmods = "uart1";
104 clock-frequency = <48000000>;
105 };
106
107 uart2: serial@48022000 {
108 compatible = "ti,omap3-uart";
109 ti,hwmods = "uart2";
110 clock-frequency = <48000000>;
111 };
112
113 uart3: serial@48024000 {
114 compatible = "ti,omap3-uart";
115 ti,hwmods = "uart3";
116 clock-frequency = <48000000>;
117 };
118
119 uart4: serial@481A6000 {
120 compatible = "ti,omap3-uart";
121 ti,hwmods = "uart4";
122 clock-frequency = <48000000>;
123 };
124
125 uart5: serial@481A8000 {
126 compatible = "ti,omap3-uart";
127 ti,hwmods = "uart5";
128 clock-frequency = <48000000>;
129 };
130
131 uart6: serial@481AA000 {
132 compatible = "ti,omap3-uart";
133 ti,hwmods = "uart6";
134 clock-frequency = <48000000>;
135 };
136
137 i2c1: i2c@44E0B000 {
138 compatible = "ti,omap4-i2c";
139 #address-cells = <1>;
140 #size-cells = <0>;
141 ti,hwmods = "i2c1";
142 };
143
144 i2c2: i2c@4802A000 {
145 compatible = "ti,omap4-i2c";
146 #address-cells = <1>;
147 #size-cells = <0>;
148 ti,hwmods = "i2c2";
149 };
150
151 i2c3: i2c@4819C000 {
152 compatible = "ti,omap4-i2c";
153 #address-cells = <1>;
154 #size-cells = <0>;
155 ti,hwmods = "i2c3";
156 };
157
158 wdt2: wdt@44e35000 {
159 compatible = "ti,omap3-wdt";
160 ti,hwmods = "wd_timer2";
161 };
162 };
163};
diff --git a/arch/arm/boot/dts/am3517-evm.dts b/arch/arm/boot/dts/am3517-evm.dts
new file mode 100644
index 00000000000..474f760ecad
--- /dev/null
+++ b/arch/arm/boot/dts/am3517-evm.dts
@@ -0,0 +1,32 @@
1/*
2 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
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/dts-v1/;
9
10/include/ "omap3.dtsi"
11
12/ {
13 model = "TI AM3517 EVM (AM3517/05)";
14 compatible = "ti,am3517-evm", "ti,omap3";
15
16 memory {
17 device_type = "memory";
18 reg = <0x80000000 0x10000000>; /* 256 MB */
19 };
20};
21
22&i2c1 {
23 clock-frequency = <400000>;
24};
25
26&i2c2 {
27 clock-frequency = <400000>;
28};
29
30&i2c3 {
31 clock-frequency = <400000>;
32};
diff --git a/arch/arm/boot/dts/armada-370-db.dts b/arch/arm/boot/dts/armada-370-db.dts
new file mode 100644
index 00000000000..fffd5c2a304
--- /dev/null
+++ b/arch/arm/boot/dts/armada-370-db.dts
@@ -0,0 +1,42 @@
1/*
2 * Device Tree file for Marvell Armada 370 evaluation board
3 * (DB-88F6710-BP-DDR3)
4 *
5 * Copyright (C) 2012 Marvell
6 *
7 * Lior Amsalem <alior@marvell.com>
8 * Gregory CLEMENT <gregory.clement@free-electrons.com>
9 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
10 *
11 * This file is licensed under the terms of the GNU General Public
12 * License version 2. This program is licensed "as is" without any
13 * warranty of any kind, whether express or implied.
14 */
15
16/dts-v1/;
17/include/ "armada-370.dtsi"
18
19/ {
20 model = "Marvell Armada 370 Evaluation Board";
21 compatible = "marvell,a370-db", "marvell,armada370", "marvell,armada-370-xp";
22
23 chosen {
24 bootargs = "console=ttyS0,115200 earlyprintk";
25 };
26
27 memory {
28 device_type = "memory";
29 reg = <0x00000000 0x20000000>; /* 512 MB */
30 };
31
32 soc {
33 serial@d0012000 {
34 clock-frequency = <200000000>;
35 status = "okay";
36 };
37 timer@d0020300 {
38 clock-frequency = <600000000>;
39 status = "okay";
40 };
41 };
42};
diff --git a/arch/arm/boot/dts/armada-370-xp.dtsi b/arch/arm/boot/dts/armada-370-xp.dtsi
new file mode 100644
index 00000000000..6b6b932a5a7
--- /dev/null
+++ b/arch/arm/boot/dts/armada-370-xp.dtsi
@@ -0,0 +1,68 @@
1/*
2 * Device Tree Include file for Marvell Armada 370 and Armada XP SoC
3 *
4 * Copyright (C) 2012 Marvell
5 *
6 * Lior Amsalem <alior@marvell.com>
7 * Gregory CLEMENT <gregory.clement@free-electrons.com>
8 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
9 * Ben Dooks <ben.dooks@codethink.co.uk>
10 *
11 * This file is licensed under the terms of the GNU General Public
12 * License version 2. This program is licensed "as is" without any
13 * warranty of any kind, whether express or implied.
14 *
15 * This file contains the definitions that are common to the Armada
16 * 370 and Armada XP SoC.
17 */
18
19/include/ "skeleton.dtsi"
20
21/ {
22 model = "Marvell Armada 370 and XP SoC";
23 compatible = "marvell,armada_370_xp";
24
25 cpus {
26 cpu@0 {
27 compatible = "marvell,sheeva-v7";
28 };
29 };
30
31 mpic: interrupt-controller@d0020000 {
32 compatible = "marvell,mpic";
33 #interrupt-cells = <1>;
34 #address-cells = <1>;
35 #size-cells = <1>;
36 interrupt-controller;
37 };
38
39 soc {
40 #address-cells = <1>;
41 #size-cells = <1>;
42 compatible = "simple-bus";
43 interrupt-parent = <&mpic>;
44 ranges;
45
46 serial@d0012000 {
47 compatible = "ns16550";
48 reg = <0xd0012000 0x100>;
49 reg-shift = <2>;
50 interrupts = <41>;
51 status = "disabled";
52 };
53 serial@d0012100 {
54 compatible = "ns16550";
55 reg = <0xd0012100 0x100>;
56 reg-shift = <2>;
57 interrupts = <42>;
58 status = "disabled";
59 };
60
61 timer@d0020300 {
62 compatible = "marvell,armada-370-xp-timer";
63 reg = <0xd0020300 0x30>;
64 interrupts = <37>, <38>, <39>, <40>;
65 };
66 };
67};
68
diff --git a/arch/arm/boot/dts/armada-370.dtsi b/arch/arm/boot/dts/armada-370.dtsi
new file mode 100644
index 00000000000..3228ccc8333
--- /dev/null
+++ b/arch/arm/boot/dts/armada-370.dtsi
@@ -0,0 +1,35 @@
1/*
2 * Device Tree Include file for Marvell Armada 370 family SoC
3 *
4 * Copyright (C) 2012 Marvell
5 *
6 * Lior Amsalem <alior@marvell.com>
7 * Gregory CLEMENT <gregory.clement@free-electrons.com>
8 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
9 *
10 * This file is licensed under the terms of the GNU General Public
11 * License version 2. This program is licensed "as is" without any
12 * warranty of any kind, whether express or implied.
13 *
14 * Contains definitions specific to the Armada 370 SoC that are not
15 * common to all Armada SoCs.
16 */
17
18/include/ "armada-370-xp.dtsi"
19
20/ {
21 model = "Marvell Armada 370 family SoC";
22 compatible = "marvell,armada370", "marvell,armada-370-xp";
23
24 mpic: interrupt-controller@d0020000 {
25 reg = <0xd0020a00 0x1d0>,
26 <0xd0021870 0x58>;
27 };
28
29 soc {
30 system-controller@d0018200 {
31 compatible = "marvell,armada-370-xp-system-controller";
32 reg = <0xd0018200 0x100>;
33 };
34 };
35};
diff --git a/arch/arm/boot/dts/armada-xp-db.dts b/arch/arm/boot/dts/armada-xp-db.dts
new file mode 100644
index 00000000000..f97040d4258
--- /dev/null
+++ b/arch/arm/boot/dts/armada-xp-db.dts
@@ -0,0 +1,50 @@
1/*
2 * Device Tree file for Marvell Armada XP evaluation board
3 * (DB-78460-BP)
4 *
5 * Copyright (C) 2012 Marvell
6 *
7 * Lior Amsalem <alior@marvell.com>
8 * Gregory CLEMENT <gregory.clement@free-electrons.com>
9 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
10 *
11 * This file is licensed under the terms of the GNU General Public
12 * License version 2. This program is licensed "as is" without any
13 * warranty of any kind, whether express or implied.
14 */
15
16/dts-v1/;
17/include/ "armada-xp.dtsi"
18
19/ {
20 model = "Marvell Armada XP Evaluation Board";
21 compatible = "marvell,axp-db", "marvell,armadaxp", "marvell,armada-370-xp";
22
23 chosen {
24 bootargs = "console=ttyS0,115200 earlyprintk";
25 };
26
27 memory {
28 device_type = "memory";
29 reg = <0x00000000 0x80000000>; /* 2 GB */
30 };
31
32 soc {
33 serial@d0012000 {
34 clock-frequency = <250000000>;
35 status = "okay";
36 };
37 serial@d0012100 {
38 clock-frequency = <250000000>;
39 status = "okay";
40 };
41 serial@d0012200 {
42 clock-frequency = <250000000>;
43 status = "okay";
44 };
45 serial@d0012300 {
46 clock-frequency = <250000000>;
47 status = "okay";
48 };
49 };
50};
diff --git a/arch/arm/boot/dts/armada-xp.dtsi b/arch/arm/boot/dts/armada-xp.dtsi
new file mode 100644
index 00000000000..71d6b5d0daf
--- /dev/null
+++ b/arch/arm/boot/dts/armada-xp.dtsi
@@ -0,0 +1,55 @@
1/*
2 * Device Tree Include file for Marvell Armada XP family SoC
3 *
4 * Copyright (C) 2012 Marvell
5 *
6 * Lior Amsalem <alior@marvell.com>
7 * Gregory CLEMENT <gregory.clement@free-electrons.com>
8 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
9 * Ben Dooks <ben.dooks@codethink.co.uk>
10 *
11 * This file is licensed under the terms of the GNU General Public
12 * License version 2. This program is licensed "as is" without any
13 * warranty of any kind, whether express or implied.
14 *
15 * Contains definitions specific to the Armada XP SoC that are not
16 * common to all Armada SoCs.
17 */
18
19/include/ "armada-370-xp.dtsi"
20
21/ {
22 model = "Marvell Armada XP family SoC";
23 compatible = "marvell,armadaxp", "marvell,armada-370-xp";
24
25 mpic: interrupt-controller@d0020000 {
26 reg = <0xd0020a00 0x1d0>,
27 <0xd0021870 0x58>;
28 };
29
30 soc {
31 serial@d0012200 {
32 compatible = "ns16550";
33 reg = <0xd0012200 0x100>;
34 reg-shift = <2>;
35 interrupts = <43>;
36 status = "disabled";
37 };
38 serial@d0012300 {
39 compatible = "ns16550";
40 reg = <0xd0012300 0x100>;
41 reg-shift = <2>;
42 interrupts = <44>;
43 status = "disabled";
44 };
45
46 timer@d0020300 {
47 marvell,timer-25Mhz;
48 };
49
50 system-controller@d0018200 {
51 compatible = "marvell,armada-370-xp-system-controller";
52 reg = <0xd0018200 0x500>;
53 };
54 };
55};
diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
index f449efc9825..66389c1c6f6 100644
--- a/arch/arm/boot/dts/at91sam9260.dtsi
+++ b/arch/arm/boot/dts/at91sam9260.dtsi
@@ -52,10 +52,11 @@
52 ranges; 52 ranges;
53 53
54 aic: interrupt-controller@fffff000 { 54 aic: interrupt-controller@fffff000 {
55 #interrupt-cells = <2>; 55 #interrupt-cells = <3>;
56 compatible = "atmel,at91rm9200-aic"; 56 compatible = "atmel,at91rm9200-aic";
57 interrupt-controller; 57 interrupt-controller;
58 reg = <0xfffff000 0x200>; 58 reg = <0xfffff000 0x200>;
59 atmel,external-irqs = <29 30 31>;
59 }; 60 };
60 61
61 ramc0: ramc@ffffea00 { 62 ramc0: ramc@ffffea00 {
@@ -81,25 +82,25 @@
81 pit: timer@fffffd30 { 82 pit: timer@fffffd30 {
82 compatible = "atmel,at91sam9260-pit"; 83 compatible = "atmel,at91sam9260-pit";
83 reg = <0xfffffd30 0xf>; 84 reg = <0xfffffd30 0xf>;
84 interrupts = <1 4>; 85 interrupts = <1 4 7>;
85 }; 86 };
86 87
87 tcb0: timer@fffa0000 { 88 tcb0: timer@fffa0000 {
88 compatible = "atmel,at91rm9200-tcb"; 89 compatible = "atmel,at91rm9200-tcb";
89 reg = <0xfffa0000 0x100>; 90 reg = <0xfffa0000 0x100>;
90 interrupts = <17 4 18 4 19 4>; 91 interrupts = <17 4 0 18 4 0 19 4 0>;
91 }; 92 };
92 93
93 tcb1: timer@fffdc000 { 94 tcb1: timer@fffdc000 {
94 compatible = "atmel,at91rm9200-tcb"; 95 compatible = "atmel,at91rm9200-tcb";
95 reg = <0xfffdc000 0x100>; 96 reg = <0xfffdc000 0x100>;
96 interrupts = <26 4 27 4 28 4>; 97 interrupts = <26 4 0 27 4 0 28 4 0>;
97 }; 98 };
98 99
99 pioA: gpio@fffff400 { 100 pioA: gpio@fffff400 {
100 compatible = "atmel,at91rm9200-gpio"; 101 compatible = "atmel,at91rm9200-gpio";
101 reg = <0xfffff400 0x100>; 102 reg = <0xfffff400 0x100>;
102 interrupts = <2 4>; 103 interrupts = <2 4 1>;
103 #gpio-cells = <2>; 104 #gpio-cells = <2>;
104 gpio-controller; 105 gpio-controller;
105 interrupt-controller; 106 interrupt-controller;
@@ -108,7 +109,7 @@
108 pioB: gpio@fffff600 { 109 pioB: gpio@fffff600 {
109 compatible = "atmel,at91rm9200-gpio"; 110 compatible = "atmel,at91rm9200-gpio";
110 reg = <0xfffff600 0x100>; 111 reg = <0xfffff600 0x100>;
111 interrupts = <3 4>; 112 interrupts = <3 4 1>;
112 #gpio-cells = <2>; 113 #gpio-cells = <2>;
113 gpio-controller; 114 gpio-controller;
114 interrupt-controller; 115 interrupt-controller;
@@ -117,7 +118,7 @@
117 pioC: gpio@fffff800 { 118 pioC: gpio@fffff800 {
118 compatible = "atmel,at91rm9200-gpio"; 119 compatible = "atmel,at91rm9200-gpio";
119 reg = <0xfffff800 0x100>; 120 reg = <0xfffff800 0x100>;
120 interrupts = <4 4>; 121 interrupts = <4 4 1>;
121 #gpio-cells = <2>; 122 #gpio-cells = <2>;
122 gpio-controller; 123 gpio-controller;
123 interrupt-controller; 124 interrupt-controller;
@@ -126,14 +127,14 @@
126 dbgu: serial@fffff200 { 127 dbgu: serial@fffff200 {
127 compatible = "atmel,at91sam9260-usart"; 128 compatible = "atmel,at91sam9260-usart";
128 reg = <0xfffff200 0x200>; 129 reg = <0xfffff200 0x200>;
129 interrupts = <1 4>; 130 interrupts = <1 4 7>;
130 status = "disabled"; 131 status = "disabled";
131 }; 132 };
132 133
133 usart0: serial@fffb0000 { 134 usart0: serial@fffb0000 {
134 compatible = "atmel,at91sam9260-usart"; 135 compatible = "atmel,at91sam9260-usart";
135 reg = <0xfffb0000 0x200>; 136 reg = <0xfffb0000 0x200>;
136 interrupts = <6 4>; 137 interrupts = <6 4 5>;
137 atmel,use-dma-rx; 138 atmel,use-dma-rx;
138 atmel,use-dma-tx; 139 atmel,use-dma-tx;
139 status = "disabled"; 140 status = "disabled";
@@ -142,7 +143,7 @@
142 usart1: serial@fffb4000 { 143 usart1: serial@fffb4000 {
143 compatible = "atmel,at91sam9260-usart"; 144 compatible = "atmel,at91sam9260-usart";
144 reg = <0xfffb4000 0x200>; 145 reg = <0xfffb4000 0x200>;
145 interrupts = <7 4>; 146 interrupts = <7 4 5>;
146 atmel,use-dma-rx; 147 atmel,use-dma-rx;
147 atmel,use-dma-tx; 148 atmel,use-dma-tx;
148 status = "disabled"; 149 status = "disabled";
@@ -151,7 +152,7 @@
151 usart2: serial@fffb8000 { 152 usart2: serial@fffb8000 {
152 compatible = "atmel,at91sam9260-usart"; 153 compatible = "atmel,at91sam9260-usart";
153 reg = <0xfffb8000 0x200>; 154 reg = <0xfffb8000 0x200>;
154 interrupts = <8 4>; 155 interrupts = <8 4 5>;
155 atmel,use-dma-rx; 156 atmel,use-dma-rx;
156 atmel,use-dma-tx; 157 atmel,use-dma-tx;
157 status = "disabled"; 158 status = "disabled";
@@ -160,7 +161,7 @@
160 usart3: serial@fffd0000 { 161 usart3: serial@fffd0000 {
161 compatible = "atmel,at91sam9260-usart"; 162 compatible = "atmel,at91sam9260-usart";
162 reg = <0xfffd0000 0x200>; 163 reg = <0xfffd0000 0x200>;
163 interrupts = <23 4>; 164 interrupts = <23 4 5>;
164 atmel,use-dma-rx; 165 atmel,use-dma-rx;
165 atmel,use-dma-tx; 166 atmel,use-dma-tx;
166 status = "disabled"; 167 status = "disabled";
@@ -169,7 +170,7 @@
169 usart4: serial@fffd4000 { 170 usart4: serial@fffd4000 {
170 compatible = "atmel,at91sam9260-usart"; 171 compatible = "atmel,at91sam9260-usart";
171 reg = <0xfffd4000 0x200>; 172 reg = <0xfffd4000 0x200>;
172 interrupts = <24 4>; 173 interrupts = <24 4 5>;
173 atmel,use-dma-rx; 174 atmel,use-dma-rx;
174 atmel,use-dma-tx; 175 atmel,use-dma-tx;
175 status = "disabled"; 176 status = "disabled";
@@ -178,7 +179,7 @@
178 usart5: serial@fffd8000 { 179 usart5: serial@fffd8000 {
179 compatible = "atmel,at91sam9260-usart"; 180 compatible = "atmel,at91sam9260-usart";
180 reg = <0xfffd8000 0x200>; 181 reg = <0xfffd8000 0x200>;
181 interrupts = <25 4>; 182 interrupts = <25 4 5>;
182 atmel,use-dma-rx; 183 atmel,use-dma-rx;
183 atmel,use-dma-tx; 184 atmel,use-dma-tx;
184 status = "disabled"; 185 status = "disabled";
@@ -187,21 +188,21 @@
187 macb0: ethernet@fffc4000 { 188 macb0: ethernet@fffc4000 {
188 compatible = "cdns,at32ap7000-macb", "cdns,macb"; 189 compatible = "cdns,at32ap7000-macb", "cdns,macb";
189 reg = <0xfffc4000 0x100>; 190 reg = <0xfffc4000 0x100>;
190 interrupts = <21 4>; 191 interrupts = <21 4 3>;
191 status = "disabled"; 192 status = "disabled";
192 }; 193 };
193 194
194 usb1: gadget@fffa4000 { 195 usb1: gadget@fffa4000 {
195 compatible = "atmel,at91rm9200-udc"; 196 compatible = "atmel,at91rm9200-udc";
196 reg = <0xfffa4000 0x4000>; 197 reg = <0xfffa4000 0x4000>;
197 interrupts = <10 4>; 198 interrupts = <10 4 2>;
198 status = "disabled"; 199 status = "disabled";
199 }; 200 };
200 201
201 adc0: adc@fffe0000 { 202 adc0: adc@fffe0000 {
202 compatible = "atmel,at91sam9260-adc"; 203 compatible = "atmel,at91sam9260-adc";
203 reg = <0xfffe0000 0x100>; 204 reg = <0xfffe0000 0x100>;
204 interrupts = <5 4>; 205 interrupts = <5 4 0>;
205 atmel,adc-use-external-triggers; 206 atmel,adc-use-external-triggers;
206 atmel,adc-channels-used = <0xf>; 207 atmel,adc-channels-used = <0xf>;
207 atmel,adc-vref = <3300>; 208 atmel,adc-vref = <3300>;
@@ -253,7 +254,7 @@
253 usb0: ohci@00500000 { 254 usb0: ohci@00500000 {
254 compatible = "atmel,at91rm9200-ohci", "usb-ohci"; 255 compatible = "atmel,at91rm9200-ohci", "usb-ohci";
255 reg = <0x00500000 0x100000>; 256 reg = <0x00500000 0x100000>;
256 interrupts = <20 4>; 257 interrupts = <20 4 2>;
257 status = "disabled"; 258 status = "disabled";
258 }; 259 };
259 }; 260 };
diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
index 0209913a65a..b460d6ce9eb 100644
--- a/arch/arm/boot/dts/at91sam9263.dtsi
+++ b/arch/arm/boot/dts/at91sam9263.dtsi
@@ -48,10 +48,11 @@
48 ranges; 48 ranges;
49 49
50 aic: interrupt-controller@fffff000 { 50 aic: interrupt-controller@fffff000 {
51 #interrupt-cells = <2>; 51 #interrupt-cells = <3>;
52 compatible = "atmel,at91rm9200-aic"; 52 compatible = "atmel,at91rm9200-aic";
53 interrupt-controller; 53 interrupt-controller;
54 reg = <0xfffff000 0x200>; 54 reg = <0xfffff000 0x200>;
55 atmel,external-irqs = <30 31>;
55 }; 56 };
56 57
57 pmc: pmc@fffffc00 { 58 pmc: pmc@fffffc00 {
@@ -68,13 +69,13 @@
68 pit: timer@fffffd30 { 69 pit: timer@fffffd30 {
69 compatible = "atmel,at91sam9260-pit"; 70 compatible = "atmel,at91sam9260-pit";
70 reg = <0xfffffd30 0xf>; 71 reg = <0xfffffd30 0xf>;
71 interrupts = <1 4>; 72 interrupts = <1 4 7>;
72 }; 73 };
73 74
74 tcb0: timer@fff7c000 { 75 tcb0: timer@fff7c000 {
75 compatible = "atmel,at91rm9200-tcb"; 76 compatible = "atmel,at91rm9200-tcb";
76 reg = <0xfff7c000 0x100>; 77 reg = <0xfff7c000 0x100>;
77 interrupts = <19 4>; 78 interrupts = <19 4 0>;
78 }; 79 };
79 80
80 rstc@fffffd00 { 81 rstc@fffffd00 {
@@ -90,7 +91,7 @@
90 pioA: gpio@fffff200 { 91 pioA: gpio@fffff200 {
91 compatible = "atmel,at91rm9200-gpio"; 92 compatible = "atmel,at91rm9200-gpio";
92 reg = <0xfffff200 0x100>; 93 reg = <0xfffff200 0x100>;
93 interrupts = <2 4>; 94 interrupts = <2 4 1>;
94 #gpio-cells = <2>; 95 #gpio-cells = <2>;
95 gpio-controller; 96 gpio-controller;
96 interrupt-controller; 97 interrupt-controller;
@@ -99,7 +100,7 @@
99 pioB: gpio@fffff400 { 100 pioB: gpio@fffff400 {
100 compatible = "atmel,at91rm9200-gpio"; 101 compatible = "atmel,at91rm9200-gpio";
101 reg = <0xfffff400 0x100>; 102 reg = <0xfffff400 0x100>;
102 interrupts = <3 4>; 103 interrupts = <3 4 1>;
103 #gpio-cells = <2>; 104 #gpio-cells = <2>;
104 gpio-controller; 105 gpio-controller;
105 interrupt-controller; 106 interrupt-controller;
@@ -108,7 +109,7 @@
108 pioC: gpio@fffff600 { 109 pioC: gpio@fffff600 {
109 compatible = "atmel,at91rm9200-gpio"; 110 compatible = "atmel,at91rm9200-gpio";
110 reg = <0xfffff600 0x100>; 111 reg = <0xfffff600 0x100>;
111 interrupts = <4 4>; 112 interrupts = <4 4 1>;
112 #gpio-cells = <2>; 113 #gpio-cells = <2>;
113 gpio-controller; 114 gpio-controller;
114 interrupt-controller; 115 interrupt-controller;
@@ -117,7 +118,7 @@
117 pioD: gpio@fffff800 { 118 pioD: gpio@fffff800 {
118 compatible = "atmel,at91rm9200-gpio"; 119 compatible = "atmel,at91rm9200-gpio";
119 reg = <0xfffff800 0x100>; 120 reg = <0xfffff800 0x100>;
120 interrupts = <4 4>; 121 interrupts = <4 4 1>;
121 #gpio-cells = <2>; 122 #gpio-cells = <2>;
122 gpio-controller; 123 gpio-controller;
123 interrupt-controller; 124 interrupt-controller;
@@ -126,7 +127,7 @@
126 pioE: gpio@fffffa00 { 127 pioE: gpio@fffffa00 {
127 compatible = "atmel,at91rm9200-gpio"; 128 compatible = "atmel,at91rm9200-gpio";
128 reg = <0xfffffa00 0x100>; 129 reg = <0xfffffa00 0x100>;
129 interrupts = <4 4>; 130 interrupts = <4 4 1>;
130 #gpio-cells = <2>; 131 #gpio-cells = <2>;
131 gpio-controller; 132 gpio-controller;
132 interrupt-controller; 133 interrupt-controller;
@@ -135,14 +136,14 @@
135 dbgu: serial@ffffee00 { 136 dbgu: serial@ffffee00 {
136 compatible = "atmel,at91sam9260-usart"; 137 compatible = "atmel,at91sam9260-usart";
137 reg = <0xffffee00 0x200>; 138 reg = <0xffffee00 0x200>;
138 interrupts = <1 4>; 139 interrupts = <1 4 7>;
139 status = "disabled"; 140 status = "disabled";
140 }; 141 };
141 142
142 usart0: serial@fff8c000 { 143 usart0: serial@fff8c000 {
143 compatible = "atmel,at91sam9260-usart"; 144 compatible = "atmel,at91sam9260-usart";
144 reg = <0xfff8c000 0x200>; 145 reg = <0xfff8c000 0x200>;
145 interrupts = <7 4>; 146 interrupts = <7 4 5>;
146 atmel,use-dma-rx; 147 atmel,use-dma-rx;
147 atmel,use-dma-tx; 148 atmel,use-dma-tx;
148 status = "disabled"; 149 status = "disabled";
@@ -151,7 +152,7 @@
151 usart1: serial@fff90000 { 152 usart1: serial@fff90000 {
152 compatible = "atmel,at91sam9260-usart"; 153 compatible = "atmel,at91sam9260-usart";
153 reg = <0xfff90000 0x200>; 154 reg = <0xfff90000 0x200>;
154 interrupts = <8 4>; 155 interrupts = <8 4 5>;
155 atmel,use-dma-rx; 156 atmel,use-dma-rx;
156 atmel,use-dma-tx; 157 atmel,use-dma-tx;
157 status = "disabled"; 158 status = "disabled";
@@ -160,7 +161,7 @@
160 usart2: serial@fff94000 { 161 usart2: serial@fff94000 {
161 compatible = "atmel,at91sam9260-usart"; 162 compatible = "atmel,at91sam9260-usart";
162 reg = <0xfff94000 0x200>; 163 reg = <0xfff94000 0x200>;
163 interrupts = <9 4>; 164 interrupts = <9 4 5>;
164 atmel,use-dma-rx; 165 atmel,use-dma-rx;
165 atmel,use-dma-tx; 166 atmel,use-dma-tx;
166 status = "disabled"; 167 status = "disabled";
@@ -169,14 +170,14 @@
169 macb0: ethernet@fffbc000 { 170 macb0: ethernet@fffbc000 {
170 compatible = "cdns,at32ap7000-macb", "cdns,macb"; 171 compatible = "cdns,at32ap7000-macb", "cdns,macb";
171 reg = <0xfffbc000 0x100>; 172 reg = <0xfffbc000 0x100>;
172 interrupts = <21 4>; 173 interrupts = <21 4 3>;
173 status = "disabled"; 174 status = "disabled";
174 }; 175 };
175 176
176 usb1: gadget@fff78000 { 177 usb1: gadget@fff78000 {
177 compatible = "atmel,at91rm9200-udc"; 178 compatible = "atmel,at91rm9200-udc";
178 reg = <0xfff78000 0x4000>; 179 reg = <0xfff78000 0x4000>;
179 interrupts = <24 4>; 180 interrupts = <24 4 2>;
180 status = "disabled"; 181 status = "disabled";
181 }; 182 };
182 }; 183 };
@@ -200,7 +201,7 @@
200 usb0: ohci@00a00000 { 201 usb0: ohci@00a00000 {
201 compatible = "atmel,at91rm9200-ohci", "usb-ohci"; 202 compatible = "atmel,at91rm9200-ohci", "usb-ohci";
202 reg = <0x00a00000 0x100000>; 203 reg = <0x00a00000 0x100000>;
203 interrupts = <29 4>; 204 interrupts = <29 4 2>;
204 status = "disabled"; 205 status = "disabled";
205 }; 206 };
206 }; 207 };
diff --git a/arch/arm/boot/dts/at91sam9g25ek.dts b/arch/arm/boot/dts/at91sam9g25ek.dts
index 7829a4d0cb2..96514c134e5 100644
--- a/arch/arm/boot/dts/at91sam9g25ek.dts
+++ b/arch/arm/boot/dts/at91sam9g25ek.dts
@@ -15,7 +15,7 @@
15 compatible = "atmel,at91sam9g25ek", "atmel,at91sam9x5ek", "atmel,at91sam9x5", "atmel,at91sam9"; 15 compatible = "atmel,at91sam9g25ek", "atmel,at91sam9x5ek", "atmel,at91sam9x5", "atmel,at91sam9";
16 16
17 chosen { 17 chosen {
18 bootargs = "128M console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs"; 18 bootargs = "console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs";
19 }; 19 };
20 20
21 ahb { 21 ahb {
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index 7dbccaf199f..bafa8806fc1 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -53,10 +53,11 @@
53 ranges; 53 ranges;
54 54
55 aic: interrupt-controller@fffff000 { 55 aic: interrupt-controller@fffff000 {
56 #interrupt-cells = <2>; 56 #interrupt-cells = <3>;
57 compatible = "atmel,at91rm9200-aic"; 57 compatible = "atmel,at91rm9200-aic";
58 interrupt-controller; 58 interrupt-controller;
59 reg = <0xfffff000 0x200>; 59 reg = <0xfffff000 0x200>;
60 atmel,external-irqs = <31>;
60 }; 61 };
61 62
62 ramc0: ramc@ffffe400 { 63 ramc0: ramc@ffffe400 {
@@ -78,7 +79,7 @@
78 pit: timer@fffffd30 { 79 pit: timer@fffffd30 {
79 compatible = "atmel,at91sam9260-pit"; 80 compatible = "atmel,at91sam9260-pit";
80 reg = <0xfffffd30 0xf>; 81 reg = <0xfffffd30 0xf>;
81 interrupts = <1 4>; 82 interrupts = <1 4 7>;
82 }; 83 };
83 84
84 85
@@ -90,25 +91,25 @@
90 tcb0: timer@fff7c000 { 91 tcb0: timer@fff7c000 {
91 compatible = "atmel,at91rm9200-tcb"; 92 compatible = "atmel,at91rm9200-tcb";
92 reg = <0xfff7c000 0x100>; 93 reg = <0xfff7c000 0x100>;
93 interrupts = <18 4>; 94 interrupts = <18 4 0>;
94 }; 95 };
95 96
96 tcb1: timer@fffd4000 { 97 tcb1: timer@fffd4000 {
97 compatible = "atmel,at91rm9200-tcb"; 98 compatible = "atmel,at91rm9200-tcb";
98 reg = <0xfffd4000 0x100>; 99 reg = <0xfffd4000 0x100>;
99 interrupts = <18 4>; 100 interrupts = <18 4 0>;
100 }; 101 };
101 102
102 dma: dma-controller@ffffec00 { 103 dma: dma-controller@ffffec00 {
103 compatible = "atmel,at91sam9g45-dma"; 104 compatible = "atmel,at91sam9g45-dma";
104 reg = <0xffffec00 0x200>; 105 reg = <0xffffec00 0x200>;
105 interrupts = <21 4>; 106 interrupts = <21 4 0>;
106 }; 107 };
107 108
108 pioA: gpio@fffff200 { 109 pioA: gpio@fffff200 {
109 compatible = "atmel,at91rm9200-gpio"; 110 compatible = "atmel,at91rm9200-gpio";
110 reg = <0xfffff200 0x100>; 111 reg = <0xfffff200 0x100>;
111 interrupts = <2 4>; 112 interrupts = <2 4 1>;
112 #gpio-cells = <2>; 113 #gpio-cells = <2>;
113 gpio-controller; 114 gpio-controller;
114 interrupt-controller; 115 interrupt-controller;
@@ -117,7 +118,7 @@
117 pioB: gpio@fffff400 { 118 pioB: gpio@fffff400 {
118 compatible = "atmel,at91rm9200-gpio"; 119 compatible = "atmel,at91rm9200-gpio";
119 reg = <0xfffff400 0x100>; 120 reg = <0xfffff400 0x100>;
120 interrupts = <3 4>; 121 interrupts = <3 4 1>;
121 #gpio-cells = <2>; 122 #gpio-cells = <2>;
122 gpio-controller; 123 gpio-controller;
123 interrupt-controller; 124 interrupt-controller;
@@ -126,7 +127,7 @@
126 pioC: gpio@fffff600 { 127 pioC: gpio@fffff600 {
127 compatible = "atmel,at91rm9200-gpio"; 128 compatible = "atmel,at91rm9200-gpio";
128 reg = <0xfffff600 0x100>; 129 reg = <0xfffff600 0x100>;
129 interrupts = <4 4>; 130 interrupts = <4 4 1>;
130 #gpio-cells = <2>; 131 #gpio-cells = <2>;
131 gpio-controller; 132 gpio-controller;
132 interrupt-controller; 133 interrupt-controller;
@@ -135,7 +136,7 @@
135 pioD: gpio@fffff800 { 136 pioD: gpio@fffff800 {
136 compatible = "atmel,at91rm9200-gpio"; 137 compatible = "atmel,at91rm9200-gpio";
137 reg = <0xfffff800 0x100>; 138 reg = <0xfffff800 0x100>;
138 interrupts = <5 4>; 139 interrupts = <5 4 1>;
139 #gpio-cells = <2>; 140 #gpio-cells = <2>;
140 gpio-controller; 141 gpio-controller;
141 interrupt-controller; 142 interrupt-controller;
@@ -144,7 +145,7 @@
144 pioE: gpio@fffffa00 { 145 pioE: gpio@fffffa00 {
145 compatible = "atmel,at91rm9200-gpio"; 146 compatible = "atmel,at91rm9200-gpio";
146 reg = <0xfffffa00 0x100>; 147 reg = <0xfffffa00 0x100>;
147 interrupts = <5 4>; 148 interrupts = <5 4 1>;
148 #gpio-cells = <2>; 149 #gpio-cells = <2>;
149 gpio-controller; 150 gpio-controller;
150 interrupt-controller; 151 interrupt-controller;
@@ -153,14 +154,14 @@
153 dbgu: serial@ffffee00 { 154 dbgu: serial@ffffee00 {
154 compatible = "atmel,at91sam9260-usart"; 155 compatible = "atmel,at91sam9260-usart";
155 reg = <0xffffee00 0x200>; 156 reg = <0xffffee00 0x200>;
156 interrupts = <1 4>; 157 interrupts = <1 4 7>;
157 status = "disabled"; 158 status = "disabled";
158 }; 159 };
159 160
160 usart0: serial@fff8c000 { 161 usart0: serial@fff8c000 {
161 compatible = "atmel,at91sam9260-usart"; 162 compatible = "atmel,at91sam9260-usart";
162 reg = <0xfff8c000 0x200>; 163 reg = <0xfff8c000 0x200>;
163 interrupts = <7 4>; 164 interrupts = <7 4 5>;
164 atmel,use-dma-rx; 165 atmel,use-dma-rx;
165 atmel,use-dma-tx; 166 atmel,use-dma-tx;
166 status = "disabled"; 167 status = "disabled";
@@ -169,7 +170,7 @@
169 usart1: serial@fff90000 { 170 usart1: serial@fff90000 {
170 compatible = "atmel,at91sam9260-usart"; 171 compatible = "atmel,at91sam9260-usart";
171 reg = <0xfff90000 0x200>; 172 reg = <0xfff90000 0x200>;
172 interrupts = <8 4>; 173 interrupts = <8 4 5>;
173 atmel,use-dma-rx; 174 atmel,use-dma-rx;
174 atmel,use-dma-tx; 175 atmel,use-dma-tx;
175 status = "disabled"; 176 status = "disabled";
@@ -178,7 +179,7 @@
178 usart2: serial@fff94000 { 179 usart2: serial@fff94000 {
179 compatible = "atmel,at91sam9260-usart"; 180 compatible = "atmel,at91sam9260-usart";
180 reg = <0xfff94000 0x200>; 181 reg = <0xfff94000 0x200>;
181 interrupts = <9 4>; 182 interrupts = <9 4 5>;
182 atmel,use-dma-rx; 183 atmel,use-dma-rx;
183 atmel,use-dma-tx; 184 atmel,use-dma-tx;
184 status = "disabled"; 185 status = "disabled";
@@ -187,7 +188,7 @@
187 usart3: serial@fff98000 { 188 usart3: serial@fff98000 {
188 compatible = "atmel,at91sam9260-usart"; 189 compatible = "atmel,at91sam9260-usart";
189 reg = <0xfff98000 0x200>; 190 reg = <0xfff98000 0x200>;
190 interrupts = <10 4>; 191 interrupts = <10 4 5>;
191 atmel,use-dma-rx; 192 atmel,use-dma-rx;
192 atmel,use-dma-tx; 193 atmel,use-dma-tx;
193 status = "disabled"; 194 status = "disabled";
@@ -196,14 +197,14 @@
196 macb0: ethernet@fffbc000 { 197 macb0: ethernet@fffbc000 {
197 compatible = "cdns,at32ap7000-macb", "cdns,macb"; 198 compatible = "cdns,at32ap7000-macb", "cdns,macb";
198 reg = <0xfffbc000 0x100>; 199 reg = <0xfffbc000 0x100>;
199 interrupts = <25 4>; 200 interrupts = <25 4 3>;
200 status = "disabled"; 201 status = "disabled";
201 }; 202 };
202 203
203 adc0: adc@fffb0000 { 204 adc0: adc@fffb0000 {
204 compatible = "atmel,at91sam9260-adc"; 205 compatible = "atmel,at91sam9260-adc";
205 reg = <0xfffb0000 0x100>; 206 reg = <0xfffb0000 0x100>;
206 interrupts = <20 4>; 207 interrupts = <20 4 0>;
207 atmel,adc-use-external-triggers; 208 atmel,adc-use-external-triggers;
208 atmel,adc-channels-used = <0xff>; 209 atmel,adc-channels-used = <0xff>;
209 atmel,adc-vref = <3300>; 210 atmel,adc-vref = <3300>;
@@ -257,14 +258,14 @@
257 usb0: ohci@00700000 { 258 usb0: ohci@00700000 {
258 compatible = "atmel,at91rm9200-ohci", "usb-ohci"; 259 compatible = "atmel,at91rm9200-ohci", "usb-ohci";
259 reg = <0x00700000 0x100000>; 260 reg = <0x00700000 0x100000>;
260 interrupts = <22 4>; 261 interrupts = <22 4 2>;
261 status = "disabled"; 262 status = "disabled";
262 }; 263 };
263 264
264 usb1: ehci@00800000 { 265 usb1: ehci@00800000 {
265 compatible = "atmel,at91sam9g45-ehci", "usb-ehci"; 266 compatible = "atmel,at91sam9g45-ehci", "usb-ehci";
266 reg = <0x00800000 0x100000>; 267 reg = <0x00800000 0x100000>;
267 interrupts = <22 4>; 268 interrupts = <22 4 2>;
268 status = "disabled"; 269 status = "disabled";
269 }; 270 };
270 }; 271 };
diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
index cb84de791b5..bfac0dfc332 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -50,7 +50,7 @@
50 ranges; 50 ranges;
51 51
52 aic: interrupt-controller@fffff000 { 52 aic: interrupt-controller@fffff000 {
53 #interrupt-cells = <2>; 53 #interrupt-cells = <3>;
54 compatible = "atmel,at91rm9200-aic"; 54 compatible = "atmel,at91rm9200-aic";
55 interrupt-controller; 55 interrupt-controller;
56 reg = <0xfffff000 0x200>; 56 reg = <0xfffff000 0x200>;
@@ -74,7 +74,7 @@
74 pit: timer@fffffe30 { 74 pit: timer@fffffe30 {
75 compatible = "atmel,at91sam9260-pit"; 75 compatible = "atmel,at91sam9260-pit";
76 reg = <0xfffffe30 0xf>; 76 reg = <0xfffffe30 0xf>;
77 interrupts = <1 4>; 77 interrupts = <1 4 7>;
78 }; 78 };
79 79
80 shdwc@fffffe10 { 80 shdwc@fffffe10 {
@@ -85,25 +85,25 @@
85 tcb0: timer@f8008000 { 85 tcb0: timer@f8008000 {
86 compatible = "atmel,at91sam9x5-tcb"; 86 compatible = "atmel,at91sam9x5-tcb";
87 reg = <0xf8008000 0x100>; 87 reg = <0xf8008000 0x100>;
88 interrupts = <17 4>; 88 interrupts = <17 4 0>;
89 }; 89 };
90 90
91 tcb1: timer@f800c000 { 91 tcb1: timer@f800c000 {
92 compatible = "atmel,at91sam9x5-tcb"; 92 compatible = "atmel,at91sam9x5-tcb";
93 reg = <0xf800c000 0x100>; 93 reg = <0xf800c000 0x100>;
94 interrupts = <17 4>; 94 interrupts = <17 4 0>;
95 }; 95 };
96 96
97 dma: dma-controller@ffffec00 { 97 dma: dma-controller@ffffec00 {
98 compatible = "atmel,at91sam9g45-dma"; 98 compatible = "atmel,at91sam9g45-dma";
99 reg = <0xffffec00 0x200>; 99 reg = <0xffffec00 0x200>;
100 interrupts = <20 4>; 100 interrupts = <20 4 0>;
101 }; 101 };
102 102
103 pioA: gpio@fffff400 { 103 pioA: gpio@fffff400 {
104 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 104 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio";
105 reg = <0xfffff400 0x100>; 105 reg = <0xfffff400 0x100>;
106 interrupts = <2 4>; 106 interrupts = <2 4 1>;
107 #gpio-cells = <2>; 107 #gpio-cells = <2>;
108 gpio-controller; 108 gpio-controller;
109 interrupt-controller; 109 interrupt-controller;
@@ -112,7 +112,7 @@
112 pioB: gpio@fffff600 { 112 pioB: gpio@fffff600 {
113 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 113 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio";
114 reg = <0xfffff600 0x100>; 114 reg = <0xfffff600 0x100>;
115 interrupts = <2 4>; 115 interrupts = <2 4 1>;
116 #gpio-cells = <2>; 116 #gpio-cells = <2>;
117 gpio-controller; 117 gpio-controller;
118 interrupt-controller; 118 interrupt-controller;
@@ -121,7 +121,7 @@
121 pioC: gpio@fffff800 { 121 pioC: gpio@fffff800 {
122 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 122 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio";
123 reg = <0xfffff800 0x100>; 123 reg = <0xfffff800 0x100>;
124 interrupts = <3 4>; 124 interrupts = <3 4 1>;
125 #gpio-cells = <2>; 125 #gpio-cells = <2>;
126 gpio-controller; 126 gpio-controller;
127 interrupt-controller; 127 interrupt-controller;
@@ -130,7 +130,7 @@
130 pioD: gpio@fffffa00 { 130 pioD: gpio@fffffa00 {
131 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 131 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio";
132 reg = <0xfffffa00 0x100>; 132 reg = <0xfffffa00 0x100>;
133 interrupts = <3 4>; 133 interrupts = <3 4 1>;
134 #gpio-cells = <2>; 134 #gpio-cells = <2>;
135 gpio-controller; 135 gpio-controller;
136 interrupt-controller; 136 interrupt-controller;
@@ -139,14 +139,14 @@
139 dbgu: serial@fffff200 { 139 dbgu: serial@fffff200 {
140 compatible = "atmel,at91sam9260-usart"; 140 compatible = "atmel,at91sam9260-usart";
141 reg = <0xfffff200 0x200>; 141 reg = <0xfffff200 0x200>;
142 interrupts = <1 4>; 142 interrupts = <1 4 7>;
143 status = "disabled"; 143 status = "disabled";
144 }; 144 };
145 145
146 usart0: serial@f801c000 { 146 usart0: serial@f801c000 {
147 compatible = "atmel,at91sam9260-usart"; 147 compatible = "atmel,at91sam9260-usart";
148 reg = <0xf801c000 0x4000>; 148 reg = <0xf801c000 0x4000>;
149 interrupts = <5 4>; 149 interrupts = <5 4 5>;
150 atmel,use-dma-rx; 150 atmel,use-dma-rx;
151 atmel,use-dma-tx; 151 atmel,use-dma-tx;
152 status = "disabled"; 152 status = "disabled";
@@ -155,7 +155,7 @@
155 usart1: serial@f8020000 { 155 usart1: serial@f8020000 {
156 compatible = "atmel,at91sam9260-usart"; 156 compatible = "atmel,at91sam9260-usart";
157 reg = <0xf8020000 0x4000>; 157 reg = <0xf8020000 0x4000>;
158 interrupts = <6 4>; 158 interrupts = <6 4 5>;
159 atmel,use-dma-rx; 159 atmel,use-dma-rx;
160 atmel,use-dma-tx; 160 atmel,use-dma-tx;
161 status = "disabled"; 161 status = "disabled";
@@ -164,7 +164,7 @@
164 usart2: serial@f8024000 { 164 usart2: serial@f8024000 {
165 compatible = "atmel,at91sam9260-usart"; 165 compatible = "atmel,at91sam9260-usart";
166 reg = <0xf8024000 0x4000>; 166 reg = <0xf8024000 0x4000>;
167 interrupts = <7 4>; 167 interrupts = <7 4 5>;
168 atmel,use-dma-rx; 168 atmel,use-dma-rx;
169 atmel,use-dma-tx; 169 atmel,use-dma-tx;
170 status = "disabled"; 170 status = "disabled";
@@ -173,7 +173,7 @@
173 usart3: serial@f8028000 { 173 usart3: serial@f8028000 {
174 compatible = "atmel,at91sam9260-usart"; 174 compatible = "atmel,at91sam9260-usart";
175 reg = <0xf8028000 0x4000>; 175 reg = <0xf8028000 0x4000>;
176 interrupts = <8 4>; 176 interrupts = <8 4 5>;
177 atmel,use-dma-rx; 177 atmel,use-dma-rx;
178 atmel,use-dma-tx; 178 atmel,use-dma-tx;
179 status = "disabled"; 179 status = "disabled";
@@ -201,7 +201,7 @@
201 usb0: ohci@00500000 { 201 usb0: ohci@00500000 {
202 compatible = "atmel,at91rm9200-ohci", "usb-ohci"; 202 compatible = "atmel,at91rm9200-ohci", "usb-ohci";
203 reg = <0x00500000 0x00100000>; 203 reg = <0x00500000 0x00100000>;
204 interrupts = <22 4>; 204 interrupts = <22 4 2>;
205 status = "disabled"; 205 status = "disabled";
206 }; 206 };
207 }; 207 };
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index 6b3ef4339ae..4a18c393b13 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -51,10 +51,11 @@
51 ranges; 51 ranges;
52 52
53 aic: interrupt-controller@fffff000 { 53 aic: interrupt-controller@fffff000 {
54 #interrupt-cells = <2>; 54 #interrupt-cells = <3>;
55 compatible = "atmel,at91rm9200-aic"; 55 compatible = "atmel,at91rm9200-aic";
56 interrupt-controller; 56 interrupt-controller;
57 reg = <0xfffff000 0x200>; 57 reg = <0xfffff000 0x200>;
58 atmel,external-irqs = <31>;
58 }; 59 };
59 60
60 ramc0: ramc@ffffe800 { 61 ramc0: ramc@ffffe800 {
@@ -80,37 +81,37 @@
80 pit: timer@fffffe30 { 81 pit: timer@fffffe30 {
81 compatible = "atmel,at91sam9260-pit"; 82 compatible = "atmel,at91sam9260-pit";
82 reg = <0xfffffe30 0xf>; 83 reg = <0xfffffe30 0xf>;
83 interrupts = <1 4>; 84 interrupts = <1 4 7>;
84 }; 85 };
85 86
86 tcb0: timer@f8008000 { 87 tcb0: timer@f8008000 {
87 compatible = "atmel,at91sam9x5-tcb"; 88 compatible = "atmel,at91sam9x5-tcb";
88 reg = <0xf8008000 0x100>; 89 reg = <0xf8008000 0x100>;
89 interrupts = <17 4>; 90 interrupts = <17 4 0>;
90 }; 91 };
91 92
92 tcb1: timer@f800c000 { 93 tcb1: timer@f800c000 {
93 compatible = "atmel,at91sam9x5-tcb"; 94 compatible = "atmel,at91sam9x5-tcb";
94 reg = <0xf800c000 0x100>; 95 reg = <0xf800c000 0x100>;
95 interrupts = <17 4>; 96 interrupts = <17 4 0>;
96 }; 97 };
97 98
98 dma0: dma-controller@ffffec00 { 99 dma0: dma-controller@ffffec00 {
99 compatible = "atmel,at91sam9g45-dma"; 100 compatible = "atmel,at91sam9g45-dma";
100 reg = <0xffffec00 0x200>; 101 reg = <0xffffec00 0x200>;
101 interrupts = <20 4>; 102 interrupts = <20 4 0>;
102 }; 103 };
103 104
104 dma1: dma-controller@ffffee00 { 105 dma1: dma-controller@ffffee00 {
105 compatible = "atmel,at91sam9g45-dma"; 106 compatible = "atmel,at91sam9g45-dma";
106 reg = <0xffffee00 0x200>; 107 reg = <0xffffee00 0x200>;
107 interrupts = <21 4>; 108 interrupts = <21 4 0>;
108 }; 109 };
109 110
110 pioA: gpio@fffff400 { 111 pioA: gpio@fffff400 {
111 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 112 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio";
112 reg = <0xfffff400 0x100>; 113 reg = <0xfffff400 0x100>;
113 interrupts = <2 4>; 114 interrupts = <2 4 1>;
114 #gpio-cells = <2>; 115 #gpio-cells = <2>;
115 gpio-controller; 116 gpio-controller;
116 interrupt-controller; 117 interrupt-controller;
@@ -119,7 +120,7 @@
119 pioB: gpio@fffff600 { 120 pioB: gpio@fffff600 {
120 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 121 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio";
121 reg = <0xfffff600 0x100>; 122 reg = <0xfffff600 0x100>;
122 interrupts = <2 4>; 123 interrupts = <2 4 1>;
123 #gpio-cells = <2>; 124 #gpio-cells = <2>;
124 gpio-controller; 125 gpio-controller;
125 interrupt-controller; 126 interrupt-controller;
@@ -128,7 +129,7 @@
128 pioC: gpio@fffff800 { 129 pioC: gpio@fffff800 {
129 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 130 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio";
130 reg = <0xfffff800 0x100>; 131 reg = <0xfffff800 0x100>;
131 interrupts = <3 4>; 132 interrupts = <3 4 1>;
132 #gpio-cells = <2>; 133 #gpio-cells = <2>;
133 gpio-controller; 134 gpio-controller;
134 interrupt-controller; 135 interrupt-controller;
@@ -137,7 +138,7 @@
137 pioD: gpio@fffffa00 { 138 pioD: gpio@fffffa00 {
138 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio"; 139 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio";
139 reg = <0xfffffa00 0x100>; 140 reg = <0xfffffa00 0x100>;
140 interrupts = <3 4>; 141 interrupts = <3 4 1>;
141 #gpio-cells = <2>; 142 #gpio-cells = <2>;
142 gpio-controller; 143 gpio-controller;
143 interrupt-controller; 144 interrupt-controller;
@@ -146,14 +147,14 @@
146 dbgu: serial@fffff200 { 147 dbgu: serial@fffff200 {
147 compatible = "atmel,at91sam9260-usart"; 148 compatible = "atmel,at91sam9260-usart";
148 reg = <0xfffff200 0x200>; 149 reg = <0xfffff200 0x200>;
149 interrupts = <1 4>; 150 interrupts = <1 4 7>;
150 status = "disabled"; 151 status = "disabled";
151 }; 152 };
152 153
153 usart0: serial@f801c000 { 154 usart0: serial@f801c000 {
154 compatible = "atmel,at91sam9260-usart"; 155 compatible = "atmel,at91sam9260-usart";
155 reg = <0xf801c000 0x200>; 156 reg = <0xf801c000 0x200>;
156 interrupts = <5 4>; 157 interrupts = <5 4 5>;
157 atmel,use-dma-rx; 158 atmel,use-dma-rx;
158 atmel,use-dma-tx; 159 atmel,use-dma-tx;
159 status = "disabled"; 160 status = "disabled";
@@ -162,7 +163,7 @@
162 usart1: serial@f8020000 { 163 usart1: serial@f8020000 {
163 compatible = "atmel,at91sam9260-usart"; 164 compatible = "atmel,at91sam9260-usart";
164 reg = <0xf8020000 0x200>; 165 reg = <0xf8020000 0x200>;
165 interrupts = <6 4>; 166 interrupts = <6 4 5>;
166 atmel,use-dma-rx; 167 atmel,use-dma-rx;
167 atmel,use-dma-tx; 168 atmel,use-dma-tx;
168 status = "disabled"; 169 status = "disabled";
@@ -171,7 +172,7 @@
171 usart2: serial@f8024000 { 172 usart2: serial@f8024000 {
172 compatible = "atmel,at91sam9260-usart"; 173 compatible = "atmel,at91sam9260-usart";
173 reg = <0xf8024000 0x200>; 174 reg = <0xf8024000 0x200>;
174 interrupts = <7 4>; 175 interrupts = <7 4 5>;
175 atmel,use-dma-rx; 176 atmel,use-dma-rx;
176 atmel,use-dma-tx; 177 atmel,use-dma-tx;
177 status = "disabled"; 178 status = "disabled";
@@ -180,21 +181,21 @@
180 macb0: ethernet@f802c000 { 181 macb0: ethernet@f802c000 {
181 compatible = "cdns,at32ap7000-macb", "cdns,macb"; 182 compatible = "cdns,at32ap7000-macb", "cdns,macb";
182 reg = <0xf802c000 0x100>; 183 reg = <0xf802c000 0x100>;
183 interrupts = <24 4>; 184 interrupts = <24 4 3>;
184 status = "disabled"; 185 status = "disabled";
185 }; 186 };
186 187
187 macb1: ethernet@f8030000 { 188 macb1: ethernet@f8030000 {
188 compatible = "cdns,at32ap7000-macb", "cdns,macb"; 189 compatible = "cdns,at32ap7000-macb", "cdns,macb";
189 reg = <0xf8030000 0x100>; 190 reg = <0xf8030000 0x100>;
190 interrupts = <27 4>; 191 interrupts = <27 4 3>;
191 status = "disabled"; 192 status = "disabled";
192 }; 193 };
193 194
194 adc0: adc@f804c000 { 195 adc0: adc@f804c000 {
195 compatible = "atmel,at91sam9260-adc"; 196 compatible = "atmel,at91sam9260-adc";
196 reg = <0xf804c000 0x100>; 197 reg = <0xf804c000 0x100>;
197 interrupts = <19 4>; 198 interrupts = <19 4 0>;
198 atmel,adc-use-external; 199 atmel,adc-use-external;
199 atmel,adc-channels-used = <0xffff>; 200 atmel,adc-channels-used = <0xffff>;
200 atmel,adc-vref = <3300>; 201 atmel,adc-vref = <3300>;
@@ -248,14 +249,14 @@
248 usb0: ohci@00600000 { 249 usb0: ohci@00600000 {
249 compatible = "atmel,at91rm9200-ohci", "usb-ohci"; 250 compatible = "atmel,at91rm9200-ohci", "usb-ohci";
250 reg = <0x00600000 0x100000>; 251 reg = <0x00600000 0x100000>;
251 interrupts = <22 4>; 252 interrupts = <22 4 2>;
252 status = "disabled"; 253 status = "disabled";
253 }; 254 };
254 255
255 usb1: ehci@00700000 { 256 usb1: ehci@00700000 {
256 compatible = "atmel,at91sam9g45-ehci", "usb-ehci"; 257 compatible = "atmel,at91sam9g45-ehci", "usb-ehci";
257 reg = <0x00700000 0x100000>; 258 reg = <0x00700000 0x100000>;
258 interrupts = <22 4>; 259 interrupts = <22 4 2>;
259 status = "disabled"; 260 status = "disabled";
260 }; 261 };
261 }; 262 };
diff --git a/arch/arm/boot/dts/db8500.dtsi b/arch/arm/boot/dts/db8500.dtsi
index 4ad5160018c..3180a9c588b 100644
--- a/arch/arm/boot/dts/db8500.dtsi
+++ b/arch/arm/boot/dts/db8500.dtsi
@@ -48,7 +48,7 @@
48 }; 48 };
49 49
50 rtc@80154000 { 50 rtc@80154000 {
51 compatible = "stericsson,db8500-rtc"; 51 compatible = "arm,rtc-pl031", "arm,primecell";
52 reg = <0x80154000 0x1000>; 52 reg = <0x80154000 0x1000>;
53 interrupts = <0 18 0x4>; 53 interrupts = <0 18 0x4>;
54 }; 54 };
@@ -60,7 +60,7 @@
60 interrupts = <0 119 0x4>; 60 interrupts = <0 119 0x4>;
61 interrupt-controller; 61 interrupt-controller;
62 #interrupt-cells = <2>; 62 #interrupt-cells = <2>;
63 supports-sleepmode; 63 st,supports-sleepmode;
64 gpio-controller; 64 gpio-controller;
65 #gpio-cells = <2>; 65 #gpio-cells = <2>;
66 gpio-bank = <0>; 66 gpio-bank = <0>;
@@ -73,7 +73,7 @@
73 interrupts = <0 120 0x4>; 73 interrupts = <0 120 0x4>;
74 interrupt-controller; 74 interrupt-controller;
75 #interrupt-cells = <2>; 75 #interrupt-cells = <2>;
76 supports-sleepmode; 76 st,supports-sleepmode;
77 gpio-controller; 77 gpio-controller;
78 #gpio-cells = <2>; 78 #gpio-cells = <2>;
79 gpio-bank = <1>; 79 gpio-bank = <1>;
@@ -86,7 +86,7 @@
86 interrupts = <0 121 0x4>; 86 interrupts = <0 121 0x4>;
87 interrupt-controller; 87 interrupt-controller;
88 #interrupt-cells = <2>; 88 #interrupt-cells = <2>;
89 supports-sleepmode; 89 st,supports-sleepmode;
90 gpio-controller; 90 gpio-controller;
91 #gpio-cells = <2>; 91 #gpio-cells = <2>;
92 gpio-bank = <2>; 92 gpio-bank = <2>;
@@ -99,7 +99,7 @@
99 interrupts = <0 122 0x4>; 99 interrupts = <0 122 0x4>;
100 interrupt-controller; 100 interrupt-controller;
101 #interrupt-cells = <2>; 101 #interrupt-cells = <2>;
102 supports-sleepmode; 102 st,supports-sleepmode;
103 gpio-controller; 103 gpio-controller;
104 #gpio-cells = <2>; 104 #gpio-cells = <2>;
105 gpio-bank = <3>; 105 gpio-bank = <3>;
@@ -112,7 +112,7 @@
112 interrupts = <0 123 0x4>; 112 interrupts = <0 123 0x4>;
113 interrupt-controller; 113 interrupt-controller;
114 #interrupt-cells = <2>; 114 #interrupt-cells = <2>;
115 supports-sleepmode; 115 st,supports-sleepmode;
116 gpio-controller; 116 gpio-controller;
117 #gpio-cells = <2>; 117 #gpio-cells = <2>;
118 gpio-bank = <4>; 118 gpio-bank = <4>;
@@ -125,7 +125,7 @@
125 interrupts = <0 124 0x4>; 125 interrupts = <0 124 0x4>;
126 interrupt-controller; 126 interrupt-controller;
127 #interrupt-cells = <2>; 127 #interrupt-cells = <2>;
128 supports-sleepmode; 128 st,supports-sleepmode;
129 gpio-controller; 129 gpio-controller;
130 #gpio-cells = <2>; 130 #gpio-cells = <2>;
131 gpio-bank = <5>; 131 gpio-bank = <5>;
@@ -138,7 +138,7 @@
138 interrupts = <0 125 0x4>; 138 interrupts = <0 125 0x4>;
139 interrupt-controller; 139 interrupt-controller;
140 #interrupt-cells = <2>; 140 #interrupt-cells = <2>;
141 supports-sleepmode; 141 st,supports-sleepmode;
142 gpio-controller; 142 gpio-controller;
143 #gpio-cells = <2>; 143 #gpio-cells = <2>;
144 gpio-bank = <6>; 144 gpio-bank = <6>;
@@ -151,7 +151,7 @@
151 interrupts = <0 126 0x4>; 151 interrupts = <0 126 0x4>;
152 interrupt-controller; 152 interrupt-controller;
153 #interrupt-cells = <2>; 153 #interrupt-cells = <2>;
154 supports-sleepmode; 154 st,supports-sleepmode;
155 gpio-controller; 155 gpio-controller;
156 #gpio-cells = <2>; 156 #gpio-cells = <2>;
157 gpio-bank = <7>; 157 gpio-bank = <7>;
@@ -164,7 +164,7 @@
164 interrupts = <0 127 0x4>; 164 interrupts = <0 127 0x4>;
165 interrupt-controller; 165 interrupt-controller;
166 #interrupt-cells = <2>; 166 #interrupt-cells = <2>;
167 supports-sleepmode; 167 st,supports-sleepmode;
168 gpio-controller; 168 gpio-controller;
169 #gpio-cells = <2>; 169 #gpio-cells = <2>;
170 gpio-bank = <8>; 170 gpio-bank = <8>;
@@ -206,62 +206,74 @@
206 206
207 // DB8500_REGULATOR_VAPE 207 // DB8500_REGULATOR_VAPE
208 db8500_vape_reg: db8500_vape { 208 db8500_vape_reg: db8500_vape {
209 regulator-compatible = "db8500_vape";
209 regulator-name = "db8500-vape"; 210 regulator-name = "db8500-vape";
210 regulator-always-on; 211 regulator-always-on;
211 }; 212 };
212 213
213 // DB8500_REGULATOR_VARM 214 // DB8500_REGULATOR_VARM
214 db8500_varm_reg: db8500_varm { 215 db8500_varm_reg: db8500_varm {
216 regulator-compatible = "db8500_varm";
215 regulator-name = "db8500-varm"; 217 regulator-name = "db8500-varm";
216 }; 218 };
217 219
218 // DB8500_REGULATOR_VMODEM 220 // DB8500_REGULATOR_VMODEM
219 db8500_vmodem_reg: db8500_vmodem { 221 db8500_vmodem_reg: db8500_vmodem {
222 regulator-compatible = "db8500_vmodem";
220 regulator-name = "db8500-vmodem"; 223 regulator-name = "db8500-vmodem";
221 }; 224 };
222 225
223 // DB8500_REGULATOR_VPLL 226 // DB8500_REGULATOR_VPLL
224 db8500_vpll_reg: db8500_vpll { 227 db8500_vpll_reg: db8500_vpll {
228 regulator-compatible = "db8500_vpll";
225 regulator-name = "db8500-vpll"; 229 regulator-name = "db8500-vpll";
226 }; 230 };
227 231
228 // DB8500_REGULATOR_VSMPS1 232 // DB8500_REGULATOR_VSMPS1
229 db8500_vsmps1_reg: db8500_vsmps1 { 233 db8500_vsmps1_reg: db8500_vsmps1 {
234 regulator-compatible = "db8500_vsmps1";
230 regulator-name = "db8500-vsmps1"; 235 regulator-name = "db8500-vsmps1";
231 }; 236 };
232 237
233 // DB8500_REGULATOR_VSMPS2 238 // DB8500_REGULATOR_VSMPS2
234 db8500_vsmps2_reg: db8500_vsmps2 { 239 db8500_vsmps2_reg: db8500_vsmps2 {
240 regulator-compatible = "db8500_vsmps2";
235 regulator-name = "db8500-vsmps2"; 241 regulator-name = "db8500-vsmps2";
236 }; 242 };
237 243
238 // DB8500_REGULATOR_VSMPS3 244 // DB8500_REGULATOR_VSMPS3
239 db8500_vsmps3_reg: db8500_vsmps3 { 245 db8500_vsmps3_reg: db8500_vsmps3 {
246 regulator-compatible = "db8500_vsmps3";
240 regulator-name = "db8500-vsmps3"; 247 regulator-name = "db8500-vsmps3";
241 }; 248 };
242 249
243 // DB8500_REGULATOR_VRF1 250 // DB8500_REGULATOR_VRF1
244 db8500_vrf1_reg: db8500_vrf1 { 251 db8500_vrf1_reg: db8500_vrf1 {
252 regulator-compatible = "db8500_vrf1";
245 regulator-name = "db8500-vrf1"; 253 regulator-name = "db8500-vrf1";
246 }; 254 };
247 255
248 // DB8500_REGULATOR_SWITCH_SVAMMDSP 256 // DB8500_REGULATOR_SWITCH_SVAMMDSP
249 db8500_sva_mmdsp_reg: db8500_sva_mmdsp { 257 db8500_sva_mmdsp_reg: db8500_sva_mmdsp {
258 regulator-compatible = "db8500_sva_mmdsp";
250 regulator-name = "db8500-sva-mmdsp"; 259 regulator-name = "db8500-sva-mmdsp";
251 }; 260 };
252 261
253 // DB8500_REGULATOR_SWITCH_SVAMMDSPRET 262 // DB8500_REGULATOR_SWITCH_SVAMMDSPRET
254 db8500_sva_mmdsp_ret_reg: db8500_sva_mmdsp_ret { 263 db8500_sva_mmdsp_ret_reg: db8500_sva_mmdsp_ret {
264 regulator-compatible = "db8500_sva_mmdsp_ret";
255 regulator-name = "db8500-sva-mmdsp-ret"; 265 regulator-name = "db8500-sva-mmdsp-ret";
256 }; 266 };
257 267
258 // DB8500_REGULATOR_SWITCH_SVAPIPE 268 // DB8500_REGULATOR_SWITCH_SVAPIPE
259 db8500_sva_pipe_reg: db8500_sva_pipe { 269 db8500_sva_pipe_reg: db8500_sva_pipe {
270 regulator-compatible = "db8500_sva_pipe";
260 regulator-name = "db8500_sva_pipe"; 271 regulator-name = "db8500_sva_pipe";
261 }; 272 };
262 273
263 // DB8500_REGULATOR_SWITCH_SIAMMDSP 274 // DB8500_REGULATOR_SWITCH_SIAMMDSP
264 db8500_sia_mmdsp_reg: db8500_sia_mmdsp { 275 db8500_sia_mmdsp_reg: db8500_sia_mmdsp {
276 regulator-compatible = "db8500_sia_mmdsp";
265 regulator-name = "db8500_sia_mmdsp"; 277 regulator-name = "db8500_sia_mmdsp";
266 }; 278 };
267 279
@@ -272,38 +284,45 @@
272 284
273 // DB8500_REGULATOR_SWITCH_SIAPIPE 285 // DB8500_REGULATOR_SWITCH_SIAPIPE
274 db8500_sia_pipe_reg: db8500_sia_pipe { 286 db8500_sia_pipe_reg: db8500_sia_pipe {
287 regulator-compatible = "db8500_sia_pipe";
275 regulator-name = "db8500-sia-pipe"; 288 regulator-name = "db8500-sia-pipe";
276 }; 289 };
277 290
278 // DB8500_REGULATOR_SWITCH_SGA 291 // DB8500_REGULATOR_SWITCH_SGA
279 db8500_sga_reg: db8500_sga { 292 db8500_sga_reg: db8500_sga {
293 regulator-compatible = "db8500_sga";
280 regulator-name = "db8500-sga"; 294 regulator-name = "db8500-sga";
281 vin-supply = <&db8500_vape_reg>; 295 vin-supply = <&db8500_vape_reg>;
282 }; 296 };
283 297
284 // DB8500_REGULATOR_SWITCH_B2R2_MCDE 298 // DB8500_REGULATOR_SWITCH_B2R2_MCDE
285 db8500_b2r2_mcde_reg: db8500_b2r2_mcde { 299 db8500_b2r2_mcde_reg: db8500_b2r2_mcde {
300 regulator-compatible = "db8500_b2r2_mcde";
286 regulator-name = "db8500-b2r2-mcde"; 301 regulator-name = "db8500-b2r2-mcde";
287 vin-supply = <&db8500_vape_reg>; 302 vin-supply = <&db8500_vape_reg>;
288 }; 303 };
289 304
290 // DB8500_REGULATOR_SWITCH_ESRAM12 305 // DB8500_REGULATOR_SWITCH_ESRAM12
291 db8500_esram12_reg: db8500_esram12 { 306 db8500_esram12_reg: db8500_esram12 {
307 regulator-compatible = "db8500_esram12";
292 regulator-name = "db8500-esram12"; 308 regulator-name = "db8500-esram12";
293 }; 309 };
294 310
295 // DB8500_REGULATOR_SWITCH_ESRAM12RET 311 // DB8500_REGULATOR_SWITCH_ESRAM12RET
296 db8500_esram12_ret_reg: db8500_esram12_ret { 312 db8500_esram12_ret_reg: db8500_esram12_ret {
313 regulator-compatible = "db8500_esram12_ret";
297 regulator-name = "db8500-esram12-ret"; 314 regulator-name = "db8500-esram12-ret";
298 }; 315 };
299 316
300 // DB8500_REGULATOR_SWITCH_ESRAM34 317 // DB8500_REGULATOR_SWITCH_ESRAM34
301 db8500_esram34_reg: db8500_esram34 { 318 db8500_esram34_reg: db8500_esram34 {
319 regulator-compatible = "db8500_esram34";
302 regulator-name = "db8500-esram34"; 320 regulator-name = "db8500-esram34";
303 }; 321 };
304 322
305 // DB8500_REGULATOR_SWITCH_ESRAM34RET 323 // DB8500_REGULATOR_SWITCH_ESRAM34RET
306 db8500_esram34_ret_reg: db8500_esram34_ret { 324 db8500_esram34_ret_reg: db8500_esram34_ret {
325 regulator-compatible = "db8500_esram34_ret";
307 regulator-name = "db8500-esram34-ret"; 326 regulator-name = "db8500-esram34-ret";
308 }; 327 };
309 }; 328 };
@@ -312,12 +331,70 @@
312 compatible = "stericsson,ab8500"; 331 compatible = "stericsson,ab8500";
313 reg = <5>; /* mailbox 5 is i2c */ 332 reg = <5>; /* mailbox 5 is i2c */
314 interrupts = <0 40 0x4>; 333 interrupts = <0 40 0x4>;
334 interrupt-controller;
335 #interrupt-cells = <2>;
336
337 ab8500-rtc {
338 compatible = "stericsson,ab8500-rtc";
339 interrupts = <17 0x4
340 18 0x4>;
341 interrupt-names = "60S", "ALARM";
342 };
343
344 ab8500-gpadc {
345 compatible = "stericsson,ab8500-gpadc";
346 interrupts = <32 0x4
347 39 0x4>;
348 interrupt-names = "HW_CONV_END", "SW_CONV_END";
349 vddadc-supply = <&ab8500_ldo_tvout_reg>;
350 };
351
352 ab8500-usb {
353 compatible = "stericsson,ab8500-usb";
354 interrupts = < 90 0x4
355 96 0x4
356 14 0x4
357 15 0x4
358 79 0x4
359 74 0x4
360 75 0x4>;
361 interrupt-names = "ID_WAKEUP_R",
362 "ID_WAKEUP_F",
363 "VBUS_DET_F",
364 "VBUS_DET_R",
365 "USB_LINK_STATUS",
366 "USB_ADP_PROBE_PLUG",
367 "USB_ADP_PROBE_UNPLUG";
368 vddulpivio18-supply = <&ab8500_ldo_initcore_reg>;
369 v-ape-supply = <&db8500_vape_reg>;
370 musb_1v8-supply = <&db8500_vsmps2_reg>;
371 };
372
373 ab8500-ponkey {
374 compatible = "stericsson,ab8500-ponkey";
375 interrupts = <6 0x4
376 7 0x4>;
377 interrupt-names = "ONKEY_DBF", "ONKEY_DBR";
378 };
379
380 ab8500-sysctrl {
381 compatible = "stericsson,ab8500-sysctrl";
382 };
383
384 ab8500-pwm {
385 compatible = "stericsson,ab8500-pwm";
386 };
387
388 ab8500-debugfs {
389 compatible = "stericsson,ab8500-debug";
390 };
315 391
316 ab8500-regulators { 392 ab8500-regulators {
317 compatible = "stericsson,ab8500-regulator"; 393 compatible = "stericsson,ab8500-regulator";
318 394
319 // supplies to the display/camera 395 // supplies to the display/camera
320 ab8500_ldo_aux1_reg: ab8500_ldo_aux1 { 396 ab8500_ldo_aux1_reg: ab8500_ldo_aux1 {
397 regulator-compatible = "ab8500_ldo_aux1";
321 regulator-name = "V-DISPLAY"; 398 regulator-name = "V-DISPLAY";
322 regulator-min-microvolt = <2500000>; 399 regulator-min-microvolt = <2500000>;
323 regulator-max-microvolt = <2900000>; 400 regulator-max-microvolt = <2900000>;
@@ -328,6 +405,7 @@
328 405
329 // supplies to the on-board eMMC 406 // supplies to the on-board eMMC
330 ab8500_ldo_aux2_reg: ab8500_ldo_aux2 { 407 ab8500_ldo_aux2_reg: ab8500_ldo_aux2 {
408 regulator-compatible = "ab8500_ldo_aux2";
331 regulator-name = "V-eMMC1"; 409 regulator-name = "V-eMMC1";
332 regulator-min-microvolt = <1100000>; 410 regulator-min-microvolt = <1100000>;
333 regulator-max-microvolt = <3300000>; 411 regulator-max-microvolt = <3300000>;
@@ -335,6 +413,7 @@
335 413
336 // supply for VAUX3; SDcard slots 414 // supply for VAUX3; SDcard slots
337 ab8500_ldo_aux3_reg: ab8500_ldo_aux3 { 415 ab8500_ldo_aux3_reg: ab8500_ldo_aux3 {
416 regulator-compatible = "ab8500_ldo_aux3";
338 regulator-name = "V-MMC-SD"; 417 regulator-name = "V-MMC-SD";
339 regulator-min-microvolt = <1100000>; 418 regulator-min-microvolt = <1100000>;
340 regulator-max-microvolt = <3300000>; 419 regulator-max-microvolt = <3300000>;
@@ -342,41 +421,49 @@
342 421
343 // supply for v-intcore12; VINTCORE12 LDO 422 // supply for v-intcore12; VINTCORE12 LDO
344 ab8500_ldo_initcore_reg: ab8500_ldo_initcore { 423 ab8500_ldo_initcore_reg: ab8500_ldo_initcore {
424 regulator-compatible = "ab8500_ldo_initcore";
345 regulator-name = "V-INTCORE"; 425 regulator-name = "V-INTCORE";
346 }; 426 };
347 427
348 // supply for tvout; gpadc; TVOUT LDO 428 // supply for tvout; gpadc; TVOUT LDO
349 ab8500_ldo_tvout_reg: ab8500_ldo_tvout { 429 ab8500_ldo_tvout_reg: ab8500_ldo_tvout {
430 regulator-compatible = "ab8500_ldo_tvout";
350 regulator-name = "V-TVOUT"; 431 regulator-name = "V-TVOUT";
351 }; 432 };
352 433
353 // supply for ab8500-usb; USB LDO 434 // supply for ab8500-usb; USB LDO
354 ab8500_ldo_usb_reg: ab8500_ldo_usb { 435 ab8500_ldo_usb_reg: ab8500_ldo_usb {
436 regulator-compatible = "ab8500_ldo_usb";
355 regulator-name = "dummy"; 437 regulator-name = "dummy";
356 }; 438 };
357 439
358 // supply for ab8500-vaudio; VAUDIO LDO 440 // supply for ab8500-vaudio; VAUDIO LDO
359 ab8500_ldo_audio_reg: ab8500_ldo_audio { 441 ab8500_ldo_audio_reg: ab8500_ldo_audio {
442 regulator-compatible = "ab8500_ldo_audio";
360 regulator-name = "V-AUD"; 443 regulator-name = "V-AUD";
361 }; 444 };
362 445
363 // supply for v-anamic1 VAMic1-LDO 446 // supply for v-anamic1 VAMic1-LDO
364 ab8500_ldo_anamic1_reg: ab8500_ldo_anamic1 { 447 ab8500_ldo_anamic1_reg: ab8500_ldo_anamic1 {
448 regulator-compatible = "ab8500_ldo_anamic1";
365 regulator-name = "V-AMIC1"; 449 regulator-name = "V-AMIC1";
366 }; 450 };
367 451
368 // supply for v-amic2; VAMIC2 LDO; reuse constants for AMIC1 452 // supply for v-amic2; VAMIC2 LDO; reuse constants for AMIC1
369 ab8500_ldo_amamic2_reg: ab8500_ldo_amamic2 { 453 ab8500_ldo_amamic2_reg: ab8500_ldo_amamic2 {
454 regulator-compatible = "ab8500_ldo_amamic2";
370 regulator-name = "V-AMIC2"; 455 regulator-name = "V-AMIC2";
371 }; 456 };
372 457
373 // supply for v-dmic; VDMIC LDO 458 // supply for v-dmic; VDMIC LDO
374 ab8500_ldo_dmic_reg: ab8500_ldo_dmic { 459 ab8500_ldo_dmic_reg: ab8500_ldo_dmic {
460 regulator-compatible = "ab8500_ldo_dmic";
375 regulator-name = "V-DMIC"; 461 regulator-name = "V-DMIC";
376 }; 462 };
377 463
378 // supply for U8500 CSI/DSI; VANA LDO 464 // supply for U8500 CSI/DSI; VANA LDO
379 ab8500_ldo_ana_reg: ab8500_ldo_ana { 465 ab8500_ldo_ana_reg: ab8500_ldo_ana {
466 regulator-compatible = "ab8500_ldo_ana";
380 regulator-name = "V-CSI/DSI"; 467 regulator-name = "V-CSI/DSI";
381 }; 468 };
382 }; 469 };
diff --git a/arch/arm/boot/dts/ea3250.dts b/arch/arm/boot/dts/ea3250.dts
new file mode 100644
index 00000000000..d79b28d9c96
--- /dev/null
+++ b/arch/arm/boot/dts/ea3250.dts
@@ -0,0 +1,174 @@
1/*
2 * Embedded Artists LPC3250 board
3 *
4 * Copyright 2012 Roland Stigge <stigge@antcom.de>
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/dts-v1/;
15/include/ "lpc32xx.dtsi"
16
17/ {
18 model = "Embedded Artists LPC3250 board based on NXP LPC3250";
19 compatible = "ea,ea3250", "nxp,lpc3250";
20 #address-cells = <1>;
21 #size-cells = <1>;
22
23 memory {
24 device_type = "memory";
25 reg = <0 0x4000000>;
26 };
27
28 ahb {
29 mac: ethernet@31060000 {
30 phy-mode = "rmii";
31 use-iram;
32 };
33
34 /* Here, choose exactly one from: ohci, usbd */
35 ohci@31020000 {
36 transceiver = <&isp1301>;
37 status = "okay";
38 };
39
40/*
41 usbd@31020000 {
42 transceiver = <&isp1301>;
43 status = "okay";
44 };
45*/
46
47 /* 128MB Flash via SLC NAND controller */
48 slc: flash@20020000 {
49 status = "okay";
50 #address-cells = <1>;
51 #size-cells = <1>;
52
53 nxp,wdr-clks = <14>;
54 nxp,wwidth = <260000000>;
55 nxp,whold = <104000000>;
56 nxp,wsetup = <200000000>;
57 nxp,rdr-clks = <14>;
58 nxp,rwidth = <34666666>;
59 nxp,rhold = <104000000>;
60 nxp,rsetup = <200000000>;
61 nand-on-flash-bbt;
62 gpios = <&gpio 5 19 1>; /* GPO_P3 19, active low */
63
64 mtd0@00000000 {
65 label = "ea3250-boot";
66 reg = <0x00000000 0x00080000>;
67 read-only;
68 };
69
70 mtd1@00080000 {
71 label = "ea3250-uboot";
72 reg = <0x00080000 0x000c0000>;
73 read-only;
74 };
75
76 mtd2@00140000 {
77 label = "ea3250-kernel";
78 reg = <0x00140000 0x00400000>;
79 };
80
81 mtd3@00540000 {
82 label = "ea3250-rootfs";
83 reg = <0x00540000 0x07ac0000>;
84 };
85 };
86
87 apb {
88 uart5: serial@40090000 {
89 status = "okay";
90 };
91
92 uart3: serial@40080000 {
93 status = "okay";
94 };
95
96 uart6: serial@40098000 {
97 status = "okay";
98 };
99
100 i2c1: i2c@400A0000 {
101 clock-frequency = <100000>;
102
103 eeprom@50 {
104 compatible = "at,24c256";
105 reg = <0x50>;
106 };
107
108 eeprom@57 {
109 compatible = "at,24c64";
110 reg = <0x57>;
111 };
112
113 uda1380: uda1380@18 {
114 compatible = "nxp,uda1380";
115 reg = <0x18>;
116 power-gpio = <&gpio 0x59 0>;
117 reset-gpio = <&gpio 0x51 0>;
118 dac-clk = "wspll";
119 };
120
121 pca9532: pca9532@60 {
122 compatible = "nxp,pca9532";
123 gpio-controller;
124 #gpio-cells = <2>;
125 reg = <0x60>;
126 };
127 };
128
129 i2c2: i2c@400A8000 {
130 clock-frequency = <100000>;
131 };
132
133 i2cusb: i2c@31020300 {
134 clock-frequency = <100000>;
135
136 isp1301: usb-transceiver@2d {
137 compatible = "nxp,isp1301";
138 reg = <0x2d>;
139 };
140 };
141
142 sd@20098000 {
143 wp-gpios = <&pca9532 5 0>;
144 cd-gpios = <&pca9532 4 0>;
145 cd-inverted;
146 bus-width = <4>;
147 status = "okay";
148 };
149 };
150
151 fab {
152 uart1: serial@40014000 {
153 status = "okay";
154 };
155
156 /* 3-axis accelerometer X,Y,Z (or AD-IN instead of Z) */
157 adc@40048000 {
158 status = "okay";
159 };
160 };
161 };
162
163 gpio_keys {
164 compatible = "gpio-keys";
165 #address-cells = <1>;
166 #size-cells = <0>;
167 autorepeat;
168 button@21 {
169 label = "GPIO Key UP";
170 linux,code = <103>;
171 gpios = <&gpio 4 1 0>; /* GPI_P3 1 */
172 };
173 };
174};
diff --git a/arch/arm/boot/dts/evk-pro3.dts b/arch/arm/boot/dts/evk-pro3.dts
new file mode 100644
index 00000000000..b7354e6506d
--- /dev/null
+++ b/arch/arm/boot/dts/evk-pro3.dts
@@ -0,0 +1,41 @@
1/*
2 * evk-pro3.dts - Device Tree file for Telit EVK-PRO3 with Telit GE863-PRO3
3 *
4 * Copyright (C) 2012 Telit,
5 * 2012 Fabio Porcedda <fabio.porcedda@gmail.com>
6 *
7 * Licensed under GPLv2 or later.
8 */
9
10/dts-v1/;
11
12/include/ "ge863-pro3.dtsi"
13
14/ {
15 model = "Telit EVK-PRO3 for Telit GE863-PRO3";
16 compatible = "telit,evk-pro3", "atmel,at91sam9260", "atmel,at91sam9";
17
18 ahb {
19 apb {
20 macb0: ethernet@fffc4000 {
21 phy-mode = "rmii";
22 status = "okay";
23 };
24
25 usb1: gadget@fffa4000 {
26 atmel,vbus-gpio = <&pioC 5 0>;
27 status = "okay";
28 };
29 };
30
31 usb0: ohci@00500000 {
32 num-ports = <2>;
33 status = "okay";
34 };
35 };
36
37 i2c@0 {
38 status = "okay";
39 };
40
41}; \ No newline at end of file
diff --git a/arch/arm/boot/dts/exynos4210-origen.dts b/arch/arm/boot/dts/exynos4210-origen.dts
index b8c476384ee..0c49caa0997 100644
--- a/arch/arm/boot/dts/exynos4210-origen.dts
+++ b/arch/arm/boot/dts/exynos4210-origen.dts
@@ -134,4 +134,16 @@
134 i2c@138D0000 { 134 i2c@138D0000 {
135 status = "disabled"; 135 status = "disabled";
136 }; 136 };
137
138 spi_0: spi@13920000 {
139 status = "disabled";
140 };
141
142 spi_1: spi@13930000 {
143 status = "disabled";
144 };
145
146 spi_2: spi@13940000 {
147 status = "disabled";
148 };
137}; 149};
diff --git a/arch/arm/boot/dts/exynos4210-smdkv310.dts b/arch/arm/boot/dts/exynos4210-smdkv310.dts
index 27afc8e535c..1beccc8f14f 100644
--- a/arch/arm/boot/dts/exynos4210-smdkv310.dts
+++ b/arch/arm/boot/dts/exynos4210-smdkv310.dts
@@ -179,4 +179,42 @@
179 i2c@138D0000 { 179 i2c@138D0000 {
180 status = "disabled"; 180 status = "disabled";
181 }; 181 };
182
183 spi_0: spi@13920000 {
184 status = "disabled";
185 };
186
187 spi_1: spi@13930000 {
188 status = "disabled";
189 };
190
191 spi_2: spi@13940000 {
192 gpios = <&gpc1 1 5 3 0>,
193 <&gpc1 3 5 3 0>,
194 <&gpc1 4 5 3 0>;
195
196 w25x80@0 {
197 #address-cells = <1>;
198 #size-cells = <1>;
199 compatible = "w25x80";
200 reg = <0>;
201 spi-max-frequency = <1000000>;
202
203 controller-data {
204 cs-gpio = <&gpc1 2 1 0 3>;
205 samsung,spi-feedback-delay = <0>;
206 };
207
208 partition@0 {
209 label = "U-Boot";
210 reg = <0x0 0x40000>;
211 read-only;
212 };
213
214 partition@40000 {
215 label = "Kernel";
216 reg = <0x40000 0xc0000>;
217 };
218 };
219 };
182}; 220};
diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
index a1dd2ee8375..02891fe876e 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -25,6 +25,12 @@
25 compatible = "samsung,exynos4210"; 25 compatible = "samsung,exynos4210";
26 interrupt-parent = <&gic>; 26 interrupt-parent = <&gic>;
27 27
28 aliases {
29 spi0 = &spi_0;
30 spi1 = &spi_1;
31 spi2 = &spi_2;
32 };
33
28 gic:interrupt-controller@10490000 { 34 gic:interrupt-controller@10490000 {
29 compatible = "arm,cortex-a9-gic"; 35 compatible = "arm,cortex-a9-gic";
30 #interrupt-cells = <3>; 36 #interrupt-cells = <3>;
@@ -33,6 +39,17 @@
33 reg = <0x10490000 0x1000>, <0x10480000 0x100>; 39 reg = <0x10490000 0x1000>, <0x10480000 0x100>;
34 }; 40 };
35 41
42 combiner:interrupt-controller@10440000 {
43 compatible = "samsung,exynos4210-combiner";
44 #interrupt-cells = <2>;
45 interrupt-controller;
46 reg = <0x10440000 0x1000>;
47 interrupts = <0 0 0>, <0 1 0>, <0 2 0>, <0 3 0>,
48 <0 4 0>, <0 5 0>, <0 6 0>, <0 7 0>,
49 <0 8 0>, <0 9 0>, <0 10 0>, <0 11 0>,
50 <0 12 0>, <0 13 0>, <0 14 0>, <0 15 0>;
51 };
52
36 watchdog@10060000 { 53 watchdog@10060000 {
37 compatible = "samsung,s3c2410-wdt"; 54 compatible = "samsung,s3c2410-wdt";
38 reg = <0x10060000 0x100>; 55 reg = <0x10060000 0x100>;
@@ -147,6 +164,36 @@
147 interrupts = <0 65 0>; 164 interrupts = <0 65 0>;
148 }; 165 };
149 166
167 spi_0: spi@13920000 {
168 compatible = "samsung,exynos4210-spi";
169 reg = <0x13920000 0x100>;
170 interrupts = <0 66 0>;
171 tx-dma-channel = <&pdma0 7>; /* preliminary */
172 rx-dma-channel = <&pdma0 6>; /* preliminary */
173 #address-cells = <1>;
174 #size-cells = <0>;
175 };
176
177 spi_1: spi@13930000 {
178 compatible = "samsung,exynos4210-spi";
179 reg = <0x13930000 0x100>;
180 interrupts = <0 67 0>;
181 tx-dma-channel = <&pdma1 7>; /* preliminary */
182 rx-dma-channel = <&pdma1 6>; /* preliminary */
183 #address-cells = <1>;
184 #size-cells = <0>;
185 };
186
187 spi_2: spi@13940000 {
188 compatible = "samsung,exynos4210-spi";
189 reg = <0x13940000 0x100>;
190 interrupts = <0 68 0>;
191 tx-dma-channel = <&pdma0 9>; /* preliminary */
192 rx-dma-channel = <&pdma0 8>; /* preliminary */
193 #address-cells = <1>;
194 #size-cells = <0>;
195 };
196
150 amba { 197 amba {
151 #address-cells = <1>; 198 #address-cells = <1>;
152 #size-cells = <1>; 199 #size-cells = <1>;
diff --git a/arch/arm/boot/dts/exynos5250-smdk5250.dts b/arch/arm/boot/dts/exynos5250-smdk5250.dts
index 49945cc1bc7..8a5e348793c 100644
--- a/arch/arm/boot/dts/exynos5250-smdk5250.dts
+++ b/arch/arm/boot/dts/exynos5250-smdk5250.dts
@@ -71,4 +71,42 @@
71 i2c@12CD0000 { 71 i2c@12CD0000 {
72 status = "disabled"; 72 status = "disabled";
73 }; 73 };
74
75 spi_0: spi@12d20000 {
76 status = "disabled";
77 };
78
79 spi_1: spi@12d30000 {
80 gpios = <&gpa2 4 2 3 0>,
81 <&gpa2 6 2 3 0>,
82 <&gpa2 7 2 3 0>;
83
84 w25q80bw@0 {
85 #address-cells = <1>;
86 #size-cells = <1>;
87 compatible = "w25x80";
88 reg = <0>;
89 spi-max-frequency = <1000000>;
90
91 controller-data {
92 cs-gpio = <&gpa2 5 1 0 3>;
93 samsung,spi-feedback-delay = <0>;
94 };
95
96 partition@0 {
97 label = "U-Boot";
98 reg = <0x0 0x40000>;
99 read-only;
100 };
101
102 partition@40000 {
103 label = "Kernel";
104 reg = <0x40000 0xc0000>;
105 };
106 };
107 };
108
109 spi_2: spi@12d40000 {
110 status = "disabled";
111 };
74}; 112};
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index 4272b294922..004aaa8d123 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -23,6 +23,12 @@
23 compatible = "samsung,exynos5250"; 23 compatible = "samsung,exynos5250";
24 interrupt-parent = <&gic>; 24 interrupt-parent = <&gic>;
25 25
26 aliases {
27 spi0 = &spi_0;
28 spi1 = &spi_1;
29 spi2 = &spi_2;
30 };
31
26 gic:interrupt-controller@10481000 { 32 gic:interrupt-controller@10481000 {
27 compatible = "arm,cortex-a9-gic"; 33 compatible = "arm,cortex-a9-gic";
28 #interrupt-cells = <3>; 34 #interrupt-cells = <3>;
@@ -146,6 +152,36 @@
146 #size-cells = <0>; 152 #size-cells = <0>;
147 }; 153 };
148 154
155 spi_0: spi@12d20000 {
156 compatible = "samsung,exynos4210-spi";
157 reg = <0x12d20000 0x100>;
158 interrupts = <0 66 0>;
159 tx-dma-channel = <&pdma0 5>; /* preliminary */
160 rx-dma-channel = <&pdma0 4>; /* preliminary */
161 #address-cells = <1>;
162 #size-cells = <0>;
163 };
164
165 spi_1: spi@12d30000 {
166 compatible = "samsung,exynos4210-spi";
167 reg = <0x12d30000 0x100>;
168 interrupts = <0 67 0>;
169 tx-dma-channel = <&pdma1 5>; /* preliminary */
170 rx-dma-channel = <&pdma1 4>; /* preliminary */
171 #address-cells = <1>;
172 #size-cells = <0>;
173 };
174
175 spi_2: spi@12d40000 {
176 compatible = "samsung,exynos4210-spi";
177 reg = <0x12d40000 0x100>;
178 interrupts = <0 68 0>;
179 tx-dma-channel = <&pdma0 7>; /* preliminary */
180 rx-dma-channel = <&pdma0 6>; /* preliminary */
181 #address-cells = <1>;
182 #size-cells = <0>;
183 };
184
149 amba { 185 amba {
150 #address-cells = <1>; 186 #address-cells = <1>;
151 #size-cells = <1>; 187 #size-cells = <1>;
diff --git a/arch/arm/boot/dts/ge863-pro3.dtsi b/arch/arm/boot/dts/ge863-pro3.dtsi
new file mode 100644
index 00000000000..17136fc7a51
--- /dev/null
+++ b/arch/arm/boot/dts/ge863-pro3.dtsi
@@ -0,0 +1,52 @@
1/*
2 * ge863_pro3.dtsi - Device Tree file for Telit GE863-PRO3
3 *
4 * Copyright (C) 2012 Telit,
5 * 2012 Fabio Porcedda <fabio.porcedda@gmail.com>
6 *
7 * Licensed under GPLv2 or later.
8 */
9
10/include/ "at91sam9260.dtsi"
11
12/ {
13 clocks {
14 #address-cells = <1>;
15 #size-cells = <1>;
16 ranges;
17
18 main_clock: clock@0 {
19 compatible = "atmel,osc", "fixed-clock";
20 clock-frequency = <6000000>;
21 };
22 };
23
24 ahb {
25 apb {
26 dbgu: serial@fffff200 {
27 status = "okay";
28 };
29 };
30
31 nand0: nand@40000000 {
32 nand-bus-width = <8>;
33 nand-ecc-mode = "soft";
34 nand-on-flash-bbt;
35 status = "okay";
36
37 boot@0 {
38 label = "boot";
39 reg = <0x0 0x7c0000>;
40 };
41
42 root@07c0000 {
43 label = "root";
44 reg = <0x7c0000 0x7840000>;
45 };
46 };
47 };
48
49 chosen {
50 bootargs = "console=ttyS0,115200 root=ubi0:rootfs ubi.mtd=1 rootfstype=ubifs";
51 };
52};
diff --git a/arch/arm/boot/dts/highbank.dts b/arch/arm/boot/dts/highbank.dts
index 83e72294aef..9fecf1ae777 100644
--- a/arch/arm/boot/dts/highbank.dts
+++ b/arch/arm/boot/dts/highbank.dts
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright 2011 Calxeda, Inc. 2 * Copyright 2011-2012 Calxeda, Inc.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License, 5 * under the terms and conditions of the GNU General Public License,
@@ -24,6 +24,7 @@
24 compatible = "calxeda,highbank"; 24 compatible = "calxeda,highbank";
25 #address-cells = <1>; 25 #address-cells = <1>;
26 #size-cells = <1>; 26 #size-cells = <1>;
27 clock-ranges;
27 28
28 cpus { 29 cpus {
29 #address-cells = <1>; 30 #address-cells = <1>;
@@ -33,24 +34,32 @@
33 compatible = "arm,cortex-a9"; 34 compatible = "arm,cortex-a9";
34 reg = <0>; 35 reg = <0>;
35 next-level-cache = <&L2>; 36 next-level-cache = <&L2>;
37 clocks = <&a9pll>;
38 clock-names = "cpu";
36 }; 39 };
37 40
38 cpu@1 { 41 cpu@1 {
39 compatible = "arm,cortex-a9"; 42 compatible = "arm,cortex-a9";
40 reg = <1>; 43 reg = <1>;
41 next-level-cache = <&L2>; 44 next-level-cache = <&L2>;
45 clocks = <&a9pll>;
46 clock-names = "cpu";
42 }; 47 };
43 48
44 cpu@2 { 49 cpu@2 {
45 compatible = "arm,cortex-a9"; 50 compatible = "arm,cortex-a9";
46 reg = <2>; 51 reg = <2>;
47 next-level-cache = <&L2>; 52 next-level-cache = <&L2>;
53 clocks = <&a9pll>;
54 clock-names = "cpu";
48 }; 55 };
49 56
50 cpu@3 { 57 cpu@3 {
51 compatible = "arm,cortex-a9"; 58 compatible = "arm,cortex-a9";
52 reg = <3>; 59 reg = <3>;
53 next-level-cache = <&L2>; 60 next-level-cache = <&L2>;
61 clocks = <&a9pll>;
62 clock-names = "cpu";
54 }; 63 };
55 }; 64 };
56 65
@@ -75,12 +84,14 @@
75 compatible = "arm,cortex-a9-twd-timer"; 84 compatible = "arm,cortex-a9-twd-timer";
76 reg = <0xfff10600 0x20>; 85 reg = <0xfff10600 0x20>;
77 interrupts = <1 13 0xf01>; 86 interrupts = <1 13 0xf01>;
87 clocks = <&a9periphclk>;
78 }; 88 };
79 89
80 watchdog@fff10620 { 90 watchdog@fff10620 {
81 compatible = "arm,cortex-a9-twd-wdt"; 91 compatible = "arm,cortex-a9-twd-wdt";
82 reg = <0xfff10620 0x20>; 92 reg = <0xfff10620 0x20>;
83 interrupts = <1 14 0xf01>; 93 interrupts = <1 14 0xf01>;
94 clocks = <&a9periphclk>;
84 }; 95 };
85 96
86 intc: interrupt-controller@fff11000 { 97 intc: interrupt-controller@fff11000 {
@@ -116,12 +127,21 @@
116 compatible = "calxeda,hb-sdhci"; 127 compatible = "calxeda,hb-sdhci";
117 reg = <0xffe0e000 0x1000>; 128 reg = <0xffe0e000 0x1000>;
118 interrupts = <0 90 4>; 129 interrupts = <0 90 4>;
130 clocks = <&eclk>;
131 };
132
133 memory-controller@fff00000 {
134 compatible = "calxeda,hb-ddr-ctrl";
135 reg = <0xfff00000 0x1000>;
136 interrupts = <0 91 4>;
119 }; 137 };
120 138
121 ipc@fff20000 { 139 ipc@fff20000 {
122 compatible = "arm,pl320", "arm,primecell"; 140 compatible = "arm,pl320", "arm,primecell";
123 reg = <0xfff20000 0x1000>; 141 reg = <0xfff20000 0x1000>;
124 interrupts = <0 7 4>; 142 interrupts = <0 7 4>;
143 clocks = <&pclk>;
144 clock-names = "apb_pclk";
125 }; 145 };
126 146
127 gpioe: gpio@fff30000 { 147 gpioe: gpio@fff30000 {
@@ -130,6 +150,8 @@
130 gpio-controller; 150 gpio-controller;
131 reg = <0xfff30000 0x1000>; 151 reg = <0xfff30000 0x1000>;
132 interrupts = <0 14 4>; 152 interrupts = <0 14 4>;
153 clocks = <&pclk>;
154 clock-names = "apb_pclk";
133 }; 155 };
134 156
135 gpiof: gpio@fff31000 { 157 gpiof: gpio@fff31000 {
@@ -138,6 +160,8 @@
138 gpio-controller; 160 gpio-controller;
139 reg = <0xfff31000 0x1000>; 161 reg = <0xfff31000 0x1000>;
140 interrupts = <0 15 4>; 162 interrupts = <0 15 4>;
163 clocks = <&pclk>;
164 clock-names = "apb_pclk";
141 }; 165 };
142 166
143 gpiog: gpio@fff32000 { 167 gpiog: gpio@fff32000 {
@@ -146,6 +170,8 @@
146 gpio-controller; 170 gpio-controller;
147 reg = <0xfff32000 0x1000>; 171 reg = <0xfff32000 0x1000>;
148 interrupts = <0 16 4>; 172 interrupts = <0 16 4>;
173 clocks = <&pclk>;
174 clock-names = "apb_pclk";
149 }; 175 };
150 176
151 gpioh: gpio@fff33000 { 177 gpioh: gpio@fff33000 {
@@ -154,24 +180,32 @@
154 gpio-controller; 180 gpio-controller;
155 reg = <0xfff33000 0x1000>; 181 reg = <0xfff33000 0x1000>;
156 interrupts = <0 17 4>; 182 interrupts = <0 17 4>;
183 clocks = <&pclk>;
184 clock-names = "apb_pclk";
157 }; 185 };
158 186
159 timer { 187 timer {
160 compatible = "arm,sp804", "arm,primecell"; 188 compatible = "arm,sp804", "arm,primecell";
161 reg = <0xfff34000 0x1000>; 189 reg = <0xfff34000 0x1000>;
162 interrupts = <0 18 4>; 190 interrupts = <0 18 4>;
191 clocks = <&pclk>;
192 clock-names = "apb_pclk";
163 }; 193 };
164 194
165 rtc@fff35000 { 195 rtc@fff35000 {
166 compatible = "arm,pl031", "arm,primecell"; 196 compatible = "arm,pl031", "arm,primecell";
167 reg = <0xfff35000 0x1000>; 197 reg = <0xfff35000 0x1000>;
168 interrupts = <0 19 4>; 198 interrupts = <0 19 4>;
199 clocks = <&pclk>;
200 clock-names = "apb_pclk";
169 }; 201 };
170 202
171 serial@fff36000 { 203 serial@fff36000 {
172 compatible = "arm,pl011", "arm,primecell"; 204 compatible = "arm,pl011", "arm,primecell";
173 reg = <0xfff36000 0x1000>; 205 reg = <0xfff36000 0x1000>;
174 interrupts = <0 20 4>; 206 interrupts = <0 20 4>;
207 clocks = <&pclk>;
208 clock-names = "apb_pclk";
175 }; 209 };
176 210
177 smic@fff3a000 { 211 smic@fff3a000 {
@@ -186,12 +220,79 @@
186 sregs@fff3c000 { 220 sregs@fff3c000 {
187 compatible = "calxeda,hb-sregs"; 221 compatible = "calxeda,hb-sregs";
188 reg = <0xfff3c000 0x1000>; 222 reg = <0xfff3c000 0x1000>;
223
224 clocks {
225 #address-cells = <1>;
226 #size-cells = <0>;
227
228 osc: oscillator {
229 #clock-cells = <0>;
230 compatible = "fixed-clock";
231 clock-frequency = <33333000>;
232 };
233
234 ddrpll: ddrpll {
235 #clock-cells = <0>;
236 compatible = "calxeda,hb-pll-clock";
237 clocks = <&osc>;
238 reg = <0x108>;
239 };
240
241 a9pll: a9pll {
242 #clock-cells = <0>;
243 compatible = "calxeda,hb-pll-clock";
244 clocks = <&osc>;
245 reg = <0x100>;
246 };
247
248 a9periphclk: a9periphclk {
249 #clock-cells = <0>;
250 compatible = "calxeda,hb-a9periph-clock";
251 clocks = <&a9pll>;
252 reg = <0x104>;
253 };
254
255 a9bclk: a9bclk {
256 #clock-cells = <0>;
257 compatible = "calxeda,hb-a9bus-clock";
258 clocks = <&a9pll>;
259 reg = <0x104>;
260 };
261
262 emmcpll: emmcpll {
263 #clock-cells = <0>;
264 compatible = "calxeda,hb-pll-clock";
265 clocks = <&osc>;
266 reg = <0x10C>;
267 };
268
269 eclk: eclk {
270 #clock-cells = <0>;
271 compatible = "calxeda,hb-emmc-clock";
272 clocks = <&emmcpll>;
273 reg = <0x114>;
274 };
275
276 pclk: pclk {
277 #clock-cells = <0>;
278 compatible = "fixed-clock";
279 clock-frequency = <150000000>;
280 };
281 };
282 };
283
284 sregs@fff3c200 {
285 compatible = "calxeda,hb-sregs-l2-ecc";
286 reg = <0xfff3c200 0x100>;
287 interrupts = <0 71 4 0 72 4>;
189 }; 288 };
190 289
191 dma@fff3d000 { 290 dma@fff3d000 {
192 compatible = "arm,pl330", "arm,primecell"; 291 compatible = "arm,pl330", "arm,primecell";
193 reg = <0xfff3d000 0x1000>; 292 reg = <0xfff3d000 0x1000>;
194 interrupts = <0 92 4>; 293 interrupts = <0 92 4>;
294 clocks = <&pclk>;
295 clock-names = "apb_pclk";
195 }; 296 };
196 297
197 ethernet@fff50000 { 298 ethernet@fff50000 {
diff --git a/arch/arm/boot/dts/imx23-evk.dts b/arch/arm/boot/dts/imx23-evk.dts
index 70bffa929b6..e3486f486b4 100644
--- a/arch/arm/boot/dts/imx23-evk.dts
+++ b/arch/arm/boot/dts/imx23-evk.dts
@@ -22,17 +22,60 @@
22 22
23 apb@80000000 { 23 apb@80000000 {
24 apbh@80000000 { 24 apbh@80000000 {
25 gpmi-nand@8000c000 {
26 pinctrl-names = "default";
27 pinctrl-0 = <&gpmi_pins_a &gpmi_pins_fixup>;
28 status = "okay";
29 };
30
25 ssp0: ssp@80010000 { 31 ssp0: ssp@80010000 {
26 compatible = "fsl,imx23-mmc"; 32 compatible = "fsl,imx23-mmc";
27 pinctrl-names = "default"; 33 pinctrl-names = "default";
28 pinctrl-0 = <&mmc0_8bit_pins_a &mmc0_pins_fixup>; 34 pinctrl-0 = <&mmc0_4bit_pins_a &mmc0_pins_fixup>;
29 bus-width = <8>; 35 bus-width = <4>;
30 wp-gpios = <&gpio1 30 0>; 36 wp-gpios = <&gpio1 30 0>;
37 vmmc-supply = <&reg_vddio_sd0>;
38 status = "okay";
39 };
40
41 pinctrl@80018000 {
42 pinctrl-names = "default";
43 pinctrl-0 = <&hog_pins_a>;
44
45 hog_pins_a: hog-gpios@0 {
46 reg = <0>;
47 fsl,pinmux-ids = <
48 0x1123 /* MX23_PAD_LCD_RESET__GPIO_1_18 */
49 0x11d3 /* MX23_PAD_PWM3__GPIO_1_29 */
50 0x11e3 /* MX23_PAD_PWM4__GPIO_1_30 */
51 >;
52 fsl,drive-strength = <0>;
53 fsl,voltage = <1>;
54 fsl,pull-up = <0>;
55 };
56 };
57
58 lcdif@80030000 {
59 pinctrl-names = "default";
60 pinctrl-0 = <&lcdif_24bit_pins_a>;
61 panel-enable-gpios = <&gpio1 18 0>;
31 status = "okay"; 62 status = "okay";
32 }; 63 };
33 }; 64 };
34 65
35 apbx@80040000 { 66 apbx@80040000 {
67 pwm: pwm@80064000 {
68 pinctrl-names = "default";
69 pinctrl-0 = <&pwm2_pins_a>;
70 status = "okay";
71 };
72
73 auart0: serial@8006c000 {
74 pinctrl-names = "default";
75 pinctrl-0 = <&auart0_pins_a>;
76 status = "okay";
77 };
78
36 duart: serial@80070000 { 79 duart: serial@80070000 {
37 pinctrl-names = "default"; 80 pinctrl-names = "default";
38 pinctrl-0 = <&duart_pins_a>; 81 pinctrl-0 = <&duart_pins_a>;
@@ -40,4 +83,23 @@
40 }; 83 };
41 }; 84 };
42 }; 85 };
86
87 regulators {
88 compatible = "simple-bus";
89
90 reg_vddio_sd0: vddio-sd0 {
91 compatible = "regulator-fixed";
92 regulator-name = "vddio-sd0";
93 regulator-min-microvolt = <3300000>;
94 regulator-max-microvolt = <3300000>;
95 gpio = <&gpio1 29 0>;
96 };
97 };
98
99 backlight {
100 compatible = "pwm-backlight";
101 pwms = <&pwm 2 5000000>;
102 brightness-levels = <0 4 8 16 32 64 128 255>;
103 default-brightness-level = <6>;
104 };
43}; 105};
diff --git a/arch/arm/boot/dts/imx23-olinuxino.dts b/arch/arm/boot/dts/imx23-olinuxino.dts
new file mode 100644
index 00000000000..20912b1d889
--- /dev/null
+++ b/arch/arm/boot/dts/imx23-olinuxino.dts
@@ -0,0 +1,44 @@
1/*
2 * Copyright 2012 Freescale Semiconductor, Inc.
3 *
4 * Author: Fabio Estevam <fabio.estevam@freescale.com>
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/dts-v1/;
15/include/ "imx23.dtsi"
16
17/ {
18 model = "i.MX23 Olinuxino Low Cost Board";
19 compatible = "olimex,imx23-olinuxino", "fsl,imx23";
20
21 memory {
22 reg = <0x40000000 0x04000000>;
23 };
24
25 apb@80000000 {
26 apbh@80000000 {
27 ssp0: ssp@80010000 {
28 compatible = "fsl,imx23-mmc";
29 pinctrl-names = "default";
30 pinctrl-0 = <&mmc0_4bit_pins_a &mmc0_pins_fixup>;
31 bus-width = <4>;
32 status = "okay";
33 };
34 };
35
36 apbx@80040000 {
37 duart: serial@80070000 {
38 pinctrl-names = "default";
39 pinctrl-0 = <&duart_pins_a>;
40 status = "okay";
41 };
42 };
43 };
44};
diff --git a/arch/arm/boot/dts/imx23-stmp378x_devb.dts b/arch/arm/boot/dts/imx23-stmp378x_devb.dts
new file mode 100644
index 00000000000..757a327ff3e
--- /dev/null
+++ b/arch/arm/boot/dts/imx23-stmp378x_devb.dts
@@ -0,0 +1,78 @@
1/*
2 * Copyright 2012 Freescale Semiconductor, Inc.
3 *
4 * The code contained herein is licensed under the GNU General Public
5 * License. You may obtain a copy of the GNU General Public License
6 * Version 2 or later at the following locations:
7 *
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
10 */
11
12/dts-v1/;
13/include/ "imx23.dtsi"
14
15/ {
16 model = "Freescale STMP378x Development Board";
17 compatible = "fsl,stmp378x-devb", "fsl,imx23";
18
19 memory {
20 reg = <0x40000000 0x04000000>;
21 };
22
23 apb@80000000 {
24 apbh@80000000 {
25 ssp0: ssp@80010000 {
26 compatible = "fsl,imx23-mmc";
27 pinctrl-names = "default";
28 pinctrl-0 = <&mmc0_4bit_pins_a &mmc0_pins_fixup>;
29 bus-width = <4>;
30 wp-gpios = <&gpio1 30 0>;
31 vmmc-supply = <&reg_vddio_sd0>;
32 status = "okay";
33 };
34
35 pinctrl@80018000 {
36 pinctrl-names = "default";
37 pinctrl-0 = <&hog_pins_a>;
38
39 hog_pins_a: hog-gpios@0 {
40 reg = <0>;
41 fsl,pinmux-ids = <
42 0x11d3 /* MX23_PAD_PWM3__GPIO_1_29 */
43 0x11e3 /* MX23_PAD_PWM4__GPIO_1_30 */
44 >;
45 fsl,drive-strength = <0>;
46 fsl,voltage = <1>;
47 fsl,pull-up = <0>;
48 };
49 };
50 };
51
52 apbx@80040000 {
53 auart0: serial@8006c000 {
54 pinctrl-names = "default";
55 pinctrl-0 = <&auart0_pins_a>;
56 status = "okay";
57 };
58
59 duart: serial@80070000 {
60 pinctrl-names = "default";
61 pinctrl-0 = <&duart_pins_a>;
62 status = "okay";
63 };
64 };
65 };
66
67 regulators {
68 compatible = "simple-bus";
69
70 reg_vddio_sd0: vddio-sd0 {
71 compatible = "regulator-fixed";
72 regulator-name = "vddio-sd0";
73 regulator-min-microvolt = <3300000>;
74 regulator-max-microvolt = <3300000>;
75 gpio = <&gpio1 29 0>;
76 };
77 };
78};
diff --git a/arch/arm/boot/dts/imx23.dtsi b/arch/arm/boot/dts/imx23.dtsi
index 8c5f9994f3f..e6138310e5c 100644
--- a/arch/arm/boot/dts/imx23.dtsi
+++ b/arch/arm/boot/dts/imx23.dtsi
@@ -18,6 +18,8 @@
18 gpio0 = &gpio0; 18 gpio0 = &gpio0;
19 gpio1 = &gpio1; 19 gpio1 = &gpio1;
20 gpio2 = &gpio2; 20 gpio2 = &gpio2;
21 serial0 = &auart0;
22 serial1 = &auart1;
21 }; 23 };
22 24
23 cpus { 25 cpus {
@@ -49,33 +51,35 @@
49 51
50 dma-apbh@80004000 { 52 dma-apbh@80004000 {
51 compatible = "fsl,imx23-dma-apbh"; 53 compatible = "fsl,imx23-dma-apbh";
52 reg = <0x80004000 2000>; 54 reg = <0x80004000 0x2000>;
53 }; 55 };
54 56
55 ecc@80008000 { 57 ecc@80008000 {
56 reg = <0x80008000 2000>; 58 reg = <0x80008000 0x2000>;
57 status = "disabled"; 59 status = "disabled";
58 }; 60 };
59 61
60 bch@8000a000 { 62 gpmi-nand@8000c000 {
61 reg = <0x8000a000 2000>; 63 compatible = "fsl,imx23-gpmi-nand";
62 status = "disabled"; 64 #address-cells = <1>;
63 }; 65 #size-cells = <1>;
64 66 reg = <0x8000c000 0x2000>, <0x8000a000 0x2000>;
65 gpmi@8000c000 { 67 reg-names = "gpmi-nand", "bch";
66 reg = <0x8000c000 2000>; 68 interrupts = <13>, <56>;
69 interrupt-names = "gpmi-dma", "bch";
70 fsl,gpmi-dma-channel = <4>;
67 status = "disabled"; 71 status = "disabled";
68 }; 72 };
69 73
70 ssp0: ssp@80010000 { 74 ssp0: ssp@80010000 {
71 reg = <0x80010000 2000>; 75 reg = <0x80010000 0x2000>;
72 interrupts = <15 14>; 76 interrupts = <15 14>;
73 fsl,ssp-dma-channel = <1>; 77 fsl,ssp-dma-channel = <1>;
74 status = "disabled"; 78 status = "disabled";
75 }; 79 };
76 80
77 etm@80014000 { 81 etm@80014000 {
78 reg = <0x80014000 2000>; 82 reg = <0x80014000 0x2000>;
79 status = "disabled"; 83 status = "disabled";
80 }; 84 };
81 85
@@ -83,7 +87,7 @@
83 #address-cells = <1>; 87 #address-cells = <1>;
84 #size-cells = <0>; 88 #size-cells = <0>;
85 compatible = "fsl,imx23-pinctrl", "simple-bus"; 89 compatible = "fsl,imx23-pinctrl", "simple-bus";
86 reg = <0x80018000 2000>; 90 reg = <0x80018000 0x2000>;
87 91
88 gpio0: gpio@0 { 92 gpio0: gpio@0 {
89 compatible = "fsl,imx23-gpio", "fsl,mxs-gpio"; 93 compatible = "fsl,imx23-gpio", "fsl,mxs-gpio";
@@ -114,24 +118,151 @@
114 118
115 duart_pins_a: duart@0 { 119 duart_pins_a: duart@0 {
116 reg = <0>; 120 reg = <0>;
117 fsl,pinmux-ids = <0x11a2 0x11b2>; 121 fsl,pinmux-ids = <
122 0x11a2 /* MX23_PAD_PWM0__DUART_RX */
123 0x11b2 /* MX23_PAD_PWM1__DUART_TX */
124 >;
125 fsl,drive-strength = <0>;
126 fsl,voltage = <1>;
127 fsl,pull-up = <0>;
128 };
129
130 auart0_pins_a: auart0@0 {
131 reg = <0>;
132 fsl,pinmux-ids = <
133 0x01c0 /* MX23_PAD_AUART1_RX__AUART1_RX */
134 0x01d0 /* MX23_PAD_AUART1_TX__AUART1_TX */
135 0x01a0 /* MX23_PAD_AUART1_CTS__AUART1_CTS */
136 0x01b0 /* MX23_PAD_AUART1_RTS__AUART1_RTS */
137 >;
118 fsl,drive-strength = <0>; 138 fsl,drive-strength = <0>;
119 fsl,voltage = <1>; 139 fsl,voltage = <1>;
120 fsl,pull-up = <0>; 140 fsl,pull-up = <0>;
121 }; 141 };
122 142
143 gpmi_pins_a: gpmi-nand@0 {
144 reg = <0>;
145 fsl,pinmux-ids = <
146 0x0000 /* MX23_PAD_GPMI_D00__GPMI_D00 */
147 0x0010 /* MX23_PAD_GPMI_D01__GPMI_D01 */
148 0x0020 /* MX23_PAD_GPMI_D02__GPMI_D02 */
149 0x0030 /* MX23_PAD_GPMI_D03__GPMI_D03 */
150 0x0040 /* MX23_PAD_GPMI_D04__GPMI_D04 */
151 0x0050 /* MX23_PAD_GPMI_D05__GPMI_D05 */
152 0x0060 /* MX23_PAD_GPMI_D06__GPMI_D06 */
153 0x0070 /* MX23_PAD_GPMI_D07__GPMI_D07 */
154 0x0100 /* MX23_PAD_GPMI_CLE__GPMI_CLE */
155 0x0110 /* MX23_PAD_GPMI_ALE__GPMI_ALE */
156 0x0130 /* MX23_PAD_GPMI_RDY0__GPMI_RDY0 */
157 0x0140 /* MX23_PAD_GPMI_RDY1__GPMI_RDY1 */
158 0x0170 /* MX23_PAD_GPMI_WPN__GPMI_WPN */
159 0x0180 /* MX23_PAD_GPMI_WRN__GPMI_WRN */
160 0x0190 /* MX23_PAD_GPMI_RDN__GPMI_RDN */
161 0x21b0 /* MX23_PAD_GPMI_CE1N__GPMI_CE1N */
162 0x21c0 /* MX23_PAD_GPMI_CE0N__GPMI_CE0N */
163 >;
164 fsl,drive-strength = <0>;
165 fsl,voltage = <1>;
166 fsl,pull-up = <0>;
167 };
168
169 gpmi_pins_fixup: gpmi-pins-fixup {
170 fsl,pinmux-ids = <
171 0x0170 /* MX23_PAD_GPMI_WPN__GPMI_WPN */
172 0x0180 /* MX23_PAD_GPMI_WRN__GPMI_WRN */
173 0x0190 /* MX23_PAD_GPMI_RDN__GPMI_RDN */
174 >;
175 fsl,drive-strength = <2>;
176 };
177
178 mmc0_4bit_pins_a: mmc0-4bit@0 {
179 reg = <0>;
180 fsl,pinmux-ids = <
181 0x2020 /* MX23_PAD_SSP1_DATA0__SSP1_DATA0 */
182 0x2030 /* MX23_PAD_SSP1_DATA1__SSP1_DATA1 */
183 0x2040 /* MX23_PAD_SSP1_DATA2__SSP1_DATA2 */
184 0x2050 /* MX23_PAD_SSP1_DATA3__SSP1_DATA3 */
185 0x2000 /* MX23_PAD_SSP1_CMD__SSP1_CMD */
186 0x2010 /* MX23_PAD_SSP1_DETECT__SSP1_DETECT */
187 0x2060 /* MX23_PAD_SSP1_SCK__SSP1_SCK */
188 >;
189 fsl,drive-strength = <1>;
190 fsl,voltage = <1>;
191 fsl,pull-up = <1>;
192 };
193
123 mmc0_8bit_pins_a: mmc0-8bit@0 { 194 mmc0_8bit_pins_a: mmc0-8bit@0 {
124 reg = <0>; 195 reg = <0>;
125 fsl,pinmux-ids = <0x2020 0x2030 0x2040 196 fsl,pinmux-ids = <
126 0x2050 0x0082 0x0092 0x00a2 197 0x2020 /* MX23_PAD_SSP1_DATA0__SSP1_DATA0 */
127 0x00b2 0x2000 0x2010 0x2060>; 198 0x2030 /* MX23_PAD_SSP1_DATA1__SSP1_DATA1 */
199 0x2040 /* MX23_PAD_SSP1_DATA2__SSP1_DATA2 */
200 0x2050 /* MX23_PAD_SSP1_DATA3__SSP1_DATA3 */
201 0x0082 /* MX23_PAD_GPMI_D08__SSP1_DATA4 */
202 0x0092 /* MX23_PAD_GPMI_D09__SSP1_DATA5 */
203 0x00a2 /* MX23_PAD_GPMI_D10__SSP1_DATA6 */
204 0x00b2 /* MX23_PAD_GPMI_D11__SSP1_DATA7 */
205 0x2000 /* MX23_PAD_SSP1_CMD__SSP1_CMD */
206 0x2010 /* MX23_PAD_SSP1_DETECT__SSP1_DETECT */
207 0x2060 /* MX23_PAD_SSP1_SCK__SSP1_SCK */
208 >;
128 fsl,drive-strength = <1>; 209 fsl,drive-strength = <1>;
129 fsl,voltage = <1>; 210 fsl,voltage = <1>;
130 fsl,pull-up = <1>; 211 fsl,pull-up = <1>;
131 }; 212 };
132 213
133 mmc0_pins_fixup: mmc0-pins-fixup { 214 mmc0_pins_fixup: mmc0-pins-fixup {
134 fsl,pinmux-ids = <0x2010 0x2060>; 215 fsl,pinmux-ids = <
216 0x2010 /* MX23_PAD_SSP1_DETECT__SSP1_DETECT */
217 0x2060 /* MX23_PAD_SSP1_SCK__SSP1_SCK */
218 >;
219 fsl,pull-up = <0>;
220 };
221
222 pwm2_pins_a: pwm2@0 {
223 reg = <0>;
224 fsl,pinmux-ids = <
225 0x11c0 /* MX23_PAD_PWM2__PWM2 */
226 >;
227 fsl,drive-strength = <0>;
228 fsl,voltage = <1>;
229 fsl,pull-up = <0>;
230 };
231
232 lcdif_24bit_pins_a: lcdif-24bit@0 {
233 reg = <0>;
234 fsl,pinmux-ids = <
235 0x1000 /* MX23_PAD_LCD_D00__LCD_D0 */
236 0x1010 /* MX23_PAD_LCD_D01__LCD_D1 */
237 0x1020 /* MX23_PAD_LCD_D02__LCD_D2 */
238 0x1030 /* MX23_PAD_LCD_D03__LCD_D3 */
239 0x1040 /* MX23_PAD_LCD_D04__LCD_D4 */
240 0x1050 /* MX23_PAD_LCD_D05__LCD_D5 */
241 0x1060 /* MX23_PAD_LCD_D06__LCD_D6 */
242 0x1070 /* MX23_PAD_LCD_D07__LCD_D7 */
243 0x1080 /* MX23_PAD_LCD_D08__LCD_D8 */
244 0x1090 /* MX23_PAD_LCD_D09__LCD_D9 */
245 0x10a0 /* MX23_PAD_LCD_D10__LCD_D10 */
246 0x10b0 /* MX23_PAD_LCD_D11__LCD_D11 */
247 0x10c0 /* MX23_PAD_LCD_D12__LCD_D12 */
248 0x10d0 /* MX23_PAD_LCD_D13__LCD_D13 */
249 0x10e0 /* MX23_PAD_LCD_D14__LCD_D14 */
250 0x10f0 /* MX23_PAD_LCD_D15__LCD_D15 */
251 0x1100 /* MX23_PAD_LCD_D16__LCD_D16 */
252 0x1110 /* MX23_PAD_LCD_D17__LCD_D17 */
253 0x0081 /* MX23_PAD_GPMI_D08__LCD_D18 */
254 0x0091 /* MX23_PAD_GPMI_D09__LCD_D19 */
255 0x00a1 /* MX23_PAD_GPMI_D10__LCD_D20 */
256 0x00b1 /* MX23_PAD_GPMI_D11__LCD_D21 */
257 0x00c1 /* MX23_PAD_GPMI_D12__LCD_D22 */
258 0x00d1 /* MX23_PAD_GPMI_D13__LCD_D23 */
259 0x1160 /* MX23_PAD_LCD_DOTCK__LCD_DOTCK */
260 0x1170 /* MX23_PAD_LCD_ENABLE__LCD_ENABLE */
261 0x1180 /* MX23_PAD_LCD_HSYNC__LCD_HSYNC */
262 0x1190 /* MX23_PAD_LCD_VSYNC__LCD_VSYNC */
263 >;
264 fsl,drive-strength = <0>;
265 fsl,voltage = <1>;
135 fsl,pull-up = <0>; 266 fsl,pull-up = <0>;
136 }; 267 };
137 }; 268 };
@@ -142,49 +273,51 @@
142 }; 273 };
143 274
144 emi@80020000 { 275 emi@80020000 {
145 reg = <0x80020000 2000>; 276 reg = <0x80020000 0x2000>;
146 status = "disabled"; 277 status = "disabled";
147 }; 278 };
148 279
149 dma-apbx@80024000 { 280 dma-apbx@80024000 {
150 compatible = "fsl,imx23-dma-apbx"; 281 compatible = "fsl,imx23-dma-apbx";
151 reg = <0x80024000 2000>; 282 reg = <0x80024000 0x2000>;
152 }; 283 };
153 284
154 dcp@80028000 { 285 dcp@80028000 {
155 reg = <0x80028000 2000>; 286 reg = <0x80028000 0x2000>;
156 status = "disabled"; 287 status = "disabled";
157 }; 288 };
158 289
159 pxp@8002a000 { 290 pxp@8002a000 {
160 reg = <0x8002a000 2000>; 291 reg = <0x8002a000 0x2000>;
161 status = "disabled"; 292 status = "disabled";
162 }; 293 };
163 294
164 ocotp@8002c000 { 295 ocotp@8002c000 {
165 reg = <0x8002c000 2000>; 296 reg = <0x8002c000 0x2000>;
166 status = "disabled"; 297 status = "disabled";
167 }; 298 };
168 299
169 axi-ahb@8002e000 { 300 axi-ahb@8002e000 {
170 reg = <0x8002e000 2000>; 301 reg = <0x8002e000 0x2000>;
171 status = "disabled"; 302 status = "disabled";
172 }; 303 };
173 304
174 lcdif@80030000 { 305 lcdif@80030000 {
306 compatible = "fsl,imx23-lcdif";
175 reg = <0x80030000 2000>; 307 reg = <0x80030000 2000>;
308 interrupts = <46 45>;
176 status = "disabled"; 309 status = "disabled";
177 }; 310 };
178 311
179 ssp1: ssp@80034000 { 312 ssp1: ssp@80034000 {
180 reg = <0x80034000 2000>; 313 reg = <0x80034000 0x2000>;
181 interrupts = <2 20>; 314 interrupts = <2 20>;
182 fsl,ssp-dma-channel = <2>; 315 fsl,ssp-dma-channel = <2>;
183 status = "disabled"; 316 status = "disabled";
184 }; 317 };
185 318
186 tvenc@80038000 { 319 tvenc@80038000 {
187 reg = <0x80038000 2000>; 320 reg = <0x80038000 0x2000>;
188 status = "disabled"; 321 status = "disabled";
189 }; 322 };
190 }; 323 };
@@ -197,37 +330,37 @@
197 ranges; 330 ranges;
198 331
199 clkctl@80040000 { 332 clkctl@80040000 {
200 reg = <0x80040000 2000>; 333 reg = <0x80040000 0x2000>;
201 status = "disabled"; 334 status = "disabled";
202 }; 335 };
203 336
204 saif0: saif@80042000 { 337 saif0: saif@80042000 {
205 reg = <0x80042000 2000>; 338 reg = <0x80042000 0x2000>;
206 status = "disabled"; 339 status = "disabled";
207 }; 340 };
208 341
209 power@80044000 { 342 power@80044000 {
210 reg = <0x80044000 2000>; 343 reg = <0x80044000 0x2000>;
211 status = "disabled"; 344 status = "disabled";
212 }; 345 };
213 346
214 saif1: saif@80046000 { 347 saif1: saif@80046000 {
215 reg = <0x80046000 2000>; 348 reg = <0x80046000 0x2000>;
216 status = "disabled"; 349 status = "disabled";
217 }; 350 };
218 351
219 audio-out@80048000 { 352 audio-out@80048000 {
220 reg = <0x80048000 2000>; 353 reg = <0x80048000 0x2000>;
221 status = "disabled"; 354 status = "disabled";
222 }; 355 };
223 356
224 audio-in@8004c000 { 357 audio-in@8004c000 {
225 reg = <0x8004c000 2000>; 358 reg = <0x8004c000 0x2000>;
226 status = "disabled"; 359 status = "disabled";
227 }; 360 };
228 361
229 lradc@80050000 { 362 lradc@80050000 {
230 reg = <0x80050000 2000>; 363 reg = <0x80050000 0x2000>;
231 status = "disabled"; 364 status = "disabled";
232 }; 365 };
233 366
@@ -237,32 +370,40 @@
237 }; 370 };
238 371
239 i2c@80058000 { 372 i2c@80058000 {
240 reg = <0x80058000 2000>; 373 reg = <0x80058000 0x2000>;
241 status = "disabled"; 374 status = "disabled";
242 }; 375 };
243 376
244 rtc@8005c000 { 377 rtc@8005c000 {
245 reg = <0x8005c000 2000>; 378 compatible = "fsl,imx23-rtc", "fsl,stmp3xxx-rtc";
246 status = "disabled"; 379 reg = <0x8005c000 0x2000>;
380 interrupts = <22>;
247 }; 381 };
248 382
249 pwm@80064000 { 383 pwm: pwm@80064000 {
250 reg = <0x80064000 2000>; 384 compatible = "fsl,imx23-pwm";
385 reg = <0x80064000 0x2000>;
386 #pwm-cells = <2>;
387 fsl,pwm-number = <5>;
251 status = "disabled"; 388 status = "disabled";
252 }; 389 };
253 390
254 timrot@80068000 { 391 timrot@80068000 {
255 reg = <0x80068000 2000>; 392 reg = <0x80068000 0x2000>;
256 status = "disabled"; 393 status = "disabled";
257 }; 394 };
258 395
259 auart0: serial@8006c000 { 396 auart0: serial@8006c000 {
397 compatible = "fsl,imx23-auart";
260 reg = <0x8006c000 0x2000>; 398 reg = <0x8006c000 0x2000>;
399 interrupts = <24 25 23>;
261 status = "disabled"; 400 status = "disabled";
262 }; 401 };
263 402
264 auart1: serial@8006e000 { 403 auart1: serial@8006e000 {
404 compatible = "fsl,imx23-auart";
265 reg = <0x8006e000 0x2000>; 405 reg = <0x8006e000 0x2000>;
406 interrupts = <59 60 58>;
266 status = "disabled"; 407 status = "disabled";
267 }; 408 };
268 409
@@ -288,7 +429,7 @@
288 ranges; 429 ranges;
289 430
290 usbctrl@80080000 { 431 usbctrl@80080000 {
291 reg = <0x80080000 0x10000>; 432 reg = <0x80080000 0x40000>;
292 status = "disabled"; 433 status = "disabled";
293 }; 434 };
294 }; 435 };
diff --git a/arch/arm/boot/dts/imx27-3ds.dts b/arch/arm/boot/dts/imx27-3ds.dts
new file mode 100644
index 00000000000..0a8978a40ec
--- /dev/null
+++ b/arch/arm/boot/dts/imx27-3ds.dts
@@ -0,0 +1,41 @@
1/*
2 * Copyright 2012 Sascha Hauer, Pengutronix
3 *
4 * The code contained herein is licensed under the GNU General Public
5 * License. You may obtain a copy of the GNU General Public License
6 * Version 2 or later at the following locations:
7 *
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
10 */
11
12/dts-v1/;
13/include/ "imx27.dtsi"
14
15/ {
16 model = "mx27_3ds";
17 compatible = "freescale,imx27-3ds", "fsl,imx27";
18
19 memory {
20 reg = <0x0 0x0>;
21 };
22
23 soc {
24 aipi@10000000 { /* aipi */
25
26 wdog@10002000 {
27 status = "okay";
28 };
29
30 uart1: serial@1000a000 {
31 fsl,uart-has-rtscts;
32 status = "okay";
33 };
34
35 fec@1002b000 {
36 status = "okay";
37 };
38 };
39 };
40
41};
diff --git a/arch/arm/boot/dts/imx27.dtsi b/arch/arm/boot/dts/imx27.dtsi
index 386c769c38d..5303ab680a3 100644
--- a/arch/arm/boot/dts/imx27.dtsi
+++ b/arch/arm/boot/dts/imx27.dtsi
@@ -19,6 +19,12 @@
19 serial3 = &uart4; 19 serial3 = &uart4;
20 serial4 = &uart5; 20 serial4 = &uart5;
21 serial5 = &uart6; 21 serial5 = &uart6;
22 gpio0 = &gpio1;
23 gpio1 = &gpio2;
24 gpio2 = &gpio3;
25 gpio3 = &gpio4;
26 gpio4 = &gpio5;
27 gpio5 = &gpio6;
22 }; 28 };
23 29
24 avic: avic-interrupt-controller@e0000000 { 30 avic: avic-interrupt-controller@e0000000 {
@@ -121,7 +127,7 @@
121 gpio-controller; 127 gpio-controller;
122 #gpio-cells = <2>; 128 #gpio-cells = <2>;
123 interrupt-controller; 129 interrupt-controller;
124 #interrupt-cells = <1>; 130 #interrupt-cells = <2>;
125 }; 131 };
126 132
127 gpio2: gpio@10015100 { 133 gpio2: gpio@10015100 {
@@ -131,7 +137,7 @@
131 gpio-controller; 137 gpio-controller;
132 #gpio-cells = <2>; 138 #gpio-cells = <2>;
133 interrupt-controller; 139 interrupt-controller;
134 #interrupt-cells = <1>; 140 #interrupt-cells = <2>;
135 }; 141 };
136 142
137 gpio3: gpio@10015200 { 143 gpio3: gpio@10015200 {
@@ -141,7 +147,7 @@
141 gpio-controller; 147 gpio-controller;
142 #gpio-cells = <2>; 148 #gpio-cells = <2>;
143 interrupt-controller; 149 interrupt-controller;
144 #interrupt-cells = <1>; 150 #interrupt-cells = <2>;
145 }; 151 };
146 152
147 gpio4: gpio@10015300 { 153 gpio4: gpio@10015300 {
@@ -151,7 +157,7 @@
151 gpio-controller; 157 gpio-controller;
152 #gpio-cells = <2>; 158 #gpio-cells = <2>;
153 interrupt-controller; 159 interrupt-controller;
154 #interrupt-cells = <1>; 160 #interrupt-cells = <2>;
155 }; 161 };
156 162
157 gpio5: gpio@10015400 { 163 gpio5: gpio@10015400 {
@@ -161,7 +167,7 @@
161 gpio-controller; 167 gpio-controller;
162 #gpio-cells = <2>; 168 #gpio-cells = <2>;
163 interrupt-controller; 169 interrupt-controller;
164 #interrupt-cells = <1>; 170 #interrupt-cells = <2>;
165 }; 171 };
166 172
167 gpio6: gpio@10015500 { 173 gpio6: gpio@10015500 {
@@ -171,7 +177,7 @@
171 gpio-controller; 177 gpio-controller;
172 #gpio-cells = <2>; 178 #gpio-cells = <2>;
173 interrupt-controller; 179 interrupt-controller;
174 #interrupt-cells = <1>; 180 #interrupt-cells = <2>;
175 }; 181 };
176 182
177 cspi3: cspi@10017000 { 183 cspi3: cspi@10017000 {
diff --git a/arch/arm/boot/dts/imx28-apx4devkit.dts b/arch/arm/boot/dts/imx28-apx4devkit.dts
new file mode 100644
index 00000000000..b383417a558
--- /dev/null
+++ b/arch/arm/boot/dts/imx28-apx4devkit.dts
@@ -0,0 +1,198 @@
1/dts-v1/;
2/include/ "imx28.dtsi"
3
4/ {
5 model = "Bluegiga APX4 Development Kit";
6 compatible = "bluegiga,apx4devkit", "fsl,imx28";
7
8 memory {
9 reg = <0x40000000 0x04000000>;
10 };
11
12 apb@80000000 {
13 apbh@80000000 {
14 gpmi-nand@8000c000 {
15 pinctrl-names = "default";
16 pinctrl-0 = <&gpmi_pins_a &gpmi_status_cfg>;
17 status = "okay";
18 };
19
20 ssp0: ssp@80010000 {
21 compatible = "fsl,imx28-mmc";
22 pinctrl-names = "default";
23 pinctrl-0 = <&mmc0_4bit_pins_a &mmc0_sck_cfg>;
24 bus-width = <4>;
25 status = "okay";
26 };
27
28 ssp2: ssp@80014000 {
29 compatible = "fsl,imx28-mmc";
30 pinctrl-names = "default";
31 pinctrl-0 = <&mmc2_4bit_pins_apx4 &mmc2_sck_cfg_apx4>;
32 bus-width = <4>;
33 status = "okay";
34 };
35
36 pinctrl@80018000 {
37 pinctrl-names = "default";
38 pinctrl-0 = <&hog_pins_a>;
39
40 hog_pins_a: hog-gpios@0 {
41 reg = <0>;
42 fsl,pinmux-ids = <
43 0x0113 /* MX28_PAD_GPMI_CE1N__GPIO_0_17 */
44 0x0153 /* MX28_PAD_GPMI_RDY1__GPIO_0_21 */
45 0x2123 /* MX28_PAD_SSP2_MISO__GPIO_2_18 */
46 0x2131 /* MX28_PAD_SSP2_SS0__GPIO_2_19 */
47 0x31c3 /* MX28_PAD_PWM3__GPIO_3_28 */
48 0x31e3 /* MX28_PAD_LCD_RESET__GPIO_3_30 */
49 0x4143 /* MX28_PAD_JTAG_RTCK__GPIO_4_20 */
50 >;
51 fsl,drive-strength = <0>;
52 fsl,voltage = <1>;
53 fsl,pull-up = <0>;
54 };
55
56 lcdif_pins_apx4: lcdif-apx4@0 {
57 reg = <0>;
58 fsl,pinmux-ids = <
59 0x1181 /* MX28_PAD_LCD_RD_E__LCD_VSYNC */
60 0x1191 /* MX28_PAD_LCD_WR_RWN__LCD_HSYNC */
61 0x11a1 /* MX28_PAD_LCD_RS__LCD_DOTCLK */
62 0x11b1 /* MX28_PAD_LCD_CS__LCD_ENABLE */
63 >;
64 fsl,drive-strength = <0>;
65 fsl,voltage = <1>;
66 fsl,pull-up = <0>;
67 };
68
69 mmc2_4bit_pins_apx4: mmc2-4bit-apx4@0 {
70 reg = <0>;
71 fsl,pinmux-ids = <
72 0x2041 /* MX28_PAD_SSP0_DATA4__SSP2_D0 */
73 0x2051 /* MX28_PAD_SSP0_DATA5__SSP2_D3 */
74 0x2061 /* MX28_PAD_SSP0_DATA6__SSP2_CMD */
75 0x2071 /* MX28_PAD_SSP0_DATA7__SSP2_SCK */
76 0x2141 /* MX28_PAD_SSP2_SS1__SSP2_D1 */
77 0x2151 /* MX28_PAD_SSP2_SS2__SSP2_D2 */
78 >;
79 fsl,drive-strength = <1>;
80 fsl,voltage = <1>;
81 fsl,pull-up = <1>;
82 };
83
84 mmc2_sck_cfg_apx4: mmc2-sck-cfg-apx4 {
85 fsl,pinmux-ids = <
86 0x2071 /* MX28_PAD_SSP0_DATA7__SSP2_SCK */
87 >;
88 fsl,drive-strength = <2>;
89 fsl,pull-up = <0>;
90 };
91 };
92
93 lcdif@80030000 {
94 pinctrl-names = "default";
95 pinctrl-0 = <&lcdif_24bit_pins_a
96 &lcdif_pins_apx4>;
97 status = "okay";
98 };
99 };
100
101 apbx@80040000 {
102 saif0: saif@80042000 {
103 pinctrl-names = "default";
104 pinctrl-0 = <&saif0_pins_a>;
105 status = "okay";
106 };
107
108 saif1: saif@80046000 {
109 pinctrl-names = "default";
110 pinctrl-0 = <&saif1_pins_a>;
111 fsl,saif-master = <&saif0>;
112 status = "okay";
113 };
114
115 i2c0: i2c@80058000 {
116 pinctrl-names = "default";
117 pinctrl-0 = <&i2c0_pins_a>;
118 status = "okay";
119
120 sgtl5000: codec@0a {
121 compatible = "fsl,sgtl5000";
122 reg = <0x0a>;
123 VDDA-supply = <&reg_3p3v>;
124 VDDIO-supply = <&reg_3p3v>;
125
126 };
127
128 pcf8563: rtc@51 {
129 compatible = "phg,pcf8563";
130 reg = <0x51>;
131 };
132 };
133
134 duart: serial@80074000 {
135 pinctrl-names = "default";
136 pinctrl-0 = <&duart_pins_a>;
137 status = "okay";
138 };
139
140 auart0: serial@8006a000 {
141 pinctrl-names = "default";
142 pinctrl-0 = <&auart0_pins_a>;
143 status = "okay";
144 };
145
146 auart1: serial@8006c000 {
147 pinctrl-names = "default";
148 pinctrl-0 = <&auart1_2pins_a>;
149 status = "okay";
150 };
151
152 auart2: serial@8006e000 {
153 pinctrl-names = "default";
154 pinctrl-0 = <&auart2_2pins_a>;
155 status = "okay";
156 };
157 };
158 };
159
160 ahb@80080000 {
161 mac0: ethernet@800f0000 {
162 phy-mode = "rmii";
163 pinctrl-names = "default";
164 pinctrl-0 = <&mac0_pins_a>;
165 status = "okay";
166 };
167 };
168
169 regulators {
170 compatible = "simple-bus";
171
172 reg_3p3v: 3p3v {
173 compatible = "regulator-fixed";
174 regulator-name = "3P3V";
175 regulator-min-microvolt = <3300000>;
176 regulator-max-microvolt = <3300000>;
177 regulator-always-on;
178 };
179 };
180
181 sound {
182 compatible = "bluegiga,apx4devkit-sgtl5000",
183 "fsl,mxs-audio-sgtl5000";
184 model = "apx4devkit-sgtl5000";
185 saif-controllers = <&saif0 &saif1>;
186 audio-codec = <&sgtl5000>;
187 };
188
189 leds {
190 compatible = "gpio-leds";
191
192 user {
193 label = "Heartbeat";
194 gpios = <&gpio3 28 0>;
195 linux,default-trigger = "heartbeat";
196 };
197 };
198};
diff --git a/arch/arm/boot/dts/imx28-cfa10036.dts b/arch/arm/boot/dts/imx28-cfa10036.dts
new file mode 100644
index 00000000000..c03a577beca
--- /dev/null
+++ b/arch/arm/boot/dts/imx28-cfa10036.dts
@@ -0,0 +1,52 @@
1/*
2 * Copyright 2012 Free Electrons
3 *
4 * The code contained herein is licensed under the GNU General Public
5 * License. You may obtain a copy of the GNU General Public License
6 * Version 2 or later at the following locations:
7 *
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
10 */
11
12/dts-v1/;
13/include/ "imx28.dtsi"
14
15/ {
16 model = "Crystalfontz CFA-10036 Board";
17 compatible = "crystalfontz,cfa10036", "fsl,imx28";
18
19 memory {
20 reg = <0x40000000 0x08000000>;
21 };
22
23 apb@80000000 {
24 apbh@80000000 {
25 ssp0: ssp@80010000 {
26 compatible = "fsl,imx28-mmc";
27 pinctrl-names = "default";
28 pinctrl-0 = <&mmc0_4bit_pins_a
29 &mmc0_cd_cfg &mmc0_sck_cfg>;
30 bus-width = <4>;
31 status = "okay";
32 };
33 };
34
35 apbx@80040000 {
36 duart: serial@80074000 {
37 pinctrl-names = "default";
38 pinctrl-0 = <&duart_pins_b>;
39 status = "okay";
40 };
41 };
42 };
43
44 leds {
45 compatible = "gpio-leds";
46
47 power {
48 gpios = <&gpio3 4 1>;
49 default-state = "on";
50 };
51 };
52};
diff --git a/arch/arm/boot/dts/imx28-evk.dts b/arch/arm/boot/dts/imx28-evk.dts
index ee520a529cb..773c0e84d1f 100644
--- a/arch/arm/boot/dts/imx28-evk.dts
+++ b/arch/arm/boot/dts/imx28-evk.dts
@@ -22,6 +22,13 @@
22 22
23 apb@80000000 { 23 apb@80000000 {
24 apbh@80000000 { 24 apbh@80000000 {
25 gpmi-nand@8000c000 {
26 pinctrl-names = "default";
27 pinctrl-0 = <&gpmi_pins_a &gpmi_status_cfg
28 &gpmi_pins_evk>;
29 status = "okay";
30 };
31
25 ssp0: ssp@80010000 { 32 ssp0: ssp@80010000 {
26 compatible = "fsl,imx28-mmc"; 33 compatible = "fsl,imx28-mmc";
27 pinctrl-names = "default"; 34 pinctrl-names = "default";
@@ -29,6 +36,7 @@
29 &mmc0_cd_cfg &mmc0_sck_cfg>; 36 &mmc0_cd_cfg &mmc0_sck_cfg>;
30 bus-width = <8>; 37 bus-width = <8>;
31 wp-gpios = <&gpio2 12 0>; 38 wp-gpios = <&gpio2 12 0>;
39 vmmc-supply = <&reg_vddio_sd0>;
32 status = "okay"; 40 status = "okay";
33 }; 41 };
34 42
@@ -36,6 +44,72 @@
36 compatible = "fsl,imx28-mmc"; 44 compatible = "fsl,imx28-mmc";
37 bus-width = <8>; 45 bus-width = <8>;
38 wp-gpios = <&gpio0 28 0>; 46 wp-gpios = <&gpio0 28 0>;
47 };
48
49 pinctrl@80018000 {
50 pinctrl-names = "default";
51 pinctrl-0 = <&hog_pins_a>;
52
53 hog_pins_a: hog-gpios@0 {
54 reg = <0>;
55 fsl,pinmux-ids = <
56 0x20d3 /* MX28_PAD_SSP1_CMD__GPIO_2_13 */
57 0x20f3 /* MX28_PAD_SSP1_DATA3__GPIO_2_15 */
58 0x40d3 /* MX28_PAD_ENET0_RX_CLK__GPIO_4_13 */
59 0x20c3 /* MX28_PAD_SSP1_SCK__GPIO_2_12 */
60 0x31c3 /* MX28_PAD_PWM3__GPIO_3_28 */
61 0x31e3 /* MX28_PAD_LCD_RESET__GPIO_3_30 */
62 0x3053 /* MX28_PAD_AUART1_TX__GPIO_3_5 */
63 0x3083 /* MX28_PAD_AUART2_RX__GPIO_3_8 */
64 0x3093 /* MX28_PAD_AUART2_TX__GPIO_3_9 */
65 >;
66 fsl,drive-strength = <0>;
67 fsl,voltage = <1>;
68 fsl,pull-up = <0>;
69 };
70
71 gpmi_pins_evk: gpmi-nand-evk@0 {
72 reg = <0>;
73 fsl,pinmux-ids = <
74 0x0110 /* MX28_PAD_GPMI_CE1N__GPMI_CE1N */
75 0x0150 /* MX28_PAD_GPMI_RDY1__GPMI_READY1 */
76 >;
77 fsl,drive-strength = <0>;
78 fsl,voltage = <1>;
79 fsl,pull-up = <0>;
80 };
81
82 lcdif_pins_evk: lcdif-evk@0 {
83 reg = <0>;
84 fsl,pinmux-ids = <
85 0x1181 /* MX28_PAD_LCD_RD_E__LCD_VSYNC */
86 0x1191 /* MX28_PAD_LCD_WR_RWN__LCD_HSYNC */
87 0x11a1 /* MX28_PAD_LCD_RS__LCD_DOTCLK */
88 0x11b1 /* MX28_PAD_LCD_CS__LCD_ENABLE */
89 >;
90 fsl,drive-strength = <0>;
91 fsl,voltage = <1>;
92 fsl,pull-up = <0>;
93 };
94 };
95
96 lcdif@80030000 {
97 pinctrl-names = "default";
98 pinctrl-0 = <&lcdif_24bit_pins_a
99 &lcdif_pins_evk>;
100 panel-enable-gpios = <&gpio3 30 0>;
101 status = "okay";
102 };
103
104 can0: can@80032000 {
105 pinctrl-names = "default";
106 pinctrl-0 = <&can0_pins_a>;
107 status = "okay";
108 };
109
110 can1: can@80034000 {
111 pinctrl-names = "default";
112 pinctrl-0 = <&can1_pins_a>;
39 status = "okay"; 113 status = "okay";
40 }; 114 };
41 }; 115 };
@@ -68,19 +142,58 @@
68 }; 142 };
69 }; 143 };
70 144
145 pwm: pwm@80064000 {
146 pinctrl-names = "default";
147 pinctrl-0 = <&pwm2_pins_a>;
148 status = "okay";
149 };
150
71 duart: serial@80074000 { 151 duart: serial@80074000 {
72 pinctrl-names = "default"; 152 pinctrl-names = "default";
73 pinctrl-0 = <&duart_pins_a>; 153 pinctrl-0 = <&duart_pins_a>;
74 status = "okay"; 154 status = "okay";
75 }; 155 };
156
157 auart0: serial@8006a000 {
158 pinctrl-names = "default";
159 pinctrl-0 = <&auart0_pins_a>;
160 status = "okay";
161 };
162
163 auart3: serial@80070000 {
164 pinctrl-names = "default";
165 pinctrl-0 = <&auart3_pins_a>;
166 status = "okay";
167 };
168
169 usbphy0: usbphy@8007c000 {
170 status = "okay";
171 };
172
173 usbphy1: usbphy@8007e000 {
174 status = "okay";
175 };
76 }; 176 };
77 }; 177 };
78 178
79 ahb@80080000 { 179 ahb@80080000 {
180 usb0: usb@80080000 {
181 vbus-supply = <&reg_usb0_vbus>;
182 status = "okay";
183 };
184
185 usb1: usb@80090000 {
186 vbus-supply = <&reg_usb1_vbus>;
187 status = "okay";
188 };
189
80 mac0: ethernet@800f0000 { 190 mac0: ethernet@800f0000 {
81 phy-mode = "rmii"; 191 phy-mode = "rmii";
82 pinctrl-names = "default"; 192 pinctrl-names = "default";
83 pinctrl-0 = <&mac0_pins_a>; 193 pinctrl-0 = <&mac0_pins_a>;
194 phy-supply = <&reg_fec_3v3>;
195 phy-reset-gpios = <&gpio4 13 0>;
196 phy-reset-duration = <100>;
84 status = "okay"; 197 status = "okay";
85 }; 198 };
86 199
@@ -102,6 +215,40 @@
102 regulator-max-microvolt = <3300000>; 215 regulator-max-microvolt = <3300000>;
103 regulator-always-on; 216 regulator-always-on;
104 }; 217 };
218
219 reg_vddio_sd0: vddio-sd0 {
220 compatible = "regulator-fixed";
221 regulator-name = "vddio-sd0";
222 regulator-min-microvolt = <3300000>;
223 regulator-max-microvolt = <3300000>;
224 gpio = <&gpio3 28 0>;
225 };
226
227 reg_fec_3v3: fec-3v3 {
228 compatible = "regulator-fixed";
229 regulator-name = "fec-3v3";
230 regulator-min-microvolt = <3300000>;
231 regulator-max-microvolt = <3300000>;
232 gpio = <&gpio2 15 0>;
233 };
234
235 reg_usb0_vbus: usb0_vbus {
236 compatible = "regulator-fixed";
237 regulator-name = "usb0_vbus";
238 regulator-min-microvolt = <5000000>;
239 regulator-max-microvolt = <5000000>;
240 gpio = <&gpio3 9 0>;
241 enable-active-high;
242 };
243
244 reg_usb1_vbus: usb1_vbus {
245 compatible = "regulator-fixed";
246 regulator-name = "usb1_vbus";
247 regulator-min-microvolt = <5000000>;
248 regulator-max-microvolt = <5000000>;
249 gpio = <&gpio3 8 0>;
250 enable-active-high;
251 };
105 }; 252 };
106 253
107 sound { 254 sound {
@@ -111,4 +258,21 @@
111 saif-controllers = <&saif0 &saif1>; 258 saif-controllers = <&saif0 &saif1>;
112 audio-codec = <&sgtl5000>; 259 audio-codec = <&sgtl5000>;
113 }; 260 };
261
262 leds {
263 compatible = "gpio-leds";
264
265 user {
266 label = "Heartbeat";
267 gpios = <&gpio3 5 0>;
268 linux,default-trigger = "heartbeat";
269 };
270 };
271
272 backlight {
273 compatible = "pwm-backlight";
274 pwms = <&pwm 2 5000000>;
275 brightness-levels = <0 4 8 16 32 64 128 255>;
276 default-brightness-level = <6>;
277 };
114}; 278};
diff --git a/arch/arm/boot/dts/imx28-m28evk.dts b/arch/arm/boot/dts/imx28-m28evk.dts
new file mode 100644
index 00000000000..183a3fd2d85
--- /dev/null
+++ b/arch/arm/boot/dts/imx28-m28evk.dts
@@ -0,0 +1,210 @@
1/*
2 * Copyright (C) 2012 Marek Vasut <marex@denx.de>
3 *
4 * The code contained herein is licensed under the GNU General Public
5 * License. You may obtain a copy of the GNU General Public License
6 * Version 2 or later at the following locations:
7 *
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
10 */
11
12/dts-v1/;
13/include/ "imx28.dtsi"
14
15/ {
16 model = "DENX M28EVK";
17 compatible = "denx,m28evk", "fsl,imx28";
18
19 memory {
20 reg = <0x40000000 0x08000000>;
21 };
22
23 apb@80000000 {
24 apbh@80000000 {
25 gpmi-nand@8000c000 {
26 pinctrl-names = "default";
27 pinctrl-0 = <&gpmi_pins_a &gpmi_status_cfg>;
28 status = "okay";
29
30 partition@0 {
31 label = "bootloader";
32 reg = <0x00000000 0x00300000>;
33 read-only;
34 };
35
36 partition@1 {
37 label = "environment";
38 reg = <0x00300000 0x00080000>;
39 };
40
41 partition@2 {
42 label = "redundant-environment";
43 reg = <0x00380000 0x00080000>;
44 };
45
46 partition@3 {
47 label = "kernel";
48 reg = <0x00400000 0x00400000>;
49 };
50
51 partition@4 {
52 label = "filesystem";
53 reg = <0x00800000 0x0f800000>;
54 };
55 };
56
57 ssp0: ssp@80010000 {
58 compatible = "fsl,imx28-mmc";
59 pinctrl-names = "default";
60 pinctrl-0 = <&mmc0_8bit_pins_a
61 &mmc0_cd_cfg
62 &mmc0_sck_cfg>;
63 bus-width = <8>;
64 wp-gpios = <&gpio3 10 1>;
65 status = "okay";
66 };
67
68 pinctrl@80018000 {
69 pinctrl-names = "default";
70 pinctrl-0 = <&hog_pins_a>;
71
72 hog_pins_a: hog-gpios@0 {
73 reg = <0>;
74 fsl,pinmux-ids = <
75 0x30a3 /* MX28_PAD_AUART2_CTS__GPIO_3_10 */
76 0x30b3 /* MX28_PAD_AUART2_RTS__GPIO_3_11 */
77 >;
78 fsl,drive-strength = <0>;
79 fsl,voltage = <1>;
80 fsl,pull-up = <0>;
81 };
82
83 lcdif_pins_m28: lcdif-m28@0 {
84 reg = <0>;
85 fsl,pinmux-ids = <
86 0x11e0 /* MX28_PAD_LCD_DOTCLK__LCD_DOTCLK */
87 0x11f0 /* MX28_PAD_LCD_ENABLE__LCD_ENABLE */
88 >;
89 fsl,drive-strength = <0>;
90 fsl,voltage = <1>;
91 fsl,pull-up = <0>;
92 };
93 };
94
95 lcdif@80030000 {
96 pinctrl-names = "default";
97 pinctrl-0 = <&lcdif_24bit_pins_a
98 &lcdif_pins_m28>;
99 status = "okay";
100 };
101
102 can0: can@80032000 {
103 pinctrl-names = "default";
104 pinctrl-0 = <&can0_pins_a>;
105 status = "okay";
106 };
107
108 can1: can@80034000 {
109 pinctrl-names = "default";
110 pinctrl-0 = <&can1_pins_a>;
111 status = "okay";
112 };
113 };
114
115 apbx@80040000 {
116 saif0: saif@80042000 {
117 pinctrl-names = "default";
118 pinctrl-0 = <&saif0_pins_a>;
119 status = "okay";
120 };
121
122 saif1: saif@80046000 {
123 pinctrl-names = "default";
124 pinctrl-0 = <&saif1_pins_a>;
125 fsl,saif-master = <&saif0>;
126 status = "okay";
127 };
128
129 i2c0: i2c@80058000 {
130 pinctrl-names = "default";
131 pinctrl-0 = <&i2c0_pins_a>;
132 status = "okay";
133
134 sgtl5000: codec@0a {
135 compatible = "fsl,sgtl5000";
136 reg = <0x0a>;
137 VDDA-supply = <&reg_3p3v>;
138 VDDIO-supply = <&reg_3p3v>;
139
140 };
141
142 eeprom: eeprom@51 {
143 compatible = "atmel,24c128";
144 reg = <0x51>;
145 pagesize = <32>;
146 };
147
148 rtc: rtc@68 {
149 compatible = "stm,mt41t62";
150 reg = <0x68>;
151 };
152 };
153
154 duart: serial@80074000 {
155 pinctrl-names = "default";
156 pinctrl-0 = <&duart_pins_a>;
157 status = "okay";
158 };
159
160 auart0: serial@8006a000 {
161 pinctrl-names = "default";
162 pinctrl-0 = <&auart0_2pins_a>;
163 status = "okay";
164 };
165
166 auart3: serial@80070000 {
167 pinctrl-names = "default";
168 pinctrl-0 = <&auart3_pins_a>;
169 status = "okay";
170 };
171 };
172 };
173
174 ahb@80080000 {
175 mac0: ethernet@800f0000 {
176 phy-mode = "rmii";
177 pinctrl-names = "default";
178 pinctrl-0 = <&mac0_pins_a>;
179 phy-reset-gpios = <&gpio3 11 0>;
180 status = "okay";
181 };
182
183 mac1: ethernet@800f4000 {
184 phy-mode = "rmii";
185 pinctrl-names = "default";
186 pinctrl-0 = <&mac1_pins_a>;
187 status = "okay";
188 };
189 };
190
191 regulators {
192 compatible = "simple-bus";
193
194 reg_3p3v: 3p3v {
195 compatible = "regulator-fixed";
196 regulator-name = "3P3V";
197 regulator-min-microvolt = <3300000>;
198 regulator-max-microvolt = <3300000>;
199 regulator-always-on;
200 };
201 };
202
203 sound {
204 compatible = "denx,m28evk-sgtl5000",
205 "fsl,mxs-audio-sgtl5000";
206 model = "m28evk-sgtl5000";
207 saif-controllers = <&saif0 &saif1>;
208 audio-codec = <&sgtl5000>;
209 };
210};
diff --git a/arch/arm/boot/dts/imx28-tx28.dts b/arch/arm/boot/dts/imx28-tx28.dts
new file mode 100644
index 00000000000..62bf767409a
--- /dev/null
+++ b/arch/arm/boot/dts/imx28-tx28.dts
@@ -0,0 +1,97 @@
1/dts-v1/;
2/include/ "imx28.dtsi"
3
4/ {
5 model = "Ka-Ro electronics TX28 module";
6 compatible = "karo,tx28", "fsl,imx28";
7
8 memory {
9 reg = <0x40000000 0x08000000>;
10 };
11
12 apb@80000000 {
13 apbh@80000000 {
14 ssp0: ssp@80010000 {
15 compatible = "fsl,imx28-mmc";
16 pinctrl-names = "default";
17 pinctrl-0 = <&mmc0_4bit_pins_a
18 &mmc0_cd_cfg
19 &mmc0_sck_cfg>;
20 bus-width = <4>;
21 status = "okay";
22 };
23
24 pinctrl@80018000 {
25 pinctrl-names = "default";
26 pinctrl-0 = <&hog_pins_a>;
27
28 hog_pins_a: hog-gpios@0 {
29 reg = <0>;
30 fsl,pinmux-ids = <
31 0x40a3 /* MX28_PAD_ENET0_RXD3__GPIO_4_10 */
32 >;
33 fsl,drive-strength = <0>;
34 fsl,voltage = <1>;
35 fsl,pull-up = <0>;
36 };
37 };
38 };
39
40 apbx@80040000 {
41 i2c0: i2c@80058000 {
42 pinctrl-names = "default";
43 pinctrl-0 = <&i2c0_pins_a>;
44 status = "okay";
45
46 ds1339: rtc@68 {
47 compatible = "mxim,ds1339";
48 reg = <0x68>;
49 };
50 };
51
52 pwm: pwm@80064000 {
53 pinctrl-names = "default";
54 pinctrl-0 = <&pwm0_pins_a>;
55 status = "okay";
56 };
57
58 duart: serial@80074000 {
59 pinctrl-names = "default";
60 pinctrl-0 = <&duart_4pins_a>;
61 status = "okay";
62 };
63
64 auart1: serial@8006c000 {
65 pinctrl-names = "default";
66 pinctrl-0 = <&auart1_pins_a>;
67 status = "okay";
68 };
69 };
70 };
71
72 ahb@80080000 {
73 mac0: ethernet@800f0000 {
74 phy-mode = "rmii";
75 pinctrl-names = "default";
76 pinctrl-0 = <&mac0_pins_a>;
77 status = "okay";
78 };
79 };
80
81 leds {
82 compatible = "gpio-leds";
83
84 user {
85 label = "Heartbeat";
86 gpios = <&gpio4 10 0>;
87 linux,default-trigger = "heartbeat";
88 };
89 };
90
91 backlight {
92 compatible = "pwm-backlight";
93 pwms = <&pwm 0 5000000>;
94 brightness-levels = <0 4 8 16 32 64 128 255>;
95 default-brightness-level = <6>;
96 };
97};
diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
index 4634cb861a5..3fa6d190fab 100644
--- a/arch/arm/boot/dts/imx28.dtsi
+++ b/arch/arm/boot/dts/imx28.dtsi
@@ -22,6 +22,11 @@
22 gpio4 = &gpio4; 22 gpio4 = &gpio4;
23 saif0 = &saif0; 23 saif0 = &saif0;
24 saif1 = &saif1; 24 saif1 = &saif1;
25 serial0 = &auart0;
26 serial1 = &auart1;
27 serial2 = &auart2;
28 serial3 = &auart3;
29 serial4 = &auart4;
25 }; 30 };
26 31
27 cpus { 32 cpus {
@@ -52,57 +57,57 @@
52 }; 57 };
53 58
54 hsadc@80002000 { 59 hsadc@80002000 {
55 reg = <0x80002000 2000>; 60 reg = <0x80002000 0x2000>;
56 interrupts = <13 87>; 61 interrupts = <13 87>;
57 status = "disabled"; 62 status = "disabled";
58 }; 63 };
59 64
60 dma-apbh@80004000 { 65 dma-apbh@80004000 {
61 compatible = "fsl,imx28-dma-apbh"; 66 compatible = "fsl,imx28-dma-apbh";
62 reg = <0x80004000 2000>; 67 reg = <0x80004000 0x2000>;
63 }; 68 };
64 69
65 perfmon@80006000 { 70 perfmon@80006000 {
66 reg = <0x80006000 800>; 71 reg = <0x80006000 0x800>;
67 interrupts = <27>; 72 interrupts = <27>;
68 status = "disabled"; 73 status = "disabled";
69 }; 74 };
70 75
71 bch@8000a000 { 76 gpmi-nand@8000c000 {
72 reg = <0x8000a000 2000>; 77 compatible = "fsl,imx28-gpmi-nand";
73 interrupts = <41>; 78 #address-cells = <1>;
74 status = "disabled"; 79 #size-cells = <1>;
75 }; 80 reg = <0x8000c000 0x2000>, <0x8000a000 0x2000>;
76 81 reg-names = "gpmi-nand", "bch";
77 gpmi@8000c000 { 82 interrupts = <88>, <41>;
78 reg = <0x8000c000 2000>; 83 interrupt-names = "gpmi-dma", "bch";
79 interrupts = <42 88>; 84 fsl,gpmi-dma-channel = <4>;
80 status = "disabled"; 85 status = "disabled";
81 }; 86 };
82 87
83 ssp0: ssp@80010000 { 88 ssp0: ssp@80010000 {
84 reg = <0x80010000 2000>; 89 reg = <0x80010000 0x2000>;
85 interrupts = <96 82>; 90 interrupts = <96 82>;
86 fsl,ssp-dma-channel = <0>; 91 fsl,ssp-dma-channel = <0>;
87 status = "disabled"; 92 status = "disabled";
88 }; 93 };
89 94
90 ssp1: ssp@80012000 { 95 ssp1: ssp@80012000 {
91 reg = <0x80012000 2000>; 96 reg = <0x80012000 0x2000>;
92 interrupts = <97 83>; 97 interrupts = <97 83>;
93 fsl,ssp-dma-channel = <1>; 98 fsl,ssp-dma-channel = <1>;
94 status = "disabled"; 99 status = "disabled";
95 }; 100 };
96 101
97 ssp2: ssp@80014000 { 102 ssp2: ssp@80014000 {
98 reg = <0x80014000 2000>; 103 reg = <0x80014000 0x2000>;
99 interrupts = <98 84>; 104 interrupts = <98 84>;
100 fsl,ssp-dma-channel = <2>; 105 fsl,ssp-dma-channel = <2>;
101 status = "disabled"; 106 status = "disabled";
102 }; 107 };
103 108
104 ssp3: ssp@80016000 { 109 ssp3: ssp@80016000 {
105 reg = <0x80016000 2000>; 110 reg = <0x80016000 0x2000>;
106 interrupts = <99 85>; 111 interrupts = <99 85>;
107 fsl,ssp-dma-channel = <3>; 112 fsl,ssp-dma-channel = <3>;
108 status = "disabled"; 113 status = "disabled";
@@ -112,7 +117,7 @@
112 #address-cells = <1>; 117 #address-cells = <1>;
113 #size-cells = <0>; 118 #size-cells = <0>;
114 compatible = "fsl,imx28-pinctrl", "simple-bus"; 119 compatible = "fsl,imx28-pinctrl", "simple-bus";
115 reg = <0x80018000 2000>; 120 reg = <0x80018000 0x2000>;
116 121
117 gpio0: gpio@0 { 122 gpio0: gpio@0 {
118 compatible = "fsl,imx28-gpio", "fsl,mxs-gpio"; 123 compatible = "fsl,imx28-gpio", "fsl,mxs-gpio";
@@ -161,7 +166,150 @@
161 166
162 duart_pins_a: duart@0 { 167 duart_pins_a: duart@0 {
163 reg = <0>; 168 reg = <0>;
164 fsl,pinmux-ids = <0x3102 0x3112>; 169 fsl,pinmux-ids = <
170 0x3102 /* MX28_PAD_PWM0__DUART_RX */
171 0x3112 /* MX28_PAD_PWM1__DUART_TX */
172 >;
173 fsl,drive-strength = <0>;
174 fsl,voltage = <1>;
175 fsl,pull-up = <0>;
176 };
177
178 duart_pins_b: duart@1 {
179 reg = <1>;
180 fsl,pinmux-ids = <
181 0x3022 /* MX28_PAD_AUART0_CTS__DUART_RX */
182 0x3032 /* MX28_PAD_AUART0_RTS__DUART_TX */
183 >;
184 fsl,drive-strength = <0>;
185 fsl,voltage = <1>;
186 fsl,pull-up = <0>;
187 };
188
189 duart_4pins_a: duart-4pins@0 {
190 reg = <0>;
191 fsl,pinmux-ids = <
192 0x3022 /* MX28_PAD_AUART0_CTS__DUART_RX */
193 0x3032 /* MX28_PAD_AUART0_RTS__DUART_TX */
194 0x3002 /* MX28_PAD_AUART0_RX__DUART_CTS */
195 0x3012 /* MX28_PAD_AUART0_TX__DUART_RTS */
196 >;
197 fsl,drive-strength = <0>;
198 fsl,voltage = <1>;
199 fsl,pull-up = <0>;
200 };
201
202 gpmi_pins_a: gpmi-nand@0 {
203 reg = <0>;
204 fsl,pinmux-ids = <
205 0x0000 /* MX28_PAD_GPMI_D00__GPMI_D0 */
206 0x0010 /* MX28_PAD_GPMI_D01__GPMI_D1 */
207 0x0020 /* MX28_PAD_GPMI_D02__GPMI_D2 */
208 0x0030 /* MX28_PAD_GPMI_D03__GPMI_D3 */
209 0x0040 /* MX28_PAD_GPMI_D04__GPMI_D4 */
210 0x0050 /* MX28_PAD_GPMI_D05__GPMI_D5 */
211 0x0060 /* MX28_PAD_GPMI_D06__GPMI_D6 */
212 0x0070 /* MX28_PAD_GPMI_D07__GPMI_D7 */
213 0x0100 /* MX28_PAD_GPMI_CE0N__GPMI_CE0N */
214 0x0140 /* MX28_PAD_GPMI_RDY0__GPMI_READY0 */
215 0x0180 /* MX28_PAD_GPMI_RDN__GPMI_RDN */
216 0x0190 /* MX28_PAD_GPMI_WRN__GPMI_WRN */
217 0x01a0 /* MX28_PAD_GPMI_ALE__GPMI_ALE */
218 0x01b0 /* MX28_PAD_GPMI_CLE__GPMI_CLE */
219 0x01c0 /* MX28_PAD_GPMI_RESETN__GPMI_RESETN */
220 >;
221 fsl,drive-strength = <0>;
222 fsl,voltage = <1>;
223 fsl,pull-up = <0>;
224 };
225
226 gpmi_status_cfg: gpmi-status-cfg {
227 fsl,pinmux-ids = <
228 0x0180 /* MX28_PAD_GPMI_RDN__GPMI_RDN */
229 0x0190 /* MX28_PAD_GPMI_WRN__GPMI_WRN */
230 0x01c0 /* MX28_PAD_GPMI_RESETN__GPMI_RESETN */
231 >;
232 fsl,drive-strength = <2>;
233 };
234
235 auart0_pins_a: auart0@0 {
236 reg = <0>;
237 fsl,pinmux-ids = <
238 0x3000 /* MX28_PAD_AUART0_RX__AUART0_RX */
239 0x3010 /* MX28_PAD_AUART0_TX__AUART0_TX */
240 0x3020 /* MX28_PAD_AUART0_CTS__AUART0_CTS */
241 0x3030 /* MX28_PAD_AUART0_RTS__AUART0_RTS */
242 >;
243 fsl,drive-strength = <0>;
244 fsl,voltage = <1>;
245 fsl,pull-up = <0>;
246 };
247
248 auart0_2pins_a: auart0-2pins@0 {
249 reg = <0>;
250 fsl,pinmux-ids = <
251 0x3000 /* MX28_PAD_AUART0_RX__AUART0_RX */
252 0x3010 /* MX28_PAD_AUART0_TX__AUART0_TX */
253 >;
254 fsl,drive-strength = <0>;
255 fsl,voltage = <1>;
256 fsl,pull-up = <0>;
257 };
258
259 auart1_pins_a: auart1@0 {
260 reg = <0>;
261 fsl,pinmux-ids = <
262 0x3040 /* MX28_PAD_AUART1_RX__AUART1_RX */
263 0x3050 /* MX28_PAD_AUART1_TX__AUART1_TX */
264 0x3060 /* MX28_PAD_AUART1_CTS__AUART1_CTS */
265 0x3070 /* MX28_PAD_AUART1_RTS__AUART1_RTS */
266 >;
267 fsl,drive-strength = <0>;
268 fsl,voltage = <1>;
269 fsl,pull-up = <0>;
270 };
271
272 auart1_2pins_a: auart1-2pins@0 {
273 reg = <0>;
274 fsl,pinmux-ids = <
275 0x3040 /* MX28_PAD_AUART1_RX__AUART1_RX */
276 0x3050 /* MX28_PAD_AUART1_TX__AUART1_TX */
277 >;
278 fsl,drive-strength = <0>;
279 fsl,voltage = <1>;
280 fsl,pull-up = <0>;
281 };
282
283 auart2_2pins_a: auart2-2pins@0 {
284 reg = <0>;
285 fsl,pinmux-ids = <
286 0x2101 /* MX28_PAD_SSP2_SCK__AUART2_RX */
287 0x2111 /* MX28_PAD_SSP2_MOSI__AUART2_TX */
288 >;
289 fsl,drive-strength = <0>;
290 fsl,voltage = <1>;
291 fsl,pull-up = <0>;
292 };
293
294 auart3_pins_a: auart3@0 {
295 reg = <0>;
296 fsl,pinmux-ids = <
297 0x30c0 /* MX28_PAD_AUART3_RX__AUART3_RX */
298 0x30d0 /* MX28_PAD_AUART3_TX__AUART3_TX */
299 0x30e0 /* MX28_PAD_AUART3_CTS__AUART3_CTS */
300 0x30f0 /* MX28_PAD_AUART3_RTS__AUART3_RTS */
301 >;
302 fsl,drive-strength = <0>;
303 fsl,voltage = <1>;
304 fsl,pull-up = <0>;
305 };
306
307 auart3_2pins_a: auart3-2pins@0 {
308 reg = <0>;
309 fsl,pinmux-ids = <
310 0x2121 /* MX28_PAD_SSP2_MISO__AUART3_RX */
311 0x2131 /* MX28_PAD_SSP2_SS0__AUART3_TX */
312 >;
165 fsl,drive-strength = <0>; 313 fsl,drive-strength = <0>;
166 fsl,voltage = <1>; 314 fsl,voltage = <1>;
167 fsl,pull-up = <0>; 315 fsl,pull-up = <0>;
@@ -169,9 +317,17 @@
169 317
170 mac0_pins_a: mac0@0 { 318 mac0_pins_a: mac0@0 {
171 reg = <0>; 319 reg = <0>;
172 fsl,pinmux-ids = <0x4000 0x4010 0x4020 320 fsl,pinmux-ids = <
173 0x4030 0x4040 0x4060 0x4070 321 0x4000 /* MX28_PAD_ENET0_MDC__ENET0_MDC */
174 0x4080 0x4100>; 322 0x4010 /* MX28_PAD_ENET0_MDIO__ENET0_MDIO */
323 0x4020 /* MX28_PAD_ENET0_RX_EN__ENET0_RX_EN */
324 0x4030 /* MX28_PAD_ENET0_RXD0__ENET0_RXD0 */
325 0x4040 /* MX28_PAD_ENET0_RXD1__ENET0_RXD1 */
326 0x4060 /* MX28_PAD_ENET0_TX_EN__ENET0_TX_EN */
327 0x4070 /* MX28_PAD_ENET0_TXD0__ENET0_TXD0 */
328 0x4080 /* MX28_PAD_ENET0_TXD1__ENET0_TXD1 */
329 0x4100 /* MX28_PAD_ENET_CLK__CLKCTRL_ENET */
330 >;
175 fsl,drive-strength = <1>; 331 fsl,drive-strength = <1>;
176 fsl,voltage = <1>; 332 fsl,voltage = <1>;
177 fsl,pull-up = <1>; 333 fsl,pull-up = <1>;
@@ -179,8 +335,14 @@
179 335
180 mac1_pins_a: mac1@0 { 336 mac1_pins_a: mac1@0 {
181 reg = <0>; 337 reg = <0>;
182 fsl,pinmux-ids = <0x40f1 0x4091 0x40a1 338 fsl,pinmux-ids = <
183 0x40e1 0x40b1 0x40c1>; 339 0x40f1 /* MX28_PAD_ENET0_CRS__ENET1_RX_EN */
340 0x4091 /* MX28_PAD_ENET0_RXD2__ENET1_RXD0 */
341 0x40a1 /* MX28_PAD_ENET0_RXD3__ENET1_RXD1 */
342 0x40e1 /* MX28_PAD_ENET0_COL__ENET1_TX_EN */
343 0x40b1 /* MX28_PAD_ENET0_TXD2__ENET1_TXD0 */
344 0x40c1 /* MX28_PAD_ENET0_TXD3__ENET1_TXD1 */
345 >;
184 fsl,drive-strength = <1>; 346 fsl,drive-strength = <1>;
185 fsl,voltage = <1>; 347 fsl,voltage = <1>;
186 fsl,pull-up = <1>; 348 fsl,pull-up = <1>;
@@ -188,28 +350,61 @@
188 350
189 mmc0_8bit_pins_a: mmc0-8bit@0 { 351 mmc0_8bit_pins_a: mmc0-8bit@0 {
190 reg = <0>; 352 reg = <0>;
191 fsl,pinmux-ids = <0x2000 0x2010 0x2020 353 fsl,pinmux-ids = <
192 0x2030 0x2040 0x2050 0x2060 354 0x2000 /* MX28_PAD_SSP0_DATA0__SSP0_D0 */
193 0x2070 0x2080 0x2090 0x20a0>; 355 0x2010 /* MX28_PAD_SSP0_DATA1__SSP0_D1 */
356 0x2020 /* MX28_PAD_SSP0_DATA2__SSP0_D2 */
357 0x2030 /* MX28_PAD_SSP0_DATA3__SSP0_D3 */
358 0x2040 /* MX28_PAD_SSP0_DATA4__SSP0_D4 */
359 0x2050 /* MX28_PAD_SSP0_DATA5__SSP0_D5 */
360 0x2060 /* MX28_PAD_SSP0_DATA6__SSP0_D6 */
361 0x2070 /* MX28_PAD_SSP0_DATA7__SSP0_D7 */
362 0x2080 /* MX28_PAD_SSP0_CMD__SSP0_CMD */
363 0x2090 /* MX28_PAD_SSP0_DETECT__SSP0_CARD_DETECT */
364 0x20a0 /* MX28_PAD_SSP0_SCK__SSP0_SCK */
365 >;
366 fsl,drive-strength = <1>;
367 fsl,voltage = <1>;
368 fsl,pull-up = <1>;
369 };
370
371 mmc0_4bit_pins_a: mmc0-4bit@0 {
372 reg = <0>;
373 fsl,pinmux-ids = <
374 0x2000 /* MX28_PAD_SSP0_DATA0__SSP0_D0 */
375 0x2010 /* MX28_PAD_SSP0_DATA1__SSP0_D1 */
376 0x2020 /* MX28_PAD_SSP0_DATA2__SSP0_D2 */
377 0x2030 /* MX28_PAD_SSP0_DATA3__SSP0_D3 */
378 0x2080 /* MX28_PAD_SSP0_CMD__SSP0_CMD */
379 0x2090 /* MX28_PAD_SSP0_DETECT__SSP0_CARD_DETECT */
380 0x20a0 /* MX28_PAD_SSP0_SCK__SSP0_SCK */
381 >;
194 fsl,drive-strength = <1>; 382 fsl,drive-strength = <1>;
195 fsl,voltage = <1>; 383 fsl,voltage = <1>;
196 fsl,pull-up = <1>; 384 fsl,pull-up = <1>;
197 }; 385 };
198 386
199 mmc0_cd_cfg: mmc0-cd-cfg { 387 mmc0_cd_cfg: mmc0-cd-cfg {
200 fsl,pinmux-ids = <0x2090>; 388 fsl,pinmux-ids = <
389 0x2090 /* MX28_PAD_SSP0_DETECT__SSP0_CARD_DETECT */
390 >;
201 fsl,pull-up = <0>; 391 fsl,pull-up = <0>;
202 }; 392 };
203 393
204 mmc0_sck_cfg: mmc0-sck-cfg { 394 mmc0_sck_cfg: mmc0-sck-cfg {
205 fsl,pinmux-ids = <0x20a0>; 395 fsl,pinmux-ids = <
396 0x20a0 /* MX28_PAD_SSP0_SCK__SSP0_SCK */
397 >;
206 fsl,drive-strength = <2>; 398 fsl,drive-strength = <2>;
207 fsl,pull-up = <0>; 399 fsl,pull-up = <0>;
208 }; 400 };
209 401
210 i2c0_pins_a: i2c0@0 { 402 i2c0_pins_a: i2c0@0 {
211 reg = <0>; 403 reg = <0>;
212 fsl,pinmux-ids = <0x3180 0x3190>; 404 fsl,pinmux-ids = <
405 0x3180 /* MX28_PAD_I2C0_SCL__I2C0_SCL */
406 0x3190 /* MX28_PAD_I2C0_SDA__I2C0_SDA */
407 >;
213 fsl,drive-strength = <1>; 408 fsl,drive-strength = <1>;
214 fsl,voltage = <1>; 409 fsl,voltage = <1>;
215 fsl,pull-up = <1>; 410 fsl,pull-up = <1>;
@@ -217,8 +412,12 @@
217 412
218 saif0_pins_a: saif0@0 { 413 saif0_pins_a: saif0@0 {
219 reg = <0>; 414 reg = <0>;
220 fsl,pinmux-ids = 415 fsl,pinmux-ids = <
221 <0x3140 0x3150 0x3160 0x3170>; 416 0x3140 /* MX28_PAD_SAIF0_MCLK__SAIF0_MCLK */
417 0x3150 /* MX28_PAD_SAIF0_LRCLK__SAIF0_LRCLK */
418 0x3160 /* MX28_PAD_SAIF0_BITCLK__SAIF0_BITCLK */
419 0x3170 /* MX28_PAD_SAIF0_SDATA0__SAIF0_SDATA0 */
420 >;
222 fsl,drive-strength = <2>; 421 fsl,drive-strength = <2>;
223 fsl,voltage = <1>; 422 fsl,voltage = <1>;
224 fsl,pull-up = <1>; 423 fsl,pull-up = <1>;
@@ -226,101 +425,181 @@
226 425
227 saif1_pins_a: saif1@0 { 426 saif1_pins_a: saif1@0 {
228 reg = <0>; 427 reg = <0>;
229 fsl,pinmux-ids = <0x31a0>; 428 fsl,pinmux-ids = <
429 0x31a0 /* MX28_PAD_SAIF1_SDATA0__SAIF1_SDATA0 */
430 >;
230 fsl,drive-strength = <2>; 431 fsl,drive-strength = <2>;
231 fsl,voltage = <1>; 432 fsl,voltage = <1>;
232 fsl,pull-up = <1>; 433 fsl,pull-up = <1>;
233 }; 434 };
435
436 pwm0_pins_a: pwm0@0 {
437 reg = <0>;
438 fsl,pinmux-ids = <
439 0x3100 /* MX28_PAD_PWM0__PWM_0 */
440 >;
441 fsl,drive-strength = <0>;
442 fsl,voltage = <1>;
443 fsl,pull-up = <0>;
444 };
445
446 pwm2_pins_a: pwm2@0 {
447 reg = <0>;
448 fsl,pinmux-ids = <
449 0x3120 /* MX28_PAD_PWM2__PWM_2 */
450 >;
451 fsl,drive-strength = <0>;
452 fsl,voltage = <1>;
453 fsl,pull-up = <0>;
454 };
455
456 lcdif_24bit_pins_a: lcdif-24bit@0 {
457 reg = <0>;
458 fsl,pinmux-ids = <
459 0x1000 /* MX28_PAD_LCD_D00__LCD_D0 */
460 0x1010 /* MX28_PAD_LCD_D01__LCD_D1 */
461 0x1020 /* MX28_PAD_LCD_D02__LCD_D2 */
462 0x1030 /* MX28_PAD_LCD_D03__LCD_D3 */
463 0x1040 /* MX28_PAD_LCD_D04__LCD_D4 */
464 0x1050 /* MX28_PAD_LCD_D05__LCD_D5 */
465 0x1060 /* MX28_PAD_LCD_D06__LCD_D6 */
466 0x1070 /* MX28_PAD_LCD_D07__LCD_D7 */
467 0x1080 /* MX28_PAD_LCD_D08__LCD_D8 */
468 0x1090 /* MX28_PAD_LCD_D09__LCD_D9 */
469 0x10a0 /* MX28_PAD_LCD_D10__LCD_D10 */
470 0x10b0 /* MX28_PAD_LCD_D11__LCD_D11 */
471 0x10c0 /* MX28_PAD_LCD_D12__LCD_D12 */
472 0x10d0 /* MX28_PAD_LCD_D13__LCD_D13 */
473 0x10e0 /* MX28_PAD_LCD_D14__LCD_D14 */
474 0x10f0 /* MX28_PAD_LCD_D15__LCD_D15 */
475 0x1100 /* MX28_PAD_LCD_D16__LCD_D16 */
476 0x1110 /* MX28_PAD_LCD_D17__LCD_D17 */
477 0x1120 /* MX28_PAD_LCD_D18__LCD_D18 */
478 0x1130 /* MX28_PAD_LCD_D19__LCD_D19 */
479 0x1140 /* MX28_PAD_LCD_D20__LCD_D20 */
480 0x1150 /* MX28_PAD_LCD_D21__LCD_D21 */
481 0x1160 /* MX28_PAD_LCD_D22__LCD_D22 */
482 0x1170 /* MX28_PAD_LCD_D23__LCD_D23 */
483 >;
484 fsl,drive-strength = <0>;
485 fsl,voltage = <1>;
486 fsl,pull-up = <0>;
487 };
488
489 can0_pins_a: can0@0 {
490 reg = <0>;
491 fsl,pinmux-ids = <
492 0x0161 /* MX28_PAD_GPMI_RDY2__CAN0_TX */
493 0x0171 /* MX28_PAD_GPMI_RDY3__CAN0_RX */
494 >;
495 fsl,drive-strength = <0>;
496 fsl,voltage = <1>;
497 fsl,pull-up = <0>;
498 };
499
500 can1_pins_a: can1@0 {
501 reg = <0>;
502 fsl,pinmux-ids = <
503 0x0121 /* MX28_PAD_GPMI_CE2N__CAN1_TX */
504 0x0131 /* MX28_PAD_GPMI_CE3N__CAN1_RX */
505 >;
506 fsl,drive-strength = <0>;
507 fsl,voltage = <1>;
508 fsl,pull-up = <0>;
509 };
234 }; 510 };
235 511
236 digctl@8001c000 { 512 digctl@8001c000 {
237 reg = <0x8001c000 2000>; 513 reg = <0x8001c000 0x2000>;
238 interrupts = <89>; 514 interrupts = <89>;
239 status = "disabled"; 515 status = "disabled";
240 }; 516 };
241 517
242 etm@80022000 { 518 etm@80022000 {
243 reg = <0x80022000 2000>; 519 reg = <0x80022000 0x2000>;
244 status = "disabled"; 520 status = "disabled";
245 }; 521 };
246 522
247 dma-apbx@80024000 { 523 dma-apbx@80024000 {
248 compatible = "fsl,imx28-dma-apbx"; 524 compatible = "fsl,imx28-dma-apbx";
249 reg = <0x80024000 2000>; 525 reg = <0x80024000 0x2000>;
250 }; 526 };
251 527
252 dcp@80028000 { 528 dcp@80028000 {
253 reg = <0x80028000 2000>; 529 reg = <0x80028000 0x2000>;
254 interrupts = <52 53 54>; 530 interrupts = <52 53 54>;
255 status = "disabled"; 531 status = "disabled";
256 }; 532 };
257 533
258 pxp@8002a000 { 534 pxp@8002a000 {
259 reg = <0x8002a000 2000>; 535 reg = <0x8002a000 0x2000>;
260 interrupts = <39>; 536 interrupts = <39>;
261 status = "disabled"; 537 status = "disabled";
262 }; 538 };
263 539
264 ocotp@8002c000 { 540 ocotp@8002c000 {
265 reg = <0x8002c000 2000>; 541 reg = <0x8002c000 0x2000>;
266 status = "disabled"; 542 status = "disabled";
267 }; 543 };
268 544
269 axi-ahb@8002e000 { 545 axi-ahb@8002e000 {
270 reg = <0x8002e000 2000>; 546 reg = <0x8002e000 0x2000>;
271 status = "disabled"; 547 status = "disabled";
272 }; 548 };
273 549
274 lcdif@80030000 { 550 lcdif@80030000 {
275 reg = <0x80030000 2000>; 551 compatible = "fsl,imx28-lcdif";
552 reg = <0x80030000 0x2000>;
276 interrupts = <38 86>; 553 interrupts = <38 86>;
277 status = "disabled"; 554 status = "disabled";
278 }; 555 };
279 556
280 can0: can@80032000 { 557 can0: can@80032000 {
281 reg = <0x80032000 2000>; 558 compatible = "fsl,imx28-flexcan", "fsl,p1010-flexcan";
559 reg = <0x80032000 0x2000>;
282 interrupts = <8>; 560 interrupts = <8>;
283 status = "disabled"; 561 status = "disabled";
284 }; 562 };
285 563
286 can1: can@80034000 { 564 can1: can@80034000 {
287 reg = <0x80034000 2000>; 565 compatible = "fsl,imx28-flexcan", "fsl,p1010-flexcan";
566 reg = <0x80034000 0x2000>;
288 interrupts = <9>; 567 interrupts = <9>;
289 status = "disabled"; 568 status = "disabled";
290 }; 569 };
291 570
292 simdbg@8003c000 { 571 simdbg@8003c000 {
293 reg = <0x8003c000 200>; 572 reg = <0x8003c000 0x200>;
294 status = "disabled"; 573 status = "disabled";
295 }; 574 };
296 575
297 simgpmisel@8003c200 { 576 simgpmisel@8003c200 {
298 reg = <0x8003c200 100>; 577 reg = <0x8003c200 0x100>;
299 status = "disabled"; 578 status = "disabled";
300 }; 579 };
301 580
302 simsspsel@8003c300 { 581 simsspsel@8003c300 {
303 reg = <0x8003c300 100>; 582 reg = <0x8003c300 0x100>;
304 status = "disabled"; 583 status = "disabled";
305 }; 584 };
306 585
307 simmemsel@8003c400 { 586 simmemsel@8003c400 {
308 reg = <0x8003c400 100>; 587 reg = <0x8003c400 0x100>;
309 status = "disabled"; 588 status = "disabled";
310 }; 589 };
311 590
312 gpiomon@8003c500 { 591 gpiomon@8003c500 {
313 reg = <0x8003c500 100>; 592 reg = <0x8003c500 0x100>;
314 status = "disabled"; 593 status = "disabled";
315 }; 594 };
316 595
317 simenet@8003c700 { 596 simenet@8003c700 {
318 reg = <0x8003c700 100>; 597 reg = <0x8003c700 0x100>;
319 status = "disabled"; 598 status = "disabled";
320 }; 599 };
321 600
322 armjtag@8003c800 { 601 armjtag@8003c800 {
323 reg = <0x8003c800 100>; 602 reg = <0x8003c800 0x100>;
324 status = "disabled"; 603 status = "disabled";
325 }; 604 };
326 }; 605 };
@@ -333,54 +612,55 @@
333 ranges; 612 ranges;
334 613
335 clkctl@80040000 { 614 clkctl@80040000 {
336 reg = <0x80040000 2000>; 615 reg = <0x80040000 0x2000>;
337 status = "disabled"; 616 status = "disabled";
338 }; 617 };
339 618
340 saif0: saif@80042000 { 619 saif0: saif@80042000 {
341 compatible = "fsl,imx28-saif"; 620 compatible = "fsl,imx28-saif";
342 reg = <0x80042000 2000>; 621 reg = <0x80042000 0x2000>;
343 interrupts = <59 80>; 622 interrupts = <59 80>;
344 fsl,saif-dma-channel = <4>; 623 fsl,saif-dma-channel = <4>;
345 status = "disabled"; 624 status = "disabled";
346 }; 625 };
347 626
348 power@80044000 { 627 power@80044000 {
349 reg = <0x80044000 2000>; 628 reg = <0x80044000 0x2000>;
350 status = "disabled"; 629 status = "disabled";
351 }; 630 };
352 631
353 saif1: saif@80046000 { 632 saif1: saif@80046000 {
354 compatible = "fsl,imx28-saif"; 633 compatible = "fsl,imx28-saif";
355 reg = <0x80046000 2000>; 634 reg = <0x80046000 0x2000>;
356 interrupts = <58 81>; 635 interrupts = <58 81>;
357 fsl,saif-dma-channel = <5>; 636 fsl,saif-dma-channel = <5>;
358 status = "disabled"; 637 status = "disabled";
359 }; 638 };
360 639
361 lradc@80050000 { 640 lradc@80050000 {
362 reg = <0x80050000 2000>; 641 reg = <0x80050000 0x2000>;
363 status = "disabled"; 642 status = "disabled";
364 }; 643 };
365 644
366 spdif@80054000 { 645 spdif@80054000 {
367 reg = <0x80054000 2000>; 646 reg = <0x80054000 0x2000>;
368 interrupts = <45 66>; 647 interrupts = <45 66>;
369 status = "disabled"; 648 status = "disabled";
370 }; 649 };
371 650
372 rtc@80056000 { 651 rtc@80056000 {
373 reg = <0x80056000 2000>; 652 compatible = "fsl,imx28-rtc", "fsl,stmp3xxx-rtc";
374 interrupts = <28 29>; 653 reg = <0x80056000 0x2000>;
375 status = "disabled"; 654 interrupts = <29>;
376 }; 655 };
377 656
378 i2c0: i2c@80058000 { 657 i2c0: i2c@80058000 {
379 #address-cells = <1>; 658 #address-cells = <1>;
380 #size-cells = <0>; 659 #size-cells = <0>;
381 compatible = "fsl,imx28-i2c"; 660 compatible = "fsl,imx28-i2c";
382 reg = <0x80058000 2000>; 661 reg = <0x80058000 0x2000>;
383 interrupts = <111 68>; 662 interrupts = <111 68>;
663 clock-frequency = <100000>;
384 status = "disabled"; 664 status = "disabled";
385 }; 665 };
386 666
@@ -388,46 +668,55 @@
388 #address-cells = <1>; 668 #address-cells = <1>;
389 #size-cells = <0>; 669 #size-cells = <0>;
390 compatible = "fsl,imx28-i2c"; 670 compatible = "fsl,imx28-i2c";
391 reg = <0x8005a000 2000>; 671 reg = <0x8005a000 0x2000>;
392 interrupts = <110 69>; 672 interrupts = <110 69>;
673 clock-frequency = <100000>;
393 status = "disabled"; 674 status = "disabled";
394 }; 675 };
395 676
396 pwm@80064000 { 677 pwm: pwm@80064000 {
397 reg = <0x80064000 2000>; 678 compatible = "fsl,imx28-pwm", "fsl,imx23-pwm";
679 reg = <0x80064000 0x2000>;
680 #pwm-cells = <2>;
681 fsl,pwm-number = <8>;
398 status = "disabled"; 682 status = "disabled";
399 }; 683 };
400 684
401 timrot@80068000 { 685 timrot@80068000 {
402 reg = <0x80068000 2000>; 686 reg = <0x80068000 0x2000>;
403 status = "disabled"; 687 status = "disabled";
404 }; 688 };
405 689
406 auart0: serial@8006a000 { 690 auart0: serial@8006a000 {
691 compatible = "fsl,imx28-auart", "fsl,imx23-auart";
407 reg = <0x8006a000 0x2000>; 692 reg = <0x8006a000 0x2000>;
408 interrupts = <112 70 71>; 693 interrupts = <112 70 71>;
409 status = "disabled"; 694 status = "disabled";
410 }; 695 };
411 696
412 auart1: serial@8006c000 { 697 auart1: serial@8006c000 {
698 compatible = "fsl,imx28-auart", "fsl,imx23-auart";
413 reg = <0x8006c000 0x2000>; 699 reg = <0x8006c000 0x2000>;
414 interrupts = <113 72 73>; 700 interrupts = <113 72 73>;
415 status = "disabled"; 701 status = "disabled";
416 }; 702 };
417 703
418 auart2: serial@8006e000 { 704 auart2: serial@8006e000 {
705 compatible = "fsl,imx28-auart", "fsl,imx23-auart";
419 reg = <0x8006e000 0x2000>; 706 reg = <0x8006e000 0x2000>;
420 interrupts = <114 74 75>; 707 interrupts = <114 74 75>;
421 status = "disabled"; 708 status = "disabled";
422 }; 709 };
423 710
424 auart3: serial@80070000 { 711 auart3: serial@80070000 {
712 compatible = "fsl,imx28-auart", "fsl,imx23-auart";
425 reg = <0x80070000 0x2000>; 713 reg = <0x80070000 0x2000>;
426 interrupts = <115 76 77>; 714 interrupts = <115 76 77>;
427 status = "disabled"; 715 status = "disabled";
428 }; 716 };
429 717
430 auart4: serial@80072000 { 718 auart4: serial@80072000 {
719 compatible = "fsl,imx28-auart", "fsl,imx23-auart";
431 reg = <0x80072000 0x2000>; 720 reg = <0x80072000 0x2000>;
432 interrupts = <116 78 79>; 721 interrupts = <116 78 79>;
433 status = "disabled"; 722 status = "disabled";
@@ -441,11 +730,13 @@
441 }; 730 };
442 731
443 usbphy0: usbphy@8007c000 { 732 usbphy0: usbphy@8007c000 {
733 compatible = "fsl,imx28-usbphy", "fsl,imx23-usbphy";
444 reg = <0x8007c000 0x2000>; 734 reg = <0x8007c000 0x2000>;
445 status = "disabled"; 735 status = "disabled";
446 }; 736 };
447 737
448 usbphy1: usbphy@8007e000 { 738 usbphy1: usbphy@8007e000 {
739 compatible = "fsl,imx28-usbphy", "fsl,imx23-usbphy";
449 reg = <0x8007e000 0x2000>; 740 reg = <0x8007e000 0x2000>;
450 status = "disabled"; 741 status = "disabled";
451 }; 742 };
@@ -459,13 +750,19 @@
459 reg = <0x80080000 0x80000>; 750 reg = <0x80080000 0x80000>;
460 ranges; 751 ranges;
461 752
462 usbctrl0: usbctrl@80080000 { 753 usb0: usb@80080000 {
754 compatible = "fsl,imx28-usb", "fsl,imx27-usb";
463 reg = <0x80080000 0x10000>; 755 reg = <0x80080000 0x10000>;
756 interrupts = <93>;
757 fsl,usbphy = <&usbphy0>;
464 status = "disabled"; 758 status = "disabled";
465 }; 759 };
466 760
467 usbctrl1: usbctrl@80090000 { 761 usb1: usb@80090000 {
762 compatible = "fsl,imx28-usb", "fsl,imx27-usb";
468 reg = <0x80090000 0x10000>; 763 reg = <0x80090000 0x10000>;
764 interrupts = <92>;
765 fsl,usbphy = <&usbphy1>;
469 status = "disabled"; 766 status = "disabled";
470 }; 767 };
471 768
diff --git a/arch/arm/boot/dts/imx31-bug.dts b/arch/arm/boot/dts/imx31-bug.dts
new file mode 100644
index 00000000000..24731cb78e8
--- /dev/null
+++ b/arch/arm/boot/dts/imx31-bug.dts
@@ -0,0 +1,31 @@
1/*
2 * Copyright 2012 Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
3 *
4 * The code contained herein is licensed under the GNU General Public
5 * License. You may obtain a copy of the GNU General Public License
6 * Version 2 or later at the following locations:
7 *
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
10 */
11
12/dts-v1/;
13/include/ "imx31.dtsi"
14
15/ {
16 model = "Buglabs i.MX31 Bug 1.x";
17 compatible = "fsl,imx31-bug", "fsl,imx31";
18
19 memory {
20 reg = <0x80000000 0x8000000>; /* 128M */
21 };
22
23 soc {
24 aips@43f00000 { /* AIPS1 */
25 uart5: serial@43fb4000 {
26 fsl,uart-has-rtscts;
27 status = "okay";
28 };
29 };
30 };
31};
diff --git a/arch/arm/boot/dts/imx31.dtsi b/arch/arm/boot/dts/imx31.dtsi
new file mode 100644
index 00000000000..eef7099f3e3
--- /dev/null
+++ b/arch/arm/boot/dts/imx31.dtsi
@@ -0,0 +1,88 @@
1/*
2 * Copyright 2012 Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
3 *
4 * The code contained herein is licensed under the GNU General Public
5 * License. You may obtain a copy of the GNU General Public License
6 * Version 2 or later at the following locations:
7 *
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
10 */
11
12/include/ "skeleton.dtsi"
13
14/ {
15 aliases {
16 serial0 = &uart1;
17 serial1 = &uart2;
18 serial2 = &uart3;
19 serial3 = &uart4;
20 serial4 = &uart5;
21 };
22
23 avic: avic-interrupt-controller@60000000 {
24 compatible = "fsl,imx31-avic", "fsl,avic";
25 interrupt-controller;
26 #interrupt-cells = <1>;
27 reg = <0x60000000 0x100000>;
28 };
29
30 soc {
31 #address-cells = <1>;
32 #size-cells = <1>;
33 compatible = "simple-bus";
34 interrupt-parent = <&avic>;
35 ranges;
36
37 aips@43f00000 { /* AIPS1 */
38 compatible = "fsl,aips-bus", "simple-bus";
39 #address-cells = <1>;
40 #size-cells = <1>;
41 reg = <0x43f00000 0x100000>;
42 ranges;
43
44 uart1: serial@43f90000 {
45 compatible = "fsl,imx31-uart", "fsl,imx21-uart";
46 reg = <0x43f90000 0x4000>;
47 interrupts = <45>;
48 status = "disabled";
49 };
50
51 uart2: serial@43f94000 {
52 compatible = "fsl,imx31-uart", "fsl,imx21-uart";
53 reg = <0x43f94000 0x4000>;
54 interrupts = <32>;
55 status = "disabled";
56 };
57
58 uart4: serial@43fb0000 {
59 compatible = "fsl,imx31-uart", "fsl,imx21-uart";
60 reg = <0x43fb0000 0x4000>;
61 interrupts = <46>;
62 status = "disabled";
63 };
64
65 uart5: serial@43fb4000 {
66 compatible = "fsl,imx31-uart", "fsl,imx21-uart";
67 reg = <0x43fb4000 0x4000>;
68 interrupts = <47>;
69 status = "disabled";
70 };
71 };
72
73 spba@50000000 {
74 compatible = "fsl,spba-bus", "simple-bus";
75 #address-cells = <1>;
76 #size-cells = <1>;
77 reg = <0x50000000 0x100000>;
78 ranges;
79
80 uart3: serial@5000c000 {
81 compatible = "fsl,imx31-uart", "fsl,imx21-uart";
82 reg = <0x5000c000 0x4000>;
83 interrupts = <18>;
84 status = "disabled";
85 };
86 };
87 };
88};
diff --git a/arch/arm/boot/dts/imx51-babbage.dts b/arch/arm/boot/dts/imx51-babbage.dts
index de065b5976e..59d9789e550 100644
--- a/arch/arm/boot/dts/imx51-babbage.dts
+++ b/arch/arm/boot/dts/imx51-babbage.dts
@@ -25,8 +25,8 @@
25 aips@70000000 { /* aips-1 */ 25 aips@70000000 { /* aips-1 */
26 spba@70000000 { 26 spba@70000000 {
27 esdhc@70004000 { /* ESDHC1 */ 27 esdhc@70004000 { /* ESDHC1 */
28 fsl,cd-internal; 28 fsl,cd-controller;
29 fsl,wp-internal; 29 fsl,wp-controller;
30 status = "okay"; 30 status = "okay";
31 }; 31 };
32 32
@@ -53,7 +53,7 @@
53 spi-max-frequency = <6000000>; 53 spi-max-frequency = <6000000>;
54 reg = <0>; 54 reg = <0>;
55 interrupt-parent = <&gpio1>; 55 interrupt-parent = <&gpio1>;
56 interrupts = <8>; 56 interrupts = <8 0x4>;
57 57
58 regulators { 58 regulators {
59 sw1_reg: sw1 { 59 sw1_reg: sw1 {
diff --git a/arch/arm/boot/dts/imx51.dtsi b/arch/arm/boot/dts/imx51.dtsi
index bfa65abe8ef..aba28dc87fc 100644
--- a/arch/arm/boot/dts/imx51.dtsi
+++ b/arch/arm/boot/dts/imx51.dtsi
@@ -17,6 +17,10 @@
17 serial0 = &uart1; 17 serial0 = &uart1;
18 serial1 = &uart2; 18 serial1 = &uart2;
19 serial2 = &uart3; 19 serial2 = &uart3;
20 gpio0 = &gpio1;
21 gpio1 = &gpio2;
22 gpio2 = &gpio3;
23 gpio3 = &gpio4;
20 }; 24 };
21 25
22 tzic: tz-interrupt-controller@e0000000 { 26 tzic: tz-interrupt-controller@e0000000 {
@@ -127,43 +131,43 @@
127 }; 131 };
128 132
129 gpio1: gpio@73f84000 { 133 gpio1: gpio@73f84000 {
130 compatible = "fsl,imx51-gpio", "fsl,imx31-gpio"; 134 compatible = "fsl,imx51-gpio", "fsl,imx35-gpio";
131 reg = <0x73f84000 0x4000>; 135 reg = <0x73f84000 0x4000>;
132 interrupts = <50 51>; 136 interrupts = <50 51>;
133 gpio-controller; 137 gpio-controller;
134 #gpio-cells = <2>; 138 #gpio-cells = <2>;
135 interrupt-controller; 139 interrupt-controller;
136 #interrupt-cells = <1>; 140 #interrupt-cells = <2>;
137 }; 141 };
138 142
139 gpio2: gpio@73f88000 { 143 gpio2: gpio@73f88000 {
140 compatible = "fsl,imx51-gpio", "fsl,imx31-gpio"; 144 compatible = "fsl,imx51-gpio", "fsl,imx35-gpio";
141 reg = <0x73f88000 0x4000>; 145 reg = <0x73f88000 0x4000>;
142 interrupts = <52 53>; 146 interrupts = <52 53>;
143 gpio-controller; 147 gpio-controller;
144 #gpio-cells = <2>; 148 #gpio-cells = <2>;
145 interrupt-controller; 149 interrupt-controller;
146 #interrupt-cells = <1>; 150 #interrupt-cells = <2>;
147 }; 151 };
148 152
149 gpio3: gpio@73f8c000 { 153 gpio3: gpio@73f8c000 {
150 compatible = "fsl,imx51-gpio", "fsl,imx31-gpio"; 154 compatible = "fsl,imx51-gpio", "fsl,imx35-gpio";
151 reg = <0x73f8c000 0x4000>; 155 reg = <0x73f8c000 0x4000>;
152 interrupts = <54 55>; 156 interrupts = <54 55>;
153 gpio-controller; 157 gpio-controller;
154 #gpio-cells = <2>; 158 #gpio-cells = <2>;
155 interrupt-controller; 159 interrupt-controller;
156 #interrupt-cells = <1>; 160 #interrupt-cells = <2>;
157 }; 161 };
158 162
159 gpio4: gpio@73f90000 { 163 gpio4: gpio@73f90000 {
160 compatible = "fsl,imx51-gpio", "fsl,imx31-gpio"; 164 compatible = "fsl,imx51-gpio", "fsl,imx35-gpio";
161 reg = <0x73f90000 0x4000>; 165 reg = <0x73f90000 0x4000>;
162 interrupts = <56 57>; 166 interrupts = <56 57>;
163 gpio-controller; 167 gpio-controller;
164 #gpio-cells = <2>; 168 #gpio-cells = <2>;
165 interrupt-controller; 169 interrupt-controller;
166 #interrupt-cells = <1>; 170 #interrupt-cells = <2>;
167 }; 171 };
168 172
169 wdog@73f98000 { /* WDOG1 */ 173 wdog@73f98000 { /* WDOG1 */
diff --git a/arch/arm/boot/dts/imx53-ard.dts b/arch/arm/boot/dts/imx53-ard.dts
index 5b8eafcdbee..da895e93a99 100644
--- a/arch/arm/boot/dts/imx53-ard.dts
+++ b/arch/arm/boot/dts/imx53-ard.dts
@@ -64,12 +64,32 @@
64 reg = <0xf4000000 0x2000000>; 64 reg = <0xf4000000 0x2000000>;
65 phy-mode = "mii"; 65 phy-mode = "mii";
66 interrupt-parent = <&gpio2>; 66 interrupt-parent = <&gpio2>;
67 interrupts = <31>; 67 interrupts = <31 0x8>;
68 reg-io-width = <4>; 68 reg-io-width = <4>;
69 /*
70 * VDD33A and VDDVARIO of LAN9220 are supplied by
71 * SW4_3V3 of LTC3589. Before the regulator driver
72 * for this PMIC is available, we use a fixed dummy
73 * 3V3 regulator to get LAN9220 driver probing work.
74 */
75 vdd33a-supply = <&reg_3p3v>;
76 vddvario-supply = <&reg_3p3v>;
69 smsc,irq-push-pull; 77 smsc,irq-push-pull;
70 }; 78 };
71 }; 79 };
72 80
81 regulators {
82 compatible = "simple-bus";
83
84 reg_3p3v: 3p3v {
85 compatible = "regulator-fixed";
86 regulator-name = "3P3V";
87 regulator-min-microvolt = <3300000>;
88 regulator-max-microvolt = <3300000>;
89 regulator-always-on;
90 };
91 };
92
73 gpio-keys { 93 gpio-keys {
74 compatible = "gpio-keys"; 94 compatible = "gpio-keys";
75 95
diff --git a/arch/arm/boot/dts/imx53.dtsi b/arch/arm/boot/dts/imx53.dtsi
index e3e869470cd..cd37165edce 100644
--- a/arch/arm/boot/dts/imx53.dtsi
+++ b/arch/arm/boot/dts/imx53.dtsi
@@ -19,6 +19,13 @@
19 serial2 = &uart3; 19 serial2 = &uart3;
20 serial3 = &uart4; 20 serial3 = &uart4;
21 serial4 = &uart5; 21 serial4 = &uart5;
22 gpio0 = &gpio1;
23 gpio1 = &gpio2;
24 gpio2 = &gpio3;
25 gpio3 = &gpio4;
26 gpio4 = &gpio5;
27 gpio5 = &gpio6;
28 gpio6 = &gpio7;
22 }; 29 };
23 30
24 tzic: tz-interrupt-controller@0fffc000 { 31 tzic: tz-interrupt-controller@0fffc000 {
@@ -129,43 +136,43 @@
129 }; 136 };
130 137
131 gpio1: gpio@53f84000 { 138 gpio1: gpio@53f84000 {
132 compatible = "fsl,imx53-gpio", "fsl,imx31-gpio"; 139 compatible = "fsl,imx53-gpio", "fsl,imx35-gpio";
133 reg = <0x53f84000 0x4000>; 140 reg = <0x53f84000 0x4000>;
134 interrupts = <50 51>; 141 interrupts = <50 51>;
135 gpio-controller; 142 gpio-controller;
136 #gpio-cells = <2>; 143 #gpio-cells = <2>;
137 interrupt-controller; 144 interrupt-controller;
138 #interrupt-cells = <1>; 145 #interrupt-cells = <2>;
139 }; 146 };
140 147
141 gpio2: gpio@53f88000 { 148 gpio2: gpio@53f88000 {
142 compatible = "fsl,imx53-gpio", "fsl,imx31-gpio"; 149 compatible = "fsl,imx53-gpio", "fsl,imx35-gpio";
143 reg = <0x53f88000 0x4000>; 150 reg = <0x53f88000 0x4000>;
144 interrupts = <52 53>; 151 interrupts = <52 53>;
145 gpio-controller; 152 gpio-controller;
146 #gpio-cells = <2>; 153 #gpio-cells = <2>;
147 interrupt-controller; 154 interrupt-controller;
148 #interrupt-cells = <1>; 155 #interrupt-cells = <2>;
149 }; 156 };
150 157
151 gpio3: gpio@53f8c000 { 158 gpio3: gpio@53f8c000 {
152 compatible = "fsl,imx53-gpio", "fsl,imx31-gpio"; 159 compatible = "fsl,imx53-gpio", "fsl,imx35-gpio";
153 reg = <0x53f8c000 0x4000>; 160 reg = <0x53f8c000 0x4000>;
154 interrupts = <54 55>; 161 interrupts = <54 55>;
155 gpio-controller; 162 gpio-controller;
156 #gpio-cells = <2>; 163 #gpio-cells = <2>;
157 interrupt-controller; 164 interrupt-controller;
158 #interrupt-cells = <1>; 165 #interrupt-cells = <2>;
159 }; 166 };
160 167
161 gpio4: gpio@53f90000 { 168 gpio4: gpio@53f90000 {
162 compatible = "fsl,imx53-gpio", "fsl,imx31-gpio"; 169 compatible = "fsl,imx53-gpio", "fsl,imx35-gpio";
163 reg = <0x53f90000 0x4000>; 170 reg = <0x53f90000 0x4000>;
164 interrupts = <56 57>; 171 interrupts = <56 57>;
165 gpio-controller; 172 gpio-controller;
166 #gpio-cells = <2>; 173 #gpio-cells = <2>;
167 interrupt-controller; 174 interrupt-controller;
168 #interrupt-cells = <1>; 175 #interrupt-cells = <2>;
169 }; 176 };
170 177
171 wdog@53f98000 { /* WDOG1 */ 178 wdog@53f98000 { /* WDOG1 */
@@ -197,33 +204,33 @@
197 }; 204 };
198 205
199 gpio5: gpio@53fdc000 { 206 gpio5: gpio@53fdc000 {
200 compatible = "fsl,imx53-gpio", "fsl,imx31-gpio"; 207 compatible = "fsl,imx53-gpio", "fsl,imx35-gpio";
201 reg = <0x53fdc000 0x4000>; 208 reg = <0x53fdc000 0x4000>;
202 interrupts = <103 104>; 209 interrupts = <103 104>;
203 gpio-controller; 210 gpio-controller;
204 #gpio-cells = <2>; 211 #gpio-cells = <2>;
205 interrupt-controller; 212 interrupt-controller;
206 #interrupt-cells = <1>; 213 #interrupt-cells = <2>;
207 }; 214 };
208 215
209 gpio6: gpio@53fe0000 { 216 gpio6: gpio@53fe0000 {
210 compatible = "fsl,imx53-gpio", "fsl,imx31-gpio"; 217 compatible = "fsl,imx53-gpio", "fsl,imx35-gpio";
211 reg = <0x53fe0000 0x4000>; 218 reg = <0x53fe0000 0x4000>;
212 interrupts = <105 106>; 219 interrupts = <105 106>;
213 gpio-controller; 220 gpio-controller;
214 #gpio-cells = <2>; 221 #gpio-cells = <2>;
215 interrupt-controller; 222 interrupt-controller;
216 #interrupt-cells = <1>; 223 #interrupt-cells = <2>;
217 }; 224 };
218 225
219 gpio7: gpio@53fe4000 { 226 gpio7: gpio@53fe4000 {
220 compatible = "fsl,imx53-gpio", "fsl,imx31-gpio"; 227 compatible = "fsl,imx53-gpio", "fsl,imx35-gpio";
221 reg = <0x53fe4000 0x4000>; 228 reg = <0x53fe4000 0x4000>;
222 interrupts = <107 108>; 229 interrupts = <107 108>;
223 gpio-controller; 230 gpio-controller;
224 #gpio-cells = <2>; 231 #gpio-cells = <2>;
225 interrupt-controller; 232 interrupt-controller;
226 #interrupt-cells = <1>; 233 #interrupt-cells = <2>;
227 }; 234 };
228 235
229 i2c@53fec000 { /* I2C3 */ 236 i2c@53fec000 { /* I2C3 */
diff --git a/arch/arm/boot/dts/imx6q-arm2.dts b/arch/arm/boot/dts/imx6q-arm2.dts
index db4c6096c56..d792581672c 100644
--- a/arch/arm/boot/dts/imx6q-arm2.dts
+++ b/arch/arm/boot/dts/imx6q-arm2.dts
@@ -22,6 +22,12 @@
22 }; 22 };
23 23
24 soc { 24 soc {
25 gpmi-nand@00112000 {
26 pinctrl-names = "default";
27 pinctrl-0 = <&pinctrl_gpmi_nand_1>;
28 status = "disabled"; /* gpmi nand conflicts with SD */
29 };
30
25 aips-bus@02100000 { /* AIPS2 */ 31 aips-bus@02100000 { /* AIPS2 */
26 ethernet@02188000 { 32 ethernet@02188000 {
27 phy-mode = "rgmii"; 33 phy-mode = "rgmii";
diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts b/arch/arm/boot/dts/imx6q-sabrelite.dts
index e0ec92973e7..72f30f3e617 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -27,6 +27,8 @@
27 ecspi@02008000 { /* eCSPI1 */ 27 ecspi@02008000 { /* eCSPI1 */
28 fsl,spi-num-chipselects = <1>; 28 fsl,spi-num-chipselects = <1>;
29 cs-gpios = <&gpio3 19 0>; 29 cs-gpios = <&gpio3 19 0>;
30 pinctrl-names = "default";
31 pinctrl-0 = <&pinctrl_ecspi1_1>;
30 status = "okay"; 32 status = "okay";
31 33
32 flash: m25p80@0 { 34 flash: m25p80@0 {
@@ -42,9 +44,32 @@
42 }; 44 };
43 }; 45 };
44 46
47 iomuxc@020e0000 {
48 pinctrl-names = "default";
49 pinctrl-0 = <&pinctrl_gpio_hog>;
50
51 gpios {
52 pinctrl_gpio_hog: gpiohog {
53 fsl,pins = <
54 144 0x80000000 /* MX6Q_PAD_EIM_D22__GPIO_3_22 */
55 121 0x80000000 /* MX6Q_PAD_EIM_D19__GPIO_3_19 */
56 953 0x80000000 /* MX6Q_PAD_GPIO_0__CCM_CLKO */
57 >;
58 };
59 };
60 };
45 }; 61 };
46 62
47 aips-bus@02100000 { /* AIPS2 */ 63 aips-bus@02100000 { /* AIPS2 */
64 usb@02184000 { /* USB OTG */
65 vbus-supply = <&reg_usb_otg_vbus>;
66 status = "okay";
67 };
68
69 usb@02184200 { /* USB1 */
70 status = "okay";
71 };
72
48 ethernet@02188000 { 73 ethernet@02188000 {
49 phy-mode = "rgmii"; 74 phy-mode = "rgmii";
50 phy-reset-gpios = <&gpio3 23 0>; 75 phy-reset-gpios = <&gpio3 23 0>;
@@ -111,6 +136,15 @@
111 regulator-max-microvolt = <3300000>; 136 regulator-max-microvolt = <3300000>;
112 regulator-always-on; 137 regulator-always-on;
113 }; 138 };
139
140 reg_usb_otg_vbus: usb_otg_vbus {
141 compatible = "regulator-fixed";
142 regulator-name = "usb_otg_vbus";
143 regulator-min-microvolt = <5000000>;
144 regulator-max-microvolt = <5000000>;
145 gpio = <&gpio3 22 0>;
146 enable-active-high;
147 };
114 }; 148 };
115 149
116 sound { 150 sound {
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 8c90cbac945..fd57079f71a 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -19,6 +19,13 @@
19 serial2 = &uart3; 19 serial2 = &uart3;
20 serial3 = &uart4; 20 serial3 = &uart4;
21 serial4 = &uart5; 21 serial4 = &uart5;
22 gpio0 = &gpio1;
23 gpio1 = &gpio2;
24 gpio2 = &gpio3;
25 gpio3 = &gpio4;
26 gpio4 = &gpio5;
27 gpio5 = &gpio6;
28 gpio6 = &gpio7;
22 }; 29 };
23 30
24 cpus { 31 cpus {
@@ -87,6 +94,23 @@
87 interrupt-parent = <&intc>; 94 interrupt-parent = <&intc>;
88 ranges; 95 ranges;
89 96
97 dma-apbh@00110000 {
98 compatible = "fsl,imx6q-dma-apbh", "fsl,imx28-dma-apbh";
99 reg = <0x00110000 0x2000>;
100 };
101
102 gpmi-nand@00112000 {
103 compatible = "fsl,imx6q-gpmi-nand";
104 #address-cells = <1>;
105 #size-cells = <1>;
106 reg = <0x00112000 0x2000>, <0x00114000 0x2000>;
107 reg-names = "gpmi-nand", "bch";
108 interrupts = <0 13 0x04>, <0 15 0x04>;
109 interrupt-names = "gpmi-dma", "bch";
110 fsl,gpmi-dma-channel = <0>;
111 status = "disabled";
112 };
113
90 timer@00a00600 { 114 timer@00a00600 {
91 compatible = "arm,cortex-a9-twd-timer"; 115 compatible = "arm,cortex-a9-twd-timer";
92 reg = <0x00a00600 0x20>; 116 reg = <0x00a00600 0x20>;
@@ -260,73 +284,73 @@
260 }; 284 };
261 285
262 gpio1: gpio@0209c000 { 286 gpio1: gpio@0209c000 {
263 compatible = "fsl,imx6q-gpio", "fsl,imx31-gpio"; 287 compatible = "fsl,imx6q-gpio", "fsl,imx35-gpio";
264 reg = <0x0209c000 0x4000>; 288 reg = <0x0209c000 0x4000>;
265 interrupts = <0 66 0x04 0 67 0x04>; 289 interrupts = <0 66 0x04 0 67 0x04>;
266 gpio-controller; 290 gpio-controller;
267 #gpio-cells = <2>; 291 #gpio-cells = <2>;
268 interrupt-controller; 292 interrupt-controller;
269 #interrupt-cells = <1>; 293 #interrupt-cells = <2>;
270 }; 294 };
271 295
272 gpio2: gpio@020a0000 { 296 gpio2: gpio@020a0000 {
273 compatible = "fsl,imx6q-gpio", "fsl,imx31-gpio"; 297 compatible = "fsl,imx6q-gpio", "fsl,imx35-gpio";
274 reg = <0x020a0000 0x4000>; 298 reg = <0x020a0000 0x4000>;
275 interrupts = <0 68 0x04 0 69 0x04>; 299 interrupts = <0 68 0x04 0 69 0x04>;
276 gpio-controller; 300 gpio-controller;
277 #gpio-cells = <2>; 301 #gpio-cells = <2>;
278 interrupt-controller; 302 interrupt-controller;
279 #interrupt-cells = <1>; 303 #interrupt-cells = <2>;
280 }; 304 };
281 305
282 gpio3: gpio@020a4000 { 306 gpio3: gpio@020a4000 {
283 compatible = "fsl,imx6q-gpio", "fsl,imx31-gpio"; 307 compatible = "fsl,imx6q-gpio", "fsl,imx35-gpio";
284 reg = <0x020a4000 0x4000>; 308 reg = <0x020a4000 0x4000>;
285 interrupts = <0 70 0x04 0 71 0x04>; 309 interrupts = <0 70 0x04 0 71 0x04>;
286 gpio-controller; 310 gpio-controller;
287 #gpio-cells = <2>; 311 #gpio-cells = <2>;
288 interrupt-controller; 312 interrupt-controller;
289 #interrupt-cells = <1>; 313 #interrupt-cells = <2>;
290 }; 314 };
291 315
292 gpio4: gpio@020a8000 { 316 gpio4: gpio@020a8000 {
293 compatible = "fsl,imx6q-gpio", "fsl,imx31-gpio"; 317 compatible = "fsl,imx6q-gpio", "fsl,imx35-gpio";
294 reg = <0x020a8000 0x4000>; 318 reg = <0x020a8000 0x4000>;
295 interrupts = <0 72 0x04 0 73 0x04>; 319 interrupts = <0 72 0x04 0 73 0x04>;
296 gpio-controller; 320 gpio-controller;
297 #gpio-cells = <2>; 321 #gpio-cells = <2>;
298 interrupt-controller; 322 interrupt-controller;
299 #interrupt-cells = <1>; 323 #interrupt-cells = <2>;
300 }; 324 };
301 325
302 gpio5: gpio@020ac000 { 326 gpio5: gpio@020ac000 {
303 compatible = "fsl,imx6q-gpio", "fsl,imx31-gpio"; 327 compatible = "fsl,imx6q-gpio", "fsl,imx35-gpio";
304 reg = <0x020ac000 0x4000>; 328 reg = <0x020ac000 0x4000>;
305 interrupts = <0 74 0x04 0 75 0x04>; 329 interrupts = <0 74 0x04 0 75 0x04>;
306 gpio-controller; 330 gpio-controller;
307 #gpio-cells = <2>; 331 #gpio-cells = <2>;
308 interrupt-controller; 332 interrupt-controller;
309 #interrupt-cells = <1>; 333 #interrupt-cells = <2>;
310 }; 334 };
311 335
312 gpio6: gpio@020b0000 { 336 gpio6: gpio@020b0000 {
313 compatible = "fsl,imx6q-gpio", "fsl,imx31-gpio"; 337 compatible = "fsl,imx6q-gpio", "fsl,imx35-gpio";
314 reg = <0x020b0000 0x4000>; 338 reg = <0x020b0000 0x4000>;
315 interrupts = <0 76 0x04 0 77 0x04>; 339 interrupts = <0 76 0x04 0 77 0x04>;
316 gpio-controller; 340 gpio-controller;
317 #gpio-cells = <2>; 341 #gpio-cells = <2>;
318 interrupt-controller; 342 interrupt-controller;
319 #interrupt-cells = <1>; 343 #interrupt-cells = <2>;
320 }; 344 };
321 345
322 gpio7: gpio@020b4000 { 346 gpio7: gpio@020b4000 {
323 compatible = "fsl,imx6q-gpio", "fsl,imx31-gpio"; 347 compatible = "fsl,imx6q-gpio", "fsl,imx35-gpio";
324 reg = <0x020b4000 0x4000>; 348 reg = <0x020b4000 0x4000>;
325 interrupts = <0 78 0x04 0 79 0x04>; 349 interrupts = <0 78 0x04 0 79 0x04>;
326 gpio-controller; 350 gpio-controller;
327 #gpio-cells = <2>; 351 #gpio-cells = <2>;
328 interrupt-controller; 352 interrupt-controller;
329 #interrupt-cells = <1>; 353 #interrupt-cells = <2>;
330 }; 354 };
331 355
332 kpp@020b8000 { 356 kpp@020b8000 {
@@ -444,12 +468,14 @@
444 }; 468 };
445 }; 469 };
446 470
447 usbphy@020c9000 { /* USBPHY1 */ 471 usbphy1: usbphy@020c9000 {
472 compatible = "fsl,imx6q-usbphy", "fsl,imx23-usbphy";
448 reg = <0x020c9000 0x1000>; 473 reg = <0x020c9000 0x1000>;
449 interrupts = <0 44 0x04>; 474 interrupts = <0 44 0x04>;
450 }; 475 };
451 476
452 usbphy@020ca000 { /* USBPHY2 */ 477 usbphy2: usbphy@020ca000 {
478 compatible = "fsl,imx6q-usbphy", "fsl,imx23-usbphy";
453 reg = <0x020ca000 0x1000>; 479 reg = <0x020ca000 0x1000>;
454 interrupts = <0 45 0x04>; 480 interrupts = <0 45 0x04>;
455 }; 481 };
@@ -495,6 +521,30 @@
495 }; 521 };
496 }; 522 };
497 523
524 gpmi-nand {
525 pinctrl_gpmi_nand_1: gpmi-nand-1 {
526 fsl,pins = <1328 0xb0b1 /* MX6Q_PAD_NANDF_CLE__RAWNAND_CLE */
527 1336 0xb0b1 /* MX6Q_PAD_NANDF_ALE__RAWNAND_ALE */
528 1344 0xb0b1 /* MX6Q_PAD_NANDF_WP_B__RAWNAND_RESETN */
529 1352 0xb000 /* MX6Q_PAD_NANDF_RB0__RAWNAND_READY0 */
530 1360 0xb0b1 /* MX6Q_PAD_NANDF_CS0__RAWNAND_CE0N */
531 1365 0xb0b1 /* MX6Q_PAD_NANDF_CS1__RAWNAND_CE1N */
532 1371 0xb0b1 /* MX6Q_PAD_NANDF_CS2__RAWNAND_CE2N */
533 1378 0xb0b1 /* MX6Q_PAD_NANDF_CS3__RAWNAND_CE3N */
534 1387 0xb0b1 /* MX6Q_PAD_SD4_CMD__RAWNAND_RDN */
535 1393 0xb0b1 /* MX6Q_PAD_SD4_CLK__RAWNAND_WRN */
536 1397 0xb0b1 /* MX6Q_PAD_NANDF_D0__RAWNAND_D0 */
537 1405 0xb0b1 /* MX6Q_PAD_NANDF_D1__RAWNAND_D1 */
538 1413 0xb0b1 /* MX6Q_PAD_NANDF_D2__RAWNAND_D2 */
539 1421 0xb0b1 /* MX6Q_PAD_NANDF_D3__RAWNAND_D3 */
540 1429 0xb0b1 /* MX6Q_PAD_NANDF_D4__RAWNAND_D4 */
541 1437 0xb0b1 /* MX6Q_PAD_NANDF_D5__RAWNAND_D5 */
542 1445 0xb0b1 /* MX6Q_PAD_NANDF_D6__RAWNAND_D6 */
543 1453 0xb0b1 /* MX6Q_PAD_NANDF_D7__RAWNAND_D7 */
544 1463 0x00b1>; /* MX6Q_PAD_SD4_DAT0__RAWNAND_DQS */
545 };
546 };
547
498 i2c1 { 548 i2c1 {
499 pinctrl_i2c1_1: i2c1grp-1 { 549 pinctrl_i2c1_1: i2c1grp-1 {
500 fsl,pins = <137 0x4001b8b1 /* MX6Q_PAD_EIM_D21__I2C1_SCL */ 550 fsl,pins = <137 0x4001b8b1 /* MX6Q_PAD_EIM_D21__I2C1_SCL */
@@ -538,6 +588,14 @@
538 1517 0x17059>; /* MX6Q_PAD_SD4_DAT7__USDHC4_DAT7 */ 588 1517 0x17059>; /* MX6Q_PAD_SD4_DAT7__USDHC4_DAT7 */
539 }; 589 };
540 }; 590 };
591
592 ecspi1 {
593 pinctrl_ecspi1_1: ecspi1grp-1 {
594 fsl,pins = <101 0x100b1 /* MX6Q_PAD_EIM_D17__ECSPI1_MISO */
595 109 0x100b1 /* MX6Q_PAD_EIM_D18__ECSPI1_MOSI */
596 94 0x100b1>; /* MX6Q_PAD_EIM_D16__ECSPI1_SCLK */
597 };
598 };
541 }; 599 };
542 600
543 dcic@020e4000 { /* DCIC1 */ 601 dcic@020e4000 { /* DCIC1 */
@@ -573,6 +631,36 @@
573 reg = <0x0217c000 0x4000>; 631 reg = <0x0217c000 0x4000>;
574 }; 632 };
575 633
634 usb@02184000 { /* USB OTG */
635 compatible = "fsl,imx6q-usb", "fsl,imx27-usb";
636 reg = <0x02184000 0x200>;
637 interrupts = <0 43 0x04>;
638 fsl,usbphy = <&usbphy1>;
639 status = "disabled";
640 };
641
642 usb@02184200 { /* USB1 */
643 compatible = "fsl,imx6q-usb", "fsl,imx27-usb";
644 reg = <0x02184200 0x200>;
645 interrupts = <0 40 0x04>;
646 fsl,usbphy = <&usbphy2>;
647 status = "disabled";
648 };
649
650 usb@02184400 { /* USB2 */
651 compatible = "fsl,imx6q-usb", "fsl,imx27-usb";
652 reg = <0x02184400 0x200>;
653 interrupts = <0 41 0x04>;
654 status = "disabled";
655 };
656
657 usb@02184600 { /* USB3 */
658 compatible = "fsl,imx6q-usb", "fsl,imx27-usb";
659 reg = <0x02184600 0x200>;
660 interrupts = <0 42 0x04>;
661 status = "disabled";
662 };
663
576 ethernet@02188000 { 664 ethernet@02188000 {
577 compatible = "fsl,imx6q-fec"; 665 compatible = "fsl,imx6q-fec";
578 reg = <0x02188000 0x4000>; 666 reg = <0x02188000 0x4000>;
diff --git a/arch/arm/boot/dts/kirkwood-dns320.dts b/arch/arm/boot/dts/kirkwood-dns320.dts
index dc09a735b04..5bb0bf39d3b 100644
--- a/arch/arm/boot/dts/kirkwood-dns320.dts
+++ b/arch/arm/boot/dts/kirkwood-dns320.dts
@@ -1,10 +1,10 @@
1/dts-v1/; 1/dts-v1/;
2 2
3/include/ "kirkwood.dtsi" 3/include/ "kirkwood-dnskw.dtsi"
4 4
5/ { 5/ {
6 model = "D-Link DNS-320 NAS (Rev A1)"; 6 model = "D-Link DNS-320 NAS (Rev A1)";
7 compatible = "dlink,dns-320-a1", "dlink,dns-320", "dlink,dns-kirkwood", "mrvl,kirkwood-88f6281", "mrvl,kirkwood"; 7 compatible = "dlink,dns-320-a1", "dlink,dns-320", "dlink,dns-kirkwood", "marvell,kirkwood-88f6281", "marvell,kirkwood";
8 8
9 memory { 9 memory {
10 device_type = "memory"; 10 device_type = "memory";
@@ -15,6 +15,31 @@
15 bootargs = "console=ttyS0,115200n8 earlyprintk"; 15 bootargs = "console=ttyS0,115200n8 earlyprintk";
16 }; 16 };
17 17
18 gpio-leds {
19 compatible = "gpio-leds";
20 blue-power {
21 label = "dns320:blue:power";
22 gpios = <&gpio0 26 1>; /* GPIO 26 Active Low */
23 linux,default-trigger = "default-on";
24 };
25 blue-usb {
26 label = "dns320:blue:usb";
27 gpios = <&gpio1 11 1>; /* GPIO 43 Active Low */
28 };
29 orange-l_hdd {
30 label = "dns320:orange:l_hdd";
31 gpios = <&gpio0 28 1>; /* GPIO 28 Active Low */
32 };
33 orange-r_hdd {
34 label = "dns320:orange:r_hdd";
35 gpios = <&gpio0 27 1>; /* GPIO 27 Active Low */
36 };
37 orange-usb {
38 label = "dns320:orange:usb";
39 gpios = <&gpio1 3 1>; /* GPIO 35 Active Low */
40 };
41 };
42
18 ocp@f1000000 { 43 ocp@f1000000 {
19 serial@12000 { 44 serial@12000 {
20 clock-frequency = <166666667>; 45 clock-frequency = <166666667>;
@@ -25,40 +50,5 @@
25 clock-frequency = <166666667>; 50 clock-frequency = <166666667>;
26 status = "okay"; 51 status = "okay";
27 }; 52 };
28
29 nand@3000000 {
30 status = "okay";
31
32 partition@0 {
33 label = "u-boot";
34 reg = <0x0000000 0x100000>;
35 read-only;
36 };
37
38 partition@100000 {
39 label = "uImage";
40 reg = <0x0100000 0x500000>;
41 };
42
43 partition@600000 {
44 label = "ramdisk";
45 reg = <0x0600000 0x500000>;
46 };
47
48 partition@b00000 {
49 label = "image";
50 reg = <0x0b00000 0x6600000>;
51 };
52
53 partition@7100000 {
54 label = "mini firmware";
55 reg = <0x7100000 0xa00000>;
56 };
57
58 partition@7b00000 {
59 label = "config";
60 reg = <0x7b00000 0x500000>;
61 };
62 };
63 }; 53 };
64}; 54};
diff --git a/arch/arm/boot/dts/kirkwood-dns325.dts b/arch/arm/boot/dts/kirkwood-dns325.dts
index c2a5562525d..d430713ea9b 100644
--- a/arch/arm/boot/dts/kirkwood-dns325.dts
+++ b/arch/arm/boot/dts/kirkwood-dns325.dts
@@ -1,10 +1,10 @@
1/dts-v1/; 1/dts-v1/;
2 2
3/include/ "kirkwood.dtsi" 3/include/ "kirkwood-dnskw.dtsi"
4 4
5/ { 5/ {
6 model = "D-Link DNS-325 NAS (Rev A1)"; 6 model = "D-Link DNS-325 NAS (Rev A1)";
7 compatible = "dlink,dns-325-a1", "dlink,dns-325", "dlink,dns-kirkwood", "mrvl,kirkwood-88f6281", "mrvl,kirkwood"; 7 compatible = "dlink,dns-325-a1", "dlink,dns-325", "dlink,dns-kirkwood", "marvell,kirkwood-88f6281", "marvell,kirkwood";
8 8
9 memory { 9 memory {
10 device_type = "memory"; 10 device_type = "memory";
@@ -15,45 +15,43 @@
15 bootargs = "console=ttyS0,115200n8 earlyprintk"; 15 bootargs = "console=ttyS0,115200n8 earlyprintk";
16 }; 16 };
17 17
18 ocp@f1000000 { 18 gpio-leds {
19 serial@12000 { 19 compatible = "gpio-leds";
20 clock-frequency = <200000000>; 20 white-power {
21 status = "okay"; 21 label = "dns325:white:power";
22 gpios = <&gpio0 26 1>; /* GPIO 26 Active Low */
23 linux,default-trigger = "default-on";
24 };
25 white-usb {
26 label = "dns325:white:usb";
27 gpios = <&gpio1 11 1>; /* GPIO 43 Active Low */
28 };
29 red-l_hdd {
30 label = "dns325:red:l_hdd";
31 gpios = <&gpio0 28 1>; /* GPIO 28 Active Low */
22 }; 32 };
33 red-r_hdd {
34 label = "dns325:red:r_hdd";
35 gpios = <&gpio0 27 1>; /* GPIO 27 Active Low */
36 };
37 red-usb {
38 label = "dns325:red:usb";
39 gpios = <&gpio0 29 1>; /* GPIO 29 Active Low */
40 };
41 };
23 42
24 nand@3000000 { 43 ocp@f1000000 {
44 i2c@11000 {
25 status = "okay"; 45 status = "okay";
26 46
27 partition@0 { 47 lm75: lm75@48 {
28 label = "u-boot"; 48 compatible = "national,lm75";
29 reg = <0x0000000 0x100000>; 49 reg = <0x48>;
30 read-only;
31 };
32
33 partition@100000 {
34 label = "uImage";
35 reg = <0x0100000 0x500000>;
36 };
37
38 partition@600000 {
39 label = "ramdisk";
40 reg = <0x0600000 0x500000>;
41 };
42
43 partition@b00000 {
44 label = "image";
45 reg = <0x0b00000 0x6600000>;
46 };
47
48 partition@7100000 {
49 label = "mini firmware";
50 reg = <0x7100000 0xa00000>;
51 };
52
53 partition@7b00000 {
54 label = "config";
55 reg = <0x7b00000 0x500000>;
56 }; 50 };
57 }; 51 };
52 serial@12000 {
53 clock-frequency = <200000000>;
54 status = "okay";
55 };
58 }; 56 };
59}; 57};
diff --git a/arch/arm/boot/dts/kirkwood-dnskw.dtsi b/arch/arm/boot/dts/kirkwood-dnskw.dtsi
new file mode 100644
index 00000000000..7408655f91b
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood-dnskw.dtsi
@@ -0,0 +1,69 @@
1/include/ "kirkwood.dtsi"
2
3/ {
4 model = "D-Link DNS NASes (kirkwood-based)";
5 compatible = "dlink,dns-kirkwood", "marvell,kirkwood-88f6281", "marvell,kirkwood";
6
7 gpio_keys {
8 compatible = "gpio-keys";
9 #address-cells = <1>;
10 #size-cells = <0>;
11 button@1 {
12 label = "Power button";
13 linux,code = <116>;
14 gpios = <&gpio1 2 1>;
15 };
16 button@2 {
17 label = "USB unmount button";
18 linux,code = <161>;
19 gpios = <&gpio1 15 1>;
20 };
21 button@3 {
22 label = "Reset button";
23 linux,code = <0x198>;
24 gpios = <&gpio1 16 1>;
25 };
26 };
27
28 ocp@f1000000 {
29 sata@80000 {
30 status = "okay";
31 nr-ports = <2>;
32 };
33
34 nand@3000000 {
35 status = "okay";
36
37 partition@0 {
38 label = "u-boot";
39 reg = <0x0000000 0x100000>;
40 read-only;
41 };
42
43 partition@100000 {
44 label = "uImage";
45 reg = <0x0100000 0x500000>;
46 };
47
48 partition@600000 {
49 label = "ramdisk";
50 reg = <0x0600000 0x500000>;
51 };
52
53 partition@b00000 {
54 label = "image";
55 reg = <0x0b00000 0x6600000>;
56 };
57
58 partition@7100000 {
59 label = "mini firmware";
60 reg = <0x7100000 0xa00000>;
61 };
62
63 partition@7b00000 {
64 label = "config";
65 reg = <0x7b00000 0x500000>;
66 };
67 };
68 };
69};
diff --git a/arch/arm/boot/dts/kirkwood-dreamplug.dts b/arch/arm/boot/dts/kirkwood-dreamplug.dts
index a5376b84227..26e281fbf6b 100644
--- a/arch/arm/boot/dts/kirkwood-dreamplug.dts
+++ b/arch/arm/boot/dts/kirkwood-dreamplug.dts
@@ -4,7 +4,7 @@
4 4
5/ { 5/ {
6 model = "Globalscale Technologies Dreamplug"; 6 model = "Globalscale Technologies Dreamplug";
7 compatible = "globalscale,dreamplug-003-ds2001", "globalscale,dreamplug", "mrvl,kirkwood-88f6281", "mrvl,kirkwood"; 7 compatible = "globalscale,dreamplug-003-ds2001", "globalscale,dreamplug", "marvell,kirkwood-88f6281", "marvell,kirkwood";
8 8
9 memory { 9 memory {
10 device_type = "memory"; 10 device_type = "memory";
@@ -20,5 +20,55 @@
20 clock-frequency = <200000000>; 20 clock-frequency = <200000000>;
21 status = "ok"; 21 status = "ok";
22 }; 22 };
23
24 spi@10600 {
25 status = "okay";
26
27 m25p40@0 {
28 #address-cells = <1>;
29 #size-cells = <1>;
30 compatible = "mx25l1606e";
31 reg = <0>;
32 spi-max-frequency = <50000000>;
33 mode = <0>;
34
35 partition@0 {
36 reg = <0x0 0x80000>;
37 label = "u-boot";
38 };
39
40 partition@100000 {
41 reg = <0x100000 0x10000>;
42 label = "u-boot env";
43 };
44
45 partition@180000 {
46 reg = <0x180000 0x10000>;
47 label = "dtb";
48 };
49 };
50 };
51
52 sata@80000 {
53 status = "okay";
54 nr-ports = <1>;
55 };
56 };
57
58 gpio-leds {
59 compatible = "gpio-leds";
60
61 bluetooth {
62 label = "dreamplug:blue:bluetooth";
63 gpios = <&gpio1 15 1>;
64 };
65 wifi {
66 label = "dreamplug:green:wifi";
67 gpios = <&gpio1 16 1>;
68 };
69 wifi-ap {
70 label = "dreamplug:green:wifi_ap";
71 gpios = <&gpio1 17 1>;
72 };
23 }; 73 };
24}; 74};
diff --git a/arch/arm/boot/dts/kirkwood-goflexnet.dts b/arch/arm/boot/dts/kirkwood-goflexnet.dts
new file mode 100644
index 00000000000..7c8238fbb6f
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood-goflexnet.dts
@@ -0,0 +1,99 @@
1/dts-v1/;
2
3/include/ "kirkwood.dtsi"
4
5/ {
6 model = "Seagate GoFlex Net";
7 compatible = "seagate,goflexnet", "marvell,kirkwood-88f6281", "marvell,kirkwood";
8
9 memory {
10 device_type = "memory";
11 reg = <0x00000000 0x8000000>;
12 };
13
14 chosen {
15 bootargs = "console=ttyS0,115200n8 earlyprintk root=/dev/sda1 rootdelay=10";
16 };
17
18 ocp@f1000000 {
19 serial@12000 {
20 clock-frequency = <200000000>;
21 status = "ok";
22 };
23
24 nand@3000000 {
25 status = "okay";
26
27 partition@0 {
28 label = "u-boot";
29 reg = <0x0000000 0x100000>;
30 read-only;
31 };
32
33 partition@100000 {
34 label = "uImage";
35 reg = <0x0100000 0x400000>;
36 };
37
38 partition@500000 {
39 label = "pogoplug";
40 reg = <0x0500000 0x2000000>;
41 };
42
43 partition@2500000 {
44 label = "root";
45 reg = <0x02500000 0xd800000>;
46 };
47 };
48 sata@80000 {
49 status = "okay";
50 nr-ports = <2>;
51 };
52
53 };
54 gpio-leds {
55 compatible = "gpio-leds";
56
57 health {
58 label = "status:green:health";
59 gpios = <&gpio1 14 1>;
60 linux,default-trigger = "default-on";
61 };
62 fault {
63 label = "status:orange:fault";
64 gpios = <&gpio1 15 1>;
65 };
66 left0 {
67 label = "status:white:left0";
68 gpios = <&gpio1 10 0>;
69 };
70 left1 {
71 label = "status:white:left1";
72 gpios = <&gpio1 11 0>;
73 };
74 left2 {
75 label = "status:white:left2";
76 gpios = <&gpio1 12 0>;
77 };
78 left3 {
79 label = "status:white:left3";
80 gpios = <&gpio1 13 0>;
81 };
82 right0 {
83 label = "status:white:right0";
84 gpios = <&gpio1 6 0>;
85 };
86 right1 {
87 label = "status:white:right1";
88 gpios = <&gpio1 7 0>;
89 };
90 right2 {
91 label = "status:white:right2";
92 gpios = <&gpio1 8 0>;
93 };
94 right3 {
95 label = "status:white:right3";
96 gpios = <&gpio1 9 0>;
97 };
98 };
99};
diff --git a/arch/arm/boot/dts/kirkwood-ib62x0.dts b/arch/arm/boot/dts/kirkwood-ib62x0.dts
index ada0f0c2308..66794ed75ff 100644
--- a/arch/arm/boot/dts/kirkwood-ib62x0.dts
+++ b/arch/arm/boot/dts/kirkwood-ib62x0.dts
@@ -4,7 +4,7 @@
4 4
5/ { 5/ {
6 model = "RaidSonic ICY BOX IB-NAS62x0 (Rev B)"; 6 model = "RaidSonic ICY BOX IB-NAS62x0 (Rev B)";
7 compatible = "raidsonic,ib-nas6210-b", "raidsonic,ib-nas6220-b", "raidsonic,ib-nas6210", "raidsonic,ib-nas6220", "raidsonic,ib-nas62x0", "mrvl,kirkwood-88f6281", "mrvl,kirkwood"; 7 compatible = "raidsonic,ib-nas6210-b", "raidsonic,ib-nas6220-b", "raidsonic,ib-nas6210", "raidsonic,ib-nas6220", "raidsonic,ib-nas62x0", "marvell,kirkwood-88f6281", "marvell,kirkwood";
8 8
9 memory { 9 memory {
10 device_type = "memory"; 10 device_type = "memory";
@@ -21,6 +21,11 @@
21 status = "okay"; 21 status = "okay";
22 }; 22 };
23 23
24 sata@80000 {
25 status = "okay";
26 nr-ports = <2>;
27 };
28
24 nand@3000000 { 29 nand@3000000 {
25 status = "okay"; 30 status = "okay";
26 31
@@ -41,4 +46,37 @@
41 46
42 }; 47 };
43 }; 48 };
49
50 gpio_keys {
51 compatible = "gpio-keys";
52 #address-cells = <1>;
53 #size-cells = <0>;
54 button@1 {
55 label = "USB Copy";
56 linux,code = <133>;
57 gpios = <&gpio0 29 1>;
58 };
59 button@2 {
60 label = "Reset";
61 linux,code = <0x198>;
62 gpios = <&gpio0 28 1>;
63 };
64 };
65 gpio-leds {
66 compatible = "gpio-leds";
67
68 green-os {
69 label = "ib62x0:green:os";
70 gpios = <&gpio0 25 0>;
71 linux,default-trigger = "default-on";
72 };
73 red-os {
74 label = "ib62x0:red:os";
75 gpios = <&gpio0 22 0>;
76 };
77 usb-copy {
78 label = "ib62x0:red:usb_copy";
79 gpios = <&gpio0 27 0>;
80 };
81 };
44}; 82};
diff --git a/arch/arm/boot/dts/kirkwood-iconnect.dts b/arch/arm/boot/dts/kirkwood-iconnect.dts
index 1ba75d4adec..f8ca6fa8819 100644
--- a/arch/arm/boot/dts/kirkwood-iconnect.dts
+++ b/arch/arm/boot/dts/kirkwood-iconnect.dts
@@ -4,7 +4,7 @@
4 4
5/ { 5/ {
6 model = "Iomega Iconnect"; 6 model = "Iomega Iconnect";
7 compatible = "iom,iconnect-1.1", "iom,iconnect", "mrvl,kirkwood-88f6281", "mrvl,kirkwood"; 7 compatible = "iom,iconnect-1.1", "iom,iconnect", "marvell,kirkwood-88f6281", "marvell,kirkwood";
8 8
9 memory { 9 memory {
10 device_type = "memory"; 10 device_type = "memory";
@@ -18,9 +18,55 @@
18 }; 18 };
19 19
20 ocp@f1000000 { 20 ocp@f1000000 {
21 i2c@11000 {
22 status = "okay";
23
24 lm63: lm63@4c {
25 compatible = "national,lm63";
26 reg = <0x4c>;
27 };
28 };
21 serial@12000 { 29 serial@12000 {
22 clock-frequency = <200000000>; 30 clock-frequency = <200000000>;
23 status = "ok"; 31 status = "ok";
24 }; 32 };
25 }; 33 };
34 gpio-leds {
35 compatible = "gpio-leds";
36
37 led-level {
38 label = "led_level";
39 gpios = <&gpio1 9 0>;
40 linux,default-trigger = "default-on";
41 };
42 power-blue {
43 label = "power:blue";
44 gpios = <&gpio1 10 0>;
45 linux,default-trigger = "timer";
46 };
47 power-red {
48 label = "power:red";
49 gpios = <&gpio1 11 0>;
50 };
51 usb1 {
52 label = "usb1:blue";
53 gpios = <&gpio1 12 0>;
54 };
55 usb2 {
56 label = "usb2:blue";
57 gpios = <&gpio1 13 0>;
58 };
59 usb3 {
60 label = "usb3:blue";
61 gpios = <&gpio1 14 0>;
62 };
63 usb4 {
64 label = "usb4:blue";
65 gpios = <&gpio1 15 0>;
66 };
67 otb {
68 label = "otb:blue";
69 gpios = <&gpio1 16 0>;
70 };
71 };
26}; 72};
diff --git a/arch/arm/boot/dts/kirkwood-lschlv2.dts b/arch/arm/boot/dts/kirkwood-lschlv2.dts
new file mode 100644
index 00000000000..9510c9ea666
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood-lschlv2.dts
@@ -0,0 +1,20 @@
1/dts-v1/;
2
3/include/ "kirkwood-lsxl.dtsi"
4
5/ {
6 model = "Buffalo Linkstation LS-CHLv2";
7 compatible = "buffalo,lschlv2", "buffalo,lsxl", "marvell,kirkwood-88f6281", "marvell,kirkwood";
8
9 memory {
10 device_type = "memory";
11 reg = <0x00000000 0x4000000>;
12 };
13
14 ocp@f1000000 {
15 serial@12000 {
16 clock-frequency = <166666667>;
17 status = "okay";
18 };
19 };
20};
diff --git a/arch/arm/boot/dts/kirkwood-lsxhl.dts b/arch/arm/boot/dts/kirkwood-lsxhl.dts
new file mode 100644
index 00000000000..739019c4cba
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood-lsxhl.dts
@@ -0,0 +1,20 @@
1/dts-v1/;
2
3/include/ "kirkwood-lsxl.dtsi"
4
5/ {
6 model = "Buffalo Linkstation LS-XHL";
7 compatible = "buffalo,lsxhl", "buffalo,lsxl", "marvell,kirkwood-88f6281", "marvell,kirkwood";
8
9 memory {
10 device_type = "memory";
11 reg = <0x00000000 0x10000000>;
12 };
13
14 ocp@f1000000 {
15 serial@12000 {
16 clock-frequency = <200000000>;
17 status = "okay";
18 };
19 };
20};
diff --git a/arch/arm/boot/dts/kirkwood-lsxl.dtsi b/arch/arm/boot/dts/kirkwood-lsxl.dtsi
new file mode 100644
index 00000000000..8ac51c08269
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood-lsxl.dtsi
@@ -0,0 +1,95 @@
1/include/ "kirkwood.dtsi"
2
3/ {
4 chosen {
5 bootargs = "console=ttyS0,115200n8 earlyprintk";
6 };
7
8 ocp@f1000000 {
9 sata@80000 {
10 status = "okay";
11 nr-ports = <1>;
12 };
13
14 spi@10600 {
15 status = "okay";
16
17 m25p40@0 {
18 #address-cells = <1>;
19 #size-cells = <1>;
20 compatible = "m25p40";
21 reg = <0>;
22 spi-max-frequency = <25000000>;
23 mode = <0>;
24
25 partition@0 {
26 reg = <0x0 0x60000>;
27 label = "uboot";
28 read-only;
29 };
30
31 partition@60000 {
32 reg = <0x60000 0x10000>;
33 label = "dtb";
34 read-only;
35 };
36
37 partition@70000 {
38 reg = <0x70000 0x10000>;
39 label = "uboot_env";
40 };
41 };
42 };
43 };
44
45 gpio_keys {
46 compatible = "gpio-keys";
47 #address-cells = <1>;
48 #size-cells = <0>;
49 button@1 {
50 label = "Function Button";
51 linux,code = <132>;
52 gpios = <&gpio1 9 1>;
53 };
54 button@2 {
55 label = "Power-on Switch";
56 linux,code = <116>;
57 gpios = <&gpio1 10 1>;
58 };
59 button@3 {
60 label = "Power-auto Switch";
61 linux,code = <142>;
62 gpios = <&gpio1 11 1>;
63 };
64 };
65
66 gpio_leds {
67 compatible = "gpio-leds";
68
69 led@1 {
70 label = "lschlv2:blue:func";
71 gpios = <&gpio1 4 1>;
72 };
73
74 led@2 {
75 label = "lschlv2:red:alarm";
76 gpios = <&gpio1 5 1>;
77 };
78
79 led@3 {
80 label = "lschlv2:amber:info";
81 gpios = <&gpio1 6 1>;
82 };
83
84 led@4 {
85 label = "lschlv2:blue:power";
86 gpios = <&gpio1 7 1>;
87 linux,default-trigger = "default-on";
88 };
89
90 led@5 {
91 label = "lschlv2:red:func";
92 gpios = <&gpio1 16 1>;
93 };
94 };
95};
diff --git a/arch/arm/boot/dts/kirkwood-ts219-6281.dts b/arch/arm/boot/dts/kirkwood-ts219-6281.dts
new file mode 100644
index 00000000000..ccbf3275780
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood-ts219-6281.dts
@@ -0,0 +1,21 @@
1/dts-v1/;
2
3/include/ "kirkwood-ts219.dtsi"
4
5/ {
6 gpio_keys {
7 compatible = "gpio-keys";
8 #address-cells = <1>;
9 #size-cells = <0>;
10 button@1 {
11 label = "USB Copy";
12 linux,code = <133>;
13 gpios = <&gpio0 15 1>;
14 };
15 button@2 {
16 label = "Reset";
17 linux,code = <0x198>;
18 gpios = <&gpio0 16 1>;
19 };
20 };
21}; \ No newline at end of file
diff --git a/arch/arm/boot/dts/kirkwood-ts219-6282.dts b/arch/arm/boot/dts/kirkwood-ts219-6282.dts
new file mode 100644
index 00000000000..fbe9932161a
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood-ts219-6282.dts
@@ -0,0 +1,21 @@
1/dts-v1/;
2
3/include/ "kirkwood-ts219.dtsi"
4
5/ {
6 gpio_keys {
7 compatible = "gpio-keys";
8 #address-cells = <1>;
9 #size-cells = <0>;
10 button@1 {
11 label = "USB Copy";
12 linux,code = <133>;
13 gpios = <&gpio1 11 1>;
14 };
15 button@2 {
16 label = "Reset";
17 linux,code = <0x198>;
18 gpios = <&gpio1 5 1>;
19 };
20 };
21}; \ No newline at end of file
diff --git a/arch/arm/boot/dts/kirkwood-ts219.dtsi b/arch/arm/boot/dts/kirkwood-ts219.dtsi
new file mode 100644
index 00000000000..64ea27cb329
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood-ts219.dtsi
@@ -0,0 +1,78 @@
1/include/ "kirkwood.dtsi"
2
3/ {
4 model = "QNAP TS219 family";
5 compatible = "qnap,ts219", "marvell,kirkwood";
6
7 memory {
8 device_type = "memory";
9 reg = <0x00000000 0x20000000>;
10 };
11
12 chosen {
13 bootargs = "console=ttyS0,115200n8";
14 };
15
16 ocp@f1000000 {
17 i2c@11000 {
18 status = "okay";
19 clock-frequency = <400000>;
20
21 s35390a: s35390a@30 {
22 compatible = "s35390a";
23 reg = <0x30>;
24 };
25 };
26 serial@12000 {
27 clock-frequency = <200000000>;
28 status = "okay";
29 };
30 serial@12100 {
31 clock-frequency = <200000000>;
32 status = "okay";
33 };
34 spi@10600 {
35 status = "okay";
36
37 m25p128@0 {
38 #address-cells = <1>;
39 #size-cells = <1>;
40 compatible = "m25p128";
41 reg = <0>;
42 spi-max-frequency = <20000000>;
43 mode = <0>;
44
45 partition@0000000 {
46 reg = <0x00000000 0x00080000>;
47 label = "U-Boot";
48 };
49
50 partition@00200000 {
51 reg = <0x00200000 0x00200000>;
52 label = "Kernel";
53 };
54
55 partition@00400000 {
56 reg = <0x00400000 0x00900000>;
57 label = "RootFS1";
58 };
59 partition@00d00000 {
60 reg = <0x00d00000 0x00300000>;
61 label = "RootFS2";
62 };
63 partition@00040000 {
64 reg = <0x00080000 0x00040000>;
65 label = "U-Boot Config";
66 };
67 partition@000c0000 {
68 reg = <0x000c0000 0x00140000>;
69 label = "NAS Config";
70 };
71 };
72 };
73 sata@80000 {
74 status = "okay";
75 nr-ports = <2>;
76 };
77 };
78};
diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
index 926528b81ba..cef9616f330 100644
--- a/arch/arm/boot/dts/kirkwood.dtsi
+++ b/arch/arm/boot/dts/kirkwood.dtsi
@@ -1,7 +1,16 @@
1/include/ "skeleton.dtsi" 1/include/ "skeleton.dtsi"
2 2
3/ { 3/ {
4 compatible = "mrvl,kirkwood"; 4 compatible = "marvell,kirkwood";
5 interrupt-parent = <&intc>;
6
7 intc: interrupt-controller {
8 compatible = "marvell,orion-intc", "marvell,intc";
9 interrupt-controller;
10 #interrupt-cells = <1>;
11 reg = <0xf1020204 0x04>,
12 <0xf1020214 0x04>;
13 };
5 14
6 ocp@f1000000 { 15 ocp@f1000000 {
7 compatible = "simple-bus"; 16 compatible = "simple-bus";
@@ -9,6 +18,24 @@
9 #address-cells = <1>; 18 #address-cells = <1>;
10 #size-cells = <1>; 19 #size-cells = <1>;
11 20
21 gpio0: gpio@10100 {
22 compatible = "marvell,orion-gpio";
23 #gpio-cells = <2>;
24 gpio-controller;
25 reg = <0x10100 0x40>;
26 ngpio = <32>;
27 interrupts = <35>, <36>, <37>, <38>;
28 };
29
30 gpio1: gpio@10140 {
31 compatible = "marvell,orion-gpio";
32 #gpio-cells = <2>;
33 gpio-controller;
34 reg = <0x10140 0x40>;
35 ngpio = <18>;
36 interrupts = <39>, <40>, <41>;
37 };
38
12 serial@12000 { 39 serial@12000 {
13 compatible = "ns16550a"; 40 compatible = "ns16550a";
14 reg = <0x12000 0x100>; 41 reg = <0x12000 0x100>;
@@ -28,22 +55,55 @@
28 }; 55 };
29 56
30 rtc@10300 { 57 rtc@10300 {
31 compatible = "mrvl,kirkwood-rtc", "mrvl,orion-rtc"; 58 compatible = "marvell,kirkwood-rtc", "marvell,orion-rtc";
32 reg = <0x10300 0x20>; 59 reg = <0x10300 0x20>;
33 interrupts = <53>; 60 interrupts = <53>;
34 }; 61 };
35 62
63 spi@10600 {
64 compatible = "marvell,orion-spi";
65 #address-cells = <1>;
66 #size-cells = <0>;
67 cell-index = <0>;
68 interrupts = <23>;
69 reg = <0x10600 0x28>;
70 status = "disabled";
71 };
72
73 wdt@20300 {
74 compatible = "marvell,orion-wdt";
75 reg = <0x20300 0x28>;
76 status = "okay";
77 };
78
79 sata@80000 {
80 compatible = "marvell,orion-sata";
81 reg = <0x80000 0x5000>;
82 interrupts = <21>;
83 status = "disabled";
84 };
85
36 nand@3000000 { 86 nand@3000000 {
37 #address-cells = <1>; 87 #address-cells = <1>;
38 #size-cells = <1>; 88 #size-cells = <1>;
39 cle = <0>; 89 cle = <0>;
40 ale = <1>; 90 ale = <1>;
41 bank-width = <1>; 91 bank-width = <1>;
42 compatible = "mrvl,orion-nand"; 92 compatible = "marvell,orion-nand";
43 reg = <0x3000000 0x400>; 93 reg = <0x3000000 0x400>;
44 chip-delay = <25>; 94 chip-delay = <25>;
45 /* set partition map and/or chip-delay in board dts */ 95 /* set partition map and/or chip-delay in board dts */
46 status = "disabled"; 96 status = "disabled";
47 }; 97 };
98
99 i2c@11000 {
100 compatible = "marvell,mv64xxx-i2c";
101 reg = <0x11000 0x20>;
102 #address-cells = <1>;
103 #size-cells = <0>;
104 interrupts = <29>;
105 clock-frequency = <100000>;
106 status = "disabled";
107 };
48 }; 108 };
49}; 109};
diff --git a/arch/arm/boot/dts/lpc32xx.dtsi b/arch/arm/boot/dts/lpc32xx.dtsi
index 3f5dad801a9..e5ffe960dbf 100644
--- a/arch/arm/boot/dts/lpc32xx.dtsi
+++ b/arch/arm/boot/dts/lpc32xx.dtsi
@@ -35,13 +35,14 @@
35 slc: flash@20020000 { 35 slc: flash@20020000 {
36 compatible = "nxp,lpc3220-slc"; 36 compatible = "nxp,lpc3220-slc";
37 reg = <0x20020000 0x1000>; 37 reg = <0x20020000 0x1000>;
38 status = "disable"; 38 status = "disabled";
39 }; 39 };
40 40
41 mlc: flash@200B0000 { 41 mlc: flash@200a8000 {
42 compatible = "nxp,lpc3220-mlc"; 42 compatible = "nxp,lpc3220-mlc";
43 reg = <0x200B0000 0x1000>; 43 reg = <0x200a8000 0x11000>;
44 status = "disable"; 44 interrupts = <11 0>;
45 status = "disabled";
45 }; 46 };
46 47
47 dma@31000000 { 48 dma@31000000 {
@@ -57,21 +58,21 @@
57 compatible = "nxp,ohci-nxp", "usb-ohci"; 58 compatible = "nxp,ohci-nxp", "usb-ohci";
58 reg = <0x31020000 0x300>; 59 reg = <0x31020000 0x300>;
59 interrupts = <0x3b 0>; 60 interrupts = <0x3b 0>;
60 status = "disable"; 61 status = "disabled";
61 }; 62 };
62 63
63 usbd@31020000 { 64 usbd@31020000 {
64 compatible = "nxp,lpc3220-udc"; 65 compatible = "nxp,lpc3220-udc";
65 reg = <0x31020000 0x300>; 66 reg = <0x31020000 0x300>;
66 interrupts = <0x3d 0>, <0x3e 0>, <0x3c 0>, <0x3a 0>; 67 interrupts = <0x3d 0>, <0x3e 0>, <0x3c 0>, <0x3a 0>;
67 status = "disable"; 68 status = "disabled";
68 }; 69 };
69 70
70 clcd@31040000 { 71 clcd@31040000 {
71 compatible = "arm,pl110", "arm,primecell"; 72 compatible = "arm,pl110", "arm,primecell";
72 reg = <0x31040000 0x1000>; 73 reg = <0x31040000 0x1000>;
73 interrupts = <0x0e 0>; 74 interrupts = <0x0e 0>;
74 status = "disable"; 75 status = "disabled";
75 }; 76 };
76 77
77 mac: ethernet@31060000 { 78 mac: ethernet@31060000 {
@@ -114,9 +115,10 @@
114 }; 115 };
115 116
116 sd@20098000 { 117 sd@20098000 {
117 compatible = "arm,pl180", "arm,primecell"; 118 compatible = "arm,pl18x", "arm,primecell";
118 reg = <0x20098000 0x1000>; 119 reg = <0x20098000 0x1000>;
119 interrupts = <0x0f 0>, <0x0d 0>; 120 interrupts = <0x0f 0>, <0x0d 0>;
121 status = "disabled";
120 }; 122 };
121 123
122 i2s1: i2s@2009C000 { 124 i2s1: i2s@2009C000 {
@@ -124,24 +126,42 @@
124 reg = <0x2009C000 0x1000>; 126 reg = <0x2009C000 0x1000>;
125 }; 127 };
126 128
129 /* UART5 first since it is the default console, ttyS0 */
130 uart5: serial@40090000 {
131 /* actually, ns16550a w/ 64 byte fifos! */
132 compatible = "nxp,lpc3220-uart";
133 reg = <0x40090000 0x1000>;
134 interrupts = <9 0>;
135 clock-frequency = <13000000>;
136 reg-shift = <2>;
137 status = "disabled";
138 };
139
127 uart3: serial@40080000 { 140 uart3: serial@40080000 {
128 compatible = "nxp,serial"; 141 compatible = "nxp,lpc3220-uart";
129 reg = <0x40080000 0x1000>; 142 reg = <0x40080000 0x1000>;
143 interrupts = <7 0>;
144 clock-frequency = <13000000>;
145 reg-shift = <2>;
146 status = "disabled";
130 }; 147 };
131 148
132 uart4: serial@40088000 { 149 uart4: serial@40088000 {
133 compatible = "nxp,serial"; 150 compatible = "nxp,lpc3220-uart";
134 reg = <0x40088000 0x1000>; 151 reg = <0x40088000 0x1000>;
135 }; 152 interrupts = <8 0>;
136 153 clock-frequency = <13000000>;
137 uart5: serial@40090000 { 154 reg-shift = <2>;
138 compatible = "nxp,serial"; 155 status = "disabled";
139 reg = <0x40090000 0x1000>;
140 }; 156 };
141 157
142 uart6: serial@40098000 { 158 uart6: serial@40098000 {
143 compatible = "nxp,serial"; 159 compatible = "nxp,lpc3220-uart";
144 reg = <0x40098000 0x1000>; 160 reg = <0x40098000 0x1000>;
161 interrupts = <10 0>;
162 clock-frequency = <13000000>;
163 reg-shift = <2>;
164 status = "disabled";
145 }; 165 };
146 166
147 i2c1: i2c@400A0000 { 167 i2c1: i2c@400A0000 {
@@ -192,18 +212,24 @@
192 }; 212 };
193 213
194 uart1: serial@40014000 { 214 uart1: serial@40014000 {
195 compatible = "nxp,serial"; 215 compatible = "nxp,lpc3220-hsuart";
196 reg = <0x40014000 0x1000>; 216 reg = <0x40014000 0x1000>;
217 interrupts = <26 0>;
218 status = "disabled";
197 }; 219 };
198 220
199 uart2: serial@40018000 { 221 uart2: serial@40018000 {
200 compatible = "nxp,serial"; 222 compatible = "nxp,lpc3220-hsuart";
201 reg = <0x40018000 0x1000>; 223 reg = <0x40018000 0x1000>;
224 interrupts = <25 0>;
225 status = "disabled";
202 }; 226 };
203 227
204 uart7: serial@4001C000 { 228 uart7: serial@4001c000 {
205 compatible = "nxp,serial"; 229 compatible = "nxp,lpc3220-hsuart";
206 reg = <0x4001C000 0x1000>; 230 reg = <0x4001c000 0x1000>;
231 interrupts = <24 0>;
232 status = "disabled";
207 }; 233 };
208 234
209 rtc@40024000 { 235 rtc@40024000 {
@@ -235,21 +261,28 @@
235 compatible = "nxp,lpc3220-adc"; 261 compatible = "nxp,lpc3220-adc";
236 reg = <0x40048000 0x1000>; 262 reg = <0x40048000 0x1000>;
237 interrupts = <0x27 0>; 263 interrupts = <0x27 0>;
238 status = "disable"; 264 status = "disabled";
239 }; 265 };
240 266
241 tsc@40048000 { 267 tsc@40048000 {
242 compatible = "nxp,lpc3220-tsc"; 268 compatible = "nxp,lpc3220-tsc";
243 reg = <0x40048000 0x1000>; 269 reg = <0x40048000 0x1000>;
244 interrupts = <0x27 0>; 270 interrupts = <0x27 0>;
245 status = "disable"; 271 status = "disabled";
246 }; 272 };
247 273
248 key@40050000 { 274 key@40050000 {
249 compatible = "nxp,lpc3220-key"; 275 compatible = "nxp,lpc3220-key";
250 reg = <0x40050000 0x1000>; 276 reg = <0x40050000 0x1000>;
277 interrupts = <54 0>;
278 status = "disabled";
251 }; 279 };
252 280
281 pwm: pwm@4005C000 {
282 compatible = "nxp,lpc3220-pwm";
283 reg = <0x4005C000 0x8>;
284 status = "disabled";
285 };
253 }; 286 };
254 }; 287 };
255}; 288};
diff --git a/arch/arm/boot/dts/omap2420-h4.dts b/arch/arm/boot/dts/omap2420-h4.dts
new file mode 100644
index 00000000000..25b50b759de
--- /dev/null
+++ b/arch/arm/boot/dts/omap2420-h4.dts
@@ -0,0 +1,20 @@
1/*
2 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
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/dts-v1/;
9
10/include/ "omap2.dtsi"
11
12/ {
13 model = "TI OMAP2420 H4 board";
14 compatible = "ti,omap2420-h4", "ti,omap2420", "ti,omap2";
15
16 memory {
17 device_type = "memory";
18 reg = <0x80000000 0x84000000>; /* 64 MB */
19 };
20};
diff --git a/arch/arm/boot/dts/omap3-beagle.dts b/arch/arm/boot/dts/omap3-beagle.dts
index 5b4506c0a8c..cdcb98c7e07 100644
--- a/arch/arm/boot/dts/omap3-beagle.dts
+++ b/arch/arm/boot/dts/omap3-beagle.dts
@@ -61,9 +61,9 @@
61}; 61};
62 62
63&mmc2 { 63&mmc2 {
64 status = "disable"; 64 status = "disabled";
65}; 65};
66 66
67&mmc3 { 67&mmc3 {
68 status = "disable"; 68 status = "disabled";
69}; 69};
diff --git a/arch/arm/boot/dts/omap3-evm.dts b/arch/arm/boot/dts/omap3-evm.dts
index 2eee16ec59b..f349ee9182c 100644
--- a/arch/arm/boot/dts/omap3-evm.dts
+++ b/arch/arm/boot/dts/omap3-evm.dts
@@ -18,3 +18,31 @@
18 reg = <0x80000000 0x10000000>; /* 256 MB */ 18 reg = <0x80000000 0x10000000>; /* 256 MB */
19 }; 19 };
20}; 20};
21
22&i2c1 {
23 clock-frequency = <2600000>;
24
25 twl: twl@48 {
26 reg = <0x48>;
27 interrupts = <7>; /* SYS_NIRQ cascaded to intc */
28 interrupt-parent = <&intc>;
29 };
30};
31
32/include/ "twl4030.dtsi"
33
34&i2c2 {
35 clock-frequency = <400000>;
36};
37
38&i2c3 {
39 clock-frequency = <400000>;
40
41 /*
42 * TVP5146 Video decoder-in for analog input support.
43 */
44 tvp5146@5c {
45 compatible = "ti,tvp5146m2";
46 reg = <0x5c>;
47 };
48};
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 99474fa5fac..81094719820 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -215,5 +215,10 @@
215 compatible = "ti,omap3-hsmmc"; 215 compatible = "ti,omap3-hsmmc";
216 ti,hwmods = "mmc3"; 216 ti,hwmods = "mmc3";
217 }; 217 };
218
219 wdt2: wdt@48314000 {
220 compatible = "ti,omap3-wdt";
221 ti,hwmods = "wd_timer2";
222 };
218 }; 223 };
219}; 224};
diff --git a/arch/arm/boot/dts/omap4-panda.dts b/arch/arm/boot/dts/omap4-panda.dts
index 1efe0c58798..9880c12877b 100644
--- a/arch/arm/boot/dts/omap4-panda.dts
+++ b/arch/arm/boot/dts/omap4-panda.dts
@@ -32,6 +32,30 @@
32 linux,default-trigger = "mmc0"; 32 linux,default-trigger = "mmc0";
33 }; 33 };
34 }; 34 };
35
36 sound: sound {
37 compatible = "ti,abe-twl6040";
38 ti,model = "PandaBoard";
39
40 ti,mclk-freq = <38400000>;
41
42 ti,mcpdm = <&mcpdm>;
43
44 ti,twl6040 = <&twl6040>;
45
46 /* Audio routing */
47 ti,audio-routing =
48 "Headset Stereophone", "HSOL",
49 "Headset Stereophone", "HSOR",
50 "Ext Spk", "HFL",
51 "Ext Spk", "HFR",
52 "Line Out", "AUXL",
53 "Line Out", "AUXR",
54 "HSMIC", "Headset Mic",
55 "Headset Mic", "Headset Mic Bias",
56 "AFML", "Line In",
57 "AFMR", "Line In";
58 };
35}; 59};
36 60
37&i2c1 { 61&i2c1 {
@@ -43,6 +67,19 @@
43 interrupts = <0 7 4>; /* IRQ_SYS_1N cascaded to gic */ 67 interrupts = <0 7 4>; /* IRQ_SYS_1N cascaded to gic */
44 interrupt-parent = <&gic>; 68 interrupt-parent = <&gic>;
45 }; 69 };
70
71 twl6040: twl@4b {
72 compatible = "ti,twl6040";
73 reg = <0x4b>;
74 /* SPI = 0, IRQ# = 119, 4 = active high level-sensitive */
75 interrupts = <0 119 4>; /* IRQ_SYS_2N cascaded to gic */
76 interrupt-parent = <&gic>;
77 ti,audpwron-gpio = <&gpio4 31 0>; /* gpio line 127 */
78
79 vio-supply = <&v1v8>;
80 v2v1-supply = <&v2v1>;
81 enable-active-high;
82 };
46}; 83};
47 84
48/include/ "twl6030.dtsi" 85/include/ "twl6030.dtsi"
@@ -74,15 +111,15 @@
74}; 111};
75 112
76&mmc2 { 113&mmc2 {
77 status = "disable"; 114 status = "disabled";
78}; 115};
79 116
80&mmc3 { 117&mmc3 {
81 status = "disable"; 118 status = "disabled";
82}; 119};
83 120
84&mmc4 { 121&mmc4 {
85 status = "disable"; 122 status = "disabled";
86}; 123};
87 124
88&mmc5 { 125&mmc5 {
diff --git a/arch/arm/boot/dts/omap4-pandaES.dts b/arch/arm/boot/dts/omap4-pandaES.dts
new file mode 100644
index 00000000000..d4ba43a48d9
--- /dev/null
+++ b/arch/arm/boot/dts/omap4-pandaES.dts
@@ -0,0 +1,24 @@
1/*
2 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
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/include/ "omap4-panda.dts"
9
10/* Audio routing is differnet between PandaBoard4430 and PandaBoardES */
11&sound {
12 ti,model = "PandaBoardES";
13
14 /* Audio routing */
15 ti,audio-routing =
16 "Headset Stereophone", "HSOL",
17 "Headset Stereophone", "HSOR",
18 "Ext Spk", "HFL",
19 "Ext Spk", "HFR",
20 "Line Out", "AUXL",
21 "Line Out", "AUXR",
22 "AFML", "Line In",
23 "AFMR", "Line In";
24};
diff --git a/arch/arm/boot/dts/omap4-sdp.dts b/arch/arm/boot/dts/omap4-sdp.dts
index d08c4d13728..72216e932fc 100644
--- a/arch/arm/boot/dts/omap4-sdp.dts
+++ b/arch/arm/boot/dts/omap4-sdp.dts
@@ -28,6 +28,14 @@
28 regulator-boot-on; 28 regulator-boot-on;
29 }; 29 };
30 30
31 vbat: fixedregulator@2 {
32 compatible = "regulator-fixed";
33 regulator-name = "VBAT";
34 regulator-min-microvolt = <3750000>;
35 regulator-max-microvolt = <3750000>;
36 regulator-boot-on;
37 };
38
31 leds { 39 leds {
32 compatible = "gpio-leds"; 40 compatible = "gpio-leds";
33 debug0 { 41 debug0 {
@@ -70,6 +78,41 @@
70 gpios = <&gpio5 11 0>; /* 139 */ 78 gpios = <&gpio5 11 0>; /* 139 */
71 }; 79 };
72 }; 80 };
81
82 sound {
83 compatible = "ti,abe-twl6040";
84 ti,model = "SDP4430";
85
86 ti,jack-detection = <1>;
87 ti,mclk-freq = <38400000>;
88
89 ti,mcpdm = <&mcpdm>;
90 ti,dmic = <&dmic>;
91
92 ti,twl6040 = <&twl6040>;
93
94 /* Audio routing */
95 ti,audio-routing =
96 "Headset Stereophone", "HSOL",
97 "Headset Stereophone", "HSOR",
98 "Earphone Spk", "EP",
99 "Ext Spk", "HFL",
100 "Ext Spk", "HFR",
101 "Line Out", "AUXL",
102 "Line Out", "AUXR",
103 "Vibrator", "VIBRAL",
104 "Vibrator", "VIBRAR",
105 "HSMIC", "Headset Mic",
106 "Headset Mic", "Headset Mic Bias",
107 "MAINMIC", "Main Handset Mic",
108 "Main Handset Mic", "Main Mic Bias",
109 "SUBMIC", "Sub Handset Mic",
110 "Sub Handset Mic", "Main Mic Bias",
111 "AFML", "Line In",
112 "AFMR", "Line In",
113 "DMic", "Digital Mic",
114 "Digital Mic", "Digital Mic1 Bias";
115 };
73}; 116};
74 117
75&i2c1 { 118&i2c1 {
@@ -81,6 +124,31 @@
81 interrupts = <0 7 4>; /* IRQ_SYS_1N cascaded to gic */ 124 interrupts = <0 7 4>; /* IRQ_SYS_1N cascaded to gic */
82 interrupt-parent = <&gic>; 125 interrupt-parent = <&gic>;
83 }; 126 };
127
128 twl6040: twl@4b {
129 compatible = "ti,twl6040";
130 reg = <0x4b>;
131 /* SPI = 0, IRQ# = 119, 4 = active high level-sensitive */
132 interrupts = <0 119 4>; /* IRQ_SYS_2N cascaded to gic */
133 interrupt-parent = <&gic>;
134 ti,audpwron-gpio = <&gpio4 31 0>; /* gpio line 127 */
135
136 vio-supply = <&v1v8>;
137 v2v1-supply = <&v2v1>;
138 enable-active-high;
139
140 /* regulators for vibra motor */
141 vddvibl-supply = <&vbat>;
142 vddvibr-supply = <&vbat>;
143
144 vibra {
145 /* Vibra driver, motor resistance parameters */
146 ti,vibldrv-res = <8>;
147 ti,vibrdrv-res = <3>;
148 ti,viblmotor-res = <10>;
149 ti,vibrmotor-res = <10>;
150 };
151 };
84}; 152};
85 153
86/include/ "twl6030.dtsi" 154/include/ "twl6030.dtsi"
@@ -147,11 +215,11 @@
147}; 215};
148 216
149&mmc3 { 217&mmc3 {
150 status = "disable"; 218 status = "disabled";
151}; 219};
152 220
153&mmc4 { 221&mmc4 {
154 status = "disable"; 222 status = "disabled";
155}; 223};
156 224
157&mmc5 { 225&mmc5 {
diff --git a/arch/arm/boot/dts/omap4-var_som.dts b/arch/arm/boot/dts/omap4-var_som.dts
new file mode 100644
index 00000000000..6601e6af609
--- /dev/null
+++ b/arch/arm/boot/dts/omap4-var_som.dts
@@ -0,0 +1,96 @@
1/*
2 * Copyright (C) 2012 Variscite Ltd. - http://www.variscite.com
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/dts-v1/;
9
10/include/ "omap4.dtsi"
11
12/ {
13 model = "Variscite OMAP4 SOM";
14 compatible = "var,omap4-var_som", "ti,omap4430", "ti,omap4";
15
16 memory {
17 device_type = "memory";
18 reg = <0x80000000 0x40000000>; /* 1 GB */
19 };
20
21 vdd_eth: fixedregulator@0 {
22 compatible = "regulator-fixed";
23 regulator-name = "VDD_ETH";
24 regulator-min-microvolt = <3300000>;
25 regulator-max-microvolt = <3300000>;
26 enable-active-high;
27 regulator-boot-on;
28 };
29};
30
31&i2c1 {
32 clock-frequency = <400000>;
33
34 twl: twl@48 {
35 reg = <0x48>;
36 /* SPI = 0, IRQ# = 7, 4 = active high level-sensitive */
37 interrupts = <0 7 4>; /* IRQ_SYS_1N cascaded to gic */
38 interrupt-parent = <&gic>;
39 };
40};
41
42/include/ "twl6030.dtsi"
43
44&i2c2 {
45 clock-frequency = <400000>;
46};
47
48&i2c3 {
49 clock-frequency = <400000>;
50
51 /*
52 * Temperature Sensor
53 * http://www.ti.com/lit/ds/symlink/tmp105.pdf
54 */
55 tmp105@49 {
56 compatible = "ti,tmp105";
57 reg = <0x49>;
58 };
59};
60
61&i2c4 {
62 clock-frequency = <400000>;
63};
64
65&mcspi1 {
66 eth@0 {
67 compatible = "ks8851";
68 spi-max-frequency = <24000000>;
69 reg = <0>;
70 interrupt-parent = <&gpio6>;
71 interrupts = <11>; /* gpio line 171 */
72 vdd-supply = <&vdd_eth>;
73 };
74};
75
76&mmc1 {
77 vmmc-supply = <&vmmc>;
78 ti,bus-width = <8>;
79 ti,non-removable;
80};
81
82&mmc2 {
83 status = "disabled";
84};
85
86&mmc3 {
87 status = "disabled";
88};
89
90&mmc4 {
91 status = "disabled";
92};
93
94&mmc5 {
95 ti,bus-width = <4>;
96};
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 359c4979c8a..04cbbcb6ff9 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -272,5 +272,28 @@
272 ti,hwmods = "mmc5"; 272 ti,hwmods = "mmc5";
273 ti,needs-special-reset; 273 ti,needs-special-reset;
274 }; 274 };
275
276 wdt2: wdt@4a314000 {
277 compatible = "ti,omap4-wdt", "ti,omap3-wdt";
278 ti,hwmods = "wd_timer2";
279 };
280
281 mcpdm: mcpdm@40132000 {
282 compatible = "ti,omap4-mcpdm";
283 reg = <0x40132000 0x7f>, /* MPU private access */
284 <0x49032000 0x7f>; /* L3 Interconnect */
285 interrupts = <0 112 0x4>;
286 interrupt-parent = <&gic>;
287 ti,hwmods = "mcpdm";
288 };
289
290 dmic: dmic@4012e000 {
291 compatible = "ti,omap4-dmic";
292 reg = <0x4012e000 0x7f>, /* MPU private access */
293 <0x4902e000 0x7f>; /* L3 Interconnect */
294 interrupts = <0 114 0x4>;
295 interrupt-parent = <&gic>;
296 ti,hwmods = "dmic";
297 };
275 }; 298 };
276}; 299};
diff --git a/arch/arm/boot/dts/omap5-evm.dts b/arch/arm/boot/dts/omap5-evm.dts
new file mode 100644
index 00000000000..200c39ad1c8
--- /dev/null
+++ b/arch/arm/boot/dts/omap5-evm.dts
@@ -0,0 +1,20 @@
1/*
2 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
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/dts-v1/;
9
10/include/ "omap5.dtsi"
11
12/ {
13 model = "TI OMAP5 EVM board";
14 compatible = "ti,omap5-evm", "ti,omap5";
15
16 memory {
17 device_type = "memory";
18 reg = <0x80000000 0x40000000>; /* 1 GB */
19 };
20};
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
new file mode 100644
index 00000000000..57e52708374
--- /dev/null
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -0,0 +1,184 @@
1/*
2 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
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 * Based on "omap4.dtsi"
8 */
9
10/*
11 * Carveout for multimedia usecases
12 * It should be the last 48MB of the first 512MB memory part
13 * In theory, it should not even exist. That zone should be reserved
14 * dynamically during the .reserve callback.
15 */
16/memreserve/ 0x9d000000 0x03000000;
17
18/include/ "skeleton.dtsi"
19
20/ {
21 compatible = "ti,omap5";
22 interrupt-parent = <&gic>;
23
24 aliases {
25 serial0 = &uart1;
26 serial1 = &uart2;
27 serial2 = &uart3;
28 serial3 = &uart4;
29 serial4 = &uart5;
30 serial5 = &uart6;
31 };
32
33 cpus {
34 cpu@0 {
35 compatible = "arm,cortex-a15";
36 };
37 cpu@1 {
38 compatible = "arm,cortex-a15";
39 };
40 };
41
42 /*
43 * The soc node represents the soc top level view. It is uses for IPs
44 * that are not memory mapped in the MPU view or for the MPU itself.
45 */
46 soc {
47 compatible = "ti,omap-infra";
48 mpu {
49 compatible = "ti,omap5-mpu";
50 ti,hwmods = "mpu";
51 };
52 };
53
54 /*
55 * XXX: Use a flat representation of the OMAP3 interconnect.
56 * The real OMAP interconnect network is quite complex.
57 * Since that will not bring real advantage to represent that in DT for
58 * the moment, just use a fake OCP bus entry to represent the whole bus
59 * hierarchy.
60 */
61 ocp {
62 compatible = "ti,omap4-l3-noc", "simple-bus";
63 #address-cells = <1>;
64 #size-cells = <1>;
65 ranges;
66 ti,hwmods = "l3_main_1", "l3_main_2", "l3_main_3";
67
68 gic: interrupt-controller@48211000 {
69 compatible = "arm,cortex-a15-gic";
70 interrupt-controller;
71 #interrupt-cells = <3>;
72 reg = <0x48211000 0x1000>,
73 <0x48212000 0x1000>;
74 };
75
76 gpio1: gpio@4ae10000 {
77 compatible = "ti,omap4-gpio";
78 ti,hwmods = "gpio1";
79 gpio-controller;
80 #gpio-cells = <2>;
81 interrupt-controller;
82 #interrupt-cells = <1>;
83 };
84
85 gpio2: gpio@48055000 {
86 compatible = "ti,omap4-gpio";
87 ti,hwmods = "gpio2";
88 gpio-controller;
89 #gpio-cells = <2>;
90 interrupt-controller;
91 #interrupt-cells = <1>;
92 };
93
94 gpio3: gpio@48057000 {
95 compatible = "ti,omap4-gpio";
96 ti,hwmods = "gpio3";
97 gpio-controller;
98 #gpio-cells = <2>;
99 interrupt-controller;
100 #interrupt-cells = <1>;
101 };
102
103 gpio4: gpio@48059000 {
104 compatible = "ti,omap4-gpio";
105 ti,hwmods = "gpio4";
106 gpio-controller;
107 #gpio-cells = <2>;
108 interrupt-controller;
109 #interrupt-cells = <1>;
110 };
111
112 gpio5: gpio@4805b000 {
113 compatible = "ti,omap4-gpio";
114 ti,hwmods = "gpio5";
115 gpio-controller;
116 #gpio-cells = <2>;
117 interrupt-controller;
118 #interrupt-cells = <1>;
119 };
120
121 gpio6: gpio@4805d000 {
122 compatible = "ti,omap4-gpio";
123 ti,hwmods = "gpio6";
124 gpio-controller;
125 #gpio-cells = <2>;
126 interrupt-controller;
127 #interrupt-cells = <1>;
128 };
129
130 gpio7: gpio@48051000 {
131 compatible = "ti,omap4-gpio";
132 ti,hwmods = "gpio7";
133 gpio-controller;
134 #gpio-cells = <2>;
135 interrupt-controller;
136 #interrupt-cells = <1>;
137 };
138
139 gpio8: gpio@48053000 {
140 compatible = "ti,omap4-gpio";
141 ti,hwmods = "gpio8";
142 gpio-controller;
143 #gpio-cells = <2>;
144 interrupt-controller;
145 #interrupt-cells = <1>;
146 };
147
148 uart1: serial@4806a000 {
149 compatible = "ti,omap4-uart";
150 ti,hwmods = "uart1";
151 clock-frequency = <48000000>;
152 };
153
154 uart2: serial@4806c000 {
155 compatible = "ti,omap4-uart";
156 ti,hwmods = "uart2";
157 clock-frequency = <48000000>;
158 };
159
160 uart3: serial@48020000 {
161 compatible = "ti,omap4-uart";
162 ti,hwmods = "uart3";
163 clock-frequency = <48000000>;
164 };
165
166 uart4: serial@4806e000 {
167 compatible = "ti,omap4-uart";
168 ti,hwmods = "uart4";
169 clock-frequency = <48000000>;
170 };
171
172 uart5: serial@48066000 {
173 compatible = "ti,omap5-uart";
174 ti,hwmods = "uart5";
175 clock-frequency = <48000000>;
176 };
177
178 uart6: serial@48068000 {
179 compatible = "ti,omap6-uart";
180 ti,hwmods = "uart6";
181 clock-frequency = <48000000>;
182 };
183 };
184};
diff --git a/arch/arm/boot/dts/phy3250.dts b/arch/arm/boot/dts/phy3250.dts
index c4ff6d1a018..802ec5b2fd0 100644
--- a/arch/arm/boot/dts/phy3250.dts
+++ b/arch/arm/boot/dts/phy3250.dts
@@ -54,6 +54,17 @@
54 #address-cells = <1>; 54 #address-cells = <1>;
55 #size-cells = <1>; 55 #size-cells = <1>;
56 56
57 nxp,wdr-clks = <14>;
58 nxp,wwidth = <40000000>;
59 nxp,whold = <100000000>;
60 nxp,wsetup = <100000000>;
61 nxp,rdr-clks = <14>;
62 nxp,rwidth = <40000000>;
63 nxp,rhold = <66666666>;
64 nxp,rsetup = <100000000>;
65 nand-on-flash-bbt;
66 gpios = <&gpio 5 19 1>; /* GPO_P3 19, active low */
67
57 mtd0@00000000 { 68 mtd0@00000000 {
58 label = "phy3250-boot"; 69 label = "phy3250-boot";
59 reg = <0x00000000 0x00064000>; 70 reg = <0x00000000 0x00064000>;
@@ -83,6 +94,14 @@
83 }; 94 };
84 95
85 apb { 96 apb {
97 uart5: serial@40090000 {
98 status = "okay";
99 };
100
101 uart3: serial@40080000 {
102 status = "okay";
103 };
104
86 i2c1: i2c@400A0000 { 105 i2c1: i2c@400A0000 {
87 clock-frequency = <100000>; 106 clock-frequency = <100000>;
88 107
@@ -114,16 +133,58 @@
114 }; 133 };
115 134
116 ssp0: ssp@20084000 { 135 ssp0: ssp@20084000 {
136 #address-cells = <1>;
137 #size-cells = <0>;
138 pl022,num-chipselects = <1>;
139 cs-gpios = <&gpio 3 5 0>;
140
117 eeprom: at25@0 { 141 eeprom: at25@0 {
142 pl022,hierarchy = <0>;
143 pl022,interface = <0>;
144 pl022,slave-tx-disable = <0>;
145 pl022,com-mode = <0>;
146 pl022,rx-level-trig = <1>;
147 pl022,tx-level-trig = <1>;
148 pl022,ctrl-len = <11>;
149 pl022,wait-state = <0>;
150 pl022,duplex = <0>;
151
152 at25,byte-len = <0x8000>;
153 at25,addr-mode = <2>;
154 at25,page-size = <64>;
155
118 compatible = "atmel,at25"; 156 compatible = "atmel,at25";
157 reg = <0>;
158 spi-max-frequency = <5000000>;
119 }; 159 };
120 }; 160 };
161
162 sd@20098000 {
163 wp-gpios = <&gpio 3 0 0>;
164 cd-gpios = <&gpio 3 1 0>;
165 cd-inverted;
166 bus-width = <4>;
167 status = "okay";
168 };
121 }; 169 };
122 170
123 fab { 171 fab {
172 uart2: serial@40018000 {
173 status = "okay";
174 };
175
124 tsc@40048000 { 176 tsc@40048000 {
125 status = "okay"; 177 status = "okay";
126 }; 178 };
179
180 key@40050000 {
181 status = "okay";
182 keypad,num-rows = <1>;
183 keypad,num-columns = <1>;
184 nxp,debounce-delay-ms = <3>;
185 nxp,scan-delay-ms = <34>;
186 linux,keymap = <0x00000002>;
187 };
127 }; 188 };
128 }; 189 };
129 190
diff --git a/arch/arm/boot/dts/r8a7740.dtsi b/arch/arm/boot/dts/r8a7740.dtsi
new file mode 100644
index 00000000000..798fa35c000
--- /dev/null
+++ b/arch/arm/boot/dts/r8a7740.dtsi
@@ -0,0 +1,21 @@
1/*
2 * Device Tree Source for the r8a7740 SoC
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp.
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/include/ "skeleton.dtsi"
12
13/ {
14 compatible = "renesas,r8a7740";
15
16 cpus {
17 cpu@0 {
18 compatible = "arm,cortex-a9";
19 };
20 };
21};
diff --git a/arch/arm/boot/dts/sh7377.dtsi b/arch/arm/boot/dts/sh7377.dtsi
new file mode 100644
index 00000000000..767ee0796da
--- /dev/null
+++ b/arch/arm/boot/dts/sh7377.dtsi
@@ -0,0 +1,21 @@
1/*
2 * Device Tree Source for the sh7377 SoC
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp.
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/include/ "skeleton.dtsi"
12
13/ {
14 compatible = "renesas,sh7377";
15
16 cpus {
17 cpu@0 {
18 compatible = "arm,cortex-a8";
19 };
20 };
21};
diff --git a/arch/arm/boot/dts/snowball.dts b/arch/arm/boot/dts/snowball.dts
index ec3c3397511..7e334d4cae2 100644
--- a/arch/arm/boot/dts/snowball.dts
+++ b/arch/arm/boot/dts/snowball.dts
@@ -77,6 +77,8 @@
77 used-led { 77 used-led {
78 label = "user_led"; 78 label = "user_led";
79 gpios = <&gpio4 14 0x4>; 79 gpios = <&gpio4 14 0x4>;
80 default-state = "on";
81 linux,default-trigger = "heartbeat";
80 }; 82 };
81 }; 83 };
82 84
@@ -101,15 +103,30 @@
101 }; 103 };
102 }; 104 };
103 105
106 // External Micro SD slot
104 sdi@80126000 { 107 sdi@80126000 {
105 status = "enabled"; 108 arm,primecell-periphid = <0x10480180>;
109 max-frequency = <50000000>;
110 bus-width = <8>;
111 mmc-cap-mmc-highspeed;
106 vmmc-supply = <&ab8500_ldo_aux3_reg>; 112 vmmc-supply = <&ab8500_ldo_aux3_reg>;
113
114 #gpio-cells = <1>;
107 cd-gpios = <&gpio6 26 0x4>; // 218 115 cd-gpios = <&gpio6 26 0x4>; // 218
116 cd-inverted;
117
118 status = "okay";
108 }; 119 };
109 120
121 // On-board eMMC
110 sdi@80114000 { 122 sdi@80114000 {
111 status = "enabled"; 123 arm,primecell-periphid = <0x10480180>;
124 max-frequency = <50000000>;
125 bus-width = <8>;
126 mmc-cap-mmc-highspeed;
112 vmmc-supply = <&ab8500_ldo_aux2_reg>; 127 vmmc-supply = <&ab8500_ldo_aux2_reg>;
128
129 status = "okay";
113 }; 130 };
114 131
115 uart@80120000 { 132 uart@80120000 {
diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi
new file mode 100644
index 00000000000..0772f5739f5
--- /dev/null
+++ b/arch/arm/boot/dts/socfpga.dtsi
@@ -0,0 +1,147 @@
1/*
2 * Copyright (C) 2012 Altera <www.altera.com>
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 as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/include/ "skeleton.dtsi"
19
20/ {
21 #address-cells = <1>;
22 #size-cells = <1>;
23
24 aliases {
25 ethernet0 = &gmac0;
26 serial0 = &uart0;
27 serial1 = &uart1;
28 };
29
30 cpus {
31 #address-cells = <1>;
32 #size-cells = <0>;
33
34 cpu@0 {
35 compatible = "arm,cortex-a9";
36 device_type = "cpu";
37 reg = <0>;
38 next-level-cache = <&L2>;
39 };
40 cpu@1 {
41 compatible = "arm,cortex-a9";
42 device_type = "cpu";
43 reg = <1>;
44 next-level-cache = <&L2>;
45 };
46 };
47
48 intc: intc@fffed000 {
49 compatible = "arm,cortex-a9-gic";
50 #interrupt-cells = <3>;
51 interrupt-controller;
52 reg = <0xfffed000 0x1000>,
53 <0xfffec100 0x100>;
54 };
55
56 soc {
57 #address-cells = <1>;
58 #size-cells = <1>;
59 compatible = "simple-bus";
60 device_type = "soc";
61 interrupt-parent = <&intc>;
62 ranges;
63
64 amba {
65 compatible = "arm,amba-bus";
66 #address-cells = <1>;
67 #size-cells = <1>;
68 ranges;
69
70 pdma: pdma@ffe01000 {
71 compatible = "arm,pl330", "arm,primecell";
72 reg = <0xffe01000 0x1000>;
73 interrupts = <0 180 4>;
74 };
75 };
76
77 gmac0: stmmac@ff700000 {
78 compatible = "altr,socfpga-stmmac", "snps,dwmac-3.70a", "snps,dwmac";
79 reg = <0xff700000 0x2000>;
80 interrupts = <0 115 4>;
81 interrupt-names = "macirq";
82 mac-address = [00 00 00 00 00 00];/* Filled in by U-Boot */
83 phy-mode = "gmii";
84 };
85
86 L2: l2-cache@fffef000 {
87 compatible = "arm,pl310-cache";
88 reg = <0xfffef000 0x1000>;
89 interrupts = <0 38 0x04>;
90 cache-unified;
91 cache-level = <2>;
92 };
93
94 /* Local timer */
95 timer@fffec600 {
96 compatible = "arm,cortex-a9-twd-timer";
97 reg = <0xfffec600 0x100>;
98 interrupts = <1 13 0xf04>;
99 };
100
101 timer0: timer@ffc08000 {
102 compatible = "snps,dw-apb-timer-sp";
103 interrupts = <0 167 4>;
104 clock-frequency = <200000000>;
105 reg = <0xffc08000 0x1000>;
106 };
107
108 timer1: timer@ffc09000 {
109 compatible = "snps,dw-apb-timer-sp";
110 interrupts = <0 168 4>;
111 clock-frequency = <200000000>;
112 reg = <0xffc09000 0x1000>;
113 };
114
115 timer2: timer@ffd00000 {
116 compatible = "snps,dw-apb-timer-osc";
117 interrupts = <0 169 4>;
118 clock-frequency = <200000000>;
119 reg = <0xffd00000 0x1000>;
120 };
121
122 timer3: timer@ffd01000 {
123 compatible = "snps,dw-apb-timer-osc";
124 interrupts = <0 170 4>;
125 clock-frequency = <200000000>;
126 reg = <0xffd01000 0x1000>;
127 };
128
129 uart0: uart@ffc02000 {
130 compatible = "snps,dw-apb-uart";
131 reg = <0xffc02000 0x1000>;
132 clock-frequency = <7372800>;
133 interrupts = <0 162 4>;
134 reg-shift = <2>;
135 reg-io-width = <4>;
136 };
137
138 uart1: uart@ffc03000 {
139 compatible = "snps,dw-apb-uart";
140 reg = <0xffc03000 0x1000>;
141 clock-frequency = <7372800>;
142 interrupts = <0 163 4>;
143 reg-shift = <2>;
144 reg-io-width = <4>;
145 };
146 };
147};
diff --git a/arch/arm/boot/dts/socfpga_cyclone5.dts b/arch/arm/boot/dts/socfpga_cyclone5.dts
new file mode 100644
index 00000000000..ab7e4a94299
--- /dev/null
+++ b/arch/arm/boot/dts/socfpga_cyclone5.dts
@@ -0,0 +1,34 @@
1/*
2 * Copyright (C) 2012 Altera Corporation <www.altera.com>
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 as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/dts-v1/;
19/include/ "socfpga.dtsi"
20
21/ {
22 model = "Altera SOCFPGA Cyclone V";
23 compatible = "altr,socfpga-cyclone5";
24
25 chosen {
26 bootargs = "console=ttyS0,57600";
27 };
28
29 memory {
30 name = "memory";
31 device_type = "memory";
32 reg = <0x0 0x10000000>; /* 256MB */
33 };
34};
diff --git a/arch/arm/boot/dts/tegra-harmony.dts b/arch/arm/boot/dts/tegra20-harmony.dts
index 7de701365fc..f146dbf6f7f 100644
--- a/arch/arm/boot/dts/tegra-harmony.dts
+++ b/arch/arm/boot/dts/tegra20-harmony.dts
@@ -307,7 +307,6 @@
307 cd-gpios = <&gpio 58 0>; /* gpio PH2 */ 307 cd-gpios = <&gpio 58 0>; /* gpio PH2 */
308 wp-gpios = <&gpio 59 0>; /* gpio PH3 */ 308 wp-gpios = <&gpio 59 0>; /* gpio PH3 */
309 power-gpios = <&gpio 70 0>; /* gpio PI6 */ 309 power-gpios = <&gpio 70 0>; /* gpio PI6 */
310 support-8bit;
311 bus-width = <8>; 310 bus-width = <8>;
312 }; 311 };
313 312
diff --git a/arch/arm/boot/dts/tegra-paz00.dts b/arch/arm/boot/dts/tegra20-paz00.dts
index bfeb117d5ae..684a9e1ff7e 100644
--- a/arch/arm/boot/dts/tegra-paz00.dts
+++ b/arch/arm/boot/dts/tegra20-paz00.dts
@@ -301,7 +301,6 @@
301 301
302 sdhci@c8000600 { 302 sdhci@c8000600 {
303 status = "okay"; 303 status = "okay";
304 support-8bit;
305 bus-width = <8>; 304 bus-width = <8>;
306 }; 305 };
307 306
diff --git a/arch/arm/boot/dts/tegra-seaboard.dts b/arch/arm/boot/dts/tegra20-seaboard.dts
index 89cb7f2acd9..85e621ab296 100644
--- a/arch/arm/boot/dts/tegra-seaboard.dts
+++ b/arch/arm/boot/dts/tegra20-seaboard.dts
@@ -64,11 +64,6 @@
64 nvidia,pins = "dap4"; 64 nvidia,pins = "dap4";
65 nvidia,function = "dap4"; 65 nvidia,function = "dap4";
66 }; 66 };
67 ddc {
68 nvidia,pins = "ddc", "owc", "spdi", "spdo",
69 "uac";
70 nvidia,function = "rsvd2";
71 };
72 dta { 67 dta {
73 nvidia,pins = "dta", "dtb", "dtc", "dtd", "dte"; 68 nvidia,pins = "dta", "dtb", "dtc", "dtd", "dte";
74 nvidia,function = "vi"; 69 nvidia,function = "vi";
@@ -129,14 +124,14 @@
129 "lspi", "lvp1", "lvs"; 124 "lspi", "lvp1", "lvs";
130 nvidia,function = "displaya"; 125 nvidia,function = "displaya";
131 }; 126 };
127 owc {
128 nvidia,pins = "owc", "spdi", "spdo", "uac";
129 nvidia,function = "rsvd2";
130 };
132 pmc { 131 pmc {
133 nvidia,pins = "pmc"; 132 nvidia,pins = "pmc";
134 nvidia,function = "pwr_on"; 133 nvidia,function = "pwr_on";
135 }; 134 };
136 pta {
137 nvidia,pins = "pta";
138 nvidia,function = "i2c2";
139 };
140 rm { 135 rm {
141 nvidia,pins = "rm"; 136 nvidia,pins = "rm";
142 nvidia,function = "i2c1"; 137 nvidia,function = "i2c1";
@@ -176,7 +171,7 @@
176 conf_ata { 171 conf_ata {
177 nvidia,pins = "ata", "atb", "atc", "atd", 172 nvidia,pins = "ata", "atb", "atc", "atd",
178 "cdev1", "cdev2", "dap1", "dap2", 173 "cdev1", "cdev2", "dap1", "dap2",
179 "dap4", "dtf", "gma", "gmc", "gmd", 174 "dap4", "ddc", "dtf", "gma", "gmc", "gmd",
180 "gme", "gpu", "gpu7", "i2cp", "irrx", 175 "gme", "gpu", "gpu7", "i2cp", "irrx",
181 "irtx", "pta", "rm", "sdc", "sdd", 176 "irtx", "pta", "rm", "sdc", "sdd",
182 "slxd", "slxk", "spdi", "spdo", "uac", 177 "slxd", "slxk", "spdi", "spdo", "uac",
@@ -185,7 +180,7 @@
185 nvidia,tristate = <0>; 180 nvidia,tristate = <0>;
186 }; 181 };
187 conf_ate { 182 conf_ate {
188 nvidia,pins = "ate", "csus", "dap3", "ddc", 183 nvidia,pins = "ate", "csus", "dap3",
189 "gpv", "owc", "slxc", "spib", "spid", 184 "gpv", "owc", "slxc", "spib", "spid",
190 "spie"; 185 "spie";
191 nvidia,pull = <0>; 186 nvidia,pull = <0>;
@@ -255,6 +250,39 @@
255 nvidia,slew-rate-falling = <3>; 250 nvidia,slew-rate-falling = <3>;
256 }; 251 };
257 }; 252 };
253
254 state_i2cmux_ddc: pinmux_i2cmux_ddc {
255 ddc {
256 nvidia,pins = "ddc";
257 nvidia,function = "i2c2";
258 };
259 pta {
260 nvidia,pins = "pta";
261 nvidia,function = "rsvd4";
262 };
263 };
264
265 state_i2cmux_pta: pinmux_i2cmux_pta {
266 ddc {
267 nvidia,pins = "ddc";
268 nvidia,function = "rsvd4";
269 };
270 pta {
271 nvidia,pins = "pta";
272 nvidia,function = "i2c2";
273 };
274 };
275
276 state_i2cmux_idle: pinmux_i2cmux_idle {
277 ddc {
278 nvidia,pins = "ddc";
279 nvidia,function = "rsvd4";
280 };
281 pta {
282 nvidia,pins = "pta";
283 nvidia,function = "rsvd4";
284 };
285 };
258 }; 286 };
259 287
260 i2s@70002800 { 288 i2s@70002800 {
@@ -303,12 +331,37 @@
303 i2c@7000c400 { 331 i2c@7000c400 {
304 status = "okay"; 332 status = "okay";
305 clock-frequency = <100000>; 333 clock-frequency = <100000>;
334 };
335
336 i2cmux {
337 compatible = "i2c-mux-pinctrl";
338 #address-cells = <1>;
339 #size-cells = <0>;
340
341 i2c-parent = <&{/i2c@7000c400}>;
306 342
307 smart-battery@b { 343 pinctrl-names = "ddc", "pta", "idle";
308 compatible = "ti,bq20z75", "smart-battery-1.1"; 344 pinctrl-0 = <&state_i2cmux_ddc>;
309 reg = <0xb>; 345 pinctrl-1 = <&state_i2cmux_pta>;
310 ti,i2c-retry-count = <2>; 346 pinctrl-2 = <&state_i2cmux_idle>;
311 ti,poll-retry-count = <10>; 347
348 i2c@0 {
349 reg = <0>;
350 #address-cells = <1>;
351 #size-cells = <0>;
352 };
353
354 i2c@1 {
355 reg = <1>;
356 #address-cells = <1>;
357 #size-cells = <0>;
358
359 smart-battery@b {
360 compatible = "ti,bq20z75", "smart-battery-1.1";
361 reg = <0xb>;
362 ti,i2c-retry-count = <2>;
363 ti,poll-retry-count = <10>;
364 };
312 }; 365 };
313 }; 366 };
314 367
@@ -334,7 +387,7 @@
334 }; 387 };
335 }; 388 };
336 389
337 emc { 390 memory-controller@0x7000f400 {
338 emc-table@190000 { 391 emc-table@190000 {
339 reg = <190000>; 392 reg = <190000>;
340 compatible = "nvidia,tegra20-emc-table"; 393 compatible = "nvidia,tegra20-emc-table";
@@ -397,7 +450,6 @@
397 450
398 sdhci@c8000600 { 451 sdhci@c8000600 {
399 status = "okay"; 452 status = "okay";
400 support-8bit;
401 bus-width = <8>; 453 bus-width = <8>;
402 }; 454 };
403 455
diff --git a/arch/arm/boot/dts/tegra-trimslice.dts b/arch/arm/boot/dts/tegra20-trimslice.dts
index 9de5636023f..27fb8a67ea4 100644
--- a/arch/arm/boot/dts/tegra-trimslice.dts
+++ b/arch/arm/boot/dts/tegra20-trimslice.dts
@@ -276,9 +276,11 @@
276 276
277 usb@c5000000 { 277 usb@c5000000 {
278 status = "okay"; 278 status = "okay";
279 nvidia,vbus-gpio = <&gpio 170 0>; /* gpio PV2 */
279 }; 280 };
280 281
281 usb@c5004000 { 282 usb@c5004000 {
283 status = "okay";
282 nvidia,phy-reset-gpio = <&gpio 168 0>; /* gpio PV0 */ 284 nvidia,phy-reset-gpio = <&gpio 168 0>; /* gpio PV0 */
283 }; 285 };
284 286
diff --git a/arch/arm/boot/dts/tegra-ventana.dts b/arch/arm/boot/dts/tegra20-ventana.dts
index 445343b0fbd..be90544e6b5 100644
--- a/arch/arm/boot/dts/tegra-ventana.dts
+++ b/arch/arm/boot/dts/tegra20-ventana.dts
@@ -314,7 +314,6 @@
314 314
315 sdhci@c8000600 { 315 sdhci@c8000600 {
316 status = "okay"; 316 status = "okay";
317 support-8bit;
318 bus-width = <8>; 317 bus-width = <8>;
319 }; 318 };
320 319
diff --git a/arch/arm/boot/dts/tegra20-whistler.dts b/arch/arm/boot/dts/tegra20-whistler.dts
new file mode 100644
index 00000000000..6916310bf58
--- /dev/null
+++ b/arch/arm/boot/dts/tegra20-whistler.dts
@@ -0,0 +1,301 @@
1/dts-v1/;
2
3/include/ "tegra20.dtsi"
4
5/ {
6 model = "NVIDIA Tegra2 Whistler evaluation board";
7 compatible = "nvidia,whistler", "nvidia,tegra20";
8
9 memory {
10 reg = <0x00000000 0x20000000>;
11 };
12
13 pinmux {
14 pinctrl-names = "default";
15 pinctrl-0 = <&state_default>;
16
17 state_default: pinmux {
18 ata {
19 nvidia,pins = "ata", "atb", "ate", "gma", "gmb",
20 "gmc", "gmd", "gpu";
21 nvidia,function = "gmi";
22 };
23 atc {
24 nvidia,pins = "atc", "atd";
25 nvidia,function = "sdio4";
26 };
27 cdev1 {
28 nvidia,pins = "cdev1";
29 nvidia,function = "plla_out";
30 };
31 cdev2 {
32 nvidia,pins = "cdev2";
33 nvidia,function = "osc";
34 };
35 crtp {
36 nvidia,pins = "crtp";
37 nvidia,function = "crt";
38 };
39 csus {
40 nvidia,pins = "csus";
41 nvidia,function = "vi_sensor_clk";
42 };
43 dap1 {
44 nvidia,pins = "dap1";
45 nvidia,function = "dap1";
46 };
47 dap2 {
48 nvidia,pins = "dap2";
49 nvidia,function = "dap2";
50 };
51 dap3 {
52 nvidia,pins = "dap3";
53 nvidia,function = "dap3";
54 };
55 dap4 {
56 nvidia,pins = "dap4";
57 nvidia,function = "dap4";
58 };
59 ddc {
60 nvidia,pins = "ddc";
61 nvidia,function = "i2c2";
62 };
63 dta {
64 nvidia,pins = "dta", "dtb", "dtc", "dtd";
65 nvidia,function = "vi";
66 };
67 dte {
68 nvidia,pins = "dte";
69 nvidia,function = "rsvd1";
70 };
71 dtf {
72 nvidia,pins = "dtf";
73 nvidia,function = "i2c3";
74 };
75 gme {
76 nvidia,pins = "gme";
77 nvidia,function = "dap5";
78 };
79 gpu7 {
80 nvidia,pins = "gpu7";
81 nvidia,function = "rtck";
82 };
83 gpv {
84 nvidia,pins = "gpv";
85 nvidia,function = "pcie";
86 };
87 hdint {
88 nvidia,pins = "hdint", "pta";
89 nvidia,function = "hdmi";
90 };
91 i2cp {
92 nvidia,pins = "i2cp";
93 nvidia,function = "i2cp";
94 };
95 irrx {
96 nvidia,pins = "irrx", "irtx";
97 nvidia,function = "uartb";
98 };
99 kbca {
100 nvidia,pins = "kbca", "kbcc", "kbce", "kbcf";
101 nvidia,function = "kbc";
102 };
103 kbcb {
104 nvidia,pins = "kbcb", "kbcd";
105 nvidia,function = "sdio2";
106 };
107 lcsn {
108 nvidia,pins = "lcsn", "lsck", "lsda", "lsdi",
109 "spia", "spib", "spic";
110 nvidia,function = "spi3";
111 };
112 ld0 {
113 nvidia,pins = "ld0", "ld1", "ld2", "ld3", "ld4",
114 "ld5", "ld6", "ld7", "ld8", "ld9",
115 "ld10", "ld11", "ld12", "ld13", "ld14",
116 "ld15", "ld16", "ld17", "ldc", "ldi",
117 "lhp0", "lhp1", "lhp2", "lhs", "lm0",
118 "lm1", "lpp", "lpw0", "lpw1", "lpw2",
119 "lsc0", "lsc1", "lspi", "lvp0", "lvp1",
120 "lvs";
121 nvidia,function = "displaya";
122 };
123 owc {
124 nvidia,pins = "owc", "uac";
125 nvidia,function = "owr";
126 };
127 pmc {
128 nvidia,pins = "pmc";
129 nvidia,function = "pwr_on";
130 };
131 rm {
132 nvidia,pins = "rm";
133 nvidia,function = "i2c1";
134 };
135 sdb {
136 nvidia,pins = "sdb", "sdc", "sdd", "slxa",
137 "slxc", "slxd", "slxk";
138 nvidia,function = "sdio3";
139 };
140 sdio1 {
141 nvidia,pins = "sdio1";
142 nvidia,function = "sdio1";
143 };
144 spdi {
145 nvidia,pins = "spdi", "spdo";
146 nvidia,function = "rsvd2";
147 };
148 spid {
149 nvidia,pins = "spid", "spie", "spig", "spih";
150 nvidia,function = "spi2_alt";
151 };
152 spif {
153 nvidia,pins = "spif";
154 nvidia,function = "spi2";
155 };
156 uaa {
157 nvidia,pins = "uaa", "uab";
158 nvidia,function = "uarta";
159 };
160 uad {
161 nvidia,pins = "uad";
162 nvidia,function = "irda";
163 };
164 uca {
165 nvidia,pins = "uca", "ucb";
166 nvidia,function = "uartc";
167 };
168 uda {
169 nvidia,pins = "uda";
170 nvidia,function = "spi1";
171 };
172 conf_ata {
173 nvidia,pins = "ata", "atb", "atc", "ddc", "gma",
174 "gmb", "gmc", "gmd", "irrx", "irtx",
175 "kbca", "kbcb", "kbcc", "kbcd", "kbce",
176 "kbcf", "sdc", "sdd", "spie", "spig",
177 "spih", "uaa", "uab", "uad", "uca",
178 "ucb";
179 nvidia,pull = <2>;
180 nvidia,tristate = <0>;
181 };
182 conf_atd {
183 nvidia,pins = "atd", "ate", "cdev1", "csus",
184 "dap1", "dap2", "dap3", "dap4", "dte",
185 "dtf", "gpu", "gpu7", "gpv", "i2cp",
186 "rm", "sdio1", "slxa", "slxc", "slxd",
187 "slxk", "spdi", "spdo", "uac", "uda";
188 nvidia,pull = <0>;
189 nvidia,tristate = <0>;
190 };
191 conf_cdev2 {
192 nvidia,pins = "cdev2", "spia", "spib";
193 nvidia,pull = <1>;
194 nvidia,tristate = <1>;
195 };
196 conf_ck32 {
197 nvidia,pins = "ck32", "ddrc", "lc", "pmca",
198 "pmcb", "pmcc", "pmcd", "xm2c",
199 "xm2d";
200 nvidia,pull = <0>;
201 };
202 conf_crtp {
203 nvidia,pins = "crtp";
204 nvidia,pull = <0>;
205 nvidia,tristate = <1>;
206 };
207 conf_dta {
208 nvidia,pins = "dta", "dtb", "dtc", "dtd",
209 "spid", "spif";
210 nvidia,pull = <1>;
211 nvidia,tristate = <0>;
212 };
213 conf_gme {
214 nvidia,pins = "gme", "owc", "pta", "spic";
215 nvidia,pull = <2>;
216 nvidia,tristate = <1>;
217 };
218 conf_ld17_0 {
219 nvidia,pins = "ld17_0", "ld19_18", "ld21_20",
220 "ld23_22";
221 nvidia,pull = <1>;
222 };
223 conf_ls {
224 nvidia,pins = "ls", "pmce";
225 nvidia,pull = <2>;
226 };
227 drive_dap1 {
228 nvidia,pins = "drive_dap1";
229 nvidia,high-speed-mode = <0>;
230 nvidia,schmitt = <1>;
231 nvidia,low-power-mode = <0>;
232 nvidia,pull-down-strength = <0>;
233 nvidia,pull-up-strength = <0>;
234 nvidia,slew-rate-rising = <0>;
235 nvidia,slew-rate-falling = <0>;
236 };
237 };
238 };
239
240 i2s@70002800 {
241 status = "okay";
242 };
243
244 serial@70006000 {
245 status = "okay";
246 clock-frequency = <216000000>;
247 };
248
249 i2c@7000d000 {
250 status = "okay";
251 clock-frequency = <100000>;
252
253 codec: codec@1a {
254 compatible = "wlf,wm8753";
255 reg = <0x1a>;
256 };
257
258 tca6416: gpio@20 {
259 compatible = "ti,tca6416";
260 reg = <0x20>;
261 gpio-controller;
262 #gpio-cells = <2>;
263 };
264 };
265
266 usb@c5000000 {
267 status = "okay";
268 nvidia,vbus-gpio = <&tca6416 0 0>; /* GPIO_PMU0 */
269 };
270
271 usb@c5008000 {
272 status = "okay";
273 nvidia,vbus-gpio = <&tca6416 1 0>; /* GPIO_PMU1 */
274 };
275
276 sdhci@c8000400 {
277 status = "okay";
278 wp-gpios = <&gpio 173 0>; /* gpio PV5 */
279 bus-width = <8>;
280 };
281
282 sdhci@c8000600 {
283 status = "okay";
284 bus-width = <8>;
285 };
286
287 sound {
288 compatible = "nvidia,tegra-audio-wm8753-whistler",
289 "nvidia,tegra-audio-wm8753";
290 nvidia,model = "NVIDIA Tegra Whistler";
291
292 nvidia,audio-routing =
293 "Headphone Jack", "LOUT1",
294 "Headphone Jack", "ROUT1",
295 "MIC2", "Mic Jack",
296 "MIC2N", "Mic Jack";
297
298 nvidia,i2s-controller = <&tegra_i2s1>;
299 nvidia,audio-codec = <&codec>;
300 };
301};
diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
index c417d67e902..405d1673904 100644
--- a/arch/arm/boot/dts/tegra20.dtsi
+++ b/arch/arm/boot/dts/tegra20.dtsi
@@ -72,7 +72,7 @@
72 reg = <0x70002800 0x200>; 72 reg = <0x70002800 0x200>;
73 interrupts = <0 13 0x04>; 73 interrupts = <0 13 0x04>;
74 nvidia,dma-request-selector = <&apbdma 2>; 74 nvidia,dma-request-selector = <&apbdma 2>;
75 status = "disable"; 75 status = "disabled";
76 }; 76 };
77 77
78 tegra_i2s2: i2s@70002a00 { 78 tegra_i2s2: i2s@70002a00 {
@@ -80,7 +80,7 @@
80 reg = <0x70002a00 0x200>; 80 reg = <0x70002a00 0x200>;
81 interrupts = <0 3 0x04>; 81 interrupts = <0 3 0x04>;
82 nvidia,dma-request-selector = <&apbdma 1>; 82 nvidia,dma-request-selector = <&apbdma 1>;
83 status = "disable"; 83 status = "disabled";
84 }; 84 };
85 85
86 serial@70006000 { 86 serial@70006000 {
@@ -88,7 +88,7 @@
88 reg = <0x70006000 0x40>; 88 reg = <0x70006000 0x40>;
89 reg-shift = <2>; 89 reg-shift = <2>;
90 interrupts = <0 36 0x04>; 90 interrupts = <0 36 0x04>;
91 status = "disable"; 91 status = "disabled";
92 }; 92 };
93 93
94 serial@70006040 { 94 serial@70006040 {
@@ -96,7 +96,7 @@
96 reg = <0x70006040 0x40>; 96 reg = <0x70006040 0x40>;
97 reg-shift = <2>; 97 reg-shift = <2>;
98 interrupts = <0 37 0x04>; 98 interrupts = <0 37 0x04>;
99 status = "disable"; 99 status = "disabled";
100 }; 100 };
101 101
102 serial@70006200 { 102 serial@70006200 {
@@ -104,7 +104,7 @@
104 reg = <0x70006200 0x100>; 104 reg = <0x70006200 0x100>;
105 reg-shift = <2>; 105 reg-shift = <2>;
106 interrupts = <0 46 0x04>; 106 interrupts = <0 46 0x04>;
107 status = "disable"; 107 status = "disabled";
108 }; 108 };
109 109
110 serial@70006300 { 110 serial@70006300 {
@@ -112,7 +112,7 @@
112 reg = <0x70006300 0x100>; 112 reg = <0x70006300 0x100>;
113 reg-shift = <2>; 113 reg-shift = <2>;
114 interrupts = <0 90 0x04>; 114 interrupts = <0 90 0x04>;
115 status = "disable"; 115 status = "disabled";
116 }; 116 };
117 117
118 serial@70006400 { 118 serial@70006400 {
@@ -120,7 +120,13 @@
120 reg = <0x70006400 0x100>; 120 reg = <0x70006400 0x100>;
121 reg-shift = <2>; 121 reg-shift = <2>;
122 interrupts = <0 91 0x04>; 122 interrupts = <0 91 0x04>;
123 status = "disable"; 123 status = "disabled";
124 };
125
126 pwm {
127 compatible = "nvidia,tegra20-pwm";
128 reg = <0x7000a000 0x100>;
129 #pwm-cells = <2>;
124 }; 130 };
125 131
126 i2c@7000c000 { 132 i2c@7000c000 {
@@ -129,7 +135,7 @@
129 interrupts = <0 38 0x04>; 135 interrupts = <0 38 0x04>;
130 #address-cells = <1>; 136 #address-cells = <1>;
131 #size-cells = <0>; 137 #size-cells = <0>;
132 status = "disable"; 138 status = "disabled";
133 }; 139 };
134 140
135 i2c@7000c400 { 141 i2c@7000c400 {
@@ -138,7 +144,7 @@
138 interrupts = <0 84 0x04>; 144 interrupts = <0 84 0x04>;
139 #address-cells = <1>; 145 #address-cells = <1>;
140 #size-cells = <0>; 146 #size-cells = <0>;
141 status = "disable"; 147 status = "disabled";
142 }; 148 };
143 149
144 i2c@7000c500 { 150 i2c@7000c500 {
@@ -147,7 +153,7 @@
147 interrupts = <0 92 0x04>; 153 interrupts = <0 92 0x04>;
148 #address-cells = <1>; 154 #address-cells = <1>;
149 #size-cells = <0>; 155 #size-cells = <0>;
150 status = "disable"; 156 status = "disabled";
151 }; 157 };
152 158
153 i2c@7000d000 { 159 i2c@7000d000 {
@@ -156,7 +162,7 @@
156 interrupts = <0 53 0x04>; 162 interrupts = <0 53 0x04>;
157 #address-cells = <1>; 163 #address-cells = <1>;
158 #size-cells = <0>; 164 #size-cells = <0>;
159 status = "disable"; 165 status = "disabled";
160 }; 166 };
161 167
162 pmc { 168 pmc {
@@ -164,7 +170,7 @@
164 reg = <0x7000e400 0x400>; 170 reg = <0x7000e400 0x400>;
165 }; 171 };
166 172
167 mc { 173 memory-controller@0x7000f000 {
168 compatible = "nvidia,tegra20-mc"; 174 compatible = "nvidia,tegra20-mc";
169 reg = <0x7000f000 0x024 175 reg = <0x7000f000 0x024
170 0x7000f03c 0x3c4>; 176 0x7000f03c 0x3c4>;
@@ -177,7 +183,7 @@
177 0x58000000 0x02000000>; /* GART aperture */ 183 0x58000000 0x02000000>; /* GART aperture */
178 }; 184 };
179 185
180 emc { 186 memory-controller@0x7000f400 {
181 compatible = "nvidia,tegra20-emc"; 187 compatible = "nvidia,tegra20-emc";
182 reg = <0x7000f400 0x200>; 188 reg = <0x7000f400 0x200>;
183 #address-cells = <1>; 189 #address-cells = <1>;
@@ -190,7 +196,7 @@
190 interrupts = <0 20 0x04>; 196 interrupts = <0 20 0x04>;
191 phy_type = "utmi"; 197 phy_type = "utmi";
192 nvidia,has-legacy-mode; 198 nvidia,has-legacy-mode;
193 status = "disable"; 199 status = "disabled";
194 }; 200 };
195 201
196 usb@c5004000 { 202 usb@c5004000 {
@@ -198,7 +204,7 @@
198 reg = <0xc5004000 0x4000>; 204 reg = <0xc5004000 0x4000>;
199 interrupts = <0 21 0x04>; 205 interrupts = <0 21 0x04>;
200 phy_type = "ulpi"; 206 phy_type = "ulpi";
201 status = "disable"; 207 status = "disabled";
202 }; 208 };
203 209
204 usb@c5008000 { 210 usb@c5008000 {
@@ -206,35 +212,35 @@
206 reg = <0xc5008000 0x4000>; 212 reg = <0xc5008000 0x4000>;
207 interrupts = <0 97 0x04>; 213 interrupts = <0 97 0x04>;
208 phy_type = "utmi"; 214 phy_type = "utmi";
209 status = "disable"; 215 status = "disabled";
210 }; 216 };
211 217
212 sdhci@c8000000 { 218 sdhci@c8000000 {
213 compatible = "nvidia,tegra20-sdhci"; 219 compatible = "nvidia,tegra20-sdhci";
214 reg = <0xc8000000 0x200>; 220 reg = <0xc8000000 0x200>;
215 interrupts = <0 14 0x04>; 221 interrupts = <0 14 0x04>;
216 status = "disable"; 222 status = "disabled";
217 }; 223 };
218 224
219 sdhci@c8000200 { 225 sdhci@c8000200 {
220 compatible = "nvidia,tegra20-sdhci"; 226 compatible = "nvidia,tegra20-sdhci";
221 reg = <0xc8000200 0x200>; 227 reg = <0xc8000200 0x200>;
222 interrupts = <0 15 0x04>; 228 interrupts = <0 15 0x04>;
223 status = "disable"; 229 status = "disabled";
224 }; 230 };
225 231
226 sdhci@c8000400 { 232 sdhci@c8000400 {
227 compatible = "nvidia,tegra20-sdhci"; 233 compatible = "nvidia,tegra20-sdhci";
228 reg = <0xc8000400 0x200>; 234 reg = <0xc8000400 0x200>;
229 interrupts = <0 19 0x04>; 235 interrupts = <0 19 0x04>;
230 status = "disable"; 236 status = "disabled";
231 }; 237 };
232 238
233 sdhci@c8000600 { 239 sdhci@c8000600 {
234 compatible = "nvidia,tegra20-sdhci"; 240 compatible = "nvidia,tegra20-sdhci";
235 reg = <0xc8000600 0x200>; 241 reg = <0xc8000600 0x200>;
236 interrupts = <0 31 0x04>; 242 interrupts = <0 31 0x04>;
237 status = "disable"; 243 status = "disabled";
238 }; 244 };
239 245
240 pmu { 246 pmu {
diff --git a/arch/arm/boot/dts/tegra-cardhu.dts b/arch/arm/boot/dts/tegra30-cardhu.dts
index 36321bceec4..c169bced131 100644
--- a/arch/arm/boot/dts/tegra-cardhu.dts
+++ b/arch/arm/boot/dts/tegra30-cardhu.dts
@@ -144,7 +144,6 @@
144 144
145 sdhci@78000600 { 145 sdhci@78000600 {
146 status = "okay"; 146 status = "okay";
147 support-8bit;
148 bus-width = <8>; 147 bus-width = <8>;
149 }; 148 };
150 149
diff --git a/arch/arm/boot/dts/tegra30.dtsi b/arch/arm/boot/dts/tegra30.dtsi
index 2dcc09e784b..3e4334d14ef 100644
--- a/arch/arm/boot/dts/tegra30.dtsi
+++ b/arch/arm/boot/dts/tegra30.dtsi
@@ -82,7 +82,7 @@
82 reg = <0x70006000 0x40>; 82 reg = <0x70006000 0x40>;
83 reg-shift = <2>; 83 reg-shift = <2>;
84 interrupts = <0 36 0x04>; 84 interrupts = <0 36 0x04>;
85 status = "disable"; 85 status = "disabled";
86 }; 86 };
87 87
88 serial@70006040 { 88 serial@70006040 {
@@ -90,7 +90,7 @@
90 reg = <0x70006040 0x40>; 90 reg = <0x70006040 0x40>;
91 reg-shift = <2>; 91 reg-shift = <2>;
92 interrupts = <0 37 0x04>; 92 interrupts = <0 37 0x04>;
93 status = "disable"; 93 status = "disabled";
94 }; 94 };
95 95
96 serial@70006200 { 96 serial@70006200 {
@@ -98,7 +98,7 @@
98 reg = <0x70006200 0x100>; 98 reg = <0x70006200 0x100>;
99 reg-shift = <2>; 99 reg-shift = <2>;
100 interrupts = <0 46 0x04>; 100 interrupts = <0 46 0x04>;
101 status = "disable"; 101 status = "disabled";
102 }; 102 };
103 103
104 serial@70006300 { 104 serial@70006300 {
@@ -106,7 +106,7 @@
106 reg = <0x70006300 0x100>; 106 reg = <0x70006300 0x100>;
107 reg-shift = <2>; 107 reg-shift = <2>;
108 interrupts = <0 90 0x04>; 108 interrupts = <0 90 0x04>;
109 status = "disable"; 109 status = "disabled";
110 }; 110 };
111 111
112 serial@70006400 { 112 serial@70006400 {
@@ -114,7 +114,13 @@
114 reg = <0x70006400 0x100>; 114 reg = <0x70006400 0x100>;
115 reg-shift = <2>; 115 reg-shift = <2>;
116 interrupts = <0 91 0x04>; 116 interrupts = <0 91 0x04>;
117 status = "disable"; 117 status = "disabled";
118 };
119
120 pwm {
121 compatible = "nvidia,tegra30-pwm", "nvidia,tegra20-pwm";
122 reg = <0x7000a000 0x100>;
123 #pwm-cells = <2>;
118 }; 124 };
119 125
120 i2c@7000c000 { 126 i2c@7000c000 {
@@ -123,7 +129,7 @@
123 interrupts = <0 38 0x04>; 129 interrupts = <0 38 0x04>;
124 #address-cells = <1>; 130 #address-cells = <1>;
125 #size-cells = <0>; 131 #size-cells = <0>;
126 status = "disable"; 132 status = "disabled";
127 }; 133 };
128 134
129 i2c@7000c400 { 135 i2c@7000c400 {
@@ -132,7 +138,7 @@
132 interrupts = <0 84 0x04>; 138 interrupts = <0 84 0x04>;
133 #address-cells = <1>; 139 #address-cells = <1>;
134 #size-cells = <0>; 140 #size-cells = <0>;
135 status = "disable"; 141 status = "disabled";
136 }; 142 };
137 143
138 i2c@7000c500 { 144 i2c@7000c500 {
@@ -141,7 +147,7 @@
141 interrupts = <0 92 0x04>; 147 interrupts = <0 92 0x04>;
142 #address-cells = <1>; 148 #address-cells = <1>;
143 #size-cells = <0>; 149 #size-cells = <0>;
144 status = "disable"; 150 status = "disabled";
145 }; 151 };
146 152
147 i2c@7000c700 { 153 i2c@7000c700 {
@@ -150,7 +156,7 @@
150 interrupts = <0 120 0x04>; 156 interrupts = <0 120 0x04>;
151 #address-cells = <1>; 157 #address-cells = <1>;
152 #size-cells = <0>; 158 #size-cells = <0>;
153 status = "disable"; 159 status = "disabled";
154 }; 160 };
155 161
156 i2c@7000d000 { 162 i2c@7000d000 {
@@ -159,7 +165,7 @@
159 interrupts = <0 53 0x04>; 165 interrupts = <0 53 0x04>;
160 #address-cells = <1>; 166 #address-cells = <1>;
161 #size-cells = <0>; 167 #size-cells = <0>;
162 status = "disable"; 168 status = "disabled";
163 }; 169 };
164 170
165 pmc { 171 pmc {
@@ -167,7 +173,7 @@
167 reg = <0x7000e400 0x400>; 173 reg = <0x7000e400 0x400>;
168 }; 174 };
169 175
170 mc { 176 memory-controller {
171 compatible = "nvidia,tegra30-mc"; 177 compatible = "nvidia,tegra30-mc";
172 reg = <0x7000f000 0x010 178 reg = <0x7000f000 0x010
173 0x7000f03c 0x1b4 179 0x7000f03c 0x1b4
@@ -201,35 +207,35 @@
201 compatible = "nvidia,tegra30-i2s"; 207 compatible = "nvidia,tegra30-i2s";
202 reg = <0x70080300 0x100>; 208 reg = <0x70080300 0x100>;
203 nvidia,ahub-cif-ids = <4 4>; 209 nvidia,ahub-cif-ids = <4 4>;
204 status = "disable"; 210 status = "disabled";
205 }; 211 };
206 212
207 tegra_i2s1: i2s@70080400 { 213 tegra_i2s1: i2s@70080400 {
208 compatible = "nvidia,tegra30-i2s"; 214 compatible = "nvidia,tegra30-i2s";
209 reg = <0x70080400 0x100>; 215 reg = <0x70080400 0x100>;
210 nvidia,ahub-cif-ids = <5 5>; 216 nvidia,ahub-cif-ids = <5 5>;
211 status = "disable"; 217 status = "disabled";
212 }; 218 };
213 219
214 tegra_i2s2: i2s@70080500 { 220 tegra_i2s2: i2s@70080500 {
215 compatible = "nvidia,tegra30-i2s"; 221 compatible = "nvidia,tegra30-i2s";
216 reg = <0x70080500 0x100>; 222 reg = <0x70080500 0x100>;
217 nvidia,ahub-cif-ids = <6 6>; 223 nvidia,ahub-cif-ids = <6 6>;
218 status = "disable"; 224 status = "disabled";
219 }; 225 };
220 226
221 tegra_i2s3: i2s@70080600 { 227 tegra_i2s3: i2s@70080600 {
222 compatible = "nvidia,tegra30-i2s"; 228 compatible = "nvidia,tegra30-i2s";
223 reg = <0x70080600 0x100>; 229 reg = <0x70080600 0x100>;
224 nvidia,ahub-cif-ids = <7 7>; 230 nvidia,ahub-cif-ids = <7 7>;
225 status = "disable"; 231 status = "disabled";
226 }; 232 };
227 233
228 tegra_i2s4: i2s@70080700 { 234 tegra_i2s4: i2s@70080700 {
229 compatible = "nvidia,tegra30-i2s"; 235 compatible = "nvidia,tegra30-i2s";
230 reg = <0x70080700 0x100>; 236 reg = <0x70080700 0x100>;
231 nvidia,ahub-cif-ids = <8 8>; 237 nvidia,ahub-cif-ids = <8 8>;
232 status = "disable"; 238 status = "disabled";
233 }; 239 };
234 }; 240 };
235 241
@@ -237,28 +243,28 @@
237 compatible = "nvidia,tegra30-sdhci", "nvidia,tegra20-sdhci"; 243 compatible = "nvidia,tegra30-sdhci", "nvidia,tegra20-sdhci";
238 reg = <0x78000000 0x200>; 244 reg = <0x78000000 0x200>;
239 interrupts = <0 14 0x04>; 245 interrupts = <0 14 0x04>;
240 status = "disable"; 246 status = "disabled";
241 }; 247 };
242 248
243 sdhci@78000200 { 249 sdhci@78000200 {
244 compatible = "nvidia,tegra30-sdhci", "nvidia,tegra20-sdhci"; 250 compatible = "nvidia,tegra30-sdhci", "nvidia,tegra20-sdhci";
245 reg = <0x78000200 0x200>; 251 reg = <0x78000200 0x200>;
246 interrupts = <0 15 0x04>; 252 interrupts = <0 15 0x04>;
247 status = "disable"; 253 status = "disabled";
248 }; 254 };
249 255
250 sdhci@78000400 { 256 sdhci@78000400 {
251 compatible = "nvidia,tegra30-sdhci", "nvidia,tegra20-sdhci"; 257 compatible = "nvidia,tegra30-sdhci", "nvidia,tegra20-sdhci";
252 reg = <0x78000400 0x200>; 258 reg = <0x78000400 0x200>;
253 interrupts = <0 19 0x04>; 259 interrupts = <0 19 0x04>;
254 status = "disable"; 260 status = "disabled";
255 }; 261 };
256 262
257 sdhci@78000600 { 263 sdhci@78000600 {
258 compatible = "nvidia,tegra30-sdhci", "nvidia,tegra20-sdhci"; 264 compatible = "nvidia,tegra30-sdhci", "nvidia,tegra20-sdhci";
259 reg = <0x78000600 0x200>; 265 reg = <0x78000600 0x200>;
260 interrupts = <0 31 0x04>; 266 interrupts = <0 31 0x04>;
261 status = "disable"; 267 status = "disabled";
262 }; 268 };
263 269
264 pmu { 270 pmu {
diff --git a/arch/arm/boot/dts/twl6030.dtsi b/arch/arm/boot/dts/twl6030.dtsi
index 3b2f3510d7e..d351b27d721 100644
--- a/arch/arm/boot/dts/twl6030.dtsi
+++ b/arch/arm/boot/dts/twl6030.dtsi
@@ -66,6 +66,7 @@
66 66
67 vcxio: regulator@8 { 67 vcxio: regulator@8 {
68 compatible = "ti,twl6030-vcxio"; 68 compatible = "ti,twl6030-vcxio";
69 regulator-always-on;
69 }; 70 };
70 71
71 vusb: regulator@9 { 72 vusb: regulator@9 {
@@ -74,10 +75,12 @@
74 75
75 v1v8: regulator@10 { 76 v1v8: regulator@10 {
76 compatible = "ti,twl6030-v1v8"; 77 compatible = "ti,twl6030-v1v8";
78 regulator-always-on;
77 }; 79 };
78 80
79 v2v1: regulator@11 { 81 v2v1: regulator@11 {
80 compatible = "ti,twl6030-v2v1"; 82 compatible = "ti,twl6030-v2v1";
83 regulator-always-on;
81 }; 84 };
82 85
83 clk32kg: regulator@12 { 86 clk32kg: regulator@12 {
diff --git a/arch/arm/boot/dts/vexpress-v2m-rs1.dtsi b/arch/arm/boot/dts/vexpress-v2m-rs1.dtsi
index 16076e2d093..d8a827bd2bf 100644
--- a/arch/arm/boot/dts/vexpress-v2m-rs1.dtsi
+++ b/arch/arm/boot/dts/vexpress-v2m-rs1.dtsi
@@ -55,6 +55,8 @@
55 reg-io-width = <4>; 55 reg-io-width = <4>;
56 smsc,irq-active-high; 56 smsc,irq-active-high;
57 smsc,irq-push-pull; 57 smsc,irq-push-pull;
58 vdd33a-supply = <&v2m_fixed_3v3>;
59 vddvario-supply = <&v2m_fixed_3v3>;
58 }; 60 };
59 61
60 usb@2,03000000 { 62 usb@2,03000000 {
@@ -157,6 +159,7 @@
157 v2m_timer23: timer@120000 { 159 v2m_timer23: timer@120000 {
158 compatible = "arm,sp804", "arm,primecell"; 160 compatible = "arm,sp804", "arm,primecell";
159 reg = <0x120000 0x1000>; 161 reg = <0x120000 0x1000>;
162 interrupts = <3>;
160 }; 163 };
161 164
162 /* DVI I2C bus */ 165 /* DVI I2C bus */
@@ -197,5 +200,13 @@
197 interrupts = <14>; 200 interrupts = <14>;
198 }; 201 };
199 }; 202 };
203
204 v2m_fixed_3v3: fixedregulator@0 {
205 compatible = "regulator-fixed";
206 regulator-name = "3V3";
207 regulator-min-microvolt = <3300000>;
208 regulator-max-microvolt = <3300000>;
209 regulator-always-on;
210 };
200 }; 211 };
201}; 212};
diff --git a/arch/arm/boot/dts/vexpress-v2m.dtsi b/arch/arm/boot/dts/vexpress-v2m.dtsi
index a6c9c7c82d5..dba53fd026b 100644
--- a/arch/arm/boot/dts/vexpress-v2m.dtsi
+++ b/arch/arm/boot/dts/vexpress-v2m.dtsi
@@ -54,6 +54,8 @@
54 reg-io-width = <4>; 54 reg-io-width = <4>;
55 smsc,irq-active-high; 55 smsc,irq-active-high;
56 smsc,irq-push-pull; 56 smsc,irq-push-pull;
57 vdd33a-supply = <&v2m_fixed_3v3>;
58 vddvario-supply = <&v2m_fixed_3v3>;
57 }; 59 };
58 60
59 usb@3,03000000 { 61 usb@3,03000000 {
@@ -156,6 +158,7 @@
156 v2m_timer23: timer@12000 { 158 v2m_timer23: timer@12000 {
157 compatible = "arm,sp804", "arm,primecell"; 159 compatible = "arm,sp804", "arm,primecell";
158 reg = <0x12000 0x1000>; 160 reg = <0x12000 0x1000>;
161 interrupts = <3>;
159 }; 162 };
160 163
161 /* DVI I2C bus */ 164 /* DVI I2C bus */
@@ -196,5 +199,13 @@
196 interrupts = <14>; 199 interrupts = <14>;
197 }; 200 };
198 }; 201 };
202
203 v2m_fixed_3v3: fixedregulator@0 {
204 compatible = "regulator-fixed";
205 regulator-name = "3V3";
206 regulator-min-microvolt = <3300000>;
207 regulator-max-microvolt = <3300000>;
208 regulator-always-on;
209 };
199 }; 210 };
200}; 211};
diff --git a/arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts b/arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts
index 7e1091d91af..d12b34ca056 100644
--- a/arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts
+++ b/arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts
@@ -14,8 +14,8 @@
14 arm,hbi = <0x237>; 14 arm,hbi = <0x237>;
15 compatible = "arm,vexpress,v2p-ca15,tc1", "arm,vexpress,v2p-ca15", "arm,vexpress"; 15 compatible = "arm,vexpress,v2p-ca15,tc1", "arm,vexpress,v2p-ca15", "arm,vexpress";
16 interrupt-parent = <&gic>; 16 interrupt-parent = <&gic>;
17 #address-cells = <1>; 17 #address-cells = <2>;
18 #size-cells = <1>; 18 #size-cells = <2>;
19 19
20 chosen { }; 20 chosen { };
21 21
@@ -47,23 +47,23 @@
47 47
48 memory@80000000 { 48 memory@80000000 {
49 device_type = "memory"; 49 device_type = "memory";
50 reg = <0x80000000 0x40000000>; 50 reg = <0 0x80000000 0 0x40000000>;
51 }; 51 };
52 52
53 hdlcd@2b000000 { 53 hdlcd@2b000000 {
54 compatible = "arm,hdlcd"; 54 compatible = "arm,hdlcd";
55 reg = <0x2b000000 0x1000>; 55 reg = <0 0x2b000000 0 0x1000>;
56 interrupts = <0 85 4>; 56 interrupts = <0 85 4>;
57 }; 57 };
58 58
59 memory-controller@2b0a0000 { 59 memory-controller@2b0a0000 {
60 compatible = "arm,pl341", "arm,primecell"; 60 compatible = "arm,pl341", "arm,primecell";
61 reg = <0x2b0a0000 0x1000>; 61 reg = <0 0x2b0a0000 0 0x1000>;
62 }; 62 };
63 63
64 wdt@2b060000 { 64 wdt@2b060000 {
65 compatible = "arm,sp805", "arm,primecell"; 65 compatible = "arm,sp805", "arm,primecell";
66 reg = <0x2b060000 0x1000>; 66 reg = <0 0x2b060000 0 0x1000>;
67 interrupts = <98>; 67 interrupts = <98>;
68 }; 68 };
69 69
@@ -72,23 +72,23 @@
72 #interrupt-cells = <3>; 72 #interrupt-cells = <3>;
73 #address-cells = <0>; 73 #address-cells = <0>;
74 interrupt-controller; 74 interrupt-controller;
75 reg = <0x2c001000 0x1000>, 75 reg = <0 0x2c001000 0 0x1000>,
76 <0x2c002000 0x1000>, 76 <0 0x2c002000 0 0x1000>,
77 <0x2c004000 0x2000>, 77 <0 0x2c004000 0 0x2000>,
78 <0x2c006000 0x2000>; 78 <0 0x2c006000 0 0x2000>;
79 interrupts = <1 9 0xf04>; 79 interrupts = <1 9 0xf04>;
80 }; 80 };
81 81
82 memory-controller@7ffd0000 { 82 memory-controller@7ffd0000 {
83 compatible = "arm,pl354", "arm,primecell"; 83 compatible = "arm,pl354", "arm,primecell";
84 reg = <0x7ffd0000 0x1000>; 84 reg = <0 0x7ffd0000 0 0x1000>;
85 interrupts = <0 86 4>, 85 interrupts = <0 86 4>,
86 <0 87 4>; 86 <0 87 4>;
87 }; 87 };
88 88
89 dma@7ffb0000 { 89 dma@7ffb0000 {
90 compatible = "arm,pl330", "arm,primecell"; 90 compatible = "arm,pl330", "arm,primecell";
91 reg = <0x7ffb0000 0x1000>; 91 reg = <0 0x7ffb0000 0 0x1000>;
92 interrupts = <0 92 4>, 92 interrupts = <0 92 4>,
93 <0 88 4>, 93 <0 88 4>,
94 <0 89 4>, 94 <0 89 4>,
@@ -111,12 +111,12 @@
111 }; 111 };
112 112
113 motherboard { 113 motherboard {
114 ranges = <0 0 0x08000000 0x04000000>, 114 ranges = <0 0 0 0x08000000 0x04000000>,
115 <1 0 0x14000000 0x04000000>, 115 <1 0 0 0x14000000 0x04000000>,
116 <2 0 0x18000000 0x04000000>, 116 <2 0 0 0x18000000 0x04000000>,
117 <3 0 0x1c000000 0x04000000>, 117 <3 0 0 0x1c000000 0x04000000>,
118 <4 0 0x0c000000 0x04000000>, 118 <4 0 0 0x0c000000 0x04000000>,
119 <5 0 0x10000000 0x04000000>; 119 <5 0 0 0x10000000 0x04000000>;
120 120
121 interrupt-map-mask = <0 0 63>; 121 interrupt-map-mask = <0 0 63>;
122 interrupt-map = <0 0 0 &gic 0 0 4>, 122 interrupt-map = <0 0 0 &gic 0 0 4>,
diff --git a/arch/arm/boot/dts/vexpress-v2p-ca15_a7.dts b/arch/arm/boot/dts/vexpress-v2p-ca15_a7.dts
new file mode 100644
index 00000000000..4890a81c546
--- /dev/null
+++ b/arch/arm/boot/dts/vexpress-v2p-ca15_a7.dts
@@ -0,0 +1,188 @@
1/*
2 * ARM Ltd. Versatile Express
3 *
4 * CoreTile Express A15x2 A7x3
5 * Cortex-A15_A7 MPCore (V2P-CA15_A7)
6 *
7 * HBI-0249A
8 */
9
10/dts-v1/;
11
12/ {
13 model = "V2P-CA15_CA7";
14 arm,hbi = <0x249>;
15 compatible = "arm,vexpress,v2p-ca15_a7", "arm,vexpress";
16 interrupt-parent = <&gic>;
17 #address-cells = <2>;
18 #size-cells = <2>;
19
20 chosen { };
21
22 aliases {
23 serial0 = &v2m_serial0;
24 serial1 = &v2m_serial1;
25 serial2 = &v2m_serial2;
26 serial3 = &v2m_serial3;
27 i2c0 = &v2m_i2c_dvi;
28 i2c1 = &v2m_i2c_pcie;
29 };
30
31 cpus {
32 #address-cells = <1>;
33 #size-cells = <0>;
34
35 cpu0: cpu@0 {
36 device_type = "cpu";
37 compatible = "arm,cortex-a15";
38 reg = <0>;
39 };
40
41 cpu1: cpu@1 {
42 device_type = "cpu";
43 compatible = "arm,cortex-a15";
44 reg = <1>;
45 };
46
47/* A7s disabled till big.LITTLE patches are available...
48 cpu2: cpu@2 {
49 device_type = "cpu";
50 compatible = "arm,cortex-a7";
51 reg = <0x100>;
52 };
53
54 cpu3: cpu@3 {
55 device_type = "cpu";
56 compatible = "arm,cortex-a7";
57 reg = <0x101>;
58 };
59
60 cpu4: cpu@4 {
61 device_type = "cpu";
62 compatible = "arm,cortex-a7";
63 reg = <0x102>;
64 };
65*/
66 };
67
68 memory@80000000 {
69 device_type = "memory";
70 reg = <0 0x80000000 0 0x40000000>;
71 };
72
73 wdt@2a490000 {
74 compatible = "arm,sp805", "arm,primecell";
75 reg = <0 0x2a490000 0 0x1000>;
76 interrupts = <98>;
77 };
78
79 hdlcd@2b000000 {
80 compatible = "arm,hdlcd";
81 reg = <0 0x2b000000 0 0x1000>;
82 interrupts = <0 85 4>;
83 };
84
85 memory-controller@2b0a0000 {
86 compatible = "arm,pl341", "arm,primecell";
87 reg = <0 0x2b0a0000 0 0x1000>;
88 };
89
90 gic: interrupt-controller@2c001000 {
91 compatible = "arm,cortex-a15-gic", "arm,cortex-a9-gic";
92 #interrupt-cells = <3>;
93 #address-cells = <0>;
94 interrupt-controller;
95 reg = <0 0x2c001000 0 0x1000>,
96 <0 0x2c002000 0 0x1000>,
97 <0 0x2c004000 0 0x2000>,
98 <0 0x2c006000 0 0x2000>;
99 interrupts = <1 9 0xf04>;
100 };
101
102 memory-controller@7ffd0000 {
103 compatible = "arm,pl354", "arm,primecell";
104 reg = <0 0x7ffd0000 0 0x1000>;
105 interrupts = <0 86 4>,
106 <0 87 4>;
107 };
108
109 dma@7ff00000 {
110 compatible = "arm,pl330", "arm,primecell";
111 reg = <0 0x7ff00000 0 0x1000>;
112 interrupts = <0 92 4>,
113 <0 88 4>,
114 <0 89 4>,
115 <0 90 4>,
116 <0 91 4>;
117 };
118
119 timer {
120 compatible = "arm,armv7-timer";
121 interrupts = <1 13 0xf08>,
122 <1 14 0xf08>,
123 <1 11 0xf08>,
124 <1 10 0xf08>;
125 };
126
127 pmu {
128 compatible = "arm,cortex-a15-pmu", "arm,cortex-a9-pmu";
129 interrupts = <0 68 4>,
130 <0 69 4>;
131 };
132
133 motherboard {
134 ranges = <0 0 0 0x08000000 0x04000000>,
135 <1 0 0 0x14000000 0x04000000>,
136 <2 0 0 0x18000000 0x04000000>,
137 <3 0 0 0x1c000000 0x04000000>,
138 <4 0 0 0x0c000000 0x04000000>,
139 <5 0 0 0x10000000 0x04000000>;
140
141 interrupt-map-mask = <0 0 63>;
142 interrupt-map = <0 0 0 &gic 0 0 4>,
143 <0 0 1 &gic 0 1 4>,
144 <0 0 2 &gic 0 2 4>,
145 <0 0 3 &gic 0 3 4>,
146 <0 0 4 &gic 0 4 4>,
147 <0 0 5 &gic 0 5 4>,
148 <0 0 6 &gic 0 6 4>,
149 <0 0 7 &gic 0 7 4>,
150 <0 0 8 &gic 0 8 4>,
151 <0 0 9 &gic 0 9 4>,
152 <0 0 10 &gic 0 10 4>,
153 <0 0 11 &gic 0 11 4>,
154 <0 0 12 &gic 0 12 4>,
155 <0 0 13 &gic 0 13 4>,
156 <0 0 14 &gic 0 14 4>,
157 <0 0 15 &gic 0 15 4>,
158 <0 0 16 &gic 0 16 4>,
159 <0 0 17 &gic 0 17 4>,
160 <0 0 18 &gic 0 18 4>,
161 <0 0 19 &gic 0 19 4>,
162 <0 0 20 &gic 0 20 4>,
163 <0 0 21 &gic 0 21 4>,
164 <0 0 22 &gic 0 22 4>,
165 <0 0 23 &gic 0 23 4>,
166 <0 0 24 &gic 0 24 4>,
167 <0 0 25 &gic 0 25 4>,
168 <0 0 26 &gic 0 26 4>,
169 <0 0 27 &gic 0 27 4>,
170 <0 0 28 &gic 0 28 4>,
171 <0 0 29 &gic 0 29 4>,
172 <0 0 30 &gic 0 30 4>,
173 <0 0 31 &gic 0 31 4>,
174 <0 0 32 &gic 0 32 4>,
175 <0 0 33 &gic 0 33 4>,
176 <0 0 34 &gic 0 34 4>,
177 <0 0 35 &gic 0 35 4>,
178 <0 0 36 &gic 0 36 4>,
179 <0 0 37 &gic 0 37 4>,
180 <0 0 38 &gic 0 38 4>,
181 <0 0 39 &gic 0 39 4>,
182 <0 0 40 &gic 0 40 4>,
183 <0 0 41 &gic 0 41 4>,
184 <0 0 42 &gic 0 42 4>;
185 };
186};
187
188/include/ "vexpress-v2m-rs1.dtsi"
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index aa07f5938f0..1143c4d5c56 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -452,6 +452,7 @@ static struct dma_map_ops dmabounce_ops = {
452 .alloc = arm_dma_alloc, 452 .alloc = arm_dma_alloc,
453 .free = arm_dma_free, 453 .free = arm_dma_free,
454 .mmap = arm_dma_mmap, 454 .mmap = arm_dma_mmap,
455 .get_sgtable = arm_dma_get_sgtable,
455 .map_page = dmabounce_map_page, 456 .map_page = dmabounce_map_page,
456 .unmap_page = dmabounce_unmap_page, 457 .unmap_page = dmabounce_unmap_page,
457 .sync_single_for_cpu = dmabounce_sync_for_cpu, 458 .sync_single_for_cpu = dmabounce_sync_for_cpu,
diff --git a/arch/arm/configs/armadillo800eva_defconfig b/arch/arm/configs/armadillo800eva_defconfig
index ddc9fe6a78a..90610c7030f 100644
--- a/arch/arm/configs/armadillo800eva_defconfig
+++ b/arch/arm/configs/armadillo800eva_defconfig
@@ -5,10 +5,7 @@ CONFIG_IKCONFIG_PROC=y
5CONFIG_LOG_BUF_SHIFT=16 5CONFIG_LOG_BUF_SHIFT=16
6# CONFIG_UTS_NS is not set 6# CONFIG_UTS_NS is not set
7# CONFIG_IPC_NS is not set 7# CONFIG_IPC_NS is not set
8# CONFIG_USER_NS is not set
9# CONFIG_PID_NS is not set 8# CONFIG_PID_NS is not set
10CONFIG_SYSFS_DEPRECATED=y
11CONFIG_SYSFS_DEPRECATED_V2=y
12CONFIG_CC_OPTIMIZE_FOR_SIZE=y 9CONFIG_CC_OPTIMIZE_FOR_SIZE=y
13CONFIG_SLAB=y 10CONFIG_SLAB=y
14CONFIG_MODULES=y 11CONFIG_MODULES=y
@@ -21,7 +18,7 @@ CONFIG_ARCH_SHMOBILE=y
21CONFIG_ARCH_R8A7740=y 18CONFIG_ARCH_R8A7740=y
22CONFIG_MACH_ARMADILLO800EVA=y 19CONFIG_MACH_ARMADILLO800EVA=y
23# CONFIG_SH_TIMER_TMU is not set 20# CONFIG_SH_TIMER_TMU is not set
24# CONFIG_ARM_THUMB is not set 21CONFIG_ARM_THUMB=y
25CONFIG_CPU_BPREDICT_DISABLE=y 22CONFIG_CPU_BPREDICT_DISABLE=y
26# CONFIG_CACHE_L2X0 is not set 23# CONFIG_CACHE_L2X0 is not set
27CONFIG_ARM_ERRATA_430973=y 24CONFIG_ARM_ERRATA_430973=y
@@ -36,9 +33,10 @@ CONFIG_AEABI=y
36CONFIG_FORCE_MAX_ZONEORDER=13 33CONFIG_FORCE_MAX_ZONEORDER=13
37CONFIG_ZBOOT_ROM_TEXT=0x0 34CONFIG_ZBOOT_ROM_TEXT=0x0
38CONFIG_ZBOOT_ROM_BSS=0x0 35CONFIG_ZBOOT_ROM_BSS=0x0
39CONFIG_CMDLINE="console=tty0 console=ttySC1,115200 earlyprintk=sh-sci.1,115200 ignore_loglevel root=/dev/nfs ip=dhcp nfsroot=,rsize=4096,wsize=4096" 36CONFIG_CMDLINE="console=tty0 console=ttySC1,115200 earlyprintk=sh-sci.1,115200 ignore_loglevel root=/dev/nfs ip=dhcp nfsroot=,rsize=4096,wsize=4096 rw"
40CONFIG_CMDLINE_FORCE=y 37CONFIG_CMDLINE_FORCE=y
41CONFIG_KEXEC=y 38CONFIG_KEXEC=y
39CONFIG_VFP=y
42# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set 40# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
43# CONFIG_SUSPEND is not set 41# CONFIG_SUSPEND is not set
44CONFIG_NET=y 42CONFIG_NET=y
@@ -89,26 +87,32 @@ CONFIG_SERIAL_SH_SCI_CONSOLE=y
89CONFIG_I2C=y 87CONFIG_I2C=y
90CONFIG_I2C_SH_MOBILE=y 88CONFIG_I2C_SH_MOBILE=y
91# CONFIG_HWMON is not set 89# CONFIG_HWMON is not set
90CONFIG_MEDIA_SUPPORT=y
91CONFIG_VIDEO_DEV=y
92# CONFIG_RC_CORE is not set
93# CONFIG_VIDEO_HELPER_CHIPS_AUTO is not set
94# CONFIG_V4L_USB_DRIVERS is not set
95CONFIG_V4L_PLATFORM_DRIVERS=y
96CONFIG_SOC_CAMERA=y
97CONFIG_SOC_CAMERA_MT9T112=y
98CONFIG_VIDEO_SH_MOBILE_CEU=y
99# CONFIG_RADIO_ADAPTERS is not set
92CONFIG_FB=y 100CONFIG_FB=y
93CONFIG_FB_MODE_HELPERS=y
94CONFIG_FB_SH_MOBILE_LCDC=y 101CONFIG_FB_SH_MOBILE_LCDC=y
102CONFIG_FB_SH_MOBILE_HDMI=y
95CONFIG_LCD_CLASS_DEVICE=y 103CONFIG_LCD_CLASS_DEVICE=y
96CONFIG_FRAMEBUFFER_CONSOLE=y 104CONFIG_FRAMEBUFFER_CONSOLE=y
97CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y 105CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
98CONFIG_LOGO=y 106CONFIG_LOGO=y
99# CONFIG_LOGO_LINUX_MONO is not set 107# CONFIG_LOGO_LINUX_MONO is not set
100# CONFIG_LOGO_LINUX_VGA16 is not set 108# CONFIG_LOGO_LINUX_VGA16 is not set
101CONFIG_SOUND=y
102CONFIG_SND=y
103# CONFIG_SND_SUPPORT_OLD_API is not set 109# CONFIG_SND_SUPPORT_OLD_API is not set
104# CONFIG_SND_VERBOSE_PROCFS is not set 110# CONFIG_SND_VERBOSE_PROCFS is not set
105# CONFIG_SND_DRIVERS is not set 111# CONFIG_SND_DRIVERS is not set
106# CONFIG_SND_ARM is not set 112# CONFIG_SND_ARM is not set
107CONFIG_SND_SOC=y
108CONFIG_SND_SOC_SH4_FSI=y 113CONFIG_SND_SOC_SH4_FSI=y
109# CONFIG_HID_SUPPORT is not set 114# CONFIG_HID_SUPPORT is not set
110CONFIG_USB=y 115CONFIG_USB=y
111# CONFIG_USB_DEVICE_CLASS is not set
112CONFIG_USB_RENESAS_USBHS=y 116CONFIG_USB_RENESAS_USBHS=y
113CONFIG_USB_GADGET=y 117CONFIG_USB_GADGET=y
114CONFIG_USB_RENESAS_USBHS_UDC=y 118CONFIG_USB_RENESAS_USBHS_UDC=y
@@ -116,6 +120,8 @@ CONFIG_USB_ETH=m
116CONFIG_MMC=y 120CONFIG_MMC=y
117CONFIG_MMC_SDHI=y 121CONFIG_MMC_SDHI=y
118CONFIG_MMC_SH_MMCIF=y 122CONFIG_MMC_SH_MMCIF=y
123CONFIG_DMADEVICES=y
124CONFIG_SH_DMAE=y
119CONFIG_UIO=y 125CONFIG_UIO=y
120CONFIG_UIO_PDRV_GENIRQ=y 126CONFIG_UIO_PDRV_GENIRQ=y
121# CONFIG_DNOTIFY is not set 127# CONFIG_DNOTIFY is not set
@@ -124,7 +130,6 @@ CONFIG_VFAT_FS=y
124CONFIG_TMPFS=y 130CONFIG_TMPFS=y
125# CONFIG_MISC_FILESYSTEMS is not set 131# CONFIG_MISC_FILESYSTEMS is not set
126CONFIG_NFS_FS=y 132CONFIG_NFS_FS=y
127CONFIG_NFS_V3=y
128CONFIG_NFS_V3_ACL=y 133CONFIG_NFS_V3_ACL=y
129CONFIG_NFS_V4=y 134CONFIG_NFS_V4=y
130CONFIG_NFS_V4_1=y 135CONFIG_NFS_V4_1=y
diff --git a/arch/arm/configs/exynos_defconfig b/arch/arm/configs/exynos_defconfig
new file mode 100644
index 00000000000..e40b435d204
--- /dev/null
+++ b/arch/arm/configs/exynos_defconfig
@@ -0,0 +1,92 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_NO_HZ=y
3CONFIG_HIGH_RES_TIMERS=y
4CONFIG_BLK_DEV_INITRD=y
5CONFIG_KALLSYMS_ALL=y
6CONFIG_MODULES=y
7CONFIG_MODULE_UNLOAD=y
8# CONFIG_BLK_DEV_BSG is not set
9CONFIG_PARTITION_ADVANCED=y
10CONFIG_EFI_PARTITION=y
11CONFIG_ARCH_EXYNOS=y
12CONFIG_S3C_LOWLEVEL_UART_PORT=1
13CONFIG_S3C24XX_PWM=y
14CONFIG_ARCH_EXYNOS5=y
15CONFIG_MACH_EXYNOS4_DT=y
16CONFIG_MACH_EXYNOS5_DT=y
17CONFIG_SMP=y
18CONFIG_NR_CPUS=2
19CONFIG_PREEMPT=y
20CONFIG_AEABI=y
21CONFIG_ARM_APPENDED_DTB=y
22CONFIG_ARM_ATAG_DTB_COMPAT=y
23CONFIG_CMDLINE="root=/dev/ram0 rw ramdisk=8192 initrd=0x41000000,8M console=ttySAC1,115200 init=/linuxrc mem=256M"
24CONFIG_VFP=y
25CONFIG_NEON=y
26CONFIG_NET=y
27CONFIG_PACKET=y
28CONFIG_UNIX=y
29CONFIG_NET_KEY=y
30CONFIG_INET=y
31CONFIG_RFKILL_REGULATOR=y
32CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
33CONFIG_PROC_DEVICETREE=y
34CONFIG_BLK_DEV_LOOP=y
35CONFIG_BLK_DEV_RAM=y
36CONFIG_BLK_DEV_RAM_SIZE=8192
37CONFIG_SCSI=y
38CONFIG_BLK_DEV_SD=y
39CONFIG_CHR_DEV_SG=y
40CONFIG_NETDEVICES=y
41CONFIG_SMSC911X=y
42CONFIG_USB_USBNET=y
43CONFIG_USB_NET_SMSC75XX=y
44CONFIG_USB_NET_SMSC95XX=y
45CONFIG_INPUT_EVDEV=y
46# CONFIG_INPUT_KEYBOARD is not set
47# CONFIG_INPUT_MOUSE is not set
48CONFIG_INPUT_TOUCHSCREEN=y
49CONFIG_SERIAL_8250=y
50CONFIG_SERIAL_SAMSUNG=y
51CONFIG_SERIAL_SAMSUNG_CONSOLE=y
52CONFIG_SERIAL_OF_PLATFORM=y
53CONFIG_HW_RANDOM=y
54CONFIG_I2C=y
55# CONFIG_HWMON is not set
56CONFIG_MFD_TPS65090=y
57CONFIG_REGULATOR=y
58CONFIG_REGULATOR_FIXED_VOLTAGE=y
59CONFIG_REGULATOR_GPIO=y
60CONFIG_REGULATOR_TPS65090=y
61CONFIG_FB=y
62CONFIG_EXYNOS_VIDEO=y
63CONFIG_EXYNOS_MIPI_DSI=y
64CONFIG_EXYNOS_DP=y
65CONFIG_FRAMEBUFFER_CONSOLE=y
66CONFIG_FONTS=y
67CONFIG_FONT_7x14=y
68CONFIG_LOGO=y
69CONFIG_USB=y
70CONFIG_EXT2_FS=y
71CONFIG_EXT3_FS=y
72CONFIG_EXT4_FS=y
73CONFIG_MSDOS_FS=y
74CONFIG_VFAT_FS=y
75CONFIG_TMPFS=y
76CONFIG_TMPFS_POSIX_ACL=y
77CONFIG_CRAMFS=y
78CONFIG_ROMFS_FS=y
79CONFIG_NLS_CODEPAGE_437=y
80CONFIG_NLS_ASCII=y
81CONFIG_NLS_ISO8859_1=y
82CONFIG_MAGIC_SYSRQ=y
83CONFIG_DEBUG_KERNEL=y
84CONFIG_DETECT_HUNG_TASK=y
85CONFIG_DEBUG_RT_MUTEXES=y
86CONFIG_DEBUG_SPINLOCK=y
87CONFIG_DEBUG_MUTEXES=y
88CONFIG_DEBUG_INFO=y
89CONFIG_DEBUG_USER=y
90CONFIG_DEBUG_LL=y
91CONFIG_EARLY_PRINTK=y
92CONFIG_CRC_CCITT=y
diff --git a/arch/arm/configs/imx_v4_v5_defconfig b/arch/arm/configs/imx_v4_v5_defconfig
index e05a2f1665a..78ed575feb1 100644
--- a/arch/arm/configs/imx_v4_v5_defconfig
+++ b/arch/arm/configs/imx_v4_v5_defconfig
@@ -2,7 +2,10 @@ CONFIG_EXPERIMENTAL=y
2# CONFIG_SWAP is not set 2# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y 3CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 4CONFIG_POSIX_MQUEUE=y
5CONFIG_NO_HZ=y
6CONFIG_HIGH_RES_TIMERS=y
5CONFIG_LOG_BUF_SHIFT=14 7CONFIG_LOG_BUF_SHIFT=14
8CONFIG_CGROUPS=y
6CONFIG_EXPERT=y 9CONFIG_EXPERT=y
7# CONFIG_COMPAT_BRK is not set 10# CONFIG_COMPAT_BRK is not set
8CONFIG_SLAB=y 11CONFIG_SLAB=y
@@ -36,8 +39,6 @@ CONFIG_MACH_IMX27IPCAM=y
36CONFIG_MACH_IMX27_DT=y 39CONFIG_MACH_IMX27_DT=y
37CONFIG_MXC_IRQ_PRIOR=y 40CONFIG_MXC_IRQ_PRIOR=y
38CONFIG_MXC_PWM=y 41CONFIG_MXC_PWM=y
39CONFIG_NO_HZ=y
40CONFIG_HIGH_RES_TIMERS=y
41CONFIG_PREEMPT=y 42CONFIG_PREEMPT=y
42CONFIG_AEABI=y 43CONFIG_AEABI=y
43CONFIG_ZBOOT_ROM_TEXT=0x0 44CONFIG_ZBOOT_ROM_TEXT=0x0
@@ -46,7 +47,6 @@ CONFIG_FPE_NWFPE=y
46CONFIG_FPE_NWFPE_XP=y 47CONFIG_FPE_NWFPE_XP=y
47CONFIG_PM_DEBUG=y 48CONFIG_PM_DEBUG=y
48CONFIG_NET=y 49CONFIG_NET=y
49CONFIG_SMSC911X=y
50CONFIG_PACKET=y 50CONFIG_PACKET=y
51CONFIG_UNIX=y 51CONFIG_UNIX=y
52CONFIG_INET=y 52CONFIG_INET=y
@@ -70,31 +70,31 @@ CONFIG_MTD_CFI=y
70CONFIG_MTD_CFI_ADV_OPTIONS=y 70CONFIG_MTD_CFI_ADV_OPTIONS=y
71CONFIG_MTD_CFI_GEOMETRY=y 71CONFIG_MTD_CFI_GEOMETRY=y
72# CONFIG_MTD_MAP_BANK_WIDTH_1 is not set 72# CONFIG_MTD_MAP_BANK_WIDTH_1 is not set
73CONFIG_MTD_MAP_BANK_WIDTH_4=y
74# CONFIG_MTD_CFI_I2 is not set 73# CONFIG_MTD_CFI_I2 is not set
75CONFIG_MTD_CFI_INTELEXT=y 74CONFIG_MTD_CFI_INTELEXT=y
76CONFIG_MTD_PHYSMAP=y 75CONFIG_MTD_PHYSMAP=y
77CONFIG_MTD_NAND=y 76CONFIG_MTD_NAND=y
78CONFIG_MTD_NAND_MXC=y 77CONFIG_MTD_NAND_MXC=y
79CONFIG_MTD_UBI=y 78CONFIG_MTD_UBI=y
80CONFIG_MISC_DEVICES=y
81CONFIG_EEPROM_AT24=y 79CONFIG_EEPROM_AT24=y
82CONFIG_EEPROM_AT25=y 80CONFIG_EEPROM_AT25=y
81CONFIG_ATA=y
82CONFIG_PATA_IMX=y
83CONFIG_NETDEVICES=y 83CONFIG_NETDEVICES=y
84CONFIG_CS89x0=y 84CONFIG_CS89x0=y
85CONFIG_CS89x0_PLATFORM=y 85CONFIG_CS89x0_PLATFORM=y
86CONFIG_DM9000=y 86CONFIG_DM9000=y
87CONFIG_SMC91X=y 87CONFIG_SMC91X=y
88CONFIG_SMC911X=y 88CONFIG_SMC911X=y
89CONFIG_SMSC911X=y
89CONFIG_SMSC_PHY=y 90CONFIG_SMSC_PHY=y
90# CONFIG_INPUT_MOUSEDEV is not set 91# CONFIG_INPUT_MOUSEDEV is not set
91CONFIG_INPUT_EVDEV=y 92CONFIG_INPUT_EVDEV=y
92# CONFIG_INPUT_KEYBOARD is not set 93CONFIG_KEYBOARD_IMX=y
93# CONFIG_INPUT_MOUSE is not set 94# CONFIG_INPUT_MOUSE is not set
94CONFIG_INPUT_TOUCHSCREEN=y 95CONFIG_INPUT_TOUCHSCREEN=y
95CONFIG_TOUCHSCREEN_ADS7846=m 96CONFIG_TOUCHSCREEN_ADS7846=m
96CONFIG_TOUCHSCREEN_MC13783=m 97CONFIG_TOUCHSCREEN_MC13783=y
97# CONFIG_SERIO is not set
98# CONFIG_LEGACY_PTYS is not set 98# CONFIG_LEGACY_PTYS is not set
99CONFIG_SERIAL_8250=m 99CONFIG_SERIAL_8250=m
100CONFIG_SERIAL_IMX=y 100CONFIG_SERIAL_IMX=y
@@ -113,31 +113,23 @@ CONFIG_HWMON=m
113CONFIG_SENSORS_MC13783_ADC=m 113CONFIG_SENSORS_MC13783_ADC=m
114CONFIG_WATCHDOG=y 114CONFIG_WATCHDOG=y
115CONFIG_IMX2_WDT=y 115CONFIG_IMX2_WDT=y
116CONFIG_MFD_MC13XXX=y 116CONFIG_MFD_MC13XXX_SPI=y
117CONFIG_REGULATOR=y 117CONFIG_REGULATOR=y
118CONFIG_REGULATOR_FIXED_VOLTAGE=y 118CONFIG_REGULATOR_FIXED_VOLTAGE=y
119CONFIG_REGULATOR_MC13783=y 119CONFIG_REGULATOR_MC13783=y
120CONFIG_REGULATOR_MC13892=y 120CONFIG_REGULATOR_MC13892=y
121CONFIG_FB=y
122CONFIG_FB_IMX=y
123CONFIG_BACKLIGHT_LCD_SUPPORT=y
124CONFIG_LCD_CLASS_DEVICE=y
125CONFIG_BACKLIGHT_CLASS_DEVICE=y
126CONFIG_LCD_L4F00242T03=y
127CONFIG_MEDIA_SUPPORT=y 121CONFIG_MEDIA_SUPPORT=y
128CONFIG_VIDEO_DEV=y 122CONFIG_VIDEO_DEV=y
129CONFIG_VIDEO_V4L2_COMMON=y
130CONFIG_VIDEO_MEDIA=y
131CONFIG_VIDEO_V4L2=y
132CONFIG_VIDEOBUF_GEN=y
133CONFIG_VIDEOBUF_DMA_CONTIG=y
134CONFIG_VIDEOBUF2_CORE=y
135CONFIG_VIDEO_CAPTURE_DRIVERS=y
136CONFIG_V4L_PLATFORM_DRIVERS=y 123CONFIG_V4L_PLATFORM_DRIVERS=y
137CONFIG_SOC_CAMERA=y 124CONFIG_SOC_CAMERA=y
138CONFIG_SOC_CAMERA_OV2640=y 125CONFIG_SOC_CAMERA_OV2640=y
139CONFIG_VIDEO_MX2_HOSTSUPPORT=y
140CONFIG_VIDEO_MX2=y 126CONFIG_VIDEO_MX2=y
127CONFIG_FB=y
128CONFIG_FB_IMX=y
129CONFIG_BACKLIGHT_LCD_SUPPORT=y
130CONFIG_LCD_CLASS_DEVICE=y
131CONFIG_LCD_L4F00242T03=y
132CONFIG_BACKLIGHT_CLASS_DEVICE=y
141CONFIG_BACKLIGHT_PWM=y 133CONFIG_BACKLIGHT_PWM=y
142CONFIG_FRAMEBUFFER_CONSOLE=y 134CONFIG_FRAMEBUFFER_CONSOLE=y
143CONFIG_FONTS=y 135CONFIG_FONTS=y
@@ -152,13 +144,17 @@ CONFIG_SND_IMX_SOC=y
152CONFIG_SND_SOC_MX27VIS_AIC32X4=y 144CONFIG_SND_SOC_MX27VIS_AIC32X4=y
153CONFIG_SND_SOC_PHYCORE_AC97=y 145CONFIG_SND_SOC_PHYCORE_AC97=y
154CONFIG_SND_SOC_EUKREA_TLV320=y 146CONFIG_SND_SOC_EUKREA_TLV320=y
147CONFIG_SND_SOC_IMX_SGTL5000=y
148CONFIG_SND_SOC_IMX_MC13783=y
155CONFIG_USB_HID=m 149CONFIG_USB_HID=m
156CONFIG_USB=y 150CONFIG_USB=y
157# CONFIG_USB_DEVICE_CLASS is not set
158CONFIG_USB_EHCI_HCD=y 151CONFIG_USB_EHCI_HCD=y
159CONFIG_USB_EHCI_MXC=y 152CONFIG_USB_EHCI_MXC=y
160CONFIG_USB_ULPI=y 153CONFIG_USB_ULPI=y
161CONFIG_MMC=y 154CONFIG_MMC=y
155CONFIG_MMC_SDHCI=y
156CONFIG_MMC_SDHCI_PLTFM=y
157CONFIG_MMC_SDHCI_ESDHC_IMX=y
162CONFIG_MMC_MXC=y 158CONFIG_MMC_MXC=y
163CONFIG_NEW_LEDS=y 159CONFIG_NEW_LEDS=y
164CONFIG_LEDS_CLASS=y 160CONFIG_LEDS_CLASS=y
@@ -173,22 +169,25 @@ CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
173CONFIG_RTC_CLASS=y 169CONFIG_RTC_CLASS=y
174CONFIG_RTC_DRV_PCF8563=y 170CONFIG_RTC_DRV_PCF8563=y
175CONFIG_RTC_DRV_IMXDI=y 171CONFIG_RTC_DRV_IMXDI=y
172CONFIG_RTC_DRV_MC13XXX=y
176CONFIG_RTC_DRV_MXC=y 173CONFIG_RTC_DRV_MXC=y
177CONFIG_DMADEVICES=y 174CONFIG_DMADEVICES=y
178CONFIG_IMX_SDMA=y 175CONFIG_IMX_SDMA=y
179CONFIG_IMX_DMA=y 176CONFIG_IMX_DMA=y
177CONFIG_COMMON_CLK_DEBUG=y
180# CONFIG_IOMMU_SUPPORT is not set 178# CONFIG_IOMMU_SUPPORT is not set
179CONFIG_EXT2_FS=y
180CONFIG_EXT3_FS=y
181CONFIG_EXT4_FS=y
181# CONFIG_DNOTIFY is not set 182# CONFIG_DNOTIFY is not set
182# CONFIG_PROC_PAGE_MONITOR is not set 183# CONFIG_PROC_PAGE_MONITOR is not set
183CONFIG_TMPFS=y 184CONFIG_TMPFS=y
184CONFIG_JFFS2_FS=y 185CONFIG_JFFS2_FS=y
185CONFIG_UBIFS_FS=y 186CONFIG_UBIFS_FS=y
186CONFIG_NFS_FS=y 187CONFIG_NFS_FS=y
187CONFIG_NFS_V3=y
188CONFIG_ROOT_NFS=y 188CONFIG_ROOT_NFS=y
189CONFIG_NLS_CODEPAGE_437=m 189CONFIG_NLS_CODEPAGE_437=m
190CONFIG_NLS_CODEPAGE_850=m 190CONFIG_NLS_CODEPAGE_850=m
191CONFIG_NLS_ISO8859_1=y 191CONFIG_NLS_ISO8859_1=y
192CONFIG_NLS_ISO8859_15=m 192CONFIG_NLS_ISO8859_15=m
193CONFIG_SYSCTL_SYSCALL_CHECK=y
194# CONFIG_CRYPTO_ANSI_CPRNG is not set 193# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/arm/configs/imx_v6_v7_defconfig b/arch/arm/configs/imx_v6_v7_defconfig
index b1d3675df72..3c9f32f9b6b 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -2,6 +2,8 @@ CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 2# CONFIG_LOCALVERSION_AUTO is not set
3CONFIG_KERNEL_LZO=y 3CONFIG_KERNEL_LZO=y
4CONFIG_SYSVIPC=y 4CONFIG_SYSVIPC=y
5CONFIG_NO_HZ=y
6CONFIG_HIGH_RES_TIMERS=y
5CONFIG_LOG_BUF_SHIFT=18 7CONFIG_LOG_BUF_SHIFT=18
6CONFIG_CGROUPS=y 8CONFIG_CGROUPS=y
7CONFIG_RELAY=y 9CONFIG_RELAY=y
@@ -29,15 +31,12 @@ CONFIG_MACH_MX35_3DS=y
29CONFIG_MACH_VPR200=y 31CONFIG_MACH_VPR200=y
30CONFIG_MACH_IMX51_DT=y 32CONFIG_MACH_IMX51_DT=y
31CONFIG_MACH_MX51_3DS=y 33CONFIG_MACH_MX51_3DS=y
32CONFIG_MACH_EUKREA_CPUIMX51=y
33CONFIG_MACH_EUKREA_CPUIMX51SD=y 34CONFIG_MACH_EUKREA_CPUIMX51SD=y
34CONFIG_MACH_MX51_EFIKAMX=y 35CONFIG_MACH_MX51_EFIKAMX=y
35CONFIG_MACH_MX51_EFIKASB=y 36CONFIG_MACH_MX51_EFIKASB=y
36CONFIG_MACH_IMX53_DT=y 37CONFIG_MACH_IMX53_DT=y
37CONFIG_SOC_IMX6Q=y 38CONFIG_SOC_IMX6Q=y
38CONFIG_MXC_PWM=y 39CONFIG_MXC_PWM=y
39CONFIG_NO_HZ=y
40CONFIG_HIGH_RES_TIMERS=y
41CONFIG_SMP=y 40CONFIG_SMP=y
42CONFIG_VMSPLIT_2G=y 41CONFIG_VMSPLIT_2G=y
43CONFIG_PREEMPT_VOLUNTARY=y 42CONFIG_PREEMPT_VOLUNTARY=y
@@ -64,17 +63,29 @@ CONFIG_IPV6=y
64# CONFIG_WIRELESS is not set 63# CONFIG_WIRELESS is not set
65CONFIG_DEVTMPFS=y 64CONFIG_DEVTMPFS=y
66CONFIG_DEVTMPFS_MOUNT=y 65CONFIG_DEVTMPFS_MOUNT=y
66# CONFIG_STANDALONE is not set
67CONFIG_CONNECTOR=y
67CONFIG_MTD=y 68CONFIG_MTD=y
68CONFIG_MTD_OF_PARTS=y 69CONFIG_MTD_CMDLINE_PARTS=y
69CONFIG_MTD_CHAR=y 70CONFIG_MTD_CHAR=y
71CONFIG_MTD_BLOCK=y
72CONFIG_MTD_CFI=y
73CONFIG_MTD_JEDECPROBE=y
74CONFIG_MTD_CFI_INTELEXT=y
75CONFIG_MTD_CFI_AMDSTD=y
76CONFIG_MTD_CFI_STAA=y
70CONFIG_MTD_DATAFLASH=y 77CONFIG_MTD_DATAFLASH=y
71CONFIG_MTD_M25P80=y 78CONFIG_MTD_M25P80=y
72CONFIG_MTD_SST25L=y 79CONFIG_MTD_SST25L=y
73# CONFIG_STANDALONE is not set 80CONFIG_MTD_NAND=y
74CONFIG_CONNECTOR=y 81CONFIG_MTD_NAND_GPMI_NAND=y
82CONFIG_MTD_NAND_MXC=y
83CONFIG_MTD_UBI=y
75CONFIG_BLK_DEV_LOOP=y 84CONFIG_BLK_DEV_LOOP=y
76CONFIG_BLK_DEV_RAM=y 85CONFIG_BLK_DEV_RAM=y
77CONFIG_BLK_DEV_RAM_SIZE=65536 86CONFIG_BLK_DEV_RAM_SIZE=65536
87CONFIG_EEPROM_AT24=y
88CONFIG_EEPROM_AT25=y
78# CONFIG_SCSI_PROC_FS is not set 89# CONFIG_SCSI_PROC_FS is not set
79CONFIG_BLK_DEV_SD=y 90CONFIG_BLK_DEV_SD=y
80CONFIG_SCSI_MULTI_LUN=y 91CONFIG_SCSI_MULTI_LUN=y
@@ -105,8 +116,11 @@ CONFIG_SMSC911X=y
105CONFIG_INPUT_EVDEV=y 116CONFIG_INPUT_EVDEV=y
106CONFIG_INPUT_EVBUG=m 117CONFIG_INPUT_EVBUG=m
107CONFIG_KEYBOARD_GPIO=y 118CONFIG_KEYBOARD_GPIO=y
119CONFIG_KEYBOARD_IMX=y
108CONFIG_MOUSE_PS2=m 120CONFIG_MOUSE_PS2=m
109CONFIG_MOUSE_PS2_ELANTECH=y 121CONFIG_MOUSE_PS2_ELANTECH=y
122CONFIG_INPUT_TOUCHSCREEN=y
123CONFIG_TOUCHSCREEN_MC13783=y
110CONFIG_INPUT_MISC=y 124CONFIG_INPUT_MISC=y
111CONFIG_INPUT_MMA8450=y 125CONFIG_INPUT_MMA8450=y
112CONFIG_SERIO_SERPORT=m 126CONFIG_SERIO_SERPORT=m
@@ -116,6 +130,7 @@ CONFIG_VT_HW_CONSOLE_BINDING=y
116CONFIG_SERIAL_IMX=y 130CONFIG_SERIAL_IMX=y
117CONFIG_SERIAL_IMX_CONSOLE=y 131CONFIG_SERIAL_IMX_CONSOLE=y
118CONFIG_HW_RANDOM=y 132CONFIG_HW_RANDOM=y
133CONFIG_HW_RANDOM_MXC_RNGA=y
119CONFIG_I2C=y 134CONFIG_I2C=y
120# CONFIG_I2C_COMPAT is not set 135# CONFIG_I2C_COMPAT is not set
121CONFIG_I2C_CHARDEV=y 136CONFIG_I2C_CHARDEV=y
@@ -130,42 +145,37 @@ CONFIG_GPIO_SYSFS=y
130# CONFIG_HWMON is not set 145# CONFIG_HWMON is not set
131CONFIG_WATCHDOG=y 146CONFIG_WATCHDOG=y
132CONFIG_IMX2_WDT=y 147CONFIG_IMX2_WDT=y
133CONFIG_MFD_MC13XXX=y 148CONFIG_MFD_MC13XXX_SPI=y
149CONFIG_MFD_MC13XXX_I2C=y
134CONFIG_REGULATOR=y 150CONFIG_REGULATOR=y
135CONFIG_REGULATOR_FIXED_VOLTAGE=y 151CONFIG_REGULATOR_FIXED_VOLTAGE=y
136CONFIG_REGULATOR_MC13783=y 152CONFIG_REGULATOR_MC13783=y
137CONFIG_REGULATOR_MC13892=y 153CONFIG_REGULATOR_MC13892=y
138CONFIG_MEDIA_SUPPORT=y 154CONFIG_MEDIA_SUPPORT=y
139CONFIG_VIDEO_V4L2=y
140CONFIG_VIDEO_DEV=y 155CONFIG_VIDEO_DEV=y
141CONFIG_VIDEO_V4L2_COMMON=y
142CONFIG_VIDEOBUF_GEN=y
143CONFIG_VIDEOBUF2_CORE=y
144CONFIG_VIDEOBUF2_MEMOPS=y
145CONFIG_VIDEOBUF2_DMA_CONTIG=y
146CONFIG_VIDEO_CAPTURE_DRIVERS=y
147CONFIG_V4L_PLATFORM_DRIVERS=y 156CONFIG_V4L_PLATFORM_DRIVERS=y
148CONFIG_SOC_CAMERA=y 157CONFIG_SOC_CAMERA=y
149CONFIG_SOC_CAMERA_OV2640=y 158CONFIG_SOC_CAMERA_OV2640=y
150CONFIG_MX3_VIDEO=y
151CONFIG_VIDEO_MX3=y 159CONFIG_VIDEO_MX3=y
152CONFIG_FB=y 160CONFIG_FB=y
153CONFIG_FB_MX3=y
154CONFIG_BACKLIGHT_LCD_SUPPORT=y 161CONFIG_BACKLIGHT_LCD_SUPPORT=y
155CONFIG_LCD_CLASS_DEVICE=y 162CONFIG_LCD_CLASS_DEVICE=y
156CONFIG_LCD_L4F00242T03=y 163CONFIG_LCD_L4F00242T03=y
157CONFIG_BACKLIGHT_CLASS_DEVICE=y 164CONFIG_BACKLIGHT_CLASS_DEVICE=y
158CONFIG_BACKLIGHT_GENERIC=y
159CONFIG_DUMMY_CONSOLE=y
160CONFIG_FRAMEBUFFER_CONSOLE=y 165CONFIG_FRAMEBUFFER_CONSOLE=y
161CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y 166CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
162CONFIG_FONTS=y 167CONFIG_FONTS=y
163CONFIG_FONT_8x8=y 168CONFIG_FONT_8x8=y
164CONFIG_FONT_8x16=y 169CONFIG_FONT_8x16=y
165CONFIG_LOGO=y 170CONFIG_LOGO=y
166CONFIG_LOGO_LINUX_MONO=y 171CONFIG_SOUND=y
167CONFIG_LOGO_LINUX_VGA16=y 172CONFIG_SND=y
168CONFIG_LOGO_LINUX_CLUT224=y 173CONFIG_SND_SOC=y
174CONFIG_SND_IMX_SOC=y
175CONFIG_SND_SOC_PHYCORE_AC97=y
176CONFIG_SND_SOC_EUKREA_TLV320=y
177CONFIG_SND_SOC_IMX_SGTL5000=y
178CONFIG_SND_SOC_IMX_MC13783=y
169CONFIG_USB=y 179CONFIG_USB=y
170CONFIG_USB_EHCI_HCD=y 180CONFIG_USB_EHCI_HCD=y
171CONFIG_USB_EHCI_MXC=y 181CONFIG_USB_EHCI_MXC=y
@@ -178,9 +188,13 @@ CONFIG_NEW_LEDS=y
178CONFIG_LEDS_CLASS=y 188CONFIG_LEDS_CLASS=y
179CONFIG_RTC_CLASS=y 189CONFIG_RTC_CLASS=y
180CONFIG_RTC_INTF_DEV_UIE_EMUL=y 190CONFIG_RTC_INTF_DEV_UIE_EMUL=y
191CONFIG_RTC_DRV_MC13XXX=y
181CONFIG_RTC_DRV_MXC=y 192CONFIG_RTC_DRV_MXC=y
182CONFIG_DMADEVICES=y 193CONFIG_DMADEVICES=y
183CONFIG_IMX_SDMA=y 194CONFIG_IMX_SDMA=y
195CONFIG_MXS_DMA=y
196CONFIG_COMMON_CLK_DEBUG=y
197# CONFIG_IOMMU_SUPPORT is not set
184CONFIG_EXT2_FS=y 198CONFIG_EXT2_FS=y
185CONFIG_EXT2_FS_XATTR=y 199CONFIG_EXT2_FS_XATTR=y
186CONFIG_EXT2_FS_POSIX_ACL=y 200CONFIG_EXT2_FS_POSIX_ACL=y
@@ -204,8 +218,9 @@ CONFIG_MSDOS_FS=m
204CONFIG_VFAT_FS=y 218CONFIG_VFAT_FS=y
205CONFIG_TMPFS=y 219CONFIG_TMPFS=y
206CONFIG_CONFIGFS_FS=m 220CONFIG_CONFIGFS_FS=m
221CONFIG_JFFS2_FS=y
222CONFIG_UBIFS_FS=y
207CONFIG_NFS_FS=y 223CONFIG_NFS_FS=y
208CONFIG_NFS_V3=y
209CONFIG_NFS_V3_ACL=y 224CONFIG_NFS_V3_ACL=y
210CONFIG_NFS_V4=y 225CONFIG_NFS_V4=y
211CONFIG_ROOT_NFS=y 226CONFIG_ROOT_NFS=y
@@ -216,14 +231,11 @@ CONFIG_NLS_ISO8859_1=y
216CONFIG_NLS_ISO8859_15=m 231CONFIG_NLS_ISO8859_15=m
217CONFIG_NLS_UTF8=y 232CONFIG_NLS_UTF8=y
218CONFIG_MAGIC_SYSRQ=y 233CONFIG_MAGIC_SYSRQ=y
219CONFIG_DEBUG_FS=y
220# CONFIG_SCHED_DEBUG is not set 234# CONFIG_SCHED_DEBUG is not set
221# CONFIG_DEBUG_BUGVERBOSE is not set 235# CONFIG_DEBUG_BUGVERBOSE is not set
222# CONFIG_FTRACE is not set 236# CONFIG_FTRACE is not set
223# CONFIG_ARM_UNWIND is not set 237# CONFIG_ARM_UNWIND is not set
224CONFIG_SECURITYFS=y 238CONFIG_SECURITYFS=y
225CONFIG_CRYPTO_DEFLATE=m
226CONFIG_CRYPTO_LZO=m
227# CONFIG_CRYPTO_ANSI_CPRNG is not set 239# CONFIG_CRYPTO_ANSI_CPRNG is not set
228# CONFIG_CRYPTO_HW is not set 240# CONFIG_CRYPTO_HW is not set
229CONFIG_CRC_CCITT=m 241CONFIG_CRC_CCITT=m
diff --git a/arch/arm/configs/kzm9d_defconfig b/arch/arm/configs/kzm9d_defconfig
new file mode 100644
index 00000000000..26146ffea1a
--- /dev/null
+++ b/arch/arm/configs/kzm9d_defconfig
@@ -0,0 +1,89 @@
1# CONFIG_ARM_PATCH_PHYS_VIRT is not set
2CONFIG_EXPERIMENTAL=y
3CONFIG_SYSVIPC=y
4CONFIG_NO_HZ=y
5CONFIG_IKCONFIG=y
6CONFIG_IKCONFIG_PROC=y
7CONFIG_LOG_BUF_SHIFT=16
8CONFIG_CC_OPTIMIZE_FOR_SIZE=y
9CONFIG_SYSCTL_SYSCALL=y
10CONFIG_EMBEDDED=y
11CONFIG_SLAB=y
12# CONFIG_BLK_DEV_BSG is not set
13# CONFIG_IOSCHED_DEADLINE is not set
14# CONFIG_IOSCHED_CFQ is not set
15CONFIG_ARCH_SHMOBILE=y
16CONFIG_ARCH_EMEV2=y
17CONFIG_MACH_KZM9D=y
18CONFIG_MEMORY_START=0x40000000
19CONFIG_MEMORY_SIZE=0x10000000
20# CONFIG_SH_TIMER_TMU is not set
21# CONFIG_SWP_EMULATE is not set
22# CONFIG_CACHE_L2X0 is not set
23CONFIG_SMP=y
24CONFIG_NR_CPUS=2
25CONFIG_HOTPLUG_CPU=y
26# CONFIG_LOCAL_TIMERS is not set
27CONFIG_AEABI=y
28# CONFIG_OABI_COMPAT is not set
29# CONFIG_CROSS_MEMORY_ATTACH is not set
30CONFIG_FORCE_MAX_ZONEORDER=13
31CONFIG_ZBOOT_ROM_TEXT=0x0
32CONFIG_ZBOOT_ROM_BSS=0x0
33CONFIG_ARM_APPENDED_DTB=y
34CONFIG_CMDLINE="console=tty0 console=ttyS1,115200n81 earlyprintk=serial8250-em.1,115200n81 mem=128M@0x40000000 ignore_loglevel root=/dev/nfs ip=dhcp nfsroot=,rsize=4096,wsize=4096"
35CONFIG_CMDLINE_FORCE=y
36CONFIG_VFP=y
37# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
38# CONFIG_SUSPEND is not set
39CONFIG_NET=y
40CONFIG_PACKET=y
41CONFIG_UNIX=y
42CONFIG_INET=y
43CONFIG_IP_PNP=y
44CONFIG_IP_PNP_DHCP=y
45# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
46# CONFIG_INET_XFRM_MODE_TUNNEL is not set
47# CONFIG_INET_XFRM_MODE_BEET is not set
48# CONFIG_INET_LRO is not set
49# CONFIG_INET_DIAG is not set
50# CONFIG_IPV6 is not set
51# CONFIG_WIRELESS is not set
52CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
53# CONFIG_BLK_DEV is not set
54CONFIG_NETDEVICES=y
55# CONFIG_NET_VENDOR_BROADCOM is not set
56# CONFIG_NET_VENDOR_CHELSIO is not set
57# CONFIG_NET_VENDOR_CIRRUS is not set
58# CONFIG_NET_VENDOR_FARADAY is not set
59# CONFIG_NET_VENDOR_INTEL is not set
60# CONFIG_NET_VENDOR_MARVELL is not set
61# CONFIG_NET_VENDOR_MICREL is not set
62# CONFIG_NET_VENDOR_NATSEMI is not set
63# CONFIG_NET_VENDOR_SEEQ is not set
64CONFIG_SMSC911X=y
65# CONFIG_NET_VENDOR_STMICRO is not set
66# CONFIG_NET_VENDOR_WIZNET is not set
67# CONFIG_WLAN is not set
68# CONFIG_INPUT_MOUSEDEV is not set
69# CONFIG_INPUT_KEYBOARD is not set
70# CONFIG_INPUT_MOUSE is not set
71# CONFIG_SERIO is not set
72# CONFIG_LEGACY_PTYS is not set
73# CONFIG_DEVKMEM is not set
74CONFIG_SERIAL_8250=y
75CONFIG_SERIAL_8250_CONSOLE=y
76CONFIG_SERIAL_8250_EM=y
77# CONFIG_HW_RANDOM is not set
78CONFIG_GPIOLIB=y
79CONFIG_GPIO_EM=y
80# CONFIG_HWMON is not set
81# CONFIG_HID_SUPPORT is not set
82# CONFIG_USB_SUPPORT is not set
83# CONFIG_IOMMU_SUPPORT is not set
84# CONFIG_DNOTIFY is not set
85CONFIG_TMPFS=y
86# CONFIG_MISC_FILESYSTEMS is not set
87CONFIG_NFS_FS=y
88CONFIG_ROOT_NFS=y
89# CONFIG_FTRACE is not set
diff --git a/arch/arm/configs/kzm9g_defconfig b/arch/arm/configs/kzm9g_defconfig
index e3ebc20ed0a..2388c861062 100644
--- a/arch/arm/configs/kzm9g_defconfig
+++ b/arch/arm/configs/kzm9g_defconfig
@@ -100,7 +100,12 @@ CONFIG_SND_SOC_SH4_FSI=y
100CONFIG_USB=y 100CONFIG_USB=y
101CONFIG_USB_DEVICEFS=y 101CONFIG_USB_DEVICEFS=y
102CONFIG_USB_R8A66597_HCD=y 102CONFIG_USB_R8A66597_HCD=y
103CONFIG_USB_RENESAS_USBHS=y
103CONFIG_USB_STORAGE=y 104CONFIG_USB_STORAGE=y
105CONFIG_USB_GADGET=y
106CONFIG_USB_RENESAS_USBHS_UDC=y
107CONFIG_USB_ETH=m
108CONFIG_USB_MASS_STORAGE=m
104CONFIG_MMC=y 109CONFIG_MMC=y
105# CONFIG_MMC_BLOCK_BOUNCE is not set 110# CONFIG_MMC_BLOCK_BOUNCE is not set
106CONFIG_MMC_SDHI=y 111CONFIG_MMC_SDHI=y
@@ -108,12 +113,13 @@ CONFIG_MMC_SH_MMCIF=y
108CONFIG_NEW_LEDS=y 113CONFIG_NEW_LEDS=y
109CONFIG_LEDS_CLASS=y 114CONFIG_LEDS_CLASS=y
110CONFIG_RTC_CLASS=y 115CONFIG_RTC_CLASS=y
116CONFIG_RTC_DRV_RS5C372=y
111CONFIG_DMADEVICES=y 117CONFIG_DMADEVICES=y
112CONFIG_SH_DMAE=y 118CONFIG_SH_DMAE=y
113CONFIG_ASYNC_TX_DMA=y 119CONFIG_ASYNC_TX_DMA=y
114CONFIG_STAGING=y 120CONFIG_STAGING=y
115# CONFIG_DNOTIFY is not set 121# CONFIG_DNOTIFY is not set
116# CONFIG_INOTIFY_USER is not set 122CONFIG_INOTIFY_USER=y
117CONFIG_VFAT_FS=y 123CONFIG_VFAT_FS=y
118CONFIG_TMPFS=y 124CONFIG_TMPFS=y
119# CONFIG_MISC_FILESYSTEMS is not set 125# CONFIG_MISC_FILESYSTEMS is not set
diff --git a/arch/arm/configs/lpc32xx_defconfig b/arch/arm/configs/lpc32xx_defconfig
index 4fa60547494..e42a0e3d4c3 100644
--- a/arch/arm/configs/lpc32xx_defconfig
+++ b/arch/arm/configs/lpc32xx_defconfig
@@ -1,5 +1,7 @@
1CONFIG_EXPERIMENTAL=y 1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
3CONFIG_NO_HZ=y
4CONFIG_HIGH_RES_TIMERS=y
3CONFIG_IKCONFIG=y 5CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y 6CONFIG_IKCONFIG_PROC=y
5CONFIG_LOG_BUF_SHIFT=16 7CONFIG_LOG_BUF_SHIFT=16
@@ -16,8 +18,7 @@ CONFIG_MODULE_UNLOAD=y
16# CONFIG_BLK_DEV_BSG is not set 18# CONFIG_BLK_DEV_BSG is not set
17CONFIG_PARTITION_ADVANCED=y 19CONFIG_PARTITION_ADVANCED=y
18CONFIG_ARCH_LPC32XX=y 20CONFIG_ARCH_LPC32XX=y
19CONFIG_NO_HZ=y 21CONFIG_KEYBOARD_GPIO_POLLED=y
20CONFIG_HIGH_RES_TIMERS=y
21CONFIG_PREEMPT=y 22CONFIG_PREEMPT=y
22CONFIG_AEABI=y 23CONFIG_AEABI=y
23CONFIG_ZBOOT_ROM_TEXT=0x0 24CONFIG_ZBOOT_ROM_TEXT=0x0
@@ -52,13 +53,17 @@ CONFIG_MTD=y
52CONFIG_MTD_CMDLINE_PARTS=y 53CONFIG_MTD_CMDLINE_PARTS=y
53CONFIG_MTD_CHAR=y 54CONFIG_MTD_CHAR=y
54CONFIG_MTD_BLOCK=y 55CONFIG_MTD_BLOCK=y
56CONFIG_MTD_M25P80=y
55CONFIG_MTD_NAND=y 57CONFIG_MTD_NAND=y
56CONFIG_MTD_NAND_MUSEUM_IDS=y 58CONFIG_MTD_NAND_MUSEUM_IDS=y
59CONFIG_MTD_NAND_SLC_LPC32XX=y
60CONFIG_MTD_NAND_MLC_LPC32XX=y
57CONFIG_BLK_DEV_LOOP=y 61CONFIG_BLK_DEV_LOOP=y
58CONFIG_BLK_DEV_CRYPTOLOOP=y 62CONFIG_BLK_DEV_CRYPTOLOOP=y
59CONFIG_BLK_DEV_RAM=y 63CONFIG_BLK_DEV_RAM=y
60CONFIG_BLK_DEV_RAM_COUNT=1 64CONFIG_BLK_DEV_RAM_COUNT=1
61CONFIG_BLK_DEV_RAM_SIZE=16384 65CONFIG_BLK_DEV_RAM_SIZE=16384
66CONFIG_EEPROM_AT24=y
62CONFIG_EEPROM_AT25=y 67CONFIG_EEPROM_AT25=y
63CONFIG_SCSI=y 68CONFIG_SCSI=y
64CONFIG_BLK_DEV_SD=y 69CONFIG_BLK_DEV_SD=y
@@ -79,16 +84,23 @@ CONFIG_LPC_ENET=y
79# CONFIG_NET_VENDOR_STMICRO is not set 84# CONFIG_NET_VENDOR_STMICRO is not set
80CONFIG_SMSC_PHY=y 85CONFIG_SMSC_PHY=y
81# CONFIG_WLAN is not set 86# CONFIG_WLAN is not set
87CONFIG_INPUT_MATRIXKMAP=y
82# CONFIG_INPUT_MOUSEDEV_PSAUX is not set 88# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
83CONFIG_INPUT_MOUSEDEV_SCREEN_X=240 89CONFIG_INPUT_MOUSEDEV_SCREEN_X=240
84CONFIG_INPUT_MOUSEDEV_SCREEN_Y=320 90CONFIG_INPUT_MOUSEDEV_SCREEN_Y=320
85CONFIG_INPUT_EVDEV=y 91CONFIG_INPUT_EVDEV=y
92# CONFIG_KEYBOARD_ATKBD is not set
93CONFIG_KEYBOARD_GPIO=y
94CONFIG_KEYBOARD_LPC32XX=y
86# CONFIG_INPUT_MOUSE is not set 95# CONFIG_INPUT_MOUSE is not set
87CONFIG_INPUT_TOUCHSCREEN=y 96CONFIG_INPUT_TOUCHSCREEN=y
88CONFIG_TOUCHSCREEN_LPC32XX=y 97CONFIG_TOUCHSCREEN_LPC32XX=y
98CONFIG_SERIO_LIBPS2=y
89# CONFIG_LEGACY_PTYS is not set 99# CONFIG_LEGACY_PTYS is not set
90CONFIG_SERIAL_8250=y 100CONFIG_SERIAL_8250=y
91CONFIG_SERIAL_8250_CONSOLE=y 101CONFIG_SERIAL_8250_CONSOLE=y
102CONFIG_SERIAL_HS_LPC32XX=y
103CONFIG_SERIAL_OF_PLATFORM=y
92# CONFIG_HW_RANDOM is not set 104# CONFIG_HW_RANDOM is not set
93CONFIG_I2C=y 105CONFIG_I2C=y
94CONFIG_I2C_CHARDEV=y 106CONFIG_I2C_CHARDEV=y
@@ -96,7 +108,8 @@ CONFIG_I2C_PNX=y
96CONFIG_SPI=y 108CONFIG_SPI=y
97CONFIG_SPI_PL022=y 109CONFIG_SPI_PL022=y
98CONFIG_GPIO_SYSFS=y 110CONFIG_GPIO_SYSFS=y
99# CONFIG_HWMON is not set 111CONFIG_SENSORS_DS620=y
112CONFIG_SENSORS_MAX6639=y
100CONFIG_WATCHDOG=y 113CONFIG_WATCHDOG=y
101CONFIG_PNX4008_WATCHDOG=y 114CONFIG_PNX4008_WATCHDOG=y
102CONFIG_FB=y 115CONFIG_FB=y
@@ -133,6 +146,8 @@ CONFIG_MMC=y
133CONFIG_MMC_ARMMMCI=y 146CONFIG_MMC_ARMMMCI=y
134CONFIG_NEW_LEDS=y 147CONFIG_NEW_LEDS=y
135CONFIG_LEDS_CLASS=y 148CONFIG_LEDS_CLASS=y
149CONFIG_LEDS_PCA9532=y
150CONFIG_LEDS_PCA9532_GPIO=y
136CONFIG_LEDS_GPIO=y 151CONFIG_LEDS_GPIO=y
137CONFIG_LEDS_TRIGGERS=y 152CONFIG_LEDS_TRIGGERS=y
138CONFIG_LEDS_TRIGGER_TIMER=y 153CONFIG_LEDS_TRIGGER_TIMER=y
@@ -146,10 +161,10 @@ CONFIG_RTC_DRV_DS1374=y
146CONFIG_RTC_DRV_PCF8563=y 161CONFIG_RTC_DRV_PCF8563=y
147CONFIG_RTC_DRV_LPC32XX=y 162CONFIG_RTC_DRV_LPC32XX=y
148CONFIG_DMADEVICES=y 163CONFIG_DMADEVICES=y
149CONFIG_AMBA_PL08X=y
150CONFIG_STAGING=y 164CONFIG_STAGING=y
151CONFIG_IIO=y
152CONFIG_LPC32XX_ADC=y 165CONFIG_LPC32XX_ADC=y
166CONFIG_MAX517=y
167CONFIG_IIO=y
153CONFIG_EXT2_FS=y 168CONFIG_EXT2_FS=y
154CONFIG_AUTOFS4_FS=y 169CONFIG_AUTOFS4_FS=y
155CONFIG_MSDOS_FS=y 170CONFIG_MSDOS_FS=y
@@ -159,7 +174,6 @@ CONFIG_JFFS2_FS=y
159CONFIG_JFFS2_FS_WBUF_VERIFY=y 174CONFIG_JFFS2_FS_WBUF_VERIFY=y
160CONFIG_CRAMFS=y 175CONFIG_CRAMFS=y
161CONFIG_NFS_FS=y 176CONFIG_NFS_FS=y
162CONFIG_NFS_V3=y
163CONFIG_ROOT_NFS=y 177CONFIG_ROOT_NFS=y
164CONFIG_NLS_CODEPAGE_437=y 178CONFIG_NLS_CODEPAGE_437=y
165CONFIG_NLS_ASCII=y 179CONFIG_NLS_ASCII=y
diff --git a/arch/arm/configs/mvebu_defconfig b/arch/arm/configs/mvebu_defconfig
new file mode 100644
index 00000000000..2e86b31c33c
--- /dev/null
+++ b/arch/arm/configs/mvebu_defconfig
@@ -0,0 +1,46 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y
3CONFIG_NO_HZ=y
4CONFIG_HIGH_RES_TIMERS=y
5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_BLK_DEV_INITRD=y
7CONFIG_EXPERT=y
8CONFIG_SLAB=y
9CONFIG_MODULES=y
10CONFIG_MODULE_UNLOAD=y
11CONFIG_ARCH_MVEBU=y
12CONFIG_MACH_ARMADA_370_XP=y
13CONFIG_AEABI=y
14CONFIG_HIGHMEM=y
15CONFIG_USE_OF=y
16CONFIG_ZBOOT_ROM_TEXT=0x0
17CONFIG_ZBOOT_ROM_BSS=0x0
18CONFIG_ARM_APPENDED_DTB=y
19CONFIG_VFP=y
20CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
21CONFIG_SERIAL_8250=y
22CONFIG_SERIAL_8250_CONSOLE=y
23CONFIG_SERIAL_OF_PLATFORM=y
24CONFIG_EXT2_FS=y
25CONFIG_EXT3_FS=y
26# CONFIG_EXT3_FS_XATTR is not set
27CONFIG_ISO9660_FS=y
28CONFIG_JOLIET=y
29CONFIG_UDF_FS=m
30CONFIG_MSDOS_FS=y
31CONFIG_VFAT_FS=y
32CONFIG_TMPFS=y
33CONFIG_NLS_CODEPAGE_437=y
34CONFIG_NLS_CODEPAGE_850=y
35CONFIG_NLS_ISO8859_1=y
36CONFIG_NLS_ISO8859_2=y
37CONFIG_NLS_UTF8=y
38CONFIG_MAGIC_SYSRQ=y
39CONFIG_DEBUG_FS=y
40# CONFIG_SCHED_DEBUG is not set
41CONFIG_TIMER_STATS=y
42# CONFIG_DEBUG_BUGVERBOSE is not set
43CONFIG_DEBUG_INFO=y
44CONFIG_DEBUG_USER=y
45CONFIG_DEBUG_LL=y
46CONFIG_EARLY_PRINTK=y
diff --git a/arch/arm/configs/mxs_defconfig b/arch/arm/configs/mxs_defconfig
index 5406c23a02e..4edcfb4e4de 100644
--- a/arch/arm/configs/mxs_defconfig
+++ b/arch/arm/configs/mxs_defconfig
@@ -28,12 +28,12 @@ CONFIG_MACH_MX28EVK=y
28CONFIG_MACH_STMP378X_DEVB=y 28CONFIG_MACH_STMP378X_DEVB=y
29CONFIG_MACH_TX28=y 29CONFIG_MACH_TX28=y
30CONFIG_MACH_M28EVK=y 30CONFIG_MACH_M28EVK=y
31CONFIG_MACH_APX4DEVKIT=y
31# CONFIG_ARM_THUMB is not set 32# CONFIG_ARM_THUMB is not set
32CONFIG_NO_HZ=y 33CONFIG_NO_HZ=y
33CONFIG_HIGH_RES_TIMERS=y 34CONFIG_HIGH_RES_TIMERS=y
34CONFIG_PREEMPT_VOLUNTARY=y 35CONFIG_PREEMPT_VOLUNTARY=y
35CONFIG_AEABI=y 36CONFIG_AEABI=y
36CONFIG_DEFAULT_MMAP_MIN_ADDR=65536
37CONFIG_AUTO_ZRELADDR=y 37CONFIG_AUTO_ZRELADDR=y
38CONFIG_FPE_NWFPE=y 38CONFIG_FPE_NWFPE=y
39CONFIG_NET=y 39CONFIG_NET=y
@@ -58,6 +58,9 @@ CONFIG_CAN_FLEXCAN=m
58CONFIG_DEVTMPFS=y 58CONFIG_DEVTMPFS=y
59# CONFIG_FIRMWARE_IN_KERNEL is not set 59# CONFIG_FIRMWARE_IN_KERNEL is not set
60# CONFIG_BLK_DEV is not set 60# CONFIG_BLK_DEV is not set
61CONFIG_MTD=y
62CONFIG_MTD_NAND=y
63CONFIG_MTD_NAND_GPMI_NAND=y
61CONFIG_NETDEVICES=y 64CONFIG_NETDEVICES=y
62CONFIG_NET_ETHERNET=y 65CONFIG_NET_ETHERNET=y
63CONFIG_ENC28J60=y 66CONFIG_ENC28J60=y
@@ -77,6 +80,7 @@ CONFIG_DEVPTS_MULTIPLE_INSTANCES=y
77# CONFIG_DEVKMEM is not set 80# CONFIG_DEVKMEM is not set
78CONFIG_SERIAL_AMBA_PL011=y 81CONFIG_SERIAL_AMBA_PL011=y
79CONFIG_SERIAL_AMBA_PL011_CONSOLE=y 82CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
83CONFIG_SERIAL_MXS_AUART=y
80# CONFIG_HW_RANDOM is not set 84# CONFIG_HW_RANDOM is not set
81CONFIG_I2C=y 85CONFIG_I2C=y
82# CONFIG_I2C_COMPAT is not set 86# CONFIG_I2C_COMPAT is not set
@@ -109,8 +113,10 @@ CONFIG_MMC=y
109CONFIG_MMC_MXS=y 113CONFIG_MMC_MXS=y
110CONFIG_RTC_CLASS=y 114CONFIG_RTC_CLASS=y
111CONFIG_RTC_DRV_DS1307=m 115CONFIG_RTC_DRV_DS1307=m
116CONFIG_RTC_DRV_STMP=y
112CONFIG_DMADEVICES=y 117CONFIG_DMADEVICES=y
113CONFIG_MXS_DMA=y 118CONFIG_MXS_DMA=y
119CONFIG_COMMON_CLK_DEBUG=y
114CONFIG_EXT3_FS=y 120CONFIG_EXT3_FS=y
115# CONFIG_DNOTIFY is not set 121# CONFIG_DNOTIFY is not set
116CONFIG_FSCACHE=m 122CONFIG_FSCACHE=m
diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
index 11828e63253..e58edc36b40 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -193,9 +193,12 @@ CONFIG_MMC_OMAP_HS=y
193CONFIG_RTC_CLASS=y 193CONFIG_RTC_CLASS=y
194CONFIG_RTC_DRV_TWL92330=y 194CONFIG_RTC_DRV_TWL92330=y
195CONFIG_RTC_DRV_TWL4030=y 195CONFIG_RTC_DRV_TWL4030=y
196CONFIG_DMADEVICES=y
197CONFIG_DMA_OMAP=y
196CONFIG_EXT2_FS=y 198CONFIG_EXT2_FS=y
197CONFIG_EXT3_FS=y 199CONFIG_EXT3_FS=y
198# CONFIG_EXT3_FS_XATTR is not set 200# CONFIG_EXT3_FS_XATTR is not set
201CONFIG_EXT4_FS=y
199CONFIG_QUOTA=y 202CONFIG_QUOTA=y
200CONFIG_QFMT_V2=y 203CONFIG_QFMT_V2=y
201CONFIG_MSDOS_FS=y 204CONFIG_MSDOS_FS=y
@@ -235,3 +238,4 @@ CONFIG_CRC_T10DIF=y
235CONFIG_CRC_ITU_T=y 238CONFIG_CRC_ITU_T=y
236CONFIG_CRC7=y 239CONFIG_CRC7=y
237CONFIG_LIBCRC32C=y 240CONFIG_LIBCRC32C=y
241CONFIG_SOC_OMAP5=y
diff --git a/arch/arm/configs/socfpga_defconfig b/arch/arm/configs/socfpga_defconfig
new file mode 100644
index 00000000000..0ac1293dba1
--- /dev/null
+++ b/arch/arm/configs/socfpga_defconfig
@@ -0,0 +1,83 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y
3CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y
5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_CGROUPS=y
7CONFIG_CPUSETS=y
8CONFIG_NAMESPACES=y
9CONFIG_EMBEDDED=y
10CONFIG_PROFILING=y
11CONFIG_OPROFILE=y
12CONFIG_MODULES=y
13CONFIG_MODULE_UNLOAD=y
14# CONFIG_LBDAF is not set
15# CONFIG_BLK_DEV_BSG is not set
16# CONFIG_IOSCHED_DEADLINE is not set
17# CONFIG_IOSCHED_CFQ is not set
18CONFIG_ARCH_SOCFPGA=y
19CONFIG_MACH_SOCFPGA_CYCLONE5=y
20CONFIG_ARM_THUMBEE=y
21# CONFIG_CACHE_L2X0 is not set
22CONFIG_HIGH_RES_TIMERS=y
23CONFIG_VMSPLIT_2G=y
24CONFIG_NR_CPUS=2
25CONFIG_AEABI=y
26CONFIG_ZBOOT_ROM_TEXT=0x0
27CONFIG_ZBOOT_ROM_BSS=0x0
28CONFIG_CMDLINE=""
29CONFIG_VFP=y
30CONFIG_NEON=y
31CONFIG_NET=y
32CONFIG_PACKET=y
33CONFIG_UNIX=y
34CONFIG_NET_KEY=y
35CONFIG_NET_KEY_MIGRATE=y
36CONFIG_INET=y
37CONFIG_IP_MULTICAST=y
38CONFIG_IP_PNP=y
39CONFIG_IP_PNP_DHCP=y
40CONFIG_IP_PNP_BOOTP=y
41CONFIG_IP_PNP_RARP=y
42CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
43CONFIG_DEVTMPFS=y
44CONFIG_PROC_DEVICETREE=y
45CONFIG_BLK_DEV_RAM=y
46CONFIG_BLK_DEV_RAM_COUNT=2
47CONFIG_BLK_DEV_RAM_SIZE=8192
48CONFIG_SCSI=y
49# CONFIG_SCSI_PROC_FS is not set
50CONFIG_BLK_DEV_SD=y
51# CONFIG_SCSI_LOWLEVEL is not set
52CONFIG_NETDEVICES=y
53CONFIG_STMMAC_ETH=y
54# CONFIG_STMMAC_PHY_ID_ZERO_WORKAROUND is not set
55CONFIG_INPUT_EVDEV=y
56# CONFIG_SERIO_SERPORT is not set
57CONFIG_SERIO_AMBAKMI=y
58CONFIG_LEGACY_PTY_COUNT=16
59CONFIG_SERIAL_8250=y
60CONFIG_SERIAL_8250_CONSOLE=y
61CONFIG_SERIAL_8250_NR_UARTS=2
62CONFIG_SERIAL_8250_RUNTIME_UARTS=2
63CONFIG_SERIAL_8250_DW=y
64# CONFIG_RTC_HCTOSYS is not set
65CONFIG_EXT2_FS=y
66CONFIG_EXT2_FS_XATTR=y
67CONFIG_EXT2_FS_POSIX_ACL=y
68# CONFIG_DNOTIFY is not set
69# CONFIG_INOTIFY_USER is not set
70CONFIG_VFAT_FS=y
71CONFIG_NTFS_FS=y
72CONFIG_NTFS_RW=y
73CONFIG_TMPFS=y
74CONFIG_JFFS2_FS=y
75CONFIG_NLS_CODEPAGE_437=y
76CONFIG_NLS_ISO8859_1=y
77CONFIG_MAGIC_SYSRQ=y
78CONFIG_DETECT_HUNG_TASK=y
79# CONFIG_SCHED_DEBUG is not set
80CONFIG_DEBUG_INFO=y
81CONFIG_ENABLE_DEFAULT_TRACERS=y
82CONFIG_DEBUG_USER=y
83CONFIG_XZ_DEC=y
diff --git a/arch/arm/configs/tct_hammer_defconfig b/arch/arm/configs/tct_hammer_defconfig
index 1d24f8458be..71277a1591b 100644
--- a/arch/arm/configs/tct_hammer_defconfig
+++ b/arch/arm/configs/tct_hammer_defconfig
@@ -7,7 +7,7 @@ CONFIG_SYSFS_DEPRECATED_V2=y
7CONFIG_BLK_DEV_INITRD=y 7CONFIG_BLK_DEV_INITRD=y
8CONFIG_EXPERT=y 8CONFIG_EXPERT=y
9# CONFIG_KALLSYMS is not set 9# CONFIG_KALLSYMS is not set
10# CONFIG_BUG is not set 10# CONFIG_BUGVERBOSE is not set
11# CONFIG_ELF_CORE is not set 11# CONFIG_ELF_CORE is not set
12# CONFIG_SHMEM is not set 12# CONFIG_SHMEM is not set
13CONFIG_SLOB=y 13CONFIG_SLOB=y
diff --git a/arch/arm/configs/tegra_defconfig b/arch/arm/configs/tegra_defconfig
index 1198dd61c7c..db2245353f0 100644
--- a/arch/arm/configs/tegra_defconfig
+++ b/arch/arm/configs/tegra_defconfig
@@ -1,4 +1,6 @@
1CONFIG_EXPERIMENTAL=y 1CONFIG_EXPERIMENTAL=y
2CONFIG_NO_HZ=y
3CONFIG_HIGH_RES_TIMERS=y
2CONFIG_IKCONFIG=y 4CONFIG_IKCONFIG=y
3CONFIG_IKCONFIG_PROC=y 5CONFIG_IKCONFIG_PROC=y
4CONFIG_CGROUPS=y 6CONFIG_CGROUPS=y
@@ -25,14 +27,9 @@ CONFIG_ARCH_TEGRA=y
25CONFIG_ARCH_TEGRA_2x_SOC=y 27CONFIG_ARCH_TEGRA_2x_SOC=y
26CONFIG_ARCH_TEGRA_3x_SOC=y 28CONFIG_ARCH_TEGRA_3x_SOC=y
27CONFIG_MACH_HARMONY=y 29CONFIG_MACH_HARMONY=y
28CONFIG_MACH_KAEN=y
29CONFIG_MACH_PAZ00=y 30CONFIG_MACH_PAZ00=y
30CONFIG_MACH_TRIMSLICE=y 31CONFIG_MACH_TRIMSLICE=y
31CONFIG_MACH_WARIO=y
32CONFIG_MACH_VENTANA=y
33CONFIG_TEGRA_EMC_SCALING_ENABLE=y 32CONFIG_TEGRA_EMC_SCALING_ENABLE=y
34CONFIG_NO_HZ=y
35CONFIG_HIGH_RES_TIMERS=y
36CONFIG_SMP=y 33CONFIG_SMP=y
37CONFIG_PREEMPT=y 34CONFIG_PREEMPT=y
38CONFIG_AEABI=y 35CONFIG_AEABI=y
@@ -103,19 +100,25 @@ CONFIG_SERIAL_OF_PLATFORM=y
103# CONFIG_HW_RANDOM is not set 100# CONFIG_HW_RANDOM is not set
104CONFIG_I2C=y 101CONFIG_I2C=y
105# CONFIG_I2C_COMPAT is not set 102# CONFIG_I2C_COMPAT is not set
103CONFIG_I2C_MUX=y
104CONFIG_I2C_MUX_PINCTRL=y
106CONFIG_I2C_TEGRA=y 105CONFIG_I2C_TEGRA=y
107CONFIG_SPI=y 106CONFIG_SPI=y
108CONFIG_SPI_TEGRA=y 107CONFIG_SPI_TEGRA=y
108CONFIG_GPIO_TPS65910=y
109CONFIG_GPIO_TPS6586X=y
109CONFIG_POWER_SUPPLY=y 110CONFIG_POWER_SUPPLY=y
110CONFIG_BATTERY_SBS=y 111CONFIG_BATTERY_SBS=y
111CONFIG_SENSORS_LM90=y 112CONFIG_SENSORS_LM90=y
112CONFIG_MFD_TPS6586X=y 113CONFIG_MFD_TPS6586X=y
114CONFIG_MFD_TPS65910=y
113CONFIG_REGULATOR=y 115CONFIG_REGULATOR=y
114CONFIG_REGULATOR_FIXED_VOLTAGE=y 116CONFIG_REGULATOR_FIXED_VOLTAGE=y
115CONFIG_REGULATOR_VIRTUAL_CONSUMER=y 117CONFIG_REGULATOR_VIRTUAL_CONSUMER=y
116CONFIG_REGULATOR_GPIO=y 118CONFIG_REGULATOR_GPIO=y
117CONFIG_REGULATOR_TPS62360=y 119CONFIG_REGULATOR_TPS62360=y
118CONFIG_REGULATOR_TPS6586X=y 120CONFIG_REGULATOR_TPS6586X=y
121CONFIG_REGULATOR_TPS65910=y
119CONFIG_SOUND=y 122CONFIG_SOUND=y
120CONFIG_SND=y 123CONFIG_SND=y
121# CONFIG_SND_SUPPORT_OLD_API is not set 124# CONFIG_SND_SUPPORT_OLD_API is not set
@@ -126,6 +129,7 @@ CONFIG_SND=y
126# CONFIG_SND_USB is not set 129# CONFIG_SND_USB is not set
127CONFIG_SND_SOC=y 130CONFIG_SND_SOC=y
128CONFIG_SND_SOC_TEGRA=y 131CONFIG_SND_SOC_TEGRA=y
132CONFIG_SND_SOC_TEGRA_WM8753=y
129CONFIG_SND_SOC_TEGRA_WM8903=y 133CONFIG_SND_SOC_TEGRA_WM8903=y
130CONFIG_SND_SOC_TEGRA_TRIMSLICE=y 134CONFIG_SND_SOC_TEGRA_TRIMSLICE=y
131CONFIG_SND_SOC_TEGRA_ALC5632=y 135CONFIG_SND_SOC_TEGRA_ALC5632=y
diff --git a/arch/arm/configs/u8500_defconfig b/arch/arm/configs/u8500_defconfig
index 2d4f661d1cf..da6845493ca 100644
--- a/arch/arm/configs/u8500_defconfig
+++ b/arch/arm/configs/u8500_defconfig
@@ -86,6 +86,7 @@ CONFIG_NEW_LEDS=y
86CONFIG_LEDS_CLASS=y 86CONFIG_LEDS_CLASS=y
87CONFIG_LEDS_LM3530=y 87CONFIG_LEDS_LM3530=y
88CONFIG_LEDS_LP5521=y 88CONFIG_LEDS_LP5521=y
89CONFIG_LEDS_GPIO=y
89CONFIG_RTC_CLASS=y 90CONFIG_RTC_CLASS=y
90CONFIG_RTC_DRV_AB8500=y 91CONFIG_RTC_DRV_AB8500=y
91CONFIG_RTC_DRV_PL031=y 92CONFIG_RTC_DRV_PL031=y
diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
index ed2e95d46e2..62e75475e57 100644
--- a/arch/arm/include/asm/arch_timer.h
+++ b/arch/arm/include/asm/arch_timer.h
@@ -1,7 +1,10 @@
1#ifndef __ASMARM_ARCH_TIMER_H 1#ifndef __ASMARM_ARCH_TIMER_H
2#define __ASMARM_ARCH_TIMER_H 2#define __ASMARM_ARCH_TIMER_H
3 3
4#include <asm/errno.h>
5
4#ifdef CONFIG_ARM_ARCH_TIMER 6#ifdef CONFIG_ARM_ARCH_TIMER
7#define ARCH_HAS_READ_CURRENT_TIMER
5int arch_timer_of_register(void); 8int arch_timer_of_register(void);
6int arch_timer_sched_clock_init(void); 9int arch_timer_sched_clock_init(void);
7#else 10#else
diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
index 004c1bc95d2..e4448e16046 100644
--- a/arch/arm/include/asm/cacheflush.h
+++ b/arch/arm/include/asm/cacheflush.h
@@ -215,7 +215,9 @@ static inline void vivt_flush_cache_mm(struct mm_struct *mm)
215static inline void 215static inline void
216vivt_flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end) 216vivt_flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
217{ 217{
218 if (cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm))) 218 struct mm_struct *mm = vma->vm_mm;
219
220 if (!mm || cpumask_test_cpu(smp_processor_id(), mm_cpumask(mm)))
219 __cpuc_flush_user_range(start & PAGE_MASK, PAGE_ALIGN(end), 221 __cpuc_flush_user_range(start & PAGE_MASK, PAGE_ALIGN(end),
220 vma->vm_flags); 222 vma->vm_flags);
221} 223}
@@ -223,7 +225,9 @@ vivt_flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned
223static inline void 225static inline void
224vivt_flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr, unsigned long pfn) 226vivt_flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr, unsigned long pfn)
225{ 227{
226 if (cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm))) { 228 struct mm_struct *mm = vma->vm_mm;
229
230 if (!mm || cpumask_test_cpu(smp_processor_id(), mm_cpumask(mm))) {
227 unsigned long addr = user_addr & PAGE_MASK; 231 unsigned long addr = user_addr & PAGE_MASK;
228 __cpuc_flush_user_range(addr, addr + PAGE_SIZE, vma->vm_flags); 232 __cpuc_flush_user_range(addr, addr + PAGE_SIZE, vma->vm_flags);
229 } 233 }
diff --git a/arch/arm/include/asm/delay.h b/arch/arm/include/asm/delay.h
index b2deda18154..dc6145120de 100644
--- a/arch/arm/include/asm/delay.h
+++ b/arch/arm/include/asm/delay.h
@@ -6,9 +6,22 @@
6#ifndef __ASM_ARM_DELAY_H 6#ifndef __ASM_ARM_DELAY_H
7#define __ASM_ARM_DELAY_H 7#define __ASM_ARM_DELAY_H
8 8
9#include <asm/memory.h>
9#include <asm/param.h> /* HZ */ 10#include <asm/param.h> /* HZ */
10 11
11extern void __delay(int loops); 12#define MAX_UDELAY_MS 2
13#define UDELAY_MULT ((UL(2199023) * HZ) >> 11)
14#define UDELAY_SHIFT 30
15
16#ifndef __ASSEMBLY__
17
18extern struct arm_delay_ops {
19 void (*delay)(unsigned long);
20 void (*const_udelay)(unsigned long);
21 void (*udelay)(unsigned long);
22} arm_delay_ops;
23
24#define __delay(n) arm_delay_ops.delay(n)
12 25
13/* 26/*
14 * This function intentionally does not exist; if you see references to 27 * This function intentionally does not exist; if you see references to
@@ -23,22 +36,27 @@ extern void __bad_udelay(void);
23 * division by multiplication: you don't have to worry about 36 * division by multiplication: you don't have to worry about
24 * loss of precision. 37 * loss of precision.
25 * 38 *
26 * Use only for very small delays ( < 1 msec). Should probably use a 39 * Use only for very small delays ( < 2 msec). Should probably use a
27 * lookup table, really, as the multiplications take much too long with 40 * lookup table, really, as the multiplications take much too long with
28 * short delays. This is a "reasonable" implementation, though (and the 41 * short delays. This is a "reasonable" implementation, though (and the
29 * first constant multiplications gets optimized away if the delay is 42 * first constant multiplications gets optimized away if the delay is
30 * a constant) 43 * a constant)
31 */ 44 */
32extern void __udelay(unsigned long usecs); 45#define __udelay(n) arm_delay_ops.udelay(n)
33extern void __const_udelay(unsigned long); 46#define __const_udelay(n) arm_delay_ops.const_udelay(n)
34
35#define MAX_UDELAY_MS 2
36 47
37#define udelay(n) \ 48#define udelay(n) \
38 (__builtin_constant_p(n) ? \ 49 (__builtin_constant_p(n) ? \
39 ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \ 50 ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \
40 __const_udelay((n) * ((2199023U*HZ)>>11))) : \ 51 __const_udelay((n) * UDELAY_MULT)) : \
41 __udelay(n)) 52 __udelay(n))
42 53
54/* Loop-based definitions for assembly code. */
55extern void __loop_delay(unsigned long loops);
56extern void __loop_udelay(unsigned long usecs);
57extern void __loop_const_udelay(unsigned long);
58
59#endif /* __ASSEMBLY__ */
60
43#endif /* defined(_ARM_DELAY_H) */ 61#endif /* defined(_ARM_DELAY_H) */
44 62
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index bbef15d0489..5c44dcb0987 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -186,17 +186,6 @@ extern int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma,
186 void *cpu_addr, dma_addr_t dma_addr, size_t size, 186 void *cpu_addr, dma_addr_t dma_addr, size_t size,
187 struct dma_attrs *attrs); 187 struct dma_attrs *attrs);
188 188
189#define dma_mmap_coherent(d, v, c, h, s) dma_mmap_attrs(d, v, c, h, s, NULL)
190
191static inline int dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
192 void *cpu_addr, dma_addr_t dma_addr,
193 size_t size, struct dma_attrs *attrs)
194{
195 struct dma_map_ops *ops = get_dma_ops(dev);
196 BUG_ON(!ops);
197 return ops->mmap(dev, vma, cpu_addr, dma_addr, size, attrs);
198}
199
200static inline void *dma_alloc_writecombine(struct device *dev, size_t size, 189static inline void *dma_alloc_writecombine(struct device *dev, size_t size,
201 dma_addr_t *dma_handle, gfp_t flag) 190 dma_addr_t *dma_handle, gfp_t flag)
202{ 191{
@@ -213,20 +202,19 @@ static inline void dma_free_writecombine(struct device *dev, size_t size,
213 return dma_free_attrs(dev, size, cpu_addr, dma_handle, &attrs); 202 return dma_free_attrs(dev, size, cpu_addr, dma_handle, &attrs);
214} 203}
215 204
216static inline int dma_mmap_writecombine(struct device *dev, struct vm_area_struct *vma, 205/*
217 void *cpu_addr, dma_addr_t dma_addr, size_t size) 206 * This can be called during early boot to increase the size of the atomic
218{ 207 * coherent DMA pool above the default value of 256KiB. It must be called
219 DEFINE_DMA_ATTRS(attrs); 208 * before postcore_initcall.
220 dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs); 209 */
221 return dma_mmap_attrs(dev, vma, cpu_addr, dma_addr, size, &attrs); 210extern void __init init_dma_coherent_pool_size(unsigned long size);
222}
223 211
224/* 212/*
225 * This can be called during boot to increase the size of the consistent 213 * This can be called during boot to increase the size of the consistent
226 * DMA region above it's default value of 2MB. It must be called before the 214 * DMA region above it's default value of 2MB. It must be called before the
227 * memory allocator is initialised, i.e. before any core_initcall. 215 * memory allocator is initialised, i.e. before any core_initcall.
228 */ 216 */
229extern void __init init_consistent_dma_size(unsigned long size); 217static inline void init_consistent_dma_size(unsigned long size) { }
230 218
231/* 219/*
232 * For SA-1111, IXP425, and ADI systems the dma-mapping functions are "magic" 220 * For SA-1111, IXP425, and ADI systems the dma-mapping functions are "magic"
@@ -280,6 +268,9 @@ extern void arm_dma_sync_sg_for_cpu(struct device *, struct scatterlist *, int,
280 enum dma_data_direction); 268 enum dma_data_direction);
281extern void arm_dma_sync_sg_for_device(struct device *, struct scatterlist *, int, 269extern void arm_dma_sync_sg_for_device(struct device *, struct scatterlist *, int,
282 enum dma_data_direction); 270 enum dma_data_direction);
271extern int arm_dma_get_sgtable(struct device *dev, struct sg_table *sgt,
272 void *cpu_addr, dma_addr_t dma_addr, size_t size,
273 struct dma_attrs *attrs);
283 274
284#endif /* __KERNEL__ */ 275#endif /* __KERNEL__ */
285#endif 276#endif
diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
index e51b1e81df0..83eb2f77291 100644
--- a/arch/arm/include/asm/kmap_types.h
+++ b/arch/arm/include/asm/kmap_types.h
@@ -4,30 +4,6 @@
4/* 4/*
5 * This is the "bare minimum". AIO seems to require this. 5 * This is the "bare minimum". AIO seems to require this.
6 */ 6 */
7enum km_type { 7#define KM_TYPE_NR 16
8 KM_BOUNCE_READ,
9 KM_SKB_SUNRPC_DATA,
10 KM_SKB_DATA_SOFTIRQ,
11 KM_USER0,
12 KM_USER1,
13 KM_BIO_SRC_IRQ,
14 KM_BIO_DST_IRQ,
15 KM_PTE0,
16 KM_PTE1,
17 KM_IRQ0,
18 KM_IRQ1,
19 KM_SOFTIRQ0,
20 KM_SOFTIRQ1,
21 KM_L1_CACHE,
22 KM_L2_CACHE,
23 KM_KDB,
24 KM_TYPE_NR
25};
26
27#ifdef CONFIG_DEBUG_HIGHMEM
28#define KM_NMI (-1)
29#define KM_NMI_PTE (-1)
30#define KM_IRQ_PTE (-1)
31#endif
32 8
33#endif 9#endif
diff --git a/arch/arm/include/asm/locks.h b/arch/arm/include/asm/locks.h
deleted file mode 100644
index ef4c897772d..00000000000
--- a/arch/arm/include/asm/locks.h
+++ /dev/null
@@ -1,274 +0,0 @@
1/*
2 * arch/arm/include/asm/locks.h
3 *
4 * Copyright (C) 2000 Russell King
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 * Interrupt safe locking assembler.
11 */
12#ifndef __ASM_PROC_LOCKS_H
13#define __ASM_PROC_LOCKS_H
14
15#if __LINUX_ARM_ARCH__ >= 6
16
17#define __down_op(ptr,fail) \
18 ({ \
19 __asm__ __volatile__( \
20 "@ down_op\n" \
21"1: ldrex lr, [%0]\n" \
22" sub lr, lr, %1\n" \
23" strex ip, lr, [%0]\n" \
24" teq ip, #0\n" \
25" bne 1b\n" \
26" teq lr, #0\n" \
27" movmi ip, %0\n" \
28" blmi " #fail \
29 : \
30 : "r" (ptr), "I" (1) \
31 : "ip", "lr", "cc"); \
32 smp_mb(); \
33 })
34
35#define __down_op_ret(ptr,fail) \
36 ({ \
37 unsigned int ret; \
38 __asm__ __volatile__( \
39 "@ down_op_ret\n" \
40"1: ldrex lr, [%1]\n" \
41" sub lr, lr, %2\n" \
42" strex ip, lr, [%1]\n" \
43" teq ip, #0\n" \
44" bne 1b\n" \
45" teq lr, #0\n" \
46" movmi ip, %1\n" \
47" movpl ip, #0\n" \
48" blmi " #fail "\n" \
49" mov %0, ip" \
50 : "=&r" (ret) \
51 : "r" (ptr), "I" (1) \
52 : "ip", "lr", "cc"); \
53 smp_mb(); \
54 ret; \
55 })
56
57#define __up_op(ptr,wake) \
58 ({ \
59 smp_mb(); \
60 __asm__ __volatile__( \
61 "@ up_op\n" \
62"1: ldrex lr, [%0]\n" \
63" add lr, lr, %1\n" \
64" strex ip, lr, [%0]\n" \
65" teq ip, #0\n" \
66" bne 1b\n" \
67" cmp lr, #0\n" \
68" movle ip, %0\n" \
69" blle " #wake \
70 : \
71 : "r" (ptr), "I" (1) \
72 : "ip", "lr", "cc"); \
73 })
74
75/*
76 * The value 0x01000000 supports up to 128 processors and
77 * lots of processes. BIAS must be chosen such that sub'ing
78 * BIAS once per CPU will result in the long remaining
79 * negative.
80 */
81#define RW_LOCK_BIAS 0x01000000
82#define RW_LOCK_BIAS_STR "0x01000000"
83
84#define __down_op_write(ptr,fail) \
85 ({ \
86 __asm__ __volatile__( \
87 "@ down_op_write\n" \
88"1: ldrex lr, [%0]\n" \
89" sub lr, lr, %1\n" \
90" strex ip, lr, [%0]\n" \
91" teq ip, #0\n" \
92" bne 1b\n" \
93" teq lr, #0\n" \
94" movne ip, %0\n" \
95" blne " #fail \
96 : \
97 : "r" (ptr), "I" (RW_LOCK_BIAS) \
98 : "ip", "lr", "cc"); \
99 smp_mb(); \
100 })
101
102#define __up_op_write(ptr,wake) \
103 ({ \
104 smp_mb(); \
105 __asm__ __volatile__( \
106 "@ up_op_write\n" \
107"1: ldrex lr, [%0]\n" \
108" adds lr, lr, %1\n" \
109" strex ip, lr, [%0]\n" \
110" teq ip, #0\n" \
111" bne 1b\n" \
112" movcs ip, %0\n" \
113" blcs " #wake \
114 : \
115 : "r" (ptr), "I" (RW_LOCK_BIAS) \
116 : "ip", "lr", "cc"); \
117 })
118
119#define __down_op_read(ptr,fail) \
120 __down_op(ptr, fail)
121
122#define __up_op_read(ptr,wake) \
123 ({ \
124 smp_mb(); \
125 __asm__ __volatile__( \
126 "@ up_op_read\n" \
127"1: ldrex lr, [%0]\n" \
128" add lr, lr, %1\n" \
129" strex ip, lr, [%0]\n" \
130" teq ip, #0\n" \
131" bne 1b\n" \
132" teq lr, #0\n" \
133" moveq ip, %0\n" \
134" bleq " #wake \
135 : \
136 : "r" (ptr), "I" (1) \
137 : "ip", "lr", "cc"); \
138 })
139
140#else
141
142#define __down_op(ptr,fail) \
143 ({ \
144 __asm__ __volatile__( \
145 "@ down_op\n" \
146" mrs ip, cpsr\n" \
147" orr lr, ip, #128\n" \
148" msr cpsr_c, lr\n" \
149" ldr lr, [%0]\n" \
150" subs lr, lr, %1\n" \
151" str lr, [%0]\n" \
152" msr cpsr_c, ip\n" \
153" movmi ip, %0\n" \
154" blmi " #fail \
155 : \
156 : "r" (ptr), "I" (1) \
157 : "ip", "lr", "cc"); \
158 smp_mb(); \
159 })
160
161#define __down_op_ret(ptr,fail) \
162 ({ \
163 unsigned int ret; \
164 __asm__ __volatile__( \
165 "@ down_op_ret\n" \
166" mrs ip, cpsr\n" \
167" orr lr, ip, #128\n" \
168" msr cpsr_c, lr\n" \
169" ldr lr, [%1]\n" \
170" subs lr, lr, %2\n" \
171" str lr, [%1]\n" \
172" msr cpsr_c, ip\n" \
173" movmi ip, %1\n" \
174" movpl ip, #0\n" \
175" blmi " #fail "\n" \
176" mov %0, ip" \
177 : "=&r" (ret) \
178 : "r" (ptr), "I" (1) \
179 : "ip", "lr", "cc"); \
180 smp_mb(); \
181 ret; \
182 })
183
184#define __up_op(ptr,wake) \
185 ({ \
186 smp_mb(); \
187 __asm__ __volatile__( \
188 "@ up_op\n" \
189" mrs ip, cpsr\n" \
190" orr lr, ip, #128\n" \
191" msr cpsr_c, lr\n" \
192" ldr lr, [%0]\n" \
193" adds lr, lr, %1\n" \
194" str lr, [%0]\n" \
195" msr cpsr_c, ip\n" \
196" movle ip, %0\n" \
197" blle " #wake \
198 : \
199 : "r" (ptr), "I" (1) \
200 : "ip", "lr", "cc"); \
201 })
202
203/*
204 * The value 0x01000000 supports up to 128 processors and
205 * lots of processes. BIAS must be chosen such that sub'ing
206 * BIAS once per CPU will result in the long remaining
207 * negative.
208 */
209#define RW_LOCK_BIAS 0x01000000
210#define RW_LOCK_BIAS_STR "0x01000000"
211
212#define __down_op_write(ptr,fail) \
213 ({ \
214 __asm__ __volatile__( \
215 "@ down_op_write\n" \
216" mrs ip, cpsr\n" \
217" orr lr, ip, #128\n" \
218" msr cpsr_c, lr\n" \
219" ldr lr, [%0]\n" \
220" subs lr, lr, %1\n" \
221" str lr, [%0]\n" \
222" msr cpsr_c, ip\n" \
223" movne ip, %0\n" \
224" blne " #fail \
225 : \
226 : "r" (ptr), "I" (RW_LOCK_BIAS) \
227 : "ip", "lr", "cc"); \
228 smp_mb(); \
229 })
230
231#define __up_op_write(ptr,wake) \
232 ({ \
233 __asm__ __volatile__( \
234 "@ up_op_write\n" \
235" mrs ip, cpsr\n" \
236" orr lr, ip, #128\n" \
237" msr cpsr_c, lr\n" \
238" ldr lr, [%0]\n" \
239" adds lr, lr, %1\n" \
240" str lr, [%0]\n" \
241" msr cpsr_c, ip\n" \
242" movcs ip, %0\n" \
243" blcs " #wake \
244 : \
245 : "r" (ptr), "I" (RW_LOCK_BIAS) \
246 : "ip", "lr", "cc"); \
247 smp_mb(); \
248 })
249
250#define __down_op_read(ptr,fail) \
251 __down_op(ptr, fail)
252
253#define __up_op_read(ptr,wake) \
254 ({ \
255 smp_mb(); \
256 __asm__ __volatile__( \
257 "@ up_op_read\n" \
258" mrs ip, cpsr\n" \
259" orr lr, ip, #128\n" \
260" msr cpsr_c, lr\n" \
261" ldr lr, [%0]\n" \
262" adds lr, lr, %1\n" \
263" str lr, [%0]\n" \
264" msr cpsr_c, ip\n" \
265" moveq ip, %0\n" \
266" bleq " #wake \
267 : \
268 : "r" (ptr), "I" (1) \
269 : "ip", "lr", "cc"); \
270 })
271
272#endif
273
274#endif
diff --git a/arch/arm/include/asm/mach/irq.h b/arch/arm/include/asm/mach/irq.h
index febe495d0c6..15cb035309f 100644
--- a/arch/arm/include/asm/mach/irq.h
+++ b/arch/arm/include/asm/mach/irq.h
@@ -17,7 +17,7 @@ struct seq_file;
17/* 17/*
18 * This is internal. Do not use it. 18 * This is internal. Do not use it.
19 */ 19 */
20extern void init_FIQ(void); 20extern void init_FIQ(int);
21extern int show_fiq_list(struct seq_file *, int); 21extern int show_fiq_list(struct seq_file *, int);
22 22
23#ifdef CONFIG_MULTI_IRQ_HANDLER 23#ifdef CONFIG_MULTI_IRQ_HANDLER
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index fcb575747e5..e965f1b560f 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -16,7 +16,7 @@
16#include <linux/compiler.h> 16#include <linux/compiler.h>
17#include <linux/const.h> 17#include <linux/const.h>
18#include <linux/types.h> 18#include <linux/types.h>
19#include <asm/sizes.h> 19#include <linux/sizes.h>
20 20
21#ifdef CONFIG_NEED_MACH_MEMORY_H 21#ifdef CONFIG_NEED_MACH_MEMORY_H
22#include <mach/memory.h> 22#include <mach/memory.h>
diff --git a/arch/arm/include/asm/mutex.h b/arch/arm/include/asm/mutex.h
index 93226cf23ae..b1479fd04a9 100644
--- a/arch/arm/include/asm/mutex.h
+++ b/arch/arm/include/asm/mutex.h
@@ -7,121 +7,10 @@
7 */ 7 */
8#ifndef _ASM_MUTEX_H 8#ifndef _ASM_MUTEX_H
9#define _ASM_MUTEX_H 9#define _ASM_MUTEX_H
10
11#if __LINUX_ARM_ARCH__ < 6
12/* On pre-ARMv6 hardware the swp based implementation is the most efficient. */
13# include <asm-generic/mutex-xchg.h>
14#else
15
16/* 10/*
17 * Attempting to lock a mutex on ARMv6+ can be done with a bastardized 11 * On pre-ARMv6 hardware this results in a swp-based implementation,
18 * atomic decrement (it is not a reliable atomic decrement but it satisfies 12 * which is the most efficient. For ARMv6+, we emit a pair of exclusive
19 * the defined semantics for our purpose, while being smaller and faster 13 * accesses instead.
20 * than a real atomic decrement or atomic swap. The idea is to attempt
21 * decrementing the lock value only once. If once decremented it isn't zero,
22 * or if its store-back fails due to a dispute on the exclusive store, we
23 * simply bail out immediately through the slow path where the lock will be
24 * reattempted until it succeeds.
25 */ 14 */
26static inline void 15#include <asm-generic/mutex-xchg.h>
27__mutex_fastpath_lock(atomic_t *count, void (*fail_fn)(atomic_t *))
28{
29 int __ex_flag, __res;
30
31 __asm__ (
32
33 "ldrex %0, [%2] \n\t"
34 "sub %0, %0, #1 \n\t"
35 "strex %1, %0, [%2] "
36
37 : "=&r" (__res), "=&r" (__ex_flag)
38 : "r" (&(count)->counter)
39 : "cc","memory" );
40
41 __res |= __ex_flag;
42 if (unlikely(__res != 0))
43 fail_fn(count);
44}
45
46static inline int
47__mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *))
48{
49 int __ex_flag, __res;
50
51 __asm__ (
52
53 "ldrex %0, [%2] \n\t"
54 "sub %0, %0, #1 \n\t"
55 "strex %1, %0, [%2] "
56
57 : "=&r" (__res), "=&r" (__ex_flag)
58 : "r" (&(count)->counter)
59 : "cc","memory" );
60
61 __res |= __ex_flag;
62 if (unlikely(__res != 0))
63 __res = fail_fn(count);
64 return __res;
65}
66
67/*
68 * Same trick is used for the unlock fast path. However the original value,
69 * rather than the result, is used to test for success in order to have
70 * better generated assembly.
71 */
72static inline void
73__mutex_fastpath_unlock(atomic_t *count, void (*fail_fn)(atomic_t *))
74{
75 int __ex_flag, __res, __orig;
76
77 __asm__ (
78
79 "ldrex %0, [%3] \n\t"
80 "add %1, %0, #1 \n\t"
81 "strex %2, %1, [%3] "
82
83 : "=&r" (__orig), "=&r" (__res), "=&r" (__ex_flag)
84 : "r" (&(count)->counter)
85 : "cc","memory" );
86
87 __orig |= __ex_flag;
88 if (unlikely(__orig != 0))
89 fail_fn(count);
90}
91
92/*
93 * If the unlock was done on a contended lock, or if the unlock simply fails
94 * then the mutex remains locked.
95 */
96#define __mutex_slowpath_needs_to_unlock() 1
97
98/*
99 * For __mutex_fastpath_trylock we use another construct which could be
100 * described as a "single value cmpxchg".
101 *
102 * This provides the needed trylock semantics like cmpxchg would, but it is
103 * lighter and less generic than a true cmpxchg implementation.
104 */
105static inline int
106__mutex_fastpath_trylock(atomic_t *count, int (*fail_fn)(atomic_t *))
107{
108 int __ex_flag, __res, __orig;
109
110 __asm__ (
111
112 "1: ldrex %0, [%3] \n\t"
113 "subs %1, %0, #1 \n\t"
114 "strexeq %2, %1, [%3] \n\t"
115 "movlt %0, #0 \n\t"
116 "cmpeq %2, #0 \n\t"
117 "bgt 1b "
118
119 : "=&r" (__orig), "=&r" (__res), "=&r" (__ex_flag)
120 : "r" (&count->counter)
121 : "cc", "memory" );
122
123 return __orig;
124}
125
126#endif
127#endif 16#endif
diff --git a/arch/arm/include/asm/perf_event.h b/arch/arm/include/asm/perf_event.h
index 00cbe10a50e..e074948d814 100644
--- a/arch/arm/include/asm/perf_event.h
+++ b/arch/arm/include/asm/perf_event.h
@@ -12,21 +12,6 @@
12#ifndef __ARM_PERF_EVENT_H__ 12#ifndef __ARM_PERF_EVENT_H__
13#define __ARM_PERF_EVENT_H__ 13#define __ARM_PERF_EVENT_H__
14 14
15/* ARM perf PMU IDs for use by internal perf clients. */ 15/* Nothing to see here... */
16enum arm_perf_pmu_ids {
17 ARM_PERF_PMU_ID_XSCALE1 = 0,
18 ARM_PERF_PMU_ID_XSCALE2,
19 ARM_PERF_PMU_ID_V6,
20 ARM_PERF_PMU_ID_V6MP,
21 ARM_PERF_PMU_ID_CA8,
22 ARM_PERF_PMU_ID_CA9,
23 ARM_PERF_PMU_ID_CA5,
24 ARM_PERF_PMU_ID_CA15,
25 ARM_PERF_PMU_ID_CA7,
26 ARM_NUM_PMU_IDS,
27};
28
29extern enum arm_perf_pmu_ids
30armpmu_get_pmu_id(void);
31 16
32#endif /* __ARM_PERF_EVENT_H__ */ 17#endif /* __ARM_PERF_EVENT_H__ */
diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
index f66626d71e7..41dc31f834c 100644
--- a/arch/arm/include/asm/pgtable.h
+++ b/arch/arm/include/asm/pgtable.h
@@ -195,6 +195,18 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd)
195 195
196#define pte_clear(mm,addr,ptep) set_pte_ext(ptep, __pte(0), 0) 196#define pte_clear(mm,addr,ptep) set_pte_ext(ptep, __pte(0), 0)
197 197
198#define pte_none(pte) (!pte_val(pte))
199#define pte_present(pte) (pte_val(pte) & L_PTE_PRESENT)
200#define pte_write(pte) (!(pte_val(pte) & L_PTE_RDONLY))
201#define pte_dirty(pte) (pte_val(pte) & L_PTE_DIRTY)
202#define pte_young(pte) (pte_val(pte) & L_PTE_YOUNG)
203#define pte_exec(pte) (!(pte_val(pte) & L_PTE_XN))
204#define pte_special(pte) (0)
205
206#define pte_present_user(pte) \
207 ((pte_val(pte) & (L_PTE_PRESENT | L_PTE_USER)) == \
208 (L_PTE_PRESENT | L_PTE_USER))
209
198#if __LINUX_ARM_ARCH__ < 6 210#if __LINUX_ARM_ARCH__ < 6
199static inline void __sync_icache_dcache(pte_t pteval) 211static inline void __sync_icache_dcache(pte_t pteval)
200{ 212{
@@ -206,25 +218,15 @@ extern void __sync_icache_dcache(pte_t pteval);
206static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, 218static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
207 pte_t *ptep, pte_t pteval) 219 pte_t *ptep, pte_t pteval)
208{ 220{
209 if (addr >= TASK_SIZE) 221 unsigned long ext = 0;
210 set_pte_ext(ptep, pteval, 0); 222
211 else { 223 if (addr < TASK_SIZE && pte_present_user(pteval)) {
212 __sync_icache_dcache(pteval); 224 __sync_icache_dcache(pteval);
213 set_pte_ext(ptep, pteval, PTE_EXT_NG); 225 ext |= PTE_EXT_NG;
214 } 226 }
215}
216 227
217#define pte_none(pte) (!pte_val(pte)) 228 set_pte_ext(ptep, pteval, ext);
218#define pte_present(pte) (pte_val(pte) & L_PTE_PRESENT) 229}
219#define pte_write(pte) (!(pte_val(pte) & L_PTE_RDONLY))
220#define pte_dirty(pte) (pte_val(pte) & L_PTE_DIRTY)
221#define pte_young(pte) (pte_val(pte) & L_PTE_YOUNG)
222#define pte_exec(pte) (!(pte_val(pte) & L_PTE_XN))
223#define pte_special(pte) (0)
224
225#define pte_present_user(pte) \
226 ((pte_val(pte) & (L_PTE_PRESENT | L_PTE_USER)) == \
227 (L_PTE_PRESENT | L_PTE_USER))
228 230
229#define PTE_BIT_FUNC(fn,op) \ 231#define PTE_BIT_FUNC(fn,op) \
230static inline pte_t pte_##fn(pte_t pte) { pte_val(pte) op; return pte; } 232static inline pte_t pte_##fn(pte_t pte) { pte_val(pte) op; return pte; }
@@ -251,13 +253,13 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
251 * 253 *
252 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 254 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
253 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 255 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
254 * <--------------- offset --------------------> <- type --> 0 0 0 256 * <--------------- offset ----------------------> < type -> 0 0 0
255 * 257 *
256 * This gives us up to 63 swap files and 32GB per swap file. Note that 258 * This gives us up to 31 swap files and 64GB per swap file. Note that
257 * the offset field is always non-zero. 259 * the offset field is always non-zero.
258 */ 260 */
259#define __SWP_TYPE_SHIFT 3 261#define __SWP_TYPE_SHIFT 3
260#define __SWP_TYPE_BITS 6 262#define __SWP_TYPE_BITS 5
261#define __SWP_TYPE_MASK ((1 << __SWP_TYPE_BITS) - 1) 263#define __SWP_TYPE_MASK ((1 << __SWP_TYPE_BITS) - 1)
262#define __SWP_OFFSET_SHIFT (__SWP_TYPE_BITS + __SWP_TYPE_SHIFT) 264#define __SWP_OFFSET_SHIFT (__SWP_TYPE_BITS + __SWP_TYPE_SHIFT)
263 265
diff --git a/arch/arm/include/asm/pmu.h b/arch/arm/include/asm/pmu.h
index 90114faa9f3..4432305f4a2 100644
--- a/arch/arm/include/asm/pmu.h
+++ b/arch/arm/include/asm/pmu.h
@@ -103,10 +103,9 @@ struct pmu_hw_events {
103 103
104struct arm_pmu { 104struct arm_pmu {
105 struct pmu pmu; 105 struct pmu pmu;
106 enum arm_perf_pmu_ids id;
107 enum arm_pmu_type type; 106 enum arm_pmu_type type;
108 cpumask_t active_irqs; 107 cpumask_t active_irqs;
109 const char *name; 108 char *name;
110 irqreturn_t (*handle_irq)(int irq_num, void *dev); 109 irqreturn_t (*handle_irq)(int irq_num, void *dev);
111 void (*enable)(struct hw_perf_event *evt, int idx); 110 void (*enable)(struct hw_perf_event *evt, int idx);
112 void (*disable)(struct hw_perf_event *evt, int idx); 111 void (*disable)(struct hw_perf_event *evt, int idx);
diff --git a/arch/arm/include/asm/sched_clock.h b/arch/arm/include/asm/sched_clock.h
index e3f75726343..05b8e82ec9f 100644
--- a/arch/arm/include/asm/sched_clock.h
+++ b/arch/arm/include/asm/sched_clock.h
@@ -10,5 +10,7 @@
10 10
11extern void sched_clock_postinit(void); 11extern void sched_clock_postinit(void);
12extern void setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate); 12extern void setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate);
13extern void setup_sched_clock_needs_suspend(u32 (*read)(void), int bits,
14 unsigned long rate);
13 15
14#endif 16#endif
diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h
index 23ebc0c82a3..24d284a1bfc 100644
--- a/arch/arm/include/asm/setup.h
+++ b/arch/arm/include/asm/setup.h
@@ -196,7 +196,7 @@ static const struct tagtable __tagtable_##fn __tag = { tag, fn }
196 196
197struct membank { 197struct membank {
198 phys_addr_t start; 198 phys_addr_t start;
199 unsigned long size; 199 phys_addr_t size;
200 unsigned int highmem; 200 unsigned int highmem;
201}; 201};
202 202
@@ -217,7 +217,7 @@ extern struct meminfo meminfo;
217#define bank_phys_end(bank) ((bank)->start + (bank)->size) 217#define bank_phys_end(bank) ((bank)->start + (bank)->size)
218#define bank_phys_size(bank) (bank)->size 218#define bank_phys_size(bank) (bank)->size
219 219
220extern int arm_add_memory(phys_addr_t start, unsigned long size); 220extern int arm_add_memory(phys_addr_t start, phys_addr_t size);
221extern void early_print(const char *str, ...); 221extern void early_print(const char *str, ...);
222extern void dump_machine_table(void); 222extern void dump_machine_table(void);
223 223
diff --git a/arch/arm/include/asm/spinlock.h b/arch/arm/include/asm/spinlock.h
index 65fa3c88095..b4ca707d0a6 100644
--- a/arch/arm/include/asm/spinlock.h
+++ b/arch/arm/include/asm/spinlock.h
@@ -59,18 +59,13 @@ static inline void dsb_sev(void)
59} 59}
60 60
61/* 61/*
62 * ARMv6 Spin-locking. 62 * ARMv6 ticket-based spin-locking.
63 * 63 *
64 * We exclusively read the old value. If it is zero, we may have 64 * A memory barrier is required after we get a lock, and before we
65 * won the lock, so we try exclusively storing it. A memory barrier 65 * release it, because V6 CPUs are assumed to have weakly ordered
66 * is required after we get a lock, and before we release it, because 66 * memory.
67 * V6 CPUs are assumed to have weakly ordered memory.
68 *
69 * Unlocked value: 0
70 * Locked value: 1
71 */ 67 */
72 68
73#define arch_spin_is_locked(x) ((x)->lock != 0)
74#define arch_spin_unlock_wait(lock) \ 69#define arch_spin_unlock_wait(lock) \
75 do { while (arch_spin_is_locked(lock)) cpu_relax(); } while (0) 70 do { while (arch_spin_is_locked(lock)) cpu_relax(); } while (0)
76 71
@@ -79,31 +74,39 @@ static inline void dsb_sev(void)
79static inline void arch_spin_lock(arch_spinlock_t *lock) 74static inline void arch_spin_lock(arch_spinlock_t *lock)
80{ 75{
81 unsigned long tmp; 76 unsigned long tmp;
77 u32 newval;
78 arch_spinlock_t lockval;
82 79
83 __asm__ __volatile__( 80 __asm__ __volatile__(
84"1: ldrex %0, [%1]\n" 81"1: ldrex %0, [%3]\n"
85" teq %0, #0\n" 82" add %1, %0, %4\n"
86 WFE("ne") 83" strex %2, %1, [%3]\n"
87" strexeq %0, %2, [%1]\n" 84" teq %2, #0\n"
88" teqeq %0, #0\n"
89" bne 1b" 85" bne 1b"
90 : "=&r" (tmp) 86 : "=&r" (lockval), "=&r" (newval), "=&r" (tmp)
91 : "r" (&lock->lock), "r" (1) 87 : "r" (&lock->slock), "I" (1 << TICKET_SHIFT)
92 : "cc"); 88 : "cc");
93 89
90 while (lockval.tickets.next != lockval.tickets.owner) {
91 wfe();
92 lockval.tickets.owner = ACCESS_ONCE(lock->tickets.owner);
93 }
94
94 smp_mb(); 95 smp_mb();
95} 96}
96 97
97static inline int arch_spin_trylock(arch_spinlock_t *lock) 98static inline int arch_spin_trylock(arch_spinlock_t *lock)
98{ 99{
99 unsigned long tmp; 100 unsigned long tmp;
101 u32 slock;
100 102
101 __asm__ __volatile__( 103 __asm__ __volatile__(
102" ldrex %0, [%1]\n" 104" ldrex %0, [%2]\n"
103" teq %0, #0\n" 105" subs %1, %0, %0, ror #16\n"
104" strexeq %0, %2, [%1]" 106" addeq %0, %0, %3\n"
105 : "=&r" (tmp) 107" strexeq %1, %0, [%2]"
106 : "r" (&lock->lock), "r" (1) 108 : "=&r" (slock), "=&r" (tmp)
109 : "r" (&lock->slock), "I" (1 << TICKET_SHIFT)
107 : "cc"); 110 : "cc");
108 111
109 if (tmp == 0) { 112 if (tmp == 0) {
@@ -116,17 +119,38 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock)
116 119
117static inline void arch_spin_unlock(arch_spinlock_t *lock) 120static inline void arch_spin_unlock(arch_spinlock_t *lock)
118{ 121{
122 unsigned long tmp;
123 u32 slock;
124
119 smp_mb(); 125 smp_mb();
120 126
121 __asm__ __volatile__( 127 __asm__ __volatile__(
122" str %1, [%0]\n" 128" mov %1, #1\n"
123 : 129"1: ldrex %0, [%2]\n"
124 : "r" (&lock->lock), "r" (0) 130" uadd16 %0, %0, %1\n"
131" strex %1, %0, [%2]\n"
132" teq %1, #0\n"
133" bne 1b"
134 : "=&r" (slock), "=&r" (tmp)
135 : "r" (&lock->slock)
125 : "cc"); 136 : "cc");
126 137
127 dsb_sev(); 138 dsb_sev();
128} 139}
129 140
141static inline int arch_spin_is_locked(arch_spinlock_t *lock)
142{
143 struct __raw_tickets tickets = ACCESS_ONCE(lock->tickets);
144 return tickets.owner != tickets.next;
145}
146
147static inline int arch_spin_is_contended(arch_spinlock_t *lock)
148{
149 struct __raw_tickets tickets = ACCESS_ONCE(lock->tickets);
150 return (tickets.next - tickets.owner) > 1;
151}
152#define arch_spin_is_contended arch_spin_is_contended
153
130/* 154/*
131 * RWLOCKS 155 * RWLOCKS
132 * 156 *
@@ -158,7 +182,7 @@ static inline int arch_write_trylock(arch_rwlock_t *rw)
158 unsigned long tmp; 182 unsigned long tmp;
159 183
160 __asm__ __volatile__( 184 __asm__ __volatile__(
161"1: ldrex %0, [%1]\n" 185" ldrex %0, [%1]\n"
162" teq %0, #0\n" 186" teq %0, #0\n"
163" strexeq %0, %2, [%1]" 187" strexeq %0, %2, [%1]"
164 : "=&r" (tmp) 188 : "=&r" (tmp)
@@ -244,7 +268,7 @@ static inline int arch_read_trylock(arch_rwlock_t *rw)
244 unsigned long tmp, tmp2 = 1; 268 unsigned long tmp, tmp2 = 1;
245 269
246 __asm__ __volatile__( 270 __asm__ __volatile__(
247"1: ldrex %0, [%2]\n" 271" ldrex %0, [%2]\n"
248" adds %0, %0, #1\n" 272" adds %0, %0, #1\n"
249" strexpl %1, %0, [%2]\n" 273" strexpl %1, %0, [%2]\n"
250 : "=&r" (tmp), "+r" (tmp2) 274 : "=&r" (tmp), "+r" (tmp2)
diff --git a/arch/arm/include/asm/spinlock_types.h b/arch/arm/include/asm/spinlock_types.h
index d14d197ae04..b262d2f8b47 100644
--- a/arch/arm/include/asm/spinlock_types.h
+++ b/arch/arm/include/asm/spinlock_types.h
@@ -5,11 +5,24 @@
5# error "please don't include this file directly" 5# error "please don't include this file directly"
6#endif 6#endif
7 7
8#define TICKET_SHIFT 16
9
8typedef struct { 10typedef struct {
9 volatile unsigned int lock; 11 union {
12 u32 slock;
13 struct __raw_tickets {
14#ifdef __ARMEB__
15 u16 next;
16 u16 owner;
17#else
18 u16 owner;
19 u16 next;
20#endif
21 } tickets;
22 };
10} arch_spinlock_t; 23} arch_spinlock_t;
11 24
12#define __ARCH_SPIN_LOCK_UNLOCKED { 0 } 25#define __ARCH_SPIN_LOCK_UNLOCKED { { 0 } }
13 26
14typedef struct { 27typedef struct {
15 volatile unsigned int lock; 28 volatile unsigned int lock;
diff --git a/arch/arm/include/asm/timex.h b/arch/arm/include/asm/timex.h
index 3be8de3adab..ce119442277 100644
--- a/arch/arm/include/asm/timex.h
+++ b/arch/arm/include/asm/timex.h
@@ -12,13 +12,15 @@
12#ifndef _ASMARM_TIMEX_H 12#ifndef _ASMARM_TIMEX_H
13#define _ASMARM_TIMEX_H 13#define _ASMARM_TIMEX_H
14 14
15#include <asm/arch_timer.h>
15#include <mach/timex.h> 16#include <mach/timex.h>
16 17
17typedef unsigned long cycles_t; 18typedef unsigned long cycles_t;
18 19
19static inline cycles_t get_cycles (void) 20#ifdef ARCH_HAS_READ_CURRENT_TIMER
20{ 21#define get_cycles() ({ cycles_t c; read_current_timer(&c) ? 0 : c; })
21 return 0; 22#else
22} 23#define get_cycles() (0)
24#endif
23 25
24#endif 26#endif
diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
index 71f6536d17a..479a6352e0b 100644
--- a/arch/arm/include/asm/uaccess.h
+++ b/arch/arm/include/asm/uaccess.h
@@ -189,6 +189,9 @@ static inline void set_fs(mm_segment_t fs)
189 189
190#define access_ok(type,addr,size) (__range_ok(addr,size) == 0) 190#define access_ok(type,addr,size) (__range_ok(addr,size) == 0)
191 191
192#define user_addr_max() \
193 (segment_eq(get_fs(), USER_DS) ? TASK_SIZE : ~0UL)
194
192/* 195/*
193 * The "__xxx" versions of the user access functions do not verify the 196 * The "__xxx" versions of the user access functions do not verify the
194 * address space - it must have been done previously with a separate 197 * address space - it must have been done previously with a separate
@@ -398,9 +401,6 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
398#define __clear_user(addr,n) (memset((void __force *)addr, 0, n), 0) 401#define __clear_user(addr,n) (memset((void __force *)addr, 0, n), 0)
399#endif 402#endif
400 403
401extern unsigned long __must_check __strncpy_from_user(char *to, const char __user *from, unsigned long count);
402extern unsigned long __must_check __strnlen_user(const char __user *s, long n);
403
404static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n) 404static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
405{ 405{
406 if (access_ok(VERIFY_READ, from, n)) 406 if (access_ok(VERIFY_READ, from, n))
@@ -427,24 +427,9 @@ static inline unsigned long __must_check clear_user(void __user *to, unsigned lo
427 return n; 427 return n;
428} 428}
429 429
430static inline long __must_check strncpy_from_user(char *dst, const char __user *src, long count) 430extern long strncpy_from_user(char *dest, const char __user *src, long count);
431{
432 long res = -EFAULT;
433 if (access_ok(VERIFY_READ, src, 1))
434 res = __strncpy_from_user(dst, src, count);
435 return res;
436}
437
438#define strlen_user(s) strnlen_user(s, ~0UL >> 1)
439 431
440static inline long __must_check strnlen_user(const char __user *s, long n) 432extern __must_check long strlen_user(const char __user *str);
441{ 433extern __must_check long strnlen_user(const char __user *str, long n);
442 unsigned long res = 0;
443
444 if (__addr_ok(s))
445 res = __strnlen_user(s, n);
446
447 return res;
448}
449 434
450#endif /* _ASMARM_UACCESS_H */ 435#endif /* _ASMARM_UACCESS_H */
diff --git a/arch/arm/include/asm/unistd.h b/arch/arm/include/asm/unistd.h
index 512cd147345..0cab47d4a83 100644
--- a/arch/arm/include/asm/unistd.h
+++ b/arch/arm/include/asm/unistd.h
@@ -446,7 +446,6 @@
446 446
447#ifdef __KERNEL__ 447#ifdef __KERNEL__
448 448
449#define __ARCH_WANT_IPC_PARSE_VERSION
450#define __ARCH_WANT_STAT64 449#define __ARCH_WANT_STAT64
451#define __ARCH_WANT_SYS_GETHOSTNAME 450#define __ARCH_WANT_SYS_GETHOSTNAME
452#define __ARCH_WANT_SYS_PAUSE 451#define __ARCH_WANT_SYS_PAUSE
diff --git a/arch/arm/include/asm/word-at-a-time.h b/arch/arm/include/asm/word-at-a-time.h
new file mode 100644
index 00000000000..4d52f92967a
--- /dev/null
+++ b/arch/arm/include/asm/word-at-a-time.h
@@ -0,0 +1,96 @@
1#ifndef __ASM_ARM_WORD_AT_A_TIME_H
2#define __ASM_ARM_WORD_AT_A_TIME_H
3
4#ifndef __ARMEB__
5
6/*
7 * Little-endian word-at-a-time zero byte handling.
8 * Heavily based on the x86 algorithm.
9 */
10#include <linux/kernel.h>
11
12struct word_at_a_time {
13 const unsigned long one_bits, high_bits;
14};
15
16#define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
17
18static inline unsigned long has_zero(unsigned long a, unsigned long *bits,
19 const struct word_at_a_time *c)
20{
21 unsigned long mask = ((a - c->one_bits) & ~a) & c->high_bits;
22 *bits = mask;
23 return mask;
24}
25
26#define prep_zero_mask(a, bits, c) (bits)
27
28static inline unsigned long create_zero_mask(unsigned long bits)
29{
30 bits = (bits - 1) & ~bits;
31 return bits >> 7;
32}
33
34static inline unsigned long find_zero(unsigned long mask)
35{
36 unsigned long ret;
37
38#if __LINUX_ARM_ARCH__ >= 5
39 /* We have clz available. */
40 ret = fls(mask) >> 3;
41#else
42 /* (000000 0000ff 00ffff ffffff) -> ( 1 1 2 3 ) */
43 ret = (0x0ff0001 + mask) >> 23;
44 /* Fix the 1 for 00 case */
45 ret &= mask;
46#endif
47
48 return ret;
49}
50
51#ifdef CONFIG_DCACHE_WORD_ACCESS
52
53#define zero_bytemask(mask) (mask)
54
55/*
56 * Load an unaligned word from kernel space.
57 *
58 * In the (very unlikely) case of the word being a page-crosser
59 * and the next page not being mapped, take the exception and
60 * return zeroes in the non-existing part.
61 */
62static inline unsigned long load_unaligned_zeropad(const void *addr)
63{
64 unsigned long ret, offset;
65
66 /* Load word from unaligned pointer addr */
67 asm(
68 "1: ldr %0, [%2]\n"
69 "2:\n"
70 " .pushsection .fixup,\"ax\"\n"
71 " .align 2\n"
72 "3: and %1, %2, #0x3\n"
73 " bic %2, %2, #0x3\n"
74 " ldr %0, [%2]\n"
75 " lsl %1, %1, #0x3\n"
76 " lsr %0, %0, %1\n"
77 " b 2b\n"
78 " .popsection\n"
79 " .pushsection __ex_table,\"a\"\n"
80 " .align 3\n"
81 " .long 1b, 3b\n"
82 " .popsection"
83 : "=&r" (ret), "=&r" (offset)
84 : "r" (addr), "Qo" (*(unsigned long *)addr));
85
86 return ret;
87}
88
89
90#endif /* DCACHE_WORD_ACCESS */
91
92#else /* __ARMEB__ */
93#include <asm-generic/word-at-a-time.h>
94#endif
95
96#endif /* __ASM_ARM_WORD_AT_A_TIME_H */
diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
index dd58035621f..cf258807160 100644
--- a/arch/arm/kernel/arch_timer.c
+++ b/arch/arm/kernel/arch_timer.c
@@ -32,6 +32,8 @@ static int arch_timer_ppi2;
32 32
33static struct clock_event_device __percpu **arch_timer_evt; 33static struct clock_event_device __percpu **arch_timer_evt;
34 34
35extern void init_current_timer_delay(unsigned long freq);
36
35/* 37/*
36 * Architected system timer support. 38 * Architected system timer support.
37 */ 39 */
@@ -137,7 +139,7 @@ static int __cpuinit arch_timer_setup(struct clock_event_device *clk)
137 /* Be safe... */ 139 /* Be safe... */
138 arch_timer_disable(); 140 arch_timer_disable();
139 141
140 clk->features = CLOCK_EVT_FEAT_ONESHOT; 142 clk->features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP;
141 clk->name = "arch_sys_timer"; 143 clk->name = "arch_sys_timer";
142 clk->rating = 450; 144 clk->rating = 450;
143 clk->set_mode = arch_timer_set_mode; 145 clk->set_mode = arch_timer_set_mode;
@@ -223,6 +225,14 @@ static cycle_t arch_counter_read(struct clocksource *cs)
223 return arch_counter_get_cntpct(); 225 return arch_counter_get_cntpct();
224} 226}
225 227
228int read_current_timer(unsigned long *timer_val)
229{
230 if (!arch_timer_rate)
231 return -ENXIO;
232 *timer_val = arch_counter_get_cntpct();
233 return 0;
234}
235
226static struct clocksource clocksource_counter = { 236static struct clocksource clocksource_counter = {
227 .name = "arch_sys_counter", 237 .name = "arch_sys_counter",
228 .rating = 400, 238 .rating = 400,
@@ -296,6 +306,7 @@ static int __init arch_timer_register(void)
296 if (err) 306 if (err)
297 goto out_free_irq; 307 goto out_free_irq;
298 308
309 init_current_timer_delay(arch_timer_rate);
299 return 0; 310 return 0;
300 311
301out_free_irq: 312out_free_irq:
diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
index b57c75e0b01..60d3b738d42 100644
--- a/arch/arm/kernel/armksyms.c
+++ b/arch/arm/kernel/armksyms.c
@@ -49,8 +49,7 @@ extern void __aeabi_ulcmp(void);
49extern void fpundefinstr(void); 49extern void fpundefinstr(void);
50 50
51 /* platform dependent support */ 51 /* platform dependent support */
52EXPORT_SYMBOL(__udelay); 52EXPORT_SYMBOL(arm_delay_ops);
53EXPORT_SYMBOL(__const_udelay);
54 53
55 /* networking */ 54 /* networking */
56EXPORT_SYMBOL(csum_partial); 55EXPORT_SYMBOL(csum_partial);
@@ -87,10 +86,6 @@ EXPORT_SYMBOL(memmove);
87EXPORT_SYMBOL(memchr); 86EXPORT_SYMBOL(memchr);
88EXPORT_SYMBOL(__memzero); 87EXPORT_SYMBOL(__memzero);
89 88
90 /* user mem (segment) */
91EXPORT_SYMBOL(__strnlen_user);
92EXPORT_SYMBOL(__strncpy_from_user);
93
94#ifdef CONFIG_MMU 89#ifdef CONFIG_MMU
95EXPORT_SYMBOL(copy_page); 90EXPORT_SYMBOL(copy_page);
96 91
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index 25552508c3f..2b2f25e7fef 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -253,7 +253,7 @@ static void __devinit pci_fixup_cy82c693(struct pci_dev *dev)
253} 253}
254DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693, pci_fixup_cy82c693); 254DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693, pci_fixup_cy82c693);
255 255
256static void __init pci_fixup_it8152(struct pci_dev *dev) 256static void __devinit pci_fixup_it8152(struct pci_dev *dev)
257{ 257{
258 int i; 258 int i;
259 /* fixup for ITE 8152 devices */ 259 /* fixup for ITE 8152 devices */
@@ -461,7 +461,7 @@ static void __init pcibios_init_hw(struct hw_pci *hw, struct list_head *head)
461 if (!sys->bus) 461 if (!sys->bus)
462 panic("PCI: unable to scan bus!"); 462 panic("PCI: unable to scan bus!");
463 463
464 busnr = sys->bus->subordinate + 1; 464 busnr = sys->bus->busn_res.end + 1;
465 465
466 list_add(&sys->node, head); 466 list_add(&sys->node, head);
467 } else { 467 } else {
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 0d1851ca6eb..0f82098c9bf 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -244,6 +244,19 @@ svc_preempt:
244 b 1b 244 b 1b
245#endif 245#endif
246 246
247__und_fault:
248 @ Correct the PC such that it is pointing at the instruction
249 @ which caused the fault. If the faulting instruction was ARM
250 @ the PC will be pointing at the next instruction, and have to
251 @ subtract 4. Otherwise, it is Thumb, and the PC will be
252 @ pointing at the second half of the Thumb instruction. We
253 @ have to subtract 2.
254 ldr r2, [r0, #S_PC]
255 sub r2, r2, r1
256 str r2, [r0, #S_PC]
257 b do_undefinstr
258ENDPROC(__und_fault)
259
247 .align 5 260 .align 5
248__und_svc: 261__und_svc:
249#ifdef CONFIG_KPROBES 262#ifdef CONFIG_KPROBES
@@ -261,25 +274,32 @@ __und_svc:
261 @ 274 @
262 @ r0 - instruction 275 @ r0 - instruction
263 @ 276 @
264#ifndef CONFIG_THUMB2_KERNEL 277#ifndef CONFIG_THUMB2_KERNEL
265 ldr r0, [r4, #-4] 278 ldr r0, [r4, #-4]
266#else 279#else
280 mov r1, #2
267 ldrh r0, [r4, #-2] @ Thumb instruction at LR - 2 281 ldrh r0, [r4, #-2] @ Thumb instruction at LR - 2
268 cmp r0, #0xe800 @ 32-bit instruction if xx >= 0 282 cmp r0, #0xe800 @ 32-bit instruction if xx >= 0
269 ldrhhs r9, [r4] @ bottom 16 bits 283 blo __und_svc_fault
270 orrhs r0, r9, r0, lsl #16 284 ldrh r9, [r4] @ bottom 16 bits
285 add r4, r4, #2
286 str r4, [sp, #S_PC]
287 orr r0, r9, r0, lsl #16
271#endif 288#endif
272 adr r9, BSYM(1f) 289 adr r9, BSYM(__und_svc_finish)
273 mov r2, r4 290 mov r2, r4
274 bl call_fpe 291 bl call_fpe
275 292
293 mov r1, #4 @ PC correction to apply
294__und_svc_fault:
276 mov r0, sp @ struct pt_regs *regs 295 mov r0, sp @ struct pt_regs *regs
277 bl do_undefinstr 296 bl __und_fault
278 297
279 @ 298 @
280 @ IRQs off again before pulling preserved data off the stack 299 @ IRQs off again before pulling preserved data off the stack
281 @ 300 @
2821: disable_irq_notrace 301__und_svc_finish:
302 disable_irq_notrace
283 303
284 @ 304 @
285 @ restore SPSR and restart the instruction 305 @ restore SPSR and restart the instruction
@@ -423,25 +443,33 @@ __und_usr:
423 mov r2, r4 443 mov r2, r4
424 mov r3, r5 444 mov r3, r5
425 445
446 @ r2 = regs->ARM_pc, which is either 2 or 4 bytes ahead of the
447 @ faulting instruction depending on Thumb mode.
448 @ r3 = regs->ARM_cpsr
426 @ 449 @
427 @ fall through to the emulation code, which returns using r9 if 450 @ The emulation code returns using r9 if it has emulated the
428 @ it has emulated the instruction, or the more conventional lr 451 @ instruction, or the more conventional lr if we are to treat
429 @ if we are to treat this as a real undefined instruction 452 @ this as a real undefined instruction
430 @
431 @ r0 - instruction
432 @ 453 @
433 adr r9, BSYM(ret_from_exception) 454 adr r9, BSYM(ret_from_exception)
434 adr lr, BSYM(__und_usr_unknown) 455
435 tst r3, #PSR_T_BIT @ Thumb mode? 456 tst r3, #PSR_T_BIT @ Thumb mode?
436 itet eq @ explicit IT needed for the 1f label 457 bne __und_usr_thumb
437 subeq r4, r2, #4 @ ARM instr at LR - 4 458 sub r4, r2, #4 @ ARM instr at LR - 4
438 subne r4, r2, #2 @ Thumb instr at LR - 2 4591: ldrt r0, [r4]
4391: ldreqt r0, [r4]
440#ifdef CONFIG_CPU_ENDIAN_BE8 460#ifdef CONFIG_CPU_ENDIAN_BE8
441 reveq r0, r0 @ little endian instruction 461 rev r0, r0 @ little endian instruction
442#endif 462#endif
443 beq call_fpe 463 @ r0 = 32-bit ARM instruction which caused the exception
464 @ r2 = PC value for the following instruction (:= regs->ARM_pc)
465 @ r4 = PC value for the faulting instruction
466 @ lr = 32-bit undefined instruction function
467 adr lr, BSYM(__und_usr_fault_32)
468 b call_fpe
469
470__und_usr_thumb:
444 @ Thumb instruction 471 @ Thumb instruction
472 sub r4, r2, #2 @ First half of thumb instr at LR - 2
445#if CONFIG_ARM_THUMB && __LINUX_ARM_ARCH__ >= 6 && CONFIG_CPU_V7 473#if CONFIG_ARM_THUMB && __LINUX_ARM_ARCH__ >= 6 && CONFIG_CPU_V7
446/* 474/*
447 * Thumb-2 instruction handling. Note that because pre-v6 and >= v6 platforms 475 * Thumb-2 instruction handling. Note that because pre-v6 and >= v6 platforms
@@ -455,7 +483,7 @@ __und_usr:
455 ldr r5, .LCcpu_architecture 483 ldr r5, .LCcpu_architecture
456 ldr r5, [r5] 484 ldr r5, [r5]
457 cmp r5, #CPU_ARCH_ARMv7 485 cmp r5, #CPU_ARCH_ARMv7
458 blo __und_usr_unknown 486 blo __und_usr_fault_16 @ 16bit undefined instruction
459/* 487/*
460 * The following code won't get run unless the running CPU really is v7, so 488 * The following code won't get run unless the running CPU really is v7, so
461 * coding round the lack of ldrht on older arches is pointless. Temporarily 489 * coding round the lack of ldrht on older arches is pointless. Temporarily
@@ -463,15 +491,18 @@ __und_usr:
463 */ 491 */
464 .arch armv6t2 492 .arch armv6t2
465#endif 493#endif
4662: 4942: ldrht r5, [r4]
467 ARM( ldrht r5, [r4], #2 )
468 THUMB( ldrht r5, [r4] )
469 THUMB( add r4, r4, #2 )
470 cmp r5, #0xe800 @ 32bit instruction if xx != 0 495 cmp r5, #0xe800 @ 32bit instruction if xx != 0
471 blo __und_usr_unknown 496 blo __und_usr_fault_16 @ 16bit undefined instruction
4723: ldrht r0, [r4] 4973: ldrht r0, [r2]
473 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4 498 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
499 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
474 orr r0, r0, r5, lsl #16 500 orr r0, r0, r5, lsl #16
501 adr lr, BSYM(__und_usr_fault_32)
502 @ r0 = the two 16-bit Thumb instructions which caused the exception
503 @ r2 = PC value for the following Thumb instruction (:= regs->ARM_pc)
504 @ r4 = PC value for the first 16-bit Thumb instruction
505 @ lr = 32bit undefined instruction function
475 506
476#if __LINUX_ARM_ARCH__ < 7 507#if __LINUX_ARM_ARCH__ < 7
477/* If the target arch was overridden, change it back: */ 508/* If the target arch was overridden, change it back: */
@@ -482,17 +513,13 @@ __und_usr:
482#endif 513#endif
483#endif /* __LINUX_ARM_ARCH__ < 7 */ 514#endif /* __LINUX_ARM_ARCH__ < 7 */
484#else /* !(CONFIG_ARM_THUMB && __LINUX_ARM_ARCH__ >= 6 && CONFIG_CPU_V7) */ 515#else /* !(CONFIG_ARM_THUMB && __LINUX_ARM_ARCH__ >= 6 && CONFIG_CPU_V7) */
485 b __und_usr_unknown 516 b __und_usr_fault_16
486#endif 517#endif
487 UNWIND(.fnend ) 518 UNWIND(.fnend)
488ENDPROC(__und_usr) 519ENDPROC(__und_usr)
489 520
490 @
491 @ fallthrough to call_fpe
492 @
493
494/* 521/*
495 * The out of line fixup for the ldrt above. 522 * The out of line fixup for the ldrt instructions above.
496 */ 523 */
497 .pushsection .fixup, "ax" 524 .pushsection .fixup, "ax"
498 .align 2 525 .align 2
@@ -524,11 +551,12 @@ ENDPROC(__und_usr)
524 * NEON handler code. 551 * NEON handler code.
525 * 552 *
526 * Emulators may wish to make use of the following registers: 553 * Emulators may wish to make use of the following registers:
527 * r0 = instruction opcode. 554 * r0 = instruction opcode (32-bit ARM or two 16-bit Thumb)
528 * r2 = PC+4 555 * r2 = PC value to resume execution after successful emulation
529 * r9 = normal "successful" return address 556 * r9 = normal "successful" return address
530 * r10 = this threads thread_info structure. 557 * r10 = this threads thread_info structure
531 * lr = unrecognised instruction return address 558 * lr = unrecognised instruction return address
559 * IRQs disabled, FIQs enabled.
532 */ 560 */
533 @ 561 @
534 @ Fall-through from Thumb-2 __und_usr 562 @ Fall-through from Thumb-2 __und_usr
@@ -659,12 +687,17 @@ ENTRY(no_fp)
659 mov pc, lr 687 mov pc, lr
660ENDPROC(no_fp) 688ENDPROC(no_fp)
661 689
662__und_usr_unknown: 690__und_usr_fault_32:
663 enable_irq 691 mov r1, #4
692 b 1f
693__und_usr_fault_16:
694 mov r1, #2
6951: enable_irq
664 mov r0, sp 696 mov r0, sp
665 adr lr, BSYM(ret_from_exception) 697 adr lr, BSYM(ret_from_exception)
666 b do_undefinstr 698 b __und_fault
667ENDPROC(__und_usr_unknown) 699ENDPROC(__und_usr_fault_32)
700ENDPROC(__und_usr_fault_16)
668 701
669 .align 5 702 .align 5
670__pabt_usr: 703__pabt_usr:
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 4afed88d250..978eac57e04 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -51,23 +51,15 @@ ret_fast_syscall:
51fast_work_pending: 51fast_work_pending:
52 str r0, [sp, #S_R0+S_OFF]! @ returned r0 52 str r0, [sp, #S_R0+S_OFF]! @ returned r0
53work_pending: 53work_pending:
54 tst r1, #_TIF_NEED_RESCHED
55 bne work_resched
56 /*
57 * TIF_SIGPENDING or TIF_NOTIFY_RESUME must've been set if we got here
58 */
59 ldr r2, [sp, #S_PSR]
60 mov r0, sp @ 'regs' 54 mov r0, sp @ 'regs'
61 tst r2, #15 @ are we returning to user mode?
62 bne no_work_pending @ no? just leave, then...
63 mov r2, why @ 'syscall' 55 mov r2, why @ 'syscall'
64 tst r1, #_TIF_SIGPENDING @ delivering a signal? 56 bl do_work_pending
65 movne why, #0 @ prevent further restarts 57 cmp r0, #0
66 bl do_notify_resume 58 beq no_work_pending
67 b ret_slow_syscall @ Check work again 59 movlt scno, #(__NR_restart_syscall - __NR_SYSCALL_BASE)
60 ldmia sp, {r0 - r6} @ have to reload r0 - r6
61 b local_restart @ ... and off we go
68 62
69work_resched:
70 bl schedule
71/* 63/*
72 * "slow" syscall return path. "why" tells us if this was a real syscall. 64 * "slow" syscall return path. "why" tells us if this was a real syscall.
73 */ 65 */
@@ -95,13 +87,7 @@ ENDPROC(ret_to_user)
95ENTRY(ret_from_fork) 87ENTRY(ret_from_fork)
96 bl schedule_tail 88 bl schedule_tail
97 get_thread_info tsk 89 get_thread_info tsk
98 ldr r1, [tsk, #TI_FLAGS] @ check for syscall tracing
99 mov why, #1 90 mov why, #1
100 tst r1, #_TIF_SYSCALL_WORK @ are we tracing syscalls?
101 beq ret_slow_syscall
102 mov r1, sp
103 mov r0, #1 @ trace exit [IP = 1]
104 bl syscall_trace
105 b ret_slow_syscall 91 b ret_slow_syscall
106ENDPROC(ret_from_fork) 92ENDPROC(ret_from_fork)
107 93
@@ -415,6 +401,7 @@ ENTRY(vector_swi)
415 eor scno, scno, #__NR_SYSCALL_BASE @ check OS number 401 eor scno, scno, #__NR_SYSCALL_BASE @ check OS number
416#endif 402#endif
417 403
404local_restart:
418 ldr r10, [tsk, #TI_FLAGS] @ check for syscall tracing 405 ldr r10, [tsk, #TI_FLAGS] @ check for syscall tracing
419 stmdb sp!, {r4, r5} @ push fifth and sixth args 406 stmdb sp!, {r4, r5} @ push fifth and sixth args
420 407
@@ -448,25 +435,24 @@ ENDPROC(vector_swi)
448 * context switches, and waiting for our parent to respond. 435 * context switches, and waiting for our parent to respond.
449 */ 436 */
450__sys_trace: 437__sys_trace:
451 mov r2, scno 438 mov r1, scno
452 add r1, sp, #S_OFF 439 add r0, sp, #S_OFF
453 mov r0, #0 @ trace entry [IP = 0] 440 bl syscall_trace_enter
454 bl syscall_trace
455 441
456 adr lr, BSYM(__sys_trace_return) @ return address 442 adr lr, BSYM(__sys_trace_return) @ return address
457 mov scno, r0 @ syscall number (possibly new) 443 mov scno, r0 @ syscall number (possibly new)
458 add r1, sp, #S_R0 + S_OFF @ pointer to regs 444 add r1, sp, #S_R0 + S_OFF @ pointer to regs
459 cmp scno, #NR_syscalls @ check upper syscall limit 445 cmp scno, #NR_syscalls @ check upper syscall limit
460 ldmccia r1, {r0 - r3} @ have to reload r0 - r3 446 ldmccia r1, {r0 - r6} @ have to reload r0 - r6
447 stmccia sp, {r4, r5} @ and update the stack args
461 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine 448 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
462 b 2b 449 b 2b
463 450
464__sys_trace_return: 451__sys_trace_return:
465 str r0, [sp, #S_R0 + S_OFF]! @ save returned r0 452 str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
466 mov r2, scno 453 mov r1, scno
467 mov r1, sp 454 mov r0, sp
468 mov r0, #1 @ trace exit [IP = 1] 455 bl syscall_trace_exit
469 bl syscall_trace
470 b ret_slow_syscall 456 b ret_slow_syscall
471 457
472 .align 5 458 .align 5
diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
index c32f8456aa0..2adda11f712 100644
--- a/arch/arm/kernel/fiq.c
+++ b/arch/arm/kernel/fiq.c
@@ -122,14 +122,16 @@ void release_fiq(struct fiq_handler *f)
122 while (current_fiq->fiq_op(current_fiq->dev_id, 0)); 122 while (current_fiq->fiq_op(current_fiq->dev_id, 0));
123} 123}
124 124
125static int fiq_start;
126
125void enable_fiq(int fiq) 127void enable_fiq(int fiq)
126{ 128{
127 enable_irq(fiq + FIQ_START); 129 enable_irq(fiq + fiq_start);
128} 130}
129 131
130void disable_fiq(int fiq) 132void disable_fiq(int fiq)
131{ 133{
132 disable_irq(fiq + FIQ_START); 134 disable_irq(fiq + fiq_start);
133} 135}
134 136
135EXPORT_SYMBOL(set_fiq_handler); 137EXPORT_SYMBOL(set_fiq_handler);
@@ -140,7 +142,8 @@ EXPORT_SYMBOL(release_fiq);
140EXPORT_SYMBOL(enable_fiq); 142EXPORT_SYMBOL(enable_fiq);
141EXPORT_SYMBOL(disable_fiq); 143EXPORT_SYMBOL(disable_fiq);
142 144
143void __init init_FIQ(void) 145void __init init_FIQ(int start)
144{ 146{
145 no_fiq_insn = *(unsigned long *)0xffff001c; 147 no_fiq_insn = *(unsigned long *)0xffff001c;
148 fiq_start = start;
146} 149}
diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
index df0bf0c8cb7..34e56647dce 100644
--- a/arch/arm/kernel/ftrace.c
+++ b/arch/arm/kernel/ftrace.c
@@ -179,19 +179,20 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
179 old = *parent; 179 old = *parent;
180 *parent = return_hooker; 180 *parent = return_hooker;
181 181
182 err = ftrace_push_return_trace(old, self_addr, &trace.depth,
183 frame_pointer);
184 if (err == -EBUSY) {
185 *parent = old;
186 return;
187 }
188
189 trace.func = self_addr; 182 trace.func = self_addr;
183 trace.depth = current->curr_ret_stack + 1;
190 184
191 /* Only trace if the calling function expects to */ 185 /* Only trace if the calling function expects to */
192 if (!ftrace_graph_entry(&trace)) { 186 if (!ftrace_graph_entry(&trace)) {
193 current->curr_ret_stack--;
194 *parent = old; 187 *parent = old;
188 return;
189 }
190
191 err = ftrace_push_return_trace(old, self_addr, &trace.depth,
192 frame_pointer);
193 if (err == -EBUSY) {
194 *parent = old;
195 return;
195 } 196 }
196} 197}
197 198
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 835898e7d70..3db960e20cb 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -55,14 +55,6 @@
55 add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE 55 add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
56 .endm 56 .endm
57 57
58#ifdef CONFIG_XIP_KERNEL
59#define KERNEL_START XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR)
60#define KERNEL_END _edata_loc
61#else
62#define KERNEL_START KERNEL_RAM_VADDR
63#define KERNEL_END _end
64#endif
65
66/* 58/*
67 * Kernel startup entry point. 59 * Kernel startup entry point.
68 * --------------------------- 60 * ---------------------------
@@ -218,51 +210,46 @@ __create_page_tables:
218 blo 1b 210 blo 1b
219 211
220 /* 212 /*
221 * Now setup the pagetables for our kernel direct 213 * Map our RAM from the start to the end of the kernel .bss section.
222 * mapped region.
223 */ 214 */
224 mov r3, pc 215 add r0, r4, #PAGE_OFFSET >> (SECTION_SHIFT - PMD_ORDER)
225 mov r3, r3, lsr #SECTION_SHIFT 216 ldr r6, =(_end - 1)
226 orr r3, r7, r3, lsl #SECTION_SHIFT 217 orr r3, r8, r7
227 add r0, r4, #(KERNEL_START & 0xff000000) >> (SECTION_SHIFT - PMD_ORDER)
228 str r3, [r0, #((KERNEL_START & 0x00f00000) >> SECTION_SHIFT) << PMD_ORDER]!
229 ldr r6, =(KERNEL_END - 1)
230 add r0, r0, #1 << PMD_ORDER
231 add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER) 218 add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER)
2321: cmp r0, r6 2191: str r3, [r0], #1 << PMD_ORDER
233 add r3, r3, #1 << SECTION_SHIFT 220 add r3, r3, #1 << SECTION_SHIFT
234 strls r3, [r0], #1 << PMD_ORDER 221 cmp r0, r6
235 bls 1b 222 bls 1b
236 223
237#ifdef CONFIG_XIP_KERNEL 224#ifdef CONFIG_XIP_KERNEL
238 /* 225 /*
239 * Map some ram to cover our .data and .bss areas. 226 * Map the kernel image separately as it is not located in RAM.
240 */ 227 */
241 add r3, r8, #TEXT_OFFSET 228#define XIP_START XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR)
242 orr r3, r3, r7 229 mov r3, pc
243 add r0, r4, #(KERNEL_RAM_VADDR & 0xff000000) >> (SECTION_SHIFT - PMD_ORDER) 230 mov r3, r3, lsr #SECTION_SHIFT
244 str r3, [r0, #(KERNEL_RAM_VADDR & 0x00f00000) >> (SECTION_SHIFT - PMD_ORDER)]! 231 orr r3, r7, r3, lsl #SECTION_SHIFT
245 ldr r6, =(_end - 1) 232 add r0, r4, #(XIP_START & 0xff000000) >> (SECTION_SHIFT - PMD_ORDER)
246 add r0, r0, #4 233 str r3, [r0, #((XIP_START & 0x00f00000) >> SECTION_SHIFT) << PMD_ORDER]!
234 ldr r6, =(_edata_loc - 1)
235 add r0, r0, #1 << PMD_ORDER
247 add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER) 236 add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER)
2481: cmp r0, r6 2371: cmp r0, r6
249 add r3, r3, #1 << 20 238 add r3, r3, #1 << SECTION_SHIFT
250 strls r3, [r0], #4 239 strls r3, [r0], #1 << PMD_ORDER
251 bls 1b 240 bls 1b
252#endif 241#endif
253 242
254 /* 243 /*
255 * Then map boot params address in r2 or the first 1MB (2MB with LPAE) 244 * Then map boot params address in r2 if specified.
256 * of ram if boot params address is not specified.
257 */ 245 */
258 mov r0, r2, lsr #SECTION_SHIFT 246 mov r0, r2, lsr #SECTION_SHIFT
259 movs r0, r0, lsl #SECTION_SHIFT 247 movs r0, r0, lsl #SECTION_SHIFT
260 moveq r0, r8 248 subne r3, r0, r8
261 sub r3, r0, r8 249 addne r3, r3, #PAGE_OFFSET
262 add r3, r3, #PAGE_OFFSET 250 addne r3, r4, r3, lsr #(SECTION_SHIFT - PMD_ORDER)
263 add r3, r4, r3, lsr #(SECTION_SHIFT - PMD_ORDER) 251 orrne r6, r7, r0
264 orr r6, r7, r0 252 strne r6, [r3]
265 str r6, [r3]
266 253
267#ifdef CONFIG_DEBUG_LL 254#ifdef CONFIG_DEBUG_LL
268#if !defined(CONFIG_DEBUG_ICEDCC) && !defined(CONFIG_DEBUG_SEMIHOSTING) 255#if !defined(CONFIG_DEBUG_ICEDCC) && !defined(CONFIG_DEBUG_SEMIHOSTING)
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index 8349d4e97e2..16cedb42c0c 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -40,13 +40,6 @@
40#include <asm/mach/irq.h> 40#include <asm/mach/irq.h>
41#include <asm/mach/time.h> 41#include <asm/mach/time.h>
42 42
43/*
44 * No architecture-specific irq_finish function defined in arm/arch/irqs.h.
45 */
46#ifndef irq_finish
47#define irq_finish(irq) do { } while (0)
48#endif
49
50unsigned long irq_err_count; 43unsigned long irq_err_count;
51 44
52int arch_show_interrupts(struct seq_file *p, int prec) 45int arch_show_interrupts(struct seq_file *p, int prec)
@@ -85,9 +78,6 @@ void handle_IRQ(unsigned int irq, struct pt_regs *regs)
85 generic_handle_irq(irq); 78 generic_handle_irq(irq);
86 } 79 }
87 80
88 /* AT91 specific workaround */
89 irq_finish(irq);
90
91 irq_exit(); 81 irq_exit();
92 set_irq_regs(old_regs); 82 set_irq_regs(old_regs);
93} 83}
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index a02eada3aa5..ab243b87118 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/arch/arm/kernel/perf_event.c
@@ -47,17 +47,14 @@ static DEFINE_PER_CPU(struct pmu_hw_events, cpu_hw_events);
47/* Set at runtime when we know what CPU type we are. */ 47/* Set at runtime when we know what CPU type we are. */
48static struct arm_pmu *cpu_pmu; 48static struct arm_pmu *cpu_pmu;
49 49
50enum arm_perf_pmu_ids 50const char *perf_pmu_name(void)
51armpmu_get_pmu_id(void)
52{ 51{
53 int id = -ENODEV; 52 if (!cpu_pmu)
54 53 return NULL;
55 if (cpu_pmu != NULL)
56 id = cpu_pmu->id;
57 54
58 return id; 55 return cpu_pmu->pmu.name;
59} 56}
60EXPORT_SYMBOL_GPL(armpmu_get_pmu_id); 57EXPORT_SYMBOL_GPL(perf_pmu_name);
61 58
62int perf_num_counters(void) 59int perf_num_counters(void)
63{ 60{
@@ -760,7 +757,7 @@ init_hw_perf_events(void)
760 cpu_pmu->name, cpu_pmu->num_events); 757 cpu_pmu->name, cpu_pmu->num_events);
761 cpu_pmu_init(cpu_pmu); 758 cpu_pmu_init(cpu_pmu);
762 register_cpu_notifier(&pmu_cpu_notifier); 759 register_cpu_notifier(&pmu_cpu_notifier);
763 armpmu_register(cpu_pmu, "cpu", PERF_TYPE_RAW); 760 armpmu_register(cpu_pmu, cpu_pmu->name, PERF_TYPE_RAW);
764 } else { 761 } else {
765 pr_info("no hardware support available\n"); 762 pr_info("no hardware support available\n");
766 } 763 }
diff --git a/arch/arm/kernel/perf_event_v6.c b/arch/arm/kernel/perf_event_v6.c
index ab627a740fa..c90fcb2b696 100644
--- a/arch/arm/kernel/perf_event_v6.c
+++ b/arch/arm/kernel/perf_event_v6.c
@@ -650,7 +650,6 @@ static int armv6_map_event(struct perf_event *event)
650} 650}
651 651
652static struct arm_pmu armv6pmu = { 652static struct arm_pmu armv6pmu = {
653 .id = ARM_PERF_PMU_ID_V6,
654 .name = "v6", 653 .name = "v6",
655 .handle_irq = armv6pmu_handle_irq, 654 .handle_irq = armv6pmu_handle_irq,
656 .enable = armv6pmu_enable_event, 655 .enable = armv6pmu_enable_event,
@@ -685,7 +684,6 @@ static int armv6mpcore_map_event(struct perf_event *event)
685} 684}
686 685
687static struct arm_pmu armv6mpcore_pmu = { 686static struct arm_pmu armv6mpcore_pmu = {
688 .id = ARM_PERF_PMU_ID_V6MP,
689 .name = "v6mpcore", 687 .name = "v6mpcore",
690 .handle_irq = armv6pmu_handle_irq, 688 .handle_irq = armv6pmu_handle_irq,
691 .enable = armv6pmu_enable_event, 689 .enable = armv6pmu_enable_event,
diff --git a/arch/arm/kernel/perf_event_v7.c b/arch/arm/kernel/perf_event_v7.c
index d3c53606816..f04070bd218 100644
--- a/arch/arm/kernel/perf_event_v7.c
+++ b/arch/arm/kernel/perf_event_v7.c
@@ -1258,7 +1258,6 @@ static u32 __init armv7_read_num_pmnc_events(void)
1258 1258
1259static struct arm_pmu *__init armv7_a8_pmu_init(void) 1259static struct arm_pmu *__init armv7_a8_pmu_init(void)
1260{ 1260{
1261 armv7pmu.id = ARM_PERF_PMU_ID_CA8;
1262 armv7pmu.name = "ARMv7 Cortex-A8"; 1261 armv7pmu.name = "ARMv7 Cortex-A8";
1263 armv7pmu.map_event = armv7_a8_map_event; 1262 armv7pmu.map_event = armv7_a8_map_event;
1264 armv7pmu.num_events = armv7_read_num_pmnc_events(); 1263 armv7pmu.num_events = armv7_read_num_pmnc_events();
@@ -1267,7 +1266,6 @@ static struct arm_pmu *__init armv7_a8_pmu_init(void)
1267 1266
1268static struct arm_pmu *__init armv7_a9_pmu_init(void) 1267static struct arm_pmu *__init armv7_a9_pmu_init(void)
1269{ 1268{
1270 armv7pmu.id = ARM_PERF_PMU_ID_CA9;
1271 armv7pmu.name = "ARMv7 Cortex-A9"; 1269 armv7pmu.name = "ARMv7 Cortex-A9";
1272 armv7pmu.map_event = armv7_a9_map_event; 1270 armv7pmu.map_event = armv7_a9_map_event;
1273 armv7pmu.num_events = armv7_read_num_pmnc_events(); 1271 armv7pmu.num_events = armv7_read_num_pmnc_events();
@@ -1276,7 +1274,6 @@ static struct arm_pmu *__init armv7_a9_pmu_init(void)
1276 1274
1277static struct arm_pmu *__init armv7_a5_pmu_init(void) 1275static struct arm_pmu *__init armv7_a5_pmu_init(void)
1278{ 1276{
1279 armv7pmu.id = ARM_PERF_PMU_ID_CA5;
1280 armv7pmu.name = "ARMv7 Cortex-A5"; 1277 armv7pmu.name = "ARMv7 Cortex-A5";
1281 armv7pmu.map_event = armv7_a5_map_event; 1278 armv7pmu.map_event = armv7_a5_map_event;
1282 armv7pmu.num_events = armv7_read_num_pmnc_events(); 1279 armv7pmu.num_events = armv7_read_num_pmnc_events();
@@ -1285,7 +1282,6 @@ static struct arm_pmu *__init armv7_a5_pmu_init(void)
1285 1282
1286static struct arm_pmu *__init armv7_a15_pmu_init(void) 1283static struct arm_pmu *__init armv7_a15_pmu_init(void)
1287{ 1284{
1288 armv7pmu.id = ARM_PERF_PMU_ID_CA15;
1289 armv7pmu.name = "ARMv7 Cortex-A15"; 1285 armv7pmu.name = "ARMv7 Cortex-A15";
1290 armv7pmu.map_event = armv7_a15_map_event; 1286 armv7pmu.map_event = armv7_a15_map_event;
1291 armv7pmu.num_events = armv7_read_num_pmnc_events(); 1287 armv7pmu.num_events = armv7_read_num_pmnc_events();
@@ -1295,7 +1291,6 @@ static struct arm_pmu *__init armv7_a15_pmu_init(void)
1295 1291
1296static struct arm_pmu *__init armv7_a7_pmu_init(void) 1292static struct arm_pmu *__init armv7_a7_pmu_init(void)
1297{ 1293{
1298 armv7pmu.id = ARM_PERF_PMU_ID_CA7;
1299 armv7pmu.name = "ARMv7 Cortex-A7"; 1294 armv7pmu.name = "ARMv7 Cortex-A7";
1300 armv7pmu.map_event = armv7_a7_map_event; 1295 armv7pmu.map_event = armv7_a7_map_event;
1301 armv7pmu.num_events = armv7_read_num_pmnc_events(); 1296 armv7pmu.num_events = armv7_read_num_pmnc_events();
diff --git a/arch/arm/kernel/perf_event_xscale.c b/arch/arm/kernel/perf_event_xscale.c
index e34e7254e65..f759fe0bab6 100644
--- a/arch/arm/kernel/perf_event_xscale.c
+++ b/arch/arm/kernel/perf_event_xscale.c
@@ -435,7 +435,6 @@ static int xscale_map_event(struct perf_event *event)
435} 435}
436 436
437static struct arm_pmu xscale1pmu = { 437static struct arm_pmu xscale1pmu = {
438 .id = ARM_PERF_PMU_ID_XSCALE1,
439 .name = "xscale1", 438 .name = "xscale1",
440 .handle_irq = xscale1pmu_handle_irq, 439 .handle_irq = xscale1pmu_handle_irq,
441 .enable = xscale1pmu_enable_event, 440 .enable = xscale1pmu_enable_event,
@@ -803,7 +802,6 @@ xscale2pmu_write_counter(int counter, u32 val)
803} 802}
804 803
805static struct arm_pmu xscale2pmu = { 804static struct arm_pmu xscale2pmu = {
806 .id = ARM_PERF_PMU_ID_XSCALE2,
807 .name = "xscale2", 805 .name = "xscale2",
808 .handle_irq = xscale2pmu_handle_irq, 806 .handle_irq = xscale2pmu_handle_irq,
809 .enable = xscale2pmu_enable_event, 807 .enable = xscale2pmu_enable_event,
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 19c95ea65b2..693b744fd57 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -247,6 +247,7 @@ void machine_shutdown(void)
247void machine_halt(void) 247void machine_halt(void)
248{ 248{
249 machine_shutdown(); 249 machine_shutdown();
250 local_irq_disable();
250 while (1); 251 while (1);
251} 252}
252 253
@@ -268,6 +269,7 @@ void machine_restart(char *cmd)
268 269
269 /* Whoops - the platform was unable to reboot. Tell the user! */ 270 /* Whoops - the platform was unable to reboot. Tell the user! */
270 printk("Reboot failed -- System halted\n"); 271 printk("Reboot failed -- System halted\n");
272 local_irq_disable();
271 while (1); 273 while (1);
272} 274}
273 275
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index 14e38261cd3..3e0fc5f7ed4 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -25,6 +25,7 @@
25#include <linux/regset.h> 25#include <linux/regset.h>
26#include <linux/audit.h> 26#include <linux/audit.h>
27#include <linux/tracehook.h> 27#include <linux/tracehook.h>
28#include <linux/unistd.h>
28 29
29#include <asm/pgtable.h> 30#include <asm/pgtable.h>
30#include <asm/traps.h> 31#include <asm/traps.h>
@@ -907,16 +908,16 @@ long arch_ptrace(struct task_struct *child, long request,
907 return ret; 908 return ret;
908} 909}
909 910
910asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno) 911enum ptrace_syscall_dir {
912 PTRACE_SYSCALL_ENTER = 0,
913 PTRACE_SYSCALL_EXIT,
914};
915
916static int ptrace_syscall_trace(struct pt_regs *regs, int scno,
917 enum ptrace_syscall_dir dir)
911{ 918{
912 unsigned long ip; 919 unsigned long ip;
913 920
914 if (why)
915 audit_syscall_exit(regs);
916 else
917 audit_syscall_entry(AUDIT_ARCH_ARM, scno, regs->ARM_r0,
918 regs->ARM_r1, regs->ARM_r2, regs->ARM_r3);
919
920 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 921 if (!test_thread_flag(TIF_SYSCALL_TRACE))
921 return scno; 922 return scno;
922 923
@@ -927,14 +928,28 @@ asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno)
927 * IP = 0 -> entry, =1 -> exit 928 * IP = 0 -> entry, =1 -> exit
928 */ 929 */
929 ip = regs->ARM_ip; 930 ip = regs->ARM_ip;
930 regs->ARM_ip = why; 931 regs->ARM_ip = dir;
931 932
932 if (why) 933 if (dir == PTRACE_SYSCALL_EXIT)
933 tracehook_report_syscall_exit(regs, 0); 934 tracehook_report_syscall_exit(regs, 0);
934 else if (tracehook_report_syscall_entry(regs)) 935 else if (tracehook_report_syscall_entry(regs))
935 current_thread_info()->syscall = -1; 936 current_thread_info()->syscall = -1;
936 937
937 regs->ARM_ip = ip; 938 regs->ARM_ip = ip;
938
939 return current_thread_info()->syscall; 939 return current_thread_info()->syscall;
940} 940}
941
942asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
943{
944 int ret = ptrace_syscall_trace(regs, scno, PTRACE_SYSCALL_ENTER);
945 audit_syscall_entry(AUDIT_ARCH_ARM, scno, regs->ARM_r0, regs->ARM_r1,
946 regs->ARM_r2, regs->ARM_r3);
947 return ret;
948}
949
950asmlinkage int syscall_trace_exit(struct pt_regs *regs, int scno)
951{
952 int ret = ptrace_syscall_trace(regs, scno, PTRACE_SYSCALL_EXIT);
953 audit_syscall_exit(regs);
954 return ret;
955}
diff --git a/arch/arm/kernel/sched_clock.c b/arch/arm/kernel/sched_clock.c
index 27d186abbc0..f4515393248 100644
--- a/arch/arm/kernel/sched_clock.c
+++ b/arch/arm/kernel/sched_clock.c
@@ -21,6 +21,8 @@ struct clock_data {
21 u32 epoch_cyc_copy; 21 u32 epoch_cyc_copy;
22 u32 mult; 22 u32 mult;
23 u32 shift; 23 u32 shift;
24 bool suspended;
25 bool needs_suspend;
24}; 26};
25 27
26static void sched_clock_poll(unsigned long wrap_ticks); 28static void sched_clock_poll(unsigned long wrap_ticks);
@@ -49,6 +51,9 @@ static unsigned long long cyc_to_sched_clock(u32 cyc, u32 mask)
49 u64 epoch_ns; 51 u64 epoch_ns;
50 u32 epoch_cyc; 52 u32 epoch_cyc;
51 53
54 if (cd.suspended)
55 return cd.epoch_ns;
56
52 /* 57 /*
53 * Load the epoch_cyc and epoch_ns atomically. We do this by 58 * Load the epoch_cyc and epoch_ns atomically. We do this by
54 * ensuring that we always write epoch_cyc, epoch_ns and 59 * ensuring that we always write epoch_cyc, epoch_ns and
@@ -98,6 +103,13 @@ static void sched_clock_poll(unsigned long wrap_ticks)
98 update_sched_clock(); 103 update_sched_clock();
99} 104}
100 105
106void __init setup_sched_clock_needs_suspend(u32 (*read)(void), int bits,
107 unsigned long rate)
108{
109 setup_sched_clock(read, bits, rate);
110 cd.needs_suspend = true;
111}
112
101void __init setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate) 113void __init setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate)
102{ 114{
103 unsigned long r, w; 115 unsigned long r, w;
@@ -169,11 +181,23 @@ void __init sched_clock_postinit(void)
169static int sched_clock_suspend(void) 181static int sched_clock_suspend(void)
170{ 182{
171 sched_clock_poll(sched_clock_timer.data); 183 sched_clock_poll(sched_clock_timer.data);
184 if (cd.needs_suspend)
185 cd.suspended = true;
172 return 0; 186 return 0;
173} 187}
174 188
189static void sched_clock_resume(void)
190{
191 if (cd.needs_suspend) {
192 cd.epoch_cyc = read_sched_clock();
193 cd.epoch_cyc_copy = cd.epoch_cyc;
194 cd.suspended = false;
195 }
196}
197
175static struct syscore_ops sched_clock_ops = { 198static struct syscore_ops sched_clock_ops = {
176 .suspend = sched_clock_suspend, 199 .suspend = sched_clock_suspend,
200 .resume = sched_clock_resume,
177}; 201};
178 202
179static int __init sched_clock_syscore_init(void) 203static int __init sched_clock_syscore_init(void)
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index e15d83bb4ea..a81dcecc734 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -508,7 +508,7 @@ void __init dump_machine_table(void)
508 /* can't use cpu_relax() here as it may require MMU setup */; 508 /* can't use cpu_relax() here as it may require MMU setup */;
509} 509}
510 510
511int __init arm_add_memory(phys_addr_t start, unsigned long size) 511int __init arm_add_memory(phys_addr_t start, phys_addr_t size)
512{ 512{
513 struct membank *bank = &meminfo.bank[meminfo.nr_banks]; 513 struct membank *bank = &meminfo.bank[meminfo.nr_banks];
514 514
@@ -538,7 +538,7 @@ int __init arm_add_memory(phys_addr_t start, unsigned long size)
538 } 538 }
539#endif 539#endif
540 540
541 bank->size = size & PAGE_MASK; 541 bank->size = size & ~(phys_addr_t)(PAGE_SIZE - 1);
542 542
543 /* 543 /*
544 * Check whether this memory region has non-zero size or 544 * Check whether this memory region has non-zero size or
@@ -558,7 +558,7 @@ int __init arm_add_memory(phys_addr_t start, unsigned long size)
558static int __init early_mem(char *p) 558static int __init early_mem(char *p)
559{ 559{
560 static int usermem __initdata = 0; 560 static int usermem __initdata = 0;
561 unsigned long size; 561 phys_addr_t size;
562 phys_addr_t start; 562 phys_addr_t start;
563 char *endp; 563 char *endp;
564 564
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index 536c5d6b340..f27789e4e38 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -27,7 +27,6 @@
27 */ 27 */
28#define SWI_SYS_SIGRETURN (0xef000000|(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE)) 28#define SWI_SYS_SIGRETURN (0xef000000|(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE))
29#define SWI_SYS_RT_SIGRETURN (0xef000000|(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE)) 29#define SWI_SYS_RT_SIGRETURN (0xef000000|(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE))
30#define SWI_SYS_RESTART (0xef000000|__NR_restart_syscall|__NR_OABI_SYSCALL_BASE)
31 30
32/* 31/*
33 * With EABI, the syscall number has to be loaded into r7. 32 * With EABI, the syscall number has to be loaded into r7.
@@ -48,18 +47,6 @@ const unsigned long sigreturn_codes[7] = {
48}; 47};
49 48
50/* 49/*
51 * Either we support OABI only, or we have EABI with the OABI
52 * compat layer enabled. In the later case we don't know if
53 * user space is EABI or not, and if not we must not clobber r7.
54 * Always using the OABI syscall solves that issue and works for
55 * all those cases.
56 */
57const unsigned long syscall_restart_code[2] = {
58 SWI_SYS_RESTART, /* swi __NR_restart_syscall */
59 0xe49df004, /* ldr pc, [sp], #4 */
60};
61
62/*
63 * atomically swap in the new signal mask, and wait for a signal. 50 * atomically swap in the new signal mask, and wait for a signal.
64 */ 51 */
65asmlinkage int sys_sigsuspend(int restart, unsigned long oldmask, old_sigset_t mask) 52asmlinkage int sys_sigsuspend(int restart, unsigned long oldmask, old_sigset_t mask)
@@ -582,12 +569,13 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
582 * the kernel can handle, and then we build all the user-level signal handling 569 * the kernel can handle, and then we build all the user-level signal handling
583 * stack-frames in one go after that. 570 * stack-frames in one go after that.
584 */ 571 */
585static void do_signal(struct pt_regs *regs, int syscall) 572static int do_signal(struct pt_regs *regs, int syscall)
586{ 573{
587 unsigned int retval = 0, continue_addr = 0, restart_addr = 0; 574 unsigned int retval = 0, continue_addr = 0, restart_addr = 0;
588 struct k_sigaction ka; 575 struct k_sigaction ka;
589 siginfo_t info; 576 siginfo_t info;
590 int signr; 577 int signr;
578 int restart = 0;
591 579
592 /* 580 /*
593 * If we were from a system call, check for system call restarting... 581 * If we were from a system call, check for system call restarting...
@@ -602,15 +590,15 @@ static void do_signal(struct pt_regs *regs, int syscall)
602 * debugger will see the already changed PSW. 590 * debugger will see the already changed PSW.
603 */ 591 */
604 switch (retval) { 592 switch (retval) {
593 case -ERESTART_RESTARTBLOCK:
594 restart -= 2;
605 case -ERESTARTNOHAND: 595 case -ERESTARTNOHAND:
606 case -ERESTARTSYS: 596 case -ERESTARTSYS:
607 case -ERESTARTNOINTR: 597 case -ERESTARTNOINTR:
598 restart++;
608 regs->ARM_r0 = regs->ARM_ORIG_r0; 599 regs->ARM_r0 = regs->ARM_ORIG_r0;
609 regs->ARM_pc = restart_addr; 600 regs->ARM_pc = restart_addr;
610 break; 601 break;
611 case -ERESTART_RESTARTBLOCK:
612 regs->ARM_r0 = -EINTR;
613 break;
614 } 602 }
615 } 603 }
616 604
@@ -619,14 +607,17 @@ static void do_signal(struct pt_regs *regs, int syscall)
619 * point the debugger may change all our registers ... 607 * point the debugger may change all our registers ...
620 */ 608 */
621 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 609 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
610 /*
611 * Depending on the signal settings we may need to revert the
612 * decision to restart the system call. But skip this if a
613 * debugger has chosen to restart at a different PC.
614 */
615 if (regs->ARM_pc != restart_addr)
616 restart = 0;
622 if (signr > 0) { 617 if (signr > 0) {
623 /* 618 if (unlikely(restart)) {
624 * Depending on the signal settings we may need to revert the 619 if (retval == -ERESTARTNOHAND ||
625 * decision to restart the system call. But skip this if a 620 retval == -ERESTART_RESTARTBLOCK
626 * debugger has chosen to restart at a different PC.
627 */
628 if (regs->ARM_pc == restart_addr) {
629 if (retval == -ERESTARTNOHAND
630 || (retval == -ERESTARTSYS 621 || (retval == -ERESTARTSYS
631 && !(ka.sa.sa_flags & SA_RESTART))) { 622 && !(ka.sa.sa_flags & SA_RESTART))) {
632 regs->ARM_r0 = -EINTR; 623 regs->ARM_r0 = -EINTR;
@@ -635,52 +626,43 @@ static void do_signal(struct pt_regs *regs, int syscall)
635 } 626 }
636 627
637 handle_signal(signr, &ka, &info, regs); 628 handle_signal(signr, &ka, &info, regs);
638 return; 629 return 0;
639 }
640
641 if (syscall) {
642 /*
643 * Handle restarting a different system call. As above,
644 * if a debugger has chosen to restart at a different PC,
645 * ignore the restart.
646 */
647 if (retval == -ERESTART_RESTARTBLOCK
648 && regs->ARM_pc == continue_addr) {
649 if (thumb_mode(regs)) {
650 regs->ARM_r7 = __NR_restart_syscall - __NR_SYSCALL_BASE;
651 regs->ARM_pc -= 2;
652 } else {
653#if defined(CONFIG_AEABI) && !defined(CONFIG_OABI_COMPAT)
654 regs->ARM_r7 = __NR_restart_syscall;
655 regs->ARM_pc -= 4;
656#else
657 u32 __user *usp;
658
659 regs->ARM_sp -= 4;
660 usp = (u32 __user *)regs->ARM_sp;
661
662 if (put_user(regs->ARM_pc, usp) == 0) {
663 regs->ARM_pc = KERN_RESTART_CODE;
664 } else {
665 regs->ARM_sp += 4;
666 force_sigsegv(0, current);
667 }
668#endif
669 }
670 }
671 } 630 }
672 631
673 restore_saved_sigmask(); 632 restore_saved_sigmask();
633 if (unlikely(restart))
634 regs->ARM_pc = continue_addr;
635 return restart;
674} 636}
675 637
676asmlinkage void 638asmlinkage int
677do_notify_resume(struct pt_regs *regs, unsigned int thread_flags, int syscall) 639do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
678{ 640{
679 if (thread_flags & _TIF_SIGPENDING) 641 do {
680 do_signal(regs, syscall); 642 if (likely(thread_flags & _TIF_NEED_RESCHED)) {
681 643 schedule();
682 if (thread_flags & _TIF_NOTIFY_RESUME) { 644 } else {
683 clear_thread_flag(TIF_NOTIFY_RESUME); 645 if (unlikely(!user_mode(regs)))
684 tracehook_notify_resume(regs); 646 return 0;
685 } 647 local_irq_enable();
648 if (thread_flags & _TIF_SIGPENDING) {
649 int restart = do_signal(regs, syscall);
650 if (unlikely(restart)) {
651 /*
652 * Restart without handlers.
653 * Deal with it without leaving
654 * the kernel space.
655 */
656 return restart;
657 }
658 syscall = 0;
659 } else {
660 clear_thread_flag(TIF_NOTIFY_RESUME);
661 tracehook_notify_resume(regs);
662 }
663 }
664 local_irq_disable();
665 thread_flags = current_thread_info()->flags;
666 } while (thread_flags & _TIF_WORK_MASK);
667 return 0;
686} 668}
diff --git a/arch/arm/kernel/signal.h b/arch/arm/kernel/signal.h
index 6fcfe8398aa..5ff067b7c75 100644
--- a/arch/arm/kernel/signal.h
+++ b/arch/arm/kernel/signal.h
@@ -8,7 +8,5 @@
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10#define KERN_SIGRETURN_CODE (CONFIG_VECTORS_BASE + 0x00000500) 10#define KERN_SIGRETURN_CODE (CONFIG_VECTORS_BASE + 0x00000500)
11#define KERN_RESTART_CODE (KERN_SIGRETURN_CODE + sizeof(sigreturn_codes))
12 11
13extern const unsigned long sigreturn_codes[7]; 12extern const unsigned long sigreturn_codes[7];
14extern const unsigned long syscall_restart_code[2];
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 2c7217d971d..ebd8ad274d7 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -179,7 +179,7 @@ void __ref cpu_die(void)
179 mb(); 179 mb();
180 180
181 /* Tell __cpu_die() that this CPU is now safe to dispose of */ 181 /* Tell __cpu_die() that this CPU is now safe to dispose of */
182 complete(&cpu_died); 182 RCU_NONIDLE(complete(&cpu_died));
183 183
184 /* 184 /*
185 * actual CPU shutdown procedure is at least platform (if not 185 * actual CPU shutdown procedure is at least platform (if not
@@ -563,7 +563,8 @@ void smp_send_stop(void)
563 563
564 cpumask_copy(&mask, cpu_online_mask); 564 cpumask_copy(&mask, cpu_online_mask);
565 cpumask_clear_cpu(smp_processor_id(), &mask); 565 cpumask_clear_cpu(smp_processor_id(), &mask);
566 smp_cross_call(&mask, IPI_CPU_STOP); 566 if (!cpumask_empty(&mask))
567 smp_cross_call(&mask, IPI_CPU_STOP);
567 568
568 /* Wait up to one second for other CPUs to stop */ 569 /* Wait up to one second for other CPUs to stop */
569 timeout = USEC_PER_SEC; 570 timeout = USEC_PER_SEC;
diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
index 8200deaa14f..26c12c6440f 100644
--- a/arch/arm/kernel/topology.c
+++ b/arch/arm/kernel/topology.c
@@ -17,11 +17,190 @@
17#include <linux/percpu.h> 17#include <linux/percpu.h>
18#include <linux/node.h> 18#include <linux/node.h>
19#include <linux/nodemask.h> 19#include <linux/nodemask.h>
20#include <linux/of.h>
20#include <linux/sched.h> 21#include <linux/sched.h>
22#include <linux/slab.h>
21 23
22#include <asm/cputype.h> 24#include <asm/cputype.h>
23#include <asm/topology.h> 25#include <asm/topology.h>
24 26
27/*
28 * cpu power scale management
29 */
30
31/*
32 * cpu power table
33 * This per cpu data structure describes the relative capacity of each core.
34 * On a heteregenous system, cores don't have the same computation capacity
35 * and we reflect that difference in the cpu_power field so the scheduler can
36 * take this difference into account during load balance. A per cpu structure
37 * is preferred because each CPU updates its own cpu_power field during the
38 * load balance except for idle cores. One idle core is selected to run the
39 * rebalance_domains for all idle cores and the cpu_power can be updated
40 * during this sequence.
41 */
42static DEFINE_PER_CPU(unsigned long, cpu_scale);
43
44unsigned long arch_scale_freq_power(struct sched_domain *sd, int cpu)
45{
46 return per_cpu(cpu_scale, cpu);
47}
48
49static void set_power_scale(unsigned int cpu, unsigned long power)
50{
51 per_cpu(cpu_scale, cpu) = power;
52}
53
54#ifdef CONFIG_OF
55struct cpu_efficiency {
56 const char *compatible;
57 unsigned long efficiency;
58};
59
60/*
61 * Table of relative efficiency of each processors
62 * The efficiency value must fit in 20bit and the final
63 * cpu_scale value must be in the range
64 * 0 < cpu_scale < 3*SCHED_POWER_SCALE/2
65 * in order to return at most 1 when DIV_ROUND_CLOSEST
66 * is used to compute the capacity of a CPU.
67 * Processors that are not defined in the table,
68 * use the default SCHED_POWER_SCALE value for cpu_scale.
69 */
70struct cpu_efficiency table_efficiency[] = {
71 {"arm,cortex-a15", 3891},
72 {"arm,cortex-a7", 2048},
73 {NULL, },
74};
75
76struct cpu_capacity {
77 unsigned long hwid;
78 unsigned long capacity;
79};
80
81struct cpu_capacity *cpu_capacity;
82
83unsigned long middle_capacity = 1;
84
85/*
86 * Iterate all CPUs' descriptor in DT and compute the efficiency
87 * (as per table_efficiency). Also calculate a middle efficiency
88 * as close as possible to (max{eff_i} - min{eff_i}) / 2
89 * This is later used to scale the cpu_power field such that an
90 * 'average' CPU is of middle power. Also see the comments near
91 * table_efficiency[] and update_cpu_power().
92 */
93static void __init parse_dt_topology(void)
94{
95 struct cpu_efficiency *cpu_eff;
96 struct device_node *cn = NULL;
97 unsigned long min_capacity = (unsigned long)(-1);
98 unsigned long max_capacity = 0;
99 unsigned long capacity = 0;
100 int alloc_size, cpu = 0;
101
102 alloc_size = nr_cpu_ids * sizeof(struct cpu_capacity);
103 cpu_capacity = (struct cpu_capacity *)kzalloc(alloc_size, GFP_NOWAIT);
104
105 while ((cn = of_find_node_by_type(cn, "cpu"))) {
106 const u32 *rate, *reg;
107 int len;
108
109 if (cpu >= num_possible_cpus())
110 break;
111
112 for (cpu_eff = table_efficiency; cpu_eff->compatible; cpu_eff++)
113 if (of_device_is_compatible(cn, cpu_eff->compatible))
114 break;
115
116 if (cpu_eff->compatible == NULL)
117 continue;
118
119 rate = of_get_property(cn, "clock-frequency", &len);
120 if (!rate || len != 4) {
121 pr_err("%s missing clock-frequency property\n",
122 cn->full_name);
123 continue;
124 }
125
126 reg = of_get_property(cn, "reg", &len);
127 if (!reg || len != 4) {
128 pr_err("%s missing reg property\n", cn->full_name);
129 continue;
130 }
131
132 capacity = ((be32_to_cpup(rate)) >> 20) * cpu_eff->efficiency;
133
134 /* Save min capacity of the system */
135 if (capacity < min_capacity)
136 min_capacity = capacity;
137
138 /* Save max capacity of the system */
139 if (capacity > max_capacity)
140 max_capacity = capacity;
141
142 cpu_capacity[cpu].capacity = capacity;
143 cpu_capacity[cpu++].hwid = be32_to_cpup(reg);
144 }
145
146 if (cpu < num_possible_cpus())
147 cpu_capacity[cpu].hwid = (unsigned long)(-1);
148
149 /* If min and max capacities are equals, we bypass the update of the
150 * cpu_scale because all CPUs have the same capacity. Otherwise, we
151 * compute a middle_capacity factor that will ensure that the capacity
152 * of an 'average' CPU of the system will be as close as possible to
153 * SCHED_POWER_SCALE, which is the default value, but with the
154 * constraint explained near table_efficiency[].
155 */
156 if (min_capacity == max_capacity)
157 cpu_capacity[0].hwid = (unsigned long)(-1);
158 else if (4*max_capacity < (3*(max_capacity + min_capacity)))
159 middle_capacity = (min_capacity + max_capacity)
160 >> (SCHED_POWER_SHIFT+1);
161 else
162 middle_capacity = ((max_capacity / 3)
163 >> (SCHED_POWER_SHIFT-1)) + 1;
164
165}
166
167/*
168 * Look for a customed capacity of a CPU in the cpu_capacity table during the
169 * boot. The update of all CPUs is in O(n^2) for heteregeneous system but the
170 * function returns directly for SMP system.
171 */
172void update_cpu_power(unsigned int cpu, unsigned long hwid)
173{
174 unsigned int idx = 0;
175
176 /* look for the cpu's hwid in the cpu capacity table */
177 for (idx = 0; idx < num_possible_cpus(); idx++) {
178 if (cpu_capacity[idx].hwid == hwid)
179 break;
180
181 if (cpu_capacity[idx].hwid == -1)
182 return;
183 }
184
185 if (idx == num_possible_cpus())
186 return;
187
188 set_power_scale(cpu, cpu_capacity[idx].capacity / middle_capacity);
189
190 printk(KERN_INFO "CPU%u: update cpu_power %lu\n",
191 cpu, arch_scale_freq_power(NULL, cpu));
192}
193
194#else
195static inline void parse_dt_topology(void) {}
196static inline void update_cpu_power(unsigned int cpuid, unsigned int mpidr) {}
197#endif
198
199
200/*
201 * cpu topology management
202 */
203
25#define MPIDR_SMP_BITMASK (0x3 << 30) 204#define MPIDR_SMP_BITMASK (0x3 << 30)
26#define MPIDR_SMP_VALUE (0x2 << 30) 205#define MPIDR_SMP_VALUE (0x2 << 30)
27 206
@@ -31,6 +210,7 @@
31 * These masks reflect the current use of the affinity levels. 210 * These masks reflect the current use of the affinity levels.
32 * The affinity level can be up to 16 bits according to ARM ARM 211 * The affinity level can be up to 16 bits according to ARM ARM
33 */ 212 */
213#define MPIDR_HWID_BITMASK 0xFFFFFF
34 214
35#define MPIDR_LEVEL0_MASK 0x3 215#define MPIDR_LEVEL0_MASK 0x3
36#define MPIDR_LEVEL0_SHIFT 0 216#define MPIDR_LEVEL0_SHIFT 0
@@ -41,6 +221,9 @@
41#define MPIDR_LEVEL2_MASK 0xFF 221#define MPIDR_LEVEL2_MASK 0xFF
42#define MPIDR_LEVEL2_SHIFT 16 222#define MPIDR_LEVEL2_SHIFT 16
43 223
224/*
225 * cpu topology table
226 */
44struct cputopo_arm cpu_topology[NR_CPUS]; 227struct cputopo_arm cpu_topology[NR_CPUS];
45 228
46const struct cpumask *cpu_coregroup_mask(int cpu) 229const struct cpumask *cpu_coregroup_mask(int cpu)
@@ -48,6 +231,32 @@ const struct cpumask *cpu_coregroup_mask(int cpu)
48 return &cpu_topology[cpu].core_sibling; 231 return &cpu_topology[cpu].core_sibling;
49} 232}
50 233
234void update_siblings_masks(unsigned int cpuid)
235{
236 struct cputopo_arm *cpu_topo, *cpuid_topo = &cpu_topology[cpuid];
237 int cpu;
238
239 /* update core and thread sibling masks */
240 for_each_possible_cpu(cpu) {
241 cpu_topo = &cpu_topology[cpu];
242
243 if (cpuid_topo->socket_id != cpu_topo->socket_id)
244 continue;
245
246 cpumask_set_cpu(cpuid, &cpu_topo->core_sibling);
247 if (cpu != cpuid)
248 cpumask_set_cpu(cpu, &cpuid_topo->core_sibling);
249
250 if (cpuid_topo->core_id != cpu_topo->core_id)
251 continue;
252
253 cpumask_set_cpu(cpuid, &cpu_topo->thread_sibling);
254 if (cpu != cpuid)
255 cpumask_set_cpu(cpu, &cpuid_topo->thread_sibling);
256 }
257 smp_wmb();
258}
259
51/* 260/*
52 * store_cpu_topology is called at boot when only one cpu is running 261 * store_cpu_topology is called at boot when only one cpu is running
53 * and with the mutex cpu_hotplug.lock locked, when several cpus have booted, 262 * and with the mutex cpu_hotplug.lock locked, when several cpus have booted,
@@ -57,7 +266,6 @@ void store_cpu_topology(unsigned int cpuid)
57{ 266{
58 struct cputopo_arm *cpuid_topo = &cpu_topology[cpuid]; 267 struct cputopo_arm *cpuid_topo = &cpu_topology[cpuid];
59 unsigned int mpidr; 268 unsigned int mpidr;
60 unsigned int cpu;
61 269
62 /* If the cpu topology has been already set, just return */ 270 /* If the cpu topology has been already set, just return */
63 if (cpuid_topo->core_id != -1) 271 if (cpuid_topo->core_id != -1)
@@ -99,26 +307,9 @@ void store_cpu_topology(unsigned int cpuid)
99 cpuid_topo->socket_id = -1; 307 cpuid_topo->socket_id = -1;
100 } 308 }
101 309
102 /* update core and thread sibling masks */ 310 update_siblings_masks(cpuid);
103 for_each_possible_cpu(cpu) { 311
104 struct cputopo_arm *cpu_topo = &cpu_topology[cpu]; 312 update_cpu_power(cpuid, mpidr & MPIDR_HWID_BITMASK);
105
106 if (cpuid_topo->socket_id == cpu_topo->socket_id) {
107 cpumask_set_cpu(cpuid, &cpu_topo->core_sibling);
108 if (cpu != cpuid)
109 cpumask_set_cpu(cpu,
110 &cpuid_topo->core_sibling);
111
112 if (cpuid_topo->core_id == cpu_topo->core_id) {
113 cpumask_set_cpu(cpuid,
114 &cpu_topo->thread_sibling);
115 if (cpu != cpuid)
116 cpumask_set_cpu(cpu,
117 &cpuid_topo->thread_sibling);
118 }
119 }
120 }
121 smp_wmb();
122 313
123 printk(KERN_INFO "CPU%u: thread %d, cpu %d, socket %d, mpidr %x\n", 314 printk(KERN_INFO "CPU%u: thread %d, cpu %d, socket %d, mpidr %x\n",
124 cpuid, cpu_topology[cpuid].thread_id, 315 cpuid, cpu_topology[cpuid].thread_id,
@@ -130,11 +321,11 @@ void store_cpu_topology(unsigned int cpuid)
130 * init_cpu_topology is called at boot when only one cpu is running 321 * init_cpu_topology is called at boot when only one cpu is running
131 * which prevent simultaneous write access to cpu_topology array 322 * which prevent simultaneous write access to cpu_topology array
132 */ 323 */
133void init_cpu_topology(void) 324void __init init_cpu_topology(void)
134{ 325{
135 unsigned int cpu; 326 unsigned int cpu;
136 327
137 /* init core mask */ 328 /* init core mask and power*/
138 for_each_possible_cpu(cpu) { 329 for_each_possible_cpu(cpu) {
139 struct cputopo_arm *cpu_topo = &(cpu_topology[cpu]); 330 struct cputopo_arm *cpu_topo = &(cpu_topology[cpu]);
140 331
@@ -143,6 +334,10 @@ void init_cpu_topology(void)
143 cpu_topo->socket_id = -1; 334 cpu_topo->socket_id = -1;
144 cpumask_clear(&cpu_topo->core_sibling); 335 cpumask_clear(&cpu_topo->core_sibling);
145 cpumask_clear(&cpu_topo->thread_sibling); 336 cpumask_clear(&cpu_topo->thread_sibling);
337
338 set_power_scale(cpu, SCHED_POWER_SCALE);
146 } 339 }
147 smp_wmb(); 340 smp_wmb();
341
342 parse_dt_topology();
148} 343}
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 3647170e9a1..f7945218b8c 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -233,9 +233,9 @@ void show_stack(struct task_struct *tsk, unsigned long *sp)
233#define S_ISA " ARM" 233#define S_ISA " ARM"
234#endif 234#endif
235 235
236static int __die(const char *str, int err, struct thread_info *thread, struct pt_regs *regs) 236static int __die(const char *str, int err, struct pt_regs *regs)
237{ 237{
238 struct task_struct *tsk = thread->task; 238 struct task_struct *tsk = current;
239 static int die_counter; 239 static int die_counter;
240 int ret; 240 int ret;
241 241
@@ -245,12 +245,12 @@ static int __die(const char *str, int err, struct thread_info *thread, struct pt
245 /* trap and error numbers are mostly meaningless on ARM */ 245 /* trap and error numbers are mostly meaningless on ARM */
246 ret = notify_die(DIE_OOPS, str, regs, err, tsk->thread.trap_no, SIGSEGV); 246 ret = notify_die(DIE_OOPS, str, regs, err, tsk->thread.trap_no, SIGSEGV);
247 if (ret == NOTIFY_STOP) 247 if (ret == NOTIFY_STOP)
248 return ret; 248 return 1;
249 249
250 print_modules(); 250 print_modules();
251 __show_regs(regs); 251 __show_regs(regs);
252 printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n", 252 printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
253 TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1); 253 TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), end_of_stack(tsk));
254 254
255 if (!user_mode(regs) || in_interrupt()) { 255 if (!user_mode(regs) || in_interrupt()) {
256 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp, 256 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
@@ -259,45 +259,77 @@ static int __die(const char *str, int err, struct thread_info *thread, struct pt
259 dump_instr(KERN_EMERG, regs); 259 dump_instr(KERN_EMERG, regs);
260 } 260 }
261 261
262 return ret; 262 return 0;
263} 263}
264 264
265static DEFINE_RAW_SPINLOCK(die_lock); 265static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
266static int die_owner = -1;
267static unsigned int die_nest_count;
266 268
267/* 269static unsigned long oops_begin(void)
268 * This function is protected against re-entrancy.
269 */
270void die(const char *str, struct pt_regs *regs, int err)
271{ 270{
272 struct thread_info *thread = current_thread_info(); 271 int cpu;
273 int ret; 272 unsigned long flags;
274 enum bug_trap_type bug_type = BUG_TRAP_TYPE_NONE;
275 273
276 oops_enter(); 274 oops_enter();
277 275
278 raw_spin_lock_irq(&die_lock); 276 /* racy, but better than risking deadlock. */
277 raw_local_irq_save(flags);
278 cpu = smp_processor_id();
279 if (!arch_spin_trylock(&die_lock)) {
280 if (cpu == die_owner)
281 /* nested oops. should stop eventually */;
282 else
283 arch_spin_lock(&die_lock);
284 }
285 die_nest_count++;
286 die_owner = cpu;
279 console_verbose(); 287 console_verbose();
280 bust_spinlocks(1); 288 bust_spinlocks(1);
281 if (!user_mode(regs)) 289 return flags;
282 bug_type = report_bug(regs->ARM_pc, regs); 290}
283 if (bug_type != BUG_TRAP_TYPE_NONE)
284 str = "Oops - BUG";
285 ret = __die(str, err, thread, regs);
286 291
287 if (regs && kexec_should_crash(thread->task)) 292static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
293{
294 if (regs && kexec_should_crash(current))
288 crash_kexec(regs); 295 crash_kexec(regs);
289 296
290 bust_spinlocks(0); 297 bust_spinlocks(0);
298 die_owner = -1;
291 add_taint(TAINT_DIE); 299 add_taint(TAINT_DIE);
292 raw_spin_unlock_irq(&die_lock); 300 die_nest_count--;
301 if (!die_nest_count)
302 /* Nest count reaches zero, release the lock. */
303 arch_spin_unlock(&die_lock);
304 raw_local_irq_restore(flags);
293 oops_exit(); 305 oops_exit();
294 306
295 if (in_interrupt()) 307 if (in_interrupt())
296 panic("Fatal exception in interrupt"); 308 panic("Fatal exception in interrupt");
297 if (panic_on_oops) 309 if (panic_on_oops)
298 panic("Fatal exception"); 310 panic("Fatal exception");
299 if (ret != NOTIFY_STOP) 311 if (signr)
300 do_exit(SIGSEGV); 312 do_exit(signr);
313}
314
315/*
316 * This function is protected against re-entrancy.
317 */
318void die(const char *str, struct pt_regs *regs, int err)
319{
320 enum bug_trap_type bug_type = BUG_TRAP_TYPE_NONE;
321 unsigned long flags = oops_begin();
322 int sig = SIGSEGV;
323
324 if (!user_mode(regs))
325 bug_type = report_bug(regs->ARM_pc, regs);
326 if (bug_type != BUG_TRAP_TYPE_NONE)
327 str = "Oops - BUG";
328
329 if (__die(str, err, regs))
330 sig = 0;
331
332 oops_end(flags, regs, sig);
301} 333}
302 334
303void arm_notify_die(const char *str, struct pt_regs *regs, 335void arm_notify_die(const char *str, struct pt_regs *regs,
@@ -370,18 +402,10 @@ static int call_undef_hook(struct pt_regs *regs, unsigned int instr)
370 402
371asmlinkage void __exception do_undefinstr(struct pt_regs *regs) 403asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
372{ 404{
373 unsigned int correction = thumb_mode(regs) ? 2 : 4;
374 unsigned int instr; 405 unsigned int instr;
375 siginfo_t info; 406 siginfo_t info;
376 void __user *pc; 407 void __user *pc;
377 408
378 /*
379 * According to the ARM ARM, PC is 2 or 4 bytes ahead,
380 * depending whether we're in Thumb mode or not.
381 * Correct this offset.
382 */
383 regs->ARM_pc -= correction;
384
385 pc = (void __user *)instruction_pointer(regs); 409 pc = (void __user *)instruction_pointer(regs);
386 410
387 if (processor_mode(regs) == SVC_MODE) { 411 if (processor_mode(regs) == SVC_MODE) {
@@ -820,8 +844,6 @@ void __init early_trap_init(void *vectors_base)
820 */ 844 */
821 memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE), 845 memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
822 sigreturn_codes, sizeof(sigreturn_codes)); 846 sigreturn_codes, sizeof(sigreturn_codes));
823 memcpy((void *)(vectors + KERN_RESTART_CODE - CONFIG_VECTORS_BASE),
824 syscall_restart_code, sizeof(syscall_restart_code));
825 847
826 flush_icache_range(vectors, vectors + PAGE_SIZE); 848 flush_icache_range(vectors, vectors + PAGE_SIZE);
827 modify_domain(DOMAIN_USER, DOMAIN_CLIENT); 849 modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 992769ae259..af72969820b 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -6,9 +6,8 @@
6 6
7lib-y := backtrace.o changebit.o csumipv6.o csumpartial.o \ 7lib-y := backtrace.o changebit.o csumipv6.o csumpartial.o \
8 csumpartialcopy.o csumpartialcopyuser.o clearbit.o \ 8 csumpartialcopy.o csumpartialcopyuser.o clearbit.o \
9 delay.o findbit.o memchr.o memcpy.o \ 9 delay.o delay-loop.o findbit.o memchr.o memcpy.o \
10 memmove.o memset.o memzero.o setbit.o \ 10 memmove.o memset.o memzero.o setbit.o \
11 strncpy_from_user.o strnlen_user.o \
12 strchr.o strrchr.o \ 11 strchr.o strrchr.o \
13 testchangebit.o testclearbit.o testsetbit.o \ 12 testchangebit.o testclearbit.o testsetbit.o \
14 ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \ 13 ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \
@@ -17,13 +16,30 @@ lib-y := backtrace.o changebit.o csumipv6.o csumpartial.o \
17 call_with_stack.o 16 call_with_stack.o
18 17
19mmu-y := clear_user.o copy_page.o getuser.o putuser.o 18mmu-y := clear_user.o copy_page.o getuser.o putuser.o
20mmu-y += copy_from_user.o copy_to_user.o 19
20# the code in uaccess.S is not preemption safe and
21# probably faster on ARMv3 only
22ifeq ($(CONFIG_PREEMPT),y)
23 mmu-y += copy_from_user.o copy_to_user.o
24else
25ifneq ($(CONFIG_CPU_32v3),y)
26 mmu-y += copy_from_user.o copy_to_user.o
27else
28 mmu-y += uaccess.o
29endif
30endif
21 31
22# using lib_ here won't override already available weak symbols 32# using lib_ here won't override already available weak symbols
23obj-$(CONFIG_UACCESS_WITH_MEMCPY) += uaccess_with_memcpy.o 33obj-$(CONFIG_UACCESS_WITH_MEMCPY) += uaccess_with_memcpy.o
24 34
25lib-$(CONFIG_MMU) += $(mmu-y) 35lib-$(CONFIG_MMU) += $(mmu-y)
26lib-y += io-readsw-armv4.o io-writesw-armv4.o 36
37ifeq ($(CONFIG_CPU_32v3),y)
38 lib-y += io-readsw-armv3.o io-writesw-armv3.o
39else
40 lib-y += io-readsw-armv4.o io-writesw-armv4.o
41endif
42
27lib-$(CONFIG_ARCH_RPC) += ecard.o io-acorn.o floppydma.o 43lib-$(CONFIG_ARCH_RPC) += ecard.o io-acorn.o floppydma.o
28lib-$(CONFIG_ARCH_SHARK) += io-shark.o 44lib-$(CONFIG_ARCH_SHARK) += io-shark.o
29 45
diff --git a/arch/arm/lib/delay.S b/arch/arm/lib/delay-loop.S
index 3c9a05c8d20..36b668d8e12 100644
--- a/arch/arm/lib/delay.S
+++ b/arch/arm/lib/delay-loop.S
@@ -9,11 +9,11 @@
9 */ 9 */
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <asm/assembler.h> 11#include <asm/assembler.h>
12#include <asm/param.h> 12#include <asm/delay.h>
13 .text 13 .text
14 14
15.LC0: .word loops_per_jiffy 15.LC0: .word loops_per_jiffy
16.LC1: .word (2199023*HZ)>>11 16.LC1: .word UDELAY_MULT
17 17
18/* 18/*
19 * r0 <= 2000 19 * r0 <= 2000
@@ -21,10 +21,10 @@
21 * HZ <= 1000 21 * HZ <= 1000
22 */ 22 */
23 23
24ENTRY(__udelay) 24ENTRY(__loop_udelay)
25 ldr r2, .LC1 25 ldr r2, .LC1
26 mul r0, r2, r0 26 mul r0, r2, r0
27ENTRY(__const_udelay) @ 0 <= r0 <= 0x7fffff06 27ENTRY(__loop_const_udelay) @ 0 <= r0 <= 0x7fffff06
28 mov r1, #-1 28 mov r1, #-1
29 ldr r2, .LC0 29 ldr r2, .LC0
30 ldr r2, [r2] @ max = 0x01ffffff 30 ldr r2, [r2] @ max = 0x01ffffff
@@ -39,12 +39,10 @@ ENTRY(__const_udelay) @ 0 <= r0 <= 0x7fffff06
39 39
40/* 40/*
41 * loops = r0 * HZ * loops_per_jiffy / 1000000 41 * loops = r0 * HZ * loops_per_jiffy / 1000000
42 *
43 * Oh, if only we had a cycle counter...
44 */ 42 */
45 43
46@ Delay routine 44@ Delay routine
47ENTRY(__delay) 45ENTRY(__loop_delay)
48 subs r0, r0, #1 46 subs r0, r0, #1
49#if 0 47#if 0
50 movls pc, lr 48 movls pc, lr
@@ -62,8 +60,8 @@ ENTRY(__delay)
62 movls pc, lr 60 movls pc, lr
63 subs r0, r0, #1 61 subs r0, r0, #1
64#endif 62#endif
65 bhi __delay 63 bhi __loop_delay
66 mov pc, lr 64 mov pc, lr
67ENDPROC(__udelay) 65ENDPROC(__loop_udelay)
68ENDPROC(__const_udelay) 66ENDPROC(__loop_const_udelay)
69ENDPROC(__delay) 67ENDPROC(__loop_delay)
diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
new file mode 100644
index 00000000000..d6dacc69254
--- /dev/null
+++ b/arch/arm/lib/delay.c
@@ -0,0 +1,71 @@
1/*
2 * Delay loops based on the OpenRISC implementation.
3 *
4 * Copyright (C) 2012 ARM Limited
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Author: Will Deacon <will.deacon@arm.com>
20 */
21
22#include <linux/delay.h>
23#include <linux/init.h>
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/timex.h>
27
28/*
29 * Default to the loop-based delay implementation.
30 */
31struct arm_delay_ops arm_delay_ops = {
32 .delay = __loop_delay,
33 .const_udelay = __loop_const_udelay,
34 .udelay = __loop_udelay,
35};
36
37#ifdef ARCH_HAS_READ_CURRENT_TIMER
38static void __timer_delay(unsigned long cycles)
39{
40 cycles_t start = get_cycles();
41
42 while ((get_cycles() - start) < cycles)
43 cpu_relax();
44}
45
46static void __timer_const_udelay(unsigned long xloops)
47{
48 unsigned long long loops = xloops;
49 loops *= loops_per_jiffy;
50 __timer_delay(loops >> UDELAY_SHIFT);
51}
52
53static void __timer_udelay(unsigned long usecs)
54{
55 __timer_const_udelay(usecs * UDELAY_MULT);
56}
57
58void __init init_current_timer_delay(unsigned long freq)
59{
60 pr_info("Switching to timer-based delay loop\n");
61 lpj_fine = freq / HZ;
62 arm_delay_ops.delay = __timer_delay;
63 arm_delay_ops.const_udelay = __timer_const_udelay;
64 arm_delay_ops.udelay = __timer_udelay;
65}
66
67unsigned long __cpuinit calibrate_delay_is_known(void)
68{
69 return lpj_fine;
70}
71#endif
diff --git a/arch/arm/lib/io-acorn.S b/arch/arm/lib/io-acorn.S
index 1b197ea7aab..69719bad674 100644
--- a/arch/arm/lib/io-acorn.S
+++ b/arch/arm/lib/io-acorn.S
@@ -11,13 +11,14 @@
11 * 11 *
12 */ 12 */
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <linux/kern_levels.h>
14#include <asm/assembler.h> 15#include <asm/assembler.h>
15 16
16 .text 17 .text
17 .align 18 .align
18 19
19.Liosl_warning: 20.Liosl_warning:
20 .ascii "<4>insl/outsl not implemented, called from %08lX\0" 21 .ascii KERN_WARNING "insl/outsl not implemented, called from %08lX\0"
21 .align 22 .align
22 23
23/* 24/*
diff --git a/arch/arm/lib/io-readsw-armv3.S b/arch/arm/lib/io-readsw-armv3.S
new file mode 100644
index 00000000000..88487c8c4f2
--- /dev/null
+++ b/arch/arm/lib/io-readsw-armv3.S
@@ -0,0 +1,106 @@
1/*
2 * linux/arch/arm/lib/io-readsw-armv3.S
3 *
4 * Copyright (C) 1995-2000 Russell King
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#include <linux/linkage.h>
11#include <asm/assembler.h>
12
13.Linsw_bad_alignment:
14 adr r0, .Linsw_bad_align_msg
15 mov r2, lr
16 b panic
17.Linsw_bad_align_msg:
18 .asciz "insw: bad buffer alignment (0x%p, lr=0x%08lX)\n"
19 .align
20
21.Linsw_align: tst r1, #1
22 bne .Linsw_bad_alignment
23
24 ldr r3, [r0]
25 strb r3, [r1], #1
26 mov r3, r3, lsr #8
27 strb r3, [r1], #1
28
29 subs r2, r2, #1
30 moveq pc, lr
31
32ENTRY(__raw_readsw)
33 teq r2, #0 @ do we have to check for the zero len?
34 moveq pc, lr
35 tst r1, #3
36 bne .Linsw_align
37
38.Linsw_aligned: mov ip, #0xff
39 orr ip, ip, ip, lsl #8
40 stmfd sp!, {r4, r5, r6, lr}
41
42 subs r2, r2, #8
43 bmi .Lno_insw_8
44
45.Linsw_8_lp: ldr r3, [r0]
46 and r3, r3, ip
47 ldr r4, [r0]
48 orr r3, r3, r4, lsl #16
49
50 ldr r4, [r0]
51 and r4, r4, ip
52 ldr r5, [r0]
53 orr r4, r4, r5, lsl #16
54
55 ldr r5, [r0]
56 and r5, r5, ip
57 ldr r6, [r0]
58 orr r5, r5, r6, lsl #16
59
60 ldr r6, [r0]
61 and r6, r6, ip
62 ldr lr, [r0]
63 orr r6, r6, lr, lsl #16
64
65 stmia r1!, {r3 - r6}
66
67 subs r2, r2, #8
68 bpl .Linsw_8_lp
69
70 tst r2, #7
71 ldmeqfd sp!, {r4, r5, r6, pc}
72
73.Lno_insw_8: tst r2, #4
74 beq .Lno_insw_4
75
76 ldr r3, [r0]
77 and r3, r3, ip
78 ldr r4, [r0]
79 orr r3, r3, r4, lsl #16
80
81 ldr r4, [r0]
82 and r4, r4, ip
83 ldr r5, [r0]
84 orr r4, r4, r5, lsl #16
85
86 stmia r1!, {r3, r4}
87
88.Lno_insw_4: tst r2, #2
89 beq .Lno_insw_2
90
91 ldr r3, [r0]
92 and r3, r3, ip
93 ldr r4, [r0]
94 orr r3, r3, r4, lsl #16
95
96 str r3, [r1], #4
97
98.Lno_insw_2: tst r2, #1
99 ldrne r3, [r0]
100 strneb r3, [r1], #1
101 movne r3, r3, lsr #8
102 strneb r3, [r1]
103
104 ldmfd sp!, {r4, r5, r6, pc}
105
106
diff --git a/arch/arm/lib/io-writesw-armv3.S b/arch/arm/lib/io-writesw-armv3.S
new file mode 100644
index 00000000000..49b800419e3
--- /dev/null
+++ b/arch/arm/lib/io-writesw-armv3.S
@@ -0,0 +1,126 @@
1/*
2 * linux/arch/arm/lib/io-writesw-armv3.S
3 *
4 * Copyright (C) 1995-2000 Russell King
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#include <linux/linkage.h>
11#include <asm/assembler.h>
12
13.Loutsw_bad_alignment:
14 adr r0, .Loutsw_bad_align_msg
15 mov r2, lr
16 b panic
17.Loutsw_bad_align_msg:
18 .asciz "outsw: bad buffer alignment (0x%p, lr=0x%08lX)\n"
19 .align
20
21.Loutsw_align: tst r1, #1
22 bne .Loutsw_bad_alignment
23
24 add r1, r1, #2
25
26 ldr r3, [r1, #-4]
27 mov r3, r3, lsr #16
28 orr r3, r3, r3, lsl #16
29 str r3, [r0]
30 subs r2, r2, #1
31 moveq pc, lr
32
33ENTRY(__raw_writesw)
34 teq r2, #0 @ do we have to check for the zero len?
35 moveq pc, lr
36 tst r1, #3
37 bne .Loutsw_align
38
39 stmfd sp!, {r4, r5, r6, lr}
40
41 subs r2, r2, #8
42 bmi .Lno_outsw_8
43
44.Loutsw_8_lp: ldmia r1!, {r3, r4, r5, r6}
45
46 mov ip, r3, lsl #16
47 orr ip, ip, ip, lsr #16
48 str ip, [r0]
49
50 mov ip, r3, lsr #16
51 orr ip, ip, ip, lsl #16
52 str ip, [r0]
53
54 mov ip, r4, lsl #16
55 orr ip, ip, ip, lsr #16
56 str ip, [r0]
57
58 mov ip, r4, lsr #16
59 orr ip, ip, ip, lsl #16
60 str ip, [r0]
61
62 mov ip, r5, lsl #16
63 orr ip, ip, ip, lsr #16
64 str ip, [r0]
65
66 mov ip, r5, lsr #16
67 orr ip, ip, ip, lsl #16
68 str ip, [r0]
69
70 mov ip, r6, lsl #16
71 orr ip, ip, ip, lsr #16
72 str ip, [r0]
73
74 mov ip, r6, lsr #16
75 orr ip, ip, ip, lsl #16
76 str ip, [r0]
77
78 subs r2, r2, #8
79 bpl .Loutsw_8_lp
80
81 tst r2, #7
82 ldmeqfd sp!, {r4, r5, r6, pc}
83
84.Lno_outsw_8: tst r2, #4
85 beq .Lno_outsw_4
86
87 ldmia r1!, {r3, r4}
88
89 mov ip, r3, lsl #16
90 orr ip, ip, ip, lsr #16
91 str ip, [r0]
92
93 mov ip, r3, lsr #16
94 orr ip, ip, ip, lsl #16
95 str ip, [r0]
96
97 mov ip, r4, lsl #16
98 orr ip, ip, ip, lsr #16
99 str ip, [r0]
100
101 mov ip, r4, lsr #16
102 orr ip, ip, ip, lsl #16
103 str ip, [r0]
104
105.Lno_outsw_4: tst r2, #2
106 beq .Lno_outsw_2
107
108 ldr r3, [r1], #4
109
110 mov ip, r3, lsl #16
111 orr ip, ip, ip, lsr #16
112 str ip, [r0]
113
114 mov ip, r3, lsr #16
115 orr ip, ip, ip, lsl #16
116 str ip, [r0]
117
118.Lno_outsw_2: tst r2, #1
119
120 ldrne r3, [r1]
121
122 movne ip, r3, lsl #16
123 orrne ip, ip, ip, lsr #16
124 strne ip, [r0]
125
126 ldmfd sp!, {r4, r5, r6, pc}
diff --git a/arch/arm/lib/strncpy_from_user.S b/arch/arm/lib/strncpy_from_user.S
deleted file mode 100644
index f202d7bd164..00000000000
--- a/arch/arm/lib/strncpy_from_user.S
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * linux/arch/arm/lib/strncpy_from_user.S
3 *
4 * Copyright (C) 1995-2000 Russell King
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#include <linux/linkage.h>
11#include <asm/assembler.h>
12#include <asm/errno.h>
13
14 .text
15 .align 5
16
17/*
18 * Copy a string from user space to kernel space.
19 * r0 = dst, r1 = src, r2 = byte length
20 * returns the number of characters copied (strlen of copied string),
21 * -EFAULT on exception, or "len" if we fill the whole buffer
22 */
23ENTRY(__strncpy_from_user)
24 mov ip, r1
251: subs r2, r2, #1
26 ldrusr r3, r1, 1, pl
27 bmi 2f
28 strb r3, [r0], #1
29 teq r3, #0
30 bne 1b
31 sub r1, r1, #1 @ take NUL character out of count
322: sub r0, r1, ip
33 mov pc, lr
34ENDPROC(__strncpy_from_user)
35
36 .pushsection .fixup,"ax"
37 .align 0
389001: mov r3, #0
39 strb r3, [r0, #0] @ null terminate
40 mov r0, #-EFAULT
41 mov pc, lr
42 .popsection
43
diff --git a/arch/arm/lib/strnlen_user.S b/arch/arm/lib/strnlen_user.S
deleted file mode 100644
index 0ecbb459c4f..00000000000
--- a/arch/arm/lib/strnlen_user.S
+++ /dev/null
@@ -1,40 +0,0 @@
1/*
2 * linux/arch/arm/lib/strnlen_user.S
3 *
4 * Copyright (C) 1995-2000 Russell King
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#include <linux/linkage.h>
11#include <asm/assembler.h>
12#include <asm/errno.h>
13
14 .text
15 .align 5
16
17/* Prototype: unsigned long __strnlen_user(const char *str, long n)
18 * Purpose : get length of a string in user memory
19 * Params : str - address of string in user memory
20 * Returns : length of string *including terminator*
21 * or zero on exception, or n + 1 if too long
22 */
23ENTRY(__strnlen_user)
24 mov r2, r0
251:
26 ldrusr r3, r0, 1
27 teq r3, #0
28 beq 2f
29 subs r1, r1, #1
30 bne 1b
31 add r0, r0, #1
322: sub r0, r0, r2
33 mov pc, lr
34ENDPROC(__strnlen_user)
35
36 .pushsection .fixup,"ax"
37 .align 0
389001: mov r0, #0
39 mov pc, lr
40 .popsection
diff --git a/arch/arm/lib/uaccess.S b/arch/arm/lib/uaccess.S
new file mode 100644
index 00000000000..5c908b1cb8e
--- /dev/null
+++ b/arch/arm/lib/uaccess.S
@@ -0,0 +1,564 @@
1/*
2 * linux/arch/arm/lib/uaccess.S
3 *
4 * Copyright (C) 1995, 1996,1997,1998 Russell King
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 * Routines to block copy data to/from user memory
11 * These are highly optimised both for the 4k page size
12 * and for various alignments.
13 */
14#include <linux/linkage.h>
15#include <asm/assembler.h>
16#include <asm/errno.h>
17#include <asm/domain.h>
18
19 .text
20
21#define PAGE_SHIFT 12
22
23/* Prototype: int __copy_to_user(void *to, const char *from, size_t n)
24 * Purpose : copy a block to user memory from kernel memory
25 * Params : to - user memory
26 * : from - kernel memory
27 * : n - number of bytes to copy
28 * Returns : Number of bytes NOT copied.
29 */
30
31.Lc2u_dest_not_aligned:
32 rsb ip, ip, #4
33 cmp ip, #2
34 ldrb r3, [r1], #1
35USER( TUSER( strb) r3, [r0], #1) @ May fault
36 ldrgeb r3, [r1], #1
37USER( TUSER( strgeb) r3, [r0], #1) @ May fault
38 ldrgtb r3, [r1], #1
39USER( TUSER( strgtb) r3, [r0], #1) @ May fault
40 sub r2, r2, ip
41 b .Lc2u_dest_aligned
42
43ENTRY(__copy_to_user)
44 stmfd sp!, {r2, r4 - r7, lr}
45 cmp r2, #4
46 blt .Lc2u_not_enough
47 ands ip, r0, #3
48 bne .Lc2u_dest_not_aligned
49.Lc2u_dest_aligned:
50
51 ands ip, r1, #3
52 bne .Lc2u_src_not_aligned
53/*
54 * Seeing as there has to be at least 8 bytes to copy, we can
55 * copy one word, and force a user-mode page fault...
56 */
57
58.Lc2u_0fupi: subs r2, r2, #4
59 addmi ip, r2, #4
60 bmi .Lc2u_0nowords
61 ldr r3, [r1], #4
62USER( TUSER( str) r3, [r0], #4) @ May fault
63 mov ip, r0, lsl #32 - PAGE_SHIFT @ On each page, use a ld/st??t instruction
64 rsb ip, ip, #0
65 movs ip, ip, lsr #32 - PAGE_SHIFT
66 beq .Lc2u_0fupi
67/*
68 * ip = max no. of bytes to copy before needing another "strt" insn
69 */
70 cmp r2, ip
71 movlt ip, r2
72 sub r2, r2, ip
73 subs ip, ip, #32
74 blt .Lc2u_0rem8lp
75
76.Lc2u_0cpy8lp: ldmia r1!, {r3 - r6}
77 stmia r0!, {r3 - r6} @ Shouldnt fault
78 ldmia r1!, {r3 - r6}
79 subs ip, ip, #32
80 stmia r0!, {r3 - r6} @ Shouldnt fault
81 bpl .Lc2u_0cpy8lp
82
83.Lc2u_0rem8lp: cmn ip, #16
84 ldmgeia r1!, {r3 - r6}
85 stmgeia r0!, {r3 - r6} @ Shouldnt fault
86 tst ip, #8
87 ldmneia r1!, {r3 - r4}
88 stmneia r0!, {r3 - r4} @ Shouldnt fault
89 tst ip, #4
90 ldrne r3, [r1], #4
91 TUSER( strne) r3, [r0], #4 @ Shouldnt fault
92 ands ip, ip, #3
93 beq .Lc2u_0fupi
94.Lc2u_0nowords: teq ip, #0
95 beq .Lc2u_finished
96.Lc2u_nowords: cmp ip, #2
97 ldrb r3, [r1], #1
98USER( TUSER( strb) r3, [r0], #1) @ May fault
99 ldrgeb r3, [r1], #1
100USER( TUSER( strgeb) r3, [r0], #1) @ May fault
101 ldrgtb r3, [r1], #1
102USER( TUSER( strgtb) r3, [r0], #1) @ May fault
103 b .Lc2u_finished
104
105.Lc2u_not_enough:
106 movs ip, r2
107 bne .Lc2u_nowords
108.Lc2u_finished: mov r0, #0
109 ldmfd sp!, {r2, r4 - r7, pc}
110
111.Lc2u_src_not_aligned:
112 bic r1, r1, #3
113 ldr r7, [r1], #4
114 cmp ip, #2
115 bgt .Lc2u_3fupi
116 beq .Lc2u_2fupi
117.Lc2u_1fupi: subs r2, r2, #4
118 addmi ip, r2, #4
119 bmi .Lc2u_1nowords
120 mov r3, r7, pull #8
121 ldr r7, [r1], #4
122 orr r3, r3, r7, push #24
123USER( TUSER( str) r3, [r0], #4) @ May fault
124 mov ip, r0, lsl #32 - PAGE_SHIFT
125 rsb ip, ip, #0
126 movs ip, ip, lsr #32 - PAGE_SHIFT
127 beq .Lc2u_1fupi
128 cmp r2, ip
129 movlt ip, r2
130 sub r2, r2, ip
131 subs ip, ip, #16
132 blt .Lc2u_1rem8lp
133
134.Lc2u_1cpy8lp: mov r3, r7, pull #8
135 ldmia r1!, {r4 - r7}
136 subs ip, ip, #16
137 orr r3, r3, r4, push #24
138 mov r4, r4, pull #8
139 orr r4, r4, r5, push #24
140 mov r5, r5, pull #8
141 orr r5, r5, r6, push #24
142 mov r6, r6, pull #8
143 orr r6, r6, r7, push #24
144 stmia r0!, {r3 - r6} @ Shouldnt fault
145 bpl .Lc2u_1cpy8lp
146
147.Lc2u_1rem8lp: tst ip, #8
148 movne r3, r7, pull #8
149 ldmneia r1!, {r4, r7}
150 orrne r3, r3, r4, push #24
151 movne r4, r4, pull #8
152 orrne r4, r4, r7, push #24
153 stmneia r0!, {r3 - r4} @ Shouldnt fault
154 tst ip, #4
155 movne r3, r7, pull #8
156 ldrne r7, [r1], #4
157 orrne r3, r3, r7, push #24
158 TUSER( strne) r3, [r0], #4 @ Shouldnt fault
159 ands ip, ip, #3
160 beq .Lc2u_1fupi
161.Lc2u_1nowords: mov r3, r7, get_byte_1
162 teq ip, #0
163 beq .Lc2u_finished
164 cmp ip, #2
165USER( TUSER( strb) r3, [r0], #1) @ May fault
166 movge r3, r7, get_byte_2
167USER( TUSER( strgeb) r3, [r0], #1) @ May fault
168 movgt r3, r7, get_byte_3
169USER( TUSER( strgtb) r3, [r0], #1) @ May fault
170 b .Lc2u_finished
171
172.Lc2u_2fupi: subs r2, r2, #4
173 addmi ip, r2, #4
174 bmi .Lc2u_2nowords
175 mov r3, r7, pull #16
176 ldr r7, [r1], #4
177 orr r3, r3, r7, push #16
178USER( TUSER( str) r3, [r0], #4) @ May fault
179 mov ip, r0, lsl #32 - PAGE_SHIFT
180 rsb ip, ip, #0
181 movs ip, ip, lsr #32 - PAGE_SHIFT
182 beq .Lc2u_2fupi
183 cmp r2, ip
184 movlt ip, r2
185 sub r2, r2, ip
186 subs ip, ip, #16
187 blt .Lc2u_2rem8lp
188
189.Lc2u_2cpy8lp: mov r3, r7, pull #16
190 ldmia r1!, {r4 - r7}
191 subs ip, ip, #16
192 orr r3, r3, r4, push #16
193 mov r4, r4, pull #16
194 orr r4, r4, r5, push #16
195 mov r5, r5, pull #16
196 orr r5, r5, r6, push #16
197 mov r6, r6, pull #16
198 orr r6, r6, r7, push #16
199 stmia r0!, {r3 - r6} @ Shouldnt fault
200 bpl .Lc2u_2cpy8lp
201
202.Lc2u_2rem8lp: tst ip, #8
203 movne r3, r7, pull #16
204 ldmneia r1!, {r4, r7}
205 orrne r3, r3, r4, push #16
206 movne r4, r4, pull #16
207 orrne r4, r4, r7, push #16
208 stmneia r0!, {r3 - r4} @ Shouldnt fault
209 tst ip, #4
210 movne r3, r7, pull #16
211 ldrne r7, [r1], #4
212 orrne r3, r3, r7, push #16
213 TUSER( strne) r3, [r0], #4 @ Shouldnt fault
214 ands ip, ip, #3
215 beq .Lc2u_2fupi
216.Lc2u_2nowords: mov r3, r7, get_byte_2
217 teq ip, #0
218 beq .Lc2u_finished
219 cmp ip, #2
220USER( TUSER( strb) r3, [r0], #1) @ May fault
221 movge r3, r7, get_byte_3
222USER( TUSER( strgeb) r3, [r0], #1) @ May fault
223 ldrgtb r3, [r1], #0
224USER( TUSER( strgtb) r3, [r0], #1) @ May fault
225 b .Lc2u_finished
226
227.Lc2u_3fupi: subs r2, r2, #4
228 addmi ip, r2, #4
229 bmi .Lc2u_3nowords
230 mov r3, r7, pull #24
231 ldr r7, [r1], #4
232 orr r3, r3, r7, push #8
233USER( TUSER( str) r3, [r0], #4) @ May fault
234 mov ip, r0, lsl #32 - PAGE_SHIFT
235 rsb ip, ip, #0
236 movs ip, ip, lsr #32 - PAGE_SHIFT
237 beq .Lc2u_3fupi
238 cmp r2, ip
239 movlt ip, r2
240 sub r2, r2, ip
241 subs ip, ip, #16
242 blt .Lc2u_3rem8lp
243
244.Lc2u_3cpy8lp: mov r3, r7, pull #24
245 ldmia r1!, {r4 - r7}
246 subs ip, ip, #16
247 orr r3, r3, r4, push #8
248 mov r4, r4, pull #24
249 orr r4, r4, r5, push #8
250 mov r5, r5, pull #24
251 orr r5, r5, r6, push #8
252 mov r6, r6, pull #24
253 orr r6, r6, r7, push #8
254 stmia r0!, {r3 - r6} @ Shouldnt fault
255 bpl .Lc2u_3cpy8lp
256
257.Lc2u_3rem8lp: tst ip, #8
258 movne r3, r7, pull #24
259 ldmneia r1!, {r4, r7}
260 orrne r3, r3, r4, push #8
261 movne r4, r4, pull #24
262 orrne r4, r4, r7, push #8
263 stmneia r0!, {r3 - r4} @ Shouldnt fault
264 tst ip, #4
265 movne r3, r7, pull #24
266 ldrne r7, [r1], #4
267 orrne r3, r3, r7, push #8
268 TUSER( strne) r3, [r0], #4 @ Shouldnt fault
269 ands ip, ip, #3
270 beq .Lc2u_3fupi
271.Lc2u_3nowords: mov r3, r7, get_byte_3
272 teq ip, #0
273 beq .Lc2u_finished
274 cmp ip, #2
275USER( TUSER( strb) r3, [r0], #1) @ May fault
276 ldrgeb r3, [r1], #1
277USER( TUSER( strgeb) r3, [r0], #1) @ May fault
278 ldrgtb r3, [r1], #0
279USER( TUSER( strgtb) r3, [r0], #1) @ May fault
280 b .Lc2u_finished
281ENDPROC(__copy_to_user)
282
283 .pushsection .fixup,"ax"
284 .align 0
2859001: ldmfd sp!, {r0, r4 - r7, pc}
286 .popsection
287
288/* Prototype: unsigned long __copy_from_user(void *to,const void *from,unsigned long n);
289 * Purpose : copy a block from user memory to kernel memory
290 * Params : to - kernel memory
291 * : from - user memory
292 * : n - number of bytes to copy
293 * Returns : Number of bytes NOT copied.
294 */
295.Lcfu_dest_not_aligned:
296 rsb ip, ip, #4
297 cmp ip, #2
298USER( TUSER( ldrb) r3, [r1], #1) @ May fault
299 strb r3, [r0], #1
300USER( TUSER( ldrgeb) r3, [r1], #1) @ May fault
301 strgeb r3, [r0], #1
302USER( TUSER( ldrgtb) r3, [r1], #1) @ May fault
303 strgtb r3, [r0], #1
304 sub r2, r2, ip
305 b .Lcfu_dest_aligned
306
307ENTRY(__copy_from_user)
308 stmfd sp!, {r0, r2, r4 - r7, lr}
309 cmp r2, #4
310 blt .Lcfu_not_enough
311 ands ip, r0, #3
312 bne .Lcfu_dest_not_aligned
313.Lcfu_dest_aligned:
314 ands ip, r1, #3
315 bne .Lcfu_src_not_aligned
316
317/*
318 * Seeing as there has to be at least 8 bytes to copy, we can
319 * copy one word, and force a user-mode page fault...
320 */
321
322.Lcfu_0fupi: subs r2, r2, #4
323 addmi ip, r2, #4
324 bmi .Lcfu_0nowords
325USER( TUSER( ldr) r3, [r1], #4)
326 str r3, [r0], #4
327 mov ip, r1, lsl #32 - PAGE_SHIFT @ On each page, use a ld/st??t instruction
328 rsb ip, ip, #0
329 movs ip, ip, lsr #32 - PAGE_SHIFT
330 beq .Lcfu_0fupi
331/*
332 * ip = max no. of bytes to copy before needing another "strt" insn
333 */
334 cmp r2, ip
335 movlt ip, r2
336 sub r2, r2, ip
337 subs ip, ip, #32
338 blt .Lcfu_0rem8lp
339
340.Lcfu_0cpy8lp: ldmia r1!, {r3 - r6} @ Shouldnt fault
341 stmia r0!, {r3 - r6}
342 ldmia r1!, {r3 - r6} @ Shouldnt fault
343 subs ip, ip, #32
344 stmia r0!, {r3 - r6}
345 bpl .Lcfu_0cpy8lp
346
347.Lcfu_0rem8lp: cmn ip, #16
348 ldmgeia r1!, {r3 - r6} @ Shouldnt fault
349 stmgeia r0!, {r3 - r6}
350 tst ip, #8
351 ldmneia r1!, {r3 - r4} @ Shouldnt fault
352 stmneia r0!, {r3 - r4}
353 tst ip, #4
354 TUSER( ldrne) r3, [r1], #4 @ Shouldnt fault
355 strne r3, [r0], #4
356 ands ip, ip, #3
357 beq .Lcfu_0fupi
358.Lcfu_0nowords: teq ip, #0
359 beq .Lcfu_finished
360.Lcfu_nowords: cmp ip, #2
361USER( TUSER( ldrb) r3, [r1], #1) @ May fault
362 strb r3, [r0], #1
363USER( TUSER( ldrgeb) r3, [r1], #1) @ May fault
364 strgeb r3, [r0], #1
365USER( TUSER( ldrgtb) r3, [r1], #1) @ May fault
366 strgtb r3, [r0], #1
367 b .Lcfu_finished
368
369.Lcfu_not_enough:
370 movs ip, r2
371 bne .Lcfu_nowords
372.Lcfu_finished: mov r0, #0
373 add sp, sp, #8
374 ldmfd sp!, {r4 - r7, pc}
375
376.Lcfu_src_not_aligned:
377 bic r1, r1, #3
378USER( TUSER( ldr) r7, [r1], #4) @ May fault
379 cmp ip, #2
380 bgt .Lcfu_3fupi
381 beq .Lcfu_2fupi
382.Lcfu_1fupi: subs r2, r2, #4
383 addmi ip, r2, #4
384 bmi .Lcfu_1nowords
385 mov r3, r7, pull #8
386USER( TUSER( ldr) r7, [r1], #4) @ May fault
387 orr r3, r3, r7, push #24
388 str r3, [r0], #4
389 mov ip, r1, lsl #32 - PAGE_SHIFT
390 rsb ip, ip, #0
391 movs ip, ip, lsr #32 - PAGE_SHIFT
392 beq .Lcfu_1fupi
393 cmp r2, ip
394 movlt ip, r2
395 sub r2, r2, ip
396 subs ip, ip, #16
397 blt .Lcfu_1rem8lp
398
399.Lcfu_1cpy8lp: mov r3, r7, pull #8
400 ldmia r1!, {r4 - r7} @ Shouldnt fault
401 subs ip, ip, #16
402 orr r3, r3, r4, push #24
403 mov r4, r4, pull #8
404 orr r4, r4, r5, push #24
405 mov r5, r5, pull #8
406 orr r5, r5, r6, push #24
407 mov r6, r6, pull #8
408 orr r6, r6, r7, push #24
409 stmia r0!, {r3 - r6}
410 bpl .Lcfu_1cpy8lp
411
412.Lcfu_1rem8lp: tst ip, #8
413 movne r3, r7, pull #8
414 ldmneia r1!, {r4, r7} @ Shouldnt fault
415 orrne r3, r3, r4, push #24
416 movne r4, r4, pull #8
417 orrne r4, r4, r7, push #24
418 stmneia r0!, {r3 - r4}
419 tst ip, #4
420 movne r3, r7, pull #8
421USER( TUSER( ldrne) r7, [r1], #4) @ May fault
422 orrne r3, r3, r7, push #24
423 strne r3, [r0], #4
424 ands ip, ip, #3
425 beq .Lcfu_1fupi
426.Lcfu_1nowords: mov r3, r7, get_byte_1
427 teq ip, #0
428 beq .Lcfu_finished
429 cmp ip, #2
430 strb r3, [r0], #1
431 movge r3, r7, get_byte_2
432 strgeb r3, [r0], #1
433 movgt r3, r7, get_byte_3
434 strgtb r3, [r0], #1
435 b .Lcfu_finished
436
437.Lcfu_2fupi: subs r2, r2, #4
438 addmi ip, r2, #4
439 bmi .Lcfu_2nowords
440 mov r3, r7, pull #16
441USER( TUSER( ldr) r7, [r1], #4) @ May fault
442 orr r3, r3, r7, push #16
443 str r3, [r0], #4
444 mov ip, r1, lsl #32 - PAGE_SHIFT
445 rsb ip, ip, #0
446 movs ip, ip, lsr #32 - PAGE_SHIFT
447 beq .Lcfu_2fupi
448 cmp r2, ip
449 movlt ip, r2
450 sub r2, r2, ip
451 subs ip, ip, #16
452 blt .Lcfu_2rem8lp
453
454
455.Lcfu_2cpy8lp: mov r3, r7, pull #16
456 ldmia r1!, {r4 - r7} @ Shouldnt fault
457 subs ip, ip, #16
458 orr r3, r3, r4, push #16
459 mov r4, r4, pull #16
460 orr r4, r4, r5, push #16
461 mov r5, r5, pull #16
462 orr r5, r5, r6, push #16
463 mov r6, r6, pull #16
464 orr r6, r6, r7, push #16
465 stmia r0!, {r3 - r6}
466 bpl .Lcfu_2cpy8lp
467
468.Lcfu_2rem8lp: tst ip, #8
469 movne r3, r7, pull #16
470 ldmneia r1!, {r4, r7} @ Shouldnt fault
471 orrne r3, r3, r4, push #16
472 movne r4, r4, pull #16
473 orrne r4, r4, r7, push #16
474 stmneia r0!, {r3 - r4}
475 tst ip, #4
476 movne r3, r7, pull #16
477USER( TUSER( ldrne) r7, [r1], #4) @ May fault
478 orrne r3, r3, r7, push #16
479 strne r3, [r0], #4
480 ands ip, ip, #3
481 beq .Lcfu_2fupi
482.Lcfu_2nowords: mov r3, r7, get_byte_2
483 teq ip, #0
484 beq .Lcfu_finished
485 cmp ip, #2
486 strb r3, [r0], #1
487 movge r3, r7, get_byte_3
488 strgeb r3, [r0], #1
489USER( TUSER( ldrgtb) r3, [r1], #0) @ May fault
490 strgtb r3, [r0], #1
491 b .Lcfu_finished
492
493.Lcfu_3fupi: subs r2, r2, #4
494 addmi ip, r2, #4
495 bmi .Lcfu_3nowords
496 mov r3, r7, pull #24
497USER( TUSER( ldr) r7, [r1], #4) @ May fault
498 orr r3, r3, r7, push #8
499 str r3, [r0], #4
500 mov ip, r1, lsl #32 - PAGE_SHIFT
501 rsb ip, ip, #0
502 movs ip, ip, lsr #32 - PAGE_SHIFT
503 beq .Lcfu_3fupi
504 cmp r2, ip
505 movlt ip, r2
506 sub r2, r2, ip
507 subs ip, ip, #16
508 blt .Lcfu_3rem8lp
509
510.Lcfu_3cpy8lp: mov r3, r7, pull #24
511 ldmia r1!, {r4 - r7} @ Shouldnt fault
512 orr r3, r3, r4, push #8
513 mov r4, r4, pull #24
514 orr r4, r4, r5, push #8
515 mov r5, r5, pull #24
516 orr r5, r5, r6, push #8
517 mov r6, r6, pull #24
518 orr r6, r6, r7, push #8
519 stmia r0!, {r3 - r6}
520 subs ip, ip, #16
521 bpl .Lcfu_3cpy8lp
522
523.Lcfu_3rem8lp: tst ip, #8
524 movne r3, r7, pull #24
525 ldmneia r1!, {r4, r7} @ Shouldnt fault
526 orrne r3, r3, r4, push #8
527 movne r4, r4, pull #24
528 orrne r4, r4, r7, push #8
529 stmneia r0!, {r3 - r4}
530 tst ip, #4
531 movne r3, r7, pull #24
532USER( TUSER( ldrne) r7, [r1], #4) @ May fault
533 orrne r3, r3, r7, push #8
534 strne r3, [r0], #4
535 ands ip, ip, #3
536 beq .Lcfu_3fupi
537.Lcfu_3nowords: mov r3, r7, get_byte_3
538 teq ip, #0
539 beq .Lcfu_finished
540 cmp ip, #2
541 strb r3, [r0], #1
542USER( TUSER( ldrgeb) r3, [r1], #1) @ May fault
543 strgeb r3, [r0], #1
544USER( TUSER( ldrgtb) r3, [r1], #1) @ May fault
545 strgtb r3, [r0], #1
546 b .Lcfu_finished
547ENDPROC(__copy_from_user)
548
549 .pushsection .fixup,"ax"
550 .align 0
551 /*
552 * We took an exception. r0 contains a pointer to
553 * the byte not copied.
554 */
5559001: ldr r2, [sp], #4 @ void *to
556 sub r2, r0, r2 @ bytes copied
557 ldr r1, [sp], #4 @ unsigned long count
558 subs r4, r1, r2 @ bytes left to copy
559 movne r1, r4
560 blne __memzero
561 mov r0, r4
562 ldmfd sp!, {r4 - r7, pc}
563 .popsection
564
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 19505c0a3f0..c8050b14e61 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -29,12 +29,16 @@ comment "Atmel AT91 Processor"
29config SOC_AT91SAM9 29config SOC_AT91SAM9
30 bool 30 bool
31 select CPU_ARM926T 31 select CPU_ARM926T
32 select MULTI_IRQ_HANDLER
33 select SPARSE_IRQ
32 select AT91_SAM9_TIME 34 select AT91_SAM9_TIME
33 select AT91_SAM9_SMC 35 select AT91_SAM9_SMC
34 36
35config SOC_AT91RM9200 37config SOC_AT91RM9200
36 bool "AT91RM9200" 38 bool "AT91RM9200"
37 select CPU_ARM920T 39 select CPU_ARM920T
40 select MULTI_IRQ_HANDLER
41 select SPARSE_IRQ
38 select GENERIC_CLOCKEVENTS 42 select GENERIC_CLOCKEVENTS
39 select HAVE_AT91_DBGU0 43 select HAVE_AT91_DBGU0
40 44
@@ -140,6 +144,8 @@ config ARCH_AT91SAM9G45
140config ARCH_AT91X40 144config ARCH_AT91X40
141 bool "AT91x40" 145 bool "AT91x40"
142 depends on !MMU 146 depends on !MMU
147 select MULTI_IRQ_HANDLER
148 select SPARSE_IRQ
143 select ARCH_USES_GETTIMEOFFSET 149 select ARCH_USES_GETTIMEOFFSET
144 150
145endchoice 151endchoice
diff --git a/arch/arm/mach-at91/Makefile.boot b/arch/arm/mach-at91/Makefile.boot
index 9e84fe4f2aa..30bb7332e30 100644
--- a/arch/arm/mach-at91/Makefile.boot
+++ b/arch/arm/mach-at91/Makefile.boot
@@ -15,7 +15,9 @@ endif
15 15
16# Keep dtb files sorted alphabetically for each SoC 16# Keep dtb files sorted alphabetically for each SoC
17# sam9260 17# sam9260
18dtb-$(CONFIG_MACH_AT91SAM_DT) += aks-cdu.dtb
18dtb-$(CONFIG_MACH_AT91SAM_DT) += ethernut5.dtb 19dtb-$(CONFIG_MACH_AT91SAM_DT) += ethernut5.dtb
20dtb-$(CONFIG_MACH_AT91SAM_DT) += evk-pro3.dtb
19dtb-$(CONFIG_MACH_AT91SAM_DT) += tny_a9260.dtb 21dtb-$(CONFIG_MACH_AT91SAM_DT) += tny_a9260.dtb
20dtb-$(CONFIG_MACH_AT91SAM_DT) += usb_a9260.dtb 22dtb-$(CONFIG_MACH_AT91SAM_DT) += usb_a9260.dtb
21# sam9263 23# sam9263
diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
index 26917687fc3..6f50c672227 100644
--- a/arch/arm/mach-at91/at91rm9200.c
+++ b/arch/arm/mach-at91/at91rm9200.c
@@ -17,6 +17,7 @@
17#include <asm/mach/map.h> 17#include <asm/mach/map.h>
18#include <asm/system_misc.h> 18#include <asm/system_misc.h>
19#include <mach/at91rm9200.h> 19#include <mach/at91rm9200.h>
20#include <mach/at91_aic.h>
20#include <mach/at91_pmc.h> 21#include <mach/at91_pmc.h>
21#include <mach/at91_st.h> 22#include <mach/at91_st.h>
22#include <mach/cpu.h> 23#include <mach/cpu.h>
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index e6b7d0533dd..01fb7325fec 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -41,8 +41,8 @@ static struct resource usbh_resources[] = {
41 .flags = IORESOURCE_MEM, 41 .flags = IORESOURCE_MEM,
42 }, 42 },
43 [1] = { 43 [1] = {
44 .start = AT91RM9200_ID_UHP, 44 .start = NR_IRQS_LEGACY + AT91RM9200_ID_UHP,
45 .end = AT91RM9200_ID_UHP, 45 .end = NR_IRQS_LEGACY + AT91RM9200_ID_UHP,
46 .flags = IORESOURCE_IRQ, 46 .flags = IORESOURCE_IRQ,
47 }, 47 },
48}; 48};
@@ -94,8 +94,8 @@ static struct resource udc_resources[] = {
94 .flags = IORESOURCE_MEM, 94 .flags = IORESOURCE_MEM,
95 }, 95 },
96 [1] = { 96 [1] = {
97 .start = AT91RM9200_ID_UDP, 97 .start = NR_IRQS_LEGACY + AT91RM9200_ID_UDP,
98 .end = AT91RM9200_ID_UDP, 98 .end = NR_IRQS_LEGACY + AT91RM9200_ID_UDP,
99 .flags = IORESOURCE_IRQ, 99 .flags = IORESOURCE_IRQ,
100 }, 100 },
101}; 101};
@@ -145,8 +145,8 @@ static struct resource eth_resources[] = {
145 .flags = IORESOURCE_MEM, 145 .flags = IORESOURCE_MEM,
146 }, 146 },
147 [1] = { 147 [1] = {
148 .start = AT91RM9200_ID_EMAC, 148 .start = NR_IRQS_LEGACY + AT91RM9200_ID_EMAC,
149 .end = AT91RM9200_ID_EMAC, 149 .end = NR_IRQS_LEGACY + AT91RM9200_ID_EMAC,
150 .flags = IORESOURCE_IRQ, 150 .flags = IORESOURCE_IRQ,
151 }, 151 },
152}; 152};
@@ -305,8 +305,8 @@ static struct resource mmc_resources[] = {
305 .flags = IORESOURCE_MEM, 305 .flags = IORESOURCE_MEM,
306 }, 306 },
307 [1] = { 307 [1] = {
308 .start = AT91RM9200_ID_MCI, 308 .start = NR_IRQS_LEGACY + AT91RM9200_ID_MCI,
309 .end = AT91RM9200_ID_MCI, 309 .end = NR_IRQS_LEGACY + AT91RM9200_ID_MCI,
310 .flags = IORESOURCE_IRQ, 310 .flags = IORESOURCE_IRQ,
311 }, 311 },
312}; 312};
@@ -488,8 +488,8 @@ static struct resource twi_resources[] = {
488 .flags = IORESOURCE_MEM, 488 .flags = IORESOURCE_MEM,
489 }, 489 },
490 [1] = { 490 [1] = {
491 .start = AT91RM9200_ID_TWI, 491 .start = NR_IRQS_LEGACY + AT91RM9200_ID_TWI,
492 .end = AT91RM9200_ID_TWI, 492 .end = NR_IRQS_LEGACY + AT91RM9200_ID_TWI,
493 .flags = IORESOURCE_IRQ, 493 .flags = IORESOURCE_IRQ,
494 }, 494 },
495}; 495};
@@ -532,8 +532,8 @@ static struct resource spi_resources[] = {
532 .flags = IORESOURCE_MEM, 532 .flags = IORESOURCE_MEM,
533 }, 533 },
534 [1] = { 534 [1] = {
535 .start = AT91RM9200_ID_SPI, 535 .start = NR_IRQS_LEGACY + AT91RM9200_ID_SPI,
536 .end = AT91RM9200_ID_SPI, 536 .end = NR_IRQS_LEGACY + AT91RM9200_ID_SPI,
537 .flags = IORESOURCE_IRQ, 537 .flags = IORESOURCE_IRQ,
538 }, 538 },
539}; 539};
@@ -598,18 +598,18 @@ static struct resource tcb0_resources[] = {
598 .flags = IORESOURCE_MEM, 598 .flags = IORESOURCE_MEM,
599 }, 599 },
600 [1] = { 600 [1] = {
601 .start = AT91RM9200_ID_TC0, 601 .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC0,
602 .end = AT91RM9200_ID_TC0, 602 .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC0,
603 .flags = IORESOURCE_IRQ, 603 .flags = IORESOURCE_IRQ,
604 }, 604 },
605 [2] = { 605 [2] = {
606 .start = AT91RM9200_ID_TC1, 606 .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC1,
607 .end = AT91RM9200_ID_TC1, 607 .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC1,
608 .flags = IORESOURCE_IRQ, 608 .flags = IORESOURCE_IRQ,
609 }, 609 },
610 [3] = { 610 [3] = {
611 .start = AT91RM9200_ID_TC2, 611 .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC2,
612 .end = AT91RM9200_ID_TC2, 612 .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC2,
613 .flags = IORESOURCE_IRQ, 613 .flags = IORESOURCE_IRQ,
614 }, 614 },
615}; 615};
@@ -628,18 +628,18 @@ static struct resource tcb1_resources[] = {
628 .flags = IORESOURCE_MEM, 628 .flags = IORESOURCE_MEM,
629 }, 629 },
630 [1] = { 630 [1] = {
631 .start = AT91RM9200_ID_TC3, 631 .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC3,
632 .end = AT91RM9200_ID_TC3, 632 .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC3,
633 .flags = IORESOURCE_IRQ, 633 .flags = IORESOURCE_IRQ,
634 }, 634 },
635 [2] = { 635 [2] = {
636 .start = AT91RM9200_ID_TC4, 636 .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC4,
637 .end = AT91RM9200_ID_TC4, 637 .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC4,
638 .flags = IORESOURCE_IRQ, 638 .flags = IORESOURCE_IRQ,
639 }, 639 },
640 [3] = { 640 [3] = {
641 .start = AT91RM9200_ID_TC5, 641 .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC5,
642 .end = AT91RM9200_ID_TC5, 642 .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC5,
643 .flags = IORESOURCE_IRQ, 643 .flags = IORESOURCE_IRQ,
644 }, 644 },
645}; 645};
@@ -673,8 +673,8 @@ static struct resource rtc_resources[] = {
673 .flags = IORESOURCE_MEM, 673 .flags = IORESOURCE_MEM,
674 }, 674 },
675 [1] = { 675 [1] = {
676 .start = AT91_ID_SYS, 676 .start = NR_IRQS_LEGACY + AT91_ID_SYS,
677 .end = AT91_ID_SYS, 677 .end = NR_IRQS_LEGACY + AT91_ID_SYS,
678 .flags = IORESOURCE_IRQ, 678 .flags = IORESOURCE_IRQ,
679 }, 679 },
680}; 680};
@@ -729,8 +729,8 @@ static struct resource ssc0_resources[] = {
729 .flags = IORESOURCE_MEM, 729 .flags = IORESOURCE_MEM,
730 }, 730 },
731 [1] = { 731 [1] = {
732 .start = AT91RM9200_ID_SSC0, 732 .start = NR_IRQS_LEGACY + AT91RM9200_ID_SSC0,
733 .end = AT91RM9200_ID_SSC0, 733 .end = NR_IRQS_LEGACY + AT91RM9200_ID_SSC0,
734 .flags = IORESOURCE_IRQ, 734 .flags = IORESOURCE_IRQ,
735 }, 735 },
736}; 736};
@@ -771,8 +771,8 @@ static struct resource ssc1_resources[] = {
771 .flags = IORESOURCE_MEM, 771 .flags = IORESOURCE_MEM,
772 }, 772 },
773 [1] = { 773 [1] = {
774 .start = AT91RM9200_ID_SSC1, 774 .start = NR_IRQS_LEGACY + AT91RM9200_ID_SSC1,
775 .end = AT91RM9200_ID_SSC1, 775 .end = NR_IRQS_LEGACY + AT91RM9200_ID_SSC1,
776 .flags = IORESOURCE_IRQ, 776 .flags = IORESOURCE_IRQ,
777 }, 777 },
778}; 778};
@@ -813,8 +813,8 @@ static struct resource ssc2_resources[] = {
813 .flags = IORESOURCE_MEM, 813 .flags = IORESOURCE_MEM,
814 }, 814 },
815 [1] = { 815 [1] = {
816 .start = AT91RM9200_ID_SSC2, 816 .start = NR_IRQS_LEGACY + AT91RM9200_ID_SSC2,
817 .end = AT91RM9200_ID_SSC2, 817 .end = NR_IRQS_LEGACY + AT91RM9200_ID_SSC2,
818 .flags = IORESOURCE_IRQ, 818 .flags = IORESOURCE_IRQ,
819 }, 819 },
820}; 820};
@@ -897,8 +897,8 @@ static struct resource dbgu_resources[] = {
897 .flags = IORESOURCE_MEM, 897 .flags = IORESOURCE_MEM,
898 }, 898 },
899 [1] = { 899 [1] = {
900 .start = AT91_ID_SYS, 900 .start = NR_IRQS_LEGACY + AT91_ID_SYS,
901 .end = AT91_ID_SYS, 901 .end = NR_IRQS_LEGACY + AT91_ID_SYS,
902 .flags = IORESOURCE_IRQ, 902 .flags = IORESOURCE_IRQ,
903 }, 903 },
904}; 904};
@@ -935,8 +935,8 @@ static struct resource uart0_resources[] = {
935 .flags = IORESOURCE_MEM, 935 .flags = IORESOURCE_MEM,
936 }, 936 },
937 [1] = { 937 [1] = {
938 .start = AT91RM9200_ID_US0, 938 .start = NR_IRQS_LEGACY + AT91RM9200_ID_US0,
939 .end = AT91RM9200_ID_US0, 939 .end = NR_IRQS_LEGACY + AT91RM9200_ID_US0,
940 .flags = IORESOURCE_IRQ, 940 .flags = IORESOURCE_IRQ,
941 }, 941 },
942}; 942};
@@ -984,8 +984,8 @@ static struct resource uart1_resources[] = {
984 .flags = IORESOURCE_MEM, 984 .flags = IORESOURCE_MEM,
985 }, 985 },
986 [1] = { 986 [1] = {
987 .start = AT91RM9200_ID_US1, 987 .start = NR_IRQS_LEGACY + AT91RM9200_ID_US1,
988 .end = AT91RM9200_ID_US1, 988 .end = NR_IRQS_LEGACY + AT91RM9200_ID_US1,
989 .flags = IORESOURCE_IRQ, 989 .flags = IORESOURCE_IRQ,
990 }, 990 },
991}; 991};
@@ -1035,8 +1035,8 @@ static struct resource uart2_resources[] = {
1035 .flags = IORESOURCE_MEM, 1035 .flags = IORESOURCE_MEM,
1036 }, 1036 },
1037 [1] = { 1037 [1] = {
1038 .start = AT91RM9200_ID_US2, 1038 .start = NR_IRQS_LEGACY + AT91RM9200_ID_US2,
1039 .end = AT91RM9200_ID_US2, 1039 .end = NR_IRQS_LEGACY + AT91RM9200_ID_US2,
1040 .flags = IORESOURCE_IRQ, 1040 .flags = IORESOURCE_IRQ,
1041 }, 1041 },
1042}; 1042};
@@ -1078,8 +1078,8 @@ static struct resource uart3_resources[] = {
1078 .flags = IORESOURCE_MEM, 1078 .flags = IORESOURCE_MEM,
1079 }, 1079 },
1080 [1] = { 1080 [1] = {
1081 .start = AT91RM9200_ID_US3, 1081 .start = NR_IRQS_LEGACY + AT91RM9200_ID_US3,
1082 .end = AT91RM9200_ID_US3, 1082 .end = NR_IRQS_LEGACY + AT91RM9200_ID_US3,
1083 .flags = IORESOURCE_IRQ, 1083 .flags = IORESOURCE_IRQ,
1084 }, 1084 },
1085}; 1085};
diff --git a/arch/arm/mach-at91/at91rm9200_time.c b/arch/arm/mach-at91/at91rm9200_time.c
index 104ca40d8d1..aaa443b48c9 100644
--- a/arch/arm/mach-at91/at91rm9200_time.c
+++ b/arch/arm/mach-at91/at91rm9200_time.c
@@ -197,7 +197,7 @@ void __init at91rm9200_timer_init(void)
197 at91_st_read(AT91_ST_SR); 197 at91_st_read(AT91_ST_SR);
198 198
199 /* Make IRQs happen for the system timer */ 199 /* Make IRQs happen for the system timer */
200 setup_irq(AT91_ID_SYS, &at91rm9200_timer_irq); 200 setup_irq(NR_IRQS_LEGACY + AT91_ID_SYS, &at91rm9200_timer_irq);
201 201
202 /* The 32KiHz "Slow Clock" (tick every 30517.58 nanoseconds) is used 202 /* The 32KiHz "Slow Clock" (tick every 30517.58 nanoseconds) is used
203 * directly for the clocksource and all clockevents, after adjusting 203 * directly for the clocksource and all clockevents, after adjusting
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 2b1e438ed87..30c7f26a466 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -20,6 +20,7 @@
20#include <mach/cpu.h> 20#include <mach/cpu.h>
21#include <mach/at91_dbgu.h> 21#include <mach/at91_dbgu.h>
22#include <mach/at91sam9260.h> 22#include <mach/at91sam9260.h>
23#include <mach/at91_aic.h>
23#include <mach/at91_pmc.h> 24#include <mach/at91_pmc.h>
24#include <mach/at91_rstc.h> 25#include <mach/at91_rstc.h>
25 26
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index 0ded951f785..bce572a530e 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -45,8 +45,8 @@ static struct resource usbh_resources[] = {
45 .flags = IORESOURCE_MEM, 45 .flags = IORESOURCE_MEM,
46 }, 46 },
47 [1] = { 47 [1] = {
48 .start = AT91SAM9260_ID_UHP, 48 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_UHP,
49 .end = AT91SAM9260_ID_UHP, 49 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_UHP,
50 .flags = IORESOURCE_IRQ, 50 .flags = IORESOURCE_IRQ,
51 }, 51 },
52}; 52};
@@ -98,8 +98,8 @@ static struct resource udc_resources[] = {
98 .flags = IORESOURCE_MEM, 98 .flags = IORESOURCE_MEM,
99 }, 99 },
100 [1] = { 100 [1] = {
101 .start = AT91SAM9260_ID_UDP, 101 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_UDP,
102 .end = AT91SAM9260_ID_UDP, 102 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_UDP,
103 .flags = IORESOURCE_IRQ, 103 .flags = IORESOURCE_IRQ,
104 }, 104 },
105}; 105};
@@ -149,8 +149,8 @@ static struct resource eth_resources[] = {
149 .flags = IORESOURCE_MEM, 149 .flags = IORESOURCE_MEM,
150 }, 150 },
151 [1] = { 151 [1] = {
152 .start = AT91SAM9260_ID_EMAC, 152 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_EMAC,
153 .end = AT91SAM9260_ID_EMAC, 153 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_EMAC,
154 .flags = IORESOURCE_IRQ, 154 .flags = IORESOURCE_IRQ,
155 }, 155 },
156}; 156};
@@ -223,8 +223,8 @@ static struct resource mmc_resources[] = {
223 .flags = IORESOURCE_MEM, 223 .flags = IORESOURCE_MEM,
224 }, 224 },
225 [1] = { 225 [1] = {
226 .start = AT91SAM9260_ID_MCI, 226 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_MCI,
227 .end = AT91SAM9260_ID_MCI, 227 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_MCI,
228 .flags = IORESOURCE_IRQ, 228 .flags = IORESOURCE_IRQ,
229 }, 229 },
230}; 230};
@@ -305,8 +305,8 @@ static struct resource mmc_resources[] = {
305 .flags = IORESOURCE_MEM, 305 .flags = IORESOURCE_MEM,
306 }, 306 },
307 [1] = { 307 [1] = {
308 .start = AT91SAM9260_ID_MCI, 308 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_MCI,
309 .end = AT91SAM9260_ID_MCI, 309 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_MCI,
310 .flags = IORESOURCE_IRQ, 310 .flags = IORESOURCE_IRQ,
311 }, 311 },
312}; 312};
@@ -496,8 +496,8 @@ static struct resource twi_resources[] = {
496 .flags = IORESOURCE_MEM, 496 .flags = IORESOURCE_MEM,
497 }, 497 },
498 [1] = { 498 [1] = {
499 .start = AT91SAM9260_ID_TWI, 499 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_TWI,
500 .end = AT91SAM9260_ID_TWI, 500 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_TWI,
501 .flags = IORESOURCE_IRQ, 501 .flags = IORESOURCE_IRQ,
502 }, 502 },
503}; 503};
@@ -540,8 +540,8 @@ static struct resource spi0_resources[] = {
540 .flags = IORESOURCE_MEM, 540 .flags = IORESOURCE_MEM,
541 }, 541 },
542 [1] = { 542 [1] = {
543 .start = AT91SAM9260_ID_SPI0, 543 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_SPI0,
544 .end = AT91SAM9260_ID_SPI0, 544 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_SPI0,
545 .flags = IORESOURCE_IRQ, 545 .flags = IORESOURCE_IRQ,
546 }, 546 },
547}; 547};
@@ -566,8 +566,8 @@ static struct resource spi1_resources[] = {
566 .flags = IORESOURCE_MEM, 566 .flags = IORESOURCE_MEM,
567 }, 567 },
568 [1] = { 568 [1] = {
569 .start = AT91SAM9260_ID_SPI1, 569 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_SPI1,
570 .end = AT91SAM9260_ID_SPI1, 570 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_SPI1,
571 .flags = IORESOURCE_IRQ, 571 .flags = IORESOURCE_IRQ,
572 }, 572 },
573}; 573};
@@ -652,18 +652,18 @@ static struct resource tcb0_resources[] = {
652 .flags = IORESOURCE_MEM, 652 .flags = IORESOURCE_MEM,
653 }, 653 },
654 [1] = { 654 [1] = {
655 .start = AT91SAM9260_ID_TC0, 655 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_TC0,
656 .end = AT91SAM9260_ID_TC0, 656 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_TC0,
657 .flags = IORESOURCE_IRQ, 657 .flags = IORESOURCE_IRQ,
658 }, 658 },
659 [2] = { 659 [2] = {
660 .start = AT91SAM9260_ID_TC1, 660 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_TC1,
661 .end = AT91SAM9260_ID_TC1, 661 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_TC1,
662 .flags = IORESOURCE_IRQ, 662 .flags = IORESOURCE_IRQ,
663 }, 663 },
664 [3] = { 664 [3] = {
665 .start = AT91SAM9260_ID_TC2, 665 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_TC2,
666 .end = AT91SAM9260_ID_TC2, 666 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_TC2,
667 .flags = IORESOURCE_IRQ, 667 .flags = IORESOURCE_IRQ,
668 }, 668 },
669}; 669};
@@ -682,18 +682,18 @@ static struct resource tcb1_resources[] = {
682 .flags = IORESOURCE_MEM, 682 .flags = IORESOURCE_MEM,
683 }, 683 },
684 [1] = { 684 [1] = {
685 .start = AT91SAM9260_ID_TC3, 685 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_TC3,
686 .end = AT91SAM9260_ID_TC3, 686 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_TC3,
687 .flags = IORESOURCE_IRQ, 687 .flags = IORESOURCE_IRQ,
688 }, 688 },
689 [2] = { 689 [2] = {
690 .start = AT91SAM9260_ID_TC4, 690 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_TC4,
691 .end = AT91SAM9260_ID_TC4, 691 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_TC4,
692 .flags = IORESOURCE_IRQ, 692 .flags = IORESOURCE_IRQ,
693 }, 693 },
694 [3] = { 694 [3] = {
695 .start = AT91SAM9260_ID_TC5, 695 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_TC5,
696 .end = AT91SAM9260_ID_TC5, 696 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_TC5,
697 .flags = IORESOURCE_IRQ, 697 .flags = IORESOURCE_IRQ,
698 }, 698 },
699}; 699};
@@ -726,6 +726,8 @@ static struct resource rtt_resources[] = {
726 .flags = IORESOURCE_MEM, 726 .flags = IORESOURCE_MEM,
727 }, { 727 }, {
728 .flags = IORESOURCE_MEM, 728 .flags = IORESOURCE_MEM,
729 }, {
730 .flags = IORESOURCE_IRQ,
729 }, 731 },
730}; 732};
731 733
@@ -744,10 +746,12 @@ static void __init at91_add_device_rtt_rtc(void)
744 * The second resource is needed: 746 * The second resource is needed:
745 * GPBR will serve as the storage for RTC time offset 747 * GPBR will serve as the storage for RTC time offset
746 */ 748 */
747 at91sam9260_rtt_device.num_resources = 2; 749 at91sam9260_rtt_device.num_resources = 3;
748 rtt_resources[1].start = AT91SAM9260_BASE_GPBR + 750 rtt_resources[1].start = AT91SAM9260_BASE_GPBR +
749 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR; 751 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
750 rtt_resources[1].end = rtt_resources[1].start + 3; 752 rtt_resources[1].end = rtt_resources[1].start + 3;
753 rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS;
754 rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS;
751} 755}
752#else 756#else
753static void __init at91_add_device_rtt_rtc(void) 757static void __init at91_add_device_rtt_rtc(void)
@@ -807,8 +811,8 @@ static struct resource ssc_resources[] = {
807 .flags = IORESOURCE_MEM, 811 .flags = IORESOURCE_MEM,
808 }, 812 },
809 [1] = { 813 [1] = {
810 .start = AT91SAM9260_ID_SSC, 814 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_SSC,
811 .end = AT91SAM9260_ID_SSC, 815 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_SSC,
812 .flags = IORESOURCE_IRQ, 816 .flags = IORESOURCE_IRQ,
813 }, 817 },
814}; 818};
@@ -882,8 +886,8 @@ static struct resource dbgu_resources[] = {
882 .flags = IORESOURCE_MEM, 886 .flags = IORESOURCE_MEM,
883 }, 887 },
884 [1] = { 888 [1] = {
885 .start = AT91_ID_SYS, 889 .start = NR_IRQS_LEGACY + AT91_ID_SYS,
886 .end = AT91_ID_SYS, 890 .end = NR_IRQS_LEGACY + AT91_ID_SYS,
887 .flags = IORESOURCE_IRQ, 891 .flags = IORESOURCE_IRQ,
888 }, 892 },
889}; 893};
@@ -920,8 +924,8 @@ static struct resource uart0_resources[] = {
920 .flags = IORESOURCE_MEM, 924 .flags = IORESOURCE_MEM,
921 }, 925 },
922 [1] = { 926 [1] = {
923 .start = AT91SAM9260_ID_US0, 927 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_US0,
924 .end = AT91SAM9260_ID_US0, 928 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_US0,
925 .flags = IORESOURCE_IRQ, 929 .flags = IORESOURCE_IRQ,
926 }, 930 },
927}; 931};
@@ -971,8 +975,8 @@ static struct resource uart1_resources[] = {
971 .flags = IORESOURCE_MEM, 975 .flags = IORESOURCE_MEM,
972 }, 976 },
973 [1] = { 977 [1] = {
974 .start = AT91SAM9260_ID_US1, 978 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_US1,
975 .end = AT91SAM9260_ID_US1, 979 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_US1,
976 .flags = IORESOURCE_IRQ, 980 .flags = IORESOURCE_IRQ,
977 }, 981 },
978}; 982};
@@ -1014,8 +1018,8 @@ static struct resource uart2_resources[] = {
1014 .flags = IORESOURCE_MEM, 1018 .flags = IORESOURCE_MEM,
1015 }, 1019 },
1016 [1] = { 1020 [1] = {
1017 .start = AT91SAM9260_ID_US2, 1021 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_US2,
1018 .end = AT91SAM9260_ID_US2, 1022 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_US2,
1019 .flags = IORESOURCE_IRQ, 1023 .flags = IORESOURCE_IRQ,
1020 }, 1024 },
1021}; 1025};
@@ -1057,8 +1061,8 @@ static struct resource uart3_resources[] = {
1057 .flags = IORESOURCE_MEM, 1061 .flags = IORESOURCE_MEM,
1058 }, 1062 },
1059 [1] = { 1063 [1] = {
1060 .start = AT91SAM9260_ID_US3, 1064 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_US3,
1061 .end = AT91SAM9260_ID_US3, 1065 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_US3,
1062 .flags = IORESOURCE_IRQ, 1066 .flags = IORESOURCE_IRQ,
1063 }, 1067 },
1064}; 1068};
@@ -1100,8 +1104,8 @@ static struct resource uart4_resources[] = {
1100 .flags = IORESOURCE_MEM, 1104 .flags = IORESOURCE_MEM,
1101 }, 1105 },
1102 [1] = { 1106 [1] = {
1103 .start = AT91SAM9260_ID_US4, 1107 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_US4,
1104 .end = AT91SAM9260_ID_US4, 1108 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_US4,
1105 .flags = IORESOURCE_IRQ, 1109 .flags = IORESOURCE_IRQ,
1106 }, 1110 },
1107}; 1111};
@@ -1138,8 +1142,8 @@ static struct resource uart5_resources[] = {
1138 .flags = IORESOURCE_MEM, 1142 .flags = IORESOURCE_MEM,
1139 }, 1143 },
1140 [1] = { 1144 [1] = {
1141 .start = AT91SAM9260_ID_US5, 1145 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_US5,
1142 .end = AT91SAM9260_ID_US5, 1146 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_US5,
1143 .flags = IORESOURCE_IRQ, 1147 .flags = IORESOURCE_IRQ,
1144 }, 1148 },
1145}; 1149};
@@ -1357,8 +1361,8 @@ static struct resource adc_resources[] = {
1357 .flags = IORESOURCE_MEM, 1361 .flags = IORESOURCE_MEM,
1358 }, 1362 },
1359 [1] = { 1363 [1] = {
1360 .start = AT91SAM9260_ID_ADC, 1364 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_ADC,
1361 .end = AT91SAM9260_ID_ADC, 1365 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_ADC,
1362 .flags = IORESOURCE_IRQ, 1366 .flags = IORESOURCE_IRQ,
1363 }, 1367 },
1364}; 1368};
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index c77d503d09d..f40762c5fed 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -19,6 +19,7 @@
19#include <asm/system_misc.h> 19#include <asm/system_misc.h>
20#include <mach/cpu.h> 20#include <mach/cpu.h>
21#include <mach/at91sam9261.h> 21#include <mach/at91sam9261.h>
22#include <mach/at91_aic.h>
22#include <mach/at91_pmc.h> 23#include <mach/at91_pmc.h>
23#include <mach/at91_rstc.h> 24#include <mach/at91_rstc.h>
24 25
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index 9295e90b08f..bc2590d712d 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -45,8 +45,8 @@ static struct resource usbh_resources[] = {
45 .flags = IORESOURCE_MEM, 45 .flags = IORESOURCE_MEM,
46 }, 46 },
47 [1] = { 47 [1] = {
48 .start = AT91SAM9261_ID_UHP, 48 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_UHP,
49 .end = AT91SAM9261_ID_UHP, 49 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_UHP,
50 .flags = IORESOURCE_IRQ, 50 .flags = IORESOURCE_IRQ,
51 }, 51 },
52}; 52};
@@ -98,8 +98,8 @@ static struct resource udc_resources[] = {
98 .flags = IORESOURCE_MEM, 98 .flags = IORESOURCE_MEM,
99 }, 99 },
100 [1] = { 100 [1] = {
101 .start = AT91SAM9261_ID_UDP, 101 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_UDP,
102 .end = AT91SAM9261_ID_UDP, 102 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_UDP,
103 .flags = IORESOURCE_IRQ, 103 .flags = IORESOURCE_IRQ,
104 }, 104 },
105}; 105};
@@ -148,8 +148,8 @@ static struct resource mmc_resources[] = {
148 .flags = IORESOURCE_MEM, 148 .flags = IORESOURCE_MEM,
149 }, 149 },
150 [1] = { 150 [1] = {
151 .start = AT91SAM9261_ID_MCI, 151 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_MCI,
152 .end = AT91SAM9261_ID_MCI, 152 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_MCI,
153 .flags = IORESOURCE_IRQ, 153 .flags = IORESOURCE_IRQ,
154 }, 154 },
155}; 155};
@@ -310,8 +310,8 @@ static struct resource twi_resources[] = {
310 .flags = IORESOURCE_MEM, 310 .flags = IORESOURCE_MEM,
311 }, 311 },
312 [1] = { 312 [1] = {
313 .start = AT91SAM9261_ID_TWI, 313 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_TWI,
314 .end = AT91SAM9261_ID_TWI, 314 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_TWI,
315 .flags = IORESOURCE_IRQ, 315 .flags = IORESOURCE_IRQ,
316 }, 316 },
317}; 317};
@@ -354,8 +354,8 @@ static struct resource spi0_resources[] = {
354 .flags = IORESOURCE_MEM, 354 .flags = IORESOURCE_MEM,
355 }, 355 },
356 [1] = { 356 [1] = {
357 .start = AT91SAM9261_ID_SPI0, 357 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_SPI0,
358 .end = AT91SAM9261_ID_SPI0, 358 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_SPI0,
359 .flags = IORESOURCE_IRQ, 359 .flags = IORESOURCE_IRQ,
360 }, 360 },
361}; 361};
@@ -380,8 +380,8 @@ static struct resource spi1_resources[] = {
380 .flags = IORESOURCE_MEM, 380 .flags = IORESOURCE_MEM,
381 }, 381 },
382 [1] = { 382 [1] = {
383 .start = AT91SAM9261_ID_SPI1, 383 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_SPI1,
384 .end = AT91SAM9261_ID_SPI1, 384 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_SPI1,
385 .flags = IORESOURCE_IRQ, 385 .flags = IORESOURCE_IRQ,
386 }, 386 },
387}; 387};
@@ -468,8 +468,8 @@ static struct resource lcdc_resources[] = {
468 .flags = IORESOURCE_MEM, 468 .flags = IORESOURCE_MEM,
469 }, 469 },
470 [1] = { 470 [1] = {
471 .start = AT91SAM9261_ID_LCDC, 471 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_LCDC,
472 .end = AT91SAM9261_ID_LCDC, 472 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_LCDC,
473 .flags = IORESOURCE_IRQ, 473 .flags = IORESOURCE_IRQ,
474 }, 474 },
475#if defined(CONFIG_FB_INTSRAM) 475#if defined(CONFIG_FB_INTSRAM)
@@ -566,18 +566,18 @@ static struct resource tcb_resources[] = {
566 .flags = IORESOURCE_MEM, 566 .flags = IORESOURCE_MEM,
567 }, 567 },
568 [1] = { 568 [1] = {
569 .start = AT91SAM9261_ID_TC0, 569 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_TC0,
570 .end = AT91SAM9261_ID_TC0, 570 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_TC0,
571 .flags = IORESOURCE_IRQ, 571 .flags = IORESOURCE_IRQ,
572 }, 572 },
573 [2] = { 573 [2] = {
574 .start = AT91SAM9261_ID_TC1, 574 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_TC1,
575 .end = AT91SAM9261_ID_TC1, 575 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_TC1,
576 .flags = IORESOURCE_IRQ, 576 .flags = IORESOURCE_IRQ,
577 }, 577 },
578 [3] = { 578 [3] = {
579 .start = AT91SAM9261_ID_TC2, 579 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_TC2,
580 .end = AT91SAM9261_ID_TC2, 580 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_TC2,
581 .flags = IORESOURCE_IRQ, 581 .flags = IORESOURCE_IRQ,
582 }, 582 },
583}; 583};
@@ -609,6 +609,8 @@ static struct resource rtt_resources[] = {
609 .flags = IORESOURCE_MEM, 609 .flags = IORESOURCE_MEM,
610 }, { 610 }, {
611 .flags = IORESOURCE_MEM, 611 .flags = IORESOURCE_MEM,
612 }, {
613 .flags = IORESOURCE_IRQ,
612 } 614 }
613}; 615};
614 616
@@ -626,10 +628,12 @@ static void __init at91_add_device_rtt_rtc(void)
626 * The second resource is needed: 628 * The second resource is needed:
627 * GPBR will serve as the storage for RTC time offset 629 * GPBR will serve as the storage for RTC time offset
628 */ 630 */
629 at91sam9261_rtt_device.num_resources = 2; 631 at91sam9261_rtt_device.num_resources = 3;
630 rtt_resources[1].start = AT91SAM9261_BASE_GPBR + 632 rtt_resources[1].start = AT91SAM9261_BASE_GPBR +
631 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR; 633 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
632 rtt_resources[1].end = rtt_resources[1].start + 3; 634 rtt_resources[1].end = rtt_resources[1].start + 3;
635 rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS;
636 rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS;
633} 637}
634#else 638#else
635static void __init at91_add_device_rtt_rtc(void) 639static void __init at91_add_device_rtt_rtc(void)
@@ -689,8 +693,8 @@ static struct resource ssc0_resources[] = {
689 .flags = IORESOURCE_MEM, 693 .flags = IORESOURCE_MEM,
690 }, 694 },
691 [1] = { 695 [1] = {
692 .start = AT91SAM9261_ID_SSC0, 696 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC0,
693 .end = AT91SAM9261_ID_SSC0, 697 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC0,
694 .flags = IORESOURCE_IRQ, 698 .flags = IORESOURCE_IRQ,
695 }, 699 },
696}; 700};
@@ -731,8 +735,8 @@ static struct resource ssc1_resources[] = {
731 .flags = IORESOURCE_MEM, 735 .flags = IORESOURCE_MEM,
732 }, 736 },
733 [1] = { 737 [1] = {
734 .start = AT91SAM9261_ID_SSC1, 738 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC1,
735 .end = AT91SAM9261_ID_SSC1, 739 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC1,
736 .flags = IORESOURCE_IRQ, 740 .flags = IORESOURCE_IRQ,
737 }, 741 },
738}; 742};
@@ -773,8 +777,8 @@ static struct resource ssc2_resources[] = {
773 .flags = IORESOURCE_MEM, 777 .flags = IORESOURCE_MEM,
774 }, 778 },
775 [1] = { 779 [1] = {
776 .start = AT91SAM9261_ID_SSC2, 780 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC2,
777 .end = AT91SAM9261_ID_SSC2, 781 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC2,
778 .flags = IORESOURCE_IRQ, 782 .flags = IORESOURCE_IRQ,
779 }, 783 },
780}; 784};
@@ -857,8 +861,8 @@ static struct resource dbgu_resources[] = {
857 .flags = IORESOURCE_MEM, 861 .flags = IORESOURCE_MEM,
858 }, 862 },
859 [1] = { 863 [1] = {
860 .start = AT91_ID_SYS, 864 .start = NR_IRQS_LEGACY + AT91_ID_SYS,
861 .end = AT91_ID_SYS, 865 .end = NR_IRQS_LEGACY + AT91_ID_SYS,
862 .flags = IORESOURCE_IRQ, 866 .flags = IORESOURCE_IRQ,
863 }, 867 },
864}; 868};
@@ -895,8 +899,8 @@ static struct resource uart0_resources[] = {
895 .flags = IORESOURCE_MEM, 899 .flags = IORESOURCE_MEM,
896 }, 900 },
897 [1] = { 901 [1] = {
898 .start = AT91SAM9261_ID_US0, 902 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_US0,
899 .end = AT91SAM9261_ID_US0, 903 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_US0,
900 .flags = IORESOURCE_IRQ, 904 .flags = IORESOURCE_IRQ,
901 }, 905 },
902}; 906};
@@ -938,8 +942,8 @@ static struct resource uart1_resources[] = {
938 .flags = IORESOURCE_MEM, 942 .flags = IORESOURCE_MEM,
939 }, 943 },
940 [1] = { 944 [1] = {
941 .start = AT91SAM9261_ID_US1, 945 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_US1,
942 .end = AT91SAM9261_ID_US1, 946 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_US1,
943 .flags = IORESOURCE_IRQ, 947 .flags = IORESOURCE_IRQ,
944 }, 948 },
945}; 949};
@@ -981,8 +985,8 @@ static struct resource uart2_resources[] = {
981 .flags = IORESOURCE_MEM, 985 .flags = IORESOURCE_MEM,
982 }, 986 },
983 [1] = { 987 [1] = {
984 .start = AT91SAM9261_ID_US2, 988 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_US2,
985 .end = AT91SAM9261_ID_US2, 989 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_US2,
986 .flags = IORESOURCE_IRQ, 990 .flags = IORESOURCE_IRQ,
987 }, 991 },
988}; 992};
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index ed91c7e9f7c..84b38105231 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -18,6 +18,7 @@
18#include <asm/mach/map.h> 18#include <asm/mach/map.h>
19#include <asm/system_misc.h> 19#include <asm/system_misc.h>
20#include <mach/at91sam9263.h> 20#include <mach/at91sam9263.h>
21#include <mach/at91_aic.h>
21#include <mach/at91_pmc.h> 22#include <mach/at91_pmc.h>
22#include <mach/at91_rstc.h> 23#include <mach/at91_rstc.h>
23 24
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index 175e0009eaa..9b6ca734f1a 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -44,8 +44,8 @@ static struct resource usbh_resources[] = {
44 .flags = IORESOURCE_MEM, 44 .flags = IORESOURCE_MEM,
45 }, 45 },
46 [1] = { 46 [1] = {
47 .start = AT91SAM9263_ID_UHP, 47 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_UHP,
48 .end = AT91SAM9263_ID_UHP, 48 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_UHP,
49 .flags = IORESOURCE_IRQ, 49 .flags = IORESOURCE_IRQ,
50 }, 50 },
51}; 51};
@@ -104,8 +104,8 @@ static struct resource udc_resources[] = {
104 .flags = IORESOURCE_MEM, 104 .flags = IORESOURCE_MEM,
105 }, 105 },
106 [1] = { 106 [1] = {
107 .start = AT91SAM9263_ID_UDP, 107 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_UDP,
108 .end = AT91SAM9263_ID_UDP, 108 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_UDP,
109 .flags = IORESOURCE_IRQ, 109 .flags = IORESOURCE_IRQ,
110 }, 110 },
111}; 111};
@@ -155,8 +155,8 @@ static struct resource eth_resources[] = {
155 .flags = IORESOURCE_MEM, 155 .flags = IORESOURCE_MEM,
156 }, 156 },
157 [1] = { 157 [1] = {
158 .start = AT91SAM9263_ID_EMAC, 158 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_EMAC,
159 .end = AT91SAM9263_ID_EMAC, 159 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_EMAC,
160 .flags = IORESOURCE_IRQ, 160 .flags = IORESOURCE_IRQ,
161 }, 161 },
162}; 162};
@@ -229,8 +229,8 @@ static struct resource mmc0_resources[] = {
229 .flags = IORESOURCE_MEM, 229 .flags = IORESOURCE_MEM,
230 }, 230 },
231 [1] = { 231 [1] = {
232 .start = AT91SAM9263_ID_MCI0, 232 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_MCI0,
233 .end = AT91SAM9263_ID_MCI0, 233 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_MCI0,
234 .flags = IORESOURCE_IRQ, 234 .flags = IORESOURCE_IRQ,
235 }, 235 },
236}; 236};
@@ -254,8 +254,8 @@ static struct resource mmc1_resources[] = {
254 .flags = IORESOURCE_MEM, 254 .flags = IORESOURCE_MEM,
255 }, 255 },
256 [1] = { 256 [1] = {
257 .start = AT91SAM9263_ID_MCI1, 257 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_MCI1,
258 .end = AT91SAM9263_ID_MCI1, 258 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_MCI1,
259 .flags = IORESOURCE_IRQ, 259 .flags = IORESOURCE_IRQ,
260 }, 260 },
261}; 261};
@@ -567,8 +567,8 @@ static struct resource twi_resources[] = {
567 .flags = IORESOURCE_MEM, 567 .flags = IORESOURCE_MEM,
568 }, 568 },
569 [1] = { 569 [1] = {
570 .start = AT91SAM9263_ID_TWI, 570 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_TWI,
571 .end = AT91SAM9263_ID_TWI, 571 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_TWI,
572 .flags = IORESOURCE_IRQ, 572 .flags = IORESOURCE_IRQ,
573 }, 573 },
574}; 574};
@@ -611,8 +611,8 @@ static struct resource spi0_resources[] = {
611 .flags = IORESOURCE_MEM, 611 .flags = IORESOURCE_MEM,
612 }, 612 },
613 [1] = { 613 [1] = {
614 .start = AT91SAM9263_ID_SPI0, 614 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_SPI0,
615 .end = AT91SAM9263_ID_SPI0, 615 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_SPI0,
616 .flags = IORESOURCE_IRQ, 616 .flags = IORESOURCE_IRQ,
617 }, 617 },
618}; 618};
@@ -637,8 +637,8 @@ static struct resource spi1_resources[] = {
637 .flags = IORESOURCE_MEM, 637 .flags = IORESOURCE_MEM,
638 }, 638 },
639 [1] = { 639 [1] = {
640 .start = AT91SAM9263_ID_SPI1, 640 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_SPI1,
641 .end = AT91SAM9263_ID_SPI1, 641 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_SPI1,
642 .flags = IORESOURCE_IRQ, 642 .flags = IORESOURCE_IRQ,
643 }, 643 },
644}; 644};
@@ -725,8 +725,8 @@ static struct resource ac97_resources[] = {
725 .flags = IORESOURCE_MEM, 725 .flags = IORESOURCE_MEM,
726 }, 726 },
727 [1] = { 727 [1] = {
728 .start = AT91SAM9263_ID_AC97C, 728 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_AC97C,
729 .end = AT91SAM9263_ID_AC97C, 729 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_AC97C,
730 .flags = IORESOURCE_IRQ, 730 .flags = IORESOURCE_IRQ,
731 }, 731 },
732}; 732};
@@ -776,8 +776,8 @@ static struct resource can_resources[] = {
776 .flags = IORESOURCE_MEM, 776 .flags = IORESOURCE_MEM,
777 }, 777 },
778 [1] = { 778 [1] = {
779 .start = AT91SAM9263_ID_CAN, 779 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_CAN,
780 .end = AT91SAM9263_ID_CAN, 780 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_CAN,
781 .flags = IORESOURCE_IRQ, 781 .flags = IORESOURCE_IRQ,
782 }, 782 },
783}; 783};
@@ -816,8 +816,8 @@ static struct resource lcdc_resources[] = {
816 .flags = IORESOURCE_MEM, 816 .flags = IORESOURCE_MEM,
817 }, 817 },
818 [1] = { 818 [1] = {
819 .start = AT91SAM9263_ID_LCDC, 819 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_LCDC,
820 .end = AT91SAM9263_ID_LCDC, 820 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_LCDC,
821 .flags = IORESOURCE_IRQ, 821 .flags = IORESOURCE_IRQ,
822 }, 822 },
823}; 823};
@@ -883,8 +883,8 @@ struct resource isi_resources[] = {
883 .flags = IORESOURCE_MEM, 883 .flags = IORESOURCE_MEM,
884 }, 884 },
885 [1] = { 885 [1] = {
886 .start = AT91SAM9263_ID_ISI, 886 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_ISI,
887 .end = AT91SAM9263_ID_ISI, 887 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_ISI,
888 .flags = IORESOURCE_IRQ, 888 .flags = IORESOURCE_IRQ,
889 }, 889 },
890}; 890};
@@ -940,8 +940,8 @@ static struct resource tcb_resources[] = {
940 .flags = IORESOURCE_MEM, 940 .flags = IORESOURCE_MEM,
941 }, 941 },
942 [1] = { 942 [1] = {
943 .start = AT91SAM9263_ID_TCB, 943 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_TCB,
944 .end = AT91SAM9263_ID_TCB, 944 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_TCB,
945 .flags = IORESOURCE_IRQ, 945 .flags = IORESOURCE_IRQ,
946 }, 946 },
947}; 947};
@@ -990,6 +990,8 @@ static struct resource rtt0_resources[] = {
990 .flags = IORESOURCE_MEM, 990 .flags = IORESOURCE_MEM,
991 }, { 991 }, {
992 .flags = IORESOURCE_MEM, 992 .flags = IORESOURCE_MEM,
993 }, {
994 .flags = IORESOURCE_IRQ,
993 } 995 }
994}; 996};
995 997
@@ -1006,6 +1008,8 @@ static struct resource rtt1_resources[] = {
1006 .flags = IORESOURCE_MEM, 1008 .flags = IORESOURCE_MEM,
1007 }, { 1009 }, {
1008 .flags = IORESOURCE_MEM, 1010 .flags = IORESOURCE_MEM,
1011 }, {
1012 .flags = IORESOURCE_IRQ,
1009 } 1013 }
1010}; 1014};
1011 1015
@@ -1027,14 +1031,14 @@ static void __init at91_add_device_rtt_rtc(void)
1027 * The second resource is needed only for the chosen RTT: 1031 * The second resource is needed only for the chosen RTT:
1028 * GPBR will serve as the storage for RTC time offset 1032 * GPBR will serve as the storage for RTC time offset
1029 */ 1033 */
1030 at91sam9263_rtt0_device.num_resources = 2; 1034 at91sam9263_rtt0_device.num_resources = 3;
1031 at91sam9263_rtt1_device.num_resources = 1; 1035 at91sam9263_rtt1_device.num_resources = 1;
1032 pdev = &at91sam9263_rtt0_device; 1036 pdev = &at91sam9263_rtt0_device;
1033 r = rtt0_resources; 1037 r = rtt0_resources;
1034 break; 1038 break;
1035 case 1: 1039 case 1:
1036 at91sam9263_rtt0_device.num_resources = 1; 1040 at91sam9263_rtt0_device.num_resources = 1;
1037 at91sam9263_rtt1_device.num_resources = 2; 1041 at91sam9263_rtt1_device.num_resources = 3;
1038 pdev = &at91sam9263_rtt1_device; 1042 pdev = &at91sam9263_rtt1_device;
1039 r = rtt1_resources; 1043 r = rtt1_resources;
1040 break; 1044 break;
@@ -1047,6 +1051,8 @@ static void __init at91_add_device_rtt_rtc(void)
1047 pdev->name = "rtc-at91sam9"; 1051 pdev->name = "rtc-at91sam9";
1048 r[1].start = AT91SAM9263_BASE_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR; 1052 r[1].start = AT91SAM9263_BASE_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
1049 r[1].end = r[1].start + 3; 1053 r[1].end = r[1].start + 3;
1054 r[2].start = NR_IRQS_LEGACY + AT91_ID_SYS;
1055 r[2].end = NR_IRQS_LEGACY + AT91_ID_SYS;
1050} 1056}
1051#else 1057#else
1052static void __init at91_add_device_rtt_rtc(void) 1058static void __init at91_add_device_rtt_rtc(void)
@@ -1108,8 +1114,8 @@ static struct resource pwm_resources[] = {
1108 .flags = IORESOURCE_MEM, 1114 .flags = IORESOURCE_MEM,
1109 }, 1115 },
1110 [1] = { 1116 [1] = {
1111 .start = AT91SAM9263_ID_PWMC, 1117 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_PWMC,
1112 .end = AT91SAM9263_ID_PWMC, 1118 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_PWMC,
1113 .flags = IORESOURCE_IRQ, 1119 .flags = IORESOURCE_IRQ,
1114 }, 1120 },
1115}; 1121};
@@ -1161,8 +1167,8 @@ static struct resource ssc0_resources[] = {
1161 .flags = IORESOURCE_MEM, 1167 .flags = IORESOURCE_MEM,
1162 }, 1168 },
1163 [1] = { 1169 [1] = {
1164 .start = AT91SAM9263_ID_SSC0, 1170 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_SSC0,
1165 .end = AT91SAM9263_ID_SSC0, 1171 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_SSC0,
1166 .flags = IORESOURCE_IRQ, 1172 .flags = IORESOURCE_IRQ,
1167 }, 1173 },
1168}; 1174};
@@ -1203,8 +1209,8 @@ static struct resource ssc1_resources[] = {
1203 .flags = IORESOURCE_MEM, 1209 .flags = IORESOURCE_MEM,
1204 }, 1210 },
1205 [1] = { 1211 [1] = {
1206 .start = AT91SAM9263_ID_SSC1, 1212 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_SSC1,
1207 .end = AT91SAM9263_ID_SSC1, 1213 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_SSC1,
1208 .flags = IORESOURCE_IRQ, 1214 .flags = IORESOURCE_IRQ,
1209 }, 1215 },
1210}; 1216};
@@ -1284,8 +1290,8 @@ static struct resource dbgu_resources[] = {
1284 .flags = IORESOURCE_MEM, 1290 .flags = IORESOURCE_MEM,
1285 }, 1291 },
1286 [1] = { 1292 [1] = {
1287 .start = AT91_ID_SYS, 1293 .start = NR_IRQS_LEGACY + AT91_ID_SYS,
1288 .end = AT91_ID_SYS, 1294 .end = NR_IRQS_LEGACY + AT91_ID_SYS,
1289 .flags = IORESOURCE_IRQ, 1295 .flags = IORESOURCE_IRQ,
1290 }, 1296 },
1291}; 1297};
@@ -1322,8 +1328,8 @@ static struct resource uart0_resources[] = {
1322 .flags = IORESOURCE_MEM, 1328 .flags = IORESOURCE_MEM,
1323 }, 1329 },
1324 [1] = { 1330 [1] = {
1325 .start = AT91SAM9263_ID_US0, 1331 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_US0,
1326 .end = AT91SAM9263_ID_US0, 1332 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_US0,
1327 .flags = IORESOURCE_IRQ, 1333 .flags = IORESOURCE_IRQ,
1328 }, 1334 },
1329}; 1335};
@@ -1365,8 +1371,8 @@ static struct resource uart1_resources[] = {
1365 .flags = IORESOURCE_MEM, 1371 .flags = IORESOURCE_MEM,
1366 }, 1372 },
1367 [1] = { 1373 [1] = {
1368 .start = AT91SAM9263_ID_US1, 1374 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_US1,
1369 .end = AT91SAM9263_ID_US1, 1375 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_US1,
1370 .flags = IORESOURCE_IRQ, 1376 .flags = IORESOURCE_IRQ,
1371 }, 1377 },
1372}; 1378};
@@ -1408,8 +1414,8 @@ static struct resource uart2_resources[] = {
1408 .flags = IORESOURCE_MEM, 1414 .flags = IORESOURCE_MEM,
1409 }, 1415 },
1410 [1] = { 1416 [1] = {
1411 .start = AT91SAM9263_ID_US2, 1417 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_US2,
1412 .end = AT91SAM9263_ID_US2, 1418 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_US2,
1413 .flags = IORESOURCE_IRQ, 1419 .flags = IORESOURCE_IRQ,
1414 }, 1420 },
1415}; 1421};
diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c
index a94758b4273..ffc0957d762 100644
--- a/arch/arm/mach-at91/at91sam926x_time.c
+++ b/arch/arm/mach-at91/at91sam926x_time.c
@@ -137,7 +137,7 @@ static struct irqaction at91sam926x_pit_irq = {
137 .name = "at91_tick", 137 .name = "at91_tick",
138 .flags = IRQF_SHARED | IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, 138 .flags = IRQF_SHARED | IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
139 .handler = at91sam926x_pit_interrupt, 139 .handler = at91sam926x_pit_interrupt,
140 .irq = AT91_ID_SYS, 140 .irq = NR_IRQS_LEGACY + AT91_ID_SYS,
141}; 141};
142 142
143static void at91sam926x_pit_reset(void) 143static void at91sam926x_pit_reset(void)
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index 4792682d52b..ef6cedd52e3 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -18,6 +18,7 @@
18#include <asm/mach/map.h> 18#include <asm/mach/map.h>
19#include <asm/system_misc.h> 19#include <asm/system_misc.h>
20#include <mach/at91sam9g45.h> 20#include <mach/at91sam9g45.h>
21#include <mach/at91_aic.h>
21#include <mach/at91_pmc.h> 22#include <mach/at91_pmc.h>
22#include <mach/cpu.h> 23#include <mach/cpu.h>
23 24
@@ -182,6 +183,13 @@ static struct clk adc_op_clk = {
182 .rate_hz = 13200000, 183 .rate_hz = 13200000,
183}; 184};
184 185
186/* AES/TDES/SHA clock - Only for sam9m11/sam9g56 */
187static struct clk aestdessha_clk = {
188 .name = "aestdessha_clk",
189 .pmc_mask = 1 << AT91SAM9G45_ID_AESTDESSHA,
190 .type = CLK_TYPE_PERIPHERAL,
191};
192
185static struct clk *periph_clocks[] __initdata = { 193static struct clk *periph_clocks[] __initdata = {
186 &pioA_clk, 194 &pioA_clk,
187 &pioB_clk, 195 &pioB_clk,
@@ -211,6 +219,7 @@ static struct clk *periph_clocks[] __initdata = {
211 &udphs_clk, 219 &udphs_clk,
212 &mmc1_clk, 220 &mmc1_clk,
213 &adc_op_clk, 221 &adc_op_clk,
222 &aestdessha_clk,
214 // irq0 223 // irq0
215}; 224};
216 225
@@ -231,6 +240,9 @@ static struct clk_lookup periph_clocks_lookups[] = {
231 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk), 240 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
232 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk), 241 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
233 CLKDEV_CON_DEV_ID(NULL, "atmel-trng", &trng_clk), 242 CLKDEV_CON_DEV_ID(NULL, "atmel-trng", &trng_clk),
243 CLKDEV_CON_DEV_ID(NULL, "atmel_sha", &aestdessha_clk),
244 CLKDEV_CON_DEV_ID(NULL, "atmel_tdes", &aestdessha_clk),
245 CLKDEV_CON_DEV_ID(NULL, "atmel_aes", &aestdessha_clk),
234 /* more usart lookup table for DT entries */ 246 /* more usart lookup table for DT entries */
235 CLKDEV_CON_DEV_ID("usart", "ffffee00.serial", &mck), 247 CLKDEV_CON_DEV_ID("usart", "ffffee00.serial", &mck),
236 CLKDEV_CON_DEV_ID("usart", "fff8c000.serial", &usart0_clk), 248 CLKDEV_CON_DEV_ID("usart", "fff8c000.serial", &usart0_clk),
@@ -387,7 +399,7 @@ static unsigned int at91sam9g45_default_irq_priority[NR_AIC_IRQS] __initdata = {
387 3, /* Ethernet */ 399 3, /* Ethernet */
388 0, /* Image Sensor Interface */ 400 0, /* Image Sensor Interface */
389 2, /* USB Device High speed port */ 401 2, /* USB Device High speed port */
390 0, 402 0, /* AESTDESSHA Crypto HW Accelerators */
391 0, /* Multimedia Card Interface 1 */ 403 0, /* Multimedia Card Interface 1 */
392 0, 404 0,
393 0, /* Advanced Interrupt Controller (IRQ0) */ 405 0, /* Advanced Interrupt Controller (IRQ0) */
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index 933fc9afe7d..1b47319ca00 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -18,6 +18,7 @@
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/i2c-gpio.h> 19#include <linux/i2c-gpio.h>
20#include <linux/atmel-mci.h> 20#include <linux/atmel-mci.h>
21#include <linux/platform_data/atmel-aes.h>
21 22
22#include <linux/platform_data/at91_adc.h> 23#include <linux/platform_data/at91_adc.h>
23 24
@@ -53,8 +54,8 @@ static struct resource hdmac_resources[] = {
53 .flags = IORESOURCE_MEM, 54 .flags = IORESOURCE_MEM,
54 }, 55 },
55 [1] = { 56 [1] = {
56 .start = AT91SAM9G45_ID_DMA, 57 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_DMA,
57 .end = AT91SAM9G45_ID_DMA, 58 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_DMA,
58 .flags = IORESOURCE_IRQ, 59 .flags = IORESOURCE_IRQ,
59 }, 60 },
60}; 61};
@@ -94,8 +95,8 @@ static struct resource usbh_ohci_resources[] = {
94 .flags = IORESOURCE_MEM, 95 .flags = IORESOURCE_MEM,
95 }, 96 },
96 [1] = { 97 [1] = {
97 .start = AT91SAM9G45_ID_UHPHS, 98 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS,
98 .end = AT91SAM9G45_ID_UHPHS, 99 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS,
99 .flags = IORESOURCE_IRQ, 100 .flags = IORESOURCE_IRQ,
100 }, 101 },
101}; 102};
@@ -156,8 +157,8 @@ static struct resource usbh_ehci_resources[] = {
156 .flags = IORESOURCE_MEM, 157 .flags = IORESOURCE_MEM,
157 }, 158 },
158 [1] = { 159 [1] = {
159 .start = AT91SAM9G45_ID_UHPHS, 160 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS,
160 .end = AT91SAM9G45_ID_UHPHS, 161 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS,
161 .flags = IORESOURCE_IRQ, 162 .flags = IORESOURCE_IRQ,
162 }, 163 },
163}; 164};
@@ -213,8 +214,8 @@ static struct resource usba_udc_resources[] = {
213 .flags = IORESOURCE_MEM, 214 .flags = IORESOURCE_MEM,
214 }, 215 },
215 [2] = { 216 [2] = {
216 .start = AT91SAM9G45_ID_UDPHS, 217 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_UDPHS,
217 .end = AT91SAM9G45_ID_UDPHS, 218 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_UDPHS,
218 .flags = IORESOURCE_IRQ, 219 .flags = IORESOURCE_IRQ,
219 }, 220 },
220}; 221};
@@ -296,8 +297,8 @@ static struct resource eth_resources[] = {
296 .flags = IORESOURCE_MEM, 297 .flags = IORESOURCE_MEM,
297 }, 298 },
298 [1] = { 299 [1] = {
299 .start = AT91SAM9G45_ID_EMAC, 300 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_EMAC,
300 .end = AT91SAM9G45_ID_EMAC, 301 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_EMAC,
301 .flags = IORESOURCE_IRQ, 302 .flags = IORESOURCE_IRQ,
302 }, 303 },
303}; 304};
@@ -370,8 +371,8 @@ static struct resource mmc0_resources[] = {
370 .flags = IORESOURCE_MEM, 371 .flags = IORESOURCE_MEM,
371 }, 372 },
372 [1] = { 373 [1] = {
373 .start = AT91SAM9G45_ID_MCI0, 374 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_MCI0,
374 .end = AT91SAM9G45_ID_MCI0, 375 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_MCI0,
375 .flags = IORESOURCE_IRQ, 376 .flags = IORESOURCE_IRQ,
376 }, 377 },
377}; 378};
@@ -395,8 +396,8 @@ static struct resource mmc1_resources[] = {
395 .flags = IORESOURCE_MEM, 396 .flags = IORESOURCE_MEM,
396 }, 397 },
397 [1] = { 398 [1] = {
398 .start = AT91SAM9G45_ID_MCI1, 399 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_MCI1,
399 .end = AT91SAM9G45_ID_MCI1, 400 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_MCI1,
400 .flags = IORESOURCE_IRQ, 401 .flags = IORESOURCE_IRQ,
401 }, 402 },
402}; 403};
@@ -645,8 +646,8 @@ static struct resource twi0_resources[] = {
645 .flags = IORESOURCE_MEM, 646 .flags = IORESOURCE_MEM,
646 }, 647 },
647 [1] = { 648 [1] = {
648 .start = AT91SAM9G45_ID_TWI0, 649 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TWI0,
649 .end = AT91SAM9G45_ID_TWI0, 650 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TWI0,
650 .flags = IORESOURCE_IRQ, 651 .flags = IORESOURCE_IRQ,
651 }, 652 },
652}; 653};
@@ -665,8 +666,8 @@ static struct resource twi1_resources[] = {
665 .flags = IORESOURCE_MEM, 666 .flags = IORESOURCE_MEM,
666 }, 667 },
667 [1] = { 668 [1] = {
668 .start = AT91SAM9G45_ID_TWI1, 669 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TWI1,
669 .end = AT91SAM9G45_ID_TWI1, 670 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TWI1,
670 .flags = IORESOURCE_IRQ, 671 .flags = IORESOURCE_IRQ,
671 }, 672 },
672}; 673};
@@ -720,8 +721,8 @@ static struct resource spi0_resources[] = {
720 .flags = IORESOURCE_MEM, 721 .flags = IORESOURCE_MEM,
721 }, 722 },
722 [1] = { 723 [1] = {
723 .start = AT91SAM9G45_ID_SPI0, 724 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_SPI0,
724 .end = AT91SAM9G45_ID_SPI0, 725 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_SPI0,
725 .flags = IORESOURCE_IRQ, 726 .flags = IORESOURCE_IRQ,
726 }, 727 },
727}; 728};
@@ -746,8 +747,8 @@ static struct resource spi1_resources[] = {
746 .flags = IORESOURCE_MEM, 747 .flags = IORESOURCE_MEM,
747 }, 748 },
748 [1] = { 749 [1] = {
749 .start = AT91SAM9G45_ID_SPI1, 750 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_SPI1,
750 .end = AT91SAM9G45_ID_SPI1, 751 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_SPI1,
751 .flags = IORESOURCE_IRQ, 752 .flags = IORESOURCE_IRQ,
752 }, 753 },
753}; 754};
@@ -834,8 +835,8 @@ static struct resource ac97_resources[] = {
834 .flags = IORESOURCE_MEM, 835 .flags = IORESOURCE_MEM,
835 }, 836 },
836 [1] = { 837 [1] = {
837 .start = AT91SAM9G45_ID_AC97C, 838 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_AC97C,
838 .end = AT91SAM9G45_ID_AC97C, 839 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_AC97C,
839 .flags = IORESOURCE_IRQ, 840 .flags = IORESOURCE_IRQ,
840 }, 841 },
841}; 842};
@@ -887,8 +888,8 @@ struct resource isi_resources[] = {
887 .flags = IORESOURCE_MEM, 888 .flags = IORESOURCE_MEM,
888 }, 889 },
889 [1] = { 890 [1] = {
890 .start = AT91SAM9G45_ID_ISI, 891 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_ISI,
891 .end = AT91SAM9G45_ID_ISI, 892 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_ISI,
892 .flags = IORESOURCE_IRQ, 893 .flags = IORESOURCE_IRQ,
893 }, 894 },
894}; 895};
@@ -979,8 +980,8 @@ static struct resource lcdc_resources[] = {
979 .flags = IORESOURCE_MEM, 980 .flags = IORESOURCE_MEM,
980 }, 981 },
981 [1] = { 982 [1] = {
982 .start = AT91SAM9G45_ID_LCDC, 983 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_LCDC,
983 .end = AT91SAM9G45_ID_LCDC, 984 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_LCDC,
984 .flags = IORESOURCE_IRQ, 985 .flags = IORESOURCE_IRQ,
985 }, 986 },
986}; 987};
@@ -1054,8 +1055,8 @@ static struct resource tcb0_resources[] = {
1054 .flags = IORESOURCE_MEM, 1055 .flags = IORESOURCE_MEM,
1055 }, 1056 },
1056 [1] = { 1057 [1] = {
1057 .start = AT91SAM9G45_ID_TCB, 1058 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TCB,
1058 .end = AT91SAM9G45_ID_TCB, 1059 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TCB,
1059 .flags = IORESOURCE_IRQ, 1060 .flags = IORESOURCE_IRQ,
1060 }, 1061 },
1061}; 1062};
@@ -1075,8 +1076,8 @@ static struct resource tcb1_resources[] = {
1075 .flags = IORESOURCE_MEM, 1076 .flags = IORESOURCE_MEM,
1076 }, 1077 },
1077 [1] = { 1078 [1] = {
1078 .start = AT91SAM9G45_ID_TCB, 1079 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TCB,
1079 .end = AT91SAM9G45_ID_TCB, 1080 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TCB,
1080 .flags = IORESOURCE_IRQ, 1081 .flags = IORESOURCE_IRQ,
1081 }, 1082 },
1082}; 1083};
@@ -1110,8 +1111,8 @@ static struct resource rtc_resources[] = {
1110 .flags = IORESOURCE_MEM, 1111 .flags = IORESOURCE_MEM,
1111 }, 1112 },
1112 [1] = { 1113 [1] = {
1113 .start = AT91_ID_SYS, 1114 .start = NR_IRQS_LEGACY + AT91_ID_SYS,
1114 .end = AT91_ID_SYS, 1115 .end = NR_IRQS_LEGACY + AT91_ID_SYS,
1115 .flags = IORESOURCE_IRQ, 1116 .flags = IORESOURCE_IRQ,
1116 }, 1117 },
1117}; 1118};
@@ -1147,8 +1148,8 @@ static struct resource tsadcc_resources[] = {
1147 .flags = IORESOURCE_MEM, 1148 .flags = IORESOURCE_MEM,
1148 }, 1149 },
1149 [1] = { 1150 [1] = {
1150 .start = AT91SAM9G45_ID_TSC, 1151 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TSC,
1151 .end = AT91SAM9G45_ID_TSC, 1152 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TSC,
1152 .flags = IORESOURCE_IRQ, 1153 .flags = IORESOURCE_IRQ,
1153 } 1154 }
1154}; 1155};
@@ -1197,8 +1198,8 @@ static struct resource adc_resources[] = {
1197 .flags = IORESOURCE_MEM, 1198 .flags = IORESOURCE_MEM,
1198 }, 1199 },
1199 [1] = { 1200 [1] = {
1200 .start = AT91SAM9G45_ID_TSC, 1201 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TSC,
1201 .end = AT91SAM9G45_ID_TSC, 1202 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TSC,
1202 .flags = IORESOURCE_IRQ, 1203 .flags = IORESOURCE_IRQ,
1203 } 1204 }
1204}; 1205};
@@ -1292,6 +1293,8 @@ static struct resource rtt_resources[] = {
1292 .flags = IORESOURCE_MEM, 1293 .flags = IORESOURCE_MEM,
1293 }, { 1294 }, {
1294 .flags = IORESOURCE_MEM, 1295 .flags = IORESOURCE_MEM,
1296 }, {
1297 .flags = IORESOURCE_IRQ,
1295 } 1298 }
1296}; 1299};
1297 1300
@@ -1309,10 +1312,12 @@ static void __init at91_add_device_rtt_rtc(void)
1309 * The second resource is needed: 1312 * The second resource is needed:
1310 * GPBR will serve as the storage for RTC time offset 1313 * GPBR will serve as the storage for RTC time offset
1311 */ 1314 */
1312 at91sam9g45_rtt_device.num_resources = 2; 1315 at91sam9g45_rtt_device.num_resources = 3;
1313 rtt_resources[1].start = AT91SAM9G45_BASE_GPBR + 1316 rtt_resources[1].start = AT91SAM9G45_BASE_GPBR +
1314 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR; 1317 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
1315 rtt_resources[1].end = rtt_resources[1].start + 3; 1318 rtt_resources[1].end = rtt_resources[1].start + 3;
1319 rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS;
1320 rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS;
1316} 1321}
1317#else 1322#else
1318static void __init at91_add_device_rtt_rtc(void) 1323static void __init at91_add_device_rtt_rtc(void)
@@ -1400,8 +1405,8 @@ static struct resource pwm_resources[] = {
1400 .flags = IORESOURCE_MEM, 1405 .flags = IORESOURCE_MEM,
1401 }, 1406 },
1402 [1] = { 1407 [1] = {
1403 .start = AT91SAM9G45_ID_PWMC, 1408 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_PWMC,
1404 .end = AT91SAM9G45_ID_PWMC, 1409 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_PWMC,
1405 .flags = IORESOURCE_IRQ, 1410 .flags = IORESOURCE_IRQ,
1406 }, 1411 },
1407}; 1412};
@@ -1453,8 +1458,8 @@ static struct resource ssc0_resources[] = {
1453 .flags = IORESOURCE_MEM, 1458 .flags = IORESOURCE_MEM,
1454 }, 1459 },
1455 [1] = { 1460 [1] = {
1456 .start = AT91SAM9G45_ID_SSC0, 1461 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_SSC0,
1457 .end = AT91SAM9G45_ID_SSC0, 1462 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_SSC0,
1458 .flags = IORESOURCE_IRQ, 1463 .flags = IORESOURCE_IRQ,
1459 }, 1464 },
1460}; 1465};
@@ -1495,8 +1500,8 @@ static struct resource ssc1_resources[] = {
1495 .flags = IORESOURCE_MEM, 1500 .flags = IORESOURCE_MEM,
1496 }, 1501 },
1497 [1] = { 1502 [1] = {
1498 .start = AT91SAM9G45_ID_SSC1, 1503 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_SSC1,
1499 .end = AT91SAM9G45_ID_SSC1, 1504 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_SSC1,
1500 .flags = IORESOURCE_IRQ, 1505 .flags = IORESOURCE_IRQ,
1501 }, 1506 },
1502}; 1507};
@@ -1575,8 +1580,8 @@ static struct resource dbgu_resources[] = {
1575 .flags = IORESOURCE_MEM, 1580 .flags = IORESOURCE_MEM,
1576 }, 1581 },
1577 [1] = { 1582 [1] = {
1578 .start = AT91_ID_SYS, 1583 .start = NR_IRQS_LEGACY + AT91_ID_SYS,
1579 .end = AT91_ID_SYS, 1584 .end = NR_IRQS_LEGACY + AT91_ID_SYS,
1580 .flags = IORESOURCE_IRQ, 1585 .flags = IORESOURCE_IRQ,
1581 }, 1586 },
1582}; 1587};
@@ -1613,8 +1618,8 @@ static struct resource uart0_resources[] = {
1613 .flags = IORESOURCE_MEM, 1618 .flags = IORESOURCE_MEM,
1614 }, 1619 },
1615 [1] = { 1620 [1] = {
1616 .start = AT91SAM9G45_ID_US0, 1621 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_US0,
1617 .end = AT91SAM9G45_ID_US0, 1622 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_US0,
1618 .flags = IORESOURCE_IRQ, 1623 .flags = IORESOURCE_IRQ,
1619 }, 1624 },
1620}; 1625};
@@ -1656,8 +1661,8 @@ static struct resource uart1_resources[] = {
1656 .flags = IORESOURCE_MEM, 1661 .flags = IORESOURCE_MEM,
1657 }, 1662 },
1658 [1] = { 1663 [1] = {
1659 .start = AT91SAM9G45_ID_US1, 1664 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_US1,
1660 .end = AT91SAM9G45_ID_US1, 1665 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_US1,
1661 .flags = IORESOURCE_IRQ, 1666 .flags = IORESOURCE_IRQ,
1662 }, 1667 },
1663}; 1668};
@@ -1699,8 +1704,8 @@ static struct resource uart2_resources[] = {
1699 .flags = IORESOURCE_MEM, 1704 .flags = IORESOURCE_MEM,
1700 }, 1705 },
1701 [1] = { 1706 [1] = {
1702 .start = AT91SAM9G45_ID_US2, 1707 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_US2,
1703 .end = AT91SAM9G45_ID_US2, 1708 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_US2,
1704 .flags = IORESOURCE_IRQ, 1709 .flags = IORESOURCE_IRQ,
1705 }, 1710 },
1706}; 1711};
@@ -1742,8 +1747,8 @@ static struct resource uart3_resources[] = {
1742 .flags = IORESOURCE_MEM, 1747 .flags = IORESOURCE_MEM,
1743 }, 1748 },
1744 [1] = { 1749 [1] = {
1745 .start = AT91SAM9G45_ID_US3, 1750 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_US3,
1746 .end = AT91SAM9G45_ID_US3, 1751 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_US3,
1747 .flags = IORESOURCE_IRQ, 1752 .flags = IORESOURCE_IRQ,
1748 }, 1753 },
1749}; 1754};
@@ -1830,6 +1835,130 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1830void __init at91_add_device_serial(void) {} 1835void __init at91_add_device_serial(void) {}
1831#endif 1836#endif
1832 1837
1838/* --------------------------------------------------------------------
1839 * SHA1/SHA256
1840 * -------------------------------------------------------------------- */
1841
1842#if defined(CONFIG_CRYPTO_DEV_ATMEL_SHA) || defined(CONFIG_CRYPTO_DEV_ATMEL_SHA_MODULE)
1843static struct resource sha_resources[] = {
1844 {
1845 .start = AT91SAM9G45_BASE_SHA,
1846 .end = AT91SAM9G45_BASE_SHA + SZ_16K - 1,
1847 .flags = IORESOURCE_MEM,
1848 },
1849 [1] = {
1850 .start = AT91SAM9G45_ID_AESTDESSHA,
1851 .end = AT91SAM9G45_ID_AESTDESSHA,
1852 .flags = IORESOURCE_IRQ,
1853 },
1854};
1855
1856static struct platform_device at91sam9g45_sha_device = {
1857 .name = "atmel_sha",
1858 .id = -1,
1859 .resource = sha_resources,
1860 .num_resources = ARRAY_SIZE(sha_resources),
1861};
1862
1863static void __init at91_add_device_sha(void)
1864{
1865 platform_device_register(&at91sam9g45_sha_device);
1866}
1867#else
1868static void __init at91_add_device_sha(void) {}
1869#endif
1870
1871/* --------------------------------------------------------------------
1872 * DES/TDES
1873 * -------------------------------------------------------------------- */
1874
1875#if defined(CONFIG_CRYPTO_DEV_ATMEL_TDES) || defined(CONFIG_CRYPTO_DEV_ATMEL_TDES_MODULE)
1876static struct resource tdes_resources[] = {
1877 [0] = {
1878 .start = AT91SAM9G45_BASE_TDES,
1879 .end = AT91SAM9G45_BASE_TDES + SZ_16K - 1,
1880 .flags = IORESOURCE_MEM,
1881 },
1882 [1] = {
1883 .start = AT91SAM9G45_ID_AESTDESSHA,
1884 .end = AT91SAM9G45_ID_AESTDESSHA,
1885 .flags = IORESOURCE_IRQ,
1886 },
1887};
1888
1889static struct platform_device at91sam9g45_tdes_device = {
1890 .name = "atmel_tdes",
1891 .id = -1,
1892 .resource = tdes_resources,
1893 .num_resources = ARRAY_SIZE(tdes_resources),
1894};
1895
1896static void __init at91_add_device_tdes(void)
1897{
1898 platform_device_register(&at91sam9g45_tdes_device);
1899}
1900#else
1901static void __init at91_add_device_tdes(void) {}
1902#endif
1903
1904/* --------------------------------------------------------------------
1905 * AES
1906 * -------------------------------------------------------------------- */
1907
1908#if defined(CONFIG_CRYPTO_DEV_ATMEL_AES) || defined(CONFIG_CRYPTO_DEV_ATMEL_AES_MODULE)
1909static struct aes_platform_data aes_data;
1910static u64 aes_dmamask = DMA_BIT_MASK(32);
1911
1912static struct resource aes_resources[] = {
1913 [0] = {
1914 .start = AT91SAM9G45_BASE_AES,
1915 .end = AT91SAM9G45_BASE_AES + SZ_16K - 1,
1916 .flags = IORESOURCE_MEM,
1917 },
1918 [1] = {
1919 .start = AT91SAM9G45_ID_AESTDESSHA,
1920 .end = AT91SAM9G45_ID_AESTDESSHA,
1921 .flags = IORESOURCE_IRQ,
1922 },
1923};
1924
1925static struct platform_device at91sam9g45_aes_device = {
1926 .name = "atmel_aes",
1927 .id = -1,
1928 .dev = {
1929 .dma_mask = &aes_dmamask,
1930 .coherent_dma_mask = DMA_BIT_MASK(32),
1931 .platform_data = &aes_data,
1932 },
1933 .resource = aes_resources,
1934 .num_resources = ARRAY_SIZE(aes_resources),
1935};
1936
1937static void __init at91_add_device_aes(void)
1938{
1939 struct at_dma_slave *atslave;
1940 struct aes_dma_data *alt_atslave;
1941
1942 alt_atslave = kzalloc(sizeof(struct aes_dma_data), GFP_KERNEL);
1943
1944 /* DMA TX slave channel configuration */
1945 atslave = &alt_atslave->txdata;
1946 atslave->dma_dev = &at_hdmac_device.dev;
1947 atslave->cfg = ATC_FIFOCFG_ENOUGHSPACE | ATC_SRC_H2SEL_HW |
1948 ATC_SRC_PER(AT_DMA_ID_AES_RX);
1949
1950 /* DMA RX slave channel configuration */
1951 atslave = &alt_atslave->rxdata;
1952 atslave->dma_dev = &at_hdmac_device.dev;
1953 atslave->cfg = ATC_FIFOCFG_ENOUGHSPACE | ATC_DST_H2SEL_HW |
1954 ATC_DST_PER(AT_DMA_ID_AES_TX);
1955
1956 aes_data.dma_slave = alt_atslave;
1957 platform_device_register(&at91sam9g45_aes_device);
1958}
1959#else
1960static void __init at91_add_device_aes(void) {}
1961#endif
1833 1962
1834/* -------------------------------------------------------------------- */ 1963/* -------------------------------------------------------------------- */
1835/* 1964/*
@@ -1847,6 +1976,9 @@ static int __init at91_add_standard_devices(void)
1847 at91_add_device_trng(); 1976 at91_add_device_trng();
1848 at91_add_device_watchdog(); 1977 at91_add_device_watchdog();
1849 at91_add_device_tc(); 1978 at91_add_device_tc();
1979 at91_add_device_sha();
1980 at91_add_device_tdes();
1981 at91_add_device_aes();
1850 return 0; 1982 return 0;
1851} 1983}
1852 1984
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index e420085a57e..72ce50a50de 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -19,6 +19,7 @@
19#include <mach/cpu.h> 19#include <mach/cpu.h>
20#include <mach/at91_dbgu.h> 20#include <mach/at91_dbgu.h>
21#include <mach/at91sam9rl.h> 21#include <mach/at91sam9rl.h>
22#include <mach/at91_aic.h>
22#include <mach/at91_pmc.h> 23#include <mach/at91_pmc.h>
23#include <mach/at91_rstc.h> 24#include <mach/at91_rstc.h>
24 25
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c
index 9c0b1481a9a..b3d365dadef 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -41,8 +41,8 @@ static struct resource hdmac_resources[] = {
41 .flags = IORESOURCE_MEM, 41 .flags = IORESOURCE_MEM,
42 }, 42 },
43 [2] = { 43 [2] = {
44 .start = AT91SAM9RL_ID_DMA, 44 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_DMA,
45 .end = AT91SAM9RL_ID_DMA, 45 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_DMA,
46 .flags = IORESOURCE_IRQ, 46 .flags = IORESOURCE_IRQ,
47 }, 47 },
48}; 48};
@@ -84,8 +84,8 @@ static struct resource usba_udc_resources[] = {
84 .flags = IORESOURCE_MEM, 84 .flags = IORESOURCE_MEM,
85 }, 85 },
86 [2] = { 86 [2] = {
87 .start = AT91SAM9RL_ID_UDPHS, 87 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_UDPHS,
88 .end = AT91SAM9RL_ID_UDPHS, 88 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_UDPHS,
89 .flags = IORESOURCE_IRQ, 89 .flags = IORESOURCE_IRQ,
90 }, 90 },
91}; 91};
@@ -172,8 +172,8 @@ static struct resource mmc_resources[] = {
172 .flags = IORESOURCE_MEM, 172 .flags = IORESOURCE_MEM,
173 }, 173 },
174 [1] = { 174 [1] = {
175 .start = AT91SAM9RL_ID_MCI, 175 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_MCI,
176 .end = AT91SAM9RL_ID_MCI, 176 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_MCI,
177 .flags = IORESOURCE_IRQ, 177 .flags = IORESOURCE_IRQ,
178 }, 178 },
179}; 179};
@@ -339,8 +339,8 @@ static struct resource twi_resources[] = {
339 .flags = IORESOURCE_MEM, 339 .flags = IORESOURCE_MEM,
340 }, 340 },
341 [1] = { 341 [1] = {
342 .start = AT91SAM9RL_ID_TWI0, 342 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_TWI0,
343 .end = AT91SAM9RL_ID_TWI0, 343 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_TWI0,
344 .flags = IORESOURCE_IRQ, 344 .flags = IORESOURCE_IRQ,
345 }, 345 },
346}; 346};
@@ -383,8 +383,8 @@ static struct resource spi_resources[] = {
383 .flags = IORESOURCE_MEM, 383 .flags = IORESOURCE_MEM,
384 }, 384 },
385 [1] = { 385 [1] = {
386 .start = AT91SAM9RL_ID_SPI, 386 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_SPI,
387 .end = AT91SAM9RL_ID_SPI, 387 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_SPI,
388 .flags = IORESOURCE_IRQ, 388 .flags = IORESOURCE_IRQ,
389 }, 389 },
390}; 390};
@@ -452,8 +452,8 @@ static struct resource ac97_resources[] = {
452 .flags = IORESOURCE_MEM, 452 .flags = IORESOURCE_MEM,
453 }, 453 },
454 [1] = { 454 [1] = {
455 .start = AT91SAM9RL_ID_AC97C, 455 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_AC97C,
456 .end = AT91SAM9RL_ID_AC97C, 456 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_AC97C,
457 .flags = IORESOURCE_IRQ, 457 .flags = IORESOURCE_IRQ,
458 }, 458 },
459}; 459};
@@ -507,8 +507,8 @@ static struct resource lcdc_resources[] = {
507 .flags = IORESOURCE_MEM, 507 .flags = IORESOURCE_MEM,
508 }, 508 },
509 [1] = { 509 [1] = {
510 .start = AT91SAM9RL_ID_LCDC, 510 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_LCDC,
511 .end = AT91SAM9RL_ID_LCDC, 511 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_LCDC,
512 .flags = IORESOURCE_IRQ, 512 .flags = IORESOURCE_IRQ,
513 }, 513 },
514}; 514};
@@ -574,18 +574,18 @@ static struct resource tcb_resources[] = {
574 .flags = IORESOURCE_MEM, 574 .flags = IORESOURCE_MEM,
575 }, 575 },
576 [1] = { 576 [1] = {
577 .start = AT91SAM9RL_ID_TC0, 577 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_TC0,
578 .end = AT91SAM9RL_ID_TC0, 578 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_TC0,
579 .flags = IORESOURCE_IRQ, 579 .flags = IORESOURCE_IRQ,
580 }, 580 },
581 [2] = { 581 [2] = {
582 .start = AT91SAM9RL_ID_TC1, 582 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_TC1,
583 .end = AT91SAM9RL_ID_TC1, 583 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_TC1,
584 .flags = IORESOURCE_IRQ, 584 .flags = IORESOURCE_IRQ,
585 }, 585 },
586 [3] = { 586 [3] = {
587 .start = AT91SAM9RL_ID_TC2, 587 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_TC2,
588 .end = AT91SAM9RL_ID_TC2, 588 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_TC2,
589 .flags = IORESOURCE_IRQ, 589 .flags = IORESOURCE_IRQ,
590 }, 590 },
591}; 591};
@@ -621,8 +621,8 @@ static struct resource tsadcc_resources[] = {
621 .flags = IORESOURCE_MEM, 621 .flags = IORESOURCE_MEM,
622 }, 622 },
623 [1] = { 623 [1] = {
624 .start = AT91SAM9RL_ID_TSC, 624 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_TSC,
625 .end = AT91SAM9RL_ID_TSC, 625 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_TSC,
626 .flags = IORESOURCE_IRQ, 626 .flags = IORESOURCE_IRQ,
627 } 627 }
628}; 628};
@@ -688,6 +688,8 @@ static struct resource rtt_resources[] = {
688 .flags = IORESOURCE_MEM, 688 .flags = IORESOURCE_MEM,
689 }, { 689 }, {
690 .flags = IORESOURCE_MEM, 690 .flags = IORESOURCE_MEM,
691 }, {
692 .flags = IORESOURCE_IRQ,
691 } 693 }
692}; 694};
693 695
@@ -705,10 +707,12 @@ static void __init at91_add_device_rtt_rtc(void)
705 * The second resource is needed: 707 * The second resource is needed:
706 * GPBR will serve as the storage for RTC time offset 708 * GPBR will serve as the storage for RTC time offset
707 */ 709 */
708 at91sam9rl_rtt_device.num_resources = 2; 710 at91sam9rl_rtt_device.num_resources = 3;
709 rtt_resources[1].start = AT91SAM9RL_BASE_GPBR + 711 rtt_resources[1].start = AT91SAM9RL_BASE_GPBR +
710 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR; 712 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
711 rtt_resources[1].end = rtt_resources[1].start + 3; 713 rtt_resources[1].end = rtt_resources[1].start + 3;
714 rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS;
715 rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS;
712} 716}
713#else 717#else
714static void __init at91_add_device_rtt_rtc(void) 718static void __init at91_add_device_rtt_rtc(void)
@@ -768,8 +772,8 @@ static struct resource pwm_resources[] = {
768 .flags = IORESOURCE_MEM, 772 .flags = IORESOURCE_MEM,
769 }, 773 },
770 [1] = { 774 [1] = {
771 .start = AT91SAM9RL_ID_PWMC, 775 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_PWMC,
772 .end = AT91SAM9RL_ID_PWMC, 776 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_PWMC,
773 .flags = IORESOURCE_IRQ, 777 .flags = IORESOURCE_IRQ,
774 }, 778 },
775}; 779};
@@ -821,8 +825,8 @@ static struct resource ssc0_resources[] = {
821 .flags = IORESOURCE_MEM, 825 .flags = IORESOURCE_MEM,
822 }, 826 },
823 [1] = { 827 [1] = {
824 .start = AT91SAM9RL_ID_SSC0, 828 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_SSC0,
825 .end = AT91SAM9RL_ID_SSC0, 829 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_SSC0,
826 .flags = IORESOURCE_IRQ, 830 .flags = IORESOURCE_IRQ,
827 }, 831 },
828}; 832};
@@ -863,8 +867,8 @@ static struct resource ssc1_resources[] = {
863 .flags = IORESOURCE_MEM, 867 .flags = IORESOURCE_MEM,
864 }, 868 },
865 [1] = { 869 [1] = {
866 .start = AT91SAM9RL_ID_SSC1, 870 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_SSC1,
867 .end = AT91SAM9RL_ID_SSC1, 871 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_SSC1,
868 .flags = IORESOURCE_IRQ, 872 .flags = IORESOURCE_IRQ,
869 }, 873 },
870}; 874};
@@ -943,8 +947,8 @@ static struct resource dbgu_resources[] = {
943 .flags = IORESOURCE_MEM, 947 .flags = IORESOURCE_MEM,
944 }, 948 },
945 [1] = { 949 [1] = {
946 .start = AT91_ID_SYS, 950 .start = NR_IRQS_LEGACY + AT91_ID_SYS,
947 .end = AT91_ID_SYS, 951 .end = NR_IRQS_LEGACY + AT91_ID_SYS,
948 .flags = IORESOURCE_IRQ, 952 .flags = IORESOURCE_IRQ,
949 }, 953 },
950}; 954};
@@ -981,8 +985,8 @@ static struct resource uart0_resources[] = {
981 .flags = IORESOURCE_MEM, 985 .flags = IORESOURCE_MEM,
982 }, 986 },
983 [1] = { 987 [1] = {
984 .start = AT91SAM9RL_ID_US0, 988 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_US0,
985 .end = AT91SAM9RL_ID_US0, 989 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_US0,
986 .flags = IORESOURCE_IRQ, 990 .flags = IORESOURCE_IRQ,
987 }, 991 },
988}; 992};
@@ -1032,8 +1036,8 @@ static struct resource uart1_resources[] = {
1032 .flags = IORESOURCE_MEM, 1036 .flags = IORESOURCE_MEM,
1033 }, 1037 },
1034 [1] = { 1038 [1] = {
1035 .start = AT91SAM9RL_ID_US1, 1039 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_US1,
1036 .end = AT91SAM9RL_ID_US1, 1040 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_US1,
1037 .flags = IORESOURCE_IRQ, 1041 .flags = IORESOURCE_IRQ,
1038 }, 1042 },
1039}; 1043};
@@ -1075,8 +1079,8 @@ static struct resource uart2_resources[] = {
1075 .flags = IORESOURCE_MEM, 1079 .flags = IORESOURCE_MEM,
1076 }, 1080 },
1077 [1] = { 1081 [1] = {
1078 .start = AT91SAM9RL_ID_US2, 1082 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_US2,
1079 .end = AT91SAM9RL_ID_US2, 1083 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_US2,
1080 .flags = IORESOURCE_IRQ, 1084 .flags = IORESOURCE_IRQ,
1081 }, 1085 },
1082}; 1086};
@@ -1118,8 +1122,8 @@ static struct resource uart3_resources[] = {
1118 .flags = IORESOURCE_MEM, 1122 .flags = IORESOURCE_MEM,
1119 }, 1123 },
1120 [1] = { 1124 [1] = {
1121 .start = AT91SAM9RL_ID_US3, 1125 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_US3,
1122 .end = AT91SAM9RL_ID_US3, 1126 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_US3,
1123 .flags = IORESOURCE_IRQ, 1127 .flags = IORESOURCE_IRQ,
1124 }, 1128 },
1125}; 1129};
diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index 1b144b4d3ce..477cf9d0667 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -312,8 +312,6 @@ static void __init at91sam9x5_map_io(void)
312 312
313void __init at91sam9x5_initialize(void) 313void __init at91sam9x5_initialize(void)
314{ 314{
315 at91_extern_irq = (1 << AT91SAM9X5_ID_IRQ0);
316
317 /* Register GPIO subsystem (using DT) */ 315 /* Register GPIO subsystem (using DT) */
318 at91_gpio_init(NULL, 0); 316 at91_gpio_init(NULL, 0);
319} 317}
@@ -321,47 +319,9 @@ void __init at91sam9x5_initialize(void)
321/* -------------------------------------------------------------------- 319/* --------------------------------------------------------------------
322 * Interrupt initialization 320 * Interrupt initialization
323 * -------------------------------------------------------------------- */ 321 * -------------------------------------------------------------------- */
324/*
325 * The default interrupt priority levels (0 = lowest, 7 = highest).
326 */
327static unsigned int at91sam9x5_default_irq_priority[NR_AIC_IRQS] __initdata = {
328 7, /* Advanced Interrupt Controller (FIQ) */
329 7, /* System Peripherals */
330 1, /* Parallel IO Controller A and B */
331 1, /* Parallel IO Controller C and D */
332 4, /* Soft Modem */
333 5, /* USART 0 */
334 5, /* USART 1 */
335 5, /* USART 2 */
336 5, /* USART 3 */
337 6, /* Two-Wire Interface 0 */
338 6, /* Two-Wire Interface 1 */
339 6, /* Two-Wire Interface 2 */
340 0, /* Multimedia Card Interface 0 */
341 5, /* Serial Peripheral Interface 0 */
342 5, /* Serial Peripheral Interface 1 */
343 5, /* UART 0 */
344 5, /* UART 1 */
345 0, /* Timer Counter 0, 1, 2, 3, 4 and 5 */
346 0, /* Pulse Width Modulation Controller */
347 0, /* ADC Controller */
348 0, /* DMA Controller 0 */
349 0, /* DMA Controller 1 */
350 2, /* USB Host High Speed port */
351 2, /* USB Device High speed port */
352 3, /* Ethernet MAC 0 */
353 3, /* LDC Controller or Image Sensor Interface */
354 0, /* Multimedia Card Interface 1 */
355 3, /* Ethernet MAC 1 */
356 4, /* Synchronous Serial Interface */
357 4, /* CAN Controller 0 */
358 4, /* CAN Controller 1 */
359 0, /* Advanced Interrupt Controller (IRQ0) */
360};
361 322
362struct at91_init_soc __initdata at91sam9x5_soc = { 323struct at91_init_soc __initdata at91sam9x5_soc = {
363 .map_io = at91sam9x5_map_io, 324 .map_io = at91sam9x5_map_io,
364 .default_irq_priority = at91sam9x5_default_irq_priority,
365 .register_clocks = at91sam9x5_register_clocks, 325 .register_clocks = at91sam9x5_register_clocks,
366 .init = at91sam9x5_initialize, 326 .init = at91sam9x5_initialize,
367}; 327};
diff --git a/arch/arm/mach-at91/at91x40.c b/arch/arm/mach-at91/at91x40.c
index d62fe090d81..46090e642d8 100644
--- a/arch/arm/mach-at91/at91x40.c
+++ b/arch/arm/mach-at91/at91x40.c
@@ -13,10 +13,12 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/irq.h> 15#include <linux/irq.h>
16#include <linux/io.h>
16#include <asm/proc-fns.h> 17#include <asm/proc-fns.h>
17#include <asm/system_misc.h> 18#include <asm/system_misc.h>
18#include <asm/mach/arch.h> 19#include <asm/mach/arch.h>
19#include <mach/at91x40.h> 20#include <mach/at91x40.h>
21#include <mach/at91_aic.h>
20#include <mach/at91_st.h> 22#include <mach/at91_st.h>
21#include <mach/timex.h> 23#include <mach/timex.h>
22#include "generic.h" 24#include "generic.h"
diff --git a/arch/arm/mach-at91/board-1arm.c b/arch/arm/mach-at91/board-1arm.c
index 271f994314a..22d8856094f 100644
--- a/arch/arm/mach-at91/board-1arm.c
+++ b/arch/arm/mach-at91/board-1arm.c
@@ -36,6 +36,7 @@
36 36
37#include <mach/board.h> 37#include <mach/board.h>
38#include <mach/cpu.h> 38#include <mach/cpu.h>
39#include <mach/at91_aic.h>
39 40
40#include "generic.h" 41#include "generic.h"
41 42
@@ -91,6 +92,7 @@ MACHINE_START(ONEARM, "Ajeco 1ARM single board computer")
91 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ 92 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
92 .timer = &at91rm9200_timer, 93 .timer = &at91rm9200_timer,
93 .map_io = at91_map_io, 94 .map_io = at91_map_io,
95 .handle_irq = at91_aic_handle_irq,
94 .init_early = onearm_init_early, 96 .init_early = onearm_init_early,
95 .init_irq = at91_init_irq_default, 97 .init_irq = at91_init_irq_default,
96 .init_machine = onearm_board_init, 98 .init_machine = onearm_board_init,
diff --git a/arch/arm/mach-at91/board-afeb-9260v1.c b/arch/arm/mach-at91/board-afeb-9260v1.c
index b7d8aa7b81e..de7be193181 100644
--- a/arch/arm/mach-at91/board-afeb-9260v1.c
+++ b/arch/arm/mach-at91/board-afeb-9260v1.c
@@ -44,6 +44,7 @@
44#include <asm/mach/irq.h> 44#include <asm/mach/irq.h>
45 45
46#include <mach/board.h> 46#include <mach/board.h>
47#include <mach/at91_aic.h>
47 48
48#include "generic.h" 49#include "generic.h"
49 50
@@ -212,6 +213,7 @@ MACHINE_START(AFEB9260, "Custom afeb9260 board")
212 /* Maintainer: Sergey Lapin <slapin@ossfans.org> */ 213 /* Maintainer: Sergey Lapin <slapin@ossfans.org> */
213 .timer = &at91sam926x_timer, 214 .timer = &at91sam926x_timer,
214 .map_io = at91_map_io, 215 .map_io = at91_map_io,
216 .handle_irq = at91_aic_handle_irq,
215 .init_early = afeb9260_init_early, 217 .init_early = afeb9260_init_early,
216 .init_irq = at91_init_irq_default, 218 .init_irq = at91_init_irq_default,
217 .init_machine = afeb9260_board_init, 219 .init_machine = afeb9260_board_init,
diff --git a/arch/arm/mach-at91/board-cam60.c b/arch/arm/mach-at91/board-cam60.c
index 29d3ef0a50f..477e708497b 100644
--- a/arch/arm/mach-at91/board-cam60.c
+++ b/arch/arm/mach-at91/board-cam60.c
@@ -39,6 +39,7 @@
39#include <asm/mach/irq.h> 39#include <asm/mach/irq.h>
40 40
41#include <mach/board.h> 41#include <mach/board.h>
42#include <mach/at91_aic.h>
42#include <mach/at91sam9_smc.h> 43#include <mach/at91sam9_smc.h>
43 44
44#include "sam9_smc.h" 45#include "sam9_smc.h"
@@ -188,6 +189,7 @@ MACHINE_START(CAM60, "KwikByte CAM60")
188 /* Maintainer: KwikByte */ 189 /* Maintainer: KwikByte */
189 .timer = &at91sam926x_timer, 190 .timer = &at91sam926x_timer,
190 .map_io = at91_map_io, 191 .map_io = at91_map_io,
192 .handle_irq = at91_aic_handle_irq,
191 .init_early = cam60_init_early, 193 .init_early = cam60_init_early,
192 .init_irq = at91_init_irq_default, 194 .init_irq = at91_init_irq_default,
193 .init_machine = cam60_board_init, 195 .init_machine = cam60_board_init,
diff --git a/arch/arm/mach-at91/board-carmeva.c b/arch/arm/mach-at91/board-carmeva.c
index 44328a6d460..a5b002f32a6 100644
--- a/arch/arm/mach-at91/board-carmeva.c
+++ b/arch/arm/mach-at91/board-carmeva.c
@@ -36,6 +36,7 @@
36 36
37#include <mach/hardware.h> 37#include <mach/hardware.h>
38#include <mach/board.h> 38#include <mach/board.h>
39#include <mach/at91_aic.h>
39 40
40#include "generic.h" 41#include "generic.h"
41 42
@@ -158,6 +159,7 @@ MACHINE_START(CARMEVA, "Carmeva")
158 /* Maintainer: Conitec Datasystems */ 159 /* Maintainer: Conitec Datasystems */
159 .timer = &at91rm9200_timer, 160 .timer = &at91rm9200_timer,
160 .map_io = at91_map_io, 161 .map_io = at91_map_io,
162 .handle_irq = at91_aic_handle_irq,
161 .init_early = carmeva_init_early, 163 .init_early = carmeva_init_early,
162 .init_irq = at91_init_irq_default, 164 .init_irq = at91_init_irq_default,
163 .init_machine = carmeva_board_init, 165 .init_machine = carmeva_board_init,
diff --git a/arch/arm/mach-at91/board-cpu9krea.c b/arch/arm/mach-at91/board-cpu9krea.c
index 69951ec7dbf..ecbc13b594d 100644
--- a/arch/arm/mach-at91/board-cpu9krea.c
+++ b/arch/arm/mach-at91/board-cpu9krea.c
@@ -41,6 +41,7 @@
41 41
42#include <mach/hardware.h> 42#include <mach/hardware.h>
43#include <mach/board.h> 43#include <mach/board.h>
44#include <mach/at91_aic.h>
44#include <mach/at91sam9_smc.h> 45#include <mach/at91sam9_smc.h>
45#include <mach/at91sam9260_matrix.h> 46#include <mach/at91sam9260_matrix.h>
46#include <mach/at91_matrix.h> 47#include <mach/at91_matrix.h>
@@ -376,6 +377,7 @@ MACHINE_START(CPUAT9G20, "Eukrea CPU9G20")
376 /* Maintainer: Eric Benard - EUKREA Electromatique */ 377 /* Maintainer: Eric Benard - EUKREA Electromatique */
377 .timer = &at91sam926x_timer, 378 .timer = &at91sam926x_timer,
378 .map_io = at91_map_io, 379 .map_io = at91_map_io,
380 .handle_irq = at91_aic_handle_irq,
379 .init_early = cpu9krea_init_early, 381 .init_early = cpu9krea_init_early,
380 .init_irq = at91_init_irq_default, 382 .init_irq = at91_init_irq_default,
381 .init_machine = cpu9krea_board_init, 383 .init_machine = cpu9krea_board_init,
diff --git a/arch/arm/mach-at91/board-cpuat91.c b/arch/arm/mach-at91/board-cpuat91.c
index 895cf2dba61..2e6d043c82f 100644
--- a/arch/arm/mach-at91/board-cpuat91.c
+++ b/arch/arm/mach-at91/board-cpuat91.c
@@ -37,6 +37,7 @@
37#include <asm/mach/irq.h> 37#include <asm/mach/irq.h>
38 38
39#include <mach/board.h> 39#include <mach/board.h>
40#include <mach/at91_aic.h>
40#include <mach/at91rm9200_mc.h> 41#include <mach/at91rm9200_mc.h>
41#include <mach/at91_ramc.h> 42#include <mach/at91_ramc.h>
42#include <mach/cpu.h> 43#include <mach/cpu.h>
@@ -178,6 +179,7 @@ MACHINE_START(CPUAT91, "Eukrea")
178 /* Maintainer: Eric Benard - EUKREA Electromatique */ 179 /* Maintainer: Eric Benard - EUKREA Electromatique */
179 .timer = &at91rm9200_timer, 180 .timer = &at91rm9200_timer,
180 .map_io = at91_map_io, 181 .map_io = at91_map_io,
182 .handle_irq = at91_aic_handle_irq,
181 .init_early = cpuat91_init_early, 183 .init_early = cpuat91_init_early,
182 .init_irq = at91_init_irq_default, 184 .init_irq = at91_init_irq_default,
183 .init_machine = cpuat91_board_init, 185 .init_machine = cpuat91_board_init,
diff --git a/arch/arm/mach-at91/board-csb337.c b/arch/arm/mach-at91/board-csb337.c
index cd813361cd2..462bc319cbc 100644
--- a/arch/arm/mach-at91/board-csb337.c
+++ b/arch/arm/mach-at91/board-csb337.c
@@ -39,6 +39,7 @@
39 39
40#include <mach/hardware.h> 40#include <mach/hardware.h>
41#include <mach/board.h> 41#include <mach/board.h>
42#include <mach/at91_aic.h>
42 43
43#include "generic.h" 44#include "generic.h"
44 45
@@ -252,6 +253,7 @@ MACHINE_START(CSB337, "Cogent CSB337")
252 /* Maintainer: Bill Gatliff */ 253 /* Maintainer: Bill Gatliff */
253 .timer = &at91rm9200_timer, 254 .timer = &at91rm9200_timer,
254 .map_io = at91_map_io, 255 .map_io = at91_map_io,
256 .handle_irq = at91_aic_handle_irq,
255 .init_early = csb337_init_early, 257 .init_early = csb337_init_early,
256 .init_irq = at91_init_irq_default, 258 .init_irq = at91_init_irq_default,
257 .init_machine = csb337_board_init, 259 .init_machine = csb337_board_init,
diff --git a/arch/arm/mach-at91/board-csb637.c b/arch/arm/mach-at91/board-csb637.c
index 7c8b05a57d7..872871ab116 100644
--- a/arch/arm/mach-at91/board-csb637.c
+++ b/arch/arm/mach-at91/board-csb637.c
@@ -36,6 +36,7 @@
36 36
37#include <mach/hardware.h> 37#include <mach/hardware.h>
38#include <mach/board.h> 38#include <mach/board.h>
39#include <mach/at91_aic.h>
39 40
40#include "generic.h" 41#include "generic.h"
41 42
@@ -133,6 +134,7 @@ MACHINE_START(CSB637, "Cogent CSB637")
133 /* Maintainer: Bill Gatliff */ 134 /* Maintainer: Bill Gatliff */
134 .timer = &at91rm9200_timer, 135 .timer = &at91rm9200_timer,
135 .map_io = at91_map_io, 136 .map_io = at91_map_io,
137 .handle_irq = at91_aic_handle_irq,
136 .init_early = csb637_init_early, 138 .init_early = csb637_init_early,
137 .init_irq = at91_init_irq_default, 139 .init_irq = at91_init_irq_default,
138 .init_machine = csb637_board_init, 140 .init_machine = csb637_board_init,
diff --git a/arch/arm/mach-at91/board-dt.c b/arch/arm/mach-at91/board-dt.c
index a1fce05aa7a..e8f45c4e0ea 100644
--- a/arch/arm/mach-at91/board-dt.c
+++ b/arch/arm/mach-at91/board-dt.c
@@ -16,6 +16,7 @@
16#include <linux/of_platform.h> 16#include <linux/of_platform.h>
17 17
18#include <mach/board.h> 18#include <mach/board.h>
19#include <mach/at91_aic.h>
19 20
20#include <asm/setup.h> 21#include <asm/setup.h>
21#include <asm/irq.h> 22#include <asm/irq.h>
@@ -53,6 +54,7 @@ DT_MACHINE_START(at91sam_dt, "Atmel AT91SAM (Device Tree)")
53 /* Maintainer: Atmel */ 54 /* Maintainer: Atmel */
54 .timer = &at91sam926x_timer, 55 .timer = &at91sam926x_timer,
55 .map_io = at91_map_io, 56 .map_io = at91_map_io,
57 .handle_irq = at91_aic_handle_irq,
56 .init_early = at91_dt_initialize, 58 .init_early = at91_dt_initialize,
57 .init_irq = at91_dt_init_irq, 59 .init_irq = at91_dt_init_irq,
58 .init_machine = at91_dt_device_init, 60 .init_machine = at91_dt_device_init,
diff --git a/arch/arm/mach-at91/board-eb01.c b/arch/arm/mach-at91/board-eb01.c
index d2023f27c65..01f66e99ece 100644
--- a/arch/arm/mach-at91/board-eb01.c
+++ b/arch/arm/mach-at91/board-eb01.c
@@ -28,6 +28,7 @@
28#include <asm/mach/arch.h> 28#include <asm/mach/arch.h>
29#include <asm/mach/map.h> 29#include <asm/mach/map.h>
30#include <mach/board.h> 30#include <mach/board.h>
31#include <mach/at91_aic.h>
31#include "generic.h" 32#include "generic.h"
32 33
33static void __init at91eb01_init_irq(void) 34static void __init at91eb01_init_irq(void)
@@ -43,6 +44,7 @@ static void __init at91eb01_init_early(void)
43MACHINE_START(AT91EB01, "Atmel AT91 EB01") 44MACHINE_START(AT91EB01, "Atmel AT91 EB01")
44 /* Maintainer: Greg Ungerer <gerg@snapgear.com> */ 45 /* Maintainer: Greg Ungerer <gerg@snapgear.com> */
45 .timer = &at91x40_timer, 46 .timer = &at91x40_timer,
47 .handle_irq = at91_aic_handle_irq,
46 .init_early = at91eb01_init_early, 48 .init_early = at91eb01_init_early,
47 .init_irq = at91eb01_init_irq, 49 .init_irq = at91eb01_init_irq,
48MACHINE_END 50MACHINE_END
diff --git a/arch/arm/mach-at91/board-eb9200.c b/arch/arm/mach-at91/board-eb9200.c
index bd101729798..d1e1f3fc0a4 100644
--- a/arch/arm/mach-at91/board-eb9200.c
+++ b/arch/arm/mach-at91/board-eb9200.c
@@ -36,6 +36,7 @@
36#include <asm/mach/irq.h> 36#include <asm/mach/irq.h>
37 37
38#include <mach/board.h> 38#include <mach/board.h>
39#include <mach/at91_aic.h>
39 40
40#include "generic.h" 41#include "generic.h"
41 42
@@ -118,6 +119,7 @@ static void __init eb9200_board_init(void)
118MACHINE_START(ATEB9200, "Embest ATEB9200") 119MACHINE_START(ATEB9200, "Embest ATEB9200")
119 .timer = &at91rm9200_timer, 120 .timer = &at91rm9200_timer,
120 .map_io = at91_map_io, 121 .map_io = at91_map_io,
122 .handle_irq = at91_aic_handle_irq,
121 .init_early = eb9200_init_early, 123 .init_early = eb9200_init_early,
122 .init_irq = at91_init_irq_default, 124 .init_irq = at91_init_irq_default,
123 .init_machine = eb9200_board_init, 125 .init_machine = eb9200_board_init,
diff --git a/arch/arm/mach-at91/board-ecbat91.c b/arch/arm/mach-at91/board-ecbat91.c
index 89cc3726a9c..9c24cb25707 100644
--- a/arch/arm/mach-at91/board-ecbat91.c
+++ b/arch/arm/mach-at91/board-ecbat91.c
@@ -39,6 +39,7 @@
39 39
40#include <mach/board.h> 40#include <mach/board.h>
41#include <mach/cpu.h> 41#include <mach/cpu.h>
42#include <mach/at91_aic.h>
42 43
43#include "generic.h" 44#include "generic.h"
44 45
@@ -170,6 +171,7 @@ MACHINE_START(ECBAT91, "emQbit's ECB_AT91")
170 /* Maintainer: emQbit.com */ 171 /* Maintainer: emQbit.com */
171 .timer = &at91rm9200_timer, 172 .timer = &at91rm9200_timer,
172 .map_io = at91_map_io, 173 .map_io = at91_map_io,
174 .handle_irq = at91_aic_handle_irq,
173 .init_early = ecb_at91init_early, 175 .init_early = ecb_at91init_early,
174 .init_irq = at91_init_irq_default, 176 .init_irq = at91_init_irq_default,
175 .init_machine = ecb_at91board_init, 177 .init_machine = ecb_at91board_init,
diff --git a/arch/arm/mach-at91/board-eco920.c b/arch/arm/mach-at91/board-eco920.c
index 558546cf63f..82bdfde3405 100644
--- a/arch/arm/mach-at91/board-eco920.c
+++ b/arch/arm/mach-at91/board-eco920.c
@@ -25,6 +25,7 @@
25#include <asm/mach/map.h> 25#include <asm/mach/map.h>
26 26
27#include <mach/board.h> 27#include <mach/board.h>
28#include <mach/at91_aic.h>
28#include <mach/at91rm9200_mc.h> 29#include <mach/at91rm9200_mc.h>
29#include <mach/at91_ramc.h> 30#include <mach/at91_ramc.h>
30#include <mach/cpu.h> 31#include <mach/cpu.h>
@@ -132,6 +133,7 @@ MACHINE_START(ECO920, "eco920")
132 /* Maintainer: Sascha Hauer */ 133 /* Maintainer: Sascha Hauer */
133 .timer = &at91rm9200_timer, 134 .timer = &at91rm9200_timer,
134 .map_io = at91_map_io, 135 .map_io = at91_map_io,
136 .handle_irq = at91_aic_handle_irq,
135 .init_early = eco920_init_early, 137 .init_early = eco920_init_early,
136 .init_irq = at91_init_irq_default, 138 .init_irq = at91_init_irq_default,
137 .init_machine = eco920_board_init, 139 .init_machine = eco920_board_init,
diff --git a/arch/arm/mach-at91/board-flexibity.c b/arch/arm/mach-at91/board-flexibity.c
index 47658f78105..6cc83a87d77 100644
--- a/arch/arm/mach-at91/board-flexibity.c
+++ b/arch/arm/mach-at91/board-flexibity.c
@@ -34,6 +34,7 @@
34 34
35#include <mach/hardware.h> 35#include <mach/hardware.h>
36#include <mach/board.h> 36#include <mach/board.h>
37#include <mach/at91_aic.h>
37 38
38#include "generic.h" 39#include "generic.h"
39 40
@@ -160,6 +161,7 @@ MACHINE_START(FLEXIBITY, "Flexibity Connect")
160 /* Maintainer: Maxim Osipov */ 161 /* Maintainer: Maxim Osipov */
161 .timer = &at91sam926x_timer, 162 .timer = &at91sam926x_timer,
162 .map_io = at91_map_io, 163 .map_io = at91_map_io,
164 .handle_irq = at91_aic_handle_irq,
163 .init_early = flexibity_init_early, 165 .init_early = flexibity_init_early,
164 .init_irq = at91_init_irq_default, 166 .init_irq = at91_init_irq_default,
165 .init_machine = flexibity_board_init, 167 .init_machine = flexibity_board_init,
diff --git a/arch/arm/mach-at91/board-foxg20.c b/arch/arm/mach-at91/board-foxg20.c
index 33411e6ecb1..69ab1247ef8 100644
--- a/arch/arm/mach-at91/board-foxg20.c
+++ b/arch/arm/mach-at91/board-foxg20.c
@@ -42,6 +42,7 @@
42#include <asm/mach/irq.h> 42#include <asm/mach/irq.h>
43 43
44#include <mach/board.h> 44#include <mach/board.h>
45#include <mach/at91_aic.h>
45#include <mach/at91sam9_smc.h> 46#include <mach/at91sam9_smc.h>
46 47
47#include "sam9_smc.h" 48#include "sam9_smc.h"
@@ -262,6 +263,7 @@ MACHINE_START(ACMENETUSFOXG20, "Acme Systems srl FOX Board G20")
262 /* Maintainer: Sergio Tanzilli */ 263 /* Maintainer: Sergio Tanzilli */
263 .timer = &at91sam926x_timer, 264 .timer = &at91sam926x_timer,
264 .map_io = at91_map_io, 265 .map_io = at91_map_io,
266 .handle_irq = at91_aic_handle_irq,
265 .init_early = foxg20_init_early, 267 .init_early = foxg20_init_early,
266 .init_irq = at91_init_irq_default, 268 .init_irq = at91_init_irq_default,
267 .init_machine = foxg20_board_init, 269 .init_machine = foxg20_board_init,
diff --git a/arch/arm/mach-at91/board-gsia18s.c b/arch/arm/mach-at91/board-gsia18s.c
index 3e0dfa643a8..a9d5e78118c 100644
--- a/arch/arm/mach-at91/board-gsia18s.c
+++ b/arch/arm/mach-at91/board-gsia18s.c
@@ -31,6 +31,7 @@
31#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
32 32
33#include <mach/board.h> 33#include <mach/board.h>
34#include <mach/at91_aic.h>
34#include <mach/at91sam9_smc.h> 35#include <mach/at91sam9_smc.h>
35#include <mach/gsia18s.h> 36#include <mach/gsia18s.h>
36#include <mach/stamp9g20.h> 37#include <mach/stamp9g20.h>
@@ -575,6 +576,7 @@ static void __init gsia18s_board_init(void)
575MACHINE_START(GSIA18S, "GS_IA18_S") 576MACHINE_START(GSIA18S, "GS_IA18_S")
576 .timer = &at91sam926x_timer, 577 .timer = &at91sam926x_timer,
577 .map_io = at91_map_io, 578 .map_io = at91_map_io,
579 .handle_irq = at91_aic_handle_irq,
578 .init_early = gsia18s_init_early, 580 .init_early = gsia18s_init_early,
579 .init_irq = at91_init_irq_default, 581 .init_irq = at91_init_irq_default,
580 .init_machine = gsia18s_board_init, 582 .init_machine = gsia18s_board_init,
diff --git a/arch/arm/mach-at91/board-kafa.c b/arch/arm/mach-at91/board-kafa.c
index f260657f32b..64c1dbf88a0 100644
--- a/arch/arm/mach-at91/board-kafa.c
+++ b/arch/arm/mach-at91/board-kafa.c
@@ -35,6 +35,7 @@
35#include <asm/mach/irq.h> 35#include <asm/mach/irq.h>
36 36
37#include <mach/board.h> 37#include <mach/board.h>
38#include <mach/at91_aic.h>
38#include <mach/cpu.h> 39#include <mach/cpu.h>
39 40
40#include "generic.h" 41#include "generic.h"
@@ -93,6 +94,7 @@ MACHINE_START(KAFA, "Sperry-Sun KAFA")
93 /* Maintainer: Sergei Sharonov */ 94 /* Maintainer: Sergei Sharonov */
94 .timer = &at91rm9200_timer, 95 .timer = &at91rm9200_timer,
95 .map_io = at91_map_io, 96 .map_io = at91_map_io,
97 .handle_irq = at91_aic_handle_irq,
96 .init_early = kafa_init_early, 98 .init_early = kafa_init_early,
97 .init_irq = at91_init_irq_default, 99 .init_irq = at91_init_irq_default,
98 .init_machine = kafa_board_init, 100 .init_machine = kafa_board_init,
diff --git a/arch/arm/mach-at91/board-kb9202.c b/arch/arm/mach-at91/board-kb9202.c
index ba39db5482b..5d96cb85175 100644
--- a/arch/arm/mach-at91/board-kb9202.c
+++ b/arch/arm/mach-at91/board-kb9202.c
@@ -37,6 +37,7 @@
37 37
38#include <mach/board.h> 38#include <mach/board.h>
39#include <mach/cpu.h> 39#include <mach/cpu.h>
40#include <mach/at91_aic.h>
40#include <mach/at91rm9200_mc.h> 41#include <mach/at91rm9200_mc.h>
41#include <mach/at91_ramc.h> 42#include <mach/at91_ramc.h>
42 43
@@ -133,6 +134,7 @@ MACHINE_START(KB9200, "KB920x")
133 /* Maintainer: KwikByte, Inc. */ 134 /* Maintainer: KwikByte, Inc. */
134 .timer = &at91rm9200_timer, 135 .timer = &at91rm9200_timer,
135 .map_io = at91_map_io, 136 .map_io = at91_map_io,
137 .handle_irq = at91_aic_handle_irq,
136 .init_early = kb9202_init_early, 138 .init_early = kb9202_init_early,
137 .init_irq = at91_init_irq_default, 139 .init_irq = at91_init_irq_default,
138 .init_machine = kb9202_board_init, 140 .init_machine = kb9202_board_init,
diff --git a/arch/arm/mach-at91/board-neocore926.c b/arch/arm/mach-at91/board-neocore926.c
index d2f4cc16176..18103c5d993 100644
--- a/arch/arm/mach-at91/board-neocore926.c
+++ b/arch/arm/mach-at91/board-neocore926.c
@@ -45,6 +45,7 @@
45 45
46#include <mach/hardware.h> 46#include <mach/hardware.h>
47#include <mach/board.h> 47#include <mach/board.h>
48#include <mach/at91_aic.h>
48#include <mach/at91sam9_smc.h> 49#include <mach/at91sam9_smc.h>
49 50
50#include "sam9_smc.h" 51#include "sam9_smc.h"
@@ -378,6 +379,7 @@ MACHINE_START(NEOCORE926, "ADENEO NEOCORE 926")
378 /* Maintainer: ADENEO */ 379 /* Maintainer: ADENEO */
379 .timer = &at91sam926x_timer, 380 .timer = &at91sam926x_timer,
380 .map_io = at91_map_io, 381 .map_io = at91_map_io,
382 .handle_irq = at91_aic_handle_irq,
381 .init_early = neocore926_init_early, 383 .init_early = neocore926_init_early,
382 .init_irq = at91_init_irq_default, 384 .init_irq = at91_init_irq_default,
383 .init_machine = neocore926_board_init, 385 .init_machine = neocore926_board_init,
diff --git a/arch/arm/mach-at91/board-pcontrol-g20.c b/arch/arm/mach-at91/board-pcontrol-g20.c
index 7fe63834242..9ca3e32c54c 100644
--- a/arch/arm/mach-at91/board-pcontrol-g20.c
+++ b/arch/arm/mach-at91/board-pcontrol-g20.c
@@ -30,6 +30,7 @@
30#include <asm/mach/arch.h> 30#include <asm/mach/arch.h>
31 31
32#include <mach/board.h> 32#include <mach/board.h>
33#include <mach/at91_aic.h>
33#include <mach/at91sam9_smc.h> 34#include <mach/at91sam9_smc.h>
34#include <mach/stamp9g20.h> 35#include <mach/stamp9g20.h>
35 36
@@ -218,6 +219,7 @@ MACHINE_START(PCONTROL_G20, "PControl G20")
218 /* Maintainer: pgsellmann@portner-elektronik.at */ 219 /* Maintainer: pgsellmann@portner-elektronik.at */
219 .timer = &at91sam926x_timer, 220 .timer = &at91sam926x_timer,
220 .map_io = at91_map_io, 221 .map_io = at91_map_io,
222 .handle_irq = at91_aic_handle_irq,
221 .init_early = pcontrol_g20_init_early, 223 .init_early = pcontrol_g20_init_early,
222 .init_irq = at91_init_irq_default, 224 .init_irq = at91_init_irq_default,
223 .init_machine = pcontrol_g20_board_init, 225 .init_machine = pcontrol_g20_board_init,
diff --git a/arch/arm/mach-at91/board-picotux200.c b/arch/arm/mach-at91/board-picotux200.c
index b45c0a5d5ca..12706550450 100644
--- a/arch/arm/mach-at91/board-picotux200.c
+++ b/arch/arm/mach-at91/board-picotux200.c
@@ -38,6 +38,7 @@
38#include <asm/mach/irq.h> 38#include <asm/mach/irq.h>
39 39
40#include <mach/board.h> 40#include <mach/board.h>
41#include <mach/at91_aic.h>
41#include <mach/at91rm9200_mc.h> 42#include <mach/at91rm9200_mc.h>
42#include <mach/at91_ramc.h> 43#include <mach/at91_ramc.h>
43 44
@@ -120,6 +121,7 @@ MACHINE_START(PICOTUX2XX, "picotux 200")
120 /* Maintainer: Kleinhenz Elektronik GmbH */ 121 /* Maintainer: Kleinhenz Elektronik GmbH */
121 .timer = &at91rm9200_timer, 122 .timer = &at91rm9200_timer,
122 .map_io = at91_map_io, 123 .map_io = at91_map_io,
124 .handle_irq = at91_aic_handle_irq,
123 .init_early = picotux200_init_early, 125 .init_early = picotux200_init_early,
124 .init_irq = at91_init_irq_default, 126 .init_irq = at91_init_irq_default,
125 .init_machine = picotux200_board_init, 127 .init_machine = picotux200_board_init,
diff --git a/arch/arm/mach-at91/board-qil-a9260.c b/arch/arm/mach-at91/board-qil-a9260.c
index 0c61bf0d272..bf351e28542 100644
--- a/arch/arm/mach-at91/board-qil-a9260.c
+++ b/arch/arm/mach-at91/board-qil-a9260.c
@@ -41,6 +41,7 @@
41 41
42#include <mach/hardware.h> 42#include <mach/hardware.h>
43#include <mach/board.h> 43#include <mach/board.h>
44#include <mach/at91_aic.h>
44#include <mach/at91sam9_smc.h> 45#include <mach/at91sam9_smc.h>
45#include <mach/at91_shdwc.h> 46#include <mach/at91_shdwc.h>
46 47
@@ -258,6 +259,7 @@ MACHINE_START(QIL_A9260, "CALAO QIL_A9260")
258 /* Maintainer: calao-systems */ 259 /* Maintainer: calao-systems */
259 .timer = &at91sam926x_timer, 260 .timer = &at91sam926x_timer,
260 .map_io = at91_map_io, 261 .map_io = at91_map_io,
262 .handle_irq = at91_aic_handle_irq,
261 .init_early = ek_init_early, 263 .init_early = ek_init_early,
262 .init_irq = at91_init_irq_default, 264 .init_irq = at91_init_irq_default,
263 .init_machine = ek_board_init, 265 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-rm9200dk.c b/arch/arm/mach-at91/board-rm9200dk.c
index afd7a471376..cc2bf979607 100644
--- a/arch/arm/mach-at91/board-rm9200dk.c
+++ b/arch/arm/mach-at91/board-rm9200dk.c
@@ -40,6 +40,7 @@
40 40
41#include <mach/hardware.h> 41#include <mach/hardware.h>
42#include <mach/board.h> 42#include <mach/board.h>
43#include <mach/at91_aic.h>
43#include <mach/at91rm9200_mc.h> 44#include <mach/at91rm9200_mc.h>
44#include <mach/at91_ramc.h> 45#include <mach/at91_ramc.h>
45 46
@@ -223,6 +224,7 @@ MACHINE_START(AT91RM9200DK, "Atmel AT91RM9200-DK")
223 /* Maintainer: SAN People/Atmel */ 224 /* Maintainer: SAN People/Atmel */
224 .timer = &at91rm9200_timer, 225 .timer = &at91rm9200_timer,
225 .map_io = at91_map_io, 226 .map_io = at91_map_io,
227 .handle_irq = at91_aic_handle_irq,
226 .init_early = dk_init_early, 228 .init_early = dk_init_early,
227 .init_irq = at91_init_irq_default, 229 .init_irq = at91_init_irq_default,
228 .init_machine = dk_board_init, 230 .init_machine = dk_board_init,
diff --git a/arch/arm/mach-at91/board-rm9200ek.c b/arch/arm/mach-at91/board-rm9200ek.c
index 2b15b8adec4..62e19e64c9d 100644
--- a/arch/arm/mach-at91/board-rm9200ek.c
+++ b/arch/arm/mach-at91/board-rm9200ek.c
@@ -40,6 +40,7 @@
40 40
41#include <mach/hardware.h> 41#include <mach/hardware.h>
42#include <mach/board.h> 42#include <mach/board.h>
43#include <mach/at91_aic.h>
43#include <mach/at91rm9200_mc.h> 44#include <mach/at91rm9200_mc.h>
44#include <mach/at91_ramc.h> 45#include <mach/at91_ramc.h>
45 46
@@ -190,6 +191,7 @@ MACHINE_START(AT91RM9200EK, "Atmel AT91RM9200-EK")
190 /* Maintainer: SAN People/Atmel */ 191 /* Maintainer: SAN People/Atmel */
191 .timer = &at91rm9200_timer, 192 .timer = &at91rm9200_timer,
192 .map_io = at91_map_io, 193 .map_io = at91_map_io,
194 .handle_irq = at91_aic_handle_irq,
193 .init_early = ek_init_early, 195 .init_early = ek_init_early,
194 .init_irq = at91_init_irq_default, 196 .init_irq = at91_init_irq_default,
195 .init_machine = ek_board_init, 197 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-rsi-ews.c b/arch/arm/mach-at91/board-rsi-ews.c
index 24ab9be7510..c3b43aefdb7 100644
--- a/arch/arm/mach-at91/board-rsi-ews.c
+++ b/arch/arm/mach-at91/board-rsi-ews.c
@@ -26,6 +26,7 @@
26 26
27#include <mach/hardware.h> 27#include <mach/hardware.h>
28#include <mach/board.h> 28#include <mach/board.h>
29#include <mach/at91_aic.h>
29 30
30#include <linux/gpio.h> 31#include <linux/gpio.h>
31 32
@@ -225,6 +226,7 @@ MACHINE_START(RSI_EWS, "RSI EWS")
225 /* Maintainer: Josef Holzmayr <holzmayr@rsi-elektrotechnik.de> */ 226 /* Maintainer: Josef Holzmayr <holzmayr@rsi-elektrotechnik.de> */
226 .timer = &at91rm9200_timer, 227 .timer = &at91rm9200_timer,
227 .map_io = at91_map_io, 228 .map_io = at91_map_io,
229 .handle_irq = at91_aic_handle_irq,
228 .init_early = rsi_ews_init_early, 230 .init_early = rsi_ews_init_early,
229 .init_irq = at91_init_irq_default, 231 .init_irq = at91_init_irq_default,
230 .init_machine = rsi_ews_board_init, 232 .init_machine = rsi_ews_board_init,
diff --git a/arch/arm/mach-at91/board-sam9-l9260.c b/arch/arm/mach-at91/board-sam9-l9260.c
index cdd21f2595d..7bf6da70d7d 100644
--- a/arch/arm/mach-at91/board-sam9-l9260.c
+++ b/arch/arm/mach-at91/board-sam9-l9260.c
@@ -38,6 +38,7 @@
38#include <asm/mach/irq.h> 38#include <asm/mach/irq.h>
39 39
40#include <mach/board.h> 40#include <mach/board.h>
41#include <mach/at91_aic.h>
41#include <mach/at91sam9_smc.h> 42#include <mach/at91sam9_smc.h>
42 43
43#include "sam9_smc.h" 44#include "sam9_smc.h"
@@ -202,6 +203,7 @@ MACHINE_START(SAM9_L9260, "Olimex SAM9-L9260")
202 /* Maintainer: Olimex */ 203 /* Maintainer: Olimex */
203 .timer = &at91sam926x_timer, 204 .timer = &at91sam926x_timer,
204 .map_io = at91_map_io, 205 .map_io = at91_map_io,
206 .handle_irq = at91_aic_handle_irq,
205 .init_early = ek_init_early, 207 .init_early = ek_init_early,
206 .init_irq = at91_init_irq_default, 208 .init_irq = at91_init_irq_default,
207 .init_machine = ek_board_init, 209 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-sam9260ek.c b/arch/arm/mach-at91/board-sam9260ek.c
index 7b3c3913551..889c1bf71eb 100644
--- a/arch/arm/mach-at91/board-sam9260ek.c
+++ b/arch/arm/mach-at91/board-sam9260ek.c
@@ -42,6 +42,7 @@
42 42
43#include <mach/hardware.h> 43#include <mach/hardware.h>
44#include <mach/board.h> 44#include <mach/board.h>
45#include <mach/at91_aic.h>
45#include <mach/at91sam9_smc.h> 46#include <mach/at91sam9_smc.h>
46#include <mach/at91_shdwc.h> 47#include <mach/at91_shdwc.h>
47#include <mach/system_rev.h> 48#include <mach/system_rev.h>
@@ -344,6 +345,7 @@ MACHINE_START(AT91SAM9260EK, "Atmel AT91SAM9260-EK")
344 /* Maintainer: Atmel */ 345 /* Maintainer: Atmel */
345 .timer = &at91sam926x_timer, 346 .timer = &at91sam926x_timer,
346 .map_io = at91_map_io, 347 .map_io = at91_map_io,
348 .handle_irq = at91_aic_handle_irq,
347 .init_early = ek_init_early, 349 .init_early = ek_init_early,
348 .init_irq = at91_init_irq_default, 350 .init_irq = at91_init_irq_default,
349 .init_machine = ek_board_init, 351 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-sam9261ek.c b/arch/arm/mach-at91/board-sam9261ek.c
index 2736453821b..2269be5fa38 100644
--- a/arch/arm/mach-at91/board-sam9261ek.c
+++ b/arch/arm/mach-at91/board-sam9261ek.c
@@ -46,6 +46,7 @@
46 46
47#include <mach/hardware.h> 47#include <mach/hardware.h>
48#include <mach/board.h> 48#include <mach/board.h>
49#include <mach/at91_aic.h>
49#include <mach/at91sam9_smc.h> 50#include <mach/at91sam9_smc.h>
50#include <mach/at91_shdwc.h> 51#include <mach/at91_shdwc.h>
51#include <mach/system_rev.h> 52#include <mach/system_rev.h>
@@ -615,6 +616,7 @@ MACHINE_START(AT91SAM9G10EK, "Atmel AT91SAM9G10-EK")
615 /* Maintainer: Atmel */ 616 /* Maintainer: Atmel */
616 .timer = &at91sam926x_timer, 617 .timer = &at91sam926x_timer,
617 .map_io = at91_map_io, 618 .map_io = at91_map_io,
619 .handle_irq = at91_aic_handle_irq,
618 .init_early = ek_init_early, 620 .init_early = ek_init_early,
619 .init_irq = at91_init_irq_default, 621 .init_irq = at91_init_irq_default,
620 .init_machine = ek_board_init, 622 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-sam9263ek.c b/arch/arm/mach-at91/board-sam9263ek.c
index 983cb98d246..82adf581afc 100644
--- a/arch/arm/mach-at91/board-sam9263ek.c
+++ b/arch/arm/mach-at91/board-sam9263ek.c
@@ -45,6 +45,7 @@
45 45
46#include <mach/hardware.h> 46#include <mach/hardware.h>
47#include <mach/board.h> 47#include <mach/board.h>
48#include <mach/at91_aic.h>
48#include <mach/at91sam9_smc.h> 49#include <mach/at91sam9_smc.h>
49#include <mach/at91_shdwc.h> 50#include <mach/at91_shdwc.h>
50#include <mach/system_rev.h> 51#include <mach/system_rev.h>
@@ -443,6 +444,7 @@ MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK")
443 /* Maintainer: Atmel */ 444 /* Maintainer: Atmel */
444 .timer = &at91sam926x_timer, 445 .timer = &at91sam926x_timer,
445 .map_io = at91_map_io, 446 .map_io = at91_map_io,
447 .handle_irq = at91_aic_handle_irq,
446 .init_early = ek_init_early, 448 .init_early = ek_init_early,
447 .init_irq = at91_init_irq_default, 449 .init_irq = at91_init_irq_default,
448 .init_machine = ek_board_init, 450 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-sam9g20ek.c b/arch/arm/mach-at91/board-sam9g20ek.c
index 6860d345110..4ea4ee00364 100644
--- a/arch/arm/mach-at91/board-sam9g20ek.c
+++ b/arch/arm/mach-at91/board-sam9g20ek.c
@@ -44,6 +44,7 @@
44#include <asm/mach/irq.h> 44#include <asm/mach/irq.h>
45 45
46#include <mach/board.h> 46#include <mach/board.h>
47#include <mach/at91_aic.h>
47#include <mach/at91sam9_smc.h> 48#include <mach/at91sam9_smc.h>
48#include <mach/system_rev.h> 49#include <mach/system_rev.h>
49 50
@@ -413,6 +414,7 @@ MACHINE_START(AT91SAM9G20EK, "Atmel AT91SAM9G20-EK")
413 /* Maintainer: Atmel */ 414 /* Maintainer: Atmel */
414 .timer = &at91sam926x_timer, 415 .timer = &at91sam926x_timer,
415 .map_io = at91_map_io, 416 .map_io = at91_map_io,
417 .handle_irq = at91_aic_handle_irq,
416 .init_early = ek_init_early, 418 .init_early = ek_init_early,
417 .init_irq = at91_init_irq_default, 419 .init_irq = at91_init_irq_default,
418 .init_machine = ek_board_init, 420 .init_machine = ek_board_init,
@@ -422,6 +424,7 @@ MACHINE_START(AT91SAM9G20EK_2MMC, "Atmel AT91SAM9G20-EK 2 MMC Slot Mod")
422 /* Maintainer: Atmel */ 424 /* Maintainer: Atmel */
423 .timer = &at91sam926x_timer, 425 .timer = &at91sam926x_timer,
424 .map_io = at91_map_io, 426 .map_io = at91_map_io,
427 .handle_irq = at91_aic_handle_irq,
425 .init_early = ek_init_early, 428 .init_early = ek_init_early,
426 .init_irq = at91_init_irq_default, 429 .init_irq = at91_init_irq_default,
427 .init_machine = ek_board_init, 430 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-sam9m10g45ek.c b/arch/arm/mach-at91/board-sam9m10g45ek.c
index 63163dc7df4..3d48ec15468 100644
--- a/arch/arm/mach-at91/board-sam9m10g45ek.c
+++ b/arch/arm/mach-at91/board-sam9m10g45ek.c
@@ -43,6 +43,7 @@
43#include <asm/mach/irq.h> 43#include <asm/mach/irq.h>
44 44
45#include <mach/board.h> 45#include <mach/board.h>
46#include <mach/at91_aic.h>
46#include <mach/at91sam9_smc.h> 47#include <mach/at91sam9_smc.h>
47#include <mach/at91_shdwc.h> 48#include <mach/at91_shdwc.h>
48#include <mach/system_rev.h> 49#include <mach/system_rev.h>
@@ -503,6 +504,7 @@ MACHINE_START(AT91SAM9M10G45EK, "Atmel AT91SAM9M10G45-EK")
503 /* Maintainer: Atmel */ 504 /* Maintainer: Atmel */
504 .timer = &at91sam926x_timer, 505 .timer = &at91sam926x_timer,
505 .map_io = at91_map_io, 506 .map_io = at91_map_io,
507 .handle_irq = at91_aic_handle_irq,
506 .init_early = ek_init_early, 508 .init_early = ek_init_early,
507 .init_irq = at91_init_irq_default, 509 .init_irq = at91_init_irq_default,
508 .init_machine = ek_board_init, 510 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-sam9rlek.c b/arch/arm/mach-at91/board-sam9rlek.c
index be3239f13da..e7dc3ead704 100644
--- a/arch/arm/mach-at91/board-sam9rlek.c
+++ b/arch/arm/mach-at91/board-sam9rlek.c
@@ -31,6 +31,7 @@
31 31
32#include <mach/hardware.h> 32#include <mach/hardware.h>
33#include <mach/board.h> 33#include <mach/board.h>
34#include <mach/at91_aic.h>
34#include <mach/at91sam9_smc.h> 35#include <mach/at91sam9_smc.h>
35#include <mach/at91_shdwc.h> 36#include <mach/at91_shdwc.h>
36 37
@@ -319,6 +320,7 @@ MACHINE_START(AT91SAM9RLEK, "Atmel AT91SAM9RL-EK")
319 /* Maintainer: Atmel */ 320 /* Maintainer: Atmel */
320 .timer = &at91sam926x_timer, 321 .timer = &at91sam926x_timer,
321 .map_io = at91_map_io, 322 .map_io = at91_map_io,
323 .handle_irq = at91_aic_handle_irq,
322 .init_early = ek_init_early, 324 .init_early = ek_init_early,
323 .init_irq = at91_init_irq_default, 325 .init_irq = at91_init_irq_default,
324 .init_machine = ek_board_init, 326 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-snapper9260.c b/arch/arm/mach-at91/board-snapper9260.c
index 9d446f1bb45..a4e031a039f 100644
--- a/arch/arm/mach-at91/board-snapper9260.c
+++ b/arch/arm/mach-at91/board-snapper9260.c
@@ -33,6 +33,7 @@
33 33
34#include <mach/hardware.h> 34#include <mach/hardware.h>
35#include <mach/board.h> 35#include <mach/board.h>
36#include <mach/at91_aic.h>
36#include <mach/at91sam9_smc.h> 37#include <mach/at91sam9_smc.h>
37 38
38#include "sam9_smc.h" 39#include "sam9_smc.h"
@@ -178,6 +179,7 @@ static void __init snapper9260_board_init(void)
178MACHINE_START(SNAPPER_9260, "Bluewater Systems Snapper 9260/9G20 module") 179MACHINE_START(SNAPPER_9260, "Bluewater Systems Snapper 9260/9G20 module")
179 .timer = &at91sam926x_timer, 180 .timer = &at91sam926x_timer,
180 .map_io = at91_map_io, 181 .map_io = at91_map_io,
182 .handle_irq = at91_aic_handle_irq,
181 .init_early = snapper9260_init_early, 183 .init_early = snapper9260_init_early,
182 .init_irq = at91_init_irq_default, 184 .init_irq = at91_init_irq_default,
183 .init_machine = snapper9260_board_init, 185 .init_machine = snapper9260_board_init,
diff --git a/arch/arm/mach-at91/board-stamp9g20.c b/arch/arm/mach-at91/board-stamp9g20.c
index ee86f9d7ee7..29eae1626bf 100644
--- a/arch/arm/mach-at91/board-stamp9g20.c
+++ b/arch/arm/mach-at91/board-stamp9g20.c
@@ -26,6 +26,7 @@
26#include <asm/mach/arch.h> 26#include <asm/mach/arch.h>
27 27
28#include <mach/board.h> 28#include <mach/board.h>
29#include <mach/at91_aic.h>
29#include <mach/at91sam9_smc.h> 30#include <mach/at91sam9_smc.h>
30 31
31#include "sam9_smc.h" 32#include "sam9_smc.h"
@@ -287,6 +288,7 @@ MACHINE_START(PORTUXG20, "taskit PortuxG20")
287 /* Maintainer: taskit GmbH */ 288 /* Maintainer: taskit GmbH */
288 .timer = &at91sam926x_timer, 289 .timer = &at91sam926x_timer,
289 .map_io = at91_map_io, 290 .map_io = at91_map_io,
291 .handle_irq = at91_aic_handle_irq,
290 .init_early = stamp9g20_init_early, 292 .init_early = stamp9g20_init_early,
291 .init_irq = at91_init_irq_default, 293 .init_irq = at91_init_irq_default,
292 .init_machine = portuxg20_board_init, 294 .init_machine = portuxg20_board_init,
@@ -296,6 +298,7 @@ MACHINE_START(STAMP9G20, "taskit Stamp9G20")
296 /* Maintainer: taskit GmbH */ 298 /* Maintainer: taskit GmbH */
297 .timer = &at91sam926x_timer, 299 .timer = &at91sam926x_timer,
298 .map_io = at91_map_io, 300 .map_io = at91_map_io,
301 .handle_irq = at91_aic_handle_irq,
299 .init_early = stamp9g20_init_early, 302 .init_early = stamp9g20_init_early,
300 .init_irq = at91_init_irq_default, 303 .init_irq = at91_init_irq_default,
301 .init_machine = stamp9g20evb_board_init, 304 .init_machine = stamp9g20evb_board_init,
diff --git a/arch/arm/mach-at91/board-usb-a926x.c b/arch/arm/mach-at91/board-usb-a926x.c
index 95393fcaf19..c1476b9fe7b 100644
--- a/arch/arm/mach-at91/board-usb-a926x.c
+++ b/arch/arm/mach-at91/board-usb-a926x.c
@@ -42,6 +42,7 @@
42 42
43#include <mach/hardware.h> 43#include <mach/hardware.h>
44#include <mach/board.h> 44#include <mach/board.h>
45#include <mach/at91_aic.h>
45#include <mach/at91sam9_smc.h> 46#include <mach/at91sam9_smc.h>
46#include <mach/at91_shdwc.h> 47#include <mach/at91_shdwc.h>
47 48
@@ -358,6 +359,7 @@ MACHINE_START(USB_A9263, "CALAO USB_A9263")
358 /* Maintainer: calao-systems */ 359 /* Maintainer: calao-systems */
359 .timer = &at91sam926x_timer, 360 .timer = &at91sam926x_timer,
360 .map_io = at91_map_io, 361 .map_io = at91_map_io,
362 .handle_irq = at91_aic_handle_irq,
361 .init_early = ek_init_early, 363 .init_early = ek_init_early,
362 .init_irq = at91_init_irq_default, 364 .init_irq = at91_init_irq_default,
363 .init_machine = ek_board_init, 365 .init_machine = ek_board_init,
@@ -367,6 +369,7 @@ MACHINE_START(USB_A9260, "CALAO USB_A9260")
367 /* Maintainer: calao-systems */ 369 /* Maintainer: calao-systems */
368 .timer = &at91sam926x_timer, 370 .timer = &at91sam926x_timer,
369 .map_io = at91_map_io, 371 .map_io = at91_map_io,
372 .handle_irq = at91_aic_handle_irq,
370 .init_early = ek_init_early, 373 .init_early = ek_init_early,
371 .init_irq = at91_init_irq_default, 374 .init_irq = at91_init_irq_default,
372 .init_machine = ek_board_init, 375 .init_machine = ek_board_init,
@@ -376,6 +379,7 @@ MACHINE_START(USB_A9G20, "CALAO USB_A92G0")
376 /* Maintainer: Jean-Christophe PLAGNIOL-VILLARD */ 379 /* Maintainer: Jean-Christophe PLAGNIOL-VILLARD */
377 .timer = &at91sam926x_timer, 380 .timer = &at91sam926x_timer,
378 .map_io = at91_map_io, 381 .map_io = at91_map_io,
382 .handle_irq = at91_aic_handle_irq,
379 .init_early = ek_init_early, 383 .init_early = ek_init_early,
380 .init_irq = at91_init_irq_default, 384 .init_irq = at91_init_irq_default,
381 .init_machine = ek_board_init, 385 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-yl-9200.c b/arch/arm/mach-at91/board-yl-9200.c
index d56665ea4b5..516d340549d 100644
--- a/arch/arm/mach-at91/board-yl-9200.c
+++ b/arch/arm/mach-at91/board-yl-9200.c
@@ -44,6 +44,7 @@
44 44
45#include <mach/hardware.h> 45#include <mach/hardware.h>
46#include <mach/board.h> 46#include <mach/board.h>
47#include <mach/at91_aic.h>
47#include <mach/at91rm9200_mc.h> 48#include <mach/at91rm9200_mc.h>
48#include <mach/at91_ramc.h> 49#include <mach/at91_ramc.h>
49#include <mach/cpu.h> 50#include <mach/cpu.h>
@@ -590,6 +591,7 @@ MACHINE_START(YL9200, "uCdragon YL-9200")
590 /* Maintainer: S.Birtles */ 591 /* Maintainer: S.Birtles */
591 .timer = &at91rm9200_timer, 592 .timer = &at91rm9200_timer,
592 .map_io = at91_map_io, 593 .map_io = at91_map_io,
594 .handle_irq = at91_aic_handle_irq,
593 .init_early = yl9200_init_early, 595 .init_early = yl9200_init_early,
594 .init_irq = at91_init_irq_default, 596 .init_irq = at91_init_irq_default,
595 .init_machine = yl9200_board_init, 597 .init_machine = yl9200_board_init,
diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
index de2ec6b8fea..188c82971eb 100644
--- a/arch/arm/mach-at91/clock.c
+++ b/arch/arm/mach-at91/clock.c
@@ -63,6 +63,12 @@ EXPORT_SYMBOL_GPL(at91_pmc_base);
63 63
64#define cpu_has_300M_plla() (cpu_is_at91sam9g10()) 64#define cpu_has_300M_plla() (cpu_is_at91sam9g10())
65 65
66#define cpu_has_240M_plla() (cpu_is_at91sam9261() \
67 || cpu_is_at91sam9263() \
68 || cpu_is_at91sam9rl())
69
70#define cpu_has_210M_plla() (cpu_is_at91sam9260())
71
66#define cpu_has_pllb() (!(cpu_is_at91sam9rl() \ 72#define cpu_has_pllb() (!(cpu_is_at91sam9rl() \
67 || cpu_is_at91sam9g45() \ 73 || cpu_is_at91sam9g45() \
68 || cpu_is_at91sam9x5() \ 74 || cpu_is_at91sam9x5() \
@@ -706,6 +712,12 @@ static int __init at91_pmc_init(unsigned long main_clock)
706 } else if (cpu_has_800M_plla()) { 712 } else if (cpu_has_800M_plla()) {
707 if (plla.rate_hz > 800000000) 713 if (plla.rate_hz > 800000000)
708 pll_overclock = true; 714 pll_overclock = true;
715 } else if (cpu_has_240M_plla()) {
716 if (plla.rate_hz > 240000000)
717 pll_overclock = true;
718 } else if (cpu_has_210M_plla()) {
719 if (plla.rate_hz > 210000000)
720 pll_overclock = true;
709 } else { 721 } else {
710 if (plla.rate_hz > 209000000) 722 if (plla.rate_hz > 209000000)
711 pll_overclock = true; 723 pll_overclock = true;
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index 0a60bf83703..f4965067765 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -29,6 +29,8 @@ extern void __init at91x40_init_interrupts(unsigned int priority[]);
29extern void __init at91_aic_init(unsigned int priority[]); 29extern void __init at91_aic_init(unsigned int priority[]);
30extern int __init at91_aic_of_init(struct device_node *node, 30extern int __init at91_aic_of_init(struct device_node *node,
31 struct device_node *parent); 31 struct device_node *parent);
32extern int __init at91_aic5_of_init(struct device_node *node,
33 struct device_node *parent);
32 34
33 35
34 /* Timer */ 36 /* Timer */
diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
index 325837a264c..be42cf0e74b 100644
--- a/arch/arm/mach-at91/gpio.c
+++ b/arch/arm/mach-at91/gpio.c
@@ -26,6 +26,8 @@
26#include <linux/of_irq.h> 26#include <linux/of_irq.h>
27#include <linux/of_gpio.h> 27#include <linux/of_gpio.h>
28 28
29#include <asm/mach/irq.h>
30
29#include <mach/hardware.h> 31#include <mach/hardware.h>
30#include <mach/at91_pio.h> 32#include <mach/at91_pio.h>
31 33
@@ -585,15 +587,14 @@ static struct irq_chip gpio_irqchip = {
585 587
586static void gpio_irq_handler(unsigned irq, struct irq_desc *desc) 588static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
587{ 589{
590 struct irq_chip *chip = irq_desc_get_chip(desc);
588 struct irq_data *idata = irq_desc_get_irq_data(desc); 591 struct irq_data *idata = irq_desc_get_irq_data(desc);
589 struct irq_chip *chip = irq_data_get_irq_chip(idata);
590 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(idata); 592 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(idata);
591 void __iomem *pio = at91_gpio->regbase; 593 void __iomem *pio = at91_gpio->regbase;
592 unsigned long isr; 594 unsigned long isr;
593 int n; 595 int n;
594 596
595 /* temporarily mask (level sensitive) parent IRQ */ 597 chained_irq_enter(chip, desc);
596 chip->irq_ack(idata);
597 for (;;) { 598 for (;;) {
598 /* Reading ISR acks pending (edge triggered) GPIO interrupts. 599 /* Reading ISR acks pending (edge triggered) GPIO interrupts.
599 * When there none are pending, we're finished unless we need 600 * When there none are pending, we're finished unless we need
@@ -614,7 +615,7 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
614 n = find_next_bit(&isr, BITS_PER_LONG, n + 1); 615 n = find_next_bit(&isr, BITS_PER_LONG, n + 1);
615 } 616 }
616 } 617 }
617 chip->irq_unmask(idata); 618 chained_irq_exit(chip, desc);
618 /* now it may re-trigger */ 619 /* now it may re-trigger */
619} 620}
620 621
diff --git a/arch/arm/mach-at91/include/mach/at91_aic.h b/arch/arm/mach-at91/include/mach/at91_aic.h
index 3045781c473..eaea66197fa 100644
--- a/arch/arm/mach-at91/include/mach/at91_aic.h
+++ b/arch/arm/mach-at91/include/mach/at91_aic.h
@@ -23,12 +23,23 @@ extern void __iomem *at91_aic_base;
23 __raw_readl(at91_aic_base + field) 23 __raw_readl(at91_aic_base + field)
24 24
25#define at91_aic_write(field, value) \ 25#define at91_aic_write(field, value) \
26 __raw_writel(value, at91_aic_base + field); 26 __raw_writel(value, at91_aic_base + field)
27#else 27#else
28.extern at91_aic_base 28.extern at91_aic_base
29#endif 29#endif
30 30
31/* Number of irq lines managed by AIC */
32#define NR_AIC_IRQS 32
33#define NR_AIC5_IRQS 128
34
35#define AT91_AIC5_SSR 0x0 /* Source Select Register [AIC5] */
36#define AT91_AIC5_INTSEL_MSK (0x7f << 0) /* Interrupt Line Selection Mask */
37
38#define AT91_AIC_IRQ_MIN_PRIORITY 0
39#define AT91_AIC_IRQ_MAX_PRIORITY 7
40
31#define AT91_AIC_SMR(n) ((n) * 4) /* Source Mode Registers 0-31 */ 41#define AT91_AIC_SMR(n) ((n) * 4) /* Source Mode Registers 0-31 */
42#define AT91_AIC5_SMR 0x4 /* Source Mode Register [AIC5] */
32#define AT91_AIC_PRIOR (7 << 0) /* Priority Level */ 43#define AT91_AIC_PRIOR (7 << 0) /* Priority Level */
33#define AT91_AIC_SRCTYPE (3 << 5) /* Interrupt Source Type */ 44#define AT91_AIC_SRCTYPE (3 << 5) /* Interrupt Source Type */
34#define AT91_AIC_SRCTYPE_LOW (0 << 5) 45#define AT91_AIC_SRCTYPE_LOW (0 << 5)
@@ -37,29 +48,52 @@ extern void __iomem *at91_aic_base;
37#define AT91_AIC_SRCTYPE_RISING (3 << 5) 48#define AT91_AIC_SRCTYPE_RISING (3 << 5)
38 49
39#define AT91_AIC_SVR(n) (0x80 + ((n) * 4)) /* Source Vector Registers 0-31 */ 50#define AT91_AIC_SVR(n) (0x80 + ((n) * 4)) /* Source Vector Registers 0-31 */
51#define AT91_AIC5_SVR 0x8 /* Source Vector Register [AIC5] */
40#define AT91_AIC_IVR 0x100 /* Interrupt Vector Register */ 52#define AT91_AIC_IVR 0x100 /* Interrupt Vector Register */
53#define AT91_AIC5_IVR 0x10 /* Interrupt Vector Register [AIC5] */
41#define AT91_AIC_FVR 0x104 /* Fast Interrupt Vector Register */ 54#define AT91_AIC_FVR 0x104 /* Fast Interrupt Vector Register */
55#define AT91_AIC5_FVR 0x14 /* Fast Interrupt Vector Register [AIC5] */
42#define AT91_AIC_ISR 0x108 /* Interrupt Status Register */ 56#define AT91_AIC_ISR 0x108 /* Interrupt Status Register */
57#define AT91_AIC5_ISR 0x18 /* Interrupt Status Register [AIC5] */
43#define AT91_AIC_IRQID (0x1f << 0) /* Current Interrupt Identifier */ 58#define AT91_AIC_IRQID (0x1f << 0) /* Current Interrupt Identifier */
44 59
45#define AT91_AIC_IPR 0x10c /* Interrupt Pending Register */ 60#define AT91_AIC_IPR 0x10c /* Interrupt Pending Register */
61#define AT91_AIC5_IPR0 0x20 /* Interrupt Pending Register 0 [AIC5] */
62#define AT91_AIC5_IPR1 0x24 /* Interrupt Pending Register 1 [AIC5] */
63#define AT91_AIC5_IPR2 0x28 /* Interrupt Pending Register 2 [AIC5] */
64#define AT91_AIC5_IPR3 0x2c /* Interrupt Pending Register 3 [AIC5] */
46#define AT91_AIC_IMR 0x110 /* Interrupt Mask Register */ 65#define AT91_AIC_IMR 0x110 /* Interrupt Mask Register */
66#define AT91_AIC5_IMR 0x30 /* Interrupt Mask Register [AIC5] */
47#define AT91_AIC_CISR 0x114 /* Core Interrupt Status Register */ 67#define AT91_AIC_CISR 0x114 /* Core Interrupt Status Register */
68#define AT91_AIC5_CISR 0x34 /* Core Interrupt Status Register [AIC5] */
48#define AT91_AIC_NFIQ (1 << 0) /* nFIQ Status */ 69#define AT91_AIC_NFIQ (1 << 0) /* nFIQ Status */
49#define AT91_AIC_NIRQ (1 << 1) /* nIRQ Status */ 70#define AT91_AIC_NIRQ (1 << 1) /* nIRQ Status */
50 71
51#define AT91_AIC_IECR 0x120 /* Interrupt Enable Command Register */ 72#define AT91_AIC_IECR 0x120 /* Interrupt Enable Command Register */
73#define AT91_AIC5_IECR 0x40 /* Interrupt Enable Command Register [AIC5] */
52#define AT91_AIC_IDCR 0x124 /* Interrupt Disable Command Register */ 74#define AT91_AIC_IDCR 0x124 /* Interrupt Disable Command Register */
75#define AT91_AIC5_IDCR 0x44 /* Interrupt Disable Command Register [AIC5] */
53#define AT91_AIC_ICCR 0x128 /* Interrupt Clear Command Register */ 76#define AT91_AIC_ICCR 0x128 /* Interrupt Clear Command Register */
77#define AT91_AIC5_ICCR 0x48 /* Interrupt Clear Command Register [AIC5] */
54#define AT91_AIC_ISCR 0x12c /* Interrupt Set Command Register */ 78#define AT91_AIC_ISCR 0x12c /* Interrupt Set Command Register */
79#define AT91_AIC5_ISCR 0x4c /* Interrupt Set Command Register [AIC5] */
55#define AT91_AIC_EOICR 0x130 /* End of Interrupt Command Register */ 80#define AT91_AIC_EOICR 0x130 /* End of Interrupt Command Register */
81#define AT91_AIC5_EOICR 0x38 /* End of Interrupt Command Register [AIC5] */
56#define AT91_AIC_SPU 0x134 /* Spurious Interrupt Vector Register */ 82#define AT91_AIC_SPU 0x134 /* Spurious Interrupt Vector Register */
83#define AT91_AIC5_SPU 0x3c /* Spurious Interrupt Vector Register [AIC5] */
57#define AT91_AIC_DCR 0x138 /* Debug Control Register */ 84#define AT91_AIC_DCR 0x138 /* Debug Control Register */
85#define AT91_AIC5_DCR 0x6c /* Debug Control Register [AIC5] */
58#define AT91_AIC_DCR_PROT (1 << 0) /* Protection Mode */ 86#define AT91_AIC_DCR_PROT (1 << 0) /* Protection Mode */
59#define AT91_AIC_DCR_GMSK (1 << 1) /* General Mask */ 87#define AT91_AIC_DCR_GMSK (1 << 1) /* General Mask */
60 88
61#define AT91_AIC_FFER 0x140 /* Fast Forcing Enable Register [SAM9 only] */ 89#define AT91_AIC_FFER 0x140 /* Fast Forcing Enable Register [SAM9 only] */
90#define AT91_AIC5_FFER 0x50 /* Fast Forcing Enable Register [AIC5] */
62#define AT91_AIC_FFDR 0x144 /* Fast Forcing Disable Register [SAM9 only] */ 91#define AT91_AIC_FFDR 0x144 /* Fast Forcing Disable Register [SAM9 only] */
92#define AT91_AIC5_FFDR 0x54 /* Fast Forcing Disable Register [AIC5] */
63#define AT91_AIC_FFSR 0x148 /* Fast Forcing Status Register [SAM9 only] */ 93#define AT91_AIC_FFSR 0x148 /* Fast Forcing Status Register [SAM9 only] */
94#define AT91_AIC5_FFSR 0x58 /* Fast Forcing Status Register [AIC5] */
95
96void at91_aic_handle_irq(struct pt_regs *regs);
97void at91_aic5_handle_irq(struct pt_regs *regs);
64 98
65#endif 99#endif
diff --git a/arch/arm/mach-at91/include/mach/at91_spi.h b/arch/arm/mach-at91/include/mach/at91_spi.h
deleted file mode 100644
index 2f6ba0c5636..00000000000
--- a/arch/arm/mach-at91/include/mach/at91_spi.h
+++ /dev/null
@@ -1,81 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/at91_spi.h
3 *
4 * Copyright (C) 2005 Ivan Kokshaysky
5 * Copyright (C) SAN People
6 *
7 * Serial Peripheral Interface (SPI) registers.
8 * Based on AT91RM9200 datasheet revision E.
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#ifndef AT91_SPI_H
17#define AT91_SPI_H
18
19#define AT91_SPI_CR 0x00 /* Control Register */
20#define AT91_SPI_SPIEN (1 << 0) /* SPI Enable */
21#define AT91_SPI_SPIDIS (1 << 1) /* SPI Disable */
22#define AT91_SPI_SWRST (1 << 7) /* SPI Software Reset */
23#define AT91_SPI_LASTXFER (1 << 24) /* Last Transfer [SAM9261 only] */
24
25#define AT91_SPI_MR 0x04 /* Mode Register */
26#define AT91_SPI_MSTR (1 << 0) /* Master/Slave Mode */
27#define AT91_SPI_PS (1 << 1) /* Peripheral Select */
28#define AT91_SPI_PS_FIXED (0 << 1)
29#define AT91_SPI_PS_VARIABLE (1 << 1)
30#define AT91_SPI_PCSDEC (1 << 2) /* Chip Select Decode */
31#define AT91_SPI_DIV32 (1 << 3) /* Clock Selection [AT91RM9200 only] */
32#define AT91_SPI_MODFDIS (1 << 4) /* Mode Fault Detection */
33#define AT91_SPI_LLB (1 << 7) /* Local Loopback Enable */
34#define AT91_SPI_PCS (0xf << 16) /* Peripheral Chip Select */
35#define AT91_SPI_DLYBCS (0xff << 24) /* Delay Between Chip Selects */
36
37#define AT91_SPI_RDR 0x08 /* Receive Data Register */
38#define AT91_SPI_RD (0xffff << 0) /* Receive Data */
39#define AT91_SPI_PCS (0xf << 16) /* Peripheral Chip Select */
40
41#define AT91_SPI_TDR 0x0c /* Transmit Data Register */
42#define AT91_SPI_TD (0xffff << 0) /* Transmit Data */
43#define AT91_SPI_PCS (0xf << 16) /* Peripheral Chip Select */
44#define AT91_SPI_LASTXFER (1 << 24) /* Last Transfer [SAM9261 only] */
45
46#define AT91_SPI_SR 0x10 /* Status Register */
47#define AT91_SPI_RDRF (1 << 0) /* Receive Data Register Full */
48#define AT91_SPI_TDRE (1 << 1) /* Transmit Data Register Full */
49#define AT91_SPI_MODF (1 << 2) /* Mode Fault Error */
50#define AT91_SPI_OVRES (1 << 3) /* Overrun Error Status */
51#define AT91_SPI_ENDRX (1 << 4) /* End of RX buffer */
52#define AT91_SPI_ENDTX (1 << 5) /* End of TX buffer */
53#define AT91_SPI_RXBUFF (1 << 6) /* RX Buffer Full */
54#define AT91_SPI_TXBUFE (1 << 7) /* TX Buffer Empty */
55#define AT91_SPI_NSSR (1 << 8) /* NSS Rising [SAM9261 only] */
56#define AT91_SPI_TXEMPTY (1 << 9) /* Transmission Register Empty [SAM9261 only] */
57#define AT91_SPI_SPIENS (1 << 16) /* SPI Enable Status */
58
59#define AT91_SPI_IER 0x14 /* Interrupt Enable Register */
60#define AT91_SPI_IDR 0x18 /* Interrupt Disable Register */
61#define AT91_SPI_IMR 0x1c /* Interrupt Mask Register */
62
63#define AT91_SPI_CSR(n) (0x30 + ((n) * 4)) /* Chip Select Registers 0-3 */
64#define AT91_SPI_CPOL (1 << 0) /* Clock Polarity */
65#define AT91_SPI_NCPHA (1 << 1) /* Clock Phase */
66#define AT91_SPI_CSAAT (1 << 3) /* Chip Select Active After Transfer [SAM9261 only] */
67#define AT91_SPI_BITS (0xf << 4) /* Bits Per Transfer */
68#define AT91_SPI_BITS_8 (0 << 4)
69#define AT91_SPI_BITS_9 (1 << 4)
70#define AT91_SPI_BITS_10 (2 << 4)
71#define AT91_SPI_BITS_11 (3 << 4)
72#define AT91_SPI_BITS_12 (4 << 4)
73#define AT91_SPI_BITS_13 (5 << 4)
74#define AT91_SPI_BITS_14 (6 << 4)
75#define AT91_SPI_BITS_15 (7 << 4)
76#define AT91_SPI_BITS_16 (8 << 4)
77#define AT91_SPI_SCBR (0xff << 8) /* Serial Clock Baud Rate */
78#define AT91_SPI_DLYBS (0xff << 16) /* Delay before SPCK */
79#define AT91_SPI_DLYBCT (0xff << 24) /* Delay between Consecutive Transfers */
80
81#endif
diff --git a/arch/arm/mach-at91/include/mach/at91_ssc.h b/arch/arm/mach-at91/include/mach/at91_ssc.h
deleted file mode 100644
index a81114c11c7..00000000000
--- a/arch/arm/mach-at91/include/mach/at91_ssc.h
+++ /dev/null
@@ -1,106 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/at91_ssc.h
3 *
4 * Copyright (C) SAN People
5 *
6 * Serial Synchronous Controller (SSC) registers.
7 * Based on AT91RM9200 datasheet revision E.
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 as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 */
14
15#ifndef AT91_SSC_H
16#define AT91_SSC_H
17
18#define AT91_SSC_CR 0x00 /* Control Register */
19#define AT91_SSC_RXEN (1 << 0) /* Receive Enable */
20#define AT91_SSC_RXDIS (1 << 1) /* Receive Disable */
21#define AT91_SSC_TXEN (1 << 8) /* Transmit Enable */
22#define AT91_SSC_TXDIS (1 << 9) /* Transmit Disable */
23#define AT91_SSC_SWRST (1 << 15) /* Software Reset */
24
25#define AT91_SSC_CMR 0x04 /* Clock Mode Register */
26#define AT91_SSC_CMR_DIV (0xfff << 0) /* Clock Divider */
27
28#define AT91_SSC_RCMR 0x10 /* Receive Clock Mode Register */
29#define AT91_SSC_CKS (3 << 0) /* Clock Selection */
30#define AT91_SSC_CKS_DIV (0 << 0)
31#define AT91_SSC_CKS_CLOCK (1 << 0)
32#define AT91_SSC_CKS_PIN (2 << 0)
33#define AT91_SSC_CKO (7 << 2) /* Clock Output Mode Selection */
34#define AT91_SSC_CKO_NONE (0 << 2)
35#define AT91_SSC_CKO_CONTINUOUS (1 << 2)
36#define AT91_SSC_CKI (1 << 5) /* Clock Inversion */
37#define AT91_SSC_CKI_FALLING (0 << 5)
38#define AT91_SSC_CK_RISING (1 << 5)
39#define AT91_SSC_CKG (1 << 6) /* Receive Clock Gating Selection [AT91SAM9261 only] */
40#define AT91_SSC_CKG_NONE (0 << 6)
41#define AT91_SSC_CKG_RFLOW (1 << 6)
42#define AT91_SSC_CKG_RFHIGH (2 << 6)
43#define AT91_SSC_START (0xf << 8) /* Start Selection */
44#define AT91_SSC_START_CONTINUOUS (0 << 8)
45#define AT91_SSC_START_TX_RX (1 << 8)
46#define AT91_SSC_START_LOW_RF (2 << 8)
47#define AT91_SSC_START_HIGH_RF (3 << 8)
48#define AT91_SSC_START_FALLING_RF (4 << 8)
49#define AT91_SSC_START_RISING_RF (5 << 8)
50#define AT91_SSC_START_LEVEL_RF (6 << 8)
51#define AT91_SSC_START_EDGE_RF (7 << 8)
52#define AT91_SSC_STOP (1 << 12) /* Receive Stop Selection [AT91SAM9261 only] */
53#define AT91_SSC_STTDLY (0xff << 16) /* Start Delay */
54#define AT91_SSC_PERIOD (0xff << 24) /* Period Divider Selection */
55
56#define AT91_SSC_RFMR 0x14 /* Receive Frame Mode Register */
57#define AT91_SSC_DATALEN (0x1f << 0) /* Data Length */
58#define AT91_SSC_LOOP (1 << 5) /* Loop Mode */
59#define AT91_SSC_MSBF (1 << 7) /* Most Significant Bit First */
60#define AT91_SSC_DATNB (0xf << 8) /* Data Number per Frame */
61#define AT91_SSC_FSLEN (0xf << 16) /* Frame Sync Length */
62#define AT91_SSC_FSOS (7 << 20) /* Frame Sync Output Selection */
63#define AT91_SSC_FSOS_NONE (0 << 20)
64#define AT91_SSC_FSOS_NEGATIVE (1 << 20)
65#define AT91_SSC_FSOS_POSITIVE (2 << 20)
66#define AT91_SSC_FSOS_LOW (3 << 20)
67#define AT91_SSC_FSOS_HIGH (4 << 20)
68#define AT91_SSC_FSOS_TOGGLE (5 << 20)
69#define AT91_SSC_FSEDGE (1 << 24) /* Frame Sync Edge Detection */
70#define AT91_SSC_FSEDGE_POSITIVE (0 << 24)
71#define AT91_SSC_FSEDGE_NEGATIVE (1 << 24)
72
73#define AT91_SSC_TCMR 0x18 /* Transmit Clock Mode Register */
74#define AT91_SSC_TFMR 0x1c /* Transmit Fram Mode Register */
75#define AT91_SSC_DATDEF (1 << 5) /* Data Default Value */
76#define AT91_SSC_FSDEN (1 << 23) /* Frame Sync Data Enable */
77
78#define AT91_SSC_RHR 0x20 /* Receive Holding Register */
79#define AT91_SSC_THR 0x24 /* Transmit Holding Register */
80#define AT91_SSC_RSHR 0x30 /* Receive Sync Holding Register */
81#define AT91_SSC_TSHR 0x34 /* Transmit Sync Holding Register */
82
83#define AT91_SSC_RC0R 0x38 /* Receive Compare 0 Register [AT91SAM9261 only] */
84#define AT91_SSC_RC1R 0x3c /* Receive Compare 1 Register [AT91SAM9261 only] */
85
86#define AT91_SSC_SR 0x40 /* Status Register */
87#define AT91_SSC_TXRDY (1 << 0) /* Transmit Ready */
88#define AT91_SSC_TXEMPTY (1 << 1) /* Transmit Empty */
89#define AT91_SSC_ENDTX (1 << 2) /* End of Transmission */
90#define AT91_SSC_TXBUFE (1 << 3) /* Transmit Buffer Empty */
91#define AT91_SSC_RXRDY (1 << 4) /* Receive Ready */
92#define AT91_SSC_OVRUN (1 << 5) /* Receive Overrun */
93#define AT91_SSC_ENDRX (1 << 6) /* End of Reception */
94#define AT91_SSC_RXBUFF (1 << 7) /* Receive Buffer Full */
95#define AT91_SSC_CP0 (1 << 8) /* Compare 0 [AT91SAM9261 only] */
96#define AT91_SSC_CP1 (1 << 9) /* Compare 1 [AT91SAM9261 only] */
97#define AT91_SSC_TXSYN (1 << 10) /* Transmit Sync */
98#define AT91_SSC_RXSYN (1 << 11) /* Receive Sync */
99#define AT91_SSC_TXENA (1 << 16) /* Transmit Enable */
100#define AT91_SSC_RXENA (1 << 17) /* Receive Enable */
101
102#define AT91_SSC_IER 0x44 /* Interrupt Enable Register */
103#define AT91_SSC_IDR 0x48 /* Interrupt Disable Register */
104#define AT91_SSC_IMR 0x4c /* Interrupt Mask Register */
105
106#endif
diff --git a/arch/arm/mach-at91/include/mach/at91sam9g45.h b/arch/arm/mach-at91/include/mach/at91sam9g45.h
index 3a4da24d591..8eba1021f53 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9g45.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9g45.h
@@ -136,6 +136,8 @@
136#define AT_DMA_ID_SSC1_RX 8 136#define AT_DMA_ID_SSC1_RX 8
137#define AT_DMA_ID_AC97_TX 9 137#define AT_DMA_ID_AC97_TX 9
138#define AT_DMA_ID_AC97_RX 10 138#define AT_DMA_ID_AC97_RX 10
139#define AT_DMA_ID_AES_TX 11
140#define AT_DMA_ID_AES_RX 12
139#define AT_DMA_ID_MCI1 13 141#define AT_DMA_ID_MCI1 13
140 142
141#endif 143#endif
diff --git a/arch/arm/mach-at91/include/mach/entry-macro.S b/arch/arm/mach-at91/include/mach/entry-macro.S
deleted file mode 100644
index 903bf205a33..00000000000
--- a/arch/arm/mach-at91/include/mach/entry-macro.S
+++ /dev/null
@@ -1,27 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/entry-macro.S
3 *
4 * Copyright (C) 2003-2005 SAN People
5 *
6 * Low-level IRQ helper macros for AT91RM9200 platforms
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
13#include <mach/hardware.h>
14#include <mach/at91_aic.h>
15
16 .macro get_irqnr_preamble, base, tmp
17 ldr \base, =at91_aic_base @ base virtual address of AIC peripheral
18 ldr \base, [\base]
19 .endm
20
21 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
22 ldr \irqnr, [\base, #AT91_AIC_IVR] @ read IRQ vector register: de-asserts nIRQ to processor (and clears interrupt)
23 ldr \irqstat, [\base, #AT91_AIC_ISR] @ read interrupt source number
24 teq \irqstat, #0 @ ISR is 0 when no current interrupt, or spurious interrupt
25 streq \tmp, [\base, #AT91_AIC_EOICR] @ not going to be handled further, then ACK it now.
26 .endm
27
diff --git a/arch/arm/mach-at91/irq.c b/arch/arm/mach-at91/irq.c
index cfcfcbe3626..1e02c0e49dc 100644
--- a/arch/arm/mach-at91/irq.c
+++ b/arch/arm/mach-at91/irq.c
@@ -23,6 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/bitmap.h>
26#include <linux/types.h> 27#include <linux/types.h>
27#include <linux/irq.h> 28#include <linux/irq.h>
28#include <linux/of.h> 29#include <linux/of.h>
@@ -30,38 +31,218 @@
30#include <linux/of_irq.h> 31#include <linux/of_irq.h>
31#include <linux/irqdomain.h> 32#include <linux/irqdomain.h>
32#include <linux/err.h> 33#include <linux/err.h>
34#include <linux/slab.h>
33 35
34#include <mach/hardware.h> 36#include <mach/hardware.h>
35#include <asm/irq.h> 37#include <asm/irq.h>
36#include <asm/setup.h> 38#include <asm/setup.h>
37 39
40#include <asm/exception.h>
38#include <asm/mach/arch.h> 41#include <asm/mach/arch.h>
39#include <asm/mach/irq.h> 42#include <asm/mach/irq.h>
40#include <asm/mach/map.h> 43#include <asm/mach/map.h>
41 44
45#include <mach/at91_aic.h>
46
42void __iomem *at91_aic_base; 47void __iomem *at91_aic_base;
43static struct irq_domain *at91_aic_domain; 48static struct irq_domain *at91_aic_domain;
44static struct device_node *at91_aic_np; 49static struct device_node *at91_aic_np;
50static unsigned int n_irqs = NR_AIC_IRQS;
51static unsigned long at91_aic_caps = 0;
52
53/* AIC5 introduces a Source Select Register */
54#define AT91_AIC_CAP_AIC5 (1 << 0)
55#define has_aic5() (at91_aic_caps & AT91_AIC_CAP_AIC5)
56
57#ifdef CONFIG_PM
58
59static unsigned long *wakeups;
60static unsigned long *backups;
61
62#define set_backup(bit) set_bit(bit, backups)
63#define clear_backup(bit) clear_bit(bit, backups)
64
65static int at91_aic_pm_init(void)
66{
67 backups = kzalloc(BITS_TO_LONGS(n_irqs) * sizeof(*backups), GFP_KERNEL);
68 if (!backups)
69 return -ENOMEM;
70
71 wakeups = kzalloc(BITS_TO_LONGS(n_irqs) * sizeof(*backups), GFP_KERNEL);
72 if (!wakeups) {
73 kfree(backups);
74 return -ENOMEM;
75 }
76
77 return 0;
78}
79
80static int at91_aic_set_wake(struct irq_data *d, unsigned value)
81{
82 if (unlikely(d->hwirq >= n_irqs))
83 return -EINVAL;
84
85 if (value)
86 set_bit(d->hwirq, wakeups);
87 else
88 clear_bit(d->hwirq, wakeups);
89
90 return 0;
91}
92
93void at91_irq_suspend(void)
94{
95 int i = 0, bit;
96
97 if (has_aic5()) {
98 /* disable enabled irqs */
99 while ((bit = find_next_bit(backups, n_irqs, i)) < n_irqs) {
100 at91_aic_write(AT91_AIC5_SSR,
101 bit & AT91_AIC5_INTSEL_MSK);
102 at91_aic_write(AT91_AIC5_IDCR, 1);
103 i = bit;
104 }
105 /* enable wakeup irqs */
106 i = 0;
107 while ((bit = find_next_bit(wakeups, n_irqs, i)) < n_irqs) {
108 at91_aic_write(AT91_AIC5_SSR,
109 bit & AT91_AIC5_INTSEL_MSK);
110 at91_aic_write(AT91_AIC5_IECR, 1);
111 i = bit;
112 }
113 } else {
114 at91_aic_write(AT91_AIC_IDCR, *backups);
115 at91_aic_write(AT91_AIC_IECR, *wakeups);
116 }
117}
118
119void at91_irq_resume(void)
120{
121 int i = 0, bit;
122
123 if (has_aic5()) {
124 /* disable wakeup irqs */
125 while ((bit = find_next_bit(wakeups, n_irqs, i)) < n_irqs) {
126 at91_aic_write(AT91_AIC5_SSR,
127 bit & AT91_AIC5_INTSEL_MSK);
128 at91_aic_write(AT91_AIC5_IDCR, 1);
129 i = bit;
130 }
131 /* enable irqs disabled for suspend */
132 i = 0;
133 while ((bit = find_next_bit(backups, n_irqs, i)) < n_irqs) {
134 at91_aic_write(AT91_AIC5_SSR,
135 bit & AT91_AIC5_INTSEL_MSK);
136 at91_aic_write(AT91_AIC5_IECR, 1);
137 i = bit;
138 }
139 } else {
140 at91_aic_write(AT91_AIC_IDCR, *wakeups);
141 at91_aic_write(AT91_AIC_IECR, *backups);
142 }
143}
144
145#else
146static inline int at91_aic_pm_init(void)
147{
148 return 0;
149}
150
151#define set_backup(bit)
152#define clear_backup(bit)
153#define at91_aic_set_wake NULL
154
155#endif /* CONFIG_PM */
156
157asmlinkage void __exception_irq_entry
158at91_aic_handle_irq(struct pt_regs *regs)
159{
160 u32 irqnr;
161 u32 irqstat;
162
163 irqnr = at91_aic_read(AT91_AIC_IVR);
164 irqstat = at91_aic_read(AT91_AIC_ISR);
165
166 /*
167 * ISR value is 0 when there is no current interrupt or when there is
168 * a spurious interrupt
169 */
170 if (!irqstat)
171 at91_aic_write(AT91_AIC_EOICR, 0);
172 else
173 handle_IRQ(irqnr, regs);
174}
175
176asmlinkage void __exception_irq_entry
177at91_aic5_handle_irq(struct pt_regs *regs)
178{
179 u32 irqnr;
180 u32 irqstat;
181
182 irqnr = at91_aic_read(AT91_AIC5_IVR);
183 irqstat = at91_aic_read(AT91_AIC5_ISR);
184
185 if (!irqstat)
186 at91_aic_write(AT91_AIC5_EOICR, 0);
187 else
188 handle_IRQ(irqnr, regs);
189}
45 190
46static void at91_aic_mask_irq(struct irq_data *d) 191static void at91_aic_mask_irq(struct irq_data *d)
47{ 192{
48 /* Disable interrupt on AIC */ 193 /* Disable interrupt on AIC */
49 at91_aic_write(AT91_AIC_IDCR, 1 << d->hwirq); 194 at91_aic_write(AT91_AIC_IDCR, 1 << d->hwirq);
195 /* Update ISR cache */
196 clear_backup(d->hwirq);
197}
198
199static void __maybe_unused at91_aic5_mask_irq(struct irq_data *d)
200{
201 /* Disable interrupt on AIC5 */
202 at91_aic_write(AT91_AIC5_SSR, d->hwirq & AT91_AIC5_INTSEL_MSK);
203 at91_aic_write(AT91_AIC5_IDCR, 1);
204 /* Update ISR cache */
205 clear_backup(d->hwirq);
50} 206}
51 207
52static void at91_aic_unmask_irq(struct irq_data *d) 208static void at91_aic_unmask_irq(struct irq_data *d)
53{ 209{
54 /* Enable interrupt on AIC */ 210 /* Enable interrupt on AIC */
55 at91_aic_write(AT91_AIC_IECR, 1 << d->hwirq); 211 at91_aic_write(AT91_AIC_IECR, 1 << d->hwirq);
212 /* Update ISR cache */
213 set_backup(d->hwirq);
214}
215
216static void __maybe_unused at91_aic5_unmask_irq(struct irq_data *d)
217{
218 /* Enable interrupt on AIC5 */
219 at91_aic_write(AT91_AIC5_SSR, d->hwirq & AT91_AIC5_INTSEL_MSK);
220 at91_aic_write(AT91_AIC5_IECR, 1);
221 /* Update ISR cache */
222 set_backup(d->hwirq);
56} 223}
57 224
58unsigned int at91_extern_irq; 225static void at91_aic_eoi(struct irq_data *d)
226{
227 /*
228 * Mark end-of-interrupt on AIC, the controller doesn't care about
229 * the value written. Moreover it's a write-only register.
230 */
231 at91_aic_write(AT91_AIC_EOICR, 0);
232}
233
234static void __maybe_unused at91_aic5_eoi(struct irq_data *d)
235{
236 at91_aic_write(AT91_AIC5_EOICR, 0);
237}
59 238
60#define is_extern_irq(hwirq) ((1 << (hwirq)) & at91_extern_irq) 239unsigned long *at91_extern_irq;
61 240
62static int at91_aic_set_type(struct irq_data *d, unsigned type) 241#define is_extern_irq(hwirq) test_bit(hwirq, at91_extern_irq)
242
243static int at91_aic_compute_srctype(struct irq_data *d, unsigned type)
63{ 244{
64 unsigned int smr, srctype; 245 int srctype;
65 246
66 switch (type) { 247 switch (type) {
67 case IRQ_TYPE_LEVEL_HIGH: 248 case IRQ_TYPE_LEVEL_HIGH:
@@ -74,65 +255,51 @@ static int at91_aic_set_type(struct irq_data *d, unsigned type)
74 if ((d->hwirq == AT91_ID_FIQ) || is_extern_irq(d->hwirq)) /* only supported on external interrupts */ 255 if ((d->hwirq == AT91_ID_FIQ) || is_extern_irq(d->hwirq)) /* only supported on external interrupts */
75 srctype = AT91_AIC_SRCTYPE_LOW; 256 srctype = AT91_AIC_SRCTYPE_LOW;
76 else 257 else
77 return -EINVAL; 258 srctype = -EINVAL;
78 break; 259 break;
79 case IRQ_TYPE_EDGE_FALLING: 260 case IRQ_TYPE_EDGE_FALLING:
80 if ((d->hwirq == AT91_ID_FIQ) || is_extern_irq(d->hwirq)) /* only supported on external interrupts */ 261 if ((d->hwirq == AT91_ID_FIQ) || is_extern_irq(d->hwirq)) /* only supported on external interrupts */
81 srctype = AT91_AIC_SRCTYPE_FALLING; 262 srctype = AT91_AIC_SRCTYPE_FALLING;
82 else 263 else
83 return -EINVAL; 264 srctype = -EINVAL;
84 break; 265 break;
85 default: 266 default:
86 return -EINVAL; 267 srctype = -EINVAL;
87 } 268 }
88 269
89 smr = at91_aic_read(AT91_AIC_SMR(d->hwirq)) & ~AT91_AIC_SRCTYPE; 270 return srctype;
90 at91_aic_write(AT91_AIC_SMR(d->hwirq), smr | srctype);
91 return 0;
92} 271}
93 272
94#ifdef CONFIG_PM 273static int at91_aic_set_type(struct irq_data *d, unsigned type)
95
96static u32 wakeups;
97static u32 backups;
98
99static int at91_aic_set_wake(struct irq_data *d, unsigned value)
100{ 274{
101 if (unlikely(d->hwirq >= NR_AIC_IRQS)) 275 unsigned int smr;
102 return -EINVAL; 276 int srctype;
103 277
104 if (value) 278 srctype = at91_aic_compute_srctype(d, type);
105 wakeups |= (1 << d->hwirq); 279 if (srctype < 0)
106 else 280 return srctype;
107 wakeups &= ~(1 << d->hwirq); 281
282 if (has_aic5()) {
283 at91_aic_write(AT91_AIC5_SSR,
284 d->hwirq & AT91_AIC5_INTSEL_MSK);
285 smr = at91_aic_read(AT91_AIC5_SMR) & ~AT91_AIC_SRCTYPE;
286 at91_aic_write(AT91_AIC5_SMR, smr | srctype);
287 } else {
288 smr = at91_aic_read(AT91_AIC_SMR(d->hwirq))
289 & ~AT91_AIC_SRCTYPE;
290 at91_aic_write(AT91_AIC_SMR(d->hwirq), smr | srctype);
291 }
108 292
109 return 0; 293 return 0;
110} 294}
111 295
112void at91_irq_suspend(void)
113{
114 backups = at91_aic_read(AT91_AIC_IMR);
115 at91_aic_write(AT91_AIC_IDCR, backups);
116 at91_aic_write(AT91_AIC_IECR, wakeups);
117}
118
119void at91_irq_resume(void)
120{
121 at91_aic_write(AT91_AIC_IDCR, wakeups);
122 at91_aic_write(AT91_AIC_IECR, backups);
123}
124
125#else
126#define at91_aic_set_wake NULL
127#endif
128
129static struct irq_chip at91_aic_chip = { 296static struct irq_chip at91_aic_chip = {
130 .name = "AIC", 297 .name = "AIC",
131 .irq_ack = at91_aic_mask_irq,
132 .irq_mask = at91_aic_mask_irq, 298 .irq_mask = at91_aic_mask_irq,
133 .irq_unmask = at91_aic_unmask_irq, 299 .irq_unmask = at91_aic_unmask_irq,
134 .irq_set_type = at91_aic_set_type, 300 .irq_set_type = at91_aic_set_type,
135 .irq_set_wake = at91_aic_set_wake, 301 .irq_set_wake = at91_aic_set_wake,
302 .irq_eoi = at91_aic_eoi,
136}; 303};
137 304
138static void __init at91_aic_hw_init(unsigned int spu_vector) 305static void __init at91_aic_hw_init(unsigned int spu_vector)
@@ -161,41 +328,172 @@ static void __init at91_aic_hw_init(unsigned int spu_vector)
161 at91_aic_write(AT91_AIC_ICCR, 0xFFFFFFFF); 328 at91_aic_write(AT91_AIC_ICCR, 0xFFFFFFFF);
162} 329}
163 330
331static void __init __maybe_unused at91_aic5_hw_init(unsigned int spu_vector)
332{
333 int i;
334
335 /*
336 * Perform 8 End Of Interrupt Command to make sure AIC
337 * will not Lock out nIRQ
338 */
339 for (i = 0; i < 8; i++)
340 at91_aic_write(AT91_AIC5_EOICR, 0);
341
342 /*
343 * Spurious Interrupt ID in Spurious Vector Register.
344 * When there is no current interrupt, the IRQ Vector Register
345 * reads the value stored in AIC_SPU
346 */
347 at91_aic_write(AT91_AIC5_SPU, spu_vector);
348
349 /* No debugging in AIC: Debug (Protect) Control Register */
350 at91_aic_write(AT91_AIC5_DCR, 0);
351
352 /* Disable and clear all interrupts initially */
353 for (i = 0; i < n_irqs; i++) {
354 at91_aic_write(AT91_AIC5_SSR, i & AT91_AIC5_INTSEL_MSK);
355 at91_aic_write(AT91_AIC5_IDCR, 1);
356 at91_aic_write(AT91_AIC5_ICCR, 1);
357 }
358}
359
164#if defined(CONFIG_OF) 360#if defined(CONFIG_OF)
361static unsigned int *at91_aic_irq_priorities;
362
165static int at91_aic_irq_map(struct irq_domain *h, unsigned int virq, 363static int at91_aic_irq_map(struct irq_domain *h, unsigned int virq,
166 irq_hw_number_t hw) 364 irq_hw_number_t hw)
167{ 365{
168 /* Put virq number in Source Vector Register */ 366 /* Put virq number in Source Vector Register */
169 at91_aic_write(AT91_AIC_SVR(hw), virq); 367 at91_aic_write(AT91_AIC_SVR(hw), virq);
170 368
171 /* Active Low interrupt, without priority */ 369 /* Active Low interrupt, with priority */
172 at91_aic_write(AT91_AIC_SMR(hw), AT91_AIC_SRCTYPE_LOW); 370 at91_aic_write(AT91_AIC_SMR(hw),
371 AT91_AIC_SRCTYPE_LOW | at91_aic_irq_priorities[hw]);
173 372
174 irq_set_chip_and_handler(virq, &at91_aic_chip, handle_level_irq); 373 irq_set_chip_and_handler(virq, &at91_aic_chip, handle_fasteoi_irq);
175 set_irq_flags(virq, IRQF_VALID | IRQF_PROBE); 374 set_irq_flags(virq, IRQF_VALID | IRQF_PROBE);
176 375
177 return 0; 376 return 0;
178} 377}
179 378
379static int at91_aic5_irq_map(struct irq_domain *h, unsigned int virq,
380 irq_hw_number_t hw)
381{
382 at91_aic_write(AT91_AIC5_SSR, hw & AT91_AIC5_INTSEL_MSK);
383
384 /* Put virq number in Source Vector Register */
385 at91_aic_write(AT91_AIC5_SVR, virq);
386
387 /* Active Low interrupt, with priority */
388 at91_aic_write(AT91_AIC5_SMR,
389 AT91_AIC_SRCTYPE_LOW | at91_aic_irq_priorities[hw]);
390
391 irq_set_chip_and_handler(virq, &at91_aic_chip, handle_fasteoi_irq);
392 set_irq_flags(virq, IRQF_VALID | IRQF_PROBE);
393
394 return 0;
395}
396
397static int at91_aic_irq_domain_xlate(struct irq_domain *d, struct device_node *ctrlr,
398 const u32 *intspec, unsigned int intsize,
399 irq_hw_number_t *out_hwirq, unsigned int *out_type)
400{
401 if (WARN_ON(intsize < 3))
402 return -EINVAL;
403 if (WARN_ON(intspec[0] >= n_irqs))
404 return -EINVAL;
405 if (WARN_ON((intspec[2] < AT91_AIC_IRQ_MIN_PRIORITY)
406 || (intspec[2] > AT91_AIC_IRQ_MAX_PRIORITY)))
407 return -EINVAL;
408
409 *out_hwirq = intspec[0];
410 *out_type = intspec[1] & IRQ_TYPE_SENSE_MASK;
411 at91_aic_irq_priorities[*out_hwirq] = intspec[2];
412
413 return 0;
414}
415
180static struct irq_domain_ops at91_aic_irq_ops = { 416static struct irq_domain_ops at91_aic_irq_ops = {
181 .map = at91_aic_irq_map, 417 .map = at91_aic_irq_map,
182 .xlate = irq_domain_xlate_twocell, 418 .xlate = at91_aic_irq_domain_xlate,
183}; 419};
184 420
185int __init at91_aic_of_init(struct device_node *node, 421int __init at91_aic_of_common_init(struct device_node *node,
186 struct device_node *parent) 422 struct device_node *parent)
187{ 423{
424 struct property *prop;
425 const __be32 *p;
426 u32 val;
427
428 at91_extern_irq = kzalloc(BITS_TO_LONGS(n_irqs)
429 * sizeof(*at91_extern_irq), GFP_KERNEL);
430 if (!at91_extern_irq)
431 return -ENOMEM;
432
433 if (at91_aic_pm_init()) {
434 kfree(at91_extern_irq);
435 return -ENOMEM;
436 }
437
438 at91_aic_irq_priorities = kzalloc(n_irqs
439 * sizeof(*at91_aic_irq_priorities),
440 GFP_KERNEL);
441 if (!at91_aic_irq_priorities)
442 return -ENOMEM;
443
188 at91_aic_base = of_iomap(node, 0); 444 at91_aic_base = of_iomap(node, 0);
189 at91_aic_np = node; 445 at91_aic_np = node;
190 446
191 at91_aic_domain = irq_domain_add_linear(at91_aic_np, NR_AIC_IRQS, 447 at91_aic_domain = irq_domain_add_linear(at91_aic_np, n_irqs,
192 &at91_aic_irq_ops, NULL); 448 &at91_aic_irq_ops, NULL);
193 if (!at91_aic_domain) 449 if (!at91_aic_domain)
194 panic("Unable to add AIC irq domain (DT)\n"); 450 panic("Unable to add AIC irq domain (DT)\n");
195 451
452 of_property_for_each_u32(node, "atmel,external-irqs", prop, p, val) {
453 if (val >= n_irqs)
454 pr_warn("AIC: external irq %d >= %d skip it\n",
455 val, n_irqs);
456 else
457 set_bit(val, at91_extern_irq);
458 }
459
196 irq_set_default_host(at91_aic_domain); 460 irq_set_default_host(at91_aic_domain);
197 461
198 at91_aic_hw_init(NR_AIC_IRQS); 462 return 0;
463}
464
465int __init at91_aic_of_init(struct device_node *node,
466 struct device_node *parent)
467{
468 int err;
469
470 err = at91_aic_of_common_init(node, parent);
471 if (err)
472 return err;
473
474 at91_aic_hw_init(n_irqs);
475
476 return 0;
477}
478
479int __init at91_aic5_of_init(struct device_node *node,
480 struct device_node *parent)
481{
482 int err;
483
484 at91_aic_caps |= AT91_AIC_CAP_AIC5;
485 n_irqs = NR_AIC5_IRQS;
486 at91_aic_chip.irq_ack = at91_aic5_mask_irq;
487 at91_aic_chip.irq_mask = at91_aic5_mask_irq;
488 at91_aic_chip.irq_unmask = at91_aic5_unmask_irq;
489 at91_aic_chip.irq_eoi = at91_aic5_eoi;
490 at91_aic_irq_ops.map = at91_aic5_irq_map;
491
492 err = at91_aic_of_common_init(node, parent);
493 if (err)
494 return err;
495
496 at91_aic5_hw_init(n_irqs);
199 497
200 return 0; 498 return 0;
201} 499}
@@ -204,22 +502,25 @@ int __init at91_aic_of_init(struct device_node *node,
204/* 502/*
205 * Initialize the AIC interrupt controller. 503 * Initialize the AIC interrupt controller.
206 */ 504 */
207void __init at91_aic_init(unsigned int priority[NR_AIC_IRQS]) 505void __init at91_aic_init(unsigned int *priority)
208{ 506{
209 unsigned int i; 507 unsigned int i;
210 int irq_base; 508 int irq_base;
211 509
510 if (at91_aic_pm_init())
511 panic("Unable to allocate bit maps\n");
512
212 at91_aic_base = ioremap(AT91_AIC, 512); 513 at91_aic_base = ioremap(AT91_AIC, 512);
213 if (!at91_aic_base) 514 if (!at91_aic_base)
214 panic("Unable to ioremap AIC registers\n"); 515 panic("Unable to ioremap AIC registers\n");
215 516
216 /* Add irq domain for AIC */ 517 /* Add irq domain for AIC */
217 irq_base = irq_alloc_descs(-1, 0, NR_AIC_IRQS, 0); 518 irq_base = irq_alloc_descs(-1, 0, n_irqs, 0);
218 if (irq_base < 0) { 519 if (irq_base < 0) {
219 WARN(1, "Cannot allocate irq_descs, assuming pre-allocated\n"); 520 WARN(1, "Cannot allocate irq_descs, assuming pre-allocated\n");
220 irq_base = 0; 521 irq_base = 0;
221 } 522 }
222 at91_aic_domain = irq_domain_add_legacy(at91_aic_np, NR_AIC_IRQS, 523 at91_aic_domain = irq_domain_add_legacy(at91_aic_np, n_irqs,
223 irq_base, 0, 524 irq_base, 0,
224 &irq_domain_simple_ops, NULL); 525 &irq_domain_simple_ops, NULL);
225 526
@@ -232,15 +533,14 @@ void __init at91_aic_init(unsigned int priority[NR_AIC_IRQS])
232 * The IVR is used by macro get_irqnr_and_base to read and verify. 533 * The IVR is used by macro get_irqnr_and_base to read and verify.
233 * The irq number is NR_AIC_IRQS when a spurious interrupt has occurred. 534 * The irq number is NR_AIC_IRQS when a spurious interrupt has occurred.
234 */ 535 */
235 for (i = 0; i < NR_AIC_IRQS; i++) { 536 for (i = 0; i < n_irqs; i++) {
236 /* Put hardware irq number in Source Vector Register: */ 537 /* Put hardware irq number in Source Vector Register: */
237 at91_aic_write(AT91_AIC_SVR(i), i); 538 at91_aic_write(AT91_AIC_SVR(i), NR_IRQS_LEGACY + i);
238 /* Active Low interrupt, with the specified priority */ 539 /* Active Low interrupt, with the specified priority */
239 at91_aic_write(AT91_AIC_SMR(i), AT91_AIC_SRCTYPE_LOW | priority[i]); 540 at91_aic_write(AT91_AIC_SMR(i), AT91_AIC_SRCTYPE_LOW | priority[i]);
240 541 irq_set_chip_and_handler(NR_IRQS_LEGACY + i, &at91_aic_chip, handle_fasteoi_irq);
241 irq_set_chip_and_handler(i, &at91_aic_chip, handle_level_irq);
242 set_irq_flags(i, IRQF_VALID | IRQF_PROBE); 542 set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
243 } 543 }
244 544
245 at91_aic_hw_init(NR_AIC_IRQS); 545 at91_aic_hw_init(n_irqs);
246} 546}
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 1bfaad62873..2c2d86505a5 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -25,6 +25,7 @@
25#include <asm/mach/time.h> 25#include <asm/mach/time.h>
26#include <asm/mach/irq.h> 26#include <asm/mach/irq.h>
27 27
28#include <mach/at91_aic.h>
28#include <mach/at91_pmc.h> 29#include <mach/at91_pmc.h>
29#include <mach/cpu.h> 30#include <mach/cpu.h>
30 31
diff --git a/arch/arm/mach-clps711x/common.c b/arch/arm/mach-clps711x/common.c
index c965fd8eb31..f15293bd797 100644
--- a/arch/arm/mach-clps711x/common.c
+++ b/arch/arm/mach-clps711x/common.c
@@ -26,7 +26,6 @@
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/irq.h> 27#include <linux/irq.h>
28#include <linux/sched.h> 28#include <linux/sched.h>
29#include <linux/timex.h>
30 29
31#include <asm/sizes.h> 30#include <asm/sizes.h>
32#include <mach/hardware.h> 31#include <mach/hardware.h>
@@ -188,7 +187,6 @@ static struct irqaction clps711x_timer_irq = {
188 187
189static void __init clps711x_timer_init(void) 188static void __init clps711x_timer_init(void)
190{ 189{
191 struct timespec tv;
192 unsigned int syscon; 190 unsigned int syscon;
193 191
194 syscon = clps_readl(SYSCON1); 192 syscon = clps_readl(SYSCON1);
@@ -198,10 +196,6 @@ static void __init clps711x_timer_init(void)
198 clps_writel(LATCH-1, TC2D); /* 512kHz / 100Hz - 1 */ 196 clps_writel(LATCH-1, TC2D); /* 512kHz / 100Hz - 1 */
199 197
200 setup_irq(IRQ_TC2OI, &clps711x_timer_irq); 198 setup_irq(IRQ_TC2OI, &clps711x_timer_irq);
201
202 tv.tv_nsec = 0;
203 tv.tv_sec = clps_readl(RTCDR);
204 do_settimeofday(&tv);
205} 199}
206 200
207struct sys_timer clps711x_timer = { 201struct sys_timer clps711x_timer = {
diff --git a/arch/arm/mach-clps711x/include/mach/memory.h b/arch/arm/mach-clps711x/include/mach/memory.h
index 3a032a67725..fc0e028d940 100644
--- a/arch/arm/mach-clps711x/include/mach/memory.h
+++ b/arch/arm/mach-clps711x/include/mach/memory.h
@@ -25,26 +25,6 @@
25 */ 25 */
26#define PLAT_PHYS_OFFSET UL(0xc0000000) 26#define PLAT_PHYS_OFFSET UL(0xc0000000)
27 27
28#if !defined(CONFIG_ARCH_CDB89712) && !defined (CONFIG_ARCH_AUTCPU12)
29
30#define __virt_to_bus(x) ((x) - PAGE_OFFSET)
31#define __bus_to_virt(x) ((x) + PAGE_OFFSET)
32#define __pfn_to_bus(x) (__pfn_to_phys(x) - PHYS_OFFSET)
33#define __bus_to_pfn(x) __phys_to_pfn((x) + PHYS_OFFSET)
34
35#endif
36
37
38/*
39 * Like the SA1100, the EDB7211 has a large gap between physical RAM
40 * banks. In 2.2, the Psion (CL-PS7110) port added custom support for
41 * discontiguous physical memory. In 2.4, we can use the standard
42 * Linux NUMA support.
43 *
44 * This is not necessary for EP7211 implementations with only one used
45 * memory bank. For those systems, simply undefine CONFIG_DISCONTIGMEM.
46 */
47
48/* 28/*
49 * The PS7211 allows up to 256MB max per DRAM bank, but the EDB7211 29 * The PS7211 allows up to 256MB max per DRAM bank, but the EDB7211
50 * uses only one of the two banks (bank #1). However, even within 30 * uses only one of the two banks (bank #1). However, even within
@@ -54,23 +34,6 @@
54 * them, so we use 24 for the node max shift to get 16MB node sizes. 34 * them, so we use 24 for the node max shift to get 16MB node sizes.
55 */ 35 */
56 36
57/*
58 * Because of the wide memory address space between physical RAM banks on the
59 * SA1100, it's much more convenient to use Linux's NUMA support to implement
60 * our memory map representation. Assuming all memory nodes have equal access
61 * characteristics, we then have generic discontiguous memory support.
62 *
63 * Of course, all this isn't mandatory for SA1100 implementations with only
64 * one used memory bank. For those, simply undefine CONFIG_DISCONTIGMEM.
65 *
66 * The nodes are matched with the physical memory bank addresses which are
67 * incidentally the same as virtual addresses.
68 *
69 * node 0: 0xc0000000 - 0xc7ffffff
70 * node 1: 0xc8000000 - 0xcfffffff
71 * node 2: 0xd0000000 - 0xd7ffffff
72 * node 3: 0xd8000000 - 0xdfffffff
73 */
74#define SECTION_SIZE_BITS 24 37#define SECTION_SIZE_BITS 24
75#define MAX_PHYSMEM_BITS 32 38#define MAX_PHYSMEM_BITS 32
76 39
diff --git a/arch/arm/mach-clps711x/p720t.c b/arch/arm/mach-clps711x/p720t.c
index 42ee8f33eaf..f266d90b9ef 100644
--- a/arch/arm/mach-clps711x/p720t.c
+++ b/arch/arm/mach-clps711x/p720t.c
@@ -86,17 +86,7 @@ static void __init p720t_map_io(void)
86 iotable_init(p720t_io_desc, ARRAY_SIZE(p720t_io_desc)); 86 iotable_init(p720t_io_desc, ARRAY_SIZE(p720t_io_desc));
87} 87}
88 88
89MACHINE_START(P720T, "ARM-Prospector720T") 89static void __init p720t_init_early(void)
90 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
91 .atag_offset = 0x100,
92 .fixup = fixup_p720t,
93 .map_io = p720t_map_io,
94 .init_irq = clps711x_init_irq,
95 .timer = &clps711x_timer,
96 .restart = clps711x_restart,
97MACHINE_END
98
99static int p720t_hw_init(void)
100{ 90{
101 /* 91 /*
102 * Power down as much as possible in case we don't 92 * Power down as much as possible in case we don't
@@ -111,13 +101,19 @@ static int p720t_hw_init(void)
111 PLD_CODEC = 0; 101 PLD_CODEC = 0;
112 PLD_TCH = 0; 102 PLD_TCH = 0;
113 PLD_SPI = 0; 103 PLD_SPI = 0;
114#ifndef CONFIG_DEBUG_LL 104 if (!IS_ENABLED(CONFIG_DEBUG_LL)) {
115 PLD_COM2 = 0; 105 PLD_COM2 = 0;
116 PLD_COM1 = 0; 106 PLD_COM1 = 0;
117#endif 107 }
118
119 return 0;
120} 108}
121 109
122__initcall(p720t_hw_init); 110MACHINE_START(P720T, "ARM-Prospector720T")
123 111 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
112 .atag_offset = 0x100,
113 .fixup = fixup_p720t,
114 .init_early = p720t_init_early,
115 .map_io = p720t_map_io,
116 .init_irq = clps711x_init_irq,
117 .timer = &clps711x_timer,
118 .restart = clps711x_restart,
119MACHINE_END
diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
index 32d837d8eab..ab99c3c3b75 100644
--- a/arch/arm/mach-davinci/Kconfig
+++ b/arch/arm/mach-davinci/Kconfig
@@ -4,6 +4,7 @@ config AINTC
4 bool 4 bool
5 5
6config CP_INTC 6config CP_INTC
7 select IRQ_DOMAIN
7 bool 8 bool
8 9
9config ARCH_DAVINCI_DMx 10config ARCH_DAVINCI_DMx
@@ -61,7 +62,6 @@ config MACH_DAVINCI_EVM
61 bool "TI DM644x EVM" 62 bool "TI DM644x EVM"
62 default ARCH_DAVINCI_DM644x 63 default ARCH_DAVINCI_DM644x
63 depends on ARCH_DAVINCI_DM644x 64 depends on ARCH_DAVINCI_DM644x
64 select MISC_DEVICES
65 select EEPROM_AT24 65 select EEPROM_AT24
66 select I2C 66 select I2C
67 help 67 help
@@ -71,7 +71,6 @@ config MACH_DAVINCI_EVM
71config MACH_SFFSDR 71config MACH_SFFSDR
72 bool "Lyrtech SFFSDR" 72 bool "Lyrtech SFFSDR"
73 depends on ARCH_DAVINCI_DM644x 73 depends on ARCH_DAVINCI_DM644x
74 select MISC_DEVICES
75 select EEPROM_AT24 74 select EEPROM_AT24
76 select I2C 75 select I2C
77 help 76 help
@@ -105,7 +104,6 @@ config MACH_DAVINCI_DM6467_EVM
105 default ARCH_DAVINCI_DM646x 104 default ARCH_DAVINCI_DM646x
106 depends on ARCH_DAVINCI_DM646x 105 depends on ARCH_DAVINCI_DM646x
107 select MACH_DAVINCI_DM6467TEVM 106 select MACH_DAVINCI_DM6467TEVM
108 select MISC_DEVICES
109 select EEPROM_AT24 107 select EEPROM_AT24
110 select I2C 108 select I2C
111 help 109 help
@@ -119,7 +117,6 @@ config MACH_DAVINCI_DM365_EVM
119 bool "TI DM365 EVM" 117 bool "TI DM365 EVM"
120 default ARCH_DAVINCI_DM365 118 default ARCH_DAVINCI_DM365
121 depends on ARCH_DAVINCI_DM365 119 depends on ARCH_DAVINCI_DM365
122 select MISC_DEVICES
123 select EEPROM_AT24 120 select EEPROM_AT24
124 select I2C 121 select I2C
125 help 122 help
@@ -131,7 +128,6 @@ config MACH_DAVINCI_DA830_EVM
131 default ARCH_DAVINCI_DA830 128 default ARCH_DAVINCI_DA830
132 depends on ARCH_DAVINCI_DA830 129 depends on ARCH_DAVINCI_DA830
133 select GPIO_PCF857X 130 select GPIO_PCF857X
134 select MISC_DEVICES
135 select EEPROM_AT24 131 select EEPROM_AT24
136 select I2C 132 select I2C
137 help 133 help
@@ -218,7 +214,6 @@ config MACH_TNETV107X
218config MACH_MITYOMAPL138 214config MACH_MITYOMAPL138
219 bool "Critical Link MityDSP-L138/MityARM-1808 SoM" 215 bool "Critical Link MityDSP-L138/MityARM-1808 SoM"
220 depends on ARCH_DAVINCI_DA850 216 depends on ARCH_DAVINCI_DA850
221 select MISC_DEVICES
222 select EEPROM_AT24 217 select EEPROM_AT24
223 select I2C 218 select I2C
224 help 219 help
diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile
index 2db78bd5c83..2227effcb0e 100644
--- a/arch/arm/mach-davinci/Makefile
+++ b/arch/arm/mach-davinci/Makefile
@@ -39,3 +39,4 @@ obj-$(CONFIG_MACH_OMAPL138_HAWKBOARD) += board-omapl138-hawk.o
39obj-$(CONFIG_CPU_FREQ) += cpufreq.o 39obj-$(CONFIG_CPU_FREQ) += cpufreq.o
40obj-$(CONFIG_CPU_IDLE) += cpuidle.o 40obj-$(CONFIG_CPU_IDLE) += cpuidle.o
41obj-$(CONFIG_SUSPEND) += pm.o sleep.o 41obj-$(CONFIG_SUSPEND) += pm.o sleep.o
42obj-$(CONFIG_HAVE_CLK) += pm_domain.o
diff --git a/arch/arm/mach-davinci/board-neuros-osd2.c b/arch/arm/mach-davinci/board-neuros-osd2.c
index 5de69f2fcca..f6b9fc70161 100644
--- a/arch/arm/mach-davinci/board-neuros-osd2.c
+++ b/arch/arm/mach-davinci/board-neuros-osd2.c
@@ -162,38 +162,6 @@ static void __init davinci_ntosd2_map_io(void)
162 dm644x_init(); 162 dm644x_init();
163} 163}
164 164
165/*
166 I2C initialization
167*/
168static struct davinci_i2c_platform_data ntosd2_i2c_pdata = {
169 .bus_freq = 20 /* kHz */,
170 .bus_delay = 100 /* usec */,
171};
172
173static struct i2c_board_info __initdata ntosd2_i2c_info[] = {
174};
175
176static int ntosd2_init_i2c(void)
177{
178 int status;
179
180 davinci_init_i2c(&ntosd2_i2c_pdata);
181 status = gpio_request(NTOSD2_MSP430_IRQ, ntosd2_i2c_info[0].type);
182 if (status == 0) {
183 status = gpio_direction_input(NTOSD2_MSP430_IRQ);
184 if (status == 0) {
185 status = gpio_to_irq(NTOSD2_MSP430_IRQ);
186 if (status > 0) {
187 ntosd2_i2c_info[0].irq = status;
188 i2c_register_board_info(1,
189 ntosd2_i2c_info,
190 ARRAY_SIZE(ntosd2_i2c_info));
191 }
192 }
193 }
194 return status;
195}
196
197static struct davinci_mmc_config davinci_ntosd2_mmc_config = { 165static struct davinci_mmc_config davinci_ntosd2_mmc_config = {
198 .wires = 4, 166 .wires = 4,
199 .version = MMC_CTLR_VERSION_1 167 .version = MMC_CTLR_VERSION_1
@@ -218,7 +186,6 @@ static __init void davinci_ntosd2_init(void)
218{ 186{
219 struct clk *aemif_clk; 187 struct clk *aemif_clk;
220 struct davinci_soc_info *soc_info = &davinci_soc_info; 188 struct davinci_soc_info *soc_info = &davinci_soc_info;
221 int status;
222 189
223 aemif_clk = clk_get(NULL, "aemif"); 190 aemif_clk = clk_get(NULL, "aemif");
224 clk_enable(aemif_clk); 191 clk_enable(aemif_clk);
@@ -242,12 +209,6 @@ static __init void davinci_ntosd2_init(void)
242 platform_add_devices(davinci_ntosd2_devices, 209 platform_add_devices(davinci_ntosd2_devices,
243 ARRAY_SIZE(davinci_ntosd2_devices)); 210 ARRAY_SIZE(davinci_ntosd2_devices));
244 211
245 /* Initialize I2C interface specific for this board */
246 status = ntosd2_init_i2c();
247 if (status < 0)
248 pr_warning("davinci_ntosd2_init: msp430 irq setup failed:"
249 " %d\n", status);
250
251 davinci_serial_init(&uart_config); 212 davinci_serial_init(&uart_config);
252 dm644x_init_asp(&dm644x_ntosd2_snd_data); 213 dm644x_init_asp(&dm644x_ntosd2_snd_data);
253 214
diff --git a/arch/arm/mach-davinci/cp_intc.c b/arch/arm/mach-davinci/cp_intc.c
index f83152d643c..006dae8dfe4 100644
--- a/arch/arm/mach-davinci/cp_intc.c
+++ b/arch/arm/mach-davinci/cp_intc.c
@@ -9,9 +9,14 @@
9 * kind, whether express or implied. 9 * kind, whether express or implied.
10 */ 10 */
11 11
12#include <linux/export.h>
12#include <linux/init.h> 13#include <linux/init.h>
13#include <linux/irq.h> 14#include <linux/irq.h>
15#include <linux/irqdomain.h>
14#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/of.h>
18#include <linux/of_address.h>
19#include <linux/of_irq.h>
15 20
16#include <mach/common.h> 21#include <mach/common.h>
17#include <mach/cp_intc.h> 22#include <mach/cp_intc.h>
@@ -28,7 +33,7 @@ static inline void cp_intc_write(unsigned long value, unsigned offset)
28 33
29static void cp_intc_ack_irq(struct irq_data *d) 34static void cp_intc_ack_irq(struct irq_data *d)
30{ 35{
31 cp_intc_write(d->irq, CP_INTC_SYS_STAT_IDX_CLR); 36 cp_intc_write(d->hwirq, CP_INTC_SYS_STAT_IDX_CLR);
32} 37}
33 38
34/* Disable interrupt */ 39/* Disable interrupt */
@@ -36,20 +41,20 @@ static void cp_intc_mask_irq(struct irq_data *d)
36{ 41{
37 /* XXX don't know why we need to disable nIRQ here... */ 42 /* XXX don't know why we need to disable nIRQ here... */
38 cp_intc_write(1, CP_INTC_HOST_ENABLE_IDX_CLR); 43 cp_intc_write(1, CP_INTC_HOST_ENABLE_IDX_CLR);
39 cp_intc_write(d->irq, CP_INTC_SYS_ENABLE_IDX_CLR); 44 cp_intc_write(d->hwirq, CP_INTC_SYS_ENABLE_IDX_CLR);
40 cp_intc_write(1, CP_INTC_HOST_ENABLE_IDX_SET); 45 cp_intc_write(1, CP_INTC_HOST_ENABLE_IDX_SET);
41} 46}
42 47
43/* Enable interrupt */ 48/* Enable interrupt */
44static void cp_intc_unmask_irq(struct irq_data *d) 49static void cp_intc_unmask_irq(struct irq_data *d)
45{ 50{
46 cp_intc_write(d->irq, CP_INTC_SYS_ENABLE_IDX_SET); 51 cp_intc_write(d->hwirq, CP_INTC_SYS_ENABLE_IDX_SET);
47} 52}
48 53
49static int cp_intc_set_irq_type(struct irq_data *d, unsigned int flow_type) 54static int cp_intc_set_irq_type(struct irq_data *d, unsigned int flow_type)
50{ 55{
51 unsigned reg = BIT_WORD(d->irq); 56 unsigned reg = BIT_WORD(d->hwirq);
52 unsigned mask = BIT_MASK(d->irq); 57 unsigned mask = BIT_MASK(d->hwirq);
53 unsigned polarity = cp_intc_read(CP_INTC_SYS_POLARITY(reg)); 58 unsigned polarity = cp_intc_read(CP_INTC_SYS_POLARITY(reg));
54 unsigned type = cp_intc_read(CP_INTC_SYS_TYPE(reg)); 59 unsigned type = cp_intc_read(CP_INTC_SYS_TYPE(reg));
55 60
@@ -99,18 +104,43 @@ static struct irq_chip cp_intc_irq_chip = {
99 .irq_set_wake = cp_intc_set_wake, 104 .irq_set_wake = cp_intc_set_wake,
100}; 105};
101 106
102void __init cp_intc_init(void) 107static struct irq_domain *cp_intc_domain;
108
109static int cp_intc_host_map(struct irq_domain *h, unsigned int virq,
110 irq_hw_number_t hw)
103{ 111{
104 unsigned long num_irq = davinci_soc_info.intc_irq_num; 112 pr_debug("cp_intc_host_map(%d, 0x%lx)\n", virq, hw);
113
114 irq_set_chip(virq, &cp_intc_irq_chip);
115 set_irq_flags(virq, IRQF_VALID | IRQF_PROBE);
116 irq_set_handler(virq, handle_edge_irq);
117 return 0;
118}
119
120static const struct irq_domain_ops cp_intc_host_ops = {
121 .map = cp_intc_host_map,
122 .xlate = irq_domain_xlate_onetwocell,
123};
124
125int __init cp_intc_of_init(struct device_node *node, struct device_node *parent)
126{
127 u32 num_irq = davinci_soc_info.intc_irq_num;
105 u8 *irq_prio = davinci_soc_info.intc_irq_prios; 128 u8 *irq_prio = davinci_soc_info.intc_irq_prios;
106 u32 *host_map = davinci_soc_info.intc_host_map; 129 u32 *host_map = davinci_soc_info.intc_host_map;
107 unsigned num_reg = BITS_TO_LONGS(num_irq); 130 unsigned num_reg = BITS_TO_LONGS(num_irq);
108 int i; 131 int i, irq_base;
109 132
110 davinci_intc_type = DAVINCI_INTC_TYPE_CP_INTC; 133 davinci_intc_type = DAVINCI_INTC_TYPE_CP_INTC;
111 davinci_intc_base = ioremap(davinci_soc_info.intc_base, SZ_8K); 134 if (node) {
135 davinci_intc_base = of_iomap(node, 0);
136 if (of_property_read_u32(node, "ti,intc-size", &num_irq))
137 pr_warn("unable to get intc-size, default to %d\n",
138 num_irq);
139 } else {
140 davinci_intc_base = ioremap(davinci_soc_info.intc_base, SZ_8K);
141 }
112 if (WARN_ON(!davinci_intc_base)) 142 if (WARN_ON(!davinci_intc_base))
113 return; 143 return -EINVAL;
114 144
115 cp_intc_write(0, CP_INTC_GLOBAL_ENABLE); 145 cp_intc_write(0, CP_INTC_GLOBAL_ENABLE);
116 146
@@ -165,13 +195,28 @@ void __init cp_intc_init(void)
165 for (i = 0; host_map[i] != -1; i++) 195 for (i = 0; host_map[i] != -1; i++)
166 cp_intc_write(host_map[i], CP_INTC_HOST_MAP(i)); 196 cp_intc_write(host_map[i], CP_INTC_HOST_MAP(i));
167 197
168 /* Set up genirq dispatching for cp_intc */ 198 irq_base = irq_alloc_descs(-1, 0, num_irq, 0);
169 for (i = 0; i < num_irq; i++) { 199 if (irq_base < 0) {
170 irq_set_chip(i, &cp_intc_irq_chip); 200 pr_warn("Couldn't allocate IRQ numbers\n");
171 set_irq_flags(i, IRQF_VALID | IRQF_PROBE); 201 irq_base = 0;
172 irq_set_handler(i, handle_edge_irq); 202 }
203
204 /* create a legacy host */
205 cp_intc_domain = irq_domain_add_legacy(node, num_irq,
206 irq_base, 0, &cp_intc_host_ops, NULL);
207
208 if (!cp_intc_domain) {
209 pr_err("cp_intc: failed to allocate irq host!\n");
210 return -EINVAL;
173 } 211 }
174 212
175 /* Enable global interrupt */ 213 /* Enable global interrupt */
176 cp_intc_write(1, CP_INTC_GLOBAL_ENABLE); 214 cp_intc_write(1, CP_INTC_GLOBAL_ENABLE);
215
216 return 0;
217}
218
219void __init cp_intc_init(void)
220{
221 cp_intc_of_init(NULL, NULL);
177} 222}
diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c
index d1624a315c9..783eab6845c 100644
--- a/arch/arm/mach-davinci/devices-da8xx.c
+++ b/arch/arm/mach-davinci/devices-da8xx.c
@@ -546,6 +546,7 @@ static struct lcd_ctrl_config lcd_cfg = {
546 .sync_edge = 0, 546 .sync_edge = 0,
547 .sync_ctrl = 1, 547 .sync_ctrl = 1,
548 .raster_order = 0, 548 .raster_order = 0,
549 .fifo_th = 6,
549}; 550};
550 551
551struct da8xx_lcdc_platform_data sharp_lcd035q3dg01_pdata = { 552struct da8xx_lcdc_platform_data sharp_lcd035q3dg01_pdata = {
diff --git a/arch/arm/mach-davinci/include/mach/cp_intc.h b/arch/arm/mach-davinci/include/mach/cp_intc.h
index 4e8190eed67..d13d8dfa2b0 100644
--- a/arch/arm/mach-davinci/include/mach/cp_intc.h
+++ b/arch/arm/mach-davinci/include/mach/cp_intc.h
@@ -52,5 +52,6 @@
52#define CP_INTC_VECTOR_ADDR(n) (0x2000 + (n << 2)) 52#define CP_INTC_VECTOR_ADDR(n) (0x2000 + (n << 2))
53 53
54void __init cp_intc_init(void); 54void __init cp_intc_init(void);
55int __init cp_intc_of_init(struct device_node *, struct device_node *);
55 56
56#endif /* __ASM_HARDWARE_CP_INTC_H */ 57#endif /* __ASM_HARDWARE_CP_INTC_H */
diff --git a/arch/arm/mach-davinci/include/mach/dm365.h b/arch/arm/mach-davinci/include/mach/dm365.h
deleted file mode 100644
index b9bf3d6a442..00000000000
--- a/arch/arm/mach-davinci/include/mach/dm365.h
+++ /dev/null
@@ -1 +0,0 @@
1/* empty, remove once unused */
diff --git a/arch/arm/mach-davinci/include/mach/dm646x.h b/arch/arm/mach-davinci/include/mach/dm646x.h
deleted file mode 100644
index b9bf3d6a442..00000000000
--- a/arch/arm/mach-davinci/include/mach/dm646x.h
+++ /dev/null
@@ -1 +0,0 @@
1/* empty, remove once unused */
diff --git a/arch/arm/mach-davinci/include/mach/entry-macro.S b/arch/arm/mach-davinci/include/mach/entry-macro.S
index 768b3c06021..cf5f573eb5f 100644
--- a/arch/arm/mach-davinci/include/mach/entry-macro.S
+++ b/arch/arm/mach-davinci/include/mach/entry-macro.S
@@ -30,12 +30,10 @@
30#endif 30#endif
31#if defined(CONFIG_CP_INTC) 31#if defined(CONFIG_CP_INTC)
321001: ldr \irqnr, [\base, #0x80] /* get irq number */ 321001: ldr \irqnr, [\base, #0x80] /* get irq number */
33 mov \tmp, \irqnr, lsr #31
33 and \irqnr, \irqnr, #0xff /* irq is in bits 0-9 */ 34 and \irqnr, \irqnr, #0xff /* irq is in bits 0-9 */
34 mov \tmp, \irqnr, lsr #3 35 and \tmp, \tmp, #0x1
35 and \tmp, \tmp, #0xfc 36 cmp \tmp, #0x1
36 add \tmp, \tmp, #0x280 /* get the register offset */
37 ldr \irqstat, [\base, \tmp] /* get the intc status */
38 cmp \irqstat, #0x0
39#endif 37#endif
401002: 381002:
41 .endm 39 .endm
diff --git a/arch/arm/mach-davinci/pm_domain.c b/arch/arm/mach-davinci/pm_domain.c
new file mode 100644
index 00000000000..00946e23c1e
--- /dev/null
+++ b/arch/arm/mach-davinci/pm_domain.c
@@ -0,0 +1,64 @@
1/*
2 * Runtime PM support code for DaVinci
3 *
4 * Author: Kevin Hilman
5 *
6 * Copyright (C) 2012 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/pm_runtime.h>
14#include <linux/pm_clock.h>
15#include <linux/platform_device.h>
16
17#ifdef CONFIG_PM_RUNTIME
18static int davinci_pm_runtime_suspend(struct device *dev)
19{
20 int ret;
21
22 dev_dbg(dev, "%s\n", __func__);
23
24 ret = pm_generic_runtime_suspend(dev);
25 if (ret)
26 return ret;
27
28 ret = pm_clk_suspend(dev);
29 if (ret) {
30 pm_generic_runtime_resume(dev);
31 return ret;
32 }
33
34 return 0;
35}
36
37static int davinci_pm_runtime_resume(struct device *dev)
38{
39 dev_dbg(dev, "%s\n", __func__);
40
41 pm_clk_resume(dev);
42 return pm_generic_runtime_resume(dev);
43}
44#endif
45
46static struct dev_pm_domain davinci_pm_domain = {
47 .ops = {
48 SET_RUNTIME_PM_OPS(davinci_pm_runtime_suspend,
49 davinci_pm_runtime_resume, NULL)
50 USE_PLATFORM_PM_SLEEP_OPS
51 },
52};
53
54static struct pm_clk_notifier_block platform_bus_notifier = {
55 .pm_domain = &davinci_pm_domain,
56};
57
58static int __init davinci_pm_runtime_init(void)
59{
60 pm_clk_add_notifier(&platform_bus_type, &platform_bus_notifier);
61
62 return 0;
63}
64core_initcall(davinci_pm_runtime_init);
diff --git a/arch/arm/mach-dove/common.c b/arch/arm/mach-dove/common.c
index 9493076fc59..6321567d8ea 100644
--- a/arch/arm/mach-dove/common.c
+++ b/arch/arm/mach-dove/common.c
@@ -101,8 +101,9 @@ void __init dove_ehci1_init(void)
101 ****************************************************************************/ 101 ****************************************************************************/
102void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data) 102void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data)
103{ 103{
104 orion_ge00_init(eth_data, 104 orion_ge00_init(eth_data, DOVE_GE00_PHYS_BASE,
105 DOVE_GE00_PHYS_BASE, IRQ_DOVE_GE00_SUM, 0); 105 IRQ_DOVE_GE00_SUM, IRQ_DOVE_GE00_ERR,
106 1600);
106} 107}
107 108
108/***************************************************************************** 109/*****************************************************************************
diff --git a/arch/arm/mach-dove/irq.c b/arch/arm/mach-dove/irq.c
index f07fd16e0c9..9bc97a5baaa 100644
--- a/arch/arm/mach-dove/irq.c
+++ b/arch/arm/mach-dove/irq.c
@@ -20,22 +20,6 @@
20#include <mach/bridge-regs.h> 20#include <mach/bridge-regs.h>
21#include "common.h" 21#include "common.h"
22 22
23static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
24{
25 int irqoff;
26 BUG_ON(irq < IRQ_DOVE_GPIO_0_7 || irq > IRQ_DOVE_HIGH_GPIO);
27
28 irqoff = irq <= IRQ_DOVE_GPIO_16_23 ? irq - IRQ_DOVE_GPIO_0_7 :
29 3 + irq - IRQ_DOVE_GPIO_24_31;
30
31 orion_gpio_irq_handler(irqoff << 3);
32 if (irq == IRQ_DOVE_HIGH_GPIO) {
33 orion_gpio_irq_handler(40);
34 orion_gpio_irq_handler(48);
35 orion_gpio_irq_handler(56);
36 }
37}
38
39static void pmu_irq_mask(struct irq_data *d) 23static void pmu_irq_mask(struct irq_data *d)
40{ 24{
41 int pin = irq_to_pmu(d->irq); 25 int pin = irq_to_pmu(d->irq);
@@ -90,6 +74,27 @@ static void pmu_irq_handler(unsigned int irq, struct irq_desc *desc)
90 } 74 }
91} 75}
92 76
77static int __initdata gpio0_irqs[4] = {
78 IRQ_DOVE_GPIO_0_7,
79 IRQ_DOVE_GPIO_8_15,
80 IRQ_DOVE_GPIO_16_23,
81 IRQ_DOVE_GPIO_24_31,
82};
83
84static int __initdata gpio1_irqs[4] = {
85 IRQ_DOVE_HIGH_GPIO,
86 0,
87 0,
88 0,
89};
90
91static int __initdata gpio2_irqs[4] = {
92 0,
93 0,
94 0,
95 0,
96};
97
93void __init dove_init_irq(void) 98void __init dove_init_irq(void)
94{ 99{
95 int i; 100 int i;
@@ -100,19 +105,14 @@ void __init dove_init_irq(void)
100 /* 105 /*
101 * Initialize gpiolib for GPIOs 0-71. 106 * Initialize gpiolib for GPIOs 0-71.
102 */ 107 */
103 orion_gpio_init(0, 32, DOVE_GPIO_LO_VIRT_BASE, 0, 108 orion_gpio_init(NULL, 0, 32, (void __iomem *)DOVE_GPIO_LO_VIRT_BASE, 0,
104 IRQ_DOVE_GPIO_START); 109 IRQ_DOVE_GPIO_START, gpio0_irqs);
105 irq_set_chained_handler(IRQ_DOVE_GPIO_0_7, gpio_irq_handler); 110
106 irq_set_chained_handler(IRQ_DOVE_GPIO_8_15, gpio_irq_handler); 111 orion_gpio_init(NULL, 32, 32, (void __iomem *)DOVE_GPIO_HI_VIRT_BASE, 0,
107 irq_set_chained_handler(IRQ_DOVE_GPIO_16_23, gpio_irq_handler); 112 IRQ_DOVE_GPIO_START + 32, gpio1_irqs);
108 irq_set_chained_handler(IRQ_DOVE_GPIO_24_31, gpio_irq_handler); 113
109 114 orion_gpio_init(NULL, 64, 8, (void __iomem *)DOVE_GPIO2_VIRT_BASE, 0,
110 orion_gpio_init(32, 32, DOVE_GPIO_HI_VIRT_BASE, 0, 115 IRQ_DOVE_GPIO_START + 64, gpio2_irqs);
111 IRQ_DOVE_GPIO_START + 32);
112 irq_set_chained_handler(IRQ_DOVE_HIGH_GPIO, gpio_irq_handler);
113
114 orion_gpio_init(64, 8, DOVE_GPIO2_VIRT_BASE, 0,
115 IRQ_DOVE_GPIO_START + 64);
116 116
117 /* 117 /*
118 * Mask and clear PMU interrupts 118 * Mask and clear PMU interrupts
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index 4dd07a0e360..4afe52aaaff 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -797,6 +797,102 @@ static struct platform_device ep93xx_wdt_device = {
797 .resource = ep93xx_wdt_resources, 797 .resource = ep93xx_wdt_resources,
798}; 798};
799 799
800/*************************************************************************
801 * EP93xx IDE
802 *************************************************************************/
803static struct resource ep93xx_ide_resources[] = {
804 DEFINE_RES_MEM(EP93XX_IDE_PHYS_BASE, 0x38),
805 DEFINE_RES_IRQ(IRQ_EP93XX_EXT3),
806};
807
808static struct platform_device ep93xx_ide_device = {
809 .name = "ep93xx-ide",
810 .id = -1,
811 .dev = {
812 .dma_mask = &ep93xx_ide_device.dev.coherent_dma_mask,
813 .coherent_dma_mask = DMA_BIT_MASK(32),
814 },
815 .num_resources = ARRAY_SIZE(ep93xx_ide_resources),
816 .resource = ep93xx_ide_resources,
817};
818
819void __init ep93xx_register_ide(void)
820{
821 platform_device_register(&ep93xx_ide_device);
822}
823
824int ep93xx_ide_acquire_gpio(struct platform_device *pdev)
825{
826 int err;
827 int i;
828
829 err = gpio_request(EP93XX_GPIO_LINE_EGPIO2, dev_name(&pdev->dev));
830 if (err)
831 return err;
832 err = gpio_request(EP93XX_GPIO_LINE_EGPIO15, dev_name(&pdev->dev));
833 if (err)
834 goto fail_egpio15;
835 for (i = 2; i < 8; i++) {
836 err = gpio_request(EP93XX_GPIO_LINE_E(i), dev_name(&pdev->dev));
837 if (err)
838 goto fail_gpio_e;
839 }
840 for (i = 4; i < 8; i++) {
841 err = gpio_request(EP93XX_GPIO_LINE_G(i), dev_name(&pdev->dev));
842 if (err)
843 goto fail_gpio_g;
844 }
845 for (i = 0; i < 8; i++) {
846 err = gpio_request(EP93XX_GPIO_LINE_H(i), dev_name(&pdev->dev));
847 if (err)
848 goto fail_gpio_h;
849 }
850
851 /* GPIO ports E[7:2], G[7:4] and H used by IDE */
852 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_EONIDE |
853 EP93XX_SYSCON_DEVCFG_GONIDE |
854 EP93XX_SYSCON_DEVCFG_HONIDE);
855 return 0;
856
857fail_gpio_h:
858 for (--i; i >= 0; --i)
859 gpio_free(EP93XX_GPIO_LINE_H(i));
860 i = 8;
861fail_gpio_g:
862 for (--i; i >= 4; --i)
863 gpio_free(EP93XX_GPIO_LINE_G(i));
864 i = 8;
865fail_gpio_e:
866 for (--i; i >= 2; --i)
867 gpio_free(EP93XX_GPIO_LINE_E(i));
868 gpio_free(EP93XX_GPIO_LINE_EGPIO15);
869fail_egpio15:
870 gpio_free(EP93XX_GPIO_LINE_EGPIO2);
871 return err;
872}
873EXPORT_SYMBOL(ep93xx_ide_acquire_gpio);
874
875void ep93xx_ide_release_gpio(struct platform_device *pdev)
876{
877 int i;
878
879 for (i = 2; i < 8; i++)
880 gpio_free(EP93XX_GPIO_LINE_E(i));
881 for (i = 4; i < 8; i++)
882 gpio_free(EP93XX_GPIO_LINE_G(i));
883 for (i = 0; i < 8; i++)
884 gpio_free(EP93XX_GPIO_LINE_H(i));
885 gpio_free(EP93XX_GPIO_LINE_EGPIO15);
886 gpio_free(EP93XX_GPIO_LINE_EGPIO2);
887
888
889 /* GPIO ports E[7:2], G[7:4] and H used by GPIO */
890 ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_EONIDE |
891 EP93XX_SYSCON_DEVCFG_GONIDE |
892 EP93XX_SYSCON_DEVCFG_HONIDE);
893}
894EXPORT_SYMBOL(ep93xx_ide_release_gpio);
895
800void __init ep93xx_init_devices(void) 896void __init ep93xx_init_devices(void)
801{ 897{
802 /* Disallow access to MaverickCrunch initially */ 898 /* Disallow access to MaverickCrunch initially */
diff --git a/arch/arm/mach-ep93xx/edb93xx.c b/arch/arm/mach-ep93xx/edb93xx.c
index d74c5cddb98..337ab7cf4c1 100644
--- a/arch/arm/mach-ep93xx/edb93xx.c
+++ b/arch/arm/mach-ep93xx/edb93xx.c
@@ -91,8 +91,8 @@ static void __init edb93xx_register_i2c(void)
91 ep93xx_register_i2c(&edb93xx_i2c_gpio_data, 91 ep93xx_register_i2c(&edb93xx_i2c_gpio_data,
92 edb93xxa_i2c_board_info, 92 edb93xxa_i2c_board_info,
93 ARRAY_SIZE(edb93xxa_i2c_board_info)); 93 ARRAY_SIZE(edb93xxa_i2c_board_info));
94 } else if (machine_is_edb9307() || machine_is_edb9312() || 94 } else if (machine_is_edb9302() || machine_is_edb9307()
95 machine_is_edb9315()) { 95 || machine_is_edb9312() || machine_is_edb9315()) {
96 ep93xx_register_i2c(&edb93xx_i2c_gpio_data, 96 ep93xx_register_i2c(&edb93xx_i2c_gpio_data,
97 edb93xx_i2c_board_info, 97 edb93xx_i2c_board_info,
98 ARRAY_SIZE(edb93xx_i2c_board_info)); 98 ARRAY_SIZE(edb93xx_i2c_board_info));
@@ -233,6 +233,29 @@ static void __init edb93xx_register_fb(void)
233} 233}
234 234
235 235
236/*************************************************************************
237 * EDB93xx IDE
238 *************************************************************************/
239static int __init edb93xx_has_ide(void)
240{
241 /*
242 * Although EDB9312 and EDB9315 do have IDE capability, they have
243 * INTRQ line wired as pull-up, which makes using IDE interface
244 * problematic.
245 */
246 return machine_is_edb9312() || machine_is_edb9315() ||
247 machine_is_edb9315a();
248}
249
250static void __init edb93xx_register_ide(void)
251{
252 if (!edb93xx_has_ide())
253 return;
254
255 ep93xx_register_ide();
256}
257
258
236static void __init edb93xx_init_machine(void) 259static void __init edb93xx_init_machine(void)
237{ 260{
238 ep93xx_init_devices(); 261 ep93xx_init_devices();
@@ -243,6 +266,7 @@ static void __init edb93xx_init_machine(void)
243 edb93xx_register_i2s(); 266 edb93xx_register_i2s();
244 edb93xx_register_pwm(); 267 edb93xx_register_pwm();
245 edb93xx_register_fb(); 268 edb93xx_register_fb();
269 edb93xx_register_ide();
246} 270}
247 271
248 272
diff --git a/arch/arm/mach-ep93xx/include/mach/platform.h b/arch/arm/mach-ep93xx/include/mach/platform.h
index 1ecb040d98b..33a5122c6dc 100644
--- a/arch/arm/mach-ep93xx/include/mach/platform.h
+++ b/arch/arm/mach-ep93xx/include/mach/platform.h
@@ -48,6 +48,9 @@ void ep93xx_register_i2s(void);
48int ep93xx_i2s_acquire(void); 48int ep93xx_i2s_acquire(void);
49void ep93xx_i2s_release(void); 49void ep93xx_i2s_release(void);
50void ep93xx_register_ac97(void); 50void ep93xx_register_ac97(void);
51void ep93xx_register_ide(void);
52int ep93xx_ide_acquire_gpio(struct platform_device *pdev);
53void ep93xx_ide_release_gpio(struct platform_device *pdev);
51 54
52void ep93xx_init_devices(void); 55void ep93xx_init_devices(void);
53extern struct sys_timer ep93xx_timer; 56extern struct sys_timer ep93xx_timer;
diff --git a/arch/arm/mach-ep93xx/soc.h b/arch/arm/mach-ep93xx/soc.h
index 979fba72292..7bf7ff8beae 100644
--- a/arch/arm/mach-ep93xx/soc.h
+++ b/arch/arm/mach-ep93xx/soc.h
@@ -69,6 +69,7 @@
69 69
70#define EP93XX_BOOT_ROM_BASE EP93XX_AHB_IOMEM(0x00090000) 70#define EP93XX_BOOT_ROM_BASE EP93XX_AHB_IOMEM(0x00090000)
71 71
72#define EP93XX_IDE_PHYS_BASE EP93XX_AHB_PHYS(0x000a0000)
72#define EP93XX_IDE_BASE EP93XX_AHB_IOMEM(0x000a0000) 73#define EP93XX_IDE_BASE EP93XX_AHB_IOMEM(0x000a0000)
73 74
74#define EP93XX_VIC1_BASE EP93XX_AHB_IOMEM(0x000b0000) 75#define EP93XX_VIC1_BASE EP93XX_AHB_IOMEM(0x000b0000)
diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig
index 6f6d13f91e4..b5b4c8c9db1 100644
--- a/arch/arm/mach-exynos/Kconfig
+++ b/arch/arm/mach-exynos/Kconfig
@@ -207,6 +207,7 @@ config MACH_SMDKV310
207 select S3C_DEV_HSMMC1 207 select S3C_DEV_HSMMC1
208 select S3C_DEV_HSMMC2 208 select S3C_DEV_HSMMC2
209 select S3C_DEV_HSMMC3 209 select S3C_DEV_HSMMC3
210 select S3C_DEV_USB_HSOTG
210 select SAMSUNG_DEV_BACKLIGHT 211 select SAMSUNG_DEV_BACKLIGHT
211 select EXYNOS_DEV_DRM 212 select EXYNOS_DEV_DRM
212 select EXYNOS_DEV_SYSMMU 213 select EXYNOS_DEV_SYSMMU
@@ -326,6 +327,7 @@ config MACH_ORIGEN
326 select S3C_DEV_WDT 327 select S3C_DEV_WDT
327 select S3C_DEV_HSMMC 328 select S3C_DEV_HSMMC
328 select S3C_DEV_HSMMC2 329 select S3C_DEV_HSMMC2
330 select S3C_DEV_USB_HSOTG
329 select S5P_DEV_FIMC0 331 select S5P_DEV_FIMC0
330 select S5P_DEV_FIMC1 332 select S5P_DEV_FIMC1
331 select S5P_DEV_FIMC2 333 select S5P_DEV_FIMC2
@@ -360,22 +362,27 @@ config MACH_SMDK4212
360 select S3C_DEV_I2C3 362 select S3C_DEV_I2C3
361 select S3C_DEV_I2C7 363 select S3C_DEV_I2C7
362 select S3C_DEV_RTC 364 select S3C_DEV_RTC
365 select S3C_DEV_USB_HSOTG
363 select S3C_DEV_WDT 366 select S3C_DEV_WDT
364 select S5P_DEV_FIMC0 367 select S5P_DEV_FIMC0
365 select S5P_DEV_FIMC1 368 select S5P_DEV_FIMC1
366 select S5P_DEV_FIMC2 369 select S5P_DEV_FIMC2
367 select S5P_DEV_FIMC3 370 select S5P_DEV_FIMC3
371 select S5P_DEV_FIMD0
368 select S5P_DEV_MFC 372 select S5P_DEV_MFC
369 select SAMSUNG_DEV_BACKLIGHT 373 select SAMSUNG_DEV_BACKLIGHT
370 select SAMSUNG_DEV_KEYPAD 374 select SAMSUNG_DEV_KEYPAD
371 select SAMSUNG_DEV_PWM 375 select SAMSUNG_DEV_PWM
372 select EXYNOS_DEV_SYSMMU 376 select EXYNOS_DEV_SYSMMU
373 select EXYNOS_DEV_DMA 377 select EXYNOS_DEV_DMA
378 select EXYNOS_DEV_DRM
379 select EXYNOS4_SETUP_FIMD0
374 select EXYNOS4_SETUP_I2C1 380 select EXYNOS4_SETUP_I2C1
375 select EXYNOS4_SETUP_I2C3 381 select EXYNOS4_SETUP_I2C3
376 select EXYNOS4_SETUP_I2C7 382 select EXYNOS4_SETUP_I2C7
377 select EXYNOS4_SETUP_KEYPAD 383 select EXYNOS4_SETUP_KEYPAD
378 select EXYNOS4_SETUP_SDHCI 384 select EXYNOS4_SETUP_SDHCI
385 select EXYNOS4_SETUP_USB_PHY
379 help 386 help
380 Machine support for Samsung SMDK4212 387 Machine support for Samsung SMDK4212
381 388
diff --git a/arch/arm/mach-exynos/clock-exynos4.c b/arch/arm/mach-exynos/clock-exynos4.c
index bcb7db45314..2f51293c187 100644
--- a/arch/arm/mach-exynos/clock-exynos4.c
+++ b/arch/arm/mach-exynos/clock-exynos4.c
@@ -586,17 +586,17 @@ static struct clk exynos4_init_clocks_off[] = {
586 .ctrlbit = (1 << 13), 586 .ctrlbit = (1 << 13),
587 }, { 587 }, {
588 .name = "spi", 588 .name = "spi",
589 .devname = "s3c64xx-spi.0", 589 .devname = "exynos4210-spi.0",
590 .enable = exynos4_clk_ip_peril_ctrl, 590 .enable = exynos4_clk_ip_peril_ctrl,
591 .ctrlbit = (1 << 16), 591 .ctrlbit = (1 << 16),
592 }, { 592 }, {
593 .name = "spi", 593 .name = "spi",
594 .devname = "s3c64xx-spi.1", 594 .devname = "exynos4210-spi.1",
595 .enable = exynos4_clk_ip_peril_ctrl, 595 .enable = exynos4_clk_ip_peril_ctrl,
596 .ctrlbit = (1 << 17), 596 .ctrlbit = (1 << 17),
597 }, { 597 }, {
598 .name = "spi", 598 .name = "spi",
599 .devname = "s3c64xx-spi.2", 599 .devname = "exynos4210-spi.2",
600 .enable = exynos4_clk_ip_peril_ctrl, 600 .enable = exynos4_clk_ip_peril_ctrl,
601 .ctrlbit = (1 << 18), 601 .ctrlbit = (1 << 18),
602 }, { 602 }, {
@@ -620,10 +620,6 @@ static struct clk exynos4_init_clocks_off[] = {
620 .enable = exynos4_clk_ip_peril_ctrl, 620 .enable = exynos4_clk_ip_peril_ctrl,
621 .ctrlbit = (1 << 27), 621 .ctrlbit = (1 << 27),
622 }, { 622 }, {
623 .name = "fimg2d",
624 .enable = exynos4_clk_ip_image_ctrl,
625 .ctrlbit = (1 << 0),
626 }, {
627 .name = "mfc", 623 .name = "mfc",
628 .devname = "s5p-mfc", 624 .devname = "s5p-mfc",
629 .enable = exynos4_clk_ip_mfc_ctrl, 625 .enable = exynos4_clk_ip_mfc_ctrl,
@@ -819,47 +815,21 @@ static struct clk *exynos4_clkset_mout_g2d0_list[] = {
819 [1] = &exynos4_clk_sclk_apll.clk, 815 [1] = &exynos4_clk_sclk_apll.clk,
820}; 816};
821 817
822static struct clksrc_sources exynos4_clkset_mout_g2d0 = { 818struct clksrc_sources exynos4_clkset_mout_g2d0 = {
823 .sources = exynos4_clkset_mout_g2d0_list, 819 .sources = exynos4_clkset_mout_g2d0_list,
824 .nr_sources = ARRAY_SIZE(exynos4_clkset_mout_g2d0_list), 820 .nr_sources = ARRAY_SIZE(exynos4_clkset_mout_g2d0_list),
825}; 821};
826 822
827static struct clksrc_clk exynos4_clk_mout_g2d0 = {
828 .clk = {
829 .name = "mout_g2d0",
830 },
831 .sources = &exynos4_clkset_mout_g2d0,
832 .reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 0, .size = 1 },
833};
834
835static struct clk *exynos4_clkset_mout_g2d1_list[] = { 823static struct clk *exynos4_clkset_mout_g2d1_list[] = {
836 [0] = &exynos4_clk_mout_epll.clk, 824 [0] = &exynos4_clk_mout_epll.clk,
837 [1] = &exynos4_clk_sclk_vpll.clk, 825 [1] = &exynos4_clk_sclk_vpll.clk,
838}; 826};
839 827
840static struct clksrc_sources exynos4_clkset_mout_g2d1 = { 828struct clksrc_sources exynos4_clkset_mout_g2d1 = {
841 .sources = exynos4_clkset_mout_g2d1_list, 829 .sources = exynos4_clkset_mout_g2d1_list,
842 .nr_sources = ARRAY_SIZE(exynos4_clkset_mout_g2d1_list), 830 .nr_sources = ARRAY_SIZE(exynos4_clkset_mout_g2d1_list),
843}; 831};
844 832
845static struct clksrc_clk exynos4_clk_mout_g2d1 = {
846 .clk = {
847 .name = "mout_g2d1",
848 },
849 .sources = &exynos4_clkset_mout_g2d1,
850 .reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 4, .size = 1 },
851};
852
853static struct clk *exynos4_clkset_mout_g2d_list[] = {
854 [0] = &exynos4_clk_mout_g2d0.clk,
855 [1] = &exynos4_clk_mout_g2d1.clk,
856};
857
858static struct clksrc_sources exynos4_clkset_mout_g2d = {
859 .sources = exynos4_clkset_mout_g2d_list,
860 .nr_sources = ARRAY_SIZE(exynos4_clkset_mout_g2d_list),
861};
862
863static struct clk *exynos4_clkset_mout_mfc0_list[] = { 833static struct clk *exynos4_clkset_mout_mfc0_list[] = {
864 [0] = &exynos4_clk_mout_mpll.clk, 834 [0] = &exynos4_clk_mout_mpll.clk,
865 [1] = &exynos4_clk_sclk_apll.clk, 835 [1] = &exynos4_clk_sclk_apll.clk,
@@ -1126,13 +1096,6 @@ static struct clksrc_clk exynos4_clksrcs[] = {
1126 .reg_div = { .reg = EXYNOS4_CLKDIV_LCD0, .shift = 0, .size = 4 }, 1096 .reg_div = { .reg = EXYNOS4_CLKDIV_LCD0, .shift = 0, .size = 4 },
1127 }, { 1097 }, {
1128 .clk = { 1098 .clk = {
1129 .name = "sclk_fimg2d",
1130 },
1131 .sources = &exynos4_clkset_mout_g2d,
1132 .reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 8, .size = 1 },
1133 .reg_div = { .reg = EXYNOS4_CLKDIV_IMAGE, .shift = 0, .size = 4 },
1134 }, {
1135 .clk = {
1136 .name = "sclk_mfc", 1099 .name = "sclk_mfc",
1137 .devname = "s5p-mfc", 1100 .devname = "s5p-mfc",
1138 }, 1101 },
@@ -1242,40 +1205,67 @@ static struct clksrc_clk exynos4_clk_sclk_mmc3 = {
1242 .reg_div = { .reg = EXYNOS4_CLKDIV_FSYS2, .shift = 24, .size = 8 }, 1205 .reg_div = { .reg = EXYNOS4_CLKDIV_FSYS2, .shift = 24, .size = 8 },
1243}; 1206};
1244 1207
1208static struct clksrc_clk exynos4_clk_mdout_spi0 = {
1209 .clk = {
1210 .name = "mdout_spi",
1211 .devname = "exynos4210-spi.0",
1212 },
1213 .sources = &exynos4_clkset_group,
1214 .reg_src = { .reg = EXYNOS4_CLKSRC_PERIL1, .shift = 16, .size = 4 },
1215 .reg_div = { .reg = EXYNOS4_CLKDIV_PERIL1, .shift = 0, .size = 4 },
1216};
1217
1218static struct clksrc_clk exynos4_clk_mdout_spi1 = {
1219 .clk = {
1220 .name = "mdout_spi",
1221 .devname = "exynos4210-spi.1",
1222 },
1223 .sources = &exynos4_clkset_group,
1224 .reg_src = { .reg = EXYNOS4_CLKSRC_PERIL1, .shift = 20, .size = 4 },
1225 .reg_div = { .reg = EXYNOS4_CLKDIV_PERIL1, .shift = 16, .size = 4 },
1226};
1227
1228static struct clksrc_clk exynos4_clk_mdout_spi2 = {
1229 .clk = {
1230 .name = "mdout_spi",
1231 .devname = "exynos4210-spi.2",
1232 },
1233 .sources = &exynos4_clkset_group,
1234 .reg_src = { .reg = EXYNOS4_CLKSRC_PERIL1, .shift = 24, .size = 4 },
1235 .reg_div = { .reg = EXYNOS4_CLKDIV_PERIL2, .shift = 0, .size = 4 },
1236};
1237
1245static struct clksrc_clk exynos4_clk_sclk_spi0 = { 1238static struct clksrc_clk exynos4_clk_sclk_spi0 = {
1246 .clk = { 1239 .clk = {
1247 .name = "sclk_spi", 1240 .name = "sclk_spi",
1248 .devname = "s3c64xx-spi.0", 1241 .devname = "exynos4210-spi.0",
1242 .parent = &exynos4_clk_mdout_spi0.clk,
1249 .enable = exynos4_clksrc_mask_peril1_ctrl, 1243 .enable = exynos4_clksrc_mask_peril1_ctrl,
1250 .ctrlbit = (1 << 16), 1244 .ctrlbit = (1 << 16),
1251 }, 1245 },
1252 .sources = &exynos4_clkset_group, 1246 .reg_div = { .reg = EXYNOS4_CLKDIV_PERIL1, .shift = 8, .size = 8 },
1253 .reg_src = { .reg = EXYNOS4_CLKSRC_PERIL1, .shift = 16, .size = 4 },
1254 .reg_div = { .reg = EXYNOS4_CLKDIV_PERIL1, .shift = 0, .size = 4 },
1255}; 1247};
1256 1248
1257static struct clksrc_clk exynos4_clk_sclk_spi1 = { 1249static struct clksrc_clk exynos4_clk_sclk_spi1 = {
1258 .clk = { 1250 .clk = {
1259 .name = "sclk_spi", 1251 .name = "sclk_spi",
1260 .devname = "s3c64xx-spi.1", 1252 .devname = "exynos4210-spi.1",
1253 .parent = &exynos4_clk_mdout_spi1.clk,
1261 .enable = exynos4_clksrc_mask_peril1_ctrl, 1254 .enable = exynos4_clksrc_mask_peril1_ctrl,
1262 .ctrlbit = (1 << 20), 1255 .ctrlbit = (1 << 20),
1263 }, 1256 },
1264 .sources = &exynos4_clkset_group, 1257 .reg_div = { .reg = EXYNOS4_CLKDIV_PERIL1, .shift = 24, .size = 8 },
1265 .reg_src = { .reg = EXYNOS4_CLKSRC_PERIL1, .shift = 20, .size = 4 },
1266 .reg_div = { .reg = EXYNOS4_CLKDIV_PERIL1, .shift = 16, .size = 4 },
1267}; 1258};
1268 1259
1269static struct clksrc_clk exynos4_clk_sclk_spi2 = { 1260static struct clksrc_clk exynos4_clk_sclk_spi2 = {
1270 .clk = { 1261 .clk = {
1271 .name = "sclk_spi", 1262 .name = "sclk_spi",
1272 .devname = "s3c64xx-spi.2", 1263 .devname = "exynos4210-spi.2",
1264 .parent = &exynos4_clk_mdout_spi2.clk,
1273 .enable = exynos4_clksrc_mask_peril1_ctrl, 1265 .enable = exynos4_clksrc_mask_peril1_ctrl,
1274 .ctrlbit = (1 << 24), 1266 .ctrlbit = (1 << 24),
1275 }, 1267 },
1276 .sources = &exynos4_clkset_group, 1268 .reg_div = { .reg = EXYNOS4_CLKDIV_PERIL2, .shift = 8, .size = 8 },
1277 .reg_src = { .reg = EXYNOS4_CLKSRC_PERIL1, .shift = 24, .size = 4 },
1278 .reg_div = { .reg = EXYNOS4_CLKDIV_PERIL2, .shift = 0, .size = 4 },
1279}; 1269};
1280 1270
1281/* Clock initialization code */ 1271/* Clock initialization code */
@@ -1331,7 +1321,9 @@ static struct clksrc_clk *exynos4_clksrc_cdev[] = {
1331 &exynos4_clk_sclk_spi0, 1321 &exynos4_clk_sclk_spi0,
1332 &exynos4_clk_sclk_spi1, 1322 &exynos4_clk_sclk_spi1,
1333 &exynos4_clk_sclk_spi2, 1323 &exynos4_clk_sclk_spi2,
1334 1324 &exynos4_clk_mdout_spi0,
1325 &exynos4_clk_mdout_spi1,
1326 &exynos4_clk_mdout_spi2,
1335}; 1327};
1336 1328
1337static struct clk_lookup exynos4_clk_lookup[] = { 1329static struct clk_lookup exynos4_clk_lookup[] = {
@@ -1347,9 +1339,9 @@ static struct clk_lookup exynos4_clk_lookup[] = {
1347 CLKDEV_INIT("dma-pl330.0", "apb_pclk", &exynos4_clk_pdma0), 1339 CLKDEV_INIT("dma-pl330.0", "apb_pclk", &exynos4_clk_pdma0),
1348 CLKDEV_INIT("dma-pl330.1", "apb_pclk", &exynos4_clk_pdma1), 1340 CLKDEV_INIT("dma-pl330.1", "apb_pclk", &exynos4_clk_pdma1),
1349 CLKDEV_INIT("dma-pl330.2", "apb_pclk", &exynos4_clk_mdma1), 1341 CLKDEV_INIT("dma-pl330.2", "apb_pclk", &exynos4_clk_mdma1),
1350 CLKDEV_INIT("s3c64xx-spi.0", "spi_busclk0", &exynos4_clk_sclk_spi0.clk), 1342 CLKDEV_INIT("exynos4210-spi.0", "spi_busclk0", &exynos4_clk_sclk_spi0.clk),
1351 CLKDEV_INIT("s3c64xx-spi.1", "spi_busclk0", &exynos4_clk_sclk_spi1.clk), 1343 CLKDEV_INIT("exynos4210-spi.1", "spi_busclk0", &exynos4_clk_sclk_spi1.clk),
1352 CLKDEV_INIT("s3c64xx-spi.2", "spi_busclk0", &exynos4_clk_sclk_spi2.clk), 1344 CLKDEV_INIT("exynos4210-spi.2", "spi_busclk0", &exynos4_clk_sclk_spi2.clk),
1353}; 1345};
1354 1346
1355static int xtal_rate; 1347static int xtal_rate;
diff --git a/arch/arm/mach-exynos/clock-exynos4.h b/arch/arm/mach-exynos/clock-exynos4.h
index 28a11970118..bd12d5f8b63 100644
--- a/arch/arm/mach-exynos/clock-exynos4.h
+++ b/arch/arm/mach-exynos/clock-exynos4.h
@@ -23,6 +23,9 @@ extern struct clksrc_sources exynos4_clkset_group;
23extern struct clk *exynos4_clkset_aclk_top_list[]; 23extern struct clk *exynos4_clkset_aclk_top_list[];
24extern struct clk *exynos4_clkset_group_list[]; 24extern struct clk *exynos4_clkset_group_list[];
25 25
26extern struct clksrc_sources exynos4_clkset_mout_g2d0;
27extern struct clksrc_sources exynos4_clkset_mout_g2d1;
28
26extern int exynos4_clksrc_mask_fsys_ctrl(struct clk *clk, int enable); 29extern int exynos4_clksrc_mask_fsys_ctrl(struct clk *clk, int enable);
27extern int exynos4_clk_ip_fsys_ctrl(struct clk *clk, int enable); 30extern int exynos4_clk_ip_fsys_ctrl(struct clk *clk, int enable);
28extern int exynos4_clk_ip_lcd1_ctrl(struct clk *clk, int enable); 31extern int exynos4_clk_ip_lcd1_ctrl(struct clk *clk, int enable);
diff --git a/arch/arm/mach-exynos/clock-exynos4210.c b/arch/arm/mach-exynos/clock-exynos4210.c
index b8689ff60ba..fed4c26e9da 100644
--- a/arch/arm/mach-exynos/clock-exynos4210.c
+++ b/arch/arm/mach-exynos/clock-exynos4210.c
@@ -48,6 +48,32 @@ static struct clksrc_clk *sysclks[] = {
48 /* nothing here yet */ 48 /* nothing here yet */
49}; 49};
50 50
51static struct clksrc_clk exynos4210_clk_mout_g2d0 = {
52 .clk = {
53 .name = "mout_g2d0",
54 },
55 .sources = &exynos4_clkset_mout_g2d0,
56 .reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 0, .size = 1 },
57};
58
59static struct clksrc_clk exynos4210_clk_mout_g2d1 = {
60 .clk = {
61 .name = "mout_g2d1",
62 },
63 .sources = &exynos4_clkset_mout_g2d1,
64 .reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 4, .size = 1 },
65};
66
67static struct clk *exynos4210_clkset_mout_g2d_list[] = {
68 [0] = &exynos4210_clk_mout_g2d0.clk,
69 [1] = &exynos4210_clk_mout_g2d1.clk,
70};
71
72static struct clksrc_sources exynos4210_clkset_mout_g2d = {
73 .sources = exynos4210_clkset_mout_g2d_list,
74 .nr_sources = ARRAY_SIZE(exynos4210_clkset_mout_g2d_list),
75};
76
51static int exynos4_clksrc_mask_lcd1_ctrl(struct clk *clk, int enable) 77static int exynos4_clksrc_mask_lcd1_ctrl(struct clk *clk, int enable)
52{ 78{
53 return s5p_gatectrl(EXYNOS4210_CLKSRC_MASK_LCD1, clk, enable); 79 return s5p_gatectrl(EXYNOS4210_CLKSRC_MASK_LCD1, clk, enable);
@@ -74,6 +100,13 @@ static struct clksrc_clk clksrcs[] = {
74 .sources = &exynos4_clkset_group, 100 .sources = &exynos4_clkset_group,
75 .reg_src = { .reg = EXYNOS4210_CLKSRC_LCD1, .shift = 0, .size = 4 }, 101 .reg_src = { .reg = EXYNOS4210_CLKSRC_LCD1, .shift = 0, .size = 4 },
76 .reg_div = { .reg = EXYNOS4210_CLKDIV_LCD1, .shift = 0, .size = 4 }, 102 .reg_div = { .reg = EXYNOS4210_CLKDIV_LCD1, .shift = 0, .size = 4 },
103 }, {
104 .clk = {
105 .name = "sclk_fimg2d",
106 },
107 .sources = &exynos4210_clkset_mout_g2d,
108 .reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 8, .size = 1 },
109 .reg_div = { .reg = EXYNOS4_CLKDIV_IMAGE, .shift = 0, .size = 4 },
77 }, 110 },
78}; 111};
79 112
@@ -105,6 +138,10 @@ static struct clk init_clocks_off[] = {
105 .devname = SYSMMU_CLOCK_DEVNAME(fimd1, 11), 138 .devname = SYSMMU_CLOCK_DEVNAME(fimd1, 11),
106 .enable = exynos4_clk_ip_lcd1_ctrl, 139 .enable = exynos4_clk_ip_lcd1_ctrl,
107 .ctrlbit = (1 << 4), 140 .ctrlbit = (1 << 4),
141 }, {
142 .name = "fimg2d",
143 .enable = exynos4_clk_ip_image_ctrl,
144 .ctrlbit = (1 << 0),
108 }, 145 },
109}; 146};
110 147
diff --git a/arch/arm/mach-exynos/clock-exynos4212.c b/arch/arm/mach-exynos/clock-exynos4212.c
index da397d21bbc..8fba0b5fb8a 100644
--- a/arch/arm/mach-exynos/clock-exynos4212.c
+++ b/arch/arm/mach-exynos/clock-exynos4212.c
@@ -68,12 +68,45 @@ static struct clksrc_clk clk_mout_mpll_user = {
68 .reg_src = { .reg = EXYNOS4_CLKSRC_CPU, .shift = 24, .size = 1 }, 68 .reg_src = { .reg = EXYNOS4_CLKSRC_CPU, .shift = 24, .size = 1 },
69}; 69};
70 70
71static struct clksrc_clk exynos4x12_clk_mout_g2d0 = {
72 .clk = {
73 .name = "mout_g2d0",
74 },
75 .sources = &exynos4_clkset_mout_g2d0,
76 .reg_src = { .reg = EXYNOS4_CLKSRC_DMC, .shift = 20, .size = 1 },
77};
78
79static struct clksrc_clk exynos4x12_clk_mout_g2d1 = {
80 .clk = {
81 .name = "mout_g2d1",
82 },
83 .sources = &exynos4_clkset_mout_g2d1,
84 .reg_src = { .reg = EXYNOS4_CLKSRC_DMC, .shift = 24, .size = 1 },
85};
86
87static struct clk *exynos4x12_clkset_mout_g2d_list[] = {
88 [0] = &exynos4x12_clk_mout_g2d0.clk,
89 [1] = &exynos4x12_clk_mout_g2d1.clk,
90};
91
92static struct clksrc_sources exynos4x12_clkset_mout_g2d = {
93 .sources = exynos4x12_clkset_mout_g2d_list,
94 .nr_sources = ARRAY_SIZE(exynos4x12_clkset_mout_g2d_list),
95};
96
71static struct clksrc_clk *sysclks[] = { 97static struct clksrc_clk *sysclks[] = {
72 &clk_mout_mpll_user, 98 &clk_mout_mpll_user,
73}; 99};
74 100
75static struct clksrc_clk clksrcs[] = { 101static struct clksrc_clk clksrcs[] = {
76 /* nothing here yet */ 102 {
103 .clk = {
104 .name = "sclk_fimg2d",
105 },
106 .sources = &exynos4x12_clkset_mout_g2d,
107 .reg_src = { .reg = EXYNOS4_CLKSRC_DMC, .shift = 28, .size = 1 },
108 .reg_div = { .reg = EXYNOS4_CLKDIV_DMC1, .shift = 0, .size = 4 },
109 },
77}; 110};
78 111
79static struct clk init_clocks_off[] = { 112static struct clk init_clocks_off[] = {
@@ -102,7 +135,11 @@ static struct clk init_clocks_off[] = {
102 .devname = "exynos-fimc-lite.1", 135 .devname = "exynos-fimc-lite.1",
103 .enable = exynos4212_clk_ip_isp0_ctrl, 136 .enable = exynos4212_clk_ip_isp0_ctrl,
104 .ctrlbit = (1 << 3), 137 .ctrlbit = (1 << 3),
105 } 138 }, {
139 .name = "fimg2d",
140 .enable = exynos4_clk_ip_dmc_ctrl,
141 .ctrlbit = (1 << 23),
142 },
106}; 143};
107 144
108#ifdef CONFIG_PM_SLEEP 145#ifdef CONFIG_PM_SLEEP
diff --git a/arch/arm/mach-exynos/clock-exynos5.c b/arch/arm/mach-exynos/clock-exynos5.c
index fefa336be2b..774533c6706 100644
--- a/arch/arm/mach-exynos/clock-exynos5.c
+++ b/arch/arm/mach-exynos/clock-exynos5.c
@@ -131,6 +131,11 @@ static int exynos5_clksrc_mask_peric0_ctrl(struct clk *clk, int enable)
131 return s5p_gatectrl(EXYNOS5_CLKSRC_MASK_PERIC0, clk, enable); 131 return s5p_gatectrl(EXYNOS5_CLKSRC_MASK_PERIC0, clk, enable);
132} 132}
133 133
134static int exynos5_clksrc_mask_peric1_ctrl(struct clk *clk, int enable)
135{
136 return s5p_gatectrl(EXYNOS5_CLKSRC_MASK_PERIC1, clk, enable);
137}
138
134static int exynos5_clk_ip_acp_ctrl(struct clk *clk, int enable) 139static int exynos5_clk_ip_acp_ctrl(struct clk *clk, int enable)
135{ 140{
136 return s5p_gatectrl(EXYNOS5_CLKGATE_IP_ACP, clk, enable); 141 return s5p_gatectrl(EXYNOS5_CLKGATE_IP_ACP, clk, enable);
@@ -741,6 +746,24 @@ static struct clk exynos5_init_clocks_off[] = {
741 .enable = exynos5_clk_ip_peric_ctrl, 746 .enable = exynos5_clk_ip_peric_ctrl,
742 .ctrlbit = (1 << 14), 747 .ctrlbit = (1 << 14),
743 }, { 748 }, {
749 .name = "spi",
750 .devname = "exynos4210-spi.0",
751 .parent = &exynos5_clk_aclk_66.clk,
752 .enable = exynos5_clk_ip_peric_ctrl,
753 .ctrlbit = (1 << 16),
754 }, {
755 .name = "spi",
756 .devname = "exynos4210-spi.1",
757 .parent = &exynos5_clk_aclk_66.clk,
758 .enable = exynos5_clk_ip_peric_ctrl,
759 .ctrlbit = (1 << 17),
760 }, {
761 .name = "spi",
762 .devname = "exynos4210-spi.2",
763 .parent = &exynos5_clk_aclk_66.clk,
764 .enable = exynos5_clk_ip_peric_ctrl,
765 .ctrlbit = (1 << 18),
766 }, {
744 .name = SYSMMU_CLOCK_NAME, 767 .name = SYSMMU_CLOCK_NAME,
745 .devname = SYSMMU_CLOCK_DEVNAME(mfc_l, 0), 768 .devname = SYSMMU_CLOCK_DEVNAME(mfc_l, 0),
746 .enable = &exynos5_clk_ip_mfc_ctrl, 769 .enable = &exynos5_clk_ip_mfc_ctrl,
@@ -1034,6 +1057,69 @@ static struct clksrc_clk exynos5_clk_sclk_mmc3 = {
1034 .reg_div = { .reg = EXYNOS5_CLKDIV_FSYS2, .shift = 24, .size = 8 }, 1057 .reg_div = { .reg = EXYNOS5_CLKDIV_FSYS2, .shift = 24, .size = 8 },
1035}; 1058};
1036 1059
1060static struct clksrc_clk exynos5_clk_mdout_spi0 = {
1061 .clk = {
1062 .name = "mdout_spi",
1063 .devname = "exynos4210-spi.0",
1064 },
1065 .sources = &exynos5_clkset_group,
1066 .reg_src = { .reg = EXYNOS5_CLKSRC_PERIC1, .shift = 16, .size = 4 },
1067 .reg_div = { .reg = EXYNOS5_CLKDIV_PERIC1, .shift = 0, .size = 4 },
1068};
1069
1070static struct clksrc_clk exynos5_clk_mdout_spi1 = {
1071 .clk = {
1072 .name = "mdout_spi",
1073 .devname = "exynos4210-spi.1",
1074 },
1075 .sources = &exynos5_clkset_group,
1076 .reg_src = { .reg = EXYNOS5_CLKSRC_PERIC1, .shift = 20, .size = 4 },
1077 .reg_div = { .reg = EXYNOS5_CLKDIV_PERIC1, .shift = 16, .size = 4 },
1078};
1079
1080static struct clksrc_clk exynos5_clk_mdout_spi2 = {
1081 .clk = {
1082 .name = "mdout_spi",
1083 .devname = "exynos4210-spi.2",
1084 },
1085 .sources = &exynos5_clkset_group,
1086 .reg_src = { .reg = EXYNOS5_CLKSRC_PERIC1, .shift = 24, .size = 4 },
1087 .reg_div = { .reg = EXYNOS5_CLKDIV_PERIC2, .shift = 0, .size = 4 },
1088};
1089
1090static struct clksrc_clk exynos5_clk_sclk_spi0 = {
1091 .clk = {
1092 .name = "sclk_spi",
1093 .devname = "exynos4210-spi.0",
1094 .parent = &exynos5_clk_mdout_spi0.clk,
1095 .enable = exynos5_clksrc_mask_peric1_ctrl,
1096 .ctrlbit = (1 << 16),
1097 },
1098 .reg_div = { .reg = EXYNOS5_CLKDIV_PERIC1, .shift = 8, .size = 8 },
1099};
1100
1101static struct clksrc_clk exynos5_clk_sclk_spi1 = {
1102 .clk = {
1103 .name = "sclk_spi",
1104 .devname = "exynos4210-spi.1",
1105 .parent = &exynos5_clk_mdout_spi1.clk,
1106 .enable = exynos5_clksrc_mask_peric1_ctrl,
1107 .ctrlbit = (1 << 20),
1108 },
1109 .reg_div = { .reg = EXYNOS5_CLKDIV_PERIC1, .shift = 24, .size = 8 },
1110};
1111
1112static struct clksrc_clk exynos5_clk_sclk_spi2 = {
1113 .clk = {
1114 .name = "sclk_spi",
1115 .devname = "exynos4210-spi.2",
1116 .parent = &exynos5_clk_mdout_spi2.clk,
1117 .enable = exynos5_clksrc_mask_peric1_ctrl,
1118 .ctrlbit = (1 << 24),
1119 },
1120 .reg_div = { .reg = EXYNOS5_CLKDIV_PERIC2, .shift = 8, .size = 8 },
1121};
1122
1037static struct clksrc_clk exynos5_clksrcs[] = { 1123static struct clksrc_clk exynos5_clksrcs[] = {
1038 { 1124 {
1039 .clk = { 1125 .clk = {
@@ -1148,6 +1234,12 @@ static struct clksrc_clk *exynos5_sysclks[] = {
1148 &exynos5_clk_dout_mmc4, 1234 &exynos5_clk_dout_mmc4,
1149 &exynos5_clk_aclk_acp, 1235 &exynos5_clk_aclk_acp,
1150 &exynos5_clk_pclk_acp, 1236 &exynos5_clk_pclk_acp,
1237 &exynos5_clk_sclk_spi0,
1238 &exynos5_clk_sclk_spi1,
1239 &exynos5_clk_sclk_spi2,
1240 &exynos5_clk_mdout_spi0,
1241 &exynos5_clk_mdout_spi1,
1242 &exynos5_clk_mdout_spi2,
1151}; 1243};
1152 1244
1153static struct clk *exynos5_clk_cdev[] = { 1245static struct clk *exynos5_clk_cdev[] = {
@@ -1176,6 +1268,9 @@ static struct clk_lookup exynos5_clk_lookup[] = {
1176 CLKDEV_INIT("exynos4-sdhci.1", "mmc_busclk.2", &exynos5_clk_sclk_mmc1.clk), 1268 CLKDEV_INIT("exynos4-sdhci.1", "mmc_busclk.2", &exynos5_clk_sclk_mmc1.clk),
1177 CLKDEV_INIT("exynos4-sdhci.2", "mmc_busclk.2", &exynos5_clk_sclk_mmc2.clk), 1269 CLKDEV_INIT("exynos4-sdhci.2", "mmc_busclk.2", &exynos5_clk_sclk_mmc2.clk),
1178 CLKDEV_INIT("exynos4-sdhci.3", "mmc_busclk.2", &exynos5_clk_sclk_mmc3.clk), 1270 CLKDEV_INIT("exynos4-sdhci.3", "mmc_busclk.2", &exynos5_clk_sclk_mmc3.clk),
1271 CLKDEV_INIT("exynos4210-spi.0", "spi_busclk0", &exynos5_clk_sclk_spi0.clk),
1272 CLKDEV_INIT("exynos4210-spi.1", "spi_busclk0", &exynos5_clk_sclk_spi1.clk),
1273 CLKDEV_INIT("exynos4210-spi.2", "spi_busclk0", &exynos5_clk_sclk_spi2.clk),
1179 CLKDEV_INIT("dma-pl330.0", "apb_pclk", &exynos5_clk_pdma0), 1274 CLKDEV_INIT("dma-pl330.0", "apb_pclk", &exynos5_clk_pdma0),
1180 CLKDEV_INIT("dma-pl330.1", "apb_pclk", &exynos5_clk_pdma1), 1275 CLKDEV_INIT("dma-pl330.1", "apb_pclk", &exynos5_clk_pdma1),
1181 CLKDEV_INIT("dma-pl330.2", "apb_pclk", &exynos5_clk_mdma1), 1276 CLKDEV_INIT("dma-pl330.2", "apb_pclk", &exynos5_clk_mdma1),
diff --git a/arch/arm/mach-exynos/common.c b/arch/arm/mach-exynos/common.c
index 742edd3bbec..4eb39cdf75e 100644
--- a/arch/arm/mach-exynos/common.c
+++ b/arch/arm/mach-exynos/common.c
@@ -540,7 +540,8 @@ static struct irq_domain_ops combiner_irq_domain_ops = {
540 .map = combiner_irq_domain_map, 540 .map = combiner_irq_domain_map,
541}; 541};
542 542
543void __init combiner_init(void __iomem *combiner_base, struct device_node *np) 543static void __init combiner_init(void __iomem *combiner_base,
544 struct device_node *np)
544{ 545{
545 int i, irq, irq_base; 546 int i, irq, irq_base;
546 unsigned int max_nr, nr_irq; 547 unsigned int max_nr, nr_irq;
@@ -712,31 +713,6 @@ static int __init exynos4_l2x0_cache_init(void)
712early_initcall(exynos4_l2x0_cache_init); 713early_initcall(exynos4_l2x0_cache_init);
713#endif 714#endif
714 715
715static int __init exynos5_l2_cache_init(void)
716{
717 unsigned int val;
718
719 if (!soc_is_exynos5250())
720 return 0;
721
722 asm volatile("mrc p15, 0, %0, c1, c0, 0\n"
723 "bic %0, %0, #(1 << 2)\n" /* cache disable */
724 "mcr p15, 0, %0, c1, c0, 0\n"
725 "mrc p15, 1, %0, c9, c0, 2\n"
726 : "=r"(val));
727
728 val |= (1 << 9) | (1 << 5) | (2 << 6) | (2 << 0);
729
730 asm volatile("mcr p15, 1, %0, c9, c0, 2\n" : : "r"(val));
731 asm volatile("mrc p15, 0, %0, c1, c0, 0\n"
732 "orr %0, %0, #(1 << 2)\n" /* cache enable */
733 "mcr p15, 0, %0, c1, c0, 0\n"
734 : : "r"(val));
735
736 return 0;
737}
738early_initcall(exynos5_l2_cache_init);
739
740static int __init exynos_init(void) 716static int __init exynos_init(void)
741{ 717{
742 printk(KERN_INFO "EXYNOS: Initializing architecture\n"); 718 printk(KERN_INFO "EXYNOS: Initializing architecture\n");
diff --git a/arch/arm/mach-exynos/include/mach/irqs.h b/arch/arm/mach-exynos/include/mach/irqs.h
index 7a4b4789eb7..35bced6f909 100644
--- a/arch/arm/mach-exynos/include/mach/irqs.h
+++ b/arch/arm/mach-exynos/include/mach/irqs.h
@@ -195,6 +195,10 @@
195#define IRQ_IIC6 EXYNOS4_IRQ_IIC6 195#define IRQ_IIC6 EXYNOS4_IRQ_IIC6
196#define IRQ_IIC7 EXYNOS4_IRQ_IIC7 196#define IRQ_IIC7 EXYNOS4_IRQ_IIC7
197 197
198#define IRQ_SPI0 EXYNOS4_IRQ_SPI0
199#define IRQ_SPI1 EXYNOS4_IRQ_SPI1
200#define IRQ_SPI2 EXYNOS4_IRQ_SPI2
201
198#define IRQ_USB_HOST EXYNOS4_IRQ_USB_HOST 202#define IRQ_USB_HOST EXYNOS4_IRQ_USB_HOST
199#define IRQ_OTG EXYNOS4_IRQ_USB_HSOTG 203#define IRQ_OTG EXYNOS4_IRQ_USB_HSOTG
200 204
diff --git a/arch/arm/mach-exynos/include/mach/map.h b/arch/arm/mach-exynos/include/mach/map.h
index ca4aa89aa46..c72b675b3e4 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -154,6 +154,9 @@
154#define EXYNOS4_PA_SPI0 0x13920000 154#define EXYNOS4_PA_SPI0 0x13920000
155#define EXYNOS4_PA_SPI1 0x13930000 155#define EXYNOS4_PA_SPI1 0x13930000
156#define EXYNOS4_PA_SPI2 0x13940000 156#define EXYNOS4_PA_SPI2 0x13940000
157#define EXYNOS5_PA_SPI0 0x12D20000
158#define EXYNOS5_PA_SPI1 0x12D30000
159#define EXYNOS5_PA_SPI2 0x12D40000
157 160
158#define EXYNOS4_PA_GPIO1 0x11400000 161#define EXYNOS4_PA_GPIO1 0x11400000
159#define EXYNOS4_PA_GPIO2 0x11000000 162#define EXYNOS4_PA_GPIO2 0x11000000
diff --git a/arch/arm/mach-exynos/include/mach/regs-pmu.h b/arch/arm/mach-exynos/include/mach/regs-pmu.h
index 43a99e6f56a..d4e392b811a 100644
--- a/arch/arm/mach-exynos/include/mach/regs-pmu.h
+++ b/arch/arm/mach-exynos/include/mach/regs-pmu.h
@@ -232,6 +232,11 @@
232 232
233#define EXYNOS5_USB_CFG S5P_PMUREG(0x0230) 233#define EXYNOS5_USB_CFG S5P_PMUREG(0x0230)
234 234
235#define EXYNOS5_AUTO_WDTRESET_DISABLE S5P_PMUREG(0x0408)
236#define EXYNOS5_MASK_WDTRESET_REQUEST S5P_PMUREG(0x040C)
237
238#define EXYNOS5_SYS_WDTRESET (1 << 20)
239
235#define EXYNOS5_ARM_CORE0_SYS_PWR_REG S5P_PMUREG(0x1000) 240#define EXYNOS5_ARM_CORE0_SYS_PWR_REG S5P_PMUREG(0x1000)
236#define EXYNOS5_DIS_IRQ_ARM_CORE0_LOCAL_SYS_PWR_REG S5P_PMUREG(0x1004) 241#define EXYNOS5_DIS_IRQ_ARM_CORE0_LOCAL_SYS_PWR_REG S5P_PMUREG(0x1004)
237#define EXYNOS5_DIS_IRQ_ARM_CORE0_CENTRAL_SYS_PWR_REG S5P_PMUREG(0x1008) 242#define EXYNOS5_DIS_IRQ_ARM_CORE0_CENTRAL_SYS_PWR_REG S5P_PMUREG(0x1008)
diff --git a/arch/arm/mach-exynos/include/mach/regs-usb-phy.h b/arch/arm/mach-exynos/include/mach/regs-usb-phy.h
index c337cf3a71b..07277735252 100644
--- a/arch/arm/mach-exynos/include/mach/regs-usb-phy.h
+++ b/arch/arm/mach-exynos/include/mach/regs-usb-phy.h
@@ -35,11 +35,21 @@
35#define PHY1_COMMON_ON_N (1 << 7) 35#define PHY1_COMMON_ON_N (1 << 7)
36#define PHY0_COMMON_ON_N (1 << 4) 36#define PHY0_COMMON_ON_N (1 << 4)
37#define PHY0_ID_PULLUP (1 << 2) 37#define PHY0_ID_PULLUP (1 << 2)
38#define CLKSEL_MASK (0x3 << 0) 38
39#define CLKSEL_SHIFT (0) 39#define EXYNOS4_CLKSEL_SHIFT (0)
40#define CLKSEL_48M (0x0 << 0) 40
41#define CLKSEL_12M (0x2 << 0) 41#define EXYNOS4210_CLKSEL_MASK (0x3 << 0)
42#define CLKSEL_24M (0x3 << 0) 42#define EXYNOS4210_CLKSEL_48M (0x0 << 0)
43#define EXYNOS4210_CLKSEL_12M (0x2 << 0)
44#define EXYNOS4210_CLKSEL_24M (0x3 << 0)
45
46#define EXYNOS4X12_CLKSEL_MASK (0x7 << 0)
47#define EXYNOS4X12_CLKSEL_9600K (0x0 << 0)
48#define EXYNOS4X12_CLKSEL_10M (0x1 << 0)
49#define EXYNOS4X12_CLKSEL_12M (0x2 << 0)
50#define EXYNOS4X12_CLKSEL_19200K (0x3 << 0)
51#define EXYNOS4X12_CLKSEL_20M (0x4 << 0)
52#define EXYNOS4X12_CLKSEL_24M (0x5 << 0)
43 53
44#define EXYNOS4_RSTCON EXYNOS4_HSOTG_PHYREG(0x08) 54#define EXYNOS4_RSTCON EXYNOS4_HSOTG_PHYREG(0x08)
45#define HOST_LINK_PORT_SWRST_MASK (0xf << 6) 55#define HOST_LINK_PORT_SWRST_MASK (0xf << 6)
diff --git a/arch/arm/mach-exynos/include/mach/spi-clocks.h b/arch/arm/mach-exynos/include/mach/spi-clocks.h
deleted file mode 100644
index c71a5fba6a8..00000000000
--- a/arch/arm/mach-exynos/include/mach/spi-clocks.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/* linux/arch/arm/mach-exynos4/include/mach/spi-clocks.h
2 *
3 * Copyright (C) 2011 Samsung Electronics Co. Ltd.
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 version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#ifndef __ASM_ARCH_SPI_CLKS_H
11#define __ASM_ARCH_SPI_CLKS_H __FILE__
12
13/* Must source from SCLK_SPI */
14#define EXYNOS_SPI_SRCCLK_SCLK 0
15
16#endif /* __ASM_ARCH_SPI_CLKS_H */
diff --git a/arch/arm/mach-exynos/mach-exynos4-dt.c b/arch/arm/mach-exynos/mach-exynos4-dt.c
index e7e9743543a..b2b5d5faa74 100644
--- a/arch/arm/mach-exynos/mach-exynos4-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos4-dt.c
@@ -55,6 +55,12 @@ static const struct of_dev_auxdata exynos4210_auxdata_lookup[] __initconst = {
55 "exynos4-sdhci.3", NULL), 55 "exynos4-sdhci.3", NULL),
56 OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS4_PA_IIC(0), 56 OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS4_PA_IIC(0),
57 "s3c2440-i2c.0", NULL), 57 "s3c2440-i2c.0", NULL),
58 OF_DEV_AUXDATA("samsung,exynos4210-spi", EXYNOS4_PA_SPI0,
59 "exynos4210-spi.0", NULL),
60 OF_DEV_AUXDATA("samsung,exynos4210-spi", EXYNOS4_PA_SPI1,
61 "exynos4210-spi.1", NULL),
62 OF_DEV_AUXDATA("samsung,exynos4210-spi", EXYNOS4_PA_SPI2,
63 "exynos4210-spi.2", NULL),
58 OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA0, "dma-pl330.0", NULL), 64 OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA0, "dma-pl330.0", NULL),
59 OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA1, "dma-pl330.1", NULL), 65 OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA1, "dma-pl330.1", NULL),
60 {}, 66 {},
diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c
index 7b1e11a228c..ef770bc2318 100644
--- a/arch/arm/mach-exynos/mach-exynos5-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
@@ -47,6 +47,12 @@ static const struct of_dev_auxdata exynos5250_auxdata_lookup[] __initconst = {
47 "s3c2440-i2c.0", NULL), 47 "s3c2440-i2c.0", NULL),
48 OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS5_PA_IIC(1), 48 OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS5_PA_IIC(1),
49 "s3c2440-i2c.1", NULL), 49 "s3c2440-i2c.1", NULL),
50 OF_DEV_AUXDATA("samsung,exynos4210-spi", EXYNOS5_PA_SPI0,
51 "exynos4210-spi.0", NULL),
52 OF_DEV_AUXDATA("samsung,exynos4210-spi", EXYNOS5_PA_SPI1,
53 "exynos4210-spi.1", NULL),
54 OF_DEV_AUXDATA("samsung,exynos4210-spi", EXYNOS5_PA_SPI2,
55 "exynos4210-spi.2", NULL),
50 OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_PDMA0, "dma-pl330.0", NULL), 56 OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_PDMA0, "dma-pl330.0", NULL),
51 OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_PDMA1, "dma-pl330.1", NULL), 57 OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_PDMA1, "dma-pl330.1", NULL),
52 OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_MDMA1, "dma-pl330.2", NULL), 58 OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_MDMA1, "dma-pl330.2", NULL),
diff --git a/arch/arm/mach-exynos/mach-nuri.c b/arch/arm/mach-exynos/mach-nuri.c
index 656f8fc9add..ea785fcaf6c 100644
--- a/arch/arm/mach-exynos/mach-nuri.c
+++ b/arch/arm/mach-exynos/mach-nuri.c
@@ -50,7 +50,6 @@
50#include <plat/gpio-cfg.h> 50#include <plat/gpio-cfg.h>
51#include <plat/iic.h> 51#include <plat/iic.h>
52#include <plat/mfc.h> 52#include <plat/mfc.h>
53#include <plat/pd.h>
54#include <plat/fimc-core.h> 53#include <plat/fimc-core.h>
55#include <plat/camport.h> 54#include <plat/camport.h>
56#include <plat/mipi_csis.h> 55#include <plat/mipi_csis.h>
@@ -1067,12 +1066,8 @@ static struct platform_device nuri_max8903_device = {
1067static void __init nuri_power_init(void) 1066static void __init nuri_power_init(void)
1068{ 1067{
1069 int gpio; 1068 int gpio;
1070 int irq_base = IRQ_GPIO_END + 1;
1071 int ta_en = 0; 1069 int ta_en = 0;
1072 1070
1073 nuri_max8997_pdata.irq_base = irq_base;
1074 irq_base += MAX8997_IRQ_NR;
1075
1076 gpio = EXYNOS4_GPX0(7); 1071 gpio = EXYNOS4_GPX0(7);
1077 gpio_request(gpio, "AP_PMIC_IRQ"); 1072 gpio_request(gpio, "AP_PMIC_IRQ");
1078 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf)); 1073 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
@@ -1342,9 +1337,8 @@ static struct platform_device *nuri_devices[] __initdata = {
1342 1337
1343static void __init nuri_map_io(void) 1338static void __init nuri_map_io(void)
1344{ 1339{
1345 clk_xusbxti.rate = 24000000;
1346 exynos_init_io(NULL, 0); 1340 exynos_init_io(NULL, 0);
1347 s3c24xx_init_clocks(24000000); 1341 s3c24xx_init_clocks(clk_xusbxti.rate);
1348 s3c24xx_init_uarts(nuri_uartcfgs, ARRAY_SIZE(nuri_uartcfgs)); 1342 s3c24xx_init_uarts(nuri_uartcfgs, ARRAY_SIZE(nuri_uartcfgs));
1349} 1343}
1350 1344
diff --git a/arch/arm/mach-exynos/mach-origen.c b/arch/arm/mach-exynos/mach-origen.c
index f5572be9d7b..4e574c24581 100644
--- a/arch/arm/mach-exynos/mach-origen.c
+++ b/arch/arm/mach-exynos/mach-origen.c
@@ -9,6 +9,7 @@
9*/ 9*/
10 10
11#include <linux/serial_core.h> 11#include <linux/serial_core.h>
12#include <linux/leds.h>
12#include <linux/gpio.h> 13#include <linux/gpio.h>
13#include <linux/mmc/host.h> 14#include <linux/mmc/host.h>
14#include <linux/platform_device.h> 15#include <linux/platform_device.h>
@@ -21,6 +22,7 @@
21#include <linux/mfd/max8997.h> 22#include <linux/mfd/max8997.h>
22#include <linux/lcd.h> 23#include <linux/lcd.h>
23#include <linux/rfkill-gpio.h> 24#include <linux/rfkill-gpio.h>
25#include <linux/platform_data/s3c-hsotg.h>
24 26
25#include <asm/mach/arch.h> 27#include <asm/mach/arch.h>
26#include <asm/hardware/gic.h> 28#include <asm/hardware/gic.h>
@@ -38,9 +40,9 @@
38#include <plat/clock.h> 40#include <plat/clock.h>
39#include <plat/gpio-cfg.h> 41#include <plat/gpio-cfg.h>
40#include <plat/backlight.h> 42#include <plat/backlight.h>
41#include <plat/pd.h>
42#include <plat/fb.h> 43#include <plat/fb.h>
43#include <plat/mfc.h> 44#include <plat/mfc.h>
45#include <plat/hdmi.h>
44 46
45#include <mach/ohci.h> 47#include <mach/ohci.h>
46#include <mach/map.h> 48#include <mach/map.h>
@@ -425,7 +427,6 @@ static struct max8997_platform_data __initdata origen_max8997_pdata = {
425 .buck1_gpiodvs = false, 427 .buck1_gpiodvs = false,
426 .buck2_gpiodvs = false, 428 .buck2_gpiodvs = false,
427 .buck5_gpiodvs = false, 429 .buck5_gpiodvs = false,
428 .irq_base = IRQ_GPIO_END + 1,
429 430
430 .ignore_gpiodvs_side_effect = true, 431 .ignore_gpiodvs_side_effect = true,
431 .buck125_default_idx = 0x0, 432 .buck125_default_idx = 0x0,
@@ -499,6 +500,37 @@ static void __init origen_ohci_init(void)
499 exynos4_ohci_set_platdata(pdata); 500 exynos4_ohci_set_platdata(pdata);
500} 501}
501 502
503/* USB OTG */
504static struct s3c_hsotg_plat origen_hsotg_pdata;
505
506static struct gpio_led origen_gpio_leds[] = {
507 {
508 .name = "origen::status1",
509 .default_trigger = "heartbeat",
510 .gpio = EXYNOS4_GPX1(3),
511 .active_low = 1,
512 },
513 {
514 .name = "origen::status2",
515 .default_trigger = "mmc0",
516 .gpio = EXYNOS4_GPX1(4),
517 .active_low = 1,
518 },
519};
520
521static struct gpio_led_platform_data origen_gpio_led_info = {
522 .leds = origen_gpio_leds,
523 .num_leds = ARRAY_SIZE(origen_gpio_leds),
524};
525
526static struct platform_device origen_leds_gpio = {
527 .name = "leds-gpio",
528 .id = -1,
529 .dev = {
530 .platform_data = &origen_gpio_led_info,
531 },
532};
533
502static struct gpio_keys_button origen_gpio_keys_table[] = { 534static struct gpio_keys_button origen_gpio_keys_table[] = {
503 { 535 {
504 .code = KEY_MENU, 536 .code = KEY_MENU,
@@ -655,6 +687,7 @@ static struct platform_device *origen_devices[] __initdata = {
655 &s3c_device_hsmmc0, 687 &s3c_device_hsmmc0,
656 &s3c_device_i2c0, 688 &s3c_device_i2c0,
657 &s3c_device_rtc, 689 &s3c_device_rtc,
690 &s3c_device_usb_hsotg,
658 &s3c_device_wdt, 691 &s3c_device_wdt,
659 &s5p_device_ehci, 692 &s5p_device_ehci,
660 &s5p_device_fimc0, 693 &s5p_device_fimc0,
@@ -677,6 +710,7 @@ static struct platform_device *origen_devices[] __initdata = {
677 &exynos4_device_ohci, 710 &exynos4_device_ohci,
678 &origen_device_gpiokeys, 711 &origen_device_gpiokeys,
679 &origen_lcd_hv070wsa, 712 &origen_lcd_hv070wsa,
713 &origen_leds_gpio,
680 &origen_device_bluetooth, 714 &origen_device_bluetooth,
681}; 715};
682 716
@@ -701,6 +735,11 @@ static void __init origen_bt_setup(void)
701 s3c_gpio_setpull(EXYNOS4_GPX2(2), S3C_GPIO_PULL_NONE); 735 s3c_gpio_setpull(EXYNOS4_GPX2(2), S3C_GPIO_PULL_NONE);
702} 736}
703 737
738/* I2C module and id for HDMIPHY */
739static struct i2c_board_info hdmiphy_info = {
740 I2C_BOARD_INFO("hdmiphy-exynos4210", 0x38),
741};
742
704static void s5p_tv_setup(void) 743static void s5p_tv_setup(void)
705{ 744{
706 /* Direct HPD to HDMI chip */ 745 /* Direct HPD to HDMI chip */
@@ -712,7 +751,7 @@ static void s5p_tv_setup(void)
712static void __init origen_map_io(void) 751static void __init origen_map_io(void)
713{ 752{
714 exynos_init_io(NULL, 0); 753 exynos_init_io(NULL, 0);
715 s3c24xx_init_clocks(24000000); 754 s3c24xx_init_clocks(clk_xusbxti.rate);
716 s3c24xx_init_uarts(origen_uartcfgs, ARRAY_SIZE(origen_uartcfgs)); 755 s3c24xx_init_uarts(origen_uartcfgs, ARRAY_SIZE(origen_uartcfgs));
717} 756}
718 757
@@ -744,10 +783,11 @@ static void __init origen_machine_init(void)
744 783
745 origen_ehci_init(); 784 origen_ehci_init();
746 origen_ohci_init(); 785 origen_ohci_init();
747 clk_xusbxti.rate = 24000000; 786 s3c_hsotg_set_platdata(&origen_hsotg_pdata);
748 787
749 s5p_tv_setup(); 788 s5p_tv_setup();
750 s5p_i2c_hdmiphy_set_platdata(NULL); 789 s5p_i2c_hdmiphy_set_platdata(NULL);
790 s5p_hdmi_set_platdata(&hdmiphy_info, NULL, 0);
751 791
752#ifdef CONFIG_DRM_EXYNOS 792#ifdef CONFIG_DRM_EXYNOS
753 s5p_device_fimd0.dev.platform_data = &drm_fimd_pdata; 793 s5p_device_fimd0.dev.platform_data = &drm_fimd_pdata;
diff --git a/arch/arm/mach-exynos/mach-smdk4x12.c b/arch/arm/mach-exynos/mach-smdk4x12.c
index fb09c70e195..b26beb13ebe 100644
--- a/arch/arm/mach-exynos/mach-smdk4x12.c
+++ b/arch/arm/mach-exynos/mach-smdk4x12.c
@@ -13,12 +13,14 @@
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/input.h> 14#include <linux/input.h>
15#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/lcd.h>
16#include <linux/mfd/max8997.h> 17#include <linux/mfd/max8997.h>
17#include <linux/mmc/host.h> 18#include <linux/mmc/host.h>
18#include <linux/platform_device.h> 19#include <linux/platform_device.h>
19#include <linux/pwm_backlight.h> 20#include <linux/pwm_backlight.h>
20#include <linux/regulator/machine.h> 21#include <linux/regulator/machine.h>
21#include <linux/serial_core.h> 22#include <linux/serial_core.h>
23#include <linux/platform_data/s3c-hsotg.h>
22 24
23#include <asm/mach/arch.h> 25#include <asm/mach/arch.h>
24#include <asm/hardware/gic.h> 26#include <asm/hardware/gic.h>
@@ -28,15 +30,18 @@
28#include <plat/clock.h> 30#include <plat/clock.h>
29#include <plat/cpu.h> 31#include <plat/cpu.h>
30#include <plat/devs.h> 32#include <plat/devs.h>
33#include <plat/fb.h>
31#include <plat/gpio-cfg.h> 34#include <plat/gpio-cfg.h>
32#include <plat/iic.h> 35#include <plat/iic.h>
33#include <plat/keypad.h> 36#include <plat/keypad.h>
34#include <plat/mfc.h> 37#include <plat/mfc.h>
38#include <plat/regs-fb.h>
35#include <plat/regs-serial.h> 39#include <plat/regs-serial.h>
36#include <plat/sdhci.h> 40#include <plat/sdhci.h>
37 41
38#include <mach/map.h> 42#include <mach/map.h>
39 43
44#include <drm/exynos_drm.h>
40#include "common.h" 45#include "common.h"
41 46
42/* Following are default values for UCON, ULCON and UFCON UART registers */ 47/* Following are default values for UCON, ULCON and UFCON UART registers */
@@ -219,8 +224,10 @@ static struct platform_pwm_backlight_data smdk4x12_bl_data = {
219 224
220static uint32_t smdk4x12_keymap[] __initdata = { 225static uint32_t smdk4x12_keymap[] __initdata = {
221 /* KEY(row, col, keycode) */ 226 /* KEY(row, col, keycode) */
222 KEY(1, 0, KEY_D), KEY(1, 1, KEY_A), KEY(1, 2, KEY_B), 227 KEY(1, 3, KEY_1), KEY(1, 4, KEY_2), KEY(1, 5, KEY_3),
223 KEY(1, 3, KEY_E), KEY(1, 4, KEY_C) 228 KEY(1, 6, KEY_4), KEY(1, 7, KEY_5),
229 KEY(2, 5, KEY_D), KEY(2, 6, KEY_A), KEY(2, 7, KEY_B),
230 KEY(0, 7, KEY_E), KEY(0, 5, KEY_C)
224}; 231};
225 232
226static struct matrix_keymap_data smdk4x12_keymap_data __initdata = { 233static struct matrix_keymap_data smdk4x12_keymap_data __initdata = {
@@ -230,10 +237,62 @@ static struct matrix_keymap_data smdk4x12_keymap_data __initdata = {
230 237
231static struct samsung_keypad_platdata smdk4x12_keypad_data __initdata = { 238static struct samsung_keypad_platdata smdk4x12_keypad_data __initdata = {
232 .keymap_data = &smdk4x12_keymap_data, 239 .keymap_data = &smdk4x12_keymap_data,
233 .rows = 2, 240 .rows = 3,
234 .cols = 5, 241 .cols = 8,
235}; 242};
236 243
244#ifdef CONFIG_DRM_EXYNOS
245static struct exynos_drm_fimd_pdata drm_fimd_pdata = {
246 .panel = {
247 .timing = {
248 .left_margin = 8,
249 .right_margin = 8,
250 .upper_margin = 6,
251 .lower_margin = 6,
252 .hsync_len = 6,
253 .vsync_len = 4,
254 .xres = 480,
255 .yres = 800,
256 },
257 },
258 .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
259 .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
260 .default_win = 0,
261 .bpp = 32,
262};
263#else
264static struct s3c_fb_pd_win smdk4x12_fb_win0 = {
265 .xres = 480,
266 .yres = 800,
267 .virtual_x = 480,
268 .virtual_y = 800 * 2,
269 .max_bpp = 32,
270 .default_bpp = 24,
271};
272
273static struct fb_videomode smdk4x12_lcd_timing = {
274 .left_margin = 8,
275 .right_margin = 8,
276 .upper_margin = 6,
277 .lower_margin = 6,
278 .hsync_len = 6,
279 .vsync_len = 4,
280 .xres = 480,
281 .yres = 800,
282};
283
284static struct s3c_fb_platdata smdk4x12_lcd_pdata __initdata = {
285 .win[0] = &smdk4x12_fb_win0,
286 .vtiming = &smdk4x12_lcd_timing,
287 .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
288 .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
289 .setup_gpio = exynos4_fimd0_gpio_setup_24bpp,
290};
291#endif
292
293/* USB OTG */
294static struct s3c_hsotg_plat smdk4x12_hsotg_pdata;
295
237static struct platform_device *smdk4x12_devices[] __initdata = { 296static struct platform_device *smdk4x12_devices[] __initdata = {
238 &s3c_device_hsmmc2, 297 &s3c_device_hsmmc2,
239 &s3c_device_hsmmc3, 298 &s3c_device_hsmmc3,
@@ -242,22 +301,25 @@ static struct platform_device *smdk4x12_devices[] __initdata = {
242 &s3c_device_i2c3, 301 &s3c_device_i2c3,
243 &s3c_device_i2c7, 302 &s3c_device_i2c7,
244 &s3c_device_rtc, 303 &s3c_device_rtc,
304 &s3c_device_usb_hsotg,
245 &s3c_device_wdt, 305 &s3c_device_wdt,
246 &s5p_device_fimc0, 306 &s5p_device_fimc0,
247 &s5p_device_fimc1, 307 &s5p_device_fimc1,
248 &s5p_device_fimc2, 308 &s5p_device_fimc2,
249 &s5p_device_fimc3, 309 &s5p_device_fimc3,
250 &s5p_device_fimc_md, 310 &s5p_device_fimc_md,
311 &s5p_device_fimd0,
251 &s5p_device_mfc, 312 &s5p_device_mfc,
252 &s5p_device_mfc_l, 313 &s5p_device_mfc_l,
253 &s5p_device_mfc_r, 314 &s5p_device_mfc_r,
315#ifdef CONFIG_DRM_EXYNOS
316 &exynos_device_drm,
317#endif
254 &samsung_device_keypad, 318 &samsung_device_keypad,
255}; 319};
256 320
257static void __init smdk4x12_map_io(void) 321static void __init smdk4x12_map_io(void)
258{ 322{
259 clk_xusbxti.rate = 24000000;
260
261 exynos_init_io(NULL, 0); 323 exynos_init_io(NULL, 0);
262 s3c24xx_init_clocks(clk_xusbxti.rate); 324 s3c24xx_init_clocks(clk_xusbxti.rate);
263 s3c24xx_init_uarts(smdk4x12_uartcfgs, ARRAY_SIZE(smdk4x12_uartcfgs)); 325 s3c24xx_init_uarts(smdk4x12_uartcfgs, ARRAY_SIZE(smdk4x12_uartcfgs));
@@ -293,6 +355,15 @@ static void __init smdk4x12_machine_init(void)
293 s3c_sdhci2_set_platdata(&smdk4x12_hsmmc2_pdata); 355 s3c_sdhci2_set_platdata(&smdk4x12_hsmmc2_pdata);
294 s3c_sdhci3_set_platdata(&smdk4x12_hsmmc3_pdata); 356 s3c_sdhci3_set_platdata(&smdk4x12_hsmmc3_pdata);
295 357
358 s3c_hsotg_set_platdata(&smdk4x12_hsotg_pdata);
359
360#ifdef CONFIG_DRM_EXYNOS
361 s5p_device_fimd0.dev.platform_data = &drm_fimd_pdata;
362 exynos4_fimd0_gpio_setup_24bpp();
363#else
364 s5p_fimd0_set_platdata(&smdk4x12_lcd_pdata);
365#endif
366
296 platform_add_devices(smdk4x12_devices, ARRAY_SIZE(smdk4x12_devices)); 367 platform_add_devices(smdk4x12_devices, ARRAY_SIZE(smdk4x12_devices));
297} 368}
298 369
diff --git a/arch/arm/mach-exynos/mach-smdkv310.c b/arch/arm/mach-exynos/mach-smdkv310.c
index 262e9e446a9..73f2bce097e 100644
--- a/arch/arm/mach-exynos/mach-smdkv310.c
+++ b/arch/arm/mach-exynos/mach-smdkv310.c
@@ -19,6 +19,7 @@
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/input.h> 20#include <linux/input.h>
21#include <linux/pwm_backlight.h> 21#include <linux/pwm_backlight.h>
22#include <linux/platform_data/s3c-hsotg.h>
22 23
23#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
24#include <asm/hardware/gic.h> 25#include <asm/hardware/gic.h>
@@ -34,12 +35,12 @@
34#include <plat/keypad.h> 35#include <plat/keypad.h>
35#include <plat/sdhci.h> 36#include <plat/sdhci.h>
36#include <plat/iic.h> 37#include <plat/iic.h>
37#include <plat/pd.h>
38#include <plat/gpio-cfg.h> 38#include <plat/gpio-cfg.h>
39#include <plat/backlight.h> 39#include <plat/backlight.h>
40#include <plat/mfc.h> 40#include <plat/mfc.h>
41#include <plat/ehci.h> 41#include <plat/ehci.h>
42#include <plat/clock.h> 42#include <plat/clock.h>
43#include <plat/hdmi.h>
43 44
44#include <mach/map.h> 45#include <mach/map.h>
45#include <mach/ohci.h> 46#include <mach/ohci.h>
@@ -271,6 +272,15 @@ static void __init smdkv310_ohci_init(void)
271 exynos4_ohci_set_platdata(pdata); 272 exynos4_ohci_set_platdata(pdata);
272} 273}
273 274
275/* USB OTG */
276static struct s3c_hsotg_plat smdkv310_hsotg_pdata;
277
278/* Audio device */
279static struct platform_device smdkv310_device_audio = {
280 .name = "smdk-audio",
281 .id = -1,
282};
283
274static struct platform_device *smdkv310_devices[] __initdata = { 284static struct platform_device *smdkv310_devices[] __initdata = {
275 &s3c_device_hsmmc0, 285 &s3c_device_hsmmc0,
276 &s3c_device_hsmmc1, 286 &s3c_device_hsmmc1,
@@ -279,6 +289,7 @@ static struct platform_device *smdkv310_devices[] __initdata = {
279 &s3c_device_i2c1, 289 &s3c_device_i2c1,
280 &s5p_device_i2c_hdmiphy, 290 &s5p_device_i2c_hdmiphy,
281 &s3c_device_rtc, 291 &s3c_device_rtc,
292 &s3c_device_usb_hsotg,
282 &s3c_device_wdt, 293 &s3c_device_wdt,
283 &s5p_device_ehci, 294 &s5p_device_ehci,
284 &s5p_device_fimc0, 295 &s5p_device_fimc0,
@@ -302,6 +313,7 @@ static struct platform_device *smdkv310_devices[] __initdata = {
302 &samsung_asoc_dma, 313 &samsung_asoc_dma,
303 &samsung_asoc_idma, 314 &samsung_asoc_idma,
304 &s5p_device_fimd0, 315 &s5p_device_fimd0,
316 &smdkv310_device_audio,
305 &smdkv310_lcd_lte480wv, 317 &smdkv310_lcd_lte480wv,
306 &smdkv310_smsc911x, 318 &smdkv310_smsc911x,
307 &exynos4_device_ahci, 319 &exynos4_device_ahci,
@@ -343,6 +355,11 @@ static struct platform_pwm_backlight_data smdkv310_bl_data = {
343 .pwm_period_ns = 1000, 355 .pwm_period_ns = 1000,
344}; 356};
345 357
358/* I2C module and id for HDMIPHY */
359static struct i2c_board_info hdmiphy_info = {
360 I2C_BOARD_INFO("hdmiphy-exynos4210", 0x38),
361};
362
346static void s5p_tv_setup(void) 363static void s5p_tv_setup(void)
347{ 364{
348 /* direct HPD to HDMI chip */ 365 /* direct HPD to HDMI chip */
@@ -354,7 +371,7 @@ static void s5p_tv_setup(void)
354static void __init smdkv310_map_io(void) 371static void __init smdkv310_map_io(void)
355{ 372{
356 exynos_init_io(NULL, 0); 373 exynos_init_io(NULL, 0);
357 s3c24xx_init_clocks(24000000); 374 s3c24xx_init_clocks(clk_xusbxti.rate);
358 s3c24xx_init_uarts(smdkv310_uartcfgs, ARRAY_SIZE(smdkv310_uartcfgs)); 375 s3c24xx_init_uarts(smdkv310_uartcfgs, ARRAY_SIZE(smdkv310_uartcfgs));
359} 376}
360 377
@@ -377,6 +394,7 @@ static void __init smdkv310_machine_init(void)
377 394
378 s5p_tv_setup(); 395 s5p_tv_setup();
379 s5p_i2c_hdmiphy_set_platdata(NULL); 396 s5p_i2c_hdmiphy_set_platdata(NULL);
397 s5p_hdmi_set_platdata(&hdmiphy_info, NULL, 0);
380 398
381 samsung_keypad_set_platdata(&smdkv310_keypad_data); 399 samsung_keypad_set_platdata(&smdkv310_keypad_data);
382 400
@@ -390,7 +408,7 @@ static void __init smdkv310_machine_init(void)
390 408
391 smdkv310_ehci_init(); 409 smdkv310_ehci_init();
392 smdkv310_ohci_init(); 410 smdkv310_ohci_init();
393 clk_xusbxti.rate = 24000000; 411 s3c_hsotg_set_platdata(&smdkv310_hsotg_pdata);
394 412
395 platform_add_devices(smdkv310_devices, ARRAY_SIZE(smdkv310_devices)); 413 platform_add_devices(smdkv310_devices, ARRAY_SIZE(smdkv310_devices));
396} 414}
@@ -417,5 +435,6 @@ MACHINE_START(SMDKC210, "SMDKC210")
417 .init_machine = smdkv310_machine_init, 435 .init_machine = smdkv310_machine_init,
418 .init_late = exynos_init_late, 436 .init_late = exynos_init_late,
419 .timer = &exynos4_timer, 437 .timer = &exynos4_timer,
438 .reserve = &smdkv310_reserve,
420 .restart = exynos4_restart, 439 .restart = exynos4_restart,
421MACHINE_END 440MACHINE_END
diff --git a/arch/arm/mach-exynos/mach-universal_c210.c b/arch/arm/mach-exynos/mach-universal_c210.c
index cd92fa86ba4..4d1f40d44ed 100644
--- a/arch/arm/mach-exynos/mach-universal_c210.c
+++ b/arch/arm/mach-exynos/mach-universal_c210.c
@@ -39,7 +39,6 @@
39#include <plat/fb.h> 39#include <plat/fb.h>
40#include <plat/mfc.h> 40#include <plat/mfc.h>
41#include <plat/sdhci.h> 41#include <plat/sdhci.h>
42#include <plat/pd.h>
43#include <plat/regs-fb-v4.h> 42#include <plat/regs-fb-v4.h>
44#include <plat/fimc-core.h> 43#include <plat/fimc-core.h>
45#include <plat/s5p-time.h> 44#include <plat/s5p-time.h>
@@ -1100,9 +1099,8 @@ static struct platform_device *universal_devices[] __initdata = {
1100 1099
1101static void __init universal_map_io(void) 1100static void __init universal_map_io(void)
1102{ 1101{
1103 clk_xusbxti.rate = 24000000;
1104 exynos_init_io(NULL, 0); 1102 exynos_init_io(NULL, 0);
1105 s3c24xx_init_clocks(24000000); 1103 s3c24xx_init_clocks(clk_xusbxti.rate);
1106 s3c24xx_init_uarts(universal_uartcfgs, ARRAY_SIZE(universal_uartcfgs)); 1104 s3c24xx_init_uarts(universal_uartcfgs, ARRAY_SIZE(universal_uartcfgs));
1107 s5p_set_timer_source(S5P_PWM2, S5P_PWM4); 1105 s5p_set_timer_source(S5P_PWM2, S5P_PWM4);
1108} 1106}
diff --git a/arch/arm/mach-exynos/pm_domains.c b/arch/arm/mach-exynos/pm_domains.c
index 373c3c00d24..c0bc83a7663 100644
--- a/arch/arm/mach-exynos/pm_domains.c
+++ b/arch/arm/mach-exynos/pm_domains.c
@@ -115,7 +115,7 @@ static __init int exynos_pm_dt_parse_domains(void)
115} 115}
116#endif /* CONFIG_OF */ 116#endif /* CONFIG_OF */
117 117
118static __init void exynos_pm_add_dev_to_genpd(struct platform_device *pdev, 118static __init __maybe_unused void exynos_pm_add_dev_to_genpd(struct platform_device *pdev,
119 struct exynos_pm_domain *pd) 119 struct exynos_pm_domain *pd)
120{ 120{
121 if (pdev->dev.bus) { 121 if (pdev->dev.bus) {
diff --git a/arch/arm/mach-exynos/pmu.c b/arch/arm/mach-exynos/pmu.c
index 4aacb66f716..3a48c852be6 100644
--- a/arch/arm/mach-exynos/pmu.c
+++ b/arch/arm/mach-exynos/pmu.c
@@ -315,7 +315,7 @@ static struct exynos_pmu_conf exynos5250_pmu_config[] = {
315 { PMU_TABLE_END,}, 315 { PMU_TABLE_END,},
316}; 316};
317 317
318void __iomem *exynos5_list_both_cnt_feed[] = { 318static void __iomem *exynos5_list_both_cnt_feed[] = {
319 EXYNOS5_ARM_CORE0_OPTION, 319 EXYNOS5_ARM_CORE0_OPTION,
320 EXYNOS5_ARM_CORE1_OPTION, 320 EXYNOS5_ARM_CORE1_OPTION,
321 EXYNOS5_ARM_COMMON_OPTION, 321 EXYNOS5_ARM_COMMON_OPTION,
@@ -329,7 +329,7 @@ void __iomem *exynos5_list_both_cnt_feed[] = {
329 EXYNOS5_TOP_PWR_SYSMEM_OPTION, 329 EXYNOS5_TOP_PWR_SYSMEM_OPTION,
330}; 330};
331 331
332void __iomem *exynos5_list_diable_wfi_wfe[] = { 332static void __iomem *exynos5_list_diable_wfi_wfe[] = {
333 EXYNOS5_ARM_CORE1_OPTION, 333 EXYNOS5_ARM_CORE1_OPTION,
334 EXYNOS5_FSYS_ARM_OPTION, 334 EXYNOS5_FSYS_ARM_OPTION,
335 EXYNOS5_ISP_ARM_OPTION, 335 EXYNOS5_ISP_ARM_OPTION,
@@ -390,6 +390,8 @@ void exynos_sys_powerdown_conf(enum sys_powerdown mode)
390 390
391static int __init exynos_pmu_init(void) 391static int __init exynos_pmu_init(void)
392{ 392{
393 unsigned int value;
394
393 exynos_pmu_config = exynos4210_pmu_config; 395 exynos_pmu_config = exynos4210_pmu_config;
394 396
395 if (soc_is_exynos4210()) { 397 if (soc_is_exynos4210()) {
@@ -399,6 +401,18 @@ static int __init exynos_pmu_init(void)
399 exynos_pmu_config = exynos4x12_pmu_config; 401 exynos_pmu_config = exynos4x12_pmu_config;
400 pr_info("EXYNOS4x12 PMU Initialize\n"); 402 pr_info("EXYNOS4x12 PMU Initialize\n");
401 } else if (soc_is_exynos5250()) { 403 } else if (soc_is_exynos5250()) {
404 /*
405 * When SYS_WDTRESET is set, watchdog timer reset request
406 * is ignored by power management unit.
407 */
408 value = __raw_readl(EXYNOS5_AUTO_WDTRESET_DISABLE);
409 value &= ~EXYNOS5_SYS_WDTRESET;
410 __raw_writel(value, EXYNOS5_AUTO_WDTRESET_DISABLE);
411
412 value = __raw_readl(EXYNOS5_MASK_WDTRESET_REQUEST);
413 value &= ~EXYNOS5_SYS_WDTRESET;
414 __raw_writel(value, EXYNOS5_MASK_WDTRESET_REQUEST);
415
402 exynos_pmu_config = exynos5250_pmu_config; 416 exynos_pmu_config = exynos5250_pmu_config;
403 pr_info("EXYNOS5250 PMU Initialize\n"); 417 pr_info("EXYNOS5250 PMU Initialize\n");
404 } else { 418 } else {
diff --git a/arch/arm/mach-exynos/setup-spi.c b/arch/arm/mach-exynos/setup-spi.c
index 833ff40ee0e..4999829d1c6 100644
--- a/arch/arm/mach-exynos/setup-spi.c
+++ b/arch/arm/mach-exynos/setup-spi.c
@@ -9,21 +9,10 @@
9 */ 9 */
10 10
11#include <linux/gpio.h> 11#include <linux/gpio.h>
12#include <linux/platform_device.h>
13
14#include <plat/gpio-cfg.h> 12#include <plat/gpio-cfg.h>
15#include <plat/s3c64xx-spi.h>
16 13
17#ifdef CONFIG_S3C64XX_DEV_SPI0 14#ifdef CONFIG_S3C64XX_DEV_SPI0
18struct s3c64xx_spi_info s3c64xx_spi0_pdata __initdata = { 15int s3c64xx_spi0_cfg_gpio(void)
19 .fifo_lvl_mask = 0x1ff,
20 .rx_lvl_offset = 15,
21 .high_speed = 1,
22 .clk_from_cmu = true,
23 .tx_st_done = 25,
24};
25
26int s3c64xx_spi0_cfg_gpio(struct platform_device *dev)
27{ 16{
28 s3c_gpio_cfgpin(EXYNOS4_GPB(0), S3C_GPIO_SFN(2)); 17 s3c_gpio_cfgpin(EXYNOS4_GPB(0), S3C_GPIO_SFN(2));
29 s3c_gpio_setpull(EXYNOS4_GPB(0), S3C_GPIO_PULL_UP); 18 s3c_gpio_setpull(EXYNOS4_GPB(0), S3C_GPIO_PULL_UP);
@@ -34,15 +23,7 @@ int s3c64xx_spi0_cfg_gpio(struct platform_device *dev)
34#endif 23#endif
35 24
36#ifdef CONFIG_S3C64XX_DEV_SPI1 25#ifdef CONFIG_S3C64XX_DEV_SPI1
37struct s3c64xx_spi_info s3c64xx_spi1_pdata __initdata = { 26int s3c64xx_spi1_cfg_gpio(void)
38 .fifo_lvl_mask = 0x7f,
39 .rx_lvl_offset = 15,
40 .high_speed = 1,
41 .clk_from_cmu = true,
42 .tx_st_done = 25,
43};
44
45int s3c64xx_spi1_cfg_gpio(struct platform_device *dev)
46{ 27{
47 s3c_gpio_cfgpin(EXYNOS4_GPB(4), S3C_GPIO_SFN(2)); 28 s3c_gpio_cfgpin(EXYNOS4_GPB(4), S3C_GPIO_SFN(2));
48 s3c_gpio_setpull(EXYNOS4_GPB(4), S3C_GPIO_PULL_UP); 29 s3c_gpio_setpull(EXYNOS4_GPB(4), S3C_GPIO_PULL_UP);
@@ -53,15 +34,7 @@ int s3c64xx_spi1_cfg_gpio(struct platform_device *dev)
53#endif 34#endif
54 35
55#ifdef CONFIG_S3C64XX_DEV_SPI2 36#ifdef CONFIG_S3C64XX_DEV_SPI2
56struct s3c64xx_spi_info s3c64xx_spi2_pdata __initdata = { 37int s3c64xx_spi2_cfg_gpio(void)
57 .fifo_lvl_mask = 0x7f,
58 .rx_lvl_offset = 15,
59 .high_speed = 1,
60 .clk_from_cmu = true,
61 .tx_st_done = 25,
62};
63
64int s3c64xx_spi2_cfg_gpio(struct platform_device *dev)
65{ 38{
66 s3c_gpio_cfgpin(EXYNOS4_GPC1(1), S3C_GPIO_SFN(5)); 39 s3c_gpio_cfgpin(EXYNOS4_GPC1(1), S3C_GPIO_SFN(5));
67 s3c_gpio_setpull(EXYNOS4_GPC1(1), S3C_GPIO_PULL_UP); 40 s3c_gpio_setpull(EXYNOS4_GPC1(1), S3C_GPIO_PULL_UP);
diff --git a/arch/arm/mach-exynos/setup-usb-phy.c b/arch/arm/mach-exynos/setup-usb-phy.c
index 1af0a7f44e0..b81cc569a8d 100644
--- a/arch/arm/mach-exynos/setup-usb-phy.c
+++ b/arch/arm/mach-exynos/setup-usb-phy.c
@@ -31,27 +31,55 @@ static void exynos4210_usb_phy_clkset(struct platform_device *pdev)
31 struct clk *xusbxti_clk; 31 struct clk *xusbxti_clk;
32 u32 phyclk; 32 u32 phyclk;
33 33
34 /* set clock frequency for PLL */
35 phyclk = readl(EXYNOS4_PHYCLK) & ~CLKSEL_MASK;
36
37 xusbxti_clk = clk_get(&pdev->dev, "xusbxti"); 34 xusbxti_clk = clk_get(&pdev->dev, "xusbxti");
38 if (xusbxti_clk && !IS_ERR(xusbxti_clk)) { 35 if (xusbxti_clk && !IS_ERR(xusbxti_clk)) {
39 switch (clk_get_rate(xusbxti_clk)) { 36 if (soc_is_exynos4210()) {
40 case 12 * MHZ: 37 /* set clock frequency for PLL */
41 phyclk |= CLKSEL_12M; 38 phyclk = readl(EXYNOS4_PHYCLK) & ~EXYNOS4210_CLKSEL_MASK;
42 break; 39
43 case 24 * MHZ: 40 switch (clk_get_rate(xusbxti_clk)) {
44 phyclk |= CLKSEL_24M; 41 case 12 * MHZ:
45 break; 42 phyclk |= EXYNOS4210_CLKSEL_12M;
46 default: 43 break;
47 case 48 * MHZ: 44 case 48 * MHZ:
48 /* default reference clock */ 45 phyclk |= EXYNOS4210_CLKSEL_48M;
49 break; 46 break;
47 default:
48 case 24 * MHZ:
49 phyclk |= EXYNOS4210_CLKSEL_24M;
50 break;
51 }
52 writel(phyclk, EXYNOS4_PHYCLK);
53 } else if (soc_is_exynos4212() || soc_is_exynos4412()) {
54 /* set clock frequency for PLL */
55 phyclk = readl(EXYNOS4_PHYCLK) & ~EXYNOS4X12_CLKSEL_MASK;
56
57 switch (clk_get_rate(xusbxti_clk)) {
58 case 9600 * KHZ:
59 phyclk |= EXYNOS4X12_CLKSEL_9600K;
60 break;
61 case 10 * MHZ:
62 phyclk |= EXYNOS4X12_CLKSEL_10M;
63 break;
64 case 12 * MHZ:
65 phyclk |= EXYNOS4X12_CLKSEL_12M;
66 break;
67 case 19200 * KHZ:
68 phyclk |= EXYNOS4X12_CLKSEL_19200K;
69 break;
70 case 20 * MHZ:
71 phyclk |= EXYNOS4X12_CLKSEL_20M;
72 break;
73 default:
74 case 24 * MHZ:
75 /* default reference clock */
76 phyclk |= EXYNOS4X12_CLKSEL_24M;
77 break;
78 }
79 writel(phyclk, EXYNOS4_PHYCLK);
50 } 80 }
51 clk_put(xusbxti_clk); 81 clk_put(xusbxti_clk);
52 } 82 }
53
54 writel(phyclk, EXYNOS4_PHYCLK);
55} 83}
56 84
57static int exynos4210_usb_phy0_init(struct platform_device *pdev) 85static int exynos4210_usb_phy0_init(struct platform_device *pdev)
diff --git a/arch/arm/mach-gemini/irq.c b/arch/arm/mach-gemini/irq.c
index ca70e5fcc7a..020852d3bdd 100644
--- a/arch/arm/mach-gemini/irq.c
+++ b/arch/arm/mach-gemini/irq.c
@@ -17,6 +17,7 @@
17#include <linux/sched.h> 17#include <linux/sched.h>
18#include <asm/irq.h> 18#include <asm/irq.h>
19#include <asm/mach/irq.h> 19#include <asm/mach/irq.h>
20#include <asm/system_misc.h>
20#include <mach/hardware.h> 21#include <mach/hardware.h>
21 22
22#define IRQ_SOURCE(base_addr) (base_addr + 0x00) 23#define IRQ_SOURCE(base_addr) (base_addr + 0x00)
diff --git a/arch/arm/mach-highbank/Makefile b/arch/arm/mach-highbank/Makefile
index ded4652ada8..3ec8bdd25d0 100644
--- a/arch/arm/mach-highbank/Makefile
+++ b/arch/arm/mach-highbank/Makefile
@@ -1,4 +1,4 @@
1obj-y := clock.o highbank.o system.o smc.o 1obj-y := highbank.o system.o smc.o
2 2
3plus_sec := $(call as-instr,.arch_extension sec,+sec) 3plus_sec := $(call as-instr,.arch_extension sec,+sec)
4AFLAGS_smc.o :=-Wa,-march=armv7-a$(plus_sec) 4AFLAGS_smc.o :=-Wa,-march=armv7-a$(plus_sec)
diff --git a/arch/arm/mach-highbank/clock.c b/arch/arm/mach-highbank/clock.c
deleted file mode 100644
index c25a2ae4fde..00000000000
--- a/arch/arm/mach-highbank/clock.c
+++ /dev/null
@@ -1,62 +0,0 @@
1/*
2 * Copyright 2011 Calxeda, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include <linux/module.h>
17#include <linux/kernel.h>
18#include <linux/errno.h>
19#include <linux/clk.h>
20#include <linux/clkdev.h>
21
22struct clk {
23 unsigned long rate;
24};
25
26int clk_enable(struct clk *clk)
27{
28 return 0;
29}
30
31void clk_disable(struct clk *clk)
32{}
33
34unsigned long clk_get_rate(struct clk *clk)
35{
36 return clk->rate;
37}
38
39long clk_round_rate(struct clk *clk, unsigned long rate)
40{
41 return clk->rate;
42}
43
44int clk_set_rate(struct clk *clk, unsigned long rate)
45{
46 return 0;
47}
48
49static struct clk eclk = { .rate = 200000000 };
50static struct clk pclk = { .rate = 150000000 };
51
52static struct clk_lookup lookups[] = {
53 { .clk = &pclk, .con_id = "apb_pclk", },
54 { .clk = &pclk, .dev_id = "sp804", },
55 { .clk = &eclk, .dev_id = "ffe0e000.sdhci", },
56 { .clk = &pclk, .dev_id = "fff36000.serial", },
57};
58
59void __init highbank_clocks_init(void)
60{
61 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
62}
diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
index 8777612b1a4..d75b0a78d88 100644
--- a/arch/arm/mach-highbank/highbank.c
+++ b/arch/arm/mach-highbank/highbank.c
@@ -105,6 +105,11 @@ static void __init highbank_init_irq(void)
105#endif 105#endif
106} 106}
107 107
108static struct clk_lookup lookup = {
109 .dev_id = "sp804",
110 .con_id = NULL,
111};
112
108static void __init highbank_timer_init(void) 113static void __init highbank_timer_init(void)
109{ 114{
110 int irq; 115 int irq;
@@ -122,6 +127,8 @@ static void __init highbank_timer_init(void)
122 irq = irq_of_parse_and_map(np, 0); 127 irq = irq_of_parse_and_map(np, 0);
123 128
124 highbank_clocks_init(); 129 highbank_clocks_init();
130 lookup.clk = of_clk_get(np, 0);
131 clkdev_add(&lookup);
125 132
126 sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1"); 133 sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1");
127 sp804_clockevents_init(timer_base, irq, "timer0"); 134 sp804_clockevents_init(timer_base, irq, "timer0");
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index eff4db5de0d..afd542ad6f9 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -52,6 +52,7 @@ config SOC_IMX25
52 select ARCH_MX25 52 select ARCH_MX25
53 select COMMON_CLK 53 select COMMON_CLK
54 select CPU_ARM926T 54 select CPU_ARM926T
55 select HAVE_CAN_FLEXCAN if CAN
55 select ARCH_MXC_IOMUX_V3 56 select ARCH_MXC_IOMUX_V3
56 select MXC_AVIC 57 select MXC_AVIC
57 58
@@ -73,12 +74,13 @@ config SOC_IMX31
73 74
74config SOC_IMX35 75config SOC_IMX35
75 bool 76 bool
76 select CPU_V6 77 select CPU_V6K
77 select ARCH_MXC_IOMUX_V3 78 select ARCH_MXC_IOMUX_V3
78 select COMMON_CLK 79 select COMMON_CLK
79 select HAVE_EPIT 80 select HAVE_EPIT
80 select MXC_AVIC 81 select MXC_AVIC
81 select SMP_ON_UP if SMP 82 select SMP_ON_UP if SMP
83 select HAVE_CAN_FLEXCAN if CAN
82 84
83config SOC_IMX5 85config SOC_IMX5
84 select CPU_V7 86 select CPU_V7
@@ -105,6 +107,7 @@ config SOC_IMX53
105 select SOC_IMX5 107 select SOC_IMX5
106 select ARCH_MX5 108 select ARCH_MX5
107 select ARCH_MX53 109 select ARCH_MX53
110 select HAVE_CAN_FLEXCAN if CAN
108 111
109if ARCH_IMX_V4_V5 112if ARCH_IMX_V4_V5
110 113
@@ -158,7 +161,6 @@ config MACH_MX25_3DS
158 select IMX_HAVE_PLATFORM_IMX2_WDT 161 select IMX_HAVE_PLATFORM_IMX2_WDT
159 select IMX_HAVE_PLATFORM_IMXDI_RTC 162 select IMX_HAVE_PLATFORM_IMXDI_RTC
160 select IMX_HAVE_PLATFORM_IMX_I2C 163 select IMX_HAVE_PLATFORM_IMX_I2C
161 select IMX_HAVE_PLATFORM_IMX_SSI
162 select IMX_HAVE_PLATFORM_IMX_FB 164 select IMX_HAVE_PLATFORM_IMX_FB
163 select IMX_HAVE_PLATFORM_IMX_KEYPAD 165 select IMX_HAVE_PLATFORM_IMX_KEYPAD
164 select IMX_HAVE_PLATFORM_IMX_UART 166 select IMX_HAVE_PLATFORM_IMX_UART
@@ -380,7 +382,6 @@ config MACH_IMX27IPCAM
380config MACH_IMX27_DT 382config MACH_IMX27_DT
381 bool "Support i.MX27 platforms from device tree" 383 bool "Support i.MX27 platforms from device tree"
382 select SOC_IMX27 384 select SOC_IMX27
383 select USE_OF
384 help 385 help
385 Include support for Freescale i.MX27 based platforms 386 Include support for Freescale i.MX27 based platforms
386 using the device tree for discovery 387 using the device tree for discovery
@@ -557,6 +558,14 @@ config MACH_BUG
557 Include support for BUGBase 1.3 platform. This includes specific 558 Include support for BUGBase 1.3 platform. This includes specific
558 configurations for the board and its peripherals. 559 configurations for the board and its peripherals.
559 560
561config MACH_IMX31_DT
562 bool "Support i.MX31 platforms from device tree"
563 select SOC_IMX31
564 select USE_OF
565 help
566 Include support for Freescale i.MX31 based platforms
567 using the device tree for discovery.
568
560comment "MX35 platforms:" 569comment "MX35 platforms:"
561 570
562config MACH_PCM043 571config MACH_PCM043
@@ -589,6 +598,7 @@ config MACH_MX35_3DS
589 select IMX_HAVE_PLATFORM_IPU_CORE 598 select IMX_HAVE_PLATFORM_IPU_CORE
590 select IMX_HAVE_PLATFORM_MXC_EHCI 599 select IMX_HAVE_PLATFORM_MXC_EHCI
591 select IMX_HAVE_PLATFORM_MXC_NAND 600 select IMX_HAVE_PLATFORM_MXC_NAND
601 select IMX_HAVE_PLATFORM_MXC_RTC
592 select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX 602 select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
593 help 603 help
594 Include support for MX35PDK platform. This includes specific 604 Include support for MX35PDK platform. This includes specific
@@ -663,7 +673,6 @@ comment "i.MX51 machines:"
663config MACH_IMX51_DT 673config MACH_IMX51_DT
664 bool "Support i.MX51 platforms from device tree" 674 bool "Support i.MX51 platforms from device tree"
665 select SOC_IMX51 675 select SOC_IMX51
666 select USE_OF
667 select MACH_MX51_BABBAGE 676 select MACH_MX51_BABBAGE
668 help 677 help
669 Include support for Freescale i.MX51 based platforms 678 Include support for Freescale i.MX51 based platforms
@@ -759,7 +768,6 @@ comment "i.MX53 machines:"
759config MACH_IMX53_DT 768config MACH_IMX53_DT
760 bool "Support i.MX53 platforms from device tree" 769 bool "Support i.MX53 platforms from device tree"
761 select SOC_IMX53 770 select SOC_IMX53
762 select USE_OF
763 select MACH_MX53_ARD 771 select MACH_MX53_ARD
764 select MACH_MX53_EVK 772 select MACH_MX53_EVK
765 select MACH_MX53_LOCO 773 select MACH_MX53_LOCO
@@ -826,13 +834,14 @@ config SOC_IMX6Q
826 select COMMON_CLK 834 select COMMON_CLK
827 select CPU_V7 835 select CPU_V7
828 select HAVE_ARM_SCU 836 select HAVE_ARM_SCU
837 select HAVE_CAN_FLEXCAN if CAN
829 select HAVE_IMX_GPC 838 select HAVE_IMX_GPC
830 select HAVE_IMX_MMDC 839 select HAVE_IMX_MMDC
831 select HAVE_IMX_SRC 840 select HAVE_IMX_SRC
832 select HAVE_SMP 841 select HAVE_SMP
842 select MFD_ANATOP
833 select PINCTRL 843 select PINCTRL
834 select PINCTRL_IMX6Q 844 select PINCTRL_IMX6Q
835 select USE_OF
836 845
837 help 846 help
838 This enables support for Freescale i.MX6 Quad processor. 847 This enables support for Freescale i.MX6 Quad processor.
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index ff29421414f..d004d37ad9d 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -9,7 +9,8 @@ obj-$(CONFIG_SOC_IMX27) += clk-imx27.o mm-imx27.o ehci-imx27.o
9obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clk-imx31.o iomux-imx31.o ehci-imx31.o pm-imx3.o 9obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clk-imx31.o iomux-imx31.o ehci-imx31.o pm-imx3.o
10obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clk-imx35.o ehci-imx35.o pm-imx3.o 10obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clk-imx35.o ehci-imx35.o pm-imx3.o
11 11
12obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o mm-imx5.o clk-imx51-imx53.o ehci-imx5.o pm-imx5.o cpu_op-mx51.o 12imx5-pm-$(CONFIG_PM) += pm-imx5.o
13obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o mm-imx5.o clk-imx51-imx53.o ehci-imx5.o $(imx5-pm-y) cpu_op-mx51.o
13 14
14obj-$(CONFIG_COMMON_CLK) += clk-pllv1.o clk-pllv2.o clk-pllv3.o clk-gate2.o \ 15obj-$(CONFIG_COMMON_CLK) += clk-pllv1.o clk-pllv2.o clk-pllv3.o clk-gate2.o \
15 clk-pfd.o clk-busy.o 16 clk-pfd.o clk-busy.o
@@ -57,6 +58,7 @@ obj-$(CONFIG_MACH_QONG) += mach-qong.o
57obj-$(CONFIG_MACH_ARMADILLO5X0) += mach-armadillo5x0.o 58obj-$(CONFIG_MACH_ARMADILLO5X0) += mach-armadillo5x0.o
58obj-$(CONFIG_MACH_KZM_ARM11_01) += mach-kzm_arm11_01.o 59obj-$(CONFIG_MACH_KZM_ARM11_01) += mach-kzm_arm11_01.o
59obj-$(CONFIG_MACH_BUG) += mach-bug.o 60obj-$(CONFIG_MACH_BUG) += mach-bug.o
61obj-$(CONFIG_MACH_IMX31_DT) += imx31-dt.o
60 62
61# i.MX35 based machines 63# i.MX35 based machines
62obj-$(CONFIG_MACH_PCM043) += mach-pcm043.o 64obj-$(CONFIG_MACH_PCM043) += mach-pcm043.o
@@ -69,14 +71,13 @@ obj-$(CONFIG_DEBUG_LL) += lluart.o
69obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o 71obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o
70obj-$(CONFIG_HAVE_IMX_MMDC) += mmdc.o 72obj-$(CONFIG_HAVE_IMX_MMDC) += mmdc.o
71obj-$(CONFIG_HAVE_IMX_SRC) += src.o 73obj-$(CONFIG_HAVE_IMX_SRC) += src.o
72obj-$(CONFIG_CPU_V7) += head-v7.o 74AFLAGS_headsmp.o :=-Wa,-march=armv7-a
73AFLAGS_head-v7.o :=-Wa,-march=armv7-a 75obj-$(CONFIG_SMP) += headsmp.o platsmp.o
74obj-$(CONFIG_SMP) += platsmp.o
75obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o 76obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
76obj-$(CONFIG_SOC_IMX6Q) += clk-imx6q.o mach-imx6q.o 77obj-$(CONFIG_SOC_IMX6Q) += clk-imx6q.o mach-imx6q.o
77 78
78ifeq ($(CONFIG_PM),y) 79ifeq ($(CONFIG_PM),y)
79obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o 80obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o headsmp.o
80endif 81endif
81 82
82# i.MX5 based machines 83# i.MX5 based machines
diff --git a/arch/arm/mach-imx/clk-imx27.c b/arch/arm/mach-imx/clk-imx27.c
index 295cbd7c08d..f69ca468004 100644
--- a/arch/arm/mach-imx/clk-imx27.c
+++ b/arch/arm/mach-imx/clk-imx27.c
@@ -223,7 +223,7 @@ int __init mx27_clocks_init(unsigned long fref)
223 clk_register_clkdev(clk[per3_gate], "per", "imx-fb.0"); 223 clk_register_clkdev(clk[per3_gate], "per", "imx-fb.0");
224 clk_register_clkdev(clk[lcdc_ipg_gate], "ipg", "imx-fb.0"); 224 clk_register_clkdev(clk[lcdc_ipg_gate], "ipg", "imx-fb.0");
225 clk_register_clkdev(clk[lcdc_ahb_gate], "ahb", "imx-fb.0"); 225 clk_register_clkdev(clk[lcdc_ahb_gate], "ahb", "imx-fb.0");
226 clk_register_clkdev(clk[csi_ahb_gate], NULL, "mx2-camera.0"); 226 clk_register_clkdev(clk[csi_ahb_gate], "ahb", "mx2-camera.0");
227 clk_register_clkdev(clk[usb_div], "per", "fsl-usb2-udc"); 227 clk_register_clkdev(clk[usb_div], "per", "fsl-usb2-udc");
228 clk_register_clkdev(clk[usb_ipg_gate], "ipg", "fsl-usb2-udc"); 228 clk_register_clkdev(clk[usb_ipg_gate], "ipg", "fsl-usb2-udc");
229 clk_register_clkdev(clk[usb_ahb_gate], "ahb", "fsl-usb2-udc"); 229 clk_register_clkdev(clk[usb_ahb_gate], "ahb", "fsl-usb2-udc");
@@ -250,13 +250,15 @@ int __init mx27_clocks_init(unsigned long fref)
250 clk_register_clkdev(clk[i2c2_ipg_gate], NULL, "imx-i2c.1"); 250 clk_register_clkdev(clk[i2c2_ipg_gate], NULL, "imx-i2c.1");
251 clk_register_clkdev(clk[owire_ipg_gate], NULL, "mxc_w1.0"); 251 clk_register_clkdev(clk[owire_ipg_gate], NULL, "mxc_w1.0");
252 clk_register_clkdev(clk[kpp_ipg_gate], NULL, "imx-keypad"); 252 clk_register_clkdev(clk[kpp_ipg_gate], NULL, "imx-keypad");
253 clk_register_clkdev(clk[emma_ahb_gate], "ahb", "imx-emma"); 253 clk_register_clkdev(clk[emma_ahb_gate], "emma-ahb", "mx2-camera.0");
254 clk_register_clkdev(clk[emma_ipg_gate], "ipg", "imx-emma"); 254 clk_register_clkdev(clk[emma_ipg_gate], "emma-ipg", "mx2-camera.0");
255 clk_register_clkdev(clk[emma_ahb_gate], "ahb", "m2m-emmaprp.0");
256 clk_register_clkdev(clk[emma_ipg_gate], "ipg", "m2m-emmaprp.0");
255 clk_register_clkdev(clk[iim_ipg_gate], "iim", NULL); 257 clk_register_clkdev(clk[iim_ipg_gate], "iim", NULL);
256 clk_register_clkdev(clk[gpio_ipg_gate], "gpio", NULL); 258 clk_register_clkdev(clk[gpio_ipg_gate], "gpio", NULL);
257 clk_register_clkdev(clk[brom_ahb_gate], "brom", NULL); 259 clk_register_clkdev(clk[brom_ahb_gate], "brom", NULL);
258 clk_register_clkdev(clk[ata_ahb_gate], "ata", NULL); 260 clk_register_clkdev(clk[ata_ahb_gate], "ata", NULL);
259 clk_register_clkdev(clk[rtc_ipg_gate], "rtc", NULL); 261 clk_register_clkdev(clk[rtc_ipg_gate], NULL, "mxc_rtc");
260 clk_register_clkdev(clk[scc_ipg_gate], "scc", NULL); 262 clk_register_clkdev(clk[scc_ipg_gate], "scc", NULL);
261 clk_register_clkdev(clk[cpu_div], "cpu", NULL); 263 clk_register_clkdev(clk[cpu_div], "cpu", NULL);
262 clk_register_clkdev(clk[emi_ahb_gate], "emi_ahb" , NULL); 264 clk_register_clkdev(clk[emi_ahb_gate], "emi_ahb" , NULL);
@@ -267,6 +269,8 @@ int __init mx27_clocks_init(unsigned long fref)
267 269
268 clk_prepare_enable(clk[emi_ahb_gate]); 270 clk_prepare_enable(clk[emi_ahb_gate]);
269 271
272 imx_print_silicon_rev("i.MX27", mx27_revision());
273
270 return 0; 274 return 0;
271} 275}
272 276
diff --git a/arch/arm/mach-imx/clk-imx31.c b/arch/arm/mach-imx/clk-imx31.c
index c9a06d800f8..1253af2d997 100644
--- a/arch/arm/mach-imx/clk-imx31.c
+++ b/arch/arm/mach-imx/clk-imx31.c
@@ -20,6 +20,7 @@
20#include <linux/clkdev.h> 20#include <linux/clkdev.h>
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/err.h> 22#include <linux/err.h>
23#include <linux/of.h>
23 24
24#include <mach/hardware.h> 25#include <mach/hardware.h>
25#include <mach/mx31.h> 26#include <mach/mx31.h>
@@ -123,13 +124,13 @@ int __init mx31_clocks_init(unsigned long fref)
123 clk_register_clkdev(clk[cspi3_gate], NULL, "imx31-cspi.2"); 124 clk_register_clkdev(clk[cspi3_gate], NULL, "imx31-cspi.2");
124 clk_register_clkdev(clk[pwm_gate], "pwm", NULL); 125 clk_register_clkdev(clk[pwm_gate], "pwm", NULL);
125 clk_register_clkdev(clk[wdog_gate], NULL, "imx2-wdt.0"); 126 clk_register_clkdev(clk[wdog_gate], NULL, "imx2-wdt.0");
126 clk_register_clkdev(clk[rtc_gate], "rtc", NULL); 127 clk_register_clkdev(clk[rtc_gate], NULL, "mxc_rtc");
127 clk_register_clkdev(clk[epit1_gate], "epit", NULL); 128 clk_register_clkdev(clk[epit1_gate], "epit", NULL);
128 clk_register_clkdev(clk[epit2_gate], "epit", NULL); 129 clk_register_clkdev(clk[epit2_gate], "epit", NULL);
129 clk_register_clkdev(clk[nfc], NULL, "mxc_nand.0"); 130 clk_register_clkdev(clk[nfc], NULL, "mxc_nand.0");
130 clk_register_clkdev(clk[ipu_gate], NULL, "ipu-core"); 131 clk_register_clkdev(clk[ipu_gate], NULL, "ipu-core");
131 clk_register_clkdev(clk[ipu_gate], NULL, "mx3_sdc_fb"); 132 clk_register_clkdev(clk[ipu_gate], NULL, "mx3_sdc_fb");
132 clk_register_clkdev(clk[kpp_gate], "kpp", NULL); 133 clk_register_clkdev(clk[kpp_gate], NULL, "imx-keypad");
133 clk_register_clkdev(clk[usb_div_post], "per", "mxc-ehci.0"); 134 clk_register_clkdev(clk[usb_div_post], "per", "mxc-ehci.0");
134 clk_register_clkdev(clk[usb_gate], "ahb", "mxc-ehci.0"); 135 clk_register_clkdev(clk[usb_gate], "ahb", "mxc-ehci.0");
135 clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.0"); 136 clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.0");
@@ -165,7 +166,7 @@ int __init mx31_clocks_init(unsigned long fref)
165 clk_register_clkdev(clk[firi_gate], "firi", NULL); 166 clk_register_clkdev(clk[firi_gate], "firi", NULL);
166 clk_register_clkdev(clk[ata_gate], NULL, "pata_imx"); 167 clk_register_clkdev(clk[ata_gate], NULL, "pata_imx");
167 clk_register_clkdev(clk[rtic_gate], "rtic", NULL); 168 clk_register_clkdev(clk[rtic_gate], "rtic", NULL);
168 clk_register_clkdev(clk[rng_gate], "rng", NULL); 169 clk_register_clkdev(clk[rng_gate], NULL, "mxc_rnga");
169 clk_register_clkdev(clk[sdma_gate], NULL, "imx31-sdma"); 170 clk_register_clkdev(clk[sdma_gate], NULL, "imx31-sdma");
170 clk_register_clkdev(clk[iim_gate], "iim", NULL); 171 clk_register_clkdev(clk[iim_gate], "iim", NULL);
171 172
@@ -179,3 +180,21 @@ int __init mx31_clocks_init(unsigned long fref)
179 180
180 return 0; 181 return 0;
181} 182}
183
184#ifdef CONFIG_OF
185int __init mx31_clocks_init_dt(void)
186{
187 struct device_node *np;
188 u32 fref = 26000000; /* default */
189
190 for_each_compatible_node(np, NULL, "fixed-clock") {
191 if (!of_device_is_compatible(np, "fsl,imx-osc26m"))
192 continue;
193
194 if (!of_property_read_u32(np, "clock-frequency", &fref))
195 break;
196 }
197
198 return mx31_clocks_init(fref);
199}
200#endif
diff --git a/arch/arm/mach-imx/clk-imx51-imx53.c b/arch/arm/mach-imx/clk-imx51-imx53.c
index a2200c77bf7..4bdcaa97bd9 100644
--- a/arch/arm/mach-imx/clk-imx51-imx53.c
+++ b/arch/arm/mach-imx/clk-imx51-imx53.c
@@ -58,7 +58,7 @@ enum imx5_clks {
58 tve_s, uart1_ipg_gate, uart1_per_gate, uart2_ipg_gate, 58 tve_s, uart1_ipg_gate, uart1_per_gate, uart2_ipg_gate,
59 uart2_per_gate, uart3_ipg_gate, uart3_per_gate, i2c1_gate, i2c2_gate, 59 uart2_per_gate, uart3_ipg_gate, uart3_per_gate, i2c1_gate, i2c2_gate,
60 gpt_ipg_gate, pwm1_ipg_gate, pwm1_hf_gate, pwm2_ipg_gate, pwm2_hf_gate, 60 gpt_ipg_gate, pwm1_ipg_gate, pwm1_hf_gate, pwm2_ipg_gate, pwm2_hf_gate,
61 gpt_gate, fec_gate, usboh3_per_gate, esdhc1_ipg_gate, esdhc2_ipg_gate, 61 gpt_hf_gate, fec_gate, usboh3_per_gate, esdhc1_ipg_gate, esdhc2_ipg_gate,
62 esdhc3_ipg_gate, esdhc4_ipg_gate, ssi1_ipg_gate, ssi2_ipg_gate, 62 esdhc3_ipg_gate, esdhc4_ipg_gate, ssi1_ipg_gate, ssi2_ipg_gate,
63 ssi3_ipg_gate, ecspi1_ipg_gate, ecspi1_per_gate, ecspi2_ipg_gate, 63 ssi3_ipg_gate, ecspi1_ipg_gate, ecspi1_per_gate, ecspi2_ipg_gate,
64 ecspi2_per_gate, cspi_ipg_gate, sdma_gate, emi_slow_gate, ipu_s, 64 ecspi2_per_gate, cspi_ipg_gate, sdma_gate, emi_slow_gate, ipu_s,
@@ -81,6 +81,7 @@ enum imx5_clks {
81 ssi1_root_podf, ssi2_root_pred, ssi2_root_podf, ssi_ext1_pred, 81 ssi1_root_podf, ssi2_root_pred, ssi2_root_podf, ssi_ext1_pred,
82 ssi_ext1_podf, ssi_ext2_pred, ssi_ext2_podf, ssi1_root_gate, 82 ssi_ext1_podf, ssi_ext2_pred, ssi_ext2_podf, ssi1_root_gate,
83 ssi2_root_gate, ssi3_root_gate, ssi_ext1_gate, ssi_ext2_gate, 83 ssi2_root_gate, ssi3_root_gate, ssi_ext1_gate, ssi_ext2_gate,
84 epit1_ipg_gate, epit1_hf_gate, epit2_ipg_gate, epit2_hf_gate,
84 clk_max 85 clk_max
85}; 86};
86 87
@@ -167,12 +168,12 @@ static void __init mx5_clocks_common_init(unsigned long rate_ckil,
167 clk[uart3_per_gate] = imx_clk_gate2("uart3_per_gate", "uart_root", MXC_CCM_CCGR1, 16); 168 clk[uart3_per_gate] = imx_clk_gate2("uart3_per_gate", "uart_root", MXC_CCM_CCGR1, 16);
168 clk[i2c1_gate] = imx_clk_gate2("i2c1_gate", "per_root", MXC_CCM_CCGR1, 18); 169 clk[i2c1_gate] = imx_clk_gate2("i2c1_gate", "per_root", MXC_CCM_CCGR1, 18);
169 clk[i2c2_gate] = imx_clk_gate2("i2c2_gate", "per_root", MXC_CCM_CCGR1, 20); 170 clk[i2c2_gate] = imx_clk_gate2("i2c2_gate", "per_root", MXC_CCM_CCGR1, 20);
170 clk[gpt_ipg_gate] = imx_clk_gate2("gpt_ipg_gate", "ipg", MXC_CCM_CCGR2, 20);
171 clk[pwm1_ipg_gate] = imx_clk_gate2("pwm1_ipg_gate", "ipg", MXC_CCM_CCGR2, 10); 171 clk[pwm1_ipg_gate] = imx_clk_gate2("pwm1_ipg_gate", "ipg", MXC_CCM_CCGR2, 10);
172 clk[pwm1_hf_gate] = imx_clk_gate2("pwm1_hf_gate", "ipg", MXC_CCM_CCGR2, 12); 172 clk[pwm1_hf_gate] = imx_clk_gate2("pwm1_hf_gate", "per_root", MXC_CCM_CCGR2, 12);
173 clk[pwm2_ipg_gate] = imx_clk_gate2("pwm2_ipg_gate", "ipg", MXC_CCM_CCGR2, 14); 173 clk[pwm2_ipg_gate] = imx_clk_gate2("pwm2_ipg_gate", "ipg", MXC_CCM_CCGR2, 14);
174 clk[pwm2_hf_gate] = imx_clk_gate2("pwm2_hf_gate", "ipg", MXC_CCM_CCGR2, 16); 174 clk[pwm2_hf_gate] = imx_clk_gate2("pwm2_hf_gate", "per_root", MXC_CCM_CCGR2, 16);
175 clk[gpt_gate] = imx_clk_gate2("gpt_gate", "per_root", MXC_CCM_CCGR2, 18); 175 clk[gpt_ipg_gate] = imx_clk_gate2("gpt_ipg_gate", "ipg", MXC_CCM_CCGR2, 18);
176 clk[gpt_hf_gate] = imx_clk_gate2("gpt_hf_gate", "per_root", MXC_CCM_CCGR2, 20);
176 clk[fec_gate] = imx_clk_gate2("fec_gate", "ipg", MXC_CCM_CCGR2, 24); 177 clk[fec_gate] = imx_clk_gate2("fec_gate", "ipg", MXC_CCM_CCGR2, 24);
177 clk[usboh3_gate] = imx_clk_gate2("usboh3_gate", "ipg", MXC_CCM_CCGR2, 26); 178 clk[usboh3_gate] = imx_clk_gate2("usboh3_gate", "ipg", MXC_CCM_CCGR2, 26);
178 clk[usboh3_per_gate] = imx_clk_gate2("usboh3_per_gate", "usboh3_podf", MXC_CCM_CCGR2, 28); 179 clk[usboh3_per_gate] = imx_clk_gate2("usboh3_per_gate", "usboh3_podf", MXC_CCM_CCGR2, 28);
@@ -226,13 +227,17 @@ static void __init mx5_clocks_common_init(unsigned long rate_ckil,
226 clk[ssi3_root_gate] = imx_clk_gate2("ssi3_root_gate", "ssi3_root_sel", MXC_CCM_CCGR3, 26); 227 clk[ssi3_root_gate] = imx_clk_gate2("ssi3_root_gate", "ssi3_root_sel", MXC_CCM_CCGR3, 26);
227 clk[ssi_ext1_gate] = imx_clk_gate2("ssi_ext1_gate", "ssi_ext1_com_sel", MXC_CCM_CCGR3, 28); 228 clk[ssi_ext1_gate] = imx_clk_gate2("ssi_ext1_gate", "ssi_ext1_com_sel", MXC_CCM_CCGR3, 28);
228 clk[ssi_ext2_gate] = imx_clk_gate2("ssi_ext2_gate", "ssi_ext2_com_sel", MXC_CCM_CCGR3, 30); 229 clk[ssi_ext2_gate] = imx_clk_gate2("ssi_ext2_gate", "ssi_ext2_com_sel", MXC_CCM_CCGR3, 30);
230 clk[epit1_ipg_gate] = imx_clk_gate2("epit1_ipg_gate", "ipg", MXC_CCM_CCGR2, 2);
231 clk[epit1_hf_gate] = imx_clk_gate2("epit1_hf_gate", "per_root", MXC_CCM_CCGR2, 4);
232 clk[epit2_ipg_gate] = imx_clk_gate2("epit2_ipg_gate", "ipg", MXC_CCM_CCGR2, 6);
233 clk[epit2_hf_gate] = imx_clk_gate2("epit2_hf_gate", "per_root", MXC_CCM_CCGR2, 8);
229 234
230 for (i = 0; i < ARRAY_SIZE(clk); i++) 235 for (i = 0; i < ARRAY_SIZE(clk); i++)
231 if (IS_ERR(clk[i])) 236 if (IS_ERR(clk[i]))
232 pr_err("i.MX5 clk %d: register failed with %ld\n", 237 pr_err("i.MX5 clk %d: register failed with %ld\n",
233 i, PTR_ERR(clk[i])); 238 i, PTR_ERR(clk[i]));
234 239
235 clk_register_clkdev(clk[gpt_gate], "per", "imx-gpt.0"); 240 clk_register_clkdev(clk[gpt_hf_gate], "per", "imx-gpt.0");
236 clk_register_clkdev(clk[gpt_ipg_gate], "ipg", "imx-gpt.0"); 241 clk_register_clkdev(clk[gpt_ipg_gate], "ipg", "imx-gpt.0");
237 clk_register_clkdev(clk[uart1_per_gate], "per", "imx21-uart.0"); 242 clk_register_clkdev(clk[uart1_per_gate], "per", "imx21-uart.0");
238 clk_register_clkdev(clk[uart1_ipg_gate], "ipg", "imx21-uart.0"); 243 clk_register_clkdev(clk[uart1_ipg_gate], "ipg", "imx21-uart.0");
@@ -248,7 +253,7 @@ static void __init mx5_clocks_common_init(unsigned long rate_ckil,
248 clk_register_clkdev(clk[ecspi1_ipg_gate], "ipg", "imx51-ecspi.0"); 253 clk_register_clkdev(clk[ecspi1_ipg_gate], "ipg", "imx51-ecspi.0");
249 clk_register_clkdev(clk[ecspi2_per_gate], "per", "imx51-ecspi.1"); 254 clk_register_clkdev(clk[ecspi2_per_gate], "per", "imx51-ecspi.1");
250 clk_register_clkdev(clk[ecspi2_ipg_gate], "ipg", "imx51-ecspi.1"); 255 clk_register_clkdev(clk[ecspi2_ipg_gate], "ipg", "imx51-ecspi.1");
251 clk_register_clkdev(clk[cspi_ipg_gate], NULL, "imx51-cspi.0"); 256 clk_register_clkdev(clk[cspi_ipg_gate], NULL, "imx35-cspi.2");
252 clk_register_clkdev(clk[pwm1_ipg_gate], "pwm", "mxc_pwm.0"); 257 clk_register_clkdev(clk[pwm1_ipg_gate], "pwm", "mxc_pwm.0");
253 clk_register_clkdev(clk[pwm2_ipg_gate], "pwm", "mxc_pwm.1"); 258 clk_register_clkdev(clk[pwm2_ipg_gate], "pwm", "mxc_pwm.1");
254 clk_register_clkdev(clk[i2c1_gate], NULL, "imx-i2c.0"); 259 clk_register_clkdev(clk[i2c1_gate], NULL, "imx-i2c.0");
@@ -279,6 +284,11 @@ static void __init mx5_clocks_common_init(unsigned long rate_ckil,
279 clk_register_clkdev(clk[dummy], NULL, "imx-keypad"); 284 clk_register_clkdev(clk[dummy], NULL, "imx-keypad");
280 clk_register_clkdev(clk[tve_gate], NULL, "imx-tve.0"); 285 clk_register_clkdev(clk[tve_gate], NULL, "imx-tve.0");
281 clk_register_clkdev(clk[ipu_di1_gate], "di1", "imx-tve.0"); 286 clk_register_clkdev(clk[ipu_di1_gate], "di1", "imx-tve.0");
287 clk_register_clkdev(clk[gpc_dvfs], "gpc_dvfs", NULL);
288 clk_register_clkdev(clk[epit1_ipg_gate], "ipg", "imx-epit.0");
289 clk_register_clkdev(clk[epit1_hf_gate], "per", "imx-epit.0");
290 clk_register_clkdev(clk[epit2_ipg_gate], "ipg", "imx-epit.1");
291 clk_register_clkdev(clk[epit2_hf_gate], "per", "imx-epit.1");
282 292
283 /* Set SDHC parents to be PLL2 */ 293 /* Set SDHC parents to be PLL2 */
284 clk_set_parent(clk[esdhc_a_sel], clk[pll2_sw]); 294 clk_set_parent(clk[esdhc_a_sel], clk[pll2_sw]);
@@ -293,6 +303,7 @@ static void __init mx5_clocks_common_init(unsigned long rate_ckil,
293 clk_prepare_enable(clk[aips_tz2]); /* fec */ 303 clk_prepare_enable(clk[aips_tz2]); /* fec */
294 clk_prepare_enable(clk[spba]); 304 clk_prepare_enable(clk[spba]);
295 clk_prepare_enable(clk[emi_fast_gate]); /* fec */ 305 clk_prepare_enable(clk[emi_fast_gate]); /* fec */
306 clk_prepare_enable(clk[emi_slow_gate]); /* eim */
296 clk_prepare_enable(clk[tmax1]); 307 clk_prepare_enable(clk[tmax1]);
297 clk_prepare_enable(clk[tmax2]); /* esdhc2, fec */ 308 clk_prepare_enable(clk[tmax2]); /* esdhc2, fec */
298 clk_prepare_enable(clk[tmax3]); /* esdhc1, esdhc4 */ 309 clk_prepare_enable(clk[tmax3]); /* esdhc1, esdhc4 */
@@ -336,7 +347,6 @@ int __init mx51_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,
336 clk_register_clkdev(clk[mx51_mipi], "mipi_hsp", NULL); 347 clk_register_clkdev(clk[mx51_mipi], "mipi_hsp", NULL);
337 clk_register_clkdev(clk[vpu_gate], NULL, "imx51-vpu.0"); 348 clk_register_clkdev(clk[vpu_gate], NULL, "imx51-vpu.0");
338 clk_register_clkdev(clk[fec_gate], NULL, "imx27-fec.0"); 349 clk_register_clkdev(clk[fec_gate], NULL, "imx27-fec.0");
339 clk_register_clkdev(clk[gpc_dvfs], "gpc_dvfs", NULL);
340 clk_register_clkdev(clk[ipu_gate], "bus", "imx51-ipu"); 350 clk_register_clkdev(clk[ipu_gate], "bus", "imx51-ipu");
341 clk_register_clkdev(clk[ipu_di0_gate], "di0", "imx51-ipu"); 351 clk_register_clkdev(clk[ipu_di0_gate], "di0", "imx51-ipu");
342 clk_register_clkdev(clk[ipu_di1_gate], "di1", "imx51-ipu"); 352 clk_register_clkdev(clk[ipu_di1_gate], "di1", "imx51-ipu");
diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index e1a17ac7b3b..4233d9e3531 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -147,12 +147,12 @@ enum mx6q_clks {
147 esai, gpt_ipg, gpt_ipg_per, gpu2d_core, gpu3d_core, hdmi_iahb, 147 esai, gpt_ipg, gpt_ipg_per, gpu2d_core, gpu3d_core, hdmi_iahb,
148 hdmi_isfr, i2c1, i2c2, i2c3, iim, enfc, ipu1, ipu1_di0, ipu1_di1, ipu2, 148 hdmi_isfr, i2c1, i2c2, i2c3, iim, enfc, ipu1, ipu1_di0, ipu1_di1, ipu2,
149 ipu2_di0, ldb_di0, ldb_di1, ipu2_di1, hsi_tx, mlb, mmdc_ch0_axi, 149 ipu2_di0, ldb_di0, ldb_di1, ipu2_di1, hsi_tx, mlb, mmdc_ch0_axi,
150 mmdc_ch1_axi, ocram, openvg_axi, pcie_axi, pwm1, pwm2, pwm3, pwm4, 150 mmdc_ch1_axi, ocram, openvg_axi, pcie_axi, pwm1, pwm2, pwm3, pwm4, per1_bch,
151 gpmi_bch_apb, gpmi_bch, gpmi_io, gpmi_apb, sata, sdma, spba, ssi1, 151 gpmi_bch_apb, gpmi_bch, gpmi_io, gpmi_apb, sata, sdma, spba, ssi1,
152 ssi2, ssi3, uart_ipg, uart_serial, usboh3, usdhc1, usdhc2, usdhc3, 152 ssi2, ssi3, uart_ipg, uart_serial, usboh3, usdhc1, usdhc2, usdhc3,
153 usdhc4, vdo_axi, vpu_axi, cko1, pll1_sys, pll2_bus, pll3_usb_otg, 153 usdhc4, vdo_axi, vpu_axi, cko1, pll1_sys, pll2_bus, pll3_usb_otg,
154 pll4_audio, pll5_video, pll6_mlb, pll7_usb_host, pll8_enet, ssi1_ipg, 154 pll4_audio, pll5_video, pll6_mlb, pll7_usb_host, pll8_enet, ssi1_ipg,
155 ssi2_ipg, ssi3_ipg, rom, 155 ssi2_ipg, ssi3_ipg, rom, usbphy1, usbphy2, ldb_di0_div_3_5, ldb_di1_div_3_5,
156 clk_max 156 clk_max
157}; 157};
158 158
@@ -198,6 +198,9 @@ int __init mx6q_clocks_init(void)
198 clk[pll7_usb_host] = imx_clk_pllv3(IMX_PLLV3_USB, "pll7_usb_host","osc", base + 0x20, 0x2000, 0x3); 198 clk[pll7_usb_host] = imx_clk_pllv3(IMX_PLLV3_USB, "pll7_usb_host","osc", base + 0x20, 0x2000, 0x3);
199 clk[pll8_enet] = imx_clk_pllv3(IMX_PLLV3_ENET, "pll8_enet", "osc", base + 0xe0, 0x182000, 0x3); 199 clk[pll8_enet] = imx_clk_pllv3(IMX_PLLV3_ENET, "pll8_enet", "osc", base + 0xe0, 0x182000, 0x3);
200 200
201 clk[usbphy1] = imx_clk_gate("usbphy1", "pll3_usb_otg", base + 0x10, 6);
202 clk[usbphy2] = imx_clk_gate("usbphy2", "pll7_usb_host", base + 0x20, 6);
203
201 /* name parent_name reg idx */ 204 /* name parent_name reg idx */
202 clk[pll2_pfd0_352m] = imx_clk_pfd("pll2_pfd0_352m", "pll2_bus", base + 0x100, 0); 205 clk[pll2_pfd0_352m] = imx_clk_pfd("pll2_pfd0_352m", "pll2_bus", base + 0x100, 0);
203 clk[pll2_pfd1_594m] = imx_clk_pfd("pll2_pfd1_594m", "pll2_bus", base + 0x100, 1); 206 clk[pll2_pfd1_594m] = imx_clk_pfd("pll2_pfd1_594m", "pll2_bus", base + 0x100, 1);
@@ -285,8 +288,10 @@ int __init mx6q_clocks_init(void)
285 clk[gpu3d_shader] = imx_clk_divider("gpu3d_shader", "gpu3d_shader_sel", base + 0x18, 29, 3); 288 clk[gpu3d_shader] = imx_clk_divider("gpu3d_shader", "gpu3d_shader_sel", base + 0x18, 29, 3);
286 clk[ipu1_podf] = imx_clk_divider("ipu1_podf", "ipu1_sel", base + 0x3c, 11, 3); 289 clk[ipu1_podf] = imx_clk_divider("ipu1_podf", "ipu1_sel", base + 0x3c, 11, 3);
287 clk[ipu2_podf] = imx_clk_divider("ipu2_podf", "ipu2_sel", base + 0x3c, 16, 3); 290 clk[ipu2_podf] = imx_clk_divider("ipu2_podf", "ipu2_sel", base + 0x3c, 16, 3);
288 clk[ldb_di0_podf] = imx_clk_divider("ldb_di0_podf", "ldb_di0_sel", base + 0x20, 10, 1); 291 clk[ldb_di0_div_3_5] = imx_clk_fixed_factor("ldb_di0_div_3_5", "ldb_di0_sel", 2, 7);
289 clk[ldb_di1_podf] = imx_clk_divider("ldb_di1_podf", "ldb_di1_sel", base + 0x20, 11, 1); 292 clk[ldb_di0_podf] = imx_clk_divider("ldb_di0_podf", "ldb_di0_div_3_5", base + 0x20, 10, 1);
293 clk[ldb_di1_div_3_5] = imx_clk_fixed_factor("ldb_di1_div_3_5", "ldb_di1_sel", 2, 7);
294 clk[ldb_di1_podf] = imx_clk_divider("ldb_di1_podf", "ldb_di1_div_3_5", base + 0x20, 11, 1);
290 clk[ipu1_di0_pre] = imx_clk_divider("ipu1_di0_pre", "ipu1_di0_pre_sel", base + 0x34, 3, 3); 295 clk[ipu1_di0_pre] = imx_clk_divider("ipu1_di0_pre", "ipu1_di0_pre_sel", base + 0x34, 3, 3);
291 clk[ipu1_di1_pre] = imx_clk_divider("ipu1_di1_pre", "ipu1_di1_pre_sel", base + 0x34, 12, 3); 296 clk[ipu1_di1_pre] = imx_clk_divider("ipu1_di1_pre", "ipu1_di1_pre_sel", base + 0x34, 12, 3);
292 clk[ipu2_di0_pre] = imx_clk_divider("ipu2_di0_pre", "ipu2_di0_pre_sel", base + 0x38, 3, 3); 297 clk[ipu2_di0_pre] = imx_clk_divider("ipu2_di0_pre", "ipu2_di0_pre_sel", base + 0x38, 3, 3);
@@ -318,7 +323,7 @@ int __init mx6q_clocks_init(void)
318 clk[ahb] = imx_clk_busy_divider("ahb", "periph", base + 0x14, 10, 3, base + 0x48, 1); 323 clk[ahb] = imx_clk_busy_divider("ahb", "periph", base + 0x14, 10, 3, base + 0x48, 1);
319 324
320 /* name parent_name reg shift */ 325 /* name parent_name reg shift */
321 clk[apbh_dma] = imx_clk_gate2("apbh_dma", "ahb", base + 0x68, 4); 326 clk[apbh_dma] = imx_clk_gate2("apbh_dma", "usdhc3", base + 0x68, 4);
322 clk[asrc] = imx_clk_gate2("asrc", "asrc_podf", base + 0x68, 6); 327 clk[asrc] = imx_clk_gate2("asrc", "asrc_podf", base + 0x68, 6);
323 clk[can1_ipg] = imx_clk_gate2("can1_ipg", "ipg", base + 0x68, 14); 328 clk[can1_ipg] = imx_clk_gate2("can1_ipg", "ipg", base + 0x68, 14);
324 clk[can1_serial] = imx_clk_gate2("can1_serial", "can_root", base + 0x68, 16); 329 clk[can1_serial] = imx_clk_gate2("can1_serial", "can_root", base + 0x68, 16);
@@ -357,6 +362,7 @@ int __init mx6q_clocks_init(void)
357 clk[ocram] = imx_clk_gate2("ocram", "ahb", base + 0x74, 28); 362 clk[ocram] = imx_clk_gate2("ocram", "ahb", base + 0x74, 28);
358 clk[openvg_axi] = imx_clk_gate2("openvg_axi", "axi", base + 0x74, 30); 363 clk[openvg_axi] = imx_clk_gate2("openvg_axi", "axi", base + 0x74, 30);
359 clk[pcie_axi] = imx_clk_gate2("pcie_axi", "pcie_axi_sel", base + 0x78, 0); 364 clk[pcie_axi] = imx_clk_gate2("pcie_axi", "pcie_axi_sel", base + 0x78, 0);
365 clk[per1_bch] = imx_clk_gate2("per1_bch", "usdhc3", base + 0x78, 12);
360 clk[pwm1] = imx_clk_gate2("pwm1", "ipg_per", base + 0x78, 16); 366 clk[pwm1] = imx_clk_gate2("pwm1", "ipg_per", base + 0x78, 16);
361 clk[pwm2] = imx_clk_gate2("pwm2", "ipg_per", base + 0x78, 18); 367 clk[pwm2] = imx_clk_gate2("pwm2", "ipg_per", base + 0x78, 18);
362 clk[pwm3] = imx_clk_gate2("pwm3", "ipg_per", base + 0x78, 20); 368 clk[pwm3] = imx_clk_gate2("pwm3", "ipg_per", base + 0x78, 20);
@@ -388,12 +394,21 @@ int __init mx6q_clocks_init(void)
388 pr_err("i.MX6q clk %d: register failed with %ld\n", 394 pr_err("i.MX6q clk %d: register failed with %ld\n",
389 i, PTR_ERR(clk[i])); 395 i, PTR_ERR(clk[i]));
390 396
391 clk_register_clkdev(clk[mmdc_ch0_axi], NULL, "mmdc_ch0_axi");
392 clk_register_clkdev(clk[mmdc_ch1_axi], NULL, "mmdc_ch1_axi");
393 clk_register_clkdev(clk[gpt_ipg], "ipg", "imx-gpt.0"); 397 clk_register_clkdev(clk[gpt_ipg], "ipg", "imx-gpt.0");
394 clk_register_clkdev(clk[gpt_ipg_per], "per", "imx-gpt.0"); 398 clk_register_clkdev(clk[gpt_ipg_per], "per", "imx-gpt.0");
395 clk_register_clkdev(clk[twd], NULL, "smp_twd"); 399 clk_register_clkdev(clk[twd], NULL, "smp_twd");
396 clk_register_clkdev(clk[usboh3], NULL, "usboh3"); 400 clk_register_clkdev(clk[apbh_dma], NULL, "110000.dma-apbh");
401 clk_register_clkdev(clk[per1_bch], "per1_bch", "112000.gpmi-nand");
402 clk_register_clkdev(clk[gpmi_bch_apb], "gpmi_bch_apb", "112000.gpmi-nand");
403 clk_register_clkdev(clk[gpmi_bch], "gpmi_bch", "112000.gpmi-nand");
404 clk_register_clkdev(clk[gpmi_apb], "gpmi_apb", "112000.gpmi-nand");
405 clk_register_clkdev(clk[gpmi_io], "gpmi_io", "112000.gpmi-nand");
406 clk_register_clkdev(clk[usboh3], NULL, "2184000.usb");
407 clk_register_clkdev(clk[usboh3], NULL, "2184200.usb");
408 clk_register_clkdev(clk[usboh3], NULL, "2184400.usb");
409 clk_register_clkdev(clk[usboh3], NULL, "2184600.usb");
410 clk_register_clkdev(clk[usbphy1], NULL, "20c9000.usbphy");
411 clk_register_clkdev(clk[usbphy2], NULL, "20ca000.usbphy");
397 clk_register_clkdev(clk[uart_serial], "per", "2020000.serial"); 412 clk_register_clkdev(clk[uart_serial], "per", "2020000.serial");
398 clk_register_clkdev(clk[uart_ipg], "ipg", "2020000.serial"); 413 clk_register_clkdev(clk[uart_ipg], "ipg", "2020000.serial");
399 clk_register_clkdev(clk[uart_serial], "per", "21e8000.serial"); 414 clk_register_clkdev(clk[uart_serial], "per", "21e8000.serial");
diff --git a/arch/arm/mach-imx/devices-imx21.h b/arch/arm/mach-imx/devices-imx21.h
index 2628e0c474d..93ece55f75d 100644
--- a/arch/arm/mach-imx/devices-imx21.h
+++ b/arch/arm/mach-imx/devices-imx21.h
@@ -14,7 +14,7 @@ extern const struct imx_imx21_hcd_data imx21_imx21_hcd_data;
14 imx_add_imx21_hcd(&imx21_imx21_hcd_data, pdata) 14 imx_add_imx21_hcd(&imx21_imx21_hcd_data, pdata)
15 15
16extern const struct imx_imx2_wdt_data imx21_imx2_wdt_data; 16extern const struct imx_imx2_wdt_data imx21_imx2_wdt_data;
17#define imx21_add_imx2_wdt(pdata) \ 17#define imx21_add_imx2_wdt() \
18 imx_add_imx2_wdt(&imx21_imx2_wdt_data) 18 imx_add_imx2_wdt(&imx21_imx2_wdt_data)
19 19
20extern const struct imx_imx_fb_data imx21_imx_fb_data; 20extern const struct imx_imx_fb_data imx21_imx_fb_data;
@@ -50,7 +50,7 @@ extern const struct imx_mxc_nand_data imx21_mxc_nand_data;
50 imx_add_mxc_nand(&imx21_mxc_nand_data, pdata) 50 imx_add_mxc_nand(&imx21_mxc_nand_data, pdata)
51 51
52extern const struct imx_mxc_w1_data imx21_mxc_w1_data; 52extern const struct imx_mxc_w1_data imx21_mxc_w1_data;
53#define imx21_add_mxc_w1(pdata) \ 53#define imx21_add_mxc_w1() \
54 imx_add_mxc_w1(&imx21_mxc_w1_data) 54 imx_add_mxc_w1(&imx21_mxc_w1_data)
55 55
56extern const struct imx_spi_imx_data imx21_cspi_data[]; 56extern const struct imx_spi_imx_data imx21_cspi_data[];
diff --git a/arch/arm/mach-imx/devices-imx25.h b/arch/arm/mach-imx/devices-imx25.h
index efa0761c508..f8e03dd1f11 100644
--- a/arch/arm/mach-imx/devices-imx25.h
+++ b/arch/arm/mach-imx/devices-imx25.h
@@ -24,11 +24,11 @@ extern const struct imx_fsl_usb2_udc_data imx25_fsl_usb2_udc_data;
24 imx_add_fsl_usb2_udc(&imx25_fsl_usb2_udc_data, pdata) 24 imx_add_fsl_usb2_udc(&imx25_fsl_usb2_udc_data, pdata)
25 25
26extern struct imx_imxdi_rtc_data imx25_imxdi_rtc_data; 26extern struct imx_imxdi_rtc_data imx25_imxdi_rtc_data;
27#define imx25_add_imxdi_rtc(pdata) \ 27#define imx25_add_imxdi_rtc() \
28 imx_add_imxdi_rtc(&imx25_imxdi_rtc_data) 28 imx_add_imxdi_rtc(&imx25_imxdi_rtc_data)
29 29
30extern const struct imx_imx2_wdt_data imx25_imx2_wdt_data; 30extern const struct imx_imx2_wdt_data imx25_imx2_wdt_data;
31#define imx25_add_imx2_wdt(pdata) \ 31#define imx25_add_imx2_wdt() \
32 imx_add_imx2_wdt(&imx25_imx2_wdt_data) 32 imx_add_imx2_wdt(&imx25_imx2_wdt_data)
33 33
34extern const struct imx_imx_fb_data imx25_imx_fb_data; 34extern const struct imx_imx_fb_data imx25_imx_fb_data;
diff --git a/arch/arm/mach-imx/devices-imx27.h b/arch/arm/mach-imx/devices-imx27.h
index 28537a5d904..436c5720fe6 100644
--- a/arch/arm/mach-imx/devices-imx27.h
+++ b/arch/arm/mach-imx/devices-imx27.h
@@ -18,7 +18,7 @@ extern const struct imx_fsl_usb2_udc_data imx27_fsl_usb2_udc_data;
18 imx_add_fsl_usb2_udc(&imx27_fsl_usb2_udc_data, pdata) 18 imx_add_fsl_usb2_udc(&imx27_fsl_usb2_udc_data, pdata)
19 19
20extern const struct imx_imx2_wdt_data imx27_imx2_wdt_data; 20extern const struct imx_imx2_wdt_data imx27_imx2_wdt_data;
21#define imx27_add_imx2_wdt(pdata) \ 21#define imx27_add_imx2_wdt() \
22 imx_add_imx2_wdt(&imx27_imx2_wdt_data) 22 imx_add_imx2_wdt(&imx27_imx2_wdt_data)
23 23
24extern const struct imx_imx_fb_data imx27_imx_fb_data; 24extern const struct imx_imx_fb_data imx27_imx_fb_data;
@@ -50,7 +50,7 @@ extern const struct imx_imx_uart_1irq_data imx27_imx_uart_data[];
50extern const struct imx_mx2_camera_data imx27_mx2_camera_data; 50extern const struct imx_mx2_camera_data imx27_mx2_camera_data;
51#define imx27_add_mx2_camera(pdata) \ 51#define imx27_add_mx2_camera(pdata) \
52 imx_add_mx2_camera(&imx27_mx2_camera_data, pdata) 52 imx_add_mx2_camera(&imx27_mx2_camera_data, pdata)
53#define imx27_add_mx2_emmaprp(pdata) \ 53#define imx27_add_mx2_emmaprp() \
54 imx_add_mx2_emmaprp(&imx27_mx2_camera_data) 54 imx_add_mx2_emmaprp(&imx27_mx2_camera_data)
55 55
56extern const struct imx_mxc_ehci_data imx27_mxc_ehci_otg_data; 56extern const struct imx_mxc_ehci_data imx27_mxc_ehci_otg_data;
@@ -69,7 +69,7 @@ extern const struct imx_mxc_nand_data imx27_mxc_nand_data;
69 imx_add_mxc_nand(&imx27_mxc_nand_data, pdata) 69 imx_add_mxc_nand(&imx27_mxc_nand_data, pdata)
70 70
71extern const struct imx_mxc_w1_data imx27_mxc_w1_data; 71extern const struct imx_mxc_w1_data imx27_mxc_w1_data;
72#define imx27_add_mxc_w1(pdata) \ 72#define imx27_add_mxc_w1() \
73 imx_add_mxc_w1(&imx27_mxc_w1_data) 73 imx_add_mxc_w1(&imx27_mxc_w1_data)
74 74
75extern const struct imx_spi_imx_data imx27_cspi_data[]; 75extern const struct imx_spi_imx_data imx27_cspi_data[];
diff --git a/arch/arm/mach-imx/devices-imx31.h b/arch/arm/mach-imx/devices-imx31.h
index 488e241a6db..8b2ceb45bb8 100644
--- a/arch/arm/mach-imx/devices-imx31.h
+++ b/arch/arm/mach-imx/devices-imx31.h
@@ -14,7 +14,7 @@ extern const struct imx_fsl_usb2_udc_data imx31_fsl_usb2_udc_data;
14 imx_add_fsl_usb2_udc(&imx31_fsl_usb2_udc_data, pdata) 14 imx_add_fsl_usb2_udc(&imx31_fsl_usb2_udc_data, pdata)
15 15
16extern const struct imx_imx2_wdt_data imx31_imx2_wdt_data; 16extern const struct imx_imx2_wdt_data imx31_imx2_wdt_data;
17#define imx31_add_imx2_wdt(pdata) \ 17#define imx31_add_imx2_wdt() \
18 imx_add_imx2_wdt(&imx31_imx2_wdt_data) 18 imx_add_imx2_wdt(&imx31_imx2_wdt_data)
19 19
20extern const struct imx_imx_i2c_data imx31_imx_i2c_data[]; 20extern const struct imx_imx_i2c_data imx31_imx_i2c_data[];
@@ -42,8 +42,8 @@ extern const struct imx_imx_uart_1irq_data imx31_imx_uart_data[];
42#define imx31_add_imx_uart4(pdata) imx31_add_imx_uart(4, pdata) 42#define imx31_add_imx_uart4(pdata) imx31_add_imx_uart(4, pdata)
43 43
44extern const struct imx_ipu_core_data imx31_ipu_core_data; 44extern const struct imx_ipu_core_data imx31_ipu_core_data;
45#define imx31_add_ipu_core(pdata) \ 45#define imx31_add_ipu_core() \
46 imx_add_ipu_core(&imx31_ipu_core_data, pdata) 46 imx_add_ipu_core(&imx31_ipu_core_data)
47#define imx31_alloc_mx3_camera(pdata) \ 47#define imx31_alloc_mx3_camera(pdata) \
48 imx_alloc_mx3_camera(&imx31_ipu_core_data, pdata) 48 imx_alloc_mx3_camera(&imx31_ipu_core_data, pdata)
49#define imx31_add_mx3_sdc_fb(pdata) \ 49#define imx31_add_mx3_sdc_fb(pdata) \
@@ -65,11 +65,11 @@ extern const struct imx_mxc_nand_data imx31_mxc_nand_data;
65 imx_add_mxc_nand(&imx31_mxc_nand_data, pdata) 65 imx_add_mxc_nand(&imx31_mxc_nand_data, pdata)
66 66
67extern const struct imx_mxc_rtc_data imx31_mxc_rtc_data; 67extern const struct imx_mxc_rtc_data imx31_mxc_rtc_data;
68#define imx31_add_mxc_rtc(pdata) \ 68#define imx31_add_mxc_rtc() \
69 imx_add_mxc_rtc(&imx31_mxc_rtc_data) 69 imx_add_mxc_rtc(&imx31_mxc_rtc_data)
70 70
71extern const struct imx_mxc_w1_data imx31_mxc_w1_data; 71extern const struct imx_mxc_w1_data imx31_mxc_w1_data;
72#define imx31_add_mxc_w1(pdata) \ 72#define imx31_add_mxc_w1() \
73 imx_add_mxc_w1(&imx31_mxc_w1_data) 73 imx_add_mxc_w1(&imx31_mxc_w1_data)
74 74
75extern const struct imx_spi_imx_data imx31_cspi_data[]; 75extern const struct imx_spi_imx_data imx31_cspi_data[];
diff --git a/arch/arm/mach-imx/devices-imx35.h b/arch/arm/mach-imx/devices-imx35.h
index 7b99ef0bb50..c3e9f206ac2 100644
--- a/arch/arm/mach-imx/devices-imx35.h
+++ b/arch/arm/mach-imx/devices-imx35.h
@@ -24,7 +24,7 @@ extern const struct imx_flexcan_data imx35_flexcan_data[];
24#define imx35_add_flexcan1(pdata) imx35_add_flexcan(1, pdata) 24#define imx35_add_flexcan1(pdata) imx35_add_flexcan(1, pdata)
25 25
26extern const struct imx_imx2_wdt_data imx35_imx2_wdt_data; 26extern const struct imx_imx2_wdt_data imx35_imx2_wdt_data;
27#define imx35_add_imx2_wdt(pdata) \ 27#define imx35_add_imx2_wdt() \
28 imx_add_imx2_wdt(&imx35_imx2_wdt_data) 28 imx_add_imx2_wdt(&imx35_imx2_wdt_data)
29 29
30extern const struct imx_imx_i2c_data imx35_imx_i2c_data[]; 30extern const struct imx_imx_i2c_data imx35_imx_i2c_data[];
@@ -50,8 +50,8 @@ extern const struct imx_imx_uart_1irq_data imx35_imx_uart_data[];
50#define imx35_add_imx_uart2(pdata) imx35_add_imx_uart(2, pdata) 50#define imx35_add_imx_uart2(pdata) imx35_add_imx_uart(2, pdata)
51 51
52extern const struct imx_ipu_core_data imx35_ipu_core_data; 52extern const struct imx_ipu_core_data imx35_ipu_core_data;
53#define imx35_add_ipu_core(pdata) \ 53#define imx35_add_ipu_core() \
54 imx_add_ipu_core(&imx35_ipu_core_data, pdata) 54 imx_add_ipu_core(&imx35_ipu_core_data)
55#define imx35_alloc_mx3_camera(pdata) \ 55#define imx35_alloc_mx3_camera(pdata) \
56 imx_alloc_mx3_camera(&imx35_ipu_core_data, pdata) 56 imx_alloc_mx3_camera(&imx35_ipu_core_data, pdata)
57#define imx35_add_mx3_sdc_fb(pdata) \ 57#define imx35_add_mx3_sdc_fb(pdata) \
@@ -68,8 +68,12 @@ extern const struct imx_mxc_nand_data imx35_mxc_nand_data;
68#define imx35_add_mxc_nand(pdata) \ 68#define imx35_add_mxc_nand(pdata) \
69 imx_add_mxc_nand(&imx35_mxc_nand_data, pdata) 69 imx_add_mxc_nand(&imx35_mxc_nand_data, pdata)
70 70
71extern const struct imx_mxc_rtc_data imx35_mxc_rtc_data;
72#define imx35_add_mxc_rtc() \
73 imx_add_mxc_rtc(&imx35_mxc_rtc_data)
74
71extern const struct imx_mxc_w1_data imx35_mxc_w1_data; 75extern const struct imx_mxc_w1_data imx35_mxc_w1_data;
72#define imx35_add_mxc_w1(pdata) \ 76#define imx35_add_mxc_w1() \
73 imx_add_mxc_w1(&imx35_mxc_w1_data) 77 imx_add_mxc_w1(&imx35_mxc_w1_data)
74 78
75extern const struct imx_sdhci_esdhc_imx_data imx35_sdhci_esdhc_imx_data[]; 79extern const struct imx_sdhci_esdhc_imx_data imx35_sdhci_esdhc_imx_data[];
diff --git a/arch/arm/mach-imx/devices-imx51.h b/arch/arm/mach-imx/devices-imx51.h
index af488bc0e22..9f171872519 100644
--- a/arch/arm/mach-imx/devices-imx51.h
+++ b/arch/arm/mach-imx/devices-imx51.h
@@ -55,7 +55,7 @@ extern const struct imx_spi_imx_data imx51_ecspi_data[];
55 imx_add_spi_imx(&imx51_ecspi_data[id], pdata) 55 imx_add_spi_imx(&imx51_ecspi_data[id], pdata)
56 56
57extern const struct imx_imx2_wdt_data imx51_imx2_wdt_data[]; 57extern const struct imx_imx2_wdt_data imx51_imx2_wdt_data[];
58#define imx51_add_imx2_wdt(id, pdata) \ 58#define imx51_add_imx2_wdt(id) \
59 imx_add_imx2_wdt(&imx51_imx2_wdt_data[id]) 59 imx_add_imx2_wdt(&imx51_imx2_wdt_data[id])
60 60
61extern const struct imx_mxc_pwm_data imx51_mxc_pwm_data[]; 61extern const struct imx_mxc_pwm_data imx51_mxc_pwm_data[];
diff --git a/arch/arm/mach-imx/devices-imx53.h b/arch/arm/mach-imx/devices-imx53.h
index 6e1e5d1f8c3..77e0db96c44 100644
--- a/arch/arm/mach-imx/devices-imx53.h
+++ b/arch/arm/mach-imx/devices-imx53.h
@@ -30,7 +30,7 @@ extern const struct imx_spi_imx_data imx53_ecspi_data[];
30 imx_add_spi_imx(&imx53_ecspi_data[id], pdata) 30 imx_add_spi_imx(&imx53_ecspi_data[id], pdata)
31 31
32extern const struct imx_imx2_wdt_data imx53_imx2_wdt_data[]; 32extern const struct imx_imx2_wdt_data imx53_imx2_wdt_data[];
33#define imx53_add_imx2_wdt(id, pdata) \ 33#define imx53_add_imx2_wdt(id) \
34 imx_add_imx2_wdt(&imx53_imx2_wdt_data[id]) 34 imx_add_imx2_wdt(&imx53_imx2_wdt_data[id])
35 35
36extern const struct imx_imx_ssi_data imx53_imx_ssi_data[]; 36extern const struct imx_imx_ssi_data imx53_imx_ssi_data[];
diff --git a/arch/arm/mach-imx/ehci-imx25.c b/arch/arm/mach-imx/ehci-imx25.c
index 865daf0b09e..05bb41d9972 100644
--- a/arch/arm/mach-imx/ehci-imx25.c
+++ b/arch/arm/mach-imx/ehci-imx25.c
@@ -24,14 +24,18 @@
24#define MX25_OTG_SIC_SHIFT 29 24#define MX25_OTG_SIC_SHIFT 29
25#define MX25_OTG_SIC_MASK (0x3 << MX25_OTG_SIC_SHIFT) 25#define MX25_OTG_SIC_MASK (0x3 << MX25_OTG_SIC_SHIFT)
26#define MX25_OTG_PM_BIT (1 << 24) 26#define MX25_OTG_PM_BIT (1 << 24)
27#define MX25_OTG_PP_BIT (1 << 11)
28#define MX25_OTG_OCPOL_BIT (1 << 3)
27 29
28#define MX25_H1_SIC_SHIFT 21 30#define MX25_H1_SIC_SHIFT 21
29#define MX25_H1_SIC_MASK (0x3 << MX25_H1_SIC_SHIFT) 31#define MX25_H1_SIC_MASK (0x3 << MX25_H1_SIC_SHIFT)
32#define MX25_H1_PP_BIT (1 << 18)
30#define MX25_H1_PM_BIT (1 << 8) 33#define MX25_H1_PM_BIT (1 << 8)
31#define MX25_H1_IPPUE_UP_BIT (1 << 7) 34#define MX25_H1_IPPUE_UP_BIT (1 << 7)
32#define MX25_H1_IPPUE_DOWN_BIT (1 << 6) 35#define MX25_H1_IPPUE_DOWN_BIT (1 << 6)
33#define MX25_H1_TLL_BIT (1 << 5) 36#define MX25_H1_TLL_BIT (1 << 5)
34#define MX25_H1_USBTE_BIT (1 << 4) 37#define MX25_H1_USBTE_BIT (1 << 4)
38#define MX25_H1_OCPOL_BIT (1 << 2)
35 39
36int mx25_initialize_usb_hw(int port, unsigned int flags) 40int mx25_initialize_usb_hw(int port, unsigned int flags)
37{ 41{
@@ -41,21 +45,35 @@ int mx25_initialize_usb_hw(int port, unsigned int flags)
41 45
42 switch (port) { 46 switch (port) {
43 case 0: /* OTG port */ 47 case 0: /* OTG port */
44 v &= ~(MX25_OTG_SIC_MASK | MX25_OTG_PM_BIT); 48 v &= ~(MX25_OTG_SIC_MASK | MX25_OTG_PM_BIT | MX25_OTG_PP_BIT |
49 MX25_OTG_OCPOL_BIT);
45 v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX25_OTG_SIC_SHIFT; 50 v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX25_OTG_SIC_SHIFT;
46 51
47 if (!(flags & MXC_EHCI_POWER_PINS_ENABLED)) 52 if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
48 v |= MX25_OTG_PM_BIT; 53 v |= MX25_OTG_PM_BIT;
49 54
55 if (flags & MXC_EHCI_PWR_PIN_ACTIVE_HIGH)
56 v |= MX25_OTG_PP_BIT;
57
58 if (!(flags & MXC_EHCI_OC_PIN_ACTIVE_LOW))
59 v |= MX25_OTG_OCPOL_BIT;
60
50 break; 61 break;
51 case 1: /* H1 port */ 62 case 1: /* H1 port */
52 v &= ~(MX25_H1_SIC_MASK | MX25_H1_PM_BIT | MX25_H1_TLL_BIT | 63 v &= ~(MX25_H1_SIC_MASK | MX25_H1_PM_BIT | MX25_H1_PP_BIT |
53 MX25_H1_USBTE_BIT | MX25_H1_IPPUE_DOWN_BIT | MX25_H1_IPPUE_UP_BIT); 64 MX25_H1_OCPOL_BIT | MX25_H1_TLL_BIT | MX25_H1_USBTE_BIT |
65 MX25_H1_IPPUE_DOWN_BIT | MX25_H1_IPPUE_UP_BIT);
54 v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX25_H1_SIC_SHIFT; 66 v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX25_H1_SIC_SHIFT;
55 67
56 if (!(flags & MXC_EHCI_POWER_PINS_ENABLED)) 68 if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
57 v |= MX25_H1_PM_BIT; 69 v |= MX25_H1_PM_BIT;
58 70
71 if (flags & MXC_EHCI_PWR_PIN_ACTIVE_HIGH)
72 v |= MX25_H1_PP_BIT;
73
74 if (!(flags & MXC_EHCI_OC_PIN_ACTIVE_LOW))
75 v |= MX25_H1_OCPOL_BIT;
76
59 if (!(flags & MXC_EHCI_TTL_ENABLED)) 77 if (!(flags & MXC_EHCI_TTL_ENABLED))
60 v |= MX25_H1_TLL_BIT; 78 v |= MX25_H1_TLL_BIT;
61 79
diff --git a/arch/arm/mach-imx/ehci-imx35.c b/arch/arm/mach-imx/ehci-imx35.c
index 001ec3971f5..73574c30cf5 100644
--- a/arch/arm/mach-imx/ehci-imx35.c
+++ b/arch/arm/mach-imx/ehci-imx35.c
@@ -24,14 +24,18 @@
24#define MX35_OTG_SIC_SHIFT 29 24#define MX35_OTG_SIC_SHIFT 29
25#define MX35_OTG_SIC_MASK (0x3 << MX35_OTG_SIC_SHIFT) 25#define MX35_OTG_SIC_MASK (0x3 << MX35_OTG_SIC_SHIFT)
26#define MX35_OTG_PM_BIT (1 << 24) 26#define MX35_OTG_PM_BIT (1 << 24)
27#define MX35_OTG_PP_BIT (1 << 11)
28#define MX35_OTG_OCPOL_BIT (1 << 3)
27 29
28#define MX35_H1_SIC_SHIFT 21 30#define MX35_H1_SIC_SHIFT 21
29#define MX35_H1_SIC_MASK (0x3 << MX35_H1_SIC_SHIFT) 31#define MX35_H1_SIC_MASK (0x3 << MX35_H1_SIC_SHIFT)
32#define MX35_H1_PP_BIT (1 << 18)
30#define MX35_H1_PM_BIT (1 << 8) 33#define MX35_H1_PM_BIT (1 << 8)
31#define MX35_H1_IPPUE_UP_BIT (1 << 7) 34#define MX35_H1_IPPUE_UP_BIT (1 << 7)
32#define MX35_H1_IPPUE_DOWN_BIT (1 << 6) 35#define MX35_H1_IPPUE_DOWN_BIT (1 << 6)
33#define MX35_H1_TLL_BIT (1 << 5) 36#define MX35_H1_TLL_BIT (1 << 5)
34#define MX35_H1_USBTE_BIT (1 << 4) 37#define MX35_H1_USBTE_BIT (1 << 4)
38#define MX35_H1_OCPOL_BIT (1 << 2)
35 39
36int mx35_initialize_usb_hw(int port, unsigned int flags) 40int mx35_initialize_usb_hw(int port, unsigned int flags)
37{ 41{
@@ -41,21 +45,35 @@ int mx35_initialize_usb_hw(int port, unsigned int flags)
41 45
42 switch (port) { 46 switch (port) {
43 case 0: /* OTG port */ 47 case 0: /* OTG port */
44 v &= ~(MX35_OTG_SIC_MASK | MX35_OTG_PM_BIT); 48 v &= ~(MX35_OTG_SIC_MASK | MX35_OTG_PM_BIT | MX35_OTG_PP_BIT |
49 MX35_OTG_OCPOL_BIT);
45 v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX35_OTG_SIC_SHIFT; 50 v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX35_OTG_SIC_SHIFT;
46 51
47 if (!(flags & MXC_EHCI_POWER_PINS_ENABLED)) 52 if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
48 v |= MX35_OTG_PM_BIT; 53 v |= MX35_OTG_PM_BIT;
49 54
55 if (flags & MXC_EHCI_PWR_PIN_ACTIVE_HIGH)
56 v |= MX35_OTG_PP_BIT;
57
58 if (!(flags & MXC_EHCI_OC_PIN_ACTIVE_LOW))
59 v |= MX35_OTG_OCPOL_BIT;
60
50 break; 61 break;
51 case 1: /* H1 port */ 62 case 1: /* H1 port */
52 v &= ~(MX35_H1_SIC_MASK | MX35_H1_PM_BIT | MX35_H1_TLL_BIT | 63 v &= ~(MX35_H1_SIC_MASK | MX35_H1_PM_BIT | MX35_H1_PP_BIT |
53 MX35_H1_USBTE_BIT | MX35_H1_IPPUE_DOWN_BIT | MX35_H1_IPPUE_UP_BIT); 64 MX35_H1_OCPOL_BIT | MX35_H1_TLL_BIT | MX35_H1_USBTE_BIT |
65 MX35_H1_IPPUE_DOWN_BIT | MX35_H1_IPPUE_UP_BIT);
54 v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX35_H1_SIC_SHIFT; 66 v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX35_H1_SIC_SHIFT;
55 67
56 if (!(flags & MXC_EHCI_POWER_PINS_ENABLED)) 68 if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
57 v |= MX35_H1_PM_BIT; 69 v |= MX35_H1_PM_BIT;
58 70
71 if (flags & MXC_EHCI_PWR_PIN_ACTIVE_HIGH)
72 v |= MX35_H1_PP_BIT;
73
74 if (!(flags & MXC_EHCI_OC_PIN_ACTIVE_LOW))
75 v |= MX35_H1_OCPOL_BIT;
76
59 if (!(flags & MXC_EHCI_TTL_ENABLED)) 77 if (!(flags & MXC_EHCI_TTL_ENABLED))
60 v |= MX35_H1_TLL_BIT; 78 v |= MX35_H1_TLL_BIT;
61 79
diff --git a/arch/arm/mach-imx/ehci-imx5.c b/arch/arm/mach-imx/ehci-imx5.c
index c17fa131728..a6a4afb0ad6 100644
--- a/arch/arm/mach-imx/ehci-imx5.c
+++ b/arch/arm/mach-imx/ehci-imx5.c
@@ -28,11 +28,14 @@
28#define MXC_OTG_UCTRL_OPM_BIT (1 << 24) /* OTG power mask */ 28#define MXC_OTG_UCTRL_OPM_BIT (1 << 24) /* OTG power mask */
29#define MXC_H1_UCTRL_H1UIE_BIT (1 << 12) /* Host1 ULPI interrupt enable */ 29#define MXC_H1_UCTRL_H1UIE_BIT (1 << 12) /* Host1 ULPI interrupt enable */
30#define MXC_H1_UCTRL_H1WIE_BIT (1 << 11) /* HOST1 wakeup intr enable */ 30#define MXC_H1_UCTRL_H1WIE_BIT (1 << 11) /* HOST1 wakeup intr enable */
31#define MXC_H1_UCTRL_H1PM_BIT (1 << 8) /* HOST1 power mask */ 31#define MXC_H1_UCTRL_H1PM_BIT (1 << 8) /* HOST1 power mask */
32 32
33/* USB_PHY_CTRL_FUNC */ 33/* USB_PHY_CTRL_FUNC */
34#define MXC_OTG_PHYCTRL_OC_POL_BIT (1 << 9) /* OTG Polarity of Overcurrent */
34#define MXC_OTG_PHYCTRL_OC_DIS_BIT (1 << 8) /* OTG Disable Overcurrent Event */ 35#define MXC_OTG_PHYCTRL_OC_DIS_BIT (1 << 8) /* OTG Disable Overcurrent Event */
36#define MXC_H1_OC_POL_BIT (1 << 6) /* UH1 Polarity of Overcurrent */
35#define MXC_H1_OC_DIS_BIT (1 << 5) /* UH1 Disable Overcurrent Event */ 37#define MXC_H1_OC_DIS_BIT (1 << 5) /* UH1 Disable Overcurrent Event */
38#define MXC_OTG_PHYCTRL_PWR_POL_BIT (1 << 3) /* OTG Power Pin Polarity */
36 39
37/* USBH2CTRL */ 40/* USBH2CTRL */
38#define MXC_H2_UCTRL_H2UIE_BIT (1 << 8) 41#define MXC_H2_UCTRL_H2UIE_BIT (1 << 8)
@@ -80,13 +83,21 @@ int mx51_initialize_usb_hw(int port, unsigned int flags)
80 if (flags & MXC_EHCI_INTERNAL_PHY) { 83 if (flags & MXC_EHCI_INTERNAL_PHY) {
81 v = __raw_readl(usbother_base + MXC_USB_PHY_CTR_FUNC_OFFSET); 84 v = __raw_readl(usbother_base + MXC_USB_PHY_CTR_FUNC_OFFSET);
82 85
86 if (flags & MXC_EHCI_OC_PIN_ACTIVE_LOW)
87 v |= MXC_OTG_PHYCTRL_OC_POL_BIT;
88 else
89 v &= ~MXC_OTG_PHYCTRL_OC_POL_BIT;
83 if (flags & MXC_EHCI_POWER_PINS_ENABLED) { 90 if (flags & MXC_EHCI_POWER_PINS_ENABLED) {
84 /* OC/USBPWR is not used */
85 v |= MXC_OTG_PHYCTRL_OC_DIS_BIT;
86 } else {
87 /* OC/USBPWR is used */ 91 /* OC/USBPWR is used */
88 v &= ~MXC_OTG_PHYCTRL_OC_DIS_BIT; 92 v &= ~MXC_OTG_PHYCTRL_OC_DIS_BIT;
93 } else {
94 /* OC/USBPWR is not used */
95 v |= MXC_OTG_PHYCTRL_OC_DIS_BIT;
89 } 96 }
97 if (flags & MXC_EHCI_PWR_PIN_ACTIVE_HIGH)
98 v |= MXC_OTG_PHYCTRL_PWR_POL_BIT;
99 else
100 v &= ~MXC_OTG_PHYCTRL_PWR_POL_BIT;
90 __raw_writel(v, usbother_base + MXC_USB_PHY_CTR_FUNC_OFFSET); 101 __raw_writel(v, usbother_base + MXC_USB_PHY_CTR_FUNC_OFFSET);
91 102
92 v = __raw_readl(usbother_base + MXC_USBCTRL_OFFSET); 103 v = __raw_readl(usbother_base + MXC_USBCTRL_OFFSET);
@@ -95,9 +106,9 @@ int mx51_initialize_usb_hw(int port, unsigned int flags)
95 else 106 else
96 v &= ~MXC_OTG_UCTRL_OWIE_BIT;/* OTG wakeup disable */ 107 v &= ~MXC_OTG_UCTRL_OWIE_BIT;/* OTG wakeup disable */
97 if (flags & MXC_EHCI_POWER_PINS_ENABLED) 108 if (flags & MXC_EHCI_POWER_PINS_ENABLED)
98 v |= MXC_OTG_UCTRL_OPM_BIT;
99 else
100 v &= ~MXC_OTG_UCTRL_OPM_BIT; 109 v &= ~MXC_OTG_UCTRL_OPM_BIT;
110 else
111 v |= MXC_OTG_UCTRL_OPM_BIT;
101 __raw_writel(v, usbother_base + MXC_USBCTRL_OFFSET); 112 __raw_writel(v, usbother_base + MXC_USBCTRL_OFFSET);
102 } 113 }
103 break; 114 break;
@@ -113,12 +124,16 @@ int mx51_initialize_usb_hw(int port, unsigned int flags)
113 } 124 }
114 125
115 if (flags & MXC_EHCI_POWER_PINS_ENABLED) 126 if (flags & MXC_EHCI_POWER_PINS_ENABLED)
116 v &= ~MXC_H1_UCTRL_H1PM_BIT; /* HOST1 power mask used*/ 127 v &= ~MXC_H1_UCTRL_H1PM_BIT; /* HOST1 power mask unused*/
117 else 128 else
118 v |= MXC_H1_UCTRL_H1PM_BIT; /* HOST1 power mask used*/ 129 v |= MXC_H1_UCTRL_H1PM_BIT; /* HOST1 power mask used*/
119 __raw_writel(v, usbother_base + MXC_USBCTRL_OFFSET); 130 __raw_writel(v, usbother_base + MXC_USBCTRL_OFFSET);
120 131
121 v = __raw_readl(usbother_base + MXC_USB_PHY_CTR_FUNC_OFFSET); 132 v = __raw_readl(usbother_base + MXC_USB_PHY_CTR_FUNC_OFFSET);
133 if (flags & MXC_EHCI_OC_PIN_ACTIVE_LOW)
134 v |= MXC_H1_OC_POL_BIT;
135 else
136 v &= ~MXC_H1_OC_POL_BIT;
122 if (flags & MXC_EHCI_POWER_PINS_ENABLED) 137 if (flags & MXC_EHCI_POWER_PINS_ENABLED)
123 v &= ~MXC_H1_OC_DIS_BIT; /* OC is used */ 138 v &= ~MXC_H1_OC_DIS_BIT; /* OC is used */
124 else 139 else
@@ -142,7 +157,7 @@ int mx51_initialize_usb_hw(int port, unsigned int flags)
142 } 157 }
143 158
144 if (flags & MXC_EHCI_POWER_PINS_ENABLED) 159 if (flags & MXC_EHCI_POWER_PINS_ENABLED)
145 v &= ~MXC_H2_UCTRL_H2PM_BIT; /* HOST2 power mask used*/ 160 v &= ~MXC_H2_UCTRL_H2PM_BIT; /* HOST2 power mask unused*/
146 else 161 else
147 v |= MXC_H2_UCTRL_H2PM_BIT; /* HOST2 power mask used*/ 162 v |= MXC_H2_UCTRL_H2PM_BIT; /* HOST2 power mask used*/
148 __raw_writel(v, usbother_base + MXC_USBH2CTRL_OFFSET); 163 __raw_writel(v, usbother_base + MXC_USBH2CTRL_OFFSET);
diff --git a/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c b/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c
index b46cab0ced5..fd3177f9e79 100644
--- a/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c
+++ b/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c
@@ -266,7 +266,7 @@ static struct spi_board_info __maybe_unused
266 .bus_num = 0, 266 .bus_num = 0,
267 .chip_select = 0, 267 .chip_select = 0,
268 .max_speed_hz = 1500000, 268 .max_speed_hz = 1500000,
269 .irq = IRQ_GPIOD(25), 269 /* irq number is run-time assigned */
270 .platform_data = &ads7846_config, 270 .platform_data = &ads7846_config,
271 .mode = SPI_MODE_2, 271 .mode = SPI_MODE_2,
272 }, 272 },
@@ -329,6 +329,7 @@ void __init eukrea_mbimx27_baseboard_init(void)
329 /* SPI_CS0 init */ 329 /* SPI_CS0 init */
330 mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT); 330 mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT);
331 imx27_add_spi_imx0(&eukrea_mbimx27_spi0_data); 331 imx27_add_spi_imx0(&eukrea_mbimx27_spi0_data);
332 eukrea_mbimx27_spi_board_info[0].irq = gpio_to_irq(IMX_GPIO_NR(4, 25));
332 spi_register_board_info(eukrea_mbimx27_spi_board_info, 333 spi_register_board_info(eukrea_mbimx27_spi_board_info,
333 ARRAY_SIZE(eukrea_mbimx27_spi_board_info)); 334 ARRAY_SIZE(eukrea_mbimx27_spi_board_info));
334 335
diff --git a/arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c b/arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c
index 557f6c48605..6e9dd12a696 100644
--- a/arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c
+++ b/arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c
@@ -95,10 +95,6 @@ static const struct fb_videomode fb_modedb[] = {
95 }, 95 },
96}; 96};
97 97
98static const struct ipu_platform_data mx3_ipu_data __initconst = {
99 .irq_base = MXC_IPU_IRQ_START,
100};
101
102static struct mx3fb_platform_data mx3fb_pdata __initdata = { 98static struct mx3fb_platform_data mx3fb_pdata __initdata = {
103 .name = "CMO-QVGA", 99 .name = "CMO-QVGA",
104 .mode = fb_modedb, 100 .mode = fb_modedb,
@@ -287,7 +283,7 @@ void __init eukrea_mbimxsd35_baseboard_init(void)
287 printk(KERN_ERR "error setting mbimxsd pads !\n"); 283 printk(KERN_ERR "error setting mbimxsd pads !\n");
288 284
289 imx35_add_imx_uart1(&uart_pdata); 285 imx35_add_imx_uart1(&uart_pdata);
290 imx35_add_ipu_core(&mx3_ipu_data); 286 imx35_add_ipu_core();
291 imx35_add_mx3_sdc_fb(&mx3fb_pdata); 287 imx35_add_mx3_sdc_fb(&mx3fb_pdata);
292 288
293 imx35_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata); 289 imx35_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata);
diff --git a/arch/arm/mach-imx/head-v7.S b/arch/arm/mach-imx/headsmp.S
index 7e49deb128a..7e49deb128a 100644
--- a/arch/arm/mach-imx/head-v7.S
+++ b/arch/arm/mach-imx/headsmp.S
diff --git a/arch/arm/mach-imx/hotplug.c b/arch/arm/mach-imx/hotplug.c
index 20ed2d56c1a..f8f7437c83b 100644
--- a/arch/arm/mach-imx/hotplug.c
+++ b/arch/arm/mach-imx/hotplug.c
@@ -42,22 +42,6 @@ static inline void cpu_enter_lowpower(void)
42 : "cc"); 42 : "cc");
43} 43}
44 44
45static inline void cpu_leave_lowpower(void)
46{
47 unsigned int v;
48
49 asm volatile(
50 "mrc p15, 0, %0, c1, c0, 0\n"
51 " orr %0, %0, %1\n"
52 " mcr p15, 0, %0, c1, c0, 0\n"
53 " mrc p15, 0, %0, c1, c0, 1\n"
54 " orr %0, %0, %2\n"
55 " mcr p15, 0, %0, c1, c0, 1\n"
56 : "=&r" (v)
57 : "Ir" (CR_C), "Ir" (0x40)
58 : "cc");
59}
60
61/* 45/*
62 * platform-specific code to shutdown a CPU 46 * platform-specific code to shutdown a CPU
63 * 47 *
@@ -67,11 +51,10 @@ void platform_cpu_die(unsigned int cpu)
67{ 51{
68 cpu_enter_lowpower(); 52 cpu_enter_lowpower();
69 imx_enable_cpu(cpu, false); 53 imx_enable_cpu(cpu, false);
70 cpu_do_idle();
71 cpu_leave_lowpower();
72 54
73 /* We should never return from idle */ 55 /* spin here until hardware takes it down */
74 panic("cpu %d unexpectedly exit from shutdown\n", cpu); 56 while (1)
57 ;
75} 58}
76 59
77int platform_cpu_disable(unsigned int cpu) 60int platform_cpu_disable(unsigned int cpu)
diff --git a/arch/arm/mach-imx/imx27-dt.c b/arch/arm/mach-imx/imx27-dt.c
index eee0cc8d92a..e80d5235dac 100644
--- a/arch/arm/mach-imx/imx27-dt.c
+++ b/arch/arm/mach-imx/imx27-dt.c
@@ -10,7 +10,6 @@
10 */ 10 */
11 11
12#include <linux/irq.h> 12#include <linux/irq.h>
13#include <linux/irqdomain.h>
14#include <linux/of_irq.h> 13#include <linux/of_irq.h>
15#include <linux/of_platform.h> 14#include <linux/of_platform.h>
16#include <asm/mach/arch.h> 15#include <asm/mach/arch.h>
@@ -33,35 +32,8 @@ static const struct of_dev_auxdata imx27_auxdata_lookup[] __initconst = {
33 { /* sentinel */ } 32 { /* sentinel */ }
34}; 33};
35 34
36static int __init imx27_avic_add_irq_domain(struct device_node *np,
37 struct device_node *interrupt_parent)
38{
39 irq_domain_add_legacy(np, 64, 0, 0, &irq_domain_simple_ops, NULL);
40 return 0;
41}
42
43static int __init imx27_gpio_add_irq_domain(struct device_node *np,
44 struct device_node *interrupt_parent)
45{
46 static int gpio_irq_base = MXC_GPIO_IRQ_START + ARCH_NR_GPIOS;
47
48 gpio_irq_base -= 32;
49 irq_domain_add_legacy(np, 32, gpio_irq_base, 0, &irq_domain_simple_ops,
50 NULL);
51
52 return 0;
53}
54
55static const struct of_device_id imx27_irq_match[] __initconst = {
56 { .compatible = "fsl,imx27-avic", .data = imx27_avic_add_irq_domain, },
57 { .compatible = "fsl,imx27-gpio", .data = imx27_gpio_add_irq_domain, },
58 { /* sentinel */ }
59};
60
61static void __init imx27_dt_init(void) 35static void __init imx27_dt_init(void)
62{ 36{
63 of_irq_init(imx27_irq_match);
64
65 of_platform_populate(NULL, of_default_bus_match_table, 37 of_platform_populate(NULL, of_default_bus_match_table,
66 imx27_auxdata_lookup, NULL); 38 imx27_auxdata_lookup, NULL);
67} 39}
@@ -75,7 +47,7 @@ static struct sys_timer imx27_timer = {
75 .init = imx27_timer_init, 47 .init = imx27_timer_init,
76}; 48};
77 49
78static const char *imx27_dt_board_compat[] __initdata = { 50static const char * const imx27_dt_board_compat[] __initconst = {
79 "fsl,imx27", 51 "fsl,imx27",
80 NULL 52 NULL
81}; 53};
diff --git a/arch/arm/mach-imx/imx31-dt.c b/arch/arm/mach-imx/imx31-dt.c
new file mode 100644
index 00000000000..a68ba207b2b
--- /dev/null
+++ b/arch/arm/mach-imx/imx31-dt.c
@@ -0,0 +1,63 @@
1/*
2 * Copyright 2012 Sascha Hauer, Pengutronix
3 *
4 * The code contained herein is licensed under the GNU General Public
5 * License. You may obtain a copy of the GNU General Public License
6 * Version 2 or later at the following locations:
7 *
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
10 */
11
12#include <linux/irq.h>
13#include <linux/of_irq.h>
14#include <linux/of_platform.h>
15#include <asm/mach/arch.h>
16#include <asm/mach/time.h>
17#include <mach/common.h>
18#include <mach/mx31.h>
19
20static const struct of_dev_auxdata imx31_auxdata_lookup[] __initconst = {
21 OF_DEV_AUXDATA("fsl,imx31-uart", MX31_UART1_BASE_ADDR,
22 "imx21-uart.0", NULL),
23 OF_DEV_AUXDATA("fsl,imx31-uart", MX31_UART2_BASE_ADDR,
24 "imx21-uart.1", NULL),
25 OF_DEV_AUXDATA("fsl,imx31-uart", MX31_UART3_BASE_ADDR,
26 "imx21-uart.2", NULL),
27 OF_DEV_AUXDATA("fsl,imx31-uart", MX31_UART4_BASE_ADDR,
28 "imx21-uart.3", NULL),
29 OF_DEV_AUXDATA("fsl,imx31-uart", MX31_UART5_BASE_ADDR,
30 "imx21-uart.4", NULL),
31 { /* sentinel */ }
32};
33
34static void __init imx31_dt_init(void)
35{
36 of_platform_populate(NULL, of_default_bus_match_table,
37 imx31_auxdata_lookup, NULL);
38}
39
40static void __init imx31_timer_init(void)
41{
42 mx31_clocks_init_dt();
43}
44
45static struct sys_timer imx31_timer = {
46 .init = imx31_timer_init,
47};
48
49static const char *imx31_dt_board_compat[] __initdata = {
50 "fsl,imx31",
51 NULL
52};
53
54DT_MACHINE_START(IMX31_DT, "Freescale i.MX31 (Device Tree Support)")
55 .map_io = mx31_map_io,
56 .init_early = imx31_init_early,
57 .init_irq = mx31_init_irq,
58 .handle_irq = imx31_handle_irq,
59 .timer = &imx31_timer,
60 .init_machine = imx31_dt_init,
61 .dt_compat = imx31_dt_board_compat,
62 .restart = mxc_restart,
63MACHINE_END
diff --git a/arch/arm/mach-imx/imx51-dt.c b/arch/arm/mach-imx/imx51-dt.c
index 18e78dba429..d4067fe3635 100644
--- a/arch/arm/mach-imx/imx51-dt.c
+++ b/arch/arm/mach-imx/imx51-dt.c
@@ -11,7 +11,6 @@
11 */ 11 */
12 12
13#include <linux/irq.h> 13#include <linux/irq.h>
14#include <linux/irqdomain.h>
15#include <linux/of_irq.h> 14#include <linux/of_irq.h>
16#include <linux/of_platform.h> 15#include <linux/of_platform.h>
17#include <linux/pinctrl/machine.h> 16#include <linux/pinctrl/machine.h>
@@ -45,30 +44,6 @@ static const struct of_dev_auxdata imx51_auxdata_lookup[] __initconst = {
45 { /* sentinel */ } 44 { /* sentinel */ }
46}; 45};
47 46
48static int __init imx51_tzic_add_irq_domain(struct device_node *np,
49 struct device_node *interrupt_parent)
50{
51 irq_domain_add_legacy(np, 128, 0, 0, &irq_domain_simple_ops, NULL);
52 return 0;
53}
54
55static int __init imx51_gpio_add_irq_domain(struct device_node *np,
56 struct device_node *interrupt_parent)
57{
58 static int gpio_irq_base = MXC_GPIO_IRQ_START + ARCH_NR_GPIOS;
59
60 gpio_irq_base -= 32;
61 irq_domain_add_legacy(np, 32, gpio_irq_base, 0, &irq_domain_simple_ops, NULL);
62
63 return 0;
64}
65
66static const struct of_device_id imx51_irq_match[] __initconst = {
67 { .compatible = "fsl,imx51-tzic", .data = imx51_tzic_add_irq_domain, },
68 { .compatible = "fsl,imx51-gpio", .data = imx51_gpio_add_irq_domain, },
69 { /* sentinel */ }
70};
71
72static const struct of_device_id imx51_iomuxc_of_match[] __initconst = { 47static const struct of_device_id imx51_iomuxc_of_match[] __initconst = {
73 { .compatible = "fsl,imx51-iomuxc-babbage", .data = imx51_babbage_common_init, }, 48 { .compatible = "fsl,imx51-iomuxc-babbage", .data = imx51_babbage_common_init, },
74 { /* sentinel */ } 49 { /* sentinel */ }
@@ -80,8 +55,6 @@ static void __init imx51_dt_init(void)
80 const struct of_device_id *of_id; 55 const struct of_device_id *of_id;
81 void (*func)(void); 56 void (*func)(void);
82 57
83 of_irq_init(imx51_irq_match);
84
85 pinctrl_provide_dummies(); 58 pinctrl_provide_dummies();
86 59
87 node = of_find_matching_node(NULL, imx51_iomuxc_of_match); 60 node = of_find_matching_node(NULL, imx51_iomuxc_of_match);
diff --git a/arch/arm/mach-imx/imx53-dt.c b/arch/arm/mach-imx/imx53-dt.c
index eb04b6248e4..1b7a2fc3659 100644
--- a/arch/arm/mach-imx/imx53-dt.c
+++ b/arch/arm/mach-imx/imx53-dt.c
@@ -15,7 +15,6 @@
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/irq.h> 17#include <linux/irq.h>
18#include <linux/irqdomain.h>
19#include <linux/of_irq.h> 18#include <linux/of_irq.h>
20#include <linux/of_platform.h> 19#include <linux/of_platform.h>
21#include <linux/pinctrl/machine.h> 20#include <linux/pinctrl/machine.h>
@@ -52,30 +51,6 @@ static const struct of_dev_auxdata imx53_auxdata_lookup[] __initconst = {
52 { /* sentinel */ } 51 { /* sentinel */ }
53}; 52};
54 53
55static int __init imx53_tzic_add_irq_domain(struct device_node *np,
56 struct device_node *interrupt_parent)
57{
58 irq_domain_add_legacy(np, 128, 0, 0, &irq_domain_simple_ops, NULL);
59 return 0;
60}
61
62static int __init imx53_gpio_add_irq_domain(struct device_node *np,
63 struct device_node *interrupt_parent)
64{
65 static int gpio_irq_base = MXC_GPIO_IRQ_START + ARCH_NR_GPIOS;
66
67 gpio_irq_base -= 32;
68 irq_domain_add_legacy(np, 32, gpio_irq_base, 0, &irq_domain_simple_ops, NULL);
69
70 return 0;
71}
72
73static const struct of_device_id imx53_irq_match[] __initconst = {
74 { .compatible = "fsl,imx53-tzic", .data = imx53_tzic_add_irq_domain, },
75 { .compatible = "fsl,imx53-gpio", .data = imx53_gpio_add_irq_domain, },
76 { /* sentinel */ }
77};
78
79static const struct of_device_id imx53_iomuxc_of_match[] __initconst = { 54static const struct of_device_id imx53_iomuxc_of_match[] __initconst = {
80 { .compatible = "fsl,imx53-iomuxc-ard", .data = imx53_ard_common_init, }, 55 { .compatible = "fsl,imx53-iomuxc-ard", .data = imx53_ard_common_init, },
81 { .compatible = "fsl,imx53-iomuxc-evk", .data = imx53_evk_common_init, }, 56 { .compatible = "fsl,imx53-iomuxc-evk", .data = imx53_evk_common_init, },
@@ -103,8 +78,6 @@ static void __init imx53_dt_init(void)
103 const struct of_device_id *of_id; 78 const struct of_device_id *of_id;
104 void (*func)(void); 79 void (*func)(void);
105 80
106 of_irq_init(imx53_irq_match);
107
108 pinctrl_provide_dummies(); 81 pinctrl_provide_dummies();
109 82
110 node = of_find_matching_node(NULL, imx53_iomuxc_of_match); 83 node = of_find_matching_node(NULL, imx53_iomuxc_of_match);
@@ -147,6 +120,7 @@ DT_MACHINE_START(IMX53_DT, "Freescale i.MX53 (Device Tree Support)")
147 .handle_irq = imx53_handle_irq, 120 .handle_irq = imx53_handle_irq,
148 .timer = &imx53_timer, 121 .timer = &imx53_timer,
149 .init_machine = imx53_dt_init, 122 .init_machine = imx53_dt_init,
123 .init_late = imx53_init_late,
150 .dt_compat = imx53_dt_board_compat, 124 .dt_compat = imx53_dt_board_compat,
151 .restart = mxc_restart, 125 .restart = mxc_restart,
152MACHINE_END 126MACHINE_END
diff --git a/arch/arm/mach-imx/mach-apf9328.c b/arch/arm/mach-imx/mach-apf9328.c
index f4a63ee9e21..7b99a79722b 100644
--- a/arch/arm/mach-imx/mach-apf9328.c
+++ b/arch/arm/mach-imx/mach-apf9328.c
@@ -18,6 +18,7 @@
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/mtd/physmap.h> 19#include <linux/mtd/physmap.h>
20#include <linux/dm9000.h> 20#include <linux/dm9000.h>
21#include <linux/gpio.h>
21#include <linux/i2c.h> 22#include <linux/i2c.h>
22 23
23#include <asm/mach-types.h> 24#include <asm/mach-types.h>
@@ -26,7 +27,6 @@
26 27
27#include <mach/common.h> 28#include <mach/common.h>
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <mach/irqs.h>
30#include <mach/iomux-mx1.h> 30#include <mach/iomux-mx1.h>
31 31
32#include "devices-imx1.h" 32#include "devices-imx1.h"
@@ -87,8 +87,7 @@ static struct resource dm9000_resources[] = {
87 .end = MX1_CS4_PHYS + 0x00C00003, 87 .end = MX1_CS4_PHYS + 0x00C00003,
88 .flags = IORESOURCE_MEM, 88 .flags = IORESOURCE_MEM,
89 }, { 89 }, {
90 .start = IRQ_GPIOB(14), 90 /* irq number is run-time assigned */
91 .end = IRQ_GPIOB(14),
92 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, 91 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
93 }, 92 },
94}; 93};
@@ -129,6 +128,8 @@ static void __init apf9328_init(void)
129 128
130 imx1_add_imx_i2c(&apf9328_i2c_data); 129 imx1_add_imx_i2c(&apf9328_i2c_data);
131 130
131 dm9000_resources[2].start = gpio_to_irq(IMX_GPIO_NR(2, 14));
132 dm9000_resources[2].end = gpio_to_irq(IMX_GPIO_NR(2, 14));
132 platform_add_devices(devices, ARRAY_SIZE(devices)); 133 platform_add_devices(devices, ARRAY_SIZE(devices));
133} 134}
134 135
diff --git a/arch/arm/mach-imx/mach-armadillo5x0.c b/arch/arm/mach-imx/mach-armadillo5x0.c
index c650145d164..2c6ab3273f9 100644
--- a/arch/arm/mach-imx/mach-armadillo5x0.c
+++ b/arch/arm/mach-imx/mach-armadillo5x0.c
@@ -367,10 +367,6 @@ static const struct fb_videomode fb_modedb[] = {
367 }, 367 },
368}; 368};
369 369
370static const struct ipu_platform_data mx3_ipu_data __initconst = {
371 .irq_base = MXC_IPU_IRQ_START,
372};
373
374static struct mx3fb_platform_data mx3fb_pdata __initdata = { 370static struct mx3fb_platform_data mx3fb_pdata __initdata = {
375 .name = "CRT-VGA", 371 .name = "CRT-VGA",
376 .mode = fb_modedb, 372 .mode = fb_modedb,
@@ -408,7 +404,8 @@ static int armadillo5x0_sdhc1_init(struct device *dev,
408 gpio_direction_input(gpio_wp); 404 gpio_direction_input(gpio_wp);
409 405
410 /* When supported the trigger type have to be BOTH */ 406 /* When supported the trigger type have to be BOTH */
411 ret = request_irq(IOMUX_TO_IRQ(MX31_PIN_ATA_DMACK), detect_irq, 407 ret = request_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK)),
408 detect_irq,
412 IRQF_DISABLED | IRQF_TRIGGER_FALLING, 409 IRQF_DISABLED | IRQF_TRIGGER_FALLING,
413 "sdhc-detect", data); 410 "sdhc-detect", data);
414 411
@@ -429,7 +426,7 @@ err_gpio_free:
429 426
430static void armadillo5x0_sdhc1_exit(struct device *dev, void *data) 427static void armadillo5x0_sdhc1_exit(struct device *dev, void *data)
431{ 428{
432 free_irq(IOMUX_TO_IRQ(MX31_PIN_ATA_DMACK), data); 429 free_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK)), data);
433 gpio_free(IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK)); 430 gpio_free(IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK));
434 gpio_free(IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B)); 431 gpio_free(IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B));
435} 432}
@@ -450,8 +447,7 @@ static struct resource armadillo5x0_smc911x_resources[] = {
450 .end = MX31_CS3_BASE_ADDR + SZ_32M - 1, 447 .end = MX31_CS3_BASE_ADDR + SZ_32M - 1,
451 .flags = IORESOURCE_MEM, 448 .flags = IORESOURCE_MEM,
452 }, { 449 }, {
453 .start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0), 450 /* irq number is run-time assigned */
454 .end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),
455 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, 451 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
456 }, 452 },
457}; 453};
@@ -498,6 +494,10 @@ static void __init armadillo5x0_init(void)
498 494
499 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies)); 495 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
500 496
497 armadillo5x0_smc911x_resources[1].start =
498 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_0));
499 armadillo5x0_smc911x_resources[1].end =
500 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_0));
501 platform_add_devices(devices, ARRAY_SIZE(devices)); 501 platform_add_devices(devices, ARRAY_SIZE(devices));
502 imx_add_gpio_keys(&armadillo5x0_button_data); 502 imx_add_gpio_keys(&armadillo5x0_button_data);
503 imx31_add_imx_i2c1(NULL); 503 imx31_add_imx_i2c1(NULL);
@@ -513,7 +513,7 @@ static void __init armadillo5x0_init(void)
513 imx31_add_mxc_mmc(0, &sdhc_pdata); 513 imx31_add_mxc_mmc(0, &sdhc_pdata);
514 514
515 /* Register FB */ 515 /* Register FB */
516 imx31_add_ipu_core(&mx3_ipu_data); 516 imx31_add_ipu_core();
517 imx31_add_mx3_sdc_fb(&mx3fb_pdata); 517 imx31_add_mx3_sdc_fb(&mx3fb_pdata);
518 518
519 /* Register NOR Flash */ 519 /* Register NOR Flash */
diff --git a/arch/arm/mach-imx/mach-cpuimx27.c b/arch/arm/mach-imx/mach-cpuimx27.c
index d085aea0870..2bb9e18d9ee 100644
--- a/arch/arm/mach-imx/mach-cpuimx27.c
+++ b/arch/arm/mach-imx/mach-cpuimx27.c
@@ -169,28 +169,28 @@ static struct i2c_board_info eukrea_cpuimx27_i2c_devices[] = {
169static struct plat_serial8250_port serial_platform_data[] = { 169static struct plat_serial8250_port serial_platform_data[] = {
170 { 170 {
171 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x200000), 171 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x200000),
172 .irq = IRQ_GPIOB(23), 172 /* irq number is run-time assigned */
173 .uartclk = 14745600, 173 .uartclk = 14745600,
174 .regshift = 1, 174 .regshift = 1,
175 .iotype = UPIO_MEM, 175 .iotype = UPIO_MEM,
176 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, 176 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
177 }, { 177 }, {
178 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x400000), 178 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x400000),
179 .irq = IRQ_GPIOB(22), 179 /* irq number is run-time assigned */
180 .uartclk = 14745600, 180 .uartclk = 14745600,
181 .regshift = 1, 181 .regshift = 1,
182 .iotype = UPIO_MEM, 182 .iotype = UPIO_MEM,
183 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, 183 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
184 }, { 184 }, {
185 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x800000), 185 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x800000),
186 .irq = IRQ_GPIOB(27), 186 /* irq number is run-time assigned */
187 .uartclk = 14745600, 187 .uartclk = 14745600,
188 .regshift = 1, 188 .regshift = 1,
189 .iotype = UPIO_MEM, 189 .iotype = UPIO_MEM,
190 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, 190 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
191 }, { 191 }, {
192 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x1000000), 192 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x1000000),
193 .irq = IRQ_GPIOB(30), 193 /* irq number is run-time assigned */
194 .uartclk = 14745600, 194 .uartclk = 14745600,
195 .regshift = 1, 195 .regshift = 1,
196 .iotype = UPIO_MEM, 196 .iotype = UPIO_MEM,
@@ -233,18 +233,18 @@ static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
233 .phy_mode = FSL_USB2_PHY_ULPI, 233 .phy_mode = FSL_USB2_PHY_ULPI,
234}; 234};
235 235
236static int otg_mode_host; 236static bool otg_mode_host __initdata;
237 237
238static int __init eukrea_cpuimx27_otg_mode(char *options) 238static int __init eukrea_cpuimx27_otg_mode(char *options)
239{ 239{
240 if (!strcmp(options, "host")) 240 if (!strcmp(options, "host"))
241 otg_mode_host = 1; 241 otg_mode_host = true;
242 else if (!strcmp(options, "device")) 242 else if (!strcmp(options, "device"))
243 otg_mode_host = 0; 243 otg_mode_host = false;
244 else 244 else
245 pr_info("otg_mode neither \"host\" nor \"device\". " 245 pr_info("otg_mode neither \"host\" nor \"device\". "
246 "Defaulting to device\n"); 246 "Defaulting to device\n");
247 return 0; 247 return 1;
248} 248}
249__setup("otg_mode=", eukrea_cpuimx27_otg_mode); 249__setup("otg_mode=", eukrea_cpuimx27_otg_mode);
250 250
@@ -266,8 +266,8 @@ static void __init eukrea_cpuimx27_init(void)
266 266
267 imx27_add_fec(NULL); 267 imx27_add_fec(NULL);
268 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 268 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
269 imx27_add_imx2_wdt(NULL); 269 imx27_add_imx2_wdt();
270 imx27_add_mxc_w1(NULL); 270 imx27_add_mxc_w1();
271 271
272#if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2) 272#if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2)
273 /* SDHC2 can be used for Wifi */ 273 /* SDHC2 can be used for Wifi */
@@ -279,6 +279,10 @@ static void __init eukrea_cpuimx27_init(void)
279#endif 279#endif
280 280
281#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) 281#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
282 serial_platform_data[0].irq = IMX_GPIO_NR(2, 23);
283 serial_platform_data[1].irq = IMX_GPIO_NR(2, 22);
284 serial_platform_data[2].irq = IMX_GPIO_NR(2, 27);
285 serial_platform_data[3].irq = IMX_GPIO_NR(2, 30);
282 platform_device_register(&serial_device); 286 platform_device_register(&serial_device);
283#endif 287#endif
284 288
diff --git a/arch/arm/mach-imx/mach-cpuimx35.c b/arch/arm/mach-imx/mach-cpuimx35.c
index 6450303f1a7..d49b0ec6bde 100644
--- a/arch/arm/mach-imx/mach-cpuimx35.c
+++ b/arch/arm/mach-imx/mach-cpuimx35.c
@@ -71,7 +71,7 @@ static struct i2c_board_info eukrea_cpuimx35_i2c_devices[] = {
71 }, { 71 }, {
72 I2C_BOARD_INFO("tsc2007", 0x48), 72 I2C_BOARD_INFO("tsc2007", 0x48),
73 .platform_data = &tsc2007_info, 73 .platform_data = &tsc2007_info,
74 .irq = IMX_GPIO_TO_IRQ(TSC2007_IRQGPIO), 74 /* irq number is run-time assigned */
75 }, 75 },
76}; 76};
77 77
@@ -141,18 +141,18 @@ static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
141 .workaround = FLS_USB2_WORKAROUND_ENGCM09152, 141 .workaround = FLS_USB2_WORKAROUND_ENGCM09152,
142}; 142};
143 143
144static int otg_mode_host; 144static bool otg_mode_host __initdata;
145 145
146static int __init eukrea_cpuimx35_otg_mode(char *options) 146static int __init eukrea_cpuimx35_otg_mode(char *options)
147{ 147{
148 if (!strcmp(options, "host")) 148 if (!strcmp(options, "host"))
149 otg_mode_host = 1; 149 otg_mode_host = true;
150 else if (!strcmp(options, "device")) 150 else if (!strcmp(options, "device"))
151 otg_mode_host = 0; 151 otg_mode_host = false;
152 else 152 else
153 pr_info("otg_mode neither \"host\" nor \"device\". " 153 pr_info("otg_mode neither \"host\" nor \"device\". "
154 "Defaulting to device\n"); 154 "Defaulting to device\n");
155 return 0; 155 return 1;
156} 156}
157__setup("otg_mode=", eukrea_cpuimx35_otg_mode); 157__setup("otg_mode=", eukrea_cpuimx35_otg_mode);
158 158
@@ -167,11 +167,12 @@ static void __init eukrea_cpuimx35_init(void)
167 ARRAY_SIZE(eukrea_cpuimx35_pads)); 167 ARRAY_SIZE(eukrea_cpuimx35_pads));
168 168
169 imx35_add_fec(NULL); 169 imx35_add_fec(NULL);
170 imx35_add_imx2_wdt(NULL); 170 imx35_add_imx2_wdt();
171 171
172 imx35_add_imx_uart0(&uart_pdata); 172 imx35_add_imx_uart0(&uart_pdata);
173 imx35_add_mxc_nand(&eukrea_cpuimx35_nand_board_info); 173 imx35_add_mxc_nand(&eukrea_cpuimx35_nand_board_info);
174 174
175 eukrea_cpuimx35_i2c_devices[1].irq = gpio_to_irq(TSC2007_IRQGPIO);
175 i2c_register_board_info(0, eukrea_cpuimx35_i2c_devices, 176 i2c_register_board_info(0, eukrea_cpuimx35_i2c_devices,
176 ARRAY_SIZE(eukrea_cpuimx35_i2c_devices)); 177 ARRAY_SIZE(eukrea_cpuimx35_i2c_devices));
177 imx35_add_imx_i2c0(&eukrea_cpuimx35_i2c0_data); 178 imx35_add_imx_i2c0(&eukrea_cpuimx35_i2c0_data);
diff --git a/arch/arm/mach-imx/mach-cpuimx51sd.c b/arch/arm/mach-imx/mach-cpuimx51sd.c
index 1e09de50cbc..b87cc49ab1e 100644
--- a/arch/arm/mach-imx/mach-cpuimx51sd.c
+++ b/arch/arm/mach-imx/mach-cpuimx51sd.c
@@ -217,18 +217,18 @@ static const struct mxc_usbh_platform_data usbh1_config __initconst = {
217 .portsc = MXC_EHCI_MODE_ULPI, 217 .portsc = MXC_EHCI_MODE_ULPI,
218}; 218};
219 219
220static int otg_mode_host; 220static bool otg_mode_host __initdata;
221 221
222static int __init eukrea_cpuimx51sd_otg_mode(char *options) 222static int __init eukrea_cpuimx51sd_otg_mode(char *options)
223{ 223{
224 if (!strcmp(options, "host")) 224 if (!strcmp(options, "host"))
225 otg_mode_host = 1; 225 otg_mode_host = true;
226 else if (!strcmp(options, "device")) 226 else if (!strcmp(options, "device"))
227 otg_mode_host = 0; 227 otg_mode_host = false;
228 else 228 else
229 pr_info("otg_mode neither \"host\" nor \"device\". " 229 pr_info("otg_mode neither \"host\" nor \"device\". "
230 "Defaulting to device\n"); 230 "Defaulting to device\n");
231 return 0; 231 return 1;
232} 232}
233__setup("otg_mode=", eukrea_cpuimx51sd_otg_mode); 233__setup("otg_mode=", eukrea_cpuimx51sd_otg_mode);
234 234
@@ -258,7 +258,7 @@ static struct spi_board_info cpuimx51sd_spi_device[] = {
258 .mode = SPI_MODE_0, 258 .mode = SPI_MODE_0,
259 .chip_select = 0, 259 .chip_select = 0,
260 .platform_data = &mcp251x_info, 260 .platform_data = &mcp251x_info,
261 .irq = IMX_GPIO_TO_IRQ(CAN_IRQGPIO) 261 /* irq number is run-time assigned */
262 }, 262 },
263}; 263};
264 264
@@ -292,7 +292,7 @@ static void __init eukrea_cpuimx51sd_init(void)
292 292
293 imx51_add_imx_uart(0, &uart_pdata); 293 imx51_add_imx_uart(0, &uart_pdata);
294 imx51_add_mxc_nand(&eukrea_cpuimx51sd_nand_board_info); 294 imx51_add_mxc_nand(&eukrea_cpuimx51sd_nand_board_info);
295 imx51_add_imx2_wdt(0, NULL); 295 imx51_add_imx2_wdt(0);
296 296
297 gpio_request(ETH_RST, "eth_rst"); 297 gpio_request(ETH_RST, "eth_rst");
298 gpio_set_value(ETH_RST, 1); 298 gpio_set_value(ETH_RST, 1);
@@ -309,6 +309,7 @@ static void __init eukrea_cpuimx51sd_init(void)
309 msleep(20); 309 msleep(20);
310 gpio_set_value(CAN_RST, 1); 310 gpio_set_value(CAN_RST, 1);
311 imx51_add_ecspi(0, &cpuimx51sd_ecspi1_pdata); 311 imx51_add_ecspi(0, &cpuimx51sd_ecspi1_pdata);
312 cpuimx51sd_spi_device[0].irq = gpio_to_irq(CAN_IRQGPIO);
312 spi_register_board_info(cpuimx51sd_spi_device, 313 spi_register_board_info(cpuimx51sd_spi_device,
313 ARRAY_SIZE(cpuimx51sd_spi_device)); 314 ARRAY_SIZE(cpuimx51sd_spi_device));
314 315
diff --git a/arch/arm/mach-imx/mach-eukrea_cpuimx25.c b/arch/arm/mach-imx/mach-eukrea_cpuimx25.c
index d1e04e676e3..017bbb70ea4 100644
--- a/arch/arm/mach-imx/mach-eukrea_cpuimx25.c
+++ b/arch/arm/mach-imx/mach-eukrea_cpuimx25.c
@@ -109,18 +109,18 @@ static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
109 .workaround = FLS_USB2_WORKAROUND_ENGCM09152, 109 .workaround = FLS_USB2_WORKAROUND_ENGCM09152,
110}; 110};
111 111
112static int otg_mode_host; 112static bool otg_mode_host __initdata;
113 113
114static int __init eukrea_cpuimx25_otg_mode(char *options) 114static int __init eukrea_cpuimx25_otg_mode(char *options)
115{ 115{
116 if (!strcmp(options, "host")) 116 if (!strcmp(options, "host"))
117 otg_mode_host = 1; 117 otg_mode_host = true;
118 else if (!strcmp(options, "device")) 118 else if (!strcmp(options, "device"))
119 otg_mode_host = 0; 119 otg_mode_host = false;
120 else 120 else
121 pr_info("otg_mode neither \"host\" nor \"device\". " 121 pr_info("otg_mode neither \"host\" nor \"device\". "
122 "Defaulting to device\n"); 122 "Defaulting to device\n");
123 return 0; 123 return 1;
124} 124}
125__setup("otg_mode=", eukrea_cpuimx25_otg_mode); 125__setup("otg_mode=", eukrea_cpuimx25_otg_mode);
126 126
@@ -134,9 +134,9 @@ static void __init eukrea_cpuimx25_init(void)
134 134
135 imx25_add_imx_uart0(&uart_pdata); 135 imx25_add_imx_uart0(&uart_pdata);
136 imx25_add_mxc_nand(&eukrea_cpuimx25_nand_board_info); 136 imx25_add_mxc_nand(&eukrea_cpuimx25_nand_board_info);
137 imx25_add_imxdi_rtc(NULL); 137 imx25_add_imxdi_rtc();
138 imx25_add_fec(&mx25_fec_pdata); 138 imx25_add_fec(&mx25_fec_pdata);
139 imx25_add_imx2_wdt(NULL); 139 imx25_add_imx2_wdt();
140 140
141 i2c_register_board_info(0, eukrea_cpuimx25_i2c_devices, 141 i2c_register_board_info(0, eukrea_cpuimx25_i2c_devices,
142 ARRAY_SIZE(eukrea_cpuimx25_i2c_devices)); 142 ARRAY_SIZE(eukrea_cpuimx25_i2c_devices));
diff --git a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
index ba09552fe5f..f264ddddd47 100644
--- a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
+++ b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
@@ -40,6 +40,7 @@
40#include <asm/mach/time.h> 40#include <asm/mach/time.h>
41#include <asm/system_info.h> 41#include <asm/system_info.h>
42#include <mach/common.h> 42#include <mach/common.h>
43#include <mach/hardware.h>
43#include <mach/iomux-mx27.h> 44#include <mach/iomux-mx27.h>
44 45
45#include "devices-imx27.h" 46#include "devices-imx27.h"
@@ -47,7 +48,7 @@
47#define TVP5150_RSTN (GPIO_PORTC + 18) 48#define TVP5150_RSTN (GPIO_PORTC + 18)
48#define TVP5150_PWDN (GPIO_PORTC + 19) 49#define TVP5150_PWDN (GPIO_PORTC + 19)
49#define OTG_PHY_CS_GPIO (GPIO_PORTF + 17) 50#define OTG_PHY_CS_GPIO (GPIO_PORTF + 17)
50#define SDHC1_IRQ IRQ_GPIOB(25) 51#define SDHC1_IRQ_GPIO IMX_GPIO_NR(2, 25)
51 52
52#define MOTHERBOARD_BIT2 (GPIO_PORTD + 31) 53#define MOTHERBOARD_BIT2 (GPIO_PORTD + 31)
53#define MOTHERBOARD_BIT1 (GPIO_PORTD + 30) 54#define MOTHERBOARD_BIT1 (GPIO_PORTD + 30)
@@ -307,14 +308,14 @@ static int visstrim_m10_sdhc1_init(struct device *dev,
307{ 308{
308 int ret; 309 int ret;
309 310
310 ret = request_irq(SDHC1_IRQ, detect_irq, IRQF_TRIGGER_FALLING, 311 ret = request_irq(gpio_to_irq(SDHC1_IRQ_GPIO), detect_irq,
311 "mmc-detect", data); 312 IRQF_TRIGGER_FALLING, "mmc-detect", data);
312 return ret; 313 return ret;
313} 314}
314 315
315static void visstrim_m10_sdhc1_exit(struct device *dev, void *data) 316static void visstrim_m10_sdhc1_exit(struct device *dev, void *data)
316{ 317{
317 free_irq(SDHC1_IRQ, data); 318 free_irq(gpio_to_irq(SDHC1_IRQ_GPIO), data);
318} 319}
319 320
320static const struct imxmmc_platform_data visstrim_m10_sdhc_pdata __initconst = { 321static const struct imxmmc_platform_data visstrim_m10_sdhc_pdata __initconst = {
diff --git a/arch/arm/mach-imx/mach-imx27ipcam.c b/arch/arm/mach-imx/mach-imx27ipcam.c
index c9d350c5dcc..7381387a890 100644
--- a/arch/arm/mach-imx/mach-imx27ipcam.c
+++ b/arch/arm/mach-imx/mach-imx27ipcam.c
@@ -57,7 +57,7 @@ static void __init mx27ipcam_init(void)
57 57
58 imx27_add_imx_uart0(NULL); 58 imx27_add_imx_uart0(NULL);
59 imx27_add_fec(NULL); 59 imx27_add_fec(NULL);
60 imx27_add_imx2_wdt(NULL); 60 imx27_add_imx2_wdt();
61} 61}
62 62
63static void __init mx27ipcam_timer_init(void) 63static void __init mx27ipcam_timer_init(void)
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index b47e98b7d53..045b3f6a387 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -12,11 +12,12 @@
12 12
13#include <linux/clk.h> 13#include <linux/clk.h>
14#include <linux/clkdev.h> 14#include <linux/clkdev.h>
15#include <linux/cpuidle.h>
15#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/export.h>
16#include <linux/init.h> 18#include <linux/init.h>
17#include <linux/io.h> 19#include <linux/io.h>
18#include <linux/irq.h> 20#include <linux/irq.h>
19#include <linux/irqdomain.h>
20#include <linux/of.h> 21#include <linux/of.h>
21#include <linux/of_address.h> 22#include <linux/of_address.h>
22#include <linux/of_irq.h> 23#include <linux/of_irq.h>
@@ -24,6 +25,8 @@
24#include <linux/pinctrl/machine.h> 25#include <linux/pinctrl/machine.h>
25#include <linux/phy.h> 26#include <linux/phy.h>
26#include <linux/micrel_phy.h> 27#include <linux/micrel_phy.h>
28#include <linux/mfd/anatop.h>
29#include <asm/cpuidle.h>
27#include <asm/smp_twd.h> 30#include <asm/smp_twd.h>
28#include <asm/hardware/cache-l2x0.h> 31#include <asm/hardware/cache-l2x0.h>
29#include <asm/hardware/gic.h> 32#include <asm/hardware/gic.h>
@@ -31,8 +34,10 @@
31#include <asm/mach/time.h> 34#include <asm/mach/time.h>
32#include <asm/system_misc.h> 35#include <asm/system_misc.h>
33#include <mach/common.h> 36#include <mach/common.h>
37#include <mach/cpuidle.h>
34#include <mach/hardware.h> 38#include <mach/hardware.h>
35 39
40
36void imx6q_restart(char mode, const char *cmd) 41void imx6q_restart(char mode, const char *cmd)
37{ 42{
38 struct device_node *np; 43 struct device_node *np;
@@ -66,7 +71,7 @@ soft:
66/* For imx6q sabrelite board: set KSZ9021RN RGMII pad skew */ 71/* For imx6q sabrelite board: set KSZ9021RN RGMII pad skew */
67static int ksz9021rn_phy_fixup(struct phy_device *phydev) 72static int ksz9021rn_phy_fixup(struct phy_device *phydev)
68{ 73{
69 if (IS_ENABLED(CONFIG_PHYLIB)) { 74 if (IS_BUILTIN(CONFIG_PHYLIB)) {
70 /* min rx data delay */ 75 /* min rx data delay */
71 phy_write(phydev, 0x0b, 0x8105); 76 phy_write(phydev, 0x0b, 0x8105);
72 phy_write(phydev, 0x0c, 0x0000); 77 phy_write(phydev, 0x0c, 0x0000);
@@ -107,12 +112,51 @@ put_clk:
107 112
108static void __init imx6q_sabrelite_init(void) 113static void __init imx6q_sabrelite_init(void)
109{ 114{
110 if (IS_ENABLED(CONFIG_PHYLIB)) 115 if (IS_BUILTIN(CONFIG_PHYLIB))
111 phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK, 116 phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
112 ksz9021rn_phy_fixup); 117 ksz9021rn_phy_fixup);
113 imx6q_sabrelite_cko1_setup(); 118 imx6q_sabrelite_cko1_setup();
114} 119}
115 120
121static void __init imx6q_usb_init(void)
122{
123 struct device_node *np;
124 struct platform_device *pdev = NULL;
125 struct anatop *adata = NULL;
126
127 np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-anatop");
128 if (np)
129 pdev = of_find_device_by_node(np);
130 if (pdev)
131 adata = platform_get_drvdata(pdev);
132 if (!adata) {
133 if (np)
134 of_node_put(np);
135 return;
136 }
137
138#define HW_ANADIG_USB1_CHRG_DETECT 0x000001b0
139#define HW_ANADIG_USB2_CHRG_DETECT 0x00000210
140
141#define BM_ANADIG_USB_CHRG_DETECT_EN_B 0x00100000
142#define BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B 0x00080000
143
144 /*
145 * The external charger detector needs to be disabled,
146 * or the signal at DP will be poor
147 */
148 anatop_write_reg(adata, HW_ANADIG_USB1_CHRG_DETECT,
149 BM_ANADIG_USB_CHRG_DETECT_EN_B
150 | BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B,
151 ~0);
152 anatop_write_reg(adata, HW_ANADIG_USB2_CHRG_DETECT,
153 BM_ANADIG_USB_CHRG_DETECT_EN_B |
154 BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B,
155 ~0);
156
157 of_node_put(np);
158}
159
116static void __init imx6q_init_machine(void) 160static void __init imx6q_init_machine(void)
117{ 161{
118 /* 162 /*
@@ -127,6 +171,20 @@ static void __init imx6q_init_machine(void)
127 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 171 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
128 172
129 imx6q_pm_init(); 173 imx6q_pm_init();
174 imx6q_usb_init();
175}
176
177static struct cpuidle_driver imx6q_cpuidle_driver = {
178 .name = "imx6q_cpuidle",
179 .owner = THIS_MODULE,
180 .en_core_tk_irqen = 1,
181 .states[0] = ARM_CPUIDLE_WFI_STATE,
182 .state_count = 1,
183};
184
185static void __init imx6q_init_late(void)
186{
187 imx_cpuidle_init(&imx6q_cpuidle_driver);
130} 188}
131 189
132static void __init imx6q_map_io(void) 190static void __init imx6q_map_io(void)
@@ -136,21 +194,8 @@ static void __init imx6q_map_io(void)
136 imx6q_clock_map_io(); 194 imx6q_clock_map_io();
137} 195}
138 196
139static int __init imx6q_gpio_add_irq_domain(struct device_node *np,
140 struct device_node *interrupt_parent)
141{
142 static int gpio_irq_base = MXC_GPIO_IRQ_START + ARCH_NR_GPIOS;
143
144 gpio_irq_base -= 32;
145 irq_domain_add_legacy(np, 32, gpio_irq_base, 0, &irq_domain_simple_ops,
146 NULL);
147
148 return 0;
149}
150
151static const struct of_device_id imx6q_irq_match[] __initconst = { 197static const struct of_device_id imx6q_irq_match[] __initconst = {
152 { .compatible = "arm,cortex-a9-gic", .data = gic_of_init, }, 198 { .compatible = "arm,cortex-a9-gic", .data = gic_of_init, },
153 { .compatible = "fsl,imx6q-gpio", .data = imx6q_gpio_add_irq_domain, },
154 { /* sentinel */ } 199 { /* sentinel */ }
155}; 200};
156 201
@@ -186,6 +231,7 @@ DT_MACHINE_START(IMX6Q, "Freescale i.MX6 Quad (Device Tree)")
186 .handle_irq = imx6q_handle_irq, 231 .handle_irq = imx6q_handle_irq,
187 .timer = &imx6q_timer, 232 .timer = &imx6q_timer,
188 .init_machine = imx6q_init_machine, 233 .init_machine = imx6q_init_machine,
234 .init_late = imx6q_init_late,
189 .dt_compat = imx6q_dt_compat, 235 .dt_compat = imx6q_dt_compat,
190 .restart = imx6q_restart, 236 .restart = imx6q_restart,
191MACHINE_END 237MACHINE_END
diff --git a/arch/arm/mach-imx/mach-kzm_arm11_01.c b/arch/arm/mach-imx/mach-kzm_arm11_01.c
index 15a26e90826..5d08533ab2c 100644
--- a/arch/arm/mach-imx/mach-kzm_arm11_01.c
+++ b/arch/arm/mach-imx/mach-kzm_arm11_01.c
@@ -73,7 +73,7 @@ static struct plat_serial8250_port serial_platform_data[] = {
73 { 73 {
74 .membase = KZM_ARM11_IO_ADDRESS(KZM_ARM11_16550), 74 .membase = KZM_ARM11_IO_ADDRESS(KZM_ARM11_16550),
75 .mapbase = KZM_ARM11_16550, 75 .mapbase = KZM_ARM11_16550,
76 .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_1), 76 /* irq number is run-time assigned */
77 .irqflags = IRQ_TYPE_EDGE_RISING, 77 .irqflags = IRQ_TYPE_EDGE_RISING,
78 .uartclk = 14745600, 78 .uartclk = 14745600,
79 .regshift = 0, 79 .regshift = 0,
@@ -91,8 +91,7 @@ static struct resource serial8250_resources[] = {
91 .flags = IORESOURCE_MEM, 91 .flags = IORESOURCE_MEM,
92 }, 92 },
93 { 93 {
94 .start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_1), 94 /* irq number is run-time assigned */
95 .end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_1),
96 .flags = IORESOURCE_IRQ, 95 .flags = IORESOURCE_IRQ,
97 }, 96 },
98}; 97};
@@ -125,6 +124,13 @@ static int __init kzm_init_ext_uart(void)
125 tmp |= 0x2; 124 tmp |= 0x2;
126 __raw_writeb(tmp, KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1)); 125 __raw_writeb(tmp, KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1));
127 126
127 serial_platform_data[0].irq =
128 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
129 serial8250_resources[1].start =
130 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
131 serial8250_resources[1].end =
132 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
133
128 return platform_device_register(&serial_device); 134 return platform_device_register(&serial_device);
129} 135}
130#else 136#else
@@ -152,8 +158,7 @@ static struct resource kzm_smsc9118_resources[] = {
152 .flags = IORESOURCE_MEM, 158 .flags = IORESOURCE_MEM,
153 }, 159 },
154 { 160 {
155 .start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_2), 161 /* irq number is run-time assigned */
156 .end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_2),
157 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, 162 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
158 }, 163 },
159}; 164};
@@ -184,6 +189,11 @@ static int __init kzm_init_smsc9118(void)
184 189
185 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies)); 190 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
186 191
192 kzm_smsc9118_resources[1].start =
193 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
194 kzm_smsc9118_resources[1].end =
195 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
196
187 return platform_device_register(&kzm_smsc9118_device); 197 return platform_device_register(&kzm_smsc9118_device);
188} 198}
189#else 199#else
diff --git a/arch/arm/mach-imx/mach-mx1ads.c b/arch/arm/mach-imx/mach-mx1ads.c
index 7274e792813..667f359a2e8 100644
--- a/arch/arm/mach-imx/mach-mx1ads.c
+++ b/arch/arm/mach-imx/mach-mx1ads.c
@@ -26,7 +26,6 @@
26#include <mach/common.h> 26#include <mach/common.h>
27#include <mach/hardware.h> 27#include <mach/hardware.h>
28#include <mach/iomux-mx1.h> 28#include <mach/iomux-mx1.h>
29#include <mach/irqs.h>
30 29
31#include "devices-imx1.h" 30#include "devices-imx1.h"
32 31
diff --git a/arch/arm/mach-imx/mach-mx21ads.c b/arch/arm/mach-imx/mach-mx21ads.c
index 3e7401fca76..ed22e3fe6ec 100644
--- a/arch/arm/mach-imx/mach-mx21ads.c
+++ b/arch/arm/mach-imx/mach-mx21ads.c
@@ -38,7 +38,7 @@
38 (MX21ADS_MMIO_BASE_ADDR + (offset)) 38 (MX21ADS_MMIO_BASE_ADDR + (offset))
39 39
40#define MX21ADS_CS8900A_MMIO_SIZE 0x200000 40#define MX21ADS_CS8900A_MMIO_SIZE 0x200000
41#define MX21ADS_CS8900A_IRQ IRQ_GPIOE(11) 41#define MX21ADS_CS8900A_IRQ_GPIO IMX_GPIO_NR(5, 11)
42#define MX21ADS_ST16C255_IOBASE_REG MX21ADS_REG_ADDR(0x200000) 42#define MX21ADS_ST16C255_IOBASE_REG MX21ADS_REG_ADDR(0x200000)
43#define MX21ADS_VERSION_REG MX21ADS_REG_ADDR(0x400000) 43#define MX21ADS_VERSION_REG MX21ADS_REG_ADDR(0x400000)
44#define MX21ADS_IO_REG MX21ADS_REG_ADDR(0x800000) 44#define MX21ADS_IO_REG MX21ADS_REG_ADDR(0x800000)
@@ -159,9 +159,10 @@ static struct platform_device mx21ads_nor_mtd_device = {
159 .resource = &mx21ads_flash_resource, 159 .resource = &mx21ads_flash_resource,
160}; 160};
161 161
162static const struct resource mx21ads_cs8900_resources[] __initconst = { 162static struct resource mx21ads_cs8900_resources[] __initdata = {
163 DEFINE_RES_MEM(MX21_CS1_BASE_ADDR, MX21ADS_CS8900A_MMIO_SIZE), 163 DEFINE_RES_MEM(MX21_CS1_BASE_ADDR, MX21ADS_CS8900A_MMIO_SIZE),
164 DEFINE_RES_IRQ(MX21ADS_CS8900A_IRQ), 164 /* irq number is run-time assigned */
165 DEFINE_RES_IRQ(-1),
165}; 166};
166 167
167static const struct platform_device_info mx21ads_cs8900_devinfo __initconst = { 168static const struct platform_device_info mx21ads_cs8900_devinfo __initconst = {
@@ -241,13 +242,13 @@ static int mx21ads_sdhc_get_ro(struct device *dev)
241static int mx21ads_sdhc_init(struct device *dev, irq_handler_t detect_irq, 242static int mx21ads_sdhc_init(struct device *dev, irq_handler_t detect_irq,
242 void *data) 243 void *data)
243{ 244{
244 return request_irq(IRQ_GPIOD(25), detect_irq, 245 return request_irq(gpio_to_irq(IMX_GPIO_NR(4, 25)), detect_irq,
245 IRQF_TRIGGER_FALLING, "mmc-detect", data); 246 IRQF_TRIGGER_FALLING, "mmc-detect", data);
246} 247}
247 248
248static void mx21ads_sdhc_exit(struct device *dev, void *data) 249static void mx21ads_sdhc_exit(struct device *dev, void *data)
249{ 250{
250 free_irq(IRQ_GPIOD(25), data); 251 free_irq(gpio_to_irq(IMX_GPIO_NR(4, 25)), data);
251} 252}
252 253
253static const struct imxmmc_platform_data mx21ads_sdhc_pdata __initconst = { 254static const struct imxmmc_platform_data mx21ads_sdhc_pdata __initconst = {
@@ -304,6 +305,11 @@ static void __init mx21ads_board_init(void)
304 imx21_add_mxc_nand(&mx21ads_nand_board_info); 305 imx21_add_mxc_nand(&mx21ads_nand_board_info);
305 306
306 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 307 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
308
309 mx21ads_cs8900_resources[1].start =
310 gpio_to_irq(MX21ADS_CS8900A_IRQ_GPIO);
311 mx21ads_cs8900_resources[1].end =
312 gpio_to_irq(MX21ADS_CS8900A_IRQ_GPIO);
307 platform_device_register_full(&mx21ads_cs8900_devinfo); 313 platform_device_register_full(&mx21ads_cs8900_devinfo);
308} 314}
309 315
diff --git a/arch/arm/mach-imx/mach-mx25_3ds.c b/arch/arm/mach-imx/mach-mx25_3ds.c
index f26734298aa..ce247fd1269 100644
--- a/arch/arm/mach-imx/mach-mx25_3ds.c
+++ b/arch/arm/mach-imx/mach-mx25_3ds.c
@@ -237,9 +237,9 @@ static void __init mx25pdk_init(void)
237 imx25_add_fsl_usb2_udc(&otg_device_pdata); 237 imx25_add_fsl_usb2_udc(&otg_device_pdata);
238 imx25_add_mxc_ehci_hs(&usbh2_pdata); 238 imx25_add_mxc_ehci_hs(&usbh2_pdata);
239 imx25_add_mxc_nand(&mx25pdk_nand_board_info); 239 imx25_add_mxc_nand(&mx25pdk_nand_board_info);
240 imx25_add_imxdi_rtc(NULL); 240 imx25_add_imxdi_rtc();
241 imx25_add_imx_fb(&mx25pdk_fb_pdata); 241 imx25_add_imx_fb(&mx25pdk_fb_pdata);
242 imx25_add_imx2_wdt(NULL); 242 imx25_add_imx2_wdt();
243 243
244 mx25pdk_fec_reset(); 244 mx25pdk_fec_reset();
245 imx25_add_fec(&mx25_fec_pdata); 245 imx25_add_fec(&mx25_fec_pdata);
diff --git a/arch/arm/mach-imx/mach-mx27_3ds.c b/arch/arm/mach-imx/mach-mx27_3ds.c
index c6d385c5225..58c24c1a7ab 100644
--- a/arch/arm/mach-imx/mach-mx27_3ds.c
+++ b/arch/arm/mach-imx/mach-mx27_3ds.c
@@ -40,7 +40,6 @@
40#include <mach/common.h> 40#include <mach/common.h>
41#include <mach/iomux-mx27.h> 41#include <mach/iomux-mx27.h>
42#include <mach/ulpi.h> 42#include <mach/ulpi.h>
43#include <mach/irqs.h>
44#include <mach/3ds_debugboard.h> 43#include <mach/3ds_debugboard.h>
45 44
46#include "devices-imx27.h" 45#include "devices-imx27.h"
@@ -48,7 +47,6 @@
48#define SD1_EN_GPIO IMX_GPIO_NR(2, 25) 47#define SD1_EN_GPIO IMX_GPIO_NR(2, 25)
49#define OTG_PHY_RESET_GPIO IMX_GPIO_NR(2, 23) 48#define OTG_PHY_RESET_GPIO IMX_GPIO_NR(2, 23)
50#define SPI2_SS0 IMX_GPIO_NR(4, 21) 49#define SPI2_SS0 IMX_GPIO_NR(4, 21)
51#define EXPIO_PARENT_INT gpio_to_irq(IMX_GPIO_NR(3, 28))
52#define PMIC_INT IMX_GPIO_NR(3, 14) 50#define PMIC_INT IMX_GPIO_NR(3, 14)
53#define SPI1_SS0 IMX_GPIO_NR(4, 28) 51#define SPI1_SS0 IMX_GPIO_NR(4, 28)
54#define SD1_CD IMX_GPIO_NR(2, 26) 52#define SD1_CD IMX_GPIO_NR(2, 26)
@@ -241,18 +239,18 @@ static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
241 .phy_mode = FSL_USB2_PHY_ULPI, 239 .phy_mode = FSL_USB2_PHY_ULPI,
242}; 240};
243 241
244static int otg_mode_host; 242static bool otg_mode_host __initdata;
245 243
246static int __init mx27_3ds_otg_mode(char *options) 244static int __init mx27_3ds_otg_mode(char *options)
247{ 245{
248 if (!strcmp(options, "host")) 246 if (!strcmp(options, "host"))
249 otg_mode_host = 1; 247 otg_mode_host = true;
250 else if (!strcmp(options, "device")) 248 else if (!strcmp(options, "device"))
251 otg_mode_host = 0; 249 otg_mode_host = false;
252 else 250 else
253 pr_info("otg_mode neither \"host\" nor \"device\". " 251 pr_info("otg_mode neither \"host\" nor \"device\". "
254 "Defaulting to device\n"); 252 "Defaulting to device\n");
255 return 0; 253 return 1;
256} 254}
257__setup("otg_mode=", mx27_3ds_otg_mode); 255__setup("otg_mode=", mx27_3ds_otg_mode);
258 256
@@ -445,7 +443,7 @@ static struct spi_board_info mx27_3ds_spi_devs[] __initdata = {
445 .bus_num = 1, 443 .bus_num = 1,
446 .chip_select = 0, /* SS0 */ 444 .chip_select = 0, /* SS0 */
447 .platform_data = &mc13783_pdata, 445 .platform_data = &mc13783_pdata,
448 .irq = IMX_GPIO_TO_IRQ(PMIC_INT), 446 /* irq number is run-time assigned */
449 .mode = SPI_CS_HIGH, 447 .mode = SPI_CS_HIGH,
450 }, { 448 }, {
451 .modalias = "l4f00242t03", 449 .modalias = "l4f00242t03",
@@ -480,7 +478,7 @@ static void __init mx27pdk_init(void)
480 imx27_add_fec(NULL); 478 imx27_add_fec(NULL);
481 imx27_add_imx_keypad(&mx27_3ds_keymap_data); 479 imx27_add_imx_keypad(&mx27_3ds_keymap_data);
482 imx27_add_mxc_mmc(0, &sdhc1_pdata); 480 imx27_add_mxc_mmc(0, &sdhc1_pdata);
483 imx27_add_imx2_wdt(NULL); 481 imx27_add_imx2_wdt();
484 otg_phy_init(); 482 otg_phy_init();
485 483
486 if (otg_mode_host) { 484 if (otg_mode_host) {
@@ -496,10 +494,11 @@ static void __init mx27pdk_init(void)
496 494
497 imx27_add_spi_imx1(&spi2_pdata); 495 imx27_add_spi_imx1(&spi2_pdata);
498 imx27_add_spi_imx0(&spi1_pdata); 496 imx27_add_spi_imx0(&spi1_pdata);
497 mx27_3ds_spi_devs[0].irq = gpio_to_irq(PMIC_INT);
499 spi_register_board_info(mx27_3ds_spi_devs, 498 spi_register_board_info(mx27_3ds_spi_devs,
500 ARRAY_SIZE(mx27_3ds_spi_devs)); 499 ARRAY_SIZE(mx27_3ds_spi_devs));
501 500
502 if (mxc_expio_init(MX27_CS5_BASE_ADDR, EXPIO_PARENT_INT)) 501 if (mxc_expio_init(MX27_CS5_BASE_ADDR, IMX_GPIO_NR(3, 28)))
503 pr_warn("Init of the debugboard failed, all devices on the debugboard are unusable.\n"); 502 pr_warn("Init of the debugboard failed, all devices on the debugboard are unusable.\n");
504 imx27_add_imx_i2c(0, &mx27_3ds_i2c0_data); 503 imx27_add_imx_i2c(0, &mx27_3ds_i2c0_data);
505 platform_add_devices(devices, ARRAY_SIZE(devices)); 504 platform_add_devices(devices, ARRAY_SIZE(devices));
diff --git a/arch/arm/mach-imx/mach-mx27ads.c b/arch/arm/mach-imx/mach-mx27ads.c
index 0228d2e07fe..7dc59bac0e5 100644
--- a/arch/arm/mach-imx/mach-mx27ads.c
+++ b/arch/arm/mach-imx/mach-mx27ads.c
@@ -246,25 +246,25 @@ static const struct imx_fb_platform_data mx27ads_fb_data __initconst = {
246static int mx27ads_sdhc1_init(struct device *dev, irq_handler_t detect_irq, 246static int mx27ads_sdhc1_init(struct device *dev, irq_handler_t detect_irq,
247 void *data) 247 void *data)
248{ 248{
249 return request_irq(IRQ_GPIOE(21), detect_irq, IRQF_TRIGGER_RISING, 249 return request_irq(gpio_to_irq(IMX_GPIO_NR(5, 21)), detect_irq,
250 "sdhc1-card-detect", data); 250 IRQF_TRIGGER_RISING, "sdhc1-card-detect", data);
251} 251}
252 252
253static int mx27ads_sdhc2_init(struct device *dev, irq_handler_t detect_irq, 253static int mx27ads_sdhc2_init(struct device *dev, irq_handler_t detect_irq,
254 void *data) 254 void *data)
255{ 255{
256 return request_irq(IRQ_GPIOB(7), detect_irq, IRQF_TRIGGER_RISING, 256 return request_irq(gpio_to_irq(IMX_GPIO_NR(2, 7)), detect_irq,
257 "sdhc2-card-detect", data); 257 IRQF_TRIGGER_RISING, "sdhc2-card-detect", data);
258} 258}
259 259
260static void mx27ads_sdhc1_exit(struct device *dev, void *data) 260static void mx27ads_sdhc1_exit(struct device *dev, void *data)
261{ 261{
262 free_irq(IRQ_GPIOE(21), data); 262 free_irq(gpio_to_irq(IMX_GPIO_NR(5, 21)), data);
263} 263}
264 264
265static void mx27ads_sdhc2_exit(struct device *dev, void *data) 265static void mx27ads_sdhc2_exit(struct device *dev, void *data)
266{ 266{
267 free_irq(IRQ_GPIOB(7), data); 267 free_irq(gpio_to_irq(IMX_GPIO_NR(2, 7)), data);
268} 268}
269 269
270static const struct imxmmc_platform_data sdhc1_pdata __initconst = { 270static const struct imxmmc_platform_data sdhc1_pdata __initconst = {
@@ -310,7 +310,7 @@ static void __init mx27ads_board_init(void)
310 310
311 imx27_add_fec(NULL); 311 imx27_add_fec(NULL);
312 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 312 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
313 imx27_add_mxc_w1(NULL); 313 imx27_add_mxc_w1();
314} 314}
315 315
316static void __init mx27ads_timer_init(void) 316static void __init mx27ads_timer_init(void)
diff --git a/arch/arm/mach-imx/mach-mx31_3ds.c b/arch/arm/mach-imx/mach-mx31_3ds.c
index 4eafdf275ea..8915f937b7d 100644
--- a/arch/arm/mach-imx/mach-mx31_3ds.c
+++ b/arch/arm/mach-imx/mach-mx31_3ds.c
@@ -44,9 +44,6 @@
44 44
45#include "devices-imx31.h" 45#include "devices-imx31.h"
46 46
47/* CPLD IRQ line for external uart, external ethernet etc */
48#define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_1)
49
50static int mx31_3ds_pins[] = { 47static int mx31_3ds_pins[] = {
51 /* UART1 */ 48 /* UART1 */
52 MX31_PIN_CTS1__CTS1, 49 MX31_PIN_CTS1__CTS1,
@@ -277,10 +274,6 @@ static const struct fb_videomode fb_modedb[] = {
277 }, 274 },
278}; 275};
279 276
280static struct ipu_platform_data mx3_ipu_data = {
281 .irq_base = MXC_IPU_IRQ_START,
282};
283
284static struct mx3fb_platform_data mx3fb_pdata __initdata = { 277static struct mx3fb_platform_data mx3fb_pdata __initdata = {
285 .name = "Epson-VGA", 278 .name = "Epson-VGA",
286 .mode = fb_modedb, 279 .mode = fb_modedb,
@@ -317,7 +310,7 @@ static int mx31_3ds_sdhc1_init(struct device *dev,
317 return ret; 310 return ret;
318 } 311 }
319 312
320 ret = request_irq(IOMUX_TO_IRQ(MX31_PIN_GPIO3_1), 313 ret = request_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO3_1)),
321 detect_irq, IRQF_DISABLED | 314 detect_irq, IRQF_DISABLED |
322 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, 315 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
323 "sdhc1-detect", data); 316 "sdhc1-detect", data);
@@ -336,7 +329,7 @@ gpio_free:
336 329
337static void mx31_3ds_sdhc1_exit(struct device *dev, void *data) 330static void mx31_3ds_sdhc1_exit(struct device *dev, void *data)
338{ 331{
339 free_irq(IOMUX_TO_IRQ(MX31_PIN_GPIO3_1), data); 332 free_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO3_1)), data);
340 gpio_free_array(mx31_3ds_sdhc1_gpios, 333 gpio_free_array(mx31_3ds_sdhc1_gpios,
341 ARRAY_SIZE(mx31_3ds_sdhc1_gpios)); 334 ARRAY_SIZE(mx31_3ds_sdhc1_gpios));
342} 335}
@@ -539,7 +532,7 @@ static struct spi_board_info mx31_3ds_spi_devs[] __initdata = {
539 .bus_num = 1, 532 .bus_num = 1,
540 .chip_select = 1, /* SS2 */ 533 .chip_select = 1, /* SS2 */
541 .platform_data = &mc13783_pdata, 534 .platform_data = &mc13783_pdata,
542 .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3), 535 /* irq number is run-time assigned */
543 .mode = SPI_CS_HIGH, 536 .mode = SPI_CS_HIGH,
544 }, { 537 }, {
545 .modalias = "l4f00242t03", 538 .modalias = "l4f00242t03",
@@ -671,18 +664,18 @@ static const struct fsl_usb2_platform_data usbotg_pdata __initconst = {
671 .phy_mode = FSL_USB2_PHY_ULPI, 664 .phy_mode = FSL_USB2_PHY_ULPI,
672}; 665};
673 666
674static int otg_mode_host; 667static bool otg_mode_host __initdata;
675 668
676static int __init mx31_3ds_otg_mode(char *options) 669static int __init mx31_3ds_otg_mode(char *options)
677{ 670{
678 if (!strcmp(options, "host")) 671 if (!strcmp(options, "host"))
679 otg_mode_host = 1; 672 otg_mode_host = true;
680 else if (!strcmp(options, "device")) 673 else if (!strcmp(options, "device"))
681 otg_mode_host = 0; 674 otg_mode_host = false;
682 else 675 else
683 pr_info("otg_mode neither \"host\" nor \"device\". " 676 pr_info("otg_mode neither \"host\" nor \"device\". "
684 "Defaulting to device\n"); 677 "Defaulting to device\n");
685 return 0; 678 return 1;
686} 679}
687__setup("otg_mode=", mx31_3ds_otg_mode); 680__setup("otg_mode=", mx31_3ds_otg_mode);
688 681
@@ -714,6 +707,7 @@ static void __init mx31_3ds_init(void)
714 imx31_add_mxc_nand(&mx31_3ds_nand_board_info); 707 imx31_add_mxc_nand(&mx31_3ds_nand_board_info);
715 708
716 imx31_add_spi_imx1(&spi1_pdata); 709 imx31_add_spi_imx1(&spi1_pdata);
710 mx31_3ds_spi_devs[0].irq = gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_3));
717 spi_register_board_info(mx31_3ds_spi_devs, 711 spi_register_board_info(mx31_3ds_spi_devs,
718 ARRAY_SIZE(mx31_3ds_spi_devs)); 712 ARRAY_SIZE(mx31_3ds_spi_devs));
719 713
@@ -736,15 +730,15 @@ static void __init mx31_3ds_init(void)
736 if (!otg_mode_host) 730 if (!otg_mode_host)
737 imx31_add_fsl_usb2_udc(&usbotg_pdata); 731 imx31_add_fsl_usb2_udc(&usbotg_pdata);
738 732
739 if (mxc_expio_init(MX31_CS5_BASE_ADDR, EXPIO_PARENT_INT)) 733 if (mxc_expio_init(MX31_CS5_BASE_ADDR, IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)))
740 printk(KERN_WARNING "Init of the debug board failed, all " 734 printk(KERN_WARNING "Init of the debug board failed, all "
741 "devices on the debug board are unusable.\n"); 735 "devices on the debug board are unusable.\n");
742 imx31_add_imx2_wdt(NULL); 736 imx31_add_imx2_wdt();
743 imx31_add_imx_i2c0(&mx31_3ds_i2c0_data); 737 imx31_add_imx_i2c0(&mx31_3ds_i2c0_data);
744 imx31_add_mxc_mmc(0, &sdhc1_pdata); 738 imx31_add_mxc_mmc(0, &sdhc1_pdata);
745 739
746 imx31_add_spi_imx0(&spi0_pdata); 740 imx31_add_spi_imx0(&spi0_pdata);
747 imx31_add_ipu_core(&mx3_ipu_data); 741 imx31_add_ipu_core();
748 imx31_add_mx3_sdc_fb(&mx3fb_pdata); 742 imx31_add_mx3_sdc_fb(&mx3fb_pdata);
749 743
750 /* CSI */ 744 /* CSI */
diff --git a/arch/arm/mach-imx/mach-mx31ads.c b/arch/arm/mach-imx/mach-mx31ads.c
index 4518e544822..d37f4809c55 100644
--- a/arch/arm/mach-imx/mach-mx31ads.c
+++ b/arch/arm/mach-imx/mach-mx31ads.c
@@ -21,6 +21,7 @@
21#include <linux/gpio.h> 21#include <linux/gpio.h>
22#include <linux/i2c.h> 22#include <linux/i2c.h>
23#include <linux/irq.h> 23#include <linux/irq.h>
24#include <linux/irqdomain.h>
24 25
25#include <asm/mach-types.h> 26#include <asm/mach-types.h>
26#include <asm/mach/arch.h> 27#include <asm/mach/arch.h>
@@ -62,20 +63,18 @@
62#define PBC_INTSTATUS_REG (PBC_INTSTATUS + PBC_BASE_ADDRESS) 63#define PBC_INTSTATUS_REG (PBC_INTSTATUS + PBC_BASE_ADDRESS)
63#define PBC_INTMASK_SET_REG (PBC_INTMASK_SET + PBC_BASE_ADDRESS) 64#define PBC_INTMASK_SET_REG (PBC_INTMASK_SET + PBC_BASE_ADDRESS)
64#define PBC_INTMASK_CLEAR_REG (PBC_INTMASK_CLEAR + PBC_BASE_ADDRESS) 65#define PBC_INTMASK_CLEAR_REG (PBC_INTMASK_CLEAR + PBC_BASE_ADDRESS)
65#define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_4)
66 66
67#define MXC_EXP_IO_BASE MXC_BOARD_IRQ_START 67#define EXPIO_INT_XUART_INTA 10
68#define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_EXP_IO_BASE) 68#define EXPIO_INT_XUART_INTB 11
69
70#define EXPIO_INT_XUART_INTA (MXC_EXP_IO_BASE + 10)
71#define EXPIO_INT_XUART_INTB (MXC_EXP_IO_BASE + 11)
72 69
73#define MXC_MAX_EXP_IO_LINES 16 70#define MXC_MAX_EXP_IO_LINES 16
74 71
75/* CS8900 */ 72/* CS8900 */
76#define EXPIO_INT_ENET_INT (MXC_EXP_IO_BASE + 8) 73#define EXPIO_INT_ENET_INT 8
77#define CS4_CS8900_MMIO_START 0x20000 74#define CS4_CS8900_MMIO_START 0x20000
78 75
76static struct irq_domain *domain;
77
79/* 78/*
80 * The serial port definition structure. 79 * The serial port definition structure.
81 */ 80 */
@@ -83,7 +82,6 @@ static struct plat_serial8250_port serial_platform_data[] = {
83 { 82 {
84 .membase = (void *)(PBC_BASE_ADDRESS + PBC_SC16C652_UARTA), 83 .membase = (void *)(PBC_BASE_ADDRESS + PBC_SC16C652_UARTA),
85 .mapbase = (unsigned long)(MX31_CS4_BASE_ADDR + PBC_SC16C652_UARTA), 84 .mapbase = (unsigned long)(MX31_CS4_BASE_ADDR + PBC_SC16C652_UARTA),
86 .irq = EXPIO_INT_XUART_INTA,
87 .uartclk = 14745600, 85 .uartclk = 14745600,
88 .regshift = 0, 86 .regshift = 0,
89 .iotype = UPIO_MEM, 87 .iotype = UPIO_MEM,
@@ -91,7 +89,6 @@ static struct plat_serial8250_port serial_platform_data[] = {
91 }, { 89 }, {
92 .membase = (void *)(PBC_BASE_ADDRESS + PBC_SC16C652_UARTB), 90 .membase = (void *)(PBC_BASE_ADDRESS + PBC_SC16C652_UARTB),
93 .mapbase = (unsigned long)(MX31_CS4_BASE_ADDR + PBC_SC16C652_UARTB), 91 .mapbase = (unsigned long)(MX31_CS4_BASE_ADDR + PBC_SC16C652_UARTB),
94 .irq = EXPIO_INT_XUART_INTB,
95 .uartclk = 14745600, 92 .uartclk = 14745600,
96 .regshift = 0, 93 .regshift = 0,
97 .iotype = UPIO_MEM, 94 .iotype = UPIO_MEM,
@@ -108,9 +105,9 @@ static struct platform_device serial_device = {
108 }, 105 },
109}; 106};
110 107
111static const struct resource mx31ads_cs8900_resources[] __initconst = { 108static struct resource mx31ads_cs8900_resources[] __initdata = {
112 DEFINE_RES_MEM(MX31_CS4_BASE_ADDR + CS4_CS8900_MMIO_START, SZ_64K), 109 DEFINE_RES_MEM(MX31_CS4_BASE_ADDR + CS4_CS8900_MMIO_START, SZ_64K),
113 DEFINE_RES_IRQ(EXPIO_INT_ENET_INT), 110 DEFINE_RES_IRQ(-1),
114}; 111};
115 112
116static const struct platform_device_info mx31ads_cs8900_devinfo __initconst = { 113static const struct platform_device_info mx31ads_cs8900_devinfo __initconst = {
@@ -122,11 +119,19 @@ static const struct platform_device_info mx31ads_cs8900_devinfo __initconst = {
122 119
123static int __init mxc_init_extuart(void) 120static int __init mxc_init_extuart(void)
124{ 121{
122 serial_platform_data[0].irq = irq_find_mapping(domain,
123 EXPIO_INT_XUART_INTA);
124 serial_platform_data[1].irq = irq_find_mapping(domain,
125 EXPIO_INT_XUART_INTB);
125 return platform_device_register(&serial_device); 126 return platform_device_register(&serial_device);
126} 127}
127 128
128static void __init mxc_init_ext_ethernet(void) 129static void __init mxc_init_ext_ethernet(void)
129{ 130{
131 mx31ads_cs8900_resources[1].start =
132 irq_find_mapping(domain, EXPIO_INT_ENET_INT);
133 mx31ads_cs8900_resources[1].end =
134 irq_find_mapping(domain, EXPIO_INT_ENET_INT);
130 platform_device_register_full( 135 platform_device_register_full(
131 (struct platform_device_info *)&mx31ads_cs8900_devinfo); 136 (struct platform_device_info *)&mx31ads_cs8900_devinfo);
132} 137}
@@ -157,12 +162,12 @@ static void mx31ads_expio_irq_handler(u32 irq, struct irq_desc *desc)
157 imr_val = __raw_readw(PBC_INTMASK_SET_REG); 162 imr_val = __raw_readw(PBC_INTMASK_SET_REG);
158 int_valid = __raw_readw(PBC_INTSTATUS_REG) & imr_val; 163 int_valid = __raw_readw(PBC_INTSTATUS_REG) & imr_val;
159 164
160 expio_irq = MXC_EXP_IO_BASE; 165 expio_irq = 0;
161 for (; int_valid != 0; int_valid >>= 1, expio_irq++) { 166 for (; int_valid != 0; int_valid >>= 1, expio_irq++) {
162 if ((int_valid & 1) == 0) 167 if ((int_valid & 1) == 0)
163 continue; 168 continue;
164 169
165 generic_handle_irq(expio_irq); 170 generic_handle_irq(irq_find_mapping(domain, expio_irq));
166 } 171 }
167} 172}
168 173
@@ -172,7 +177,7 @@ static void mx31ads_expio_irq_handler(u32 irq, struct irq_desc *desc)
172 */ 177 */
173static void expio_mask_irq(struct irq_data *d) 178static void expio_mask_irq(struct irq_data *d)
174{ 179{
175 u32 expio = MXC_IRQ_TO_EXPIO(d->irq); 180 u32 expio = d->hwirq;
176 /* mask the interrupt */ 181 /* mask the interrupt */
177 __raw_writew(1 << expio, PBC_INTMASK_CLEAR_REG); 182 __raw_writew(1 << expio, PBC_INTMASK_CLEAR_REG);
178 __raw_readw(PBC_INTMASK_CLEAR_REG); 183 __raw_readw(PBC_INTMASK_CLEAR_REG);
@@ -184,7 +189,7 @@ static void expio_mask_irq(struct irq_data *d)
184 */ 189 */
185static void expio_ack_irq(struct irq_data *d) 190static void expio_ack_irq(struct irq_data *d)
186{ 191{
187 u32 expio = MXC_IRQ_TO_EXPIO(d->irq); 192 u32 expio = d->hwirq;
188 /* clear the interrupt status */ 193 /* clear the interrupt status */
189 __raw_writew(1 << expio, PBC_INTSTATUS_REG); 194 __raw_writew(1 << expio, PBC_INTSTATUS_REG);
190} 195}
@@ -195,7 +200,7 @@ static void expio_ack_irq(struct irq_data *d)
195 */ 200 */
196static void expio_unmask_irq(struct irq_data *d) 201static void expio_unmask_irq(struct irq_data *d)
197{ 202{
198 u32 expio = MXC_IRQ_TO_EXPIO(d->irq); 203 u32 expio = d->hwirq;
199 /* unmask the interrupt */ 204 /* unmask the interrupt */
200 __raw_writew(1 << expio, PBC_INTMASK_SET_REG); 205 __raw_writew(1 << expio, PBC_INTMASK_SET_REG);
201} 206}
@@ -209,7 +214,8 @@ static struct irq_chip expio_irq_chip = {
209 214
210static void __init mx31ads_init_expio(void) 215static void __init mx31ads_init_expio(void)
211{ 216{
212 int i; 217 int irq_base;
218 int i, irq;
213 219
214 printk(KERN_INFO "MX31ADS EXPIO(CPLD) hardware\n"); 220 printk(KERN_INFO "MX31ADS EXPIO(CPLD) hardware\n");
215 221
@@ -221,13 +227,21 @@ static void __init mx31ads_init_expio(void)
221 /* disable the interrupt and clear the status */ 227 /* disable the interrupt and clear the status */
222 __raw_writew(0xFFFF, PBC_INTMASK_CLEAR_REG); 228 __raw_writew(0xFFFF, PBC_INTMASK_CLEAR_REG);
223 __raw_writew(0xFFFF, PBC_INTSTATUS_REG); 229 __raw_writew(0xFFFF, PBC_INTSTATUS_REG);
224 for (i = MXC_EXP_IO_BASE; i < (MXC_EXP_IO_BASE + MXC_MAX_EXP_IO_LINES); 230
225 i++) { 231 irq_base = irq_alloc_descs(-1, 0, MXC_MAX_EXP_IO_LINES, numa_node_id());
232 WARN_ON(irq_base < 0);
233
234 domain = irq_domain_add_legacy(NULL, MXC_MAX_EXP_IO_LINES, irq_base, 0,
235 &irq_domain_simple_ops, NULL);
236 WARN_ON(!domain);
237
238 for (i = irq_base; i < irq_base + MXC_MAX_EXP_IO_LINES; i++) {
226 irq_set_chip_and_handler(i, &expio_irq_chip, handle_level_irq); 239 irq_set_chip_and_handler(i, &expio_irq_chip, handle_level_irq);
227 set_irq_flags(i, IRQF_VALID); 240 set_irq_flags(i, IRQF_VALID);
228 } 241 }
229 irq_set_irq_type(EXPIO_PARENT_INT, IRQ_TYPE_LEVEL_HIGH); 242 irq = gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_4));
230 irq_set_chained_handler(EXPIO_PARENT_INT, mx31ads_expio_irq_handler); 243 irq_set_irq_type(irq, IRQ_TYPE_LEVEL_HIGH);
244 irq_set_chained_handler(irq, mx31ads_expio_irq_handler);
231} 245}
232 246
233#ifdef CONFIG_MACH_MX31ADS_WM1133_EV1 247#ifdef CONFIG_MACH_MX31ADS_WM1133_EV1
@@ -479,7 +493,6 @@ static int mx31_wm8350_init(struct wm8350 *wm8350)
479 493
480static struct wm8350_platform_data __initdata mx31_wm8350_pdata = { 494static struct wm8350_platform_data __initdata mx31_wm8350_pdata = {
481 .init = mx31_wm8350_init, 495 .init = mx31_wm8350_init,
482 .irq_base = MXC_BOARD_IRQ_START + MXC_MAX_EXP_IO_LINES,
483}; 496};
484#endif 497#endif
485 498
@@ -488,13 +501,17 @@ static struct i2c_board_info __initdata mx31ads_i2c1_devices[] = {
488 { 501 {
489 I2C_BOARD_INFO("wm8350", 0x1a), 502 I2C_BOARD_INFO("wm8350", 0x1a),
490 .platform_data = &mx31_wm8350_pdata, 503 .platform_data = &mx31_wm8350_pdata,
491 .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3), 504 /* irq number is run-time assigned */
492 }, 505 },
493#endif 506#endif
494}; 507};
495 508
496static void __init mxc_init_i2c(void) 509static void __init mxc_init_i2c(void)
497{ 510{
511#ifdef CONFIG_MACH_MX31ADS_WM1133_EV1
512 mx31ads_i2c1_devices[0].irq =
513 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_3));
514#endif
498 i2c_register_board_info(1, mx31ads_i2c1_devices, 515 i2c_register_board_info(1, mx31ads_i2c1_devices,
499 ARRAY_SIZE(mx31ads_i2c1_devices)); 516 ARRAY_SIZE(mx31ads_i2c1_devices));
500 517
diff --git a/arch/arm/mach-imx/mach-mx31lilly.c b/arch/arm/mach-imx/mach-mx31lilly.c
index 83714b0cc29..34b9bf075da 100644
--- a/arch/arm/mach-imx/mach-mx31lilly.c
+++ b/arch/arm/mach-imx/mach-mx31lilly.c
@@ -65,8 +65,7 @@ static struct resource smsc91x_resources[] = {
65 .flags = IORESOURCE_MEM, 65 .flags = IORESOURCE_MEM,
66 }, 66 },
67 { 67 {
68 .start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0), 68 /* irq number is run-time assigned */
69 .end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),
70 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING, 69 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING,
71 } 70 }
72}; 71};
@@ -233,7 +232,7 @@ static struct spi_board_info mc13783_dev __initdata = {
233 .bus_num = 1, 232 .bus_num = 1,
234 .chip_select = 0, 233 .chip_select = 0,
235 .platform_data = &mc13783_pdata, 234 .platform_data = &mc13783_pdata,
236 .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3), 235 /* irq number is run-time assigned */
237}; 236};
238 237
239static struct platform_device *devices[] __initdata = { 238static struct platform_device *devices[] __initdata = {
@@ -285,10 +284,15 @@ static void __init mx31lilly_board_init(void)
285 284
286 imx31_add_spi_imx0(&spi0_pdata); 285 imx31_add_spi_imx0(&spi0_pdata);
287 imx31_add_spi_imx1(&spi1_pdata); 286 imx31_add_spi_imx1(&spi1_pdata);
287 mc13783_dev.irq = gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_3));
288 spi_register_board_info(&mc13783_dev, 1); 288 spi_register_board_info(&mc13783_dev, 1);
289 289
290 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies)); 290 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
291 291
292 smsc91x_resources[1].start =
293 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_0));
294 smsc91x_resources[1].end =
295 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_0));
292 platform_add_devices(devices, ARRAY_SIZE(devices)); 296 platform_add_devices(devices, ARRAY_SIZE(devices));
293 297
294 /* USB */ 298 /* USB */
diff --git a/arch/arm/mach-imx/mach-mx31lite.c b/arch/arm/mach-imx/mach-mx31lite.c
index 686c6058798..c8785b39eae 100644
--- a/arch/arm/mach-imx/mach-mx31lite.c
+++ b/arch/arm/mach-imx/mach-mx31lite.c
@@ -43,7 +43,6 @@
43#include <mach/common.h> 43#include <mach/common.h>
44#include <mach/board-mx31lite.h> 44#include <mach/board-mx31lite.h>
45#include <mach/iomux-mx3.h> 45#include <mach/iomux-mx3.h>
46#include <mach/irqs.h>
47#include <mach/ulpi.h> 46#include <mach/ulpi.h>
48 47
49#include "devices-imx31.h" 48#include "devices-imx31.h"
@@ -83,8 +82,7 @@ static struct resource smsc911x_resources[] = {
83 .end = MX31_CS4_BASE_ADDR + 0x100, 82 .end = MX31_CS4_BASE_ADDR + 0x100,
84 .flags = IORESOURCE_MEM, 83 .flags = IORESOURCE_MEM,
85 }, { 84 }, {
86 .start = IOMUX_TO_IRQ(MX31_PIN_SFS6), 85 /* irq number is run-time assigned */
87 .end = IOMUX_TO_IRQ(MX31_PIN_SFS6),
88 .flags = IORESOURCE_IRQ, 86 .flags = IORESOURCE_IRQ,
89 }, 87 },
90}; 88};
@@ -124,7 +122,7 @@ static struct spi_board_info mc13783_spi_dev __initdata = {
124 .bus_num = 1, 122 .bus_num = 1,
125 .chip_select = 0, 123 .chip_select = 0,
126 .platform_data = &mc13783_pdata, 124 .platform_data = &mc13783_pdata,
127 .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3), 125 /* irq number is run-time assigned */
128}; 126};
129 127
130/* 128/*
@@ -258,6 +256,7 @@ static void __init mx31lite_init(void)
258 imx31_add_mxc_nand(&mx31lite_nand_board_info); 256 imx31_add_mxc_nand(&mx31lite_nand_board_info);
259 257
260 imx31_add_spi_imx1(&spi1_pdata); 258 imx31_add_spi_imx1(&spi1_pdata);
259 mc13783_spi_dev.irq = gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_3));
261 spi_register_board_info(&mc13783_spi_dev, 1); 260 spi_register_board_info(&mc13783_spi_dev, 1);
262 261
263 /* USB */ 262 /* USB */
@@ -274,6 +273,10 @@ static void __init mx31lite_init(void)
274 pr_warning("could not get LAN irq gpio\n"); 273 pr_warning("could not get LAN irq gpio\n");
275 else { 274 else {
276 gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_SFS6)); 275 gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_SFS6));
276 smsc911x_resources[1].start =
277 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_SFS6));
278 smsc911x_resources[1].end =
279 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_SFS6));
277 platform_device_register(&smsc911x_device); 280 platform_device_register(&smsc911x_device);
278 } 281 }
279} 282}
diff --git a/arch/arm/mach-imx/mach-mx31moboard.c b/arch/arm/mach-imx/mach-mx31moboard.c
index 016791f038b..d46290b288e 100644
--- a/arch/arm/mach-imx/mach-mx31moboard.c
+++ b/arch/arm/mach-imx/mach-mx31moboard.c
@@ -303,7 +303,7 @@ static struct imx_ssi_platform_data moboard_ssi_pdata = {
303static struct spi_board_info moboard_spi_board_info[] __initdata = { 303static struct spi_board_info moboard_spi_board_info[] __initdata = {
304 { 304 {
305 .modalias = "mc13783", 305 .modalias = "mc13783",
306 .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3), 306 /* irq number is run-time assigned */
307 .max_speed_hz = 300000, 307 .max_speed_hz = 300000,
308 .bus_num = 1, 308 .bus_num = 1,
309 .chip_select = 0, 309 .chip_select = 0,
@@ -473,10 +473,6 @@ static const struct gpio_led_platform_data mx31moboard_led_pdata __initconst = {
473 .leds = mx31moboard_leds, 473 .leds = mx31moboard_leds,
474}; 474};
475 475
476static const struct ipu_platform_data mx3_ipu_data __initconst = {
477 .irq_base = MXC_IPU_IRQ_START,
478};
479
480static struct platform_device *devices[] __initdata = { 476static struct platform_device *devices[] __initdata = {
481 &mx31moboard_flash, 477 &mx31moboard_flash,
482}; 478};
@@ -494,7 +490,7 @@ static int __init mx31moboard_init_cam(void)
494 int dma, ret = -ENOMEM; 490 int dma, ret = -ENOMEM;
495 struct platform_device *pdev; 491 struct platform_device *pdev;
496 492
497 imx31_add_ipu_core(&mx3_ipu_data); 493 imx31_add_ipu_core();
498 494
499 pdev = imx31_alloc_mx3_camera(&camera_pdata); 495 pdev = imx31_alloc_mx3_camera(&camera_pdata);
500 if (IS_ERR(pdev)) 496 if (IS_ERR(pdev))
@@ -544,7 +540,7 @@ static void __init mx31moboard_init(void)
544 platform_add_devices(devices, ARRAY_SIZE(devices)); 540 platform_add_devices(devices, ARRAY_SIZE(devices));
545 gpio_led_register_device(-1, &mx31moboard_led_pdata); 541 gpio_led_register_device(-1, &mx31moboard_led_pdata);
546 542
547 imx31_add_imx2_wdt(NULL); 543 imx31_add_imx2_wdt();
548 544
549 imx31_add_imx_uart0(&uart0_pdata); 545 imx31_add_imx_uart0(&uart0_pdata);
550 imx31_add_imx_uart4(&uart4_pdata); 546 imx31_add_imx_uart4(&uart4_pdata);
@@ -557,6 +553,8 @@ static void __init mx31moboard_init(void)
557 553
558 gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_3), "pmic-irq"); 554 gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_3), "pmic-irq");
559 gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_3)); 555 gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_3));
556 moboard_spi_board_info[0].irq =
557 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_3));
560 spi_register_board_info(moboard_spi_board_info, 558 spi_register_board_info(moboard_spi_board_info,
561 ARRAY_SIZE(moboard_spi_board_info)); 559 ARRAY_SIZE(moboard_spi_board_info));
562 560
diff --git a/arch/arm/mach-imx/mach-mx35_3ds.c b/arch/arm/mach-imx/mach-mx35_3ds.c
index 28aa19476de..504983c68aa 100644
--- a/arch/arm/mach-imx/mach-mx35_3ds.c
+++ b/arch/arm/mach-imx/mach-mx35_3ds.c
@@ -46,7 +46,6 @@
46#include <mach/hardware.h> 46#include <mach/hardware.h>
47#include <mach/common.h> 47#include <mach/common.h>
48#include <mach/iomux-mx35.h> 48#include <mach/iomux-mx35.h>
49#include <mach/irqs.h>
50#include <mach/3ds_debugboard.h> 49#include <mach/3ds_debugboard.h>
51#include <video/platform_lcd.h> 50#include <video/platform_lcd.h>
52 51
@@ -80,10 +79,6 @@ static const struct fb_videomode fb_modedb[] = {
80 }, 79 },
81}; 80};
82 81
83static const struct ipu_platform_data mx3_ipu_data __initconst = {
84 .irq_base = MXC_IPU_IRQ_START,
85};
86
87static struct mx3fb_platform_data mx3fb_pdata __initdata = { 82static struct mx3fb_platform_data mx3fb_pdata __initdata = {
88 .name = "Ceramate-CLAA070VC01", 83 .name = "Ceramate-CLAA070VC01",
89 .mode = fb_modedb, 84 .mode = fb_modedb,
@@ -136,8 +131,6 @@ static struct platform_device mx35_3ds_lcd = {
136 .dev.platform_data = &mx35_3ds_lcd_data, 131 .dev.platform_data = &mx35_3ds_lcd_data,
137}; 132};
138 133
139#define EXPIO_PARENT_INT gpio_to_irq(IMX_GPIO_NR(1, 1))
140
141static const struct imxuart_platform_data uart_pdata __initconst = { 134static const struct imxuart_platform_data uart_pdata __initconst = {
142 .flags = IMXUART_HAVE_RTSCTS, 135 .flags = IMXUART_HAVE_RTSCTS,
143}; 136};
@@ -297,10 +290,6 @@ err:
297 return ret; 290 return ret;
298} 291}
299 292
300static const struct ipu_platform_data mx35_3ds_ipu_data __initconst = {
301 .irq_base = MXC_IPU_IRQ_START,
302};
303
304static struct i2c_board_info mx35_3ds_i2c_camera = { 293static struct i2c_board_info mx35_3ds_i2c_camera = {
305 I2C_BOARD_INFO("ov2640", 0x30), 294 I2C_BOARD_INFO("ov2640", 0x30),
306}; 295};
@@ -492,7 +481,7 @@ static struct i2c_board_info mx35_3ds_i2c_mc13892 = {
492 481
493 I2C_BOARD_INFO("mc13892", 0x08), 482 I2C_BOARD_INFO("mc13892", 0x08),
494 .platform_data = &mx35_3ds_mc13892_data, 483 .platform_data = &mx35_3ds_mc13892_data,
495 .irq = IMX_GPIO_TO_IRQ(GPIO_PMIC_INT), 484 /* irq number is run-time assigned */
496}; 485};
497 486
498static void __init imx35_3ds_init_mc13892(void) 487static void __init imx35_3ds_init_mc13892(void)
@@ -504,6 +493,7 @@ static void __init imx35_3ds_init_mc13892(void)
504 return; 493 return;
505 } 494 }
506 495
496 mx35_3ds_i2c_mc13892.irq = gpio_to_irq(GPIO_PMIC_INT);
507 i2c_register_board_info(0, &mx35_3ds_i2c_mc13892, 1); 497 i2c_register_board_info(0, &mx35_3ds_i2c_mc13892, 1);
508} 498}
509 499
@@ -540,18 +530,18 @@ static const struct mxc_usbh_platform_data usb_host_pdata __initconst = {
540 .portsc = MXC_EHCI_MODE_SERIAL, 530 .portsc = MXC_EHCI_MODE_SERIAL,
541}; 531};
542 532
543static int otg_mode_host; 533static bool otg_mode_host __initdata;
544 534
545static int __init mx35_3ds_otg_mode(char *options) 535static int __init mx35_3ds_otg_mode(char *options)
546{ 536{
547 if (!strcmp(options, "host")) 537 if (!strcmp(options, "host"))
548 otg_mode_host = 1; 538 otg_mode_host = true;
549 else if (!strcmp(options, "device")) 539 else if (!strcmp(options, "device"))
550 otg_mode_host = 0; 540 otg_mode_host = false;
551 else 541 else
552 pr_info("otg_mode neither \"host\" nor \"device\". " 542 pr_info("otg_mode neither \"host\" nor \"device\". "
553 "Defaulting to device\n"); 543 "Defaulting to device\n");
554 return 0; 544 return 1;
555} 545}
556__setup("otg_mode=", mx35_3ds_otg_mode); 546__setup("otg_mode=", mx35_3ds_otg_mode);
557 547
@@ -571,7 +561,8 @@ static void __init mx35_3ds_init(void)
571 mxc_iomux_v3_setup_multiple_pads(mx35pdk_pads, ARRAY_SIZE(mx35pdk_pads)); 561 mxc_iomux_v3_setup_multiple_pads(mx35pdk_pads, ARRAY_SIZE(mx35pdk_pads));
572 562
573 imx35_add_fec(NULL); 563 imx35_add_fec(NULL);
574 imx35_add_imx2_wdt(NULL); 564 imx35_add_imx2_wdt();
565 imx35_add_mxc_rtc();
575 platform_add_devices(devices, ARRAY_SIZE(devices)); 566 platform_add_devices(devices, ARRAY_SIZE(devices));
576 567
577 imx35_add_imx_uart0(&uart_pdata); 568 imx35_add_imx_uart0(&uart_pdata);
@@ -587,7 +578,7 @@ static void __init mx35_3ds_init(void)
587 imx35_add_mxc_nand(&mx35pdk_nand_board_info); 578 imx35_add_mxc_nand(&mx35pdk_nand_board_info);
588 imx35_add_sdhci_esdhc_imx(0, NULL); 579 imx35_add_sdhci_esdhc_imx(0, NULL);
589 580
590 if (mxc_expio_init(MX35_CS5_BASE_ADDR, EXPIO_PARENT_INT)) 581 if (mxc_expio_init(MX35_CS5_BASE_ADDR, IMX_GPIO_NR(1, 1)))
591 pr_warn("Init of the debugboard failed, all " 582 pr_warn("Init of the debugboard failed, all "
592 "devices on the debugboard are unusable.\n"); 583 "devices on the debugboard are unusable.\n");
593 imx35_add_imx_i2c0(&mx35_3ds_i2c0_data); 584 imx35_add_imx_i2c0(&mx35_3ds_i2c0_data);
@@ -595,7 +586,7 @@ static void __init mx35_3ds_init(void)
595 i2c_register_board_info( 586 i2c_register_board_info(
596 0, i2c_devices_3ds, ARRAY_SIZE(i2c_devices_3ds)); 587 0, i2c_devices_3ds, ARRAY_SIZE(i2c_devices_3ds));
597 588
598 imx35_add_ipu_core(&mx35_3ds_ipu_data); 589 imx35_add_ipu_core();
599 platform_device_register(&mx35_3ds_ov2640); 590 platform_device_register(&mx35_3ds_ov2640);
600 imx35_3ds_init_camera(); 591 imx35_3ds_init_camera();
601 592
diff --git a/arch/arm/mach-imx/mach-mx51_3ds.c b/arch/arm/mach-imx/mach-mx51_3ds.c
index 3c5b163923f..9ee84a4af63 100644
--- a/arch/arm/mach-imx/mach-mx51_3ds.c
+++ b/arch/arm/mach-imx/mach-mx51_3ds.c
@@ -26,7 +26,6 @@
26 26
27#include "devices-imx51.h" 27#include "devices-imx51.h"
28 28
29#define EXPIO_PARENT_INT gpio_to_irq(IMX_GPIO_NR(1, 6))
30#define MX51_3DS_ECSPI2_CS (GPIO_PORTC + 28) 29#define MX51_3DS_ECSPI2_CS (GPIO_PORTC + 28)
31 30
32static iomux_v3_cfg_t mx51_3ds_pads[] = { 31static iomux_v3_cfg_t mx51_3ds_pads[] = {
@@ -148,13 +147,13 @@ static void __init mx51_3ds_init(void)
148 spi_register_board_info(mx51_3ds_spi_nor_device, 147 spi_register_board_info(mx51_3ds_spi_nor_device,
149 ARRAY_SIZE(mx51_3ds_spi_nor_device)); 148 ARRAY_SIZE(mx51_3ds_spi_nor_device));
150 149
151 if (mxc_expio_init(MX51_CS5_BASE_ADDR, EXPIO_PARENT_INT)) 150 if (mxc_expio_init(MX51_CS5_BASE_ADDR, IMX_GPIO_NR(1, 6)))
152 printk(KERN_WARNING "Init of the debugboard failed, all " 151 printk(KERN_WARNING "Init of the debugboard failed, all "
153 "devices on the board are unusable.\n"); 152 "devices on the board are unusable.\n");
154 153
155 imx51_add_sdhci_esdhc_imx(0, NULL); 154 imx51_add_sdhci_esdhc_imx(0, NULL);
156 imx51_add_imx_keypad(&mx51_3ds_map_data); 155 imx51_add_imx_keypad(&mx51_3ds_map_data);
157 imx51_add_imx2_wdt(0, NULL); 156 imx51_add_imx2_wdt(0);
158} 157}
159 158
160static void __init mx51_3ds_timer_init(void) 159static void __init mx51_3ds_timer_init(void)
diff --git a/arch/arm/mach-imx/mach-mx51_babbage.c b/arch/arm/mach-imx/mach-mx51_babbage.c
index dde397014d4..7b31cbde877 100644
--- a/arch/arm/mach-imx/mach-mx51_babbage.c
+++ b/arch/arm/mach-imx/mach-mx51_babbage.c
@@ -307,18 +307,18 @@ static const struct mxc_usbh_platform_data usbh1_config __initconst = {
307 .portsc = MXC_EHCI_MODE_ULPI, 307 .portsc = MXC_EHCI_MODE_ULPI,
308}; 308};
309 309
310static int otg_mode_host; 310static bool otg_mode_host __initdata;
311 311
312static int __init babbage_otg_mode(char *options) 312static int __init babbage_otg_mode(char *options)
313{ 313{
314 if (!strcmp(options, "host")) 314 if (!strcmp(options, "host"))
315 otg_mode_host = 1; 315 otg_mode_host = true;
316 else if (!strcmp(options, "device")) 316 else if (!strcmp(options, "device"))
317 otg_mode_host = 0; 317 otg_mode_host = false;
318 else 318 else
319 pr_info("otg_mode neither \"host\" nor \"device\". " 319 pr_info("otg_mode neither \"host\" nor \"device\". "
320 "Defaulting to device\n"); 320 "Defaulting to device\n");
321 return 0; 321 return 1;
322} 322}
323__setup("otg_mode=", babbage_otg_mode); 323__setup("otg_mode=", babbage_otg_mode);
324 324
@@ -411,7 +411,7 @@ static void __init mx51_babbage_init(void)
411 spi_register_board_info(mx51_babbage_spi_board_info, 411 spi_register_board_info(mx51_babbage_spi_board_info,
412 ARRAY_SIZE(mx51_babbage_spi_board_info)); 412 ARRAY_SIZE(mx51_babbage_spi_board_info));
413 imx51_add_ecspi(0, &mx51_babbage_spi_pdata); 413 imx51_add_ecspi(0, &mx51_babbage_spi_pdata);
414 imx51_add_imx2_wdt(0, NULL); 414 imx51_add_imx2_wdt(0);
415} 415}
416 416
417static void __init mx51_babbage_timer_init(void) 417static void __init mx51_babbage_timer_init(void)
diff --git a/arch/arm/mach-imx/mach-mx53_ard.c b/arch/arm/mach-imx/mach-mx53_ard.c
index 05641980dc5..6c28e65f424 100644
--- a/arch/arm/mach-imx/mach-mx53_ard.c
+++ b/arch/arm/mach-imx/mach-mx53_ard.c
@@ -135,8 +135,7 @@ static struct resource ard_smsc911x_resources[] = {
135 .flags = IORESOURCE_MEM, 135 .flags = IORESOURCE_MEM,
136 }, 136 },
137 { 137 {
138 .start = IMX_GPIO_TO_IRQ(ARD_ETHERNET_INT_B), 138 /* irq number is run-time assigned */
139 .end = IMX_GPIO_TO_IRQ(ARD_ETHERNET_INT_B),
140 .flags = IORESOURCE_IRQ, 139 .flags = IORESOURCE_IRQ,
141 }, 140 },
142}; 141};
@@ -240,10 +239,12 @@ static void __init mx53_ard_board_init(void)
240 imx53_ard_common_init(); 239 imx53_ard_common_init();
241 mx53_ard_io_init(); 240 mx53_ard_io_init();
242 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies)); 241 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
242 ard_smsc911x_resources[1].start = gpio_to_irq(ARD_ETHERNET_INT_B);
243 ard_smsc911x_resources[1].end = gpio_to_irq(ARD_ETHERNET_INT_B);
243 platform_add_devices(devices, ARRAY_SIZE(devices)); 244 platform_add_devices(devices, ARRAY_SIZE(devices));
244 245
245 imx53_add_sdhci_esdhc_imx(0, &mx53_ard_sd1_data); 246 imx53_add_sdhci_esdhc_imx(0, &mx53_ard_sd1_data);
246 imx53_add_imx2_wdt(0, NULL); 247 imx53_add_imx2_wdt(0);
247 imx53_add_imx_i2c(1, &mx53_ard_i2c2_data); 248 imx53_add_imx_i2c(1, &mx53_ard_i2c2_data);
248 imx53_add_imx_i2c(2, &mx53_ard_i2c3_data); 249 imx53_add_imx_i2c(2, &mx53_ard_i2c3_data);
249 imx_add_gpio_keys(&ard_button_data); 250 imx_add_gpio_keys(&ard_button_data);
@@ -266,5 +267,6 @@ MACHINE_START(MX53_ARD, "Freescale MX53 ARD Board")
266 .handle_irq = imx53_handle_irq, 267 .handle_irq = imx53_handle_irq,
267 .timer = &mx53_ard_timer, 268 .timer = &mx53_ard_timer,
268 .init_machine = mx53_ard_board_init, 269 .init_machine = mx53_ard_board_init,
270 .init_late = imx53_init_late,
269 .restart = mxc_restart, 271 .restart = mxc_restart,
270MACHINE_END 272MACHINE_END
diff --git a/arch/arm/mach-imx/mach-mx53_evk.c b/arch/arm/mach-imx/mach-mx53_evk.c
index 5a72188b9cd..09fe2197b49 100644
--- a/arch/arm/mach-imx/mach-mx53_evk.c
+++ b/arch/arm/mach-imx/mach-mx53_evk.c
@@ -154,7 +154,7 @@ static void __init mx53_evk_board_init(void)
154 spi_register_board_info(mx53_evk_spi_board_info, 154 spi_register_board_info(mx53_evk_spi_board_info,
155 ARRAY_SIZE(mx53_evk_spi_board_info)); 155 ARRAY_SIZE(mx53_evk_spi_board_info));
156 imx53_add_ecspi(0, &mx53_evk_spi_data); 156 imx53_add_ecspi(0, &mx53_evk_spi_data);
157 imx53_add_imx2_wdt(0, NULL); 157 imx53_add_imx2_wdt(0);
158 gpio_led_register_device(-1, &mx53evk_leds_data); 158 gpio_led_register_device(-1, &mx53evk_leds_data);
159} 159}
160 160
@@ -174,5 +174,6 @@ MACHINE_START(MX53_EVK, "Freescale MX53 EVK Board")
174 .handle_irq = imx53_handle_irq, 174 .handle_irq = imx53_handle_irq,
175 .timer = &mx53_evk_timer, 175 .timer = &mx53_evk_timer,
176 .init_machine = mx53_evk_board_init, 176 .init_machine = mx53_evk_board_init,
177 .init_late = imx53_init_late,
177 .restart = mxc_restart, 178 .restart = mxc_restart,
178MACHINE_END 179MACHINE_END
diff --git a/arch/arm/mach-imx/mach-mx53_loco.c b/arch/arm/mach-imx/mach-mx53_loco.c
index 37f67cac15a..8abe23c1d3c 100644
--- a/arch/arm/mach-imx/mach-mx53_loco.c
+++ b/arch/arm/mach-imx/mach-mx53_loco.c
@@ -283,7 +283,7 @@ static void __init mx53_loco_board_init(void)
283 imx53_add_imx_uart(0, NULL); 283 imx53_add_imx_uart(0, NULL);
284 mx53_loco_fec_reset(); 284 mx53_loco_fec_reset();
285 imx53_add_fec(&mx53_loco_fec_data); 285 imx53_add_fec(&mx53_loco_fec_data);
286 imx53_add_imx2_wdt(0, NULL); 286 imx53_add_imx2_wdt(0);
287 287
288 ret = gpio_request_one(LOCO_ACCEL_EN, GPIOF_OUT_INIT_HIGH, "accel_en"); 288 ret = gpio_request_one(LOCO_ACCEL_EN, GPIOF_OUT_INIT_HIGH, "accel_en");
289 if (ret) 289 if (ret)
@@ -316,5 +316,6 @@ MACHINE_START(MX53_LOCO, "Freescale MX53 LOCO Board")
316 .handle_irq = imx53_handle_irq, 316 .handle_irq = imx53_handle_irq,
317 .timer = &mx53_loco_timer, 317 .timer = &mx53_loco_timer,
318 .init_machine = mx53_loco_board_init, 318 .init_machine = mx53_loco_board_init,
319 .init_late = imx53_init_late,
319 .restart = mxc_restart, 320 .restart = mxc_restart,
320MACHINE_END 321MACHINE_END
diff --git a/arch/arm/mach-imx/mach-mx53_smd.c b/arch/arm/mach-imx/mach-mx53_smd.c
index 8e972c5c3e1..b15d6a6d3b6 100644
--- a/arch/arm/mach-imx/mach-mx53_smd.c
+++ b/arch/arm/mach-imx/mach-mx53_smd.c
@@ -138,7 +138,7 @@ static void __init mx53_smd_board_init(void)
138 mx53_smd_init_uart(); 138 mx53_smd_init_uart();
139 mx53_smd_fec_reset(); 139 mx53_smd_fec_reset();
140 imx53_add_fec(&mx53_smd_fec_data); 140 imx53_add_fec(&mx53_smd_fec_data);
141 imx53_add_imx2_wdt(0, NULL); 141 imx53_add_imx2_wdt(0);
142 imx53_add_imx_i2c(0, &mx53_smd_i2c_data); 142 imx53_add_imx_i2c(0, &mx53_smd_i2c_data);
143 imx53_add_sdhci_esdhc_imx(0, NULL); 143 imx53_add_sdhci_esdhc_imx(0, NULL);
144 imx53_add_sdhci_esdhc_imx(1, NULL); 144 imx53_add_sdhci_esdhc_imx(1, NULL);
@@ -163,5 +163,6 @@ MACHINE_START(MX53_SMD, "Freescale MX53 SMD Board")
163 .handle_irq = imx53_handle_irq, 163 .handle_irq = imx53_handle_irq,
164 .timer = &mx53_smd_timer, 164 .timer = &mx53_smd_timer,
165 .init_machine = mx53_smd_board_init, 165 .init_machine = mx53_smd_board_init,
166 .init_late = imx53_init_late,
166 .restart = mxc_restart, 167 .restart = mxc_restart,
167MACHINE_END 168MACHINE_END
diff --git a/arch/arm/mach-imx/mach-mxt_td60.c b/arch/arm/mach-imx/mach-mxt_td60.c
index 8b3d3f07d89..0bf6d30aa32 100644
--- a/arch/arm/mach-imx/mach-mxt_td60.c
+++ b/arch/arm/mach-imx/mach-mxt_td60.c
@@ -213,13 +213,13 @@ static const struct imx_fb_platform_data mxt_td60_fb_data __initconst = {
213static int mxt_td60_sdhc1_init(struct device *dev, irq_handler_t detect_irq, 213static int mxt_td60_sdhc1_init(struct device *dev, irq_handler_t detect_irq,
214 void *data) 214 void *data)
215{ 215{
216 return request_irq(IRQ_GPIOF(8), detect_irq, IRQF_TRIGGER_FALLING, 216 return request_irq(gpio_to_irq(IMX_GPIO_NR(6, 8)), detect_irq,
217 "sdhc1-card-detect", data); 217 IRQF_TRIGGER_FALLING, "sdhc1-card-detect", data);
218} 218}
219 219
220static void mxt_td60_sdhc1_exit(struct device *dev, void *data) 220static void mxt_td60_sdhc1_exit(struct device *dev, void *data)
221{ 221{
222 free_irq(IRQ_GPIOF(8), data); 222 free_irq(gpio_to_irq(IMX_GPIO_NR(6, 8)), data);
223} 223}
224 224
225static const struct imxmmc_platform_data sdhc1_pdata __initconst = { 225static const struct imxmmc_platform_data sdhc1_pdata __initconst = {
diff --git a/arch/arm/mach-imx/mach-pca100.c b/arch/arm/mach-imx/mach-pca100.c
index 541152e450c..de8516b7d69 100644
--- a/arch/arm/mach-imx/mach-pca100.c
+++ b/arch/arm/mach-imx/mach-pca100.c
@@ -36,7 +36,6 @@
36#include <mach/hardware.h> 36#include <mach/hardware.h>
37#include <mach/iomux-mx27.h> 37#include <mach/iomux-mx27.h>
38#include <asm/mach/time.h> 38#include <asm/mach/time.h>
39#include <mach/irqs.h>
40#include <mach/ulpi.h> 39#include <mach/ulpi.h>
41 40
42#include "devices-imx27.h" 41#include "devices-imx27.h"
@@ -245,7 +244,7 @@ static int pca100_sdhc2_init(struct device *dev, irq_handler_t detect_irq,
245{ 244{
246 int ret; 245 int ret;
247 246
248 ret = request_irq(IRQ_GPIOC(29), detect_irq, 247 ret = request_irq(gpio_to_irq(IMX_GPIO_NR(3, 29)), detect_irq,
249 IRQF_DISABLED | IRQF_TRIGGER_FALLING, 248 IRQF_DISABLED | IRQF_TRIGGER_FALLING,
250 "imx-mmc-detect", data); 249 "imx-mmc-detect", data);
251 if (ret) 250 if (ret)
@@ -257,7 +256,7 @@ static int pca100_sdhc2_init(struct device *dev, irq_handler_t detect_irq,
257 256
258static void pca100_sdhc2_exit(struct device *dev, void *data) 257static void pca100_sdhc2_exit(struct device *dev, void *data)
259{ 258{
260 free_irq(IRQ_GPIOC(29), data); 259 free_irq(gpio_to_irq(IMX_GPIO_NR(3, 29)), data);
261} 260}
262 261
263static const struct imxmmc_platform_data sdhc_pdata __initconst = { 262static const struct imxmmc_platform_data sdhc_pdata __initconst = {
@@ -298,18 +297,18 @@ static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
298 .phy_mode = FSL_USB2_PHY_ULPI, 297 .phy_mode = FSL_USB2_PHY_ULPI,
299}; 298};
300 299
301static int otg_mode_host; 300static bool otg_mode_host __initdata;
302 301
303static int __init pca100_otg_mode(char *options) 302static int __init pca100_otg_mode(char *options)
304{ 303{
305 if (!strcmp(options, "host")) 304 if (!strcmp(options, "host"))
306 otg_mode_host = 1; 305 otg_mode_host = true;
307 else if (!strcmp(options, "device")) 306 else if (!strcmp(options, "device"))
308 otg_mode_host = 0; 307 otg_mode_host = false;
309 else 308 else
310 pr_info("otg_mode neither \"host\" nor \"device\". " 309 pr_info("otg_mode neither \"host\" nor \"device\". "
311 "Defaulting to device\n"); 310 "Defaulting to device\n");
312 return 0; 311 return 1;
313} 312}
314__setup("otg_mode=", pca100_otg_mode); 313__setup("otg_mode=", pca100_otg_mode);
315 314
@@ -408,8 +407,8 @@ static void __init pca100_init(void)
408 imx27_add_imx_fb(&pca100_fb_data); 407 imx27_add_imx_fb(&pca100_fb_data);
409 408
410 imx27_add_fec(NULL); 409 imx27_add_fec(NULL);
411 imx27_add_imx2_wdt(NULL); 410 imx27_add_imx2_wdt();
412 imx27_add_mxc_w1(NULL); 411 imx27_add_mxc_w1();
413} 412}
414 413
415static void __init pca100_timer_init(void) 414static void __init pca100_timer_init(void)
diff --git a/arch/arm/mach-imx/mach-pcm037.c b/arch/arm/mach-imx/mach-pcm037.c
index 0a40004154f..e3c45130fb3 100644
--- a/arch/arm/mach-imx/mach-pcm037.c
+++ b/arch/arm/mach-imx/mach-pcm037.c
@@ -225,8 +225,7 @@ static struct resource smsc911x_resources[] = {
225 .end = MX31_CS1_BASE_ADDR + 0x300 + SZ_64K - 1, 225 .end = MX31_CS1_BASE_ADDR + 0x300 + SZ_64K - 1,
226 .flags = IORESOURCE_MEM, 226 .flags = IORESOURCE_MEM,
227 }, { 227 }, {
228 .start = IOMUX_TO_IRQ(MX31_PIN_GPIO3_1), 228 /* irq number is run-time assigned */
229 .end = IOMUX_TO_IRQ(MX31_PIN_GPIO3_1),
230 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, 229 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
231 }, 230 },
232}; 231};
@@ -371,7 +370,7 @@ static int pcm970_sdhc1_init(struct device *dev, irq_handler_t detect_irq,
371 gpio_direction_input(SDHC1_GPIO_WP); 370 gpio_direction_input(SDHC1_GPIO_WP);
372#endif 371#endif
373 372
374 ret = request_irq(IOMUX_TO_IRQ(MX31_PIN_SCK6), detect_irq, 373 ret = request_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_SCK6)), detect_irq,
375 IRQF_DISABLED | IRQF_TRIGGER_FALLING, 374 IRQF_DISABLED | IRQF_TRIGGER_FALLING,
376 "sdhc-detect", data); 375 "sdhc-detect", data);
377 if (ret) 376 if (ret)
@@ -391,7 +390,7 @@ err_gpio_free:
391 390
392static void pcm970_sdhc1_exit(struct device *dev, void *data) 391static void pcm970_sdhc1_exit(struct device *dev, void *data)
393{ 392{
394 free_irq(IOMUX_TO_IRQ(MX31_PIN_SCK6), data); 393 free_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_SCK6)), data);
395 gpio_free(SDHC1_GPIO_DET); 394 gpio_free(SDHC1_GPIO_DET);
396 gpio_free(SDHC1_GPIO_WP); 395 gpio_free(SDHC1_GPIO_WP);
397} 396}
@@ -442,10 +441,6 @@ static struct platform_device *devices[] __initdata = {
442 &pcm037_mt9v022, 441 &pcm037_mt9v022,
443}; 442};
444 443
445static const struct ipu_platform_data mx3_ipu_data __initconst = {
446 .irq_base = MXC_IPU_IRQ_START,
447};
448
449static const struct fb_videomode fb_modedb[] = { 444static const struct fb_videomode fb_modedb[] = {
450 { 445 {
451 /* 240x320 @ 60 Hz Sharp */ 446 /* 240x320 @ 60 Hz Sharp */
@@ -511,8 +506,7 @@ static struct resource pcm970_sja1000_resources[] = {
511 .end = MX31_CS5_BASE_ADDR + 0x100 - 1, 506 .end = MX31_CS5_BASE_ADDR + 0x100 - 1,
512 .flags = IORESOURCE_MEM, 507 .flags = IORESOURCE_MEM,
513 }, { 508 }, {
514 .start = IOMUX_TO_IRQ(IOMUX_PIN(48, 105)), 509 /* irq number is run-time assigned */
515 .end = IOMUX_TO_IRQ(IOMUX_PIN(48, 105)),
516 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE, 510 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
517 }, 511 },
518}; 512};
@@ -557,18 +551,18 @@ static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
557 .phy_mode = FSL_USB2_PHY_ULPI, 551 .phy_mode = FSL_USB2_PHY_ULPI,
558}; 552};
559 553
560static int otg_mode_host; 554static bool otg_mode_host __initdata;
561 555
562static int __init pcm037_otg_mode(char *options) 556static int __init pcm037_otg_mode(char *options)
563{ 557{
564 if (!strcmp(options, "host")) 558 if (!strcmp(options, "host"))
565 otg_mode_host = 1; 559 otg_mode_host = true;
566 else if (!strcmp(options, "device")) 560 else if (!strcmp(options, "device"))
567 otg_mode_host = 0; 561 otg_mode_host = false;
568 else 562 else
569 pr_info("otg_mode neither \"host\" nor \"device\". " 563 pr_info("otg_mode neither \"host\" nor \"device\". "
570 "Defaulting to device\n"); 564 "Defaulting to device\n");
571 return 0; 565 return 1;
572} 566}
573__setup("otg_mode=", pcm037_otg_mode); 567__setup("otg_mode=", pcm037_otg_mode);
574 568
@@ -619,13 +613,13 @@ static void __init pcm037_init(void)
619 613
620 platform_add_devices(devices, ARRAY_SIZE(devices)); 614 platform_add_devices(devices, ARRAY_SIZE(devices));
621 615
622 imx31_add_imx2_wdt(NULL); 616 imx31_add_imx2_wdt();
623 imx31_add_imx_uart0(&uart_pdata); 617 imx31_add_imx_uart0(&uart_pdata);
624 /* XXX: should't this have .flags = 0 (i.e. no RTSCTS) on PCM037_EET? */ 618 /* XXX: should't this have .flags = 0 (i.e. no RTSCTS) on PCM037_EET? */
625 imx31_add_imx_uart1(&uart_pdata); 619 imx31_add_imx_uart1(&uart_pdata);
626 imx31_add_imx_uart2(&uart_pdata); 620 imx31_add_imx_uart2(&uart_pdata);
627 621
628 imx31_add_mxc_w1(NULL); 622 imx31_add_mxc_w1();
629 623
630 /* LAN9217 IRQ pin */ 624 /* LAN9217 IRQ pin */
631 ret = gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO3_1), "lan9217-irq"); 625 ret = gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO3_1), "lan9217-irq");
@@ -633,6 +627,10 @@ static void __init pcm037_init(void)
633 pr_warning("could not get LAN irq gpio\n"); 627 pr_warning("could not get LAN irq gpio\n");
634 else { 628 else {
635 gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO3_1)); 629 gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO3_1));
630 smsc911x_resources[1].start =
631 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO3_1));
632 smsc911x_resources[1].end =
633 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO3_1));
636 platform_device_register(&pcm037_eth); 634 platform_device_register(&pcm037_eth);
637 } 635 }
638 636
@@ -646,7 +644,7 @@ static void __init pcm037_init(void)
646 644
647 imx31_add_mxc_nand(&pcm037_nand_board_info); 645 imx31_add_mxc_nand(&pcm037_nand_board_info);
648 imx31_add_mxc_mmc(0, &sdhc_pdata); 646 imx31_add_mxc_mmc(0, &sdhc_pdata);
649 imx31_add_ipu_core(&mx3_ipu_data); 647 imx31_add_ipu_core();
650 imx31_add_mx3_sdc_fb(&mx3fb_pdata); 648 imx31_add_mx3_sdc_fb(&mx3fb_pdata);
651 649
652 /* CSI */ 650 /* CSI */
@@ -659,6 +657,10 @@ static void __init pcm037_init(void)
659 657
660 pcm037_init_camera(); 658 pcm037_init_camera();
661 659
660 pcm970_sja1000_resources[1].start =
661 gpio_to_irq(IOMUX_TO_GPIO(IOMUX_PIN(48, 105)));
662 pcm970_sja1000_resources[1].end =
663 gpio_to_irq(IOMUX_TO_GPIO(IOMUX_PIN(48, 105)));
662 platform_device_register(&pcm970_sja1000); 664 platform_device_register(&pcm970_sja1000);
663 665
664 if (otg_mode_host) { 666 if (otg_mode_host) {
diff --git a/arch/arm/mach-imx/mach-pcm038.c b/arch/arm/mach-imx/mach-pcm038.c
index 2f3debe2a11..95f49d936fd 100644
--- a/arch/arm/mach-imx/mach-pcm038.c
+++ b/arch/arm/mach-imx/mach-pcm038.c
@@ -27,6 +27,7 @@
27#include <linux/mfd/mc13783.h> 27#include <linux/mfd/mc13783.h>
28#include <linux/spi/spi.h> 28#include <linux/spi/spi.h>
29#include <linux/irq.h> 29#include <linux/irq.h>
30#include <linux/gpio.h>
30 31
31#include <asm/mach-types.h> 32#include <asm/mach-types.h>
32#include <asm/mach/arch.h> 33#include <asm/mach/arch.h>
@@ -274,7 +275,7 @@ static struct mc13xxx_platform_data pcm038_pmic = {
274static struct spi_board_info pcm038_spi_board_info[] __initdata = { 275static struct spi_board_info pcm038_spi_board_info[] __initdata = {
275 { 276 {
276 .modalias = "mc13783", 277 .modalias = "mc13783",
277 .irq = IRQ_GPIOB(23), 278 /* irq number is run-time assigned */
278 .max_speed_hz = 300000, 279 .max_speed_hz = 300000,
279 .bus_num = 0, 280 .bus_num = 0,
280 .chip_select = 0, 281 .chip_select = 0,
@@ -325,6 +326,7 @@ static void __init pcm038_init(void)
325 mxc_gpio_mode(GPIO_PORTB | 23 | GPIO_GPIO | GPIO_IN); 326 mxc_gpio_mode(GPIO_PORTB | 23 | GPIO_GPIO | GPIO_IN);
326 327
327 imx27_add_spi_imx0(&pcm038_spi0_data); 328 imx27_add_spi_imx0(&pcm038_spi0_data);
329 pcm038_spi_board_info[0].irq = gpio_to_irq(IMX_GPIO_NR(2, 23));
328 spi_register_board_info(pcm038_spi_board_info, 330 spi_register_board_info(pcm038_spi_board_info,
329 ARRAY_SIZE(pcm038_spi_board_info)); 331 ARRAY_SIZE(pcm038_spi_board_info));
330 332
@@ -332,8 +334,8 @@ static void __init pcm038_init(void)
332 334
333 imx27_add_fec(NULL); 335 imx27_add_fec(NULL);
334 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 336 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
335 imx27_add_imx2_wdt(NULL); 337 imx27_add_imx2_wdt();
336 imx27_add_mxc_w1(NULL); 338 imx27_add_mxc_w1();
337 339
338#ifdef CONFIG_MACH_PCM970_BASEBOARD 340#ifdef CONFIG_MACH_PCM970_BASEBOARD
339 pcm970_baseboard_init(); 341 pcm970_baseboard_init();
diff --git a/arch/arm/mach-imx/mach-pcm043.c b/arch/arm/mach-imx/mach-pcm043.c
index 73585f55cca..e4bd4387e34 100644
--- a/arch/arm/mach-imx/mach-pcm043.c
+++ b/arch/arm/mach-imx/mach-pcm043.c
@@ -76,10 +76,6 @@ static const struct fb_videomode fb_modedb[] = {
76 }, 76 },
77}; 77};
78 78
79static const struct ipu_platform_data mx3_ipu_data __initconst = {
80 .irq_base = MXC_IPU_IRQ_START,
81};
82
83static struct mx3fb_platform_data mx3fb_pdata __initdata = { 79static struct mx3fb_platform_data mx3fb_pdata __initdata = {
84 .name = "Sharp-LQ035Q7", 80 .name = "Sharp-LQ035Q7",
85 .mode = fb_modedb, 81 .mode = fb_modedb,
@@ -330,18 +326,18 @@ static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
330 .phy_mode = FSL_USB2_PHY_UTMI, 326 .phy_mode = FSL_USB2_PHY_UTMI,
331}; 327};
332 328
333static int otg_mode_host; 329static bool otg_mode_host __initdata;
334 330
335static int __init pcm043_otg_mode(char *options) 331static int __init pcm043_otg_mode(char *options)
336{ 332{
337 if (!strcmp(options, "host")) 333 if (!strcmp(options, "host"))
338 otg_mode_host = 1; 334 otg_mode_host = true;
339 else if (!strcmp(options, "device")) 335 else if (!strcmp(options, "device"))
340 otg_mode_host = 0; 336 otg_mode_host = false;
341 else 337 else
342 pr_info("otg_mode neither \"host\" nor \"device\". " 338 pr_info("otg_mode neither \"host\" nor \"device\". "
343 "Defaulting to device\n"); 339 "Defaulting to device\n");
344 return 0; 340 return 1;
345} 341}
346__setup("otg_mode=", pcm043_otg_mode); 342__setup("otg_mode=", pcm043_otg_mode);
347 343
@@ -363,7 +359,7 @@ static void __init pcm043_init(void)
363 359
364 imx35_add_fec(NULL); 360 imx35_add_fec(NULL);
365 platform_add_devices(devices, ARRAY_SIZE(devices)); 361 platform_add_devices(devices, ARRAY_SIZE(devices));
366 imx35_add_imx2_wdt(NULL); 362 imx35_add_imx2_wdt();
367 363
368 imx35_add_imx_uart0(&uart_pdata); 364 imx35_add_imx_uart0(&uart_pdata);
369 imx35_add_mxc_nand(&pcm037_nand_board_info); 365 imx35_add_mxc_nand(&pcm037_nand_board_info);
@@ -376,7 +372,7 @@ static void __init pcm043_init(void)
376 372
377 imx35_add_imx_i2c0(&pcm043_i2c0_data); 373 imx35_add_imx_i2c0(&pcm043_i2c0_data);
378 374
379 imx35_add_ipu_core(&mx3_ipu_data); 375 imx35_add_ipu_core();
380 imx35_add_mx3_sdc_fb(&mx3fb_pdata); 376 imx35_add_mx3_sdc_fb(&mx3fb_pdata);
381 377
382 if (otg_mode_host) { 378 if (otg_mode_host) {
diff --git a/arch/arm/mach-imx/mach-qong.c b/arch/arm/mach-imx/mach-qong.c
index 260621055b6..fb25fbd3122 100644
--- a/arch/arm/mach-imx/mach-qong.c
+++ b/arch/arm/mach-imx/mach-qong.c
@@ -22,7 +22,6 @@
22#include <linux/gpio.h> 22#include <linux/gpio.h>
23 23
24#include <mach/hardware.h> 24#include <mach/hardware.h>
25#include <mach/irqs.h>
26#include <asm/mach-types.h> 25#include <asm/mach-types.h>
27#include <asm/mach/arch.h> 26#include <asm/mach/arch.h>
28#include <asm/mach/time.h> 27#include <asm/mach/time.h>
@@ -51,8 +50,6 @@
51 (QONG_FPGA_BASEADDR + QONG_DNET_ID * QONG_FPGA_PERIPH_SIZE) 50 (QONG_FPGA_BASEADDR + QONG_DNET_ID * QONG_FPGA_PERIPH_SIZE)
52#define QONG_DNET_SIZE 0x00001000 51#define QONG_DNET_SIZE 0x00001000
53 52
54#define QONG_FPGA_IRQ IOMUX_TO_IRQ(MX31_PIN_DTR_DCE1)
55
56static const struct imxuart_platform_data uart_pdata __initconst = { 53static const struct imxuart_platform_data uart_pdata __initconst = {
57 .flags = IMXUART_HAVE_RTSCTS, 54 .flags = IMXUART_HAVE_RTSCTS,
58}; 55};
@@ -78,8 +75,7 @@ static struct resource dnet_resources[] = {
78 .end = QONG_DNET_BASEADDR + QONG_DNET_SIZE - 1, 75 .end = QONG_DNET_BASEADDR + QONG_DNET_SIZE - 1,
79 .flags = IORESOURCE_MEM, 76 .flags = IORESOURCE_MEM,
80 }, { 77 }, {
81 .start = QONG_FPGA_IRQ, 78 /* irq number is run-time assigned */
82 .end = QONG_FPGA_IRQ,
83 .flags = IORESOURCE_IRQ, 79 .flags = IORESOURCE_IRQ,
84 }, 80 },
85}; 81};
@@ -95,6 +91,10 @@ static int __init qong_init_dnet(void)
95{ 91{
96 int ret; 92 int ret;
97 93
94 dnet_resources[1].start =
95 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1));
96 dnet_resources[1].end =
97 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1));
98 ret = platform_device_register(&dnet_device); 98 ret = platform_device_register(&dnet_device);
99 return ret; 99 return ret;
100} 100}
@@ -252,7 +252,7 @@ static void __init qong_init(void)
252 mxc_init_imx_uart(); 252 mxc_init_imx_uart();
253 qong_init_nor_mtd(); 253 qong_init_nor_mtd();
254 qong_init_fpga(); 254 qong_init_fpga();
255 imx31_add_imx2_wdt(NULL); 255 imx31_add_imx2_wdt();
256} 256}
257 257
258static void __init qong_timer_init(void) 258static void __init qong_timer_init(void)
diff --git a/arch/arm/mach-imx/mach-scb9328.c b/arch/arm/mach-imx/mach-scb9328.c
index cb9ceae2f64..67ff38e9a3c 100644
--- a/arch/arm/mach-imx/mach-scb9328.c
+++ b/arch/arm/mach-imx/mach-scb9328.c
@@ -14,6 +14,7 @@
14#include <linux/mtd/physmap.h> 14#include <linux/mtd/physmap.h>
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/dm9000.h> 16#include <linux/dm9000.h>
17#include <linux/gpio.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>
@@ -21,7 +22,6 @@
21 22
22#include <mach/common.h> 23#include <mach/common.h>
23#include <mach/hardware.h> 24#include <mach/hardware.h>
24#include <mach/irqs.h>
25#include <mach/iomux-mx1.h> 25#include <mach/iomux-mx1.h>
26 26
27#include "devices-imx1.h" 27#include "devices-imx1.h"
@@ -78,8 +78,7 @@ static struct resource dm9000x_resources[] = {
78 .end = MX1_CS5_PHYS + 5, 78 .end = MX1_CS5_PHYS + 5,
79 .flags = IORESOURCE_MEM, /* data access */ 79 .flags = IORESOURCE_MEM, /* data access */
80 }, { 80 }, {
81 .start = IRQ_GPIOC(3), 81 /* irq number is run-time assigned */
82 .end = IRQ_GPIOC(3),
83 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, 82 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
84 }, 83 },
85}; 84};
@@ -123,6 +122,8 @@ static void __init scb9328_init(void)
123 imx1_add_imx_uart0(&uart_pdata); 122 imx1_add_imx_uart0(&uart_pdata);
124 123
125 printk(KERN_INFO"Scb9328: Adding devices\n"); 124 printk(KERN_INFO"Scb9328: Adding devices\n");
125 dm9000x_resources[2].start = gpio_to_irq(IMX_GPIO_NR(3, 3));
126 dm9000x_resources[2].end = gpio_to_irq(IMX_GPIO_NR(3, 3));
126 platform_add_devices(devices, ARRAY_SIZE(devices)); 127 platform_add_devices(devices, ARRAY_SIZE(devices));
127} 128}
128 129
diff --git a/arch/arm/mach-imx/mach-vpr200.c b/arch/arm/mach-imx/mach-vpr200.c
index add8c69c6c1..39eb7960e2a 100644
--- a/arch/arm/mach-imx/mach-vpr200.c
+++ b/arch/arm/mach-imx/mach-vpr200.c
@@ -31,7 +31,6 @@
31#include <mach/hardware.h> 31#include <mach/hardware.h>
32#include <mach/common.h> 32#include <mach/common.h>
33#include <mach/iomux-mx35.h> 33#include <mach/iomux-mx35.h>
34#include <mach/irqs.h>
35 34
36#include <linux/i2c.h> 35#include <linux/i2c.h>
37#include <linux/i2c/at24.h> 36#include <linux/i2c/at24.h>
@@ -87,10 +86,6 @@ static const struct fb_videomode fb_modedb[] = {
87 } 86 }
88}; 87};
89 88
90static const struct ipu_platform_data mx3_ipu_data __initconst = {
91 .irq_base = MXC_IPU_IRQ_START,
92};
93
94static struct mx3fb_platform_data mx3fb_pdata __initdata = { 89static struct mx3fb_platform_data mx3fb_pdata __initdata = {
95 .name = "PT0708048", 90 .name = "PT0708048",
96 .mode = fb_modedb, 91 .mode = fb_modedb,
@@ -162,7 +157,7 @@ static struct i2c_board_info vpr200_i2c_devices[] = {
162 }, { 157 }, {
163 I2C_BOARD_INFO("mc13892", 0x08), 158 I2C_BOARD_INFO("mc13892", 0x08),
164 .platform_data = &vpr200_pmic, 159 .platform_data = &vpr200_pmic,
165 .irq = IMX_GPIO_TO_IRQ(GPIO_PMIC_INT), 160 /* irq number is run-time assigned */
166 } 161 }
167}; 162};
168 163
@@ -272,7 +267,7 @@ static void __init vpr200_board_init(void)
272 mxc_iomux_v3_setup_multiple_pads(vpr200_pads, ARRAY_SIZE(vpr200_pads)); 267 mxc_iomux_v3_setup_multiple_pads(vpr200_pads, ARRAY_SIZE(vpr200_pads));
273 268
274 imx35_add_fec(NULL); 269 imx35_add_fec(NULL);
275 imx35_add_imx2_wdt(NULL); 270 imx35_add_imx2_wdt();
276 imx_add_gpio_keys(&vpr200_gpio_keys_data); 271 imx_add_gpio_keys(&vpr200_gpio_keys_data);
277 272
278 platform_add_devices(devices, ARRAY_SIZE(devices)); 273 platform_add_devices(devices, ARRAY_SIZE(devices));
@@ -290,7 +285,7 @@ static void __init vpr200_board_init(void)
290 imx35_add_imx_uart0(NULL); 285 imx35_add_imx_uart0(NULL);
291 imx35_add_imx_uart2(NULL); 286 imx35_add_imx_uart2(NULL);
292 287
293 imx35_add_ipu_core(&mx3_ipu_data); 288 imx35_add_ipu_core();
294 imx35_add_mx3_sdc_fb(&mx3fb_pdata); 289 imx35_add_mx3_sdc_fb(&mx3fb_pdata);
295 290
296 imx35_add_fsl_usb2_udc(&otg_device_pdata); 291 imx35_add_fsl_usb2_udc(&otg_device_pdata);
@@ -299,6 +294,7 @@ static void __init vpr200_board_init(void)
299 imx35_add_mxc_nand(&vpr200_nand_board_info); 294 imx35_add_mxc_nand(&vpr200_nand_board_info);
300 imx35_add_sdhci_esdhc_imx(0, NULL); 295 imx35_add_sdhci_esdhc_imx(0, NULL);
301 296
297 vpr200_i2c_devices[1].irq = gpio_to_irq(GPIO_PMIC_INT);
302 i2c_register_board_info(0, vpr200_i2c_devices, 298 i2c_register_board_info(0, vpr200_i2c_devices,
303 ARRAY_SIZE(vpr200_i2c_devices)); 299 ARRAY_SIZE(vpr200_i2c_devices));
304 300
diff --git a/arch/arm/mach-imx/mm-imx1.c b/arch/arm/mach-imx/mm-imx1.c
index fcafd3dafb8..6d60d51868b 100644
--- a/arch/arm/mach-imx/mm-imx1.c
+++ b/arch/arm/mach-imx/mm-imx1.c
@@ -24,7 +24,6 @@
24 24
25#include <mach/common.h> 25#include <mach/common.h>
26#include <mach/hardware.h> 26#include <mach/hardware.h>
27#include <mach/irqs.h>
28#include <mach/iomux-v1.h> 27#include <mach/iomux-v1.h>
29 28
30static struct map_desc imx_io_desc[] __initdata = { 29static struct map_desc imx_io_desc[] __initdata = {
diff --git a/arch/arm/mach-imx/mm-imx21.c b/arch/arm/mach-imx/mm-imx21.c
index 5f43905e529..d056dad0940 100644
--- a/arch/arm/mach-imx/mm-imx21.c
+++ b/arch/arm/mach-imx/mm-imx21.c
@@ -26,7 +26,6 @@
26#include <mach/devices-common.h> 26#include <mach/devices-common.h>
27#include <asm/pgtable.h> 27#include <asm/pgtable.h>
28#include <asm/mach/map.h> 28#include <asm/mach/map.h>
29#include <mach/irqs.h>
30#include <mach/iomux-v1.h> 29#include <mach/iomux-v1.h>
31 30
32/* MX21 memory map definition */ 31/* MX21 memory map definition */
diff --git a/arch/arm/mach-imx/mm-imx25.c b/arch/arm/mach-imx/mm-imx25.c
index 6ff37140a4f..f3f5c6542ab 100644
--- a/arch/arm/mach-imx/mm-imx25.c
+++ b/arch/arm/mach-imx/mm-imx25.c
@@ -29,7 +29,6 @@
29#include <mach/hardware.h> 29#include <mach/hardware.h>
30#include <mach/mx25.h> 30#include <mach/mx25.h>
31#include <mach/iomux-v3.h> 31#include <mach/iomux-v3.h>
32#include <mach/irqs.h>
33 32
34/* 33/*
35 * This table defines static virtual address mappings for I/O regions. 34 * This table defines static virtual address mappings for I/O regions.
@@ -90,11 +89,11 @@ static const struct resource imx25_audmux_res[] __initconst = {
90 89
91void __init imx25_soc_init(void) 90void __init imx25_soc_init(void)
92{ 91{
93 /* i.mx25 has the i.mx31 type gpio */ 92 /* i.mx25 has the i.mx35 type gpio */
94 mxc_register_gpio("imx31-gpio", 0, MX25_GPIO1_BASE_ADDR, SZ_16K, MX25_INT_GPIO1, 0); 93 mxc_register_gpio("imx35-gpio", 0, MX25_GPIO1_BASE_ADDR, SZ_16K, MX25_INT_GPIO1, 0);
95 mxc_register_gpio("imx31-gpio", 1, MX25_GPIO2_BASE_ADDR, SZ_16K, MX25_INT_GPIO2, 0); 94 mxc_register_gpio("imx35-gpio", 1, MX25_GPIO2_BASE_ADDR, SZ_16K, MX25_INT_GPIO2, 0);
96 mxc_register_gpio("imx31-gpio", 2, MX25_GPIO3_BASE_ADDR, SZ_16K, MX25_INT_GPIO3, 0); 95 mxc_register_gpio("imx35-gpio", 2, MX25_GPIO3_BASE_ADDR, SZ_16K, MX25_INT_GPIO3, 0);
97 mxc_register_gpio("imx31-gpio", 3, MX25_GPIO4_BASE_ADDR, SZ_16K, MX25_INT_GPIO4, 0); 96 mxc_register_gpio("imx35-gpio", 3, MX25_GPIO4_BASE_ADDR, SZ_16K, MX25_INT_GPIO4, 0);
98 97
99 pinctrl_provide_dummies(); 98 pinctrl_provide_dummies();
100 /* i.mx25 has the i.mx35 type sdma */ 99 /* i.mx25 has the i.mx35 type sdma */
diff --git a/arch/arm/mach-imx/mm-imx27.c b/arch/arm/mach-imx/mm-imx27.c
index 25662558e01..e7e24afc45e 100644
--- a/arch/arm/mach-imx/mm-imx27.c
+++ b/arch/arm/mach-imx/mm-imx27.c
@@ -26,7 +26,6 @@
26#include <mach/devices-common.h> 26#include <mach/devices-common.h>
27#include <asm/pgtable.h> 27#include <asm/pgtable.h>
28#include <asm/mach/map.h> 28#include <asm/mach/map.h>
29#include <mach/irqs.h>
30#include <mach/iomux-v1.h> 29#include <mach/iomux-v1.h>
31 30
32/* MX27 memory map definition */ 31/* MX27 memory map definition */
diff --git a/arch/arm/mach-imx/mm-imx3.c b/arch/arm/mach-imx/mm-imx3.c
index a8983b9778d..9d2c843bde0 100644
--- a/arch/arm/mach-imx/mm-imx3.c
+++ b/arch/arm/mach-imx/mm-imx3.c
@@ -30,7 +30,6 @@
30#include <mach/devices-common.h> 30#include <mach/devices-common.h>
31#include <mach/hardware.h> 31#include <mach/hardware.h>
32#include <mach/iomux-v3.h> 32#include <mach/iomux-v3.h>
33#include <mach/irqs.h>
34 33
35#include "crmregs-imx3.h" 34#include "crmregs-imx3.h"
36 35
@@ -273,10 +272,9 @@ void __init imx35_soc_init(void)
273 272
274 imx3_init_l2x0(); 273 imx3_init_l2x0();
275 274
276 /* i.mx35 has the i.mx31 type gpio */ 275 mxc_register_gpio("imx35-gpio", 0, MX35_GPIO1_BASE_ADDR, SZ_16K, MX35_INT_GPIO1, 0);
277 mxc_register_gpio("imx31-gpio", 0, MX35_GPIO1_BASE_ADDR, SZ_16K, MX35_INT_GPIO1, 0); 276 mxc_register_gpio("imx35-gpio", 1, MX35_GPIO2_BASE_ADDR, SZ_16K, MX35_INT_GPIO2, 0);
278 mxc_register_gpio("imx31-gpio", 1, MX35_GPIO2_BASE_ADDR, SZ_16K, MX35_INT_GPIO2, 0); 277 mxc_register_gpio("imx35-gpio", 2, MX35_GPIO3_BASE_ADDR, SZ_16K, MX35_INT_GPIO3, 0);
279 mxc_register_gpio("imx31-gpio", 2, MX35_GPIO3_BASE_ADDR, SZ_16K, MX35_INT_GPIO3, 0);
280 278
281 pinctrl_provide_dummies(); 279 pinctrl_provide_dummies();
282 if (to_version == 1) { 280 if (to_version == 1) {
diff --git a/arch/arm/mach-imx/mm-imx5.c b/arch/arm/mach-imx/mm-imx5.c
index 1d003053d56..52d8f534be1 100644
--- a/arch/arm/mach-imx/mm-imx5.c
+++ b/arch/arm/mach-imx/mm-imx5.c
@@ -16,7 +16,6 @@
16#include <linux/clk.h> 16#include <linux/clk.h>
17#include <linux/pinctrl/machine.h> 17#include <linux/pinctrl/machine.h>
18 18
19#include <asm/system_misc.h>
20#include <asm/mach/map.h> 19#include <asm/mach/map.h>
21 20
22#include <mach/hardware.h> 21#include <mach/hardware.h>
@@ -24,24 +23,6 @@
24#include <mach/devices-common.h> 23#include <mach/devices-common.h>
25#include <mach/iomux-v3.h> 24#include <mach/iomux-v3.h>
26 25
27static struct clk *gpc_dvfs_clk;
28
29static void imx5_idle(void)
30{
31 /* gpc clock is needed for SRPG */
32 if (gpc_dvfs_clk == NULL) {
33 gpc_dvfs_clk = clk_get(NULL, "gpc_dvfs");
34 if (IS_ERR(gpc_dvfs_clk))
35 return;
36 clk_prepare(gpc_dvfs_clk);
37 }
38 clk_enable(gpc_dvfs_clk);
39 mx5_cpu_lp_set(WAIT_UNCLOCKED_POWER_OFF);
40 if (!tzic_enable_wake())
41 cpu_do_idle();
42 clk_disable(gpc_dvfs_clk);
43}
44
45/* 26/*
46 * Define the MX50 memory map. 27 * Define the MX50 memory map.
47 */ 28 */
@@ -105,7 +86,6 @@ void __init imx51_init_early(void)
105 mxc_set_cpu_type(MXC_CPU_MX51); 86 mxc_set_cpu_type(MXC_CPU_MX51);
106 mxc_iomux_v3_init(MX51_IO_ADDRESS(MX51_IOMUXC_BASE_ADDR)); 87 mxc_iomux_v3_init(MX51_IO_ADDRESS(MX51_IOMUXC_BASE_ADDR));
107 mxc_arch_reset_init(MX51_IO_ADDRESS(MX51_WDOG1_BASE_ADDR)); 88 mxc_arch_reset_init(MX51_IO_ADDRESS(MX51_WDOG1_BASE_ADDR));
108 arm_pm_idle = imx5_idle;
109} 89}
110 90
111void __init imx53_init_early(void) 91void __init imx53_init_early(void)
@@ -181,13 +161,13 @@ static const struct resource imx53_audmux_res[] __initconst = {
181 161
182void __init imx50_soc_init(void) 162void __init imx50_soc_init(void)
183{ 163{
184 /* i.mx50 has the i.mx31 type gpio */ 164 /* i.mx50 has the i.mx35 type gpio */
185 mxc_register_gpio("imx31-gpio", 0, MX50_GPIO1_BASE_ADDR, SZ_16K, MX50_INT_GPIO1_LOW, MX50_INT_GPIO1_HIGH); 165 mxc_register_gpio("imx35-gpio", 0, MX50_GPIO1_BASE_ADDR, SZ_16K, MX50_INT_GPIO1_LOW, MX50_INT_GPIO1_HIGH);
186 mxc_register_gpio("imx31-gpio", 1, MX50_GPIO2_BASE_ADDR, SZ_16K, MX50_INT_GPIO2_LOW, MX50_INT_GPIO2_HIGH); 166 mxc_register_gpio("imx35-gpio", 1, MX50_GPIO2_BASE_ADDR, SZ_16K, MX50_INT_GPIO2_LOW, MX50_INT_GPIO2_HIGH);
187 mxc_register_gpio("imx31-gpio", 2, MX50_GPIO3_BASE_ADDR, SZ_16K, MX50_INT_GPIO3_LOW, MX50_INT_GPIO3_HIGH); 167 mxc_register_gpio("imx35-gpio", 2, MX50_GPIO3_BASE_ADDR, SZ_16K, MX50_INT_GPIO3_LOW, MX50_INT_GPIO3_HIGH);
188 mxc_register_gpio("imx31-gpio", 3, MX50_GPIO4_BASE_ADDR, SZ_16K, MX50_INT_GPIO4_LOW, MX50_INT_GPIO4_HIGH); 168 mxc_register_gpio("imx35-gpio", 3, MX50_GPIO4_BASE_ADDR, SZ_16K, MX50_INT_GPIO4_LOW, MX50_INT_GPIO4_HIGH);
189 mxc_register_gpio("imx31-gpio", 4, MX50_GPIO5_BASE_ADDR, SZ_16K, MX50_INT_GPIO5_LOW, MX50_INT_GPIO5_HIGH); 169 mxc_register_gpio("imx35-gpio", 4, MX50_GPIO5_BASE_ADDR, SZ_16K, MX50_INT_GPIO5_LOW, MX50_INT_GPIO5_HIGH);
190 mxc_register_gpio("imx31-gpio", 5, MX50_GPIO6_BASE_ADDR, SZ_16K, MX50_INT_GPIO6_LOW, MX50_INT_GPIO6_HIGH); 170 mxc_register_gpio("imx35-gpio", 5, MX50_GPIO6_BASE_ADDR, SZ_16K, MX50_INT_GPIO6_LOW, MX50_INT_GPIO6_HIGH);
191 171
192 /* i.mx50 has the i.mx31 type audmux */ 172 /* i.mx50 has the i.mx31 type audmux */
193 platform_device_register_simple("imx31-audmux", 0, imx50_audmux_res, 173 platform_device_register_simple("imx31-audmux", 0, imx50_audmux_res,
@@ -196,11 +176,11 @@ void __init imx50_soc_init(void)
196 176
197void __init imx51_soc_init(void) 177void __init imx51_soc_init(void)
198{ 178{
199 /* i.mx51 has the i.mx31 type gpio */ 179 /* i.mx51 has the i.mx35 type gpio */
200 mxc_register_gpio("imx31-gpio", 0, MX51_GPIO1_BASE_ADDR, SZ_16K, MX51_INT_GPIO1_LOW, MX51_INT_GPIO1_HIGH); 180 mxc_register_gpio("imx35-gpio", 0, MX51_GPIO1_BASE_ADDR, SZ_16K, MX51_INT_GPIO1_LOW, MX51_INT_GPIO1_HIGH);
201 mxc_register_gpio("imx31-gpio", 1, MX51_GPIO2_BASE_ADDR, SZ_16K, MX51_INT_GPIO2_LOW, MX51_INT_GPIO2_HIGH); 181 mxc_register_gpio("imx35-gpio", 1, MX51_GPIO2_BASE_ADDR, SZ_16K, MX51_INT_GPIO2_LOW, MX51_INT_GPIO2_HIGH);
202 mxc_register_gpio("imx31-gpio", 2, MX51_GPIO3_BASE_ADDR, SZ_16K, MX51_INT_GPIO3_LOW, MX51_INT_GPIO3_HIGH); 182 mxc_register_gpio("imx35-gpio", 2, MX51_GPIO3_BASE_ADDR, SZ_16K, MX51_INT_GPIO3_LOW, MX51_INT_GPIO3_HIGH);
203 mxc_register_gpio("imx31-gpio", 3, MX51_GPIO4_BASE_ADDR, SZ_16K, MX51_INT_GPIO4_LOW, MX51_INT_GPIO4_HIGH); 183 mxc_register_gpio("imx35-gpio", 3, MX51_GPIO4_BASE_ADDR, SZ_16K, MX51_INT_GPIO4_LOW, MX51_INT_GPIO4_HIGH);
204 184
205 pinctrl_provide_dummies(); 185 pinctrl_provide_dummies();
206 186
@@ -218,14 +198,14 @@ void __init imx51_soc_init(void)
218 198
219void __init imx53_soc_init(void) 199void __init imx53_soc_init(void)
220{ 200{
221 /* i.mx53 has the i.mx31 type gpio */ 201 /* i.mx53 has the i.mx35 type gpio */
222 mxc_register_gpio("imx31-gpio", 0, MX53_GPIO1_BASE_ADDR, SZ_16K, MX53_INT_GPIO1_LOW, MX53_INT_GPIO1_HIGH); 202 mxc_register_gpio("imx35-gpio", 0, MX53_GPIO1_BASE_ADDR, SZ_16K, MX53_INT_GPIO1_LOW, MX53_INT_GPIO1_HIGH);
223 mxc_register_gpio("imx31-gpio", 1, MX53_GPIO2_BASE_ADDR, SZ_16K, MX53_INT_GPIO2_LOW, MX53_INT_GPIO2_HIGH); 203 mxc_register_gpio("imx35-gpio", 1, MX53_GPIO2_BASE_ADDR, SZ_16K, MX53_INT_GPIO2_LOW, MX53_INT_GPIO2_HIGH);
224 mxc_register_gpio("imx31-gpio", 2, MX53_GPIO3_BASE_ADDR, SZ_16K, MX53_INT_GPIO3_LOW, MX53_INT_GPIO3_HIGH); 204 mxc_register_gpio("imx35-gpio", 2, MX53_GPIO3_BASE_ADDR, SZ_16K, MX53_INT_GPIO3_LOW, MX53_INT_GPIO3_HIGH);
225 mxc_register_gpio("imx31-gpio", 3, MX53_GPIO4_BASE_ADDR, SZ_16K, MX53_INT_GPIO4_LOW, MX53_INT_GPIO4_HIGH); 205 mxc_register_gpio("imx35-gpio", 3, MX53_GPIO4_BASE_ADDR, SZ_16K, MX53_INT_GPIO4_LOW, MX53_INT_GPIO4_HIGH);
226 mxc_register_gpio("imx31-gpio", 4, MX53_GPIO5_BASE_ADDR, SZ_16K, MX53_INT_GPIO5_LOW, MX53_INT_GPIO5_HIGH); 206 mxc_register_gpio("imx35-gpio", 4, MX53_GPIO5_BASE_ADDR, SZ_16K, MX53_INT_GPIO5_LOW, MX53_INT_GPIO5_HIGH);
227 mxc_register_gpio("imx31-gpio", 5, MX53_GPIO6_BASE_ADDR, SZ_16K, MX53_INT_GPIO6_LOW, MX53_INT_GPIO6_HIGH); 207 mxc_register_gpio("imx35-gpio", 5, MX53_GPIO6_BASE_ADDR, SZ_16K, MX53_INT_GPIO6_LOW, MX53_INT_GPIO6_HIGH);
228 mxc_register_gpio("imx31-gpio", 6, MX53_GPIO7_BASE_ADDR, SZ_16K, MX53_INT_GPIO7_LOW, MX53_INT_GPIO7_HIGH); 208 mxc_register_gpio("imx35-gpio", 6, MX53_GPIO7_BASE_ADDR, SZ_16K, MX53_INT_GPIO7_LOW, MX53_INT_GPIO7_HIGH);
229 209
230 pinctrl_provide_dummies(); 210 pinctrl_provide_dummies();
231 /* i.mx53 has the i.mx35 type sdma */ 211 /* i.mx53 has the i.mx35 type sdma */
@@ -243,4 +223,10 @@ void __init imx53_soc_init(void)
243void __init imx51_init_late(void) 223void __init imx51_init_late(void)
244{ 224{
245 mx51_neon_fixup(); 225 mx51_neon_fixup();
226 imx51_pm_init();
227}
228
229void __init imx53_init_late(void)
230{
231 imx53_pm_init();
246} 232}
diff --git a/arch/arm/mach-imx/mx31lilly-db.c b/arch/arm/mach-imx/mx31lilly-db.c
index 7d26f766a4e..29e890f9205 100644
--- a/arch/arm/mach-imx/mx31lilly-db.c
+++ b/arch/arm/mach-imx/mx31lilly-db.c
@@ -130,7 +130,8 @@ static int mxc_mmc1_init(struct device *dev,
130 gpio_direction_input(gpio_det); 130 gpio_direction_input(gpio_det);
131 gpio_direction_input(gpio_wp); 131 gpio_direction_input(gpio_wp);
132 132
133 ret = request_irq(IOMUX_TO_IRQ(MX31_PIN_GPIO1_1), detect_irq, 133 ret = request_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)),
134 detect_irq,
134 IRQF_DISABLED | IRQF_TRIGGER_FALLING, 135 IRQF_DISABLED | IRQF_TRIGGER_FALLING,
135 "MMC detect", data); 136 "MMC detect", data);
136 if (ret) 137 if (ret)
@@ -151,7 +152,7 @@ static void mxc_mmc1_exit(struct device *dev, void *data)
151{ 152{
152 gpio_free(gpio_det); 153 gpio_free(gpio_det);
153 gpio_free(gpio_wp); 154 gpio_free(gpio_wp);
154 free_irq(IOMUX_TO_IRQ(MX31_PIN_GPIO1_1), data); 155 free_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)), data);
155} 156}
156 157
157static const struct imxmmc_platform_data mmc_pdata __initconst = { 158static const struct imxmmc_platform_data mmc_pdata __initconst = {
@@ -161,10 +162,6 @@ static const struct imxmmc_platform_data mmc_pdata __initconst = {
161}; 162};
162 163
163/* Framebuffer support */ 164/* Framebuffer support */
164static const struct ipu_platform_data ipu_data __initconst = {
165 .irq_base = MXC_IPU_IRQ_START,
166};
167
168static const struct fb_videomode fb_modedb = { 165static const struct fb_videomode fb_modedb = {
169 /* 640x480 TFT panel (IPS-056T) */ 166 /* 640x480 TFT panel (IPS-056T) */
170 .name = "CRT-VGA", 167 .name = "CRT-VGA",
@@ -198,7 +195,7 @@ static void __init mx31lilly_init_fb(void)
198 return; 195 return;
199 } 196 }
200 197
201 imx31_add_ipu_core(&ipu_data); 198 imx31_add_ipu_core();
202 imx31_add_mx3_sdc_fb(&fb_pdata); 199 imx31_add_mx3_sdc_fb(&fb_pdata);
203 gpio_direction_output(LCD_VCC_EN_GPIO, 1); 200 gpio_direction_output(LCD_VCC_EN_GPIO, 1);
204} 201}
diff --git a/arch/arm/mach-imx/mx31lite-db.c b/arch/arm/mach-imx/mx31lite-db.c
index bf0fb87946b..83d17d9e0bc 100644
--- a/arch/arm/mach-imx/mx31lite-db.c
+++ b/arch/arm/mach-imx/mx31lite-db.c
@@ -116,7 +116,8 @@ static int mxc_mmc1_init(struct device *dev,
116 gpio_direction_input(gpio_det); 116 gpio_direction_input(gpio_det);
117 gpio_direction_input(gpio_wp); 117 gpio_direction_input(gpio_wp);
118 118
119 ret = request_irq(IOMUX_TO_IRQ(MX31_PIN_DCD_DCE1), detect_irq, 119 ret = request_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)),
120 detect_irq,
120 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 121 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
121 "MMC detect", data); 122 "MMC detect", data);
122 if (ret) 123 if (ret)
@@ -137,7 +138,7 @@ static void mxc_mmc1_exit(struct device *dev, void *data)
137{ 138{
138 gpio_free(gpio_det); 139 gpio_free(gpio_det);
139 gpio_free(gpio_wp); 140 gpio_free(gpio_wp);
140 free_irq(IOMUX_TO_IRQ(MX31_PIN_DCD_DCE1), data); 141 free_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)), data);
141} 142}
142 143
143static const struct imxmmc_platform_data mmc_pdata __initconst = { 144static const struct imxmmc_platform_data mmc_pdata __initconst = {
@@ -191,6 +192,6 @@ void __init mx31lite_db_init(void)
191 imx31_add_mxc_mmc(0, &mmc_pdata); 192 imx31_add_mxc_mmc(0, &mmc_pdata);
192 imx31_add_spi_imx0(&spi0_pdata); 193 imx31_add_spi_imx0(&spi0_pdata);
193 gpio_led_register_device(-1, &litekit_led_platform_data); 194 gpio_led_register_device(-1, &litekit_led_platform_data);
194 imx31_add_imx2_wdt(NULL); 195 imx31_add_imx2_wdt();
195 imx31_add_mxc_rtc(NULL); 196 imx31_add_mxc_rtc();
196} 197}
diff --git a/arch/arm/mach-imx/mx51_efika.c b/arch/arm/mach-imx/mx51_efika.c
index ec6ca91b299..ee870c49bc6 100644
--- a/arch/arm/mach-imx/mx51_efika.c
+++ b/arch/arm/mach-imx/mx51_efika.c
@@ -587,7 +587,7 @@ static struct spi_board_info mx51_efika_spi_board_info[] __initdata = {
587 .bus_num = 0, 587 .bus_num = 0,
588 .chip_select = 0, 588 .chip_select = 0,
589 .platform_data = &mx51_efika_mc13892_data, 589 .platform_data = &mx51_efika_mc13892_data,
590 .irq = IMX_GPIO_TO_IRQ(EFIKAMX_PMIC), 590 /* irq number is run-time assigned */
591 }, 591 },
592}; 592};
593 593
@@ -620,6 +620,7 @@ void __init efika_board_common_init(void)
620 620
621 gpio_request(EFIKAMX_PMIC, "pmic irq"); 621 gpio_request(EFIKAMX_PMIC, "pmic irq");
622 gpio_direction_input(EFIKAMX_PMIC); 622 gpio_direction_input(EFIKAMX_PMIC);
623 mx51_efika_spi_board_info[1].irq = gpio_to_irq(EFIKAMX_PMIC);
623 spi_register_board_info(mx51_efika_spi_board_info, 624 spi_register_board_info(mx51_efika_spi_board_info,
624 ARRAY_SIZE(mx51_efika_spi_board_info)); 625 ARRAY_SIZE(mx51_efika_spi_board_info));
625 imx51_add_ecspi(0, &mx51_efika_spi_pdata); 626 imx51_add_ecspi(0, &mx51_efika_spi_pdata);
diff --git a/arch/arm/mach-imx/pcm970-baseboard.c b/arch/arm/mach-imx/pcm970-baseboard.c
index 99afbc3f43a..9917e2ff51d 100644
--- a/arch/arm/mach-imx/pcm970-baseboard.c
+++ b/arch/arm/mach-imx/pcm970-baseboard.c
@@ -95,14 +95,14 @@ static int pcm970_sdhc2_init(struct device *dev, irq_handler_t detect_irq, void
95{ 95{
96 int ret; 96 int ret;
97 97
98 ret = request_irq(IRQ_GPIOC(29), detect_irq, IRQF_TRIGGER_FALLING, 98 ret = request_irq(gpio_to_irq(IMX_GPIO_NR(3, 29)), detect_irq,
99 "imx-mmc-detect", data); 99 IRQF_TRIGGER_FALLING, "imx-mmc-detect", data);
100 if (ret) 100 if (ret)
101 return ret; 101 return ret;
102 102
103 ret = gpio_request(GPIO_PORTC + 28, "imx-mmc-ro"); 103 ret = gpio_request(GPIO_PORTC + 28, "imx-mmc-ro");
104 if (ret) { 104 if (ret) {
105 free_irq(IRQ_GPIOC(29), data); 105 free_irq(gpio_to_irq(IMX_GPIO_NR(3, 29)), data);
106 return ret; 106 return ret;
107 } 107 }
108 108
@@ -113,7 +113,7 @@ static int pcm970_sdhc2_init(struct device *dev, irq_handler_t detect_irq, void
113 113
114static void pcm970_sdhc2_exit(struct device *dev, void *data) 114static void pcm970_sdhc2_exit(struct device *dev, void *data)
115{ 115{
116 free_irq(IRQ_GPIOC(29), data); 116 free_irq(gpio_to_irq(IMX_GPIO_NR(3, 29)), data);
117 gpio_free(GPIO_PORTC + 28); 117 gpio_free(GPIO_PORTC + 28);
118} 118}
119 119
@@ -192,8 +192,7 @@ static struct resource pcm970_sja1000_resources[] = {
192 .end = MX27_CS4_BASE_ADDR + 0x100 - 1, 192 .end = MX27_CS4_BASE_ADDR + 0x100 - 1,
193 .flags = IORESOURCE_MEM, 193 .flags = IORESOURCE_MEM,
194 }, { 194 }, {
195 .start = IRQ_GPIOE(19), 195 /* irq number is run-time assigned */
196 .end = IRQ_GPIOE(19),
197 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE, 196 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
198 }, 197 },
199}; 198};
@@ -227,5 +226,7 @@ void __init pcm970_baseboard_init(void)
227 imx27_add_imx_fb(&pcm038_fb_data); 226 imx27_add_imx_fb(&pcm038_fb_data);
228 mxc_gpio_mode(GPIO_PORTC | 28 | GPIO_GPIO | GPIO_IN); 227 mxc_gpio_mode(GPIO_PORTC | 28 | GPIO_GPIO | GPIO_IN);
229 imx27_add_mxc_mmc(1, &sdhc_pdata); 228 imx27_add_mxc_mmc(1, &sdhc_pdata);
229 pcm970_sja1000_resources[1].start = gpio_to_irq(IMX_GPIO_NR(5, 19));
230 pcm970_sja1000_resources[1].end = gpio_to_irq(IMX_GPIO_NR(5, 19));
230 platform_device_register(&pcm970_sja1000); 231 platform_device_register(&pcm970_sja1000);
231} 232}
diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c
index e26a9cb05ed..19621ed1ffa 100644
--- a/arch/arm/mach-imx/pm-imx5.c
+++ b/arch/arm/mach-imx/pm-imx5.c
@@ -12,19 +12,30 @@
12#include <linux/clk.h> 12#include <linux/clk.h>
13#include <linux/io.h> 13#include <linux/io.h>
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/export.h>
15#include <asm/cacheflush.h> 16#include <asm/cacheflush.h>
17#include <asm/system_misc.h>
16#include <asm/tlbflush.h> 18#include <asm/tlbflush.h>
17#include <mach/common.h> 19#include <mach/common.h>
20#include <mach/cpuidle.h>
18#include <mach/hardware.h> 21#include <mach/hardware.h>
19#include "crm-regs-imx5.h" 22#include "crm-regs-imx5.h"
20 23
21static struct clk *gpc_dvfs_clk; 24/*
25 * The WAIT_UNCLOCKED_POWER_OFF state only requires <= 500ns to exit.
26 * This is also the lowest power state possible without affecting
27 * non-cpu parts of the system. For these reasons, imx5 should default
28 * to always using this state for cpu idling. The PM_SUSPEND_STANDBY also
29 * uses this state and needs to take no action when registers remain confgiured
30 * for this state.
31 */
32#define IMX5_DEFAULT_CPU_IDLE_STATE WAIT_UNCLOCKED_POWER_OFF
22 33
23/* 34/*
24 * set cpu low power mode before WFI instruction. This function is called 35 * set cpu low power mode before WFI instruction. This function is called
25 * mx5 because it can be used for mx50, mx51, and mx53. 36 * mx5 because it can be used for mx50, mx51, and mx53.
26 */ 37 */
27void mx5_cpu_lp_set(enum mxc_cpu_pwr_mode mode) 38static void mx5_cpu_lp_set(enum mxc_cpu_pwr_mode mode)
28{ 39{
29 u32 plat_lpc, arm_srpgcr, ccm_clpcr; 40 u32 plat_lpc, arm_srpgcr, ccm_clpcr;
30 u32 empgc0, empgc1; 41 u32 empgc0, empgc1;
@@ -87,11 +98,6 @@ void mx5_cpu_lp_set(enum mxc_cpu_pwr_mode mode)
87 } 98 }
88} 99}
89 100
90static int mx5_suspend_prepare(void)
91{
92 return clk_prepare_enable(gpc_dvfs_clk);
93}
94
95static int mx5_suspend_enter(suspend_state_t state) 101static int mx5_suspend_enter(suspend_state_t state)
96{ 102{
97 switch (state) { 103 switch (state) {
@@ -99,7 +105,7 @@ static int mx5_suspend_enter(suspend_state_t state)
99 mx5_cpu_lp_set(STOP_POWER_OFF); 105 mx5_cpu_lp_set(STOP_POWER_OFF);
100 break; 106 break;
101 case PM_SUSPEND_STANDBY: 107 case PM_SUSPEND_STANDBY:
102 mx5_cpu_lp_set(WAIT_UNCLOCKED_POWER_OFF); 108 /* DEFAULT_IDLE_STATE already configured */
103 break; 109 break;
104 default: 110 default:
105 return -EINVAL; 111 return -EINVAL;
@@ -114,12 +120,10 @@ static int mx5_suspend_enter(suspend_state_t state)
114 __raw_writel(0, MXC_SRPG_EMPGC1_SRPGCR); 120 __raw_writel(0, MXC_SRPG_EMPGC1_SRPGCR);
115 } 121 }
116 cpu_do_idle(); 122 cpu_do_idle();
117 return 0;
118}
119 123
120static void mx5_suspend_finish(void) 124 /* return registers to default idle state */
121{ 125 mx5_cpu_lp_set(IMX5_DEFAULT_CPU_IDLE_STATE);
122 clk_disable_unprepare(gpc_dvfs_clk); 126 return 0;
123} 127}
124 128
125static int mx5_pm_valid(suspend_state_t state) 129static int mx5_pm_valid(suspend_state_t state)
@@ -129,25 +133,80 @@ static int mx5_pm_valid(suspend_state_t state)
129 133
130static const struct platform_suspend_ops mx5_suspend_ops = { 134static const struct platform_suspend_ops mx5_suspend_ops = {
131 .valid = mx5_pm_valid, 135 .valid = mx5_pm_valid,
132 .prepare = mx5_suspend_prepare,
133 .enter = mx5_suspend_enter, 136 .enter = mx5_suspend_enter,
134 .finish = mx5_suspend_finish,
135}; 137};
136 138
137static int __init mx5_pm_init(void) 139static inline int imx5_cpu_do_idle(void)
140{
141 int ret = tzic_enable_wake();
142
143 if (likely(!ret))
144 cpu_do_idle();
145
146 return ret;
147}
148
149static void imx5_pm_idle(void)
150{
151 imx5_cpu_do_idle();
152}
153
154static int imx5_cpuidle_enter(struct cpuidle_device *dev,
155 struct cpuidle_driver *drv, int idx)
156{
157 int ret;
158
159 ret = imx5_cpu_do_idle();
160 if (ret < 0)
161 return ret;
162
163 return idx;
164}
165
166static struct cpuidle_driver imx5_cpuidle_driver = {
167 .name = "imx5_cpuidle",
168 .owner = THIS_MODULE,
169 .en_core_tk_irqen = 1,
170 .states[0] = {
171 .enter = imx5_cpuidle_enter,
172 .exit_latency = 2,
173 .target_residency = 1,
174 .flags = CPUIDLE_FLAG_TIME_VALID,
175 .name = "IMX5 SRPG",
176 .desc = "CPU state retained,powered off",
177 },
178 .state_count = 1,
179};
180
181static int __init imx5_pm_common_init(void)
138{ 182{
139 if (!cpu_is_mx51() && !cpu_is_mx53()) 183 int ret;
140 return 0; 184 struct clk *gpc_dvfs_clk = clk_get(NULL, "gpc_dvfs");
141 185
142 if (gpc_dvfs_clk == NULL) 186 if (IS_ERR(gpc_dvfs_clk))
143 gpc_dvfs_clk = clk_get(NULL, "gpc_dvfs"); 187 return PTR_ERR(gpc_dvfs_clk);
144 188
145 if (!IS_ERR(gpc_dvfs_clk)) { 189 ret = clk_prepare_enable(gpc_dvfs_clk);
146 if (cpu_is_mx51()) 190 if (ret)
147 suspend_set_ops(&mx5_suspend_ops); 191 return ret;
148 } else
149 return -EPERM;
150 192
193 arm_pm_idle = imx5_pm_idle;
194
195 /* Set the registers to the default cpu idle state. */
196 mx5_cpu_lp_set(IMX5_DEFAULT_CPU_IDLE_STATE);
197
198 imx_cpuidle_init(&imx5_cpuidle_driver);
151 return 0; 199 return 0;
152} 200}
153device_initcall(mx5_pm_init); 201
202void __init imx51_pm_init(void)
203{
204 int ret = imx5_pm_common_init();
205 if (!ret)
206 suspend_set_ops(&mx5_suspend_ops);
207}
208
209void __init imx53_pm_init(void)
210{
211 imx5_pm_common_init();
212}
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
index eaf6c6366ff..3fa6c51390d 100644
--- a/arch/arm/mach-integrator/core.c
+++ b/arch/arm/mach-integrator/core.c
@@ -11,6 +11,7 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/export.h>
14#include <linux/spinlock.h> 15#include <linux/spinlock.h>
15#include <linux/interrupt.h> 16#include <linux/interrupt.h>
16#include <linux/irq.h> 17#include <linux/irq.h>
@@ -21,7 +22,6 @@
21#include <linux/amba/bus.h> 22#include <linux/amba/bus.h>
22#include <linux/amba/serial.h> 23#include <linux/amba/serial.h>
23#include <linux/io.h> 24#include <linux/io.h>
24#include <linux/clkdev.h>
25 25
26#include <mach/hardware.h> 26#include <mach/hardware.h>
27#include <mach/platform.h> 27#include <mach/platform.h>
@@ -41,17 +41,17 @@ static struct amba_pl010_data integrator_uart_data;
41#define KMI0_IRQ { IRQ_KMIINT0 } 41#define KMI0_IRQ { IRQ_KMIINT0 }
42#define KMI1_IRQ { IRQ_KMIINT1 } 42#define KMI1_IRQ { IRQ_KMIINT1 }
43 43
44static AMBA_APB_DEVICE(rtc, "mb:15", 0, 44static AMBA_APB_DEVICE(rtc, "rtc", 0,
45 INTEGRATOR_RTC_BASE, INTEGRATOR_RTC_IRQ, NULL); 45 INTEGRATOR_RTC_BASE, INTEGRATOR_RTC_IRQ, NULL);
46 46
47static AMBA_APB_DEVICE(uart0, "mb:16", 0, 47static AMBA_APB_DEVICE(uart0, "uart0", 0,
48 INTEGRATOR_UART0_BASE, INTEGRATOR_UART0_IRQ, &integrator_uart_data); 48 INTEGRATOR_UART0_BASE, INTEGRATOR_UART0_IRQ, &integrator_uart_data);
49 49
50static AMBA_APB_DEVICE(uart1, "mb:17", 0, 50static AMBA_APB_DEVICE(uart1, "uart1", 0,
51 INTEGRATOR_UART1_BASE, INTEGRATOR_UART1_IRQ, &integrator_uart_data); 51 INTEGRATOR_UART1_BASE, INTEGRATOR_UART1_IRQ, &integrator_uart_data);
52 52
53static AMBA_APB_DEVICE(kmi0, "mb:18", 0, KMI0_BASE, KMI0_IRQ, NULL); 53static AMBA_APB_DEVICE(kmi0, "kmi0", 0, KMI0_BASE, KMI0_IRQ, NULL);
54static AMBA_APB_DEVICE(kmi1, "mb:19", 0, KMI1_BASE, KMI1_IRQ, NULL); 54static AMBA_APB_DEVICE(kmi1, "kmi1", 0, KMI1_BASE, KMI1_IRQ, NULL);
55 55
56static struct amba_device *amba_devs[] __initdata = { 56static struct amba_device *amba_devs[] __initdata = {
57 &rtc_device, 57 &rtc_device,
@@ -61,50 +61,6 @@ static struct amba_device *amba_devs[] __initdata = {
61 &kmi1_device, 61 &kmi1_device,
62}; 62};
63 63
64/*
65 * These are fixed clocks.
66 */
67static struct clk clk24mhz = {
68 .rate = 24000000,
69};
70
71static struct clk uartclk = {
72 .rate = 14745600,
73};
74
75static struct clk dummy_apb_pclk;
76
77static struct clk_lookup lookups[] = {
78 { /* Bus clock */
79 .con_id = "apb_pclk",
80 .clk = &dummy_apb_pclk,
81 }, {
82 /* Integrator/AP timer frequency */
83 .dev_id = "ap_timer",
84 .clk = &clk24mhz,
85 }, { /* UART0 */
86 .dev_id = "mb:16",
87 .clk = &uartclk,
88 }, { /* UART1 */
89 .dev_id = "mb:17",
90 .clk = &uartclk,
91 }, { /* KMI0 */
92 .dev_id = "mb:18",
93 .clk = &clk24mhz,
94 }, { /* KMI1 */
95 .dev_id = "mb:19",
96 .clk = &clk24mhz,
97 }, { /* MMCI - IntegratorCP */
98 .dev_id = "mb:1c",
99 .clk = &uartclk,
100 }
101};
102
103void __init integrator_init_early(void)
104{
105 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
106}
107
108static int __init integrator_init(void) 64static int __init integrator_init(void)
109{ 65{
110 int i; 66 int i;
diff --git a/arch/arm/mach-integrator/include/mach/clkdev.h b/arch/arm/mach-integrator/include/mach/clkdev.h
deleted file mode 100644
index bfe07679fae..00000000000
--- a/arch/arm/mach-integrator/include/mach/clkdev.h
+++ /dev/null
@@ -1,26 +0,0 @@
1#ifndef __ASM_MACH_CLKDEV_H
2#define __ASM_MACH_CLKDEV_H
3
4#include <linux/module.h>
5#include <plat/clock.h>
6
7struct clk {
8 unsigned long rate;
9 const struct clk_ops *ops;
10 struct module *owner;
11 const struct icst_params *params;
12 void __iomem *vcoreg;
13 void *data;
14};
15
16static inline int __clk_get(struct clk *clk)
17{
18 return try_module_get(clk->owner);
19}
20
21static inline void __clk_put(struct clk *clk)
22{
23 module_put(clk->owner);
24}
25
26#endif
diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c
index c857501c578..3b2267529f5 100644
--- a/arch/arm/mach-integrator/integrator_ap.c
+++ b/arch/arm/mach-integrator/integrator_ap.c
@@ -33,6 +33,7 @@
33#include <linux/io.h> 33#include <linux/io.h>
34#include <linux/mtd/physmap.h> 34#include <linux/mtd/physmap.h>
35#include <linux/clk.h> 35#include <linux/clk.h>
36#include <linux/platform_data/clk-integrator.h>
36#include <video/vga.h> 37#include <video/vga.h>
37 38
38#include <mach/hardware.h> 39#include <mach/hardware.h>
@@ -174,6 +175,7 @@ static void __init ap_init_irq(void)
174 175
175 fpga_irq_init(VA_IC_BASE, "SC", IRQ_PIC_START, 176 fpga_irq_init(VA_IC_BASE, "SC", IRQ_PIC_START,
176 -1, INTEGRATOR_SC_VALID_INT, NULL); 177 -1, INTEGRATOR_SC_VALID_INT, NULL);
178 integrator_clk_init(false);
177} 179}
178 180
179#ifdef CONFIG_PM 181#ifdef CONFIG_PM
@@ -440,6 +442,10 @@ static void integrator_clockevent_init(unsigned long inrate)
440 0xffffU); 442 0xffffU);
441} 443}
442 444
445void __init ap_init_early(void)
446{
447}
448
443/* 449/*
444 * Set up timer(s). 450 * Set up timer(s).
445 */ 451 */
@@ -450,7 +456,7 @@ static void __init ap_init_timer(void)
450 456
451 clk = clk_get_sys("ap_timer", NULL); 457 clk = clk_get_sys("ap_timer", NULL);
452 BUG_ON(IS_ERR(clk)); 458 BUG_ON(IS_ERR(clk));
453 clk_enable(clk); 459 clk_prepare_enable(clk);
454 rate = clk_get_rate(clk); 460 rate = clk_get_rate(clk);
455 461
456 writel(0, TIMER0_VA_BASE + TIMER_CTRL); 462 writel(0, TIMER0_VA_BASE + TIMER_CTRL);
@@ -471,7 +477,7 @@ MACHINE_START(INTEGRATOR, "ARM-Integrator")
471 .reserve = integrator_reserve, 477 .reserve = integrator_reserve,
472 .map_io = ap_map_io, 478 .map_io = ap_map_io,
473 .nr_irqs = NR_IRQS_INTEGRATOR_AP, 479 .nr_irqs = NR_IRQS_INTEGRATOR_AP,
474 .init_early = integrator_init_early, 480 .init_early = ap_init_early,
475 .init_irq = ap_init_irq, 481 .init_irq = ap_init_irq,
476 .handle_irq = fpga_handle_irq, 482 .handle_irq = fpga_handle_irq,
477 .timer = &ap_timer, 483 .timer = &ap_timer,
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index a56c5360893..82d5c837cc7 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -21,8 +21,8 @@
21#include <linux/amba/mmci.h> 21#include <linux/amba/mmci.h>
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/gfp.h> 23#include <linux/gfp.h>
24#include <linux/clkdev.h>
25#include <linux/mtd/physmap.h> 24#include <linux/mtd/physmap.h>
25#include <linux/platform_data/clk-integrator.h>
26 26
27#include <mach/hardware.h> 27#include <mach/hardware.h>
28#include <mach/platform.h> 28#include <mach/platform.h>
@@ -171,65 +171,10 @@ static void __init intcp_init_irq(void)
171 171
172 fpga_irq_init(INTCP_VA_SIC_BASE, "SIC", IRQ_SIC_START, 172 fpga_irq_init(INTCP_VA_SIC_BASE, "SIC", IRQ_SIC_START,
173 IRQ_CP_CPPLDINT, sic_mask, NULL); 173 IRQ_CP_CPPLDINT, sic_mask, NULL);
174 integrator_clk_init(true);
174} 175}
175 176
176/* 177/*
177 * Clock handling
178 */
179#define CM_LOCK (__io_address(INTEGRATOR_HDR_BASE)+INTEGRATOR_HDR_LOCK_OFFSET)
180#define CM_AUXOSC (__io_address(INTEGRATOR_HDR_BASE)+0x1c)
181
182static const struct icst_params cp_auxvco_params = {
183 .ref = 24000000,
184 .vco_max = ICST525_VCO_MAX_5V,
185 .vco_min = ICST525_VCO_MIN,
186 .vd_min = 8,
187 .vd_max = 263,
188 .rd_min = 3,
189 .rd_max = 65,
190 .s2div = icst525_s2div,
191 .idx2s = icst525_idx2s,
192};
193
194static void cp_auxvco_set(struct clk *clk, struct icst_vco vco)
195{
196 u32 val;
197
198 val = readl(clk->vcoreg) & ~0x7ffff;
199 val |= vco.v | (vco.r << 9) | (vco.s << 16);
200
201 writel(0xa05f, CM_LOCK);
202 writel(val, clk->vcoreg);
203 writel(0, CM_LOCK);
204}
205
206static const struct clk_ops cp_auxclk_ops = {
207 .round = icst_clk_round,
208 .set = icst_clk_set,
209 .setvco = cp_auxvco_set,
210};
211
212static struct clk cp_auxclk = {
213 .ops = &cp_auxclk_ops,
214 .params = &cp_auxvco_params,
215 .vcoreg = CM_AUXOSC,
216};
217
218static struct clk sp804_clk = {
219 .rate = 1000000,
220};
221
222static struct clk_lookup cp_lookups[] = {
223 { /* CLCD */
224 .dev_id = "mb:c0",
225 .clk = &cp_auxclk,
226 }, { /* SP804 timers */
227 .dev_id = "sp804",
228 .clk = &sp804_clk,
229 },
230};
231
232/*
233 * Flash handling. 178 * Flash handling.
234 */ 179 */
235static int intcp_flash_init(struct platform_device *dev) 180static int intcp_flash_init(struct platform_device *dev)
@@ -336,10 +281,10 @@ static struct mmci_platform_data mmc_data = {
336#define INTEGRATOR_CP_MMC_IRQS { IRQ_CP_MMCIINT0, IRQ_CP_MMCIINT1 } 281#define INTEGRATOR_CP_MMC_IRQS { IRQ_CP_MMCIINT0, IRQ_CP_MMCIINT1 }
337#define INTEGRATOR_CP_AACI_IRQS { IRQ_CP_AACIINT } 282#define INTEGRATOR_CP_AACI_IRQS { IRQ_CP_AACIINT }
338 283
339static AMBA_APB_DEVICE(mmc, "mb:1c", 0, INTEGRATOR_CP_MMC_BASE, 284static AMBA_APB_DEVICE(mmc, "mmci", 0, INTEGRATOR_CP_MMC_BASE,
340 INTEGRATOR_CP_MMC_IRQS, &mmc_data); 285 INTEGRATOR_CP_MMC_IRQS, &mmc_data);
341 286
342static AMBA_APB_DEVICE(aaci, "mb:1d", 0, INTEGRATOR_CP_AACI_BASE, 287static AMBA_APB_DEVICE(aaci, "aaci", 0, INTEGRATOR_CP_AACI_BASE,
343 INTEGRATOR_CP_AACI_IRQS, NULL); 288 INTEGRATOR_CP_AACI_IRQS, NULL);
344 289
345 290
@@ -393,7 +338,7 @@ static struct clcd_board clcd_data = {
393 .remove = versatile_clcd_remove_dma, 338 .remove = versatile_clcd_remove_dma,
394}; 339};
395 340
396static AMBA_AHB_DEVICE(clcd, "mb:c0", 0, INTCP_PA_CLCD_BASE, 341static AMBA_AHB_DEVICE(clcd, "clcd", 0, INTCP_PA_CLCD_BASE,
397 { IRQ_CP_CLCDCINT }, &clcd_data); 342 { IRQ_CP_CLCDCINT }, &clcd_data);
398 343
399static struct amba_device *amba_devs[] __initdata = { 344static struct amba_device *amba_devs[] __initdata = {
@@ -406,10 +351,6 @@ static struct amba_device *amba_devs[] __initdata = {
406 351
407static void __init intcp_init_early(void) 352static void __init intcp_init_early(void)
408{ 353{
409 clkdev_add_table(cp_lookups, ARRAY_SIZE(cp_lookups));
410
411 integrator_init_early();
412
413#ifdef CONFIG_PLAT_VERSATILE_SCHED_CLOCK 354#ifdef CONFIG_PLAT_VERSATILE_SCHED_CLOCK
414 versatile_sched_clock_init(REFCOUNTER, 24000000); 355 versatile_sched_clock_init(REFCOUNTER, 24000000);
415#endif 356#endif
diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
index 199764fe0fb..ca5c15a4e62 100644
--- a/arch/arm/mach-kirkwood/Kconfig
+++ b/arch/arm/mach-kirkwood/Kconfig
@@ -80,6 +80,35 @@ config MACH_IB62X0_DT
80 RaidSonic IB-NAS6210 & IB-NAS6220 devices, using 80 RaidSonic IB-NAS6210 & IB-NAS6220 devices, using
81 Flattened Device Tree. 81 Flattened Device Tree.
82 82
83config MACH_TS219_DT
84 bool "Device Tree for QNAP TS-11X, TS-21X NAS"
85 select ARCH_KIRKWOOD_DT
86 select ARM_APPENDED_DTB
87 select ARM_ATAG_DTB_COMPAT
88 help
89 Say 'Y' here if you want your kernel to support the QNAP
90 TS-110, TS-119, TS-119P+, TS-210, TS-219, TS-219P and
91 TS-219P+ Turbo NAS devices using Fattened Device Tree.
92 There are two different Device Tree descriptions, depending
93 on if the device is based on an if the board uses the MV6281
94 or MV6282. If you have the wrong one, the buttons will not
95 work.
96
97config MACH_GOFLEXNET_DT
98 bool "Seagate GoFlex Net (Flattened Device Tree)"
99 select ARCH_KIRKWOOD_DT
100 help
101 Say 'Y' here if you want your kernel to support the
102 Seagate GoFlex Net (Flattened Device Tree).
103
104config MACH_LSXL_DT
105 bool "Buffalo Linkstation LS-XHL, LS-CHLv2 (Flattened Device Tree)"
106 select ARCH_KIRKWOOD_DT
107 help
108 Say 'Y' here if you want your kernel to support the
109 Buffalo Linkstation LS-XHL & LS-CHLv2 devices, using
110 Flattened Device Tree.
111
83config MACH_TS219 112config MACH_TS219
84 bool "QNAP TS-110, TS-119, TS-119P+, TS-210, TS-219, TS-219P and TS-219P+ Turbo NAS" 113 bool "QNAP TS-110, TS-119, TS-119P+, TS-210, TS-219, TS-219P and TS-219P+ Turbo NAS"
85 help 114 help
diff --git a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile
index d2b05907b10..055c85a1cc4 100644
--- a/arch/arm/mach-kirkwood/Makefile
+++ b/arch/arm/mach-kirkwood/Makefile
@@ -25,3 +25,6 @@ obj-$(CONFIG_MACH_DREAMPLUG_DT) += board-dreamplug.o
25obj-$(CONFIG_MACH_ICONNECT_DT) += board-iconnect.o 25obj-$(CONFIG_MACH_ICONNECT_DT) += board-iconnect.o
26obj-$(CONFIG_MACH_DLINK_KIRKWOOD_DT) += board-dnskw.o 26obj-$(CONFIG_MACH_DLINK_KIRKWOOD_DT) += board-dnskw.o
27obj-$(CONFIG_MACH_IB62X0_DT) += board-ib62x0.o 27obj-$(CONFIG_MACH_IB62X0_DT) += board-ib62x0.o
28obj-$(CONFIG_MACH_TS219_DT) += board-ts219.o tsx1x-common.o
29obj-$(CONFIG_MACH_GOFLEXNET_DT) += board-goflexnet.o
30obj-$(CONFIG_MACH_LSXL_DT) += board-lsxl.o
diff --git a/arch/arm/mach-kirkwood/Makefile.boot b/arch/arm/mach-kirkwood/Makefile.boot
index 02edbdf5b06..a13299d758e 100644
--- a/arch/arm/mach-kirkwood/Makefile.boot
+++ b/arch/arm/mach-kirkwood/Makefile.boot
@@ -7,3 +7,8 @@ dtb-$(CONFIG_MACH_DLINK_KIRKWOOD_DT) += kirkwood-dns320.dtb
7dtb-$(CONFIG_MACH_DLINK_KIRKWOOD_DT) += kirkwood-dns325.dtb 7dtb-$(CONFIG_MACH_DLINK_KIRKWOOD_DT) += kirkwood-dns325.dtb
8dtb-$(CONFIG_MACH_ICONNECT_DT) += kirkwood-iconnect.dtb 8dtb-$(CONFIG_MACH_ICONNECT_DT) += kirkwood-iconnect.dtb
9dtb-$(CONFIG_MACH_IB62X0_DT) += kirkwood-ib62x0.dtb 9dtb-$(CONFIG_MACH_IB62X0_DT) += kirkwood-ib62x0.dtb
10dtb-$(CONFIG_MACH_TS219_DT) += kirkwood-ts219-6281.dtb
11dtb-$(CONFIG_MACH_TS219_DT) += kirkwood-ts219-6282.dtb
12dtb-$(CONFIG_MACH_GOFLEXNET_DT) += kirkwood-goflexnet.dtb
13dtb-$(CONFIG_MACH_LSXL_DT) += kirkwood-lschlv2.dtb
14dtb-$(CONFIG_MACH_LSXL_DT) += kirkwood-lsxhl.dtb
diff --git a/arch/arm/mach-kirkwood/board-dnskw.c b/arch/arm/mach-kirkwood/board-dnskw.c
index 58c2d68f944..4ab35065a14 100644
--- a/arch/arm/mach-kirkwood/board-dnskw.c
+++ b/arch/arm/mach-kirkwood/board-dnskw.c
@@ -14,13 +14,11 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/i2c.h>
18#include <linux/ata_platform.h> 17#include <linux/ata_platform.h>
19#include <linux/mv643xx_eth.h> 18#include <linux/mv643xx_eth.h>
20#include <linux/of.h> 19#include <linux/of.h>
21#include <linux/gpio.h> 20#include <linux/gpio.h>
22#include <linux/input.h> 21#include <linux/input.h>
23#include <linux/gpio_keys.h>
24#include <linux/gpio-fan.h> 22#include <linux/gpio-fan.h>
25#include <linux/leds.h> 23#include <linux/leds.h>
26#include <asm/mach-types.h> 24#include <asm/mach-types.h>
@@ -35,10 +33,6 @@ static struct mv643xx_eth_platform_data dnskw_ge00_data = {
35 .phy_addr = MV643XX_ETH_PHY_ADDR(8), 33 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
36}; 34};
37 35
38static struct mv_sata_platform_data dnskw_sata_data = {
39 .n_ports = 2,
40};
41
42static unsigned int dnskw_mpp_config[] __initdata = { 36static unsigned int dnskw_mpp_config[] __initdata = {
43 MPP13_UART1_TXD, /* Custom ... */ 37 MPP13_UART1_TXD, /* Custom ... */
44 MPP14_UART1_RXD, /* ... Controller (DNS-320 only) */ 38 MPP14_UART1_RXD, /* ... Controller (DNS-320 only) */
@@ -73,132 +67,6 @@ static unsigned int dnskw_mpp_config[] __initdata = {
73 0 67 0
74}; 68};
75 69
76static struct gpio_led dns325_led_pins[] = {
77 {
78 .name = "dns325:white:power",
79 .gpio = 26,
80 .active_low = 1,
81 .default_trigger = "default-on",
82 },
83 {
84 .name = "dns325:white:usb",
85 .gpio = 43,
86 .active_low = 1,
87 },
88 {
89 .name = "dns325:red:l_hdd",
90 .gpio = 28,
91 .active_low = 1,
92 },
93 {
94 .name = "dns325:red:r_hdd",
95 .gpio = 27,
96 .active_low = 1,
97 },
98 {
99 .name = "dns325:red:usb",
100 .gpio = 29,
101 .active_low = 1,
102 },
103};
104
105static struct gpio_led_platform_data dns325_led_data = {
106 .num_leds = ARRAY_SIZE(dns325_led_pins),
107 .leds = dns325_led_pins,
108};
109
110static struct platform_device dns325_led_device = {
111 .name = "leds-gpio",
112 .id = -1,
113 .dev = {
114 .platform_data = &dns325_led_data,
115 },
116};
117
118static struct gpio_led dns320_led_pins[] = {
119 {
120 .name = "dns320:blue:power",
121 .gpio = 26,
122 .active_low = 1,
123 .default_trigger = "default-on",
124 },
125 {
126 .name = "dns320:blue:usb",
127 .gpio = 43,
128 .active_low = 1,
129 },
130 {
131 .name = "dns320:orange:l_hdd",
132 .gpio = 28,
133 .active_low = 1,
134 },
135 {
136 .name = "dns320:orange:r_hdd",
137 .gpio = 27,
138 .active_low = 1,
139 },
140 {
141 .name = "dns320:orange:usb",
142 .gpio = 35,
143 .active_low = 1,
144 },
145};
146
147static struct gpio_led_platform_data dns320_led_data = {
148 .num_leds = ARRAY_SIZE(dns320_led_pins),
149 .leds = dns320_led_pins,
150};
151
152static struct platform_device dns320_led_device = {
153 .name = "leds-gpio",
154 .id = -1,
155 .dev = {
156 .platform_data = &dns320_led_data,
157 },
158};
159
160static struct i2c_board_info dns325_i2c_board_info[] __initdata = {
161 {
162 I2C_BOARD_INFO("lm75", 0x48),
163 },
164 /* Something at 0x0c also */
165};
166
167static struct gpio_keys_button dnskw_button_pins[] = {
168 {
169 .code = KEY_POWER,
170 .gpio = 34,
171 .desc = "Power button",
172 .active_low = 1,
173 },
174 {
175 .code = KEY_EJECTCD,
176 .gpio = 47,
177 .desc = "USB unmount button",
178 .active_low = 1,
179 },
180 {
181 .code = KEY_RESTART,
182 .gpio = 48,
183 .desc = "Reset button",
184 .active_low = 1,
185 },
186};
187
188static struct gpio_keys_platform_data dnskw_button_data = {
189 .buttons = dnskw_button_pins,
190 .nbuttons = ARRAY_SIZE(dnskw_button_pins),
191};
192
193static struct platform_device dnskw_button_device = {
194 .name = "gpio-keys",
195 .id = -1,
196 .num_resources = 0,
197 .dev = {
198 .platform_data = &dnskw_button_data,
199 }
200};
201
202/* Fan: ADDA AD045HB-G73 40mm 6000rpm@5v */ 70/* Fan: ADDA AD045HB-G73 40mm 6000rpm@5v */
203static struct gpio_fan_speed dnskw_fan_speed[] = { 71static struct gpio_fan_speed dnskw_fan_speed[] = {
204 { 0, 0 }, 72 { 0, 0 },
@@ -245,20 +113,9 @@ void __init dnskw_init(void)
245 113
246 kirkwood_ehci_init(); 114 kirkwood_ehci_init();
247 kirkwood_ge00_init(&dnskw_ge00_data); 115 kirkwood_ge00_init(&dnskw_ge00_data);
248 kirkwood_sata_init(&dnskw_sata_data);
249 kirkwood_i2c_init();
250 116
251 platform_device_register(&dnskw_button_device);
252 platform_device_register(&dnskw_fan_device); 117 platform_device_register(&dnskw_fan_device);
253 118
254 if (of_machine_is_compatible("dlink,dns-325")) {
255 i2c_register_board_info(0, dns325_i2c_board_info,
256 ARRAY_SIZE(dns325_i2c_board_info));
257 platform_device_register(&dns325_led_device);
258
259 } else if (of_machine_is_compatible("dlink,dns-320"))
260 platform_device_register(&dns320_led_device);
261
262 /* Register power-off GPIO. */ 119 /* Register power-off GPIO. */
263 if (gpio_request(36, "dnskw:power:off") == 0 120 if (gpio_request(36, "dnskw:power:off") == 0
264 && gpio_direction_output(36, 0) == 0) 121 && gpio_direction_output(36, 0) == 0)
diff --git a/arch/arm/mach-kirkwood/board-dreamplug.c b/arch/arm/mach-kirkwood/board-dreamplug.c
index 55e357ab292..aeb234d0d0e 100644
--- a/arch/arm/mach-kirkwood/board-dreamplug.c
+++ b/arch/arm/mach-kirkwood/board-dreamplug.c
@@ -14,7 +14,6 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/mtd/partitions.h>
18#include <linux/ata_platform.h> 17#include <linux/ata_platform.h>
19#include <linux/mv643xx_eth.h> 18#include <linux/mv643xx_eth.h>
20#include <linux/of.h> 19#include <linux/of.h>
@@ -23,7 +22,6 @@
23#include <linux/of_irq.h> 22#include <linux/of_irq.h>
24#include <linux/of_platform.h> 23#include <linux/of_platform.h>
25#include <linux/gpio.h> 24#include <linux/gpio.h>
26#include <linux/leds.h>
27#include <linux/mtd/physmap.h> 25#include <linux/mtd/physmap.h>
28#include <linux/spi/flash.h> 26#include <linux/spi/flash.h>
29#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
@@ -36,42 +34,6 @@
36#include "common.h" 34#include "common.h"
37#include "mpp.h" 35#include "mpp.h"
38 36
39struct mtd_partition dreamplug_partitions[] = {
40 {
41 .name = "u-boot",
42 .size = SZ_512K,
43 .offset = 0,
44 },
45 {
46 .name = "u-boot env",
47 .size = SZ_64K,
48 .offset = SZ_512K + SZ_512K,
49 },
50 {
51 .name = "dtb",
52 .size = SZ_64K,
53 .offset = SZ_512K + SZ_512K + SZ_512K,
54 },
55};
56
57static const struct flash_platform_data dreamplug_spi_slave_data = {
58 .type = "mx25l1606e",
59 .name = "spi_flash",
60 .parts = dreamplug_partitions,
61 .nr_parts = ARRAY_SIZE(dreamplug_partitions),
62};
63
64static struct spi_board_info __initdata dreamplug_spi_slave_info[] = {
65 {
66 .modalias = "m25p80",
67 .platform_data = &dreamplug_spi_slave_data,
68 .irq = -1,
69 .max_speed_hz = 50000000,
70 .bus_num = 0,
71 .chip_select = 0,
72 },
73};
74
75static struct mv643xx_eth_platform_data dreamplug_ge00_data = { 37static struct mv643xx_eth_platform_data dreamplug_ge00_data = {
76 .phy_addr = MV643XX_ETH_PHY_ADDR(0), 38 .phy_addr = MV643XX_ETH_PHY_ADDR(0),
77}; 39};
@@ -80,45 +42,10 @@ static struct mv643xx_eth_platform_data dreamplug_ge01_data = {
80 .phy_addr = MV643XX_ETH_PHY_ADDR(1), 42 .phy_addr = MV643XX_ETH_PHY_ADDR(1),
81}; 43};
82 44
83static struct mv_sata_platform_data dreamplug_sata_data = {
84 .n_ports = 1,
85};
86
87static struct mvsdio_platform_data dreamplug_mvsdio_data = { 45static struct mvsdio_platform_data dreamplug_mvsdio_data = {
88 /* unfortunately the CD signal has not been connected */ 46 /* unfortunately the CD signal has not been connected */
89}; 47};
90 48
91static struct gpio_led dreamplug_led_pins[] = {
92 {
93 .name = "dreamplug:blue:bluetooth",
94 .gpio = 47,
95 .active_low = 1,
96 },
97 {
98 .name = "dreamplug:green:wifi",
99 .gpio = 48,
100 .active_low = 1,
101 },
102 {
103 .name = "dreamplug:green:wifi_ap",
104 .gpio = 49,
105 .active_low = 1,
106 },
107};
108
109static struct gpio_led_platform_data dreamplug_led_data = {
110 .leds = dreamplug_led_pins,
111 .num_leds = ARRAY_SIZE(dreamplug_led_pins),
112};
113
114static struct platform_device dreamplug_leds = {
115 .name = "leds-gpio",
116 .id = -1,
117 .dev = {
118 .platform_data = &dreamplug_led_data,
119 }
120};
121
122static unsigned int dreamplug_mpp_config[] __initdata = { 49static unsigned int dreamplug_mpp_config[] __initdata = {
123 MPP0_SPI_SCn, 50 MPP0_SPI_SCn,
124 MPP1_SPI_MOSI, 51 MPP1_SPI_MOSI,
@@ -137,15 +64,8 @@ void __init dreamplug_init(void)
137 */ 64 */
138 kirkwood_mpp_conf(dreamplug_mpp_config); 65 kirkwood_mpp_conf(dreamplug_mpp_config);
139 66
140 spi_register_board_info(dreamplug_spi_slave_info,
141 ARRAY_SIZE(dreamplug_spi_slave_info));
142 kirkwood_spi_init();
143
144 kirkwood_ehci_init(); 67 kirkwood_ehci_init();
145 kirkwood_ge00_init(&dreamplug_ge00_data); 68 kirkwood_ge00_init(&dreamplug_ge00_data);
146 kirkwood_ge01_init(&dreamplug_ge01_data); 69 kirkwood_ge01_init(&dreamplug_ge01_data);
147 kirkwood_sata_init(&dreamplug_sata_data);
148 kirkwood_sdio_init(&dreamplug_mvsdio_data); 70 kirkwood_sdio_init(&dreamplug_mvsdio_data);
149
150 platform_device_register(&dreamplug_leds);
151} 71}
diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
index edc3f8a9d45..e4eb450de30 100644
--- a/arch/arm/mach-kirkwood/board-dt.c
+++ b/arch/arm/mach-kirkwood/board-dt.c
@@ -18,6 +18,7 @@
18#include <asm/mach/arch.h> 18#include <asm/mach/arch.h>
19#include <asm/mach/map.h> 19#include <asm/mach/map.h>
20#include <mach/bridge-regs.h> 20#include <mach/bridge-regs.h>
21#include <plat/irq.h>
21#include "common.h" 22#include "common.h"
22 23
23static struct of_device_id kirkwood_dt_match_table[] __initdata = { 24static struct of_device_id kirkwood_dt_match_table[] __initdata = {
@@ -25,6 +26,16 @@ static struct of_device_id kirkwood_dt_match_table[] __initdata = {
25 { } 26 { }
26}; 27};
27 28
29struct of_dev_auxdata kirkwood_auxdata_lookup[] __initdata = {
30 OF_DEV_AUXDATA("marvell,orion-spi", 0xf1010600, "orion_spi.0", NULL),
31 OF_DEV_AUXDATA("marvell,mv64xxx-i2c", 0xf1011000, "mv64xxx_i2c.0",
32 NULL),
33 OF_DEV_AUXDATA("marvell,orion-wdt", 0xf1020300, "orion_wdt", NULL),
34 OF_DEV_AUXDATA("marvell,orion-sata", 0xf1080000, "sata_mv.0", NULL),
35 OF_DEV_AUXDATA("marvell,orion-nand", 0xf4000000, "orion_nand", NULL),
36 {},
37};
38
28static void __init kirkwood_dt_init(void) 39static void __init kirkwood_dt_init(void)
29{ 40{
30 pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk); 41 pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);
@@ -47,7 +58,6 @@ static void __init kirkwood_dt_init(void)
47 kirkwood_clk_init(); 58 kirkwood_clk_init();
48 59
49 /* internal devices that every board has */ 60 /* internal devices that every board has */
50 kirkwood_wdt_init();
51 kirkwood_xor0_init(); 61 kirkwood_xor0_init();
52 kirkwood_xor1_init(); 62 kirkwood_xor1_init();
53 kirkwood_crypto_init(); 63 kirkwood_crypto_init();
@@ -68,7 +78,17 @@ static void __init kirkwood_dt_init(void)
68 if (of_machine_is_compatible("raidsonic,ib-nas62x0")) 78 if (of_machine_is_compatible("raidsonic,ib-nas62x0"))
69 ib62x0_init(); 79 ib62x0_init();
70 80
71 of_platform_populate(NULL, kirkwood_dt_match_table, NULL, NULL); 81 if (of_machine_is_compatible("qnap,ts219"))
82 qnap_dt_ts219_init();
83
84 if (of_machine_is_compatible("seagate,goflexnet"))
85 goflexnet_init();
86
87 if (of_machine_is_compatible("buffalo,lsxl"))
88 lsxl_init();
89
90 of_platform_populate(NULL, kirkwood_dt_match_table,
91 kirkwood_auxdata_lookup, NULL);
72} 92}
73 93
74static const char *kirkwood_dt_board_compat[] = { 94static const char *kirkwood_dt_board_compat[] = {
@@ -77,6 +97,9 @@ static const char *kirkwood_dt_board_compat[] = {
77 "dlink,dns-325", 97 "dlink,dns-325",
78 "iom,iconnect", 98 "iom,iconnect",
79 "raidsonic,ib-nas62x0", 99 "raidsonic,ib-nas62x0",
100 "qnap,ts219",
101 "seagate,goflexnet",
102 "buffalo,lsxl",
80 NULL 103 NULL
81}; 104};
82 105
@@ -84,7 +107,7 @@ DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
84 /* Maintainer: Jason Cooper <jason@lakedaemon.net> */ 107 /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
85 .map_io = kirkwood_map_io, 108 .map_io = kirkwood_map_io,
86 .init_early = kirkwood_init_early, 109 .init_early = kirkwood_init_early,
87 .init_irq = kirkwood_init_irq, 110 .init_irq = orion_dt_init_irq,
88 .timer = &kirkwood_timer, 111 .timer = &kirkwood_timer,
89 .init_machine = kirkwood_dt_init, 112 .init_machine = kirkwood_dt_init,
90 .restart = kirkwood_restart, 113 .restart = kirkwood_restart,
diff --git a/arch/arm/mach-kirkwood/board-goflexnet.c b/arch/arm/mach-kirkwood/board-goflexnet.c
new file mode 100644
index 00000000000..413e2c8ef5f
--- /dev/null
+++ b/arch/arm/mach-kirkwood/board-goflexnet.c
@@ -0,0 +1,71 @@
1/*
2 * Copyright 2012 (C), Jason Cooper <jason@lakedaemon.net>
3 *
4 * arch/arm/mach-kirkwood/board-goflexnet.c
5 *
6 * Seagate GoFlext Net Board Init for drivers not converted to
7 * flattened device tree yet.
8 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 *
13 * Copied and modified for Seagate GoFlex Net support by
14 * Joshua Coombs <josh.coombs@gmail.com> based on ArchLinux ARM's
15 * GoFlex kernel patches.
16 *
17 */
18
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/platform_device.h>
22#include <linux/ata_platform.h>
23#include <linux/mv643xx_eth.h>
24#include <linux/of.h>
25#include <linux/of_address.h>
26#include <linux/of_fdt.h>
27#include <linux/of_irq.h>
28#include <linux/of_platform.h>
29#include <linux/gpio.h>
30#include <asm/mach-types.h>
31#include <asm/mach/arch.h>
32#include <asm/mach/map.h>
33#include <mach/kirkwood.h>
34#include <mach/bridge-regs.h>
35#include <plat/mvsdio.h>
36#include "common.h"
37#include "mpp.h"
38
39static struct mv643xx_eth_platform_data goflexnet_ge00_data = {
40 .phy_addr = MV643XX_ETH_PHY_ADDR(0),
41};
42
43static unsigned int goflexnet_mpp_config[] __initdata = {
44 MPP29_GPIO, /* USB Power Enable */
45 MPP47_GPIO, /* LED Orange */
46 MPP46_GPIO, /* LED Green */
47 MPP45_GPIO, /* LED Left Capacity 3 */
48 MPP44_GPIO, /* LED Left Capacity 2 */
49 MPP43_GPIO, /* LED Left Capacity 1 */
50 MPP42_GPIO, /* LED Left Capacity 0 */
51 MPP41_GPIO, /* LED Right Capacity 3 */
52 MPP40_GPIO, /* LED Right Capacity 2 */
53 MPP39_GPIO, /* LED Right Capacity 1 */
54 MPP38_GPIO, /* LED Right Capacity 0 */
55 0
56};
57
58void __init goflexnet_init(void)
59{
60 /*
61 * Basic setup. Needs to be called early.
62 */
63 kirkwood_mpp_conf(goflexnet_mpp_config);
64
65 if (gpio_request(29, "USB Power Enable") != 0 ||
66 gpio_direction_output(29, 1) != 0)
67 pr_err("can't setup GPIO 29 (USB Power Enable)\n");
68 kirkwood_ehci_init();
69
70 kirkwood_ge00_init(&goflexnet_ge00_data);
71}
diff --git a/arch/arm/mach-kirkwood/board-ib62x0.c b/arch/arm/mach-kirkwood/board-ib62x0.c
index eddf1df8891..cfc47f80e73 100644
--- a/arch/arm/mach-kirkwood/board-ib62x0.c
+++ b/arch/arm/mach-kirkwood/board-ib62x0.c
@@ -18,9 +18,7 @@
18#include <linux/ata_platform.h> 18#include <linux/ata_platform.h>
19#include <linux/mv643xx_eth.h> 19#include <linux/mv643xx_eth.h>
20#include <linux/gpio.h> 20#include <linux/gpio.h>
21#include <linux/gpio_keys.h>
22#include <linux/input.h> 21#include <linux/input.h>
23#include <linux/leds.h>
24#include <asm/mach-types.h> 22#include <asm/mach-types.h>
25#include <asm/mach/arch.h> 23#include <asm/mach/arch.h>
26#include <mach/kirkwood.h> 24#include <mach/kirkwood.h>
@@ -33,10 +31,6 @@ static struct mv643xx_eth_platform_data ib62x0_ge00_data = {
33 .phy_addr = MV643XX_ETH_PHY_ADDR(8), 31 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
34}; 32};
35 33
36static struct mv_sata_platform_data ib62x0_sata_data = {
37 .n_ports = 2,
38};
39
40static unsigned int ib62x0_mpp_config[] __initdata = { 34static unsigned int ib62x0_mpp_config[] __initdata = {
41 MPP0_NF_IO2, 35 MPP0_NF_IO2,
42 MPP1_NF_IO3, 36 MPP1_NF_IO3,
@@ -55,69 +49,6 @@ static unsigned int ib62x0_mpp_config[] __initdata = {
55 0 49 0
56}; 50};
57 51
58static struct gpio_led ib62x0_led_pins[] = {
59 {
60 .name = "ib62x0:green:os",
61 .default_trigger = "default-on",
62 .gpio = 25,
63 .active_low = 0,
64 },
65 {
66 .name = "ib62x0:red:os",
67 .default_trigger = "none",
68 .gpio = 22,
69 .active_low = 0,
70 },
71 {
72 .name = "ib62x0:red:usb_copy",
73 .default_trigger = "none",
74 .gpio = 27,
75 .active_low = 0,
76 },
77};
78
79static struct gpio_led_platform_data ib62x0_led_data = {
80 .leds = ib62x0_led_pins,
81 .num_leds = ARRAY_SIZE(ib62x0_led_pins),
82};
83
84static struct platform_device ib62x0_led_device = {
85 .name = "leds-gpio",
86 .id = -1,
87 .dev = {
88 .platform_data = &ib62x0_led_data,
89 }
90};
91
92static struct gpio_keys_button ib62x0_button_pins[] = {
93 {
94 .code = KEY_COPY,
95 .gpio = 29,
96 .desc = "USB Copy",
97 .active_low = 1,
98 },
99 {
100 .code = KEY_RESTART,
101 .gpio = 28,
102 .desc = "Reset",
103 .active_low = 1,
104 },
105};
106
107static struct gpio_keys_platform_data ib62x0_button_data = {
108 .buttons = ib62x0_button_pins,
109 .nbuttons = ARRAY_SIZE(ib62x0_button_pins),
110};
111
112static struct platform_device ib62x0_button_device = {
113 .name = "gpio-keys",
114 .id = -1,
115 .num_resources = 0,
116 .dev = {
117 .platform_data = &ib62x0_button_data,
118 }
119};
120
121static void ib62x0_power_off(void) 52static void ib62x0_power_off(void)
122{ 53{
123 gpio_set_value(IB62X0_GPIO_POWER_OFF, 1); 54 gpio_set_value(IB62X0_GPIO_POWER_OFF, 1);
@@ -132,9 +63,6 @@ void __init ib62x0_init(void)
132 63
133 kirkwood_ehci_init(); 64 kirkwood_ehci_init();
134 kirkwood_ge00_init(&ib62x0_ge00_data); 65 kirkwood_ge00_init(&ib62x0_ge00_data);
135 kirkwood_sata_init(&ib62x0_sata_data);
136 platform_device_register(&ib62x0_led_device);
137 platform_device_register(&ib62x0_button_device);
138 if (gpio_request(IB62X0_GPIO_POWER_OFF, "ib62x0:power:off") == 0 && 66 if (gpio_request(IB62X0_GPIO_POWER_OFF, "ib62x0:power:off") == 0 &&
139 gpio_direction_output(IB62X0_GPIO_POWER_OFF, 0) == 0) 67 gpio_direction_output(IB62X0_GPIO_POWER_OFF, 0) == 0)
140 pm_power_off = ib62x0_power_off; 68 pm_power_off = ib62x0_power_off;
diff --git a/arch/arm/mach-kirkwood/board-iconnect.c b/arch/arm/mach-kirkwood/board-iconnect.c
index b0d3cc49269..d7a9198ed30 100644
--- a/arch/arm/mach-kirkwood/board-iconnect.c
+++ b/arch/arm/mach-kirkwood/board-iconnect.c
@@ -19,8 +19,6 @@
19#include <linux/mtd/partitions.h> 19#include <linux/mtd/partitions.h>
20#include <linux/mv643xx_eth.h> 20#include <linux/mv643xx_eth.h>
21#include <linux/gpio.h> 21#include <linux/gpio.h>
22#include <linux/leds.h>
23#include <linux/i2c.h>
24#include <linux/input.h> 22#include <linux/input.h>
25#include <linux/gpio_keys.h> 23#include <linux/gpio_keys.h>
26#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
@@ -32,50 +30,6 @@ static struct mv643xx_eth_platform_data iconnect_ge00_data = {
32 .phy_addr = MV643XX_ETH_PHY_ADDR(11), 30 .phy_addr = MV643XX_ETH_PHY_ADDR(11),
33}; 31};
34 32
35static struct gpio_led iconnect_led_pins[] = {
36 {
37 .name = "led_level",
38 .gpio = 41,
39 .default_trigger = "default-on",
40 }, {
41 .name = "power:blue",
42 .gpio = 42,
43 .default_trigger = "timer",
44 }, {
45 .name = "power:red",
46 .gpio = 43,
47 }, {
48 .name = "usb1:blue",
49 .gpio = 44,
50 }, {
51 .name = "usb2:blue",
52 .gpio = 45,
53 }, {
54 .name = "usb3:blue",
55 .gpio = 46,
56 }, {
57 .name = "usb4:blue",
58 .gpio = 47,
59 }, {
60 .name = "otb:blue",
61 .gpio = 48,
62 },
63};
64
65static struct gpio_led_platform_data iconnect_led_data = {
66 .leds = iconnect_led_pins,
67 .num_leds = ARRAY_SIZE(iconnect_led_pins),
68 .gpio_blink_set = orion_gpio_led_blink_set,
69};
70
71static struct platform_device iconnect_leds = {
72 .name = "leds-gpio",
73 .id = -1,
74 .dev = {
75 .platform_data = &iconnect_led_data,
76 }
77};
78
79static unsigned int iconnect_mpp_config[] __initdata = { 33static unsigned int iconnect_mpp_config[] __initdata = {
80 MPP12_GPIO, 34 MPP12_GPIO,
81 MPP35_GPIO, 35 MPP35_GPIO,
@@ -90,12 +44,6 @@ static unsigned int iconnect_mpp_config[] __initdata = {
90 0 44 0
91}; 45};
92 46
93static struct i2c_board_info __initdata iconnect_board_info[] = {
94 {
95 I2C_BOARD_INFO("lm63", 0x4c),
96 },
97};
98
99static struct mtd_partition iconnect_nand_parts[] = { 47static struct mtd_partition iconnect_nand_parts[] = {
100 { 48 {
101 .name = "flash", 49 .name = "flash",
@@ -142,15 +90,11 @@ void __init iconnect_init(void)
142{ 90{
143 kirkwood_mpp_conf(iconnect_mpp_config); 91 kirkwood_mpp_conf(iconnect_mpp_config);
144 kirkwood_nand_init(ARRAY_AND_SIZE(iconnect_nand_parts), 25); 92 kirkwood_nand_init(ARRAY_AND_SIZE(iconnect_nand_parts), 25);
145 kirkwood_i2c_init();
146 i2c_register_board_info(0, iconnect_board_info,
147 ARRAY_SIZE(iconnect_board_info));
148 93
149 kirkwood_ehci_init(); 94 kirkwood_ehci_init();
150 kirkwood_ge00_init(&iconnect_ge00_data); 95 kirkwood_ge00_init(&iconnect_ge00_data);
151 96
152 platform_device_register(&iconnect_button_device); 97 platform_device_register(&iconnect_button_device);
153 platform_device_register(&iconnect_leds);
154} 98}
155 99
156static int __init iconnect_pci_init(void) 100static int __init iconnect_pci_init(void)
diff --git a/arch/arm/mach-kirkwood/board-lsxl.c b/arch/arm/mach-kirkwood/board-lsxl.c
new file mode 100644
index 00000000000..83d8975592f
--- /dev/null
+++ b/arch/arm/mach-kirkwood/board-lsxl.c
@@ -0,0 +1,135 @@
1/*
2 * Copyright 2012 (C), Michael Walle <michael@walle.cc>
3 *
4 * arch/arm/mach-kirkwood/board-lsxl.c
5 *
6 * Buffalo Linkstation LS-XHL and LS-CHLv2 init for drivers not
7 * converted to flattened device tree yet.
8 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 */
13
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/platform_device.h>
17#include <linux/mtd/partitions.h>
18#include <linux/ata_platform.h>
19#include <linux/spi/flash.h>
20#include <linux/spi/spi.h>
21#include <linux/mv643xx_eth.h>
22#include <linux/gpio.h>
23#include <linux/gpio-fan.h>
24#include <linux/input.h>
25#include <asm/mach-types.h>
26#include <asm/mach/arch.h>
27#include <mach/kirkwood.h>
28#include "common.h"
29#include "mpp.h"
30
31static struct mv643xx_eth_platform_data lsxl_ge00_data = {
32 .phy_addr = MV643XX_ETH_PHY_ADDR(0),
33};
34
35static struct mv643xx_eth_platform_data lsxl_ge01_data = {
36 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
37};
38
39static unsigned int lsxl_mpp_config[] __initdata = {
40 MPP10_GPO, /* HDD Power Enable */
41 MPP11_GPIO, /* USB Vbus Enable */
42 MPP18_GPO, /* FAN High Enable# */
43 MPP19_GPO, /* FAN Low Enable# */
44 MPP36_GPIO, /* Function Blue LED */
45 MPP37_GPIO, /* Alarm LED */
46 MPP38_GPIO, /* Info LED */
47 MPP39_GPIO, /* Power LED */
48 MPP40_GPIO, /* Fan Lock */
49 MPP41_GPIO, /* Function Button */
50 MPP42_GPIO, /* Power Switch */
51 MPP43_GPIO, /* Power Auto Switch */
52 MPP48_GPIO, /* Function Red LED */
53 0
54};
55
56#define LSXL_GPIO_FAN_HIGH 18
57#define LSXL_GPIO_FAN_LOW 19
58#define LSXL_GPIO_FAN_LOCK 40
59
60static struct gpio_fan_alarm lsxl_alarm = {
61 .gpio = LSXL_GPIO_FAN_LOCK,
62};
63
64static struct gpio_fan_speed lsxl_speeds[] = {
65 {
66 .rpm = 0,
67 .ctrl_val = 3,
68 }, {
69 .rpm = 1500,
70 .ctrl_val = 1,
71 }, {
72 .rpm = 3250,
73 .ctrl_val = 2,
74 }, {
75 .rpm = 5000,
76 .ctrl_val = 0,
77 }
78};
79
80static int lsxl_gpio_list[] = {
81 LSXL_GPIO_FAN_HIGH, LSXL_GPIO_FAN_LOW,
82};
83
84static struct gpio_fan_platform_data lsxl_fan_data = {
85 .num_ctrl = ARRAY_SIZE(lsxl_gpio_list),
86 .ctrl = lsxl_gpio_list,
87 .alarm = &lsxl_alarm,
88 .num_speed = ARRAY_SIZE(lsxl_speeds),
89 .speed = lsxl_speeds,
90};
91
92static struct platform_device lsxl_fan_device = {
93 .name = "gpio-fan",
94 .id = -1,
95 .num_resources = 0,
96 .dev = {
97 .platform_data = &lsxl_fan_data,
98 },
99};
100
101/*
102 * On the LS-XHL/LS-CHLv2, the shutdown process is following:
103 * - Userland monitors key events until the power switch goes to off position
104 * - The board reboots
105 * - U-boot starts and goes into an idle mode waiting for the user
106 * to move the switch to ON position
107 *
108 */
109static void lsxl_power_off(void)
110{
111 kirkwood_restart('h', NULL);
112}
113
114#define LSXL_GPIO_HDD_POWER 10
115#define LSXL_GPIO_USB_POWER 11
116
117void __init lsxl_init(void)
118{
119 /*
120 * Basic setup. Needs to be called early.
121 */
122 kirkwood_mpp_conf(lsxl_mpp_config);
123
124 /* usb and sata power on */
125 gpio_set_value(LSXL_GPIO_USB_POWER, 1);
126 gpio_set_value(LSXL_GPIO_HDD_POWER, 1);
127
128 kirkwood_ehci_init();
129 kirkwood_ge00_init(&lsxl_ge00_data);
130 kirkwood_ge01_init(&lsxl_ge01_data);
131 platform_device_register(&lsxl_fan_device);
132
133 /* register power-off method */
134 pm_power_off = lsxl_power_off;
135}
diff --git a/arch/arm/mach-kirkwood/board-ts219.c b/arch/arm/mach-kirkwood/board-ts219.c
new file mode 100644
index 00000000000..1750e68506c
--- /dev/null
+++ b/arch/arm/mach-kirkwood/board-ts219.c
@@ -0,0 +1,82 @@
1/*
2 *
3 * QNAP TS-11x/TS-21x Turbo NAS Board Setup via DT
4 *
5 * Copyright (C) 2012 Andrew Lunn <andrew@lunn.ch>
6 *
7 * Based on the board file ts219-setup.c:
8 *
9 * Copyright (C) 2009 Martin Michlmayr <tbm@cyrius.com>
10 * Copyright (C) 2008 Byron Bradley <byron.bbradley@gmail.com>
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
16 */
17
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/platform_device.h>
21#include <linux/mv643xx_eth.h>
22#include <linux/ata_platform.h>
23#include <linux/gpio_keys.h>
24#include <linux/input.h>
25#include <asm/mach-types.h>
26#include <asm/mach/arch.h>
27#include <mach/kirkwood.h>
28#include "common.h"
29#include "mpp.h"
30#include "tsx1x-common.h"
31
32static struct mv643xx_eth_platform_data qnap_ts219_ge00_data = {
33 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
34};
35
36static unsigned int qnap_ts219_mpp_config[] __initdata = {
37 MPP0_SPI_SCn,
38 MPP1_SPI_MOSI,
39 MPP2_SPI_SCK,
40 MPP3_SPI_MISO,
41 MPP4_SATA1_ACTn,
42 MPP5_SATA0_ACTn,
43 MPP8_TW0_SDA,
44 MPP9_TW0_SCK,
45 MPP10_UART0_TXD,
46 MPP11_UART0_RXD,
47 MPP13_UART1_TXD, /* PIC controller */
48 MPP14_UART1_RXD, /* PIC controller */
49 MPP15_GPIO, /* USB Copy button (on devices with 88F6281) */
50 MPP16_GPIO, /* Reset button (on devices with 88F6281) */
51 MPP36_GPIO, /* RAM: 0: 256 MB, 1: 512 MB */
52 MPP37_GPIO, /* Reset button (on devices with 88F6282) */
53 MPP43_GPIO, /* USB Copy button (on devices with 88F6282) */
54 MPP44_GPIO, /* Board ID: 0: TS-11x, 1: TS-21x */
55 0
56};
57
58void __init qnap_dt_ts219_init(void)
59{
60 u32 dev, rev;
61
62 kirkwood_mpp_conf(qnap_ts219_mpp_config);
63
64 kirkwood_pcie_id(&dev, &rev);
65 if (dev == MV88F6282_DEV_ID)
66 qnap_ts219_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
67
68 kirkwood_ge00_init(&qnap_ts219_ge00_data);
69 kirkwood_ehci_init();
70
71 pm_power_off = qnap_tsx1x_power_off;
72}
73
74/* FIXME: Will not work with DT. Maybe use MPP40_GPIO? */
75static int __init ts219_pci_init(void)
76{
77 if (machine_is_ts219())
78 kirkwood_pcie_init(KW_PCIE0);
79
80 return 0;
81}
82subsys_initcall(ts219_pci_init);
diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
index f261cd24264..1201191d7f1 100644
--- a/arch/arm/mach-kirkwood/common.c
+++ b/arch/arm/mach-kirkwood/common.c
@@ -17,6 +17,7 @@
17#include <linux/dma-mapping.h> 17#include <linux/dma-mapping.h>
18#include <linux/clk-provider.h> 18#include <linux/clk-provider.h>
19#include <linux/spinlock.h> 19#include <linux/spinlock.h>
20#include <linux/mv643xx_i2c.h>
20#include <net/dsa.h> 21#include <net/dsa.h>
21#include <asm/page.h> 22#include <asm/page.h>
22#include <asm/timex.h> 23#include <asm/timex.h>
@@ -67,6 +68,14 @@ void __init kirkwood_map_io(void)
67 * CLK tree 68 * CLK tree
68 ****************************************************************************/ 69 ****************************************************************************/
69 70
71static void enable_sata0(void)
72{
73 /* Enable PLL and IVREF */
74 writel(readl(SATA0_PHY_MODE_2) | 0xf, SATA0_PHY_MODE_2);
75 /* Enable PHY */
76 writel(readl(SATA0_IF_CTRL) & ~0x200, SATA0_IF_CTRL);
77}
78
70static void disable_sata0(void) 79static void disable_sata0(void)
71{ 80{
72 /* Disable PLL and IVREF */ 81 /* Disable PLL and IVREF */
@@ -75,6 +84,14 @@ static void disable_sata0(void)
75 writel(readl(SATA0_IF_CTRL) | 0x200, SATA0_IF_CTRL); 84 writel(readl(SATA0_IF_CTRL) | 0x200, SATA0_IF_CTRL);
76} 85}
77 86
87static void enable_sata1(void)
88{
89 /* Enable PLL and IVREF */
90 writel(readl(SATA1_PHY_MODE_2) | 0xf, SATA1_PHY_MODE_2);
91 /* Enable PHY */
92 writel(readl(SATA1_IF_CTRL) & ~0x200, SATA1_IF_CTRL);
93}
94
78static void disable_sata1(void) 95static void disable_sata1(void)
79{ 96{
80 /* Disable PLL and IVREF */ 97 /* Disable PLL and IVREF */
@@ -107,23 +124,38 @@ static void disable_pcie1(void)
107 } 124 }
108} 125}
109 126
110/* An extended version of the gated clk. This calls fn() before 127/* An extended version of the gated clk. This calls fn_en()/fn_dis
111 * disabling the clock. We use this to turn off PHYs etc. */ 128 * before enabling/disabling the clock. We use this to turn on/off
129 * PHYs etc. */
112struct clk_gate_fn { 130struct clk_gate_fn {
113 struct clk_gate gate; 131 struct clk_gate gate;
114 void (*fn)(void); 132 void (*fn_en)(void);
133 void (*fn_dis)(void);
115}; 134};
116 135
117#define to_clk_gate_fn(_gate) container_of(_gate, struct clk_gate_fn, gate) 136#define to_clk_gate_fn(_gate) container_of(_gate, struct clk_gate_fn, gate)
118#define to_clk_gate(_hw) container_of(_hw, struct clk_gate, hw) 137#define to_clk_gate(_hw) container_of(_hw, struct clk_gate, hw)
119 138
139static int clk_gate_fn_enable(struct clk_hw *hw)
140{
141 struct clk_gate *gate = to_clk_gate(hw);
142 struct clk_gate_fn *gate_fn = to_clk_gate_fn(gate);
143 int ret;
144
145 ret = clk_gate_ops.enable(hw);
146 if (!ret && gate_fn->fn_en)
147 gate_fn->fn_en();
148
149 return ret;
150}
151
120static void clk_gate_fn_disable(struct clk_hw *hw) 152static void clk_gate_fn_disable(struct clk_hw *hw)
121{ 153{
122 struct clk_gate *gate = to_clk_gate(hw); 154 struct clk_gate *gate = to_clk_gate(hw);
123 struct clk_gate_fn *gate_fn = to_clk_gate_fn(gate); 155 struct clk_gate_fn *gate_fn = to_clk_gate_fn(gate);
124 156
125 if (gate_fn->fn) 157 if (gate_fn->fn_dis)
126 gate_fn->fn(); 158 gate_fn->fn_dis();
127 159
128 clk_gate_ops.disable(hw); 160 clk_gate_ops.disable(hw);
129} 161}
@@ -135,7 +167,7 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
135 const char *parent_name, unsigned long flags, 167 const char *parent_name, unsigned long flags,
136 void __iomem *reg, u8 bit_idx, 168 void __iomem *reg, u8 bit_idx,
137 u8 clk_gate_flags, spinlock_t *lock, 169 u8 clk_gate_flags, spinlock_t *lock,
138 void (*fn)(void)) 170 void (*fn_en)(void), void (*fn_dis)(void))
139{ 171{
140 struct clk_gate_fn *gate_fn; 172 struct clk_gate_fn *gate_fn;
141 struct clk *clk; 173 struct clk *clk;
@@ -159,11 +191,14 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
159 gate_fn->gate.flags = clk_gate_flags; 191 gate_fn->gate.flags = clk_gate_flags;
160 gate_fn->gate.lock = lock; 192 gate_fn->gate.lock = lock;
161 gate_fn->gate.hw.init = &init; 193 gate_fn->gate.hw.init = &init;
162 gate_fn->fn = fn; 194 gate_fn->fn_en = fn_en;
195 gate_fn->fn_dis = fn_dis;
163 196
164 /* ops is the gate ops, but with our disable function */ 197 /* ops is the gate ops, but with our enable/disable functions */
165 if (clk_gate_fn_ops.disable != clk_gate_fn_disable) { 198 if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
199 clk_gate_fn_ops.disable != clk_gate_fn_disable) {
166 clk_gate_fn_ops = clk_gate_ops; 200 clk_gate_fn_ops = clk_gate_ops;
201 clk_gate_fn_ops.enable = clk_gate_fn_enable;
167 clk_gate_fn_ops.disable = clk_gate_fn_disable; 202 clk_gate_fn_ops.disable = clk_gate_fn_disable;
168 } 203 }
169 204
@@ -187,11 +222,12 @@ static struct clk __init *kirkwood_register_gate(const char *name, u8 bit_idx)
187 222
188static struct clk __init *kirkwood_register_gate_fn(const char *name, 223static struct clk __init *kirkwood_register_gate_fn(const char *name,
189 u8 bit_idx, 224 u8 bit_idx,
190 void (*fn)(void)) 225 void (*fn_en)(void),
226 void (*fn_dis)(void))
191{ 227{
192 return clk_register_gate_fn(NULL, name, "tclk", 0, 228 return clk_register_gate_fn(NULL, name, "tclk", 0,
193 (void __iomem *)CLOCK_GATING_CTRL, 229 (void __iomem *)CLOCK_GATING_CTRL,
194 bit_idx, 0, &gating_lock, fn); 230 bit_idx, 0, &gating_lock, fn_en, fn_dis);
195} 231}
196 232
197static struct clk *ge0, *ge1; 233static struct clk *ge0, *ge1;
@@ -208,18 +244,18 @@ void __init kirkwood_clk_init(void)
208 ge0 = kirkwood_register_gate("ge0", CGC_BIT_GE0); 244 ge0 = kirkwood_register_gate("ge0", CGC_BIT_GE0);
209 ge1 = kirkwood_register_gate("ge1", CGC_BIT_GE1); 245 ge1 = kirkwood_register_gate("ge1", CGC_BIT_GE1);
210 sata0 = kirkwood_register_gate_fn("sata0", CGC_BIT_SATA0, 246 sata0 = kirkwood_register_gate_fn("sata0", CGC_BIT_SATA0,
211 disable_sata0); 247 enable_sata0, disable_sata0);
212 sata1 = kirkwood_register_gate_fn("sata1", CGC_BIT_SATA1, 248 sata1 = kirkwood_register_gate_fn("sata1", CGC_BIT_SATA1,
213 disable_sata1); 249 enable_sata1, disable_sata1);
214 usb0 = kirkwood_register_gate("usb0", CGC_BIT_USB0); 250 usb0 = kirkwood_register_gate("usb0", CGC_BIT_USB0);
215 sdio = kirkwood_register_gate("sdio", CGC_BIT_SDIO); 251 sdio = kirkwood_register_gate("sdio", CGC_BIT_SDIO);
216 crypto = kirkwood_register_gate("crypto", CGC_BIT_CRYPTO); 252 crypto = kirkwood_register_gate("crypto", CGC_BIT_CRYPTO);
217 xor0 = kirkwood_register_gate("xor0", CGC_BIT_XOR0); 253 xor0 = kirkwood_register_gate("xor0", CGC_BIT_XOR0);
218 xor1 = kirkwood_register_gate("xor1", CGC_BIT_XOR1); 254 xor1 = kirkwood_register_gate("xor1", CGC_BIT_XOR1);
219 pex0 = kirkwood_register_gate_fn("pex0", CGC_BIT_PEX0, 255 pex0 = kirkwood_register_gate_fn("pex0", CGC_BIT_PEX0,
220 disable_pcie0); 256 NULL, disable_pcie0);
221 pex1 = kirkwood_register_gate_fn("pex1", CGC_BIT_PEX1, 257 pex1 = kirkwood_register_gate_fn("pex1", CGC_BIT_PEX1,
222 disable_pcie1); 258 NULL, disable_pcie1);
223 audio = kirkwood_register_gate("audio", CGC_BIT_AUDIO); 259 audio = kirkwood_register_gate("audio", CGC_BIT_AUDIO);
224 kirkwood_register_gate("tdm", CGC_BIT_TDM); 260 kirkwood_register_gate("tdm", CGC_BIT_TDM);
225 kirkwood_register_gate("tsu", CGC_BIT_TSU); 261 kirkwood_register_gate("tsu", CGC_BIT_TSU);
@@ -241,6 +277,12 @@ void __init kirkwood_clk_init(void)
241 orion_clkdev_add("0", "pcie", pex0); 277 orion_clkdev_add("0", "pcie", pex0);
242 orion_clkdev_add("1", "pcie", pex1); 278 orion_clkdev_add("1", "pcie", pex1);
243 orion_clkdev_add(NULL, "kirkwood-i2s", audio); 279 orion_clkdev_add(NULL, "kirkwood-i2s", audio);
280 orion_clkdev_add(NULL, MV64XXX_I2C_CTLR_NAME ".0", runit);
281
282 /* Marvell says runit is used by SPI, UART, NAND, TWSI, ...,
283 * so should never be gated.
284 */
285 clk_prepare_enable(runit);
244} 286}
245 287
246/***************************************************************************** 288/*****************************************************************************
@@ -259,7 +301,7 @@ void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
259{ 301{
260 orion_ge00_init(eth_data, 302 orion_ge00_init(eth_data,
261 GE00_PHYS_BASE, IRQ_KIRKWOOD_GE00_SUM, 303 GE00_PHYS_BASE, IRQ_KIRKWOOD_GE00_SUM,
262 IRQ_KIRKWOOD_GE00_ERR); 304 IRQ_KIRKWOOD_GE00_ERR, 1600);
263 /* The interface forgets the MAC address assigned by u-boot if 305 /* The interface forgets the MAC address assigned by u-boot if
264 the clock is turned off, so claim the clk now. */ 306 the clock is turned off, so claim the clk now. */
265 clk_prepare_enable(ge0); 307 clk_prepare_enable(ge0);
@@ -273,7 +315,7 @@ void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data)
273{ 315{
274 orion_ge01_init(eth_data, 316 orion_ge01_init(eth_data,
275 GE01_PHYS_BASE, IRQ_KIRKWOOD_GE01_SUM, 317 GE01_PHYS_BASE, IRQ_KIRKWOOD_GE01_SUM,
276 IRQ_KIRKWOOD_GE01_ERR); 318 IRQ_KIRKWOOD_GE01_ERR, 1600);
277 clk_prepare_enable(ge1); 319 clk_prepare_enable(ge1);
278} 320}
279 321
@@ -475,6 +517,13 @@ void __init kirkwood_wdt_init(void)
475void __init kirkwood_init_early(void) 517void __init kirkwood_init_early(void)
476{ 518{
477 orion_time_set_base(TIMER_VIRT_BASE); 519 orion_time_set_base(TIMER_VIRT_BASE);
520
521 /*
522 * Some Kirkwood devices allocate their coherent buffers from atomic
523 * context. Increase size of atomic coherent pool to make sure such
524 * the allocations won't fail.
525 */
526 init_dma_coherent_pool_size(SZ_1M);
478} 527}
479 528
480int kirkwood_tclk; 529int kirkwood_tclk;
diff --git a/arch/arm/mach-kirkwood/common.h b/arch/arm/mach-kirkwood/common.h
index 9248fa2c165..304dd1abfdc 100644
--- a/arch/arm/mach-kirkwood/common.h
+++ b/arch/arm/mach-kirkwood/common.h
@@ -58,6 +58,11 @@ void dreamplug_init(void);
58#else 58#else
59static inline void dreamplug_init(void) {}; 59static inline void dreamplug_init(void) {};
60#endif 60#endif
61#ifdef CONFIG_MACH_TS219_DT
62void qnap_dt_ts219_init(void);
63#else
64static inline void qnap_dt_ts219_init(void) {};
65#endif
61 66
62#ifdef CONFIG_MACH_DLINK_KIRKWOOD_DT 67#ifdef CONFIG_MACH_DLINK_KIRKWOOD_DT
63void dnskw_init(void); 68void dnskw_init(void);
@@ -77,6 +82,18 @@ void ib62x0_init(void);
77static inline void ib62x0_init(void) {}; 82static inline void ib62x0_init(void) {};
78#endif 83#endif
79 84
85#ifdef CONFIG_MACH_GOFLEXNET_DT
86void goflexnet_init(void);
87#else
88static inline void goflexnet_init(void) {};
89#endif
90
91#ifdef CONFIG_MACH_LSXL_DT
92void lsxl_init(void);
93#else
94static inline void lsxl_init(void) {};
95#endif
96
80/* early init functions not converted to fdt yet */ 97/* early init functions not converted to fdt yet */
81char *kirkwood_id(void); 98char *kirkwood_id(void);
82void kirkwood_l2_init(void); 99void kirkwood_l2_init(void);
diff --git a/arch/arm/mach-kirkwood/db88f6281-bp-setup.c b/arch/arm/mach-kirkwood/db88f6281-bp-setup.c
index d9335937959..be90b7d0e10 100644
--- a/arch/arm/mach-kirkwood/db88f6281-bp-setup.c
+++ b/arch/arm/mach-kirkwood/db88f6281-bp-setup.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/sizes.h>
13#include <linux/platform_device.h> 14#include <linux/platform_device.h>
14#include <linux/mtd/partitions.h> 15#include <linux/mtd/partitions.h>
15#include <linux/ata_platform.h> 16#include <linux/ata_platform.h>
diff --git a/arch/arm/mach-kirkwood/irq.c b/arch/arm/mach-kirkwood/irq.c
index c4c68e5b94f..720063ffa19 100644
--- a/arch/arm/mach-kirkwood/irq.c
+++ b/arch/arm/mach-kirkwood/irq.c
@@ -9,20 +9,23 @@
9 */ 9 */
10#include <linux/gpio.h> 10#include <linux/gpio.h>
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/irq.h> 12#include <linux/irq.h>
14#include <linux/io.h>
15#include <mach/bridge-regs.h> 13#include <mach/bridge-regs.h>
16#include <plat/irq.h> 14#include <plat/irq.h>
17#include "common.h"
18 15
19static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc) 16static int __initdata gpio0_irqs[4] = {
20{ 17 IRQ_KIRKWOOD_GPIO_LOW_0_7,
21 BUG_ON(irq < IRQ_KIRKWOOD_GPIO_LOW_0_7); 18 IRQ_KIRKWOOD_GPIO_LOW_8_15,
22 BUG_ON(irq > IRQ_KIRKWOOD_GPIO_HIGH_16_23); 19 IRQ_KIRKWOOD_GPIO_LOW_16_23,
20 IRQ_KIRKWOOD_GPIO_LOW_24_31,
21};
23 22
24 orion_gpio_irq_handler((irq - IRQ_KIRKWOOD_GPIO_LOW_0_7) << 3); 23static int __initdata gpio1_irqs[4] = {
25} 24 IRQ_KIRKWOOD_GPIO_HIGH_0_7,
25 IRQ_KIRKWOOD_GPIO_HIGH_8_15,
26 IRQ_KIRKWOOD_GPIO_HIGH_16_23,
27 0,
28};
26 29
27void __init kirkwood_init_irq(void) 30void __init kirkwood_init_irq(void)
28{ 31{
@@ -32,17 +35,8 @@ void __init kirkwood_init_irq(void)
32 /* 35 /*
33 * Initialize gpiolib for GPIOs 0-49. 36 * Initialize gpiolib for GPIOs 0-49.
34 */ 37 */
35 orion_gpio_init(0, 32, GPIO_LOW_VIRT_BASE, 0, 38 orion_gpio_init(NULL, 0, 32, (void __iomem *)GPIO_LOW_VIRT_BASE, 0,
36 IRQ_KIRKWOOD_GPIO_START); 39 IRQ_KIRKWOOD_GPIO_START, gpio0_irqs);
37 irq_set_chained_handler(IRQ_KIRKWOOD_GPIO_LOW_0_7, gpio_irq_handler); 40 orion_gpio_init(NULL, 32, 18, (void __iomem *)GPIO_HIGH_VIRT_BASE, 0,
38 irq_set_chained_handler(IRQ_KIRKWOOD_GPIO_LOW_8_15, gpio_irq_handler); 41 IRQ_KIRKWOOD_GPIO_START + 32, gpio1_irqs);
39 irq_set_chained_handler(IRQ_KIRKWOOD_GPIO_LOW_16_23, gpio_irq_handler);
40 irq_set_chained_handler(IRQ_KIRKWOOD_GPIO_LOW_24_31, gpio_irq_handler);
41
42 orion_gpio_init(32, 18, GPIO_HIGH_VIRT_BASE, 0,
43 IRQ_KIRKWOOD_GPIO_START + 32);
44 irq_set_chained_handler(IRQ_KIRKWOOD_GPIO_HIGH_0_7, gpio_irq_handler);
45 irq_set_chained_handler(IRQ_KIRKWOOD_GPIO_HIGH_8_15, gpio_irq_handler);
46 irq_set_chained_handler(IRQ_KIRKWOOD_GPIO_HIGH_16_23,
47 gpio_irq_handler);
48} 42}
diff --git a/arch/arm/mach-lpc32xx/Kconfig b/arch/arm/mach-lpc32xx/Kconfig
deleted file mode 100644
index e0b3eee8383..00000000000
--- a/arch/arm/mach-lpc32xx/Kconfig
+++ /dev/null
@@ -1,32 +0,0 @@
1if ARCH_LPC32XX
2
3menu "Individual UART enable selections"
4
5config ARCH_LPC32XX_UART3_SELECT
6 bool "Add support for standard UART3"
7 help
8 Adds support for standard UART 3 when the 8250 serial support
9 is enabled.
10
11config ARCH_LPC32XX_UART4_SELECT
12 bool "Add support for standard UART4"
13 help
14 Adds support for standard UART 4 when the 8250 serial support
15 is enabled.
16
17config ARCH_LPC32XX_UART5_SELECT
18 bool "Add support for standard UART5"
19 default y
20 help
21 Adds support for standard UART 5 when the 8250 serial support
22 is enabled.
23
24config ARCH_LPC32XX_UART6_SELECT
25 bool "Add support for standard UART6"
26 help
27 Adds support for standard UART 6 when the 8250 serial support
28 is enabled.
29
30endmenu
31
32endif
diff --git a/arch/arm/mach-lpc32xx/Makefile.boot b/arch/arm/mach-lpc32xx/Makefile.boot
index 2cfe0ee635c..697323b5f92 100644
--- a/arch/arm/mach-lpc32xx/Makefile.boot
+++ b/arch/arm/mach-lpc32xx/Makefile.boot
@@ -2,3 +2,4 @@
2params_phys-y := 0x80000100 2params_phys-y := 0x80000100
3initrd_phys-y := 0x82000000 3initrd_phys-y := 0x82000000
4 4
5dtb-$(CONFIG_ARCH_LPC32XX) += ea3250.dtb phy3250.dtb
diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
index f6a3ffec1f4..f48c2e961b8 100644
--- a/arch/arm/mach-lpc32xx/clock.c
+++ b/arch/arm/mach-lpc32xx/clock.c
@@ -607,6 +607,19 @@ static struct clk clk_dma = {
607 .get_rate = local_return_parent_rate, 607 .get_rate = local_return_parent_rate,
608}; 608};
609 609
610static struct clk clk_pwm = {
611 .parent = &clk_pclk,
612 .enable = local_onoff_enable,
613 .enable_reg = LPC32XX_CLKPWR_PWM_CLK_CTRL,
614 .enable_mask = LPC32XX_CLKPWR_PWMCLK_PWM1CLK_EN |
615 LPC32XX_CLKPWR_PWMCLK_PWM1SEL_PCLK |
616 LPC32XX_CLKPWR_PWMCLK_PWM1_DIV(1) |
617 LPC32XX_CLKPWR_PWMCLK_PWM2CLK_EN |
618 LPC32XX_CLKPWR_PWMCLK_PWM2SEL_PCLK |
619 LPC32XX_CLKPWR_PWMCLK_PWM2_DIV(1),
620 .get_rate = local_return_parent_rate,
621};
622
610static struct clk clk_uart3 = { 623static struct clk clk_uart3 = {
611 .parent = &clk_pclk, 624 .parent = &clk_pclk,
612 .enable = local_onoff_enable, 625 .enable = local_onoff_enable,
@@ -691,10 +704,21 @@ static struct clk clk_nand = {
691 .parent = &clk_hclk, 704 .parent = &clk_hclk,
692 .enable = local_onoff_enable, 705 .enable = local_onoff_enable,
693 .enable_reg = LPC32XX_CLKPWR_NAND_CLK_CTRL, 706 .enable_reg = LPC32XX_CLKPWR_NAND_CLK_CTRL,
694 .enable_mask = LPC32XX_CLKPWR_NANDCLK_SLCCLK_EN, 707 .enable_mask = LPC32XX_CLKPWR_NANDCLK_SLCCLK_EN |
708 LPC32XX_CLKPWR_NANDCLK_SEL_SLC,
695 .get_rate = local_return_parent_rate, 709 .get_rate = local_return_parent_rate,
696}; 710};
697 711
712static struct clk clk_nand_mlc = {
713 .parent = &clk_hclk,
714 .enable = local_onoff_enable,
715 .enable_reg = LPC32XX_CLKPWR_NAND_CLK_CTRL,
716 .enable_mask = LPC32XX_CLKPWR_NANDCLK_MLCCLK_EN |
717 LPC32XX_CLKPWR_NANDCLK_DMA_INT |
718 LPC32XX_CLKPWR_NANDCLK_INTSEL_MLC,
719 .get_rate = local_return_parent_rate,
720};
721
698static struct clk clk_i2s0 = { 722static struct clk clk_i2s0 = {
699 .parent = &clk_hclk, 723 .parent = &clk_hclk,
700 .enable = local_onoff_enable, 724 .enable = local_onoff_enable,
@@ -707,7 +731,8 @@ static struct clk clk_i2s1 = {
707 .parent = &clk_hclk, 731 .parent = &clk_hclk,
708 .enable = local_onoff_enable, 732 .enable = local_onoff_enable,
709 .enable_reg = LPC32XX_CLKPWR_I2S_CLK_CTRL, 733 .enable_reg = LPC32XX_CLKPWR_I2S_CLK_CTRL,
710 .enable_mask = LPC32XX_CLKPWR_I2SCTRL_I2SCLK1_EN, 734 .enable_mask = LPC32XX_CLKPWR_I2SCTRL_I2SCLK1_EN |
735 LPC32XX_CLKPWR_I2SCTRL_I2S1_USE_DMA,
711 .get_rate = local_return_parent_rate, 736 .get_rate = local_return_parent_rate,
712}; 737};
713 738
@@ -727,14 +752,77 @@ static struct clk clk_rtc = {
727 .get_rate = local_return_parent_rate, 752 .get_rate = local_return_parent_rate,
728}; 753};
729 754
755static int local_usb_enable(struct clk *clk, int enable)
756{
757 u32 tmp;
758
759 if (enable) {
760 /* Set up I2C pull levels */
761 tmp = __raw_readl(LPC32XX_CLKPWR_I2C_CLK_CTRL);
762 tmp |= LPC32XX_CLKPWR_I2CCLK_USBI2CHI_DRIVE;
763 __raw_writel(tmp, LPC32XX_CLKPWR_I2C_CLK_CTRL);
764 }
765
766 return local_onoff_enable(clk, enable);
767}
768
730static struct clk clk_usbd = { 769static struct clk clk_usbd = {
731 .parent = &clk_usbpll, 770 .parent = &clk_usbpll,
732 .enable = local_onoff_enable, 771 .enable = local_usb_enable,
733 .enable_reg = LPC32XX_CLKPWR_USB_CTRL, 772 .enable_reg = LPC32XX_CLKPWR_USB_CTRL,
734 .enable_mask = LPC32XX_CLKPWR_USBCTRL_HCLK_EN, 773 .enable_mask = LPC32XX_CLKPWR_USBCTRL_HCLK_EN,
735 .get_rate = local_return_parent_rate, 774 .get_rate = local_return_parent_rate,
736}; 775};
737 776
777#define OTG_ALWAYS_MASK (LPC32XX_USB_OTG_OTG_CLOCK_ON | \
778 LPC32XX_USB_OTG_I2C_CLOCK_ON)
779
780static int local_usb_otg_enable(struct clk *clk, int enable)
781{
782 int to = 1000;
783
784 if (enable) {
785 __raw_writel(clk->enable_mask, clk->enable_reg);
786
787 while (((__raw_readl(LPC32XX_USB_OTG_CLK_STAT) &
788 clk->enable_mask) != clk->enable_mask) && (to > 0))
789 to--;
790 } else {
791 __raw_writel(OTG_ALWAYS_MASK, clk->enable_reg);
792
793 while (((__raw_readl(LPC32XX_USB_OTG_CLK_STAT) &
794 OTG_ALWAYS_MASK) != OTG_ALWAYS_MASK) && (to > 0))
795 to--;
796 }
797
798 if (to)
799 return 0;
800 else
801 return -1;
802}
803
804static struct clk clk_usb_otg_dev = {
805 .parent = &clk_usbpll,
806 .enable = local_usb_otg_enable,
807 .enable_reg = LPC32XX_USB_OTG_CLK_CTRL,
808 .enable_mask = LPC32XX_USB_OTG_AHB_M_CLOCK_ON |
809 LPC32XX_USB_OTG_OTG_CLOCK_ON |
810 LPC32XX_USB_OTG_DEV_CLOCK_ON |
811 LPC32XX_USB_OTG_I2C_CLOCK_ON,
812 .get_rate = local_return_parent_rate,
813};
814
815static struct clk clk_usb_otg_host = {
816 .parent = &clk_usbpll,
817 .enable = local_usb_otg_enable,
818 .enable_reg = LPC32XX_USB_OTG_CLK_CTRL,
819 .enable_mask = LPC32XX_USB_OTG_AHB_M_CLOCK_ON |
820 LPC32XX_USB_OTG_OTG_CLOCK_ON |
821 LPC32XX_USB_OTG_HOST_CLOCK_ON |
822 LPC32XX_USB_OTG_I2C_CLOCK_ON,
823 .get_rate = local_return_parent_rate,
824};
825
738static int tsc_onoff_enable(struct clk *clk, int enable) 826static int tsc_onoff_enable(struct clk *clk, int enable)
739{ 827{
740 u32 tmp; 828 u32 tmp;
@@ -800,11 +888,17 @@ static int mmc_onoff_enable(struct clk *clk, int enable)
800 u32 tmp; 888 u32 tmp;
801 889
802 tmp = __raw_readl(LPC32XX_CLKPWR_MS_CTRL) & 890 tmp = __raw_readl(LPC32XX_CLKPWR_MS_CTRL) &
803 ~LPC32XX_CLKPWR_MSCARD_SDCARD_EN; 891 ~(LPC32XX_CLKPWR_MSCARD_SDCARD_EN |
892 LPC32XX_CLKPWR_MSCARD_MSDIO_PU_EN |
893 LPC32XX_CLKPWR_MSCARD_MSDIO_PIN_DIS |
894 LPC32XX_CLKPWR_MSCARD_MSDIO0_DIS |
895 LPC32XX_CLKPWR_MSCARD_MSDIO1_DIS |
896 LPC32XX_CLKPWR_MSCARD_MSDIO23_DIS);
804 897
805 /* If rate is 0, disable clock */ 898 /* If rate is 0, disable clock */
806 if (enable != 0) 899 if (enable != 0)
807 tmp |= LPC32XX_CLKPWR_MSCARD_SDCARD_EN; 900 tmp |= LPC32XX_CLKPWR_MSCARD_SDCARD_EN |
901 LPC32XX_CLKPWR_MSCARD_MSDIO_PU_EN;
808 902
809 __raw_writel(tmp, LPC32XX_CLKPWR_MS_CTRL); 903 __raw_writel(tmp, LPC32XX_CLKPWR_MS_CTRL);
810 904
@@ -853,7 +947,7 @@ static unsigned long mmc_round_rate(struct clk *clk, unsigned long rate)
853 947
854static int mmc_set_rate(struct clk *clk, unsigned long rate) 948static int mmc_set_rate(struct clk *clk, unsigned long rate)
855{ 949{
856 u32 oldclk, tmp; 950 u32 tmp;
857 unsigned long prate, div, crate = mmc_round_rate(clk, rate); 951 unsigned long prate, div, crate = mmc_round_rate(clk, rate);
858 952
859 prate = clk->parent->get_rate(clk->parent); 953 prate = clk->parent->get_rate(clk->parent);
@@ -861,16 +955,12 @@ static int mmc_set_rate(struct clk *clk, unsigned long rate)
861 div = prate / crate; 955 div = prate / crate;
862 956
863 /* The MMC clock must be on when accessing an MMC register */ 957 /* The MMC clock must be on when accessing an MMC register */
864 oldclk = __raw_readl(LPC32XX_CLKPWR_MS_CTRL);
865 __raw_writel(oldclk | LPC32XX_CLKPWR_MSCARD_SDCARD_EN,
866 LPC32XX_CLKPWR_MS_CTRL);
867 tmp = __raw_readl(LPC32XX_CLKPWR_MS_CTRL) & 958 tmp = __raw_readl(LPC32XX_CLKPWR_MS_CTRL) &
868 ~LPC32XX_CLKPWR_MSCARD_SDCARD_DIV(0xf); 959 ~LPC32XX_CLKPWR_MSCARD_SDCARD_DIV(0xf);
869 tmp |= LPC32XX_CLKPWR_MSCARD_SDCARD_DIV(div); 960 tmp |= LPC32XX_CLKPWR_MSCARD_SDCARD_DIV(div) |
961 LPC32XX_CLKPWR_MSCARD_SDCARD_EN;
870 __raw_writel(tmp, LPC32XX_CLKPWR_MS_CTRL); 962 __raw_writel(tmp, LPC32XX_CLKPWR_MS_CTRL);
871 963
872 __raw_writel(oldclk, LPC32XX_CLKPWR_MS_CTRL);
873
874 return 0; 964 return 0;
875} 965}
876 966
@@ -1111,6 +1201,7 @@ static struct clk_lookup lookups[] = {
1111 CLKDEV_INIT(NULL, "vfp9_ck", &clk_vfp9), 1201 CLKDEV_INIT(NULL, "vfp9_ck", &clk_vfp9),
1112 CLKDEV_INIT("pl08xdmac", NULL, &clk_dma), 1202 CLKDEV_INIT("pl08xdmac", NULL, &clk_dma),
1113 CLKDEV_INIT("4003c000.watchdog", NULL, &clk_wdt), 1203 CLKDEV_INIT("4003c000.watchdog", NULL, &clk_wdt),
1204 CLKDEV_INIT("4005c000.pwm", NULL, &clk_pwm),
1114 CLKDEV_INIT(NULL, "uart3_ck", &clk_uart3), 1205 CLKDEV_INIT(NULL, "uart3_ck", &clk_uart3),
1115 CLKDEV_INIT(NULL, "uart4_ck", &clk_uart4), 1206 CLKDEV_INIT(NULL, "uart4_ck", &clk_uart4),
1116 CLKDEV_INIT(NULL, "uart5_ck", &clk_uart5), 1207 CLKDEV_INIT(NULL, "uart5_ck", &clk_uart5),
@@ -1120,8 +1211,9 @@ static struct clk_lookup lookups[] = {
1120 CLKDEV_INIT("31020300.i2c", NULL, &clk_i2c2), 1211 CLKDEV_INIT("31020300.i2c", NULL, &clk_i2c2),
1121 CLKDEV_INIT("dev:ssp0", NULL, &clk_ssp0), 1212 CLKDEV_INIT("dev:ssp0", NULL, &clk_ssp0),
1122 CLKDEV_INIT("dev:ssp1", NULL, &clk_ssp1), 1213 CLKDEV_INIT("dev:ssp1", NULL, &clk_ssp1),
1123 CLKDEV_INIT("lpc32xx_keys.0", NULL, &clk_kscan), 1214 CLKDEV_INIT("40050000.key", NULL, &clk_kscan),
1124 CLKDEV_INIT("lpc32xx-nand.0", "nand_ck", &clk_nand), 1215 CLKDEV_INIT("20020000.flash", NULL, &clk_nand),
1216 CLKDEV_INIT("200a8000.flash", NULL, &clk_nand_mlc),
1125 CLKDEV_INIT("40048000.adc", NULL, &clk_adc), 1217 CLKDEV_INIT("40048000.adc", NULL, &clk_adc),
1126 CLKDEV_INIT(NULL, "i2s0_ck", &clk_i2s0), 1218 CLKDEV_INIT(NULL, "i2s0_ck", &clk_i2s0),
1127 CLKDEV_INIT(NULL, "i2s1_ck", &clk_i2s1), 1219 CLKDEV_INIT(NULL, "i2s1_ck", &clk_i2s1),
@@ -1130,6 +1222,9 @@ static struct clk_lookup lookups[] = {
1130 CLKDEV_INIT("31060000.ethernet", NULL, &clk_net), 1222 CLKDEV_INIT("31060000.ethernet", NULL, &clk_net),
1131 CLKDEV_INIT("dev:clcd", NULL, &clk_lcd), 1223 CLKDEV_INIT("dev:clcd", NULL, &clk_lcd),
1132 CLKDEV_INIT("31020000.usbd", "ck_usbd", &clk_usbd), 1224 CLKDEV_INIT("31020000.usbd", "ck_usbd", &clk_usbd),
1225 CLKDEV_INIT("31020000.ohci", "ck_usbd", &clk_usbd),
1226 CLKDEV_INIT("31020000.usbd", "ck_usb_otg", &clk_usb_otg_dev),
1227 CLKDEV_INIT("31020000.ohci", "ck_usb_otg", &clk_usb_otg_host),
1133 CLKDEV_INIT("lpc32xx_rtc", NULL, &clk_rtc), 1228 CLKDEV_INIT("lpc32xx_rtc", NULL, &clk_rtc),
1134}; 1229};
1135 1230
diff --git a/arch/arm/mach-lpc32xx/common.c b/arch/arm/mach-lpc32xx/common.c
index 5c96057b6d7..a48dc2dec48 100644
--- a/arch/arm/mach-lpc32xx/common.c
+++ b/arch/arm/mach-lpc32xx/common.c
@@ -26,6 +26,7 @@
26#include <linux/io.h> 26#include <linux/io.h>
27 27
28#include <asm/mach/map.h> 28#include <asm/mach/map.h>
29#include <asm/system_info.h>
29 30
30#include <mach/hardware.h> 31#include <mach/hardware.h>
31#include <mach/platform.h> 32#include <mach/platform.h>
@@ -224,7 +225,7 @@ void lpc23xx_restart(char mode, const char *cmd)
224 ; 225 ;
225} 226}
226 227
227static int __init lpc32xx_display_uid(void) 228static int __init lpc32xx_check_uid(void)
228{ 229{
229 u32 uid[4]; 230 u32 uid[4];
230 231
@@ -233,6 +234,11 @@ static int __init lpc32xx_display_uid(void)
233 printk(KERN_INFO "LPC32XX unique ID: %08x%08x%08x%08x\n", 234 printk(KERN_INFO "LPC32XX unique ID: %08x%08x%08x%08x\n",
234 uid[3], uid[2], uid[1], uid[0]); 235 uid[3], uid[2], uid[1], uid[0]);
235 236
237 if (!system_serial_low && !system_serial_high) {
238 system_serial_low = uid[0];
239 system_serial_high = uid[1];
240 }
241
236 return 1; 242 return 1;
237} 243}
238arch_initcall(lpc32xx_display_uid); 244arch_initcall(lpc32xx_check_uid);
diff --git a/arch/arm/mach-lpc32xx/include/mach/gpio.h b/arch/arm/mach-lpc32xx/include/mach/gpio.h
index 2ba6ca412be..0052e7a7617 100644
--- a/arch/arm/mach-lpc32xx/include/mach/gpio.h
+++ b/arch/arm/mach-lpc32xx/include/mach/gpio.h
@@ -3,6 +3,4 @@
3 3
4#include "gpio-lpc32xx.h" 4#include "gpio-lpc32xx.h"
5 5
6#define ARCH_NR_GPIOS (LPC32XX_GPO_P3_GRP + LPC32XX_GPO_P3_MAX)
7
8#endif /* __MACH_GPIO_H */ 6#endif /* __MACH_GPIO_H */
diff --git a/arch/arm/mach-lpc32xx/include/mach/platform.h b/arch/arm/mach-lpc32xx/include/mach/platform.h
index c584f5bb164..acc4aabf1c7 100644
--- a/arch/arm/mach-lpc32xx/include/mach/platform.h
+++ b/arch/arm/mach-lpc32xx/include/mach/platform.h
@@ -694,4 +694,18 @@
694#define LPC32XX_GPIO_P2_MUX_CLR _GPREG(0x02C) 694#define LPC32XX_GPIO_P2_MUX_CLR _GPREG(0x02C)
695#define LPC32XX_GPIO_P2_MUX_STATE _GPREG(0x030) 695#define LPC32XX_GPIO_P2_MUX_STATE _GPREG(0x030)
696 696
697/*
698 * USB Otg Registers
699 */
700#define _OTGREG(x) io_p2v(LPC32XX_USB_OTG_BASE + (x))
701#define LPC32XX_USB_OTG_CLK_CTRL _OTGREG(0xFF4)
702#define LPC32XX_USB_OTG_CLK_STAT _OTGREG(0xFF8)
703
704/* USB OTG CLK CTRL bit defines */
705#define LPC32XX_USB_OTG_AHB_M_CLOCK_ON _BIT(4)
706#define LPC32XX_USB_OTG_OTG_CLOCK_ON _BIT(3)
707#define LPC32XX_USB_OTG_I2C_CLOCK_ON _BIT(2)
708#define LPC32XX_USB_OTG_DEV_CLOCK_ON _BIT(1)
709#define LPC32XX_USB_OTG_HOST_CLOCK_ON _BIT(0)
710
697#endif 711#endif
diff --git a/arch/arm/mach-lpc32xx/phy3250.c b/arch/arm/mach-lpc32xx/phy3250.c
index 540106cdb9e..b07dcc90829 100644
--- a/arch/arm/mach-lpc32xx/phy3250.c
+++ b/arch/arm/mach-lpc32xx/phy3250.c
@@ -30,12 +30,13 @@
30#include <linux/amba/bus.h> 30#include <linux/amba/bus.h>
31#include <linux/amba/clcd.h> 31#include <linux/amba/clcd.h>
32#include <linux/amba/pl022.h> 32#include <linux/amba/pl022.h>
33#include <linux/amba/pl08x.h>
34#include <linux/amba/mmci.h>
33#include <linux/of.h> 35#include <linux/of.h>
34#include <linux/of_address.h> 36#include <linux/of_address.h>
35#include <linux/of_irq.h> 37#include <linux/of_irq.h>
36#include <linux/of_platform.h> 38#include <linux/of_platform.h>
37#include <linux/clk.h> 39#include <linux/clk.h>
38#include <linux/amba/pl08x.h>
39 40
40#include <asm/setup.h> 41#include <asm/setup.h>
41#include <asm/mach-types.h> 42#include <asm/mach-types.h>
@@ -50,9 +51,9 @@
50/* 51/*
51 * Mapped GPIOLIB GPIOs 52 * Mapped GPIOLIB GPIOs
52 */ 53 */
53#define SPI0_CS_GPIO LPC32XX_GPIO(LPC32XX_GPIO_P3_GRP, 5) 54#define LCD_POWER_GPIO LPC32XX_GPIO(LPC32XX_GPO_P3_GRP, 0)
54#define LCD_POWER_GPIO LPC32XX_GPIO(LPC32XX_GPO_P3_GRP, 0) 55#define BKL_POWER_GPIO LPC32XX_GPIO(LPC32XX_GPO_P3_GRP, 4)
55#define BKL_POWER_GPIO LPC32XX_GPIO(LPC32XX_GPO_P3_GRP, 4) 56#define MMC_PWR_ENABLE_GPIO LPC32XX_GPIO(LPC32XX_GPO_P3_GRP, 5)
56 57
57/* 58/*
58 * AMBA LCD controller 59 * AMBA LCD controller
@@ -158,24 +159,6 @@ static struct clcd_board lpc32xx_clcd_data = {
158/* 159/*
159 * AMBA SSP (SPI) 160 * AMBA SSP (SPI)
160 */ 161 */
161static void phy3250_spi_cs_set(u32 control)
162{
163 gpio_set_value(SPI0_CS_GPIO, (int) control);
164}
165
166static struct pl022_config_chip spi0_chip_info = {
167 .com_mode = INTERRUPT_TRANSFER,
168 .iface = SSP_INTERFACE_MOTOROLA_SPI,
169 .hierarchy = SSP_MASTER,
170 .slave_tx_disable = 0,
171 .rx_lev_trig = SSP_RX_4_OR_MORE_ELEM,
172 .tx_lev_trig = SSP_TX_4_OR_MORE_EMPTY_LOC,
173 .ctrl_len = SSP_BITS_8,
174 .wait_state = SSP_MWIRE_WAIT_ZERO,
175 .duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX,
176 .cs_control = phy3250_spi_cs_set,
177};
178
179static struct pl022_ssp_controller lpc32xx_ssp0_data = { 162static struct pl022_ssp_controller lpc32xx_ssp0_data = {
180 .bus_id = 0, 163 .bus_id = 0,
181 .num_chipselect = 1, 164 .num_chipselect = 1,
@@ -188,45 +171,56 @@ static struct pl022_ssp_controller lpc32xx_ssp1_data = {
188 .enable_dma = 0, 171 .enable_dma = 0,
189}; 172};
190 173
191/* AT25 driver registration */ 174static struct pl08x_channel_data pl08x_slave_channels[] = {
192static int __init phy3250_spi_board_register(void) 175 {
176 .bus_id = "nand-slc",
177 .min_signal = 1, /* SLC NAND Flash */
178 .max_signal = 1,
179 .periph_buses = PL08X_AHB1,
180 },
181 {
182 .bus_id = "nand-mlc",
183 .min_signal = 12, /* MLC NAND Flash */
184 .max_signal = 12,
185 .periph_buses = PL08X_AHB1,
186 },
187};
188
189static int pl08x_get_signal(const struct pl08x_channel_data *cd)
190{
191 return cd->min_signal;
192}
193
194static void pl08x_put_signal(const struct pl08x_channel_data *cd, int ch)
193{ 195{
194#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
195 static struct spi_board_info info[] = {
196 {
197 .modalias = "spidev",
198 .max_speed_hz = 5000000,
199 .bus_num = 0,
200 .chip_select = 0,
201 .controller_data = &spi0_chip_info,
202 },
203 };
204
205#else
206 static struct spi_eeprom eeprom = {
207 .name = "at25256a",
208 .byte_len = 0x8000,
209 .page_size = 64,
210 .flags = EE_ADDR2,
211 };
212
213 static struct spi_board_info info[] = {
214 {
215 .modalias = "at25",
216 .max_speed_hz = 5000000,
217 .bus_num = 0,
218 .chip_select = 0,
219 .mode = SPI_MODE_0,
220 .platform_data = &eeprom,
221 .controller_data = &spi0_chip_info,
222 },
223 };
224#endif
225 return spi_register_board_info(info, ARRAY_SIZE(info));
226} 196}
227arch_initcall(phy3250_spi_board_register);
228 197
229static struct pl08x_platform_data pl08x_pd = { 198static struct pl08x_platform_data pl08x_pd = {
199 .slave_channels = &pl08x_slave_channels[0],
200 .num_slave_channels = ARRAY_SIZE(pl08x_slave_channels),
201 .get_signal = pl08x_get_signal,
202 .put_signal = pl08x_put_signal,
203 .lli_buses = PL08X_AHB1,
204 .mem_buses = PL08X_AHB1,
205};
206
207static int mmc_handle_ios(struct device *dev, struct mmc_ios *ios)
208{
209 /* Only on and off are supported */
210 if (ios->power_mode == MMC_POWER_OFF)
211 gpio_set_value(MMC_PWR_ENABLE_GPIO, 0);
212 else
213 gpio_set_value(MMC_PWR_ENABLE_GPIO, 1);
214 return 0;
215}
216
217static struct mmci_platform_data lpc32xx_mmci_data = {
218 .ocr_mask = MMC_VDD_30_31 | MMC_VDD_31_32 |
219 MMC_VDD_32_33 | MMC_VDD_33_34,
220 .ios_handler = mmc_handle_ios,
221 .dma_filter = NULL,
222 /* No DMA for now since AMBA PL080 dmaengine driver only does scatter
223 * gather, and the MMCI driver doesn't do it this way */
230}; 224};
231 225
232static const struct of_dev_auxdata lpc32xx_auxdata_lookup[] __initconst = { 226static const struct of_dev_auxdata lpc32xx_auxdata_lookup[] __initconst = {
@@ -234,6 +228,8 @@ static const struct of_dev_auxdata lpc32xx_auxdata_lookup[] __initconst = {
234 OF_DEV_AUXDATA("arm,pl022", 0x2008C000, "dev:ssp1", &lpc32xx_ssp1_data), 228 OF_DEV_AUXDATA("arm,pl022", 0x2008C000, "dev:ssp1", &lpc32xx_ssp1_data),
235 OF_DEV_AUXDATA("arm,pl110", 0x31040000, "dev:clcd", &lpc32xx_clcd_data), 229 OF_DEV_AUXDATA("arm,pl110", 0x31040000, "dev:clcd", &lpc32xx_clcd_data),
236 OF_DEV_AUXDATA("arm,pl080", 0x31000000, "pl08xdmac", &pl08x_pd), 230 OF_DEV_AUXDATA("arm,pl080", 0x31000000, "pl08xdmac", &pl08x_pd),
231 OF_DEV_AUXDATA("arm,pl18x", 0x20098000, "20098000.sd",
232 &lpc32xx_mmci_data),
237 { } 233 { }
238}; 234};
239 235
@@ -241,10 +237,6 @@ static void __init lpc3250_machine_init(void)
241{ 237{
242 u32 tmp; 238 u32 tmp;
243 239
244 /* Setup SLC NAND controller muxing */
245 __raw_writel(LPC32XX_CLKPWR_NANDCLK_SEL_SLC,
246 LPC32XX_CLKPWR_NAND_CLK_CTRL);
247
248 /* Setup LCD muxing to RGB565 */ 240 /* Setup LCD muxing to RGB565 */
249 tmp = __raw_readl(LPC32XX_CLKPWR_LCDCLK_CTRL) & 241 tmp = __raw_readl(LPC32XX_CLKPWR_LCDCLK_CTRL) &
250 ~(LPC32XX_CLKPWR_LCDCTRL_LCDTYPE_MSK | 242 ~(LPC32XX_CLKPWR_LCDCTRL_LCDTYPE_MSK |
@@ -252,47 +244,8 @@ static void __init lpc3250_machine_init(void)
252 tmp |= LPC32XX_CLKPWR_LCDCTRL_LCDTYPE_TFT16; 244 tmp |= LPC32XX_CLKPWR_LCDCTRL_LCDTYPE_TFT16;
253 __raw_writel(tmp, LPC32XX_CLKPWR_LCDCLK_CTRL); 245 __raw_writel(tmp, LPC32XX_CLKPWR_LCDCLK_CTRL);
254 246
255 /* Set up USB power */
256 tmp = __raw_readl(LPC32XX_CLKPWR_USB_CTRL);
257 tmp |= LPC32XX_CLKPWR_USBCTRL_HCLK_EN |
258 LPC32XX_CLKPWR_USBCTRL_USBI2C_EN;
259 __raw_writel(tmp, LPC32XX_CLKPWR_USB_CTRL);
260
261 /* Set up I2C pull levels */
262 tmp = __raw_readl(LPC32XX_CLKPWR_I2C_CLK_CTRL);
263 tmp |= LPC32XX_CLKPWR_I2CCLK_USBI2CHI_DRIVE |
264 LPC32XX_CLKPWR_I2CCLK_I2C2HI_DRIVE;
265 __raw_writel(tmp, LPC32XX_CLKPWR_I2C_CLK_CTRL);
266
267 /* Disable IrDA pulsing support on UART6 */
268 tmp = __raw_readl(LPC32XX_UARTCTL_CTRL);
269 tmp |= LPC32XX_UART_UART6_IRDAMOD_BYPASS;
270 __raw_writel(tmp, LPC32XX_UARTCTL_CTRL);
271
272 /* Enable DMA for I2S1 channel */
273 tmp = __raw_readl(LPC32XX_CLKPWR_I2S_CLK_CTRL);
274 tmp = LPC32XX_CLKPWR_I2SCTRL_I2S1_USE_DMA;
275 __raw_writel(tmp, LPC32XX_CLKPWR_I2S_CLK_CTRL);
276
277 lpc32xx_serial_init(); 247 lpc32xx_serial_init();
278 248
279 /*
280 * AMBA peripheral clocks need to be enabled prior to AMBA device
281 * detection or a data fault will occur, so enable the clocks
282 * here.
283 */
284 tmp = __raw_readl(LPC32XX_CLKPWR_LCDCLK_CTRL);
285 __raw_writel((tmp | LPC32XX_CLKPWR_LCDCTRL_CLK_EN),
286 LPC32XX_CLKPWR_LCDCLK_CTRL);
287
288 tmp = __raw_readl(LPC32XX_CLKPWR_SSP_CLK_CTRL);
289 __raw_writel((tmp | LPC32XX_CLKPWR_SSPCTRL_SSPCLK0_EN),
290 LPC32XX_CLKPWR_SSP_CLK_CTRL);
291
292 tmp = __raw_readl(LPC32XX_CLKPWR_DMA_CLK_CTRL);
293 __raw_writel((tmp | LPC32XX_CLKPWR_DMACLKCTRL_CLK_EN),
294 LPC32XX_CLKPWR_DMA_CLK_CTRL);
295
296 /* Test clock needed for UDA1380 initial init */ 249 /* Test clock needed for UDA1380 initial init */
297 __raw_writel(LPC32XX_CLKPWR_TESTCLK2_SEL_MOSC | 250 __raw_writel(LPC32XX_CLKPWR_TESTCLK2_SEL_MOSC |
298 LPC32XX_CLKPWR_TESTCLK_TESTCLK2_EN, 251 LPC32XX_CLKPWR_TESTCLK_TESTCLK2_EN,
@@ -302,12 +255,10 @@ static void __init lpc3250_machine_init(void)
302 lpc32xx_auxdata_lookup, NULL); 255 lpc32xx_auxdata_lookup, NULL);
303 256
304 /* Register GPIOs used on this board */ 257 /* Register GPIOs used on this board */
305 if (gpio_request(SPI0_CS_GPIO, "spi0 cs")) 258 if (gpio_request(MMC_PWR_ENABLE_GPIO, "mmc_power_en"))
306 printk(KERN_ERR "Error requesting gpio %u", 259 pr_err("Error requesting gpio %u", MMC_PWR_ENABLE_GPIO);
307 SPI0_CS_GPIO); 260 else if (gpio_direction_output(MMC_PWR_ENABLE_GPIO, 1))
308 else if (gpio_direction_output(SPI0_CS_GPIO, 1)) 261 pr_err("Error setting gpio %u to output", MMC_PWR_ENABLE_GPIO);
309 printk(KERN_ERR "Error setting gpio %u to output",
310 SPI0_CS_GPIO);
311} 262}
312 263
313static char const *lpc32xx_dt_compat[] __initdata = { 264static char const *lpc32xx_dt_compat[] __initdata = {
diff --git a/arch/arm/mach-lpc32xx/serial.c b/arch/arm/mach-lpc32xx/serial.c
index f2735281616..05621a29fba 100644
--- a/arch/arm/mach-lpc32xx/serial.c
+++ b/arch/arm/mach-lpc32xx/serial.c
@@ -31,59 +31,6 @@
31 31
32#define LPC32XX_SUART_FIFO_SIZE 64 32#define LPC32XX_SUART_FIFO_SIZE 64
33 33
34/* Standard 8250/16550 compatible serial ports */
35static struct plat_serial8250_port serial_std_platform_data[] = {
36#ifdef CONFIG_ARCH_LPC32XX_UART5_SELECT
37 {
38 .membase = io_p2v(LPC32XX_UART5_BASE),
39 .mapbase = LPC32XX_UART5_BASE,
40 .irq = IRQ_LPC32XX_UART_IIR5,
41 .uartclk = LPC32XX_MAIN_OSC_FREQ,
42 .regshift = 2,
43 .iotype = UPIO_MEM32,
44 .flags = UPF_BOOT_AUTOCONF | UPF_BUGGY_UART |
45 UPF_SKIP_TEST,
46 },
47#endif
48#ifdef CONFIG_ARCH_LPC32XX_UART3_SELECT
49 {
50 .membase = io_p2v(LPC32XX_UART3_BASE),
51 .mapbase = LPC32XX_UART3_BASE,
52 .irq = IRQ_LPC32XX_UART_IIR3,
53 .uartclk = LPC32XX_MAIN_OSC_FREQ,
54 .regshift = 2,
55 .iotype = UPIO_MEM32,
56 .flags = UPF_BOOT_AUTOCONF | UPF_BUGGY_UART |
57 UPF_SKIP_TEST,
58 },
59#endif
60#ifdef CONFIG_ARCH_LPC32XX_UART4_SELECT
61 {
62 .membase = io_p2v(LPC32XX_UART4_BASE),
63 .mapbase = LPC32XX_UART4_BASE,
64 .irq = IRQ_LPC32XX_UART_IIR4,
65 .uartclk = LPC32XX_MAIN_OSC_FREQ,
66 .regshift = 2,
67 .iotype = UPIO_MEM32,
68 .flags = UPF_BOOT_AUTOCONF | UPF_BUGGY_UART |
69 UPF_SKIP_TEST,
70 },
71#endif
72#ifdef CONFIG_ARCH_LPC32XX_UART6_SELECT
73 {
74 .membase = io_p2v(LPC32XX_UART6_BASE),
75 .mapbase = LPC32XX_UART6_BASE,
76 .irq = IRQ_LPC32XX_UART_IIR6,
77 .uartclk = LPC32XX_MAIN_OSC_FREQ,
78 .regshift = 2,
79 .iotype = UPIO_MEM32,
80 .flags = UPF_BOOT_AUTOCONF | UPF_BUGGY_UART |
81 UPF_SKIP_TEST,
82 },
83#endif
84 { },
85};
86
87struct uartinit { 34struct uartinit {
88 char *uart_ck_name; 35 char *uart_ck_name;
89 u32 ck_mode_mask; 36 u32 ck_mode_mask;
@@ -92,7 +39,6 @@ struct uartinit {
92}; 39};
93 40
94static struct uartinit uartinit_data[] __initdata = { 41static struct uartinit uartinit_data[] __initdata = {
95#ifdef CONFIG_ARCH_LPC32XX_UART5_SELECT
96 { 42 {
97 .uart_ck_name = "uart5_ck", 43 .uart_ck_name = "uart5_ck",
98 .ck_mode_mask = 44 .ck_mode_mask =
@@ -100,8 +46,6 @@ static struct uartinit uartinit_data[] __initdata = {
100 .pdiv_clk_reg = LPC32XX_CLKPWR_UART5_CLK_CTRL, 46 .pdiv_clk_reg = LPC32XX_CLKPWR_UART5_CLK_CTRL,
101 .mapbase = LPC32XX_UART5_BASE, 47 .mapbase = LPC32XX_UART5_BASE,
102 }, 48 },
103#endif
104#ifdef CONFIG_ARCH_LPC32XX_UART3_SELECT
105 { 49 {
106 .uart_ck_name = "uart3_ck", 50 .uart_ck_name = "uart3_ck",
107 .ck_mode_mask = 51 .ck_mode_mask =
@@ -109,8 +53,6 @@ static struct uartinit uartinit_data[] __initdata = {
109 .pdiv_clk_reg = LPC32XX_CLKPWR_UART3_CLK_CTRL, 53 .pdiv_clk_reg = LPC32XX_CLKPWR_UART3_CLK_CTRL,
110 .mapbase = LPC32XX_UART3_BASE, 54 .mapbase = LPC32XX_UART3_BASE,
111 }, 55 },
112#endif
113#ifdef CONFIG_ARCH_LPC32XX_UART4_SELECT
114 { 56 {
115 .uart_ck_name = "uart4_ck", 57 .uart_ck_name = "uart4_ck",
116 .ck_mode_mask = 58 .ck_mode_mask =
@@ -118,8 +60,6 @@ static struct uartinit uartinit_data[] __initdata = {
118 .pdiv_clk_reg = LPC32XX_CLKPWR_UART4_CLK_CTRL, 60 .pdiv_clk_reg = LPC32XX_CLKPWR_UART4_CLK_CTRL,
119 .mapbase = LPC32XX_UART4_BASE, 61 .mapbase = LPC32XX_UART4_BASE,
120 }, 62 },
121#endif
122#ifdef CONFIG_ARCH_LPC32XX_UART6_SELECT
123 { 63 {
124 .uart_ck_name = "uart6_ck", 64 .uart_ck_name = "uart6_ck",
125 .ck_mode_mask = 65 .ck_mode_mask =
@@ -127,19 +67,6 @@ static struct uartinit uartinit_data[] __initdata = {
127 .pdiv_clk_reg = LPC32XX_CLKPWR_UART6_CLK_CTRL, 67 .pdiv_clk_reg = LPC32XX_CLKPWR_UART6_CLK_CTRL,
128 .mapbase = LPC32XX_UART6_BASE, 68 .mapbase = LPC32XX_UART6_BASE,
129 }, 69 },
130#endif
131};
132
133static struct platform_device serial_std_platform_device = {
134 .name = "serial8250",
135 .id = 0,
136 .dev = {
137 .platform_data = serial_std_platform_data,
138 },
139};
140
141static struct platform_device *lpc32xx_serial_devs[] __initdata = {
142 &serial_std_platform_device,
143}; 70};
144 71
145void __init lpc32xx_serial_init(void) 72void __init lpc32xx_serial_init(void)
@@ -156,15 +83,8 @@ void __init lpc32xx_serial_init(void)
156 clk = clk_get(NULL, uartinit_data[i].uart_ck_name); 83 clk = clk_get(NULL, uartinit_data[i].uart_ck_name);
157 if (!IS_ERR(clk)) { 84 if (!IS_ERR(clk)) {
158 clk_enable(clk); 85 clk_enable(clk);
159 serial_std_platform_data[i].uartclk =
160 clk_get_rate(clk);
161 } 86 }
162 87
163 /* Fall back on main osc rate if clock rate return fails */
164 if (serial_std_platform_data[i].uartclk == 0)
165 serial_std_platform_data[i].uartclk =
166 LPC32XX_MAIN_OSC_FREQ;
167
168 /* Setup UART clock modes for all UARTs, disable autoclock */ 88 /* Setup UART clock modes for all UARTs, disable autoclock */
169 clkmodes |= uartinit_data[i].ck_mode_mask; 89 clkmodes |= uartinit_data[i].ck_mode_mask;
170 90
@@ -189,7 +109,7 @@ void __init lpc32xx_serial_init(void)
189 __raw_writel(clkmodes, LPC32XX_UARTCTL_CLKMODE); 109 __raw_writel(clkmodes, LPC32XX_UARTCTL_CLKMODE);
190 for (i = 0; i < ARRAY_SIZE(uartinit_data); i++) { 110 for (i = 0; i < ARRAY_SIZE(uartinit_data); i++) {
191 /* Force a flush of the RX FIFOs to work around a HW bug */ 111 /* Force a flush of the RX FIFOs to work around a HW bug */
192 puart = serial_std_platform_data[i].mapbase; 112 puart = uartinit_data[i].mapbase;
193 __raw_writel(0xC1, LPC32XX_UART_IIR_FCR(puart)); 113 __raw_writel(0xC1, LPC32XX_UART_IIR_FCR(puart));
194 __raw_writel(0x00, LPC32XX_UART_DLL_FIFO(puart)); 114 __raw_writel(0x00, LPC32XX_UART_DLL_FIFO(puart));
195 j = LPC32XX_SUART_FIFO_SIZE; 115 j = LPC32XX_SUART_FIFO_SIZE;
@@ -198,11 +118,13 @@ void __init lpc32xx_serial_init(void)
198 __raw_writel(0, LPC32XX_UART_IIR_FCR(puart)); 118 __raw_writel(0, LPC32XX_UART_IIR_FCR(puart));
199 } 119 }
200 120
121 /* Disable IrDA pulsing support on UART6 */
122 tmp = __raw_readl(LPC32XX_UARTCTL_CTRL);
123 tmp |= LPC32XX_UART_UART6_IRDAMOD_BYPASS;
124 __raw_writel(tmp, LPC32XX_UARTCTL_CTRL);
125
201 /* Disable UART5->USB transparent mode or USB won't work */ 126 /* Disable UART5->USB transparent mode or USB won't work */
202 tmp = __raw_readl(LPC32XX_UARTCTL_CTRL); 127 tmp = __raw_readl(LPC32XX_UARTCTL_CTRL);
203 tmp &= ~LPC32XX_UART_U5_ROUTE_TO_USB; 128 tmp &= ~LPC32XX_UART_U5_ROUTE_TO_USB;
204 __raw_writel(tmp, LPC32XX_UARTCTL_CTRL); 129 __raw_writel(tmp, LPC32XX_UARTCTL_CTRL);
205
206 platform_add_devices(lpc32xx_serial_devs,
207 ARRAY_SIZE(lpc32xx_serial_devs));
208} 130}
diff --git a/arch/arm/mach-mmp/gplugd.c b/arch/arm/mach-mmp/gplugd.c
index f516e74ce0d..5c3d61ee729 100644
--- a/arch/arm/mach-mmp/gplugd.c
+++ b/arch/arm/mach-mmp/gplugd.c
@@ -14,6 +14,7 @@
14#include <asm/mach/arch.h> 14#include <asm/mach/arch.h>
15#include <asm/mach-types.h> 15#include <asm/mach-types.h>
16 16
17#include <mach/irqs.h>
17#include <mach/pxa168.h> 18#include <mach/pxa168.h>
18#include <mach/mfp-pxa168.h> 19#include <mach/mfp-pxa168.h>
19 20
diff --git a/arch/arm/mach-mmp/sram.c b/arch/arm/mach-mmp/sram.c
index 4304f951937..7e8a5a2e1ec 100644
--- a/arch/arm/mach-mmp/sram.c
+++ b/arch/arm/mach-mmp/sram.c
@@ -68,7 +68,7 @@ static int __devinit sram_probe(struct platform_device *pdev)
68 struct resource *res; 68 struct resource *res;
69 int ret = 0; 69 int ret = 0;
70 70
71 if (!pdata && !pdata->pool_name) 71 if (!pdata || !pdata->pool_name)
72 return -ENODEV; 72 return -ENODEV;
73 73
74 info = kzalloc(sizeof(*info), GFP_KERNEL); 74 info = kzalloc(sizeof(*info), GFP_KERNEL);
diff --git a/arch/arm/mach-msm/platsmp.c b/arch/arm/mach-msm/platsmp.c
index db0117ec55f..e012dc8391c 100644
--- a/arch/arm/mach-msm/platsmp.c
+++ b/arch/arm/mach-msm/platsmp.c
@@ -127,7 +127,7 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
127 * the boot monitor to read the system wide flags register, 127 * the boot monitor to read the system wide flags register,
128 * and branch to the address found there. 128 * and branch to the address found there.
129 */ 129 */
130 gic_raise_softirq(cpumask_of(cpu), 1); 130 gic_raise_softirq(cpumask_of(cpu), 0);
131 131
132 timeout = jiffies + (1 * HZ); 132 timeout = jiffies + (1 * HZ);
133 while (time_before(jiffies, timeout)) { 133 while (time_before(jiffies, timeout)) {
diff --git a/arch/arm/mach-mv78xx0/addr-map.c b/arch/arm/mach-mv78xx0/addr-map.c
index 62b53d710ef..a9bc84180d2 100644
--- a/arch/arm/mach-mv78xx0/addr-map.c
+++ b/arch/arm/mach-mv78xx0/addr-map.c
@@ -37,7 +37,7 @@
37#define WIN0_OFF(n) (BRIDGE_VIRT_BASE + 0x0000 + ((n) << 4)) 37#define WIN0_OFF(n) (BRIDGE_VIRT_BASE + 0x0000 + ((n) << 4))
38#define WIN8_OFF(n) (BRIDGE_VIRT_BASE + 0x0900 + (((n) - 8) << 4)) 38#define WIN8_OFF(n) (BRIDGE_VIRT_BASE + 0x0900 + (((n) - 8) << 4))
39 39
40static void __init __iomem *win_cfg_base(int win) 40static void __init __iomem *win_cfg_base(const struct orion_addr_map_cfg *cfg, int win)
41{ 41{
42 /* 42 /*
43 * Find the control register base address for this window. 43 * Find the control register base address for this window.
diff --git a/arch/arm/mach-mv78xx0/common.c b/arch/arm/mach-mv78xx0/common.c
index b4c53b846c9..3057f7d4329 100644
--- a/arch/arm/mach-mv78xx0/common.c
+++ b/arch/arm/mach-mv78xx0/common.c
@@ -213,7 +213,8 @@ void __init mv78xx0_ge00_init(struct mv643xx_eth_platform_data *eth_data)
213{ 213{
214 orion_ge00_init(eth_data, 214 orion_ge00_init(eth_data,
215 GE00_PHYS_BASE, IRQ_MV78XX0_GE00_SUM, 215 GE00_PHYS_BASE, IRQ_MV78XX0_GE00_SUM,
216 IRQ_MV78XX0_GE_ERR); 216 IRQ_MV78XX0_GE_ERR,
217 MV643XX_TX_CSUM_DEFAULT_LIMIT);
217} 218}
218 219
219 220
@@ -224,7 +225,8 @@ void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data)
224{ 225{
225 orion_ge01_init(eth_data, 226 orion_ge01_init(eth_data,
226 GE01_PHYS_BASE, IRQ_MV78XX0_GE01_SUM, 227 GE01_PHYS_BASE, IRQ_MV78XX0_GE01_SUM,
227 NO_IRQ); 228 NO_IRQ,
229 MV643XX_TX_CSUM_DEFAULT_LIMIT);
228} 230}
229 231
230 232
diff --git a/arch/arm/mach-mv78xx0/irq.c b/arch/arm/mach-mv78xx0/irq.c
index e421b701663..eff9a750bbe 100644
--- a/arch/arm/mach-mv78xx0/irq.c
+++ b/arch/arm/mach-mv78xx0/irq.c
@@ -9,19 +9,17 @@
9 */ 9 */
10#include <linux/gpio.h> 10#include <linux/gpio.h>
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/pci.h>
14#include <linux/irq.h> 12#include <linux/irq.h>
15#include <mach/bridge-regs.h> 13#include <mach/bridge-regs.h>
16#include <plat/irq.h> 14#include <plat/irq.h>
17#include "common.h" 15#include "common.h"
18 16
19static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc) 17static int __initdata gpio0_irqs[4] = {
20{ 18 IRQ_MV78XX0_GPIO_0_7,
21 BUG_ON(irq < IRQ_MV78XX0_GPIO_0_7 || irq > IRQ_MV78XX0_GPIO_24_31); 19 IRQ_MV78XX0_GPIO_8_15,
22 20 IRQ_MV78XX0_GPIO_16_23,
23 orion_gpio_irq_handler((irq - IRQ_MV78XX0_GPIO_0_7) << 3); 21 IRQ_MV78XX0_GPIO_24_31,
24} 22};
25 23
26void __init mv78xx0_init_irq(void) 24void __init mv78xx0_init_irq(void)
27{ 25{
@@ -34,11 +32,7 @@ void __init mv78xx0_init_irq(void)
34 * registers for core #1 are at an offset of 0x18 from those of 32 * registers for core #1 are at an offset of 0x18 from those of
35 * core #0.) 33 * core #0.)
36 */ 34 */
37 orion_gpio_init(0, 32, GPIO_VIRT_BASE, 35 orion_gpio_init(NULL, 0, 32, (void __iomem *)GPIO_VIRT_BASE,
38 mv78xx0_core_index() ? 0x18 : 0, 36 mv78xx0_core_index() ? 0x18 : 0,
39 IRQ_MV78XX0_GPIO_START); 37 IRQ_MV78XX0_GPIO_START, gpio0_irqs);
40 irq_set_chained_handler(IRQ_MV78XX0_GPIO_0_7, gpio_irq_handler);
41 irq_set_chained_handler(IRQ_MV78XX0_GPIO_8_15, gpio_irq_handler);
42 irq_set_chained_handler(IRQ_MV78XX0_GPIO_16_23, gpio_irq_handler);
43 irq_set_chained_handler(IRQ_MV78XX0_GPIO_24_31, gpio_irq_handler);
44} 38}
diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
new file mode 100644
index 00000000000..caa2c5e734f
--- /dev/null
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -0,0 +1,16 @@
1if ARCH_MVEBU
2
3menu "Marvell SOC with device tree"
4
5config MACH_ARMADA_370_XP
6 bool "Marvell Armada 370 and Aramada XP boards"
7 select ARMADA_370_XP_TIMER
8 select CPU_V7
9 help
10
11 Say 'Y' here if you want your kernel to support boards based on
12 Marvell Armada 370 or Armada XP with device tree.
13
14endmenu
15
16endif
diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile
new file mode 100644
index 00000000000..e61d2b8fdf5
--- /dev/null
+++ b/arch/arm/mach-mvebu/Makefile
@@ -0,0 +1,2 @@
1obj-y += system-controller.o
2obj-$(CONFIG_MACH_ARMADA_370_XP) += armada-370-xp.o irq-armada-370-xp.o
diff --git a/arch/arm/mach-mvebu/Makefile.boot b/arch/arm/mach-mvebu/Makefile.boot
new file mode 100644
index 00000000000..2579a2fc233
--- /dev/null
+++ b/arch/arm/mach-mvebu/Makefile.boot
@@ -0,0 +1,3 @@
1zreladdr-y := 0x00008000
2dtb-$(CONFIG_MACH_ARMADA_370_XP) += armada-370-db.dtb
3dtb-$(CONFIG_MACH_ARMADA_370_XP) += armada-xp-db.dtb
diff --git a/arch/arm/mach-mvebu/armada-370-xp.c b/arch/arm/mach-mvebu/armada-370-xp.c
new file mode 100644
index 00000000000..4ef923b032e
--- /dev/null
+++ b/arch/arm/mach-mvebu/armada-370-xp.c
@@ -0,0 +1,63 @@
1/*
2 * Device Tree support for Armada 370 and XP platforms.
3 *
4 * Copyright (C) 2012 Marvell
5 *
6 * Lior Amsalem <alior@marvell.com>
7 * Gregory CLEMENT <gregory.clement@free-electrons.com>
8 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
9 *
10 * This file is licensed under the terms of the GNU General Public
11 * License version 2. This program is licensed "as is" without any
12 * warranty of any kind, whether express or implied.
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/of_platform.h>
18#include <linux/io.h>
19#include <linux/time-armada-370-xp.h>
20#include <asm/mach/arch.h>
21#include <asm/mach/map.h>
22#include <asm/mach/time.h>
23#include <mach/armada-370-xp.h>
24#include "common.h"
25
26static struct map_desc armada_370_xp_io_desc[] __initdata = {
27 {
28 .virtual = ARMADA_370_XP_REGS_VIRT_BASE,
29 .pfn = __phys_to_pfn(ARMADA_370_XP_REGS_PHYS_BASE),
30 .length = ARMADA_370_XP_REGS_SIZE,
31 .type = MT_DEVICE,
32 },
33};
34
35void __init armada_370_xp_map_io(void)
36{
37 iotable_init(armada_370_xp_io_desc, ARRAY_SIZE(armada_370_xp_io_desc));
38}
39
40struct sys_timer armada_370_xp_timer = {
41 .init = armada_370_xp_timer_init,
42};
43
44static void __init armada_370_xp_dt_init(void)
45{
46 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
47}
48
49static const char * const armada_370_xp_dt_board_dt_compat[] = {
50 "marvell,a370-db",
51 "marvell,axp-db",
52 NULL,
53};
54
55DT_MACHINE_START(ARMADA_XP_DT, "Marvell Aramada 370/XP (Device Tree)")
56 .init_machine = armada_370_xp_dt_init,
57 .map_io = armada_370_xp_map_io,
58 .init_irq = armada_370_xp_init_irq,
59 .handle_irq = armada_370_xp_handle_irq,
60 .timer = &armada_370_xp_timer,
61 .restart = mvebu_restart,
62 .dt_compat = armada_370_xp_dt_board_dt_compat,
63MACHINE_END
diff --git a/arch/arm/mach-mvebu/common.h b/arch/arm/mach-mvebu/common.h
new file mode 100644
index 00000000000..02f89eaa25f
--- /dev/null
+++ b/arch/arm/mach-mvebu/common.h
@@ -0,0 +1,23 @@
1/*
2 * Core functions for Marvell System On Chip
3 *
4 * Copyright (C) 2012 Marvell
5 *
6 * Lior Amsalem <alior@marvell.com>
7 * Gregory CLEMENT <gregory.clement@free-electrons.com>
8 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
9 *
10 * This file is licensed under the terms of the GNU General Public
11 * License version 2. This program is licensed "as is" without any
12 * warranty of any kind, whether express or implied.
13 */
14
15#ifndef __ARCH_MVEBU_COMMON_H
16#define __ARCH_MVEBU_COMMON_H
17
18void mvebu_restart(char mode, const char *cmd);
19
20void armada_370_xp_init_irq(void);
21void armada_370_xp_handle_irq(struct pt_regs *regs);
22
23#endif
diff --git a/arch/arm/mach-mvebu/include/mach/armada-370-xp.h b/arch/arm/mach-mvebu/include/mach/armada-370-xp.h
new file mode 100644
index 00000000000..25f0ca8d782
--- /dev/null
+++ b/arch/arm/mach-mvebu/include/mach/armada-370-xp.h
@@ -0,0 +1,22 @@
1/*
2 * Generic definitions for Marvell Armada_370_XP SoCs
3 *
4 * Copyright (C) 2012 Marvell
5 *
6 * Lior Amsalem <alior@marvell.com>
7 * Gregory CLEMENT <gregory.clement@free-electrons.com>
8 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
9 *
10 * This file is licensed under the terms of the GNU General Public
11 * License version 2. This program is licensed "as is" without any
12 * warranty of any kind, whether express or implied.
13 */
14
15#ifndef __MACH_ARMADA_370_XP_H
16#define __MACH_ARMADA_370_XP_H
17
18#define ARMADA_370_XP_REGS_PHYS_BASE 0xd0000000
19#define ARMADA_370_XP_REGS_VIRT_BASE 0xfeb00000
20#define ARMADA_370_XP_REGS_SIZE SZ_1M
21
22#endif /* __MACH_ARMADA_370_XP_H */
diff --git a/arch/arm/mach-mvebu/include/mach/debug-macro.S b/arch/arm/mach-mvebu/include/mach/debug-macro.S
new file mode 100644
index 00000000000..22825760c7e
--- /dev/null
+++ b/arch/arm/mach-mvebu/include/mach/debug-macro.S
@@ -0,0 +1,24 @@
1/*
2 * Early serial output macro for Marvell SoC
3 *
4 * Copyright (C) 2012 Marvell
5 *
6 * Lior Amsalem <alior@marvell.com>
7 * Gregory Clement <gregory.clement@free-electrons.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 <mach/armada-370-xp.h>
15
16 .macro addruart, rp, rv, tmp
17 ldr \rp, =ARMADA_370_XP_REGS_PHYS_BASE
18 ldr \rv, =ARMADA_370_XP_REGS_VIRT_BASE
19 orr \rp, \rp, #0x00012000
20 orr \rv, \rv, #0x00012000
21 .endm
22
23#define UART_SHIFT 2
24#include <asm/hardware/debug-8250.S>
diff --git a/arch/arm/mach-mvebu/include/mach/timex.h b/arch/arm/mach-mvebu/include/mach/timex.h
new file mode 100644
index 00000000000..ab324a3748f
--- /dev/null
+++ b/arch/arm/mach-mvebu/include/mach/timex.h
@@ -0,0 +1,13 @@
1/*
2 * Marvell Armada SoC time definitions
3 *
4 * Copyright (C) 2012 Marvell
5 *
6 * Lior Amsalem <alior@marvell.com>
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
13#define CLOCK_TICK_RATE (100 * HZ)
diff --git a/arch/arm/mach-mvebu/include/mach/uncompress.h b/arch/arm/mach-mvebu/include/mach/uncompress.h
new file mode 100644
index 00000000000..d6a100ccf30
--- /dev/null
+++ b/arch/arm/mach-mvebu/include/mach/uncompress.h
@@ -0,0 +1,43 @@
1/*
2 * Marvell Armada SoC kernel uncompression UART routines
3 *
4 * Copyright (C) 2012 Marvell
5 *
6 * Lior Amsalem <alior@marvell.com>
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
13#include <mach/armada-370-xp.h>
14
15#define UART_THR ((volatile unsigned char *)(ARMADA_370_XP_REGS_PHYS_BASE\
16 + 0x12000))
17#define UART_LSR ((volatile unsigned char *)(ARMADA_370_XP_REGS_PHYS_BASE\
18 + 0x12014))
19
20#define LSR_THRE 0x20
21
22static void putc(const char c)
23{
24 int i;
25
26 for (i = 0; i < 0x1000; i++) {
27 /* Transmit fifo not full? */
28 if (*UART_LSR & LSR_THRE)
29 break;
30 }
31
32 *UART_THR = c;
33}
34
35static void flush(void)
36{
37}
38
39/*
40 * nothing to do
41 */
42#define arch_decomp_setup()
43#define arch_decomp_wdog()
diff --git a/arch/arm/mach-mvebu/irq-armada-370-xp.c b/arch/arm/mach-mvebu/irq-armada-370-xp.c
new file mode 100644
index 00000000000..5f5f9394b6b
--- /dev/null
+++ b/arch/arm/mach-mvebu/irq-armada-370-xp.c
@@ -0,0 +1,133 @@
1/*
2 * Marvell Armada 370 and Armada XP SoC IRQ handling
3 *
4 * Copyright (C) 2012 Marvell
5 *
6 * Lior Amsalem <alior@marvell.com>
7 * Gregory CLEMENT <gregory.clement@free-electrons.com>
8 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
9 * Ben Dooks <ben.dooks@codethink.co.uk>
10 *
11 * This file is licensed under the terms of the GNU General Public
12 * License version 2. This program is licensed "as is" without any
13 * warranty of any kind, whether express or implied.
14 */
15
16#include <linux/kernel.h>
17#include <linux/module.h>
18#include <linux/init.h>
19#include <linux/irq.h>
20#include <linux/interrupt.h>
21#include <linux/io.h>
22#include <linux/of_address.h>
23#include <linux/of_irq.h>
24#include <linux/irqdomain.h>
25#include <asm/mach/arch.h>
26#include <asm/exception.h>
27
28/* Interrupt Controller Registers Map */
29#define ARMADA_370_XP_INT_SET_MASK_OFFS (0x48)
30#define ARMADA_370_XP_INT_CLEAR_MASK_OFFS (0x4C)
31
32#define ARMADA_370_XP_INT_CONTROL (0x00)
33#define ARMADA_370_XP_INT_SET_ENABLE_OFFS (0x30)
34#define ARMADA_370_XP_INT_CLEAR_ENABLE_OFFS (0x34)
35
36#define ARMADA_370_XP_CPU_INTACK_OFFS (0x44)
37
38static void __iomem *per_cpu_int_base;
39static void __iomem *main_int_base;
40static struct irq_domain *armada_370_xp_mpic_domain;
41
42static void armada_370_xp_irq_mask(struct irq_data *d)
43{
44 writel(irqd_to_hwirq(d),
45 per_cpu_int_base + ARMADA_370_XP_INT_SET_MASK_OFFS);
46}
47
48static void armada_370_xp_irq_unmask(struct irq_data *d)
49{
50 writel(irqd_to_hwirq(d),
51 per_cpu_int_base + ARMADA_370_XP_INT_CLEAR_MASK_OFFS);
52}
53
54static struct irq_chip armada_370_xp_irq_chip = {
55 .name = "armada_370_xp_irq",
56 .irq_mask = armada_370_xp_irq_mask,
57 .irq_mask_ack = armada_370_xp_irq_mask,
58 .irq_unmask = armada_370_xp_irq_unmask,
59};
60
61static int armada_370_xp_mpic_irq_map(struct irq_domain *h,
62 unsigned int virq, irq_hw_number_t hw)
63{
64 armada_370_xp_irq_mask(irq_get_irq_data(virq));
65 writel(hw, main_int_base + ARMADA_370_XP_INT_SET_ENABLE_OFFS);
66
67 irq_set_chip_and_handler(virq, &armada_370_xp_irq_chip,
68 handle_level_irq);
69 irq_set_status_flags(virq, IRQ_LEVEL);
70 set_irq_flags(virq, IRQF_VALID | IRQF_PROBE);
71
72 return 0;
73}
74
75static struct irq_domain_ops armada_370_xp_mpic_irq_ops = {
76 .map = armada_370_xp_mpic_irq_map,
77 .xlate = irq_domain_xlate_onecell,
78};
79
80static int __init armada_370_xp_mpic_of_init(struct device_node *node,
81 struct device_node *parent)
82{
83 u32 control;
84
85 main_int_base = of_iomap(node, 0);
86 per_cpu_int_base = of_iomap(node, 1);
87
88 BUG_ON(!main_int_base);
89 BUG_ON(!per_cpu_int_base);
90
91 control = readl(main_int_base + ARMADA_370_XP_INT_CONTROL);
92
93 armada_370_xp_mpic_domain =
94 irq_domain_add_linear(node, (control >> 2) & 0x3ff,
95 &armada_370_xp_mpic_irq_ops, NULL);
96
97 if (!armada_370_xp_mpic_domain)
98 panic("Unable to add Armada_370_Xp MPIC irq domain (DT)\n");
99
100 irq_set_default_host(armada_370_xp_mpic_domain);
101 return 0;
102}
103
104asmlinkage void __exception_irq_entry armada_370_xp_handle_irq(struct pt_regs
105 *regs)
106{
107 u32 irqstat, irqnr;
108
109 do {
110 irqstat = readl_relaxed(per_cpu_int_base +
111 ARMADA_370_XP_CPU_INTACK_OFFS);
112 irqnr = irqstat & 0x3FF;
113
114 if (irqnr < 1023) {
115 irqnr =
116 irq_find_mapping(armada_370_xp_mpic_domain, irqnr);
117 handle_IRQ(irqnr, regs);
118 continue;
119 }
120
121 break;
122 } while (1);
123}
124
125static const struct of_device_id mpic_of_match[] __initconst = {
126 {.compatible = "marvell,mpic", .data = armada_370_xp_mpic_of_init},
127 {},
128};
129
130void __init armada_370_xp_init_irq(void)
131{
132 of_irq_init(mpic_of_match);
133}
diff --git a/arch/arm/mach-mvebu/system-controller.c b/arch/arm/mach-mvebu/system-controller.c
new file mode 100644
index 00000000000..b8079df8c98
--- /dev/null
+++ b/arch/arm/mach-mvebu/system-controller.c
@@ -0,0 +1,105 @@
1/*
2 * System controller support for Armada 370 and XP platforms.
3 *
4 * Copyright (C) 2012 Marvell
5 *
6 * Lior Amsalem <alior@marvell.com>
7 * Gregory CLEMENT <gregory.clement@free-electrons.com>
8 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
9 *
10 * This file is licensed under the terms of the GNU General Public
11 * License version 2. This program is licensed "as is" without any
12 * warranty of any kind, whether express or implied.
13 *
14 * The Armada 370 and Armada XP SoCs both have a range of
15 * miscellaneous registers, that do not belong to a particular device,
16 * but rather provide system-level features. This basic
17 * system-controller driver provides a device tree binding for those
18 * registers, and implements utility functions offering various
19 * features related to those registers.
20 *
21 * For now, the feature set is limited to restarting the platform by a
22 * soft-reset, but it might be extended in the future.
23 */
24
25#include <linux/kernel.h>
26#include <linux/init.h>
27#include <linux/of_address.h>
28#include <linux/io.h>
29
30static void __iomem *system_controller_base;
31
32struct mvebu_system_controller {
33 u32 rstoutn_mask_offset;
34 u32 system_soft_reset_offset;
35
36 u32 rstoutn_mask_reset_out_en;
37 u32 system_soft_reset;
38};
39static struct mvebu_system_controller *mvebu_sc;
40
41const struct mvebu_system_controller armada_370_xp_system_controller = {
42 .rstoutn_mask_offset = 0x60,
43 .system_soft_reset_offset = 0x64,
44 .rstoutn_mask_reset_out_en = 0x1,
45 .system_soft_reset = 0x1,
46};
47
48const struct mvebu_system_controller orion_system_controller = {
49 .rstoutn_mask_offset = 0x108,
50 .system_soft_reset_offset = 0x10c,
51 .rstoutn_mask_reset_out_en = 0x4,
52 .system_soft_reset = 0x1,
53};
54
55static struct of_device_id of_system_controller_table[] = {
56 {
57 .compatible = "marvell,orion-system-controller",
58 .data = (void *) &orion_system_controller,
59 }, {
60 .compatible = "marvell,armada-370-xp-system-controller",
61 .data = (void *) &armada_370_xp_system_controller,
62 },
63 { /* end of list */ },
64};
65
66void mvebu_restart(char mode, const char *cmd)
67{
68 if (!system_controller_base) {
69 pr_err("Cannot restart, system-controller not available: check the device tree\n");
70 } else {
71 /*
72 * Enable soft reset to assert RSTOUTn.
73 */
74 writel(mvebu_sc->rstoutn_mask_reset_out_en,
75 system_controller_base +
76 mvebu_sc->rstoutn_mask_offset);
77 /*
78 * Assert soft reset.
79 */
80 writel(mvebu_sc->system_soft_reset,
81 system_controller_base +
82 mvebu_sc->system_soft_reset_offset);
83 }
84
85 while (1)
86 ;
87}
88
89static int __init mvebu_system_controller_init(void)
90{
91 struct device_node *np;
92
93 np = of_find_matching_node(NULL, of_system_controller_table);
94 if (np) {
95 const struct of_device_id *match =
96 of_match_node(of_system_controller_table, np);
97 BUG_ON(!match);
98 system_controller_base = of_iomap(np, 0);
99 mvebu_sc = (struct mvebu_system_controller *)match->data;
100 }
101
102 return 0;
103}
104
105arch_initcall(mvebu_system_controller_init);
diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig
index 91cf0625819..9a8bbda195b 100644
--- a/arch/arm/mach-mxs/Kconfig
+++ b/arch/arm/mach-mxs/Kconfig
@@ -2,9 +2,6 @@ if ARCH_MXS
2 2
3source "arch/arm/mach-mxs/devices/Kconfig" 3source "arch/arm/mach-mxs/devices/Kconfig"
4 4
5config MXS_OCOTP
6 bool
7
8config SOC_IMX23 5config SOC_IMX23
9 bool 6 bool
10 select ARM_AMBA 7 select ARM_AMBA
@@ -16,6 +13,7 @@ config SOC_IMX28
16 bool 13 bool
17 select ARM_AMBA 14 select ARM_AMBA
18 select CPU_ARM926T 15 select CPU_ARM926T
16 select HAVE_CAN_FLEXCAN if CAN
19 select HAVE_PWM 17 select HAVE_PWM
20 select PINCTRL_IMX28 18 select PINCTRL_IMX28
21 19
@@ -65,7 +63,6 @@ config MACH_MX28EVK
65 select MXS_HAVE_PLATFORM_MXS_SAIF 63 select MXS_HAVE_PLATFORM_MXS_SAIF
66 select MXS_HAVE_PLATFORM_MXS_I2C 64 select MXS_HAVE_PLATFORM_MXS_I2C
67 select MXS_HAVE_PLATFORM_RTC_STMP3XXX 65 select MXS_HAVE_PLATFORM_RTC_STMP3XXX
68 select MXS_OCOTP
69 help 66 help
70 Include support for MX28EVK platform. This includes specific 67 Include support for MX28EVK platform. This includes specific
71 configurations for the board and its peripherals. 68 configurations for the board and its peripherals.
@@ -93,7 +90,6 @@ config MODULE_M28
93 select MXS_HAVE_PLATFORM_MXS_I2C 90 select MXS_HAVE_PLATFORM_MXS_I2C
94 select MXS_HAVE_PLATFORM_MXS_MMC 91 select MXS_HAVE_PLATFORM_MXS_MMC
95 select MXS_HAVE_PLATFORM_MXSFB 92 select MXS_HAVE_PLATFORM_MXSFB
96 select MXS_OCOTP
97 93
98config MODULE_APX4 94config MODULE_APX4
99 bool 95 bool
@@ -105,7 +101,6 @@ config MODULE_APX4
105 select MXS_HAVE_PLATFORM_MXS_I2C 101 select MXS_HAVE_PLATFORM_MXS_I2C
106 select MXS_HAVE_PLATFORM_MXS_MMC 102 select MXS_HAVE_PLATFORM_MXS_MMC
107 select MXS_HAVE_PLATFORM_MXS_SAIF 103 select MXS_HAVE_PLATFORM_MXS_SAIF
108 select MXS_OCOTP
109 104
110config MACH_TX28 105config MACH_TX28
111 bool "Ka-Ro TX28 module" 106 bool "Ka-Ro TX28 module"
diff --git a/arch/arm/mach-mxs/Makefile b/arch/arm/mach-mxs/Makefile
index e41590ccb43..fed3695a133 100644
--- a/arch/arm/mach-mxs/Makefile
+++ b/arch/arm/mach-mxs/Makefile
@@ -1,7 +1,6 @@
1# Common support 1# Common support
2obj-y := devices.o icoll.o iomux.o system.o timer.o mm.o 2obj-y := devices.o icoll.o iomux.o ocotp.o system.o timer.o mm.o
3 3
4obj-$(CONFIG_MXS_OCOTP) += ocotp.o
5obj-$(CONFIG_PM) += pm.o 4obj-$(CONFIG_PM) += pm.o
6 5
7obj-$(CONFIG_MACH_MXS_DT) += mach-mxs.o 6obj-$(CONFIG_MACH_MXS_DT) += mach-mxs.o
diff --git a/arch/arm/mach-mxs/Makefile.boot b/arch/arm/mach-mxs/Makefile.boot
index 07b11fe6453..4582999cf08 100644
--- a/arch/arm/mach-mxs/Makefile.boot
+++ b/arch/arm/mach-mxs/Makefile.boot
@@ -1 +1,10 @@
1zreladdr-y += 0x40008000 1zreladdr-y += 0x40008000
2
3dtb-y += imx23-evk.dtb \
4 imx23-olinuxino.dtb \
5 imx23-stmp378x_devb.dtb \
6 imx28-apx4devkit.dtb \
7 imx28-cfa10036.dtb \
8 imx28-evk.dtb \
9 imx28-m28evk.dtb \
10 imx28-tx28.dtb \
diff --git a/arch/arm/mach-mxs/devices-mx23.h b/arch/arm/mach-mxs/devices-mx23.h
index 9acdd638704..9ee5cede3d4 100644
--- a/arch/arm/mach-mxs/devices-mx23.h
+++ b/arch/arm/mach-mxs/devices-mx23.h
@@ -10,7 +10,7 @@
10 */ 10 */
11#include <mach/mx23.h> 11#include <mach/mx23.h>
12#include <mach/devices-common.h> 12#include <mach/devices-common.h>
13#include <mach/mxsfb.h> 13#include <linux/mxsfb.h>
14#include <linux/amba/bus.h> 14#include <linux/amba/bus.h>
15 15
16static inline int mx23_add_duart(void) 16static inline int mx23_add_duart(void)
diff --git a/arch/arm/mach-mxs/devices-mx28.h b/arch/arm/mach-mxs/devices-mx28.h
index 84b2960df11..fcab431060f 100644
--- a/arch/arm/mach-mxs/devices-mx28.h
+++ b/arch/arm/mach-mxs/devices-mx28.h
@@ -10,7 +10,7 @@
10 */ 10 */
11#include <mach/mx28.h> 11#include <mach/mx28.h>
12#include <mach/devices-common.h> 12#include <mach/devices-common.h>
13#include <mach/mxsfb.h> 13#include <linux/mxsfb.h>
14#include <linux/amba/bus.h> 14#include <linux/amba/bus.h>
15 15
16static inline int mx28_add_duart(void) 16static inline int mx28_add_duart(void)
diff --git a/arch/arm/mach-mxs/devices/platform-mxsfb.c b/arch/arm/mach-mxs/devices/platform-mxsfb.c
index 5a75b7180f7..76b53f73418 100644
--- a/arch/arm/mach-mxs/devices/platform-mxsfb.c
+++ b/arch/arm/mach-mxs/devices/platform-mxsfb.c
@@ -10,7 +10,7 @@
10#include <mach/mx23.h> 10#include <mach/mx23.h>
11#include <mach/mx28.h> 11#include <mach/mx28.h>
12#include <mach/devices-common.h> 12#include <mach/devices-common.h>
13#include <mach/mxsfb.h> 13#include <linux/mxsfb.h>
14 14
15#ifdef CONFIG_SOC_IMX23 15#ifdef CONFIG_SOC_IMX23
16struct platform_device *__init mx23_add_mxsfb( 16struct platform_device *__init mx23_add_mxsfb(
diff --git a/arch/arm/mach-mxs/include/mach/mxsfb.h b/arch/arm/mach-mxs/include/mach/mxsfb.h
deleted file mode 100644
index e4d79791515..00000000000
--- a/arch/arm/mach-mxs/include/mach/mxsfb.h
+++ /dev/null
@@ -1,49 +0,0 @@
1/*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
14 * MA 02110-1301, USA.
15 */
16
17#ifndef __MACH_FB_H
18#define __MACH_FB_H
19
20#include <linux/fb.h>
21
22#define STMLCDIF_8BIT 1 /** pixel data bus to the display is of 8 bit width */
23#define STMLCDIF_16BIT 0 /** pixel data bus to the display is of 16 bit width */
24#define STMLCDIF_18BIT 2 /** pixel data bus to the display is of 18 bit width */
25#define STMLCDIF_24BIT 3 /** pixel data bus to the display is of 24 bit width */
26
27#define FB_SYNC_DATA_ENABLE_HIGH_ACT (1 << 6)
28#define FB_SYNC_DOTCLK_FAILING_ACT (1 << 7) /* failing/negtive edge sampling */
29
30struct mxsfb_platform_data {
31 struct fb_videomode *mode_list;
32 unsigned mode_count;
33
34 unsigned default_bpp;
35
36 unsigned dotclk_delay; /* refer manual HW_LCDIF_VDCTRL4 register */
37 unsigned ld_intf_width; /* refer STMLCDIF_* macros */
38
39 unsigned fb_size; /* Size of the video memory. If zero a
40 * default will be used
41 */
42 unsigned long fb_phys; /* physical address for the video memory. If
43 * zero the framebuffer memory will be dynamically
44 * allocated. If specified,fb_size must also be specified.
45 * fb_phys must be unused by Linux.
46 */
47};
48
49#endif /* __MACH_FB_H */
diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
index 8cac94b3302..8dabfe81d07 100644
--- a/arch/arm/mach-mxs/mach-mxs.c
+++ b/arch/arm/mach-mxs/mach-mxs.c
@@ -16,12 +16,95 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/irqdomain.h> 18#include <linux/irqdomain.h>
19#include <linux/micrel_phy.h>
20#include <linux/mxsfb.h>
19#include <linux/of_irq.h> 21#include <linux/of_irq.h>
20#include <linux/of_platform.h> 22#include <linux/of_platform.h>
23#include <linux/phy.h>
21#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
22#include <asm/mach/time.h> 25#include <asm/mach/time.h>
23#include <mach/common.h> 26#include <mach/common.h>
24 27
28static struct fb_videomode mx23evk_video_modes[] = {
29 {
30 .name = "Samsung-LMS430HF02",
31 .refresh = 60,
32 .xres = 480,
33 .yres = 272,
34 .pixclock = 108096, /* picosecond (9.2 MHz) */
35 .left_margin = 15,
36 .right_margin = 8,
37 .upper_margin = 12,
38 .lower_margin = 4,
39 .hsync_len = 1,
40 .vsync_len = 1,
41 .sync = FB_SYNC_DATA_ENABLE_HIGH_ACT |
42 FB_SYNC_DOTCLK_FAILING_ACT,
43 },
44};
45
46static struct fb_videomode mx28evk_video_modes[] = {
47 {
48 .name = "Seiko-43WVF1G",
49 .refresh = 60,
50 .xres = 800,
51 .yres = 480,
52 .pixclock = 29851, /* picosecond (33.5 MHz) */
53 .left_margin = 89,
54 .right_margin = 164,
55 .upper_margin = 23,
56 .lower_margin = 10,
57 .hsync_len = 10,
58 .vsync_len = 10,
59 .sync = FB_SYNC_DATA_ENABLE_HIGH_ACT |
60 FB_SYNC_DOTCLK_FAILING_ACT,
61 },
62};
63
64static struct fb_videomode m28evk_video_modes[] = {
65 {
66 .name = "Ampire AM-800480R2TMQW-T01H",
67 .refresh = 60,
68 .xres = 800,
69 .yres = 480,
70 .pixclock = 30066, /* picosecond (33.26 MHz) */
71 .left_margin = 0,
72 .right_margin = 256,
73 .upper_margin = 0,
74 .lower_margin = 45,
75 .hsync_len = 1,
76 .vsync_len = 1,
77 .sync = FB_SYNC_DATA_ENABLE_HIGH_ACT,
78 },
79};
80
81static struct fb_videomode apx4devkit_video_modes[] = {
82 {
83 .name = "HannStar PJ70112A",
84 .refresh = 60,
85 .xres = 800,
86 .yres = 480,
87 .pixclock = 33333, /* picosecond (30.00 MHz) */
88 .left_margin = 88,
89 .right_margin = 40,
90 .upper_margin = 32,
91 .lower_margin = 13,
92 .hsync_len = 48,
93 .vsync_len = 3,
94 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT |
95 FB_SYNC_DATA_ENABLE_HIGH_ACT |
96 FB_SYNC_DOTCLK_FAILING_ACT,
97 },
98};
99
100static struct mxsfb_platform_data mxsfb_pdata __initdata;
101
102static struct of_dev_auxdata mxs_auxdata_lookup[] __initdata = {
103 OF_DEV_AUXDATA("fsl,imx23-lcdif", 0x80030000, NULL, &mxsfb_pdata),
104 OF_DEV_AUXDATA("fsl,imx28-lcdif", 0x80030000, NULL, &mxsfb_pdata),
105 { /* sentinel */ }
106};
107
25static int __init mxs_icoll_add_irq_domain(struct device_node *np, 108static int __init mxs_icoll_add_irq_domain(struct device_node *np,
26 struct device_node *interrupt_parent) 109 struct device_node *interrupt_parent)
27{ 110{
@@ -71,33 +154,151 @@ static struct sys_timer imx28_timer = {
71 .init = imx28_timer_init, 154 .init = imx28_timer_init,
72}; 155};
73 156
74static void __init imx28_evk_init(void) 157enum mac_oui {
158 OUI_FSL,
159 OUI_DENX,
160};
161
162static void __init update_fec_mac_prop(enum mac_oui oui)
163{
164 struct device_node *np, *from = NULL;
165 struct property *newmac;
166 const u32 *ocotp = mxs_get_ocotp();
167 u8 *macaddr;
168 u32 val;
169 int i;
170
171 for (i = 0; i < 2; i++) {
172 np = of_find_compatible_node(from, NULL, "fsl,imx28-fec");
173 if (!np)
174 return;
175 from = np;
176
177 newmac = kzalloc(sizeof(*newmac) + 6, GFP_KERNEL);
178 if (!newmac)
179 return;
180 newmac->value = newmac + 1;
181 newmac->length = 6;
182
183 newmac->name = kstrdup("local-mac-address", GFP_KERNEL);
184 if (!newmac->name) {
185 kfree(newmac);
186 return;
187 }
188
189 /*
190 * OCOTP only stores the last 4 octets for each mac address,
191 * so hard-code OUI here.
192 */
193 macaddr = newmac->value;
194 switch (oui) {
195 case OUI_FSL:
196 macaddr[0] = 0x00;
197 macaddr[1] = 0x04;
198 macaddr[2] = 0x9f;
199 break;
200 case OUI_DENX:
201 macaddr[0] = 0xc0;
202 macaddr[1] = 0xe5;
203 macaddr[2] = 0x4e;
204 break;
205 }
206 val = ocotp[i];
207 macaddr[3] = (val >> 16) & 0xff;
208 macaddr[4] = (val >> 8) & 0xff;
209 macaddr[5] = (val >> 0) & 0xff;
210
211 prom_update_property(np, newmac);
212 }
213}
214
215static void __init imx23_evk_init(void)
216{
217 mxsfb_pdata.mode_list = mx23evk_video_modes;
218 mxsfb_pdata.mode_count = ARRAY_SIZE(mx23evk_video_modes);
219 mxsfb_pdata.default_bpp = 32;
220 mxsfb_pdata.ld_intf_width = STMLCDIF_24BIT;
221}
222
223static inline void enable_clk_enet_out(void)
75{ 224{
76 struct clk *clk; 225 struct clk *clk = clk_get_sys("enet_out", NULL);
77 226
78 /* Enable fec phy clock */
79 clk = clk_get_sys("enet_out", NULL);
80 if (!IS_ERR(clk)) 227 if (!IS_ERR(clk))
81 clk_prepare_enable(clk); 228 clk_prepare_enable(clk);
82} 229}
83 230
231static void __init imx28_evk_init(void)
232{
233 enable_clk_enet_out();
234 update_fec_mac_prop(OUI_FSL);
235
236 mxsfb_pdata.mode_list = mx28evk_video_modes;
237 mxsfb_pdata.mode_count = ARRAY_SIZE(mx28evk_video_modes);
238 mxsfb_pdata.default_bpp = 32;
239 mxsfb_pdata.ld_intf_width = STMLCDIF_24BIT;
240}
241
242static void __init m28evk_init(void)
243{
244 enable_clk_enet_out();
245 update_fec_mac_prop(OUI_DENX);
246
247 mxsfb_pdata.mode_list = m28evk_video_modes;
248 mxsfb_pdata.mode_count = ARRAY_SIZE(m28evk_video_modes);
249 mxsfb_pdata.default_bpp = 16;
250 mxsfb_pdata.ld_intf_width = STMLCDIF_18BIT;
251}
252
253static int apx4devkit_phy_fixup(struct phy_device *phy)
254{
255 phy->dev_flags |= MICREL_PHY_50MHZ_CLK;
256 return 0;
257}
258
259static void __init apx4devkit_init(void)
260{
261 enable_clk_enet_out();
262
263 if (IS_BUILTIN(CONFIG_PHYLIB))
264 phy_register_fixup_for_uid(PHY_ID_KS8051, MICREL_PHY_ID_MASK,
265 apx4devkit_phy_fixup);
266
267 mxsfb_pdata.mode_list = apx4devkit_video_modes;
268 mxsfb_pdata.mode_count = ARRAY_SIZE(apx4devkit_video_modes);
269 mxsfb_pdata.default_bpp = 32;
270 mxsfb_pdata.ld_intf_width = STMLCDIF_24BIT;
271}
272
84static void __init mxs_machine_init(void) 273static void __init mxs_machine_init(void)
85{ 274{
86 if (of_machine_is_compatible("fsl,imx28-evk")) 275 if (of_machine_is_compatible("fsl,imx28-evk"))
87 imx28_evk_init(); 276 imx28_evk_init();
277 else if (of_machine_is_compatible("fsl,imx23-evk"))
278 imx23_evk_init();
279 else if (of_machine_is_compatible("denx,m28evk"))
280 m28evk_init();
281 else if (of_machine_is_compatible("bluegiga,apx4devkit"))
282 apx4devkit_init();
88 283
89 of_platform_populate(NULL, of_default_bus_match_table, 284 of_platform_populate(NULL, of_default_bus_match_table,
90 NULL, NULL); 285 mxs_auxdata_lookup, NULL);
91} 286}
92 287
93static const char *imx23_dt_compat[] __initdata = { 288static const char *imx23_dt_compat[] __initdata = {
94 "fsl,imx23-evk", 289 "fsl,imx23-evk",
290 "fsl,stmp378x_devb"
291 "olimex,imx23-olinuxino",
95 "fsl,imx23", 292 "fsl,imx23",
96 NULL, 293 NULL,
97}; 294};
98 295
99static const char *imx28_dt_compat[] __initdata = { 296static const char *imx28_dt_compat[] __initdata = {
297 "bluegiga,apx4devkit",
298 "crystalfontz,cfa10036",
299 "denx,m28evk",
100 "fsl,imx28-evk", 300 "fsl,imx28-evk",
301 "karo,tx28",
101 "fsl,imx28", 302 "fsl,imx28",
102 NULL, 303 NULL,
103}; 304};
diff --git a/arch/arm/mach-mxs/module-tx28.c b/arch/arm/mach-mxs/module-tx28.c
index 9a7b08b2a92..0f71f82101c 100644
--- a/arch/arm/mach-mxs/module-tx28.c
+++ b/arch/arm/mach-mxs/module-tx28.c
@@ -11,7 +11,7 @@
11#include <linux/gpio.h> 11#include <linux/gpio.h>
12 12
13#include <mach/iomux-mx28.h> 13#include <mach/iomux-mx28.h>
14#include "../devices-mx28.h" 14#include "devices-mx28.h"
15 15
16#include "module-tx28.h" 16#include "module-tx28.h"
17 17
diff --git a/arch/arm/mach-netx/fb.c b/arch/arm/mach-netx/fb.c
index 2cdf6ef69be..d122ee6ab99 100644
--- a/arch/arm/mach-netx/fb.c
+++ b/arch/arm/mach-netx/fb.c
@@ -69,29 +69,6 @@ void netx_clcd_remove(struct clcd_fb *fb)
69 fb->fb.screen_base, fb->fb.fix.smem_start); 69 fb->fb.screen_base, fb->fb.fix.smem_start);
70} 70}
71 71
72void clk_disable(struct clk *clk)
73{
74}
75
76int clk_set_rate(struct clk *clk, unsigned long rate)
77{
78 return 0;
79}
80
81int clk_enable(struct clk *clk)
82{
83 return 0;
84}
85
86struct clk *clk_get(struct device *dev, const char *id)
87{
88 return dev && strcmp(dev_name(dev), "fb") == 0 ? NULL : ERR_PTR(-ENOENT);
89}
90
91void clk_put(struct clk *clk)
92{
93}
94
95static AMBA_AHB_DEVICE(fb, "fb", 0, 0x00104000, { NETX_IRQ_LCD }, NULL); 72static AMBA_AHB_DEVICE(fb, "fb", 0, 0x00104000, { NETX_IRQ_LCD }, NULL);
96 73
97int netx_fb_init(struct clcd_board *board, struct clcd_panel *panel) 74int netx_fb_init(struct clcd_board *board, struct clcd_panel *panel)
diff --git a/arch/arm/mach-nomadik/Makefile b/arch/arm/mach-nomadik/Makefile
index a6bbd1a7b4e..a42c9a33d3b 100644
--- a/arch/arm/mach-nomadik/Makefile
+++ b/arch/arm/mach-nomadik/Makefile
@@ -7,8 +7,6 @@
7 7
8# Object file lists. 8# Object file lists.
9 9
10obj-y += clock.o
11
12# Cpu revision 10# Cpu revision
13obj-$(CONFIG_NOMADIK_8815) += cpu-8815.o 11obj-$(CONFIG_NOMADIK_8815) += cpu-8815.o
14 12
diff --git a/arch/arm/mach-nomadik/board-nhk8815.c b/arch/arm/mach-nomadik/board-nhk8815.c
index 2e8d3e176bc..f4535a7dadf 100644
--- a/arch/arm/mach-nomadik/board-nhk8815.c
+++ b/arch/arm/mach-nomadik/board-nhk8815.c
@@ -14,12 +14,14 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/amba/bus.h> 16#include <linux/amba/bus.h>
17#include <linux/amba/mmci.h>
17#include <linux/interrupt.h> 18#include <linux/interrupt.h>
18#include <linux/gpio.h> 19#include <linux/gpio.h>
19#include <linux/mtd/mtd.h> 20#include <linux/mtd/mtd.h>
20#include <linux/mtd/nand.h> 21#include <linux/mtd/nand.h>
21#include <linux/mtd/onenand.h> 22#include <linux/mtd/onenand.h>
22#include <linux/mtd/partitions.h> 23#include <linux/mtd/partitions.h>
24#include <linux/i2c.h>
23#include <linux/io.h> 25#include <linux/io.h>
24#include <asm/hardware/vic.h> 26#include <asm/hardware/vic.h>
25#include <asm/sizes.h> 27#include <asm/sizes.h>
@@ -185,16 +187,28 @@ static void __init nhk8815_onenand_init(void)
185#endif 187#endif
186} 188}
187 189
188static AMBA_APB_DEVICE(uart0, "uart0", 0, NOMADIK_UART0_BASE, 190static struct mmci_platform_data mmcsd_plat_data = {
189 { IRQ_UART0 }, NULL); 191 .ocr_mask = MMC_VDD_29_30,
192 .f_max = 48000000,
193 .gpio_wp = -1,
194 .gpio_cd = 111,
195 .cd_invert = true,
196 .capabilities = MMC_CAP_MMC_HIGHSPEED |
197 MMC_CAP_SD_HIGHSPEED | MMC_CAP_4_BIT_DATA,
198};
190 199
191static AMBA_APB_DEVICE(uart1, "uart1", 0, NOMADIK_UART1_BASE, 200static int __init nhk8815_mmcsd_init(void)
192 { IRQ_UART1 }, NULL); 201{
202 int ret;
193 203
194static struct amba_device *amba_devs[] __initdata = { 204 ret = gpio_request(112, "card detect bias");
195 &uart0_device, 205 if (ret)
196 &uart1_device, 206 return ret;
197}; 207 gpio_direction_output(112, 0);
208 amba_apb_device_add(NULL, "mmci", NOMADIK_SDI_BASE, SZ_4K, IRQ_SDMMC, 0, &mmcsd_plat_data, 0x10180180);
209 return 0;
210}
211module_init(nhk8815_mmcsd_init);
198 212
199static struct resource nhk8815_eth_resources[] = { 213static struct resource nhk8815_eth_resources[] = {
200 { 214 {
@@ -253,17 +267,46 @@ static struct sys_timer nomadik_timer = {
253 .init = nomadik_timer_init, 267 .init = nomadik_timer_init,
254}; 268};
255 269
270static struct i2c_board_info __initdata nhk8815_i2c0_devices[] = {
271 {
272 I2C_BOARD_INFO("stw4811", 0x2d),
273 },
274};
275
276static struct i2c_board_info __initdata nhk8815_i2c1_devices[] = {
277 {
278 I2C_BOARD_INFO("camera", 0x10),
279 },
280 {
281 I2C_BOARD_INFO("stw5095", 0x1a),
282 },
283 {
284 I2C_BOARD_INFO("lis3lv02dl", 0x1d),
285 },
286};
287
288static struct i2c_board_info __initdata nhk8815_i2c2_devices[] = {
289 {
290 I2C_BOARD_INFO("stw4811-usb", 0x2d),
291 },
292};
293
256static void __init nhk8815_platform_init(void) 294static void __init nhk8815_platform_init(void)
257{ 295{
258 int i;
259
260 cpu8815_platform_init(); 296 cpu8815_platform_init();
261 nhk8815_onenand_init(); 297 nhk8815_onenand_init();
262 platform_add_devices(nhk8815_platform_devices, 298 platform_add_devices(nhk8815_platform_devices,
263 ARRAY_SIZE(nhk8815_platform_devices)); 299 ARRAY_SIZE(nhk8815_platform_devices));
264 300
265 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) 301 amba_apb_device_add(NULL, "uart0", NOMADIK_UART0_BASE, SZ_4K, IRQ_UART0, 0, NULL, 0);
266 amba_device_register(amba_devs[i], &iomem_resource); 302 amba_apb_device_add(NULL, "uart1", NOMADIK_UART1_BASE, SZ_4K, IRQ_UART1, 0, NULL, 0);
303
304 i2c_register_board_info(0, nhk8815_i2c0_devices,
305 ARRAY_SIZE(nhk8815_i2c0_devices));
306 i2c_register_board_info(1, nhk8815_i2c1_devices,
307 ARRAY_SIZE(nhk8815_i2c1_devices));
308 i2c_register_board_info(2, nhk8815_i2c2_devices,
309 ARRAY_SIZE(nhk8815_i2c2_devices));
267} 310}
268 311
269MACHINE_START(NOMADIK, "NHK8815") 312MACHINE_START(NOMADIK, "NHK8815")
diff --git a/arch/arm/mach-nomadik/clock.c b/arch/arm/mach-nomadik/clock.c
deleted file mode 100644
index 48a59f24e10..00000000000
--- a/arch/arm/mach-nomadik/clock.c
+++ /dev/null
@@ -1,75 +0,0 @@
1/*
2 * linux/arch/arm/mach-nomadik/clock.c
3 *
4 * Copyright (C) 2009 Alessandro Rubini
5 */
6#include <linux/kernel.h>
7#include <linux/module.h>
8#include <linux/errno.h>
9#include <linux/clk.h>
10#include <linux/clkdev.h>
11#include "clock.h"
12
13/*
14 * The nomadik board uses generic clocks, but the serial pl011 file
15 * calls clk_enable(), clk_disable(), clk_get_rate(), so we provide them
16 */
17unsigned long clk_get_rate(struct clk *clk)
18{
19 return clk->rate;
20}
21EXPORT_SYMBOL(clk_get_rate);
22
23/* enable and disable do nothing */
24int clk_enable(struct clk *clk)
25{
26 return 0;
27}
28EXPORT_SYMBOL(clk_enable);
29
30void clk_disable(struct clk *clk)
31{
32}
33EXPORT_SYMBOL(clk_disable);
34
35static struct clk clk_24 = {
36 .rate = 2400000,
37};
38
39static struct clk clk_48 = {
40 .rate = 48 * 1000 * 1000,
41};
42
43/*
44 * Catch-all default clock to satisfy drivers using the clk API. We don't
45 * model the actual hardware clocks yet.
46 */
47static struct clk clk_default;
48
49#define CLK(_clk, dev) \
50 { \
51 .clk = _clk, \
52 .dev_id = dev, \
53 }
54
55static struct clk_lookup lookups[] = {
56 {
57 .con_id = "apb_pclk",
58 .clk = &clk_default,
59 },
60 CLK(&clk_24, "mtu0"),
61 CLK(&clk_24, "mtu1"),
62 CLK(&clk_48, "uart0"),
63 CLK(&clk_48, "uart1"),
64 CLK(&clk_default, "gpio.0"),
65 CLK(&clk_default, "gpio.1"),
66 CLK(&clk_default, "gpio.2"),
67 CLK(&clk_default, "gpio.3"),
68 CLK(&clk_default, "rng"),
69};
70
71int __init clk_init(void)
72{
73 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
74 return 0;
75}
diff --git a/arch/arm/mach-nomadik/clock.h b/arch/arm/mach-nomadik/clock.h
deleted file mode 100644
index 78da2e7c398..00000000000
--- a/arch/arm/mach-nomadik/clock.h
+++ /dev/null
@@ -1,15 +0,0 @@
1
2/*
3 * linux/arch/arm/mach-nomadik/clock.h
4 *
5 * Copyright (C) 2009 Alessandro Rubini
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 */
11struct clk {
12 unsigned long rate;
13};
14
15int __init clk_init(void);
diff --git a/arch/arm/mach-nomadik/cpu-8815.c b/arch/arm/mach-nomadik/cpu-8815.c
index 27f43a46985..6fd8e46567a 100644
--- a/arch/arm/mach-nomadik/cpu-8815.c
+++ b/arch/arm/mach-nomadik/cpu-8815.c
@@ -22,6 +22,10 @@
22#include <linux/amba/bus.h> 22#include <linux/amba/bus.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/slab.h>
26#include <linux/irq.h>
27#include <linux/dma-mapping.h>
28#include <linux/platform_data/clk-nomadik.h>
25 29
26#include <plat/gpio-nomadik.h> 30#include <plat/gpio-nomadik.h>
27#include <mach/hardware.h> 31#include <mach/hardware.h>
@@ -32,91 +36,63 @@
32#include <asm/cacheflush.h> 36#include <asm/cacheflush.h>
33#include <asm/hardware/cache-l2x0.h> 37#include <asm/hardware/cache-l2x0.h>
34 38
35#include "clock.h"
36#include "cpu-8815.h" 39#include "cpu-8815.h"
37 40
38#define __MEM_4K_RESOURCE(x) \
39 .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM}
40
41/* The 8815 has 4 GPIO blocks, let's register them immediately */ 41/* The 8815 has 4 GPIO blocks, let's register them immediately */
42 42static resource_size_t __initdata cpu8815_gpio_base[] = {
43#define GPIO_RESOURCE(block) \ 43 NOMADIK_GPIO0_BASE,
44 { \ 44 NOMADIK_GPIO1_BASE,
45 .start = NOMADIK_GPIO##block##_BASE, \ 45 NOMADIK_GPIO2_BASE,
46 .end = NOMADIK_GPIO##block##_BASE + SZ_4K - 1, \ 46 NOMADIK_GPIO3_BASE,
47 .flags = IORESOURCE_MEM, \
48 }, \
49 { \
50 .start = IRQ_GPIO##block, \
51 .end = IRQ_GPIO##block, \
52 .flags = IORESOURCE_IRQ, \
53 }
54
55#define GPIO_DEVICE(block) \
56 { \
57 .name = "gpio", \
58 .id = block, \
59 .num_resources = 2, \
60 .resource = &cpu8815_gpio_resources[block * 2], \
61 .dev = { \
62 .platform_data = &cpu8815_gpio[block], \
63 }, \
64 }
65
66static struct nmk_gpio_platform_data cpu8815_gpio[] = {
67 {
68 .name = "GPIO-0-31",
69 .first_gpio = 0,
70 .first_irq = NOMADIK_GPIO_TO_IRQ(0),
71 }, {
72 .name = "GPIO-32-63",
73 .first_gpio = 32,
74 .first_irq = NOMADIK_GPIO_TO_IRQ(32),
75 }, {
76 .name = "GPIO-64-95",
77 .first_gpio = 64,
78 .first_irq = NOMADIK_GPIO_TO_IRQ(64),
79 }, {
80 .name = "GPIO-96-127", /* 124..127 not routed to pin */
81 .first_gpio = 96,
82 .first_irq = NOMADIK_GPIO_TO_IRQ(96),
83 }
84}; 47};
85 48
86static struct resource cpu8815_gpio_resources[] = { 49static struct platform_device *
87 GPIO_RESOURCE(0), 50cpu8815_add_gpio(int id, resource_size_t addr, int irq,
88 GPIO_RESOURCE(1), 51 struct nmk_gpio_platform_data *pdata)
89 GPIO_RESOURCE(2), 52{
90 GPIO_RESOURCE(3), 53 struct resource resources[] = {
91}; 54 {
92 55 .start = addr,
93static struct platform_device cpu8815_platform_gpio[] = { 56 .end = addr + 127,
94 GPIO_DEVICE(0), 57 .flags = IORESOURCE_MEM,
95 GPIO_DEVICE(1), 58 },
96 GPIO_DEVICE(2), 59 {
97 GPIO_DEVICE(3), 60 .start = irq,
98}; 61 .end = irq,
62 .flags = IORESOURCE_IRQ,
63 }
64 };
65
66 return platform_device_register_resndata(NULL, "gpio", id,
67 resources, ARRAY_SIZE(resources),
68 pdata, sizeof(*pdata));
69}
99 70
100static AMBA_APB_DEVICE(cpu8815_amba_rng, "rng", 0, NOMADIK_RNG_BASE, { }, NULL); 71void cpu8815_add_gpios(resource_size_t *base, int num, int irq,
72 struct nmk_gpio_platform_data *pdata)
73{
74 int first = 0;
75 int i;
101 76
102static struct platform_device *platform_devs[] __initdata = { 77 for (i = 0; i < num; i++, first += 32, irq++) {
103 cpu8815_platform_gpio + 0, 78 pdata->first_gpio = first;
104 cpu8815_platform_gpio + 1, 79 pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first);
105 cpu8815_platform_gpio + 2, 80 pdata->num_gpio = 32;
106 cpu8815_platform_gpio + 3,
107};
108 81
109static struct amba_device *amba_devs[] __initdata = { 82 cpu8815_add_gpio(i, base[i], irq, pdata);
110 &cpu8815_amba_rng_device 83 }
111}; 84}
112 85
113static int __init cpu8815_init(void) 86static int __init cpu8815_init(void)
114{ 87{
115 int i; 88 struct nmk_gpio_platform_data pdata = {
116 89 /* No custom data yet */
117 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); 90 };
118 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) 91
119 amba_device_register(amba_devs[i], &iomem_resource); 92 cpu8815_add_gpios(cpu8815_gpio_base, ARRAY_SIZE(cpu8815_gpio_base),
93 IRQ_GPIO0, &pdata);
94 amba_apb_device_add(NULL, "rng", NOMADIK_RNG_BASE, SZ_4K, 0, 0, NULL, 0);
95 amba_apb_device_add(NULL, "rtc-pl031", NOMADIK_RTC_BASE, SZ_4K, IRQ_RTC_RTT, 0, NULL, 0);
120 return 0; 96 return 0;
121} 97}
122arch_initcall(cpu8815_init); 98arch_initcall(cpu8815_init);
@@ -147,7 +123,7 @@ void __init cpu8815_init_irq(void)
147 * Init clocks here so that they are available for system timer 123 * Init clocks here so that they are available for system timer
148 * initialization. 124 * initialization.
149 */ 125 */
150 clk_init(); 126 nomadik_clk_init();
151} 127}
152 128
153/* 129/*
diff --git a/arch/arm/mach-nomadik/i2c-8815nhk.c b/arch/arm/mach-nomadik/i2c-8815nhk.c
index 0fc2f6f1cc9..6d14454d460 100644
--- a/arch/arm/mach-nomadik/i2c-8815nhk.c
+++ b/arch/arm/mach-nomadik/i2c-8815nhk.c
@@ -5,6 +5,7 @@
5#include <linux/i2c-gpio.h> 5#include <linux/i2c-gpio.h>
6#include <linux/platform_device.h> 6#include <linux/platform_device.h>
7#include <plat/gpio-nomadik.h> 7#include <plat/gpio-nomadik.h>
8#include <plat/pincfg.h>
8 9
9/* 10/*
10 * There are two busses in the 8815NHK. 11 * There are two busses in the 8815NHK.
@@ -12,19 +13,27 @@
12 * use bit-bang through GPIO by now, to keep things simple 13 * use bit-bang through GPIO by now, to keep things simple
13 */ 14 */
14 15
16/* I2C0 connected to the STw4811 power management chip */
15static struct i2c_gpio_platform_data nhk8815_i2c_data0 = { 17static struct i2c_gpio_platform_data nhk8815_i2c_data0 = {
16 /* keep defaults for timeouts; pins are push-pull bidirectional */ 18 /* keep defaults for timeouts; pins are push-pull bidirectional */
17 .scl_pin = 62, 19 .scl_pin = 62,
18 .sda_pin = 63, 20 .sda_pin = 63,
19}; 21};
20 22
23/* I2C1 connected to various sensors */
21static struct i2c_gpio_platform_data nhk8815_i2c_data1 = { 24static struct i2c_gpio_platform_data nhk8815_i2c_data1 = {
22 /* keep defaults for timeouts; pins are push-pull bidirectional */ 25 /* keep defaults for timeouts; pins are push-pull bidirectional */
23 .scl_pin = 53, 26 .scl_pin = 53,
24 .sda_pin = 54, 27 .sda_pin = 54,
25}; 28};
26 29
27/* first bus: GPIO XX and YY */ 30/* I2C2 connected to the USB portions of the STw4811 only */
31static struct i2c_gpio_platform_data nhk8815_i2c_data2 = {
32 /* keep defaults for timeouts; pins are push-pull bidirectional */
33 .scl_pin = 73,
34 .sda_pin = 74,
35};
36
28static struct platform_device nhk8815_i2c_dev0 = { 37static struct platform_device nhk8815_i2c_dev0 = {
29 .name = "i2c-gpio", 38 .name = "i2c-gpio",
30 .id = 0, 39 .id = 0,
@@ -32,7 +41,7 @@ static struct platform_device nhk8815_i2c_dev0 = {
32 .platform_data = &nhk8815_i2c_data0, 41 .platform_data = &nhk8815_i2c_data0,
33 }, 42 },
34}; 43};
35/* second bus: GPIO XX and YY */ 44
36static struct platform_device nhk8815_i2c_dev1 = { 45static struct platform_device nhk8815_i2c_dev1 = {
37 .name = "i2c-gpio", 46 .name = "i2c-gpio",
38 .id = 1, 47 .id = 1,
@@ -41,15 +50,29 @@ static struct platform_device nhk8815_i2c_dev1 = {
41 }, 50 },
42}; 51};
43 52
53static struct platform_device nhk8815_i2c_dev2 = {
54 .name = "i2c-gpio",
55 .id = 2,
56 .dev = {
57 .platform_data = &nhk8815_i2c_data2,
58 },
59};
60
61static pin_cfg_t cpu8815_pins_i2c[] = {
62 PIN_CFG_INPUT(62, GPIO, PULLUP),
63 PIN_CFG_INPUT(63, GPIO, PULLUP),
64 PIN_CFG_INPUT(53, GPIO, PULLUP),
65 PIN_CFG_INPUT(54, GPIO, PULLUP),
66 PIN_CFG_INPUT(73, GPIO, PULLUP),
67 PIN_CFG_INPUT(74, GPIO, PULLUP),
68};
69
44static int __init nhk8815_i2c_init(void) 70static int __init nhk8815_i2c_init(void)
45{ 71{
46 nmk_gpio_set_mode(nhk8815_i2c_data0.scl_pin, NMK_GPIO_ALT_GPIO); 72 nmk_config_pins(cpu8815_pins_i2c, ARRAY_SIZE(cpu8815_pins_i2c));
47 nmk_gpio_set_mode(nhk8815_i2c_data0.sda_pin, NMK_GPIO_ALT_GPIO);
48 platform_device_register(&nhk8815_i2c_dev0); 73 platform_device_register(&nhk8815_i2c_dev0);
49
50 nmk_gpio_set_mode(nhk8815_i2c_data1.scl_pin, NMK_GPIO_ALT_GPIO);
51 nmk_gpio_set_mode(nhk8815_i2c_data1.sda_pin, NMK_GPIO_ALT_GPIO);
52 platform_device_register(&nhk8815_i2c_dev1); 74 platform_device_register(&nhk8815_i2c_dev1);
75 platform_device_register(&nhk8815_i2c_dev2);
53 76
54 return 0; 77 return 0;
55} 78}
@@ -58,6 +81,7 @@ static void __exit nhk8815_i2c_exit(void)
58{ 81{
59 platform_device_unregister(&nhk8815_i2c_dev0); 82 platform_device_unregister(&nhk8815_i2c_dev0);
60 platform_device_unregister(&nhk8815_i2c_dev1); 83 platform_device_unregister(&nhk8815_i2c_dev1);
84 platform_device_unregister(&nhk8815_i2c_dev2);
61 return; 85 return;
62} 86}
63 87
diff --git a/arch/arm/mach-nomadik/include/mach/irqs.h b/arch/arm/mach-nomadik/include/mach/irqs.h
index 8faabc56039..a118e615f86 100644
--- a/arch/arm/mach-nomadik/include/mach/irqs.h
+++ b/arch/arm/mach-nomadik/include/mach/irqs.h
@@ -22,56 +22,56 @@
22 22
23#include <mach/hardware.h> 23#include <mach/hardware.h>
24 24
25#define IRQ_VIC_START 0 /* first VIC interrupt is 0 */ 25#define IRQ_VIC_START 1 /* first VIC interrupt is 1 */
26 26
27/* 27/*
28 * Interrupt numbers generic for all Nomadik Chip cuts 28 * Interrupt numbers generic for all Nomadik Chip cuts
29 */ 29 */
30#define IRQ_WATCHDOG 0 30#define IRQ_WATCHDOG 1
31#define IRQ_SOFTINT 1 31#define IRQ_SOFTINT 2
32#define IRQ_CRYPTO 2 32#define IRQ_CRYPTO 3
33#define IRQ_OWM 3 33#define IRQ_OWM 4
34#define IRQ_MTU0 4 34#define IRQ_MTU0 5
35#define IRQ_MTU1 5 35#define IRQ_MTU1 6
36#define IRQ_GPIO0 6 36#define IRQ_GPIO0 7
37#define IRQ_GPIO1 7 37#define IRQ_GPIO1 8
38#define IRQ_GPIO2 8 38#define IRQ_GPIO2 9
39#define IRQ_GPIO3 9 39#define IRQ_GPIO3 10
40#define IRQ_RTC_RTT 10 40#define IRQ_RTC_RTT 11
41#define IRQ_SSP 11 41#define IRQ_SSP 12
42#define IRQ_UART0 12 42#define IRQ_UART0 13
43#define IRQ_DMA1 13 43#define IRQ_DMA1 14
44#define IRQ_CLCD_MDIF 14 44#define IRQ_CLCD_MDIF 15
45#define IRQ_DMA0 15 45#define IRQ_DMA0 16
46#define IRQ_PWRFAIL 16 46#define IRQ_PWRFAIL 17
47#define IRQ_UART1 17 47#define IRQ_UART1 18
48#define IRQ_FIRDA 18 48#define IRQ_FIRDA 19
49#define IRQ_MSP0 19 49#define IRQ_MSP0 20
50#define IRQ_I2C0 20 50#define IRQ_I2C0 21
51#define IRQ_I2C1 21 51#define IRQ_I2C1 22
52#define IRQ_SDMMC 22 52#define IRQ_SDMMC 23
53#define IRQ_USBOTG 23 53#define IRQ_USBOTG 24
54#define IRQ_SVA_IT0 24 54#define IRQ_SVA_IT0 25
55#define IRQ_SVA_IT1 25 55#define IRQ_SVA_IT1 26
56#define IRQ_SAA_IT0 26 56#define IRQ_SAA_IT0 27
57#define IRQ_SAA_IT1 27 57#define IRQ_SAA_IT1 28
58#define IRQ_UART2 28 58#define IRQ_UART2 29
59#define IRQ_MSP2 31 59#define IRQ_MSP2 30
60#define IRQ_L2CC 48 60#define IRQ_L2CC 49
61#define IRQ_HPI 49 61#define IRQ_HPI 50
62#define IRQ_SKE 50 62#define IRQ_SKE 51
63#define IRQ_KP 51 63#define IRQ_KP 52
64#define IRQ_MEMST 54 64#define IRQ_MEMST 55
65#define IRQ_SGA_IT 58 65#define IRQ_SGA_IT 59
66#define IRQ_USBM 60 66#define IRQ_USBM 61
67#define IRQ_MSP1 62 67#define IRQ_MSP1 63
68 68
69#define NOMADIK_SOC_NR_IRQS 64 69#define NOMADIK_GPIO_OFFSET (IRQ_VIC_START+64)
70 70
71/* After chip-specific IRQ numbers we have the GPIO ones */ 71/* After chip-specific IRQ numbers we have the GPIO ones */
72#define NOMADIK_NR_GPIO 128 /* last 4 not wired to pins */ 72#define NOMADIK_NR_GPIO 128 /* last 4 not wired to pins */
73#define NOMADIK_GPIO_TO_IRQ(gpio) ((gpio) + NOMADIK_SOC_NR_IRQS) 73#define NOMADIK_GPIO_TO_IRQ(gpio) ((gpio) + NOMADIK_GPIO_OFFSET)
74#define NOMADIK_IRQ_TO_GPIO(irq) ((irq) - NOMADIK_SOC_NR_IRQS) 74#define NOMADIK_IRQ_TO_GPIO(irq) ((irq) - NOMADIK_GPIO_OFFSET)
75#define NR_IRQS NOMADIK_GPIO_TO_IRQ(NOMADIK_NR_GPIO) 75#define NR_IRQS NOMADIK_GPIO_TO_IRQ(NOMADIK_NR_GPIO)
76 76
77/* Following two are used by entry_macro.S, to access our dual-vic */ 77/* Following two are used by entry_macro.S, to access our dual-vic */
@@ -79,4 +79,3 @@
79#define VIC_REG_IRQSR1 0x20 79#define VIC_REG_IRQSR1 0x20
80 80
81#endif /* __ASM_ARCH_IRQS_H */ 81#endif /* __ASM_ARCH_IRQS_H */
82
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index f2f8a584701..c53469802c0 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -37,12 +37,12 @@
37#include <plat/board-ams-delta.h> 37#include <plat/board-ams-delta.h>
38#include <plat/keypad.h> 38#include <plat/keypad.h>
39#include <plat/mux.h> 39#include <plat/mux.h>
40#include <plat/usb.h>
41#include <plat/board.h> 40#include <plat/board.h>
42 41
43#include <mach/hardware.h> 42#include <mach/hardware.h>
44#include <mach/ams-delta-fiq.h> 43#include <mach/ams-delta-fiq.h>
45#include <mach/camera.h> 44#include <mach/camera.h>
45#include <mach/usb.h>
46 46
47#include "iomap.h" 47#include "iomap.h"
48#include "common.h" 48#include "common.h"
diff --git a/arch/arm/mach-omap1/board-generic.c b/arch/arm/mach-omap1/board-generic.c
index e75e2d55a2d..6ec385e2b98 100644
--- a/arch/arm/mach-omap1/board-generic.c
+++ b/arch/arm/mach-omap1/board-generic.c
@@ -23,8 +23,10 @@
23#include <asm/mach/map.h> 23#include <asm/mach/map.h>
24 24
25#include <plat/mux.h> 25#include <plat/mux.h>
26#include <plat/usb.h>
27#include <plat/board.h> 26#include <plat/board.h>
27
28#include <mach/usb.h>
29
28#include "common.h" 30#include "common.h"
29 31
30/* assume no Mini-AB port */ 32/* assume no Mini-AB port */
diff --git a/arch/arm/mach-omap1/board-h2-mmc.c b/arch/arm/mach-omap1/board-h2-mmc.c
index da0e37d4082..e1362ce4849 100644
--- a/arch/arm/mach-omap1/board-h2-mmc.c
+++ b/arch/arm/mach-omap1/board-h2-mmc.c
@@ -54,7 +54,6 @@ static struct omap_mmc_platform_data mmc1_data = {
54 .nr_slots = 1, 54 .nr_slots = 1,
55 .init = mmc_late_init, 55 .init = mmc_late_init,
56 .cleanup = mmc_cleanup, 56 .cleanup = mmc_cleanup,
57 .dma_mask = 0xffffffff,
58 .slots[0] = { 57 .slots[0] = {
59 .set_power = mmc_set_power, 58 .set_power = mmc_set_power,
60 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 59 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index a28e989a63f..44a4ab195fb 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -40,11 +40,11 @@
40#include <plat/dma.h> 40#include <plat/dma.h>
41#include <plat/tc.h> 41#include <plat/tc.h>
42#include <plat/irda.h> 42#include <plat/irda.h>
43#include <plat/usb.h>
44#include <plat/keypad.h> 43#include <plat/keypad.h>
45#include <plat/flash.h> 44#include <plat/flash.h>
46 45
47#include <mach/hardware.h> 46#include <mach/hardware.h>
47#include <mach/usb.h>
48 48
49#include "common.h" 49#include "common.h"
50#include "board-h2.h" 50#include "board-h2.h"
diff --git a/arch/arm/mach-omap1/board-h3-mmc.c b/arch/arm/mach-omap1/board-h3-mmc.c
index f8242aa9b76..c74daace8cd 100644
--- a/arch/arm/mach-omap1/board-h3-mmc.c
+++ b/arch/arm/mach-omap1/board-h3-mmc.c
@@ -36,7 +36,6 @@ static int mmc_set_power(struct device *dev, int slot, int power_on,
36 */ 36 */
37static struct omap_mmc_platform_data mmc1_data = { 37static struct omap_mmc_platform_data mmc1_data = {
38 .nr_slots = 1, 38 .nr_slots = 1,
39 .dma_mask = 0xffffffff,
40 .slots[0] = { 39 .slots[0] = {
41 .set_power = mmc_set_power, 40 .set_power = mmc_set_power,
42 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 41 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index 108a8640fc6..86cb5a04a40 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -40,13 +40,13 @@
40 40
41#include <plat/mux.h> 41#include <plat/mux.h>
42#include <plat/tc.h> 42#include <plat/tc.h>
43#include <plat/usb.h>
44#include <plat/keypad.h> 43#include <plat/keypad.h>
45#include <plat/dma.h> 44#include <plat/dma.h>
46#include <plat/flash.h> 45#include <plat/flash.h>
47 46
48#include <mach/hardware.h> 47#include <mach/hardware.h>
49#include <mach/irqs.h> 48#include <mach/irqs.h>
49#include <mach/usb.h>
50 50
51#include "common.h" 51#include "common.h"
52#include "board-h3.h" 52#include "board-h3.h"
diff --git a/arch/arm/mach-omap1/board-htcherald.c b/arch/arm/mach-omap1/board-htcherald.c
index 118a9d4a4c5..b3f6e943e66 100644
--- a/arch/arm/mach-omap1/board-htcherald.c
+++ b/arch/arm/mach-omap1/board-htcherald.c
@@ -44,10 +44,10 @@
44#include <plat/omap7xx.h> 44#include <plat/omap7xx.h>
45#include <plat/board.h> 45#include <plat/board.h>
46#include <plat/keypad.h> 46#include <plat/keypad.h>
47#include <plat/usb.h>
48#include <plat/mmc.h> 47#include <plat/mmc.h>
49 48
50#include <mach/irqs.h> 49#include <mach/irqs.h>
50#include <mach/usb.h>
51 51
52#include "common.h" 52#include "common.h"
53 53
diff --git a/arch/arm/mach-omap1/board-innovator.c b/arch/arm/mach-omap1/board-innovator.c
index 7970223a559..f21c2966daa 100644
--- a/arch/arm/mach-omap1/board-innovator.c
+++ b/arch/arm/mach-omap1/board-innovator.c
@@ -35,11 +35,11 @@
35#include <plat/flash.h> 35#include <plat/flash.h>
36#include <plat/fpga.h> 36#include <plat/fpga.h>
37#include <plat/tc.h> 37#include <plat/tc.h>
38#include <plat/usb.h>
39#include <plat/keypad.h> 38#include <plat/keypad.h>
40#include <plat/mmc.h> 39#include <plat/mmc.h>
41 40
42#include <mach/hardware.h> 41#include <mach/hardware.h>
42#include <mach/usb.h>
43 43
44#include "iomap.h" 44#include "iomap.h"
45#include "common.h" 45#include "common.h"
diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index 7212ae97f44..2c0ca8fc338 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -26,7 +26,6 @@
26#include <asm/mach/map.h> 26#include <asm/mach/map.h>
27 27
28#include <plat/mux.h> 28#include <plat/mux.h>
29#include <plat/usb.h>
30#include <plat/board.h> 29#include <plat/board.h>
31#include <plat/keypad.h> 30#include <plat/keypad.h>
32#include <plat/lcd_mipid.h> 31#include <plat/lcd_mipid.h>
@@ -34,6 +33,7 @@
34#include <plat/clock.h> 33#include <plat/clock.h>
35 34
36#include <mach/hardware.h> 35#include <mach/hardware.h>
36#include <mach/usb.h>
37 37
38#include "common.h" 38#include "common.h"
39 39
@@ -185,7 +185,6 @@ static int nokia770_mmc_get_cover_state(struct device *dev, int slot)
185 185
186static struct omap_mmc_platform_data nokia770_mmc2_data = { 186static struct omap_mmc_platform_data nokia770_mmc2_data = {
187 .nr_slots = 1, 187 .nr_slots = 1,
188 .dma_mask = 0xffffffff,
189 .max_freq = 12000000, 188 .max_freq = 12000000,
190 .slots[0] = { 189 .slots[0] = {
191 .set_power = nokia770_mmc_set_power, 190 .set_power = nokia770_mmc_set_power,
diff --git a/arch/arm/mach-omap1/board-osk.c b/arch/arm/mach-omap1/board-osk.c
index da8d872d3d1..8784705edb6 100644
--- a/arch/arm/mach-omap1/board-osk.c
+++ b/arch/arm/mach-omap1/board-osk.c
@@ -45,11 +45,11 @@
45#include <asm/mach/map.h> 45#include <asm/mach/map.h>
46 46
47#include <plat/flash.h> 47#include <plat/flash.h>
48#include <plat/usb.h>
49#include <plat/mux.h> 48#include <plat/mux.h>
50#include <plat/tc.h> 49#include <plat/tc.h>
51 50
52#include <mach/hardware.h> 51#include <mach/hardware.h>
52#include <mach/usb.h>
53 53
54#include "common.h" 54#include "common.h"
55 55
diff --git a/arch/arm/mach-omap1/board-palmte.c b/arch/arm/mach-omap1/board-palmte.c
index 949b62a7369..26bcb9defcd 100644
--- a/arch/arm/mach-omap1/board-palmte.c
+++ b/arch/arm/mach-omap1/board-palmte.c
@@ -35,7 +35,6 @@
35 35
36#include <plat/flash.h> 36#include <plat/flash.h>
37#include <plat/mux.h> 37#include <plat/mux.h>
38#include <plat/usb.h>
39#include <plat/tc.h> 38#include <plat/tc.h>
40#include <plat/dma.h> 39#include <plat/dma.h>
41#include <plat/board.h> 40#include <plat/board.h>
@@ -43,6 +42,7 @@
43#include <plat/keypad.h> 42#include <plat/keypad.h>
44 43
45#include <mach/hardware.h> 44#include <mach/hardware.h>
45#include <mach/usb.h>
46 46
47#include "common.h" 47#include "common.h"
48 48
diff --git a/arch/arm/mach-omap1/board-palmtt.c b/arch/arm/mach-omap1/board-palmtt.c
index 7f1e1cf2bf4..4d099446dfa 100644
--- a/arch/arm/mach-omap1/board-palmtt.c
+++ b/arch/arm/mach-omap1/board-palmtt.c
@@ -35,7 +35,6 @@
35#include <plat/led.h> 35#include <plat/led.h>
36#include <plat/flash.h> 36#include <plat/flash.h>
37#include <plat/mux.h> 37#include <plat/mux.h>
38#include <plat/usb.h>
39#include <plat/dma.h> 38#include <plat/dma.h>
40#include <plat/tc.h> 39#include <plat/tc.h>
41#include <plat/board.h> 40#include <plat/board.h>
@@ -43,6 +42,7 @@
43#include <plat/keypad.h> 42#include <plat/keypad.h>
44 43
45#include <mach/hardware.h> 44#include <mach/hardware.h>
45#include <mach/usb.h>
46 46
47#include "common.h" 47#include "common.h"
48 48
diff --git a/arch/arm/mach-omap1/board-palmz71.c b/arch/arm/mach-omap1/board-palmz71.c
index 3c71c6bace2..355980321c2 100644
--- a/arch/arm/mach-omap1/board-palmz71.c
+++ b/arch/arm/mach-omap1/board-palmz71.c
@@ -37,7 +37,6 @@
37 37
38#include <plat/flash.h> 38#include <plat/flash.h>
39#include <plat/mux.h> 39#include <plat/mux.h>
40#include <plat/usb.h>
41#include <plat/dma.h> 40#include <plat/dma.h>
42#include <plat/tc.h> 41#include <plat/tc.h>
43#include <plat/board.h> 42#include <plat/board.h>
@@ -45,6 +44,7 @@
45#include <plat/keypad.h> 44#include <plat/keypad.h>
46 45
47#include <mach/hardware.h> 46#include <mach/hardware.h>
47#include <mach/usb.h>
48 48
49#include "common.h" 49#include "common.h"
50 50
@@ -288,8 +288,7 @@ palmz71_gpio_setup(int early)
288 } 288 }
289 gpio_direction_input(PALMZ71_USBDETECT_GPIO); 289 gpio_direction_input(PALMZ71_USBDETECT_GPIO);
290 if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO), 290 if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
291 palmz71_powercable, IRQF_SAMPLE_RANDOM, 291 palmz71_powercable, 0, "palmz71-cable", NULL))
292 "palmz71-cable", NULL))
293 printk(KERN_ERR 292 printk(KERN_ERR
294 "IRQ request for power cable failed!\n"); 293 "IRQ request for power cable failed!\n");
295 palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO), NULL); 294 palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO), NULL);
diff --git a/arch/arm/mach-omap1/board-sx1.c b/arch/arm/mach-omap1/board-sx1.c
index 3b7b82b1368..8c665bd16ac 100644
--- a/arch/arm/mach-omap1/board-sx1.c
+++ b/arch/arm/mach-omap1/board-sx1.c
@@ -37,13 +37,13 @@
37#include <plat/mux.h> 37#include <plat/mux.h>
38#include <plat/dma.h> 38#include <plat/dma.h>
39#include <plat/irda.h> 39#include <plat/irda.h>
40#include <plat/usb.h>
41#include <plat/tc.h> 40#include <plat/tc.h>
42#include <plat/board.h> 41#include <plat/board.h>
43#include <plat/keypad.h> 42#include <plat/keypad.h>
44#include <plat/board-sx1.h> 43#include <plat/board-sx1.h>
45 44
46#include <mach/hardware.h> 45#include <mach/hardware.h>
46#include <mach/usb.h>
47 47
48#include "common.h" 48#include "common.h"
49 49
diff --git a/arch/arm/mach-omap1/board-voiceblue.c b/arch/arm/mach-omap1/board-voiceblue.c
index afd67f0ec49..3497769eb35 100644
--- a/arch/arm/mach-omap1/board-voiceblue.c
+++ b/arch/arm/mach-omap1/board-voiceblue.c
@@ -35,9 +35,10 @@
35#include <plat/flash.h> 35#include <plat/flash.h>
36#include <plat/mux.h> 36#include <plat/mux.h>
37#include <plat/tc.h> 37#include <plat/tc.h>
38#include <plat/usb.h> 38#include <plat/board.h>
39 39
40#include <mach/hardware.h> 40#include <mach/hardware.h>
41#include <mach/usb.h>
41 42
42#include "common.h" 43#include "common.h"
43 44
diff --git a/arch/arm/mach-omap1/clock_data.c b/arch/arm/mach-omap1/clock_data.c
index c6ce93f71d0..c007d80dfb6 100644
--- a/arch/arm/mach-omap1/clock_data.c
+++ b/arch/arm/mach-omap1/clock_data.c
@@ -25,10 +25,11 @@
25#include <plat/clock.h> 25#include <plat/clock.h>
26#include <plat/cpu.h> 26#include <plat/cpu.h>
27#include <plat/clkdev_omap.h> 27#include <plat/clkdev_omap.h>
28#include <plat/board.h>
28#include <plat/sram.h> /* for omap_sram_reprogram_clock() */ 29#include <plat/sram.h> /* for omap_sram_reprogram_clock() */
29#include <plat/usb.h> /* for OTG_BASE */
30 30
31#include <mach/hardware.h> 31#include <mach/hardware.h>
32#include <mach/usb.h> /* for OTG_BASE */
32 33
33#include "iomap.h" 34#include "iomap.h"
34#include "clock.h" 35#include "clock.h"
diff --git a/arch/arm/mach-omap1/include/mach/usb.h b/arch/arm/mach-omap1/include/mach/usb.h
new file mode 100644
index 00000000000..753cd5ce694
--- /dev/null
+++ b/arch/arm/mach-omap1/include/mach/usb.h
@@ -0,0 +1,165 @@
1/*
2 * FIXME correct answer depends on hmc_mode,
3 * as does (on omap1) any nonzero value for config->otg port number
4 */
5#ifdef CONFIG_USB_GADGET_OMAP
6#define is_usb0_device(config) 1
7#else
8#define is_usb0_device(config) 0
9#endif
10
11struct omap_usb_config {
12 /* Configure drivers according to the connectors on your board:
13 * - "A" connector (rectagular)
14 * ... for host/OHCI use, set "register_host".
15 * - "B" connector (squarish) or "Mini-B"
16 * ... for device/gadget use, set "register_dev".
17 * - "Mini-AB" connector (very similar to Mini-B)
18 * ... for OTG use as device OR host, initialize "otg"
19 */
20 unsigned register_host:1;
21 unsigned register_dev:1;
22 u8 otg; /* port number, 1-based: usb1 == 2 */
23
24 u8 hmc_mode;
25
26 /* implicitly true if otg: host supports remote wakeup? */
27 u8 rwc;
28
29 /* signaling pins used to talk to transceiver on usbN:
30 * 0 == usbN unused
31 * 2 == usb0-only, using internal transceiver
32 * 3 == 3 wire bidirectional
33 * 4 == 4 wire bidirectional
34 * 6 == 6 wire unidirectional (or TLL)
35 */
36 u8 pins[3];
37
38 struct platform_device *udc_device;
39 struct platform_device *ohci_device;
40 struct platform_device *otg_device;
41
42 u32 (*usb0_init)(unsigned nwires, unsigned is_device);
43 u32 (*usb1_init)(unsigned nwires);
44 u32 (*usb2_init)(unsigned nwires, unsigned alt_pingroup);
45
46 int (*ocpi_enable)(void);
47};
48
49void omap_otg_init(struct omap_usb_config *config);
50
51#if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE)
52void omap1_usb_init(struct omap_usb_config *pdata);
53#else
54static inline void omap1_usb_init(struct omap_usb_config *pdata)
55{
56}
57#endif
58
59#define OMAP1_OTG_BASE 0xfffb0400
60#define OMAP1_UDC_BASE 0xfffb4000
61#define OMAP1_OHCI_BASE 0xfffba000
62
63#define OMAP2_OHCI_BASE 0x4805e000
64#define OMAP2_UDC_BASE 0x4805e200
65#define OMAP2_OTG_BASE 0x4805e300
66#define OTG_BASE OMAP1_OTG_BASE
67#define UDC_BASE OMAP1_UDC_BASE
68#define OMAP_OHCI_BASE OMAP1_OHCI_BASE
69
70/*
71 * OTG and transceiver registers, for OMAPs starting with ARM926
72 */
73#define OTG_REV (OTG_BASE + 0x00)
74#define OTG_SYSCON_1 (OTG_BASE + 0x04)
75# define USB2_TRX_MODE(w) (((w)>>24)&0x07)
76# define USB1_TRX_MODE(w) (((w)>>20)&0x07)
77# define USB0_TRX_MODE(w) (((w)>>16)&0x07)
78# define OTG_IDLE_EN (1 << 15)
79# define HST_IDLE_EN (1 << 14)
80# define DEV_IDLE_EN (1 << 13)
81# define OTG_RESET_DONE (1 << 2)
82# define OTG_SOFT_RESET (1 << 1)
83#define OTG_SYSCON_2 (OTG_BASE + 0x08)
84# define OTG_EN (1 << 31)
85# define USBX_SYNCHRO (1 << 30)
86# define OTG_MST16 (1 << 29)
87# define SRP_GPDATA (1 << 28)
88# define SRP_GPDVBUS (1 << 27)
89# define SRP_GPUVBUS(w) (((w)>>24)&0x07)
90# define A_WAIT_VRISE(w) (((w)>>20)&0x07)
91# define B_ASE_BRST(w) (((w)>>16)&0x07)
92# define SRP_DPW (1 << 14)
93# define SRP_DATA (1 << 13)
94# define SRP_VBUS (1 << 12)
95# define OTG_PADEN (1 << 10)
96# define HMC_PADEN (1 << 9)
97# define UHOST_EN (1 << 8)
98# define HMC_TLLSPEED (1 << 7)
99# define HMC_TLLATTACH (1 << 6)
100# define OTG_HMC(w) (((w)>>0)&0x3f)
101#define OTG_CTRL (OTG_BASE + 0x0c)
102# define OTG_USB2_EN (1 << 29)
103# define OTG_USB2_DP (1 << 28)
104# define OTG_USB2_DM (1 << 27)
105# define OTG_USB1_EN (1 << 26)
106# define OTG_USB1_DP (1 << 25)
107# define OTG_USB1_DM (1 << 24)
108# define OTG_USB0_EN (1 << 23)
109# define OTG_USB0_DP (1 << 22)
110# define OTG_USB0_DM (1 << 21)
111# define OTG_ASESSVLD (1 << 20)
112# define OTG_BSESSEND (1 << 19)
113# define OTG_BSESSVLD (1 << 18)
114# define OTG_VBUSVLD (1 << 17)
115# define OTG_ID (1 << 16)
116# define OTG_DRIVER_SEL (1 << 15)
117# define OTG_A_SETB_HNPEN (1 << 12)
118# define OTG_A_BUSREQ (1 << 11)
119# define OTG_B_HNPEN (1 << 9)
120# define OTG_B_BUSREQ (1 << 8)
121# define OTG_BUSDROP (1 << 7)
122# define OTG_PULLDOWN (1 << 5)
123# define OTG_PULLUP (1 << 4)
124# define OTG_DRV_VBUS (1 << 3)
125# define OTG_PD_VBUS (1 << 2)
126# define OTG_PU_VBUS (1 << 1)
127# define OTG_PU_ID (1 << 0)
128#define OTG_IRQ_EN (OTG_BASE + 0x10) /* 16-bit */
129# define DRIVER_SWITCH (1 << 15)
130# define A_VBUS_ERR (1 << 13)
131# define A_REQ_TMROUT (1 << 12)
132# define A_SRP_DETECT (1 << 11)
133# define B_HNP_FAIL (1 << 10)
134# define B_SRP_TMROUT (1 << 9)
135# define B_SRP_DONE (1 << 8)
136# define B_SRP_STARTED (1 << 7)
137# define OPRT_CHG (1 << 0)
138#define OTG_IRQ_SRC (OTG_BASE + 0x14) /* 16-bit */
139 // same bits as in IRQ_EN
140#define OTG_OUTCTRL (OTG_BASE + 0x18) /* 16-bit */
141# define OTGVPD (1 << 14)
142# define OTGVPU (1 << 13)
143# define OTGPUID (1 << 12)
144# define USB2VDR (1 << 10)
145# define USB2PDEN (1 << 9)
146# define USB2PUEN (1 << 8)
147# define USB1VDR (1 << 6)
148# define USB1PDEN (1 << 5)
149# define USB1PUEN (1 << 4)
150# define USB0VDR (1 << 2)
151# define USB0PDEN (1 << 1)
152# define USB0PUEN (1 << 0)
153#define OTG_TEST (OTG_BASE + 0x20) /* 16-bit */
154#define OTG_VENDOR_CODE (OTG_BASE + 0xfc) /* 16-bit */
155
156/*-------------------------------------------------------------------------*/
157
158/* OMAP1 */
159#define USB_TRANSCEIVER_CTRL (0xfffe1000 + 0x0064)
160# define CONF_USB2_UNI_R (1 << 8)
161# define CONF_USB1_UNI_R (1 << 7)
162# define CONF_USB_PORT0_R(x) (((x)>>4)&0x7)
163# define CONF_USB0_ISOLATE_R (1 << 3)
164# define CONF_USB_PWRDN_DM_R (1 << 2)
165# define CONF_USB_PWRDN_DP_R (1 << 1)
diff --git a/arch/arm/mach-omap1/timer.c b/arch/arm/mach-omap1/timer.c
index 64c65bcb2d6..aa81593db1a 100644
--- a/arch/arm/mach-omap1/timer.c
+++ b/arch/arm/mach-omap1/timer.c
@@ -140,7 +140,8 @@ static int __init omap1_dm_timer_init(void)
140 } 140 }
141 141
142 pdata->set_timer_src = omap1_dm_timer_set_src; 142 pdata->set_timer_src = omap1_dm_timer_set_src;
143 pdata->needs_manual_reset = 1; 143 pdata->timer_capability = OMAP_TIMER_ALWON |
144 OMAP_TIMER_NEEDS_RESET;
144 145
145 ret = platform_device_add_data(pdev, pdata, sizeof(*pdata)); 146 ret = platform_device_add_data(pdev, pdata, sizeof(*pdata));
146 if (ret) { 147 if (ret) {
diff --git a/arch/arm/mach-omap1/usb.c b/arch/arm/mach-omap1/usb.c
index e61afd92276..65f88176fba 100644
--- a/arch/arm/mach-omap1/usb.c
+++ b/arch/arm/mach-omap1/usb.c
@@ -27,7 +27,8 @@
27#include <asm/irq.h> 27#include <asm/irq.h>
28 28
29#include <plat/mux.h> 29#include <plat/mux.h>
30#include <plat/usb.h> 30
31#include <mach/usb.h>
31 32
32#include "common.h" 33#include "common.h"
33 34
@@ -55,6 +56,119 @@
55#define INT_USB_IRQ_HGEN INT_USB_HHC_1 56#define INT_USB_IRQ_HGEN INT_USB_HHC_1
56#define INT_USB_IRQ_OTG IH2_BASE + 8 57#define INT_USB_IRQ_OTG IH2_BASE + 8
57 58
59#ifdef CONFIG_ARCH_OMAP_OTG
60
61void __init
62omap_otg_init(struct omap_usb_config *config)
63{
64 u32 syscon;
65 int alt_pingroup = 0;
66
67 /* NOTE: no bus or clock setup (yet?) */
68
69 syscon = omap_readl(OTG_SYSCON_1) & 0xffff;
70 if (!(syscon & OTG_RESET_DONE))
71 pr_debug("USB resets not complete?\n");
72
73 //omap_writew(0, OTG_IRQ_EN);
74
75 /* pin muxing and transceiver pinouts */
76 if (config->pins[0] > 2) /* alt pingroup 2 */
77 alt_pingroup = 1;
78 syscon |= config->usb0_init(config->pins[0], is_usb0_device(config));
79 syscon |= config->usb1_init(config->pins[1]);
80 syscon |= config->usb2_init(config->pins[2], alt_pingroup);
81 pr_debug("OTG_SYSCON_1 = %08x\n", omap_readl(OTG_SYSCON_1));
82 omap_writel(syscon, OTG_SYSCON_1);
83
84 syscon = config->hmc_mode;
85 syscon |= USBX_SYNCHRO | (4 << 16) /* B_ASE0_BRST */;
86#ifdef CONFIG_USB_OTG
87 if (config->otg)
88 syscon |= OTG_EN;
89#endif
90 if (cpu_class_is_omap1())
91 pr_debug("USB_TRANSCEIVER_CTRL = %03x\n",
92 omap_readl(USB_TRANSCEIVER_CTRL));
93 pr_debug("OTG_SYSCON_2 = %08x\n", omap_readl(OTG_SYSCON_2));
94 omap_writel(syscon, OTG_SYSCON_2);
95
96 printk("USB: hmc %d", config->hmc_mode);
97 if (!alt_pingroup)
98 printk(", usb2 alt %d wires", config->pins[2]);
99 else if (config->pins[0])
100 printk(", usb0 %d wires%s", config->pins[0],
101 is_usb0_device(config) ? " (dev)" : "");
102 if (config->pins[1])
103 printk(", usb1 %d wires", config->pins[1]);
104 if (!alt_pingroup && config->pins[2])
105 printk(", usb2 %d wires", config->pins[2]);
106 if (config->otg)
107 printk(", Mini-AB on usb%d", config->otg - 1);
108 printk("\n");
109
110 if (cpu_class_is_omap1()) {
111 u16 w;
112
113 /* leave USB clocks/controllers off until needed */
114 w = omap_readw(ULPD_SOFT_REQ);
115 w &= ~SOFT_USB_CLK_REQ;
116 omap_writew(w, ULPD_SOFT_REQ);
117
118 w = omap_readw(ULPD_CLOCK_CTRL);
119 w &= ~USB_MCLK_EN;
120 w |= DIS_USB_PVCI_CLK;
121 omap_writew(w, ULPD_CLOCK_CTRL);
122 }
123 syscon = omap_readl(OTG_SYSCON_1);
124 syscon |= HST_IDLE_EN|DEV_IDLE_EN|OTG_IDLE_EN;
125
126#ifdef CONFIG_USB_GADGET_OMAP
127 if (config->otg || config->register_dev) {
128 struct platform_device *udc_device = config->udc_device;
129 int status;
130
131 syscon &= ~DEV_IDLE_EN;
132 udc_device->dev.platform_data = config;
133 status = platform_device_register(udc_device);
134 if (status)
135 pr_debug("can't register UDC device, %d\n", status);
136 }
137#endif
138
139#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
140 if (config->otg || config->register_host) {
141 struct platform_device *ohci_device = config->ohci_device;
142 int status;
143
144 syscon &= ~HST_IDLE_EN;
145 ohci_device->dev.platform_data = config;
146 status = platform_device_register(ohci_device);
147 if (status)
148 pr_debug("can't register OHCI device, %d\n", status);
149 }
150#endif
151
152#ifdef CONFIG_USB_OTG
153 if (config->otg) {
154 struct platform_device *otg_device = config->otg_device;
155 int status;
156
157 syscon &= ~OTG_IDLE_EN;
158 otg_device->dev.platform_data = config;
159 status = platform_device_register(otg_device);
160 if (status)
161 pr_debug("can't register OTG device, %d\n", status);
162 }
163#endif
164 pr_debug("OTG_SYSCON_1 = %08x\n", omap_readl(OTG_SYSCON_1));
165 omap_writel(syscon, OTG_SYSCON_1);
166}
167
168#else
169void omap_otg_init(struct omap_usb_config *config) {}
170#endif
171
58#ifdef CONFIG_USB_GADGET_OMAP 172#ifdef CONFIG_USB_GADGET_OMAP
59 173
60static struct resource udc_resources[] = { 174static struct resource udc_resources[] = {
diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 4cf5142f22c..fcd4e85c4dd 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -9,7 +9,7 @@ config ARCH_OMAP2PLUS_TYPICAL
9 select REGULATOR 9 select REGULATOR
10 select PM_RUNTIME 10 select PM_RUNTIME
11 select VFP 11 select VFP
12 select NEON if ARCH_OMAP3 || ARCH_OMAP4 12 select NEON if ARCH_OMAP3 || ARCH_OMAP4 || SOC_OMAP5
13 select SERIAL_OMAP 13 select SERIAL_OMAP
14 select SERIAL_OMAP_CONSOLE 14 select SERIAL_OMAP_CONSOLE
15 select I2C 15 select I2C
@@ -21,12 +21,16 @@ config ARCH_OMAP2PLUS_TYPICAL
21 help 21 help
22 Compile a kernel suitable for booting most boards 22 Compile a kernel suitable for booting most boards
23 23
24config SOC_HAS_OMAP2_SDRC
25 bool "OMAP2 SDRAM Controller support"
26
24config ARCH_OMAP2 27config ARCH_OMAP2
25 bool "TI OMAP2" 28 bool "TI OMAP2"
26 depends on ARCH_OMAP2PLUS 29 depends on ARCH_OMAP2PLUS
27 default y 30 default y
28 select CPU_V6 31 select CPU_V6
29 select MULTI_IRQ_HANDLER 32 select MULTI_IRQ_HANDLER
33 select SOC_HAS_OMAP2_SDRC
30 34
31config ARCH_OMAP3 35config ARCH_OMAP3
32 bool "TI OMAP3" 36 bool "TI OMAP3"
@@ -35,9 +39,11 @@ config ARCH_OMAP3
35 select CPU_V7 39 select CPU_V7
36 select USB_ARCH_HAS_EHCI if USB_SUPPORT 40 select USB_ARCH_HAS_EHCI if USB_SUPPORT
37 select ARCH_HAS_OPP 41 select ARCH_HAS_OPP
42 select PM_RUNTIME if CPU_IDLE
38 select PM_OPP if PM 43 select PM_OPP if PM
39 select ARM_CPU_SUSPEND if PM 44 select ARM_CPU_SUSPEND if PM
40 select MULTI_IRQ_HANDLER 45 select MULTI_IRQ_HANDLER
46 select SOC_HAS_OMAP2_SDRC
41 47
42config ARCH_OMAP4 48config ARCH_OMAP4
43 bool "TI OMAP4" 49 bool "TI OMAP4"
@@ -52,9 +58,18 @@ config ARCH_OMAP4
52 select PL310_ERRATA_727915 58 select PL310_ERRATA_727915
53 select ARM_ERRATA_720789 59 select ARM_ERRATA_720789
54 select ARCH_HAS_OPP 60 select ARCH_HAS_OPP
61 select PM_RUNTIME if CPU_IDLE
55 select PM_OPP if PM 62 select PM_OPP if PM
56 select USB_ARCH_HAS_EHCI if USB_SUPPORT 63 select USB_ARCH_HAS_EHCI if USB_SUPPORT
57 select ARM_CPU_SUSPEND if PM 64 select ARM_CPU_SUSPEND if PM
65 select ARCH_NEEDS_CPU_IDLE_COUPLED if SMP
66
67config SOC_OMAP5
68 bool "TI OMAP5"
69 select CPU_V7
70 select ARM_GIC
71 select HAVE_SMP
72 select ARM_CPU_SUSPEND if PM
58 73
59comment "OMAP Core Type" 74comment "OMAP Core Type"
60 depends on ARCH_OMAP2 75 depends on ARCH_OMAP2
@@ -64,19 +79,19 @@ config SOC_OMAP2420
64 depends on ARCH_OMAP2 79 depends on ARCH_OMAP2
65 default y 80 default y
66 select OMAP_DM_TIMER 81 select OMAP_DM_TIMER
67 select ARCH_OMAP_OTG 82 select SOC_HAS_OMAP2_SDRC
68 83
69config SOC_OMAP2430 84config SOC_OMAP2430
70 bool "OMAP2430 support" 85 bool "OMAP2430 support"
71 depends on ARCH_OMAP2 86 depends on ARCH_OMAP2
72 default y 87 default y
73 select ARCH_OMAP_OTG 88 select SOC_HAS_OMAP2_SDRC
74 89
75config SOC_OMAP3430 90config SOC_OMAP3430
76 bool "OMAP3430 support" 91 bool "OMAP3430 support"
77 depends on ARCH_OMAP3 92 depends on ARCH_OMAP3
78 default y 93 default y
79 select ARCH_OMAP_OTG 94 select SOC_HAS_OMAP2_SDRC
80 95
81config SOC_TI81XX 96config SOC_TI81XX
82 bool "TI81XX support" 97 bool "TI81XX support"
@@ -85,8 +100,10 @@ config SOC_TI81XX
85 100
86config SOC_AM33XX 101config SOC_AM33XX
87 bool "AM33XX support" 102 bool "AM33XX support"
88 depends on ARCH_OMAP3
89 default y 103 default y
104 select CPU_V7
105 select ARM_CPU_SUSPEND if PM
106 select MULTI_IRQ_HANDLER
90 107
91config OMAP_PACKAGE_ZAF 108config OMAP_PACKAGE_ZAF
92 bool 109 bool
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index fa742f3c262..f6a24b3f9c4 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -6,7 +6,7 @@
6obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer.o pm.o \ 6obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer.o pm.o \
7 common.o gpio.o dma.o wd_timer.o display.o i2c.o hdq1w.o 7 common.o gpio.o dma.o wd_timer.o display.o i2c.o hdq1w.o
8 8
9omap-2-3-common = irq.o sdrc.o 9omap-2-3-common = irq.o
10hwmod-common = omap_hwmod.o \ 10hwmod-common = omap_hwmod.o \
11 omap_hwmod_common_data.o 11 omap_hwmod_common_data.o
12clock-common = clock.o clock_common_data.o \ 12clock-common = clock.o clock_common_data.o \
@@ -16,19 +16,24 @@ secure-common = omap-smc.o omap-secure.o
16obj-$(CONFIG_ARCH_OMAP2) += $(omap-2-3-common) $(hwmod-common) 16obj-$(CONFIG_ARCH_OMAP2) += $(omap-2-3-common) $(hwmod-common)
17obj-$(CONFIG_ARCH_OMAP3) += $(omap-2-3-common) $(hwmod-common) $(secure-common) 17obj-$(CONFIG_ARCH_OMAP3) += $(omap-2-3-common) $(hwmod-common) $(secure-common)
18obj-$(CONFIG_ARCH_OMAP4) += prm44xx.o $(hwmod-common) $(secure-common) 18obj-$(CONFIG_ARCH_OMAP4) += prm44xx.o $(hwmod-common) $(secure-common)
19obj-$(CONFIG_SOC_AM33XX) += irq.o $(hwmod-common)
20obj-$(CONFIG_SOC_OMAP5) += prm44xx.o $(hwmod-common) $(secure-common)
19 21
20ifneq ($(CONFIG_SND_OMAP_SOC_MCBSP),) 22ifneq ($(CONFIG_SND_OMAP_SOC_MCBSP),)
21obj-y += mcbsp.o 23obj-y += mcbsp.o
22endif 24endif
23 25
24obj-$(CONFIG_TWL4030_CORE) += omap_twl.o 26obj-$(CONFIG_TWL4030_CORE) += omap_twl.o
27obj-$(CONFIG_SOC_HAS_OMAP2_SDRC) += sdrc.o
25 28
26# SMP support ONLY available for OMAP4 29# SMP support ONLY available for OMAP4
27 30
28obj-$(CONFIG_SMP) += omap-smp.o omap-headsmp.o 31obj-$(CONFIG_SMP) += omap-smp.o omap-headsmp.o
29obj-$(CONFIG_HOTPLUG_CPU) += omap-hotplug.o 32obj-$(CONFIG_HOTPLUG_CPU) += omap-hotplug.o
30obj-$(CONFIG_ARCH_OMAP4) += omap4-common.o omap-wakeupgen.o 33omap-4-5-common = omap4-common.o omap-wakeupgen.o \
31obj-$(CONFIG_ARCH_OMAP4) += sleep44xx.o 34 sleep44xx.o
35obj-$(CONFIG_ARCH_OMAP4) += $(omap-4-5-common)
36obj-$(CONFIG_SOC_OMAP5) += $(omap-4-5-common)
32 37
33plus_sec := $(call as-instr,.arch_extension sec,+sec) 38plus_sec := $(call as-instr,.arch_extension sec,+sec)
34AFLAGS_omap-headsmp.o :=-Wa,-march=armv7-a$(plus_sec) 39AFLAGS_omap-headsmp.o :=-Wa,-march=armv7-a$(plus_sec)
@@ -66,12 +71,12 @@ ifeq ($(CONFIG_PM),y)
66obj-$(CONFIG_ARCH_OMAP2) += pm24xx.o 71obj-$(CONFIG_ARCH_OMAP2) += pm24xx.o
67obj-$(CONFIG_ARCH_OMAP2) += sleep24xx.o 72obj-$(CONFIG_ARCH_OMAP2) += sleep24xx.o
68obj-$(CONFIG_ARCH_OMAP3) += pm34xx.o sleep34xx.o 73obj-$(CONFIG_ARCH_OMAP3) += pm34xx.o sleep34xx.o
69obj-$(CONFIG_ARCH_OMAP3) += cpuidle34xx.o
70obj-$(CONFIG_ARCH_OMAP4) += pm44xx.o omap-mpuss-lowpower.o 74obj-$(CONFIG_ARCH_OMAP4) += pm44xx.o omap-mpuss-lowpower.o
71obj-$(CONFIG_ARCH_OMAP4) += cpuidle44xx.o 75obj-$(CONFIG_SOC_OMAP5) += omap-mpuss-lowpower.o
72obj-$(CONFIG_PM_DEBUG) += pm-debug.o 76obj-$(CONFIG_PM_DEBUG) += pm-debug.o
73obj-$(CONFIG_OMAP_SMARTREFLEX) += sr_device.o smartreflex.o 77
74obj-$(CONFIG_OMAP_SMARTREFLEX_CLASS3) += smartreflex-class3.o 78obj-$(CONFIG_POWER_AVS_OMAP) += sr_device.o
79obj-$(CONFIG_POWER_AVS_OMAP_CLASS3) += smartreflex-class3.o
75 80
76AFLAGS_sleep24xx.o :=-Wa,-march=armv6 81AFLAGS_sleep24xx.o :=-Wa,-march=armv6
77AFLAGS_sleep34xx.o :=-Wa,-march=armv7-a$(plus_sec) 82AFLAGS_sleep34xx.o :=-Wa,-march=armv7-a$(plus_sec)
@@ -82,14 +87,22 @@ endif
82 87
83endif 88endif
84 89
90ifeq ($(CONFIG_CPU_IDLE),y)
91obj-$(CONFIG_ARCH_OMAP3) += cpuidle34xx.o
92obj-$(CONFIG_ARCH_OMAP4) += cpuidle44xx.o
93endif
94
85# PRCM 95# PRCM
96omap-prcm-4-5-common = prcm.o cminst44xx.o cm44xx.o \
97 prcm_mpu44xx.o prminst44xx.o \
98 vc44xx_data.o vp44xx_data.o
86obj-y += prm_common.o 99obj-y += prm_common.o
87obj-$(CONFIG_ARCH_OMAP2) += prcm.o cm2xxx_3xxx.o prm2xxx_3xxx.o 100obj-$(CONFIG_ARCH_OMAP2) += prcm.o cm2xxx_3xxx.o prm2xxx_3xxx.o
88obj-$(CONFIG_ARCH_OMAP3) += prcm.o cm2xxx_3xxx.o prm2xxx_3xxx.o 101obj-$(CONFIG_ARCH_OMAP3) += prcm.o cm2xxx_3xxx.o prm2xxx_3xxx.o
89obj-$(CONFIG_ARCH_OMAP3) += vc3xxx_data.o vp3xxx_data.o 102obj-$(CONFIG_ARCH_OMAP3) += vc3xxx_data.o vp3xxx_data.o
90obj-$(CONFIG_ARCH_OMAP4) += prcm.o cminst44xx.o cm44xx.o 103obj-$(CONFIG_SOC_AM33XX) += prcm.o prm33xx.o cm33xx.o
91obj-$(CONFIG_ARCH_OMAP4) += prcm_mpu44xx.o prminst44xx.o 104obj-$(CONFIG_ARCH_OMAP4) += $(omap-prcm-4-5-common) prm44xx.o
92obj-$(CONFIG_ARCH_OMAP4) += vc44xx_data.o vp44xx_data.o prm44xx.o 105obj-$(CONFIG_SOC_OMAP5) += $(omap-prcm-4-5-common)
93 106
94# OMAP voltage domains 107# OMAP voltage domains
95voltagedomain-common := voltage.o vc.o vp.o 108voltagedomain-common := voltage.o vc.o vp.o
@@ -99,6 +112,9 @@ obj-$(CONFIG_ARCH_OMAP3) += $(voltagedomain-common)
99obj-$(CONFIG_ARCH_OMAP3) += voltagedomains3xxx_data.o 112obj-$(CONFIG_ARCH_OMAP3) += voltagedomains3xxx_data.o
100obj-$(CONFIG_ARCH_OMAP4) += $(voltagedomain-common) 113obj-$(CONFIG_ARCH_OMAP4) += $(voltagedomain-common)
101obj-$(CONFIG_ARCH_OMAP4) += voltagedomains44xx_data.o 114obj-$(CONFIG_ARCH_OMAP4) += voltagedomains44xx_data.o
115obj-$(CONFIG_SOC_AM33XX) += $(voltagedomain-common)
116obj-$(CONFIG_SOC_AM33XX) += voltagedomains33xx_data.o
117obj-$(CONFIG_SOC_OMAP5) += $(voltagedomain-common)
102 118
103# OMAP powerdomain framework 119# OMAP powerdomain framework
104powerdomain-common += powerdomain.o powerdomain-common.o 120powerdomain-common += powerdomain.o powerdomain-common.o
@@ -113,10 +129,14 @@ obj-$(CONFIG_ARCH_OMAP3) += powerdomains2xxx_3xxx_data.o
113obj-$(CONFIG_ARCH_OMAP4) += $(powerdomain-common) 129obj-$(CONFIG_ARCH_OMAP4) += $(powerdomain-common)
114obj-$(CONFIG_ARCH_OMAP4) += powerdomain44xx.o 130obj-$(CONFIG_ARCH_OMAP4) += powerdomain44xx.o
115obj-$(CONFIG_ARCH_OMAP4) += powerdomains44xx_data.o 131obj-$(CONFIG_ARCH_OMAP4) += powerdomains44xx_data.o
132obj-$(CONFIG_SOC_AM33XX) += $(powerdomain-common)
133obj-$(CONFIG_SOC_AM33XX) += powerdomain33xx.o
134obj-$(CONFIG_SOC_AM33XX) += powerdomains33xx_data.o
135obj-$(CONFIG_SOC_OMAP5) += $(powerdomain-common)
136obj-$(CONFIG_SOC_OMAP5) += powerdomain44xx.o
116 137
117# PRCM clockdomain control 138# PRCM clockdomain control
118clockdomain-common += clockdomain.o 139clockdomain-common += clockdomain.o
119clockdomain-common += clockdomains_common_data.o
120obj-$(CONFIG_ARCH_OMAP2) += $(clockdomain-common) 140obj-$(CONFIG_ARCH_OMAP2) += $(clockdomain-common)
121obj-$(CONFIG_ARCH_OMAP2) += clockdomain2xxx_3xxx.o 141obj-$(CONFIG_ARCH_OMAP2) += clockdomain2xxx_3xxx.o
122obj-$(CONFIG_ARCH_OMAP2) += clockdomains2xxx_3xxx_data.o 142obj-$(CONFIG_ARCH_OMAP2) += clockdomains2xxx_3xxx_data.o
@@ -129,6 +149,11 @@ obj-$(CONFIG_ARCH_OMAP3) += clockdomains3xxx_data.o
129obj-$(CONFIG_ARCH_OMAP4) += $(clockdomain-common) 149obj-$(CONFIG_ARCH_OMAP4) += $(clockdomain-common)
130obj-$(CONFIG_ARCH_OMAP4) += clockdomain44xx.o 150obj-$(CONFIG_ARCH_OMAP4) += clockdomain44xx.o
131obj-$(CONFIG_ARCH_OMAP4) += clockdomains44xx_data.o 151obj-$(CONFIG_ARCH_OMAP4) += clockdomains44xx_data.o
152obj-$(CONFIG_SOC_AM33XX) += $(clockdomain-common)
153obj-$(CONFIG_SOC_AM33XX) += clockdomain33xx.o
154obj-$(CONFIG_SOC_AM33XX) += clockdomains33xx_data.o
155obj-$(CONFIG_SOC_OMAP5) += $(clockdomain-common)
156obj-$(CONFIG_SOC_OMAP5) += clockdomain44xx.o
132 157
133# Clock framework 158# Clock framework
134obj-$(CONFIG_ARCH_OMAP2) += $(clock-common) clock2xxx.o 159obj-$(CONFIG_ARCH_OMAP2) += $(clock-common) clock2xxx.o
@@ -146,6 +171,10 @@ obj-$(CONFIG_ARCH_OMAP3) += dpll3xxx.o clock3xxx_data.o
146obj-$(CONFIG_ARCH_OMAP3) += clkt_iclk.o 171obj-$(CONFIG_ARCH_OMAP3) += clkt_iclk.o
147obj-$(CONFIG_ARCH_OMAP4) += $(clock-common) clock44xx_data.o 172obj-$(CONFIG_ARCH_OMAP4) += $(clock-common) clock44xx_data.o
148obj-$(CONFIG_ARCH_OMAP4) += dpll3xxx.o dpll44xx.o 173obj-$(CONFIG_ARCH_OMAP4) += dpll3xxx.o dpll44xx.o
174obj-$(CONFIG_SOC_AM33XX) += $(clock-common) dpll3xxx.o
175obj-$(CONFIG_SOC_AM33XX) += clock33xx_data.o
176obj-$(CONFIG_SOC_OMAP5) += $(clock-common)
177obj-$(CONFIG_SOC_OMAP5) += dpll3xxx.o dpll44xx.o
149 178
150# OMAP2 clock rate set data (old "OPP" data) 179# OMAP2 clock rate set data (old "OPP" data)
151obj-$(CONFIG_SOC_OMAP2420) += opp2420_data.o 180obj-$(CONFIG_SOC_OMAP2420) += opp2420_data.o
@@ -173,6 +202,7 @@ obj-$(CONFIG_OMAP3_EMU) += emu.o
173# L3 interconnect 202# L3 interconnect
174obj-$(CONFIG_ARCH_OMAP3) += omap_l3_smx.o 203obj-$(CONFIG_ARCH_OMAP3) += omap_l3_smx.o
175obj-$(CONFIG_ARCH_OMAP4) += omap_l3_noc.o 204obj-$(CONFIG_ARCH_OMAP4) += omap_l3_noc.o
205obj-$(CONFIG_SOC_OMAP5) += omap_l3_noc.o
176 206
177obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o 207obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o
178mailbox_mach-objs := mailbox.o 208mailbox_mach-objs := mailbox.o
@@ -189,6 +219,10 @@ endif
189# OMAP2420 MSDI controller integration support ("MMC") 219# OMAP2420 MSDI controller integration support ("MMC")
190obj-$(CONFIG_SOC_OMAP2420) += msdi.o 220obj-$(CONFIG_SOC_OMAP2420) += msdi.o
191 221
222ifneq ($(CONFIG_DRM_OMAP),)
223obj-y += drm.o
224endif
225
192# Specific board support 226# Specific board support
193obj-$(CONFIG_MACH_OMAP_GENERIC) += board-generic.o 227obj-$(CONFIG_MACH_OMAP_GENERIC) += board-generic.o
194obj-$(CONFIG_MACH_OMAP_H4) += board-h4.o 228obj-$(CONFIG_MACH_OMAP_H4) += board-h4.o
@@ -244,9 +278,6 @@ obj-y += $(omap-flash-y) $(omap-flash-m)
244omap-hsmmc-$(CONFIG_MMC_OMAP_HS) := hsmmc.o 278omap-hsmmc-$(CONFIG_MMC_OMAP_HS) := hsmmc.o
245obj-y += $(omap-hsmmc-m) $(omap-hsmmc-y) 279obj-y += $(omap-hsmmc-m) $(omap-hsmmc-y)
246 280
247
248usbfs-$(CONFIG_ARCH_OMAP_OTG) := usb-fs.o
249obj-y += $(usbfs-m) $(usbfs-y)
250obj-y += usb-musb.o 281obj-y += usb-musb.o
251obj-y += omap_phy_internal.o 282obj-y += omap_phy_internal.o
252 283
diff --git a/arch/arm/mach-omap2/am35xx-emac.c b/arch/arm/mach-omap2/am35xx-emac.c
index 447682c4e11..2c90ac68668 100644
--- a/arch/arm/mach-omap2/am35xx-emac.c
+++ b/arch/arm/mach-omap2/am35xx-emac.c
@@ -15,27 +15,13 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18#include <linux/clk.h> 18#include <linux/err.h>
19#include <linux/davinci_emac.h> 19#include <linux/davinci_emac.h>
20#include <linux/platform_device.h> 20#include <asm/system.h>
21#include <plat/irqs.h> 21#include <plat/omap_device.h>
22#include <mach/am35xx.h> 22#include <mach/am35xx.h>
23
24#include "control.h" 23#include "control.h"
25 24#include "am35xx-emac.h"
26static struct mdio_platform_data am35xx_emac_mdio_pdata;
27
28static struct resource am35xx_emac_mdio_resources[] = {
29 DEFINE_RES_MEM(AM35XX_IPSS_EMAC_BASE + AM35XX_EMAC_MDIO_OFFSET, SZ_4K),
30};
31
32static struct platform_device am35xx_emac_mdio_device = {
33 .name = "davinci_mdio",
34 .id = 0,
35 .num_resources = ARRAY_SIZE(am35xx_emac_mdio_resources),
36 .resource = am35xx_emac_mdio_resources,
37 .dev.platform_data = &am35xx_emac_mdio_pdata,
38};
39 25
40static void am35xx_enable_emac_int(void) 26static void am35xx_enable_emac_int(void)
41{ 27{
@@ -69,41 +55,57 @@ static struct emac_platform_data am35xx_emac_pdata = {
69 .interrupt_disable = am35xx_disable_emac_int, 55 .interrupt_disable = am35xx_disable_emac_int,
70}; 56};
71 57
72static struct resource am35xx_emac_resources[] = { 58static struct mdio_platform_data am35xx_mdio_pdata;
73 DEFINE_RES_MEM(AM35XX_IPSS_EMAC_BASE, 0x30000),
74 DEFINE_RES_IRQ(INT_35XX_EMAC_C0_RXTHRESH_IRQ),
75 DEFINE_RES_IRQ(INT_35XX_EMAC_C0_RX_PULSE_IRQ),
76 DEFINE_RES_IRQ(INT_35XX_EMAC_C0_TX_PULSE_IRQ),
77 DEFINE_RES_IRQ(INT_35XX_EMAC_C0_MISC_PULSE_IRQ),
78};
79 59
80static struct platform_device am35xx_emac_device = { 60static int __init omap_davinci_emac_dev_init(struct omap_hwmod *oh,
81 .name = "davinci_emac", 61 void *pdata, int pdata_len)
82 .id = -1, 62{
83 .num_resources = ARRAY_SIZE(am35xx_emac_resources), 63 struct platform_device *pdev;
84 .resource = am35xx_emac_resources, 64
85 .dev = { 65 pdev = omap_device_build(oh->class->name, 0, oh, pdata, pdata_len,
86 .platform_data = &am35xx_emac_pdata, 66 NULL, 0, false);
87 }, 67 if (IS_ERR(pdev)) {
88}; 68 WARN(1, "Can't build omap_device for %s:%s.\n",
69 oh->class->name, oh->name);
70 return PTR_ERR(pdev);
71 }
72
73 return 0;
74}
89 75
90void __init am35xx_emac_init(unsigned long mdio_bus_freq, u8 rmii_en) 76void __init am35xx_emac_init(unsigned long mdio_bus_freq, u8 rmii_en)
91{ 77{
78 struct omap_hwmod *oh;
92 u32 v; 79 u32 v;
93 int err; 80 int ret;
94 81
95 am35xx_emac_pdata.rmii_en = rmii_en; 82 oh = omap_hwmod_lookup("davinci_mdio");
96 am35xx_emac_mdio_pdata.bus_freq = mdio_bus_freq; 83 if (!oh) {
97 err = platform_device_register(&am35xx_emac_device); 84 pr_err("Could not find davinci_mdio hwmod\n");
98 if (err) { 85 return;
99 pr_err("AM35x: failed registering EMAC device: %d\n", err); 86 }
87
88 am35xx_mdio_pdata.bus_freq = mdio_bus_freq;
89
90 ret = omap_davinci_emac_dev_init(oh, &am35xx_mdio_pdata,
91 sizeof(am35xx_mdio_pdata));
92 if (ret) {
93 pr_err("Could not build davinci_mdio hwmod device\n");
100 return; 94 return;
101 } 95 }
102 96
103 err = platform_device_register(&am35xx_emac_mdio_device); 97 oh = omap_hwmod_lookup("davinci_emac");
104 if (err) { 98 if (!oh) {
105 pr_err("AM35x: failed registering EMAC MDIO device: %d\n", err); 99 pr_err("Could not find davinci_emac hwmod\n");
106 platform_device_unregister(&am35xx_emac_device); 100 return;
101 }
102
103 am35xx_emac_pdata.rmii_en = rmii_en;
104
105 ret = omap_davinci_emac_dev_init(oh, &am35xx_emac_pdata,
106 sizeof(am35xx_emac_pdata));
107 if (ret) {
108 pr_err("Could not build davinci_emac hwmod device\n");
107 return; 109 return;
108 } 110 }
109 111
diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
index 99ca6bad5c3..9511584fdc4 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -218,9 +218,6 @@ static struct twl4030_gpio_platform_data sdp2430_gpio_data = {
218}; 218};
219 219
220static struct twl4030_platform_data sdp2430_twldata = { 220static struct twl4030_platform_data sdp2430_twldata = {
221 .irq_base = TWL4030_IRQ_BASE,
222 .irq_end = TWL4030_IRQ_END,
223
224 /* platform_data for children goes here */ 221 /* platform_data for children goes here */
225 .gpio = &sdp2430_gpio_data, 222 .gpio = &sdp2430_gpio_data,
226 .vmmc1 = &sdp2430_vmmc1, 223 .vmmc1 = &sdp2430_vmmc1,
@@ -254,16 +251,6 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
254 {} /* Terminator */ 251 {} /* Terminator */
255}; 252};
256 253
257static struct omap_usb_config sdp2430_usb_config __initdata = {
258 .otg = 1,
259#ifdef CONFIG_USB_GADGET_OMAP
260 .hmc_mode = 0x0,
261#elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
262 .hmc_mode = 0x1,
263#endif
264 .pins[0] = 3,
265};
266
267#ifdef CONFIG_OMAP_MUX 254#ifdef CONFIG_OMAP_MUX
268static struct omap_board_mux board_mux[] __initdata = { 255static struct omap_board_mux board_mux[] __initdata = {
269 { .reg_offset = OMAP_MUX_TERMINATOR }, 256 { .reg_offset = OMAP_MUX_TERMINATOR },
@@ -280,7 +267,6 @@ static void __init omap_2430sdp_init(void)
280 omap_serial_init(); 267 omap_serial_init();
281 omap_sdrc_init(NULL, NULL); 268 omap_sdrc_init(NULL, NULL);
282 omap_hsmmc_init(mmc); 269 omap_hsmmc_init(mmc);
283 omap2_usbfs_init(&sdp2430_usb_config);
284 270
285 omap_mux_init_signal("usb0hs_stp", OMAP_PULL_ENA | OMAP_PULL_UP); 271 omap_mux_init_signal("usb0hs_stp", OMAP_PULL_ENA | OMAP_PULL_UP);
286 usb_musb_init(NULL); 272 usb_musb_init(NULL);
diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c
index 8e17284a803..ad8a7d94afc 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -821,6 +821,9 @@ static void __init omap_4430sdp_display_init(void)
821#ifdef CONFIG_OMAP_MUX 821#ifdef CONFIG_OMAP_MUX
822static struct omap_board_mux board_mux[] __initdata = { 822static struct omap_board_mux board_mux[] __initdata = {
823 OMAP4_MUX(USBB2_ULPITLL_CLK, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), 823 OMAP4_MUX(USBB2_ULPITLL_CLK, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
824 /* NIRQ2 for twl6040 */
825 OMAP4_MUX(SYS_NIRQ2, OMAP_MUX_MODE0 |
826 OMAP_PIN_INPUT_PULLUP | OMAP_PIN_OFF_WAKEUPENABLE),
824 { .reg_offset = OMAP_MUX_TERMINATOR }, 827 { .reg_offset = OMAP_MUX_TERMINATOR },
825}; 828};
826 829
diff --git a/arch/arm/mach-omap2/board-apollon.c b/arch/arm/mach-omap2/board-apollon.c
index 502c31e123b..e5fa46bfde2 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -35,7 +35,6 @@
35#include <asm/mach/flash.h> 35#include <asm/mach/flash.h>
36 36
37#include <plat/led.h> 37#include <plat/led.h>
38#include <plat/usb.h>
39#include <plat/board.h> 38#include <plat/board.h>
40#include "common.h" 39#include "common.h"
41#include <plat/gpmc.h> 40#include <plat/gpmc.h>
@@ -253,13 +252,6 @@ out:
253 clk_put(gpmc_fck); 252 clk_put(gpmc_fck);
254} 253}
255 254
256static struct omap_usb_config apollon_usb_config __initdata = {
257 .register_dev = 1,
258 .hmc_mode = 0x14, /* 0:dev 1:host1 2:disable */
259
260 .pins[0] = 6,
261};
262
263static struct panel_generic_dpi_data apollon_panel_data = { 255static struct panel_generic_dpi_data apollon_panel_data = {
264 .name = "apollon", 256 .name = "apollon",
265}; 257};
@@ -297,15 +289,6 @@ static void __init apollon_led_init(void)
297 gpio_request_array(apollon_gpio_leds, ARRAY_SIZE(apollon_gpio_leds)); 289 gpio_request_array(apollon_gpio_leds, ARRAY_SIZE(apollon_gpio_leds));
298} 290}
299 291
300static void __init apollon_usb_init(void)
301{
302 /* USB device */
303 /* DEVICE_SUSPEND */
304 omap_mux_init_signal("mcbsp2_clkx.gpio_12", 0);
305 gpio_request_one(12, GPIOF_OUT_INIT_LOW, "USB suspend");
306 omap2_usbfs_init(&apollon_usb_config);
307}
308
309#ifdef CONFIG_OMAP_MUX 292#ifdef CONFIG_OMAP_MUX
310static struct omap_board_mux board_mux[] __initdata = { 293static struct omap_board_mux board_mux[] __initdata = {
311 { .reg_offset = OMAP_MUX_TERMINATOR }, 294 { .reg_offset = OMAP_MUX_TERMINATOR },
@@ -321,7 +304,6 @@ static void __init omap_apollon_init(void)
321 apollon_init_smc91x(); 304 apollon_init_smc91x();
322 apollon_led_init(); 305 apollon_led_init();
323 apollon_flash_init(); 306 apollon_flash_init();
324 apollon_usb_init();
325 307
326 /* REVISIT: where's the correct place */ 308 /* REVISIT: where's the correct place */
327 omap_mux_init_signal("sys_nirq", OMAP_PULL_ENA | OMAP_PULL_UP); 309 omap_mux_init_signal("sys_nirq", OMAP_PULL_ENA | OMAP_PULL_UP);
@@ -329,7 +311,7 @@ static void __init omap_apollon_init(void)
329 /* LCD PWR_EN */ 311 /* LCD PWR_EN */
330 omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP); 312 omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP);
331 313
332 /* Use Interal loop-back in MMC/SDIO Module Input Clock selection */ 314 /* Use Internal loop-back in MMC/SDIO Module Input Clock selection */
333 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0); 315 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
334 v |= (1 << 24); 316 v |= (1 << 24);
335 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0); 317 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c
index ded100c80a9..97d719047af 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -490,6 +490,71 @@ static struct twl4030_platform_data cm_t35_twldata = {
490 .power = &cm_t35_power_data, 490 .power = &cm_t35_power_data,
491}; 491};
492 492
493#if defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
494#include <media/omap3isp.h>
495#include "devices.h"
496
497static struct i2c_board_info cm_t35_isp_i2c_boardinfo[] = {
498 {
499 I2C_BOARD_INFO("mt9t001", 0x5d),
500 },
501 {
502 I2C_BOARD_INFO("tvp5150", 0x5c),
503 },
504};
505
506static struct isp_subdev_i2c_board_info cm_t35_isp_primary_subdevs[] = {
507 {
508 .board_info = &cm_t35_isp_i2c_boardinfo[0],
509 .i2c_adapter_id = 3,
510 },
511 { NULL, 0, },
512};
513
514static struct isp_subdev_i2c_board_info cm_t35_isp_secondary_subdevs[] = {
515 {
516 .board_info = &cm_t35_isp_i2c_boardinfo[1],
517 .i2c_adapter_id = 3,
518 },
519 { NULL, 0, },
520};
521
522static struct isp_v4l2_subdevs_group cm_t35_isp_subdevs[] = {
523 {
524 .subdevs = cm_t35_isp_primary_subdevs,
525 .interface = ISP_INTERFACE_PARALLEL,
526 .bus = {
527 .parallel = {
528 .clk_pol = 1,
529 },
530 },
531 },
532 {
533 .subdevs = cm_t35_isp_secondary_subdevs,
534 .interface = ISP_INTERFACE_PARALLEL,
535 .bus = {
536 .parallel = {
537 .clk_pol = 0,
538 },
539 },
540 },
541 { NULL, 0, },
542};
543
544static struct isp_platform_data cm_t35_isp_pdata = {
545 .subdevs = cm_t35_isp_subdevs,
546};
547
548static void __init cm_t35_init_camera(void)
549{
550 if (omap3_init_camera(&cm_t35_isp_pdata) < 0)
551 pr_warn("CM-T3x: Failed registering camera device!\n");
552}
553
554#else
555static inline void cm_t35_init_camera(void) {}
556#endif /* CONFIG_VIDEO_OMAP3 */
557
493static void __init cm_t35_init_i2c(void) 558static void __init cm_t35_init_i2c(void)
494{ 559{
495 omap3_pmic_get_config(&cm_t35_twldata, TWL_COMMON_PDATA_USB, 560 omap3_pmic_get_config(&cm_t35_twldata, TWL_COMMON_PDATA_USB,
@@ -497,6 +562,8 @@ static void __init cm_t35_init_i2c(void)
497 TWL_COMMON_PDATA_AUDIO); 562 TWL_COMMON_PDATA_AUDIO);
498 563
499 omap3_pmic_init("tps65930", &cm_t35_twldata); 564 omap3_pmic_init("tps65930", &cm_t35_twldata);
565
566 omap_register_i2c_bus(3, 400, NULL, 0);
500} 567}
501 568
502#ifdef CONFIG_OMAP_MUX 569#ifdef CONFIG_OMAP_MUX
@@ -574,6 +641,27 @@ static struct omap_board_mux board_mux[] __initdata = {
574 OMAP3_MUX(DSS_DATA16, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), 641 OMAP3_MUX(DSS_DATA16, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT),
575 OMAP3_MUX(DSS_DATA17, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), 642 OMAP3_MUX(DSS_DATA17, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT),
576 643
644 /* Camera */
645 OMAP3_MUX(CAM_HS, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
646 OMAP3_MUX(CAM_VS, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
647 OMAP3_MUX(CAM_XCLKA, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
648 OMAP3_MUX(CAM_PCLK, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
649 OMAP3_MUX(CAM_FLD, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
650 OMAP3_MUX(CAM_D0, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
651 OMAP3_MUX(CAM_D1, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
652 OMAP3_MUX(CAM_D2, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
653 OMAP3_MUX(CAM_D3, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
654 OMAP3_MUX(CAM_D4, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
655 OMAP3_MUX(CAM_D5, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
656 OMAP3_MUX(CAM_D6, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
657 OMAP3_MUX(CAM_D7, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
658 OMAP3_MUX(CAM_D8, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLDOWN),
659 OMAP3_MUX(CAM_D9, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLDOWN),
660 OMAP3_MUX(CAM_STROBE, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
661
662 OMAP3_MUX(CAM_D10, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLDOWN),
663 OMAP3_MUX(CAM_D11, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLDOWN),
664
577 /* display controls */ 665 /* display controls */
578 OMAP3_MUX(MCBSP1_FSR, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), 666 OMAP3_MUX(MCBSP1_FSR, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
579 OMAP3_MUX(GPMC_NCS7, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), 667 OMAP3_MUX(GPMC_NCS7, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
@@ -646,6 +734,7 @@ static void __init cm_t3x_common_init(void)
646 734
647 usb_musb_init(NULL); 735 usb_musb_init(NULL);
648 cm_t35_init_usbh(); 736 cm_t35_init_usbh();
737 cm_t35_init_camera();
649} 738}
650 739
651static void __init cm_t35_init(void) 740static void __init cm_t35_init(void)
diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c
index 20293465786..6f93a20536e 100644
--- a/arch/arm/mach-omap2/board-generic.c
+++ b/arch/arm/mach-omap2/board-generic.c
@@ -25,23 +25,12 @@
25#include "common-board-devices.h" 25#include "common-board-devices.h"
26 26
27#if !(defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)) 27#if !(defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3))
28#define omap_intc_of_init NULL 28#define intc_of_init NULL
29#endif 29#endif
30#ifndef CONFIG_ARCH_OMAP4 30#ifndef CONFIG_ARCH_OMAP4
31#define gic_of_init NULL 31#define gic_of_init NULL
32#endif 32#endif
33 33
34static struct of_device_id irq_match[] __initdata = {
35 { .compatible = "ti,omap2-intc", .data = omap_intc_of_init, },
36 { .compatible = "arm,cortex-a9-gic", .data = gic_of_init, },
37 { }
38};
39
40static void __init omap_init_irq(void)
41{
42 of_irq_init(irq_match);
43}
44
45static struct of_device_id omap_dt_match_table[] __initdata = { 34static struct of_device_id omap_dt_match_table[] __initdata = {
46 { .compatible = "simple-bus", }, 35 { .compatible = "simple-bus", },
47 { .compatible = "ti,omap-infra", }, 36 { .compatible = "ti,omap-infra", },
@@ -65,7 +54,7 @@ DT_MACHINE_START(OMAP242X_DT, "Generic OMAP2420 (Flattened Device Tree)")
65 .reserve = omap_reserve, 54 .reserve = omap_reserve,
66 .map_io = omap242x_map_io, 55 .map_io = omap242x_map_io,
67 .init_early = omap2420_init_early, 56 .init_early = omap2420_init_early,
68 .init_irq = omap_init_irq, 57 .init_irq = omap_intc_of_init,
69 .handle_irq = omap2_intc_handle_irq, 58 .handle_irq = omap2_intc_handle_irq,
70 .init_machine = omap_generic_init, 59 .init_machine = omap_generic_init,
71 .timer = &omap2_timer, 60 .timer = &omap2_timer,
@@ -84,7 +73,7 @@ DT_MACHINE_START(OMAP243X_DT, "Generic OMAP2430 (Flattened Device Tree)")
84 .reserve = omap_reserve, 73 .reserve = omap_reserve,
85 .map_io = omap243x_map_io, 74 .map_io = omap243x_map_io,
86 .init_early = omap2430_init_early, 75 .init_early = omap2430_init_early,
87 .init_irq = omap_init_irq, 76 .init_irq = omap_intc_of_init,
88 .handle_irq = omap2_intc_handle_irq, 77 .handle_irq = omap2_intc_handle_irq,
89 .init_machine = omap_generic_init, 78 .init_machine = omap_generic_init,
90 .timer = &omap2_timer, 79 .timer = &omap2_timer,
@@ -103,7 +92,7 @@ DT_MACHINE_START(OMAP3_DT, "Generic OMAP3 (Flattened Device Tree)")
103 .reserve = omap_reserve, 92 .reserve = omap_reserve,
104 .map_io = omap3_map_io, 93 .map_io = omap3_map_io,
105 .init_early = omap3430_init_early, 94 .init_early = omap3430_init_early,
106 .init_irq = omap_init_irq, 95 .init_irq = omap_intc_of_init,
107 .handle_irq = omap3_intc_handle_irq, 96 .handle_irq = omap3_intc_handle_irq,
108 .init_machine = omap_generic_init, 97 .init_machine = omap_generic_init,
109 .timer = &omap3_timer, 98 .timer = &omap3_timer,
@@ -112,6 +101,24 @@ DT_MACHINE_START(OMAP3_DT, "Generic OMAP3 (Flattened Device Tree)")
112MACHINE_END 101MACHINE_END
113#endif 102#endif
114 103
104#ifdef CONFIG_SOC_AM33XX
105static const char *am33xx_boards_compat[] __initdata = {
106 "ti,am33xx",
107 NULL,
108};
109
110DT_MACHINE_START(AM33XX_DT, "Generic AM33XX (Flattened Device Tree)")
111 .reserve = omap_reserve,
112 .map_io = am33xx_map_io,
113 .init_early = am33xx_init_early,
114 .init_irq = omap_intc_of_init,
115 .handle_irq = omap3_intc_handle_irq,
116 .init_machine = omap_generic_init,
117 .timer = &omap3_am33xx_timer,
118 .dt_compat = am33xx_boards_compat,
119MACHINE_END
120#endif
121
115#ifdef CONFIG_ARCH_OMAP4 122#ifdef CONFIG_ARCH_OMAP4
116static const char *omap4_boards_compat[] __initdata = { 123static const char *omap4_boards_compat[] __initdata = {
117 "ti,omap4", 124 "ti,omap4",
@@ -122,7 +129,7 @@ DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)")
122 .reserve = omap_reserve, 129 .reserve = omap_reserve,
123 .map_io = omap4_map_io, 130 .map_io = omap4_map_io,
124 .init_early = omap4430_init_early, 131 .init_early = omap4430_init_early,
125 .init_irq = omap_init_irq, 132 .init_irq = omap_gic_of_init,
126 .handle_irq = gic_handle_irq, 133 .handle_irq = gic_handle_irq,
127 .init_machine = omap_generic_init, 134 .init_machine = omap_generic_init,
128 .init_late = omap4430_init_late, 135 .init_late = omap4430_init_late,
@@ -131,3 +138,22 @@ DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)")
131 .restart = omap_prcm_restart, 138 .restart = omap_prcm_restart,
132MACHINE_END 139MACHINE_END
133#endif 140#endif
141
142#ifdef CONFIG_SOC_OMAP5
143static const char *omap5_boards_compat[] __initdata = {
144 "ti,omap5",
145 NULL,
146};
147
148DT_MACHINE_START(OMAP5_DT, "Generic OMAP5 (Flattened Device Tree)")
149 .reserve = omap_reserve,
150 .map_io = omap5_map_io,
151 .init_early = omap5_init_early,
152 .init_irq = omap_gic_of_init,
153 .handle_irq = gic_handle_irq,
154 .init_machine = omap_generic_init,
155 .timer = &omap5_timer,
156 .dt_compat = omap5_boards_compat,
157 .restart = omap_prcm_restart,
158MACHINE_END
159#endif
diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c
index 876becf8205..ace20482e3e 100644
--- a/arch/arm/mach-omap2/board-h4.c
+++ b/arch/arm/mach-omap2/board-h4.c
@@ -32,7 +32,6 @@
32#include <asm/mach/arch.h> 32#include <asm/mach/arch.h>
33#include <asm/mach/map.h> 33#include <asm/mach/map.h>
34 34
35#include <plat/usb.h>
36#include <plat/board.h> 35#include <plat/board.h>
37#include "common.h" 36#include "common.h"
38#include <plat/menelaus.h> 37#include <plat/menelaus.h>
@@ -329,17 +328,6 @@ static void __init h4_init_flash(void)
329 h4_flash_resource.end = base + SZ_64M - 1; 328 h4_flash_resource.end = base + SZ_64M - 1;
330} 329}
331 330
332static struct omap_usb_config h4_usb_config __initdata = {
333 /* S1.10 OFF -- usb "download port"
334 * usb0 switched to Mini-B port and isp1105 transceiver;
335 * S2.POS3 = ON, S2.POS4 = OFF ... to enable battery charging
336 */
337 .register_dev = 1,
338 .pins[0] = 3,
339/* .hmc_mode = 0x14,*/ /* 0:dev 1:host 2:disable */
340 .hmc_mode = 0x00, /* 0:dev|otg 1:disable 2:disable */
341};
342
343static struct at24_platform_data m24c01 = { 331static struct at24_platform_data m24c01 = {
344 .byte_len = SZ_1K / 8, 332 .byte_len = SZ_1K / 8,
345 .page_size = 16, 333 .page_size = 16,
@@ -381,7 +369,6 @@ static void __init omap_h4_init(void)
381 ARRAY_SIZE(h4_i2c_board_info)); 369 ARRAY_SIZE(h4_i2c_board_info));
382 370
383 platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices)); 371 platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
384 omap2_usbfs_init(&h4_usb_config);
385 omap_serial_init(); 372 omap_serial_init();
386 omap_sdrc_init(NULL, NULL); 373 omap_sdrc_init(NULL, NULL);
387 h4_init_flash(); 374 h4_init_flash();
diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
index 74915295482..28214483aab 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -554,6 +554,8 @@ static const struct usbhs_omap_board_data igep3_usbhs_bdata __initconst = {
554 554
555#ifdef CONFIG_OMAP_MUX 555#ifdef CONFIG_OMAP_MUX
556static struct omap_board_mux board_mux[] __initdata = { 556static struct omap_board_mux board_mux[] __initdata = {
557 /* SMSC9221 LAN Controller ETH IRQ (GPIO_176) */
558 OMAP3_MUX(MCSPI1_CS2, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
557 { .reg_offset = OMAP_MUX_TERMINATOR }, 559 { .reg_offset = OMAP_MUX_TERMINATOR },
558}; 560};
559#endif 561#endif
diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index 2c5d0ed7528..677357ff61a 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -468,7 +468,6 @@ static struct omap_mmc_platform_data mmc1_data = {
468 .cleanup = n8x0_mmc_cleanup, 468 .cleanup = n8x0_mmc_cleanup,
469 .shutdown = n8x0_mmc_shutdown, 469 .shutdown = n8x0_mmc_shutdown,
470 .max_freq = 24000000, 470 .max_freq = 24000000,
471 .dma_mask = 0xffffffff,
472 .slots[0] = { 471 .slots[0] = {
473 .wires = 4, 472 .wires = 4,
474 .set_power = n8x0_mmc_set_power, 473 .set_power = n8x0_mmc_set_power,
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 580fd17208d..6202fc76e49 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -433,7 +433,7 @@ static struct platform_device *omap3_beagle_devices[] __initdata = {
433 433
434static const struct usbhs_omap_board_data usbhs_bdata __initconst = { 434static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
435 435
436 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY, 436 .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
437 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY, 437 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
438 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED, 438 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
439 439
diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index 639bd07ea38..0d362e9f9cb 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -24,6 +24,10 @@
24#include <linux/leds.h> 24#include <linux/leds.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26 26
27#include <linux/mtd/mtd.h>
28#include <linux/mtd/partitions.h>
29#include <linux/mtd/nand.h>
30
27#include <linux/spi/spi.h> 31#include <linux/spi/spi.h>
28#include <linux/spi/ads7846.h> 32#include <linux/spi/ads7846.h>
29#include <linux/i2c/twl.h> 33#include <linux/i2c/twl.h>
@@ -43,6 +47,7 @@
43 47
44#include <plat/board.h> 48#include <plat/board.h>
45#include <plat/usb.h> 49#include <plat/usb.h>
50#include <plat/nand.h>
46#include "common.h" 51#include "common.h"
47#include <plat/mcspi.h> 52#include <plat/mcspi.h>
48#include <video/omapdss.h> 53#include <video/omapdss.h>
@@ -355,6 +360,19 @@ static int omap3evm_twl_gpio_setup(struct device *dev,
355 360
356 platform_device_register(&leds_gpio); 361 platform_device_register(&leds_gpio);
357 362
363 /* Enable VBUS switch by setting TWL4030.GPIO2DIR as output
364 * for starting USB tranceiver
365 */
366#ifdef CONFIG_TWL4030_CORE
367 if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2) {
368 u8 val;
369
370 twl_i2c_read_u8(TWL4030_MODULE_GPIO, &val, REG_GPIODATADIR1);
371 val |= 0x04; /* TWL4030.GPIO2DIR BIT at GPIODATADIR1(0x9B) */
372 twl_i2c_write_u8(TWL4030_MODULE_GPIO, val, REG_GPIODATADIR1);
373 }
374#endif
375
358 return 0; 376 return 0;
359} 377}
360 378
@@ -461,6 +479,28 @@ struct wl12xx_platform_data omap3evm_wlan_data __initdata = {
461}; 479};
462#endif 480#endif
463 481
482/* VAUX2 for USB */
483static struct regulator_consumer_supply omap3evm_vaux2_supplies[] = {
484 REGULATOR_SUPPLY("VDD_CSIPHY1", "omap3isp"), /* OMAP ISP */
485 REGULATOR_SUPPLY("VDD_CSIPHY2", "omap3isp"), /* OMAP ISP */
486 REGULATOR_SUPPLY("hsusb1", "ehci-omap.0"),
487 REGULATOR_SUPPLY("vaux2", NULL),
488};
489
490static struct regulator_init_data omap3evm_vaux2 = {
491 .constraints = {
492 .min_uV = 2800000,
493 .max_uV = 2800000,
494 .apply_uV = true,
495 .valid_modes_mask = REGULATOR_MODE_NORMAL
496 | REGULATOR_MODE_STANDBY,
497 .valid_ops_mask = REGULATOR_CHANGE_MODE
498 | REGULATOR_CHANGE_STATUS,
499 },
500 .num_consumer_supplies = ARRAY_SIZE(omap3evm_vaux2_supplies),
501 .consumer_supplies = omap3evm_vaux2_supplies,
502};
503
464static struct twl4030_platform_data omap3evm_twldata = { 504static struct twl4030_platform_data omap3evm_twldata = {
465 /* platform_data for children goes here */ 505 /* platform_data for children goes here */
466 .keypad = &omap3evm_kp_data, 506 .keypad = &omap3evm_kp_data,
@@ -607,6 +647,37 @@ static struct regulator_consumer_supply dummy_supplies[] = {
607 REGULATOR_SUPPLY("vdd33a", "smsc911x.0"), 647 REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
608}; 648};
609 649
650static struct mtd_partition omap3evm_nand_partitions[] = {
651 /* All the partition sizes are listed in terms of NAND block size */
652 {
653 .name = "X-Loader",
654 .offset = 0,
655 .size = 4*(SZ_128K),
656 .mask_flags = MTD_WRITEABLE
657 },
658 {
659 .name = "U-Boot",
660 .offset = MTDPART_OFS_APPEND,
661 .size = 14*(SZ_128K),
662 .mask_flags = MTD_WRITEABLE
663 },
664 {
665 .name = "U-Boot Env",
666 .offset = MTDPART_OFS_APPEND,
667 .size = 2*(SZ_128K)
668 },
669 {
670 .name = "Kernel",
671 .offset = MTDPART_OFS_APPEND,
672 .size = 40*(SZ_128K)
673 },
674 {
675 .name = "File system",
676 .size = MTDPART_SIZ_FULL,
677 .offset = MTDPART_OFS_APPEND,
678 },
679};
680
610static void __init omap3_evm_init(void) 681static void __init omap3_evm_init(void)
611{ 682{
612 struct omap_board_mux *obm; 683 struct omap_board_mux *obm;
@@ -623,6 +694,9 @@ static void __init omap3_evm_init(void)
623 omap_mux_init_gpio(63, OMAP_PIN_INPUT); 694 omap_mux_init_gpio(63, OMAP_PIN_INPUT);
624 omap_hsmmc_init(mmc); 695 omap_hsmmc_init(mmc);
625 696
697 if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2)
698 omap3evm_twldata.vaux2 = &omap3evm_vaux2;
699
626 omap3_evm_i2c_init(); 700 omap3_evm_i2c_init();
627 701
628 omap_display_init(&omap3_evm_dss_data); 702 omap_display_init(&omap3_evm_dss_data);
@@ -656,6 +730,9 @@ static void __init omap3_evm_init(void)
656 } 730 }
657 usb_musb_init(&musb_board_data); 731 usb_musb_init(&musb_board_data);
658 usbhs_init(&usbhs_bdata); 732 usbhs_init(&usbhs_bdata);
733 omap_nand_flash_init(NAND_BUSWIDTH_16, omap3evm_nand_partitions,
734 ARRAY_SIZE(omap3evm_nand_partitions));
735
659 omap_ads7846_init(1, OMAP3_EVM_TS_GPIO, 310, NULL); 736 omap_ads7846_init(1, OMAP3_EVM_TS_GPIO, 310, NULL);
660 omap3evm_init_smsc911x(); 737 omap3evm_init_smsc911x();
661 omap3_evm_display_init(); 738 omap3_evm_display_init();
diff --git a/arch/arm/mach-omap2/board-omap3logic.c b/arch/arm/mach-omap2/board-omap3logic.c
index 932e1778aff..fca93d1afd4 100644
--- a/arch/arm/mach-omap2/board-omap3logic.c
+++ b/arch/arm/mach-omap2/board-omap3logic.c
@@ -93,9 +93,6 @@ static struct twl4030_usb_data omap3logic_usb_data = {
93 93
94 94
95static struct twl4030_platform_data omap3logic_twldata = { 95static struct twl4030_platform_data omap3logic_twldata = {
96 .irq_base = TWL4030_IRQ_BASE,
97 .irq_end = TWL4030_IRQ_END,
98
99 /* platform_data for children goes here */ 96 /* platform_data for children goes here */
100 .gpio = &omap3logic_gpio_data, 97 .gpio = &omap3logic_gpio_data,
101 .vmmc1 = &omap3logic_vmmc1, 98 .vmmc1 = &omap3logic_vmmc1,
diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index 982fb2622ab..70f6d1d2546 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -106,7 +106,7 @@ static struct platform_device leds_gpio = {
106static struct omap_abe_twl6040_data panda_abe_audio_data = { 106static struct omap_abe_twl6040_data panda_abe_audio_data = {
107 /* Audio out */ 107 /* Audio out */
108 .has_hs = ABE_TWL6040_LEFT | ABE_TWL6040_RIGHT, 108 .has_hs = ABE_TWL6040_LEFT | ABE_TWL6040_RIGHT,
109 /* HandsFree through expasion connector */ 109 /* HandsFree through expansion connector */
110 .has_hf = ABE_TWL6040_LEFT | ABE_TWL6040_RIGHT, 110 .has_hf = ABE_TWL6040_LEFT | ABE_TWL6040_RIGHT,
111 /* PandaBoard: FM TX, PandaBoardES: can be connected to audio out */ 111 /* PandaBoard: FM TX, PandaBoardES: can be connected to audio out */
112 .has_aux = ABE_TWL6040_LEFT | ABE_TWL6040_RIGHT, 112 .has_aux = ABE_TWL6040_LEFT | ABE_TWL6040_RIGHT,
@@ -379,6 +379,9 @@ static struct omap_board_mux board_mux[] __initdata = {
379 OMAP4_MUX(DPM_EMU18, OMAP_PIN_OUTPUT | OMAP_MUX_MODE5), 379 OMAP4_MUX(DPM_EMU18, OMAP_PIN_OUTPUT | OMAP_MUX_MODE5),
380 /* dispc2_data0 */ 380 /* dispc2_data0 */
381 OMAP4_MUX(DPM_EMU19, OMAP_PIN_OUTPUT | OMAP_MUX_MODE5), 381 OMAP4_MUX(DPM_EMU19, OMAP_PIN_OUTPUT | OMAP_MUX_MODE5),
382 /* NIRQ2 for twl6040 */
383 OMAP4_MUX(SYS_NIRQ2, OMAP_MUX_MODE0 |
384 OMAP_PIN_INPUT_PULLUP | OMAP_PIN_OFF_WAKEUPENABLE),
382 { .reg_offset = OMAP_MUX_TERMINATOR }, 385 { .reg_offset = OMAP_MUX_TERMINATOR },
383}; 386};
384 387
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index 5c4e6654216..ea3f565ba1a 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -398,24 +398,6 @@ int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent)
398 return omap2_clksel_set_parent(clk, new_parent); 398 return omap2_clksel_set_parent(clk, new_parent);
399} 399}
400 400
401/* OMAP3/4 non-CORE DPLL clkops */
402
403#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
404
405const struct clkops clkops_omap3_noncore_dpll_ops = {
406 .enable = omap3_noncore_dpll_enable,
407 .disable = omap3_noncore_dpll_disable,
408 .allow_idle = omap3_dpll_allow_idle,
409 .deny_idle = omap3_dpll_deny_idle,
410};
411
412const struct clkops clkops_omap3_core_dpll_ops = {
413 .allow_idle = omap3_dpll_allow_idle,
414 .deny_idle = omap3_dpll_deny_idle,
415};
416
417#endif
418
419/* 401/*
420 * OMAP2+ clock reset and init functions 402 * OMAP2+ clock reset and init functions
421 */ 403 */
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index a1bb23a2335..35ec5f3d9a7 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -155,4 +155,18 @@ extern const struct clkops clkops_omap3_noncore_dpll_ops;
155extern const struct clkops clkops_omap3_core_dpll_ops; 155extern const struct clkops clkops_omap3_core_dpll_ops;
156extern const struct clkops clkops_omap4_dpllmx_ops; 156extern const struct clkops clkops_omap4_dpllmx_ops;
157 157
158/* clksel_rate blocks shared between OMAP44xx and AM33xx */
159extern const struct clksel_rate div_1_0_rates[];
160extern const struct clksel_rate div_1_1_rates[];
161extern const struct clksel_rate div_1_2_rates[];
162extern const struct clksel_rate div_1_3_rates[];
163extern const struct clksel_rate div_1_4_rates[];
164extern const struct clksel_rate div31_1to31_rates[];
165
166/* clocks shared between various OMAP SoCs */
167extern struct clk virt_19200000_ck;
168extern struct clk virt_26000000_ck;
169
170extern int am33xx_clk_init(void);
171
158#endif 172#endif
diff --git a/arch/arm/mach-omap2/clock2420_data.c b/arch/arm/mach-omap2/clock2420_data.c
index bace9308a4d..002745181ad 100644
--- a/arch/arm/mach-omap2/clock2420_data.c
+++ b/arch/arm/mach-omap2/clock2420_data.c
@@ -1774,8 +1774,6 @@ static struct omap_clk omap2420_clks[] = {
1774 CLK(NULL, "osc_ck", &osc_ck, CK_242X), 1774 CLK(NULL, "osc_ck", &osc_ck, CK_242X),
1775 CLK(NULL, "sys_ck", &sys_ck, CK_242X), 1775 CLK(NULL, "sys_ck", &sys_ck, CK_242X),
1776 CLK(NULL, "alt_ck", &alt_ck, CK_242X), 1776 CLK(NULL, "alt_ck", &alt_ck, CK_242X),
1777 CLK("omap-mcbsp.1", "pad_fck", &mcbsp_clks, CK_242X),
1778 CLK("omap-mcbsp.2", "pad_fck", &mcbsp_clks, CK_242X),
1779 CLK(NULL, "mcbsp_clks", &mcbsp_clks, CK_242X), 1777 CLK(NULL, "mcbsp_clks", &mcbsp_clks, CK_242X),
1780 /* internal analog sources */ 1778 /* internal analog sources */
1781 CLK(NULL, "dpll_ck", &dpll_ck, CK_242X), 1779 CLK(NULL, "dpll_ck", &dpll_ck, CK_242X),
@@ -1784,8 +1782,6 @@ static struct omap_clk omap2420_clks[] = {
1784 /* internal prcm root sources */ 1782 /* internal prcm root sources */
1785 CLK(NULL, "func_54m_ck", &func_54m_ck, CK_242X), 1783 CLK(NULL, "func_54m_ck", &func_54m_ck, CK_242X),
1786 CLK(NULL, "core_ck", &core_ck, CK_242X), 1784 CLK(NULL, "core_ck", &core_ck, CK_242X),
1787 CLK("omap-mcbsp.1", "prcm_fck", &func_96m_ck, CK_242X),
1788 CLK("omap-mcbsp.2", "prcm_fck", &func_96m_ck, CK_242X),
1789 CLK(NULL, "func_96m_ck", &func_96m_ck, CK_242X), 1785 CLK(NULL, "func_96m_ck", &func_96m_ck, CK_242X),
1790 CLK(NULL, "func_48m_ck", &func_48m_ck, CK_242X), 1786 CLK(NULL, "func_48m_ck", &func_48m_ck, CK_242X),
1791 CLK(NULL, "func_12m_ck", &func_12m_ck, CK_242X), 1787 CLK(NULL, "func_12m_ck", &func_12m_ck, CK_242X),
@@ -1901,42 +1897,9 @@ static struct omap_clk omap2420_clks[] = {
1901 CLK(NULL, "pka_ick", &pka_ick, CK_242X), 1897 CLK(NULL, "pka_ick", &pka_ick, CK_242X),
1902 CLK(NULL, "usb_fck", &usb_fck, CK_242X), 1898 CLK(NULL, "usb_fck", &usb_fck, CK_242X),
1903 CLK("musb-hdrc", "fck", &osc_ck, CK_242X), 1899 CLK("musb-hdrc", "fck", &osc_ck, CK_242X),
1904 CLK("omap_timer.1", "32k_ck", &func_32k_ck, CK_243X), 1900 CLK(NULL, "timer_32k_ck", &func_32k_ck, CK_243X),
1905 CLK("omap_timer.2", "32k_ck", &func_32k_ck, CK_243X), 1901 CLK(NULL, "timer_sys_ck", &sys_ck, CK_243X),
1906 CLK("omap_timer.3", "32k_ck", &func_32k_ck, CK_243X), 1902 CLK(NULL, "timer_ext_ck", &alt_ck, CK_243X),
1907 CLK("omap_timer.4", "32k_ck", &func_32k_ck, CK_243X),
1908 CLK("omap_timer.5", "32k_ck", &func_32k_ck, CK_243X),
1909 CLK("omap_timer.6", "32k_ck", &func_32k_ck, CK_243X),
1910 CLK("omap_timer.7", "32k_ck", &func_32k_ck, CK_243X),
1911 CLK("omap_timer.8", "32k_ck", &func_32k_ck, CK_243X),
1912 CLK("omap_timer.9", "32k_ck", &func_32k_ck, CK_243X),
1913 CLK("omap_timer.10", "32k_ck", &func_32k_ck, CK_243X),
1914 CLK("omap_timer.11", "32k_ck", &func_32k_ck, CK_243X),
1915 CLK("omap_timer.12", "32k_ck", &func_32k_ck, CK_243X),
1916 CLK("omap_timer.1", "sys_ck", &sys_ck, CK_243X),
1917 CLK("omap_timer.2", "sys_ck", &sys_ck, CK_243X),
1918 CLK("omap_timer.3", "sys_ck", &sys_ck, CK_243X),
1919 CLK("omap_timer.4", "sys_ck", &sys_ck, CK_243X),
1920 CLK("omap_timer.5", "sys_ck", &sys_ck, CK_243X),
1921 CLK("omap_timer.6", "sys_ck", &sys_ck, CK_243X),
1922 CLK("omap_timer.7", "sys_ck", &sys_ck, CK_243X),
1923 CLK("omap_timer.8", "sys_ck", &sys_ck, CK_243X),
1924 CLK("omap_timer.9", "sys_ck", &sys_ck, CK_243X),
1925 CLK("omap_timer.10", "sys_ck", &sys_ck, CK_243X),
1926 CLK("omap_timer.11", "sys_ck", &sys_ck, CK_243X),
1927 CLK("omap_timer.12", "sys_ck", &sys_ck, CK_243X),
1928 CLK("omap_timer.1", "alt_ck", &alt_ck, CK_243X),
1929 CLK("omap_timer.2", "alt_ck", &alt_ck, CK_243X),
1930 CLK("omap_timer.3", "alt_ck", &alt_ck, CK_243X),
1931 CLK("omap_timer.4", "alt_ck", &alt_ck, CK_243X),
1932 CLK("omap_timer.5", "alt_ck", &alt_ck, CK_243X),
1933 CLK("omap_timer.6", "alt_ck", &alt_ck, CK_243X),
1934 CLK("omap_timer.7", "alt_ck", &alt_ck, CK_243X),
1935 CLK("omap_timer.8", "alt_ck", &alt_ck, CK_243X),
1936 CLK("omap_timer.9", "alt_ck", &alt_ck, CK_243X),
1937 CLK("omap_timer.10", "alt_ck", &alt_ck, CK_243X),
1938 CLK("omap_timer.11", "alt_ck", &alt_ck, CK_243X),
1939 CLK("omap_timer.12", "alt_ck", &alt_ck, CK_243X),
1940}; 1903};
1941 1904
1942/* 1905/*
diff --git a/arch/arm/mach-omap2/clock2430_data.c b/arch/arm/mach-omap2/clock2430_data.c
index 3b4d09a5039..cacabb070e2 100644
--- a/arch/arm/mach-omap2/clock2430_data.c
+++ b/arch/arm/mach-omap2/clock2430_data.c
@@ -1858,11 +1858,6 @@ static struct omap_clk omap2430_clks[] = {
1858 CLK(NULL, "osc_ck", &osc_ck, CK_243X), 1858 CLK(NULL, "osc_ck", &osc_ck, CK_243X),
1859 CLK(NULL, "sys_ck", &sys_ck, CK_243X), 1859 CLK(NULL, "sys_ck", &sys_ck, CK_243X),
1860 CLK(NULL, "alt_ck", &alt_ck, CK_243X), 1860 CLK(NULL, "alt_ck", &alt_ck, CK_243X),
1861 CLK("omap-mcbsp.1", "pad_fck", &mcbsp_clks, CK_243X),
1862 CLK("omap-mcbsp.2", "pad_fck", &mcbsp_clks, CK_243X),
1863 CLK("omap-mcbsp.3", "pad_fck", &mcbsp_clks, CK_243X),
1864 CLK("omap-mcbsp.4", "pad_fck", &mcbsp_clks, CK_243X),
1865 CLK("omap-mcbsp.5", "pad_fck", &mcbsp_clks, CK_243X),
1866 CLK(NULL, "mcbsp_clks", &mcbsp_clks, CK_243X), 1861 CLK(NULL, "mcbsp_clks", &mcbsp_clks, CK_243X),
1867 /* internal analog sources */ 1862 /* internal analog sources */
1868 CLK(NULL, "dpll_ck", &dpll_ck, CK_243X), 1863 CLK(NULL, "dpll_ck", &dpll_ck, CK_243X),
@@ -1871,11 +1866,6 @@ static struct omap_clk omap2430_clks[] = {
1871 /* internal prcm root sources */ 1866 /* internal prcm root sources */
1872 CLK(NULL, "func_54m_ck", &func_54m_ck, CK_243X), 1867 CLK(NULL, "func_54m_ck", &func_54m_ck, CK_243X),
1873 CLK(NULL, "core_ck", &core_ck, CK_243X), 1868 CLK(NULL, "core_ck", &core_ck, CK_243X),
1874 CLK("omap-mcbsp.1", "prcm_fck", &func_96m_ck, CK_243X),
1875 CLK("omap-mcbsp.2", "prcm_fck", &func_96m_ck, CK_243X),
1876 CLK("omap-mcbsp.3", "prcm_fck", &func_96m_ck, CK_243X),
1877 CLK("omap-mcbsp.4", "prcm_fck", &func_96m_ck, CK_243X),
1878 CLK("omap-mcbsp.5", "prcm_fck", &func_96m_ck, CK_243X),
1879 CLK(NULL, "func_96m_ck", &func_96m_ck, CK_243X), 1869 CLK(NULL, "func_96m_ck", &func_96m_ck, CK_243X),
1880 CLK(NULL, "func_48m_ck", &func_48m_ck, CK_243X), 1870 CLK(NULL, "func_48m_ck", &func_48m_ck, CK_243X),
1881 CLK(NULL, "func_12m_ck", &func_12m_ck, CK_243X), 1871 CLK(NULL, "func_12m_ck", &func_12m_ck, CK_243X),
@@ -2000,42 +1990,9 @@ static struct omap_clk omap2430_clks[] = {
2000 CLK(NULL, "mdm_intc_ick", &mdm_intc_ick, CK_243X), 1990 CLK(NULL, "mdm_intc_ick", &mdm_intc_ick, CK_243X),
2001 CLK("omap_hsmmc.0", "mmchsdb_fck", &mmchsdb1_fck, CK_243X), 1991 CLK("omap_hsmmc.0", "mmchsdb_fck", &mmchsdb1_fck, CK_243X),
2002 CLK("omap_hsmmc.1", "mmchsdb_fck", &mmchsdb2_fck, CK_243X), 1992 CLK("omap_hsmmc.1", "mmchsdb_fck", &mmchsdb2_fck, CK_243X),
2003 CLK("omap_timer.1", "32k_ck", &func_32k_ck, CK_243X), 1993 CLK(NULL, "timer_32k_ck", &func_32k_ck, CK_243X),
2004 CLK("omap_timer.2", "32k_ck", &func_32k_ck, CK_243X), 1994 CLK(NULL, "timer_sys_ck", &sys_ck, CK_243X),
2005 CLK("omap_timer.3", "32k_ck", &func_32k_ck, CK_243X), 1995 CLK(NULL, "timer_ext_ck", &alt_ck, CK_243X),
2006 CLK("omap_timer.4", "32k_ck", &func_32k_ck, CK_243X),
2007 CLK("omap_timer.5", "32k_ck", &func_32k_ck, CK_243X),
2008 CLK("omap_timer.6", "32k_ck", &func_32k_ck, CK_243X),
2009 CLK("omap_timer.7", "32k_ck", &func_32k_ck, CK_243X),
2010 CLK("omap_timer.8", "32k_ck", &func_32k_ck, CK_243X),
2011 CLK("omap_timer.9", "32k_ck", &func_32k_ck, CK_243X),
2012 CLK("omap_timer.10", "32k_ck", &func_32k_ck, CK_243X),
2013 CLK("omap_timer.11", "32k_ck", &func_32k_ck, CK_243X),
2014 CLK("omap_timer.12", "32k_ck", &func_32k_ck, CK_243X),
2015 CLK("omap_timer.1", "sys_ck", &sys_ck, CK_243X),
2016 CLK("omap_timer.2", "sys_ck", &sys_ck, CK_243X),
2017 CLK("omap_timer.3", "sys_ck", &sys_ck, CK_243X),
2018 CLK("omap_timer.4", "sys_ck", &sys_ck, CK_243X),
2019 CLK("omap_timer.5", "sys_ck", &sys_ck, CK_243X),
2020 CLK("omap_timer.6", "sys_ck", &sys_ck, CK_243X),
2021 CLK("omap_timer.7", "sys_ck", &sys_ck, CK_243X),
2022 CLK("omap_timer.8", "sys_ck", &sys_ck, CK_243X),
2023 CLK("omap_timer.9", "sys_ck", &sys_ck, CK_243X),
2024 CLK("omap_timer.10", "sys_ck", &sys_ck, CK_243X),
2025 CLK("omap_timer.11", "sys_ck", &sys_ck, CK_243X),
2026 CLK("omap_timer.12", "sys_ck", &sys_ck, CK_243X),
2027 CLK("omap_timer.1", "alt_ck", &alt_ck, CK_243X),
2028 CLK("omap_timer.2", "alt_ck", &alt_ck, CK_243X),
2029 CLK("omap_timer.3", "alt_ck", &alt_ck, CK_243X),
2030 CLK("omap_timer.4", "alt_ck", &alt_ck, CK_243X),
2031 CLK("omap_timer.5", "alt_ck", &alt_ck, CK_243X),
2032 CLK("omap_timer.6", "alt_ck", &alt_ck, CK_243X),
2033 CLK("omap_timer.7", "alt_ck", &alt_ck, CK_243X),
2034 CLK("omap_timer.8", "alt_ck", &alt_ck, CK_243X),
2035 CLK("omap_timer.9", "alt_ck", &alt_ck, CK_243X),
2036 CLK("omap_timer.10", "alt_ck", &alt_ck, CK_243X),
2037 CLK("omap_timer.11", "alt_ck", &alt_ck, CK_243X),
2038 CLK("omap_timer.12", "alt_ck", &alt_ck, CK_243X),
2039}; 1996};
2040 1997
2041/* 1998/*
diff --git a/arch/arm/mach-omap2/clock33xx_data.c b/arch/arm/mach-omap2/clock33xx_data.c
new file mode 100644
index 00000000000..25bbcc7ca4d
--- /dev/null
+++ b/arch/arm/mach-omap2/clock33xx_data.c
@@ -0,0 +1,1105 @@
1/*
2 * AM33XX Clock data
3 *
4 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
5 * Vaibhav Hiremath <hvaibhav@ti.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation version 2.
10 *
11 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
12 * kind, whether express or implied; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <linux/kernel.h>
18#include <linux/list.h>
19#include <linux/clk.h>
20#include <plat/clkdev_omap.h>
21#include <plat/am33xx.h>
22
23#include "iomap.h"
24#include "control.h"
25#include "clock.h"
26#include "cm.h"
27#include "cm33xx.h"
28#include "cm-regbits-33xx.h"
29#include "prm.h"
30
31/* Maximum DPLL multiplier, divider values for AM33XX */
32#define AM33XX_MAX_DPLL_MULT 2047
33#define AM33XX_MAX_DPLL_DIV 128
34
35/* Modulemode control */
36#define AM33XX_MODULEMODE_HWCTRL 0
37#define AM33XX_MODULEMODE_SWCTRL 1
38
39/* TRM ERRATA: Timer 3 & 6 default parent (TCLKIN) may not be always
40 * physically present, in such a case HWMOD enabling of
41 * clock would be failure with default parent. And timer
42 * probe thinks clock is already enabled, this leads to
43 * crash upon accessing timer 3 & 6 registers in probe.
44 * Fix by setting parent of both these timers to master
45 * oscillator clock.
46 */
47static inline void am33xx_init_timer_parent(struct clk *clk)
48{
49 omap2_clksel_set_parent(clk, clk->parent);
50}
51
52/* Root clocks */
53
54/* RTC 32k */
55static struct clk clk_32768_ck = {
56 .name = "clk_32768_ck",
57 .clkdm_name = "l4_rtc_clkdm",
58 .rate = 32768,
59 .ops = &clkops_null,
60};
61
62/* On-Chip 32KHz RC OSC */
63static struct clk clk_rc32k_ck = {
64 .name = "clk_rc32k_ck",
65 .rate = 32000,
66 .ops = &clkops_null,
67};
68
69/* Crystal input clks */
70static struct clk virt_24000000_ck = {
71 .name = "virt_24000000_ck",
72 .rate = 24000000,
73 .ops = &clkops_null,
74};
75
76static struct clk virt_25000000_ck = {
77 .name = "virt_25000000_ck",
78 .rate = 25000000,
79 .ops = &clkops_null,
80};
81
82/* Oscillator clock */
83/* 19.2, 24, 25 or 26 MHz */
84static const struct clksel sys_clkin_sel[] = {
85 { .parent = &virt_19200000_ck, .rates = div_1_0_rates },
86 { .parent = &virt_24000000_ck, .rates = div_1_1_rates },
87 { .parent = &virt_25000000_ck, .rates = div_1_2_rates },
88 { .parent = &virt_26000000_ck, .rates = div_1_3_rates },
89 { .parent = NULL },
90};
91
92/* External clock - 12 MHz */
93static struct clk tclkin_ck = {
94 .name = "tclkin_ck",
95 .rate = 12000000,
96 .ops = &clkops_null,
97};
98
99/*
100 * sys_clk in: input to the dpll and also used as funtional clock for,
101 * adc_tsc, smartreflex0-1, timer1-7, mcasp0-1, dcan0-1, cefuse
102 *
103 */
104static struct clk sys_clkin_ck = {
105 .name = "sys_clkin_ck",
106 .parent = &virt_24000000_ck,
107 .init = &omap2_init_clksel_parent,
108 .clksel_reg = AM33XX_CTRL_REGADDR(AM33XX_CONTROL_STATUS),
109 .clksel_mask = AM33XX_CONTROL_STATUS_SYSBOOT1_MASK,
110 .clksel = sys_clkin_sel,
111 .ops = &clkops_null,
112 .recalc = &omap2_clksel_recalc,
113};
114
115/* DPLL_CORE */
116static struct dpll_data dpll_core_dd = {
117 .mult_div1_reg = AM33XX_CM_CLKSEL_DPLL_CORE,
118 .clk_bypass = &sys_clkin_ck,
119 .clk_ref = &sys_clkin_ck,
120 .control_reg = AM33XX_CM_CLKMODE_DPLL_CORE,
121 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
122 .idlest_reg = AM33XX_CM_IDLEST_DPLL_CORE,
123 .mult_mask = AM33XX_DPLL_MULT_MASK,
124 .div1_mask = AM33XX_DPLL_DIV_MASK,
125 .enable_mask = AM33XX_DPLL_EN_MASK,
126 .idlest_mask = AM33XX_ST_DPLL_CLK_MASK,
127 .max_multiplier = AM33XX_MAX_DPLL_MULT,
128 .max_divider = AM33XX_MAX_DPLL_DIV,
129 .min_divider = 1,
130};
131
132/* CLKDCOLDO output */
133static struct clk dpll_core_ck = {
134 .name = "dpll_core_ck",
135 .parent = &sys_clkin_ck,
136 .dpll_data = &dpll_core_dd,
137 .init = &omap2_init_dpll_parent,
138 .ops = &clkops_omap3_core_dpll_ops,
139 .recalc = &omap3_dpll_recalc,
140};
141
142static struct clk dpll_core_x2_ck = {
143 .name = "dpll_core_x2_ck",
144 .parent = &dpll_core_ck,
145 .flags = CLOCK_CLKOUTX2,
146 .ops = &clkops_null,
147 .recalc = &omap3_clkoutx2_recalc,
148};
149
150
151static const struct clksel dpll_core_m4_div[] = {
152 { .parent = &dpll_core_x2_ck, .rates = div31_1to31_rates },
153 { .parent = NULL },
154};
155
156static struct clk dpll_core_m4_ck = {
157 .name = "dpll_core_m4_ck",
158 .parent = &dpll_core_x2_ck,
159 .init = &omap2_init_clksel_parent,
160 .clksel = dpll_core_m4_div,
161 .clksel_reg = AM33XX_CM_DIV_M4_DPLL_CORE,
162 .clksel_mask = AM33XX_HSDIVIDER_CLKOUT1_DIV_MASK,
163 .ops = &clkops_null,
164 .recalc = &omap2_clksel_recalc,
165 .round_rate = &omap2_clksel_round_rate,
166 .set_rate = &omap2_clksel_set_rate,
167};
168
169static const struct clksel dpll_core_m5_div[] = {
170 { .parent = &dpll_core_x2_ck, .rates = div31_1to31_rates },
171 { .parent = NULL },
172};
173
174static struct clk dpll_core_m5_ck = {
175 .name = "dpll_core_m5_ck",
176 .parent = &dpll_core_x2_ck,
177 .init = &omap2_init_clksel_parent,
178 .clksel = dpll_core_m5_div,
179 .clksel_reg = AM33XX_CM_DIV_M5_DPLL_CORE,
180 .clksel_mask = AM33XX_HSDIVIDER_CLKOUT2_DIV_MASK,
181 .ops = &clkops_null,
182 .recalc = &omap2_clksel_recalc,
183 .round_rate = &omap2_clksel_round_rate,
184 .set_rate = &omap2_clksel_set_rate,
185};
186
187static const struct clksel dpll_core_m6_div[] = {
188 { .parent = &dpll_core_x2_ck, .rates = div31_1to31_rates },
189 { .parent = NULL },
190};
191
192static struct clk dpll_core_m6_ck = {
193 .name = "dpll_core_m6_ck",
194 .parent = &dpll_core_x2_ck,
195 .init = &omap2_init_clksel_parent,
196 .clksel = dpll_core_m6_div,
197 .clksel_reg = AM33XX_CM_DIV_M6_DPLL_CORE,
198 .clksel_mask = AM33XX_HSDIVIDER_CLKOUT3_DIV_MASK,
199 .ops = &clkops_null,
200 .recalc = &omap2_clksel_recalc,
201 .round_rate = &omap2_clksel_round_rate,
202 .set_rate = &omap2_clksel_set_rate,
203};
204
205/* DPLL_MPU */
206static struct dpll_data dpll_mpu_dd = {
207 .mult_div1_reg = AM33XX_CM_CLKSEL_DPLL_MPU,
208 .clk_bypass = &sys_clkin_ck,
209 .clk_ref = &sys_clkin_ck,
210 .control_reg = AM33XX_CM_CLKMODE_DPLL_MPU,
211 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
212 .idlest_reg = AM33XX_CM_IDLEST_DPLL_MPU,
213 .mult_mask = AM33XX_DPLL_MULT_MASK,
214 .div1_mask = AM33XX_DPLL_DIV_MASK,
215 .enable_mask = AM33XX_DPLL_EN_MASK,
216 .idlest_mask = AM33XX_ST_DPLL_CLK_MASK,
217 .max_multiplier = AM33XX_MAX_DPLL_MULT,
218 .max_divider = AM33XX_MAX_DPLL_DIV,
219 .min_divider = 1,
220};
221
222/* CLKOUT: fdpll/M2 */
223static struct clk dpll_mpu_ck = {
224 .name = "dpll_mpu_ck",
225 .parent = &sys_clkin_ck,
226 .dpll_data = &dpll_mpu_dd,
227 .init = &omap2_init_dpll_parent,
228 .ops = &clkops_omap3_noncore_dpll_ops,
229 .recalc = &omap3_dpll_recalc,
230 .round_rate = &omap2_dpll_round_rate,
231 .set_rate = &omap3_noncore_dpll_set_rate,
232};
233
234/*
235 * TODO: Add clksel here (sys_clkin, CORE_CLKOUTM6, PER_CLKOUTM2
236 * and ALT_CLK1/2)
237 */
238static const struct clksel dpll_mpu_m2_div[] = {
239 { .parent = &dpll_mpu_ck, .rates = div31_1to31_rates },
240 { .parent = NULL },
241};
242
243static struct clk dpll_mpu_m2_ck = {
244 .name = "dpll_mpu_m2_ck",
245 .clkdm_name = "mpu_clkdm",
246 .parent = &dpll_mpu_ck,
247 .clksel = dpll_mpu_m2_div,
248 .clksel_reg = AM33XX_CM_DIV_M2_DPLL_MPU,
249 .clksel_mask = AM33XX_DPLL_CLKOUT_DIV_MASK,
250 .ops = &clkops_null,
251 .recalc = &omap2_clksel_recalc,
252 .round_rate = &omap2_clksel_round_rate,
253 .set_rate = &omap2_clksel_set_rate,
254};
255
256/* DPLL_DDR */
257static struct dpll_data dpll_ddr_dd = {
258 .mult_div1_reg = AM33XX_CM_CLKSEL_DPLL_DDR,
259 .clk_bypass = &sys_clkin_ck,
260 .clk_ref = &sys_clkin_ck,
261 .control_reg = AM33XX_CM_CLKMODE_DPLL_DDR,
262 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
263 .idlest_reg = AM33XX_CM_IDLEST_DPLL_DDR,
264 .mult_mask = AM33XX_DPLL_MULT_MASK,
265 .div1_mask = AM33XX_DPLL_DIV_MASK,
266 .enable_mask = AM33XX_DPLL_EN_MASK,
267 .idlest_mask = AM33XX_ST_DPLL_CLK_MASK,
268 .max_multiplier = AM33XX_MAX_DPLL_MULT,
269 .max_divider = AM33XX_MAX_DPLL_DIV,
270 .min_divider = 1,
271};
272
273/* CLKOUT: fdpll/M2 */
274static struct clk dpll_ddr_ck = {
275 .name = "dpll_ddr_ck",
276 .parent = &sys_clkin_ck,
277 .dpll_data = &dpll_ddr_dd,
278 .init = &omap2_init_dpll_parent,
279 .ops = &clkops_null,
280 .recalc = &omap3_dpll_recalc,
281};
282
283/*
284 * TODO: Add clksel here (sys_clkin, CORE_CLKOUTM6, PER_CLKOUTM2
285 * and ALT_CLK1/2)
286 */
287static const struct clksel dpll_ddr_m2_div[] = {
288 { .parent = &dpll_ddr_ck, .rates = div31_1to31_rates },
289 { .parent = NULL },
290};
291
292static struct clk dpll_ddr_m2_ck = {
293 .name = "dpll_ddr_m2_ck",
294 .parent = &dpll_ddr_ck,
295 .clksel = dpll_ddr_m2_div,
296 .clksel_reg = AM33XX_CM_DIV_M2_DPLL_DDR,
297 .clksel_mask = AM33XX_DPLL_CLKOUT_DIV_MASK,
298 .ops = &clkops_null,
299 .recalc = &omap2_clksel_recalc,
300 .round_rate = &omap2_clksel_round_rate,
301 .set_rate = &omap2_clksel_set_rate,
302};
303
304/* emif_fck functional clock */
305static struct clk dpll_ddr_m2_div2_ck = {
306 .name = "dpll_ddr_m2_div2_ck",
307 .clkdm_name = "l3_clkdm",
308 .parent = &dpll_ddr_m2_ck,
309 .ops = &clkops_null,
310 .fixed_div = 2,
311 .recalc = &omap_fixed_divisor_recalc,
312};
313
314/* DPLL_DISP */
315static struct dpll_data dpll_disp_dd = {
316 .mult_div1_reg = AM33XX_CM_CLKSEL_DPLL_DISP,
317 .clk_bypass = &sys_clkin_ck,
318 .clk_ref = &sys_clkin_ck,
319 .control_reg = AM33XX_CM_CLKMODE_DPLL_DISP,
320 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
321 .idlest_reg = AM33XX_CM_IDLEST_DPLL_DISP,
322 .mult_mask = AM33XX_DPLL_MULT_MASK,
323 .div1_mask = AM33XX_DPLL_DIV_MASK,
324 .enable_mask = AM33XX_DPLL_EN_MASK,
325 .idlest_mask = AM33XX_ST_DPLL_CLK_MASK,
326 .max_multiplier = AM33XX_MAX_DPLL_MULT,
327 .max_divider = AM33XX_MAX_DPLL_DIV,
328 .min_divider = 1,
329};
330
331/* CLKOUT: fdpll/M2 */
332static struct clk dpll_disp_ck = {
333 .name = "dpll_disp_ck",
334 .parent = &sys_clkin_ck,
335 .dpll_data = &dpll_disp_dd,
336 .init = &omap2_init_dpll_parent,
337 .ops = &clkops_null,
338 .recalc = &omap3_dpll_recalc,
339 .round_rate = &omap2_dpll_round_rate,
340 .set_rate = &omap3_noncore_dpll_set_rate,
341};
342
343/*
344 * TODO: Add clksel here (sys_clkin, CORE_CLKOUTM6, PER_CLKOUTM2
345 * and ALT_CLK1/2)
346 */
347static const struct clksel dpll_disp_m2_div[] = {
348 { .parent = &dpll_disp_ck, .rates = div31_1to31_rates },
349 { .parent = NULL },
350};
351
352static struct clk dpll_disp_m2_ck = {
353 .name = "dpll_disp_m2_ck",
354 .parent = &dpll_disp_ck,
355 .clksel = dpll_disp_m2_div,
356 .clksel_reg = AM33XX_CM_DIV_M2_DPLL_DISP,
357 .clksel_mask = AM33XX_DPLL_CLKOUT_DIV_MASK,
358 .ops = &clkops_null,
359 .recalc = &omap2_clksel_recalc,
360 .round_rate = &omap2_clksel_round_rate,
361 .set_rate = &omap2_clksel_set_rate,
362};
363
364/* DPLL_PER */
365static struct dpll_data dpll_per_dd = {
366 .mult_div1_reg = AM33XX_CM_CLKSEL_DPLL_PERIPH,
367 .clk_bypass = &sys_clkin_ck,
368 .clk_ref = &sys_clkin_ck,
369 .control_reg = AM33XX_CM_CLKMODE_DPLL_PER,
370 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
371 .idlest_reg = AM33XX_CM_IDLEST_DPLL_PER,
372 .mult_mask = AM33XX_DPLL_MULT_PERIPH_MASK,
373 .div1_mask = AM33XX_DPLL_PER_DIV_MASK,
374 .enable_mask = AM33XX_DPLL_EN_MASK,
375 .idlest_mask = AM33XX_ST_DPLL_CLK_MASK,
376 .max_multiplier = AM33XX_MAX_DPLL_MULT,
377 .max_divider = AM33XX_MAX_DPLL_DIV,
378 .min_divider = 1,
379 .flags = DPLL_J_TYPE,
380};
381
382/* CLKDCOLDO */
383static struct clk dpll_per_ck = {
384 .name = "dpll_per_ck",
385 .parent = &sys_clkin_ck,
386 .dpll_data = &dpll_per_dd,
387 .init = &omap2_init_dpll_parent,
388 .ops = &clkops_null,
389 .recalc = &omap3_dpll_recalc,
390 .round_rate = &omap2_dpll_round_rate,
391 .set_rate = &omap3_noncore_dpll_set_rate,
392};
393
394/* CLKOUT: fdpll/M2 */
395static const struct clksel dpll_per_m2_div[] = {
396 { .parent = &dpll_per_ck, .rates = div31_1to31_rates },
397 { .parent = NULL },
398};
399
400static struct clk dpll_per_m2_ck = {
401 .name = "dpll_per_m2_ck",
402 .parent = &dpll_per_ck,
403 .clksel = dpll_per_m2_div,
404 .clksel_reg = AM33XX_CM_DIV_M2_DPLL_PER,
405 .clksel_mask = AM33XX_DPLL_CLKOUT_DIV_MASK,
406 .ops = &clkops_null,
407 .recalc = &omap2_clksel_recalc,
408 .round_rate = &omap2_clksel_round_rate,
409 .set_rate = &omap2_clksel_set_rate,
410};
411
412static struct clk dpll_per_m2_div4_wkupdm_ck = {
413 .name = "dpll_per_m2_div4_wkupdm_ck",
414 .clkdm_name = "l4_wkup_clkdm",
415 .parent = &dpll_per_m2_ck,
416 .fixed_div = 4,
417 .ops = &clkops_null,
418 .recalc = &omap_fixed_divisor_recalc,
419};
420
421static struct clk dpll_per_m2_div4_ck = {
422 .name = "dpll_per_m2_div4_ck",
423 .clkdm_name = "l4ls_clkdm",
424 .parent = &dpll_per_m2_ck,
425 .fixed_div = 4,
426 .ops = &clkops_null,
427 .recalc = &omap_fixed_divisor_recalc,
428};
429
430static struct clk l3_gclk = {
431 .name = "l3_gclk",
432 .clkdm_name = "l3_clkdm",
433 .parent = &dpll_core_m4_ck,
434 .ops = &clkops_null,
435 .recalc = &followparent_recalc,
436};
437
438static struct clk dpll_core_m4_div2_ck = {
439 .name = "dpll_core_m4_div2_ck",
440 .clkdm_name = "l4_wkup_clkdm",
441 .parent = &dpll_core_m4_ck,
442 .ops = &clkops_null,
443 .fixed_div = 2,
444 .recalc = &omap_fixed_divisor_recalc,
445};
446
447static struct clk l4_rtc_gclk = {
448 .name = "l4_rtc_gclk",
449 .parent = &dpll_core_m4_ck,
450 .ops = &clkops_null,
451 .fixed_div = 2,
452 .recalc = &omap_fixed_divisor_recalc,
453};
454
455static struct clk clk_24mhz = {
456 .name = "clk_24mhz",
457 .parent = &dpll_per_m2_ck,
458 .fixed_div = 8,
459 .ops = &clkops_null,
460 .recalc = &omap_fixed_divisor_recalc,
461};
462
463/*
464 * Below clock nodes describes clockdomains derived out
465 * of core clock.
466 */
467static struct clk l4hs_gclk = {
468 .name = "l4hs_gclk",
469 .clkdm_name = "l4hs_clkdm",
470 .parent = &dpll_core_m4_ck,
471 .ops = &clkops_null,
472 .recalc = &followparent_recalc,
473};
474
475static struct clk l3s_gclk = {
476 .name = "l3s_gclk",
477 .clkdm_name = "l3s_clkdm",
478 .parent = &dpll_core_m4_div2_ck,
479 .ops = &clkops_null,
480 .recalc = &followparent_recalc,
481};
482
483static struct clk l4fw_gclk = {
484 .name = "l4fw_gclk",
485 .clkdm_name = "l4fw_clkdm",
486 .parent = &dpll_core_m4_div2_ck,
487 .ops = &clkops_null,
488 .recalc = &followparent_recalc,
489};
490
491static struct clk l4ls_gclk = {
492 .name = "l4ls_gclk",
493 .clkdm_name = "l4ls_clkdm",
494 .parent = &dpll_core_m4_div2_ck,
495 .ops = &clkops_null,
496 .recalc = &followparent_recalc,
497};
498
499static struct clk sysclk_div_ck = {
500 .name = "sysclk_div_ck",
501 .parent = &dpll_core_m4_ck,
502 .ops = &clkops_null,
503 .recalc = &followparent_recalc,
504};
505
506/*
507 * In order to match the clock domain with hwmod clockdomain entry,
508 * separate clock nodes is required for the modules which are
509 * directly getting their funtioncal clock from sys_clkin.
510 */
511static struct clk adc_tsc_fck = {
512 .name = "adc_tsc_fck",
513 .clkdm_name = "l4_wkup_clkdm",
514 .parent = &sys_clkin_ck,
515 .ops = &clkops_null,
516 .recalc = &followparent_recalc,
517};
518
519static struct clk dcan0_fck = {
520 .name = "dcan0_fck",
521 .clkdm_name = "l4ls_clkdm",
522 .parent = &sys_clkin_ck,
523 .ops = &clkops_null,
524 .recalc = &followparent_recalc,
525};
526
527static struct clk dcan1_fck = {
528 .name = "dcan1_fck",
529 .clkdm_name = "l4ls_clkdm",
530 .parent = &sys_clkin_ck,
531 .ops = &clkops_null,
532 .recalc = &followparent_recalc,
533};
534
535static struct clk mcasp0_fck = {
536 .name = "mcasp0_fck",
537 .clkdm_name = "l3s_clkdm",
538 .parent = &sys_clkin_ck,
539 .ops = &clkops_null,
540 .recalc = &followparent_recalc,
541};
542
543static struct clk mcasp1_fck = {
544 .name = "mcasp1_fck",
545 .clkdm_name = "l3s_clkdm",
546 .parent = &sys_clkin_ck,
547 .ops = &clkops_null,
548 .recalc = &followparent_recalc,
549};
550
551static struct clk smartreflex0_fck = {
552 .name = "smartreflex0_fck",
553 .clkdm_name = "l4_wkup_clkdm",
554 .parent = &sys_clkin_ck,
555 .ops = &clkops_null,
556 .recalc = &followparent_recalc,
557};
558
559static struct clk smartreflex1_fck = {
560 .name = "smartreflex1_fck",
561 .clkdm_name = "l4_wkup_clkdm",
562 .parent = &sys_clkin_ck,
563 .ops = &clkops_null,
564 .recalc = &followparent_recalc,
565};
566
567/*
568 * Modules clock nodes
569 *
570 * The following clock leaf nodes are added for the moment because:
571 *
572 * - hwmod data is not present for these modules, either hwmod
573 * control is not required or its not populated.
574 * - Driver code is not yet migrated to use hwmod/runtime pm
575 * - Modules outside kernel access (to disable them by default)
576 *
577 * - debugss
578 * - mmu (gfx domain)
579 * - cefuse
580 * - usbotg_fck (its additional clock and not really a modulemode)
581 * - ieee5000
582 */
583static struct clk debugss_ick = {
584 .name = "debugss_ick",
585 .clkdm_name = "l3_aon_clkdm",
586 .parent = &dpll_core_m4_ck,
587 .ops = &clkops_omap2_dflt,
588 .enable_reg = AM33XX_CM_WKUP_DEBUGSS_CLKCTRL,
589 .enable_bit = AM33XX_MODULEMODE_SWCTRL,
590 .recalc = &followparent_recalc,
591};
592
593static struct clk mmu_fck = {
594 .name = "mmu_fck",
595 .clkdm_name = "gfx_l3_clkdm",
596 .parent = &dpll_core_m4_ck,
597 .ops = &clkops_omap2_dflt,
598 .enable_reg = AM33XX_CM_GFX_MMUDATA_CLKCTRL,
599 .enable_bit = AM33XX_MODULEMODE_SWCTRL,
600 .recalc = &followparent_recalc,
601};
602
603static struct clk cefuse_fck = {
604 .name = "cefuse_fck",
605 .clkdm_name = "l4_cefuse_clkdm",
606 .parent = &sys_clkin_ck,
607 .enable_reg = AM33XX_CM_CEFUSE_CEFUSE_CLKCTRL,
608 .enable_bit = AM33XX_MODULEMODE_SWCTRL,
609 .ops = &clkops_omap2_dflt,
610 .recalc = &followparent_recalc,
611};
612
613/*
614 * clkdiv32 is generated from fixed division of 732.4219
615 */
616static struct clk clkdiv32k_ick = {
617 .name = "clkdiv32k_ick",
618 .clkdm_name = "clk_24mhz_clkdm",
619 .rate = 32768,
620 .parent = &clk_24mhz,
621 .enable_reg = AM33XX_CM_PER_CLKDIV32K_CLKCTRL,
622 .enable_bit = AM33XX_MODULEMODE_SWCTRL,
623 .ops = &clkops_omap2_dflt,
624};
625
626static struct clk usbotg_fck = {
627 .name = "usbotg_fck",
628 .clkdm_name = "l3s_clkdm",
629 .parent = &dpll_per_ck,
630 .enable_reg = AM33XX_CM_CLKDCOLDO_DPLL_PER,
631 .enable_bit = AM33XX_ST_DPLL_CLKDCOLDO_SHIFT,
632 .ops = &clkops_omap2_dflt,
633 .recalc = &followparent_recalc,
634};
635
636static struct clk ieee5000_fck = {
637 .name = "ieee5000_fck",
638 .clkdm_name = "l3s_clkdm",
639 .parent = &dpll_core_m4_div2_ck,
640 .enable_reg = AM33XX_CM_PER_IEEE5000_CLKCTRL,
641 .enable_bit = AM33XX_MODULEMODE_SWCTRL,
642 .ops = &clkops_omap2_dflt,
643 .recalc = &followparent_recalc,
644};
645
646/* Timers */
647static const struct clksel timer1_clkmux_sel[] = {
648 { .parent = &sys_clkin_ck, .rates = div_1_0_rates },
649 { .parent = &clkdiv32k_ick, .rates = div_1_1_rates },
650 { .parent = &tclkin_ck, .rates = div_1_2_rates },
651 { .parent = &clk_rc32k_ck, .rates = div_1_3_rates },
652 { .parent = &clk_32768_ck, .rates = div_1_4_rates },
653 { .parent = NULL },
654};
655
656static struct clk timer1_fck = {
657 .name = "timer1_fck",
658 .clkdm_name = "l4ls_clkdm",
659 .parent = &sys_clkin_ck,
660 .init = &omap2_init_clksel_parent,
661 .clksel = timer1_clkmux_sel,
662 .clksel_reg = AM33XX_CLKSEL_TIMER1MS_CLK,
663 .clksel_mask = AM33XX_CLKSEL_0_2_MASK,
664 .ops = &clkops_null,
665 .recalc = &omap2_clksel_recalc,
666};
667
668static const struct clksel timer2_to_7_clk_sel[] = {
669 { .parent = &tclkin_ck, .rates = div_1_0_rates },
670 { .parent = &sys_clkin_ck, .rates = div_1_1_rates },
671 { .parent = &clkdiv32k_ick, .rates = div_1_2_rates },
672 { .parent = NULL },
673};
674
675static struct clk timer2_fck = {
676 .name = "timer2_fck",
677 .clkdm_name = "l4ls_clkdm",
678 .parent = &sys_clkin_ck,
679 .init = &omap2_init_clksel_parent,
680 .clksel = timer2_to_7_clk_sel,
681 .clksel_reg = AM33XX_CLKSEL_TIMER2_CLK,
682 .clksel_mask = AM33XX_CLKSEL_0_1_MASK,
683 .ops = &clkops_null,
684 .recalc = &omap2_clksel_recalc,
685};
686
687static struct clk timer3_fck = {
688 .name = "timer3_fck",
689 .clkdm_name = "l4ls_clkdm",
690 .parent = &sys_clkin_ck,
691 .init = &am33xx_init_timer_parent,
692 .clksel = timer2_to_7_clk_sel,
693 .clksel_reg = AM33XX_CLKSEL_TIMER3_CLK,
694 .clksel_mask = AM33XX_CLKSEL_0_1_MASK,
695 .ops = &clkops_null,
696 .recalc = &omap2_clksel_recalc,
697};
698
699static struct clk timer4_fck = {
700 .name = "timer4_fck",
701 .clkdm_name = "l4ls_clkdm",
702 .parent = &sys_clkin_ck,
703 .init = &omap2_init_clksel_parent,
704 .clksel = timer2_to_7_clk_sel,
705 .clksel_reg = AM33XX_CLKSEL_TIMER4_CLK,
706 .clksel_mask = AM33XX_CLKSEL_0_1_MASK,
707 .ops = &clkops_null,
708 .recalc = &omap2_clksel_recalc,
709};
710
711static struct clk timer5_fck = {
712 .name = "timer5_fck",
713 .clkdm_name = "l4ls_clkdm",
714 .parent = &sys_clkin_ck,
715 .init = &omap2_init_clksel_parent,
716 .clksel = timer2_to_7_clk_sel,
717 .clksel_reg = AM33XX_CLKSEL_TIMER5_CLK,
718 .clksel_mask = AM33XX_CLKSEL_0_1_MASK,
719 .ops = &clkops_null,
720 .recalc = &omap2_clksel_recalc,
721};
722
723static struct clk timer6_fck = {
724 .name = "timer6_fck",
725 .clkdm_name = "l4ls_clkdm",
726 .parent = &sys_clkin_ck,
727 .init = &am33xx_init_timer_parent,
728 .clksel = timer2_to_7_clk_sel,
729 .clksel_reg = AM33XX_CLKSEL_TIMER6_CLK,
730 .clksel_mask = AM33XX_CLKSEL_0_1_MASK,
731 .ops = &clkops_null,
732 .recalc = &omap2_clksel_recalc,
733};
734
735static struct clk timer7_fck = {
736 .name = "timer7_fck",
737 .clkdm_name = "l4ls_clkdm",
738 .parent = &sys_clkin_ck,
739 .init = &omap2_init_clksel_parent,
740 .clksel = timer2_to_7_clk_sel,
741 .clksel_reg = AM33XX_CLKSEL_TIMER7_CLK,
742 .clksel_mask = AM33XX_CLKSEL_0_1_MASK,
743 .ops = &clkops_null,
744 .recalc = &omap2_clksel_recalc,
745};
746
747static struct clk cpsw_125mhz_gclk = {
748 .name = "cpsw_125mhz_gclk",
749 .clkdm_name = "cpsw_125mhz_clkdm",
750 .parent = &dpll_core_m5_ck,
751 .ops = &clkops_null,
752 .fixed_div = 2,
753 .recalc = &omap_fixed_divisor_recalc,
754};
755
756static const struct clksel cpsw_cpts_rft_clkmux_sel[] = {
757 { .parent = &dpll_core_m5_ck, .rates = div_1_0_rates },
758 { .parent = &dpll_core_m4_ck, .rates = div_1_1_rates },
759 { .parent = NULL },
760};
761
762static struct clk cpsw_cpts_rft_clk = {
763 .name = "cpsw_cpts_rft_clk",
764 .clkdm_name = "cpsw_125mhz_clkdm",
765 .parent = &dpll_core_m5_ck,
766 .clksel = cpsw_cpts_rft_clkmux_sel,
767 .clksel_reg = AM33XX_CM_CPTS_RFT_CLKSEL,
768 .clksel_mask = AM33XX_CLKSEL_0_0_MASK,
769 .ops = &clkops_null,
770 .recalc = &followparent_recalc,
771};
772
773/* gpio */
774static const struct clksel gpio0_dbclk_mux_sel[] = {
775 { .parent = &clk_rc32k_ck, .rates = div_1_0_rates },
776 { .parent = &clk_32768_ck, .rates = div_1_1_rates },
777 { .parent = &clkdiv32k_ick, .rates = div_1_2_rates },
778 { .parent = NULL },
779};
780
781static struct clk gpio0_dbclk_mux_ck = {
782 .name = "gpio0_dbclk_mux_ck",
783 .clkdm_name = "l4_wkup_clkdm",
784 .parent = &clk_rc32k_ck,
785 .init = &omap2_init_clksel_parent,
786 .clksel = gpio0_dbclk_mux_sel,
787 .clksel_reg = AM33XX_CLKSEL_GPIO0_DBCLK,
788 .clksel_mask = AM33XX_CLKSEL_0_1_MASK,
789 .ops = &clkops_null,
790 .recalc = &omap2_clksel_recalc,
791};
792
793static struct clk gpio0_dbclk = {
794 .name = "gpio0_dbclk",
795 .clkdm_name = "l4_wkup_clkdm",
796 .parent = &gpio0_dbclk_mux_ck,
797 .enable_reg = AM33XX_CM_WKUP_GPIO0_CLKCTRL,
798 .enable_bit = AM33XX_OPTFCLKEN_GPIO0_GDBCLK_SHIFT,
799 .ops = &clkops_omap2_dflt,
800 .recalc = &followparent_recalc,
801};
802
803static struct clk gpio1_dbclk = {
804 .name = "gpio1_dbclk",
805 .clkdm_name = "l4ls_clkdm",
806 .parent = &clkdiv32k_ick,
807 .enable_reg = AM33XX_CM_PER_GPIO1_CLKCTRL,
808 .enable_bit = AM33XX_OPTFCLKEN_GPIO_1_GDBCLK_SHIFT,
809 .ops = &clkops_omap2_dflt,
810 .recalc = &followparent_recalc,
811};
812
813static struct clk gpio2_dbclk = {
814 .name = "gpio2_dbclk",
815 .clkdm_name = "l4ls_clkdm",
816 .parent = &clkdiv32k_ick,
817 .enable_reg = AM33XX_CM_PER_GPIO2_CLKCTRL,
818 .enable_bit = AM33XX_OPTFCLKEN_GPIO_2_GDBCLK_SHIFT,
819 .ops = &clkops_omap2_dflt,
820 .recalc = &followparent_recalc,
821};
822
823static struct clk gpio3_dbclk = {
824 .name = "gpio3_dbclk",
825 .clkdm_name = "l4ls_clkdm",
826 .parent = &clkdiv32k_ick,
827 .enable_reg = AM33XX_CM_PER_GPIO3_CLKCTRL,
828 .enable_bit = AM33XX_OPTFCLKEN_GPIO_3_GDBCLK_SHIFT,
829 .ops = &clkops_omap2_dflt,
830 .recalc = &followparent_recalc,
831};
832
833static const struct clksel pruss_ocp_clk_mux_sel[] = {
834 { .parent = &l3_gclk, .rates = div_1_0_rates },
835 { .parent = &dpll_disp_m2_ck, .rates = div_1_1_rates },
836 { .parent = NULL },
837};
838
839static struct clk pruss_ocp_gclk = {
840 .name = "pruss_ocp_gclk",
841 .clkdm_name = "pruss_ocp_clkdm",
842 .parent = &l3_gclk,
843 .init = &omap2_init_clksel_parent,
844 .clksel = pruss_ocp_clk_mux_sel,
845 .clksel_reg = AM33XX_CLKSEL_PRUSS_OCP_CLK,
846 .clksel_mask = AM33XX_CLKSEL_0_0_MASK,
847 .ops = &clkops_null,
848 .recalc = &followparent_recalc,
849};
850
851static const struct clksel lcd_clk_mux_sel[] = {
852 { .parent = &dpll_disp_m2_ck, .rates = div_1_0_rates },
853 { .parent = &dpll_core_m5_ck, .rates = div_1_1_rates },
854 { .parent = &dpll_per_m2_ck, .rates = div_1_2_rates },
855 { .parent = NULL },
856};
857
858static struct clk lcd_gclk = {
859 .name = "lcd_gclk",
860 .clkdm_name = "lcdc_clkdm",
861 .parent = &dpll_disp_m2_ck,
862 .init = &omap2_init_clksel_parent,
863 .clksel = lcd_clk_mux_sel,
864 .clksel_reg = AM33XX_CLKSEL_LCDC_PIXEL_CLK,
865 .clksel_mask = AM33XX_CLKSEL_0_1_MASK,
866 .ops = &clkops_null,
867 .recalc = &followparent_recalc,
868};
869
870static struct clk mmc_clk = {
871 .name = "mmc_clk",
872 .clkdm_name = "l4ls_clkdm",
873 .parent = &dpll_per_m2_ck,
874 .ops = &clkops_null,
875 .fixed_div = 2,
876 .recalc = &omap_fixed_divisor_recalc,
877};
878
879static struct clk mmc2_fck = {
880 .name = "mmc2_fck",
881 .clkdm_name = "l3s_clkdm",
882 .parent = &mmc_clk,
883 .ops = &clkops_null,
884 .recalc = &followparent_recalc,
885};
886
887static const struct clksel gfx_clksel_sel[] = {
888 { .parent = &dpll_core_m4_ck, .rates = div_1_0_rates },
889 { .parent = &dpll_per_m2_ck, .rates = div_1_1_rates },
890 { .parent = NULL },
891};
892
893static struct clk gfx_fclk_clksel_ck = {
894 .name = "gfx_fclk_clksel_ck",
895 .parent = &dpll_core_m4_ck,
896 .clksel = gfx_clksel_sel,
897 .ops = &clkops_null,
898 .clksel_reg = AM33XX_CLKSEL_GFX_FCLK,
899 .clksel_mask = AM33XX_CLKSEL_GFX_FCLK_MASK,
900 .recalc = &omap2_clksel_recalc,
901};
902
903static const struct clksel_rate div_1_0_2_1_rates[] = {
904 { .div = 1, .val = 0, .flags = RATE_IN_AM33XX },
905 { .div = 2, .val = 1, .flags = RATE_IN_AM33XX },
906 { .div = 0 },
907};
908
909static const struct clksel gfx_div_sel[] = {
910 { .parent = &gfx_fclk_clksel_ck, .rates = div_1_0_2_1_rates },
911 { .parent = NULL },
912};
913
914static struct clk gfx_fck_div_ck = {
915 .name = "gfx_fck_div_ck",
916 .clkdm_name = "gfx_l3_clkdm",
917 .parent = &gfx_fclk_clksel_ck,
918 .init = &omap2_init_clksel_parent,
919 .clksel = gfx_div_sel,
920 .clksel_reg = AM33XX_CLKSEL_GFX_FCLK,
921 .clksel_mask = AM33XX_CLKSEL_0_0_MASK,
922 .recalc = &omap2_clksel_recalc,
923 .round_rate = &omap2_clksel_round_rate,
924 .set_rate = &omap2_clksel_set_rate,
925 .ops = &clkops_null,
926};
927
928static const struct clksel sysclkout_pre_sel[] = {
929 { .parent = &clk_32768_ck, .rates = div_1_0_rates },
930 { .parent = &l3_gclk, .rates = div_1_1_rates },
931 { .parent = &dpll_ddr_m2_ck, .rates = div_1_2_rates },
932 { .parent = &dpll_per_m2_ck, .rates = div_1_3_rates },
933 { .parent = &lcd_gclk, .rates = div_1_4_rates },
934 { .parent = NULL },
935};
936
937static struct clk sysclkout_pre_ck = {
938 .name = "sysclkout_pre_ck",
939 .parent = &clk_32768_ck,
940 .init = &omap2_init_clksel_parent,
941 .clksel = sysclkout_pre_sel,
942 .clksel_reg = AM33XX_CM_CLKOUT_CTRL,
943 .clksel_mask = AM33XX_CLKOUT2SOURCE_MASK,
944 .ops = &clkops_null,
945 .recalc = &omap2_clksel_recalc,
946};
947
948/* Divide by 8 clock rates with default clock is 1/1*/
949static const struct clksel_rate div8_rates[] = {
950 { .div = 1, .val = 0, .flags = RATE_IN_AM33XX },
951 { .div = 2, .val = 1, .flags = RATE_IN_AM33XX },
952 { .div = 3, .val = 2, .flags = RATE_IN_AM33XX },
953 { .div = 4, .val = 3, .flags = RATE_IN_AM33XX },
954 { .div = 5, .val = 4, .flags = RATE_IN_AM33XX },
955 { .div = 6, .val = 5, .flags = RATE_IN_AM33XX },
956 { .div = 7, .val = 6, .flags = RATE_IN_AM33XX },
957 { .div = 8, .val = 7, .flags = RATE_IN_AM33XX },
958 { .div = 0 },
959};
960
961static const struct clksel clkout2_div[] = {
962 { .parent = &sysclkout_pre_ck, .rates = div8_rates },
963 { .parent = NULL },
964};
965
966static struct clk clkout2_ck = {
967 .name = "clkout2_ck",
968 .parent = &sysclkout_pre_ck,
969 .ops = &clkops_omap2_dflt,
970 .clksel = clkout2_div,
971 .clksel_reg = AM33XX_CM_CLKOUT_CTRL,
972 .clksel_mask = AM33XX_CLKOUT2DIV_MASK,
973 .enable_reg = AM33XX_CM_CLKOUT_CTRL,
974 .enable_bit = AM33XX_CLKOUT2EN_SHIFT,
975 .recalc = &omap2_clksel_recalc,
976 .round_rate = &omap2_clksel_round_rate,
977 .set_rate = &omap2_clksel_set_rate,
978};
979
980static const struct clksel wdt_clkmux_sel[] = {
981 { .parent = &clk_rc32k_ck, .rates = div_1_0_rates },
982 { .parent = &clkdiv32k_ick, .rates = div_1_1_rates },
983 { .parent = NULL },
984};
985
986static struct clk wdt1_fck = {
987 .name = "wdt1_fck",
988 .clkdm_name = "l4_wkup_clkdm",
989 .parent = &clk_rc32k_ck,
990 .init = &omap2_init_clksel_parent,
991 .clksel = wdt_clkmux_sel,
992 .clksel_reg = AM33XX_CLKSEL_WDT1_CLK,
993 .clksel_mask = AM33XX_CLKSEL_0_1_MASK,
994 .ops = &clkops_null,
995 .recalc = &omap2_clksel_recalc,
996};
997
998/*
999 * clkdev
1000 */
1001static struct omap_clk am33xx_clks[] = {
1002 CLK(NULL, "clk_32768_ck", &clk_32768_ck, CK_AM33XX),
1003 CLK(NULL, "clk_rc32k_ck", &clk_rc32k_ck, CK_AM33XX),
1004 CLK(NULL, "virt_19200000_ck", &virt_19200000_ck, CK_AM33XX),
1005 CLK(NULL, "virt_24000000_ck", &virt_24000000_ck, CK_AM33XX),
1006 CLK(NULL, "virt_25000000_ck", &virt_25000000_ck, CK_AM33XX),
1007 CLK(NULL, "virt_26000000_ck", &virt_26000000_ck, CK_AM33XX),
1008 CLK(NULL, "sys_clkin_ck", &sys_clkin_ck, CK_AM33XX),
1009 CLK(NULL, "tclkin_ck", &tclkin_ck, CK_AM33XX),
1010 CLK(NULL, "dpll_core_ck", &dpll_core_ck, CK_AM33XX),
1011 CLK(NULL, "dpll_core_x2_ck", &dpll_core_x2_ck, CK_AM33XX),
1012 CLK(NULL, "dpll_core_m4_ck", &dpll_core_m4_ck, CK_AM33XX),
1013 CLK(NULL, "dpll_core_m5_ck", &dpll_core_m5_ck, CK_AM33XX),
1014 CLK(NULL, "dpll_core_m6_ck", &dpll_core_m6_ck, CK_AM33XX),
1015 CLK(NULL, "dpll_mpu_ck", &dpll_mpu_ck, CK_AM33XX),
1016 CLK(NULL, "dpll_mpu_m2_ck", &dpll_mpu_m2_ck, CK_AM33XX),
1017 CLK(NULL, "dpll_ddr_ck", &dpll_ddr_ck, CK_AM33XX),
1018 CLK(NULL, "dpll_ddr_m2_ck", &dpll_ddr_m2_ck, CK_AM33XX),
1019 CLK(NULL, "dpll_ddr_m2_div2_ck", &dpll_ddr_m2_div2_ck, CK_AM33XX),
1020 CLK(NULL, "dpll_disp_ck", &dpll_disp_ck, CK_AM33XX),
1021 CLK(NULL, "dpll_disp_m2_ck", &dpll_disp_m2_ck, CK_AM33XX),
1022 CLK(NULL, "dpll_per_ck", &dpll_per_ck, CK_AM33XX),
1023 CLK(NULL, "dpll_per_m2_ck", &dpll_per_m2_ck, CK_AM33XX),
1024 CLK(NULL, "dpll_per_m2_div4_wkupdm_ck", &dpll_per_m2_div4_wkupdm_ck, CK_AM33XX),
1025 CLK(NULL, "dpll_per_m2_div4_ck", &dpll_per_m2_div4_ck, CK_AM33XX),
1026 CLK(NULL, "adc_tsc_fck", &adc_tsc_fck, CK_AM33XX),
1027 CLK(NULL, "cefuse_fck", &cefuse_fck, CK_AM33XX),
1028 CLK(NULL, "clkdiv32k_ick", &clkdiv32k_ick, CK_AM33XX),
1029 CLK(NULL, "dcan0_fck", &dcan0_fck, CK_AM33XX),
1030 CLK(NULL, "dcan1_fck", &dcan1_fck, CK_AM33XX),
1031 CLK(NULL, "debugss_ick", &debugss_ick, CK_AM33XX),
1032 CLK(NULL, "pruss_ocp_gclk", &pruss_ocp_gclk, CK_AM33XX),
1033 CLK("davinci-mcasp.0", NULL, &mcasp0_fck, CK_AM33XX),
1034 CLK("davinci-mcasp.1", NULL, &mcasp1_fck, CK_AM33XX),
1035 CLK("NULL", "mmc2_fck", &mmc2_fck, CK_AM33XX),
1036 CLK(NULL, "mmu_fck", &mmu_fck, CK_AM33XX),
1037 CLK(NULL, "smartreflex0_fck", &smartreflex0_fck, CK_AM33XX),
1038 CLK(NULL, "smartreflex1_fck", &smartreflex1_fck, CK_AM33XX),
1039 CLK(NULL, "gpt1_fck", &timer1_fck, CK_AM33XX),
1040 CLK(NULL, "gpt2_fck", &timer2_fck, CK_AM33XX),
1041 CLK(NULL, "gpt3_fck", &timer3_fck, CK_AM33XX),
1042 CLK(NULL, "gpt4_fck", &timer4_fck, CK_AM33XX),
1043 CLK(NULL, "gpt5_fck", &timer5_fck, CK_AM33XX),
1044 CLK(NULL, "gpt6_fck", &timer6_fck, CK_AM33XX),
1045 CLK(NULL, "gpt7_fck", &timer7_fck, CK_AM33XX),
1046 CLK(NULL, "usbotg_fck", &usbotg_fck, CK_AM33XX),
1047 CLK(NULL, "ieee5000_fck", &ieee5000_fck, CK_AM33XX),
1048 CLK(NULL, "wdt1_fck", &wdt1_fck, CK_AM33XX),
1049 CLK(NULL, "l4_rtc_gclk", &l4_rtc_gclk, CK_AM33XX),
1050 CLK(NULL, "l3_gclk", &l3_gclk, CK_AM33XX),
1051 CLK(NULL, "dpll_core_m4_div2_ck", &dpll_core_m4_div2_ck, CK_AM33XX),
1052 CLK(NULL, "l4hs_gclk", &l4hs_gclk, CK_AM33XX),
1053 CLK(NULL, "l3s_gclk", &l3s_gclk, CK_AM33XX),
1054 CLK(NULL, "l4fw_gclk", &l4fw_gclk, CK_AM33XX),
1055 CLK(NULL, "l4ls_gclk", &l4ls_gclk, CK_AM33XX),
1056 CLK(NULL, "clk_24mhz", &clk_24mhz, CK_AM33XX),
1057 CLK(NULL, "sysclk_div_ck", &sysclk_div_ck, CK_AM33XX),
1058 CLK(NULL, "cpsw_125mhz_gclk", &cpsw_125mhz_gclk, CK_AM33XX),
1059 CLK(NULL, "cpsw_cpts_rft_clk", &cpsw_cpts_rft_clk, CK_AM33XX),
1060 CLK(NULL, "gpio0_dbclk_mux_ck", &gpio0_dbclk_mux_ck, CK_AM33XX),
1061 CLK(NULL, "gpio0_dbclk", &gpio0_dbclk, CK_AM33XX),
1062 CLK(NULL, "gpio1_dbclk", &gpio1_dbclk, CK_AM33XX),
1063 CLK(NULL, "gpio2_dbclk", &gpio2_dbclk, CK_AM33XX),
1064 CLK(NULL, "gpio3_dbclk", &gpio3_dbclk, CK_AM33XX),
1065 CLK(NULL, "lcd_gclk", &lcd_gclk, CK_AM33XX),
1066 CLK(NULL, "mmc_clk", &mmc_clk, CK_AM33XX),
1067 CLK(NULL, "gfx_fclk_clksel_ck", &gfx_fclk_clksel_ck, CK_AM33XX),
1068 CLK(NULL, "gfx_fck_div_ck", &gfx_fck_div_ck, CK_AM33XX),
1069 CLK(NULL, "sysclkout_pre_ck", &sysclkout_pre_ck, CK_AM33XX),
1070 CLK(NULL, "clkout2_ck", &clkout2_ck, CK_AM33XX),
1071};
1072
1073int __init am33xx_clk_init(void)
1074{
1075 struct omap_clk *c;
1076 u32 cpu_clkflg;
1077
1078 if (soc_is_am33xx()) {
1079 cpu_mask = RATE_IN_AM33XX;
1080 cpu_clkflg = CK_AM33XX;
1081 }
1082
1083 clk_init(&omap2_clk_functions);
1084
1085 for (c = am33xx_clks; c < am33xx_clks + ARRAY_SIZE(am33xx_clks); c++)
1086 clk_preinit(c->lk.clk);
1087
1088 for (c = am33xx_clks; c < am33xx_clks + ARRAY_SIZE(am33xx_clks); c++) {
1089 if (c->cpu & cpu_clkflg) {
1090 clkdev_add(&c->lk);
1091 clk_register(c->lk.clk);
1092 omap2_init_clk_clkdm(c->lk.clk);
1093 }
1094 }
1095
1096 recalculate_root_clocks();
1097
1098 /*
1099 * Only enable those clocks we will need, let the drivers
1100 * enable other clocks as necessary
1101 */
1102 clk_enable_init_clocks();
1103
1104 return 0;
1105}
diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-omap2/clock3xxx_data.c
index 1efdec236ae..83bed9ad301 100644
--- a/arch/arm/mach-omap2/clock3xxx_data.c
+++ b/arch/arm/mach-omap2/clock3xxx_data.c
@@ -93,18 +93,6 @@ static struct clk virt_16_8m_ck = {
93 .rate = 16800000, 93 .rate = 16800000,
94}; 94};
95 95
96static struct clk virt_19_2m_ck = {
97 .name = "virt_19_2m_ck",
98 .ops = &clkops_null,
99 .rate = 19200000,
100};
101
102static struct clk virt_26m_ck = {
103 .name = "virt_26m_ck",
104 .ops = &clkops_null,
105 .rate = 26000000,
106};
107
108static struct clk virt_38_4m_ck = { 96static struct clk virt_38_4m_ck = {
109 .name = "virt_38_4m_ck", 97 .name = "virt_38_4m_ck",
110 .ops = &clkops_null, 98 .ops = &clkops_null,
@@ -145,8 +133,8 @@ static const struct clksel osc_sys_clksel[] = {
145 { .parent = &virt_12m_ck, .rates = osc_sys_12m_rates }, 133 { .parent = &virt_12m_ck, .rates = osc_sys_12m_rates },
146 { .parent = &virt_13m_ck, .rates = osc_sys_13m_rates }, 134 { .parent = &virt_13m_ck, .rates = osc_sys_13m_rates },
147 { .parent = &virt_16_8m_ck, .rates = osc_sys_16_8m_rates }, 135 { .parent = &virt_16_8m_ck, .rates = osc_sys_16_8m_rates },
148 { .parent = &virt_19_2m_ck, .rates = osc_sys_19_2m_rates }, 136 { .parent = &virt_19200000_ck, .rates = osc_sys_19_2m_rates },
149 { .parent = &virt_26m_ck, .rates = osc_sys_26m_rates }, 137 { .parent = &virt_26000000_ck, .rates = osc_sys_26m_rates },
150 { .parent = &virt_38_4m_ck, .rates = osc_sys_38_4m_rates }, 138 { .parent = &virt_38_4m_ck, .rates = osc_sys_38_4m_rates },
151 { .parent = NULL }, 139 { .parent = NULL },
152}; 140};
@@ -2490,13 +2478,13 @@ static struct clk uart4_fck = {
2490}; 2478};
2491 2479
2492static struct clk uart4_fck_am35xx = { 2480static struct clk uart4_fck_am35xx = {
2493 .name = "uart4_fck", 2481 .name = "uart4_fck",
2494 .ops = &clkops_omap2_dflt_wait, 2482 .ops = &clkops_omap2_dflt_wait,
2495 .parent = &per_48m_fck, 2483 .parent = &core_48m_fck,
2496 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 2484 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
2497 .enable_bit = OMAP3430_EN_UART4_SHIFT, 2485 .enable_bit = AM35XX_EN_UART4_SHIFT,
2498 .clkdm_name = "core_l4_clkdm", 2486 .clkdm_name = "core_l4_clkdm",
2499 .recalc = &followparent_recalc, 2487 .recalc = &followparent_recalc,
2500}; 2488};
2501 2489
2502static struct clk gpt2_fck = { 2490static struct clk gpt2_fck = {
@@ -3201,8 +3189,12 @@ static struct clk vpfe_fck = {
3201}; 3189};
3202 3190
3203/* 3191/*
3204 * The UART1/2 functional clock acts as the functional 3192 * The UART1/2 functional clock acts as the functional clock for
3205 * clock for UART4. No separate fclk control available. 3193 * UART4. No separate fclk control available. XXX Well now we have a
3194 * uart4_fck that is apparently used as the UART4 functional clock,
3195 * but it also seems that uart1_fck or uart2_fck are still needed, at
3196 * least for UART4 softresets to complete. This really needs
3197 * clarification.
3206 */ 3198 */
3207static struct clk uart4_ick_am35xx = { 3199static struct clk uart4_ick_am35xx = {
3208 .name = "uart4_ick", 3200 .name = "uart4_ick",
@@ -3230,17 +3222,12 @@ static struct omap_clk omap3xxx_clks[] = {
3230 CLK(NULL, "virt_12m_ck", &virt_12m_ck, CK_3XXX), 3222 CLK(NULL, "virt_12m_ck", &virt_12m_ck, CK_3XXX),
3231 CLK(NULL, "virt_13m_ck", &virt_13m_ck, CK_3XXX), 3223 CLK(NULL, "virt_13m_ck", &virt_13m_ck, CK_3XXX),
3232 CLK(NULL, "virt_16_8m_ck", &virt_16_8m_ck, CK_3430ES2PLUS | CK_AM35XX | CK_36XX), 3224 CLK(NULL, "virt_16_8m_ck", &virt_16_8m_ck, CK_3430ES2PLUS | CK_AM35XX | CK_36XX),
3233 CLK(NULL, "virt_19_2m_ck", &virt_19_2m_ck, CK_3XXX), 3225 CLK(NULL, "virt_19200000_ck", &virt_19200000_ck, CK_3XXX),
3234 CLK(NULL, "virt_26m_ck", &virt_26m_ck, CK_3XXX), 3226 CLK(NULL, "virt_26000000_ck", &virt_26000000_ck, CK_3XXX),
3235 CLK(NULL, "virt_38_4m_ck", &virt_38_4m_ck, CK_3XXX), 3227 CLK(NULL, "virt_38_4m_ck", &virt_38_4m_ck, CK_3XXX),
3236 CLK(NULL, "osc_sys_ck", &osc_sys_ck, CK_3XXX), 3228 CLK(NULL, "osc_sys_ck", &osc_sys_ck, CK_3XXX),
3237 CLK(NULL, "sys_ck", &sys_ck, CK_3XXX), 3229 CLK(NULL, "sys_ck", &sys_ck, CK_3XXX),
3238 CLK(NULL, "sys_altclk", &sys_altclk, CK_3XXX), 3230 CLK(NULL, "sys_altclk", &sys_altclk, CK_3XXX),
3239 CLK("omap-mcbsp.1", "pad_fck", &mcbsp_clks, CK_3XXX),
3240 CLK("omap-mcbsp.2", "pad_fck", &mcbsp_clks, CK_3XXX),
3241 CLK("omap-mcbsp.3", "pad_fck", &mcbsp_clks, CK_3XXX),
3242 CLK("omap-mcbsp.4", "pad_fck", &mcbsp_clks, CK_3XXX),
3243 CLK("omap-mcbsp.5", "pad_fck", &mcbsp_clks, CK_3XXX),
3244 CLK(NULL, "mcbsp_clks", &mcbsp_clks, CK_3XXX), 3231 CLK(NULL, "mcbsp_clks", &mcbsp_clks, CK_3XXX),
3245 CLK(NULL, "sys_clkout1", &sys_clkout1, CK_3XXX), 3232 CLK(NULL, "sys_clkout1", &sys_clkout1, CK_3XXX),
3246 CLK(NULL, "dpll1_ck", &dpll1_ck, CK_3XXX), 3233 CLK(NULL, "dpll1_ck", &dpll1_ck, CK_3XXX),
@@ -3307,8 +3294,6 @@ static struct omap_clk omap3xxx_clks[] = {
3307 CLK(NULL, "ts_fck", &ts_fck, CK_3430ES2PLUS | CK_AM35XX | CK_36XX), 3294 CLK(NULL, "ts_fck", &ts_fck, CK_3430ES2PLUS | CK_AM35XX | CK_36XX),
3308 CLK(NULL, "usbtll_fck", &usbtll_fck, CK_3430ES2PLUS | CK_AM35XX | CK_36XX), 3295 CLK(NULL, "usbtll_fck", &usbtll_fck, CK_3430ES2PLUS | CK_AM35XX | CK_36XX),
3309 CLK("usbhs_omap", "usbtll_fck", &usbtll_fck, CK_3430ES2PLUS | CK_AM35XX | CK_36XX), 3296 CLK("usbhs_omap", "usbtll_fck", &usbtll_fck, CK_3430ES2PLUS | CK_AM35XX | CK_36XX),
3310 CLK("omap-mcbsp.1", "prcm_fck", &core_96m_fck, CK_3XXX),
3311 CLK("omap-mcbsp.5", "prcm_fck", &core_96m_fck, CK_3XXX),
3312 CLK(NULL, "core_96m_fck", &core_96m_fck, CK_3XXX), 3297 CLK(NULL, "core_96m_fck", &core_96m_fck, CK_3XXX),
3313 CLK(NULL, "mmchs3_fck", &mmchs3_fck, CK_3430ES2PLUS | CK_AM35XX | CK_36XX), 3298 CLK(NULL, "mmchs3_fck", &mmchs3_fck, CK_3430ES2PLUS | CK_AM35XX | CK_36XX),
3314 CLK(NULL, "mmchs2_fck", &mmchs2_fck, CK_3XXX), 3299 CLK(NULL, "mmchs2_fck", &mmchs2_fck, CK_3XXX),
@@ -3391,15 +3376,15 @@ static struct omap_clk omap3xxx_clks[] = {
3391 CLK(NULL, "usbhost_48m_fck", &usbhost_48m_fck, CK_3430ES2PLUS | CK_AM35XX | CK_36XX), 3376 CLK(NULL, "usbhost_48m_fck", &usbhost_48m_fck, CK_3430ES2PLUS | CK_AM35XX | CK_36XX),
3392 CLK(NULL, "usbhost_ick", &usbhost_ick, CK_3430ES2PLUS | CK_AM35XX | CK_36XX), 3377 CLK(NULL, "usbhost_ick", &usbhost_ick, CK_3430ES2PLUS | CK_AM35XX | CK_36XX),
3393 CLK("usbhs_omap", "usbhost_ick", &usbhost_ick, CK_3430ES2PLUS | CK_AM35XX | CK_36XX), 3378 CLK("usbhs_omap", "usbhost_ick", &usbhost_ick, CK_3430ES2PLUS | CK_AM35XX | CK_36XX),
3394 CLK("usbhs_omap", "utmi_p1_gfclk", &dummy_ck, CK_3XXX), 3379 CLK(NULL, "utmi_p1_gfclk", &dummy_ck, CK_3XXX),
3395 CLK("usbhs_omap", "utmi_p2_gfclk", &dummy_ck, CK_3XXX), 3380 CLK(NULL, "utmi_p2_gfclk", &dummy_ck, CK_3XXX),
3396 CLK("usbhs_omap", "xclk60mhsp1_ck", &dummy_ck, CK_3XXX), 3381 CLK(NULL, "xclk60mhsp1_ck", &dummy_ck, CK_3XXX),
3397 CLK("usbhs_omap", "xclk60mhsp2_ck", &dummy_ck, CK_3XXX), 3382 CLK(NULL, "xclk60mhsp2_ck", &dummy_ck, CK_3XXX),
3398 CLK("usbhs_omap", "usb_host_hs_utmi_p1_clk", &dummy_ck, CK_3XXX), 3383 CLK(NULL, "usb_host_hs_utmi_p1_clk", &dummy_ck, CK_3XXX),
3399 CLK("usbhs_omap", "usb_host_hs_utmi_p2_clk", &dummy_ck, CK_3XXX), 3384 CLK(NULL, "usb_host_hs_utmi_p2_clk", &dummy_ck, CK_3XXX),
3400 CLK("usbhs_omap", "usb_tll_hs_usb_ch0_clk", &dummy_ck, CK_3XXX), 3385 CLK("usbhs_omap", "usb_tll_hs_usb_ch0_clk", &dummy_ck, CK_3XXX),
3401 CLK("usbhs_omap", "usb_tll_hs_usb_ch1_clk", &dummy_ck, CK_3XXX), 3386 CLK("usbhs_omap", "usb_tll_hs_usb_ch1_clk", &dummy_ck, CK_3XXX),
3402 CLK("usbhs_omap", "init_60m_fclk", &dummy_ck, CK_3XXX), 3387 CLK(NULL, "init_60m_fclk", &dummy_ck, CK_3XXX),
3403 CLK(NULL, "usim_fck", &usim_fck, CK_3430ES2PLUS | CK_36XX), 3388 CLK(NULL, "usim_fck", &usim_fck, CK_3430ES2PLUS | CK_36XX),
3404 CLK(NULL, "gpt1_fck", &gpt1_fck, CK_3XXX), 3389 CLK(NULL, "gpt1_fck", &gpt1_fck, CK_3XXX),
3405 CLK(NULL, "wkup_32k_fck", &wkup_32k_fck, CK_3XXX), 3390 CLK(NULL, "wkup_32k_fck", &wkup_32k_fck, CK_3XXX),
@@ -3413,9 +3398,6 @@ static struct omap_clk omap3xxx_clks[] = {
3413 CLK(NULL, "omap_32ksync_ick", &omap_32ksync_ick, CK_3XXX), 3398 CLK(NULL, "omap_32ksync_ick", &omap_32ksync_ick, CK_3XXX),
3414 CLK(NULL, "gpt12_ick", &gpt12_ick, CK_3XXX), 3399 CLK(NULL, "gpt12_ick", &gpt12_ick, CK_3XXX),
3415 CLK(NULL, "gpt1_ick", &gpt1_ick, CK_3XXX), 3400 CLK(NULL, "gpt1_ick", &gpt1_ick, CK_3XXX),
3416 CLK("omap-mcbsp.2", "prcm_fck", &per_96m_fck, CK_3XXX),
3417 CLK("omap-mcbsp.3", "prcm_fck", &per_96m_fck, CK_3XXX),
3418 CLK("omap-mcbsp.4", "prcm_fck", &per_96m_fck, CK_3XXX),
3419 CLK(NULL, "per_96m_fck", &per_96m_fck, CK_3XXX), 3401 CLK(NULL, "per_96m_fck", &per_96m_fck, CK_3XXX),
3420 CLK(NULL, "per_48m_fck", &per_48m_fck, CK_3XXX), 3402 CLK(NULL, "per_48m_fck", &per_48m_fck, CK_3XXX),
3421 CLK(NULL, "uart3_fck", &uart3_fck, CK_3XXX), 3403 CLK(NULL, "uart3_fck", &uart3_fck, CK_3XXX),
@@ -3474,38 +3456,16 @@ static struct omap_clk omap3xxx_clks[] = {
3474 CLK(NULL, "ipss_ick", &ipss_ick, CK_AM35XX), 3456 CLK(NULL, "ipss_ick", &ipss_ick, CK_AM35XX),
3475 CLK(NULL, "rmii_ck", &rmii_ck, CK_AM35XX), 3457 CLK(NULL, "rmii_ck", &rmii_ck, CK_AM35XX),
3476 CLK(NULL, "pclk_ck", &pclk_ck, CK_AM35XX), 3458 CLK(NULL, "pclk_ck", &pclk_ck, CK_AM35XX),
3477 CLK("davinci_emac", NULL, &emac_ick, CK_AM35XX), 3459 CLK("davinci_emac.0", NULL, &emac_ick, CK_AM35XX),
3478 CLK("davinci_mdio.0", NULL, &emac_fck, CK_AM35XX), 3460 CLK("davinci_mdio.0", NULL, &emac_fck, CK_AM35XX),
3479 CLK("vpfe-capture", "master", &vpfe_ick, CK_AM35XX), 3461 CLK("vpfe-capture", "master", &vpfe_ick, CK_AM35XX),
3480 CLK("vpfe-capture", "slave", &vpfe_fck, CK_AM35XX), 3462 CLK("vpfe-capture", "slave", &vpfe_fck, CK_AM35XX),
3481 CLK("musb-am35x", "ick", &hsotgusb_ick_am35xx, CK_AM35XX), 3463 CLK(NULL, "hsotgusb_ick", &hsotgusb_ick_am35xx, CK_AM35XX),
3482 CLK("musb-am35x", "fck", &hsotgusb_fck_am35xx, CK_AM35XX), 3464 CLK(NULL, "hsotgusb_fck", &hsotgusb_fck_am35xx, CK_AM35XX),
3483 CLK(NULL, "hecc_ck", &hecc_ck, CK_AM35XX), 3465 CLK(NULL, "hecc_ck", &hecc_ck, CK_AM35XX),
3484 CLK(NULL, "uart4_ick", &uart4_ick_am35xx, CK_AM35XX), 3466 CLK(NULL, "uart4_ick", &uart4_ick_am35xx, CK_AM35XX),
3485 CLK("omap_timer.1", "32k_ck", &omap_32k_fck, CK_3XXX), 3467 CLK(NULL, "timer_32k_ck", &omap_32k_fck, CK_3XXX),
3486 CLK("omap_timer.2", "32k_ck", &omap_32k_fck, CK_3XXX), 3468 CLK(NULL, "timer_sys_ck", &sys_ck, CK_3XXX),
3487 CLK("omap_timer.3", "32k_ck", &omap_32k_fck, CK_3XXX),
3488 CLK("omap_timer.4", "32k_ck", &omap_32k_fck, CK_3XXX),
3489 CLK("omap_timer.5", "32k_ck", &omap_32k_fck, CK_3XXX),
3490 CLK("omap_timer.6", "32k_ck", &omap_32k_fck, CK_3XXX),
3491 CLK("omap_timer.7", "32k_ck", &omap_32k_fck, CK_3XXX),
3492 CLK("omap_timer.8", "32k_ck", &omap_32k_fck, CK_3XXX),
3493 CLK("omap_timer.9", "32k_ck", &omap_32k_fck, CK_3XXX),
3494 CLK("omap_timer.10", "32k_ck", &omap_32k_fck, CK_3XXX),
3495 CLK("omap_timer.11", "32k_ck", &omap_32k_fck, CK_3XXX),
3496 CLK("omap_timer.12", "32k_ck", &omap_32k_fck, CK_3XXX),
3497 CLK("omap_timer.1", "sys_ck", &sys_ck, CK_3XXX),
3498 CLK("omap_timer.2", "sys_ck", &sys_ck, CK_3XXX),
3499 CLK("omap_timer.3", "sys_ck", &sys_ck, CK_3XXX),
3500 CLK("omap_timer.4", "sys_ck", &sys_ck, CK_3XXX),
3501 CLK("omap_timer.5", "sys_ck", &sys_ck, CK_3XXX),
3502 CLK("omap_timer.6", "sys_ck", &sys_ck, CK_3XXX),
3503 CLK("omap_timer.7", "sys_ck", &sys_ck, CK_3XXX),
3504 CLK("omap_timer.8", "sys_ck", &sys_ck, CK_3XXX),
3505 CLK("omap_timer.9", "sys_ck", &sys_ck, CK_3XXX),
3506 CLK("omap_timer.10", "sys_ck", &sys_ck, CK_3XXX),
3507 CLK("omap_timer.11", "sys_ck", &sys_ck, CK_3XXX),
3508 CLK("omap_timer.12", "sys_ck", &sys_ck, CK_3XXX),
3509}; 3469};
3510 3470
3511 3471
@@ -3523,7 +3483,7 @@ int __init omap3xxx_clk_init(void)
3523 } else if (cpu_is_ti816x()) { 3483 } else if (cpu_is_ti816x()) {
3524 cpu_mask = RATE_IN_TI816X; 3484 cpu_mask = RATE_IN_TI816X;
3525 cpu_clkflg = CK_TI816X; 3485 cpu_clkflg = CK_TI816X;
3526 } else if (cpu_is_am33xx()) { 3486 } else if (soc_is_am33xx()) {
3527 cpu_mask = RATE_IN_AM33XX; 3487 cpu_mask = RATE_IN_AM33XX;
3528 } else if (cpu_is_ti814x()) { 3488 } else if (cpu_is_ti814x()) {
3529 cpu_mask = RATE_IN_TI814X; 3489 cpu_mask = RATE_IN_TI814X;
diff --git a/arch/arm/mach-omap2/clock44xx_data.c b/arch/arm/mach-omap2/clock44xx_data.c
index ba6f9a0a43e..d7f55e43b76 100644
--- a/arch/arm/mach-omap2/clock44xx_data.c
+++ b/arch/arm/mach-omap2/clock44xx_data.c
@@ -107,18 +107,6 @@ static struct clk virt_16800000_ck = {
107 .rate = 16800000, 107 .rate = 16800000,
108}; 108};
109 109
110static struct clk virt_19200000_ck = {
111 .name = "virt_19200000_ck",
112 .ops = &clkops_null,
113 .rate = 19200000,
114};
115
116static struct clk virt_26000000_ck = {
117 .name = "virt_26000000_ck",
118 .ops = &clkops_null,
119 .rate = 26000000,
120};
121
122static struct clk virt_27000000_ck = { 110static struct clk virt_27000000_ck = {
123 .name = "virt_27000000_ck", 111 .name = "virt_27000000_ck",
124 .ops = &clkops_null, 112 .ops = &clkops_null,
@@ -131,31 +119,6 @@ static struct clk virt_38400000_ck = {
131 .rate = 38400000, 119 .rate = 38400000,
132}; 120};
133 121
134static const struct clksel_rate div_1_0_rates[] = {
135 { .div = 1, .val = 0, .flags = RATE_IN_4430 },
136 { .div = 0 },
137};
138
139static const struct clksel_rate div_1_1_rates[] = {
140 { .div = 1, .val = 1, .flags = RATE_IN_4430 },
141 { .div = 0 },
142};
143
144static const struct clksel_rate div_1_2_rates[] = {
145 { .div = 1, .val = 2, .flags = RATE_IN_4430 },
146 { .div = 0 },
147};
148
149static const struct clksel_rate div_1_3_rates[] = {
150 { .div = 1, .val = 3, .flags = RATE_IN_4430 },
151 { .div = 0 },
152};
153
154static const struct clksel_rate div_1_4_rates[] = {
155 { .div = 1, .val = 4, .flags = RATE_IN_4430 },
156 { .div = 0 },
157};
158
159static const struct clksel_rate div_1_5_rates[] = { 122static const struct clksel_rate div_1_5_rates[] = {
160 { .div = 1, .val = 5, .flags = RATE_IN_4430 }, 123 { .div = 1, .val = 5, .flags = RATE_IN_4430 },
161 { .div = 0 }, 124 { .div = 0 },
@@ -289,41 +252,6 @@ static struct clk dpll_abe_x2_ck = {
289 .recalc = &omap3_clkoutx2_recalc, 252 .recalc = &omap3_clkoutx2_recalc,
290}; 253};
291 254
292static const struct clksel_rate div31_1to31_rates[] = {
293 { .div = 1, .val = 1, .flags = RATE_IN_4430 },
294 { .div = 2, .val = 2, .flags = RATE_IN_4430 },
295 { .div = 3, .val = 3, .flags = RATE_IN_4430 },
296 { .div = 4, .val = 4, .flags = RATE_IN_4430 },
297 { .div = 5, .val = 5, .flags = RATE_IN_4430 },
298 { .div = 6, .val = 6, .flags = RATE_IN_4430 },
299 { .div = 7, .val = 7, .flags = RATE_IN_4430 },
300 { .div = 8, .val = 8, .flags = RATE_IN_4430 },
301 { .div = 9, .val = 9, .flags = RATE_IN_4430 },
302 { .div = 10, .val = 10, .flags = RATE_IN_4430 },
303 { .div = 11, .val = 11, .flags = RATE_IN_4430 },
304 { .div = 12, .val = 12, .flags = RATE_IN_4430 },
305 { .div = 13, .val = 13, .flags = RATE_IN_4430 },
306 { .div = 14, .val = 14, .flags = RATE_IN_4430 },
307 { .div = 15, .val = 15, .flags = RATE_IN_4430 },
308 { .div = 16, .val = 16, .flags = RATE_IN_4430 },
309 { .div = 17, .val = 17, .flags = RATE_IN_4430 },
310 { .div = 18, .val = 18, .flags = RATE_IN_4430 },
311 { .div = 19, .val = 19, .flags = RATE_IN_4430 },
312 { .div = 20, .val = 20, .flags = RATE_IN_4430 },
313 { .div = 21, .val = 21, .flags = RATE_IN_4430 },
314 { .div = 22, .val = 22, .flags = RATE_IN_4430 },
315 { .div = 23, .val = 23, .flags = RATE_IN_4430 },
316 { .div = 24, .val = 24, .flags = RATE_IN_4430 },
317 { .div = 25, .val = 25, .flags = RATE_IN_4430 },
318 { .div = 26, .val = 26, .flags = RATE_IN_4430 },
319 { .div = 27, .val = 27, .flags = RATE_IN_4430 },
320 { .div = 28, .val = 28, .flags = RATE_IN_4430 },
321 { .div = 29, .val = 29, .flags = RATE_IN_4430 },
322 { .div = 30, .val = 30, .flags = RATE_IN_4430 },
323 { .div = 31, .val = 31, .flags = RATE_IN_4430 },
324 { .div = 0 },
325};
326
327static const struct clksel dpll_abe_m2x2_div[] = { 255static const struct clksel dpll_abe_m2x2_div[] = {
328 { .parent = &dpll_abe_x2_ck, .rates = div31_1to31_rates }, 256 { .parent = &dpll_abe_x2_ck, .rates = div31_1to31_rates },
329 { .parent = NULL }, 257 { .parent = NULL },
@@ -3299,17 +3227,17 @@ static struct omap_clk omap44xx_clks[] = {
3299 CLK(NULL, "smartreflex_core_fck", &smartreflex_core_fck, CK_443X), 3227 CLK(NULL, "smartreflex_core_fck", &smartreflex_core_fck, CK_443X),
3300 CLK(NULL, "smartreflex_iva_fck", &smartreflex_iva_fck, CK_443X), 3228 CLK(NULL, "smartreflex_iva_fck", &smartreflex_iva_fck, CK_443X),
3301 CLK(NULL, "smartreflex_mpu_fck", &smartreflex_mpu_fck, CK_443X), 3229 CLK(NULL, "smartreflex_mpu_fck", &smartreflex_mpu_fck, CK_443X),
3302 CLK(NULL, "gpt1_fck", &timer1_fck, CK_443X), 3230 CLK(NULL, "timer1_fck", &timer1_fck, CK_443X),
3303 CLK(NULL, "gpt10_fck", &timer10_fck, CK_443X), 3231 CLK(NULL, "timer10_fck", &timer10_fck, CK_443X),
3304 CLK(NULL, "gpt11_fck", &timer11_fck, CK_443X), 3232 CLK(NULL, "timer11_fck", &timer11_fck, CK_443X),
3305 CLK(NULL, "gpt2_fck", &timer2_fck, CK_443X), 3233 CLK(NULL, "timer2_fck", &timer2_fck, CK_443X),
3306 CLK(NULL, "gpt3_fck", &timer3_fck, CK_443X), 3234 CLK(NULL, "timer3_fck", &timer3_fck, CK_443X),
3307 CLK(NULL, "gpt4_fck", &timer4_fck, CK_443X), 3235 CLK(NULL, "timer4_fck", &timer4_fck, CK_443X),
3308 CLK(NULL, "gpt5_fck", &timer5_fck, CK_443X), 3236 CLK(NULL, "timer5_fck", &timer5_fck, CK_443X),
3309 CLK(NULL, "gpt6_fck", &timer6_fck, CK_443X), 3237 CLK(NULL, "timer6_fck", &timer6_fck, CK_443X),
3310 CLK(NULL, "gpt7_fck", &timer7_fck, CK_443X), 3238 CLK(NULL, "timer7_fck", &timer7_fck, CK_443X),
3311 CLK(NULL, "gpt8_fck", &timer8_fck, CK_443X), 3239 CLK(NULL, "timer8_fck", &timer8_fck, CK_443X),
3312 CLK(NULL, "gpt9_fck", &timer9_fck, CK_443X), 3240 CLK(NULL, "timer9_fck", &timer9_fck, CK_443X),
3313 CLK(NULL, "uart1_fck", &uart1_fck, CK_443X), 3241 CLK(NULL, "uart1_fck", &uart1_fck, CK_443X),
3314 CLK(NULL, "uart2_fck", &uart2_fck, CK_443X), 3242 CLK(NULL, "uart2_fck", &uart2_fck, CK_443X),
3315 CLK(NULL, "uart3_fck", &uart3_fck, CK_443X), 3243 CLK(NULL, "uart3_fck", &uart3_fck, CK_443X),
@@ -3385,28 +3313,18 @@ static struct omap_clk omap44xx_clks[] = {
3385 CLK("usbhs_omap", "usbhost_ick", &dummy_ck, CK_443X), 3313 CLK("usbhs_omap", "usbhost_ick", &dummy_ck, CK_443X),
3386 CLK("usbhs_omap", "usbtll_fck", &dummy_ck, CK_443X), 3314 CLK("usbhs_omap", "usbtll_fck", &dummy_ck, CK_443X),
3387 CLK("omap_wdt", "ick", &dummy_ck, CK_443X), 3315 CLK("omap_wdt", "ick", &dummy_ck, CK_443X),
3388 CLK("omap_timer.1", "32k_ck", &sys_32k_ck, CK_443X), 3316 CLK(NULL, "timer_32k_ck", &sys_32k_ck, CK_443X),
3389 CLK("omap_timer.2", "32k_ck", &sys_32k_ck, CK_443X), 3317 CLK("omap_timer.1", "timer_sys_ck", &sys_clkin_ck, CK_443X),
3390 CLK("omap_timer.3", "32k_ck", &sys_32k_ck, CK_443X), 3318 CLK("omap_timer.2", "timer_sys_ck", &sys_clkin_ck, CK_443X),
3391 CLK("omap_timer.4", "32k_ck", &sys_32k_ck, CK_443X), 3319 CLK("omap_timer.3", "timer_sys_ck", &sys_clkin_ck, CK_443X),
3392 CLK("omap_timer.5", "32k_ck", &sys_32k_ck, CK_443X), 3320 CLK("omap_timer.4", "timer_sys_ck", &sys_clkin_ck, CK_443X),
3393 CLK("omap_timer.6", "32k_ck", &sys_32k_ck, CK_443X), 3321 CLK("omap_timer.9", "timer_sys_ck", &sys_clkin_ck, CK_443X),
3394 CLK("omap_timer.7", "32k_ck", &sys_32k_ck, CK_443X), 3322 CLK("omap_timer.10", "timer_sys_ck", &sys_clkin_ck, CK_443X),
3395 CLK("omap_timer.8", "32k_ck", &sys_32k_ck, CK_443X), 3323 CLK("omap_timer.11", "timer_sys_ck", &sys_clkin_ck, CK_443X),
3396 CLK("omap_timer.9", "32k_ck", &sys_32k_ck, CK_443X), 3324 CLK("omap_timer.5", "timer_sys_ck", &syc_clk_div_ck, CK_443X),
3397 CLK("omap_timer.10", "32k_ck", &sys_32k_ck, CK_443X), 3325 CLK("omap_timer.6", "timer_sys_ck", &syc_clk_div_ck, CK_443X),
3398 CLK("omap_timer.11", "32k_ck", &sys_32k_ck, CK_443X), 3326 CLK("omap_timer.7", "timer_sys_ck", &syc_clk_div_ck, CK_443X),
3399 CLK("omap_timer.1", "sys_ck", &sys_clkin_ck, CK_443X), 3327 CLK("omap_timer.8", "timer_sys_ck", &syc_clk_div_ck, CK_443X),
3400 CLK("omap_timer.2", "sys_ck", &sys_clkin_ck, CK_443X),
3401 CLK("omap_timer.3", "sys_ck", &sys_clkin_ck, CK_443X),
3402 CLK("omap_timer.4", "sys_ck", &sys_clkin_ck, CK_443X),
3403 CLK("omap_timer.9", "sys_ck", &sys_clkin_ck, CK_443X),
3404 CLK("omap_timer.10", "sys_ck", &sys_clkin_ck, CK_443X),
3405 CLK("omap_timer.11", "sys_ck", &sys_clkin_ck, CK_443X),
3406 CLK("omap_timer.5", "sys_ck", &syc_clk_div_ck, CK_443X),
3407 CLK("omap_timer.6", "sys_ck", &syc_clk_div_ck, CK_443X),
3408 CLK("omap_timer.7", "sys_ck", &syc_clk_div_ck, CK_443X),
3409 CLK("omap_timer.8", "sys_ck", &syc_clk_div_ck, CK_443X),
3410}; 3328};
3411 3329
3412int __init omap4xxx_clk_init(void) 3330int __init omap4xxx_clk_init(void)
diff --git a/arch/arm/mach-omap2/clock_common_data.c b/arch/arm/mach-omap2/clock_common_data.c
index 6424d46be14..b9f3ba68148 100644
--- a/arch/arm/mach-omap2/clock_common_data.c
+++ b/arch/arm/mach-omap2/clock_common_data.c
@@ -43,3 +43,80 @@ const struct clksel_rate dsp_ick_rates[] = {
43 { .div = 3, .val = 3, .flags = RATE_IN_243X }, 43 { .div = 3, .val = 3, .flags = RATE_IN_243X },
44 { .div = 0 }, 44 { .div = 0 },
45}; 45};
46
47
48/* clksel_rate blocks shared between OMAP44xx and AM33xx */
49
50const struct clksel_rate div_1_0_rates[] = {
51 { .div = 1, .val = 0, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
52 { .div = 0 },
53};
54
55const struct clksel_rate div_1_1_rates[] = {
56 { .div = 1, .val = 1, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
57 { .div = 0 },
58};
59
60const struct clksel_rate div_1_2_rates[] = {
61 { .div = 1, .val = 2, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
62 { .div = 0 },
63};
64
65const struct clksel_rate div_1_3_rates[] = {
66 { .div = 1, .val = 3, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
67 { .div = 0 },
68};
69
70const struct clksel_rate div_1_4_rates[] = {
71 { .div = 1, .val = 4, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
72 { .div = 0 },
73};
74
75const struct clksel_rate div31_1to31_rates[] = {
76 { .div = 1, .val = 1, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
77 { .div = 2, .val = 2, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
78 { .div = 3, .val = 3, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
79 { .div = 4, .val = 4, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
80 { .div = 5, .val = 5, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
81 { .div = 6, .val = 6, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
82 { .div = 7, .val = 7, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
83 { .div = 8, .val = 8, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
84 { .div = 9, .val = 9, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
85 { .div = 10, .val = 10, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
86 { .div = 11, .val = 11, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
87 { .div = 12, .val = 12, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
88 { .div = 13, .val = 13, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
89 { .div = 14, .val = 14, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
90 { .div = 15, .val = 15, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
91 { .div = 16, .val = 16, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
92 { .div = 17, .val = 17, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
93 { .div = 18, .val = 18, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
94 { .div = 19, .val = 19, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
95 { .div = 20, .val = 20, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
96 { .div = 21, .val = 21, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
97 { .div = 22, .val = 22, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
98 { .div = 23, .val = 23, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
99 { .div = 24, .val = 24, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
100 { .div = 25, .val = 25, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
101 { .div = 26, .val = 26, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
102 { .div = 27, .val = 27, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
103 { .div = 28, .val = 28, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
104 { .div = 29, .val = 29, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
105 { .div = 30, .val = 30, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
106 { .div = 31, .val = 31, .flags = RATE_IN_4430 | RATE_IN_AM33XX },
107 { .div = 0 },
108};
109
110/* Clocks shared between various OMAP SoCs */
111
112struct clk virt_19200000_ck = {
113 .name = "virt_19200000_ck",
114 .ops = &clkops_null,
115 .rate = 19200000,
116};
117
118struct clk virt_26000000_ck = {
119 .name = "virt_26000000_ck",
120 .ops = &clkops_null,
121 .rate = 26000000,
122};
diff --git a/arch/arm/mach-omap2/clockdomain.h b/arch/arm/mach-omap2/clockdomain.h
index 6227e9505c2..5601dc13785 100644
--- a/arch/arm/mach-omap2/clockdomain.h
+++ b/arch/arm/mach-omap2/clockdomain.h
@@ -199,6 +199,7 @@ int clkdm_hwmod_disable(struct clockdomain *clkdm, struct omap_hwmod *oh);
199extern void __init omap242x_clockdomains_init(void); 199extern void __init omap242x_clockdomains_init(void);
200extern void __init omap243x_clockdomains_init(void); 200extern void __init omap243x_clockdomains_init(void);
201extern void __init omap3xxx_clockdomains_init(void); 201extern void __init omap3xxx_clockdomains_init(void);
202extern void __init am33xx_clockdomains_init(void);
202extern void __init omap44xx_clockdomains_init(void); 203extern void __init omap44xx_clockdomains_init(void);
203extern void _clkdm_add_autodeps(struct clockdomain *clkdm); 204extern void _clkdm_add_autodeps(struct clockdomain *clkdm);
204extern void _clkdm_del_autodeps(struct clockdomain *clkdm); 205extern void _clkdm_del_autodeps(struct clockdomain *clkdm);
@@ -206,11 +207,10 @@ extern void _clkdm_del_autodeps(struct clockdomain *clkdm);
206extern struct clkdm_ops omap2_clkdm_operations; 207extern struct clkdm_ops omap2_clkdm_operations;
207extern struct clkdm_ops omap3_clkdm_operations; 208extern struct clkdm_ops omap3_clkdm_operations;
208extern struct clkdm_ops omap4_clkdm_operations; 209extern struct clkdm_ops omap4_clkdm_operations;
210extern struct clkdm_ops am33xx_clkdm_operations;
209 211
210extern struct clkdm_dep gfx_24xx_wkdeps[]; 212extern struct clkdm_dep gfx_24xx_wkdeps[];
211extern struct clkdm_dep dsp_24xx_wkdeps[]; 213extern struct clkdm_dep dsp_24xx_wkdeps[];
212extern struct clockdomain wkup_common_clkdm; 214extern struct clockdomain wkup_common_clkdm;
213extern struct clockdomain prm_common_clkdm;
214extern struct clockdomain cm_common_clkdm;
215 215
216#endif 216#endif
diff --git a/arch/arm/mach-omap2/clockdomain33xx.c b/arch/arm/mach-omap2/clockdomain33xx.c
new file mode 100644
index 00000000000..aca6388fad7
--- /dev/null
+++ b/arch/arm/mach-omap2/clockdomain33xx.c
@@ -0,0 +1,74 @@
1/*
2 * AM33XX clockdomain control
3 *
4 * Copyright (C) 2011-2012 Texas Instruments Incorporated - http://www.ti.com/
5 * Vaibhav Hiremath <hvaibhav@ti.com>
6 *
7 * Derived from mach-omap2/clockdomain44xx.c written by Rajendra Nayak
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 as
11 * published by the Free Software Foundation version 2.
12 *
13 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
14 * kind, whether express or implied; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#include <linux/kernel.h>
20
21#include "clockdomain.h"
22#include "cm33xx.h"
23
24
25static int am33xx_clkdm_sleep(struct clockdomain *clkdm)
26{
27 am33xx_cm_clkdm_force_sleep(clkdm->cm_inst, clkdm->clkdm_offs);
28 return 0;
29}
30
31static int am33xx_clkdm_wakeup(struct clockdomain *clkdm)
32{
33 am33xx_cm_clkdm_force_wakeup(clkdm->cm_inst, clkdm->clkdm_offs);
34 return 0;
35}
36
37static void am33xx_clkdm_allow_idle(struct clockdomain *clkdm)
38{
39 am33xx_cm_clkdm_enable_hwsup(clkdm->cm_inst, clkdm->clkdm_offs);
40}
41
42static void am33xx_clkdm_deny_idle(struct clockdomain *clkdm)
43{
44 am33xx_cm_clkdm_disable_hwsup(clkdm->cm_inst, clkdm->clkdm_offs);
45}
46
47static int am33xx_clkdm_clk_enable(struct clockdomain *clkdm)
48{
49 if (clkdm->flags & CLKDM_CAN_FORCE_WAKEUP)
50 return am33xx_clkdm_wakeup(clkdm);
51
52 return 0;
53}
54
55static int am33xx_clkdm_clk_disable(struct clockdomain *clkdm)
56{
57 bool hwsup = false;
58
59 hwsup = am33xx_cm_is_clkdm_in_hwsup(clkdm->cm_inst, clkdm->clkdm_offs);
60
61 if (!hwsup && (clkdm->flags & CLKDM_CAN_FORCE_SLEEP))
62 am33xx_clkdm_sleep(clkdm);
63
64 return 0;
65}
66
67struct clkdm_ops am33xx_clkdm_operations = {
68 .clkdm_sleep = am33xx_clkdm_sleep,
69 .clkdm_wakeup = am33xx_clkdm_wakeup,
70 .clkdm_allow_idle = am33xx_clkdm_allow_idle,
71 .clkdm_deny_idle = am33xx_clkdm_deny_idle,
72 .clkdm_clk_enable = am33xx_clkdm_clk_enable,
73 .clkdm_clk_disable = am33xx_clkdm_clk_disable,
74};
diff --git a/arch/arm/mach-omap2/clockdomain44xx.c b/arch/arm/mach-omap2/clockdomain44xx.c
index 4f04dd11d65..762f2cc542c 100644
--- a/arch/arm/mach-omap2/clockdomain44xx.c
+++ b/arch/arm/mach-omap2/clockdomain44xx.c
@@ -70,7 +70,7 @@ static int omap4_clkdm_clear_all_wkup_sleep_deps(struct clockdomain *clkdm)
70 70
71static int omap4_clkdm_sleep(struct clockdomain *clkdm) 71static int omap4_clkdm_sleep(struct clockdomain *clkdm)
72{ 72{
73 omap4_cminst_clkdm_force_sleep(clkdm->prcm_partition, 73 omap4_cminst_clkdm_enable_hwsup(clkdm->prcm_partition,
74 clkdm->cm_inst, clkdm->clkdm_offs); 74 clkdm->cm_inst, clkdm->clkdm_offs);
75 return 0; 75 return 0;
76} 76}
@@ -90,8 +90,12 @@ static void omap4_clkdm_allow_idle(struct clockdomain *clkdm)
90 90
91static void omap4_clkdm_deny_idle(struct clockdomain *clkdm) 91static void omap4_clkdm_deny_idle(struct clockdomain *clkdm)
92{ 92{
93 omap4_cminst_clkdm_disable_hwsup(clkdm->prcm_partition, 93 if (clkdm->flags & CLKDM_CAN_FORCE_WAKEUP)
94 clkdm->cm_inst, clkdm->clkdm_offs); 94 omap4_clkdm_wakeup(clkdm);
95 else
96 omap4_cminst_clkdm_disable_hwsup(clkdm->prcm_partition,
97 clkdm->cm_inst,
98 clkdm->clkdm_offs);
95} 99}
96 100
97static int omap4_clkdm_clk_enable(struct clockdomain *clkdm) 101static int omap4_clkdm_clk_enable(struct clockdomain *clkdm)
diff --git a/arch/arm/mach-omap2/clockdomains2420_data.c b/arch/arm/mach-omap2/clockdomains2420_data.c
index 0ab8e46d5b2..5c741852fac 100644
--- a/arch/arm/mach-omap2/clockdomains2420_data.c
+++ b/arch/arm/mach-omap2/clockdomains2420_data.c
@@ -131,8 +131,6 @@ static struct clockdomain dss_2420_clkdm = {
131 131
132static struct clockdomain *clockdomains_omap242x[] __initdata = { 132static struct clockdomain *clockdomains_omap242x[] __initdata = {
133 &wkup_common_clkdm, 133 &wkup_common_clkdm,
134 &cm_common_clkdm,
135 &prm_common_clkdm,
136 &mpu_2420_clkdm, 134 &mpu_2420_clkdm,
137 &iva1_2420_clkdm, 135 &iva1_2420_clkdm,
138 &dsp_2420_clkdm, 136 &dsp_2420_clkdm,
diff --git a/arch/arm/mach-omap2/clockdomains2430_data.c b/arch/arm/mach-omap2/clockdomains2430_data.c
index 3645ed04489..f09617555e1 100644
--- a/arch/arm/mach-omap2/clockdomains2430_data.c
+++ b/arch/arm/mach-omap2/clockdomains2430_data.c
@@ -157,8 +157,6 @@ static struct clockdomain dss_2430_clkdm = {
157 157
158static struct clockdomain *clockdomains_omap243x[] __initdata = { 158static struct clockdomain *clockdomains_omap243x[] __initdata = {
159 &wkup_common_clkdm, 159 &wkup_common_clkdm,
160 &cm_common_clkdm,
161 &prm_common_clkdm,
162 &mpu_2430_clkdm, 160 &mpu_2430_clkdm,
163 &mdm_clkdm, 161 &mdm_clkdm,
164 &dsp_2430_clkdm, 162 &dsp_2430_clkdm,
diff --git a/arch/arm/mach-omap2/clockdomains33xx_data.c b/arch/arm/mach-omap2/clockdomains33xx_data.c
new file mode 100644
index 00000000000..32c90fd9eba
--- /dev/null
+++ b/arch/arm/mach-omap2/clockdomains33xx_data.c
@@ -0,0 +1,196 @@
1/*
2 * AM33XX Clock Domain data.
3 *
4 * Copyright (C) 2011-2012 Texas Instruments Incorporated - http://www.ti.com/
5 * Vaibhav Hiremath <hvaibhav@ti.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation version 2.
10 *
11 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
12 * kind, whether express or implied; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <linux/kernel.h>
18#include <linux/io.h>
19
20#include "clockdomain.h"
21#include "cm.h"
22#include "cm33xx.h"
23#include "cm-regbits-33xx.h"
24
25static struct clockdomain l4ls_am33xx_clkdm = {
26 .name = "l4ls_clkdm",
27 .pwrdm = { .name = "per_pwrdm" },
28 .cm_inst = AM33XX_CM_PER_MOD,
29 .clkdm_offs = AM33XX_CM_PER_L4LS_CLKSTCTRL_OFFSET,
30 .flags = CLKDM_CAN_SWSUP,
31};
32
33static struct clockdomain l3s_am33xx_clkdm = {
34 .name = "l3s_clkdm",
35 .pwrdm = { .name = "per_pwrdm" },
36 .cm_inst = AM33XX_CM_PER_MOD,
37 .clkdm_offs = AM33XX_CM_PER_L3S_CLKSTCTRL_OFFSET,
38 .flags = CLKDM_CAN_SWSUP,
39};
40
41static struct clockdomain l4fw_am33xx_clkdm = {
42 .name = "l4fw_clkdm",
43 .pwrdm = { .name = "per_pwrdm" },
44 .cm_inst = AM33XX_CM_PER_MOD,
45 .clkdm_offs = AM33XX_CM_PER_L4FW_CLKSTCTRL_OFFSET,
46 .flags = CLKDM_CAN_SWSUP,
47};
48
49static struct clockdomain l3_am33xx_clkdm = {
50 .name = "l3_clkdm",
51 .pwrdm = { .name = "per_pwrdm" },
52 .cm_inst = AM33XX_CM_PER_MOD,
53 .clkdm_offs = AM33XX_CM_PER_L3_CLKSTCTRL_OFFSET,
54 .flags = CLKDM_CAN_SWSUP,
55};
56
57static struct clockdomain l4hs_am33xx_clkdm = {
58 .name = "l4hs_clkdm",
59 .pwrdm = { .name = "per_pwrdm" },
60 .cm_inst = AM33XX_CM_PER_MOD,
61 .clkdm_offs = AM33XX_CM_PER_L4HS_CLKSTCTRL_OFFSET,
62 .flags = CLKDM_CAN_SWSUP,
63};
64
65static struct clockdomain ocpwp_l3_am33xx_clkdm = {
66 .name = "ocpwp_l3_clkdm",
67 .pwrdm = { .name = "per_pwrdm" },
68 .cm_inst = AM33XX_CM_PER_MOD,
69 .clkdm_offs = AM33XX_CM_PER_OCPWP_L3_CLKSTCTRL_OFFSET,
70 .flags = CLKDM_CAN_SWSUP,
71};
72
73static struct clockdomain pruss_ocp_am33xx_clkdm = {
74 .name = "pruss_ocp_clkdm",
75 .pwrdm = { .name = "per_pwrdm" },
76 .cm_inst = AM33XX_CM_PER_MOD,
77 .clkdm_offs = AM33XX_CM_PER_PRUSS_CLKSTCTRL_OFFSET,
78 .flags = CLKDM_CAN_SWSUP,
79};
80
81static struct clockdomain cpsw_125mhz_am33xx_clkdm = {
82 .name = "cpsw_125mhz_clkdm",
83 .pwrdm = { .name = "per_pwrdm" },
84 .cm_inst = AM33XX_CM_PER_MOD,
85 .clkdm_offs = AM33XX_CM_PER_CPSW_CLKSTCTRL_OFFSET,
86 .flags = CLKDM_CAN_SWSUP,
87};
88
89static struct clockdomain lcdc_am33xx_clkdm = {
90 .name = "lcdc_clkdm",
91 .pwrdm = { .name = "per_pwrdm" },
92 .cm_inst = AM33XX_CM_PER_MOD,
93 .clkdm_offs = AM33XX_CM_PER_LCDC_CLKSTCTRL_OFFSET,
94 .flags = CLKDM_CAN_SWSUP,
95};
96
97static struct clockdomain clk_24mhz_am33xx_clkdm = {
98 .name = "clk_24mhz_clkdm",
99 .pwrdm = { .name = "per_pwrdm" },
100 .cm_inst = AM33XX_CM_PER_MOD,
101 .clkdm_offs = AM33XX_CM_PER_CLK_24MHZ_CLKSTCTRL_OFFSET,
102 .flags = CLKDM_CAN_SWSUP,
103};
104
105static struct clockdomain l4_wkup_am33xx_clkdm = {
106 .name = "l4_wkup_clkdm",
107 .pwrdm = { .name = "wkup_pwrdm" },
108 .cm_inst = AM33XX_CM_WKUP_MOD,
109 .clkdm_offs = AM33XX_CM_WKUP_CLKSTCTRL_OFFSET,
110 .flags = CLKDM_CAN_SWSUP,
111};
112
113static struct clockdomain l3_aon_am33xx_clkdm = {
114 .name = "l3_aon_clkdm",
115 .pwrdm = { .name = "wkup_pwrdm" },
116 .cm_inst = AM33XX_CM_WKUP_MOD,
117 .clkdm_offs = AM33XX_CM_L3_AON_CLKSTCTRL_OFFSET,
118 .flags = CLKDM_CAN_SWSUP,
119};
120
121static struct clockdomain l4_wkup_aon_am33xx_clkdm = {
122 .name = "l4_wkup_aon_clkdm",
123 .pwrdm = { .name = "wkup_pwrdm" },
124 .cm_inst = AM33XX_CM_WKUP_MOD,
125 .clkdm_offs = AM33XX_CM_L4_WKUP_AON_CLKSTCTRL_OFFSET,
126 .flags = CLKDM_CAN_SWSUP,
127};
128
129static struct clockdomain mpu_am33xx_clkdm = {
130 .name = "mpu_clkdm",
131 .pwrdm = { .name = "mpu_pwrdm" },
132 .cm_inst = AM33XX_CM_MPU_MOD,
133 .clkdm_offs = AM33XX_CM_MPU_CLKSTCTRL_OFFSET,
134 .flags = CLKDM_CAN_SWSUP,
135};
136
137static struct clockdomain l4_rtc_am33xx_clkdm = {
138 .name = "l4_rtc_clkdm",
139 .pwrdm = { .name = "rtc_pwrdm" },
140 .cm_inst = AM33XX_CM_RTC_MOD,
141 .clkdm_offs = AM33XX_CM_RTC_CLKSTCTRL_OFFSET,
142 .flags = CLKDM_CAN_SWSUP,
143};
144
145static struct clockdomain gfx_l3_am33xx_clkdm = {
146 .name = "gfx_l3_clkdm",
147 .pwrdm = { .name = "gfx_pwrdm" },
148 .cm_inst = AM33XX_CM_GFX_MOD,
149 .clkdm_offs = AM33XX_CM_GFX_L3_CLKSTCTRL_OFFSET,
150 .flags = CLKDM_CAN_SWSUP,
151};
152
153static struct clockdomain gfx_l4ls_gfx_am33xx_clkdm = {
154 .name = "gfx_l4ls_gfx_clkdm",
155 .pwrdm = { .name = "gfx_pwrdm" },
156 .cm_inst = AM33XX_CM_GFX_MOD,
157 .clkdm_offs = AM33XX_CM_GFX_L4LS_GFX_CLKSTCTRL__1_OFFSET,
158 .flags = CLKDM_CAN_SWSUP,
159};
160
161static struct clockdomain l4_cefuse_am33xx_clkdm = {
162 .name = "l4_cefuse_clkdm",
163 .pwrdm = { .name = "cefuse_pwrdm" },
164 .cm_inst = AM33XX_CM_CEFUSE_MOD,
165 .clkdm_offs = AM33XX_CM_CEFUSE_CLKSTCTRL_OFFSET,
166 .flags = CLKDM_CAN_SWSUP,
167};
168
169static struct clockdomain *clockdomains_am33xx[] __initdata = {
170 &l4ls_am33xx_clkdm,
171 &l3s_am33xx_clkdm,
172 &l4fw_am33xx_clkdm,
173 &l3_am33xx_clkdm,
174 &l4hs_am33xx_clkdm,
175 &ocpwp_l3_am33xx_clkdm,
176 &pruss_ocp_am33xx_clkdm,
177 &cpsw_125mhz_am33xx_clkdm,
178 &lcdc_am33xx_clkdm,
179 &clk_24mhz_am33xx_clkdm,
180 &l4_wkup_am33xx_clkdm,
181 &l3_aon_am33xx_clkdm,
182 &l4_wkup_aon_am33xx_clkdm,
183 &mpu_am33xx_clkdm,
184 &l4_rtc_am33xx_clkdm,
185 &gfx_l3_am33xx_clkdm,
186 &gfx_l4ls_gfx_am33xx_clkdm,
187 &l4_cefuse_am33xx_clkdm,
188 NULL,
189};
190
191void __init am33xx_clockdomains_init(void)
192{
193 clkdm_register_platform_funcs(&am33xx_clkdm_operations);
194 clkdm_register_clkdms(clockdomains_am33xx);
195 clkdm_complete_init();
196}
diff --git a/arch/arm/mach-omap2/clockdomains3xxx_data.c b/arch/arm/mach-omap2/clockdomains3xxx_data.c
index 6038adb9771..56089c49142 100644
--- a/arch/arm/mach-omap2/clockdomains3xxx_data.c
+++ b/arch/arm/mach-omap2/clockdomains3xxx_data.c
@@ -59,6 +59,12 @@ static struct clkdm_dep gfx_sgx_3xxx_wkdeps[] = {
59 { NULL }, 59 { NULL },
60}; 60};
61 61
62static struct clkdm_dep gfx_sgx_am35x_wkdeps[] = {
63 { .clkdm_name = "mpu_clkdm" },
64 { .clkdm_name = "wkup_clkdm" },
65 { NULL },
66};
67
62/* 3430: PM_WKDEP_PER: CORE, IVA2, MPU, WKUP */ 68/* 3430: PM_WKDEP_PER: CORE, IVA2, MPU, WKUP */
63static struct clkdm_dep per_wkdeps[] = { 69static struct clkdm_dep per_wkdeps[] = {
64 { .clkdm_name = "core_l3_clkdm" }, 70 { .clkdm_name = "core_l3_clkdm" },
@@ -69,6 +75,14 @@ static struct clkdm_dep per_wkdeps[] = {
69 { NULL }, 75 { NULL },
70}; 76};
71 77
78static struct clkdm_dep per_am35x_wkdeps[] = {
79 { .clkdm_name = "core_l3_clkdm" },
80 { .clkdm_name = "core_l4_clkdm" },
81 { .clkdm_name = "mpu_clkdm" },
82 { .clkdm_name = "wkup_clkdm" },
83 { NULL },
84};
85
72/* 3430ES2: PM_WKDEP_USBHOST: CORE, IVA2, MPU, WKUP */ 86/* 3430ES2: PM_WKDEP_USBHOST: CORE, IVA2, MPU, WKUP */
73static struct clkdm_dep usbhost_wkdeps[] = { 87static struct clkdm_dep usbhost_wkdeps[] = {
74 { .clkdm_name = "core_l3_clkdm" }, 88 { .clkdm_name = "core_l3_clkdm" },
@@ -79,6 +93,14 @@ static struct clkdm_dep usbhost_wkdeps[] = {
79 { NULL }, 93 { NULL },
80}; 94};
81 95
96static struct clkdm_dep usbhost_am35x_wkdeps[] = {
97 { .clkdm_name = "core_l3_clkdm" },
98 { .clkdm_name = "core_l4_clkdm" },
99 { .clkdm_name = "mpu_clkdm" },
100 { .clkdm_name = "wkup_clkdm" },
101 { NULL },
102};
103
82/* 3430 PM_WKDEP_MPU: CORE, IVA2, DSS, PER */ 104/* 3430 PM_WKDEP_MPU: CORE, IVA2, DSS, PER */
83static struct clkdm_dep mpu_3xxx_wkdeps[] = { 105static struct clkdm_dep mpu_3xxx_wkdeps[] = {
84 { .clkdm_name = "core_l3_clkdm" }, 106 { .clkdm_name = "core_l3_clkdm" },
@@ -89,6 +111,14 @@ static struct clkdm_dep mpu_3xxx_wkdeps[] = {
89 { NULL }, 111 { NULL },
90}; 112};
91 113
114static struct clkdm_dep mpu_am35x_wkdeps[] = {
115 { .clkdm_name = "core_l3_clkdm" },
116 { .clkdm_name = "core_l4_clkdm" },
117 { .clkdm_name = "dss_clkdm" },
118 { .clkdm_name = "per_clkdm" },
119 { NULL },
120};
121
92/* 3430 PM_WKDEP_IVA2: CORE, MPU, WKUP, DSS, PER */ 122/* 3430 PM_WKDEP_IVA2: CORE, MPU, WKUP, DSS, PER */
93static struct clkdm_dep iva2_wkdeps[] = { 123static struct clkdm_dep iva2_wkdeps[] = {
94 { .clkdm_name = "core_l3_clkdm" }, 124 { .clkdm_name = "core_l3_clkdm" },
@@ -116,6 +146,12 @@ static struct clkdm_dep dss_wkdeps[] = {
116 { NULL }, 146 { NULL },
117}; 147};
118 148
149static struct clkdm_dep dss_am35x_wkdeps[] = {
150 { .clkdm_name = "mpu_clkdm" },
151 { .clkdm_name = "wkup_clkdm" },
152 { NULL },
153};
154
119/* 3430: PM_WKDEP_NEON: MPU */ 155/* 3430: PM_WKDEP_NEON: MPU */
120static struct clkdm_dep neon_wkdeps[] = { 156static struct clkdm_dep neon_wkdeps[] = {
121 { .clkdm_name = "mpu_clkdm" }, 157 { .clkdm_name = "mpu_clkdm" },
@@ -131,6 +167,11 @@ static struct clkdm_dep dss_sleepdeps[] = {
131 { NULL }, 167 { NULL },
132}; 168};
133 169
170static struct clkdm_dep dss_am35x_sleepdeps[] = {
171 { .clkdm_name = "mpu_clkdm" },
172 { NULL },
173};
174
134/* 3430: CM_SLEEPDEP_PER: MPU, IVA */ 175/* 3430: CM_SLEEPDEP_PER: MPU, IVA */
135static struct clkdm_dep per_sleepdeps[] = { 176static struct clkdm_dep per_sleepdeps[] = {
136 { .clkdm_name = "mpu_clkdm" }, 177 { .clkdm_name = "mpu_clkdm" },
@@ -138,6 +179,11 @@ static struct clkdm_dep per_sleepdeps[] = {
138 { NULL }, 179 { NULL },
139}; 180};
140 181
182static struct clkdm_dep per_am35x_sleepdeps[] = {
183 { .clkdm_name = "mpu_clkdm" },
184 { NULL },
185};
186
141/* 3430ES2: CM_SLEEPDEP_USBHOST: MPU, IVA */ 187/* 3430ES2: CM_SLEEPDEP_USBHOST: MPU, IVA */
142static struct clkdm_dep usbhost_sleepdeps[] = { 188static struct clkdm_dep usbhost_sleepdeps[] = {
143 { .clkdm_name = "mpu_clkdm" }, 189 { .clkdm_name = "mpu_clkdm" },
@@ -145,6 +191,11 @@ static struct clkdm_dep usbhost_sleepdeps[] = {
145 { NULL }, 191 { NULL },
146}; 192};
147 193
194static struct clkdm_dep usbhost_am35x_sleepdeps[] = {
195 { .clkdm_name = "mpu_clkdm" },
196 { NULL },
197};
198
148/* 3430: CM_SLEEPDEP_CAM: MPU */ 199/* 3430: CM_SLEEPDEP_CAM: MPU */
149static struct clkdm_dep cam_sleepdeps[] = { 200static struct clkdm_dep cam_sleepdeps[] = {
150 { .clkdm_name = "mpu_clkdm" }, 201 { .clkdm_name = "mpu_clkdm" },
@@ -175,6 +226,15 @@ static struct clockdomain mpu_3xxx_clkdm = {
175 .clktrctrl_mask = OMAP3430_CLKTRCTRL_MPU_MASK, 226 .clktrctrl_mask = OMAP3430_CLKTRCTRL_MPU_MASK,
176}; 227};
177 228
229static struct clockdomain mpu_am35x_clkdm = {
230 .name = "mpu_clkdm",
231 .pwrdm = { .name = "mpu_pwrdm" },
232 .flags = CLKDM_CAN_HWSUP | CLKDM_CAN_FORCE_WAKEUP,
233 .dep_bit = OMAP3430_EN_MPU_SHIFT,
234 .wkdep_srcs = mpu_am35x_wkdeps,
235 .clktrctrl_mask = OMAP3430_CLKTRCTRL_MPU_MASK,
236};
237
178static struct clockdomain neon_clkdm = { 238static struct clockdomain neon_clkdm = {
179 .name = "neon_clkdm", 239 .name = "neon_clkdm",
180 .pwrdm = { .name = "neon_pwrdm" }, 240 .pwrdm = { .name = "neon_pwrdm" },
@@ -210,6 +270,15 @@ static struct clockdomain sgx_clkdm = {
210 .clktrctrl_mask = OMAP3430ES2_CLKTRCTRL_SGX_MASK, 270 .clktrctrl_mask = OMAP3430ES2_CLKTRCTRL_SGX_MASK,
211}; 271};
212 272
273static struct clockdomain sgx_am35x_clkdm = {
274 .name = "sgx_clkdm",
275 .pwrdm = { .name = "sgx_pwrdm" },
276 .flags = CLKDM_CAN_HWSUP_SWSUP,
277 .wkdep_srcs = gfx_sgx_am35x_wkdeps,
278 .sleepdep_srcs = gfx_sgx_sleepdeps,
279 .clktrctrl_mask = OMAP3430ES2_CLKTRCTRL_SGX_MASK,
280};
281
213/* 282/*
214 * The die-to-die clockdomain was documented in the 34xx ES1 TRM, but 283 * The die-to-die clockdomain was documented in the 34xx ES1 TRM, but
215 * then that information was removed from the 34xx ES2+ TRM. It is 284 * then that information was removed from the 34xx ES2+ TRM. It is
@@ -261,6 +330,16 @@ static struct clockdomain dss_3xxx_clkdm = {
261 .clktrctrl_mask = OMAP3430_CLKTRCTRL_DSS_MASK, 330 .clktrctrl_mask = OMAP3430_CLKTRCTRL_DSS_MASK,
262}; 331};
263 332
333static struct clockdomain dss_am35x_clkdm = {
334 .name = "dss_clkdm",
335 .pwrdm = { .name = "dss_pwrdm" },
336 .flags = CLKDM_CAN_HWSUP_SWSUP,
337 .dep_bit = OMAP3430_PM_WKDEP_MPU_EN_DSS_SHIFT,
338 .wkdep_srcs = dss_am35x_wkdeps,
339 .sleepdep_srcs = dss_am35x_sleepdeps,
340 .clktrctrl_mask = OMAP3430_CLKTRCTRL_DSS_MASK,
341};
342
264static struct clockdomain cam_clkdm = { 343static struct clockdomain cam_clkdm = {
265 .name = "cam_clkdm", 344 .name = "cam_clkdm",
266 .pwrdm = { .name = "cam_pwrdm" }, 345 .pwrdm = { .name = "cam_pwrdm" },
@@ -279,6 +358,15 @@ static struct clockdomain usbhost_clkdm = {
279 .clktrctrl_mask = OMAP3430ES2_CLKTRCTRL_USBHOST_MASK, 358 .clktrctrl_mask = OMAP3430ES2_CLKTRCTRL_USBHOST_MASK,
280}; 359};
281 360
361static struct clockdomain usbhost_am35x_clkdm = {
362 .name = "usbhost_clkdm",
363 .pwrdm = { .name = "core_pwrdm" },
364 .flags = CLKDM_CAN_HWSUP_SWSUP,
365 .wkdep_srcs = usbhost_am35x_wkdeps,
366 .sleepdep_srcs = usbhost_am35x_sleepdeps,
367 .clktrctrl_mask = OMAP3430ES2_CLKTRCTRL_USBHOST_MASK,
368};
369
282static struct clockdomain per_clkdm = { 370static struct clockdomain per_clkdm = {
283 .name = "per_clkdm", 371 .name = "per_clkdm",
284 .pwrdm = { .name = "per_pwrdm" }, 372 .pwrdm = { .name = "per_pwrdm" },
@@ -289,6 +377,16 @@ static struct clockdomain per_clkdm = {
289 .clktrctrl_mask = OMAP3430_CLKTRCTRL_PER_MASK, 377 .clktrctrl_mask = OMAP3430_CLKTRCTRL_PER_MASK,
290}; 378};
291 379
380static struct clockdomain per_am35x_clkdm = {
381 .name = "per_clkdm",
382 .pwrdm = { .name = "per_pwrdm" },
383 .flags = CLKDM_CAN_HWSUP_SWSUP,
384 .dep_bit = OMAP3430_EN_PER_SHIFT,
385 .wkdep_srcs = per_am35x_wkdeps,
386 .sleepdep_srcs = per_am35x_sleepdeps,
387 .clktrctrl_mask = OMAP3430_CLKTRCTRL_PER_MASK,
388};
389
292/* 390/*
293 * Disable hw supervised mode for emu_clkdm, because emu_pwrdm is 391 * Disable hw supervised mode for emu_clkdm, because emu_pwrdm is
294 * switched of even if sdti is in use 392 * switched of even if sdti is in use
@@ -341,31 +439,42 @@ static struct clkdm_autodep clkdm_autodeps[] = {
341 } 439 }
342}; 440};
343 441
442static struct clkdm_autodep clkdm_am35x_autodeps[] = {
443 {
444 .clkdm = { .name = "mpu_clkdm" },
445 },
446 {
447 .clkdm = { .name = NULL },
448 }
449};
450
344/* 451/*
345 * 452 *
346 */ 453 */
347 454
348static struct clockdomain *clockdomains_omap3430_common[] __initdata = { 455static struct clockdomain *clockdomains_common[] __initdata = {
349 &wkup_common_clkdm, 456 &wkup_common_clkdm,
350 &cm_common_clkdm,
351 &prm_common_clkdm,
352 &mpu_3xxx_clkdm,
353 &neon_clkdm, 457 &neon_clkdm,
354 &iva2_clkdm,
355 &d2d_clkdm,
356 &core_l3_3xxx_clkdm, 458 &core_l3_3xxx_clkdm,
357 &core_l4_3xxx_clkdm, 459 &core_l4_3xxx_clkdm,
358 &dss_3xxx_clkdm,
359 &cam_clkdm,
360 &per_clkdm,
361 &emu_clkdm, 460 &emu_clkdm,
362 &dpll1_clkdm, 461 &dpll1_clkdm,
363 &dpll2_clkdm,
364 &dpll3_clkdm, 462 &dpll3_clkdm,
365 &dpll4_clkdm, 463 &dpll4_clkdm,
366 NULL 464 NULL
367}; 465};
368 466
467static struct clockdomain *clockdomains_omap3430[] __initdata = {
468 &mpu_3xxx_clkdm,
469 &iva2_clkdm,
470 &d2d_clkdm,
471 &dss_3xxx_clkdm,
472 &cam_clkdm,
473 &per_clkdm,
474 &dpll2_clkdm,
475 NULL
476};
477
369static struct clockdomain *clockdomains_omap3430es1[] __initdata = { 478static struct clockdomain *clockdomains_omap3430es1[] __initdata = {
370 &gfx_3430es1_clkdm, 479 &gfx_3430es1_clkdm,
371 NULL, 480 NULL,
@@ -378,21 +487,41 @@ static struct clockdomain *clockdomains_omap3430es2plus[] __initdata = {
378 NULL, 487 NULL,
379}; 488};
380 489
490static struct clockdomain *clockdomains_am35x[] __initdata = {
491 &mpu_am35x_clkdm,
492 &sgx_am35x_clkdm,
493 &dss_am35x_clkdm,
494 &per_am35x_clkdm,
495 &usbhost_am35x_clkdm,
496 &dpll5_clkdm,
497 NULL
498};
499
381void __init omap3xxx_clockdomains_init(void) 500void __init omap3xxx_clockdomains_init(void)
382{ 501{
383 struct clockdomain **sc; 502 struct clockdomain **sc;
503 unsigned int rev;
384 504
385 if (!cpu_is_omap34xx()) 505 if (!cpu_is_omap34xx())
386 return; 506 return;
387 507
388 clkdm_register_platform_funcs(&omap3_clkdm_operations); 508 clkdm_register_platform_funcs(&omap3_clkdm_operations);
389 clkdm_register_clkdms(clockdomains_omap3430_common); 509 clkdm_register_clkdms(clockdomains_common);
390 510
391 sc = (omap_rev() == OMAP3430_REV_ES1_0) ? clockdomains_omap3430es1 : 511 rev = omap_rev();
392 clockdomains_omap3430es2plus;
393 512
394 clkdm_register_clkdms(sc); 513 if (rev == AM35XX_REV_ES1_0 || rev == AM35XX_REV_ES1_1) {
514 clkdm_register_clkdms(clockdomains_am35x);
515 clkdm_register_autodeps(clkdm_am35x_autodeps);
516 } else {
517 clkdm_register_clkdms(clockdomains_omap3430);
518
519 sc = (rev == OMAP3430_REV_ES1_0) ?
520 clockdomains_omap3430es1 : clockdomains_omap3430es2plus;
521
522 clkdm_register_clkdms(sc);
523 clkdm_register_autodeps(clkdm_autodeps);
524 }
395 525
396 clkdm_register_autodeps(clkdm_autodeps);
397 clkdm_complete_init(); 526 clkdm_complete_init();
398} 527}
diff --git a/arch/arm/mach-omap2/clockdomains44xx_data.c b/arch/arm/mach-omap2/clockdomains44xx_data.c
index 7f2133abe7d..63d60a773d3 100644
--- a/arch/arm/mach-omap2/clockdomains44xx_data.c
+++ b/arch/arm/mach-omap2/clockdomains44xx_data.c
@@ -430,8 +430,6 @@ static struct clockdomain *clockdomains_omap44xx[] __initdata = {
430 &l4_wkup_44xx_clkdm, 430 &l4_wkup_44xx_clkdm,
431 &emu_sys_44xx_clkdm, 431 &emu_sys_44xx_clkdm,
432 &l3_dma_44xx_clkdm, 432 &l3_dma_44xx_clkdm,
433 &prm_common_clkdm,
434 &cm_common_clkdm,
435 NULL 433 NULL
436}; 434};
437 435
diff --git a/arch/arm/mach-omap2/clockdomains_common_data.c b/arch/arm/mach-omap2/clockdomains_common_data.c
deleted file mode 100644
index 615b1f04967..00000000000
--- a/arch/arm/mach-omap2/clockdomains_common_data.c
+++ /dev/null
@@ -1,24 +0,0 @@
1/*
2 * OMAP2+-common clockdomain data
3 *
4 * Copyright (C) 2008-2012 Texas Instruments, Inc.
5 * Copyright (C) 2008-2010 Nokia Corporation
6 *
7 * Paul Walmsley, Jouni Högander
8 */
9
10#include <linux/kernel.h>
11#include <linux/io.h>
12
13#include "clockdomain.h"
14
15/* These are implicit clockdomains - they are never defined as such in TRM */
16struct clockdomain prm_common_clkdm = {
17 .name = "prm_clkdm",
18 .pwrdm = { .name = "wkup_pwrdm" },
19};
20
21struct clockdomain cm_common_clkdm = {
22 .name = "cm_clkdm",
23 .pwrdm = { .name = "core_pwrdm" },
24};
diff --git a/arch/arm/mach-omap2/cm-regbits-33xx.h b/arch/arm/mach-omap2/cm-regbits-33xx.h
new file mode 100644
index 00000000000..532027ee3d8
--- /dev/null
+++ b/arch/arm/mach-omap2/cm-regbits-33xx.h
@@ -0,0 +1,687 @@
1/*
2 * AM33XX Power Management register bits
3 *
4 * This file is automatically generated from the AM33XX hardware databases.
5 * Vaibhav Hiremath <hvaibhav@ti.com>
6 *
7 * Copyright (C) 2011-2012 Texas Instruments Incorporated - http://www.ti.com/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation version 2.
12 *
13 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
14 * kind, whether express or implied; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19
20#ifndef __ARCH_ARM_MACH_OMAP2_CM_REGBITS_33XX_H
21#define __ARCH_ARM_MACH_OMAP2_CM_REGBITS_33XX_H
22
23/*
24 * Used by CM_AUTOIDLE_DPLL_CORE, CM_AUTOIDLE_DPLL_DDR, CM_AUTOIDLE_DPLL_DISP,
25 * CM_AUTOIDLE_DPLL_MPU, CM_AUTOIDLE_DPLL_PER
26 */
27#define AM33XX_AUTO_DPLL_MODE_SHIFT 0
28#define AM33XX_AUTO_DPLL_MODE_MASK (0x7 << 0)
29
30/* Used by CM_WKUP_CLKSTCTRL */
31#define AM33XX_CLKACTIVITY_ADC_FCLK_SHIFT 14
32#define AM33XX_CLKACTIVITY_ADC_FCLK_MASK (1 << 16)
33
34/* Used by CM_PER_L4LS_CLKSTCTRL */
35#define AM33XX_CLKACTIVITY_CAN_CLK_SHIFT 11
36#define AM33XX_CLKACTIVITY_CAN_CLK_MASK (1 << 11)
37
38/* Used by CM_PER_CLK_24MHZ_CLKSTCTRL */
39#define AM33XX_CLKACTIVITY_CLK_24MHZ_GCLK_SHIFT 4
40#define AM33XX_CLKACTIVITY_CLK_24MHZ_GCLK_MASK (1 << 4)
41
42/* Used by CM_PER_CPSW_CLKSTCTRL */
43#define AM33XX_CLKACTIVITY_CPSW_125MHZ_GCLK_SHIFT 4
44#define AM33XX_CLKACTIVITY_CPSW_125MHZ_GCLK_MASK (1 << 4)
45
46/* Used by CM_PER_L4HS_CLKSTCTRL */
47#define AM33XX_CLKACTIVITY_CPSW_250MHZ_GCLK_SHIFT 4
48#define AM33XX_CLKACTIVITY_CPSW_250MHZ_GCLK_MASK (1 << 4)
49
50/* Used by CM_PER_L4HS_CLKSTCTRL */
51#define AM33XX_CLKACTIVITY_CPSW_50MHZ_GCLK_SHIFT 5
52#define AM33XX_CLKACTIVITY_CPSW_50MHZ_GCLK_MASK (1 << 5)
53
54/* Used by CM_PER_L4HS_CLKSTCTRL */
55#define AM33XX_CLKACTIVITY_CPSW_5MHZ_GCLK_SHIFT 6
56#define AM33XX_CLKACTIVITY_CPSW_5MHZ_GCLK_MASK (1 << 6)
57
58/* Used by CM_PER_L3_CLKSTCTRL */
59#define AM33XX_CLKACTIVITY_CPTS_RFT_GCLK_SHIFT 6
60#define AM33XX_CLKACTIVITY_CPTS_RFT_GCLK_MASK (1 << 6)
61
62/* Used by CM_CEFUSE_CLKSTCTRL */
63#define AM33XX_CLKACTIVITY_CUST_EFUSE_SYS_CLK_SHIFT 9
64#define AM33XX_CLKACTIVITY_CUST_EFUSE_SYS_CLK_MASK (1 << 9)
65
66/* Used by CM_L3_AON_CLKSTCTRL */
67#define AM33XX_CLKACTIVITY_DBGSYSCLK_SHIFT 2
68#define AM33XX_CLKACTIVITY_DBGSYSCLK_MASK (1 << 2)
69
70/* Used by CM_L3_AON_CLKSTCTRL */
71#define AM33XX_CLKACTIVITY_DEBUG_CLKA_SHIFT 4
72#define AM33XX_CLKACTIVITY_DEBUG_CLKA_MASK (1 << 4)
73
74/* Used by CM_PER_L3_CLKSTCTRL */
75#define AM33XX_CLKACTIVITY_EMIF_GCLK_SHIFT 2
76#define AM33XX_CLKACTIVITY_EMIF_GCLK_MASK (1 << 2)
77
78/* Used by CM_GFX_L3_CLKSTCTRL */
79#define AM33XX_CLKACTIVITY_GFX_FCLK_SHIFT 9
80#define AM33XX_CLKACTIVITY_GFX_FCLK_MASK (1 << 9)
81
82/* Used by CM_GFX_L3_CLKSTCTRL */
83#define AM33XX_CLKACTIVITY_GFX_L3_GCLK_SHIFT 8
84#define AM33XX_CLKACTIVITY_GFX_L3_GCLK_MASK (1 << 8)
85
86/* Used by CM_WKUP_CLKSTCTRL */
87#define AM33XX_CLKACTIVITY_GPIO0_GDBCLK_SHIFT 8
88#define AM33XX_CLKACTIVITY_GPIO0_GDBCLK_MASK (1 << 8)
89
90/* Used by CM_PER_L4LS_CLKSTCTRL */
91#define AM33XX_CLKACTIVITY_GPIO_1_GDBCLK_SHIFT 19
92#define AM33XX_CLKACTIVITY_GPIO_1_GDBCLK_MASK (1 << 19)
93
94/* Used by CM_PER_L4LS_CLKSTCTRL */
95#define AM33XX_CLKACTIVITY_GPIO_2_GDBCLK_SHIFT 20
96#define AM33XX_CLKACTIVITY_GPIO_2_GDBCLK_MASK (1 << 20)
97
98/* Used by CM_PER_L4LS_CLKSTCTRL */
99#define AM33XX_CLKACTIVITY_GPIO_3_GDBCLK_SHIFT 21
100#define AM33XX_CLKACTIVITY_GPIO_3_GDBCLK_MASK (1 << 21)
101
102/* Used by CM_PER_L4LS_CLKSTCTRL */
103#define AM33XX_CLKACTIVITY_GPIO_4_GDBCLK_SHIFT 22
104#define AM33XX_CLKACTIVITY_GPIO_4_GDBCLK_MASK (1 << 22)
105
106/* Used by CM_PER_L4LS_CLKSTCTRL */
107#define AM33XX_CLKACTIVITY_GPIO_5_GDBCLK_SHIFT 26
108#define AM33XX_CLKACTIVITY_GPIO_5_GDBCLK_MASK (1 << 26)
109
110/* Used by CM_PER_L4LS_CLKSTCTRL */
111#define AM33XX_CLKACTIVITY_GPIO_6_GDBCLK_SHIFT 18
112#define AM33XX_CLKACTIVITY_GPIO_6_GDBCLK_MASK (1 << 18)
113
114/* Used by CM_WKUP_CLKSTCTRL */
115#define AM33XX_CLKACTIVITY_I2C0_GFCLK_SHIFT 11
116#define AM33XX_CLKACTIVITY_I2C0_GFCLK_MASK (1 << 11)
117
118/* Used by CM_PER_L4LS_CLKSTCTRL */
119#define AM33XX_CLKACTIVITY_I2C_FCLK_SHIFT 24
120#define AM33XX_CLKACTIVITY_I2C_FCLK_MASK (1 << 24)
121
122/* Used by CM_PER_PRUSS_CLKSTCTRL */
123#define AM33XX_CLKACTIVITY_PRUSS_IEP_GCLK_SHIFT 5
124#define AM33XX_CLKACTIVITY_PRUSS_IEP_GCLK_MASK (1 << 5)
125
126/* Used by CM_PER_PRUSS_CLKSTCTRL */
127#define AM33XX_CLKACTIVITY_PRUSS_OCP_GCLK_SHIFT 4
128#define AM33XX_CLKACTIVITY_PRUSS_OCP_GCLK_MASK (1 << 4)
129
130/* Used by CM_PER_PRUSS_CLKSTCTRL */
131#define AM33XX_CLKACTIVITY_PRUSS_UART_GCLK_SHIFT 6
132#define AM33XX_CLKACTIVITY_PRUSS_UART_GCLK_MASK (1 << 6)
133
134/* Used by CM_PER_L3S_CLKSTCTRL */
135#define AM33XX_CLKACTIVITY_L3S_GCLK_SHIFT 3
136#define AM33XX_CLKACTIVITY_L3S_GCLK_MASK (1 << 3)
137
138/* Used by CM_L3_AON_CLKSTCTRL */
139#define AM33XX_CLKACTIVITY_L3_AON_GCLK_SHIFT 3
140#define AM33XX_CLKACTIVITY_L3_AON_GCLK_MASK (1 << 3)
141
142/* Used by CM_PER_L3_CLKSTCTRL */
143#define AM33XX_CLKACTIVITY_L3_GCLK_SHIFT 4
144#define AM33XX_CLKACTIVITY_L3_GCLK_MASK (1 << 4)
145
146/* Used by CM_PER_L4FW_CLKSTCTRL */
147#define AM33XX_CLKACTIVITY_L4FW_GCLK_SHIFT 8
148#define AM33XX_CLKACTIVITY_L4FW_GCLK_MASK (1 << 8)
149
150/* Used by CM_PER_L4HS_CLKSTCTRL */
151#define AM33XX_CLKACTIVITY_L4HS_GCLK_SHIFT 3
152#define AM33XX_CLKACTIVITY_L4HS_GCLK_MASK (1 << 3)
153
154/* Used by CM_PER_L4LS_CLKSTCTRL */
155#define AM33XX_CLKACTIVITY_L4LS_GCLK_SHIFT 8
156#define AM33XX_CLKACTIVITY_L4LS_GCLK_MASK (1 << 8)
157
158/* Used by CM_GFX_L4LS_GFX_CLKSTCTRL__1 */
159#define AM33XX_CLKACTIVITY_L4LS_GFX_GCLK_SHIFT 8
160#define AM33XX_CLKACTIVITY_L4LS_GFX_GCLK_MASK (1 << 8)
161
162/* Used by CM_CEFUSE_CLKSTCTRL */
163#define AM33XX_CLKACTIVITY_L4_CEFUSE_GICLK_SHIFT 8
164#define AM33XX_CLKACTIVITY_L4_CEFUSE_GICLK_MASK (1 << 8)
165
166/* Used by CM_RTC_CLKSTCTRL */
167#define AM33XX_CLKACTIVITY_L4_RTC_GCLK_SHIFT 8
168#define AM33XX_CLKACTIVITY_L4_RTC_GCLK_MASK (1 << 8)
169
170/* Used by CM_L4_WKUP_AON_CLKSTCTRL */
171#define AM33XX_CLKACTIVITY_L4_WKUP_AON_GCLK_SHIFT 2
172#define AM33XX_CLKACTIVITY_L4_WKUP_AON_GCLK_MASK (1 << 2)
173
174/* Used by CM_WKUP_CLKSTCTRL */
175#define AM33XX_CLKACTIVITY_L4_WKUP_GCLK_SHIFT 2
176#define AM33XX_CLKACTIVITY_L4_WKUP_GCLK_MASK (1 << 2)
177
178/* Used by CM_PER_L4LS_CLKSTCTRL */
179#define AM33XX_CLKACTIVITY_LCDC_GCLK_SHIFT 17
180#define AM33XX_CLKACTIVITY_LCDC_GCLK_MASK (1 << 17)
181
182/* Used by CM_PER_LCDC_CLKSTCTRL */
183#define AM33XX_CLKACTIVITY_LCDC_L3_OCP_GCLK_SHIFT 4
184#define AM33XX_CLKACTIVITY_LCDC_L3_OCP_GCLK_MASK (1 << 4)
185
186/* Used by CM_PER_LCDC_CLKSTCTRL */
187#define AM33XX_CLKACTIVITY_LCDC_L4_OCP_GCLK_SHIFT 5
188#define AM33XX_CLKACTIVITY_LCDC_L4_OCP_GCLK_MASK (1 << 5)
189
190/* Used by CM_PER_L3_CLKSTCTRL */
191#define AM33XX_CLKACTIVITY_MCASP_GCLK_SHIFT 7
192#define AM33XX_CLKACTIVITY_MCASP_GCLK_MASK (1 << 7)
193
194/* Used by CM_PER_L3_CLKSTCTRL */
195#define AM33XX_CLKACTIVITY_MMC_FCLK_SHIFT 3
196#define AM33XX_CLKACTIVITY_MMC_FCLK_MASK (1 << 3)
197
198/* Used by CM_MPU_CLKSTCTRL */
199#define AM33XX_CLKACTIVITY_MPU_CLK_SHIFT 2
200#define AM33XX_CLKACTIVITY_MPU_CLK_MASK (1 << 2)
201
202/* Used by CM_PER_OCPWP_L3_CLKSTCTRL */
203#define AM33XX_CLKACTIVITY_OCPWP_L3_GCLK_SHIFT 4
204#define AM33XX_CLKACTIVITY_OCPWP_L3_GCLK_MASK (1 << 4)
205
206/* Used by CM_PER_OCPWP_L3_CLKSTCTRL */
207#define AM33XX_CLKACTIVITY_OCPWP_L4_GCLK_SHIFT 5
208#define AM33XX_CLKACTIVITY_OCPWP_L4_GCLK_MASK (1 << 5)
209
210/* Used by CM_RTC_CLKSTCTRL */
211#define AM33XX_CLKACTIVITY_RTC_32KCLK_SHIFT 9
212#define AM33XX_CLKACTIVITY_RTC_32KCLK_MASK (1 << 9)
213
214/* Used by CM_PER_L4LS_CLKSTCTRL */
215#define AM33XX_CLKACTIVITY_SPI_GCLK_SHIFT 25
216#define AM33XX_CLKACTIVITY_SPI_GCLK_MASK (1 << 25)
217
218/* Used by CM_WKUP_CLKSTCTRL */
219#define AM33XX_CLKACTIVITY_SR_SYSCLK_SHIFT 3
220#define AM33XX_CLKACTIVITY_SR_SYSCLK_MASK (1 << 3)
221
222/* Used by CM_WKUP_CLKSTCTRL */
223#define AM33XX_CLKACTIVITY_TIMER0_GCLK_SHIFT 10
224#define AM33XX_CLKACTIVITY_TIMER0_GCLK_MASK (1 << 10)
225
226/* Used by CM_WKUP_CLKSTCTRL */
227#define AM33XX_CLKACTIVITY_TIMER1_GCLK_SHIFT 13
228#define AM33XX_CLKACTIVITY_TIMER1_GCLK_MASK (1 << 13)
229
230/* Used by CM_PER_L4LS_CLKSTCTRL */
231#define AM33XX_CLKACTIVITY_TIMER2_GCLK_SHIFT 14
232#define AM33XX_CLKACTIVITY_TIMER2_GCLK_MASK (1 << 14)
233
234/* Used by CM_PER_L4LS_CLKSTCTRL */
235#define AM33XX_CLKACTIVITY_TIMER3_GCLK_SHIFT 15
236#define AM33XX_CLKACTIVITY_TIMER3_GCLK_MASK (1 << 15)
237
238/* Used by CM_PER_L4LS_CLKSTCTRL */
239#define AM33XX_CLKACTIVITY_TIMER4_GCLK_SHIFT 16
240#define AM33XX_CLKACTIVITY_TIMER4_GCLK_MASK (1 << 16)
241
242/* Used by CM_PER_L4LS_CLKSTCTRL */
243#define AM33XX_CLKACTIVITY_TIMER5_GCLK_SHIFT 27
244#define AM33XX_CLKACTIVITY_TIMER5_GCLK_MASK (1 << 27)
245
246/* Used by CM_PER_L4LS_CLKSTCTRL */
247#define AM33XX_CLKACTIVITY_TIMER6_GCLK_SHIFT 28
248#define AM33XX_CLKACTIVITY_TIMER6_GCLK_MASK (1 << 28)
249
250/* Used by CM_PER_L4LS_CLKSTCTRL */
251#define AM33XX_CLKACTIVITY_TIMER7_GCLK_SHIFT 13
252#define AM33XX_CLKACTIVITY_TIMER7_GCLK_MASK (1 << 13)
253
254/* Used by CM_WKUP_CLKSTCTRL */
255#define AM33XX_CLKACTIVITY_UART0_GFCLK_SHIFT 12
256#define AM33XX_CLKACTIVITY_UART0_GFCLK_MASK (1 << 12)
257
258/* Used by CM_PER_L4LS_CLKSTCTRL */
259#define AM33XX_CLKACTIVITY_UART_GFCLK_SHIFT 10
260#define AM33XX_CLKACTIVITY_UART_GFCLK_MASK (1 << 10)
261
262/* Used by CM_WKUP_CLKSTCTRL */
263#define AM33XX_CLKACTIVITY_WDT0_GCLK_SHIFT 9
264#define AM33XX_CLKACTIVITY_WDT0_GCLK_MASK (1 << 9)
265
266/* Used by CM_WKUP_CLKSTCTRL */
267#define AM33XX_CLKACTIVITY_WDT1_GCLK_SHIFT 4
268#define AM33XX_CLKACTIVITY_WDT1_GCLK_MASK (1 << 4)
269
270/* Used by CLKSEL_GFX_FCLK */
271#define AM33XX_CLKDIV_SEL_GFX_FCLK_SHIFT 0
272#define AM33XX_CLKDIV_SEL_GFX_FCLK_MASK (1 << 0)
273
274/* Used by CM_CLKOUT_CTRL */
275#define AM33XX_CLKOUT2DIV_SHIFT 3
276#define AM33XX_CLKOUT2DIV_MASK (0x05 << 3)
277
278/* Used by CM_CLKOUT_CTRL */
279#define AM33XX_CLKOUT2EN_SHIFT 7
280#define AM33XX_CLKOUT2EN_MASK (1 << 7)
281
282/* Used by CM_CLKOUT_CTRL */
283#define AM33XX_CLKOUT2SOURCE_SHIFT 0
284#define AM33XX_CLKOUT2SOURCE_MASK (0x02 << 0)
285
286/*
287 * Used by CLKSEL_GPIO0_DBCLK, CLKSEL_LCDC_PIXEL_CLK, CLKSEL_TIMER2_CLK,
288 * CLKSEL_TIMER3_CLK, CLKSEL_TIMER4_CLK, CLKSEL_TIMER5_CLK, CLKSEL_TIMER6_CLK,
289 * CLKSEL_TIMER7_CLK
290 */
291#define AM33XX_CLKSEL_SHIFT 0
292#define AM33XX_CLKSEL_MASK (0x01 << 0)
293
294/*
295 * Renamed from CLKSEL Used by CLKSEL_PRUSS_OCP_CLK, CLKSEL_WDT1_CLK,
296 * CM_CPTS_RFT_CLKSEL
297 */
298#define AM33XX_CLKSEL_0_0_SHIFT 0
299#define AM33XX_CLKSEL_0_0_MASK (1 << 0)
300
301#define AM33XX_CLKSEL_0_1_SHIFT 0
302#define AM33XX_CLKSEL_0_1_MASK (3 << 0)
303
304/* Renamed from CLKSEL Used by CLKSEL_TIMER1MS_CLK */
305#define AM33XX_CLKSEL_0_2_SHIFT 0
306#define AM33XX_CLKSEL_0_2_MASK (7 << 0)
307
308/* Used by CLKSEL_GFX_FCLK */
309#define AM33XX_CLKSEL_GFX_FCLK_SHIFT 1
310#define AM33XX_CLKSEL_GFX_FCLK_MASK (1 << 1)
311
312/*
313 * Used by CM_MPU_CLKSTCTRL, CM_RTC_CLKSTCTRL, CM_PER_CLK_24MHZ_CLKSTCTRL,
314 * CM_PER_CPSW_CLKSTCTRL, CM_PER_PRUSS_CLKSTCTRL, CM_PER_L3S_CLKSTCTRL,
315 * CM_PER_L3_CLKSTCTRL, CM_PER_L4FW_CLKSTCTRL, CM_PER_L4HS_CLKSTCTRL,
316 * CM_PER_L4LS_CLKSTCTRL, CM_PER_LCDC_CLKSTCTRL, CM_PER_OCPWP_L3_CLKSTCTRL,
317 * CM_L3_AON_CLKSTCTRL, CM_L4_WKUP_AON_CLKSTCTRL, CM_WKUP_CLKSTCTRL,
318 * CM_GFX_L3_CLKSTCTRL, CM_GFX_L4LS_GFX_CLKSTCTRL__1, CM_CEFUSE_CLKSTCTRL
319 */
320#define AM33XX_CLKTRCTRL_SHIFT 0
321#define AM33XX_CLKTRCTRL_MASK (0x3 << 0)
322
323/*
324 * Used by CM_SSC_DELTAMSTEP_DPLL_CORE, CM_SSC_DELTAMSTEP_DPLL_DDR,
325 * CM_SSC_DELTAMSTEP_DPLL_DISP, CM_SSC_DELTAMSTEP_DPLL_MPU,
326 * CM_SSC_DELTAMSTEP_DPLL_PER
327 */
328#define AM33XX_DELTAMSTEP_SHIFT 0
329#define AM33XX_DELTAMSTEP_MASK (0x19 << 0)
330
331/* Used by CM_CLKSEL_DPLL_DDR, CM_CLKSEL_DPLL_DISP, CM_CLKSEL_DPLL_MPU */
332#define AM33XX_DPLL_BYP_CLKSEL_SHIFT 23
333#define AM33XX_DPLL_BYP_CLKSEL_MASK (1 << 23)
334
335/* Used by CM_CLKDCOLDO_DPLL_PER */
336#define AM33XX_DPLL_CLKDCOLDO_GATE_CTRL_SHIFT 8
337#define AM33XX_DPLL_CLKDCOLDO_GATE_CTRL_MASK (1 << 8)
338
339/* Used by CM_CLKDCOLDO_DPLL_PER */
340#define AM33XX_DPLL_CLKDCOLDO_PWDN_SHIFT 12
341#define AM33XX_DPLL_CLKDCOLDO_PWDN_MASK (1 << 12)
342
343/* Used by CM_DIV_M2_DPLL_DDR, CM_DIV_M2_DPLL_DISP, CM_DIV_M2_DPLL_MPU */
344#define AM33XX_DPLL_CLKOUT_DIV_SHIFT 0
345#define AM33XX_DPLL_CLKOUT_DIV_MASK (0x1f << 0)
346
347/* Renamed from DPLL_CLKOUT_DIV Used by CM_DIV_M2_DPLL_PER */
348#define AM33XX_DPLL_CLKOUT_DIV_0_6_SHIFT 0
349#define AM33XX_DPLL_CLKOUT_DIV_0_6_MASK (0x06 << 0)
350
351/* Used by CM_DIV_M2_DPLL_DDR, CM_DIV_M2_DPLL_DISP, CM_DIV_M2_DPLL_MPU */
352#define AM33XX_DPLL_CLKOUT_DIVCHACK_SHIFT 5
353#define AM33XX_DPLL_CLKOUT_DIVCHACK_MASK (1 << 5)
354
355/* Renamed from DPLL_CLKOUT_DIVCHACK Used by CM_DIV_M2_DPLL_PER */
356#define AM33XX_DPLL_CLKOUT_DIVCHACK_M2_PER_SHIFT 7
357#define AM33XX_DPLL_CLKOUT_DIVCHACK_M2_PER_MASK (1 << 7)
358
359/*
360 * Used by CM_DIV_M2_DPLL_DDR, CM_DIV_M2_DPLL_DISP, CM_DIV_M2_DPLL_MPU,
361 * CM_DIV_M2_DPLL_PER
362 */
363#define AM33XX_DPLL_CLKOUT_GATE_CTRL_SHIFT 8
364#define AM33XX_DPLL_CLKOUT_GATE_CTRL_MASK (1 << 8)
365
366/*
367 * Used by CM_CLKSEL_DPLL_CORE, CM_CLKSEL_DPLL_DDR, CM_CLKSEL_DPLL_DISP,
368 * CM_CLKSEL_DPLL_MPU
369 */
370#define AM33XX_DPLL_DIV_SHIFT 0
371#define AM33XX_DPLL_DIV_MASK (0x7f << 0)
372
373#define AM33XX_DPLL_PER_DIV_MASK (0xff << 0)
374
375/* Renamed from DPLL_DIV Used by CM_CLKSEL_DPLL_PERIPH */
376#define AM33XX_DPLL_DIV_0_7_SHIFT 0
377#define AM33XX_DPLL_DIV_0_7_MASK (0x07 << 0)
378
379/*
380 * Used by CM_CLKMODE_DPLL_CORE, CM_CLKMODE_DPLL_DDR, CM_CLKMODE_DPLL_DISP,
381 * CM_CLKMODE_DPLL_MPU
382 */
383#define AM33XX_DPLL_DRIFTGUARD_EN_SHIFT 8
384#define AM33XX_DPLL_DRIFTGUARD_EN_MASK (1 << 8)
385
386/*
387 * Used by CM_CLKMODE_DPLL_CORE, CM_CLKMODE_DPLL_DDR, CM_CLKMODE_DPLL_DISP,
388 * CM_CLKMODE_DPLL_MPU, CM_CLKMODE_DPLL_PER
389 */
390#define AM33XX_DPLL_EN_SHIFT 0
391#define AM33XX_DPLL_EN_MASK (0x7 << 0)
392
393/*
394 * Used by CM_CLKMODE_DPLL_CORE, CM_CLKMODE_DPLL_DDR, CM_CLKMODE_DPLL_DISP,
395 * CM_CLKMODE_DPLL_MPU
396 */
397#define AM33XX_DPLL_LPMODE_EN_SHIFT 10
398#define AM33XX_DPLL_LPMODE_EN_MASK (1 << 10)
399
400/*
401 * Used by CM_CLKSEL_DPLL_CORE, CM_CLKSEL_DPLL_DDR, CM_CLKSEL_DPLL_DISP,
402 * CM_CLKSEL_DPLL_MPU
403 */
404#define AM33XX_DPLL_MULT_SHIFT 8
405#define AM33XX_DPLL_MULT_MASK (0x7ff << 8)
406
407/* Renamed from DPLL_MULT Used by CM_CLKSEL_DPLL_PERIPH */
408#define AM33XX_DPLL_MULT_PERIPH_SHIFT 8
409#define AM33XX_DPLL_MULT_PERIPH_MASK (0xfff << 8)
410
411/*
412 * Used by CM_CLKMODE_DPLL_CORE, CM_CLKMODE_DPLL_DDR, CM_CLKMODE_DPLL_DISP,
413 * CM_CLKMODE_DPLL_MPU
414 */
415#define AM33XX_DPLL_REGM4XEN_SHIFT 11
416#define AM33XX_DPLL_REGM4XEN_MASK (1 << 11)
417
418/* Used by CM_CLKSEL_DPLL_PERIPH */
419#define AM33XX_DPLL_SD_DIV_SHIFT 24
420#define AM33XX_DPLL_SD_DIV_MASK (24, 31)
421
422/*
423 * Used by CM_CLKMODE_DPLL_CORE, CM_CLKMODE_DPLL_DDR, CM_CLKMODE_DPLL_DISP,
424 * CM_CLKMODE_DPLL_MPU, CM_CLKMODE_DPLL_PER
425 */
426#define AM33XX_DPLL_SSC_ACK_SHIFT 13
427#define AM33XX_DPLL_SSC_ACK_MASK (1 << 13)
428
429/*
430 * Used by CM_CLKMODE_DPLL_CORE, CM_CLKMODE_DPLL_DDR, CM_CLKMODE_DPLL_DISP,
431 * CM_CLKMODE_DPLL_MPU, CM_CLKMODE_DPLL_PER
432 */
433#define AM33XX_DPLL_SSC_DOWNSPREAD_SHIFT 14
434#define AM33XX_DPLL_SSC_DOWNSPREAD_MASK (1 << 14)
435
436/*
437 * Used by CM_CLKMODE_DPLL_CORE, CM_CLKMODE_DPLL_DDR, CM_CLKMODE_DPLL_DISP,
438 * CM_CLKMODE_DPLL_MPU, CM_CLKMODE_DPLL_PER
439 */
440#define AM33XX_DPLL_SSC_EN_SHIFT 12
441#define AM33XX_DPLL_SSC_EN_MASK (1 << 12)
442
443/* Used by CM_DIV_M4_DPLL_CORE */
444#define AM33XX_HSDIVIDER_CLKOUT1_DIV_SHIFT 0
445#define AM33XX_HSDIVIDER_CLKOUT1_DIV_MASK (0x1f << 0)
446
447/* Used by CM_DIV_M4_DPLL_CORE */
448#define AM33XX_HSDIVIDER_CLKOUT1_DIVCHACK_SHIFT 5
449#define AM33XX_HSDIVIDER_CLKOUT1_DIVCHACK_MASK (1 << 5)
450
451/* Used by CM_DIV_M4_DPLL_CORE */
452#define AM33XX_HSDIVIDER_CLKOUT1_GATE_CTRL_SHIFT 8
453#define AM33XX_HSDIVIDER_CLKOUT1_GATE_CTRL_MASK (1 << 8)
454
455/* Used by CM_DIV_M4_DPLL_CORE */
456#define AM33XX_HSDIVIDER_CLKOUT1_PWDN_SHIFT 12
457#define AM33XX_HSDIVIDER_CLKOUT1_PWDN_MASK (1 << 12)
458
459/* Used by CM_DIV_M5_DPLL_CORE */
460#define AM33XX_HSDIVIDER_CLKOUT2_DIV_SHIFT 0
461#define AM33XX_HSDIVIDER_CLKOUT2_DIV_MASK (0x1f << 0)
462
463/* Used by CM_DIV_M5_DPLL_CORE */
464#define AM33XX_HSDIVIDER_CLKOUT2_DIVCHACK_SHIFT 5
465#define AM33XX_HSDIVIDER_CLKOUT2_DIVCHACK_MASK (1 << 5)
466
467/* Used by CM_DIV_M5_DPLL_CORE */
468#define AM33XX_HSDIVIDER_CLKOUT2_GATE_CTRL_SHIFT 8
469#define AM33XX_HSDIVIDER_CLKOUT2_GATE_CTRL_MASK (1 << 8)
470
471/* Used by CM_DIV_M5_DPLL_CORE */
472#define AM33XX_HSDIVIDER_CLKOUT2_PWDN_SHIFT 12
473#define AM33XX_HSDIVIDER_CLKOUT2_PWDN_MASK (1 << 12)
474
475/* Used by CM_DIV_M6_DPLL_CORE */
476#define AM33XX_HSDIVIDER_CLKOUT3_DIV_SHIFT 0
477#define AM33XX_HSDIVIDER_CLKOUT3_DIV_MASK (0x04 << 0)
478
479/* Used by CM_DIV_M6_DPLL_CORE */
480#define AM33XX_HSDIVIDER_CLKOUT3_DIVCHACK_SHIFT 5
481#define AM33XX_HSDIVIDER_CLKOUT3_DIVCHACK_MASK (1 << 5)
482
483/* Used by CM_DIV_M6_DPLL_CORE */
484#define AM33XX_HSDIVIDER_CLKOUT3_GATE_CTRL_SHIFT 8
485#define AM33XX_HSDIVIDER_CLKOUT3_GATE_CTRL_MASK (1 << 8)
486
487/* Used by CM_DIV_M6_DPLL_CORE */
488#define AM33XX_HSDIVIDER_CLKOUT3_PWDN_SHIFT 12
489#define AM33XX_HSDIVIDER_CLKOUT3_PWDN_MASK (1 << 12)
490
491/*
492 * Used by CM_MPU_MPU_CLKCTRL, CM_RTC_RTC_CLKCTRL, CM_PER_AES0_CLKCTRL,
493 * CM_PER_AES1_CLKCTRL, CM_PER_CLKDIV32K_CLKCTRL, CM_PER_CPGMAC0_CLKCTRL,
494 * CM_PER_DCAN0_CLKCTRL, CM_PER_DCAN1_CLKCTRL, CM_PER_DES_CLKCTRL,
495 * CM_PER_ELM_CLKCTRL, CM_PER_EMIF_CLKCTRL, CM_PER_EMIF_FW_CLKCTRL,
496 * CM_PER_EPWMSS0_CLKCTRL, CM_PER_EPWMSS1_CLKCTRL, CM_PER_EPWMSS2_CLKCTRL,
497 * CM_PER_GPIO1_CLKCTRL, CM_PER_GPIO2_CLKCTRL, CM_PER_GPIO3_CLKCTRL,
498 * CM_PER_GPIO4_CLKCTRL, CM_PER_GPIO5_CLKCTRL, CM_PER_GPIO6_CLKCTRL,
499 * CM_PER_GPMC_CLKCTRL, CM_PER_I2C1_CLKCTRL, CM_PER_I2C2_CLKCTRL,
500 * CM_PER_PRUSS_CLKCTRL, CM_PER_IEEE5000_CLKCTRL, CM_PER_L3_CLKCTRL,
501 * CM_PER_L3_INSTR_CLKCTRL, CM_PER_L4FW_CLKCTRL, CM_PER_L4HS_CLKCTRL,
502 * CM_PER_L4LS_CLKCTRL, CM_PER_LCDC_CLKCTRL, CM_PER_MAILBOX0_CLKCTRL,
503 * CM_PER_MAILBOX1_CLKCTRL, CM_PER_MCASP0_CLKCTRL, CM_PER_MCASP1_CLKCTRL,
504 * CM_PER_MCASP2_CLKCTRL, CM_PER_MLB_CLKCTRL, CM_PER_MMC0_CLKCTRL,
505 * CM_PER_MMC1_CLKCTRL, CM_PER_MMC2_CLKCTRL, CM_PER_MSTR_EXPS_CLKCTRL,
506 * CM_PER_OCMCRAM_CLKCTRL, CM_PER_OCPWP_CLKCTRL, CM_PER_PCIE_CLKCTRL,
507 * CM_PER_PKA_CLKCTRL, CM_PER_RNG_CLKCTRL, CM_PER_SHA0_CLKCTRL,
508 * CM_PER_SLV_EXPS_CLKCTRL, CM_PER_SPARE0_CLKCTRL, CM_PER_SPARE1_CLKCTRL,
509 * CM_PER_SPARE_CLKCTRL, CM_PER_SPI0_CLKCTRL, CM_PER_SPI1_CLKCTRL,
510 * CM_PER_SPI2_CLKCTRL, CM_PER_SPI3_CLKCTRL, CM_PER_SPINLOCK_CLKCTRL,
511 * CM_PER_TIMER2_CLKCTRL, CM_PER_TIMER3_CLKCTRL, CM_PER_TIMER4_CLKCTRL,
512 * CM_PER_TIMER5_CLKCTRL, CM_PER_TIMER6_CLKCTRL, CM_PER_TIMER7_CLKCTRL,
513 * CM_PER_TPCC_CLKCTRL, CM_PER_TPTC0_CLKCTRL, CM_PER_TPTC1_CLKCTRL,
514 * CM_PER_TPTC2_CLKCTRL, CM_PER_UART1_CLKCTRL, CM_PER_UART2_CLKCTRL,
515 * CM_PER_UART3_CLKCTRL, CM_PER_UART4_CLKCTRL, CM_PER_UART5_CLKCTRL,
516 * CM_PER_USB0_CLKCTRL, CM_WKUP_ADC_TSC_CLKCTRL, CM_WKUP_CONTROL_CLKCTRL,
517 * CM_WKUP_DEBUGSS_CLKCTRL, CM_WKUP_GPIO0_CLKCTRL, CM_WKUP_I2C0_CLKCTRL,
518 * CM_WKUP_L4WKUP_CLKCTRL, CM_WKUP_SMARTREFLEX0_CLKCTRL,
519 * CM_WKUP_SMARTREFLEX1_CLKCTRL, CM_WKUP_TIMER0_CLKCTRL,
520 * CM_WKUP_TIMER1_CLKCTRL, CM_WKUP_UART0_CLKCTRL, CM_WKUP_WDT0_CLKCTRL,
521 * CM_WKUP_WDT1_CLKCTRL, CM_GFX_BITBLT_CLKCTRL, CM_GFX_GFX_CLKCTRL,
522 * CM_GFX_MMUCFG_CLKCTRL, CM_GFX_MMUDATA_CLKCTRL, CM_CEFUSE_CEFUSE_CLKCTRL
523 */
524#define AM33XX_IDLEST_SHIFT 16
525#define AM33XX_IDLEST_MASK (0x3 << 16)
526#define AM33XX_IDLEST_VAL 0x3
527
528/* Used by CM_MAC_CLKSEL */
529#define AM33XX_MII_CLK_SEL_SHIFT 2
530#define AM33XX_MII_CLK_SEL_MASK (1 << 2)
531
532/*
533 * Used by CM_SSC_MODFREQDIV_DPLL_CORE, CM_SSC_MODFREQDIV_DPLL_DDR,
534 * CM_SSC_MODFREQDIV_DPLL_DISP, CM_SSC_MODFREQDIV_DPLL_MPU,
535 * CM_SSC_MODFREQDIV_DPLL_PER
536 */
537#define AM33XX_MODFREQDIV_EXPONENT_SHIFT 8
538#define AM33XX_MODFREQDIV_EXPONENT_MASK (0x10 << 8)
539
540/*
541 * Used by CM_SSC_MODFREQDIV_DPLL_CORE, CM_SSC_MODFREQDIV_DPLL_DDR,
542 * CM_SSC_MODFREQDIV_DPLL_DISP, CM_SSC_MODFREQDIV_DPLL_MPU,
543 * CM_SSC_MODFREQDIV_DPLL_PER
544 */
545#define AM33XX_MODFREQDIV_MANTISSA_SHIFT 0
546#define AM33XX_MODFREQDIV_MANTISSA_MASK (0x06 << 0)
547
548/*
549 * Used by CM_MPU_MPU_CLKCTRL, CM_RTC_RTC_CLKCTRL, CM_PER_AES0_CLKCTRL,
550 * CM_PER_AES1_CLKCTRL, CM_PER_CLKDIV32K_CLKCTRL, CM_PER_CPGMAC0_CLKCTRL,
551 * CM_PER_DCAN0_CLKCTRL, CM_PER_DCAN1_CLKCTRL, CM_PER_DES_CLKCTRL,
552 * CM_PER_ELM_CLKCTRL, CM_PER_EMIF_CLKCTRL, CM_PER_EMIF_FW_CLKCTRL,
553 * CM_PER_EPWMSS0_CLKCTRL, CM_PER_EPWMSS1_CLKCTRL, CM_PER_EPWMSS2_CLKCTRL,
554 * CM_PER_GPIO1_CLKCTRL, CM_PER_GPIO2_CLKCTRL, CM_PER_GPIO3_CLKCTRL,
555 * CM_PER_GPIO4_CLKCTRL, CM_PER_GPIO5_CLKCTRL, CM_PER_GPIO6_CLKCTRL,
556 * CM_PER_GPMC_CLKCTRL, CM_PER_I2C1_CLKCTRL, CM_PER_I2C2_CLKCTRL,
557 * CM_PER_PRUSS_CLKCTRL, CM_PER_IEEE5000_CLKCTRL, CM_PER_L3_CLKCTRL,
558 * CM_PER_L3_INSTR_CLKCTRL, CM_PER_L4FW_CLKCTRL, CM_PER_L4HS_CLKCTRL,
559 * CM_PER_L4LS_CLKCTRL, CM_PER_LCDC_CLKCTRL, CM_PER_MAILBOX0_CLKCTRL,
560 * CM_PER_MAILBOX1_CLKCTRL, CM_PER_MCASP0_CLKCTRL, CM_PER_MCASP1_CLKCTRL,
561 * CM_PER_MCASP2_CLKCTRL, CM_PER_MLB_CLKCTRL, CM_PER_MMC0_CLKCTRL,
562 * CM_PER_MMC1_CLKCTRL, CM_PER_MMC2_CLKCTRL, CM_PER_MSTR_EXPS_CLKCTRL,
563 * CM_PER_OCMCRAM_CLKCTRL, CM_PER_OCPWP_CLKCTRL, CM_PER_PCIE_CLKCTRL,
564 * CM_PER_PKA_CLKCTRL, CM_PER_RNG_CLKCTRL, CM_PER_SHA0_CLKCTRL,
565 * CM_PER_SLV_EXPS_CLKCTRL, CM_PER_SPARE0_CLKCTRL, CM_PER_SPARE1_CLKCTRL,
566 * CM_PER_SPARE_CLKCTRL, CM_PER_SPI0_CLKCTRL, CM_PER_SPI1_CLKCTRL,
567 * CM_PER_SPI2_CLKCTRL, CM_PER_SPI3_CLKCTRL, CM_PER_SPINLOCK_CLKCTRL,
568 * CM_PER_TIMER2_CLKCTRL, CM_PER_TIMER3_CLKCTRL, CM_PER_TIMER4_CLKCTRL,
569 * CM_PER_TIMER5_CLKCTRL, CM_PER_TIMER6_CLKCTRL, CM_PER_TIMER7_CLKCTRL,
570 * CM_PER_TPCC_CLKCTRL, CM_PER_TPTC0_CLKCTRL, CM_PER_TPTC1_CLKCTRL,
571 * CM_PER_TPTC2_CLKCTRL, CM_PER_UART1_CLKCTRL, CM_PER_UART2_CLKCTRL,
572 * CM_PER_UART3_CLKCTRL, CM_PER_UART4_CLKCTRL, CM_PER_UART5_CLKCTRL,
573 * CM_PER_USB0_CLKCTRL, CM_WKUP_ADC_TSC_CLKCTRL, CM_WKUP_CONTROL_CLKCTRL,
574 * CM_WKUP_DEBUGSS_CLKCTRL, CM_WKUP_GPIO0_CLKCTRL, CM_WKUP_I2C0_CLKCTRL,
575 * CM_WKUP_L4WKUP_CLKCTRL, CM_WKUP_SMARTREFLEX0_CLKCTRL,
576 * CM_WKUP_SMARTREFLEX1_CLKCTRL, CM_WKUP_TIMER0_CLKCTRL,
577 * CM_WKUP_TIMER1_CLKCTRL, CM_WKUP_UART0_CLKCTRL, CM_WKUP_WDT0_CLKCTRL,
578 * CM_WKUP_WDT1_CLKCTRL, CM_WKUP_WKUP_M3_CLKCTRL, CM_GFX_BITBLT_CLKCTRL,
579 * CM_GFX_GFX_CLKCTRL, CM_GFX_MMUCFG_CLKCTRL, CM_GFX_MMUDATA_CLKCTRL,
580 * CM_CEFUSE_CEFUSE_CLKCTRL
581 */
582#define AM33XX_MODULEMODE_SHIFT 0
583#define AM33XX_MODULEMODE_MASK (0x3 << 0)
584
585/* Used by CM_WKUP_DEBUGSS_CLKCTRL */
586#define AM33XX_OPTCLK_DEBUG_CLKA_SHIFT 30
587#define AM33XX_OPTCLK_DEBUG_CLKA_MASK (1 << 30)
588
589/* Used by CM_WKUP_DEBUGSS_CLKCTRL */
590#define AM33XX_OPTFCLKEN_DBGSYSCLK_SHIFT 19
591#define AM33XX_OPTFCLKEN_DBGSYSCLK_MASK (1 << 19)
592
593/* Used by CM_WKUP_GPIO0_CLKCTRL */
594#define AM33XX_OPTFCLKEN_GPIO0_GDBCLK_SHIFT 18
595#define AM33XX_OPTFCLKEN_GPIO0_GDBCLK_MASK (1 << 18)
596
597/* Used by CM_PER_GPIO1_CLKCTRL */
598#define AM33XX_OPTFCLKEN_GPIO_1_GDBCLK_SHIFT 18
599#define AM33XX_OPTFCLKEN_GPIO_1_GDBCLK_MASK (1 << 18)
600
601/* Used by CM_PER_GPIO2_CLKCTRL */
602#define AM33XX_OPTFCLKEN_GPIO_2_GDBCLK_SHIFT 18
603#define AM33XX_OPTFCLKEN_GPIO_2_GDBCLK_MASK (1 << 18)
604
605/* Used by CM_PER_GPIO3_CLKCTRL */
606#define AM33XX_OPTFCLKEN_GPIO_3_GDBCLK_SHIFT 18
607#define AM33XX_OPTFCLKEN_GPIO_3_GDBCLK_MASK (1 << 18)
608
609/* Used by CM_PER_GPIO4_CLKCTRL */
610#define AM33XX_OPTFCLKEN_GPIO_4_GDBCLK_SHIFT 18
611#define AM33XX_OPTFCLKEN_GPIO_4_GDBCLK_MASK (1 << 18)
612
613/* Used by CM_PER_GPIO5_CLKCTRL */
614#define AM33XX_OPTFCLKEN_GPIO_5_GDBCLK_SHIFT 18
615#define AM33XX_OPTFCLKEN_GPIO_5_GDBCLK_MASK (1 << 18)
616
617/* Used by CM_PER_GPIO6_CLKCTRL */
618#define AM33XX_OPTFCLKEN_GPIO_6_GDBCLK_SHIFT 18
619#define AM33XX_OPTFCLKEN_GPIO_6_GDBCLK_MASK (1 << 18)
620
621/*
622 * Used by CM_MPU_MPU_CLKCTRL, CM_PER_CPGMAC0_CLKCTRL, CM_PER_PRUSS_CLKCTRL,
623 * CM_PER_IEEE5000_CLKCTRL, CM_PER_LCDC_CLKCTRL, CM_PER_MLB_CLKCTRL,
624 * CM_PER_MSTR_EXPS_CLKCTRL, CM_PER_OCPWP_CLKCTRL, CM_PER_PCIE_CLKCTRL,
625 * CM_PER_SPARE_CLKCTRL, CM_PER_TPTC0_CLKCTRL, CM_PER_TPTC1_CLKCTRL,
626 * CM_PER_TPTC2_CLKCTRL, CM_PER_USB0_CLKCTRL, CM_WKUP_DEBUGSS_CLKCTRL,
627 * CM_WKUP_WKUP_M3_CLKCTRL, CM_GFX_BITBLT_CLKCTRL, CM_GFX_GFX_CLKCTRL
628 */
629#define AM33XX_STBYST_SHIFT 18
630#define AM33XX_STBYST_MASK (1 << 18)
631
632/* Used by CM_WKUP_DEBUGSS_CLKCTRL */
633#define AM33XX_STM_PMD_CLKDIVSEL_SHIFT 27
634#define AM33XX_STM_PMD_CLKDIVSEL_MASK (0x29 << 27)
635
636/* Used by CM_WKUP_DEBUGSS_CLKCTRL */
637#define AM33XX_STM_PMD_CLKSEL_SHIFT 22
638#define AM33XX_STM_PMD_CLKSEL_MASK (0x23 << 22)
639
640/*
641 * Used by CM_IDLEST_DPLL_CORE, CM_IDLEST_DPLL_DDR, CM_IDLEST_DPLL_DISP,
642 * CM_IDLEST_DPLL_MPU, CM_IDLEST_DPLL_PER
643 */
644#define AM33XX_ST_DPLL_CLK_SHIFT 0
645#define AM33XX_ST_DPLL_CLK_MASK (1 << 0)
646
647/* Used by CM_CLKDCOLDO_DPLL_PER */
648#define AM33XX_ST_DPLL_CLKDCOLDO_SHIFT 8
649#define AM33XX_ST_DPLL_CLKDCOLDO_MASK (1 << 8)
650
651/*
652 * Used by CM_DIV_M2_DPLL_DDR, CM_DIV_M2_DPLL_DISP, CM_DIV_M2_DPLL_MPU,
653 * CM_DIV_M2_DPLL_PER
654 */
655#define AM33XX_ST_DPLL_CLKOUT_SHIFT 9
656#define AM33XX_ST_DPLL_CLKOUT_MASK (1 << 9)
657
658/* Used by CM_DIV_M4_DPLL_CORE */
659#define AM33XX_ST_HSDIVIDER_CLKOUT1_SHIFT 9
660#define AM33XX_ST_HSDIVIDER_CLKOUT1_MASK (1 << 9)
661
662/* Used by CM_DIV_M5_DPLL_CORE */
663#define AM33XX_ST_HSDIVIDER_CLKOUT2_SHIFT 9
664#define AM33XX_ST_HSDIVIDER_CLKOUT2_MASK (1 << 9)
665
666/* Used by CM_DIV_M6_DPLL_CORE */
667#define AM33XX_ST_HSDIVIDER_CLKOUT3_SHIFT 9
668#define AM33XX_ST_HSDIVIDER_CLKOUT3_MASK (1 << 9)
669
670/*
671 * Used by CM_IDLEST_DPLL_CORE, CM_IDLEST_DPLL_DDR, CM_IDLEST_DPLL_DISP,
672 * CM_IDLEST_DPLL_MPU, CM_IDLEST_DPLL_PER
673 */
674#define AM33XX_ST_MN_BYPASS_SHIFT 8
675#define AM33XX_ST_MN_BYPASS_MASK (1 << 8)
676
677/* Used by CM_WKUP_DEBUGSS_CLKCTRL */
678#define AM33XX_TRC_PMD_CLKDIVSEL_SHIFT 24
679#define AM33XX_TRC_PMD_CLKDIVSEL_MASK (0x26 << 24)
680
681/* Used by CM_WKUP_DEBUGSS_CLKCTRL */
682#define AM33XX_TRC_PMD_CLKSEL_SHIFT 20
683#define AM33XX_TRC_PMD_CLKSEL_MASK (0x21 << 20)
684
685/* Used by CONTROL_SEC_CLK_CTRL */
686#define AM33XX_TIMER0_CLKSEL_MASK (0x3 << 4)
687#endif
diff --git a/arch/arm/mach-omap2/cm-regbits-34xx.h b/arch/arm/mach-omap2/cm-regbits-34xx.h
index 8083a8cdc55..766338fe4d3 100644
--- a/arch/arm/mach-omap2/cm-regbits-34xx.h
+++ b/arch/arm/mach-omap2/cm-regbits-34xx.h
@@ -169,8 +169,6 @@
169/* AM35XX specific CM_ICLKEN1_CORE bits */ 169/* AM35XX specific CM_ICLKEN1_CORE bits */
170#define AM35XX_EN_IPSS_MASK (1 << 4) 170#define AM35XX_EN_IPSS_MASK (1 << 4)
171#define AM35XX_EN_IPSS_SHIFT 4 171#define AM35XX_EN_IPSS_SHIFT 4
172#define AM35XX_EN_UART4_MASK (1 << 23)
173#define AM35XX_EN_UART4_SHIFT 23
174 172
175/* CM_ICLKEN2_CORE */ 173/* CM_ICLKEN2_CORE */
176#define OMAP3430_EN_PKA_MASK (1 << 4) 174#define OMAP3430_EN_PKA_MASK (1 << 4)
@@ -207,6 +205,8 @@
207#define OMAP3430_ST_DES2_MASK (1 << 26) 205#define OMAP3430_ST_DES2_MASK (1 << 26)
208#define OMAP3430_ST_MSPRO_SHIFT 23 206#define OMAP3430_ST_MSPRO_SHIFT 23
209#define OMAP3430_ST_MSPRO_MASK (1 << 23) 207#define OMAP3430_ST_MSPRO_MASK (1 << 23)
208#define AM35XX_ST_UART4_SHIFT 23
209#define AM35XX_ST_UART4_MASK (1 << 23)
210#define OMAP3430_ST_HDQ_SHIFT 22 210#define OMAP3430_ST_HDQ_SHIFT 22
211#define OMAP3430_ST_HDQ_MASK (1 << 22) 211#define OMAP3430_ST_HDQ_MASK (1 << 22)
212#define OMAP3430ES1_ST_FAC_SHIFT 8 212#define OMAP3430ES1_ST_FAC_SHIFT 8
diff --git a/arch/arm/mach-omap2/cm33xx.c b/arch/arm/mach-omap2/cm33xx.c
new file mode 100644
index 00000000000..13f56eafef0
--- /dev/null
+++ b/arch/arm/mach-omap2/cm33xx.c
@@ -0,0 +1,313 @@
1/*
2 * AM33XX CM functions
3 *
4 * Copyright (C) 2011-2012 Texas Instruments Incorporated - http://www.ti.com/
5 * Vaibhav Hiremath <hvaibhav@ti.com>
6 *
7 * Reference taken from from OMAP4 cminst44xx.c
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 as
11 * published by the Free Software Foundation version 2.
12 *
13 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
14 * kind, whether express or implied; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#include <linux/kernel.h>
20#include <linux/types.h>
21#include <linux/errno.h>
22#include <linux/err.h>
23#include <linux/io.h>
24
25#include <plat/common.h>
26
27#include "cm.h"
28#include "cm33xx.h"
29#include "cm-regbits-34xx.h"
30#include "cm-regbits-33xx.h"
31#include "prm33xx.h"
32
33/*
34 * CLKCTRL_IDLEST_*: possible values for the CM_*_CLKCTRL.IDLEST bitfield:
35 *
36 * 0x0 func: Module is fully functional, including OCP
37 * 0x1 trans: Module is performing transition: wakeup, or sleep, or sleep
38 * abortion
39 * 0x2 idle: Module is in Idle mode (only OCP part). It is functional if
40 * using separate functional clock
41 * 0x3 disabled: Module is disabled and cannot be accessed
42 *
43 */
44#define CLKCTRL_IDLEST_FUNCTIONAL 0x0
45#define CLKCTRL_IDLEST_INTRANSITION 0x1
46#define CLKCTRL_IDLEST_INTERFACE_IDLE 0x2
47#define CLKCTRL_IDLEST_DISABLED 0x3
48
49/* Private functions */
50
51/* Read a register in a CM instance */
52static inline u32 am33xx_cm_read_reg(s16 inst, u16 idx)
53{
54 return __raw_readl(cm_base + inst + idx);
55}
56
57/* Write into a register in a CM */
58static inline void am33xx_cm_write_reg(u32 val, s16 inst, u16 idx)
59{
60 __raw_writel(val, cm_base + inst + idx);
61}
62
63/* Read-modify-write a register in CM */
64static inline u32 am33xx_cm_rmw_reg_bits(u32 mask, u32 bits, s16 inst, s16 idx)
65{
66 u32 v;
67
68 v = am33xx_cm_read_reg(inst, idx);
69 v &= ~mask;
70 v |= bits;
71 am33xx_cm_write_reg(v, inst, idx);
72
73 return v;
74}
75
76static inline u32 am33xx_cm_set_reg_bits(u32 bits, s16 inst, s16 idx)
77{
78 return am33xx_cm_rmw_reg_bits(bits, bits, inst, idx);
79}
80
81static inline u32 am33xx_cm_clear_reg_bits(u32 bits, s16 inst, s16 idx)
82{
83 return am33xx_cm_rmw_reg_bits(bits, 0x0, inst, idx);
84}
85
86static inline u32 am33xx_cm_read_reg_bits(u16 inst, s16 idx, u32 mask)
87{
88 u32 v;
89
90 v = am33xx_cm_read_reg(inst, idx);
91 v &= mask;
92 v >>= __ffs(mask);
93
94 return v;
95}
96
97/**
98 * _clkctrl_idlest - read a CM_*_CLKCTRL register; mask & shift IDLEST bitfield
99 * @inst: CM instance register offset (*_INST macro)
100 * @cdoffs: Clockdomain register offset (*_CDOFFS macro)
101 * @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
102 *
103 * Return the IDLEST bitfield of a CM_*_CLKCTRL register, shifted down to
104 * bit 0.
105 */
106static u32 _clkctrl_idlest(u16 inst, s16 cdoffs, u16 clkctrl_offs)
107{
108 u32 v = am33xx_cm_read_reg(inst, clkctrl_offs);
109 v &= AM33XX_IDLEST_MASK;
110 v >>= AM33XX_IDLEST_SHIFT;
111 return v;
112}
113
114/**
115 * _is_module_ready - can module registers be accessed without causing an abort?
116 * @inst: CM instance register offset (*_INST macro)
117 * @cdoffs: Clockdomain register offset (*_CDOFFS macro)
118 * @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
119 *
120 * Returns true if the module's CM_*_CLKCTRL.IDLEST bitfield is either
121 * *FUNCTIONAL or *INTERFACE_IDLE; false otherwise.
122 */
123static bool _is_module_ready(u16 inst, s16 cdoffs, u16 clkctrl_offs)
124{
125 u32 v;
126
127 v = _clkctrl_idlest(inst, cdoffs, clkctrl_offs);
128
129 return (v == CLKCTRL_IDLEST_FUNCTIONAL ||
130 v == CLKCTRL_IDLEST_INTERFACE_IDLE) ? true : false;
131}
132
133/**
134 * _clktrctrl_write - write @c to a CM_CLKSTCTRL.CLKTRCTRL register bitfield
135 * @c: CLKTRCTRL register bitfield (LSB = bit 0, i.e., unshifted)
136 * @inst: CM instance register offset (*_INST macro)
137 * @cdoffs: Clockdomain register offset (*_CDOFFS macro)
138 *
139 * @c must be the unshifted value for CLKTRCTRL - i.e., this function
140 * will handle the shift itself.
141 */
142static void _clktrctrl_write(u8 c, s16 inst, u16 cdoffs)
143{
144 u32 v;
145
146 v = am33xx_cm_read_reg(inst, cdoffs);
147 v &= ~AM33XX_CLKTRCTRL_MASK;
148 v |= c << AM33XX_CLKTRCTRL_SHIFT;
149 am33xx_cm_write_reg(v, inst, cdoffs);
150}
151
152/* Public functions */
153
154/**
155 * am33xx_cm_is_clkdm_in_hwsup - is a clockdomain in hwsup idle mode?
156 * @inst: CM instance register offset (*_INST macro)
157 * @cdoffs: Clockdomain register offset (*_CDOFFS macro)
158 *
159 * Returns true if the clockdomain referred to by (@inst, @cdoffs)
160 * is in hardware-supervised idle mode, or 0 otherwise.
161 */
162bool am33xx_cm_is_clkdm_in_hwsup(s16 inst, u16 cdoffs)
163{
164 u32 v;
165
166 v = am33xx_cm_read_reg(inst, cdoffs);
167 v &= AM33XX_CLKTRCTRL_MASK;
168 v >>= AM33XX_CLKTRCTRL_SHIFT;
169
170 return (v == OMAP34XX_CLKSTCTRL_ENABLE_AUTO) ? true : false;
171}
172
173/**
174 * am33xx_cm_clkdm_enable_hwsup - put a clockdomain in hwsup-idle mode
175 * @inst: CM instance register offset (*_INST macro)
176 * @cdoffs: Clockdomain register offset (*_CDOFFS macro)
177 *
178 * Put a clockdomain referred to by (@inst, @cdoffs) into
179 * hardware-supervised idle mode. No return value.
180 */
181void am33xx_cm_clkdm_enable_hwsup(s16 inst, u16 cdoffs)
182{
183 _clktrctrl_write(OMAP34XX_CLKSTCTRL_ENABLE_AUTO, inst, cdoffs);
184}
185
186/**
187 * am33xx_cm_clkdm_disable_hwsup - put a clockdomain in swsup-idle mode
188 * @inst: CM instance register offset (*_INST macro)
189 * @cdoffs: Clockdomain register offset (*_CDOFFS macro)
190 *
191 * Put a clockdomain referred to by (@inst, @cdoffs) into
192 * software-supervised idle mode, i.e., controlled manually by the
193 * Linux OMAP clockdomain code. No return value.
194 */
195void am33xx_cm_clkdm_disable_hwsup(s16 inst, u16 cdoffs)
196{
197 _clktrctrl_write(OMAP34XX_CLKSTCTRL_DISABLE_AUTO, inst, cdoffs);
198}
199
200/**
201 * am33xx_cm_clkdm_force_sleep - try to put a clockdomain into idle
202 * @inst: CM instance register offset (*_INST macro)
203 * @cdoffs: Clockdomain register offset (*_CDOFFS macro)
204 *
205 * Put a clockdomain referred to by (@inst, @cdoffs) into idle
206 * No return value.
207 */
208void am33xx_cm_clkdm_force_sleep(s16 inst, u16 cdoffs)
209{
210 _clktrctrl_write(OMAP34XX_CLKSTCTRL_FORCE_SLEEP, inst, cdoffs);
211}
212
213/**
214 * am33xx_cm_clkdm_force_wakeup - try to take a clockdomain out of idle
215 * @inst: CM instance register offset (*_INST macro)
216 * @cdoffs: Clockdomain register offset (*_CDOFFS macro)
217 *
218 * Take a clockdomain referred to by (@inst, @cdoffs) out of idle,
219 * waking it up. No return value.
220 */
221void am33xx_cm_clkdm_force_wakeup(s16 inst, u16 cdoffs)
222{
223 _clktrctrl_write(OMAP34XX_CLKSTCTRL_FORCE_WAKEUP, inst, cdoffs);
224}
225
226/*
227 *
228 */
229
230/**
231 * am33xx_cm_wait_module_ready - wait for a module to be in 'func' state
232 * @inst: CM instance register offset (*_INST macro)
233 * @cdoffs: Clockdomain register offset (*_CDOFFS macro)
234 * @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
235 *
236 * Wait for the module IDLEST to be functional. If the idle state is in any
237 * the non functional state (trans, idle or disabled), module and thus the
238 * sysconfig cannot be accessed and will probably lead to an "imprecise
239 * external abort"
240 */
241int am33xx_cm_wait_module_ready(u16 inst, s16 cdoffs, u16 clkctrl_offs)
242{
243 int i = 0;
244
245 if (!clkctrl_offs)
246 return 0;
247
248 omap_test_timeout(_is_module_ready(inst, cdoffs, clkctrl_offs),
249 MAX_MODULE_READY_TIME, i);
250
251 return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY;
252}
253
254/**
255 * am33xx_cm_wait_module_idle - wait for a module to be in 'disabled'
256 * state
257 * @inst: CM instance register offset (*_INST macro)
258 * @cdoffs: Clockdomain register offset (*_CDOFFS macro)
259 * @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
260 *
261 * Wait for the module IDLEST to be disabled. Some PRCM transition,
262 * like reset assertion or parent clock de-activation must wait the
263 * module to be fully disabled.
264 */
265int am33xx_cm_wait_module_idle(u16 inst, s16 cdoffs, u16 clkctrl_offs)
266{
267 int i = 0;
268
269 if (!clkctrl_offs)
270 return 0;
271
272 omap_test_timeout((_clkctrl_idlest(inst, cdoffs, clkctrl_offs) ==
273 CLKCTRL_IDLEST_DISABLED),
274 MAX_MODULE_READY_TIME, i);
275
276 return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY;
277}
278
279/**
280 * am33xx_cm_module_enable - Enable the modulemode inside CLKCTRL
281 * @mode: Module mode (SW or HW)
282 * @inst: CM instance register offset (*_INST macro)
283 * @cdoffs: Clockdomain register offset (*_CDOFFS macro)
284 * @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
285 *
286 * No return value.
287 */
288void am33xx_cm_module_enable(u8 mode, u16 inst, s16 cdoffs, u16 clkctrl_offs)
289{
290 u32 v;
291
292 v = am33xx_cm_read_reg(inst, clkctrl_offs);
293 v &= ~AM33XX_MODULEMODE_MASK;
294 v |= mode << AM33XX_MODULEMODE_SHIFT;
295 am33xx_cm_write_reg(v, inst, clkctrl_offs);
296}
297
298/**
299 * am33xx_cm_module_disable - Disable the module inside CLKCTRL
300 * @inst: CM instance register offset (*_INST macro)
301 * @cdoffs: Clockdomain register offset (*_CDOFFS macro)
302 * @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
303 *
304 * No return value.
305 */
306void am33xx_cm_module_disable(u16 inst, s16 cdoffs, u16 clkctrl_offs)
307{
308 u32 v;
309
310 v = am33xx_cm_read_reg(inst, clkctrl_offs);
311 v &= ~AM33XX_MODULEMODE_MASK;
312 am33xx_cm_write_reg(v, inst, clkctrl_offs);
313}
diff --git a/arch/arm/mach-omap2/cm33xx.h b/arch/arm/mach-omap2/cm33xx.h
new file mode 100644
index 00000000000..5fa0b62e1a7
--- /dev/null
+++ b/arch/arm/mach-omap2/cm33xx.h
@@ -0,0 +1,420 @@
1/*
2 * AM33XX CM offset macros
3 *
4 * Copyright (C) 2011-2012 Texas Instruments Incorporated - http://www.ti.com/
5 * Vaibhav Hiremath <hvaibhav@ti.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation version 2.
10 *
11 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
12 * kind, whether express or implied; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#ifndef __ARCH_ARM_MACH_OMAP2_CM_33XX_H
18#define __ARCH_ARM_MACH_OMAP2_CM_33XX_H
19
20#include <linux/delay.h>
21#include <linux/errno.h>
22#include <linux/err.h>
23#include <linux/io.h>
24
25#include "common.h"
26
27#include "cm.h"
28#include "cm-regbits-33xx.h"
29#include "cm33xx.h"
30
31/* CM base address */
32#define AM33XX_CM_BASE 0x44e00000
33
34#define AM33XX_CM_REGADDR(inst, reg) \
35 AM33XX_L4_WK_IO_ADDRESS(AM33XX_CM_BASE + (inst) + (reg))
36
37/* CM instances */
38#define AM33XX_CM_PER_MOD 0x0000
39#define AM33XX_CM_WKUP_MOD 0x0400
40#define AM33XX_CM_DPLL_MOD 0x0500
41#define AM33XX_CM_MPU_MOD 0x0600
42#define AM33XX_CM_DEVICE_MOD 0x0700
43#define AM33XX_CM_RTC_MOD 0x0800
44#define AM33XX_CM_GFX_MOD 0x0900
45#define AM33XX_CM_CEFUSE_MOD 0x0A00
46
47/* CM */
48
49/* CM.PER_CM register offsets */
50#define AM33XX_CM_PER_L4LS_CLKSTCTRL_OFFSET 0x0000
51#define AM33XX_CM_PER_L4LS_CLKSTCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0000)
52#define AM33XX_CM_PER_L3S_CLKSTCTRL_OFFSET 0x0004
53#define AM33XX_CM_PER_L3S_CLKSTCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0004)
54#define AM33XX_CM_PER_L4FW_CLKSTCTRL_OFFSET 0x0008
55#define AM33XX_CM_PER_L4FW_CLKSTCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0008)
56#define AM33XX_CM_PER_L3_CLKSTCTRL_OFFSET 0x000c
57#define AM33XX_CM_PER_L3_CLKSTCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x000c)
58#define AM33XX_CM_PER_CPGMAC0_CLKCTRL_OFFSET 0x0014
59#define AM33XX_CM_PER_CPGMAC0_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0014)
60#define AM33XX_CM_PER_LCDC_CLKCTRL_OFFSET 0x0018
61#define AM33XX_CM_PER_LCDC_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0018)
62#define AM33XX_CM_PER_USB0_CLKCTRL_OFFSET 0x001c
63#define AM33XX_CM_PER_USB0_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x001c)
64#define AM33XX_CM_PER_MLB_CLKCTRL_OFFSET 0x0020
65#define AM33XX_CM_PER_MLB_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0020)
66#define AM33XX_CM_PER_TPTC0_CLKCTRL_OFFSET 0x0024
67#define AM33XX_CM_PER_TPTC0_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0024)
68#define AM33XX_CM_PER_EMIF_CLKCTRL_OFFSET 0x0028
69#define AM33XX_CM_PER_EMIF_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0028)
70#define AM33XX_CM_PER_OCMCRAM_CLKCTRL_OFFSET 0x002c
71#define AM33XX_CM_PER_OCMCRAM_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x002c)
72#define AM33XX_CM_PER_GPMC_CLKCTRL_OFFSET 0x0030
73#define AM33XX_CM_PER_GPMC_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0030)
74#define AM33XX_CM_PER_MCASP0_CLKCTRL_OFFSET 0x0034
75#define AM33XX_CM_PER_MCASP0_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0034)
76#define AM33XX_CM_PER_UART5_CLKCTRL_OFFSET 0x0038
77#define AM33XX_CM_PER_UART5_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0038)
78#define AM33XX_CM_PER_MMC0_CLKCTRL_OFFSET 0x003c
79#define AM33XX_CM_PER_MMC0_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x003c)
80#define AM33XX_CM_PER_ELM_CLKCTRL_OFFSET 0x0040
81#define AM33XX_CM_PER_ELM_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0040)
82#define AM33XX_CM_PER_I2C2_CLKCTRL_OFFSET 0x0044
83#define AM33XX_CM_PER_I2C2_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0044)
84#define AM33XX_CM_PER_I2C1_CLKCTRL_OFFSET 0x0048
85#define AM33XX_CM_PER_I2C1_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0048)
86#define AM33XX_CM_PER_SPI0_CLKCTRL_OFFSET 0x004c
87#define AM33XX_CM_PER_SPI0_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x004c)
88#define AM33XX_CM_PER_SPI1_CLKCTRL_OFFSET 0x0050
89#define AM33XX_CM_PER_SPI1_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0050)
90#define AM33XX_CM_PER_SPI2_CLKCTRL_OFFSET 0x0054
91#define AM33XX_CM_PER_SPI2_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0054)
92#define AM33XX_CM_PER_SPI3_CLKCTRL_OFFSET 0x0058
93#define AM33XX_CM_PER_SPI3_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0058)
94#define AM33XX_CM_PER_L4LS_CLKCTRL_OFFSET 0x0060
95#define AM33XX_CM_PER_L4LS_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0060)
96#define AM33XX_CM_PER_L4FW_CLKCTRL_OFFSET 0x0064
97#define AM33XX_CM_PER_L4FW_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0064)
98#define AM33XX_CM_PER_MCASP1_CLKCTRL_OFFSET 0x0068
99#define AM33XX_CM_PER_MCASP1_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0068)
100#define AM33XX_CM_PER_UART1_CLKCTRL_OFFSET 0x006c
101#define AM33XX_CM_PER_UART1_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x006c)
102#define AM33XX_CM_PER_UART2_CLKCTRL_OFFSET 0x0070
103#define AM33XX_CM_PER_UART2_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0070)
104#define AM33XX_CM_PER_UART3_CLKCTRL_OFFSET 0x0074
105#define AM33XX_CM_PER_UART3_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0074)
106#define AM33XX_CM_PER_UART4_CLKCTRL_OFFSET 0x0078
107#define AM33XX_CM_PER_UART4_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0078)
108#define AM33XX_CM_PER_TIMER7_CLKCTRL_OFFSET 0x007c
109#define AM33XX_CM_PER_TIMER7_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x007c)
110#define AM33XX_CM_PER_TIMER2_CLKCTRL_OFFSET 0x0080
111#define AM33XX_CM_PER_TIMER2_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0080)
112#define AM33XX_CM_PER_TIMER3_CLKCTRL_OFFSET 0x0084
113#define AM33XX_CM_PER_TIMER3_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0084)
114#define AM33XX_CM_PER_TIMER4_CLKCTRL_OFFSET 0x0088
115#define AM33XX_CM_PER_TIMER4_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0088)
116#define AM33XX_CM_PER_MCASP2_CLKCTRL_OFFSET 0x008c
117#define AM33XX_CM_PER_MCASP2_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x008c)
118#define AM33XX_CM_PER_RNG_CLKCTRL_OFFSET 0x0090
119#define AM33XX_CM_PER_RNG_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0090)
120#define AM33XX_CM_PER_AES0_CLKCTRL_OFFSET 0x0094
121#define AM33XX_CM_PER_AES0_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0094)
122#define AM33XX_CM_PER_AES1_CLKCTRL_OFFSET 0x0098
123#define AM33XX_CM_PER_AES1_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0098)
124#define AM33XX_CM_PER_DES_CLKCTRL_OFFSET 0x009c
125#define AM33XX_CM_PER_DES_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x009c)
126#define AM33XX_CM_PER_SHA0_CLKCTRL_OFFSET 0x00a0
127#define AM33XX_CM_PER_SHA0_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00a0)
128#define AM33XX_CM_PER_PKA_CLKCTRL_OFFSET 0x00a4
129#define AM33XX_CM_PER_PKA_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00a4)
130#define AM33XX_CM_PER_GPIO6_CLKCTRL_OFFSET 0x00a8
131#define AM33XX_CM_PER_GPIO6_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00a8)
132#define AM33XX_CM_PER_GPIO1_CLKCTRL_OFFSET 0x00ac
133#define AM33XX_CM_PER_GPIO1_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00ac)
134#define AM33XX_CM_PER_GPIO2_CLKCTRL_OFFSET 0x00b0
135#define AM33XX_CM_PER_GPIO2_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00b0)
136#define AM33XX_CM_PER_GPIO3_CLKCTRL_OFFSET 0x00b4
137#define AM33XX_CM_PER_GPIO3_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00b4)
138#define AM33XX_CM_PER_GPIO4_CLKCTRL_OFFSET 0x00b8
139#define AM33XX_CM_PER_GPIO4_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00b8)
140#define AM33XX_CM_PER_TPCC_CLKCTRL_OFFSET 0x00bc
141#define AM33XX_CM_PER_TPCC_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00bc)
142#define AM33XX_CM_PER_DCAN0_CLKCTRL_OFFSET 0x00c0
143#define AM33XX_CM_PER_DCAN0_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00c0)
144#define AM33XX_CM_PER_DCAN1_CLKCTRL_OFFSET 0x00c4
145#define AM33XX_CM_PER_DCAN1_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00c4)
146#define AM33XX_CM_PER_EPWMSS1_CLKCTRL_OFFSET 0x00cc
147#define AM33XX_CM_PER_EPWMSS1_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00cc)
148#define AM33XX_CM_PER_EMIF_FW_CLKCTRL_OFFSET 0x00d0
149#define AM33XX_CM_PER_EMIF_FW_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00d0)
150#define AM33XX_CM_PER_EPWMSS0_CLKCTRL_OFFSET 0x00d4
151#define AM33XX_CM_PER_EPWMSS0_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00d4)
152#define AM33XX_CM_PER_EPWMSS2_CLKCTRL_OFFSET 0x00d8
153#define AM33XX_CM_PER_EPWMSS2_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00d8)
154#define AM33XX_CM_PER_L3_INSTR_CLKCTRL_OFFSET 0x00dc
155#define AM33XX_CM_PER_L3_INSTR_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00dc)
156#define AM33XX_CM_PER_L3_CLKCTRL_OFFSET 0x00e0
157#define AM33XX_CM_PER_L3_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00e0)
158#define AM33XX_CM_PER_IEEE5000_CLKCTRL_OFFSET 0x00e4
159#define AM33XX_CM_PER_IEEE5000_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00e4)
160#define AM33XX_CM_PER_PRUSS_CLKCTRL_OFFSET 0x00e8
161#define AM33XX_CM_PER_PRUSS_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00e8)
162#define AM33XX_CM_PER_TIMER5_CLKCTRL_OFFSET 0x00ec
163#define AM33XX_CM_PER_TIMER5_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00ec)
164#define AM33XX_CM_PER_TIMER6_CLKCTRL_OFFSET 0x00f0
165#define AM33XX_CM_PER_TIMER6_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00f0)
166#define AM33XX_CM_PER_MMC1_CLKCTRL_OFFSET 0x00f4
167#define AM33XX_CM_PER_MMC1_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00f4)
168#define AM33XX_CM_PER_MMC2_CLKCTRL_OFFSET 0x00f8
169#define AM33XX_CM_PER_MMC2_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00f8)
170#define AM33XX_CM_PER_TPTC1_CLKCTRL_OFFSET 0x00fc
171#define AM33XX_CM_PER_TPTC1_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x00fc)
172#define AM33XX_CM_PER_TPTC2_CLKCTRL_OFFSET 0x0100
173#define AM33XX_CM_PER_TPTC2_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0100)
174#define AM33XX_CM_PER_GPIO5_CLKCTRL_OFFSET 0x0104
175#define AM33XX_CM_PER_GPIO5_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0104)
176#define AM33XX_CM_PER_SPINLOCK_CLKCTRL_OFFSET 0x010c
177#define AM33XX_CM_PER_SPINLOCK_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x010c)
178#define AM33XX_CM_PER_MAILBOX0_CLKCTRL_OFFSET 0x0110
179#define AM33XX_CM_PER_MAILBOX0_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0110)
180#define AM33XX_CM_PER_L4HS_CLKSTCTRL_OFFSET 0x011c
181#define AM33XX_CM_PER_L4HS_CLKSTCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x011c)
182#define AM33XX_CM_PER_L4HS_CLKCTRL_OFFSET 0x0120
183#define AM33XX_CM_PER_L4HS_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0120)
184#define AM33XX_CM_PER_MSTR_EXPS_CLKCTRL_OFFSET 0x0124
185#define AM33XX_CM_PER_MSTR_EXPS_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0124)
186#define AM33XX_CM_PER_SLV_EXPS_CLKCTRL_OFFSET 0x0128
187#define AM33XX_CM_PER_SLV_EXPS_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0128)
188#define AM33XX_CM_PER_OCPWP_L3_CLKSTCTRL_OFFSET 0x012c
189#define AM33XX_CM_PER_OCPWP_L3_CLKSTCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x012c)
190#define AM33XX_CM_PER_OCPWP_CLKCTRL_OFFSET 0x0130
191#define AM33XX_CM_PER_OCPWP_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0130)
192#define AM33XX_CM_PER_MAILBOX1_CLKCTRL_OFFSET 0x0134
193#define AM33XX_CM_PER_MAILBOX1_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0134)
194#define AM33XX_CM_PER_PRUSS_CLKSTCTRL_OFFSET 0x0140
195#define AM33XX_CM_PER_PRUSS_CLKSTCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0140)
196#define AM33XX_CM_PER_CPSW_CLKSTCTRL_OFFSET 0x0144
197#define AM33XX_CM_PER_CPSW_CLKSTCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0144)
198#define AM33XX_CM_PER_LCDC_CLKSTCTRL_OFFSET 0x0148
199#define AM33XX_CM_PER_LCDC_CLKSTCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0148)
200#define AM33XX_CM_PER_CLKDIV32K_CLKCTRL_OFFSET 0x014c
201#define AM33XX_CM_PER_CLKDIV32K_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x014c)
202#define AM33XX_CM_PER_CLK_24MHZ_CLKSTCTRL_OFFSET 0x0150
203#define AM33XX_CM_PER_CLK_24MHZ_CLKSTCTRL AM33XX_CM_REGADDR(AM33XX_CM_PER_MOD, 0x0150)
204
205/* CM.WKUP_CM register offsets */
206#define AM33XX_CM_WKUP_CLKSTCTRL_OFFSET 0x0000
207#define AM33XX_CM_WKUP_CLKSTCTRL AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0000)
208#define AM33XX_CM_WKUP_CONTROL_CLKCTRL_OFFSET 0x0004
209#define AM33XX_CM_WKUP_CONTROL_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0004)
210#define AM33XX_CM_WKUP_GPIO0_CLKCTRL_OFFSET 0x0008
211#define AM33XX_CM_WKUP_GPIO0_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0008)
212#define AM33XX_CM_WKUP_L4WKUP_CLKCTRL_OFFSET 0x000c
213#define AM33XX_CM_WKUP_L4WKUP_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x000c)
214#define AM33XX_CM_WKUP_TIMER0_CLKCTRL_OFFSET 0x0010
215#define AM33XX_CM_WKUP_TIMER0_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0010)
216#define AM33XX_CM_WKUP_DEBUGSS_CLKCTRL_OFFSET 0x0014
217#define AM33XX_CM_WKUP_DEBUGSS_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0014)
218#define AM33XX_CM_L3_AON_CLKSTCTRL_OFFSET 0x0018
219#define AM33XX_CM_L3_AON_CLKSTCTRL AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0018)
220#define AM33XX_CM_AUTOIDLE_DPLL_MPU_OFFSET 0x001c
221#define AM33XX_CM_AUTOIDLE_DPLL_MPU AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x001c)
222#define AM33XX_CM_IDLEST_DPLL_MPU_OFFSET 0x0020
223#define AM33XX_CM_IDLEST_DPLL_MPU AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0020)
224#define AM33XX_CM_SSC_DELTAMSTEP_DPLL_MPU_OFFSET 0x0024
225#define AM33XX_CM_SSC_DELTAMSTEP_DPLL_MPU AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0024)
226#define AM33XX_CM_SSC_MODFREQDIV_DPLL_MPU_OFFSET 0x0028
227#define AM33XX_CM_SSC_MODFREQDIV_DPLL_MPU AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0028)
228#define AM33XX_CM_CLKSEL_DPLL_MPU_OFFSET 0x002c
229#define AM33XX_CM_CLKSEL_DPLL_MPU AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x002c)
230#define AM33XX_CM_AUTOIDLE_DPLL_DDR_OFFSET 0x0030
231#define AM33XX_CM_AUTOIDLE_DPLL_DDR AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0030)
232#define AM33XX_CM_IDLEST_DPLL_DDR_OFFSET 0x0034
233#define AM33XX_CM_IDLEST_DPLL_DDR AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0034)
234#define AM33XX_CM_SSC_DELTAMSTEP_DPLL_DDR_OFFSET 0x0038
235#define AM33XX_CM_SSC_DELTAMSTEP_DPLL_DDR AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0038)
236#define AM33XX_CM_SSC_MODFREQDIV_DPLL_DDR_OFFSET 0x003c
237#define AM33XX_CM_SSC_MODFREQDIV_DPLL_DDR AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x003c)
238#define AM33XX_CM_CLKSEL_DPLL_DDR_OFFSET 0x0040
239#define AM33XX_CM_CLKSEL_DPLL_DDR AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0040)
240#define AM33XX_CM_AUTOIDLE_DPLL_DISP_OFFSET 0x0044
241#define AM33XX_CM_AUTOIDLE_DPLL_DISP AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0044)
242#define AM33XX_CM_IDLEST_DPLL_DISP_OFFSET 0x0048
243#define AM33XX_CM_IDLEST_DPLL_DISP AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0048)
244#define AM33XX_CM_SSC_DELTAMSTEP_DPLL_DISP_OFFSET 0x004c
245#define AM33XX_CM_SSC_DELTAMSTEP_DPLL_DISP AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x004c)
246#define AM33XX_CM_SSC_MODFREQDIV_DPLL_DISP_OFFSET 0x0050
247#define AM33XX_CM_SSC_MODFREQDIV_DPLL_DISP AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0050)
248#define AM33XX_CM_CLKSEL_DPLL_DISP_OFFSET 0x0054
249#define AM33XX_CM_CLKSEL_DPLL_DISP AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0054)
250#define AM33XX_CM_AUTOIDLE_DPLL_CORE_OFFSET 0x0058
251#define AM33XX_CM_AUTOIDLE_DPLL_CORE AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0058)
252#define AM33XX_CM_IDLEST_DPLL_CORE_OFFSET 0x005c
253#define AM33XX_CM_IDLEST_DPLL_CORE AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x005c)
254#define AM33XX_CM_SSC_DELTAMSTEP_DPLL_CORE_OFFSET 0x0060
255#define AM33XX_CM_SSC_DELTAMSTEP_DPLL_CORE AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0060)
256#define AM33XX_CM_SSC_MODFREQDIV_DPLL_CORE_OFFSET 0x0064
257#define AM33XX_CM_SSC_MODFREQDIV_DPLL_CORE AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0064)
258#define AM33XX_CM_CLKSEL_DPLL_CORE_OFFSET 0x0068
259#define AM33XX_CM_CLKSEL_DPLL_CORE AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0068)
260#define AM33XX_CM_AUTOIDLE_DPLL_PER_OFFSET 0x006c
261#define AM33XX_CM_AUTOIDLE_DPLL_PER AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x006c)
262#define AM33XX_CM_IDLEST_DPLL_PER_OFFSET 0x0070
263#define AM33XX_CM_IDLEST_DPLL_PER AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0070)
264#define AM33XX_CM_SSC_DELTAMSTEP_DPLL_PER_OFFSET 0x0074
265#define AM33XX_CM_SSC_DELTAMSTEP_DPLL_PER AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0074)
266#define AM33XX_CM_SSC_MODFREQDIV_DPLL_PER_OFFSET 0x0078
267#define AM33XX_CM_SSC_MODFREQDIV_DPLL_PER AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0078)
268#define AM33XX_CM_CLKDCOLDO_DPLL_PER_OFFSET 0x007c
269#define AM33XX_CM_CLKDCOLDO_DPLL_PER AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x007c)
270#define AM33XX_CM_DIV_M4_DPLL_CORE_OFFSET 0x0080
271#define AM33XX_CM_DIV_M4_DPLL_CORE AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0080)
272#define AM33XX_CM_DIV_M5_DPLL_CORE_OFFSET 0x0084
273#define AM33XX_CM_DIV_M5_DPLL_CORE AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0084)
274#define AM33XX_CM_CLKMODE_DPLL_MPU_OFFSET 0x0088
275#define AM33XX_CM_CLKMODE_DPLL_MPU AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0088)
276#define AM33XX_CM_CLKMODE_DPLL_PER_OFFSET 0x008c
277#define AM33XX_CM_CLKMODE_DPLL_PER AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x008c)
278#define AM33XX_CM_CLKMODE_DPLL_CORE_OFFSET 0x0090
279#define AM33XX_CM_CLKMODE_DPLL_CORE AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0090)
280#define AM33XX_CM_CLKMODE_DPLL_DDR_OFFSET 0x0094
281#define AM33XX_CM_CLKMODE_DPLL_DDR AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0094)
282#define AM33XX_CM_CLKMODE_DPLL_DISP_OFFSET 0x0098
283#define AM33XX_CM_CLKMODE_DPLL_DISP AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x0098)
284#define AM33XX_CM_CLKSEL_DPLL_PERIPH_OFFSET 0x009c
285#define AM33XX_CM_CLKSEL_DPLL_PERIPH AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x009c)
286#define AM33XX_CM_DIV_M2_DPLL_DDR_OFFSET 0x00a0
287#define AM33XX_CM_DIV_M2_DPLL_DDR AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x00a0)
288#define AM33XX_CM_DIV_M2_DPLL_DISP_OFFSET 0x00a4
289#define AM33XX_CM_DIV_M2_DPLL_DISP AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x00a4)
290#define AM33XX_CM_DIV_M2_DPLL_MPU_OFFSET 0x00a8
291#define AM33XX_CM_DIV_M2_DPLL_MPU AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x00a8)
292#define AM33XX_CM_DIV_M2_DPLL_PER_OFFSET 0x00ac
293#define AM33XX_CM_DIV_M2_DPLL_PER AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x00ac)
294#define AM33XX_CM_WKUP_WKUP_M3_CLKCTRL_OFFSET 0x00b0
295#define AM33XX_CM_WKUP_WKUP_M3_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x00b0)
296#define AM33XX_CM_WKUP_UART0_CLKCTRL_OFFSET 0x00b4
297#define AM33XX_CM_WKUP_UART0_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x00b4)
298#define AM33XX_CM_WKUP_I2C0_CLKCTRL_OFFSET 0x00b8
299#define AM33XX_CM_WKUP_I2C0_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x00b8)
300#define AM33XX_CM_WKUP_ADC_TSC_CLKCTRL_OFFSET 0x00bc
301#define AM33XX_CM_WKUP_ADC_TSC_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x00bc)
302#define AM33XX_CM_WKUP_SMARTREFLEX0_CLKCTRL_OFFSET 0x00c0
303#define AM33XX_CM_WKUP_SMARTREFLEX0_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x00c0)
304#define AM33XX_CM_WKUP_TIMER1_CLKCTRL_OFFSET 0x00c4
305#define AM33XX_CM_WKUP_TIMER1_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x00c4)
306#define AM33XX_CM_WKUP_SMARTREFLEX1_CLKCTRL_OFFSET 0x00c8
307#define AM33XX_CM_WKUP_SMARTREFLEX1_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x00c8)
308#define AM33XX_CM_L4_WKUP_AON_CLKSTCTRL_OFFSET 0x00cc
309#define AM33XX_CM_L4_WKUP_AON_CLKSTCTRL AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x00cc)
310#define AM33XX_CM_WKUP_WDT0_CLKCTRL_OFFSET 0x00d0
311#define AM33XX_CM_WKUP_WDT0_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x00d0)
312#define AM33XX_CM_WKUP_WDT1_CLKCTRL_OFFSET 0x00d4
313#define AM33XX_CM_WKUP_WDT1_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x00d4)
314#define AM33XX_CM_DIV_M6_DPLL_CORE_OFFSET 0x00d8
315#define AM33XX_CM_DIV_M6_DPLL_CORE AM33XX_CM_REGADDR(AM33XX_CM_WKUP_MOD, 0x00d8)
316
317/* CM.DPLL_CM register offsets */
318#define AM33XX_CLKSEL_TIMER7_CLK_OFFSET 0x0004
319#define AM33XX_CLKSEL_TIMER7_CLK AM33XX_CM_REGADDR(AM33XX_CM_DPLL_MOD, 0x0004)
320#define AM33XX_CLKSEL_TIMER2_CLK_OFFSET 0x0008
321#define AM33XX_CLKSEL_TIMER2_CLK AM33XX_CM_REGADDR(AM33XX_CM_DPLL_MOD, 0x0008)
322#define AM33XX_CLKSEL_TIMER3_CLK_OFFSET 0x000c
323#define AM33XX_CLKSEL_TIMER3_CLK AM33XX_CM_REGADDR(AM33XX_CM_DPLL_MOD, 0x000c)
324#define AM33XX_CLKSEL_TIMER4_CLK_OFFSET 0x0010
325#define AM33XX_CLKSEL_TIMER4_CLK AM33XX_CM_REGADDR(AM33XX_CM_DPLL_MOD, 0x0010)
326#define AM33XX_CM_MAC_CLKSEL_OFFSET 0x0014
327#define AM33XX_CM_MAC_CLKSEL AM33XX_CM_REGADDR(AM33XX_CM_DPLL_MOD, 0x0014)
328#define AM33XX_CLKSEL_TIMER5_CLK_OFFSET 0x0018
329#define AM33XX_CLKSEL_TIMER5_CLK AM33XX_CM_REGADDR(AM33XX_CM_DPLL_MOD, 0x0018)
330#define AM33XX_CLKSEL_TIMER6_CLK_OFFSET 0x001c
331#define AM33XX_CLKSEL_TIMER6_CLK AM33XX_CM_REGADDR(AM33XX_CM_DPLL_MOD, 0x001c)
332#define AM33XX_CM_CPTS_RFT_CLKSEL_OFFSET 0x0020
333#define AM33XX_CM_CPTS_RFT_CLKSEL AM33XX_CM_REGADDR(AM33XX_CM_DPLL_MOD, 0x0020)
334#define AM33XX_CLKSEL_TIMER1MS_CLK_OFFSET 0x0028
335#define AM33XX_CLKSEL_TIMER1MS_CLK AM33XX_CM_REGADDR(AM33XX_CM_DPLL_MOD, 0x0028)
336#define AM33XX_CLKSEL_GFX_FCLK_OFFSET 0x002c
337#define AM33XX_CLKSEL_GFX_FCLK AM33XX_CM_REGADDR(AM33XX_CM_DPLL_MOD, 0x002c)
338#define AM33XX_CLKSEL_PRUSS_OCP_CLK_OFFSET 0x0030
339#define AM33XX_CLKSEL_PRUSS_OCP_CLK AM33XX_CM_REGADDR(AM33XX_CM_DPLL_MOD, 0x0030)
340#define AM33XX_CLKSEL_LCDC_PIXEL_CLK_OFFSET 0x0034
341#define AM33XX_CLKSEL_LCDC_PIXEL_CLK AM33XX_CM_REGADDR(AM33XX_CM_DPLL_MOD, 0x0034)
342#define AM33XX_CLKSEL_WDT1_CLK_OFFSET 0x0038
343#define AM33XX_CLKSEL_WDT1_CLK AM33XX_CM_REGADDR(AM33XX_CM_DPLL_MOD, 0x0038)
344#define AM33XX_CLKSEL_GPIO0_DBCLK_OFFSET 0x003c
345#define AM33XX_CLKSEL_GPIO0_DBCLK AM33XX_CM_REGADDR(AM33XX_CM_DPLL_MOD, 0x003c)
346
347/* CM.MPU_CM register offsets */
348#define AM33XX_CM_MPU_CLKSTCTRL_OFFSET 0x0000
349#define AM33XX_CM_MPU_CLKSTCTRL AM33XX_CM_REGADDR(AM33XX_CM_MPU_MOD, 0x0000)
350#define AM33XX_CM_MPU_MPU_CLKCTRL_OFFSET 0x0004
351#define AM33XX_CM_MPU_MPU_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_MPU_MOD, 0x0004)
352
353/* CM.DEVICE_CM register offsets */
354#define AM33XX_CM_CLKOUT_CTRL_OFFSET 0x0000
355#define AM33XX_CM_CLKOUT_CTRL AM33XX_CM_REGADDR(AM33XX_CM_DEVICE_MOD, 0x0000)
356
357/* CM.RTC_CM register offsets */
358#define AM33XX_CM_RTC_RTC_CLKCTRL_OFFSET 0x0000
359#define AM33XX_CM_RTC_RTC_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_RTC_MOD, 0x0000)
360#define AM33XX_CM_RTC_CLKSTCTRL_OFFSET 0x0004
361#define AM33XX_CM_RTC_CLKSTCTRL AM33XX_CM_REGADDR(AM33XX_CM_RTC_MOD, 0x0004)
362
363/* CM.GFX_CM register offsets */
364#define AM33XX_CM_GFX_L3_CLKSTCTRL_OFFSET 0x0000
365#define AM33XX_CM_GFX_L3_CLKSTCTRL AM33XX_CM_REGADDR(AM33XX_CM_GFX_MOD, 0x0000)
366#define AM33XX_CM_GFX_GFX_CLKCTRL_OFFSET 0x0004
367#define AM33XX_CM_GFX_GFX_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_GFX_MOD, 0x0004)
368#define AM33XX_CM_GFX_BITBLT_CLKCTRL_OFFSET 0x0008
369#define AM33XX_CM_GFX_BITBLT_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_GFX_MOD, 0x0008)
370#define AM33XX_CM_GFX_L4LS_GFX_CLKSTCTRL__1_OFFSET 0x000c
371#define AM33XX_CM_GFX_L4LS_GFX_CLKSTCTRL__1 AM33XX_CM_REGADDR(AM33XX_CM_GFX_MOD, 0x000c)
372#define AM33XX_CM_GFX_MMUCFG_CLKCTRL_OFFSET 0x0010
373#define AM33XX_CM_GFX_MMUCFG_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_GFX_MOD, 0x0010)
374#define AM33XX_CM_GFX_MMUDATA_CLKCTRL_OFFSET 0x0014
375#define AM33XX_CM_GFX_MMUDATA_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_GFX_MOD, 0x0014)
376
377/* CM.CEFUSE_CM register offsets */
378#define AM33XX_CM_CEFUSE_CLKSTCTRL_OFFSET 0x0000
379#define AM33XX_CM_CEFUSE_CLKSTCTRL AM33XX_CM_REGADDR(AM33XX_CM_CEFUSE_MOD, 0x0000)
380#define AM33XX_CM_CEFUSE_CEFUSE_CLKCTRL_OFFSET 0x0020
381#define AM33XX_CM_CEFUSE_CEFUSE_CLKCTRL AM33XX_CM_REGADDR(AM33XX_CM_CEFUSE_MOD, 0x0020)
382
383
384extern bool am33xx_cm_is_clkdm_in_hwsup(s16 inst, u16 cdoffs);
385extern void am33xx_cm_clkdm_enable_hwsup(s16 inst, u16 cdoffs);
386extern void am33xx_cm_clkdm_disable_hwsup(s16 inst, u16 cdoffs);
387extern void am33xx_cm_clkdm_force_sleep(s16 inst, u16 cdoffs);
388extern void am33xx_cm_clkdm_force_wakeup(s16 inst, u16 cdoffs);
389
390#ifdef CONFIG_SOC_AM33XX
391extern int am33xx_cm_wait_module_idle(u16 inst, s16 cdoffs,
392 u16 clkctrl_offs);
393extern void am33xx_cm_module_enable(u8 mode, u16 inst, s16 cdoffs,
394 u16 clkctrl_offs);
395extern void am33xx_cm_module_disable(u16 inst, s16 cdoffs,
396 u16 clkctrl_offs);
397extern int am33xx_cm_wait_module_ready(u16 inst, s16 cdoffs,
398 u16 clkctrl_offs);
399#else
400static inline int am33xx_cm_wait_module_idle(u16 inst, s16 cdoffs,
401 u16 clkctrl_offs)
402{
403 return 0;
404}
405static inline void am33xx_cm_module_enable(u8 mode, u16 inst, s16 cdoffs,
406 u16 clkctrl_offs)
407{
408}
409static inline void am33xx_cm_module_disable(u16 inst, s16 cdoffs,
410 u16 clkctrl_offs)
411{
412}
413static inline int am33xx_cm_wait_module_ready(u16 inst, s16 cdoffs,
414 u16 clkctrl_offs)
415{
416 return 0;
417}
418#endif
419
420#endif
diff --git a/arch/arm/mach-omap2/cminst44xx.c b/arch/arm/mach-omap2/cminst44xx.c
index 1a39945d9ff..1894015ff04 100644
--- a/arch/arm/mach-omap2/cminst44xx.c
+++ b/arch/arm/mach-omap2/cminst44xx.c
@@ -235,20 +235,6 @@ void omap4_cminst_clkdm_disable_hwsup(u8 part, s16 inst, u16 cdoffs)
235} 235}
236 236
237/** 237/**
238 * omap4_cminst_clkdm_force_sleep - try to put a clockdomain into idle
239 * @part: PRCM partition ID that the clockdomain registers exist in
240 * @inst: CM instance register offset (*_INST macro)
241 * @cdoffs: Clockdomain register offset (*_CDOFFS macro)
242 *
243 * Put a clockdomain referred to by (@part, @inst, @cdoffs) into idle
244 * No return value.
245 */
246void omap4_cminst_clkdm_force_sleep(u8 part, s16 inst, u16 cdoffs)
247{
248 _clktrctrl_write(OMAP34XX_CLKSTCTRL_FORCE_SLEEP, part, inst, cdoffs);
249}
250
251/**
252 * omap4_cminst_clkdm_force_sleep - try to take a clockdomain out of idle 238 * omap4_cminst_clkdm_force_sleep - try to take a clockdomain out of idle
253 * @part: PRCM partition ID that the clockdomain registers exist in 239 * @part: PRCM partition ID that the clockdomain registers exist in
254 * @inst: CM instance register offset (*_INST macro) 240 * @inst: CM instance register offset (*_INST macro)
diff --git a/arch/arm/mach-omap2/cminst44xx.h b/arch/arm/mach-omap2/cminst44xx.h
index a018a732787..d69fdefef98 100644
--- a/arch/arm/mach-omap2/cminst44xx.h
+++ b/arch/arm/mach-omap2/cminst44xx.h
@@ -16,38 +16,13 @@ extern void omap4_cminst_clkdm_enable_hwsup(u8 part, s16 inst, u16 cdoffs);
16extern void omap4_cminst_clkdm_disable_hwsup(u8 part, s16 inst, u16 cdoffs); 16extern void omap4_cminst_clkdm_disable_hwsup(u8 part, s16 inst, u16 cdoffs);
17extern void omap4_cminst_clkdm_force_sleep(u8 part, s16 inst, u16 cdoffs); 17extern void omap4_cminst_clkdm_force_sleep(u8 part, s16 inst, u16 cdoffs);
18extern void omap4_cminst_clkdm_force_wakeup(u8 part, s16 inst, u16 cdoffs); 18extern void omap4_cminst_clkdm_force_wakeup(u8 part, s16 inst, u16 cdoffs);
19
20extern int omap4_cminst_wait_module_ready(u8 part, u16 inst, s16 cdoffs, u16 clkctrl_offs); 19extern int omap4_cminst_wait_module_ready(u8 part, u16 inst, s16 cdoffs, u16 clkctrl_offs);
21
22# ifdef CONFIG_ARCH_OMAP4
23extern int omap4_cminst_wait_module_idle(u8 part, u16 inst, s16 cdoffs, 20extern int omap4_cminst_wait_module_idle(u8 part, u16 inst, s16 cdoffs,
24 u16 clkctrl_offs); 21 u16 clkctrl_offs);
25
26extern void omap4_cminst_module_enable(u8 mode, u8 part, u16 inst, s16 cdoffs, 22extern void omap4_cminst_module_enable(u8 mode, u8 part, u16 inst, s16 cdoffs,
27 u16 clkctrl_offs); 23 u16 clkctrl_offs);
28extern void omap4_cminst_module_disable(u8 part, u16 inst, s16 cdoffs, 24extern void omap4_cminst_module_disable(u8 part, u16 inst, s16 cdoffs,
29 u16 clkctrl_offs); 25 u16 clkctrl_offs);
30
31# else
32
33static inline int omap4_cminst_wait_module_idle(u8 part, u16 inst, s16 cdoffs,
34 u16 clkctrl_offs)
35{
36 return 0;
37}
38
39static inline void omap4_cminst_module_enable(u8 mode, u8 part, u16 inst,
40 s16 cdoffs, u16 clkctrl_offs)
41{
42}
43
44static inline void omap4_cminst_module_disable(u8 part, u16 inst, s16 cdoffs,
45 u16 clkctrl_offs)
46{
47}
48
49# endif
50
51/* 26/*
52 * In an ideal world, we would not export these low-level functions, 27 * In an ideal world, we would not export these low-level functions,
53 * but this will probably take some time to fix properly 28 * but this will probably take some time to fix properly
diff --git a/arch/arm/mach-omap2/common-board-devices.c b/arch/arm/mach-omap2/common-board-devices.c
index 1706ebcec08..c1875862679 100644
--- a/arch/arm/mach-omap2/common-board-devices.c
+++ b/arch/arm/mach-omap2/common-board-devices.c
@@ -63,28 +63,30 @@ void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
63 struct spi_board_info *spi_bi = &ads7846_spi_board_info; 63 struct spi_board_info *spi_bi = &ads7846_spi_board_info;
64 int err; 64 int err;
65 65
66 if (board_pdata && board_pdata->get_pendown_state) { 66 err = gpio_request_one(gpio_pendown, GPIOF_IN, "TSPenDown");
67 err = gpio_request_one(gpio_pendown, GPIOF_IN, "TSPenDown"); 67 if (err) {
68 if (err) { 68 pr_err("Couldn't obtain gpio for TSPenDown: %d\n", err);
69 pr_err("Couldn't obtain gpio for TSPenDown: %d\n", err); 69 return;
70 return;
71 }
72 gpio_export(gpio_pendown, 0);
73
74 if (gpio_debounce)
75 gpio_set_debounce(gpio_pendown, gpio_debounce);
76 } 70 }
77 71
72 if (gpio_debounce)
73 gpio_set_debounce(gpio_pendown, gpio_debounce);
74
78 spi_bi->bus_num = bus_num; 75 spi_bi->bus_num = bus_num;
79 spi_bi->irq = gpio_to_irq(gpio_pendown); 76 spi_bi->irq = gpio_to_irq(gpio_pendown);
80 77
81 if (board_pdata) { 78 if (board_pdata) {
82 board_pdata->gpio_pendown = gpio_pendown; 79 board_pdata->gpio_pendown = gpio_pendown;
83 spi_bi->platform_data = board_pdata; 80 spi_bi->platform_data = board_pdata;
81 if (board_pdata->get_pendown_state)
82 gpio_export(gpio_pendown, 0);
84 } else { 83 } else {
85 ads7846_config.gpio_pendown = gpio_pendown; 84 ads7846_config.gpio_pendown = gpio_pendown;
86 } 85 }
87 86
87 if (!board_pdata || (board_pdata && !board_pdata->get_pendown_state))
88 gpio_free(gpio_pendown);
89
88 spi_register_board_info(&ads7846_spi_board_info, 1); 90 spi_register_board_info(&ads7846_spi_board_info, 1);
89} 91}
90#else 92#else
diff --git a/arch/arm/mach-omap2/common.c b/arch/arm/mach-omap2/common.c
index 8a6953a34fe..069f9725b1c 100644
--- a/arch/arm/mach-omap2/common.c
+++ b/arch/arm/mach-omap2/common.c
@@ -29,8 +29,6 @@
29 29
30/* Global address base setup code */ 30/* Global address base setup code */
31 31
32#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
33
34static void __init __omap2_set_globals(struct omap_globals *omap2_globals) 32static void __init __omap2_set_globals(struct omap_globals *omap2_globals)
35{ 33{
36 omap2_set_globals_tap(omap2_globals); 34 omap2_set_globals_tap(omap2_globals);
@@ -39,8 +37,6 @@ static void __init __omap2_set_globals(struct omap_globals *omap2_globals)
39 omap2_set_globals_prcm(omap2_globals); 37 omap2_set_globals_prcm(omap2_globals);
40} 38}
41 39
42#endif
43
44#if defined(CONFIG_SOC_OMAP2420) 40#if defined(CONFIG_SOC_OMAP2420)
45 41
46static struct omap_globals omap242x_globals = { 42static struct omap_globals omap242x_globals = {
@@ -134,7 +130,9 @@ void __init ti81xx_map_io(void)
134{ 130{
135 omapti81xx_map_common_io(); 131 omapti81xx_map_common_io();
136} 132}
133#endif
137 134
135#if defined(CONFIG_SOC_AM33XX)
138#define AM33XX_TAP_BASE (AM33XX_CTRL_BASE + \ 136#define AM33XX_TAP_BASE (AM33XX_CTRL_BASE + \
139 TI81XX_CONTROL_DEVICE_ID - 0x204) 137 TI81XX_CONTROL_DEVICE_ID - 0x204)
140 138
@@ -171,9 +169,7 @@ static struct omap_globals omap4_globals = {
171 169
172void __init omap2_set_globals_443x(void) 170void __init omap2_set_globals_443x(void)
173{ 171{
174 omap2_set_globals_tap(&omap4_globals); 172 __omap2_set_globals(&omap4_globals);
175 omap2_set_globals_control(&omap4_globals);
176 omap2_set_globals_prcm(&omap4_globals);
177} 173}
178 174
179void __init omap4_map_io(void) 175void __init omap4_map_io(void)
@@ -182,3 +178,27 @@ void __init omap4_map_io(void)
182} 178}
183#endif 179#endif
184 180
181#if defined(CONFIG_SOC_OMAP5)
182static struct omap_globals omap5_globals = {
183 .class = OMAP54XX_CLASS,
184 .tap = OMAP2_L4_IO_ADDRESS(OMAP54XX_SCM_BASE),
185 .ctrl = OMAP2_L4_IO_ADDRESS(OMAP54XX_SCM_BASE),
186 .ctrl_pad = OMAP2_L4_IO_ADDRESS(OMAP54XX_CTRL_BASE),
187 .prm = OMAP2_L4_IO_ADDRESS(OMAP54XX_PRM_BASE),
188 .cm = OMAP2_L4_IO_ADDRESS(OMAP54XX_CM_CORE_AON_BASE),
189 .cm2 = OMAP2_L4_IO_ADDRESS(OMAP54XX_CM_CORE_BASE),
190 .prcm_mpu = OMAP2_L4_IO_ADDRESS(OMAP54XX_PRCM_MPU_BASE),
191};
192
193void __init omap2_set_globals_5xxx(void)
194{
195 omap2_set_globals_tap(&omap5_globals);
196 omap2_set_globals_control(&omap5_globals);
197 omap2_set_globals_prcm(&omap5_globals);
198}
199
200void __init omap5_map_io(void)
201{
202 omap5_map_common_io();
203}
204#endif
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
index be9dfd1abe6..1f65b1871c2 100644
--- a/arch/arm/mach-omap2/common.h
+++ b/arch/arm/mach-omap2/common.h
@@ -115,12 +115,22 @@ static inline int omap_mux_late_init(void)
115} 115}
116#endif 116#endif
117 117
118#ifdef CONFIG_SOC_OMAP5
119extern void omap5_map_common_io(void);
120#else
121static inline void omap5_map_common_io(void)
122{
123}
124#endif
125
118extern void omap2_init_common_infrastructure(void); 126extern void omap2_init_common_infrastructure(void);
119 127
120extern struct sys_timer omap2_timer; 128extern struct sys_timer omap2_timer;
121extern struct sys_timer omap3_timer; 129extern struct sys_timer omap3_timer;
122extern struct sys_timer omap3_secure_timer; 130extern struct sys_timer omap3_secure_timer;
131extern struct sys_timer omap3_am33xx_timer;
123extern struct sys_timer omap4_timer; 132extern struct sys_timer omap4_timer;
133extern struct sys_timer omap5_timer;
124 134
125void omap2420_init_early(void); 135void omap2420_init_early(void);
126void omap2430_init_early(void); 136void omap2430_init_early(void);
@@ -128,9 +138,12 @@ void omap3430_init_early(void);
128void omap35xx_init_early(void); 138void omap35xx_init_early(void);
129void omap3630_init_early(void); 139void omap3630_init_early(void);
130void omap3_init_early(void); /* Do not use this one */ 140void omap3_init_early(void); /* Do not use this one */
141void am33xx_init_early(void);
131void am35xx_init_early(void); 142void am35xx_init_early(void);
132void ti81xx_init_early(void); 143void ti81xx_init_early(void);
144void am33xx_init_early(void);
133void omap4430_init_early(void); 145void omap4430_init_early(void);
146void omap5_init_early(void);
134void omap3_init_late(void); /* Do not use this one */ 147void omap3_init_late(void); /* Do not use this one */
135void omap4430_init_late(void); 148void omap4430_init_late(void);
136void omap2420_init_late(void); 149void omap2420_init_late(void);
@@ -166,12 +179,18 @@ void omap2_set_globals_242x(void);
166void omap2_set_globals_243x(void); 179void omap2_set_globals_243x(void);
167void omap2_set_globals_3xxx(void); 180void omap2_set_globals_3xxx(void);
168void omap2_set_globals_443x(void); 181void omap2_set_globals_443x(void);
182void omap2_set_globals_5xxx(void);
169void omap2_set_globals_ti81xx(void); 183void omap2_set_globals_ti81xx(void);
170void omap2_set_globals_am33xx(void); 184void omap2_set_globals_am33xx(void);
171 185
172/* These get called from omap2_set_globals_xxxx(), do not call these */ 186/* These get called from omap2_set_globals_xxxx(), do not call these */
173void omap2_set_globals_tap(struct omap_globals *); 187void omap2_set_globals_tap(struct omap_globals *);
188#if defined(CONFIG_SOC_HAS_OMAP2_SDRC)
174void omap2_set_globals_sdrc(struct omap_globals *); 189void omap2_set_globals_sdrc(struct omap_globals *);
190#else
191static inline void omap2_set_globals_sdrc(struct omap_globals *omap2_globals)
192{ }
193#endif
175void omap2_set_globals_control(struct omap_globals *); 194void omap2_set_globals_control(struct omap_globals *);
176void omap2_set_globals_prcm(struct omap_globals *); 195void omap2_set_globals_prcm(struct omap_globals *);
177 196
@@ -180,6 +199,7 @@ void omap243x_map_io(void);
180void omap3_map_io(void); 199void omap3_map_io(void);
181void am33xx_map_io(void); 200void am33xx_map_io(void);
182void omap4_map_io(void); 201void omap4_map_io(void);
202void omap5_map_io(void);
183void ti81xx_map_io(void); 203void ti81xx_map_io(void);
184void omap_barriers_init(void); 204void omap_barriers_init(void);
185 205
@@ -219,6 +239,8 @@ void omap3_intc_prepare_idle(void);
219void omap3_intc_resume_idle(void); 239void omap3_intc_resume_idle(void);
220void omap2_intc_handle_irq(struct pt_regs *regs); 240void omap2_intc_handle_irq(struct pt_regs *regs);
221void omap3_intc_handle_irq(struct pt_regs *regs); 241void omap3_intc_handle_irq(struct pt_regs *regs);
242void omap_intc_of_init(void);
243void omap_gic_of_init(void);
222 244
223#ifdef CONFIG_CACHE_L2X0 245#ifdef CONFIG_CACHE_L2X0
224extern void __iomem *omap4_get_l2cache_base(void); 246extern void __iomem *omap4_get_l2cache_base(void);
@@ -226,10 +248,10 @@ extern void __iomem *omap4_get_l2cache_base(void);
226 248
227struct device_node; 249struct device_node;
228#ifdef CONFIG_OF 250#ifdef CONFIG_OF
229int __init omap_intc_of_init(struct device_node *node, 251int __init intc_of_init(struct device_node *node,
230 struct device_node *parent); 252 struct device_node *parent);
231#else 253#else
232int __init omap_intc_of_init(struct device_node *node, 254int __init intc_of_init(struct device_node *node,
233 struct device_node *parent) 255 struct device_node *parent)
234{ 256{
235 return 0; 257 return 0;
@@ -256,6 +278,7 @@ extern void omap_secondary_startup(void);
256extern u32 omap_modify_auxcoreboot0(u32 set_mask, u32 clear_mask); 278extern u32 omap_modify_auxcoreboot0(u32 set_mask, u32 clear_mask);
257extern void omap_auxcoreboot_addr(u32 cpu_addr); 279extern void omap_auxcoreboot_addr(u32 cpu_addr);
258extern u32 omap_read_auxcoreboot0(void); 280extern u32 omap_read_auxcoreboot0(void);
281extern void omap5_secondary_startup(void);
259#endif 282#endif
260 283
261#if defined(CONFIG_SMP) && defined(CONFIG_PM) 284#if defined(CONFIG_SMP) && defined(CONFIG_PM)
diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
index 08e674bb041..3223b81e753 100644
--- a/arch/arm/mach-omap2/control.c
+++ b/arch/arm/mach-omap2/control.c
@@ -241,6 +241,49 @@ void omap3_ctrl_write_boot_mode(u8 bootmode)
241 241
242#endif 242#endif
243 243
244/**
245 * omap_ctrl_write_dsp_boot_addr - set boot address for a remote processor
246 * @bootaddr: physical address of the boot loader
247 *
248 * Set boot address for the boot loader of a supported processor
249 * when a power ON sequence occurs.
250 */
251void omap_ctrl_write_dsp_boot_addr(u32 bootaddr)
252{
253 u32 offset = cpu_is_omap243x() ? OMAP243X_CONTROL_IVA2_BOOTADDR :
254 cpu_is_omap34xx() ? OMAP343X_CONTROL_IVA2_BOOTADDR :
255 cpu_is_omap44xx() ? OMAP4_CTRL_MODULE_CORE_DSP_BOOTADDR :
256 0;
257
258 if (!offset) {
259 pr_err("%s: unsupported omap type\n", __func__);
260 return;
261 }
262
263 omap_ctrl_writel(bootaddr, offset);
264}
265
266/**
267 * omap_ctrl_write_dsp_boot_mode - set boot mode for a remote processor
268 * @bootmode: 8-bit value to pass to some boot code
269 *
270 * Sets boot mode for the boot loader of a supported processor
271 * when a power ON sequence occurs.
272 */
273void omap_ctrl_write_dsp_boot_mode(u8 bootmode)
274{
275 u32 offset = cpu_is_omap243x() ? OMAP243X_CONTROL_IVA2_BOOTMOD :
276 cpu_is_omap34xx() ? OMAP343X_CONTROL_IVA2_BOOTMOD :
277 0;
278
279 if (!offset) {
280 pr_err("%s: unsupported omap type\n", __func__);
281 return;
282 }
283
284 omap_ctrl_writel(bootmode, offset);
285}
286
244#if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM) 287#if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
245/* 288/*
246 * Clears the scratchpad contents in case of cold boot- 289 * Clears the scratchpad contents in case of cold boot-
diff --git a/arch/arm/mach-omap2/control.h b/arch/arm/mach-omap2/control.h
index a406fd045ce..b8cdc8531b6 100644
--- a/arch/arm/mach-omap2/control.h
+++ b/arch/arm/mach-omap2/control.h
@@ -21,6 +21,8 @@
21#include <mach/ctrl_module_pad_core_44xx.h> 21#include <mach/ctrl_module_pad_core_44xx.h>
22#include <mach/ctrl_module_pad_wkup_44xx.h> 22#include <mach/ctrl_module_pad_wkup_44xx.h>
23 23
24#include <plat/am33xx.h>
25
24#ifndef __ASSEMBLY__ 26#ifndef __ASSEMBLY__
25#define OMAP242X_CTRL_REGADDR(reg) \ 27#define OMAP242X_CTRL_REGADDR(reg) \
26 OMAP2_L4_IO_ADDRESS(OMAP242X_CTRL_BASE + (reg)) 28 OMAP2_L4_IO_ADDRESS(OMAP242X_CTRL_BASE + (reg))
@@ -28,6 +30,8 @@
28 OMAP2_L4_IO_ADDRESS(OMAP243X_CTRL_BASE + (reg)) 30 OMAP2_L4_IO_ADDRESS(OMAP243X_CTRL_BASE + (reg))
29#define OMAP343X_CTRL_REGADDR(reg) \ 31#define OMAP343X_CTRL_REGADDR(reg) \
30 OMAP2_L4_IO_ADDRESS(OMAP343X_CTRL_BASE + (reg)) 32 OMAP2_L4_IO_ADDRESS(OMAP343X_CTRL_BASE + (reg))
33#define AM33XX_CTRL_REGADDR(reg) \
34 AM33XX_L4_WK_IO_ADDRESS(AM33XX_SCM_BASE + (reg))
31#else 35#else
32#define OMAP242X_CTRL_REGADDR(reg) \ 36#define OMAP242X_CTRL_REGADDR(reg) \
33 OMAP2_L4_IO_ADDRESS(OMAP242X_CTRL_BASE + (reg)) 37 OMAP2_L4_IO_ADDRESS(OMAP242X_CTRL_BASE + (reg))
@@ -35,6 +39,8 @@
35 OMAP2_L4_IO_ADDRESS(OMAP243X_CTRL_BASE + (reg)) 39 OMAP2_L4_IO_ADDRESS(OMAP243X_CTRL_BASE + (reg))
36#define OMAP343X_CTRL_REGADDR(reg) \ 40#define OMAP343X_CTRL_REGADDR(reg) \
37 OMAP2_L4_IO_ADDRESS(OMAP343X_CTRL_BASE + (reg)) 41 OMAP2_L4_IO_ADDRESS(OMAP343X_CTRL_BASE + (reg))
42#define AM33XX_CTRL_REGADDR(reg) \
43 AM33XX_L4_WK_IO_ADDRESS(AM33XX_SCM_BASE + (reg))
38#endif /* __ASSEMBLY__ */ 44#endif /* __ASSEMBLY__ */
39 45
40/* 46/*
@@ -182,6 +188,7 @@
182#define OMAP3630_CONTROL_FUSE_OPP120_VDD1 (OMAP2_CONTROL_GENERAL + 0x0120) 188#define OMAP3630_CONTROL_FUSE_OPP120_VDD1 (OMAP2_CONTROL_GENERAL + 0x0120)
183#define OMAP3630_CONTROL_FUSE_OPP50_VDD2 (OMAP2_CONTROL_GENERAL + 0x0128) 189#define OMAP3630_CONTROL_FUSE_OPP50_VDD2 (OMAP2_CONTROL_GENERAL + 0x0128)
184#define OMAP3630_CONTROL_FUSE_OPP100_VDD2 (OMAP2_CONTROL_GENERAL + 0x012C) 190#define OMAP3630_CONTROL_FUSE_OPP100_VDD2 (OMAP2_CONTROL_GENERAL + 0x012C)
191#define OMAP3630_CONTROL_CAMERA_PHY_CTRL (OMAP2_CONTROL_GENERAL + 0x02f0)
185 192
186/* OMAP44xx control efuse offsets */ 193/* OMAP44xx control efuse offsets */
187#define OMAP44XX_CONTROL_FUSE_IVA_OPP50 0x22C 194#define OMAP44XX_CONTROL_FUSE_IVA_OPP50 0x22C
@@ -246,6 +253,10 @@
246/* TI81XX CONTROL_DEVCONF register offsets */ 253/* TI81XX CONTROL_DEVCONF register offsets */
247#define TI81XX_CONTROL_DEVICE_ID (TI81XX_CONTROL_DEVCONF + 0x000) 254#define TI81XX_CONTROL_DEVICE_ID (TI81XX_CONTROL_DEVCONF + 0x000)
248 255
256/* OMAP54XX CONTROL STATUS register */
257#define OMAP5XXX_CONTROL_STATUS 0x134
258#define OMAP5_DEVICETYPE_MASK (0x7 << 6)
259
249/* 260/*
250 * REVISIT: This list of registers is not comprehensive - there are more 261 * REVISIT: This list of registers is not comprehensive - there are more
251 * that should be added. 262 * that should be added.
@@ -312,15 +323,15 @@
312 OMAP343X_SCRATCHPAD + reg) 323 OMAP343X_SCRATCHPAD + reg)
313 324
314/* AM35XX_CONTROL_IPSS_CLK_CTRL bits */ 325/* AM35XX_CONTROL_IPSS_CLK_CTRL bits */
315#define AM35XX_USBOTG_VBUSP_CLK_SHIFT 0 326#define AM35XX_USBOTG_VBUSP_CLK_SHIFT 0
316#define AM35XX_CPGMAC_VBUSP_CLK_SHIFT 1 327#define AM35XX_CPGMAC_VBUSP_CLK_SHIFT 1
317#define AM35XX_VPFE_VBUSP_CLK_SHIFT 2 328#define AM35XX_VPFE_VBUSP_CLK_SHIFT 2
318#define AM35XX_HECC_VBUSP_CLK_SHIFT 3 329#define AM35XX_HECC_VBUSP_CLK_SHIFT 3
319#define AM35XX_USBOTG_FCLK_SHIFT 8 330#define AM35XX_USBOTG_FCLK_SHIFT 8
320#define AM35XX_CPGMAC_FCLK_SHIFT 9 331#define AM35XX_CPGMAC_FCLK_SHIFT 9
321#define AM35XX_VPFE_FCLK_SHIFT 10 332#define AM35XX_VPFE_FCLK_SHIFT 10
322 333
323/*AM35XX CONTROL_LVL_INTR_CLEAR bits*/ 334/* AM35XX CONTROL_LVL_INTR_CLEAR bits */
324#define AM35XX_CPGMAC_C0_MISC_PULSE_CLR BIT(0) 335#define AM35XX_CPGMAC_C0_MISC_PULSE_CLR BIT(0)
325#define AM35XX_CPGMAC_C0_RX_PULSE_CLR BIT(1) 336#define AM35XX_CPGMAC_C0_RX_PULSE_CLR BIT(1)
326#define AM35XX_CPGMAC_C0_RX_THRESH_CLR BIT(2) 337#define AM35XX_CPGMAC_C0_RX_THRESH_CLR BIT(2)
@@ -330,21 +341,22 @@
330#define AM35XX_VPFE_CCDC_VD1_INT_CLR BIT(6) 341#define AM35XX_VPFE_CCDC_VD1_INT_CLR BIT(6)
331#define AM35XX_VPFE_CCDC_VD2_INT_CLR BIT(7) 342#define AM35XX_VPFE_CCDC_VD2_INT_CLR BIT(7)
332 343
333/*AM35XX CONTROL_IP_SW_RESET bits*/ 344/* AM35XX CONTROL_IP_SW_RESET bits */
334#define AM35XX_USBOTGSS_SW_RST BIT(0) 345#define AM35XX_USBOTGSS_SW_RST BIT(0)
335#define AM35XX_CPGMACSS_SW_RST BIT(1) 346#define AM35XX_CPGMACSS_SW_RST BIT(1)
336#define AM35XX_VPFE_VBUSP_SW_RST BIT(2) 347#define AM35XX_VPFE_VBUSP_SW_RST BIT(2)
337#define AM35XX_HECC_SW_RST BIT(3) 348#define AM35XX_HECC_SW_RST BIT(3)
338#define AM35XX_VPFE_PCLK_SW_RST BIT(4) 349#define AM35XX_VPFE_PCLK_SW_RST BIT(4)
339 350
340/* 351/* AM33XX CONTROL_STATUS register */
341 * CONTROL AM33XX STATUS register
342 */
343#define AM33XX_CONTROL_STATUS 0x040 352#define AM33XX_CONTROL_STATUS 0x040
353#define AM33XX_CONTROL_SEC_CLK_CTRL 0x1bc
344 354
345/* 355/* AM33XX CONTROL_STATUS bitfields (partial) */
346 * CONTROL OMAP STATUS register to identify OMAP3 features 356#define AM33XX_CONTROL_STATUS_SYSBOOT1_SHIFT 22
347 */ 357#define AM33XX_CONTROL_STATUS_SYSBOOT1_MASK (0x3 << 22)
358
359/* CONTROL OMAP STATUS register to identify OMAP3 features */
348#define OMAP3_CONTROL_OMAP_STATUS 0x044c 360#define OMAP3_CONTROL_OMAP_STATUS 0x044c
349 361
350#define OMAP3_SGX_SHIFT 13 362#define OMAP3_SGX_SHIFT 13
@@ -397,6 +409,8 @@ extern u32 omap3_arm_context[128];
397extern void omap3_control_save_context(void); 409extern void omap3_control_save_context(void);
398extern void omap3_control_restore_context(void); 410extern void omap3_control_restore_context(void);
399extern void omap3_ctrl_write_boot_mode(u8 bootmode); 411extern void omap3_ctrl_write_boot_mode(u8 bootmode);
412extern void omap_ctrl_write_dsp_boot_addr(u32 bootaddr);
413extern void omap_ctrl_write_dsp_boot_mode(u8 bootmode);
400extern void omap3630_ctrl_disable_rta(void); 414extern void omap3630_ctrl_disable_rta(void);
401extern int omap3_ctrl_save_padconf(void); 415extern int omap3_ctrl_save_padconf(void);
402#else 416#else
diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
index 207bc1c7759..f2a49a48ef5 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -36,8 +36,6 @@
36#include "control.h" 36#include "control.h"
37#include "common.h" 37#include "common.h"
38 38
39#ifdef CONFIG_CPU_IDLE
40
41/* Mach specific information to be recorded in the C-state driver_data */ 39/* Mach specific information to be recorded in the C-state driver_data */
42struct omap3_idle_statedata { 40struct omap3_idle_statedata {
43 u32 mpu_state; 41 u32 mpu_state;
@@ -77,20 +75,6 @@ static struct omap3_idle_statedata omap3_idle_data[] = {
77 75
78static struct powerdomain *mpu_pd, *core_pd, *per_pd, *cam_pd; 76static struct powerdomain *mpu_pd, *core_pd, *per_pd, *cam_pd;
79 77
80static int _cpuidle_allow_idle(struct powerdomain *pwrdm,
81 struct clockdomain *clkdm)
82{
83 clkdm_allow_idle(clkdm);
84 return 0;
85}
86
87static int _cpuidle_deny_idle(struct powerdomain *pwrdm,
88 struct clockdomain *clkdm)
89{
90 clkdm_deny_idle(clkdm);
91 return 0;
92}
93
94static int __omap3_enter_idle(struct cpuidle_device *dev, 78static int __omap3_enter_idle(struct cpuidle_device *dev,
95 struct cpuidle_driver *drv, 79 struct cpuidle_driver *drv,
96 int index) 80 int index)
@@ -108,8 +92,8 @@ static int __omap3_enter_idle(struct cpuidle_device *dev,
108 92
109 /* Deny idle for C1 */ 93 /* Deny idle for C1 */
110 if (index == 0) { 94 if (index == 0) {
111 pwrdm_for_each_clkdm(mpu_pd, _cpuidle_deny_idle); 95 clkdm_deny_idle(mpu_pd->pwrdm_clkdms[0]);
112 pwrdm_for_each_clkdm(core_pd, _cpuidle_deny_idle); 96 clkdm_deny_idle(core_pd->pwrdm_clkdms[0]);
113 } 97 }
114 98
115 /* 99 /*
@@ -131,8 +115,8 @@ static int __omap3_enter_idle(struct cpuidle_device *dev,
131 115
132 /* Re-allow idle for C1 */ 116 /* Re-allow idle for C1 */
133 if (index == 0) { 117 if (index == 0) {
134 pwrdm_for_each_clkdm(mpu_pd, _cpuidle_allow_idle); 118 clkdm_allow_idle(mpu_pd->pwrdm_clkdms[0]);
135 pwrdm_for_each_clkdm(core_pd, _cpuidle_allow_idle); 119 clkdm_allow_idle(core_pd->pwrdm_clkdms[0]);
136 } 120 }
137 121
138return_sleep_time: 122return_sleep_time:
@@ -178,7 +162,7 @@ static int next_valid_state(struct cpuidle_device *dev,
178 u32 mpu_deepest_state = PWRDM_POWER_RET; 162 u32 mpu_deepest_state = PWRDM_POWER_RET;
179 u32 core_deepest_state = PWRDM_POWER_RET; 163 u32 core_deepest_state = PWRDM_POWER_RET;
180 int idx; 164 int idx;
181 int next_index = -1; 165 int next_index = 0; /* C1 is the default value */
182 166
183 if (enable_off_mode) { 167 if (enable_off_mode) {
184 mpu_deepest_state = PWRDM_POWER_OFF; 168 mpu_deepest_state = PWRDM_POWER_OFF;
@@ -209,12 +193,6 @@ static int next_valid_state(struct cpuidle_device *dev,
209 } 193 }
210 } 194 }
211 195
212 /*
213 * C1 is always valid.
214 * So, no need to check for 'next_index == -1' outside
215 * this loop.
216 */
217
218 return next_index; 196 return next_index;
219} 197}
220 198
@@ -228,23 +206,22 @@ static int next_valid_state(struct cpuidle_device *dev,
228 * the device to the specified or a safer state. 206 * the device to the specified or a safer state.
229 */ 207 */
230static int omap3_enter_idle_bm(struct cpuidle_device *dev, 208static int omap3_enter_idle_bm(struct cpuidle_device *dev,
231 struct cpuidle_driver *drv, 209 struct cpuidle_driver *drv,
232 int index) 210 int index)
233{ 211{
234 int new_state_idx; 212 int new_state_idx;
235 u32 core_next_state, per_next_state = 0, per_saved_state = 0, cam_state; 213 u32 core_next_state, per_next_state = 0, per_saved_state = 0;
236 struct omap3_idle_statedata *cx; 214 struct omap3_idle_statedata *cx;
237 int ret; 215 int ret;
238 216
239 /* 217 /*
240 * Prevent idle completely if CAM is active. 218 * Use only C1 if CAM is active.
241 * CAM does not have wakeup capability in OMAP3. 219 * CAM does not have wakeup capability in OMAP3.
242 */ 220 */
243 cam_state = pwrdm_read_pwrst(cam_pd); 221 if (pwrdm_read_pwrst(cam_pd) == PWRDM_POWER_ON)
244 if (cam_state == PWRDM_POWER_ON) {
245 new_state_idx = drv->safe_state_index; 222 new_state_idx = drv->safe_state_index;
246 goto select_state; 223 else
247 } 224 new_state_idx = next_valid_state(dev, drv, index);
248 225
249 /* 226 /*
250 * FIXME: we currently manage device-specific idle states 227 * FIXME: we currently manage device-specific idle states
@@ -254,24 +231,28 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
254 * its own code. 231 * its own code.
255 */ 232 */
256 233
257 /* 234 /* Program PER state */
258 * Prevent PER off if CORE is not in retention or off as this 235 cx = &omap3_idle_data[new_state_idx];
259 * would disable PER wakeups completely.
260 */
261 cx = &omap3_idle_data[index];
262 core_next_state = cx->core_state; 236 core_next_state = cx->core_state;
263 per_next_state = per_saved_state = pwrdm_read_next_pwrst(per_pd); 237 per_next_state = per_saved_state = pwrdm_read_next_pwrst(per_pd);
264 if ((per_next_state == PWRDM_POWER_OFF) && 238 if (new_state_idx == 0) {
265 (core_next_state > PWRDM_POWER_RET)) 239 /* In C1 do not allow PER state lower than CORE state */
266 per_next_state = PWRDM_POWER_RET; 240 if (per_next_state < core_next_state)
241 per_next_state = core_next_state;
242 } else {
243 /*
244 * Prevent PER OFF if CORE is not in RETention or OFF as this
245 * would disable PER wakeups completely.
246 */
247 if ((per_next_state == PWRDM_POWER_OFF) &&
248 (core_next_state > PWRDM_POWER_RET))
249 per_next_state = PWRDM_POWER_RET;
250 }
267 251
268 /* Are we changing PER target state? */ 252 /* Are we changing PER target state? */
269 if (per_next_state != per_saved_state) 253 if (per_next_state != per_saved_state)
270 pwrdm_set_next_pwrst(per_pd, per_next_state); 254 pwrdm_set_next_pwrst(per_pd, per_next_state);
271 255
272 new_state_idx = next_valid_state(dev, drv, index);
273
274select_state:
275 ret = omap3_enter_idle(dev, drv, new_state_idx); 256 ret = omap3_enter_idle(dev, drv, new_state_idx);
276 257
277 /* Restore original PER state if it was modified */ 258 /* Restore original PER state if it was modified */
@@ -288,7 +269,7 @@ struct cpuidle_driver omap3_idle_driver = {
288 .owner = THIS_MODULE, 269 .owner = THIS_MODULE,
289 .states = { 270 .states = {
290 { 271 {
291 .enter = omap3_enter_idle, 272 .enter = omap3_enter_idle_bm,
292 .exit_latency = 2 + 2, 273 .exit_latency = 2 + 2,
293 .target_residency = 5, 274 .target_residency = 5,
294 .flags = CPUIDLE_FLAG_TIME_VALID, 275 .flags = CPUIDLE_FLAG_TIME_VALID,
@@ -379,9 +360,3 @@ int __init omap3_idle_init(void)
379 360
380 return 0; 361 return 0;
381} 362}
382#else
383int __init omap3_idle_init(void)
384{
385 return 0;
386}
387#endif /* CONFIG_CPU_IDLE */
diff --git a/arch/arm/mach-omap2/cpuidle44xx.c b/arch/arm/mach-omap2/cpuidle44xx.c
index be1617ca84b..288bee6cbb7 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -21,8 +21,7 @@
21#include "common.h" 21#include "common.h"
22#include "pm.h" 22#include "pm.h"
23#include "prm.h" 23#include "prm.h"
24 24#include "clockdomain.h"
25#ifdef CONFIG_CPU_IDLE
26 25
27/* Machine specific information */ 26/* Machine specific information */
28struct omap4_idle_statedata { 27struct omap4_idle_statedata {
@@ -49,10 +48,14 @@ static struct omap4_idle_statedata omap4_idle_data[] = {
49 }, 48 },
50}; 49};
51 50
52static struct powerdomain *mpu_pd, *cpu0_pd, *cpu1_pd; 51static struct powerdomain *mpu_pd, *cpu_pd[NR_CPUS];
52static struct clockdomain *cpu_clkdm[NR_CPUS];
53
54static atomic_t abort_barrier;
55static bool cpu_done[NR_CPUS];
53 56
54/** 57/**
55 * omap4_enter_idle - Programs OMAP4 to enter the specified state 58 * omap4_enter_idle_coupled_[simple/coupled] - OMAP4 cpuidle entry functions
56 * @dev: cpuidle device 59 * @dev: cpuidle device
57 * @drv: cpuidle driver 60 * @drv: cpuidle driver
58 * @index: the index of state to be entered 61 * @index: the index of state to be entered
@@ -61,60 +64,84 @@ static struct powerdomain *mpu_pd, *cpu0_pd, *cpu1_pd;
61 * specified low power state selected by the governor. 64 * specified low power state selected by the governor.
62 * Returns the amount of time spent in the low power state. 65 * Returns the amount of time spent in the low power state.
63 */ 66 */
64static int omap4_enter_idle(struct cpuidle_device *dev, 67static int omap4_enter_idle_simple(struct cpuidle_device *dev,
68 struct cpuidle_driver *drv,
69 int index)
70{
71 local_fiq_disable();
72 omap_do_wfi();
73 local_fiq_enable();
74
75 return index;
76}
77
78static int omap4_enter_idle_coupled(struct cpuidle_device *dev,
65 struct cpuidle_driver *drv, 79 struct cpuidle_driver *drv,
66 int index) 80 int index)
67{ 81{
68 struct omap4_idle_statedata *cx = &omap4_idle_data[index]; 82 struct omap4_idle_statedata *cx = &omap4_idle_data[index];
69 u32 cpu1_state;
70 int cpu_id = smp_processor_id(); 83 int cpu_id = smp_processor_id();
71 84
72 local_fiq_disable(); 85 local_fiq_disable();
73 86
74 /* 87 /*
75 * CPU0 has to stay ON (i.e in C1) until CPU1 is OFF state. 88 * CPU0 has to wait and stay ON until CPU1 is OFF state.
76 * This is necessary to honour hardware recommondation 89 * This is necessary to honour hardware recommondation
77 * of triggeing all the possible low power modes once CPU1 is 90 * of triggeing all the possible low power modes once CPU1 is
78 * out of coherency and in OFF mode. 91 * out of coherency and in OFF mode.
79 * Update dev->last_state so that governor stats reflects right
80 * data.
81 */ 92 */
82 cpu1_state = pwrdm_read_pwrst(cpu1_pd); 93 if (dev->cpu == 0 && cpumask_test_cpu(1, cpu_online_mask)) {
83 if (cpu1_state != PWRDM_POWER_OFF) { 94 while (pwrdm_read_pwrst(cpu_pd[1]) != PWRDM_POWER_OFF) {
84 index = drv->safe_state_index; 95 cpu_relax();
85 cx = &omap4_idle_data[index]; 96
97 /*
98 * CPU1 could have already entered & exited idle
99 * without hitting off because of a wakeup
100 * or a failed attempt to hit off mode. Check for
101 * that here, otherwise we could spin forever
102 * waiting for CPU1 off.
103 */
104 if (cpu_done[1])
105 goto fail;
106
107 }
86 } 108 }
87 109
88 if (index > 0) 110 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu_id);
89 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu_id);
90 111
91 /* 112 /*
92 * Call idle CPU PM enter notifier chain so that 113 * Call idle CPU PM enter notifier chain so that
93 * VFP and per CPU interrupt context is saved. 114 * VFP and per CPU interrupt context is saved.
94 */ 115 */
95 if (cx->cpu_state == PWRDM_POWER_OFF) 116 cpu_pm_enter();
96 cpu_pm_enter(); 117
97 118 if (dev->cpu == 0) {
98 pwrdm_set_logic_retst(mpu_pd, cx->mpu_logic_state); 119 pwrdm_set_logic_retst(mpu_pd, cx->mpu_logic_state);
99 omap_set_pwrdm_state(mpu_pd, cx->mpu_state); 120 omap_set_pwrdm_state(mpu_pd, cx->mpu_state);
100 121
101 /* 122 /*
102 * Call idle CPU cluster PM enter notifier chain 123 * Call idle CPU cluster PM enter notifier chain
103 * to save GIC and wakeupgen context. 124 * to save GIC and wakeupgen context.
104 */ 125 */
105 if ((cx->mpu_state == PWRDM_POWER_RET) && 126 if ((cx->mpu_state == PWRDM_POWER_RET) &&
106 (cx->mpu_logic_state == PWRDM_POWER_OFF)) 127 (cx->mpu_logic_state == PWRDM_POWER_OFF))
107 cpu_cluster_pm_enter(); 128 cpu_cluster_pm_enter();
129 }
108 130
109 omap4_enter_lowpower(dev->cpu, cx->cpu_state); 131 omap4_enter_lowpower(dev->cpu, cx->cpu_state);
132 cpu_done[dev->cpu] = true;
133
134 /* Wakeup CPU1 only if it is not offlined */
135 if (dev->cpu == 0 && cpumask_test_cpu(1, cpu_online_mask)) {
136 clkdm_wakeup(cpu_clkdm[1]);
137 clkdm_allow_idle(cpu_clkdm[1]);
138 }
110 139
111 /* 140 /*
112 * Call idle CPU PM exit notifier chain to restore 141 * Call idle CPU PM exit notifier chain to restore
113 * VFP and per CPU IRQ context. Only CPU0 state is 142 * VFP and per CPU IRQ context.
114 * considered since CPU1 is managed by CPU hotplug.
115 */ 143 */
116 if (pwrdm_read_prev_pwrst(cpu0_pd) == PWRDM_POWER_OFF) 144 cpu_pm_exit();
117 cpu_pm_exit();
118 145
119 /* 146 /*
120 * Call idle CPU cluster PM exit notifier chain 147 * Call idle CPU cluster PM exit notifier chain
@@ -123,8 +150,11 @@ static int omap4_enter_idle(struct cpuidle_device *dev,
123 if (omap4_mpuss_read_prev_context_state()) 150 if (omap4_mpuss_read_prev_context_state())
124 cpu_cluster_pm_exit(); 151 cpu_cluster_pm_exit();
125 152
126 if (index > 0) 153 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu_id);
127 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu_id); 154
155fail:
156 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
157 cpu_done[dev->cpu] = false;
128 158
129 local_fiq_enable(); 159 local_fiq_enable();
130 160
@@ -143,7 +173,7 @@ struct cpuidle_driver omap4_idle_driver = {
143 .exit_latency = 2 + 2, 173 .exit_latency = 2 + 2,
144 .target_residency = 5, 174 .target_residency = 5,
145 .flags = CPUIDLE_FLAG_TIME_VALID, 175 .flags = CPUIDLE_FLAG_TIME_VALID,
146 .enter = omap4_enter_idle, 176 .enter = omap4_enter_idle_simple,
147 .name = "C1", 177 .name = "C1",
148 .desc = "MPUSS ON" 178 .desc = "MPUSS ON"
149 }, 179 },
@@ -151,8 +181,8 @@ struct cpuidle_driver omap4_idle_driver = {
151 /* C2 - CPU0 OFF + CPU1 OFF + MPU CSWR */ 181 /* C2 - CPU0 OFF + CPU1 OFF + MPU CSWR */
152 .exit_latency = 328 + 440, 182 .exit_latency = 328 + 440,
153 .target_residency = 960, 183 .target_residency = 960,
154 .flags = CPUIDLE_FLAG_TIME_VALID, 184 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_COUPLED,
155 .enter = omap4_enter_idle, 185 .enter = omap4_enter_idle_coupled,
156 .name = "C2", 186 .name = "C2",
157 .desc = "MPUSS CSWR", 187 .desc = "MPUSS CSWR",
158 }, 188 },
@@ -160,8 +190,8 @@ struct cpuidle_driver omap4_idle_driver = {
160 /* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */ 190 /* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
161 .exit_latency = 460 + 518, 191 .exit_latency = 460 + 518,
162 .target_residency = 1100, 192 .target_residency = 1100,
163 .flags = CPUIDLE_FLAG_TIME_VALID, 193 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_COUPLED,
164 .enter = omap4_enter_idle, 194 .enter = omap4_enter_idle_coupled,
165 .name = "C3", 195 .name = "C3",
166 .desc = "MPUSS OSWR", 196 .desc = "MPUSS OSWR",
167 }, 197 },
@@ -170,6 +200,16 @@ struct cpuidle_driver omap4_idle_driver = {
170 .safe_state_index = 0, 200 .safe_state_index = 0,
171}; 201};
172 202
203/*
204 * For each cpu, setup the broadcast timer because local timers
205 * stops for the states above C1.
206 */
207static void omap_setup_broadcast_timer(void *arg)
208{
209 int cpu = smp_processor_id();
210 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ON, &cpu);
211}
212
173/** 213/**
174 * omap4_idle_init - Init routine for OMAP4 idle 214 * omap4_idle_init - Init routine for OMAP4 idle
175 * 215 *
@@ -182,26 +222,32 @@ int __init omap4_idle_init(void)
182 unsigned int cpu_id = 0; 222 unsigned int cpu_id = 0;
183 223
184 mpu_pd = pwrdm_lookup("mpu_pwrdm"); 224 mpu_pd = pwrdm_lookup("mpu_pwrdm");
185 cpu0_pd = pwrdm_lookup("cpu0_pwrdm"); 225 cpu_pd[0] = pwrdm_lookup("cpu0_pwrdm");
186 cpu1_pd = pwrdm_lookup("cpu1_pwrdm"); 226 cpu_pd[1] = pwrdm_lookup("cpu1_pwrdm");
187 if ((!mpu_pd) || (!cpu0_pd) || (!cpu1_pd)) 227 if ((!mpu_pd) || (!cpu_pd[0]) || (!cpu_pd[1]))
188 return -ENODEV; 228 return -ENODEV;
189 229
190 dev = &per_cpu(omap4_idle_dev, cpu_id); 230 cpu_clkdm[0] = clkdm_lookup("mpu0_clkdm");
191 dev->cpu = cpu_id; 231 cpu_clkdm[1] = clkdm_lookup("mpu1_clkdm");
192 232 if (!cpu_clkdm[0] || !cpu_clkdm[1])
193 cpuidle_register_driver(&omap4_idle_driver); 233 return -ENODEV;
194 234
195 if (cpuidle_register_device(dev)) { 235 /* Configure the broadcast timer on each cpu */
196 pr_err("%s: CPUidle register device failed\n", __func__); 236 on_each_cpu(omap_setup_broadcast_timer, NULL, 1);
197 return -EIO; 237
238 for_each_cpu(cpu_id, cpu_online_mask) {
239 dev = &per_cpu(omap4_idle_dev, cpu_id);
240 dev->cpu = cpu_id;
241#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
242 dev->coupled_cpus = *cpu_online_mask;
243#endif
244 cpuidle_register_driver(&omap4_idle_driver);
245
246 if (cpuidle_register_device(dev)) {
247 pr_err("%s: CPUidle register failed\n", __func__);
248 return -EIO;
249 }
198 } 250 }
199 251
200 return 0; 252 return 0;
201} 253}
202#else
203int __init omap4_idle_init(void)
204{
205 return 0;
206}
207#endif /* CONFIG_CPU_IDLE */
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 7b4b9327e54..c00c68961bb 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -27,7 +27,6 @@
27 27
28#include "iomap.h" 28#include "iomap.h"
29#include <plat/board.h> 29#include <plat/board.h>
30#include <plat/mmc.h>
31#include <plat/dma.h> 30#include <plat/dma.h>
32#include <plat/omap_hwmod.h> 31#include <plat/omap_hwmod.h>
33#include <plat/omap_device.h> 32#include <plat/omap_device.h>
@@ -84,7 +83,7 @@ static int __init omap4_l3_init(void)
84 * To avoid code running on other OMAPs in 83 * To avoid code running on other OMAPs in
85 * multi-omap builds 84 * multi-omap builds
86 */ 85 */
87 if (!(cpu_is_omap44xx())) 86 if (!cpu_is_omap44xx() && !soc_is_omap54xx())
88 return -ENODEV; 87 return -ENODEV;
89 88
90 for (i = 0; i < L3_MODULES; i++) { 89 for (i = 0; i < L3_MODULES; i++) {
@@ -603,112 +602,6 @@ static inline void omap_init_aes(void) { }
603 602
604/*-------------------------------------------------------------------------*/ 603/*-------------------------------------------------------------------------*/
605 604
606#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
607
608static inline void omap242x_mmc_mux(struct omap_mmc_platform_data
609 *mmc_controller)
610{
611 if ((mmc_controller->slots[0].switch_pin > 0) && \
612 (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
613 omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
614 OMAP_PIN_INPUT_PULLUP);
615 if ((mmc_controller->slots[0].gpio_wp > 0) && \
616 (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
617 omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
618 OMAP_PIN_INPUT_PULLUP);
619
620 omap_mux_init_signal("sdmmc_cmd", 0);
621 omap_mux_init_signal("sdmmc_clki", 0);
622 omap_mux_init_signal("sdmmc_clko", 0);
623 omap_mux_init_signal("sdmmc_dat0", 0);
624 omap_mux_init_signal("sdmmc_dat_dir0", 0);
625 omap_mux_init_signal("sdmmc_cmd_dir", 0);
626 if (mmc_controller->slots[0].caps & MMC_CAP_4_BIT_DATA) {
627 omap_mux_init_signal("sdmmc_dat1", 0);
628 omap_mux_init_signal("sdmmc_dat2", 0);
629 omap_mux_init_signal("sdmmc_dat3", 0);
630 omap_mux_init_signal("sdmmc_dat_dir1", 0);
631 omap_mux_init_signal("sdmmc_dat_dir2", 0);
632 omap_mux_init_signal("sdmmc_dat_dir3", 0);
633 }
634
635 /*
636 * Use internal loop-back in MMC/SDIO Module Input Clock
637 * selection
638 */
639 if (mmc_controller->slots[0].internal_clock) {
640 u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
641 v |= (1 << 24);
642 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
643 }
644}
645
646void __init omap242x_init_mmc(struct omap_mmc_platform_data **mmc_data)
647{
648 struct platform_device *pdev;
649 struct omap_hwmod *oh;
650 int id = 0;
651 char *oh_name = "msdi1";
652 char *dev_name = "mmci-omap";
653
654 if (!mmc_data[0]) {
655 pr_err("%s fails: Incomplete platform data\n", __func__);
656 return;
657 }
658
659 omap242x_mmc_mux(mmc_data[0]);
660
661 oh = omap_hwmod_lookup(oh_name);
662 if (!oh) {
663 pr_err("Could not look up %s\n", oh_name);
664 return;
665 }
666 pdev = omap_device_build(dev_name, id, oh, mmc_data[0],
667 sizeof(struct omap_mmc_platform_data), NULL, 0, 0);
668 if (IS_ERR(pdev))
669 WARN(1, "Can'd build omap_device for %s:%s.\n",
670 dev_name, oh->name);
671}
672
673#endif
674
675/*-------------------------------------------------------------------------*/
676
677#if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
678#define OMAP_HDQ_BASE 0x480B2000
679static struct resource omap_hdq_resources[] = {
680 {
681 .start = OMAP_HDQ_BASE,
682 .end = OMAP_HDQ_BASE + 0x1C,
683 .flags = IORESOURCE_MEM,
684 },
685 {
686 .start = INT_24XX_HDQ_IRQ,
687 .flags = IORESOURCE_IRQ,
688 },
689};
690static struct platform_device omap_hdq_dev = {
691 .name = "omap_hdq",
692 .id = 0,
693 .dev = {
694 .platform_data = NULL,
695 },
696 .num_resources = ARRAY_SIZE(omap_hdq_resources),
697 .resource = omap_hdq_resources,
698};
699static inline void omap_hdq_init(void)
700{
701 if (cpu_is_omap2420())
702 return;
703
704 platform_device_register(&omap_hdq_dev);
705}
706#else
707static inline void omap_hdq_init(void) {}
708#endif
709
710/*---------------------------------------------------------------------------*/
711
712#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \ 605#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
713 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE) 606 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
714#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE) 607#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
@@ -753,7 +646,6 @@ static int __init omap2_init_devices(void)
753 omap_init_mcspi(); 646 omap_init_mcspi();
754 } 647 }
755 omap_init_pmu(); 648 omap_init_pmu();
756 omap_hdq_init();
757 omap_init_sti(); 649 omap_init_sti();
758 omap_init_sham(); 650 omap_init_sham();
759 omap_init_aes(); 651 omap_init_aes();
@@ -772,7 +664,7 @@ static int __init omap_init_wdt(void)
772 char *oh_name = "wd_timer2"; 664 char *oh_name = "wd_timer2";
773 char *dev_name = "omap_wdt"; 665 char *dev_name = "omap_wdt";
774 666
775 if (!cpu_class_is_omap2()) 667 if (!cpu_class_is_omap2() || of_have_populated_dt())
776 return 0; 668 return 0;
777 669
778 oh = omap_hwmod_lookup(oh_name); 670 oh = omap_hwmod_lookup(oh_name);
diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c
index 5fb47a14f4b..af1ed7d24a1 100644
--- a/arch/arm/mach-omap2/display.c
+++ b/arch/arm/mach-omap2/display.c
@@ -37,6 +37,7 @@
37 37
38#define DISPC_CONTROL 0x0040 38#define DISPC_CONTROL 0x0040
39#define DISPC_CONTROL2 0x0238 39#define DISPC_CONTROL2 0x0238
40#define DISPC_CONTROL3 0x0848
40#define DISPC_IRQSTATUS 0x0018 41#define DISPC_IRQSTATUS 0x0018
41 42
42#define DSS_SYSCONFIG 0x10 43#define DSS_SYSCONFIG 0x10
@@ -52,6 +53,7 @@
52#define EVSYNC_EVEN_IRQ_SHIFT 2 53#define EVSYNC_EVEN_IRQ_SHIFT 2
53#define EVSYNC_ODD_IRQ_SHIFT 3 54#define EVSYNC_ODD_IRQ_SHIFT 3
54#define FRAMEDONE2_IRQ_SHIFT 22 55#define FRAMEDONE2_IRQ_SHIFT 22
56#define FRAMEDONE3_IRQ_SHIFT 30
55#define FRAMEDONETV_IRQ_SHIFT 24 57#define FRAMEDONETV_IRQ_SHIFT 24
56 58
57/* 59/*
@@ -376,7 +378,7 @@ int __init omap_display_init(struct omap_dss_board_info *board_data)
376static void dispc_disable_outputs(void) 378static void dispc_disable_outputs(void)
377{ 379{
378 u32 v, irq_mask = 0; 380 u32 v, irq_mask = 0;
379 bool lcd_en, digit_en, lcd2_en = false; 381 bool lcd_en, digit_en, lcd2_en = false, lcd3_en = false;
380 int i; 382 int i;
381 struct omap_dss_dispc_dev_attr *da; 383 struct omap_dss_dispc_dev_attr *da;
382 struct omap_hwmod *oh; 384 struct omap_hwmod *oh;
@@ -405,7 +407,13 @@ static void dispc_disable_outputs(void)
405 lcd2_en = v & LCD_EN_MASK; 407 lcd2_en = v & LCD_EN_MASK;
406 } 408 }
407 409
408 if (!(lcd_en | digit_en | lcd2_en)) 410 /* store value of LCDENABLE for LCD3 */
411 if (da->manager_count > 3) {
412 v = omap_hwmod_read(oh, DISPC_CONTROL3);
413 lcd3_en = v & LCD_EN_MASK;
414 }
415
416 if (!(lcd_en | digit_en | lcd2_en | lcd3_en))
409 return; /* no managers currently enabled */ 417 return; /* no managers currently enabled */
410 418
411 /* 419 /*
@@ -426,10 +434,12 @@ static void dispc_disable_outputs(void)
426 434
427 if (lcd2_en) 435 if (lcd2_en)
428 irq_mask |= 1 << FRAMEDONE2_IRQ_SHIFT; 436 irq_mask |= 1 << FRAMEDONE2_IRQ_SHIFT;
437 if (lcd3_en)
438 irq_mask |= 1 << FRAMEDONE3_IRQ_SHIFT;
429 439
430 /* 440 /*
431 * clear any previous FRAMEDONE, FRAMEDONETV, 441 * clear any previous FRAMEDONE, FRAMEDONETV,
432 * EVSYNC_EVEN/ODD or FRAMEDONE2 interrupts 442 * EVSYNC_EVEN/ODD, FRAMEDONE2 or FRAMEDONE3 interrupts
433 */ 443 */
434 omap_hwmod_write(irq_mask, oh, DISPC_IRQSTATUS); 444 omap_hwmod_write(irq_mask, oh, DISPC_IRQSTATUS);
435 445
@@ -445,12 +455,19 @@ static void dispc_disable_outputs(void)
445 omap_hwmod_write(v, oh, DISPC_CONTROL2); 455 omap_hwmod_write(v, oh, DISPC_CONTROL2);
446 } 456 }
447 457
458 /* disable LCD3 manager */
459 if (da->manager_count > 3) {
460 v = omap_hwmod_read(oh, DISPC_CONTROL3);
461 v &= ~LCD_EN_MASK;
462 omap_hwmod_write(v, oh, DISPC_CONTROL3);
463 }
464
448 i = 0; 465 i = 0;
449 while ((omap_hwmod_read(oh, DISPC_IRQSTATUS) & irq_mask) != 466 while ((omap_hwmod_read(oh, DISPC_IRQSTATUS) & irq_mask) !=
450 irq_mask) { 467 irq_mask) {
451 i++; 468 i++;
452 if (i > FRAMEDONE_IRQ_TIMEOUT) { 469 if (i > FRAMEDONE_IRQ_TIMEOUT) {
453 pr_err("didn't get FRAMEDONE1/2 or TV interrupt\n"); 470 pr_err("didn't get FRAMEDONE1/2/3 or TV interrupt\n");
454 break; 471 break;
455 } 472 }
456 mdelay(1); 473 mdelay(1);
diff --git a/arch/arm/mach-omap2/dpll3xxx.c b/arch/arm/mach-omap2/dpll3xxx.c
index f0f10beeffe..b9c8d2f6a81 100644
--- a/arch/arm/mach-omap2/dpll3xxx.c
+++ b/arch/arm/mach-omap2/dpll3xxx.c
@@ -135,11 +135,20 @@ static u16 _omap3_dpll_compute_freqsel(struct clk *clk, u8 n)
135 */ 135 */
136static int _omap3_noncore_dpll_lock(struct clk *clk) 136static int _omap3_noncore_dpll_lock(struct clk *clk)
137{ 137{
138 const struct dpll_data *dd;
138 u8 ai; 139 u8 ai;
139 int r; 140 u8 state = 1;
141 int r = 0;
140 142
141 pr_debug("clock: locking DPLL %s\n", clk->name); 143 pr_debug("clock: locking DPLL %s\n", clk->name);
142 144
145 dd = clk->dpll_data;
146 state <<= __ffs(dd->idlest_mask);
147
148 /* Check if already locked */
149 if ((__raw_readl(dd->idlest_reg) & dd->idlest_mask) == state)
150 goto done;
151
143 ai = omap3_dpll_autoidle_read(clk); 152 ai = omap3_dpll_autoidle_read(clk);
144 153
145 if (ai) 154 if (ai)
@@ -152,6 +161,7 @@ static int _omap3_noncore_dpll_lock(struct clk *clk)
152 if (ai) 161 if (ai)
153 omap3_dpll_allow_idle(clk); 162 omap3_dpll_allow_idle(clk);
154 163
164done:
155 return r; 165 return r;
156} 166}
157 167
@@ -628,3 +638,17 @@ unsigned long omap3_clkoutx2_recalc(struct clk *clk)
628 rate = clk->parent->rate * 2; 638 rate = clk->parent->rate * 2;
629 return rate; 639 return rate;
630} 640}
641
642/* OMAP3/4 non-CORE DPLL clkops */
643
644const struct clkops clkops_omap3_noncore_dpll_ops = {
645 .enable = omap3_noncore_dpll_enable,
646 .disable = omap3_noncore_dpll_disable,
647 .allow_idle = omap3_dpll_allow_idle,
648 .deny_idle = omap3_dpll_deny_idle,
649};
650
651const struct clkops clkops_omap3_core_dpll_ops = {
652 .allow_idle = omap3_dpll_allow_idle,
653 .deny_idle = omap3_dpll_deny_idle,
654};
diff --git a/arch/arm/mach-omap2/drm.c b/arch/arm/mach-omap2/drm.c
new file mode 100644
index 00000000000..72e0f01b715
--- /dev/null
+++ b/arch/arm/mach-omap2/drm.c
@@ -0,0 +1,61 @@
1/*
2 * DRM/KMS device registration for TI OMAP platforms
3 *
4 * Copyright (C) 2012 Texas Instruments
5 * Author: Rob Clark <rob.clark@linaro.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
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 with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <linux/module.h>
21#include <linux/kernel.h>
22#include <linux/mm.h>
23#include <linux/init.h>
24#include <linux/platform_device.h>
25#include <linux/dma-mapping.h>
26
27#include <plat/omap_device.h>
28#include <plat/omap_hwmod.h>
29
30#if defined(CONFIG_DRM_OMAP) || (CONFIG_DRM_OMAP_MODULE)
31
32static struct platform_device omap_drm_device = {
33 .dev = {
34 .coherent_dma_mask = DMA_BIT_MASK(32),
35 },
36 .name = "omapdrm",
37 .id = 0,
38};
39
40static int __init omap_init_drm(void)
41{
42 struct omap_hwmod *oh = NULL;
43 struct platform_device *pdev;
44
45 /* lookup and populate the DMM information, if present - OMAP4+ */
46 oh = omap_hwmod_lookup("dmm");
47
48 if (oh) {
49 pdev = omap_device_build(oh->name, -1, oh, NULL, 0, NULL, 0,
50 false);
51 WARN(IS_ERR(pdev), "Could not build omap_device for %s\n",
52 oh->name);
53 }
54
55 return platform_device_register(&omap_drm_device);
56
57}
58
59arch_initcall(omap_init_drm);
60
61#endif
diff --git a/arch/arm/mach-omap2/dsp.c b/arch/arm/mach-omap2/dsp.c
index 88ffa1e645c..a636ebc16b3 100644
--- a/arch/arm/mach-omap2/dsp.c
+++ b/arch/arm/mach-omap2/dsp.c
@@ -23,6 +23,7 @@
23 23
24#include <asm/memblock.h> 24#include <asm/memblock.h>
25 25
26#include "control.h"
26#include "cm2xxx_3xxx.h" 27#include "cm2xxx_3xxx.h"
27#include "prm2xxx_3xxx.h" 28#include "prm2xxx_3xxx.h"
28#ifdef CONFIG_BRIDGE_DVFS 29#ifdef CONFIG_BRIDGE_DVFS
@@ -46,6 +47,9 @@ static struct omap_dsp_platform_data omap_dsp_pdata __initdata = {
46 .dsp_cm_read = omap2_cm_read_mod_reg, 47 .dsp_cm_read = omap2_cm_read_mod_reg,
47 .dsp_cm_write = omap2_cm_write_mod_reg, 48 .dsp_cm_write = omap2_cm_write_mod_reg,
48 .dsp_cm_rmw_bits = omap2_cm_rmw_mod_reg_bits, 49 .dsp_cm_rmw_bits = omap2_cm_rmw_mod_reg_bits,
50
51 .set_bootaddr = omap_ctrl_write_dsp_boot_addr,
52 .set_bootmode = omap_ctrl_write_dsp_boot_mode,
49}; 53};
50 54
51static phys_addr_t omap_dsp_phys_mempool_base; 55static phys_addr_t omap_dsp_phys_mempool_base;
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 2286410671e..b2b5759ab0f 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -727,7 +727,8 @@ static int __init gpmc_init(void)
727 ck = "gpmc_fck"; 727 ck = "gpmc_fck";
728 l = OMAP34XX_GPMC_BASE; 728 l = OMAP34XX_GPMC_BASE;
729 gpmc_irq = INT_34XX_GPMC_IRQ; 729 gpmc_irq = INT_34XX_GPMC_IRQ;
730 } else if (cpu_is_omap44xx()) { 730 } else if (cpu_is_omap44xx() || soc_is_omap54xx()) {
731 /* Base address and irq number are same for OMAP4/5 */
731 ck = "gpmc_ck"; 732 ck = "gpmc_ck";
732 l = OMAP44XX_GPMC_BASE; 733 l = OMAP44XX_GPMC_BASE;
733 gpmc_irq = OMAP44XX_IRQ_GPMC; 734 gpmc_irq = OMAP44XX_IRQ_GPMC;
diff --git a/arch/arm/mach-omap2/hdq1w.c b/arch/arm/mach-omap2/hdq1w.c
index 297ebe03f09..cdd6dda0382 100644
--- a/arch/arm/mach-omap2/hdq1w.c
+++ b/arch/arm/mach-omap2/hdq1w.c
@@ -22,7 +22,13 @@
22 * 02110-1301 USA 22 * 02110-1301 USA
23 */ 23 */
24 24
25#include <linux/kernel.h>
26#include <linux/init.h>
27#include <linux/err.h>
28#include <linux/platform_device.h>
29
25#include <plat/omap_hwmod.h> 30#include <plat/omap_hwmod.h>
31#include <plat/omap_device.h>
26#include <plat/hdq1w.h> 32#include <plat/hdq1w.h>
27 33
28#include "common.h" 34#include "common.h"
@@ -70,3 +76,23 @@ int omap_hdq1w_reset(struct omap_hwmod *oh)
70 76
71 return 0; 77 return 0;
72} 78}
79
80static int __init omap_init_hdq(void)
81{
82 int id = -1;
83 struct platform_device *pdev;
84 struct omap_hwmod *oh;
85 char *oh_name = "hdq1w";
86 char *devname = "omap_hdq";
87
88 oh = omap_hwmod_lookup(oh_name);
89 if (!oh)
90 return 0;
91
92 pdev = omap_device_build(devname, id, oh, NULL, 0, NULL, 0, 0);
93 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
94 devname, oh->name);
95
96 return 0;
97}
98arch_initcall(omap_init_hdq);
diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
index be697d4e084..a9675d8d182 100644
--- a/arch/arm/mach-omap2/hsmmc.c
+++ b/arch/arm/mach-omap2/hsmmc.c
@@ -315,7 +315,6 @@ static int __init omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c,
315 mmc->slots[0].caps = c->caps; 315 mmc->slots[0].caps = c->caps;
316 mmc->slots[0].pm_caps = c->pm_caps; 316 mmc->slots[0].pm_caps = c->pm_caps;
317 mmc->slots[0].internal_clock = !c->ext_clock; 317 mmc->slots[0].internal_clock = !c->ext_clock;
318 mmc->dma_mask = 0xffffffff;
319 mmc->max_freq = c->max_freq; 318 mmc->max_freq = c->max_freq;
320 if (cpu_is_omap44xx()) 319 if (cpu_is_omap44xx())
321 mmc->reg_offset = OMAP4_MMC_REG_OFFSET; 320 mmc->reg_offset = OMAP4_MMC_REG_OFFSET;
diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index 00486a8564f..40373db649a 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -44,12 +44,17 @@ int omap_type(void)
44 44
45 if (cpu_is_omap24xx()) { 45 if (cpu_is_omap24xx()) {
46 val = omap_ctrl_readl(OMAP24XX_CONTROL_STATUS); 46 val = omap_ctrl_readl(OMAP24XX_CONTROL_STATUS);
47 } else if (cpu_is_am33xx()) { 47 } else if (soc_is_am33xx()) {
48 val = omap_ctrl_readl(AM33XX_CONTROL_STATUS); 48 val = omap_ctrl_readl(AM33XX_CONTROL_STATUS);
49 } else if (cpu_is_omap34xx()) { 49 } else if (cpu_is_omap34xx()) {
50 val = omap_ctrl_readl(OMAP343X_CONTROL_STATUS); 50 val = omap_ctrl_readl(OMAP343X_CONTROL_STATUS);
51 } else if (cpu_is_omap44xx()) { 51 } else if (cpu_is_omap44xx()) {
52 val = omap_ctrl_readl(OMAP4_CTRL_MODULE_CORE_STATUS); 52 val = omap_ctrl_readl(OMAP4_CTRL_MODULE_CORE_STATUS);
53 } else if (soc_is_omap54xx()) {
54 val = omap_ctrl_readl(OMAP5XXX_CONTROL_STATUS);
55 val &= OMAP5_DEVICETYPE_MASK;
56 val >>= 6;
57 goto out;
53 } else { 58 } else {
54 pr_err("Cannot detect omap type!\n"); 59 pr_err("Cannot detect omap type!\n");
55 goto out; 60 goto out;
@@ -100,7 +105,7 @@ static u16 tap_prod_id;
100 105
101void omap_get_die_id(struct omap_die_id *odi) 106void omap_get_die_id(struct omap_die_id *odi)
102{ 107{
103 if (cpu_is_omap44xx()) { 108 if (cpu_is_omap44xx() || soc_is_omap54xx()) {
104 odi->id_0 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_0); 109 odi->id_0 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_0);
105 odi->id_1 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_1); 110 odi->id_1 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_1);
106 odi->id_2 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_2); 111 odi->id_2 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_2);
@@ -189,7 +194,7 @@ static void __init omap3_cpuinfo(void)
189 cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505"; 194 cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505";
190 } else if (cpu_is_ti816x()) { 195 } else if (cpu_is_ti816x()) {
191 cpu_name = "TI816X"; 196 cpu_name = "TI816X";
192 } else if (cpu_is_am335x()) { 197 } else if (soc_is_am335x()) {
193 cpu_name = "AM335X"; 198 cpu_name = "AM335X";
194 } else if (cpu_is_ti814x()) { 199 } else if (cpu_is_ti814x()) {
195 cpu_name = "TI814X"; 200 cpu_name = "TI814X";
@@ -513,6 +518,41 @@ void __init omap4xxx_check_revision(void)
513 ((omap_rev() >> 12) & 0xf), ((omap_rev() >> 8) & 0xf)); 518 ((omap_rev() >> 12) & 0xf), ((omap_rev() >> 8) & 0xf));
514} 519}
515 520
521void __init omap5xxx_check_revision(void)
522{
523 u32 idcode;
524 u16 hawkeye;
525 u8 rev;
526
527 idcode = read_tap_reg(OMAP_TAP_IDCODE);
528 hawkeye = (idcode >> 12) & 0xffff;
529 rev = (idcode >> 28) & 0xff;
530 switch (hawkeye) {
531 case 0xb942:
532 switch (rev) {
533 case 0:
534 default:
535 omap_revision = OMAP5430_REV_ES1_0;
536 }
537 break;
538
539 case 0xb998:
540 switch (rev) {
541 case 0:
542 default:
543 omap_revision = OMAP5432_REV_ES1_0;
544 }
545 break;
546
547 default:
548 /* Unknown default to latest silicon rev as default*/
549 omap_revision = OMAP5430_REV_ES1_0;
550 }
551
552 pr_info("OMAP%04x ES%d.0\n",
553 omap_rev() >> 16, ((omap_rev() >> 12) & 0xf));
554}
555
516/* 556/*
517 * Set up things for map_io and processor detection later on. Gets called 557 * Set up things for map_io and processor detection later on. Gets called
518 * pretty much first thing from board init. For multi-omap, this gets 558 * pretty much first thing from board init. For multi-omap, this gets
diff --git a/arch/arm/mach-omap2/include/mach/am35xx.h b/arch/arm/mach-omap2/include/mach/am35xx.h
index f1e13d1ca5e..95594495fcf 100644
--- a/arch/arm/mach-omap2/include/mach/am35xx.h
+++ b/arch/arm/mach-omap2/include/mach/am35xx.h
@@ -36,6 +36,8 @@
36#define AM35XX_EMAC_CNTRL_MOD_OFFSET (0x0) 36#define AM35XX_EMAC_CNTRL_MOD_OFFSET (0x0)
37#define AM35XX_EMAC_CNTRL_RAM_OFFSET (0x20000) 37#define AM35XX_EMAC_CNTRL_RAM_OFFSET (0x20000)
38#define AM35XX_EMAC_MDIO_OFFSET (0x30000) 38#define AM35XX_EMAC_MDIO_OFFSET (0x30000)
39#define AM35XX_IPSS_MDIO_BASE (AM35XX_IPSS_EMAC_BASE + \
40 AM35XX_EMAC_MDIO_OFFSET)
39#define AM35XX_EMAC_CNTRL_RAM_SIZE (0x2000) 41#define AM35XX_EMAC_CNTRL_RAM_SIZE (0x2000)
40#define AM35XX_EMAC_RAM_ADDR (AM3517_EMAC_BASE + \ 42#define AM35XX_EMAC_RAM_ADDR (AM3517_EMAC_BASE + \
41 AM3517_EMAC_CNTRL_RAM_OFFSET) 43 AM3517_EMAC_CNTRL_RAM_OFFSET)
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
index 2f7ac70a20d..01970824e0e 100644
--- a/arch/arm/mach-omap2/include/mach/ctrl_module_core_44xx.h
+++ b/arch/arm/mach-omap2/include/mach/ctrl_module_core_44xx.h
@@ -42,6 +42,7 @@
42#define OMAP4_CTRL_MODULE_CORE_STD_FUSE_OPP_DPLL_1 0x0268 42#define OMAP4_CTRL_MODULE_CORE_STD_FUSE_OPP_DPLL_1 0x0268
43#define OMAP4_CTRL_MODULE_CORE_STATUS 0x02c4 43#define OMAP4_CTRL_MODULE_CORE_STATUS 0x02c4
44#define OMAP4_CTRL_MODULE_CORE_DEV_CONF 0x0300 44#define OMAP4_CTRL_MODULE_CORE_DEV_CONF 0x0300
45#define OMAP4_CTRL_MODULE_CORE_DSP_BOOTADDR 0x0304
45#define OMAP4_CTRL_MODULE_CORE_LDOVBB_IVA_VOLTAGE_CTRL 0x0314 46#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_LDOVBB_MPU_VOLTAGE_CTRL 0x0318
47#define OMAP4_CTRL_MODULE_CORE_LDOSRAM_IVA_VOLTAGE_CTRL 0x0320 48#define OMAP4_CTRL_MODULE_CORE_LDOSRAM_IVA_VOLTAGE_CTRL 0x0320
diff --git a/arch/arm/mach-omap2/include/mach/debug-macro.S b/arch/arm/mach-omap2/include/mach/debug-macro.S
index cdfc2a1f0e7..93d10de7129 100644
--- a/arch/arm/mach-omap2/include/mach/debug-macro.S
+++ b/arch/arm/mach-omap2/include/mach/debug-macro.S
@@ -60,18 +60,20 @@ omap_uart_lsr: .word 0
60 beq 23f @ configure OMAP2UART3 60 beq 23f @ configure OMAP2UART3
61 cmp \rp, #OMAP3UART3 @ only on 34xx 61 cmp \rp, #OMAP3UART3 @ only on 34xx
62 beq 33f @ configure OMAP3UART3 62 beq 33f @ configure OMAP3UART3
63 cmp \rp, #OMAP4UART3 @ only on 44xx 63 cmp \rp, #OMAP4UART3 @ only on 44xx/54xx
64 beq 43f @ configure OMAP4UART3 64 beq 43f @ configure OMAP4/5UART3
65 cmp \rp, #OMAP3UART4 @ only on 36xx 65 cmp \rp, #OMAP3UART4 @ only on 36xx
66 beq 34f @ configure OMAP3UART4 66 beq 34f @ configure OMAP3UART4
67 cmp \rp, #OMAP4UART4 @ only on 44xx 67 cmp \rp, #OMAP4UART4 @ only on 44xx/54xx
68 beq 44f @ configure OMAP4UART4 68 beq 44f @ configure OMAP4/5UART4
69 cmp \rp, #TI81XXUART1 @ ti81Xx UART offsets different 69 cmp \rp, #TI81XXUART1 @ ti81Xx UART offsets different
70 beq 81f @ configure UART1 70 beq 81f @ configure UART1
71 cmp \rp, #TI81XXUART2 @ ti81Xx UART offsets different 71 cmp \rp, #TI81XXUART2 @ ti81Xx UART offsets different
72 beq 82f @ configure UART2 72 beq 82f @ configure UART2
73 cmp \rp, #TI81XXUART3 @ ti81Xx UART offsets different 73 cmp \rp, #TI81XXUART3 @ ti81Xx UART offsets different
74 beq 83f @ configure UART3 74 beq 83f @ configure UART3
75 cmp \rp, #AM33XXUART1 @ AM33XX UART offsets different
76 beq 84f @ configure UART1
75 cmp \rp, #ZOOM_UART @ only on zoom2/3 77 cmp \rp, #ZOOM_UART @ only on zoom2/3
76 beq 95f @ configure ZOOM_UART 78 beq 95f @ configure ZOOM_UART
77 79
@@ -100,7 +102,9 @@ omap_uart_lsr: .word 0
100 b 98f 102 b 98f
10183: mov \rp, #UART_OFFSET(TI81XX_UART3_BASE) 10383: mov \rp, #UART_OFFSET(TI81XX_UART3_BASE)
102 b 98f 104 b 98f
103 10584: ldr \rp, =AM33XX_UART1_BASE
106 and \rp, \rp, #0x00ffffff
107 b 97f
10495: ldr \rp, =ZOOM_UART_BASE 10895: ldr \rp, =ZOOM_UART_BASE
105 str \rp, [\tmp, #0] @ omap_uart_phys 109 str \rp, [\tmp, #0] @ omap_uart_phys
106 ldr \rp, =ZOOM_UART_VIRT 110 ldr \rp, =ZOOM_UART_VIRT
@@ -109,6 +113,17 @@ omap_uart_lsr: .word 0
109 str \rp, [\tmp, #8] @ omap_uart_lsr 113 str \rp, [\tmp, #8] @ omap_uart_lsr
110 b 10b 114 b 10b
111 115
116 /* AM33XX: Store both phys and virt address for the uart */
11797: add \rp, \rp, #0x44000000 @ phys base
118 str \rp, [\tmp, #0] @ omap_uart_phys
119 sub \rp, \rp, #0x44000000 @ phys base
120 add \rp, \rp, #0xf9000000 @ virt base
121 str \rp, [\tmp, #4] @ omap_uart_virt
122 mov \rp, #(UART_LSR << OMAP_PORT_SHIFT)
123 str \rp, [\tmp, #8] @ omap_uart_lsr
124
125 b 10b
126
112 /* Store both phys and virt address for the uart */ 127 /* Store both phys and virt address for the uart */
11398: add \rp, \rp, #0x48000000 @ phys base 12898: add \rp, \rp, #0x48000000 @ phys base
114 str \rp, [\tmp, #0] @ omap_uart_phys 129 str \rp, [\tmp, #0] @ omap_uart_phys
diff --git a/arch/arm/mach-omap2/include/mach/omap-wakeupgen.h b/arch/arm/mach-omap2/include/mach/omap-wakeupgen.h
index 548de90b58c..b0fd16f5c39 100644
--- a/arch/arm/mach-omap2/include/mach/omap-wakeupgen.h
+++ b/arch/arm/mach-omap2/include/mach/omap-wakeupgen.h
@@ -11,15 +11,20 @@
11#ifndef OMAP_ARCH_WAKEUPGEN_H 11#ifndef OMAP_ARCH_WAKEUPGEN_H
12#define OMAP_ARCH_WAKEUPGEN_H 12#define OMAP_ARCH_WAKEUPGEN_H
13 13
14/* OMAP4 and OMAP5 has same base address */
15#define OMAP_WKUPGEN_BASE 0x48281000
16
14#define OMAP_WKG_CONTROL_0 0x00 17#define OMAP_WKG_CONTROL_0 0x00
15#define OMAP_WKG_ENB_A_0 0x10 18#define OMAP_WKG_ENB_A_0 0x10
16#define OMAP_WKG_ENB_B_0 0x14 19#define OMAP_WKG_ENB_B_0 0x14
17#define OMAP_WKG_ENB_C_0 0x18 20#define OMAP_WKG_ENB_C_0 0x18
18#define OMAP_WKG_ENB_D_0 0x1c 21#define OMAP_WKG_ENB_D_0 0x1c
22#define OMAP_WKG_ENB_E_0 0x20
19#define OMAP_WKG_ENB_A_1 0x410 23#define OMAP_WKG_ENB_A_1 0x410
20#define OMAP_WKG_ENB_B_1 0x414 24#define OMAP_WKG_ENB_B_1 0x414
21#define OMAP_WKG_ENB_C_1 0x418 25#define OMAP_WKG_ENB_C_1 0x418
22#define OMAP_WKG_ENB_D_1 0x41c 26#define OMAP_WKG_ENB_D_1 0x41c
27#define OMAP_WKG_ENB_E_1 0x420
23#define OMAP_AUX_CORE_BOOT_0 0x800 28#define OMAP_AUX_CORE_BOOT_0 0x800
24#define OMAP_AUX_CORE_BOOT_1 0x804 29#define OMAP_AUX_CORE_BOOT_1 0x804
25#define OMAP_PTMSYNCREQ_MASK 0xc00 30#define OMAP_PTMSYNCREQ_MASK 0xc00
@@ -28,4 +33,6 @@
28#define OMAP_TIMESTAMPCYCLEHI 0xc0c 33#define OMAP_TIMESTAMPCYCLEHI 0xc0c
29 34
30extern int __init omap_wakeupgen_init(void); 35extern int __init omap_wakeupgen_init(void);
36extern void __iomem *omap_get_wakeupgen_base(void);
37extern int omap_secure_apis_support(void);
31#endif 38#endif
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 8d014ba04ab..4d2d981ff5c 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -38,6 +38,7 @@
38#include "powerdomain.h" 38#include "powerdomain.h"
39#include "clockdomain.h" 39#include "clockdomain.h"
40#include "common.h" 40#include "common.h"
41#include "clock.h"
41#include "clock2xxx.h" 42#include "clock2xxx.h"
42#include "clock3xxx.h" 43#include "clock3xxx.h"
43#include "clock44xx.h" 44#include "clock44xx.h"
@@ -233,6 +234,35 @@ static struct map_desc omap44xx_io_desc[] __initdata = {
233}; 234};
234#endif 235#endif
235 236
237#ifdef CONFIG_SOC_OMAP5
238static struct map_desc omap54xx_io_desc[] __initdata = {
239 {
240 .virtual = L3_54XX_VIRT,
241 .pfn = __phys_to_pfn(L3_54XX_PHYS),
242 .length = L3_54XX_SIZE,
243 .type = MT_DEVICE,
244 },
245 {
246 .virtual = L4_54XX_VIRT,
247 .pfn = __phys_to_pfn(L4_54XX_PHYS),
248 .length = L4_54XX_SIZE,
249 .type = MT_DEVICE,
250 },
251 {
252 .virtual = L4_WK_54XX_VIRT,
253 .pfn = __phys_to_pfn(L4_WK_54XX_PHYS),
254 .length = L4_WK_54XX_SIZE,
255 .type = MT_DEVICE,
256 },
257 {
258 .virtual = L4_PER_54XX_VIRT,
259 .pfn = __phys_to_pfn(L4_PER_54XX_PHYS),
260 .length = L4_PER_54XX_SIZE,
261 .type = MT_DEVICE,
262 },
263};
264#endif
265
236#ifdef CONFIG_SOC_OMAP2420 266#ifdef CONFIG_SOC_OMAP2420
237void __init omap242x_map_common_io(void) 267void __init omap242x_map_common_io(void)
238{ 268{
@@ -278,6 +308,12 @@ void __init omap44xx_map_common_io(void)
278} 308}
279#endif 309#endif
280 310
311#ifdef CONFIG_SOC_OMAP5
312void __init omap5_map_common_io(void)
313{
314 iotable_init(omap54xx_io_desc, ARRAY_SIZE(omap54xx_io_desc));
315}
316#endif
281/* 317/*
282 * omap2_init_reprogram_sdrc - reprogram SDRC timing parameters 318 * omap2_init_reprogram_sdrc - reprogram SDRC timing parameters
283 * 319 *
@@ -477,6 +513,20 @@ void __init ti81xx_init_late(void)
477} 513}
478#endif 514#endif
479 515
516#ifdef CONFIG_SOC_AM33XX
517void __init am33xx_init_early(void)
518{
519 omap2_set_globals_am33xx();
520 omap3xxx_check_revision();
521 ti81xx_check_features();
522 omap_common_init_early();
523 am33xx_voltagedomains_init();
524 am33xx_powerdomains_init();
525 am33xx_clockdomains_init();
526 am33xx_clk_init();
527}
528#endif
529
480#ifdef CONFIG_ARCH_OMAP4 530#ifdef CONFIG_ARCH_OMAP4
481void __init omap4430_init_early(void) 531void __init omap4430_init_early(void)
482{ 532{
@@ -500,6 +550,15 @@ void __init omap4430_init_late(void)
500} 550}
501#endif 551#endif
502 552
553#ifdef CONFIG_SOC_OMAP5
554void __init omap5_init_early(void)
555{
556 omap2_set_globals_5xxx();
557 omap5xxx_check_revision();
558 omap_common_init_early();
559}
560#endif
561
503void __init omap_sdrc_init(struct omap_sdrc_params *sdrc_cs0, 562void __init omap_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
504 struct omap_sdrc_params *sdrc_cs1) 563 struct omap_sdrc_params *sdrc_cs1)
505{ 564{
diff --git a/arch/arm/mach-omap2/iomap.h b/arch/arm/mach-omap2/iomap.h
index 80b88921fab..cce2b65039f 100644
--- a/arch/arm/mach-omap2/iomap.h
+++ b/arch/arm/mach-omap2/iomap.h
@@ -1,6 +1,14 @@
1/* 1/*
2 * IO mappings for OMAP2+ 2 * IO mappings for OMAP2+
3 * 3 *
4 * IO definitions for TI OMAP processors and boards
5 *
6 * Copied from arch/arm/mach-sa1100/include/mach/io.h
7 * Copyright (C) 1997-1999 Russell King
8 *
9 * Copyright (C) 2009-2012 Texas Instruments
10 * Added OMAP4/5 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
11 *
4 * This program is free software; you can redistribute it and/or modify it 12 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the 13 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your 14 * Free Software Foundation; either version 2 of the License, or (at your
@@ -166,4 +174,23 @@
166 /* 0x49000000 --> 0xfb000000 */ 174 /* 0x49000000 --> 0xfb000000 */
167#define L4_ABE_44XX_VIRT (L4_ABE_44XX_PHYS + OMAP2_L4_IO_OFFSET) 175#define L4_ABE_44XX_VIRT (L4_ABE_44XX_PHYS + OMAP2_L4_IO_OFFSET)
168#define L4_ABE_44XX_SIZE SZ_1M 176#define L4_ABE_44XX_SIZE SZ_1M
177/*
178 * ----------------------------------------------------------------------------
179 * Omap5 specific IO mapping
180 * ----------------------------------------------------------------------------
181 */
182#define L3_54XX_PHYS L3_54XX_BASE /* 0x44000000 --> 0xf8000000 */
183#define L3_54XX_VIRT (L3_54XX_PHYS + OMAP4_L3_IO_OFFSET)
184#define L3_54XX_SIZE SZ_1M
185
186#define L4_54XX_PHYS L4_54XX_BASE /* 0x4a000000 --> 0xfc000000 */
187#define L4_54XX_VIRT (L4_54XX_PHYS + OMAP2_L4_IO_OFFSET)
188#define L4_54XX_SIZE SZ_4M
189
190#define L4_WK_54XX_PHYS L4_WK_54XX_BASE /* 0x4ae00000 --> 0xfce00000 */
191#define L4_WK_54XX_VIRT (L4_WK_54XX_PHYS + OMAP2_L4_IO_OFFSET)
192#define L4_WK_54XX_SIZE SZ_2M
169 193
194#define L4_PER_54XX_PHYS L4_PER_54XX_BASE /* 0x48000000 --> 0xfa000000 */
195#define L4_PER_54XX_VIRT (L4_PER_54XX_PHYS + OMAP2_L4_IO_OFFSET)
196#define L4_PER_54XX_SIZE SZ_4M
diff --git a/arch/arm/mach-omap2/irq.c b/arch/arm/mach-omap2/irq.c
index 6038a8c84b7..bcd83db41bb 100644
--- a/arch/arm/mach-omap2/irq.c
+++ b/arch/arm/mach-omap2/irq.c
@@ -21,6 +21,7 @@
21#include <linux/irqdomain.h> 21#include <linux/irqdomain.h>
22#include <linux/of.h> 22#include <linux/of.h>
23#include <linux/of_address.h> 23#include <linux/of_address.h>
24#include <linux/of_irq.h>
24 25
25#include <mach/hardware.h> 26#include <mach/hardware.h>
26 27
@@ -258,11 +259,11 @@ asmlinkage void __exception_irq_entry omap2_intc_handle_irq(struct pt_regs *regs
258 omap_intc_handle_irq(base_addr, regs); 259 omap_intc_handle_irq(base_addr, regs);
259} 260}
260 261
261int __init omap_intc_of_init(struct device_node *node, 262int __init intc_of_init(struct device_node *node,
262 struct device_node *parent) 263 struct device_node *parent)
263{ 264{
264 struct resource res; 265 struct resource res;
265 u32 nr_irqs = 96; 266 u32 nr_irq = 96;
266 267
267 if (WARN_ON(!node)) 268 if (WARN_ON(!node))
268 return -ENODEV; 269 return -ENODEV;
@@ -272,15 +273,25 @@ int __init omap_intc_of_init(struct device_node *node,
272 return -EINVAL; 273 return -EINVAL;
273 } 274 }
274 275
275 if (of_property_read_u32(node, "ti,intc-size", &nr_irqs)) 276 if (of_property_read_u32(node, "ti,intc-size", &nr_irq))
276 pr_warn("unable to get intc-size, default to %d\n", nr_irqs); 277 pr_warn("unable to get intc-size, default to %d\n", nr_irq);
277 278
278 omap_init_irq(res.start, nr_irqs, of_node_get(node)); 279 omap_init_irq(res.start, nr_irq, of_node_get(node));
279 280
280 return 0; 281 return 0;
281} 282}
282 283
283#ifdef CONFIG_ARCH_OMAP3 284static struct of_device_id irq_match[] __initdata = {
285 { .compatible = "ti,omap2-intc", .data = intc_of_init, },
286 { }
287};
288
289void __init omap_intc_of_init(void)
290{
291 of_irq_init(irq_match);
292}
293
294#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_SOC_AM33XX)
284static struct omap3_intc_regs intc_context[ARRAY_SIZE(irq_banks)]; 295static struct omap3_intc_regs intc_context[ARRAY_SIZE(irq_banks)];
285 296
286void omap_intc_save_context(void) 297void omap_intc_save_context(void)
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 19b8b677486..6875be837d9 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -83,8 +83,6 @@ static int omap2_mbox_startup(struct omap_mbox *mbox)
83 l = mbox_read_reg(MAILBOX_REVISION); 83 l = mbox_read_reg(MAILBOX_REVISION);
84 pr_debug("omap mailbox rev %d.%d\n", (l & 0xf0) >> 4, (l & 0x0f)); 84 pr_debug("omap mailbox rev %d.%d\n", (l & 0xf0) >> 4, (l & 0x0f));
85 85
86 omap2_mbox_enable_irq(mbox, IRQ_RX);
87
88 return 0; 86 return 0;
89} 87}
90 88
diff --git a/arch/arm/mach-omap2/msdi.c b/arch/arm/mach-omap2/msdi.c
index ef2a6924731..fb5bc6cf377 100644
--- a/arch/arm/mach-omap2/msdi.c
+++ b/arch/arm/mach-omap2/msdi.c
@@ -22,11 +22,15 @@
22 */ 22 */
23 23
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/err.h>
25 26
26#include <plat/omap_hwmod.h> 27#include <plat/omap_hwmod.h>
28#include <plat/omap_device.h>
27#include <plat/mmc.h> 29#include <plat/mmc.h>
28 30
29#include "common.h" 31#include "common.h"
32#include "control.h"
33#include "mux.h"
30 34
31/* 35/*
32 * MSDI_CON_OFFSET: offset in bytes of the MSDI IP block's CON register 36 * MSDI_CON_OFFSET: offset in bytes of the MSDI IP block's CON register
@@ -86,3 +90,72 @@ int omap_msdi_reset(struct omap_hwmod *oh)
86 90
87 return 0; 91 return 0;
88} 92}
93
94#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
95
96static inline void omap242x_mmc_mux(struct omap_mmc_platform_data
97 *mmc_controller)
98{
99 if ((mmc_controller->slots[0].switch_pin > 0) && \
100 (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
101 omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
102 OMAP_PIN_INPUT_PULLUP);
103 if ((mmc_controller->slots[0].gpio_wp > 0) && \
104 (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
105 omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
106 OMAP_PIN_INPUT_PULLUP);
107
108 omap_mux_init_signal("sdmmc_cmd", 0);
109 omap_mux_init_signal("sdmmc_clki", 0);
110 omap_mux_init_signal("sdmmc_clko", 0);
111 omap_mux_init_signal("sdmmc_dat0", 0);
112 omap_mux_init_signal("sdmmc_dat_dir0", 0);
113 omap_mux_init_signal("sdmmc_cmd_dir", 0);
114 if (mmc_controller->slots[0].caps & MMC_CAP_4_BIT_DATA) {
115 omap_mux_init_signal("sdmmc_dat1", 0);
116 omap_mux_init_signal("sdmmc_dat2", 0);
117 omap_mux_init_signal("sdmmc_dat3", 0);
118 omap_mux_init_signal("sdmmc_dat_dir1", 0);
119 omap_mux_init_signal("sdmmc_dat_dir2", 0);
120 omap_mux_init_signal("sdmmc_dat_dir3", 0);
121 }
122
123 /*
124 * Use internal loop-back in MMC/SDIO Module Input Clock
125 * selection
126 */
127 if (mmc_controller->slots[0].internal_clock) {
128 u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
129 v |= (1 << 24);
130 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
131 }
132}
133
134void __init omap242x_init_mmc(struct omap_mmc_platform_data **mmc_data)
135{
136 struct platform_device *pdev;
137 struct omap_hwmod *oh;
138 int id = 0;
139 char *oh_name = "msdi1";
140 char *dev_name = "mmci-omap";
141
142 if (!mmc_data[0]) {
143 pr_err("%s fails: Incomplete platform data\n", __func__);
144 return;
145 }
146
147 omap242x_mmc_mux(mmc_data[0]);
148
149 oh = omap_hwmod_lookup(oh_name);
150 if (!oh) {
151 pr_err("Could not look up %s\n", oh_name);
152 return;
153 }
154 pdev = omap_device_build(dev_name, id, oh, mmc_data[0],
155 sizeof(struct omap_mmc_platform_data), NULL, 0, 0);
156 if (IS_ERR(pdev))
157 WARN(1, "Can'd build omap_device for %s:%s.\n",
158 dev_name, oh->name);
159}
160
161#endif
diff --git a/arch/arm/mach-omap2/mux.h b/arch/arm/mach-omap2/mux.h
index 471e62a74a1..76f9b3c2f58 100644
--- a/arch/arm/mach-omap2/mux.h
+++ b/arch/arm/mach-omap2/mux.h
@@ -127,7 +127,6 @@ struct omap_mux_partition {
127 * @gpio: GPIO number 127 * @gpio: GPIO number
128 * @muxnames: available signal modes for a ball 128 * @muxnames: available signal modes for a ball
129 * @balls: available balls on the package 129 * @balls: available balls on the package
130 * @partition: mux partition
131 */ 130 */
132struct omap_mux { 131struct omap_mux {
133 u16 reg_offset; 132 u16 reg_offset;
diff --git a/arch/arm/mach-omap2/omap-headsmp.S b/arch/arm/mach-omap2/omap-headsmp.S
index 503ac777a2b..502e3135aad 100644
--- a/arch/arm/mach-omap2/omap-headsmp.S
+++ b/arch/arm/mach-omap2/omap-headsmp.S
@@ -19,6 +19,27 @@
19#include <linux/init.h> 19#include <linux/init.h>
20 20
21 __CPUINIT 21 __CPUINIT
22
23/* Physical address needed since MMU not enabled yet on secondary core */
24#define AUX_CORE_BOOT0_PA 0x48281800
25
26/*
27 * OMAP5 specific entry point for secondary CPU to jump from ROM
28 * code. This routine also provides a holding flag into which
29 * secondary core is held until we're ready for it to initialise.
30 * The primary core will update this flag using a hardware
31+ * register AuxCoreBoot0.
32 */
33ENTRY(omap5_secondary_startup)
34wait: ldr r2, =AUX_CORE_BOOT0_PA @ read from AuxCoreBoot0
35 ldr r0, [r2]
36 mov r0, r0, lsr #5
37 mrc p15, 0, r4, c0, c0, 5
38 and r4, r4, #0x0f
39 cmp r0, r4
40 bne wait
41 b secondary_startup
42END(omap5_secondary_startup)
22/* 43/*
23 * OMAP4 specific entry point for secondary CPU to jump from ROM 44 * OMAP4 specific entry point for secondary CPU to jump from ROM
24 * code. This routine also provides a holding flag into which 45 * code. This routine also provides a holding flag into which
diff --git a/arch/arm/mach-omap2/omap-hotplug.c b/arch/arm/mach-omap2/omap-hotplug.c
index 56c345b8b93..414083b427d 100644
--- a/arch/arm/mach-omap2/omap-hotplug.c
+++ b/arch/arm/mach-omap2/omap-hotplug.c
@@ -17,8 +17,10 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/smp.h> 19#include <linux/smp.h>
20#include <linux/io.h>
20 21
21#include <asm/cacheflush.h> 22#include <asm/cacheflush.h>
23#include <mach/omap-wakeupgen.h>
22 24
23#include "common.h" 25#include "common.h"
24 26
@@ -35,7 +37,8 @@ int platform_cpu_kill(unsigned int cpu)
35 */ 37 */
36void __ref platform_cpu_die(unsigned int cpu) 38void __ref platform_cpu_die(unsigned int cpu)
37{ 39{
38 unsigned int this_cpu; 40 unsigned int boot_cpu = 0;
41 void __iomem *base = omap_get_wakeupgen_base();
39 42
40 flush_cache_all(); 43 flush_cache_all();
41 dsb(); 44 dsb();
@@ -43,16 +46,27 @@ void __ref platform_cpu_die(unsigned int cpu)
43 /* 46 /*
44 * we're ready for shutdown now, so do it 47 * we're ready for shutdown now, so do it
45 */ 48 */
46 if (omap_modify_auxcoreboot0(0x0, 0x200) != 0x0) 49 if (omap_secure_apis_support()) {
47 pr_err("Secure clear status failed\n"); 50 if (omap_modify_auxcoreboot0(0x0, 0x200) != 0x0)
51 pr_err("Secure clear status failed\n");
52 } else {
53 __raw_writel(0, base + OMAP_AUX_CORE_BOOT_0);
54 }
55
48 56
49 for (;;) { 57 for (;;) {
50 /* 58 /*
51 * Enter into low power state 59 * Enter into low power state
52 */ 60 */
53 omap4_hotplug_cpu(cpu, PWRDM_POWER_OFF); 61 omap4_hotplug_cpu(cpu, PWRDM_POWER_OFF);
54 this_cpu = smp_processor_id(); 62
55 if (omap_read_auxcoreboot0() == this_cpu) { 63 if (omap_secure_apis_support())
64 boot_cpu = omap_read_auxcoreboot0();
65 else
66 boot_cpu =
67 __raw_readl(base + OMAP_AUX_CORE_BOOT_0) >> 5;
68
69 if (boot_cpu == smp_processor_id()) {
56 /* 70 /*
57 * OK, proper wakeup, we're done 71 * OK, proper wakeup, we're done
58 */ 72 */
diff --git a/arch/arm/mach-omap2/omap-iommu.c b/arch/arm/mach-omap2/omap-iommu.c
index ac49384d028..1be8bcb52e9 100644
--- a/arch/arm/mach-omap2/omap-iommu.c
+++ b/arch/arm/mach-omap2/omap-iommu.c
@@ -73,19 +73,17 @@ static struct iommu_device omap4_devices[] = {
73 .da_end = 0xFFFFF000, 73 .da_end = 0xFFFFF000,
74 }, 74 },
75 }, 75 },
76#if defined(CONFIG_MPU_TESLA_IOMMU)
77 { 76 {
78 .base = OMAP4_MMU2_BASE, 77 .base = OMAP4_MMU2_BASE,
79 .irq = INT_44XX_DSP_MMU, 78 .irq = OMAP44XX_IRQ_TESLA_MMU,
80 .pdata = { 79 .pdata = {
81 .name = "tesla", 80 .name = "tesla",
82 .nr_tlb_entries = 32, 81 .nr_tlb_entries = 32,
83 .clk_name = "tesla_ick", 82 .clk_name = "dsp_fck",
84 .da_start = 0x0, 83 .da_start = 0x0,
85 .da_end = 0xFFFFF000, 84 .da_end = 0xFFFFF000,
86 }, 85 },
87 }, 86 },
88#endif
89}; 87};
90#define NR_OMAP4_IOMMU_DEVICES ARRAY_SIZE(omap4_devices) 88#define NR_OMAP4_IOMMU_DEVICES ARRAY_SIZE(omap4_devices)
91static struct platform_device *omap4_iommu_pdev[NR_OMAP4_IOMMU_DEVICES]; 89static struct platform_device *omap4_iommu_pdev[NR_OMAP4_IOMMU_DEVICES];
diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
index 13670aa84e5..637a1bdf2ac 100644
--- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
+++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
@@ -255,7 +255,7 @@ int omap4_enter_lowpower(unsigned int cpu, unsigned int power_state)
255 return -ENXIO; 255 return -ENXIO;
256 } 256 }
257 257
258 pwrdm_pre_transition(); 258 pwrdm_pre_transition(NULL);
259 259
260 /* 260 /*
261 * Check MPUSS next state and save interrupt controller if needed. 261 * Check MPUSS next state and save interrupt controller if needed.
@@ -287,7 +287,7 @@ int omap4_enter_lowpower(unsigned int cpu, unsigned int power_state)
287 wakeup_cpu = smp_processor_id(); 287 wakeup_cpu = smp_processor_id();
288 set_cpu_next_pwrst(wakeup_cpu, PWRDM_POWER_ON); 288 set_cpu_next_pwrst(wakeup_cpu, PWRDM_POWER_ON);
289 289
290 pwrdm_post_transition(); 290 pwrdm_post_transition(NULL);
291 291
292 return 0; 292 return 0;
293} 293}
@@ -313,7 +313,7 @@ int __cpuinit omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state)
313 scu_pwrst_prepare(cpu, power_state); 313 scu_pwrst_prepare(cpu, power_state);
314 314
315 /* 315 /*
316 * CPU never retuns back if targetted power state is OFF mode. 316 * CPU never retuns back if targeted power state is OFF mode.
317 * CPU ONLINE follows normal CPU ONLINE ptah via 317 * CPU ONLINE follows normal CPU ONLINE ptah via
318 * omap_secondary_startup(). 318 * omap_secondary_startup().
319 */ 319 */
diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
index deffbf1c962..9a35adf9123 100644
--- a/arch/arm/mach-omap2/omap-smp.c
+++ b/arch/arm/mach-omap2/omap-smp.c
@@ -26,11 +26,19 @@
26 26
27#include <mach/hardware.h> 27#include <mach/hardware.h>
28#include <mach/omap-secure.h> 28#include <mach/omap-secure.h>
29#include <mach/omap-wakeupgen.h>
30#include <asm/cputype.h>
29 31
30#include "iomap.h" 32#include "iomap.h"
31#include "common.h" 33#include "common.h"
32#include "clockdomain.h" 34#include "clockdomain.h"
33 35
36#define CPU_MASK 0xff0ffff0
37#define CPU_CORTEX_A9 0x410FC090
38#define CPU_CORTEX_A15 0x410FC0F0
39
40#define OMAP5_CORE_COUNT 0x2
41
34/* SCU base address */ 42/* SCU base address */
35static void __iomem *scu_base; 43static void __iomem *scu_base;
36 44
@@ -73,6 +81,8 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
73{ 81{
74 static struct clockdomain *cpu1_clkdm; 82 static struct clockdomain *cpu1_clkdm;
75 static bool booted; 83 static bool booted;
84 void __iomem *base = omap_get_wakeupgen_base();
85
76 /* 86 /*
77 * Set synchronisation state between this boot processor 87 * Set synchronisation state between this boot processor
78 * and the secondary one 88 * and the secondary one
@@ -85,7 +95,11 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
85 * the AuxCoreBoot1 register is updated with cpu state 95 * the AuxCoreBoot1 register is updated with cpu state
86 * A barrier is added to ensure that write buffer is drained 96 * A barrier is added to ensure that write buffer is drained
87 */ 97 */
88 omap_modify_auxcoreboot0(0x200, 0xfffffdff); 98 if (omap_secure_apis_support())
99 omap_modify_auxcoreboot0(0x200, 0xfffffdff);
100 else
101 __raw_writel(0x20, base + OMAP_AUX_CORE_BOOT_0);
102
89 flush_cache_all(); 103 flush_cache_all();
90 smp_wmb(); 104 smp_wmb();
91 105
@@ -111,7 +125,7 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
111 booted = true; 125 booted = true;
112 } 126 }
113 127
114 gic_raise_softirq(cpumask_of(cpu), 1); 128 gic_raise_softirq(cpumask_of(cpu), 0);
115 129
116 /* 130 /*
117 * Now the secondary core is starting up let it run its 131 * Now the secondary core is starting up let it run its
@@ -124,13 +138,19 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
124 138
125static void __init wakeup_secondary(void) 139static void __init wakeup_secondary(void)
126{ 140{
141 void __iomem *base = omap_get_wakeupgen_base();
127 /* 142 /*
128 * Write the address of secondary startup routine into the 143 * Write the address of secondary startup routine into the
129 * AuxCoreBoot1 where ROM code will jump and start executing 144 * AuxCoreBoot1 where ROM code will jump and start executing
130 * on secondary core once out of WFE 145 * on secondary core once out of WFE
131 * A barrier is added to ensure that write buffer is drained 146 * A barrier is added to ensure that write buffer is drained
132 */ 147 */
133 omap_auxcoreboot_addr(virt_to_phys(omap_secondary_startup)); 148 if (omap_secure_apis_support())
149 omap_auxcoreboot_addr(virt_to_phys(omap_secondary_startup));
150 else
151 __raw_writel(virt_to_phys(omap5_secondary_startup),
152 base + OMAP_AUX_CORE_BOOT_1);
153
134 smp_wmb(); 154 smp_wmb();
135 155
136 /* 156 /*
@@ -147,16 +167,21 @@ static void __init wakeup_secondary(void)
147 */ 167 */
148void __init smp_init_cpus(void) 168void __init smp_init_cpus(void)
149{ 169{
150 unsigned int i, ncores; 170 unsigned int i = 0, ncores = 1, cpu_id;
151 171
152 /* 172 /* Use ARM cpuid check here, as SoC detection will not work so early */
153 * Currently we can't call ioremap here because 173 cpu_id = read_cpuid(CPUID_ID) & CPU_MASK;
154 * SoC detection won't work until after init_early. 174 if (cpu_id == CPU_CORTEX_A9) {
155 */ 175 /*
156 scu_base = OMAP2_L4_IO_ADDRESS(OMAP44XX_SCU_BASE); 176 * Currently we can't call ioremap here because
157 BUG_ON(!scu_base); 177 * SoC detection won't work until after init_early.
158 178 */
159 ncores = scu_get_core_count(scu_base); 179 scu_base = OMAP2_L4_IO_ADDRESS(OMAP44XX_SCU_BASE);
180 BUG_ON(!scu_base);
181 ncores = scu_get_core_count(scu_base);
182 } else if (cpu_id == CPU_CORTEX_A15) {
183 ncores = OMAP5_CORE_COUNT;
184 }
160 185
161 /* sanity check */ 186 /* sanity check */
162 if (ncores > nr_cpu_ids) { 187 if (ncores > nr_cpu_ids) {
@@ -178,6 +203,7 @@ void __init platform_smp_prepare_cpus(unsigned int max_cpus)
178 * Initialise the SCU and wake up the secondary core using 203 * Initialise the SCU and wake up the secondary core using
179 * wakeup_secondary(). 204 * wakeup_secondary().
180 */ 205 */
181 scu_enable(scu_base); 206 if (scu_base)
207 scu_enable(scu_base);
182 wakeup_secondary(); 208 wakeup_secondary();
183} 209}
diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
index d811c779035..05fdebfaa19 100644
--- a/arch/arm/mach-omap2/omap-wakeupgen.c
+++ b/arch/arm/mach-omap2/omap-wakeupgen.c
@@ -33,18 +33,23 @@
33#include "omap4-sar-layout.h" 33#include "omap4-sar-layout.h"
34#include "common.h" 34#include "common.h"
35 35
36#define NR_REG_BANKS 4 36#define MAX_NR_REG_BANKS 5
37#define MAX_IRQS 128 37#define MAX_IRQS 160
38#define WKG_MASK_ALL 0x00000000 38#define WKG_MASK_ALL 0x00000000
39#define WKG_UNMASK_ALL 0xffffffff 39#define WKG_UNMASK_ALL 0xffffffff
40#define CPU_ENA_OFFSET 0x400 40#define CPU_ENA_OFFSET 0x400
41#define CPU0_ID 0x0 41#define CPU0_ID 0x0
42#define CPU1_ID 0x1 42#define CPU1_ID 0x1
43#define OMAP4_NR_BANKS 4
44#define OMAP4_NR_IRQS 128
43 45
44static void __iomem *wakeupgen_base; 46static void __iomem *wakeupgen_base;
45static void __iomem *sar_base; 47static void __iomem *sar_base;
46static DEFINE_SPINLOCK(wakeupgen_lock); 48static DEFINE_SPINLOCK(wakeupgen_lock);
47static unsigned int irq_target_cpu[NR_IRQS]; 49static unsigned int irq_target_cpu[NR_IRQS];
50static unsigned int irq_banks = MAX_NR_REG_BANKS;
51static unsigned int max_irqs = MAX_IRQS;
52static unsigned int omap_secure_apis;
48 53
49/* 54/*
50 * Static helper functions. 55 * Static helper functions.
@@ -146,13 +151,13 @@ static void wakeupgen_unmask(struct irq_data *d)
146} 151}
147 152
148#ifdef CONFIG_HOTPLUG_CPU 153#ifdef CONFIG_HOTPLUG_CPU
149static DEFINE_PER_CPU(u32 [NR_REG_BANKS], irqmasks); 154static DEFINE_PER_CPU(u32 [MAX_NR_REG_BANKS], irqmasks);
150 155
151static void _wakeupgen_save_masks(unsigned int cpu) 156static void _wakeupgen_save_masks(unsigned int cpu)
152{ 157{
153 u8 i; 158 u8 i;
154 159
155 for (i = 0; i < NR_REG_BANKS; i++) 160 for (i = 0; i < irq_banks; i++)
156 per_cpu(irqmasks, cpu)[i] = wakeupgen_readl(i, cpu); 161 per_cpu(irqmasks, cpu)[i] = wakeupgen_readl(i, cpu);
157} 162}
158 163
@@ -160,7 +165,7 @@ static void _wakeupgen_restore_masks(unsigned int cpu)
160{ 165{
161 u8 i; 166 u8 i;
162 167
163 for (i = 0; i < NR_REG_BANKS; i++) 168 for (i = 0; i < irq_banks; i++)
164 wakeupgen_writel(per_cpu(irqmasks, cpu)[i], i, cpu); 169 wakeupgen_writel(per_cpu(irqmasks, cpu)[i], i, cpu);
165} 170}
166 171
@@ -168,7 +173,7 @@ static void _wakeupgen_set_all(unsigned int cpu, unsigned int reg)
168{ 173{
169 u8 i; 174 u8 i;
170 175
171 for (i = 0; i < NR_REG_BANKS; i++) 176 for (i = 0; i < irq_banks; i++)
172 wakeupgen_writel(reg, i, cpu); 177 wakeupgen_writel(reg, i, cpu);
173} 178}
174 179
@@ -196,25 +201,14 @@ static void wakeupgen_irqmask_all(unsigned int cpu, unsigned int set)
196#endif 201#endif
197 202
198#ifdef CONFIG_CPU_PM 203#ifdef CONFIG_CPU_PM
199/* 204static inline void omap4_irq_save_context(void)
200 * Save WakeupGen interrupt context in SAR BANK3. Restore is done by
201 * ROM code. WakeupGen IP is integrated along with GIC to manage the
202 * interrupt wakeups from CPU low power states. It manages
203 * masking/unmasking of Shared peripheral interrupts(SPI). So the
204 * interrupt enable/disable control should be in sync and consistent
205 * at WakeupGen and GIC so that interrupts are not lost.
206 */
207static void irq_save_context(void)
208{ 205{
209 u32 i, val; 206 u32 i, val;
210 207
211 if (omap_rev() == OMAP4430_REV_ES1_0) 208 if (omap_rev() == OMAP4430_REV_ES1_0)
212 return; 209 return;
213 210
214 if (!sar_base) 211 for (i = 0; i < irq_banks; i++) {
215 sar_base = omap4_get_sar_ram_base();
216
217 for (i = 0; i < NR_REG_BANKS; i++) {
218 /* Save the CPUx interrupt mask for IRQ 0 to 127 */ 212 /* Save the CPUx interrupt mask for IRQ 0 to 127 */
219 val = wakeupgen_readl(i, 0); 213 val = wakeupgen_readl(i, 0);
220 sar_writel(val, WAKEUPGENENB_OFFSET_CPU0, i); 214 sar_writel(val, WAKEUPGENENB_OFFSET_CPU0, i);
@@ -254,6 +248,53 @@ static void irq_save_context(void)
254 val = __raw_readl(sar_base + SAR_BACKUP_STATUS_OFFSET); 248 val = __raw_readl(sar_base + SAR_BACKUP_STATUS_OFFSET);
255 val |= SAR_BACKUP_STATUS_WAKEUPGEN; 249 val |= SAR_BACKUP_STATUS_WAKEUPGEN;
256 __raw_writel(val, sar_base + SAR_BACKUP_STATUS_OFFSET); 250 __raw_writel(val, sar_base + SAR_BACKUP_STATUS_OFFSET);
251
252}
253
254static inline void omap5_irq_save_context(void)
255{
256 u32 i, val;
257
258 for (i = 0; i < irq_banks; i++) {
259 /* Save the CPUx interrupt mask for IRQ 0 to 159 */
260 val = wakeupgen_readl(i, 0);
261 sar_writel(val, OMAP5_WAKEUPGENENB_OFFSET_CPU0, i);
262 val = wakeupgen_readl(i, 1);
263 sar_writel(val, OMAP5_WAKEUPGENENB_OFFSET_CPU1, i);
264 sar_writel(0x0, OMAP5_WAKEUPGENENB_SECURE_OFFSET_CPU0, i);
265 sar_writel(0x0, OMAP5_WAKEUPGENENB_SECURE_OFFSET_CPU1, i);
266 }
267
268 /* Save AuxBoot* registers */
269 val = __raw_readl(wakeupgen_base + OMAP_AUX_CORE_BOOT_0);
270 __raw_writel(val, sar_base + OMAP5_AUXCOREBOOT0_OFFSET);
271 val = __raw_readl(wakeupgen_base + OMAP_AUX_CORE_BOOT_0);
272 __raw_writel(val, sar_base + OMAP5_AUXCOREBOOT1_OFFSET);
273
274 /* Set the Backup Bit Mask status */
275 val = __raw_readl(sar_base + OMAP5_SAR_BACKUP_STATUS_OFFSET);
276 val |= SAR_BACKUP_STATUS_WAKEUPGEN;
277 __raw_writel(val, sar_base + OMAP5_SAR_BACKUP_STATUS_OFFSET);
278
279}
280
281/*
282 * Save WakeupGen interrupt context in SAR BANK3. Restore is done by
283 * ROM code. WakeupGen IP is integrated along with GIC to manage the
284 * interrupt wakeups from CPU low power states. It manages
285 * masking/unmasking of Shared peripheral interrupts(SPI). So the
286 * interrupt enable/disable control should be in sync and consistent
287 * at WakeupGen and GIC so that interrupts are not lost.
288 */
289static void irq_save_context(void)
290{
291 if (!sar_base)
292 sar_base = omap4_get_sar_ram_base();
293
294 if (soc_is_omap54xx())
295 omap5_irq_save_context();
296 else
297 omap4_irq_save_context();
257} 298}
258 299
259/* 300/*
@@ -262,9 +303,14 @@ static void irq_save_context(void)
262static void irq_sar_clear(void) 303static void irq_sar_clear(void)
263{ 304{
264 u32 val; 305 u32 val;
265 val = __raw_readl(sar_base + SAR_BACKUP_STATUS_OFFSET); 306 u32 offset = SAR_BACKUP_STATUS_OFFSET;
307
308 if (soc_is_omap54xx())
309 offset = OMAP5_SAR_BACKUP_STATUS_OFFSET;
310
311 val = __raw_readl(sar_base + offset);
266 val &= ~SAR_BACKUP_STATUS_WAKEUPGEN; 312 val &= ~SAR_BACKUP_STATUS_WAKEUPGEN;
267 __raw_writel(val, sar_base + SAR_BACKUP_STATUS_OFFSET); 313 __raw_writel(val, sar_base + offset);
268} 314}
269 315
270/* 316/*
@@ -336,13 +382,25 @@ static struct notifier_block irq_notifier_block = {
336 382
337static void __init irq_pm_init(void) 383static void __init irq_pm_init(void)
338{ 384{
339 cpu_pm_register_notifier(&irq_notifier_block); 385 /* FIXME: Remove this when MPU OSWR support is added */
386 if (!soc_is_omap54xx())
387 cpu_pm_register_notifier(&irq_notifier_block);
340} 388}
341#else 389#else
342static void __init irq_pm_init(void) 390static void __init irq_pm_init(void)
343{} 391{}
344#endif 392#endif
345 393
394void __iomem *omap_get_wakeupgen_base(void)
395{
396 return wakeupgen_base;
397}
398
399int omap_secure_apis_support(void)
400{
401 return omap_secure_apis;
402}
403
346/* 404/*
347 * Initialise the wakeupgen module. 405 * Initialise the wakeupgen module.
348 */ 406 */
@@ -358,12 +416,18 @@ int __init omap_wakeupgen_init(void)
358 } 416 }
359 417
360 /* Static mapping, never released */ 418 /* Static mapping, never released */
361 wakeupgen_base = ioremap(OMAP44XX_WKUPGEN_BASE, SZ_4K); 419 wakeupgen_base = ioremap(OMAP_WKUPGEN_BASE, SZ_4K);
362 if (WARN_ON(!wakeupgen_base)) 420 if (WARN_ON(!wakeupgen_base))
363 return -ENOMEM; 421 return -ENOMEM;
364 422
423 if (cpu_is_omap44xx()) {
424 irq_banks = OMAP4_NR_BANKS;
425 max_irqs = OMAP4_NR_IRQS;
426 omap_secure_apis = 1;
427 }
428
365 /* Clear all IRQ bitmasks at wakeupGen level */ 429 /* Clear all IRQ bitmasks at wakeupGen level */
366 for (i = 0; i < NR_REG_BANKS; i++) { 430 for (i = 0; i < irq_banks; i++) {
367 wakeupgen_writel(0, i, CPU0_ID); 431 wakeupgen_writel(0, i, CPU0_ID);
368 wakeupgen_writel(0, i, CPU1_ID); 432 wakeupgen_writel(0, i, CPU1_ID);
369 } 433 }
@@ -382,7 +446,7 @@ int __init omap_wakeupgen_init(void)
382 */ 446 */
383 447
384 /* Associate all the IRQs to boot CPU like GIC init does. */ 448 /* Associate all the IRQs to boot CPU like GIC init does. */
385 for (i = 0; i < NR_IRQS; i++) 449 for (i = 0; i < max_irqs; i++)
386 irq_target_cpu[i] = boot_cpu; 450 irq_target_cpu[i] = boot_cpu;
387 451
388 irq_hotplug_init(); 452 irq_hotplug_init();
diff --git a/arch/arm/mach-omap2/omap4-common.c b/arch/arm/mach-omap2/omap4-common.c
index a8161e5f320..c29dee998a7 100644
--- a/arch/arm/mach-omap2/omap4-common.c
+++ b/arch/arm/mach-omap2/omap4-common.c
@@ -21,6 +21,8 @@
21#include <asm/hardware/cache-l2x0.h> 21#include <asm/hardware/cache-l2x0.h>
22#include <asm/mach/map.h> 22#include <asm/mach/map.h>
23#include <asm/memblock.h> 23#include <asm/memblock.h>
24#include <linux/of_irq.h>
25#include <linux/of_platform.h>
24 26
25#include <plat/irqs.h> 27#include <plat/irqs.h>
26#include <plat/sram.h> 28#include <plat/sram.h>
@@ -210,6 +212,18 @@ static int __init omap4_sar_ram_init(void)
210} 212}
211early_initcall(omap4_sar_ram_init); 213early_initcall(omap4_sar_ram_init);
212 214
215static struct of_device_id irq_match[] __initdata = {
216 { .compatible = "arm,cortex-a9-gic", .data = gic_of_init, },
217 { .compatible = "arm,cortex-a15-gic", .data = gic_of_init, },
218 { }
219};
220
221void __init omap_gic_of_init(void)
222{
223 omap_wakeupgen_init();
224 of_irq_init(irq_match);
225}
226
213#if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE) 227#if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
214static int omap4_twl6030_hsmmc_late_init(struct device *dev) 228static int omap4_twl6030_hsmmc_late_init(struct device *dev)
215{ 229{
diff --git a/arch/arm/mach-omap2/omap4-sar-layout.h b/arch/arm/mach-omap2/omap4-sar-layout.h
index fe5b545ad44..e170fe803b0 100644
--- a/arch/arm/mach-omap2/omap4-sar-layout.h
+++ b/arch/arm/mach-omap2/omap4-sar-layout.h
@@ -12,7 +12,7 @@
12#define OMAP_ARCH_OMAP4_SAR_LAYOUT_H 12#define OMAP_ARCH_OMAP4_SAR_LAYOUT_H
13 13
14/* 14/*
15 * SAR BANK offsets from base address OMAP44XX_SAR_RAM_BASE 15 * SAR BANK offsets from base address OMAP44XX/54XX_SAR_RAM_BASE
16 */ 16 */
17#define SAR_BANK1_OFFSET 0x0000 17#define SAR_BANK1_OFFSET 0x0000
18#define SAR_BANK2_OFFSET 0x1000 18#define SAR_BANK2_OFFSET 0x1000
@@ -47,4 +47,14 @@
47#define PTMSYNCREQ_EN_OFFSET (SAR_BANK3_OFFSET + 0x6d0) 47#define PTMSYNCREQ_EN_OFFSET (SAR_BANK3_OFFSET + 0x6d0)
48#define SAR_BACKUP_STATUS_WAKEUPGEN 0x10 48#define SAR_BACKUP_STATUS_WAKEUPGEN 0x10
49 49
50/* WakeUpGen save restore offset from OMAP54XX_SAR_RAM_BASE */
51#define OMAP5_WAKEUPGENENB_OFFSET_CPU0 (SAR_BANK3_OFFSET + 0x8d4)
52#define OMAP5_WAKEUPGENENB_SECURE_OFFSET_CPU0 (SAR_BANK3_OFFSET + 0x8e8)
53#define OMAP5_WAKEUPGENENB_OFFSET_CPU1 (SAR_BANK3_OFFSET + 0x8fc)
54#define OMAP5_WAKEUPGENENB_SECURE_OFFSET_CPU1 (SAR_BANK3_OFFSET + 0x910)
55#define OMAP5_AUXCOREBOOT0_OFFSET (SAR_BANK3_OFFSET + 0x924)
56#define OMAP5_AUXCOREBOOT1_OFFSET (SAR_BANK3_OFFSET + 0x928)
57#define OMAP5_AMBA_IF_MODE_OFFSET (SAR_BANK3_OFFSET + 0x92c)
58#define OMAP5_SAR_BACKUP_STATUS_OFFSET (SAR_BANK3_OFFSET + 0x800)
59
50#endif 60#endif
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 2d710f50fca..6ca8e519968 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -153,6 +153,7 @@
153#include "prm44xx.h" 153#include "prm44xx.h"
154#include "prminst44xx.h" 154#include "prminst44xx.h"
155#include "mux.h" 155#include "mux.h"
156#include "pm.h"
156 157
157/* Maximum microseconds to wait for OMAP module to softreset */ 158/* Maximum microseconds to wait for OMAP module to softreset */
158#define MAX_MODULE_SOFTRESET_WAIT 10000 159#define MAX_MODULE_SOFTRESET_WAIT 10000
@@ -166,12 +167,40 @@
166 */ 167 */
167#define LINKS_PER_OCP_IF 2 168#define LINKS_PER_OCP_IF 2
168 169
170/**
171 * struct omap_hwmod_soc_ops - fn ptrs for some SoC-specific operations
172 * @enable_module: function to enable a module (via MODULEMODE)
173 * @disable_module: function to disable a module (via MODULEMODE)
174 *
175 * XXX Eventually this functionality will be hidden inside the PRM/CM
176 * device drivers. Until then, this should avoid huge blocks of cpu_is_*()
177 * conditionals in this code.
178 */
179struct omap_hwmod_soc_ops {
180 void (*enable_module)(struct omap_hwmod *oh);
181 int (*disable_module)(struct omap_hwmod *oh);
182 int (*wait_target_ready)(struct omap_hwmod *oh);
183 int (*assert_hardreset)(struct omap_hwmod *oh,
184 struct omap_hwmod_rst_info *ohri);
185 int (*deassert_hardreset)(struct omap_hwmod *oh,
186 struct omap_hwmod_rst_info *ohri);
187 int (*is_hardreset_asserted)(struct omap_hwmod *oh,
188 struct omap_hwmod_rst_info *ohri);
189 int (*init_clkdm)(struct omap_hwmod *oh);
190};
191
192/* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
193static struct omap_hwmod_soc_ops soc_ops;
194
169/* omap_hwmod_list contains all registered struct omap_hwmods */ 195/* omap_hwmod_list contains all registered struct omap_hwmods */
170static LIST_HEAD(omap_hwmod_list); 196static LIST_HEAD(omap_hwmod_list);
171 197
172/* mpu_oh: used to add/remove MPU initiator from sleepdep list */ 198/* mpu_oh: used to add/remove MPU initiator from sleepdep list */
173static struct omap_hwmod *mpu_oh; 199static struct omap_hwmod *mpu_oh;
174 200
201/* io_chain_lock: used to serialize reconfigurations of the I/O chain */
202static DEFINE_SPINLOCK(io_chain_lock);
203
175/* 204/*
176 * linkspace: ptr to a buffer that struct omap_hwmod_link records are 205 * linkspace: ptr to a buffer that struct omap_hwmod_link records are
177 * allocated from - used to reduce the number of small memory 206 * allocated from - used to reduce the number of small memory
@@ -186,6 +215,9 @@ static struct omap_hwmod_link *linkspace;
186 */ 215 */
187static unsigned short free_ls, max_ls, ls_supp; 216static unsigned short free_ls, max_ls, ls_supp;
188 217
218/* inited: set to true once the hwmod code is initialized */
219static bool inited;
220
189/* Private functions */ 221/* Private functions */
190 222
191/** 223/**
@@ -388,6 +420,49 @@ static int _set_softreset(struct omap_hwmod *oh, u32 *v)
388} 420}
389 421
390/** 422/**
423 * _set_dmadisable: set OCP_SYSCONFIG.DMADISABLE bit in @v
424 * @oh: struct omap_hwmod *
425 *
426 * The DMADISABLE bit is a semi-automatic bit present in sysconfig register
427 * of some modules. When the DMA must perform read/write accesses, the
428 * DMADISABLE bit is cleared by the hardware. But when the DMA must stop
429 * for power management, software must set the DMADISABLE bit back to 1.
430 *
431 * Set the DMADISABLE bit in @v for hwmod @oh. Returns -EINVAL upon
432 * error or 0 upon success.
433 */
434static int _set_dmadisable(struct omap_hwmod *oh)
435{
436 u32 v;
437 u32 dmadisable_mask;
438
439 if (!oh->class->sysc ||
440 !(oh->class->sysc->sysc_flags & SYSC_HAS_DMADISABLE))
441 return -EINVAL;
442
443 if (!oh->class->sysc->sysc_fields) {
444 WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name);
445 return -EINVAL;
446 }
447
448 /* clocks must be on for this operation */
449 if (oh->_state != _HWMOD_STATE_ENABLED) {
450 pr_warn("omap_hwmod: %s: dma can be disabled only from enabled state\n", oh->name);
451 return -EINVAL;
452 }
453
454 pr_debug("omap_hwmod: %s: setting DMADISABLE\n", oh->name);
455
456 v = oh->_sysc_cache;
457 dmadisable_mask =
458 (0x1 << oh->class->sysc->sysc_fields->dmadisable_shift);
459 v |= dmadisable_mask;
460 _write_sysconfig(v, oh);
461
462 return 0;
463}
464
465/**
391 * _set_module_autoidle: set the OCP_SYSCONFIG AUTOIDLE field in @v 466 * _set_module_autoidle: set the OCP_SYSCONFIG AUTOIDLE field in @v
392 * @oh: struct omap_hwmod * 467 * @oh: struct omap_hwmod *
393 * @autoidle: desired AUTOIDLE bitfield value (0 or 1) 468 * @autoidle: desired AUTOIDLE bitfield value (0 or 1)
@@ -771,23 +846,19 @@ static void _disable_optional_clocks(struct omap_hwmod *oh)
771} 846}
772 847
773/** 848/**
774 * _enable_module - enable CLKCTRL modulemode on OMAP4 849 * _omap4_enable_module - enable CLKCTRL modulemode on OMAP4
775 * @oh: struct omap_hwmod * 850 * @oh: struct omap_hwmod *
776 * 851 *
777 * Enables the PRCM module mode related to the hwmod @oh. 852 * Enables the PRCM module mode related to the hwmod @oh.
778 * No return value. 853 * No return value.
779 */ 854 */
780static void _enable_module(struct omap_hwmod *oh) 855static void _omap4_enable_module(struct omap_hwmod *oh)
781{ 856{
782 /* The module mode does not exist prior OMAP4 */
783 if (cpu_is_omap24xx() || cpu_is_omap34xx())
784 return;
785
786 if (!oh->clkdm || !oh->prcm.omap4.modulemode) 857 if (!oh->clkdm || !oh->prcm.omap4.modulemode)
787 return; 858 return;
788 859
789 pr_debug("omap_hwmod: %s: _enable_module: %d\n", 860 pr_debug("omap_hwmod: %s: %s: %d\n",
790 oh->name, oh->prcm.omap4.modulemode); 861 oh->name, __func__, oh->prcm.omap4.modulemode);
791 862
792 omap4_cminst_module_enable(oh->prcm.omap4.modulemode, 863 omap4_cminst_module_enable(oh->prcm.omap4.modulemode,
793 oh->clkdm->prcm_partition, 864 oh->clkdm->prcm_partition,
@@ -807,10 +878,7 @@ static void _enable_module(struct omap_hwmod *oh)
807 */ 878 */
808static int _omap4_wait_target_disable(struct omap_hwmod *oh) 879static int _omap4_wait_target_disable(struct omap_hwmod *oh)
809{ 880{
810 if (!cpu_is_omap44xx()) 881 if (!oh || !oh->clkdm)
811 return 0;
812
813 if (!oh)
814 return -EINVAL; 882 return -EINVAL;
815 883
816 if (oh->_int_flags & _HWMOD_NO_MPU_PORT) 884 if (oh->_int_flags & _HWMOD_NO_MPU_PORT)
@@ -1301,24 +1369,20 @@ static struct omap_hwmod *_lookup(const char *name)
1301 1369
1302 return oh; 1370 return oh;
1303} 1371}
1372
1304/** 1373/**
1305 * _init_clkdm - look up a clockdomain name, store pointer in omap_hwmod 1374 * _init_clkdm - look up a clockdomain name, store pointer in omap_hwmod
1306 * @oh: struct omap_hwmod * 1375 * @oh: struct omap_hwmod *
1307 * 1376 *
1308 * Convert a clockdomain name stored in a struct omap_hwmod into a 1377 * Convert a clockdomain name stored in a struct omap_hwmod into a
1309 * clockdomain pointer, and save it into the struct omap_hwmod. 1378 * clockdomain pointer, and save it into the struct omap_hwmod.
1310 * return -EINVAL if clkdm_name does not exist or if the lookup failed. 1379 * Return -EINVAL if the clkdm_name lookup failed.
1311 */ 1380 */
1312static int _init_clkdm(struct omap_hwmod *oh) 1381static int _init_clkdm(struct omap_hwmod *oh)
1313{ 1382{
1314 if (cpu_is_omap24xx() || cpu_is_omap34xx()) 1383 if (!oh->clkdm_name)
1315 return 0; 1384 return 0;
1316 1385
1317 if (!oh->clkdm_name) {
1318 pr_warning("omap_hwmod: %s: no clkdm_name\n", oh->name);
1319 return -EINVAL;
1320 }
1321
1322 oh->clkdm = clkdm_lookup(oh->clkdm_name); 1386 oh->clkdm = clkdm_lookup(oh->clkdm_name);
1323 if (!oh->clkdm) { 1387 if (!oh->clkdm) {
1324 pr_warning("omap_hwmod: %s: could not associate to clkdm %s\n", 1388 pr_warning("omap_hwmod: %s: could not associate to clkdm %s\n",
@@ -1354,7 +1418,8 @@ static int _init_clocks(struct omap_hwmod *oh, void *data)
1354 ret |= _init_main_clk(oh); 1418 ret |= _init_main_clk(oh);
1355 ret |= _init_interface_clks(oh); 1419 ret |= _init_interface_clks(oh);
1356 ret |= _init_opt_clks(oh); 1420 ret |= _init_opt_clks(oh);
1357 ret |= _init_clkdm(oh); 1421 if (soc_ops.init_clkdm)
1422 ret |= soc_ops.init_clkdm(oh);
1358 1423
1359 if (!ret) 1424 if (!ret)
1360 oh->_state = _HWMOD_STATE_CLKS_INITED; 1425 oh->_state = _HWMOD_STATE_CLKS_INITED;
@@ -1365,53 +1430,6 @@ static int _init_clocks(struct omap_hwmod *oh, void *data)
1365} 1430}
1366 1431
1367/** 1432/**
1368 * _wait_target_ready - wait for a module to leave slave idle
1369 * @oh: struct omap_hwmod *
1370 *
1371 * Wait for a module @oh to leave slave idle. Returns 0 if the module
1372 * does not have an IDLEST bit or if the module successfully leaves
1373 * slave idle; otherwise, pass along the return value of the
1374 * appropriate *_cm*_wait_module_ready() function.
1375 */
1376static int _wait_target_ready(struct omap_hwmod *oh)
1377{
1378 struct omap_hwmod_ocp_if *os;
1379 int ret;
1380
1381 if (!oh)
1382 return -EINVAL;
1383
1384 if (oh->flags & HWMOD_NO_IDLEST)
1385 return 0;
1386
1387 os = _find_mpu_rt_port(oh);
1388 if (!os)
1389 return 0;
1390
1391 /* XXX check module SIDLEMODE */
1392
1393 /* XXX check clock enable states */
1394
1395 if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
1396 ret = omap2_cm_wait_module_ready(oh->prcm.omap2.module_offs,
1397 oh->prcm.omap2.idlest_reg_id,
1398 oh->prcm.omap2.idlest_idle_bit);
1399 } else if (cpu_is_omap44xx()) {
1400 if (!oh->clkdm)
1401 return -EINVAL;
1402
1403 ret = omap4_cminst_wait_module_ready(oh->clkdm->prcm_partition,
1404 oh->clkdm->cm_inst,
1405 oh->clkdm->clkdm_offs,
1406 oh->prcm.omap4.clkctrl_offs);
1407 } else {
1408 BUG();
1409 };
1410
1411 return ret;
1412}
1413
1414/**
1415 * _lookup_hardreset - fill register bit info for this hwmod/reset line 1433 * _lookup_hardreset - fill register bit info for this hwmod/reset line
1416 * @oh: struct omap_hwmod * 1434 * @oh: struct omap_hwmod *
1417 * @name: name of the reset line in the context of this hwmod 1435 * @name: name of the reset line in the context of this hwmod
@@ -1447,32 +1465,31 @@ static u8 _lookup_hardreset(struct omap_hwmod *oh, const char *name,
1447 * @oh: struct omap_hwmod * 1465 * @oh: struct omap_hwmod *
1448 * @name: name of the reset line to lookup and assert 1466 * @name: name of the reset line to lookup and assert
1449 * 1467 *
1450 * Some IP like dsp, ipu or iva contain processor that require 1468 * Some IP like dsp, ipu or iva contain processor that require an HW
1451 * an HW reset line to be assert / deassert in order to enable fully 1469 * reset line to be assert / deassert in order to enable fully the IP.
1452 * the IP. 1470 * Returns -EINVAL if @oh is null, -ENOSYS if we have no way of
1471 * asserting the hardreset line on the currently-booted SoC, or passes
1472 * along the return value from _lookup_hardreset() or the SoC's
1473 * assert_hardreset code.
1453 */ 1474 */
1454static int _assert_hardreset(struct omap_hwmod *oh, const char *name) 1475static int _assert_hardreset(struct omap_hwmod *oh, const char *name)
1455{ 1476{
1456 struct omap_hwmod_rst_info ohri; 1477 struct omap_hwmod_rst_info ohri;
1457 u8 ret; 1478 u8 ret = -EINVAL;
1458 1479
1459 if (!oh) 1480 if (!oh)
1460 return -EINVAL; 1481 return -EINVAL;
1461 1482
1483 if (!soc_ops.assert_hardreset)
1484 return -ENOSYS;
1485
1462 ret = _lookup_hardreset(oh, name, &ohri); 1486 ret = _lookup_hardreset(oh, name, &ohri);
1463 if (IS_ERR_VALUE(ret)) 1487 if (IS_ERR_VALUE(ret))
1464 return ret; 1488 return ret;
1465 1489
1466 if (cpu_is_omap24xx() || cpu_is_omap34xx()) 1490 ret = soc_ops.assert_hardreset(oh, &ohri);
1467 return omap2_prm_assert_hardreset(oh->prcm.omap2.module_offs, 1491
1468 ohri.rst_shift); 1492 return ret;
1469 else if (cpu_is_omap44xx())
1470 return omap4_prminst_assert_hardreset(ohri.rst_shift,
1471 oh->clkdm->pwrdm.ptr->prcm_partition,
1472 oh->clkdm->pwrdm.ptr->prcm_offs,
1473 oh->prcm.omap4.rstctrl_offs);
1474 else
1475 return -EINVAL;
1476} 1493}
1477 1494
1478/** 1495/**
@@ -1481,38 +1498,29 @@ static int _assert_hardreset(struct omap_hwmod *oh, const char *name)
1481 * @oh: struct omap_hwmod * 1498 * @oh: struct omap_hwmod *
1482 * @name: name of the reset line to look up and deassert 1499 * @name: name of the reset line to look up and deassert
1483 * 1500 *
1484 * Some IP like dsp, ipu or iva contain processor that require 1501 * Some IP like dsp, ipu or iva contain processor that require an HW
1485 * an HW reset line to be assert / deassert in order to enable fully 1502 * reset line to be assert / deassert in order to enable fully the IP.
1486 * the IP. 1503 * Returns -EINVAL if @oh is null, -ENOSYS if we have no way of
1504 * deasserting the hardreset line on the currently-booted SoC, or passes
1505 * along the return value from _lookup_hardreset() or the SoC's
1506 * deassert_hardreset code.
1487 */ 1507 */
1488static int _deassert_hardreset(struct omap_hwmod *oh, const char *name) 1508static int _deassert_hardreset(struct omap_hwmod *oh, const char *name)
1489{ 1509{
1490 struct omap_hwmod_rst_info ohri; 1510 struct omap_hwmod_rst_info ohri;
1491 int ret; 1511 int ret = -EINVAL;
1492 1512
1493 if (!oh) 1513 if (!oh)
1494 return -EINVAL; 1514 return -EINVAL;
1495 1515
1516 if (!soc_ops.deassert_hardreset)
1517 return -ENOSYS;
1518
1496 ret = _lookup_hardreset(oh, name, &ohri); 1519 ret = _lookup_hardreset(oh, name, &ohri);
1497 if (IS_ERR_VALUE(ret)) 1520 if (IS_ERR_VALUE(ret))
1498 return ret; 1521 return ret;
1499 1522
1500 if (cpu_is_omap24xx() || cpu_is_omap34xx()) { 1523 ret = soc_ops.deassert_hardreset(oh, &ohri);
1501 ret = omap2_prm_deassert_hardreset(oh->prcm.omap2.module_offs,
1502 ohri.rst_shift,
1503 ohri.st_shift);
1504 } else if (cpu_is_omap44xx()) {
1505 if (ohri.st_shift)
1506 pr_err("omap_hwmod: %s: %s: hwmod data error: OMAP4 does not support st_shift\n",
1507 oh->name, name);
1508 ret = omap4_prminst_deassert_hardreset(ohri.rst_shift,
1509 oh->clkdm->pwrdm.ptr->prcm_partition,
1510 oh->clkdm->pwrdm.ptr->prcm_offs,
1511 oh->prcm.omap4.rstctrl_offs);
1512 } else {
1513 return -EINVAL;
1514 }
1515
1516 if (ret == -EBUSY) 1524 if (ret == -EBUSY)
1517 pr_warning("omap_hwmod: %s: failed to hardreset\n", oh->name); 1525 pr_warning("omap_hwmod: %s: failed to hardreset\n", oh->name);
1518 1526
@@ -1525,31 +1533,28 @@ static int _deassert_hardreset(struct omap_hwmod *oh, const char *name)
1525 * @oh: struct omap_hwmod * 1533 * @oh: struct omap_hwmod *
1526 * @name: name of the reset line to look up and read 1534 * @name: name of the reset line to look up and read
1527 * 1535 *
1528 * Return the state of the reset line. 1536 * Return the state of the reset line. Returns -EINVAL if @oh is
1537 * null, -ENOSYS if we have no way of reading the hardreset line
1538 * status on the currently-booted SoC, or passes along the return
1539 * value from _lookup_hardreset() or the SoC's is_hardreset_asserted
1540 * code.
1529 */ 1541 */
1530static int _read_hardreset(struct omap_hwmod *oh, const char *name) 1542static int _read_hardreset(struct omap_hwmod *oh, const char *name)
1531{ 1543{
1532 struct omap_hwmod_rst_info ohri; 1544 struct omap_hwmod_rst_info ohri;
1533 u8 ret; 1545 u8 ret = -EINVAL;
1534 1546
1535 if (!oh) 1547 if (!oh)
1536 return -EINVAL; 1548 return -EINVAL;
1537 1549
1550 if (!soc_ops.is_hardreset_asserted)
1551 return -ENOSYS;
1552
1538 ret = _lookup_hardreset(oh, name, &ohri); 1553 ret = _lookup_hardreset(oh, name, &ohri);
1539 if (IS_ERR_VALUE(ret)) 1554 if (IS_ERR_VALUE(ret))
1540 return ret; 1555 return ret;
1541 1556
1542 if (cpu_is_omap24xx() || cpu_is_omap34xx()) { 1557 return soc_ops.is_hardreset_asserted(oh, &ohri);
1543 return omap2_prm_is_hardreset_asserted(oh->prcm.omap2.module_offs,
1544 ohri.st_shift);
1545 } else if (cpu_is_omap44xx()) {
1546 return omap4_prminst_is_hardreset_asserted(ohri.rst_shift,
1547 oh->clkdm->pwrdm.ptr->prcm_partition,
1548 oh->clkdm->pwrdm.ptr->prcm_offs,
1549 oh->prcm.omap4.rstctrl_offs);
1550 } else {
1551 return -EINVAL;
1552 }
1553} 1558}
1554 1559
1555/** 1560/**
@@ -1587,10 +1592,6 @@ static int _omap4_disable_module(struct omap_hwmod *oh)
1587{ 1592{
1588 int v; 1593 int v;
1589 1594
1590 /* The module mode does not exist prior OMAP4 */
1591 if (!cpu_is_omap44xx())
1592 return -EINVAL;
1593
1594 if (!oh->clkdm || !oh->prcm.omap4.modulemode) 1595 if (!oh->clkdm || !oh->prcm.omap4.modulemode)
1595 return -EINVAL; 1596 return -EINVAL;
1596 1597
@@ -1714,11 +1715,17 @@ dis_opt_clks:
1714 * therefore have no OCP header registers to access. Others (like the 1715 * therefore have no OCP header registers to access. Others (like the
1715 * IVA) have idiosyncratic reset sequences. So for these relatively 1716 * IVA) have idiosyncratic reset sequences. So for these relatively
1716 * rare cases, custom reset code can be supplied in the struct 1717 * rare cases, custom reset code can be supplied in the struct
1717 * omap_hwmod_class .reset function pointer. Passes along the return 1718 * omap_hwmod_class .reset function pointer.
1718 * value from either _ocp_softreset() or the custom reset function - 1719 *
1719 * these must return -EINVAL if the hwmod cannot be reset this way or 1720 * _set_dmadisable() is called to set the DMADISABLE bit so that it
1720 * if the hwmod is in the wrong state, -ETIMEDOUT if the module did 1721 * does not prevent idling of the system. This is necessary for cases
1721 * not reset in time, or 0 upon success. 1722 * where ROMCODE/BOOTLOADER uses dma and transfers control to the
1723 * kernel without disabling dma.
1724 *
1725 * Passes along the return value from either _ocp_softreset() or the
1726 * custom reset function - these must return -EINVAL if the hwmod
1727 * cannot be reset this way or if the hwmod is in the wrong state,
1728 * -ETIMEDOUT if the module did not reset in time, or 0 upon success.
1722 */ 1729 */
1723static int _reset(struct omap_hwmod *oh) 1730static int _reset(struct omap_hwmod *oh)
1724{ 1731{
@@ -1740,6 +1747,8 @@ static int _reset(struct omap_hwmod *oh)
1740 } 1747 }
1741 } 1748 }
1742 1749
1750 _set_dmadisable(oh);
1751
1743 /* 1752 /*
1744 * OCP_SYSCONFIG bits need to be reprogrammed after a 1753 * OCP_SYSCONFIG bits need to be reprogrammed after a
1745 * softreset. The _enable() function should be split to avoid 1754 * softreset. The _enable() function should be split to avoid
@@ -1754,6 +1763,32 @@ static int _reset(struct omap_hwmod *oh)
1754} 1763}
1755 1764
1756/** 1765/**
1766 * _reconfigure_io_chain - clear any I/O chain wakeups and reconfigure chain
1767 *
1768 * Call the appropriate PRM function to clear any logged I/O chain
1769 * wakeups and to reconfigure the chain. This apparently needs to be
1770 * done upon every mux change. Since hwmods can be concurrently
1771 * enabled and idled, hold a spinlock around the I/O chain
1772 * reconfiguration sequence. No return value.
1773 *
1774 * XXX When the PRM code is moved to drivers, this function can be removed,
1775 * as the PRM infrastructure should abstract this.
1776 */
1777static void _reconfigure_io_chain(void)
1778{
1779 unsigned long flags;
1780
1781 spin_lock_irqsave(&io_chain_lock, flags);
1782
1783 if (cpu_is_omap34xx() && omap3_has_io_chain_ctrl())
1784 omap3xxx_prm_reconfigure_io_chain();
1785 else if (cpu_is_omap44xx())
1786 omap44xx_prm_reconfigure_io_chain();
1787
1788 spin_unlock_irqrestore(&io_chain_lock, flags);
1789}
1790
1791/**
1757 * _enable - enable an omap_hwmod 1792 * _enable - enable an omap_hwmod
1758 * @oh: struct omap_hwmod * 1793 * @oh: struct omap_hwmod *
1759 * 1794 *
@@ -1809,8 +1844,10 @@ static int _enable(struct omap_hwmod *oh)
1809 /* Mux pins for device runtime if populated */ 1844 /* Mux pins for device runtime if populated */
1810 if (oh->mux && (!oh->mux->enabled || 1845 if (oh->mux && (!oh->mux->enabled ||
1811 ((oh->_state == _HWMOD_STATE_IDLE) && 1846 ((oh->_state == _HWMOD_STATE_IDLE) &&
1812 oh->mux->pads_dynamic))) 1847 oh->mux->pads_dynamic))) {
1813 omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED); 1848 omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED);
1849 _reconfigure_io_chain();
1850 }
1814 1851
1815 _add_initiator_dep(oh, mpu_oh); 1852 _add_initiator_dep(oh, mpu_oh);
1816 1853
@@ -1830,9 +1867,11 @@ static int _enable(struct omap_hwmod *oh)
1830 } 1867 }
1831 1868
1832 _enable_clocks(oh); 1869 _enable_clocks(oh);
1833 _enable_module(oh); 1870 if (soc_ops.enable_module)
1871 soc_ops.enable_module(oh);
1834 1872
1835 r = _wait_target_ready(oh); 1873 r = (soc_ops.wait_target_ready) ? soc_ops.wait_target_ready(oh) :
1874 -EINVAL;
1836 if (!r) { 1875 if (!r) {
1837 /* 1876 /*
1838 * Set the clockdomain to HW_AUTO only if the target is ready, 1877 * Set the clockdomain to HW_AUTO only if the target is ready,
@@ -1886,7 +1925,8 @@ static int _idle(struct omap_hwmod *oh)
1886 _idle_sysc(oh); 1925 _idle_sysc(oh);
1887 _del_initiator_dep(oh, mpu_oh); 1926 _del_initiator_dep(oh, mpu_oh);
1888 1927
1889 _omap4_disable_module(oh); 1928 if (soc_ops.disable_module)
1929 soc_ops.disable_module(oh);
1890 1930
1891 /* 1931 /*
1892 * The module must be in idle mode before disabling any parents 1932 * The module must be in idle mode before disabling any parents
@@ -1899,8 +1939,10 @@ static int _idle(struct omap_hwmod *oh)
1899 clkdm_hwmod_disable(oh->clkdm, oh); 1939 clkdm_hwmod_disable(oh->clkdm, oh);
1900 1940
1901 /* Mux pins for device idle if populated */ 1941 /* Mux pins for device idle if populated */
1902 if (oh->mux && oh->mux->pads_dynamic) 1942 if (oh->mux && oh->mux->pads_dynamic) {
1903 omap_hwmod_mux(oh->mux, _HWMOD_STATE_IDLE); 1943 omap_hwmod_mux(oh->mux, _HWMOD_STATE_IDLE);
1944 _reconfigure_io_chain();
1945 }
1904 1946
1905 oh->_state = _HWMOD_STATE_IDLE; 1947 oh->_state = _HWMOD_STATE_IDLE;
1906 1948
@@ -1991,7 +2033,8 @@ static int _shutdown(struct omap_hwmod *oh)
1991 if (oh->_state == _HWMOD_STATE_ENABLED) { 2033 if (oh->_state == _HWMOD_STATE_ENABLED) {
1992 _del_initiator_dep(oh, mpu_oh); 2034 _del_initiator_dep(oh, mpu_oh);
1993 /* XXX what about the other system initiators here? dma, dsp */ 2035 /* XXX what about the other system initiators here? dma, dsp */
1994 _omap4_disable_module(oh); 2036 if (soc_ops.disable_module)
2037 soc_ops.disable_module(oh);
1995 _disable_clocks(oh); 2038 _disable_clocks(oh);
1996 if (oh->clkdm) 2039 if (oh->clkdm)
1997 clkdm_hwmod_disable(oh->clkdm, oh); 2040 clkdm_hwmod_disable(oh->clkdm, oh);
@@ -2447,6 +2490,194 @@ static int __init _alloc_linkspace(struct omap_hwmod_ocp_if **ois)
2447 return 0; 2490 return 0;
2448} 2491}
2449 2492
2493/* Static functions intended only for use in soc_ops field function pointers */
2494
2495/**
2496 * _omap2_wait_target_ready - wait for a module to leave slave idle
2497 * @oh: struct omap_hwmod *
2498 *
2499 * Wait for a module @oh to leave slave idle. Returns 0 if the module
2500 * does not have an IDLEST bit or if the module successfully leaves
2501 * slave idle; otherwise, pass along the return value of the
2502 * appropriate *_cm*_wait_module_ready() function.
2503 */
2504static int _omap2_wait_target_ready(struct omap_hwmod *oh)
2505{
2506 if (!oh)
2507 return -EINVAL;
2508
2509 if (oh->flags & HWMOD_NO_IDLEST)
2510 return 0;
2511
2512 if (!_find_mpu_rt_port(oh))
2513 return 0;
2514
2515 /* XXX check module SIDLEMODE, hardreset status, enabled clocks */
2516
2517 return omap2_cm_wait_module_ready(oh->prcm.omap2.module_offs,
2518 oh->prcm.omap2.idlest_reg_id,
2519 oh->prcm.omap2.idlest_idle_bit);
2520}
2521
2522/**
2523 * _omap4_wait_target_ready - wait for a module to leave slave idle
2524 * @oh: struct omap_hwmod *
2525 *
2526 * Wait for a module @oh to leave slave idle. Returns 0 if the module
2527 * does not have an IDLEST bit or if the module successfully leaves
2528 * slave idle; otherwise, pass along the return value of the
2529 * appropriate *_cm*_wait_module_ready() function.
2530 */
2531static int _omap4_wait_target_ready(struct omap_hwmod *oh)
2532{
2533 if (!oh || !oh->clkdm)
2534 return -EINVAL;
2535
2536 if (oh->flags & HWMOD_NO_IDLEST)
2537 return 0;
2538
2539 if (!_find_mpu_rt_port(oh))
2540 return 0;
2541
2542 /* XXX check module SIDLEMODE, hardreset status */
2543
2544 return omap4_cminst_wait_module_ready(oh->clkdm->prcm_partition,
2545 oh->clkdm->cm_inst,
2546 oh->clkdm->clkdm_offs,
2547 oh->prcm.omap4.clkctrl_offs);
2548}
2549
2550/**
2551 * _omap2_assert_hardreset - call OMAP2 PRM hardreset fn with hwmod args
2552 * @oh: struct omap_hwmod * to assert hardreset
2553 * @ohri: hardreset line data
2554 *
2555 * Call omap2_prm_assert_hardreset() with parameters extracted from
2556 * the hwmod @oh and the hardreset line data @ohri. Only intended for
2557 * use as an soc_ops function pointer. Passes along the return value
2558 * from omap2_prm_assert_hardreset(). XXX This function is scheduled
2559 * for removal when the PRM code is moved into drivers/.
2560 */
2561static int _omap2_assert_hardreset(struct omap_hwmod *oh,
2562 struct omap_hwmod_rst_info *ohri)
2563{
2564 return omap2_prm_assert_hardreset(oh->prcm.omap2.module_offs,
2565 ohri->rst_shift);
2566}
2567
2568/**
2569 * _omap2_deassert_hardreset - call OMAP2 PRM hardreset fn with hwmod args
2570 * @oh: struct omap_hwmod * to deassert hardreset
2571 * @ohri: hardreset line data
2572 *
2573 * Call omap2_prm_deassert_hardreset() with parameters extracted from
2574 * the hwmod @oh and the hardreset line data @ohri. Only intended for
2575 * use as an soc_ops function pointer. Passes along the return value
2576 * from omap2_prm_deassert_hardreset(). XXX This function is
2577 * scheduled for removal when the PRM code is moved into drivers/.
2578 */
2579static int _omap2_deassert_hardreset(struct omap_hwmod *oh,
2580 struct omap_hwmod_rst_info *ohri)
2581{
2582 return omap2_prm_deassert_hardreset(oh->prcm.omap2.module_offs,
2583 ohri->rst_shift,
2584 ohri->st_shift);
2585}
2586
2587/**
2588 * _omap2_is_hardreset_asserted - call OMAP2 PRM hardreset fn with hwmod args
2589 * @oh: struct omap_hwmod * to test hardreset
2590 * @ohri: hardreset line data
2591 *
2592 * Call omap2_prm_is_hardreset_asserted() with parameters extracted
2593 * from the hwmod @oh and the hardreset line data @ohri. Only
2594 * intended for use as an soc_ops function pointer. Passes along the
2595 * return value from omap2_prm_is_hardreset_asserted(). XXX This
2596 * function is scheduled for removal when the PRM code is moved into
2597 * drivers/.
2598 */
2599static int _omap2_is_hardreset_asserted(struct omap_hwmod *oh,
2600 struct omap_hwmod_rst_info *ohri)
2601{
2602 return omap2_prm_is_hardreset_asserted(oh->prcm.omap2.module_offs,
2603 ohri->st_shift);
2604}
2605
2606/**
2607 * _omap4_assert_hardreset - call OMAP4 PRM hardreset fn with hwmod args
2608 * @oh: struct omap_hwmod * to assert hardreset
2609 * @ohri: hardreset line data
2610 *
2611 * Call omap4_prminst_assert_hardreset() with parameters extracted
2612 * from the hwmod @oh and the hardreset line data @ohri. Only
2613 * intended for use as an soc_ops function pointer. Passes along the
2614 * return value from omap4_prminst_assert_hardreset(). XXX This
2615 * function is scheduled for removal when the PRM code is moved into
2616 * drivers/.
2617 */
2618static int _omap4_assert_hardreset(struct omap_hwmod *oh,
2619 struct omap_hwmod_rst_info *ohri)
2620{
2621 if (!oh->clkdm)
2622 return -EINVAL;
2623
2624 return omap4_prminst_assert_hardreset(ohri->rst_shift,
2625 oh->clkdm->pwrdm.ptr->prcm_partition,
2626 oh->clkdm->pwrdm.ptr->prcm_offs,
2627 oh->prcm.omap4.rstctrl_offs);
2628}
2629
2630/**
2631 * _omap4_deassert_hardreset - call OMAP4 PRM hardreset fn with hwmod args
2632 * @oh: struct omap_hwmod * to deassert hardreset
2633 * @ohri: hardreset line data
2634 *
2635 * Call omap4_prminst_deassert_hardreset() with parameters extracted
2636 * from the hwmod @oh and the hardreset line data @ohri. Only
2637 * intended for use as an soc_ops function pointer. Passes along the
2638 * return value from omap4_prminst_deassert_hardreset(). XXX This
2639 * function is scheduled for removal when the PRM code is moved into
2640 * drivers/.
2641 */
2642static int _omap4_deassert_hardreset(struct omap_hwmod *oh,
2643 struct omap_hwmod_rst_info *ohri)
2644{
2645 if (!oh->clkdm)
2646 return -EINVAL;
2647
2648 if (ohri->st_shift)
2649 pr_err("omap_hwmod: %s: %s: hwmod data error: OMAP4 does not support st_shift\n",
2650 oh->name, ohri->name);
2651 return omap4_prminst_deassert_hardreset(ohri->rst_shift,
2652 oh->clkdm->pwrdm.ptr->prcm_partition,
2653 oh->clkdm->pwrdm.ptr->prcm_offs,
2654 oh->prcm.omap4.rstctrl_offs);
2655}
2656
2657/**
2658 * _omap4_is_hardreset_asserted - call OMAP4 PRM hardreset fn with hwmod args
2659 * @oh: struct omap_hwmod * to test hardreset
2660 * @ohri: hardreset line data
2661 *
2662 * Call omap4_prminst_is_hardreset_asserted() with parameters
2663 * extracted from the hwmod @oh and the hardreset line data @ohri.
2664 * Only intended for use as an soc_ops function pointer. Passes along
2665 * the return value from omap4_prminst_is_hardreset_asserted(). XXX
2666 * This function is scheduled for removal when the PRM code is moved
2667 * into drivers/.
2668 */
2669static int _omap4_is_hardreset_asserted(struct omap_hwmod *oh,
2670 struct omap_hwmod_rst_info *ohri)
2671{
2672 if (!oh->clkdm)
2673 return -EINVAL;
2674
2675 return omap4_prminst_is_hardreset_asserted(ohri->rst_shift,
2676 oh->clkdm->pwrdm.ptr->prcm_partition,
2677 oh->clkdm->pwrdm.ptr->prcm_offs,
2678 oh->prcm.omap4.rstctrl_offs);
2679}
2680
2450/* Public functions */ 2681/* Public functions */
2451 2682
2452u32 omap_hwmod_read(struct omap_hwmod *oh, u16 reg_offs) 2683u32 omap_hwmod_read(struct omap_hwmod *oh, u16 reg_offs)
@@ -2579,12 +2810,18 @@ int omap_hwmod_for_each(int (*fn)(struct omap_hwmod *oh, void *data),
2579 * 2810 *
2580 * Intended to be called early in boot before the clock framework is 2811 * Intended to be called early in boot before the clock framework is
2581 * initialized. If @ois is not null, will register all omap_hwmods 2812 * initialized. If @ois is not null, will register all omap_hwmods
2582 * listed in @ois that are valid for this chip. Returns 0. 2813 * listed in @ois that are valid for this chip. Returns -EINVAL if
2814 * omap_hwmod_init() hasn't been called before calling this function,
2815 * -ENOMEM if the link memory area can't be allocated, or 0 upon
2816 * success.
2583 */ 2817 */
2584int __init omap_hwmod_register_links(struct omap_hwmod_ocp_if **ois) 2818int __init omap_hwmod_register_links(struct omap_hwmod_ocp_if **ois)
2585{ 2819{
2586 int r, i; 2820 int r, i;
2587 2821
2822 if (!inited)
2823 return -EINVAL;
2824
2588 if (!ois) 2825 if (!ois)
2589 return 0; 2826 return 0;
2590 2827
@@ -3417,3 +3654,47 @@ int omap_hwmod_pad_route_irq(struct omap_hwmod *oh, int pad_idx, int irq_idx)
3417 3654
3418 return 0; 3655 return 0;
3419} 3656}
3657
3658/**
3659 * omap_hwmod_init - initialize the hwmod code
3660 *
3661 * Sets up some function pointers needed by the hwmod code to operate on the
3662 * currently-booted SoC. Intended to be called once during kernel init
3663 * before any hwmods are registered. No return value.
3664 */
3665void __init omap_hwmod_init(void)
3666{
3667 if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
3668 soc_ops.wait_target_ready = _omap2_wait_target_ready;
3669 soc_ops.assert_hardreset = _omap2_assert_hardreset;
3670 soc_ops.deassert_hardreset = _omap2_deassert_hardreset;
3671 soc_ops.is_hardreset_asserted = _omap2_is_hardreset_asserted;
3672 } else if (cpu_is_omap44xx() || soc_is_omap54xx()) {
3673 soc_ops.enable_module = _omap4_enable_module;
3674 soc_ops.disable_module = _omap4_disable_module;
3675 soc_ops.wait_target_ready = _omap4_wait_target_ready;
3676 soc_ops.assert_hardreset = _omap4_assert_hardreset;
3677 soc_ops.deassert_hardreset = _omap4_deassert_hardreset;
3678 soc_ops.is_hardreset_asserted = _omap4_is_hardreset_asserted;
3679 soc_ops.init_clkdm = _init_clkdm;
3680 } else {
3681 WARN(1, "omap_hwmod: unknown SoC type\n");
3682 }
3683
3684 inited = true;
3685}
3686
3687/**
3688 * omap_hwmod_get_main_clk - get pointer to main clock name
3689 * @oh: struct omap_hwmod *
3690 *
3691 * Returns the main clock name assocated with @oh upon success,
3692 * or NULL if @oh is NULL.
3693 */
3694const char *omap_hwmod_get_main_clk(struct omap_hwmod *oh)
3695{
3696 if (!oh)
3697 return NULL;
3698
3699 return oh->main_clk;
3700}
diff --git a/arch/arm/mach-omap2/omap_hwmod_2420_data.c b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
index a7640d1b215..50cfab61b0e 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2420_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
@@ -192,6 +192,11 @@ static struct omap_hwmod_class omap2420_mcbsp_hwmod_class = {
192 .name = "mcbsp", 192 .name = "mcbsp",
193}; 193};
194 194
195static struct omap_hwmod_opt_clk mcbsp_opt_clks[] = {
196 { .role = "pad_fck", .clk = "mcbsp_clks" },
197 { .role = "prcm_fck", .clk = "func_96m_ck" },
198};
199
195/* mcbsp1 */ 200/* mcbsp1 */
196static struct omap_hwmod_irq_info omap2420_mcbsp1_irqs[] = { 201static struct omap_hwmod_irq_info omap2420_mcbsp1_irqs[] = {
197 { .name = "tx", .irq = 59 }, 202 { .name = "tx", .irq = 59 },
@@ -214,6 +219,8 @@ static struct omap_hwmod omap2420_mcbsp1_hwmod = {
214 .idlest_idle_bit = OMAP24XX_ST_MCBSP1_SHIFT, 219 .idlest_idle_bit = OMAP24XX_ST_MCBSP1_SHIFT,
215 }, 220 },
216 }, 221 },
222 .opt_clks = mcbsp_opt_clks,
223 .opt_clks_cnt = ARRAY_SIZE(mcbsp_opt_clks),
217}; 224};
218 225
219/* mcbsp2 */ 226/* mcbsp2 */
@@ -238,6 +245,8 @@ static struct omap_hwmod omap2420_mcbsp2_hwmod = {
238 .idlest_idle_bit = OMAP24XX_ST_MCBSP2_SHIFT, 245 .idlest_idle_bit = OMAP24XX_ST_MCBSP2_SHIFT,
239 }, 246 },
240 }, 247 },
248 .opt_clks = mcbsp_opt_clks,
249 .opt_clks_cnt = ARRAY_SIZE(mcbsp_opt_clks),
241}; 250};
242 251
243static struct omap_hwmod_class_sysconfig omap2420_msdi_sysc = { 252static struct omap_hwmod_class_sysconfig omap2420_msdi_sysc = {
@@ -585,5 +594,6 @@ static struct omap_hwmod_ocp_if *omap2420_hwmod_ocp_ifs[] __initdata = {
585 594
586int __init omap2420_hwmod_init(void) 595int __init omap2420_hwmod_init(void)
587{ 596{
597 omap_hwmod_init();
588 return omap_hwmod_register_links(omap2420_hwmod_ocp_ifs); 598 return omap_hwmod_register_links(omap2420_hwmod_ocp_ifs);
589} 599}
diff --git a/arch/arm/mach-omap2/omap_hwmod_2430_data.c b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
index 4d726498123..58b5bc196d3 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2430_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
@@ -296,6 +296,11 @@ static struct omap_hwmod_class omap2430_mcbsp_hwmod_class = {
296 .rev = MCBSP_CONFIG_TYPE2, 296 .rev = MCBSP_CONFIG_TYPE2,
297}; 297};
298 298
299static struct omap_hwmod_opt_clk mcbsp_opt_clks[] = {
300 { .role = "pad_fck", .clk = "mcbsp_clks" },
301 { .role = "prcm_fck", .clk = "func_96m_ck" },
302};
303
299/* mcbsp1 */ 304/* mcbsp1 */
300static struct omap_hwmod_irq_info omap2430_mcbsp1_irqs[] = { 305static struct omap_hwmod_irq_info omap2430_mcbsp1_irqs[] = {
301 { .name = "tx", .irq = 59 }, 306 { .name = "tx", .irq = 59 },
@@ -320,6 +325,8 @@ static struct omap_hwmod omap2430_mcbsp1_hwmod = {
320 .idlest_idle_bit = OMAP24XX_ST_MCBSP1_SHIFT, 325 .idlest_idle_bit = OMAP24XX_ST_MCBSP1_SHIFT,
321 }, 326 },
322 }, 327 },
328 .opt_clks = mcbsp_opt_clks,
329 .opt_clks_cnt = ARRAY_SIZE(mcbsp_opt_clks),
323}; 330};
324 331
325/* mcbsp2 */ 332/* mcbsp2 */
@@ -345,6 +352,8 @@ static struct omap_hwmod omap2430_mcbsp2_hwmod = {
345 .idlest_idle_bit = OMAP24XX_ST_MCBSP2_SHIFT, 352 .idlest_idle_bit = OMAP24XX_ST_MCBSP2_SHIFT,
346 }, 353 },
347 }, 354 },
355 .opt_clks = mcbsp_opt_clks,
356 .opt_clks_cnt = ARRAY_SIZE(mcbsp_opt_clks),
348}; 357};
349 358
350/* mcbsp3 */ 359/* mcbsp3 */
@@ -370,6 +379,8 @@ static struct omap_hwmod omap2430_mcbsp3_hwmod = {
370 .idlest_idle_bit = OMAP2430_ST_MCBSP3_SHIFT, 379 .idlest_idle_bit = OMAP2430_ST_MCBSP3_SHIFT,
371 }, 380 },
372 }, 381 },
382 .opt_clks = mcbsp_opt_clks,
383 .opt_clks_cnt = ARRAY_SIZE(mcbsp_opt_clks),
373}; 384};
374 385
375/* mcbsp4 */ 386/* mcbsp4 */
@@ -401,6 +412,8 @@ static struct omap_hwmod omap2430_mcbsp4_hwmod = {
401 .idlest_idle_bit = OMAP2430_ST_MCBSP4_SHIFT, 412 .idlest_idle_bit = OMAP2430_ST_MCBSP4_SHIFT,
402 }, 413 },
403 }, 414 },
415 .opt_clks = mcbsp_opt_clks,
416 .opt_clks_cnt = ARRAY_SIZE(mcbsp_opt_clks),
404}; 417};
405 418
406/* mcbsp5 */ 419/* mcbsp5 */
@@ -432,6 +445,8 @@ static struct omap_hwmod omap2430_mcbsp5_hwmod = {
432 .idlest_idle_bit = OMAP2430_ST_MCBSP5_SHIFT, 445 .idlest_idle_bit = OMAP2430_ST_MCBSP5_SHIFT,
433 }, 446 },
434 }, 447 },
448 .opt_clks = mcbsp_opt_clks,
449 .opt_clks_cnt = ARRAY_SIZE(mcbsp_opt_clks),
435}; 450};
436 451
437/* MMC/SD/SDIO common */ 452/* MMC/SD/SDIO common */
@@ -938,5 +953,6 @@ static struct omap_hwmod_ocp_if *omap2430_hwmod_ocp_ifs[] __initdata = {
938 953
939int __init omap2430_hwmod_init(void) 954int __init omap2430_hwmod_init(void)
940{ 955{
956 omap_hwmod_init();
941 return omap_hwmod_register_links(omap2430_hwmod_ocp_ifs); 957 return omap_hwmod_register_links(omap2430_hwmod_ocp_ifs);
942} 958}
diff --git a/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c b/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
index 83eafd96eca..afad69c6ba6 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
@@ -68,7 +68,6 @@ static struct omap_hwmod_class_sysconfig omap2xxx_timer_sysc = {
68struct omap_hwmod_class omap2xxx_timer_hwmod_class = { 68struct omap_hwmod_class omap2xxx_timer_hwmod_class = {
69 .name = "timer", 69 .name = "timer",
70 .sysc = &omap2xxx_timer_sysc, 70 .sysc = &omap2xxx_timer_sysc,
71 .rev = OMAP_TIMER_IP_VERSION_1,
72}; 71};
73 72
74/* 73/*
@@ -257,7 +256,6 @@ struct omap_hwmod omap2xxx_timer2_hwmod = {
257 .idlest_idle_bit = OMAP24XX_ST_GPT2_SHIFT, 256 .idlest_idle_bit = OMAP24XX_ST_GPT2_SHIFT,
258 }, 257 },
259 }, 258 },
260 .dev_attr = &capability_alwon_dev_attr,
261 .class = &omap2xxx_timer_hwmod_class, 259 .class = &omap2xxx_timer_hwmod_class,
262}; 260};
263 261
@@ -276,7 +274,6 @@ struct omap_hwmod omap2xxx_timer3_hwmod = {
276 .idlest_idle_bit = OMAP24XX_ST_GPT3_SHIFT, 274 .idlest_idle_bit = OMAP24XX_ST_GPT3_SHIFT,
277 }, 275 },
278 }, 276 },
279 .dev_attr = &capability_alwon_dev_attr,
280 .class = &omap2xxx_timer_hwmod_class, 277 .class = &omap2xxx_timer_hwmod_class,
281}; 278};
282 279
@@ -295,7 +292,6 @@ struct omap_hwmod omap2xxx_timer4_hwmod = {
295 .idlest_idle_bit = OMAP24XX_ST_GPT4_SHIFT, 292 .idlest_idle_bit = OMAP24XX_ST_GPT4_SHIFT,
296 }, 293 },
297 }, 294 },
298 .dev_attr = &capability_alwon_dev_attr,
299 .class = &omap2xxx_timer_hwmod_class, 295 .class = &omap2xxx_timer_hwmod_class,
300}; 296};
301 297
@@ -314,7 +310,6 @@ struct omap_hwmod omap2xxx_timer5_hwmod = {
314 .idlest_idle_bit = OMAP24XX_ST_GPT5_SHIFT, 310 .idlest_idle_bit = OMAP24XX_ST_GPT5_SHIFT,
315 }, 311 },
316 }, 312 },
317 .dev_attr = &capability_alwon_dev_attr,
318 .class = &omap2xxx_timer_hwmod_class, 313 .class = &omap2xxx_timer_hwmod_class,
319}; 314};
320 315
@@ -333,7 +328,6 @@ struct omap_hwmod omap2xxx_timer6_hwmod = {
333 .idlest_idle_bit = OMAP24XX_ST_GPT6_SHIFT, 328 .idlest_idle_bit = OMAP24XX_ST_GPT6_SHIFT,
334 }, 329 },
335 }, 330 },
336 .dev_attr = &capability_alwon_dev_attr,
337 .class = &omap2xxx_timer_hwmod_class, 331 .class = &omap2xxx_timer_hwmod_class,
338}; 332};
339 333
@@ -352,7 +346,6 @@ struct omap_hwmod omap2xxx_timer7_hwmod = {
352 .idlest_idle_bit = OMAP24XX_ST_GPT7_SHIFT, 346 .idlest_idle_bit = OMAP24XX_ST_GPT7_SHIFT,
353 }, 347 },
354 }, 348 },
355 .dev_attr = &capability_alwon_dev_attr,
356 .class = &omap2xxx_timer_hwmod_class, 349 .class = &omap2xxx_timer_hwmod_class,
357}; 350};
358 351
@@ -371,7 +364,6 @@ struct omap_hwmod omap2xxx_timer8_hwmod = {
371 .idlest_idle_bit = OMAP24XX_ST_GPT8_SHIFT, 364 .idlest_idle_bit = OMAP24XX_ST_GPT8_SHIFT,
372 }, 365 },
373 }, 366 },
374 .dev_attr = &capability_alwon_dev_attr,
375 .class = &omap2xxx_timer_hwmod_class, 367 .class = &omap2xxx_timer_hwmod_class,
376}; 368};
377 369
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index b26d3c9bca1..c9e38200216 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -14,6 +14,8 @@
14 * 14 *
15 * XXX these should be marked initdata for multi-OMAP kernels 15 * XXX these should be marked initdata for multi-OMAP kernels
16 */ 16 */
17#include <linux/power/smartreflex.h>
18
17#include <plat/omap_hwmod.h> 19#include <plat/omap_hwmod.h>
18#include <mach/irqs.h> 20#include <mach/irqs.h>
19#include <plat/cpu.h> 21#include <plat/cpu.h>
@@ -29,8 +31,6 @@
29#include <plat/dmtimer.h> 31#include <plat/dmtimer.h>
30 32
31#include "omap_hwmod_common_data.h" 33#include "omap_hwmod_common_data.h"
32
33#include "smartreflex.h"
34#include "prm-regbits-34xx.h" 34#include "prm-regbits-34xx.h"
35#include "cm-regbits-34xx.h" 35#include "cm-regbits-34xx.h"
36#include "wd_timer.h" 36#include "wd_timer.h"
@@ -129,7 +129,6 @@ static struct omap_hwmod_class_sysconfig omap3xxx_timer_1ms_sysc = {
129static struct omap_hwmod_class omap3xxx_timer_1ms_hwmod_class = { 129static struct omap_hwmod_class omap3xxx_timer_1ms_hwmod_class = {
130 .name = "timer", 130 .name = "timer",
131 .sysc = &omap3xxx_timer_1ms_sysc, 131 .sysc = &omap3xxx_timer_1ms_sysc,
132 .rev = OMAP_TIMER_IP_VERSION_1,
133}; 132};
134 133
135static struct omap_hwmod_class_sysconfig omap3xxx_timer_sysc = { 134static struct omap_hwmod_class_sysconfig omap3xxx_timer_sysc = {
@@ -145,12 +144,11 @@ static struct omap_hwmod_class_sysconfig omap3xxx_timer_sysc = {
145static struct omap_hwmod_class omap3xxx_timer_hwmod_class = { 144static struct omap_hwmod_class omap3xxx_timer_hwmod_class = {
146 .name = "timer", 145 .name = "timer",
147 .sysc = &omap3xxx_timer_sysc, 146 .sysc = &omap3xxx_timer_sysc,
148 .rev = OMAP_TIMER_IP_VERSION_1,
149}; 147};
150 148
151/* secure timers dev attribute */ 149/* secure timers dev attribute */
152static struct omap_timer_capability_dev_attr capability_secure_dev_attr = { 150static struct omap_timer_capability_dev_attr capability_secure_dev_attr = {
153 .timer_capability = OMAP_TIMER_SECURE, 151 .timer_capability = OMAP_TIMER_ALWON | OMAP_TIMER_SECURE,
154}; 152};
155 153
156/* always-on timers dev attribute */ 154/* always-on timers dev attribute */
@@ -195,7 +193,6 @@ static struct omap_hwmod omap3xxx_timer2_hwmod = {
195 .idlest_idle_bit = OMAP3430_ST_GPT2_SHIFT, 193 .idlest_idle_bit = OMAP3430_ST_GPT2_SHIFT,
196 }, 194 },
197 }, 195 },
198 .dev_attr = &capability_alwon_dev_attr,
199 .class = &omap3xxx_timer_1ms_hwmod_class, 196 .class = &omap3xxx_timer_1ms_hwmod_class,
200}; 197};
201 198
@@ -213,7 +210,6 @@ static struct omap_hwmod omap3xxx_timer3_hwmod = {
213 .idlest_idle_bit = OMAP3430_ST_GPT3_SHIFT, 210 .idlest_idle_bit = OMAP3430_ST_GPT3_SHIFT,
214 }, 211 },
215 }, 212 },
216 .dev_attr = &capability_alwon_dev_attr,
217 .class = &omap3xxx_timer_hwmod_class, 213 .class = &omap3xxx_timer_hwmod_class,
218}; 214};
219 215
@@ -231,7 +227,6 @@ static struct omap_hwmod omap3xxx_timer4_hwmod = {
231 .idlest_idle_bit = OMAP3430_ST_GPT4_SHIFT, 227 .idlest_idle_bit = OMAP3430_ST_GPT4_SHIFT,
232 }, 228 },
233 }, 229 },
234 .dev_attr = &capability_alwon_dev_attr,
235 .class = &omap3xxx_timer_hwmod_class, 230 .class = &omap3xxx_timer_hwmod_class,
236}; 231};
237 232
@@ -249,7 +244,6 @@ static struct omap_hwmod omap3xxx_timer5_hwmod = {
249 .idlest_idle_bit = OMAP3430_ST_GPT5_SHIFT, 244 .idlest_idle_bit = OMAP3430_ST_GPT5_SHIFT,
250 }, 245 },
251 }, 246 },
252 .dev_attr = &capability_alwon_dev_attr,
253 .class = &omap3xxx_timer_hwmod_class, 247 .class = &omap3xxx_timer_hwmod_class,
254}; 248};
255 249
@@ -267,7 +261,6 @@ static struct omap_hwmod omap3xxx_timer6_hwmod = {
267 .idlest_idle_bit = OMAP3430_ST_GPT6_SHIFT, 261 .idlest_idle_bit = OMAP3430_ST_GPT6_SHIFT,
268 }, 262 },
269 }, 263 },
270 .dev_attr = &capability_alwon_dev_attr,
271 .class = &omap3xxx_timer_hwmod_class, 264 .class = &omap3xxx_timer_hwmod_class,
272}; 265};
273 266
@@ -285,7 +278,6 @@ static struct omap_hwmod omap3xxx_timer7_hwmod = {
285 .idlest_idle_bit = OMAP3430_ST_GPT7_SHIFT, 278 .idlest_idle_bit = OMAP3430_ST_GPT7_SHIFT,
286 }, 279 },
287 }, 280 },
288 .dev_attr = &capability_alwon_dev_attr,
289 .class = &omap3xxx_timer_hwmod_class, 281 .class = &omap3xxx_timer_hwmod_class,
290}; 282};
291 283
@@ -527,11 +519,27 @@ static struct omap_hwmod omap36xx_uart4_hwmod = {
527 519
528static struct omap_hwmod_irq_info am35xx_uart4_mpu_irqs[] = { 520static struct omap_hwmod_irq_info am35xx_uart4_mpu_irqs[] = {
529 { .irq = INT_35XX_UART4_IRQ, }, 521 { .irq = INT_35XX_UART4_IRQ, },
522 { .irq = -1 }
530}; 523};
531 524
532static struct omap_hwmod_dma_info am35xx_uart4_sdma_reqs[] = { 525static struct omap_hwmod_dma_info am35xx_uart4_sdma_reqs[] = {
533 { .name = "rx", .dma_req = AM35XX_DMA_UART4_RX, }, 526 { .name = "rx", .dma_req = AM35XX_DMA_UART4_RX, },
534 { .name = "tx", .dma_req = AM35XX_DMA_UART4_TX, }, 527 { .name = "tx", .dma_req = AM35XX_DMA_UART4_TX, },
528 { .dma_req = -1 }
529};
530
531/*
532 * XXX AM35xx UART4 cannot complete its softreset without uart1_fck or
533 * uart2_fck being enabled. So we add uart1_fck as an optional clock,
534 * below, and set the HWMOD_CONTROL_OPT_CLKS_IN_RESET. This really
535 * should not be needed. The functional clock structure of the AM35xx
536 * UART4 is extremely unclear and opaque; it is unclear what the role
537 * of uart1/2_fck is for the UART4. Any clarification from either
538 * empirical testing or the AM3505/3517 hardware designers would be
539 * most welcome.
540 */
541static struct omap_hwmod_opt_clk am35xx_uart4_opt_clks[] = {
542 { .role = "softreset_uart1_fck", .clk = "uart1_fck" },
535}; 543};
536 544
537static struct omap_hwmod am35xx_uart4_hwmod = { 545static struct omap_hwmod am35xx_uart4_hwmod = {
@@ -543,11 +551,14 @@ static struct omap_hwmod am35xx_uart4_hwmod = {
543 .omap2 = { 551 .omap2 = {
544 .module_offs = CORE_MOD, 552 .module_offs = CORE_MOD,
545 .prcm_reg_id = 1, 553 .prcm_reg_id = 1,
546 .module_bit = OMAP3430_EN_UART4_SHIFT, 554 .module_bit = AM35XX_EN_UART4_SHIFT,
547 .idlest_reg_id = 1, 555 .idlest_reg_id = 1,
548 .idlest_idle_bit = OMAP3430_EN_UART4_SHIFT, 556 .idlest_idle_bit = AM35XX_ST_UART4_SHIFT,
549 }, 557 },
550 }, 558 },
559 .opt_clks = am35xx_uart4_opt_clks,
560 .opt_clks_cnt = ARRAY_SIZE(am35xx_uart4_opt_clks),
561 .flags = HWMOD_CONTROL_OPT_CLKS_IN_RESET,
551 .class = &omap2_uart_class, 562 .class = &omap2_uart_class,
552}; 563};
553 564
@@ -1074,6 +1085,17 @@ static struct omap_hwmod_class omap3xxx_mcbsp_hwmod_class = {
1074 .rev = MCBSP_CONFIG_TYPE3, 1085 .rev = MCBSP_CONFIG_TYPE3,
1075}; 1086};
1076 1087
1088/* McBSP functional clock mapping */
1089static struct omap_hwmod_opt_clk mcbsp15_opt_clks[] = {
1090 { .role = "pad_fck", .clk = "mcbsp_clks" },
1091 { .role = "prcm_fck", .clk = "core_96m_fck" },
1092};
1093
1094static struct omap_hwmod_opt_clk mcbsp234_opt_clks[] = {
1095 { .role = "pad_fck", .clk = "mcbsp_clks" },
1096 { .role = "prcm_fck", .clk = "per_96m_fck" },
1097};
1098
1077/* mcbsp1 */ 1099/* mcbsp1 */
1078static struct omap_hwmod_irq_info omap3xxx_mcbsp1_irqs[] = { 1100static struct omap_hwmod_irq_info omap3xxx_mcbsp1_irqs[] = {
1079 { .name = "common", .irq = 16 }, 1101 { .name = "common", .irq = 16 },
@@ -1097,6 +1119,8 @@ static struct omap_hwmod omap3xxx_mcbsp1_hwmod = {
1097 .idlest_idle_bit = OMAP3430_ST_MCBSP1_SHIFT, 1119 .idlest_idle_bit = OMAP3430_ST_MCBSP1_SHIFT,
1098 }, 1120 },
1099 }, 1121 },
1122 .opt_clks = mcbsp15_opt_clks,
1123 .opt_clks_cnt = ARRAY_SIZE(mcbsp15_opt_clks),
1100}; 1124};
1101 1125
1102/* mcbsp2 */ 1126/* mcbsp2 */
@@ -1126,6 +1150,8 @@ static struct omap_hwmod omap3xxx_mcbsp2_hwmod = {
1126 .idlest_idle_bit = OMAP3430_ST_MCBSP2_SHIFT, 1150 .idlest_idle_bit = OMAP3430_ST_MCBSP2_SHIFT,
1127 }, 1151 },
1128 }, 1152 },
1153 .opt_clks = mcbsp234_opt_clks,
1154 .opt_clks_cnt = ARRAY_SIZE(mcbsp234_opt_clks),
1129 .dev_attr = &omap34xx_mcbsp2_dev_attr, 1155 .dev_attr = &omap34xx_mcbsp2_dev_attr,
1130}; 1156};
1131 1157
@@ -1156,6 +1182,8 @@ static struct omap_hwmod omap3xxx_mcbsp3_hwmod = {
1156 .idlest_idle_bit = OMAP3430_ST_MCBSP3_SHIFT, 1182 .idlest_idle_bit = OMAP3430_ST_MCBSP3_SHIFT,
1157 }, 1183 },
1158 }, 1184 },
1185 .opt_clks = mcbsp234_opt_clks,
1186 .opt_clks_cnt = ARRAY_SIZE(mcbsp234_opt_clks),
1159 .dev_attr = &omap34xx_mcbsp3_dev_attr, 1187 .dev_attr = &omap34xx_mcbsp3_dev_attr,
1160}; 1188};
1161 1189
@@ -1188,6 +1216,8 @@ static struct omap_hwmod omap3xxx_mcbsp4_hwmod = {
1188 .idlest_idle_bit = OMAP3430_ST_MCBSP4_SHIFT, 1216 .idlest_idle_bit = OMAP3430_ST_MCBSP4_SHIFT,
1189 }, 1217 },
1190 }, 1218 },
1219 .opt_clks = mcbsp234_opt_clks,
1220 .opt_clks_cnt = ARRAY_SIZE(mcbsp234_opt_clks),
1191}; 1221};
1192 1222
1193/* mcbsp5 */ 1223/* mcbsp5 */
@@ -1219,6 +1249,8 @@ static struct omap_hwmod omap3xxx_mcbsp5_hwmod = {
1219 .idlest_idle_bit = OMAP3430_ST_MCBSP5_SHIFT, 1249 .idlest_idle_bit = OMAP3430_ST_MCBSP5_SHIFT,
1220 }, 1250 },
1221 }, 1251 },
1252 .opt_clks = mcbsp15_opt_clks,
1253 .opt_clks_cnt = ARRAY_SIZE(mcbsp15_opt_clks),
1222}; 1254};
1223 1255
1224/* 'mcbsp sidetone' class */ 1256/* 'mcbsp sidetone' class */
@@ -1325,7 +1357,7 @@ static struct omap_hwmod_irq_info omap3_smartreflex_mpu_irqs[] = {
1325}; 1357};
1326 1358
1327static struct omap_hwmod omap34xx_sr1_hwmod = { 1359static struct omap_hwmod omap34xx_sr1_hwmod = {
1328 .name = "sr1", 1360 .name = "smartreflex_mpu_iva",
1329 .class = &omap34xx_smartreflex_hwmod_class, 1361 .class = &omap34xx_smartreflex_hwmod_class,
1330 .main_clk = "sr1_fck", 1362 .main_clk = "sr1_fck",
1331 .prcm = { 1363 .prcm = {
@@ -1343,7 +1375,7 @@ static struct omap_hwmod omap34xx_sr1_hwmod = {
1343}; 1375};
1344 1376
1345static struct omap_hwmod omap36xx_sr1_hwmod = { 1377static struct omap_hwmod omap36xx_sr1_hwmod = {
1346 .name = "sr1", 1378 .name = "smartreflex_mpu_iva",
1347 .class = &omap36xx_smartreflex_hwmod_class, 1379 .class = &omap36xx_smartreflex_hwmod_class,
1348 .main_clk = "sr1_fck", 1380 .main_clk = "sr1_fck",
1349 .prcm = { 1381 .prcm = {
@@ -1370,7 +1402,7 @@ static struct omap_hwmod_irq_info omap3_smartreflex_core_irqs[] = {
1370}; 1402};
1371 1403
1372static struct omap_hwmod omap34xx_sr2_hwmod = { 1404static struct omap_hwmod omap34xx_sr2_hwmod = {
1373 .name = "sr2", 1405 .name = "smartreflex_core",
1374 .class = &omap34xx_smartreflex_hwmod_class, 1406 .class = &omap34xx_smartreflex_hwmod_class,
1375 .main_clk = "sr2_fck", 1407 .main_clk = "sr2_fck",
1376 .prcm = { 1408 .prcm = {
@@ -1388,7 +1420,7 @@ static struct omap_hwmod omap34xx_sr2_hwmod = {
1388}; 1420};
1389 1421
1390static struct omap_hwmod omap36xx_sr2_hwmod = { 1422static struct omap_hwmod omap36xx_sr2_hwmod = {
1391 .name = "sr2", 1423 .name = "smartreflex_core",
1392 .class = &omap36xx_smartreflex_hwmod_class, 1424 .class = &omap36xx_smartreflex_hwmod_class,
1393 .main_clk = "sr2_fck", 1425 .main_clk = "sr2_fck",
1394 .prcm = { 1426 .prcm = {
@@ -1638,25 +1670,20 @@ static struct omap_hwmod omap3xxx_usbhsotg_hwmod = {
1638 1670
1639/* usb_otg_hs */ 1671/* usb_otg_hs */
1640static struct omap_hwmod_irq_info am35xx_usbhsotg_mpu_irqs[] = { 1672static struct omap_hwmod_irq_info am35xx_usbhsotg_mpu_irqs[] = {
1641
1642 { .name = "mc", .irq = 71 }, 1673 { .name = "mc", .irq = 71 },
1643 { .irq = -1 } 1674 { .irq = -1 }
1644}; 1675};
1645 1676
1646static struct omap_hwmod_class am35xx_usbotg_class = { 1677static struct omap_hwmod_class am35xx_usbotg_class = {
1647 .name = "am35xx_usbotg", 1678 .name = "am35xx_usbotg",
1648 .sysc = NULL,
1649}; 1679};
1650 1680
1651static struct omap_hwmod am35xx_usbhsotg_hwmod = { 1681static struct omap_hwmod am35xx_usbhsotg_hwmod = {
1652 .name = "am35x_otg_hs", 1682 .name = "am35x_otg_hs",
1653 .mpu_irqs = am35xx_usbhsotg_mpu_irqs, 1683 .mpu_irqs = am35xx_usbhsotg_mpu_irqs,
1654 .main_clk = NULL, 1684 .main_clk = "hsotgusb_fck",
1655 .prcm = {
1656 .omap2 = {
1657 },
1658 },
1659 .class = &am35xx_usbotg_class, 1685 .class = &am35xx_usbotg_class,
1686 .flags = HWMOD_NO_IDLEST,
1660}; 1687};
1661 1688
1662/* MMC/SD/SDIO common */ 1689/* MMC/SD/SDIO common */
@@ -2097,9 +2124,10 @@ static struct omap_hwmod_ocp_if omap3xxx_usbhsotg__l3 = {
2097static struct omap_hwmod_ocp_if am35xx_usbhsotg__l3 = { 2124static struct omap_hwmod_ocp_if am35xx_usbhsotg__l3 = {
2098 .master = &am35xx_usbhsotg_hwmod, 2125 .master = &am35xx_usbhsotg_hwmod,
2099 .slave = &omap3xxx_l3_main_hwmod, 2126 .slave = &omap3xxx_l3_main_hwmod,
2100 .clk = "core_l3_ick", 2127 .clk = "hsotgusb_ick",
2101 .user = OCP_USER_MPU, 2128 .user = OCP_USER_MPU,
2102}; 2129};
2130
2103/* L4_CORE -> L4_WKUP interface */ 2131/* L4_CORE -> L4_WKUP interface */
2104static struct omap_hwmod_ocp_if omap3xxx_l4_core__l4_wkup = { 2132static struct omap_hwmod_ocp_if omap3xxx_l4_core__l4_wkup = {
2105 .master = &omap3xxx_l4_core_hwmod, 2133 .master = &omap3xxx_l4_core_hwmod,
@@ -2243,6 +2271,7 @@ static struct omap_hwmod_addr_space am35xx_uart4_addr_space[] = {
2243 .pa_end = OMAP3_UART4_AM35XX_BASE + SZ_1K - 1, 2271 .pa_end = OMAP3_UART4_AM35XX_BASE + SZ_1K - 1,
2244 .flags = ADDR_MAP_ON_INIT | ADDR_TYPE_RT, 2272 .flags = ADDR_MAP_ON_INIT | ADDR_TYPE_RT,
2245 }, 2273 },
2274 { }
2246}; 2275};
2247 2276
2248static struct omap_hwmod_ocp_if am35xx_l4_core__uart4 = { 2277static struct omap_hwmod_ocp_if am35xx_l4_core__uart4 = {
@@ -2393,7 +2422,7 @@ static struct omap_hwmod_addr_space am35xx_usbhsotg_addrs[] = {
2393static struct omap_hwmod_ocp_if am35xx_l4_core__usbhsotg = { 2422static struct omap_hwmod_ocp_if am35xx_l4_core__usbhsotg = {
2394 .master = &omap3xxx_l4_core_hwmod, 2423 .master = &omap3xxx_l4_core_hwmod,
2395 .slave = &am35xx_usbhsotg_hwmod, 2424 .slave = &am35xx_usbhsotg_hwmod,
2396 .clk = "l4_ick", 2425 .clk = "hsotgusb_ick",
2397 .addr = am35xx_usbhsotg_addrs, 2426 .addr = am35xx_usbhsotg_addrs,
2398 .user = OCP_USER_MPU, 2427 .user = OCP_USER_MPU,
2399}; 2428};
@@ -3138,6 +3167,107 @@ static struct omap_hwmod_ocp_if omap3xxx_l4_wkup__counter_32k = {
3138 .user = OCP_USER_MPU | OCP_USER_SDMA, 3167 .user = OCP_USER_MPU | OCP_USER_SDMA,
3139}; 3168};
3140 3169
3170/* am35xx has Davinci MDIO & EMAC */
3171static struct omap_hwmod_class am35xx_mdio_class = {
3172 .name = "davinci_mdio",
3173};
3174
3175static struct omap_hwmod am35xx_mdio_hwmod = {
3176 .name = "davinci_mdio",
3177 .class = &am35xx_mdio_class,
3178 .flags = HWMOD_NO_IDLEST,
3179};
3180
3181/*
3182 * XXX Should be connected to an IPSS hwmod, not the L3 directly;
3183 * but this will probably require some additional hwmod core support,
3184 * so is left as a future to-do item.
3185 */
3186static struct omap_hwmod_ocp_if am35xx_mdio__l3 = {
3187 .master = &am35xx_mdio_hwmod,
3188 .slave = &omap3xxx_l3_main_hwmod,
3189 .clk = "emac_fck",
3190 .user = OCP_USER_MPU,
3191};
3192
3193static struct omap_hwmod_addr_space am35xx_mdio_addrs[] = {
3194 {
3195 .pa_start = AM35XX_IPSS_MDIO_BASE,
3196 .pa_end = AM35XX_IPSS_MDIO_BASE + SZ_4K - 1,
3197 .flags = ADDR_TYPE_RT,
3198 },
3199 { }
3200};
3201
3202/* l4_core -> davinci mdio */
3203/*
3204 * XXX Should be connected to an IPSS hwmod, not the L4_CORE directly;
3205 * but this will probably require some additional hwmod core support,
3206 * so is left as a future to-do item.
3207 */
3208static struct omap_hwmod_ocp_if am35xx_l4_core__mdio = {
3209 .master = &omap3xxx_l4_core_hwmod,
3210 .slave = &am35xx_mdio_hwmod,
3211 .clk = "emac_fck",
3212 .addr = am35xx_mdio_addrs,
3213 .user = OCP_USER_MPU,
3214};
3215
3216static struct omap_hwmod_irq_info am35xx_emac_mpu_irqs[] = {
3217 { .name = "rxthresh", .irq = INT_35XX_EMAC_C0_RXTHRESH_IRQ },
3218 { .name = "rx_pulse", .irq = INT_35XX_EMAC_C0_RX_PULSE_IRQ },
3219 { .name = "tx_pulse", .irq = INT_35XX_EMAC_C0_TX_PULSE_IRQ },
3220 { .name = "misc_pulse", .irq = INT_35XX_EMAC_C0_MISC_PULSE_IRQ },
3221 { .irq = -1 }
3222};
3223
3224static struct omap_hwmod_class am35xx_emac_class = {
3225 .name = "davinci_emac",
3226};
3227
3228static struct omap_hwmod am35xx_emac_hwmod = {
3229 .name = "davinci_emac",
3230 .mpu_irqs = am35xx_emac_mpu_irqs,
3231 .class = &am35xx_emac_class,
3232 .flags = HWMOD_NO_IDLEST,
3233};
3234
3235/* l3_core -> davinci emac interface */
3236/*
3237 * XXX Should be connected to an IPSS hwmod, not the L3 directly;
3238 * but this will probably require some additional hwmod core support,
3239 * so is left as a future to-do item.
3240 */
3241static struct omap_hwmod_ocp_if am35xx_emac__l3 = {
3242 .master = &am35xx_emac_hwmod,
3243 .slave = &omap3xxx_l3_main_hwmod,
3244 .clk = "emac_ick",
3245 .user = OCP_USER_MPU,
3246};
3247
3248static struct omap_hwmod_addr_space am35xx_emac_addrs[] = {
3249 {
3250 .pa_start = AM35XX_IPSS_EMAC_BASE,
3251 .pa_end = AM35XX_IPSS_EMAC_BASE + 0x30000 - 1,
3252 .flags = ADDR_TYPE_RT,
3253 },
3254 { }
3255};
3256
3257/* l4_core -> davinci emac */
3258/*
3259 * XXX Should be connected to an IPSS hwmod, not the L4_CORE directly;
3260 * but this will probably require some additional hwmod core support,
3261 * so is left as a future to-do item.
3262 */
3263static struct omap_hwmod_ocp_if am35xx_l4_core__emac = {
3264 .master = &omap3xxx_l4_core_hwmod,
3265 .slave = &am35xx_emac_hwmod,
3266 .clk = "emac_ick",
3267 .addr = am35xx_emac_addrs,
3268 .user = OCP_USER_MPU,
3269};
3270
3141static struct omap_hwmod_ocp_if *omap3xxx_hwmod_ocp_ifs[] __initdata = { 3271static struct omap_hwmod_ocp_if *omap3xxx_hwmod_ocp_ifs[] __initdata = {
3142 &omap3xxx_l3_main__l4_core, 3272 &omap3xxx_l3_main__l4_core,
3143 &omap3xxx_l3_main__l4_per, 3273 &omap3xxx_l3_main__l4_per,
@@ -3266,6 +3396,10 @@ static struct omap_hwmod_ocp_if *am35xx_hwmod_ocp_ifs[] __initdata = {
3266 &omap3xxx_l4_core__usb_tll_hs, 3396 &omap3xxx_l4_core__usb_tll_hs,
3267 &omap3xxx_l4_core__es3plus_mmc1, 3397 &omap3xxx_l4_core__es3plus_mmc1,
3268 &omap3xxx_l4_core__es3plus_mmc2, 3398 &omap3xxx_l4_core__es3plus_mmc2,
3399 &am35xx_mdio__l3,
3400 &am35xx_l4_core__mdio,
3401 &am35xx_emac__l3,
3402 &am35xx_l4_core__emac,
3269 NULL 3403 NULL
3270}; 3404};
3271 3405
@@ -3283,6 +3417,8 @@ int __init omap3xxx_hwmod_init(void)
3283 struct omap_hwmod_ocp_if **h = NULL; 3417 struct omap_hwmod_ocp_if **h = NULL;
3284 unsigned int rev; 3418 unsigned int rev;
3285 3419
3420 omap_hwmod_init();
3421
3286 /* Register hwmod links common to all OMAP3 */ 3422 /* Register hwmod links common to all OMAP3 */
3287 r = omap_hwmod_register_links(omap3xxx_hwmod_ocp_ifs); 3423 r = omap_hwmod_register_links(omap3xxx_hwmod_ocp_ifs);
3288 if (r < 0) 3424 if (r < 0)
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index b7bcba5221b..242aee498ce 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/power/smartreflex.h>
22 23
23#include <plat/omap_hwmod.h> 24#include <plat/omap_hwmod.h>
24#include <plat/cpu.h> 25#include <plat/cpu.h>
@@ -32,8 +33,6 @@
32#include <plat/common.h> 33#include <plat/common.h>
33 34
34#include "omap_hwmod_common_data.h" 35#include "omap_hwmod_common_data.h"
35
36#include "smartreflex.h"
37#include "cm1_44xx.h" 36#include "cm1_44xx.h"
38#include "cm2_44xx.h" 37#include "cm2_44xx.h"
39#include "prm44xx.h" 38#include "prm44xx.h"
@@ -2544,14 +2543,12 @@ static struct omap_hwmod omap44xx_prcm_mpu_hwmod = {
2544static struct omap_hwmod omap44xx_cm_core_aon_hwmod = { 2543static struct omap_hwmod omap44xx_cm_core_aon_hwmod = {
2545 .name = "cm_core_aon", 2544 .name = "cm_core_aon",
2546 .class = &omap44xx_prcm_hwmod_class, 2545 .class = &omap44xx_prcm_hwmod_class,
2547 .clkdm_name = "cm_clkdm",
2548}; 2546};
2549 2547
2550/* cm_core */ 2548/* cm_core */
2551static struct omap_hwmod omap44xx_cm_core_hwmod = { 2549static struct omap_hwmod omap44xx_cm_core_hwmod = {
2552 .name = "cm_core", 2550 .name = "cm_core",
2553 .class = &omap44xx_prcm_hwmod_class, 2551 .class = &omap44xx_prcm_hwmod_class,
2554 .clkdm_name = "cm_clkdm",
2555}; 2552};
2556 2553
2557/* prm */ 2554/* prm */
@@ -2568,7 +2565,6 @@ static struct omap_hwmod_rst_info omap44xx_prm_resets[] = {
2568static struct omap_hwmod omap44xx_prm_hwmod = { 2565static struct omap_hwmod omap44xx_prm_hwmod = {
2569 .name = "prm", 2566 .name = "prm",
2570 .class = &omap44xx_prcm_hwmod_class, 2567 .class = &omap44xx_prcm_hwmod_class,
2571 .clkdm_name = "prm_clkdm",
2572 .mpu_irqs = omap44xx_prm_irqs, 2568 .mpu_irqs = omap44xx_prm_irqs,
2573 .rst_lines = omap44xx_prm_resets, 2569 .rst_lines = omap44xx_prm_resets,
2574 .rst_lines_cnt = ARRAY_SIZE(omap44xx_prm_resets), 2570 .rst_lines_cnt = ARRAY_SIZE(omap44xx_prm_resets),
@@ -2947,7 +2943,6 @@ static struct omap_hwmod omap44xx_timer2_hwmod = {
2947 .modulemode = MODULEMODE_SWCTRL, 2943 .modulemode = MODULEMODE_SWCTRL,
2948 }, 2944 },
2949 }, 2945 },
2950 .dev_attr = &capability_alwon_dev_attr,
2951}; 2946};
2952 2947
2953/* timer3 */ 2948/* timer3 */
@@ -2969,7 +2964,6 @@ static struct omap_hwmod omap44xx_timer3_hwmod = {
2969 .modulemode = MODULEMODE_SWCTRL, 2964 .modulemode = MODULEMODE_SWCTRL,
2970 }, 2965 },
2971 }, 2966 },
2972 .dev_attr = &capability_alwon_dev_attr,
2973}; 2967};
2974 2968
2975/* timer4 */ 2969/* timer4 */
@@ -2991,7 +2985,6 @@ static struct omap_hwmod omap44xx_timer4_hwmod = {
2991 .modulemode = MODULEMODE_SWCTRL, 2985 .modulemode = MODULEMODE_SWCTRL,
2992 }, 2986 },
2993 }, 2987 },
2994 .dev_attr = &capability_alwon_dev_attr,
2995}; 2988};
2996 2989
2997/* timer5 */ 2990/* timer5 */
@@ -3013,7 +3006,6 @@ static struct omap_hwmod omap44xx_timer5_hwmod = {
3013 .modulemode = MODULEMODE_SWCTRL, 3006 .modulemode = MODULEMODE_SWCTRL,
3014 }, 3007 },
3015 }, 3008 },
3016 .dev_attr = &capability_alwon_dev_attr,
3017}; 3009};
3018 3010
3019/* timer6 */ 3011/* timer6 */
@@ -3036,7 +3028,6 @@ static struct omap_hwmod omap44xx_timer6_hwmod = {
3036 .modulemode = MODULEMODE_SWCTRL, 3028 .modulemode = MODULEMODE_SWCTRL,
3037 }, 3029 },
3038 }, 3030 },
3039 .dev_attr = &capability_alwon_dev_attr,
3040}; 3031};
3041 3032
3042/* timer7 */ 3033/* timer7 */
@@ -3058,7 +3049,6 @@ static struct omap_hwmod omap44xx_timer7_hwmod = {
3058 .modulemode = MODULEMODE_SWCTRL, 3049 .modulemode = MODULEMODE_SWCTRL,
3059 }, 3050 },
3060 }, 3051 },
3061 .dev_attr = &capability_alwon_dev_attr,
3062}; 3052};
3063 3053
3064/* timer8 */ 3054/* timer8 */
@@ -6148,6 +6138,7 @@ static struct omap_hwmod_ocp_if *omap44xx_hwmod_ocp_ifs[] __initdata = {
6148 6138
6149int __init omap44xx_hwmod_init(void) 6139int __init omap44xx_hwmod_init(void)
6150{ 6140{
6141 omap_hwmod_init();
6151 return omap_hwmod_register_links(omap44xx_hwmod_ocp_ifs); 6142 return omap_hwmod_register_links(omap44xx_hwmod_ocp_ifs);
6152} 6143}
6153 6144
diff --git a/arch/arm/mach-omap2/omap_hwmod_common_data.c b/arch/arm/mach-omap2/omap_hwmod_common_data.c
index 51e5418899f..9f1ccdc8cc8 100644
--- a/arch/arm/mach-omap2/omap_hwmod_common_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_common_data.c
@@ -47,6 +47,16 @@ struct omap_hwmod_sysc_fields omap_hwmod_sysc_type2 = {
47 .midle_shift = SYSC_TYPE2_MIDLEMODE_SHIFT, 47 .midle_shift = SYSC_TYPE2_MIDLEMODE_SHIFT,
48 .sidle_shift = SYSC_TYPE2_SIDLEMODE_SHIFT, 48 .sidle_shift = SYSC_TYPE2_SIDLEMODE_SHIFT,
49 .srst_shift = SYSC_TYPE2_SOFTRESET_SHIFT, 49 .srst_shift = SYSC_TYPE2_SOFTRESET_SHIFT,
50 .dmadisable_shift = SYSC_TYPE2_DMADISABLE_SHIFT,
51};
52
53/**
54 * struct omap_hwmod_sysc_type3 - TYPE3 sysconfig scheme.
55 * Used by some IPs on AM33xx
56 */
57struct omap_hwmod_sysc_fields omap_hwmod_sysc_type3 = {
58 .midle_shift = SYSC_TYPE3_MIDLEMODE_SHIFT,
59 .sidle_shift = SYSC_TYPE3_SIDLEMODE_SHIFT,
50}; 60};
51 61
52struct omap_dss_dispc_dev_attr omap2_3_dss_dispc_dev_attr = { 62struct omap_dss_dispc_dev_attr omap2_3_dss_dispc_dev_attr = {
diff --git a/arch/arm/mach-omap2/omap_l3_noc.h b/arch/arm/mach-omap2/omap_l3_noc.h
index 90b50984cd2..a6ce34dc481 100644
--- a/arch/arm/mach-omap2/omap_l3_noc.h
+++ b/arch/arm/mach-omap2/omap_l3_noc.h
@@ -51,7 +51,9 @@ static u32 l3_targ_inst_clk1[] = {
51 0x200, /* DMM2 */ 51 0x200, /* DMM2 */
52 0x300, /* ABE */ 52 0x300, /* ABE */
53 0x400, /* L4CFG */ 53 0x400, /* L4CFG */
54 0x600 /* CLK2 PWR DISC */ 54 0x600, /* CLK2 PWR DISC */
55 0x0, /* Host CLK1 */
56 0x900 /* L4 Wakeup */
55}; 57};
56 58
57static u32 l3_targ_inst_clk2[] = { 59static u32 l3_targ_inst_clk2[] = {
@@ -72,11 +74,16 @@ static u32 l3_targ_inst_clk2[] = {
72 0xE00, /* missing in TRM corresponds to AES2*/ 74 0xE00, /* missing in TRM corresponds to AES2*/
73 0xC00, /* L4 PER3 */ 75 0xC00, /* L4 PER3 */
74 0xA00, /* L4 PER1*/ 76 0xA00, /* L4 PER1*/
75 0xB00 /* L4 PER2*/ 77 0xB00, /* L4 PER2*/
78 0x0, /* HOST CLK2 */
79 0x1800, /* CAL */
80 0x1700 /* LLI */
76}; 81};
77 82
78static u32 l3_targ_inst_clk3[] = { 83static u32 l3_targ_inst_clk3[] = {
79 0x0100 /* EMUSS */ 84 0x0100 /* EMUSS */,
85 0x0300, /* DEBUGSS_CT_TBR */
86 0x0 /* HOST CLK3 */
80}; 87};
81 88
82static struct l3_masters_data { 89static struct l3_masters_data {
@@ -110,13 +117,15 @@ static struct l3_masters_data {
110 { 0xC8, "USBHOSTFS"} 117 { 0xC8, "USBHOSTFS"}
111}; 118};
112 119
113static char *l3_targ_inst_name[L3_MODULES][18] = { 120static char *l3_targ_inst_name[L3_MODULES][21] = {
114 { 121 {
115 "DMM1", 122 "DMM1",
116 "DMM2", 123 "DMM2",
117 "ABE", 124 "ABE",
118 "L4CFG", 125 "L4CFG",
119 "CLK2 PWR DISC", 126 "CLK2 PWR DISC",
127 "HOST CLK1",
128 "L4 WAKEUP"
120 }, 129 },
121 { 130 {
122 "CORTEX M3" , 131 "CORTEX M3" ,
@@ -137,9 +146,14 @@ static char *l3_targ_inst_name[L3_MODULES][18] = {
137 "L4 PER3", 146 "L4 PER3",
138 "L4 PER1", 147 "L4 PER1",
139 "L4 PER2", 148 "L4 PER2",
149 "HOST CLK2",
150 "CAL",
151 "LLI"
140 }, 152 },
141 { 153 {
142 "EMUSS", 154 "EMUSS",
155 "DEBUG SOURCE",
156 "HOST CLK3"
143 }, 157 },
144}; 158};
145 159
diff --git a/arch/arm/mach-omap2/opp.c b/arch/arm/mach-omap2/opp.c
index de6d4645174..d8f6dbf45d1 100644
--- a/arch/arm/mach-omap2/opp.c
+++ b/arch/arm/mach-omap2/opp.c
@@ -53,7 +53,7 @@ int __init omap_init_opp_table(struct omap_opp_def *opp_def,
53 omap_table_init = 1; 53 omap_table_init = 1;
54 54
55 /* Lets now register with OPP library */ 55 /* Lets now register with OPP library */
56 for (i = 0; i < opp_def_size; i++) { 56 for (i = 0; i < opp_def_size; i++, opp_def++) {
57 struct omap_hwmod *oh; 57 struct omap_hwmod *oh;
58 struct device *dev; 58 struct device *dev;
59 59
@@ -86,7 +86,6 @@ int __init omap_init_opp_table(struct omap_opp_def *opp_def,
86 __func__, opp_def->freq, 86 __func__, opp_def->freq,
87 opp_def->hwmod_name, i, r); 87 opp_def->hwmod_name, i, r);
88 } 88 }
89 opp_def++;
90 } 89 }
91 90
92 return 0; 91 return 0;
diff --git a/arch/arm/mach-omap2/opp4xxx_data.c b/arch/arm/mach-omap2/opp4xxx_data.c
index 2293ba27101..c95415da23c 100644
--- a/arch/arm/mach-omap2/opp4xxx_data.c
+++ b/arch/arm/mach-omap2/opp4xxx_data.c
@@ -94,7 +94,7 @@ int __init omap4_opp_init(void)
94{ 94{
95 int r = -ENODEV; 95 int r = -ENODEV;
96 96
97 if (!cpu_is_omap44xx()) 97 if (!cpu_is_omap443x())
98 return r; 98 return r;
99 99
100 r = omap_init_opp_table(omap44xx_opp_def_list, 100 r = omap_init_opp_table(omap44xx_opp_def_list,
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 78564895e91..686137d164d 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -15,12 +15,25 @@
15 15
16#include "powerdomain.h" 16#include "powerdomain.h"
17 17
18#ifdef CONFIG_CPU_IDLE
19extern int __init omap3_idle_init(void);
20extern int __init omap4_idle_init(void);
21#else
22static inline int omap3_idle_init(void)
23{
24 return 0;
25}
26
27static inline int omap4_idle_init(void)
28{
29 return 0;
30}
31#endif
32
18extern void *omap3_secure_ram_storage; 33extern void *omap3_secure_ram_storage;
19extern void omap3_pm_off_mode_enable(int); 34extern void omap3_pm_off_mode_enable(int);
20extern void omap_sram_idle(void); 35extern void omap_sram_idle(void);
21extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state); 36extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state);
22extern int omap3_idle_init(void);
23extern int omap4_idle_init(void);
24extern int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused); 37extern int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused);
25extern int (*omap_pm_suspend)(void); 38extern int (*omap_pm_suspend)(void);
26 39
@@ -88,7 +101,7 @@ extern void enable_omap3630_toggle_l2_on_restore(void);
88static inline void enable_omap3630_toggle_l2_on_restore(void) { } 101static inline void enable_omap3630_toggle_l2_on_restore(void) { }
89#endif /* defined(CONFIG_PM) && defined(CONFIG_ARCH_OMAP3) */ 102#endif /* defined(CONFIG_PM) && defined(CONFIG_ARCH_OMAP3) */
90 103
91#ifdef CONFIG_OMAP_SMARTREFLEX 104#ifdef CONFIG_POWER_AVS_OMAP
92extern int omap_devinit_smartreflex(void); 105extern int omap_devinit_smartreflex(void);
93extern void omap_enable_smartreflex_on_init(void); 106extern void omap_enable_smartreflex_on_init(void);
94#else 107#else
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 3a595e89972..05bd8f02723 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -70,34 +70,6 @@ void (*omap3_do_wfi_sram)(void);
70 70
71static struct powerdomain *mpu_pwrdm, *neon_pwrdm; 71static struct powerdomain *mpu_pwrdm, *neon_pwrdm;
72static struct powerdomain *core_pwrdm, *per_pwrdm; 72static struct powerdomain *core_pwrdm, *per_pwrdm;
73static struct powerdomain *cam_pwrdm;
74
75static void omap3_enable_io_chain(void)
76{
77 int timeout = 0;
78
79 omap2_prm_set_mod_reg_bits(OMAP3430_EN_IO_CHAIN_MASK, WKUP_MOD,
80 PM_WKEN);
81 /* Do a readback to assure write has been done */
82 omap2_prm_read_mod_reg(WKUP_MOD, PM_WKEN);
83
84 while (!(omap2_prm_read_mod_reg(WKUP_MOD, PM_WKEN) &
85 OMAP3430_ST_IO_CHAIN_MASK)) {
86 timeout++;
87 if (timeout > 1000) {
88 pr_err("Wake up daisy chain activation failed.\n");
89 return;
90 }
91 omap2_prm_set_mod_reg_bits(OMAP3430_ST_IO_CHAIN_MASK,
92 WKUP_MOD, PM_WKEN);
93 }
94}
95
96static void omap3_disable_io_chain(void)
97{
98 omap2_prm_clear_mod_reg_bits(OMAP3430_EN_IO_CHAIN_MASK, WKUP_MOD,
99 PM_WKEN);
100}
101 73
102static void omap3_core_save_context(void) 74static void omap3_core_save_context(void)
103{ 75{
@@ -299,15 +271,8 @@ void omap_sram_idle(void)
299 /* Enable IO-PAD and IO-CHAIN wakeups */ 271 /* Enable IO-PAD and IO-CHAIN wakeups */
300 per_next_state = pwrdm_read_next_pwrst(per_pwrdm); 272 per_next_state = pwrdm_read_next_pwrst(per_pwrdm);
301 core_next_state = pwrdm_read_next_pwrst(core_pwrdm); 273 core_next_state = pwrdm_read_next_pwrst(core_pwrdm);
302 if (omap3_has_io_wakeup() &&
303 (per_next_state < PWRDM_POWER_ON ||
304 core_next_state < PWRDM_POWER_ON)) {
305 omap2_prm_set_mod_reg_bits(OMAP3430_EN_IO_MASK, WKUP_MOD, PM_WKEN);
306 if (omap3_has_io_chain_ctrl())
307 omap3_enable_io_chain();
308 }
309 274
310 pwrdm_pre_transition(); 275 pwrdm_pre_transition(NULL);
311 276
312 /* PER */ 277 /* PER */
313 if (per_next_state < PWRDM_POWER_ON) { 278 if (per_next_state < PWRDM_POWER_ON) {
@@ -372,23 +337,11 @@ void omap_sram_idle(void)
372 } 337 }
373 omap3_intc_resume_idle(); 338 omap3_intc_resume_idle();
374 339
375 pwrdm_post_transition(); 340 pwrdm_post_transition(NULL);
376 341
377 /* PER */ 342 /* PER */
378 if (per_next_state < PWRDM_POWER_ON) 343 if (per_next_state < PWRDM_POWER_ON)
379 omap2_gpio_resume_after_idle(); 344 omap2_gpio_resume_after_idle();
380
381 /* Disable IO-PAD and IO-CHAIN wakeup */
382 if (omap3_has_io_wakeup() &&
383 (per_next_state < PWRDM_POWER_ON ||
384 core_next_state < PWRDM_POWER_ON)) {
385 omap2_prm_clear_mod_reg_bits(OMAP3430_EN_IO_MASK, WKUP_MOD,
386 PM_WKEN);
387 if (omap3_has_io_chain_ctrl())
388 omap3_disable_io_chain();
389 }
390
391 clkdm_allow_idle(mpu_pwrdm->pwrdm_clkdms[0]);
392} 345}
393 346
394static void omap3_pm_idle(void) 347static void omap3_pm_idle(void)
@@ -581,10 +534,13 @@ static void __init prcm_setup_regs(void)
581 OMAP3430_PER_MOD, OMAP3430_PM_MPUGRPSEL); 534 OMAP3430_PER_MOD, OMAP3430_PM_MPUGRPSEL);
582 535
583 /* Don't attach IVA interrupts */ 536 /* Don't attach IVA interrupts */
584 omap2_prm_write_mod_reg(0, WKUP_MOD, OMAP3430_PM_IVAGRPSEL); 537 if (omap3_has_iva()) {
585 omap2_prm_write_mod_reg(0, CORE_MOD, OMAP3430_PM_IVAGRPSEL1); 538 omap2_prm_write_mod_reg(0, WKUP_MOD, OMAP3430_PM_IVAGRPSEL);
586 omap2_prm_write_mod_reg(0, CORE_MOD, OMAP3430ES2_PM_IVAGRPSEL3); 539 omap2_prm_write_mod_reg(0, CORE_MOD, OMAP3430_PM_IVAGRPSEL1);
587 omap2_prm_write_mod_reg(0, OMAP3430_PER_MOD, OMAP3430_PM_IVAGRPSEL); 540 omap2_prm_write_mod_reg(0, CORE_MOD, OMAP3430ES2_PM_IVAGRPSEL3);
541 omap2_prm_write_mod_reg(0, OMAP3430_PER_MOD,
542 OMAP3430_PM_IVAGRPSEL);
543 }
588 544
589 /* Clear any pending 'reset' flags */ 545 /* Clear any pending 'reset' flags */
590 omap2_prm_write_mod_reg(0xffffffff, MPU_MOD, OMAP2_RM_RSTST); 546 omap2_prm_write_mod_reg(0xffffffff, MPU_MOD, OMAP2_RM_RSTST);
@@ -598,7 +554,9 @@ static void __init prcm_setup_regs(void)
598 /* Clear any pending PRCM interrupts */ 554 /* Clear any pending PRCM interrupts */
599 omap2_prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET); 555 omap2_prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
600 556
601 omap3_iva_idle(); 557 if (omap3_has_iva())
558 omap3_iva_idle();
559
602 omap3_d2d_idle(); 560 omap3_d2d_idle();
603} 561}
604 562
@@ -749,7 +707,6 @@ int __init omap3_pm_init(void)
749 neon_pwrdm = pwrdm_lookup("neon_pwrdm"); 707 neon_pwrdm = pwrdm_lookup("neon_pwrdm");
750 per_pwrdm = pwrdm_lookup("per_pwrdm"); 708 per_pwrdm = pwrdm_lookup("per_pwrdm");
751 core_pwrdm = pwrdm_lookup("core_pwrdm"); 709 core_pwrdm = pwrdm_lookup("core_pwrdm");
752 cam_pwrdm = pwrdm_lookup("cam_pwrdm");
753 710
754 neon_clkdm = clkdm_lookup("neon_clkdm"); 711 neon_clkdm = clkdm_lookup("neon_clkdm");
755 mpu_clkdm = clkdm_lookup("mpu_clkdm"); 712 mpu_clkdm = clkdm_lookup("mpu_clkdm");
diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index 96114901b93..69b36e185e9 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -526,7 +526,8 @@ int pwrdm_read_next_pwrst(struct powerdomain *pwrdm)
526 * 526 *
527 * Return the powerdomain @pwrdm's current power state. Returns -EINVAL 527 * Return the powerdomain @pwrdm's current power state. Returns -EINVAL
528 * if the powerdomain pointer is null or returns the current power state 528 * if the powerdomain pointer is null or returns the current power state
529 * upon success. 529 * upon success. Note that if the power domain only supports the ON state
530 * then just return ON as the current state.
530 */ 531 */
531int pwrdm_read_pwrst(struct powerdomain *pwrdm) 532int pwrdm_read_pwrst(struct powerdomain *pwrdm)
532{ 533{
@@ -535,6 +536,9 @@ int pwrdm_read_pwrst(struct powerdomain *pwrdm)
535 if (!pwrdm) 536 if (!pwrdm)
536 return -EINVAL; 537 return -EINVAL;
537 538
539 if (pwrdm->pwrsts == PWRSTS_ON)
540 return PWRDM_POWER_ON;
541
538 if (arch_pwrdm && arch_pwrdm->pwrdm_read_pwrst) 542 if (arch_pwrdm && arch_pwrdm->pwrdm_read_pwrst)
539 ret = arch_pwrdm->pwrdm_read_pwrst(pwrdm); 543 ret = arch_pwrdm->pwrdm_read_pwrst(pwrdm);
540 544
@@ -981,15 +985,23 @@ int pwrdm_state_switch(struct powerdomain *pwrdm)
981 return ret; 985 return ret;
982} 986}
983 987
984int pwrdm_pre_transition(void) 988int pwrdm_pre_transition(struct powerdomain *pwrdm)
985{ 989{
986 pwrdm_for_each(_pwrdm_pre_transition_cb, NULL); 990 if (pwrdm)
991 _pwrdm_pre_transition_cb(pwrdm, NULL);
992 else
993 pwrdm_for_each(_pwrdm_pre_transition_cb, NULL);
994
987 return 0; 995 return 0;
988} 996}
989 997
990int pwrdm_post_transition(void) 998int pwrdm_post_transition(struct powerdomain *pwrdm)
991{ 999{
992 pwrdm_for_each(_pwrdm_post_transition_cb, NULL); 1000 if (pwrdm)
1001 _pwrdm_post_transition_cb(pwrdm, NULL);
1002 else
1003 pwrdm_for_each(_pwrdm_post_transition_cb, NULL);
1004
993 return 0; 1005 return 0;
994} 1006}
995 1007
diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index 8f88d65c46e..baee90608d1 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -67,9 +67,9 @@
67 67
68/* 68/*
69 * Maximum number of clockdomains that can be associated with a powerdomain. 69 * Maximum number of clockdomains that can be associated with a powerdomain.
70 * CORE powerdomain on OMAP4 is the worst case 70 * PER powerdomain on AM33XX is the worst case
71 */ 71 */
72#define PWRDM_MAX_CLKDMS 9 72#define PWRDM_MAX_CLKDMS 11
73 73
74/* XXX A completely arbitrary number. What is reasonable here? */ 74/* XXX A completely arbitrary number. What is reasonable here? */
75#define PWRDM_TRANSITION_BAILOUT 100000 75#define PWRDM_TRANSITION_BAILOUT 100000
@@ -92,6 +92,15 @@ struct powerdomain;
92 * @pwrdm_clkdms: Clockdomains in this powerdomain 92 * @pwrdm_clkdms: Clockdomains in this powerdomain
93 * @node: list_head linking all powerdomains 93 * @node: list_head linking all powerdomains
94 * @voltdm_node: list_head linking all powerdomains in a voltagedomain 94 * @voltdm_node: list_head linking all powerdomains in a voltagedomain
95 * @pwrstctrl_offs: (AM33XX only) XXX_PWRSTCTRL reg offset from prcm_offs
96 * @pwrstst_offs: (AM33XX only) XXX_PWRSTST reg offset from prcm_offs
97 * @logicretstate_mask: (AM33XX only) mask for logic retention bitfield
98 * in @pwrstctrl_offs
99 * @mem_on_mask: (AM33XX only) mask for mem on bitfield in @pwrstctrl_offs
100 * @mem_ret_mask: (AM33XX only) mask for mem ret bitfield in @pwrstctrl_offs
101 * @mem_pwrst_mask: (AM33XX only) mask for mem state bitfield in @pwrstst_offs
102 * @mem_retst_mask: (AM33XX only) mask for mem retention state bitfield
103 * in @pwrstctrl_offs
95 * @state: 104 * @state:
96 * @state_counter: 105 * @state_counter:
97 * @timer: 106 * @timer:
@@ -121,6 +130,14 @@ struct powerdomain {
121 unsigned ret_logic_off_counter; 130 unsigned ret_logic_off_counter;
122 unsigned ret_mem_off_counter[PWRDM_MAX_MEM_BANKS]; 131 unsigned ret_mem_off_counter[PWRDM_MAX_MEM_BANKS];
123 132
133 const u8 pwrstctrl_offs;
134 const u8 pwrstst_offs;
135 const u32 logicretstate_mask;
136 const u32 mem_on_mask[PWRDM_MAX_MEM_BANKS];
137 const u32 mem_ret_mask[PWRDM_MAX_MEM_BANKS];
138 const u32 mem_pwrst_mask[PWRDM_MAX_MEM_BANKS];
139 const u32 mem_retst_mask[PWRDM_MAX_MEM_BANKS];
140
124#ifdef CONFIG_PM_DEBUG 141#ifdef CONFIG_PM_DEBUG
125 s64 timer; 142 s64 timer;
126 s64 state_timer[PWRDM_MAX_PWRSTS]; 143 s64 state_timer[PWRDM_MAX_PWRSTS];
@@ -213,8 +230,8 @@ bool pwrdm_has_hdwr_sar(struct powerdomain *pwrdm);
213int pwrdm_wait_transition(struct powerdomain *pwrdm); 230int pwrdm_wait_transition(struct powerdomain *pwrdm);
214 231
215int pwrdm_state_switch(struct powerdomain *pwrdm); 232int pwrdm_state_switch(struct powerdomain *pwrdm);
216int pwrdm_pre_transition(void); 233int pwrdm_pre_transition(struct powerdomain *pwrdm);
217int pwrdm_post_transition(void); 234int pwrdm_post_transition(struct powerdomain *pwrdm);
218int pwrdm_set_lowpwrstchange(struct powerdomain *pwrdm); 235int pwrdm_set_lowpwrstchange(struct powerdomain *pwrdm);
219int pwrdm_get_context_loss_count(struct powerdomain *pwrdm); 236int pwrdm_get_context_loss_count(struct powerdomain *pwrdm);
220bool pwrdm_can_ever_lose_context(struct powerdomain *pwrdm); 237bool pwrdm_can_ever_lose_context(struct powerdomain *pwrdm);
@@ -222,10 +239,12 @@ bool pwrdm_can_ever_lose_context(struct powerdomain *pwrdm);
222extern void omap242x_powerdomains_init(void); 239extern void omap242x_powerdomains_init(void);
223extern void omap243x_powerdomains_init(void); 240extern void omap243x_powerdomains_init(void);
224extern void omap3xxx_powerdomains_init(void); 241extern void omap3xxx_powerdomains_init(void);
242extern void am33xx_powerdomains_init(void);
225extern void omap44xx_powerdomains_init(void); 243extern void omap44xx_powerdomains_init(void);
226 244
227extern struct pwrdm_ops omap2_pwrdm_operations; 245extern struct pwrdm_ops omap2_pwrdm_operations;
228extern struct pwrdm_ops omap3_pwrdm_operations; 246extern struct pwrdm_ops omap3_pwrdm_operations;
247extern struct pwrdm_ops am33xx_pwrdm_operations;
229extern struct pwrdm_ops omap4_pwrdm_operations; 248extern struct pwrdm_ops omap4_pwrdm_operations;
230 249
231/* Common Internal functions used across OMAP rev's */ 250/* Common Internal functions used across OMAP rev's */
diff --git a/arch/arm/mach-omap2/powerdomain33xx.c b/arch/arm/mach-omap2/powerdomain33xx.c
new file mode 100644
index 00000000000..67c5663899b
--- /dev/null
+++ b/arch/arm/mach-omap2/powerdomain33xx.c
@@ -0,0 +1,229 @@
1/*
2 * AM33XX Powerdomain control
3 *
4 * Copyright (C) 2011-2012 Texas Instruments Incorporated - http://www.ti.com/
5 *
6 * Derived from mach-omap2/powerdomain44xx.c written by Rajendra Nayak
7 * <rnayak@ti.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation version 2.
12 *
13 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
14 * kind, whether express or implied; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#include <linux/io.h>
20#include <linux/errno.h>
21#include <linux/delay.h>
22
23#include <plat/prcm.h>
24
25#include "powerdomain.h"
26#include "prm33xx.h"
27#include "prm-regbits-33xx.h"
28
29
30static int am33xx_pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst)
31{
32 am33xx_prm_rmw_reg_bits(OMAP_POWERSTATE_MASK,
33 (pwrst << OMAP_POWERSTATE_SHIFT),
34 pwrdm->prcm_offs, pwrdm->pwrstctrl_offs);
35 return 0;
36}
37
38static int am33xx_pwrdm_read_next_pwrst(struct powerdomain *pwrdm)
39{
40 u32 v;
41
42 v = am33xx_prm_read_reg(pwrdm->prcm_offs, pwrdm->pwrstctrl_offs);
43 v &= OMAP_POWERSTATE_MASK;
44 v >>= OMAP_POWERSTATE_SHIFT;
45
46 return v;
47}
48
49static int am33xx_pwrdm_read_pwrst(struct powerdomain *pwrdm)
50{
51 u32 v;
52
53 v = am33xx_prm_read_reg(pwrdm->prcm_offs, pwrdm->pwrstst_offs);
54 v &= OMAP_POWERSTATEST_MASK;
55 v >>= OMAP_POWERSTATEST_SHIFT;
56
57 return v;
58}
59
60static int am33xx_pwrdm_read_prev_pwrst(struct powerdomain *pwrdm)
61{
62 u32 v;
63
64 v = am33xx_prm_read_reg(pwrdm->prcm_offs, pwrdm->pwrstst_offs);
65 v &= AM33XX_LASTPOWERSTATEENTERED_MASK;
66 v >>= AM33XX_LASTPOWERSTATEENTERED_SHIFT;
67
68 return v;
69}
70
71static int am33xx_pwrdm_set_lowpwrstchange(struct powerdomain *pwrdm)
72{
73 am33xx_prm_rmw_reg_bits(AM33XX_LOWPOWERSTATECHANGE_MASK,
74 (1 << AM33XX_LOWPOWERSTATECHANGE_SHIFT),
75 pwrdm->prcm_offs, pwrdm->pwrstctrl_offs);
76 return 0;
77}
78
79static int am33xx_pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm)
80{
81 am33xx_prm_rmw_reg_bits(AM33XX_LASTPOWERSTATEENTERED_MASK,
82 AM33XX_LASTPOWERSTATEENTERED_MASK,
83 pwrdm->prcm_offs, pwrdm->pwrstst_offs);
84 return 0;
85}
86
87static int am33xx_pwrdm_set_logic_retst(struct powerdomain *pwrdm, u8 pwrst)
88{
89 u32 m;
90
91 m = pwrdm->logicretstate_mask;
92 if (!m)
93 return -EINVAL;
94
95 am33xx_prm_rmw_reg_bits(m, (pwrst << __ffs(m)),
96 pwrdm->prcm_offs, pwrdm->pwrstctrl_offs);
97
98 return 0;
99}
100
101static int am33xx_pwrdm_read_logic_pwrst(struct powerdomain *pwrdm)
102{
103 u32 v;
104
105 v = am33xx_prm_read_reg(pwrdm->prcm_offs, pwrdm->pwrstst_offs);
106 v &= AM33XX_LOGICSTATEST_MASK;
107 v >>= AM33XX_LOGICSTATEST_SHIFT;
108
109 return v;
110}
111
112static int am33xx_pwrdm_read_logic_retst(struct powerdomain *pwrdm)
113{
114 u32 v, m;
115
116 m = pwrdm->logicretstate_mask;
117 if (!m)
118 return -EINVAL;
119
120 v = am33xx_prm_read_reg(pwrdm->prcm_offs, pwrdm->pwrstctrl_offs);
121 v &= m;
122 v >>= __ffs(m);
123
124 return v;
125}
126
127static int am33xx_pwrdm_set_mem_onst(struct powerdomain *pwrdm, u8 bank,
128 u8 pwrst)
129{
130 u32 m;
131
132 m = pwrdm->mem_on_mask[bank];
133 if (!m)
134 return -EINVAL;
135
136 am33xx_prm_rmw_reg_bits(m, (pwrst << __ffs(m)),
137 pwrdm->prcm_offs, pwrdm->pwrstctrl_offs);
138
139 return 0;
140}
141
142static int am33xx_pwrdm_set_mem_retst(struct powerdomain *pwrdm, u8 bank,
143 u8 pwrst)
144{
145 u32 m;
146
147 m = pwrdm->mem_ret_mask[bank];
148 if (!m)
149 return -EINVAL;
150
151 am33xx_prm_rmw_reg_bits(m, (pwrst << __ffs(m)),
152 pwrdm->prcm_offs, pwrdm->pwrstctrl_offs);
153
154 return 0;
155}
156
157static int am33xx_pwrdm_read_mem_pwrst(struct powerdomain *pwrdm, u8 bank)
158{
159 u32 m, v;
160
161 m = pwrdm->mem_pwrst_mask[bank];
162 if (!m)
163 return -EINVAL;
164
165 v = am33xx_prm_read_reg(pwrdm->prcm_offs, pwrdm->pwrstst_offs);
166 v &= m;
167 v >>= __ffs(m);
168
169 return v;
170}
171
172static int am33xx_pwrdm_read_mem_retst(struct powerdomain *pwrdm, u8 bank)
173{
174 u32 m, v;
175
176 m = pwrdm->mem_retst_mask[bank];
177 if (!m)
178 return -EINVAL;
179
180 v = am33xx_prm_read_reg(pwrdm->prcm_offs, pwrdm->pwrstctrl_offs);
181 v &= m;
182 v >>= __ffs(m);
183
184 return v;
185}
186
187static int am33xx_pwrdm_wait_transition(struct powerdomain *pwrdm)
188{
189 u32 c = 0;
190
191 /*
192 * REVISIT: pwrdm_wait_transition() may be better implemented
193 * via a callback and a periodic timer check -- how long do we expect
194 * powerdomain transitions to take?
195 */
196
197 /* XXX Is this udelay() value meaningful? */
198 while ((am33xx_prm_read_reg(pwrdm->prcm_offs, pwrdm->pwrstst_offs)
199 & OMAP_INTRANSITION_MASK) &&
200 (c++ < PWRDM_TRANSITION_BAILOUT))
201 udelay(1);
202
203 if (c > PWRDM_TRANSITION_BAILOUT) {
204 pr_err("powerdomain: %s: waited too long to complete transition\n",
205 pwrdm->name);
206 return -EAGAIN;
207 }
208
209 pr_debug("powerdomain: completed transition in %d loops\n", c);
210
211 return 0;
212}
213
214struct pwrdm_ops am33xx_pwrdm_operations = {
215 .pwrdm_set_next_pwrst = am33xx_pwrdm_set_next_pwrst,
216 .pwrdm_read_next_pwrst = am33xx_pwrdm_read_next_pwrst,
217 .pwrdm_read_pwrst = am33xx_pwrdm_read_pwrst,
218 .pwrdm_read_prev_pwrst = am33xx_pwrdm_read_prev_pwrst,
219 .pwrdm_set_logic_retst = am33xx_pwrdm_set_logic_retst,
220 .pwrdm_read_logic_pwrst = am33xx_pwrdm_read_logic_pwrst,
221 .pwrdm_read_logic_retst = am33xx_pwrdm_read_logic_retst,
222 .pwrdm_clear_all_prev_pwrst = am33xx_pwrdm_clear_all_prev_pwrst,
223 .pwrdm_set_lowpwrstchange = am33xx_pwrdm_set_lowpwrstchange,
224 .pwrdm_read_mem_pwrst = am33xx_pwrdm_read_mem_pwrst,
225 .pwrdm_read_mem_retst = am33xx_pwrdm_read_mem_retst,
226 .pwrdm_set_mem_onst = am33xx_pwrdm_set_mem_onst,
227 .pwrdm_set_mem_retst = am33xx_pwrdm_set_mem_retst,
228 .pwrdm_wait_transition = am33xx_pwrdm_wait_transition,
229};
diff --git a/arch/arm/mach-omap2/powerdomains33xx_data.c b/arch/arm/mach-omap2/powerdomains33xx_data.c
new file mode 100644
index 00000000000..869adb82569
--- /dev/null
+++ b/arch/arm/mach-omap2/powerdomains33xx_data.c
@@ -0,0 +1,185 @@
1/*
2 * AM33XX Power domain data
3 *
4 * Copyright (C) 2011-2012 Texas Instruments Incorporated - http://www.ti.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 as
8 * published by the Free Software Foundation version 2.
9 *
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/kernel.h>
17#include <linux/init.h>
18
19#include "powerdomain.h"
20#include "prcm-common.h"
21#include "prm-regbits-33xx.h"
22#include "prm33xx.h"
23
24static struct powerdomain gfx_33xx_pwrdm = {
25 .name = "gfx_pwrdm",
26 .voltdm = { .name = "core" },
27 .prcm_offs = AM33XX_PRM_GFX_MOD,
28 .pwrstctrl_offs = AM33XX_PM_GFX_PWRSTCTRL_OFFSET,
29 .pwrstst_offs = AM33XX_PM_GFX_PWRSTST_OFFSET,
30 .pwrsts = PWRSTS_OFF_RET_ON,
31 .pwrsts_logic_ret = PWRSTS_OFF_RET,
32 .flags = PWRDM_HAS_LOWPOWERSTATECHANGE,
33 .banks = 1,
34 .logicretstate_mask = AM33XX_LOGICRETSTATE_MASK,
35 .mem_on_mask = {
36 [0] = AM33XX_GFX_MEM_ONSTATE_MASK, /* gfx_mem */
37 },
38 .mem_ret_mask = {
39 [0] = AM33XX_GFX_MEM_RETSTATE_MASK, /* gfx_mem */
40 },
41 .mem_pwrst_mask = {
42 [0] = AM33XX_GFX_MEM_STATEST_MASK, /* gfx_mem */
43 },
44 .mem_retst_mask = {
45 [0] = AM33XX_GFX_MEM_RETSTATE_MASK, /* gfx_mem */
46 },
47 .pwrsts_mem_ret = {
48 [0] = PWRSTS_OFF_RET, /* gfx_mem */
49 },
50 .pwrsts_mem_on = {
51 [0] = PWRSTS_ON, /* gfx_mem */
52 },
53};
54
55static struct powerdomain rtc_33xx_pwrdm = {
56 .name = "rtc_pwrdm",
57 .voltdm = { .name = "rtc" },
58 .prcm_offs = AM33XX_PRM_RTC_MOD,
59 .pwrstctrl_offs = AM33XX_PM_RTC_PWRSTCTRL_OFFSET,
60 .pwrstst_offs = AM33XX_PM_RTC_PWRSTST_OFFSET,
61 .pwrsts = PWRSTS_ON,
62 .logicretstate_mask = AM33XX_LOGICRETSTATE_MASK,
63};
64
65static struct powerdomain wkup_33xx_pwrdm = {
66 .name = "wkup_pwrdm",
67 .voltdm = { .name = "core" },
68 .prcm_offs = AM33XX_PRM_WKUP_MOD,
69 .pwrstctrl_offs = AM33XX_PM_WKUP_PWRSTCTRL_OFFSET,
70 .pwrstst_offs = AM33XX_PM_WKUP_PWRSTST_OFFSET,
71 .pwrsts = PWRSTS_ON,
72 .logicretstate_mask = AM33XX_LOGICRETSTATE_3_3_MASK,
73};
74
75static struct powerdomain per_33xx_pwrdm = {
76 .name = "per_pwrdm",
77 .voltdm = { .name = "core" },
78 .prcm_offs = AM33XX_PRM_PER_MOD,
79 .pwrstctrl_offs = AM33XX_PM_PER_PWRSTCTRL_OFFSET,
80 .pwrstst_offs = AM33XX_PM_PER_PWRSTST_OFFSET,
81 .pwrsts = PWRSTS_OFF_RET_ON,
82 .pwrsts_logic_ret = PWRSTS_OFF_RET,
83 .flags = PWRDM_HAS_LOWPOWERSTATECHANGE,
84 .banks = 3,
85 .logicretstate_mask = AM33XX_LOGICRETSTATE_3_3_MASK,
86 .mem_on_mask = {
87 [0] = AM33XX_PRUSS_MEM_ONSTATE_MASK, /* pruss_mem */
88 [1] = AM33XX_PER_MEM_ONSTATE_MASK, /* per_mem */
89 [2] = AM33XX_RAM_MEM_ONSTATE_MASK, /* ram_mem */
90 },
91 .mem_ret_mask = {
92 [0] = AM33XX_PRUSS_MEM_RETSTATE_MASK, /* pruss_mem */
93 [1] = AM33XX_PER_MEM_RETSTATE_MASK, /* per_mem */
94 [2] = AM33XX_RAM_MEM_RETSTATE_MASK, /* ram_mem */
95 },
96 .mem_pwrst_mask = {
97 [0] = AM33XX_PRUSS_MEM_STATEST_MASK, /* pruss_mem */
98 [1] = AM33XX_PER_MEM_STATEST_MASK, /* per_mem */
99 [2] = AM33XX_RAM_MEM_STATEST_MASK, /* ram_mem */
100 },
101 .mem_retst_mask = {
102 [0] = AM33XX_PRUSS_MEM_RETSTATE_MASK, /* pruss_mem */
103 [1] = AM33XX_PER_MEM_RETSTATE_MASK, /* per_mem */
104 [2] = AM33XX_RAM_MEM_RETSTATE_MASK, /* ram_mem */
105 },
106 .pwrsts_mem_ret = {
107 [0] = PWRSTS_OFF_RET, /* pruss_mem */
108 [1] = PWRSTS_OFF_RET, /* per_mem */
109 [2] = PWRSTS_OFF_RET, /* ram_mem */
110 },
111 .pwrsts_mem_on = {
112 [0] = PWRSTS_ON, /* pruss_mem */
113 [1] = PWRSTS_ON, /* per_mem */
114 [2] = PWRSTS_ON, /* ram_mem */
115 },
116};
117
118static struct powerdomain mpu_33xx_pwrdm = {
119 .name = "mpu_pwrdm",
120 .voltdm = { .name = "mpu" },
121 .prcm_offs = AM33XX_PRM_MPU_MOD,
122 .pwrstctrl_offs = AM33XX_PM_MPU_PWRSTCTRL_OFFSET,
123 .pwrstst_offs = AM33XX_PM_MPU_PWRSTST_OFFSET,
124 .pwrsts = PWRSTS_OFF_RET_ON,
125 .pwrsts_logic_ret = PWRSTS_OFF_RET,
126 .flags = PWRDM_HAS_LOWPOWERSTATECHANGE,
127 .banks = 3,
128 .logicretstate_mask = AM33XX_LOGICRETSTATE_MASK,
129 .mem_on_mask = {
130 [0] = AM33XX_MPU_L1_ONSTATE_MASK, /* mpu_l1 */
131 [1] = AM33XX_MPU_L2_ONSTATE_MASK, /* mpu_l2 */
132 [2] = AM33XX_MPU_RAM_ONSTATE_MASK, /* mpu_ram */
133 },
134 .mem_ret_mask = {
135 [0] = AM33XX_MPU_L1_RETSTATE_MASK, /* mpu_l1 */
136 [1] = AM33XX_MPU_L2_RETSTATE_MASK, /* mpu_l2 */
137 [2] = AM33XX_MPU_RAM_RETSTATE_MASK, /* mpu_ram */
138 },
139 .mem_pwrst_mask = {
140 [0] = AM33XX_MPU_L1_STATEST_MASK, /* mpu_l1 */
141 [1] = AM33XX_MPU_L2_STATEST_MASK, /* mpu_l2 */
142 [2] = AM33XX_MPU_RAM_STATEST_MASK, /* mpu_ram */
143 },
144 .mem_retst_mask = {
145 [0] = AM33XX_MPU_L1_RETSTATE_MASK, /* mpu_l1 */
146 [1] = AM33XX_MPU_L2_RETSTATE_MASK, /* mpu_l2 */
147 [2] = AM33XX_MPU_RAM_RETSTATE_MASK, /* mpu_ram */
148 },
149 .pwrsts_mem_ret = {
150 [0] = PWRSTS_OFF_RET, /* mpu_l1 */
151 [1] = PWRSTS_OFF_RET, /* mpu_l2 */
152 [2] = PWRSTS_OFF_RET, /* mpu_ram */
153 },
154 .pwrsts_mem_on = {
155 [0] = PWRSTS_ON, /* mpu_l1 */
156 [1] = PWRSTS_ON, /* mpu_l2 */
157 [2] = PWRSTS_ON, /* mpu_ram */
158 },
159};
160
161static struct powerdomain cefuse_33xx_pwrdm = {
162 .name = "cefuse_pwrdm",
163 .voltdm = { .name = "core" },
164 .prcm_offs = AM33XX_PRM_CEFUSE_MOD,
165 .pwrstctrl_offs = AM33XX_PM_CEFUSE_PWRSTCTRL_OFFSET,
166 .pwrstst_offs = AM33XX_PM_CEFUSE_PWRSTST_OFFSET,
167 .pwrsts = PWRSTS_OFF_ON,
168};
169
170static struct powerdomain *powerdomains_am33xx[] __initdata = {
171 &gfx_33xx_pwrdm,
172 &rtc_33xx_pwrdm,
173 &wkup_33xx_pwrdm,
174 &per_33xx_pwrdm,
175 &mpu_33xx_pwrdm,
176 &cefuse_33xx_pwrdm,
177 NULL,
178};
179
180void __init am33xx_powerdomains_init(void)
181{
182 pwrdm_register_platform_funcs(&am33xx_pwrdm_operations);
183 pwrdm_register_pwrdms(powerdomains_am33xx);
184 pwrdm_complete_init();
185}
diff --git a/arch/arm/mach-omap2/powerdomains3xxx_data.c b/arch/arm/mach-omap2/powerdomains3xxx_data.c
index fb0a0a6869d..bb883e46307 100644
--- a/arch/arm/mach-omap2/powerdomains3xxx_data.c
+++ b/arch/arm/mach-omap2/powerdomains3xxx_data.c
@@ -71,6 +71,22 @@ static struct powerdomain mpu_3xxx_pwrdm = {
71 .voltdm = { .name = "mpu_iva" }, 71 .voltdm = { .name = "mpu_iva" },
72}; 72};
73 73
74static struct powerdomain mpu_am35x_pwrdm = {
75 .name = "mpu_pwrdm",
76 .prcm_offs = MPU_MOD,
77 .pwrsts = PWRSTS_ON,
78 .pwrsts_logic_ret = PWRSTS_ON,
79 .flags = PWRDM_HAS_MPU_QUIRK,
80 .banks = 1,
81 .pwrsts_mem_ret = {
82 [0] = PWRSTS_ON,
83 },
84 .pwrsts_mem_on = {
85 [0] = PWRSTS_ON,
86 },
87 .voltdm = { .name = "mpu_iva" },
88};
89
74/* 90/*
75 * The USBTLL Save-and-Restore mechanism is broken on 91 * The USBTLL Save-and-Restore mechanism is broken on
76 * 3430s up to ES3.0 and 3630ES1.0. Hence this feature 92 * 3430s up to ES3.0 and 3630ES1.0. Hence this feature
@@ -120,6 +136,23 @@ static struct powerdomain core_3xxx_es3_1_pwrdm = {
120 .voltdm = { .name = "core" }, 136 .voltdm = { .name = "core" },
121}; 137};
122 138
139static struct powerdomain core_am35x_pwrdm = {
140 .name = "core_pwrdm",
141 .prcm_offs = CORE_MOD,
142 .pwrsts = PWRSTS_ON,
143 .pwrsts_logic_ret = PWRSTS_ON,
144 .banks = 2,
145 .pwrsts_mem_ret = {
146 [0] = PWRSTS_ON, /* MEM1RETSTATE */
147 [1] = PWRSTS_ON, /* MEM2RETSTATE */
148 },
149 .pwrsts_mem_on = {
150 [0] = PWRSTS_ON, /* MEM1ONSTATE */
151 [1] = PWRSTS_ON, /* MEM2ONSTATE */
152 },
153 .voltdm = { .name = "core" },
154};
155
123static struct powerdomain dss_pwrdm = { 156static struct powerdomain dss_pwrdm = {
124 .name = "dss_pwrdm", 157 .name = "dss_pwrdm",
125 .prcm_offs = OMAP3430_DSS_MOD, 158 .prcm_offs = OMAP3430_DSS_MOD,
@@ -135,6 +168,21 @@ static struct powerdomain dss_pwrdm = {
135 .voltdm = { .name = "core" }, 168 .voltdm = { .name = "core" },
136}; 169};
137 170
171static struct powerdomain dss_am35x_pwrdm = {
172 .name = "dss_pwrdm",
173 .prcm_offs = OMAP3430_DSS_MOD,
174 .pwrsts = PWRSTS_ON,
175 .pwrsts_logic_ret = PWRSTS_ON,
176 .banks = 1,
177 .pwrsts_mem_ret = {
178 [0] = PWRSTS_ON, /* MEMRETSTATE */
179 },
180 .pwrsts_mem_on = {
181 [0] = PWRSTS_ON, /* MEMONSTATE */
182 },
183 .voltdm = { .name = "core" },
184};
185
138/* 186/*
139 * Although the 34XX TRM Rev K Table 4-371 notes that retention is a 187 * Although the 34XX TRM Rev K Table 4-371 notes that retention is a
140 * possible SGX powerstate, the SGX device itself does not support 188 * possible SGX powerstate, the SGX device itself does not support
@@ -156,6 +204,21 @@ static struct powerdomain sgx_pwrdm = {
156 .voltdm = { .name = "core" }, 204 .voltdm = { .name = "core" },
157}; 205};
158 206
207static struct powerdomain sgx_am35x_pwrdm = {
208 .name = "sgx_pwrdm",
209 .prcm_offs = OMAP3430ES2_SGX_MOD,
210 .pwrsts = PWRSTS_ON,
211 .pwrsts_logic_ret = PWRSTS_ON,
212 .banks = 1,
213 .pwrsts_mem_ret = {
214 [0] = PWRSTS_ON, /* MEMRETSTATE */
215 },
216 .pwrsts_mem_on = {
217 [0] = PWRSTS_ON, /* MEMONSTATE */
218 },
219 .voltdm = { .name = "core" },
220};
221
159static struct powerdomain cam_pwrdm = { 222static struct powerdomain cam_pwrdm = {
160 .name = "cam_pwrdm", 223 .name = "cam_pwrdm",
161 .prcm_offs = OMAP3430_CAM_MOD, 224 .prcm_offs = OMAP3430_CAM_MOD,
@@ -186,6 +249,21 @@ static struct powerdomain per_pwrdm = {
186 .voltdm = { .name = "core" }, 249 .voltdm = { .name = "core" },
187}; 250};
188 251
252static struct powerdomain per_am35x_pwrdm = {
253 .name = "per_pwrdm",
254 .prcm_offs = OMAP3430_PER_MOD,
255 .pwrsts = PWRSTS_ON,
256 .pwrsts_logic_ret = PWRSTS_ON,
257 .banks = 1,
258 .pwrsts_mem_ret = {
259 [0] = PWRSTS_ON, /* MEMRETSTATE */
260 },
261 .pwrsts_mem_on = {
262 [0] = PWRSTS_ON, /* MEMONSTATE */
263 },
264 .voltdm = { .name = "core" },
265};
266
189static struct powerdomain emu_pwrdm = { 267static struct powerdomain emu_pwrdm = {
190 .name = "emu_pwrdm", 268 .name = "emu_pwrdm",
191 .prcm_offs = OMAP3430_EMU_MOD, 269 .prcm_offs = OMAP3430_EMU_MOD,
@@ -200,6 +278,14 @@ static struct powerdomain neon_pwrdm = {
200 .voltdm = { .name = "mpu_iva" }, 278 .voltdm = { .name = "mpu_iva" },
201}; 279};
202 280
281static struct powerdomain neon_am35x_pwrdm = {
282 .name = "neon_pwrdm",
283 .prcm_offs = OMAP3430_NEON_MOD,
284 .pwrsts = PWRSTS_ON,
285 .pwrsts_logic_ret = PWRSTS_ON,
286 .voltdm = { .name = "mpu_iva" },
287};
288
203static struct powerdomain usbhost_pwrdm = { 289static struct powerdomain usbhost_pwrdm = {
204 .name = "usbhost_pwrdm", 290 .name = "usbhost_pwrdm",
205 .prcm_offs = OMAP3430ES2_USBHOST_MOD, 291 .prcm_offs = OMAP3430ES2_USBHOST_MOD,
@@ -293,6 +379,22 @@ static struct powerdomain *powerdomains_omap3430es3_1plus[] __initdata = {
293 NULL 379 NULL
294}; 380};
295 381
382static struct powerdomain *powerdomains_am35x[] __initdata = {
383 &wkup_omap2_pwrdm,
384 &mpu_am35x_pwrdm,
385 &neon_am35x_pwrdm,
386 &core_am35x_pwrdm,
387 &sgx_am35x_pwrdm,
388 &dss_am35x_pwrdm,
389 &per_am35x_pwrdm,
390 &emu_pwrdm,
391 &dpll1_pwrdm,
392 &dpll3_pwrdm,
393 &dpll4_pwrdm,
394 &dpll5_pwrdm,
395 NULL
396};
397
296void __init omap3xxx_powerdomains_init(void) 398void __init omap3xxx_powerdomains_init(void)
297{ 399{
298 unsigned int rev; 400 unsigned int rev;
@@ -301,21 +403,34 @@ void __init omap3xxx_powerdomains_init(void)
301 return; 403 return;
302 404
303 pwrdm_register_platform_funcs(&omap3_pwrdm_operations); 405 pwrdm_register_platform_funcs(&omap3_pwrdm_operations);
304 pwrdm_register_pwrdms(powerdomains_omap3430_common);
305 406
306 rev = omap_rev(); 407 rev = omap_rev();
307 408
308 if (rev == OMAP3430_REV_ES1_0) 409 if (rev == AM35XX_REV_ES1_0 || rev == AM35XX_REV_ES1_1) {
309 pwrdm_register_pwrdms(powerdomains_omap3430es1); 410 pwrdm_register_pwrdms(powerdomains_am35x);
310 else if (rev == OMAP3430_REV_ES2_0 || rev == OMAP3430_REV_ES2_1 || 411 } else {
311 rev == OMAP3430_REV_ES3_0 || rev == OMAP3630_REV_ES1_0) 412 pwrdm_register_pwrdms(powerdomains_omap3430_common);
312 pwrdm_register_pwrdms(powerdomains_omap3430es2_es3_0); 413
313 else if (rev == OMAP3430_REV_ES3_1 || rev == OMAP3430_REV_ES3_1_2 || 414 switch (rev) {
314 rev == AM35XX_REV_ES1_0 || rev == AM35XX_REV_ES1_1 || 415 case OMAP3430_REV_ES1_0:
315 rev == OMAP3630_REV_ES1_1 || rev == OMAP3630_REV_ES1_2) 416 pwrdm_register_pwrdms(powerdomains_omap3430es1);
316 pwrdm_register_pwrdms(powerdomains_omap3430es3_1plus); 417 break;
317 else 418 case OMAP3430_REV_ES2_0:
318 WARN(1, "OMAP3 powerdomain init: unknown chip type\n"); 419 case OMAP3430_REV_ES2_1:
420 case OMAP3430_REV_ES3_0:
421 case OMAP3630_REV_ES1_0:
422 pwrdm_register_pwrdms(powerdomains_omap3430es2_es3_0);
423 break;
424 case OMAP3430_REV_ES3_1:
425 case OMAP3430_REV_ES3_1_2:
426 case OMAP3630_REV_ES1_1:
427 case OMAP3630_REV_ES1_2:
428 pwrdm_register_pwrdms(powerdomains_omap3430es3_1plus);
429 break;
430 default:
431 WARN(1, "OMAP3 powerdomain init: unknown chip type\n");
432 }
433 }
319 434
320 pwrdm_complete_init(); 435 pwrdm_complete_init();
321} 436}
diff --git a/arch/arm/mach-omap2/prcm-common.h b/arch/arm/mach-omap2/prcm-common.h
index 6da3ba483ad..e5f0503a68b 100644
--- a/arch/arm/mach-omap2/prcm-common.h
+++ b/arch/arm/mach-omap2/prcm-common.h
@@ -203,8 +203,8 @@
203#define OMAP3430_EN_MMC2_SHIFT 25 203#define OMAP3430_EN_MMC2_SHIFT 25
204#define OMAP3430_EN_MMC1_MASK (1 << 24) 204#define OMAP3430_EN_MMC1_MASK (1 << 24)
205#define OMAP3430_EN_MMC1_SHIFT 24 205#define OMAP3430_EN_MMC1_SHIFT 24
206#define OMAP3430_EN_UART4_MASK (1 << 23) 206#define AM35XX_EN_UART4_MASK (1 << 23)
207#define OMAP3430_EN_UART4_SHIFT 23 207#define AM35XX_EN_UART4_SHIFT 23
208#define OMAP3430_EN_MCSPI4_MASK (1 << 21) 208#define OMAP3430_EN_MCSPI4_MASK (1 << 21)
209#define OMAP3430_EN_MCSPI4_SHIFT 21 209#define OMAP3430_EN_MCSPI4_SHIFT 21
210#define OMAP3430_EN_MCSPI3_MASK (1 << 20) 210#define OMAP3430_EN_MCSPI3_MASK (1 << 20)
@@ -410,13 +410,21 @@
410 */ 410 */
411#define MAX_MODULE_HARDRESET_WAIT 10000 411#define MAX_MODULE_HARDRESET_WAIT 10000
412 412
413/*
414 * Maximum time(us) it takes to output the signal WUCLKOUT of the last
415 * pad of the I/O ring after asserting WUCLKIN high. Tero measured
416 * the actual time at 7 to 8 microseconds on OMAP3 and 2 to 4
417 * microseconds on OMAP4, so this timeout may be too high.
418 */
419#define MAX_IOPAD_LATCH_TIME 100
420
413# ifndef __ASSEMBLER__ 421# ifndef __ASSEMBLER__
414extern void __iomem *prm_base; 422extern void __iomem *prm_base;
415extern void __iomem *cm_base; 423extern void __iomem *cm_base;
416extern void __iomem *cm2_base; 424extern void __iomem *cm2_base;
417extern void __iomem *prcm_mpu_base; 425extern void __iomem *prcm_mpu_base;
418 426
419#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_ARCH_OMAP5) 427#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5)
420extern void omap_prm_base_init(void); 428extern void omap_prm_base_init(void);
421extern void omap_cm_base_init(void); 429extern void omap_cm_base_init(void);
422#else 430#else
diff --git a/arch/arm/mach-omap2/prcm.c b/arch/arm/mach-omap2/prcm.c
index 480f40a5ee4..053e24ed3c4 100644
--- a/arch/arm/mach-omap2/prcm.c
+++ b/arch/arm/mach-omap2/prcm.c
@@ -35,6 +35,7 @@
35#include "prm2xxx_3xxx.h" 35#include "prm2xxx_3xxx.h"
36#include "prm44xx.h" 36#include "prm44xx.h"
37#include "prminst44xx.h" 37#include "prminst44xx.h"
38#include "cminst44xx.h"
38#include "prm-regbits-24xx.h" 39#include "prm-regbits-24xx.h"
39#include "prm-regbits-44xx.h" 40#include "prm-regbits-44xx.h"
40#include "control.h" 41#include "control.h"
@@ -159,8 +160,30 @@ void __init omap2_set_globals_prcm(struct omap_globals *omap2_globals)
159 if (omap2_globals->prcm_mpu) 160 if (omap2_globals->prcm_mpu)
160 prcm_mpu_base = omap2_globals->prcm_mpu; 161 prcm_mpu_base = omap2_globals->prcm_mpu;
161 162
162 if (cpu_is_omap44xx()) { 163 if (cpu_is_omap44xx() || soc_is_omap54xx()) {
163 omap_prm_base_init(); 164 omap_prm_base_init();
164 omap_cm_base_init(); 165 omap_cm_base_init();
165 } 166 }
166} 167}
168
169/*
170 * Stubbed functions so that common files continue to build when
171 * custom builds are used
172 * XXX These are temporary and should be removed at the earliest possible
173 * opportunity
174 */
175int __weak omap4_cminst_wait_module_idle(u8 part, u16 inst, s16 cdoffs,
176 u16 clkctrl_offs)
177{
178 return 0;
179}
180
181void __weak omap4_cminst_module_enable(u8 mode, u8 part, u16 inst,
182 s16 cdoffs, u16 clkctrl_offs)
183{
184}
185
186void __weak omap4_cminst_module_disable(u8 part, u16 inst, s16 cdoffs,
187 u16 clkctrl_offs)
188{
189}
diff --git a/arch/arm/mach-omap2/prm-regbits-33xx.h b/arch/arm/mach-omap2/prm-regbits-33xx.h
new file mode 100644
index 00000000000..0221b5c20e8
--- /dev/null
+++ b/arch/arm/mach-omap2/prm-regbits-33xx.h
@@ -0,0 +1,357 @@
1/*
2 * AM33XX PRM_XXX register bits
3 *
4 * Copyright (C) 2011-2012 Texas Instruments Incorporated - http://www.ti.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 as
8 * published by the Free Software Foundation version 2.
9 *
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef __ARCH_ARM_MACH_OMAP2_PRM_REGBITS_33XX_H
17#define __ARCH_ARM_MACH_OMAP2_PRM_REGBITS_33XX_H
18
19#include "prm.h"
20
21/* Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_MPU_SETUP */
22#define AM33XX_ABBOFF_ACT_EXPORT_SHIFT 1
23#define AM33XX_ABBOFF_ACT_EXPORT_MASK (1 << 1)
24
25/* Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_MPU_SETUP */
26#define AM33XX_ABBOFF_SLEEP_EXPORT_SHIFT 2
27#define AM33XX_ABBOFF_SLEEP_EXPORT_MASK (1 << 2)
28
29/* Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_MPU_SETUP */
30#define AM33XX_AIPOFF_SHIFT 8
31#define AM33XX_AIPOFF_MASK (1 << 8)
32
33/* Used by PM_WKUP_PWRSTST */
34#define AM33XX_DEBUGSS_MEM_STATEST_SHIFT 17
35#define AM33XX_DEBUGSS_MEM_STATEST_MASK (0x3 << 17)
36
37/* Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_MPU_SETUP */
38#define AM33XX_DISABLE_RTA_EXPORT_SHIFT 0
39#define AM33XX_DISABLE_RTA_EXPORT_MASK (1 << 0)
40
41/* Used by PRM_IRQENABLE_M3, PRM_IRQENABLE_MPU */
42#define AM33XX_DPLL_CORE_RECAL_EN_SHIFT 12
43#define AM33XX_DPLL_CORE_RECAL_EN_MASK (1 << 12)
44
45/* Used by PRM_IRQSTATUS_M3, PRM_IRQSTATUS_MPU */
46#define AM33XX_DPLL_CORE_RECAL_ST_SHIFT 12
47#define AM33XX_DPLL_CORE_RECAL_ST_MASK (1 << 12)
48
49/* Used by PRM_IRQENABLE_M3, PRM_IRQENABLE_MPU */
50#define AM33XX_DPLL_DDR_RECAL_EN_SHIFT 14
51#define AM33XX_DPLL_DDR_RECAL_EN_MASK (1 << 14)
52
53/* Used by PRM_IRQSTATUS_M3, PRM_IRQSTATUS_MPU */
54#define AM33XX_DPLL_DDR_RECAL_ST_SHIFT 14
55#define AM33XX_DPLL_DDR_RECAL_ST_MASK (1 << 14)
56
57/* Used by PRM_IRQENABLE_M3, PRM_IRQENABLE_MPU */
58#define AM33XX_DPLL_DISP_RECAL_EN_SHIFT 15
59#define AM33XX_DPLL_DISP_RECAL_EN_MASK (1 << 15)
60
61/* Used by PRM_IRQSTATUS_M3, PRM_IRQSTATUS_MPU */
62#define AM33XX_DPLL_DISP_RECAL_ST_SHIFT 13
63#define AM33XX_DPLL_DISP_RECAL_ST_MASK (1 << 13)
64
65/* Used by PRM_IRQENABLE_M3, PRM_IRQENABLE_MPU */
66#define AM33XX_DPLL_MPU_RECAL_EN_SHIFT 11
67#define AM33XX_DPLL_MPU_RECAL_EN_MASK (1 << 11)
68
69/* Used by PRM_IRQSTATUS_M3, PRM_IRQSTATUS_MPU */
70#define AM33XX_DPLL_MPU_RECAL_ST_SHIFT 11
71#define AM33XX_DPLL_MPU_RECAL_ST_MASK (1 << 11)
72
73/* Used by PRM_IRQENABLE_M3, PRM_IRQENABLE_MPU */
74#define AM33XX_DPLL_PER_RECAL_EN_SHIFT 13
75#define AM33XX_DPLL_PER_RECAL_EN_MASK (1 << 13)
76
77/* Used by PRM_IRQSTATUS_M3, PRM_IRQSTATUS_MPU */
78#define AM33XX_DPLL_PER_RECAL_ST_SHIFT 15
79#define AM33XX_DPLL_PER_RECAL_ST_MASK (1 << 15)
80
81/* Used by RM_WKUP_RSTST */
82#define AM33XX_EMULATION_M3_RST_SHIFT 6
83#define AM33XX_EMULATION_M3_RST_MASK (1 << 6)
84
85/* Used by RM_MPU_RSTST */
86#define AM33XX_EMULATION_MPU_RST_SHIFT 5
87#define AM33XX_EMULATION_MPU_RST_MASK (1 << 5)
88
89/* Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_MPU_SETUP */
90#define AM33XX_ENFUNC1_EXPORT_SHIFT 3
91#define AM33XX_ENFUNC1_EXPORT_MASK (1 << 3)
92
93/* Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_MPU_SETUP */
94#define AM33XX_ENFUNC3_EXPORT_SHIFT 5
95#define AM33XX_ENFUNC3_EXPORT_MASK (1 << 5)
96
97/* Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_MPU_SETUP */
98#define AM33XX_ENFUNC4_SHIFT 6
99#define AM33XX_ENFUNC4_MASK (1 << 6)
100
101/* Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_MPU_SETUP */
102#define AM33XX_ENFUNC5_SHIFT 7
103#define AM33XX_ENFUNC5_MASK (1 << 7)
104
105/* Used by PRM_RSTST */
106#define AM33XX_EXTERNAL_WARM_RST_SHIFT 5
107#define AM33XX_EXTERNAL_WARM_RST_MASK (1 << 5)
108
109/* Used by PRM_IRQENABLE_M3, PRM_IRQENABLE_MPU */
110#define AM33XX_FORCEWKUP_EN_SHIFT 10
111#define AM33XX_FORCEWKUP_EN_MASK (1 << 10)
112
113/* Used by PRM_IRQSTATUS_M3, PRM_IRQSTATUS_MPU */
114#define AM33XX_FORCEWKUP_ST_SHIFT 10
115#define AM33XX_FORCEWKUP_ST_MASK (1 << 10)
116
117/* Used by PM_GFX_PWRSTCTRL */
118#define AM33XX_GFX_MEM_ONSTATE_SHIFT 17
119#define AM33XX_GFX_MEM_ONSTATE_MASK (0x3 << 17)
120
121/* Used by PM_GFX_PWRSTCTRL */
122#define AM33XX_GFX_MEM_RETSTATE_SHIFT 6
123#define AM33XX_GFX_MEM_RETSTATE_MASK (1 << 6)
124
125/* Used by PM_GFX_PWRSTST */
126#define AM33XX_GFX_MEM_STATEST_SHIFT 4
127#define AM33XX_GFX_MEM_STATEST_MASK (0x3 << 4)
128
129/* Used by RM_GFX_RSTCTRL, RM_GFX_RSTST */
130#define AM33XX_GFX_RST_SHIFT 0
131#define AM33XX_GFX_RST_MASK (1 << 0)
132
133/* Used by PRM_RSTST */
134#define AM33XX_GLOBAL_COLD_RST_SHIFT 0
135#define AM33XX_GLOBAL_COLD_RST_MASK (1 << 0)
136
137/* Used by PRM_RSTST */
138#define AM33XX_GLOBAL_WARM_SW_RST_SHIFT 1
139#define AM33XX_GLOBAL_WARM_SW_RST_MASK (1 << 1)
140
141/* Used by RM_WKUP_RSTST */
142#define AM33XX_ICECRUSHER_M3_RST_SHIFT 7
143#define AM33XX_ICECRUSHER_M3_RST_MASK (1 << 7)
144
145/* Used by RM_MPU_RSTST */
146#define AM33XX_ICECRUSHER_MPU_RST_SHIFT 6
147#define AM33XX_ICECRUSHER_MPU_RST_MASK (1 << 6)
148
149/* Used by PRM_RSTST */
150#define AM33XX_ICEPICK_RST_SHIFT 9
151#define AM33XX_ICEPICK_RST_MASK (1 << 9)
152
153/* Used by RM_PER_RSTCTRL */
154#define AM33XX_PRUSS_LRST_SHIFT 1
155#define AM33XX_PRUSS_LRST_MASK (1 << 1)
156
157/* Used by PM_PER_PWRSTCTRL */
158#define AM33XX_PRUSS_MEM_ONSTATE_SHIFT 5
159#define AM33XX_PRUSS_MEM_ONSTATE_MASK (0x3 << 5)
160
161/* Used by PM_PER_PWRSTCTRL */
162#define AM33XX_PRUSS_MEM_RETSTATE_SHIFT 7
163#define AM33XX_PRUSS_MEM_RETSTATE_MASK (1 << 7)
164
165/* Used by PM_PER_PWRSTST */
166#define AM33XX_PRUSS_MEM_STATEST_SHIFT 23
167#define AM33XX_PRUSS_MEM_STATEST_MASK (0x3 << 23)
168
169/*
170 * Used by PM_GFX_PWRSTST, PM_CEFUSE_PWRSTST, PM_PER_PWRSTST, PM_MPU_PWRSTST,
171 * PM_WKUP_PWRSTST, PM_RTC_PWRSTST
172 */
173#define AM33XX_INTRANSITION_SHIFT 20
174#define AM33XX_INTRANSITION_MASK (1 << 20)
175
176/* Used by PM_CEFUSE_PWRSTST */
177#define AM33XX_LASTPOWERSTATEENTERED_SHIFT 24
178#define AM33XX_LASTPOWERSTATEENTERED_MASK (0x3 << 24)
179
180/* Used by PM_GFX_PWRSTCTRL, PM_MPU_PWRSTCTRL, PM_RTC_PWRSTCTRL */
181#define AM33XX_LOGICRETSTATE_SHIFT 2
182#define AM33XX_LOGICRETSTATE_MASK (1 << 2)
183
184/* Renamed from LOGICRETSTATE Used by PM_PER_PWRSTCTRL, PM_WKUP_PWRSTCTRL */
185#define AM33XX_LOGICRETSTATE_3_3_SHIFT 3
186#define AM33XX_LOGICRETSTATE_3_3_MASK (1 << 3)
187
188/*
189 * Used by PM_GFX_PWRSTST, PM_CEFUSE_PWRSTST, PM_PER_PWRSTST, PM_MPU_PWRSTST,
190 * PM_WKUP_PWRSTST, PM_RTC_PWRSTST
191 */
192#define AM33XX_LOGICSTATEST_SHIFT 2
193#define AM33XX_LOGICSTATEST_MASK (1 << 2)
194
195/*
196 * Used by PM_GFX_PWRSTCTRL, PM_CEFUSE_PWRSTCTRL, PM_PER_PWRSTCTRL,
197 * PM_MPU_PWRSTCTRL, PM_WKUP_PWRSTCTRL, PM_RTC_PWRSTCTRL
198 */
199#define AM33XX_LOWPOWERSTATECHANGE_SHIFT 4
200#define AM33XX_LOWPOWERSTATECHANGE_MASK (1 << 4)
201
202/* Used by PM_MPU_PWRSTCTRL */
203#define AM33XX_MPU_L1_ONSTATE_SHIFT 18
204#define AM33XX_MPU_L1_ONSTATE_MASK (0x3 << 18)
205
206/* Used by PM_MPU_PWRSTCTRL */
207#define AM33XX_MPU_L1_RETSTATE_SHIFT 22
208#define AM33XX_MPU_L1_RETSTATE_MASK (1 << 22)
209
210/* Used by PM_MPU_PWRSTST */
211#define AM33XX_MPU_L1_STATEST_SHIFT 6
212#define AM33XX_MPU_L1_STATEST_MASK (0x3 << 6)
213
214/* Used by PM_MPU_PWRSTCTRL */
215#define AM33XX_MPU_L2_ONSTATE_SHIFT 20
216#define AM33XX_MPU_L2_ONSTATE_MASK (0x3 << 20)
217
218/* Used by PM_MPU_PWRSTCTRL */
219#define AM33XX_MPU_L2_RETSTATE_SHIFT 23
220#define AM33XX_MPU_L2_RETSTATE_MASK (1 << 23)
221
222/* Used by PM_MPU_PWRSTST */
223#define AM33XX_MPU_L2_STATEST_SHIFT 8
224#define AM33XX_MPU_L2_STATEST_MASK (0x3 << 8)
225
226/* Used by PM_MPU_PWRSTCTRL */
227#define AM33XX_MPU_RAM_ONSTATE_SHIFT 16
228#define AM33XX_MPU_RAM_ONSTATE_MASK (0x3 << 16)
229
230/* Used by PM_MPU_PWRSTCTRL */
231#define AM33XX_MPU_RAM_RETSTATE_SHIFT 24
232#define AM33XX_MPU_RAM_RETSTATE_MASK (1 << 24)
233
234/* Used by PM_MPU_PWRSTST */
235#define AM33XX_MPU_RAM_STATEST_SHIFT 4
236#define AM33XX_MPU_RAM_STATEST_MASK (0x3 << 4)
237
238/* Used by PRM_RSTST */
239#define AM33XX_MPU_SECURITY_VIOL_RST_SHIFT 2
240#define AM33XX_MPU_SECURITY_VIOL_RST_MASK (1 << 2)
241
242/* Used by PRM_SRAM_COUNT */
243#define AM33XX_PCHARGECNT_VALUE_SHIFT 0
244#define AM33XX_PCHARGECNT_VALUE_MASK (0x3f << 0)
245
246/* Used by RM_PER_RSTCTRL */
247#define AM33XX_PCI_LRST_SHIFT 0
248#define AM33XX_PCI_LRST_MASK (1 << 0)
249
250/* Renamed from PCI_LRST Used by RM_PER_RSTST */
251#define AM33XX_PCI_LRST_5_5_SHIFT 5
252#define AM33XX_PCI_LRST_5_5_MASK (1 << 5)
253
254/* Used by PM_PER_PWRSTCTRL */
255#define AM33XX_PER_MEM_ONSTATE_SHIFT 25
256#define AM33XX_PER_MEM_ONSTATE_MASK (0x3 << 25)
257
258/* Used by PM_PER_PWRSTCTRL */
259#define AM33XX_PER_MEM_RETSTATE_SHIFT 29
260#define AM33XX_PER_MEM_RETSTATE_MASK (1 << 29)
261
262/* Used by PM_PER_PWRSTST */
263#define AM33XX_PER_MEM_STATEST_SHIFT 17
264#define AM33XX_PER_MEM_STATEST_MASK (0x3 << 17)
265
266/*
267 * Used by PM_GFX_PWRSTCTRL, PM_CEFUSE_PWRSTCTRL, PM_PER_PWRSTCTRL,
268 * PM_MPU_PWRSTCTRL
269 */
270#define AM33XX_POWERSTATE_SHIFT 0
271#define AM33XX_POWERSTATE_MASK (0x3 << 0)
272
273/* Used by PM_GFX_PWRSTST, PM_CEFUSE_PWRSTST, PM_PER_PWRSTST, PM_MPU_PWRSTST */
274#define AM33XX_POWERSTATEST_SHIFT 0
275#define AM33XX_POWERSTATEST_MASK (0x3 << 0)
276
277/* Used by PM_PER_PWRSTCTRL */
278#define AM33XX_RAM_MEM_ONSTATE_SHIFT 30
279#define AM33XX_RAM_MEM_ONSTATE_MASK (0x3 << 30)
280
281/* Used by PM_PER_PWRSTCTRL */
282#define AM33XX_RAM_MEM_RETSTATE_SHIFT 27
283#define AM33XX_RAM_MEM_RETSTATE_MASK (1 << 27)
284
285/* Used by PM_PER_PWRSTST */
286#define AM33XX_RAM_MEM_STATEST_SHIFT 21
287#define AM33XX_RAM_MEM_STATEST_MASK (0x3 << 21)
288
289/* Used by PRM_LDO_SRAM_CORE_CTRL, PRM_LDO_SRAM_MPU_CTRL */
290#define AM33XX_RETMODE_ENABLE_SHIFT 0
291#define AM33XX_RETMODE_ENABLE_MASK (1 << 0)
292
293/* Used by REVISION_PRM */
294#define AM33XX_REV_SHIFT 0
295#define AM33XX_REV_MASK (0xff << 0)
296
297/* Used by PRM_RSTTIME */
298#define AM33XX_RSTTIME1_SHIFT 0
299#define AM33XX_RSTTIME1_MASK (0xff << 0)
300
301/* Used by PRM_RSTTIME */
302#define AM33XX_RSTTIME2_SHIFT 8
303#define AM33XX_RSTTIME2_MASK (0x1f << 8)
304
305/* Used by PRM_RSTCTRL */
306#define AM33XX_RST_GLOBAL_COLD_SW_SHIFT 1
307#define AM33XX_RST_GLOBAL_COLD_SW_MASK (1 << 1)
308
309/* Used by PRM_RSTCTRL */
310#define AM33XX_RST_GLOBAL_WARM_SW_SHIFT 0
311#define AM33XX_RST_GLOBAL_WARM_SW_MASK (1 << 0)
312
313/* Used by PRM_SRAM_COUNT */
314#define AM33XX_SLPCNT_VALUE_SHIFT 16
315#define AM33XX_SLPCNT_VALUE_MASK (0xff << 16)
316
317/* Used by PRM_LDO_SRAM_CORE_CTRL, PRM_LDO_SRAM_MPU_CTRL */
318#define AM33XX_SRAMLDO_STATUS_SHIFT 8
319#define AM33XX_SRAMLDO_STATUS_MASK (1 << 8)
320
321/* Used by PRM_LDO_SRAM_CORE_CTRL, PRM_LDO_SRAM_MPU_CTRL */
322#define AM33XX_SRAM_IN_TRANSITION_SHIFT 9
323#define AM33XX_SRAM_IN_TRANSITION_MASK (1 << 9)
324
325/* Used by PRM_SRAM_COUNT */
326#define AM33XX_STARTUP_COUNT_SHIFT 24
327#define AM33XX_STARTUP_COUNT_MASK (0xff << 24)
328
329/* Used by PRM_IRQENABLE_M3, PRM_IRQENABLE_MPU */
330#define AM33XX_TRANSITION_EN_SHIFT 8
331#define AM33XX_TRANSITION_EN_MASK (1 << 8)
332
333/* Used by PRM_IRQSTATUS_M3, PRM_IRQSTATUS_MPU */
334#define AM33XX_TRANSITION_ST_SHIFT 8
335#define AM33XX_TRANSITION_ST_MASK (1 << 8)
336
337/* Used by PRM_SRAM_COUNT */
338#define AM33XX_VSETUPCNT_VALUE_SHIFT 8
339#define AM33XX_VSETUPCNT_VALUE_MASK (0xff << 8)
340
341/* Used by PRM_RSTST */
342#define AM33XX_WDT0_RST_SHIFT 3
343#define AM33XX_WDT0_RST_MASK (1 << 3)
344
345/* Used by PRM_RSTST */
346#define AM33XX_WDT1_RST_SHIFT 4
347#define AM33XX_WDT1_RST_MASK (1 << 4)
348
349/* Used by RM_WKUP_RSTCTRL */
350#define AM33XX_WKUP_M3_LRST_SHIFT 3
351#define AM33XX_WKUP_M3_LRST_MASK (1 << 3)
352
353/* Renamed from WKUP_M3_LRST Used by RM_WKUP_RSTST */
354#define AM33XX_WKUP_M3_LRST_5_5_SHIFT 5
355#define AM33XX_WKUP_M3_LRST_5_5_MASK (1 << 5)
356
357#endif
diff --git a/arch/arm/mach-omap2/prm2xxx_3xxx.c b/arch/arm/mach-omap2/prm2xxx_3xxx.c
index 21cb74003a5..a0309dea679 100644
--- a/arch/arm/mach-omap2/prm2xxx_3xxx.c
+++ b/arch/arm/mach-omap2/prm2xxx_3xxx.c
@@ -302,11 +302,59 @@ void omap3xxx_prm_restore_irqen(u32 *saved_mask)
302 OMAP3_PRM_IRQENABLE_MPU_OFFSET); 302 OMAP3_PRM_IRQENABLE_MPU_OFFSET);
303} 303}
304 304
305/**
306 * omap3xxx_prm_reconfigure_io_chain - clear latches and reconfigure I/O chain
307 *
308 * Clear any previously-latched I/O wakeup events and ensure that the
309 * I/O wakeup gates are aligned with the current mux settings. Works
310 * by asserting WUCLKIN, waiting for WUCLKOUT to be asserted, and then
311 * deasserting WUCLKIN and clearing the ST_IO_CHAIN WKST bit. No
312 * return value.
313 */
314void omap3xxx_prm_reconfigure_io_chain(void)
315{
316 int i = 0;
317
318 omap2_prm_set_mod_reg_bits(OMAP3430_EN_IO_CHAIN_MASK, WKUP_MOD,
319 PM_WKEN);
320
321 omap_test_timeout(omap2_prm_read_mod_reg(WKUP_MOD, PM_WKST) &
322 OMAP3430_ST_IO_CHAIN_MASK,
323 MAX_IOPAD_LATCH_TIME, i);
324 if (i == MAX_IOPAD_LATCH_TIME)
325 pr_warn("PRM: I/O chain clock line assertion timed out\n");
326
327 omap2_prm_clear_mod_reg_bits(OMAP3430_EN_IO_CHAIN_MASK, WKUP_MOD,
328 PM_WKEN);
329
330 omap2_prm_set_mod_reg_bits(OMAP3430_ST_IO_CHAIN_MASK, WKUP_MOD,
331 PM_WKST);
332
333 omap2_prm_read_mod_reg(WKUP_MOD, PM_WKST);
334}
335
336/**
337 * omap3xxx_prm_enable_io_wakeup - enable wakeup events from I/O wakeup latches
338 *
339 * Activates the I/O wakeup event latches and allows events logged by
340 * those latches to signal a wakeup event to the PRCM. For I/O
341 * wakeups to occur, WAKEUPENABLE bits must be set in the pad mux
342 * registers, and omap3xxx_prm_reconfigure_io_chain() must be called.
343 * No return value.
344 */
345static void __init omap3xxx_prm_enable_io_wakeup(void)
346{
347 if (omap3_has_io_wakeup())
348 omap2_prm_set_mod_reg_bits(OMAP3430_EN_IO_MASK, WKUP_MOD,
349 PM_WKEN);
350}
351
305static int __init omap3xxx_prcm_init(void) 352static int __init omap3xxx_prcm_init(void)
306{ 353{
307 int ret = 0; 354 int ret = 0;
308 355
309 if (cpu_is_omap34xx()) { 356 if (cpu_is_omap34xx()) {
357 omap3xxx_prm_enable_io_wakeup();
310 ret = omap_prcm_register_chain_handler(&omap3_prcm_irq_setup); 358 ret = omap_prcm_register_chain_handler(&omap3_prcm_irq_setup);
311 if (!ret) 359 if (!ret)
312 irq_set_status_flags(omap_prcm_event_to_irq("io"), 360 irq_set_status_flags(omap_prcm_event_to_irq("io"),
diff --git a/arch/arm/mach-omap2/prm2xxx_3xxx.h b/arch/arm/mach-omap2/prm2xxx_3xxx.h
index 70ac2a19dc5..c19d249b481 100644
--- a/arch/arm/mach-omap2/prm2xxx_3xxx.h
+++ b/arch/arm/mach-omap2/prm2xxx_3xxx.h
@@ -228,68 +228,6 @@
228 228
229 229
230#ifndef __ASSEMBLER__ 230#ifndef __ASSEMBLER__
231/*
232 * Stub omap2xxx/omap3xxx functions so that common files
233 * continue to build when custom builds are used
234 */
235#if defined(CONFIG_ARCH_OMAP4) && !(defined(CONFIG_ARCH_OMAP2) || \
236 defined(CONFIG_ARCH_OMAP3))
237static inline u32 omap2_prm_read_mod_reg(s16 module, u16 idx)
238{
239 WARN(1, "prm: omap2xxx/omap3xxx specific function and "
240 "not suppose to be used on omap4\n");
241 return 0;
242}
243static inline void omap2_prm_write_mod_reg(u32 val, s16 module, u16 idx)
244{
245 WARN(1, "prm: omap2xxx/omap3xxx specific function and "
246 "not suppose to be used on omap4\n");
247}
248static inline u32 omap2_prm_rmw_mod_reg_bits(u32 mask, u32 bits,
249 s16 module, s16 idx)
250{
251 WARN(1, "prm: omap2xxx/omap3xxx specific function and "
252 "not suppose to be used on omap4\n");
253 return 0;
254}
255static inline u32 omap2_prm_set_mod_reg_bits(u32 bits, s16 module, s16 idx)
256{
257 WARN(1, "prm: omap2xxx/omap3xxx specific function and "
258 "not suppose to be used on omap4\n");
259 return 0;
260}
261static inline u32 omap2_prm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx)
262{
263 WARN(1, "prm: omap2xxx/omap3xxx specific function and "
264 "not suppose to be used on omap4\n");
265 return 0;
266}
267static inline u32 omap2_prm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask)
268{
269 WARN(1, "prm: omap2xxx/omap3xxx specific function and "
270 "not suppose to be used on omap4\n");
271 return 0;
272}
273static inline int omap2_prm_is_hardreset_asserted(s16 prm_mod, u8 shift)
274{
275 WARN(1, "prm: omap2xxx/omap3xxx specific function and "
276 "not suppose to be used on omap4\n");
277 return 0;
278}
279static inline int omap2_prm_assert_hardreset(s16 prm_mod, u8 shift)
280{
281 WARN(1, "prm: omap2xxx/omap3xxx specific function and "
282 "not suppose to be used on omap4\n");
283 return 0;
284}
285static inline int omap2_prm_deassert_hardreset(s16 prm_mod, u8 rst_shift,
286 u8 st_shift)
287{
288 WARN(1, "prm: omap2xxx/omap3xxx specific function and "
289 "not suppose to be used on omap4\n");
290 return 0;
291}
292#else
293/* Power/reset management domain register get/set */ 231/* Power/reset management domain register get/set */
294extern u32 omap2_prm_read_mod_reg(s16 module, u16 idx); 232extern u32 omap2_prm_read_mod_reg(s16 module, u16 idx);
295extern void omap2_prm_write_mod_reg(u32 val, s16 module, u16 idx); 233extern void omap2_prm_write_mod_reg(u32 val, s16 module, u16 idx);
@@ -315,15 +253,15 @@ extern u32 omap3_prm_vcvp_read(u8 offset);
315extern void omap3_prm_vcvp_write(u32 val, u8 offset); 253extern void omap3_prm_vcvp_write(u32 val, u8 offset);
316extern u32 omap3_prm_vcvp_rmw(u32 mask, u32 bits, u8 offset); 254extern u32 omap3_prm_vcvp_rmw(u32 mask, u32 bits, u8 offset);
317 255
256extern void omap3xxx_prm_reconfigure_io_chain(void);
257
318/* PRM interrupt-related functions */ 258/* PRM interrupt-related functions */
319extern void omap3xxx_prm_read_pending_irqs(unsigned long *events); 259extern void omap3xxx_prm_read_pending_irqs(unsigned long *events);
320extern void omap3xxx_prm_ocp_barrier(void); 260extern void omap3xxx_prm_ocp_barrier(void);
321extern void omap3xxx_prm_save_and_clear_irqen(u32 *saved_mask); 261extern void omap3xxx_prm_save_and_clear_irqen(u32 *saved_mask);
322extern void omap3xxx_prm_restore_irqen(u32 *saved_mask); 262extern void omap3xxx_prm_restore_irqen(u32 *saved_mask);
323 263
324#endif /* CONFIG_ARCH_OMAP4 */ 264#endif /* __ASSEMBLER */
325
326#endif
327 265
328/* 266/*
329 * Bits common to specific registers 267 * Bits common to specific registers
diff --git a/arch/arm/mach-omap2/prm33xx.c b/arch/arm/mach-omap2/prm33xx.c
new file mode 100644
index 00000000000..e7dbb6cf125
--- /dev/null
+++ b/arch/arm/mach-omap2/prm33xx.c
@@ -0,0 +1,135 @@
1/*
2 * AM33XX PRM functions
3 *
4 * Copyright (C) 2011-2012 Texas Instruments Incorporated - http://www.ti.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 as
8 * published by the Free Software Foundation version 2.
9 *
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/kernel.h>
17#include <linux/types.h>
18#include <linux/errno.h>
19#include <linux/err.h>
20#include <linux/io.h>
21
22#include <plat/common.h>
23
24#include "common.h"
25#include "prm33xx.h"
26#include "prm-regbits-33xx.h"
27
28/* Read a register in a PRM instance */
29u32 am33xx_prm_read_reg(s16 inst, u16 idx)
30{
31 return __raw_readl(prm_base + inst + idx);
32}
33
34/* Write into a register in a PRM instance */
35void am33xx_prm_write_reg(u32 val, s16 inst, u16 idx)
36{
37 __raw_writel(val, prm_base + inst + idx);
38}
39
40/* Read-modify-write a register in PRM. Caller must lock */
41u32 am33xx_prm_rmw_reg_bits(u32 mask, u32 bits, s16 inst, s16 idx)
42{
43 u32 v;
44
45 v = am33xx_prm_read_reg(inst, idx);
46 v &= ~mask;
47 v |= bits;
48 am33xx_prm_write_reg(v, inst, idx);
49
50 return v;
51}
52
53/**
54 * am33xx_prm_is_hardreset_asserted - read the HW reset line state of
55 * submodules contained in the hwmod module
56 * @shift: register bit shift corresponding to the reset line to check
57 * @inst: CM instance register offset (*_INST macro)
58 * @rstctrl_offs: RM_RSTCTRL register address offset for this module
59 *
60 * Returns 1 if the (sub)module hardreset line is currently asserted,
61 * 0 if the (sub)module hardreset line is not currently asserted, or
62 * -EINVAL upon parameter error.
63 */
64int am33xx_prm_is_hardreset_asserted(u8 shift, s16 inst, u16 rstctrl_offs)
65{
66 u32 v;
67
68 v = am33xx_prm_read_reg(inst, rstctrl_offs);
69 v &= 1 << shift;
70 v >>= shift;
71
72 return v;
73}
74
75/**
76 * am33xx_prm_assert_hardreset - assert the HW reset line of a submodule
77 * @shift: register bit shift corresponding to the reset line to assert
78 * @inst: CM instance register offset (*_INST macro)
79 * @rstctrl_reg: RM_RSTCTRL register address for this module
80 *
81 * Some IPs like dsp, ipu or iva contain processors that require an HW
82 * reset line to be asserted / deasserted in order to fully enable the
83 * IP. These modules may have multiple hard-reset lines that reset
84 * different 'submodules' inside the IP block. This function will
85 * place the submodule into reset. Returns 0 upon success or -EINVAL
86 * upon an argument error.
87 */
88int am33xx_prm_assert_hardreset(u8 shift, s16 inst, u16 rstctrl_offs)
89{
90 u32 mask = 1 << shift;
91
92 am33xx_prm_rmw_reg_bits(mask, mask, inst, rstctrl_offs);
93
94 return 0;
95}
96
97/**
98 * am33xx_prm_deassert_hardreset - deassert a submodule hardreset line and
99 * wait
100 * @shift: register bit shift corresponding to the reset line to deassert
101 * @inst: CM instance register offset (*_INST macro)
102 * @rstctrl_reg: RM_RSTCTRL register address for this module
103 * @rstst_reg: RM_RSTST register address for this module
104 *
105 * Some IPs like dsp, ipu or iva contain processors that require an HW
106 * reset line to be asserted / deasserted in order to fully enable the
107 * IP. These modules may have multiple hard-reset lines that reset
108 * different 'submodules' inside the IP block. This function will
109 * take the submodule out of reset and wait until the PRCM indicates
110 * that the reset has completed before returning. Returns 0 upon success or
111 * -EINVAL upon an argument error, -EEXIST if the submodule was already out
112 * of reset, or -EBUSY if the submodule did not exit reset promptly.
113 */
114int am33xx_prm_deassert_hardreset(u8 shift, s16 inst,
115 u16 rstctrl_offs, u16 rstst_offs)
116{
117 int c;
118 u32 mask = 1 << shift;
119
120 /* Check the current status to avoid de-asserting the line twice */
121 if (am33xx_prm_is_hardreset_asserted(shift, inst, rstctrl_offs) == 0)
122 return -EEXIST;
123
124 /* Clear the reset status by writing 1 to the status bit */
125 am33xx_prm_rmw_reg_bits(0xffffffff, mask, inst, rstst_offs);
126 /* de-assert the reset control line */
127 am33xx_prm_rmw_reg_bits(mask, 0, inst, rstctrl_offs);
128 /* wait the status to be set */
129
130 omap_test_timeout(am33xx_prm_is_hardreset_asserted(shift, inst,
131 rstst_offs),
132 MAX_MODULE_HARDRESET_WAIT, c);
133
134 return (c == MAX_MODULE_HARDRESET_WAIT) ? -EBUSY : 0;
135}
diff --git a/arch/arm/mach-omap2/prm33xx.h b/arch/arm/mach-omap2/prm33xx.h
new file mode 100644
index 00000000000..3f25c563a82
--- /dev/null
+++ b/arch/arm/mach-omap2/prm33xx.h
@@ -0,0 +1,129 @@
1/*
2 * AM33XX PRM instance offset macros
3 *
4 * Copyright (C) 2011-2012 Texas Instruments Incorporated - http://www.ti.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 as
8 * published by the Free Software Foundation version 2.
9 *
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef __ARCH_ARM_MACH_OMAP2_PRM33XX_H
17#define __ARCH_ARM_MACH_OMAP2_PRM33XX_H
18
19#include "prcm-common.h"
20#include "prm.h"
21
22#define AM33XX_PRM_BASE 0x44E00000
23
24#define AM33XX_PRM_REGADDR(inst, reg) \
25 AM33XX_L4_WK_IO_ADDRESS(AM33XX_PRM_BASE + (inst) + (reg))
26
27
28/* PRM instances */
29#define AM33XX_PRM_OCP_SOCKET_MOD 0x0B00
30#define AM33XX_PRM_PER_MOD 0x0C00
31#define AM33XX_PRM_WKUP_MOD 0x0D00
32#define AM33XX_PRM_MPU_MOD 0x0E00
33#define AM33XX_PRM_DEVICE_MOD 0x0F00
34#define AM33XX_PRM_RTC_MOD 0x1000
35#define AM33XX_PRM_GFX_MOD 0x1100
36#define AM33XX_PRM_CEFUSE_MOD 0x1200
37
38/* PRM */
39
40/* PRM.OCP_SOCKET_PRM register offsets */
41#define AM33XX_REVISION_PRM_OFFSET 0x0000
42#define AM33XX_REVISION_PRM AM33XX_PRM_REGADDR(AM33XX_PRM_OCP_SOCKET_MOD, 0x0000)
43#define AM33XX_PRM_IRQSTATUS_MPU_OFFSET 0x0004
44#define AM33XX_PRM_IRQSTATUS_MPU AM33XX_PRM_REGADDR(AM33XX_PRM_OCP_SOCKET_MOD, 0x0004)
45#define AM33XX_PRM_IRQENABLE_MPU_OFFSET 0x0008
46#define AM33XX_PRM_IRQENABLE_MPU AM33XX_PRM_REGADDR(AM33XX_PRM_OCP_SOCKET_MOD, 0x0008)
47#define AM33XX_PRM_IRQSTATUS_M3_OFFSET 0x000c
48#define AM33XX_PRM_IRQSTATUS_M3 AM33XX_PRM_REGADDR(AM33XX_PRM_OCP_SOCKET_MOD, 0x000c)
49#define AM33XX_PRM_IRQENABLE_M3_OFFSET 0x0010
50#define AM33XX_PRM_IRQENABLE_M3 AM33XX_PRM_REGADDR(AM33XX_PRM_OCP_SOCKET_MOD, 0x0010)
51
52/* PRM.PER_PRM register offsets */
53#define AM33XX_RM_PER_RSTCTRL_OFFSET 0x0000
54#define AM33XX_RM_PER_RSTCTRL AM33XX_PRM_REGADDR(AM33XX_PRM_PER_MOD, 0x0000)
55#define AM33XX_RM_PER_RSTST_OFFSET 0x0004
56#define AM33XX_RM_PER_RSTST AM33XX_PRM_REGADDR(AM33XX_PRM_PER_MOD, 0x0004)
57#define AM33XX_PM_PER_PWRSTST_OFFSET 0x0008
58#define AM33XX_PM_PER_PWRSTST AM33XX_PRM_REGADDR(AM33XX_PRM_PER_MOD, 0x0008)
59#define AM33XX_PM_PER_PWRSTCTRL_OFFSET 0x000c
60#define AM33XX_PM_PER_PWRSTCTRL AM33XX_PRM_REGADDR(AM33XX_PRM_PER_MOD, 0x000c)
61
62/* PRM.WKUP_PRM register offsets */
63#define AM33XX_RM_WKUP_RSTCTRL_OFFSET 0x0000
64#define AM33XX_RM_WKUP_RSTCTRL AM33XX_PRM_REGADDR(AM33XX_PRM_WKUP_MOD, 0x0000)
65#define AM33XX_PM_WKUP_PWRSTCTRL_OFFSET 0x0004
66#define AM33XX_PM_WKUP_PWRSTCTRL AM33XX_PRM_REGADDR(AM33XX_PRM_WKUP_MOD, 0x0004)
67#define AM33XX_PM_WKUP_PWRSTST_OFFSET 0x0008
68#define AM33XX_PM_WKUP_PWRSTST AM33XX_PRM_REGADDR(AM33XX_PRM_WKUP_MOD, 0x0008)
69#define AM33XX_RM_WKUP_RSTST_OFFSET 0x000c
70#define AM33XX_RM_WKUP_RSTST AM33XX_PRM_REGADDR(AM33XX_PRM_WKUP_MOD, 0x000c)
71
72/* PRM.MPU_PRM register offsets */
73#define AM33XX_PM_MPU_PWRSTCTRL_OFFSET 0x0000
74#define AM33XX_PM_MPU_PWRSTCTRL AM33XX_PRM_REGADDR(AM33XX_PRM_MPU_MOD, 0x0000)
75#define AM33XX_PM_MPU_PWRSTST_OFFSET 0x0004
76#define AM33XX_PM_MPU_PWRSTST AM33XX_PRM_REGADDR(AM33XX_PRM_MPU_MOD, 0x0004)
77#define AM33XX_RM_MPU_RSTST_OFFSET 0x0008
78#define AM33XX_RM_MPU_RSTST AM33XX_PRM_REGADDR(AM33XX_PRM_MPU_MOD, 0x0008)
79
80/* PRM.DEVICE_PRM register offsets */
81#define AM33XX_PRM_RSTCTRL_OFFSET 0x0000
82#define AM33XX_PRM_RSTCTRL AM33XX_PRM_REGADDR(AM33XX_PRM_DEVICE_MOD, 0x0000)
83#define AM33XX_PRM_RSTTIME_OFFSET 0x0004
84#define AM33XX_PRM_RSTTIME AM33XX_PRM_REGADDR(AM33XX_PRM_DEVICE_MOD, 0x0004)
85#define AM33XX_PRM_RSTST_OFFSET 0x0008
86#define AM33XX_PRM_RSTST AM33XX_PRM_REGADDR(AM33XX_PRM_DEVICE_MOD, 0x0008)
87#define AM33XX_PRM_SRAM_COUNT_OFFSET 0x000c
88#define AM33XX_PRM_SRAM_COUNT AM33XX_PRM_REGADDR(AM33XX_PRM_DEVICE_MOD, 0x000c)
89#define AM33XX_PRM_LDO_SRAM_CORE_SETUP_OFFSET 0x0010
90#define AM33XX_PRM_LDO_SRAM_CORE_SETUP AM33XX_PRM_REGADDR(AM33XX_PRM_DEVICE_MOD, 0x0010)
91#define AM33XX_PRM_LDO_SRAM_CORE_CTRL_OFFSET 0x0014
92#define AM33XX_PRM_LDO_SRAM_CORE_CTRL AM33XX_PRM_REGADDR(AM33XX_PRM_DEVICE_MOD, 0x0014)
93#define AM33XX_PRM_LDO_SRAM_MPU_SETUP_OFFSET 0x0018
94#define AM33XX_PRM_LDO_SRAM_MPU_SETUP AM33XX_PRM_REGADDR(AM33XX_PRM_DEVICE_MOD, 0x0018)
95#define AM33XX_PRM_LDO_SRAM_MPU_CTRL_OFFSET 0x001c
96#define AM33XX_PRM_LDO_SRAM_MPU_CTRL AM33XX_PRM_REGADDR(AM33XX_PRM_DEVICE_MOD, 0x001c)
97
98/* PRM.RTC_PRM register offsets */
99#define AM33XX_PM_RTC_PWRSTCTRL_OFFSET 0x0000
100#define AM33XX_PM_RTC_PWRSTCTRL AM33XX_PRM_REGADDR(AM33XX_PRM_RTC_MOD, 0x0000)
101#define AM33XX_PM_RTC_PWRSTST_OFFSET 0x0004
102#define AM33XX_PM_RTC_PWRSTST AM33XX_PRM_REGADDR(AM33XX_PRM_RTC_MOD, 0x0004)
103
104/* PRM.GFX_PRM register offsets */
105#define AM33XX_PM_GFX_PWRSTCTRL_OFFSET 0x0000
106#define AM33XX_PM_GFX_PWRSTCTRL AM33XX_PRM_REGADDR(AM33XX_PRM_GFX_MOD, 0x0000)
107#define AM33XX_RM_GFX_RSTCTRL_OFFSET 0x0004
108#define AM33XX_RM_GFX_RSTCTRL AM33XX_PRM_REGADDR(AM33XX_PRM_GFX_MOD, 0x0004)
109#define AM33XX_PM_GFX_PWRSTST_OFFSET 0x0010
110#define AM33XX_PM_GFX_PWRSTST AM33XX_PRM_REGADDR(AM33XX_PRM_GFX_MOD, 0x0010)
111#define AM33XX_RM_GFX_RSTST_OFFSET 0x0014
112#define AM33XX_RM_GFX_RSTST AM33XX_PRM_REGADDR(AM33XX_PRM_GFX_MOD, 0x0014)
113
114/* PRM.CEFUSE_PRM register offsets */
115#define AM33XX_PM_CEFUSE_PWRSTCTRL_OFFSET 0x0000
116#define AM33XX_PM_CEFUSE_PWRSTCTRL AM33XX_PRM_REGADDR(AM33XX_PRM_CEFUSE_MOD, 0x0000)
117#define AM33XX_PM_CEFUSE_PWRSTST_OFFSET 0x0004
118#define AM33XX_PM_CEFUSE_PWRSTST AM33XX_PRM_REGADDR(AM33XX_PRM_CEFUSE_MOD, 0x0004)
119
120extern u32 am33xx_prm_read_reg(s16 inst, u16 idx);
121extern void am33xx_prm_write_reg(u32 val, s16 inst, u16 idx);
122extern u32 am33xx_prm_rmw_reg_bits(u32 mask, u32 bits, s16 inst, s16 idx);
123extern void am33xx_prm_global_warm_sw_reset(void);
124extern int am33xx_prm_is_hardreset_asserted(u8 shift, s16 inst,
125 u16 rstctrl_offs);
126extern int am33xx_prm_assert_hardreset(u8 shift, s16 inst, u16 rstctrl_offs);
127extern int am33xx_prm_deassert_hardreset(u8 shift, s16 inst,
128 u16 rstctrl_offs, u16 rstst_offs);
129#endif
diff --git a/arch/arm/mach-omap2/prm44xx.c b/arch/arm/mach-omap2/prm44xx.c
index f106d21ff58..bb727c2d933 100644
--- a/arch/arm/mach-omap2/prm44xx.c
+++ b/arch/arm/mach-omap2/prm44xx.c
@@ -233,10 +233,71 @@ void omap44xx_prm_restore_irqen(u32 *saved_mask)
233 OMAP4_PRM_IRQENABLE_MPU_2_OFFSET); 233 OMAP4_PRM_IRQENABLE_MPU_2_OFFSET);
234} 234}
235 235
236/**
237 * omap44xx_prm_reconfigure_io_chain - clear latches and reconfigure I/O chain
238 *
239 * Clear any previously-latched I/O wakeup events and ensure that the
240 * I/O wakeup gates are aligned with the current mux settings. Works
241 * by asserting WUCLKIN, waiting for WUCLKOUT to be asserted, and then
242 * deasserting WUCLKIN and waiting for WUCLKOUT to be deasserted.
243 * No return value. XXX Are the final two steps necessary?
244 */
245void omap44xx_prm_reconfigure_io_chain(void)
246{
247 int i = 0;
248
249 /* Trigger WUCLKIN enable */
250 omap4_prm_rmw_inst_reg_bits(OMAP4430_WUCLK_CTRL_MASK,
251 OMAP4430_WUCLK_CTRL_MASK,
252 OMAP4430_PRM_DEVICE_INST,
253 OMAP4_PRM_IO_PMCTRL_OFFSET);
254 omap_test_timeout(
255 (((omap4_prm_read_inst_reg(OMAP4430_PRM_DEVICE_INST,
256 OMAP4_PRM_IO_PMCTRL_OFFSET) &
257 OMAP4430_WUCLK_STATUS_MASK) >>
258 OMAP4430_WUCLK_STATUS_SHIFT) == 1),
259 MAX_IOPAD_LATCH_TIME, i);
260 if (i == MAX_IOPAD_LATCH_TIME)
261 pr_warn("PRM: I/O chain clock line assertion timed out\n");
262
263 /* Trigger WUCLKIN disable */
264 omap4_prm_rmw_inst_reg_bits(OMAP4430_WUCLK_CTRL_MASK, 0x0,
265 OMAP4430_PRM_DEVICE_INST,
266 OMAP4_PRM_IO_PMCTRL_OFFSET);
267 omap_test_timeout(
268 (((omap4_prm_read_inst_reg(OMAP4430_PRM_DEVICE_INST,
269 OMAP4_PRM_IO_PMCTRL_OFFSET) &
270 OMAP4430_WUCLK_STATUS_MASK) >>
271 OMAP4430_WUCLK_STATUS_SHIFT) == 0),
272 MAX_IOPAD_LATCH_TIME, i);
273 if (i == MAX_IOPAD_LATCH_TIME)
274 pr_warn("PRM: I/O chain clock line deassertion timed out\n");
275
276 return;
277}
278
279/**
280 * omap44xx_prm_enable_io_wakeup - enable wakeup events from I/O wakeup latches
281 *
282 * Activates the I/O wakeup event latches and allows events logged by
283 * those latches to signal a wakeup event to the PRCM. For I/O wakeups
284 * to occur, WAKEUPENABLE bits must be set in the pad mux registers, and
285 * omap44xx_prm_reconfigure_io_chain() must be called. No return value.
286 */
287static void __init omap44xx_prm_enable_io_wakeup(void)
288{
289 omap4_prm_rmw_inst_reg_bits(OMAP4430_GLOBAL_WUEN_MASK,
290 OMAP4430_GLOBAL_WUEN_MASK,
291 OMAP4430_PRM_DEVICE_INST,
292 OMAP4_PRM_IO_PMCTRL_OFFSET);
293}
294
236static int __init omap4xxx_prcm_init(void) 295static int __init omap4xxx_prcm_init(void)
237{ 296{
238 if (cpu_is_omap44xx()) 297 if (cpu_is_omap44xx()) {
298 omap44xx_prm_enable_io_wakeup();
239 return omap_prcm_register_chain_handler(&omap4_prcm_irq_setup); 299 return omap_prcm_register_chain_handler(&omap4_prcm_irq_setup);
300 }
240 return 0; 301 return 0;
241} 302}
242subsys_initcall(omap4xxx_prcm_init); 303subsys_initcall(omap4xxx_prcm_init);
diff --git a/arch/arm/mach-omap2/prm44xx.h b/arch/arm/mach-omap2/prm44xx.h
index 7978092946d..ee72ae6bd8c 100644
--- a/arch/arm/mach-omap2/prm44xx.h
+++ b/arch/arm/mach-omap2/prm44xx.h
@@ -763,6 +763,8 @@ extern u32 omap4_prm_vcvp_read(u8 offset);
763extern void omap4_prm_vcvp_write(u32 val, u8 offset); 763extern void omap4_prm_vcvp_write(u32 val, u8 offset);
764extern u32 omap4_prm_vcvp_rmw(u32 mask, u32 bits, u8 offset); 764extern u32 omap4_prm_vcvp_rmw(u32 mask, u32 bits, u8 offset);
765 765
766extern void omap44xx_prm_reconfigure_io_chain(void);
767
766/* PRM interrupt-related functions */ 768/* PRM interrupt-related functions */
767extern void omap44xx_prm_read_pending_irqs(unsigned long *events); 769extern void omap44xx_prm_read_pending_irqs(unsigned long *events);
768extern void omap44xx_prm_ocp_barrier(void); 770extern void omap44xx_prm_ocp_barrier(void);
diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
index dfe00ddb5c6..03b126d9ad9 100644
--- a/arch/arm/mach-omap2/prm_common.c
+++ b/arch/arm/mach-omap2/prm_common.c
@@ -85,7 +85,7 @@ static void omap_prcm_irq_handler(unsigned int irq, struct irq_desc *desc)
85 unsigned long priority_pending[OMAP_PRCM_MAX_NR_PENDING_REG]; 85 unsigned long priority_pending[OMAP_PRCM_MAX_NR_PENDING_REG];
86 struct irq_chip *chip = irq_desc_get_chip(desc); 86 struct irq_chip *chip = irq_desc_get_chip(desc);
87 unsigned int virtirq; 87 unsigned int virtirq;
88 int nr_irqs = prcm_irq_setup->nr_regs * 32; 88 int nr_irq = prcm_irq_setup->nr_regs * 32;
89 89
90 /* 90 /*
91 * If we are suspended, mask all interrupts from PRCM level, 91 * If we are suspended, mask all interrupts from PRCM level,
@@ -110,7 +110,7 @@ static void omap_prcm_irq_handler(unsigned int irq, struct irq_desc *desc)
110 prcm_irq_setup->read_pending_irqs(pending); 110 prcm_irq_setup->read_pending_irqs(pending);
111 111
112 /* No bit set, then all IRQs are handled */ 112 /* No bit set, then all IRQs are handled */
113 if (find_first_bit(pending, nr_irqs) >= nr_irqs) 113 if (find_first_bit(pending, nr_irq) >= nr_irq)
114 break; 114 break;
115 115
116 omap_prcm_events_filter_priority(pending, priority_pending); 116 omap_prcm_events_filter_priority(pending, priority_pending);
@@ -121,11 +121,11 @@ static void omap_prcm_irq_handler(unsigned int irq, struct irq_desc *desc)
121 */ 121 */
122 122
123 /* Serve priority events first */ 123 /* Serve priority events first */
124 for_each_set_bit(virtirq, priority_pending, nr_irqs) 124 for_each_set_bit(virtirq, priority_pending, nr_irq)
125 generic_handle_irq(prcm_irq_setup->base_irq + virtirq); 125 generic_handle_irq(prcm_irq_setup->base_irq + virtirq);
126 126
127 /* Serve normal events next */ 127 /* Serve normal events next */
128 for_each_set_bit(virtirq, pending, nr_irqs) 128 for_each_set_bit(virtirq, pending, nr_irq)
129 generic_handle_irq(prcm_irq_setup->base_irq + virtirq); 129 generic_handle_irq(prcm_irq_setup->base_irq + virtirq);
130 } 130 }
131 if (chip->irq_ack) 131 if (chip->irq_ack)
@@ -319,3 +319,65 @@ err:
319 omap_prcm_irq_cleanup(); 319 omap_prcm_irq_cleanup();
320 return -ENOMEM; 320 return -ENOMEM;
321} 321}
322
323/*
324 * Stubbed functions so that common files continue to build when
325 * custom builds are used
326 * XXX These are temporary and should be removed at the earliest possible
327 * opportunity
328 */
329u32 __weak omap2_prm_read_mod_reg(s16 module, u16 idx)
330{
331 WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n");
332 return 0;
333}
334
335void __weak omap2_prm_write_mod_reg(u32 val, s16 module, u16 idx)
336{
337 WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n");
338}
339
340u32 __weak omap2_prm_rmw_mod_reg_bits(u32 mask, u32 bits,
341 s16 module, s16 idx)
342{
343 WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n");
344 return 0;
345}
346
347u32 __weak omap2_prm_set_mod_reg_bits(u32 bits, s16 module, s16 idx)
348{
349 WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n");
350 return 0;
351}
352
353u32 __weak omap2_prm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx)
354{
355 WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n");
356 return 0;
357}
358
359u32 __weak omap2_prm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask)
360{
361 WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n");
362 return 0;
363}
364
365int __weak omap2_prm_is_hardreset_asserted(s16 prm_mod, u8 shift)
366{
367 WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n");
368 return 0;
369}
370
371int __weak omap2_prm_assert_hardreset(s16 prm_mod, u8 shift)
372{
373 WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n");
374 return 0;
375}
376
377int __weak omap2_prm_deassert_hardreset(s16 prm_mod, u8 rst_shift,
378 u8 st_shift)
379{
380 WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n");
381 return 0;
382}
383
diff --git a/arch/arm/mach-omap2/sleep44xx.S b/arch/arm/mach-omap2/sleep44xx.S
index 9f6b83d1b19..91e71d8f46f 100644
--- a/arch/arm/mach-omap2/sleep44xx.S
+++ b/arch/arm/mach-omap2/sleep44xx.S
@@ -56,9 +56,13 @@ ppa_por_params:
56 * The restore function pointer is stored at CPUx_WAKEUP_NS_PA_ADDR_OFFSET. 56 * The restore function pointer is stored at CPUx_WAKEUP_NS_PA_ADDR_OFFSET.
57 * It returns to the caller for CPU INACTIVE and ON power states or in case 57 * It returns to the caller for CPU INACTIVE and ON power states or in case
58 * CPU failed to transition to targeted OFF/DORMANT state. 58 * CPU failed to transition to targeted OFF/DORMANT state.
59 *
60 * omap4_finish_suspend() calls v7_flush_dcache_all() which doesn't save
61 * stack frame and it expects the caller to take care of it. Hence the entire
62 * stack frame is saved to avoid possible stack corruption.
59 */ 63 */
60ENTRY(omap4_finish_suspend) 64ENTRY(omap4_finish_suspend)
61 stmfd sp!, {lr} 65 stmfd sp!, {r4-r12, lr}
62 cmp r0, #0x0 66 cmp r0, #0x0
63 beq do_WFI @ No lowpower state, jump to WFI 67 beq do_WFI @ No lowpower state, jump to WFI
64 68
@@ -226,7 +230,7 @@ scu_gp_clear:
226skip_scu_gp_clear: 230skip_scu_gp_clear:
227 isb 231 isb
228 dsb 232 dsb
229 ldmfd sp!, {pc} 233 ldmfd sp!, {r4-r12, pc}
230ENDPROC(omap4_finish_suspend) 234ENDPROC(omap4_finish_suspend)
231 235
232/* 236/*
diff --git a/arch/arm/mach-omap2/smartreflex-class3.c b/arch/arm/mach-omap2/smartreflex-class3.c
index 955566eefac..1da8f03c479 100644
--- a/arch/arm/mach-omap2/smartreflex-class3.c
+++ b/arch/arm/mach-omap2/smartreflex-class3.c
@@ -11,36 +11,37 @@
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
12 */ 12 */
13 13
14#include "smartreflex.h" 14#include <linux/power/smartreflex.h>
15#include "voltage.h"
15 16
16static int sr_class3_enable(struct voltagedomain *voltdm) 17static int sr_class3_enable(struct omap_sr *sr)
17{ 18{
18 unsigned long volt = voltdm_get_voltage(voltdm); 19 unsigned long volt = voltdm_get_voltage(sr->voltdm);
19 20
20 if (!volt) { 21 if (!volt) {
21 pr_warning("%s: Curr voltage unknown. Cannot enable sr_%s\n", 22 pr_warning("%s: Curr voltage unknown. Cannot enable %s\n",
22 __func__, voltdm->name); 23 __func__, sr->name);
23 return -ENODATA; 24 return -ENODATA;
24 } 25 }
25 26
26 omap_vp_enable(voltdm); 27 omap_vp_enable(sr->voltdm);
27 return sr_enable(voltdm, volt); 28 return sr_enable(sr->voltdm, volt);
28} 29}
29 30
30static int sr_class3_disable(struct voltagedomain *voltdm, int is_volt_reset) 31static int sr_class3_disable(struct omap_sr *sr, int is_volt_reset)
31{ 32{
32 sr_disable_errgen(voltdm); 33 sr_disable_errgen(sr->voltdm);
33 omap_vp_disable(voltdm); 34 omap_vp_disable(sr->voltdm);
34 sr_disable(voltdm); 35 sr_disable(sr->voltdm);
35 if (is_volt_reset) 36 if (is_volt_reset)
36 voltdm_reset(voltdm); 37 voltdm_reset(sr->voltdm);
37 38
38 return 0; 39 return 0;
39} 40}
40 41
41static int sr_class3_configure(struct voltagedomain *voltdm) 42static int sr_class3_configure(struct omap_sr *sr)
42{ 43{
43 return sr_configure_errgen(voltdm); 44 return sr_configure_errgen(sr->voltdm);
44} 45}
45 46
46/* SR class3 structure */ 47/* SR class3 structure */
diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
deleted file mode 100644
index 008fbd7b935..00000000000
--- a/arch/arm/mach-omap2/smartreflex.c
+++ /dev/null
@@ -1,1165 +0,0 @@
1/*
2 * OMAP SmartReflex Voltage Control
3 *
4 * Author: Thara Gopinath <thara@ti.com>
5 *
6 * Copyright (C) 2010 Texas Instruments, Inc.
7 * Thara Gopinath <thara@ti.com>
8 *
9 * Copyright (C) 2008 Nokia Corporation
10 * Kalle Jokiniemi
11 *
12 * Copyright (C) 2007 Texas Instruments, Inc.
13 * Lesly A M <x0080970@ti.com>
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#include <linux/module.h>
21#include <linux/interrupt.h>
22#include <linux/clk.h>
23#include <linux/io.h>
24#include <linux/debugfs.h>
25#include <linux/delay.h>
26#include <linux/slab.h>
27#include <linux/pm_runtime.h>
28
29#include "common.h"
30
31#include "pm.h"
32#include "smartreflex.h"
33
34#define SMARTREFLEX_NAME_LEN 16
35#define NVALUE_NAME_LEN 40
36#define SR_DISABLE_TIMEOUT 200
37
38struct omap_sr {
39 struct list_head node;
40 struct platform_device *pdev;
41 struct omap_sr_nvalue_table *nvalue_table;
42 struct voltagedomain *voltdm;
43 struct dentry *dbg_dir;
44 unsigned int irq;
45 int srid;
46 int ip_type;
47 int nvalue_count;
48 bool autocomp_active;
49 u32 clk_length;
50 u32 err_weight;
51 u32 err_minlimit;
52 u32 err_maxlimit;
53 u32 accum_data;
54 u32 senn_avgweight;
55 u32 senp_avgweight;
56 u32 senp_mod;
57 u32 senn_mod;
58 void __iomem *base;
59};
60
61/* sr_list contains all the instances of smartreflex module */
62static LIST_HEAD(sr_list);
63
64static struct omap_sr_class_data *sr_class;
65static struct omap_sr_pmic_data *sr_pmic_data;
66static struct dentry *sr_dbg_dir;
67
68static inline void sr_write_reg(struct omap_sr *sr, unsigned offset, u32 value)
69{
70 __raw_writel(value, (sr->base + offset));
71}
72
73static inline void sr_modify_reg(struct omap_sr *sr, unsigned offset, u32 mask,
74 u32 value)
75{
76 u32 reg_val;
77
78 /*
79 * Smartreflex error config register is special as it contains
80 * certain status bits which if written a 1 into means a clear
81 * of those bits. So in order to make sure no accidental write of
82 * 1 happens to those status bits, do a clear of them in the read
83 * value. This mean this API doesn't rewrite values in these bits
84 * if they are currently set, but does allow the caller to write
85 * those bits.
86 */
87 if (sr->ip_type == SR_TYPE_V1 && offset == ERRCONFIG_V1)
88 mask |= ERRCONFIG_STATUS_V1_MASK;
89 else if (sr->ip_type == SR_TYPE_V2 && offset == ERRCONFIG_V2)
90 mask |= ERRCONFIG_VPBOUNDINTST_V2;
91
92 reg_val = __raw_readl(sr->base + offset);
93 reg_val &= ~mask;
94
95 value &= mask;
96
97 reg_val |= value;
98
99 __raw_writel(reg_val, (sr->base + offset));
100}
101
102static inline u32 sr_read_reg(struct omap_sr *sr, unsigned offset)
103{
104 return __raw_readl(sr->base + offset);
105}
106
107static struct omap_sr *_sr_lookup(struct voltagedomain *voltdm)
108{
109 struct omap_sr *sr_info;
110
111 if (!voltdm) {
112 pr_err("%s: Null voltage domain passed!\n", __func__);
113 return ERR_PTR(-EINVAL);
114 }
115
116 list_for_each_entry(sr_info, &sr_list, node) {
117 if (voltdm == sr_info->voltdm)
118 return sr_info;
119 }
120
121 return ERR_PTR(-ENODATA);
122}
123
124static irqreturn_t sr_interrupt(int irq, void *data)
125{
126 struct omap_sr *sr_info = data;
127 u32 status = 0;
128
129 switch (sr_info->ip_type) {
130 case SR_TYPE_V1:
131 /* Read the status bits */
132 status = sr_read_reg(sr_info, ERRCONFIG_V1);
133
134 /* Clear them by writing back */
135 sr_write_reg(sr_info, ERRCONFIG_V1, status);
136 break;
137 case SR_TYPE_V2:
138 /* Read the status bits */
139 status = sr_read_reg(sr_info, IRQSTATUS);
140
141 /* Clear them by writing back */
142 sr_write_reg(sr_info, IRQSTATUS, status);
143 break;
144 default:
145 dev_err(&sr_info->pdev->dev, "UNKNOWN IP type %d\n",
146 sr_info->ip_type);
147 return IRQ_NONE;
148 }
149
150 if (sr_class->notify)
151 sr_class->notify(sr_info->voltdm, status);
152
153 return IRQ_HANDLED;
154}
155
156static void sr_set_clk_length(struct omap_sr *sr)
157{
158 struct clk *sys_ck;
159 u32 sys_clk_speed;
160
161 if (cpu_is_omap34xx())
162 sys_ck = clk_get(NULL, "sys_ck");
163 else
164 sys_ck = clk_get(NULL, "sys_clkin_ck");
165
166 if (IS_ERR(sys_ck)) {
167 dev_err(&sr->pdev->dev, "%s: unable to get sys clk\n",
168 __func__);
169 return;
170 }
171
172 sys_clk_speed = clk_get_rate(sys_ck);
173 clk_put(sys_ck);
174
175 switch (sys_clk_speed) {
176 case 12000000:
177 sr->clk_length = SRCLKLENGTH_12MHZ_SYSCLK;
178 break;
179 case 13000000:
180 sr->clk_length = SRCLKLENGTH_13MHZ_SYSCLK;
181 break;
182 case 19200000:
183 sr->clk_length = SRCLKLENGTH_19MHZ_SYSCLK;
184 break;
185 case 26000000:
186 sr->clk_length = SRCLKLENGTH_26MHZ_SYSCLK;
187 break;
188 case 38400000:
189 sr->clk_length = SRCLKLENGTH_38MHZ_SYSCLK;
190 break;
191 default:
192 dev_err(&sr->pdev->dev, "%s: Invalid sysclk value: %d\n",
193 __func__, sys_clk_speed);
194 break;
195 }
196}
197
198static void sr_set_regfields(struct omap_sr *sr)
199{
200 /*
201 * For time being these values are defined in smartreflex.h
202 * and populated during init. May be they can be moved to board
203 * file or pmic specific data structure. In that case these structure
204 * fields will have to be populated using the pdata or pmic structure.
205 */
206 if (cpu_is_omap34xx() || cpu_is_omap44xx()) {
207 sr->err_weight = OMAP3430_SR_ERRWEIGHT;
208 sr->err_maxlimit = OMAP3430_SR_ERRMAXLIMIT;
209 sr->accum_data = OMAP3430_SR_ACCUMDATA;
210 if (!(strcmp(sr->voltdm->name, "mpu"))) {
211 sr->senn_avgweight = OMAP3430_SR1_SENNAVGWEIGHT;
212 sr->senp_avgweight = OMAP3430_SR1_SENPAVGWEIGHT;
213 } else {
214 sr->senn_avgweight = OMAP3430_SR2_SENNAVGWEIGHT;
215 sr->senp_avgweight = OMAP3430_SR2_SENPAVGWEIGHT;
216 }
217 }
218}
219
220static void sr_start_vddautocomp(struct omap_sr *sr)
221{
222 if (!sr_class || !(sr_class->enable) || !(sr_class->configure)) {
223 dev_warn(&sr->pdev->dev,
224 "%s: smartreflex class driver not registered\n",
225 __func__);
226 return;
227 }
228
229 if (!sr_class->enable(sr->voltdm))
230 sr->autocomp_active = true;
231}
232
233static void sr_stop_vddautocomp(struct omap_sr *sr)
234{
235 if (!sr_class || !(sr_class->disable)) {
236 dev_warn(&sr->pdev->dev,
237 "%s: smartreflex class driver not registered\n",
238 __func__);
239 return;
240 }
241
242 if (sr->autocomp_active) {
243 sr_class->disable(sr->voltdm, 1);
244 sr->autocomp_active = false;
245 }
246}
247
248/*
249 * This function handles the intializations which have to be done
250 * only when both sr device and class driver regiter has
251 * completed. This will be attempted to be called from both sr class
252 * driver register and sr device intializtion API's. Only one call
253 * will ultimately succeed.
254 *
255 * Currently this function registers interrupt handler for a particular SR
256 * if smartreflex class driver is already registered and has
257 * requested for interrupts and the SR interrupt line in present.
258 */
259static int sr_late_init(struct omap_sr *sr_info)
260{
261 char *name;
262 struct omap_sr_data *pdata = sr_info->pdev->dev.platform_data;
263 struct resource *mem;
264 int ret = 0;
265
266 if (sr_class->notify && sr_class->notify_flags && sr_info->irq) {
267 name = kasprintf(GFP_KERNEL, "sr_%s", sr_info->voltdm->name);
268 if (name == NULL) {
269 ret = -ENOMEM;
270 goto error;
271 }
272 ret = request_irq(sr_info->irq, sr_interrupt,
273 0, name, sr_info);
274 if (ret)
275 goto error;
276 disable_irq(sr_info->irq);
277 }
278
279 if (pdata && pdata->enable_on_init)
280 sr_start_vddautocomp(sr_info);
281
282 return ret;
283
284error:
285 iounmap(sr_info->base);
286 mem = platform_get_resource(sr_info->pdev, IORESOURCE_MEM, 0);
287 release_mem_region(mem->start, resource_size(mem));
288 list_del(&sr_info->node);
289 dev_err(&sr_info->pdev->dev, "%s: ERROR in registering"
290 "interrupt handler. Smartreflex will"
291 "not function as desired\n", __func__);
292 kfree(name);
293 kfree(sr_info);
294
295 return ret;
296}
297
298static void sr_v1_disable(struct omap_sr *sr)
299{
300 int timeout = 0;
301 int errconf_val = ERRCONFIG_MCUACCUMINTST | ERRCONFIG_MCUVALIDINTST |
302 ERRCONFIG_MCUBOUNDINTST;
303
304 /* Enable MCUDisableAcknowledge interrupt */
305 sr_modify_reg(sr, ERRCONFIG_V1,
306 ERRCONFIG_MCUDISACKINTEN, ERRCONFIG_MCUDISACKINTEN);
307
308 /* SRCONFIG - disable SR */
309 sr_modify_reg(sr, SRCONFIG, SRCONFIG_SRENABLE, 0x0);
310
311 /* Disable all other SR interrupts and clear the status as needed */
312 if (sr_read_reg(sr, ERRCONFIG_V1) & ERRCONFIG_VPBOUNDINTST_V1)
313 errconf_val |= ERRCONFIG_VPBOUNDINTST_V1;
314 sr_modify_reg(sr, ERRCONFIG_V1,
315 (ERRCONFIG_MCUACCUMINTEN | ERRCONFIG_MCUVALIDINTEN |
316 ERRCONFIG_MCUBOUNDINTEN | ERRCONFIG_VPBOUNDINTEN_V1),
317 errconf_val);
318
319 /*
320 * Wait for SR to be disabled.
321 * wait until ERRCONFIG.MCUDISACKINTST = 1. Typical latency is 1us.
322 */
323 omap_test_timeout((sr_read_reg(sr, ERRCONFIG_V1) &
324 ERRCONFIG_MCUDISACKINTST), SR_DISABLE_TIMEOUT,
325 timeout);
326
327 if (timeout >= SR_DISABLE_TIMEOUT)
328 dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n",
329 __func__);
330
331 /* Disable MCUDisableAcknowledge interrupt & clear pending interrupt */
332 sr_modify_reg(sr, ERRCONFIG_V1, ERRCONFIG_MCUDISACKINTEN,
333 ERRCONFIG_MCUDISACKINTST);
334}
335
336static void sr_v2_disable(struct omap_sr *sr)
337{
338 int timeout = 0;
339
340 /* Enable MCUDisableAcknowledge interrupt */
341 sr_write_reg(sr, IRQENABLE_SET, IRQENABLE_MCUDISABLEACKINT);
342
343 /* SRCONFIG - disable SR */
344 sr_modify_reg(sr, SRCONFIG, SRCONFIG_SRENABLE, 0x0);
345
346 /*
347 * Disable all other SR interrupts and clear the status
348 * write to status register ONLY on need basis - only if status
349 * is set.
350 */
351 if (sr_read_reg(sr, ERRCONFIG_V2) & ERRCONFIG_VPBOUNDINTST_V2)
352 sr_modify_reg(sr, ERRCONFIG_V2, ERRCONFIG_VPBOUNDINTEN_V2,
353 ERRCONFIG_VPBOUNDINTST_V2);
354 else
355 sr_modify_reg(sr, ERRCONFIG_V2, ERRCONFIG_VPBOUNDINTEN_V2,
356 0x0);
357 sr_write_reg(sr, IRQENABLE_CLR, (IRQENABLE_MCUACCUMINT |
358 IRQENABLE_MCUVALIDINT |
359 IRQENABLE_MCUBOUNDSINT));
360 sr_write_reg(sr, IRQSTATUS, (IRQSTATUS_MCUACCUMINT |
361 IRQSTATUS_MCVALIDINT |
362 IRQSTATUS_MCBOUNDSINT));
363
364 /*
365 * Wait for SR to be disabled.
366 * wait until IRQSTATUS.MCUDISACKINTST = 1. Typical latency is 1us.
367 */
368 omap_test_timeout((sr_read_reg(sr, IRQSTATUS) &
369 IRQSTATUS_MCUDISABLEACKINT), SR_DISABLE_TIMEOUT,
370 timeout);
371
372 if (timeout >= SR_DISABLE_TIMEOUT)
373 dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n",
374 __func__);
375
376 /* Disable MCUDisableAcknowledge interrupt & clear pending interrupt */
377 sr_write_reg(sr, IRQENABLE_CLR, IRQENABLE_MCUDISABLEACKINT);
378 sr_write_reg(sr, IRQSTATUS, IRQSTATUS_MCUDISABLEACKINT);
379}
380
381static u32 sr_retrieve_nvalue(struct omap_sr *sr, u32 efuse_offs)
382{
383 int i;
384
385 if (!sr->nvalue_table) {
386 dev_warn(&sr->pdev->dev, "%s: Missing ntarget value table\n",
387 __func__);
388 return 0;
389 }
390
391 for (i = 0; i < sr->nvalue_count; i++) {
392 if (sr->nvalue_table[i].efuse_offs == efuse_offs)
393 return sr->nvalue_table[i].nvalue;
394 }
395
396 return 0;
397}
398
399/* Public Functions */
400
401/**
402 * sr_configure_errgen() - Configures the smrtreflex to perform AVS using the
403 * error generator module.
404 * @voltdm: VDD pointer to which the SR module to be configured belongs to.
405 *
406 * This API is to be called from the smartreflex class driver to
407 * configure the error generator module inside the smartreflex module.
408 * SR settings if using the ERROR module inside Smartreflex.
409 * SR CLASS 3 by default uses only the ERROR module where as
410 * SR CLASS 2 can choose between ERROR module and MINMAXAVG
411 * module. Returns 0 on success and error value in case of failure.
412 */
413int sr_configure_errgen(struct voltagedomain *voltdm)
414{
415 u32 sr_config, sr_errconfig, errconfig_offs;
416 u32 vpboundint_en, vpboundint_st;
417 u32 senp_en = 0, senn_en = 0;
418 u8 senp_shift, senn_shift;
419 struct omap_sr *sr = _sr_lookup(voltdm);
420
421 if (IS_ERR(sr)) {
422 pr_warning("%s: omap_sr struct for sr_%s not found\n",
423 __func__, voltdm->name);
424 return PTR_ERR(sr);
425 }
426
427 if (!sr->clk_length)
428 sr_set_clk_length(sr);
429
430 senp_en = sr->senp_mod;
431 senn_en = sr->senn_mod;
432
433 sr_config = (sr->clk_length << SRCONFIG_SRCLKLENGTH_SHIFT) |
434 SRCONFIG_SENENABLE | SRCONFIG_ERRGEN_EN;
435
436 switch (sr->ip_type) {
437 case SR_TYPE_V1:
438 sr_config |= SRCONFIG_DELAYCTRL;
439 senn_shift = SRCONFIG_SENNENABLE_V1_SHIFT;
440 senp_shift = SRCONFIG_SENPENABLE_V1_SHIFT;
441 errconfig_offs = ERRCONFIG_V1;
442 vpboundint_en = ERRCONFIG_VPBOUNDINTEN_V1;
443 vpboundint_st = ERRCONFIG_VPBOUNDINTST_V1;
444 break;
445 case SR_TYPE_V2:
446 senn_shift = SRCONFIG_SENNENABLE_V2_SHIFT;
447 senp_shift = SRCONFIG_SENPENABLE_V2_SHIFT;
448 errconfig_offs = ERRCONFIG_V2;
449 vpboundint_en = ERRCONFIG_VPBOUNDINTEN_V2;
450 vpboundint_st = ERRCONFIG_VPBOUNDINTST_V2;
451 break;
452 default:
453 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex"
454 "module without specifying the ip\n", __func__);
455 return -EINVAL;
456 }
457
458 sr_config |= ((senn_en << senn_shift) | (senp_en << senp_shift));
459 sr_write_reg(sr, SRCONFIG, sr_config);
460 sr_errconfig = (sr->err_weight << ERRCONFIG_ERRWEIGHT_SHIFT) |
461 (sr->err_maxlimit << ERRCONFIG_ERRMAXLIMIT_SHIFT) |
462 (sr->err_minlimit << ERRCONFIG_ERRMINLIMIT_SHIFT);
463 sr_modify_reg(sr, errconfig_offs, (SR_ERRWEIGHT_MASK |
464 SR_ERRMAXLIMIT_MASK | SR_ERRMINLIMIT_MASK),
465 sr_errconfig);
466
467 /* Enabling the interrupts if the ERROR module is used */
468 sr_modify_reg(sr, errconfig_offs, (vpboundint_en | vpboundint_st),
469 vpboundint_en);
470
471 return 0;
472}
473
474/**
475 * sr_disable_errgen() - Disables SmartReflex AVS module's errgen component
476 * @voltdm: VDD pointer to which the SR module to be configured belongs to.
477 *
478 * This API is to be called from the smartreflex class driver to
479 * disable the error generator module inside the smartreflex module.
480 *
481 * Returns 0 on success and error value in case of failure.
482 */
483int sr_disable_errgen(struct voltagedomain *voltdm)
484{
485 u32 errconfig_offs;
486 u32 vpboundint_en, vpboundint_st;
487 struct omap_sr *sr = _sr_lookup(voltdm);
488
489 if (IS_ERR(sr)) {
490 pr_warning("%s: omap_sr struct for sr_%s not found\n",
491 __func__, voltdm->name);
492 return PTR_ERR(sr);
493 }
494
495 switch (sr->ip_type) {
496 case SR_TYPE_V1:
497 errconfig_offs = ERRCONFIG_V1;
498 vpboundint_en = ERRCONFIG_VPBOUNDINTEN_V1;
499 vpboundint_st = ERRCONFIG_VPBOUNDINTST_V1;
500 break;
501 case SR_TYPE_V2:
502 errconfig_offs = ERRCONFIG_V2;
503 vpboundint_en = ERRCONFIG_VPBOUNDINTEN_V2;
504 vpboundint_st = ERRCONFIG_VPBOUNDINTST_V2;
505 break;
506 default:
507 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex"
508 "module without specifying the ip\n", __func__);
509 return -EINVAL;
510 }
511
512 /* Disable the interrupts of ERROR module */
513 sr_modify_reg(sr, errconfig_offs, vpboundint_en | vpboundint_st, 0);
514
515 /* Disable the Sensor and errorgen */
516 sr_modify_reg(sr, SRCONFIG, SRCONFIG_SENENABLE | SRCONFIG_ERRGEN_EN, 0);
517
518 return 0;
519}
520
521/**
522 * sr_configure_minmax() - Configures the smrtreflex to perform AVS using the
523 * minmaxavg module.
524 * @voltdm: VDD pointer to which the SR module to be configured belongs to.
525 *
526 * This API is to be called from the smartreflex class driver to
527 * configure the minmaxavg module inside the smartreflex module.
528 * SR settings if using the ERROR module inside Smartreflex.
529 * SR CLASS 3 by default uses only the ERROR module where as
530 * SR CLASS 2 can choose between ERROR module and MINMAXAVG
531 * module. Returns 0 on success and error value in case of failure.
532 */
533int sr_configure_minmax(struct voltagedomain *voltdm)
534{
535 u32 sr_config, sr_avgwt;
536 u32 senp_en = 0, senn_en = 0;
537 u8 senp_shift, senn_shift;
538 struct omap_sr *sr = _sr_lookup(voltdm);
539
540 if (IS_ERR(sr)) {
541 pr_warning("%s: omap_sr struct for sr_%s not found\n",
542 __func__, voltdm->name);
543 return PTR_ERR(sr);
544 }
545
546 if (!sr->clk_length)
547 sr_set_clk_length(sr);
548
549 senp_en = sr->senp_mod;
550 senn_en = sr->senn_mod;
551
552 sr_config = (sr->clk_length << SRCONFIG_SRCLKLENGTH_SHIFT) |
553 SRCONFIG_SENENABLE |
554 (sr->accum_data << SRCONFIG_ACCUMDATA_SHIFT);
555
556 switch (sr->ip_type) {
557 case SR_TYPE_V1:
558 sr_config |= SRCONFIG_DELAYCTRL;
559 senn_shift = SRCONFIG_SENNENABLE_V1_SHIFT;
560 senp_shift = SRCONFIG_SENPENABLE_V1_SHIFT;
561 break;
562 case SR_TYPE_V2:
563 senn_shift = SRCONFIG_SENNENABLE_V2_SHIFT;
564 senp_shift = SRCONFIG_SENPENABLE_V2_SHIFT;
565 break;
566 default:
567 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex"
568 "module without specifying the ip\n", __func__);
569 return -EINVAL;
570 }
571
572 sr_config |= ((senn_en << senn_shift) | (senp_en << senp_shift));
573 sr_write_reg(sr, SRCONFIG, sr_config);
574 sr_avgwt = (sr->senp_avgweight << AVGWEIGHT_SENPAVGWEIGHT_SHIFT) |
575 (sr->senn_avgweight << AVGWEIGHT_SENNAVGWEIGHT_SHIFT);
576 sr_write_reg(sr, AVGWEIGHT, sr_avgwt);
577
578 /*
579 * Enabling the interrupts if MINMAXAVG module is used.
580 * TODO: check if all the interrupts are mandatory
581 */
582 switch (sr->ip_type) {
583 case SR_TYPE_V1:
584 sr_modify_reg(sr, ERRCONFIG_V1,
585 (ERRCONFIG_MCUACCUMINTEN | ERRCONFIG_MCUVALIDINTEN |
586 ERRCONFIG_MCUBOUNDINTEN),
587 (ERRCONFIG_MCUACCUMINTEN | ERRCONFIG_MCUACCUMINTST |
588 ERRCONFIG_MCUVALIDINTEN | ERRCONFIG_MCUVALIDINTST |
589 ERRCONFIG_MCUBOUNDINTEN | ERRCONFIG_MCUBOUNDINTST));
590 break;
591 case SR_TYPE_V2:
592 sr_write_reg(sr, IRQSTATUS,
593 IRQSTATUS_MCUACCUMINT | IRQSTATUS_MCVALIDINT |
594 IRQSTATUS_MCBOUNDSINT | IRQSTATUS_MCUDISABLEACKINT);
595 sr_write_reg(sr, IRQENABLE_SET,
596 IRQENABLE_MCUACCUMINT | IRQENABLE_MCUVALIDINT |
597 IRQENABLE_MCUBOUNDSINT | IRQENABLE_MCUDISABLEACKINT);
598 break;
599 default:
600 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex"
601 "module without specifying the ip\n", __func__);
602 return -EINVAL;
603 }
604
605 return 0;
606}
607
608/**
609 * sr_enable() - Enables the smartreflex module.
610 * @voltdm: VDD pointer to which the SR module to be configured belongs to.
611 * @volt: The voltage at which the Voltage domain associated with
612 * the smartreflex module is operating at.
613 * This is required only to program the correct Ntarget value.
614 *
615 * This API is to be called from the smartreflex class driver to
616 * enable a smartreflex module. Returns 0 on success. Returns error
617 * value if the voltage passed is wrong or if ntarget value is wrong.
618 */
619int sr_enable(struct voltagedomain *voltdm, unsigned long volt)
620{
621 struct omap_volt_data *volt_data;
622 struct omap_sr *sr = _sr_lookup(voltdm);
623 u32 nvalue_reciprocal;
624 int ret;
625
626 if (IS_ERR(sr)) {
627 pr_warning("%s: omap_sr struct for sr_%s not found\n",
628 __func__, voltdm->name);
629 return PTR_ERR(sr);
630 }
631
632 volt_data = omap_voltage_get_voltdata(sr->voltdm, volt);
633
634 if (IS_ERR(volt_data)) {
635 dev_warn(&sr->pdev->dev, "%s: Unable to get voltage table"
636 "for nominal voltage %ld\n", __func__, volt);
637 return PTR_ERR(volt_data);
638 }
639
640 nvalue_reciprocal = sr_retrieve_nvalue(sr, volt_data->sr_efuse_offs);
641
642 if (!nvalue_reciprocal) {
643 dev_warn(&sr->pdev->dev, "%s: NVALUE = 0 at voltage %ld\n",
644 __func__, volt);
645 return -ENODATA;
646 }
647
648 /* errminlimit is opp dependent and hence linked to voltage */
649 sr->err_minlimit = volt_data->sr_errminlimit;
650
651 pm_runtime_get_sync(&sr->pdev->dev);
652
653 /* Check if SR is already enabled. If yes do nothing */
654 if (sr_read_reg(sr, SRCONFIG) & SRCONFIG_SRENABLE)
655 return 0;
656
657 /* Configure SR */
658 ret = sr_class->configure(voltdm);
659 if (ret)
660 return ret;
661
662 sr_write_reg(sr, NVALUERECIPROCAL, nvalue_reciprocal);
663
664 /* SRCONFIG - enable SR */
665 sr_modify_reg(sr, SRCONFIG, SRCONFIG_SRENABLE, SRCONFIG_SRENABLE);
666 return 0;
667}
668
669/**
670 * sr_disable() - Disables the smartreflex module.
671 * @voltdm: VDD pointer to which the SR module to be configured belongs to.
672 *
673 * This API is to be called from the smartreflex class driver to
674 * disable a smartreflex module.
675 */
676void sr_disable(struct voltagedomain *voltdm)
677{
678 struct omap_sr *sr = _sr_lookup(voltdm);
679
680 if (IS_ERR(sr)) {
681 pr_warning("%s: omap_sr struct for sr_%s not found\n",
682 __func__, voltdm->name);
683 return;
684 }
685
686 /* Check if SR clocks are already disabled. If yes do nothing */
687 if (pm_runtime_suspended(&sr->pdev->dev))
688 return;
689
690 /*
691 * Disable SR if only it is indeed enabled. Else just
692 * disable the clocks.
693 */
694 if (sr_read_reg(sr, SRCONFIG) & SRCONFIG_SRENABLE) {
695 switch (sr->ip_type) {
696 case SR_TYPE_V1:
697 sr_v1_disable(sr);
698 break;
699 case SR_TYPE_V2:
700 sr_v2_disable(sr);
701 break;
702 default:
703 dev_err(&sr->pdev->dev, "UNKNOWN IP type %d\n",
704 sr->ip_type);
705 }
706 }
707
708 pm_runtime_put_sync_suspend(&sr->pdev->dev);
709}
710
711/**
712 * sr_register_class() - API to register a smartreflex class parameters.
713 * @class_data: The structure containing various sr class specific data.
714 *
715 * This API is to be called by the smartreflex class driver to register itself
716 * with the smartreflex driver during init. Returns 0 on success else the
717 * error value.
718 */
719int sr_register_class(struct omap_sr_class_data *class_data)
720{
721 struct omap_sr *sr_info;
722
723 if (!class_data) {
724 pr_warning("%s:, Smartreflex class data passed is NULL\n",
725 __func__);
726 return -EINVAL;
727 }
728
729 if (sr_class) {
730 pr_warning("%s: Smartreflex class driver already registered\n",
731 __func__);
732 return -EBUSY;
733 }
734
735 sr_class = class_data;
736
737 /*
738 * Call into late init to do intializations that require
739 * both sr driver and sr class driver to be initiallized.
740 */
741 list_for_each_entry(sr_info, &sr_list, node)
742 sr_late_init(sr_info);
743
744 return 0;
745}
746
747/**
748 * omap_sr_enable() - API to enable SR clocks and to call into the
749 * registered smartreflex class enable API.
750 * @voltdm: VDD pointer to which the SR module to be configured belongs to.
751 *
752 * This API is to be called from the kernel in order to enable
753 * a particular smartreflex module. This API will do the initial
754 * configurations to turn on the smartreflex module and in turn call
755 * into the registered smartreflex class enable API.
756 */
757void omap_sr_enable(struct voltagedomain *voltdm)
758{
759 struct omap_sr *sr = _sr_lookup(voltdm);
760
761 if (IS_ERR(sr)) {
762 pr_warning("%s: omap_sr struct for sr_%s not found\n",
763 __func__, voltdm->name);
764 return;
765 }
766
767 if (!sr->autocomp_active)
768 return;
769
770 if (!sr_class || !(sr_class->enable) || !(sr_class->configure)) {
771 dev_warn(&sr->pdev->dev, "%s: smartreflex class driver not"
772 "registered\n", __func__);
773 return;
774 }
775
776 sr_class->enable(voltdm);
777}
778
779/**
780 * omap_sr_disable() - API to disable SR without resetting the voltage
781 * processor voltage
782 * @voltdm: VDD pointer to which the SR module to be configured belongs to.
783 *
784 * This API is to be called from the kernel in order to disable
785 * a particular smartreflex module. This API will in turn call
786 * into the registered smartreflex class disable API. This API will tell
787 * the smartreflex class disable not to reset the VP voltage after
788 * disabling smartreflex.
789 */
790void omap_sr_disable(struct voltagedomain *voltdm)
791{
792 struct omap_sr *sr = _sr_lookup(voltdm);
793
794 if (IS_ERR(sr)) {
795 pr_warning("%s: omap_sr struct for sr_%s not found\n",
796 __func__, voltdm->name);
797 return;
798 }
799
800 if (!sr->autocomp_active)
801 return;
802
803 if (!sr_class || !(sr_class->disable)) {
804 dev_warn(&sr->pdev->dev, "%s: smartreflex class driver not"
805 "registered\n", __func__);
806 return;
807 }
808
809 sr_class->disable(voltdm, 0);
810}
811
812/**
813 * omap_sr_disable_reset_volt() - API to disable SR and reset the
814 * voltage processor voltage
815 * @voltdm: VDD pointer to which the SR module to be configured belongs to.
816 *
817 * This API is to be called from the kernel in order to disable
818 * a particular smartreflex module. This API will in turn call
819 * into the registered smartreflex class disable API. This API will tell
820 * the smartreflex class disable to reset the VP voltage after
821 * disabling smartreflex.
822 */
823void omap_sr_disable_reset_volt(struct voltagedomain *voltdm)
824{
825 struct omap_sr *sr = _sr_lookup(voltdm);
826
827 if (IS_ERR(sr)) {
828 pr_warning("%s: omap_sr struct for sr_%s not found\n",
829 __func__, voltdm->name);
830 return;
831 }
832
833 if (!sr->autocomp_active)
834 return;
835
836 if (!sr_class || !(sr_class->disable)) {
837 dev_warn(&sr->pdev->dev, "%s: smartreflex class driver not"
838 "registered\n", __func__);
839 return;
840 }
841
842 sr_class->disable(voltdm, 1);
843}
844
845/**
846 * omap_sr_register_pmic() - API to register pmic specific info.
847 * @pmic_data: The structure containing pmic specific data.
848 *
849 * This API is to be called from the PMIC specific code to register with
850 * smartreflex driver pmic specific info. Currently the only info required
851 * is the smartreflex init on the PMIC side.
852 */
853void omap_sr_register_pmic(struct omap_sr_pmic_data *pmic_data)
854{
855 if (!pmic_data) {
856 pr_warning("%s: Trying to register NULL PMIC data structure"
857 "with smartreflex\n", __func__);
858 return;
859 }
860
861 sr_pmic_data = pmic_data;
862}
863
864/* PM Debug FS entries to enable and disable smartreflex. */
865static int omap_sr_autocomp_show(void *data, u64 *val)
866{
867 struct omap_sr *sr_info = data;
868
869 if (!sr_info) {
870 pr_warning("%s: omap_sr struct not found\n", __func__);
871 return -EINVAL;
872 }
873
874 *val = sr_info->autocomp_active;
875
876 return 0;
877}
878
879static int omap_sr_autocomp_store(void *data, u64 val)
880{
881 struct omap_sr *sr_info = data;
882
883 if (!sr_info) {
884 pr_warning("%s: omap_sr struct not found\n", __func__);
885 return -EINVAL;
886 }
887
888 /* Sanity check */
889 if (val > 1) {
890 pr_warning("%s: Invalid argument %lld\n", __func__, val);
891 return -EINVAL;
892 }
893
894 /* control enable/disable only if there is a delta in value */
895 if (sr_info->autocomp_active != val) {
896 if (!val)
897 sr_stop_vddautocomp(sr_info);
898 else
899 sr_start_vddautocomp(sr_info);
900 }
901
902 return 0;
903}
904
905DEFINE_SIMPLE_ATTRIBUTE(pm_sr_fops, omap_sr_autocomp_show,
906 omap_sr_autocomp_store, "%llu\n");
907
908static int __init omap_sr_probe(struct platform_device *pdev)
909{
910 struct omap_sr *sr_info;
911 struct omap_sr_data *pdata = pdev->dev.platform_data;
912 struct resource *mem, *irq;
913 struct dentry *nvalue_dir;
914 struct omap_volt_data *volt_data;
915 int i, ret = 0;
916 char *name;
917
918 sr_info = kzalloc(sizeof(struct omap_sr), GFP_KERNEL);
919 if (!sr_info) {
920 dev_err(&pdev->dev, "%s: unable to allocate sr_info\n",
921 __func__);
922 return -ENOMEM;
923 }
924
925 platform_set_drvdata(pdev, sr_info);
926
927 if (!pdata) {
928 dev_err(&pdev->dev, "%s: platform data missing\n", __func__);
929 ret = -EINVAL;
930 goto err_free_devinfo;
931 }
932
933 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
934 if (!mem) {
935 dev_err(&pdev->dev, "%s: no mem resource\n", __func__);
936 ret = -ENODEV;
937 goto err_free_devinfo;
938 }
939
940 mem = request_mem_region(mem->start, resource_size(mem),
941 dev_name(&pdev->dev));
942 if (!mem) {
943 dev_err(&pdev->dev, "%s: no mem region\n", __func__);
944 ret = -EBUSY;
945 goto err_free_devinfo;
946 }
947
948 irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
949
950 pm_runtime_enable(&pdev->dev);
951 pm_runtime_irq_safe(&pdev->dev);
952
953 sr_info->pdev = pdev;
954 sr_info->srid = pdev->id;
955 sr_info->voltdm = pdata->voltdm;
956 sr_info->nvalue_table = pdata->nvalue_table;
957 sr_info->nvalue_count = pdata->nvalue_count;
958 sr_info->senn_mod = pdata->senn_mod;
959 sr_info->senp_mod = pdata->senp_mod;
960 sr_info->autocomp_active = false;
961 sr_info->ip_type = pdata->ip_type;
962 sr_info->base = ioremap(mem->start, resource_size(mem));
963 if (!sr_info->base) {
964 dev_err(&pdev->dev, "%s: ioremap fail\n", __func__);
965 ret = -ENOMEM;
966 goto err_release_region;
967 }
968
969 if (irq)
970 sr_info->irq = irq->start;
971
972 sr_set_clk_length(sr_info);
973 sr_set_regfields(sr_info);
974
975 list_add(&sr_info->node, &sr_list);
976
977 /*
978 * Call into late init to do intializations that require
979 * both sr driver and sr class driver to be initiallized.
980 */
981 if (sr_class) {
982 ret = sr_late_init(sr_info);
983 if (ret) {
984 pr_warning("%s: Error in SR late init\n", __func__);
985 goto err_iounmap;
986 }
987 }
988
989 dev_info(&pdev->dev, "%s: SmartReflex driver initialized\n", __func__);
990 if (!sr_dbg_dir) {
991 sr_dbg_dir = debugfs_create_dir("smartreflex", NULL);
992 if (IS_ERR_OR_NULL(sr_dbg_dir)) {
993 ret = PTR_ERR(sr_dbg_dir);
994 pr_err("%s:sr debugfs dir creation failed(%d)\n",
995 __func__, ret);
996 goto err_iounmap;
997 }
998 }
999
1000 name = kasprintf(GFP_KERNEL, "sr_%s", sr_info->voltdm->name);
1001 if (!name) {
1002 dev_err(&pdev->dev, "%s: Unable to alloc debugfs name\n",
1003 __func__);
1004 ret = -ENOMEM;
1005 goto err_iounmap;
1006 }
1007 sr_info->dbg_dir = debugfs_create_dir(name, sr_dbg_dir);
1008 kfree(name);
1009 if (IS_ERR_OR_NULL(sr_info->dbg_dir)) {
1010 dev_err(&pdev->dev, "%s: Unable to create debugfs directory\n",
1011 __func__);
1012 ret = PTR_ERR(sr_info->dbg_dir);
1013 goto err_iounmap;
1014 }
1015
1016 (void) debugfs_create_file("autocomp", S_IRUGO | S_IWUSR,
1017 sr_info->dbg_dir, (void *)sr_info, &pm_sr_fops);
1018 (void) debugfs_create_x32("errweight", S_IRUGO, sr_info->dbg_dir,
1019 &sr_info->err_weight);
1020 (void) debugfs_create_x32("errmaxlimit", S_IRUGO, sr_info->dbg_dir,
1021 &sr_info->err_maxlimit);
1022 (void) debugfs_create_x32("errminlimit", S_IRUGO, sr_info->dbg_dir,
1023 &sr_info->err_minlimit);
1024
1025 nvalue_dir = debugfs_create_dir("nvalue", sr_info->dbg_dir);
1026 if (IS_ERR_OR_NULL(nvalue_dir)) {
1027 dev_err(&pdev->dev, "%s: Unable to create debugfs directory"
1028 "for n-values\n", __func__);
1029 ret = PTR_ERR(nvalue_dir);
1030 goto err_debugfs;
1031 }
1032
1033 omap_voltage_get_volttable(sr_info->voltdm, &volt_data);
1034 if (!volt_data) {
1035 dev_warn(&pdev->dev, "%s: No Voltage table for the"
1036 " corresponding vdd vdd_%s. Cannot create debugfs"
1037 "entries for n-values\n",
1038 __func__, sr_info->voltdm->name);
1039 ret = -ENODATA;
1040 goto err_debugfs;
1041 }
1042
1043 for (i = 0; i < sr_info->nvalue_count; i++) {
1044 char name[NVALUE_NAME_LEN + 1];
1045
1046 snprintf(name, sizeof(name), "volt_%d",
1047 volt_data[i].volt_nominal);
1048 (void) debugfs_create_x32(name, S_IRUGO | S_IWUSR, nvalue_dir,
1049 &(sr_info->nvalue_table[i].nvalue));
1050 }
1051
1052 return ret;
1053
1054err_debugfs:
1055 debugfs_remove_recursive(sr_info->dbg_dir);
1056err_iounmap:
1057 list_del(&sr_info->node);
1058 iounmap(sr_info->base);
1059err_release_region:
1060 release_mem_region(mem->start, resource_size(mem));
1061err_free_devinfo:
1062 kfree(sr_info);
1063
1064 return ret;
1065}
1066
1067static int __devexit omap_sr_remove(struct platform_device *pdev)
1068{
1069 struct omap_sr_data *pdata = pdev->dev.platform_data;
1070 struct omap_sr *sr_info;
1071 struct resource *mem;
1072
1073 if (!pdata) {
1074 dev_err(&pdev->dev, "%s: platform data missing\n", __func__);
1075 return -EINVAL;
1076 }
1077
1078 sr_info = _sr_lookup(pdata->voltdm);
1079 if (IS_ERR(sr_info)) {
1080 dev_warn(&pdev->dev, "%s: omap_sr struct not found\n",
1081 __func__);
1082 return PTR_ERR(sr_info);
1083 }
1084
1085 if (sr_info->autocomp_active)
1086 sr_stop_vddautocomp(sr_info);
1087 if (sr_info->dbg_dir)
1088 debugfs_remove_recursive(sr_info->dbg_dir);
1089
1090 list_del(&sr_info->node);
1091 iounmap(sr_info->base);
1092 kfree(sr_info);
1093 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1094 release_mem_region(mem->start, resource_size(mem));
1095
1096 return 0;
1097}
1098
1099static void __devexit omap_sr_shutdown(struct platform_device *pdev)
1100{
1101 struct omap_sr_data *pdata = pdev->dev.platform_data;
1102 struct omap_sr *sr_info;
1103
1104 if (!pdata) {
1105 dev_err(&pdev->dev, "%s: platform data missing\n", __func__);
1106 return;
1107 }
1108
1109 sr_info = _sr_lookup(pdata->voltdm);
1110 if (IS_ERR(sr_info)) {
1111 dev_warn(&pdev->dev, "%s: omap_sr struct not found\n",
1112 __func__);
1113 return;
1114 }
1115
1116 if (sr_info->autocomp_active)
1117 sr_stop_vddautocomp(sr_info);
1118
1119 return;
1120}
1121
1122static struct platform_driver smartreflex_driver = {
1123 .remove = __devexit_p(omap_sr_remove),
1124 .shutdown = __devexit_p(omap_sr_shutdown),
1125 .driver = {
1126 .name = "smartreflex",
1127 },
1128};
1129
1130static int __init sr_init(void)
1131{
1132 int ret = 0;
1133
1134 /*
1135 * sr_init is a late init. If by then a pmic specific API is not
1136 * registered either there is no need for anything to be done on
1137 * the PMIC side or somebody has forgotten to register a PMIC
1138 * handler. Warn for the second condition.
1139 */
1140 if (sr_pmic_data && sr_pmic_data->sr_pmic_init)
1141 sr_pmic_data->sr_pmic_init();
1142 else
1143 pr_warning("%s: No PMIC hook to init smartreflex\n", __func__);
1144
1145 ret = platform_driver_probe(&smartreflex_driver, omap_sr_probe);
1146 if (ret) {
1147 pr_err("%s: platform driver register failed for SR\n",
1148 __func__);
1149 return ret;
1150 }
1151
1152 return 0;
1153}
1154late_initcall(sr_init);
1155
1156static void __exit sr_exit(void)
1157{
1158 platform_driver_unregister(&smartreflex_driver);
1159}
1160module_exit(sr_exit);
1161
1162MODULE_DESCRIPTION("OMAP Smartreflex Driver");
1163MODULE_LICENSE("GPL");
1164MODULE_ALIAS("platform:" DRIVER_NAME);
1165MODULE_AUTHOR("Texas Instruments Inc");
diff --git a/arch/arm/mach-omap2/smartreflex.h b/arch/arm/mach-omap2/smartreflex.h
deleted file mode 100644
index 5809141171f..00000000000
--- a/arch/arm/mach-omap2/smartreflex.h
+++ /dev/null
@@ -1,256 +0,0 @@
1/*
2 * OMAP Smartreflex Defines and Routines
3 *
4 * Author: Thara Gopinath <thara@ti.com>
5 *
6 * Copyright (C) 2010 Texas Instruments, Inc.
7 * Thara Gopinath <thara@ti.com>
8 *
9 * Copyright (C) 2008 Nokia Corporation
10 * Kalle Jokiniemi
11 *
12 * Copyright (C) 2007 Texas Instruments, Inc.
13 * Lesly A M <x0080970@ti.com>
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 __ASM_ARM_OMAP_SMARTREFLEX_H
21#define __ASM_ARM_OMAP_SMARTREFLEX_H
22
23#include <linux/platform_device.h>
24
25#include "voltage.h"
26
27/*
28 * Different Smartreflex IPs version. The v1 is the 65nm version used in
29 * OMAP3430. The v2 is the update for the 45nm version of the IP
30 * used in OMAP3630 and OMAP4430
31 */
32#define SR_TYPE_V1 1
33#define SR_TYPE_V2 2
34
35/* SMART REFLEX REG ADDRESS OFFSET */
36#define SRCONFIG 0x00
37#define SRSTATUS 0x04
38#define SENVAL 0x08
39#define SENMIN 0x0C
40#define SENMAX 0x10
41#define SENAVG 0x14
42#define AVGWEIGHT 0x18
43#define NVALUERECIPROCAL 0x1c
44#define SENERROR_V1 0x20
45#define ERRCONFIG_V1 0x24
46#define IRQ_EOI 0x20
47#define IRQSTATUS_RAW 0x24
48#define IRQSTATUS 0x28
49#define IRQENABLE_SET 0x2C
50#define IRQENABLE_CLR 0x30
51#define SENERROR_V2 0x34
52#define ERRCONFIG_V2 0x38
53
54/* Bit/Shift Positions */
55
56/* SRCONFIG */
57#define SRCONFIG_ACCUMDATA_SHIFT 22
58#define SRCONFIG_SRCLKLENGTH_SHIFT 12
59#define SRCONFIG_SENNENABLE_V1_SHIFT 5
60#define SRCONFIG_SENPENABLE_V1_SHIFT 3
61#define SRCONFIG_SENNENABLE_V2_SHIFT 1
62#define SRCONFIG_SENPENABLE_V2_SHIFT 0
63#define SRCONFIG_CLKCTRL_SHIFT 0
64
65#define SRCONFIG_ACCUMDATA_MASK (0x3ff << 22)
66
67#define SRCONFIG_SRENABLE BIT(11)
68#define SRCONFIG_SENENABLE BIT(10)
69#define SRCONFIG_ERRGEN_EN BIT(9)
70#define SRCONFIG_MINMAXAVG_EN BIT(8)
71#define SRCONFIG_DELAYCTRL BIT(2)
72
73/* AVGWEIGHT */
74#define AVGWEIGHT_SENPAVGWEIGHT_SHIFT 2
75#define AVGWEIGHT_SENNAVGWEIGHT_SHIFT 0
76
77/* NVALUERECIPROCAL */
78#define NVALUERECIPROCAL_SENPGAIN_SHIFT 20
79#define NVALUERECIPROCAL_SENNGAIN_SHIFT 16
80#define NVALUERECIPROCAL_RNSENP_SHIFT 8
81#define NVALUERECIPROCAL_RNSENN_SHIFT 0
82
83/* ERRCONFIG */
84#define ERRCONFIG_ERRWEIGHT_SHIFT 16
85#define ERRCONFIG_ERRMAXLIMIT_SHIFT 8
86#define ERRCONFIG_ERRMINLIMIT_SHIFT 0
87
88#define SR_ERRWEIGHT_MASK (0x07 << 16)
89#define SR_ERRMAXLIMIT_MASK (0xff << 8)
90#define SR_ERRMINLIMIT_MASK (0xff << 0)
91
92#define ERRCONFIG_VPBOUNDINTEN_V1 BIT(31)
93#define ERRCONFIG_VPBOUNDINTST_V1 BIT(30)
94#define ERRCONFIG_MCUACCUMINTEN BIT(29)
95#define ERRCONFIG_MCUACCUMINTST BIT(28)
96#define ERRCONFIG_MCUVALIDINTEN BIT(27)
97#define ERRCONFIG_MCUVALIDINTST BIT(26)
98#define ERRCONFIG_MCUBOUNDINTEN BIT(25)
99#define ERRCONFIG_MCUBOUNDINTST BIT(24)
100#define ERRCONFIG_MCUDISACKINTEN BIT(23)
101#define ERRCONFIG_VPBOUNDINTST_V2 BIT(23)
102#define ERRCONFIG_MCUDISACKINTST BIT(22)
103#define ERRCONFIG_VPBOUNDINTEN_V2 BIT(22)
104
105#define ERRCONFIG_STATUS_V1_MASK (ERRCONFIG_VPBOUNDINTST_V1 | \
106 ERRCONFIG_MCUACCUMINTST | \
107 ERRCONFIG_MCUVALIDINTST | \
108 ERRCONFIG_MCUBOUNDINTST | \
109 ERRCONFIG_MCUDISACKINTST)
110/* IRQSTATUS */
111#define IRQSTATUS_MCUACCUMINT BIT(3)
112#define IRQSTATUS_MCVALIDINT BIT(2)
113#define IRQSTATUS_MCBOUNDSINT BIT(1)
114#define IRQSTATUS_MCUDISABLEACKINT BIT(0)
115
116/* IRQENABLE_SET and IRQENABLE_CLEAR */
117#define IRQENABLE_MCUACCUMINT BIT(3)
118#define IRQENABLE_MCUVALIDINT BIT(2)
119#define IRQENABLE_MCUBOUNDSINT BIT(1)
120#define IRQENABLE_MCUDISABLEACKINT BIT(0)
121
122/* Common Bit values */
123
124#define SRCLKLENGTH_12MHZ_SYSCLK 0x3c
125#define SRCLKLENGTH_13MHZ_SYSCLK 0x41
126#define SRCLKLENGTH_19MHZ_SYSCLK 0x60
127#define SRCLKLENGTH_26MHZ_SYSCLK 0x82
128#define SRCLKLENGTH_38MHZ_SYSCLK 0xC0
129
130/*
131 * 3430 specific values. Maybe these should be passed from board file or
132 * pmic structures.
133 */
134#define OMAP3430_SR_ACCUMDATA 0x1f4
135
136#define OMAP3430_SR1_SENPAVGWEIGHT 0x03
137#define OMAP3430_SR1_SENNAVGWEIGHT 0x03
138
139#define OMAP3430_SR2_SENPAVGWEIGHT 0x01
140#define OMAP3430_SR2_SENNAVGWEIGHT 0x01
141
142#define OMAP3430_SR_ERRWEIGHT 0x04
143#define OMAP3430_SR_ERRMAXLIMIT 0x02
144
145/**
146 * struct omap_sr_pmic_data - Strucutre to be populated by pmic code to pass
147 * pmic specific info to smartreflex driver
148 *
149 * @sr_pmic_init: API to initialize smartreflex on the PMIC side.
150 */
151struct omap_sr_pmic_data {
152 void (*sr_pmic_init) (void);
153};
154
155/**
156 * struct omap_smartreflex_dev_attr - Smartreflex Device attribute.
157 *
158 * @sensor_voltdm_name: Name of voltdomain of SR instance
159 */
160struct omap_smartreflex_dev_attr {
161 const char *sensor_voltdm_name;
162};
163
164#ifdef CONFIG_OMAP_SMARTREFLEX
165/*
166 * The smart reflex driver supports CLASS1 CLASS2 and CLASS3 SR.
167 * The smartreflex class driver should pass the class type.
168 * Should be used to populate the class_type field of the
169 * omap_smartreflex_class_data structure.
170 */
171#define SR_CLASS1 0x1
172#define SR_CLASS2 0x2
173#define SR_CLASS3 0x3
174
175/**
176 * struct omap_sr_class_data - Smartreflex class driver info
177 *
178 * @enable: API to enable a particular class smaartreflex.
179 * @disable: API to disable a particular class smartreflex.
180 * @configure: API to configure a particular class smartreflex.
181 * @notify: API to notify the class driver about an event in SR.
182 * Not needed for class3.
183 * @notify_flags: specify the events to be notified to the class driver
184 * @class_type: specify which smartreflex class.
185 * Can be used by the SR driver to take any class
186 * based decisions.
187 */
188struct omap_sr_class_data {
189 int (*enable)(struct voltagedomain *voltdm);
190 int (*disable)(struct voltagedomain *voltdm, int is_volt_reset);
191 int (*configure)(struct voltagedomain *voltdm);
192 int (*notify)(struct voltagedomain *voltdm, u32 status);
193 u8 notify_flags;
194 u8 class_type;
195};
196
197/**
198 * struct omap_sr_nvalue_table - Smartreflex n-target value info
199 *
200 * @efuse_offs: The offset of the efuse where n-target values are stored.
201 * @nvalue: The n-target value.
202 */
203struct omap_sr_nvalue_table {
204 u32 efuse_offs;
205 u32 nvalue;
206};
207
208/**
209 * struct omap_sr_data - Smartreflex platform data.
210 *
211 * @ip_type: Smartreflex IP type.
212 * @senp_mod: SENPENABLE value for the sr
213 * @senn_mod: SENNENABLE value for sr
214 * @nvalue_count: Number of distinct nvalues in the nvalue table
215 * @enable_on_init: whether this sr module needs to enabled at
216 * boot up or not.
217 * @nvalue_table: table containing the efuse offsets and nvalues
218 * corresponding to them.
219 * @voltdm: Pointer to the voltage domain associated with the SR
220 */
221struct omap_sr_data {
222 int ip_type;
223 u32 senp_mod;
224 u32 senn_mod;
225 int nvalue_count;
226 bool enable_on_init;
227 struct omap_sr_nvalue_table *nvalue_table;
228 struct voltagedomain *voltdm;
229};
230
231/* Smartreflex module enable/disable interface */
232void omap_sr_enable(struct voltagedomain *voltdm);
233void omap_sr_disable(struct voltagedomain *voltdm);
234void omap_sr_disable_reset_volt(struct voltagedomain *voltdm);
235
236/* API to register the pmic specific data with the smartreflex driver. */
237void omap_sr_register_pmic(struct omap_sr_pmic_data *pmic_data);
238
239/* Smartreflex driver hooks to be called from Smartreflex class driver */
240int sr_enable(struct voltagedomain *voltdm, unsigned long volt);
241void sr_disable(struct voltagedomain *voltdm);
242int sr_configure_errgen(struct voltagedomain *voltdm);
243int sr_disable_errgen(struct voltagedomain *voltdm);
244int sr_configure_minmax(struct voltagedomain *voltdm);
245
246/* API to register the smartreflex class driver with the smartreflex driver */
247int sr_register_class(struct omap_sr_class_data *class_data);
248#else
249static inline void omap_sr_enable(struct voltagedomain *voltdm) {}
250static inline void omap_sr_disable(struct voltagedomain *voltdm) {}
251static inline void omap_sr_disable_reset_volt(
252 struct voltagedomain *voltdm) {}
253static inline void omap_sr_register_pmic(
254 struct omap_sr_pmic_data *pmic_data) {}
255#endif
256#endif
diff --git a/arch/arm/mach-omap2/sr_device.c b/arch/arm/mach-omap2/sr_device.c
index a503e1e8358..d033a65f4e4 100644
--- a/arch/arm/mach-omap2/sr_device.c
+++ b/arch/arm/mach-omap2/sr_device.c
@@ -17,6 +17,7 @@
17 * it under the terms of the GNU General Public License version 2 as 17 * it under the terms of the GNU General Public License version 2 as
18 * published by the Free Software Foundation. 18 * published by the Free Software Foundation.
19 */ 19 */
20#include <linux/power/smartreflex.h>
20 21
21#include <linux/err.h> 22#include <linux/err.h>
22#include <linux/slab.h> 23#include <linux/slab.h>
@@ -24,7 +25,6 @@
24 25
25#include <plat/omap_device.h> 26#include <plat/omap_device.h>
26 27
27#include "smartreflex.h"
28#include "voltage.h" 28#include "voltage.h"
29#include "control.h" 29#include "control.h"
30#include "pm.h" 30#include "pm.h"
@@ -36,7 +36,10 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
36 struct omap_sr_data *sr_data) 36 struct omap_sr_data *sr_data)
37{ 37{
38 struct omap_sr_nvalue_table *nvalue_table; 38 struct omap_sr_nvalue_table *nvalue_table;
39 int i, count = 0; 39 int i, j, count = 0;
40
41 sr_data->nvalue_count = 0;
42 sr_data->nvalue_table = NULL;
40 43
41 while (volt_data[count].volt_nominal) 44 while (volt_data[count].volt_nominal)
42 count++; 45 count++;
@@ -44,8 +47,14 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
44 nvalue_table = kzalloc(sizeof(struct omap_sr_nvalue_table)*count, 47 nvalue_table = kzalloc(sizeof(struct omap_sr_nvalue_table)*count,
45 GFP_KERNEL); 48 GFP_KERNEL);
46 49
47 for (i = 0; i < count; i++) { 50 if (!nvalue_table) {
51 pr_err("OMAP: SmartReflex: cannot allocate memory for n-value table\n");
52 return;
53 }
54
55 for (i = 0, j = 0; i < count; i++) {
48 u32 v; 56 u32 v;
57
49 /* 58 /*
50 * In OMAP4 the efuse registers are 24 bit aligned. 59 * In OMAP4 the efuse registers are 24 bit aligned.
51 * A __raw_readl will fail for non-32 bit aligned address 60 * A __raw_readl will fail for non-32 bit aligned address
@@ -58,15 +67,30 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
58 omap_ctrl_readb(offset + 1) << 8 | 67 omap_ctrl_readb(offset + 1) << 8 |
59 omap_ctrl_readb(offset + 2) << 16; 68 omap_ctrl_readb(offset + 2) << 16;
60 } else { 69 } else {
61 v = omap_ctrl_readl(volt_data[i].sr_efuse_offs); 70 v = omap_ctrl_readl(volt_data[i].sr_efuse_offs);
62 } 71 }
63 72
64 nvalue_table[i].efuse_offs = volt_data[i].sr_efuse_offs; 73 /*
65 nvalue_table[i].nvalue = v; 74 * Many OMAP SoCs don't have the eFuse values set.
75 * For example, pretty much all OMAP3xxx before
76 * ES3.something.
77 *
78 * XXX There needs to be some way for board files or
79 * userspace to add these in.
80 */
81 if (v == 0)
82 continue;
83
84 nvalue_table[j].nvalue = v;
85 nvalue_table[j].efuse_offs = volt_data[i].sr_efuse_offs;
86 nvalue_table[j].errminlimit = volt_data[i].sr_errminlimit;
87 nvalue_table[j].volt_nominal = volt_data[i].volt_nominal;
88
89 j++;
66 } 90 }
67 91
68 sr_data->nvalue_table = nvalue_table; 92 sr_data->nvalue_table = nvalue_table;
69 sr_data->nvalue_count = count; 93 sr_data->nvalue_count = j;
70} 94}
71 95
72static int __init sr_dev_init(struct omap_hwmod *oh, void *user) 96static int __init sr_dev_init(struct omap_hwmod *oh, void *user)
@@ -93,6 +117,7 @@ static int __init sr_dev_init(struct omap_hwmod *oh, void *user)
93 goto exit; 117 goto exit;
94 } 118 }
95 119
120 sr_data->name = oh->name;
96 sr_data->ip_type = oh->class->rev; 121 sr_data->ip_type = oh->class->rev;
97 sr_data->senn_mod = 0x1; 122 sr_data->senn_mod = 0x1;
98 sr_data->senp_mod = 0x1; 123 sr_data->senp_mod = 0x1;
@@ -106,7 +131,7 @@ static int __init sr_dev_init(struct omap_hwmod *oh, void *user)
106 131
107 omap_voltage_get_volttable(sr_data->voltdm, &volt_data); 132 omap_voltage_get_volttable(sr_data->voltdm, &volt_data);
108 if (!volt_data) { 133 if (!volt_data) {
109 pr_warning("%s: No Voltage table registerd fo VDD%d." 134 pr_warning("%s: No Voltage table registered fo VDD%d."
110 "Something really wrong\n\n", __func__, i + 1); 135 "Something really wrong\n\n", __func__, i + 1);
111 goto exit; 136 goto exit;
112 } 137 }
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 840929bd9da..2ff6d41ec6c 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -69,11 +69,6 @@
69#define OMAP3_SECURE_TIMER 1 69#define OMAP3_SECURE_TIMER 1
70#endif 70#endif
71 71
72/* MAX_GPTIMER_ID: number of GPTIMERs on the chip */
73#define MAX_GPTIMER_ID 12
74
75static u32 sys_timer_reserved;
76
77/* Clockevent code */ 72/* Clockevent code */
78 73
79static struct omap_dm_timer clkev; 74static struct omap_dm_timer clkev;
@@ -135,6 +130,7 @@ static struct clock_event_device clockevent_gpt = {
135 .name = "gp_timer", 130 .name = "gp_timer",
136 .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, 131 .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
137 .shift = 32, 132 .shift = 32,
133 .rating = 300,
138 .set_next_event = omap2_gp_timer_set_next_event, 134 .set_next_event = omap2_gp_timer_set_next_event,
139 .set_mode = omap2_gp_timer_set_mode, 135 .set_mode = omap2_gp_timer_set_mode,
140}; 136};
@@ -173,14 +169,14 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
173 return -ENXIO; 169 return -ENXIO;
174 170
175 /* After the dmtimer is using hwmod these clocks won't be needed */ 171 /* After the dmtimer is using hwmod these clocks won't be needed */
176 sprintf(name, "gpt%d_fck", gptimer_id); 172 timer->fclk = clk_get(NULL, omap_hwmod_get_main_clk(oh));
177 timer->fclk = clk_get(NULL, name);
178 if (IS_ERR(timer->fclk)) 173 if (IS_ERR(timer->fclk))
179 return -ENODEV; 174 return -ENODEV;
180 175
181 omap_hwmod_enable(oh); 176 omap_hwmod_enable(oh);
182 177
183 sys_timer_reserved |= (1 << (gptimer_id - 1)); 178 if (omap_dm_timer_reserve_systimer(gptimer_id))
179 return -ENODEV;
184 180
185 if (gptimer_id != 12) { 181 if (gptimer_id != 12) {
186 struct clk *src; 182 struct clk *src;
@@ -228,7 +224,8 @@ static void __init omap2_gp_clockevent_init(int gptimer_id,
228 clockevent_delta2ns(3, &clockevent_gpt); 224 clockevent_delta2ns(3, &clockevent_gpt);
229 /* Timer internal resynch latency. */ 225 /* Timer internal resynch latency. */
230 226
231 clockevent_gpt.cpumask = cpumask_of(0); 227 clockevent_gpt.cpumask = cpu_possible_mask;
228 clockevent_gpt.irq = omap_dm_timer_get_irq(&clkev);
232 clockevents_register_device(&clockevent_gpt); 229 clockevents_register_device(&clockevent_gpt);
233 230
234 pr_info("OMAP clockevent source: GPTIMER%d at %lu Hz\n", 231 pr_info("OMAP clockevent source: GPTIMER%d at %lu Hz\n",
@@ -368,6 +365,11 @@ OMAP_SYS_TIMER_INIT(3_secure, OMAP3_SECURE_TIMER, OMAP3_CLKEV_SOURCE,
368OMAP_SYS_TIMER(3_secure) 365OMAP_SYS_TIMER(3_secure)
369#endif 366#endif
370 367
368#ifdef CONFIG_SOC_AM33XX
369OMAP_SYS_TIMER_INIT(3_am33xx, 1, OMAP4_MPU_SOURCE, 2, OMAP4_MPU_SOURCE)
370OMAP_SYS_TIMER(3_am33xx)
371#endif
372
371#ifdef CONFIG_ARCH_OMAP4 373#ifdef CONFIG_ARCH_OMAP4
372#ifdef CONFIG_LOCAL_TIMERS 374#ifdef CONFIG_LOCAL_TIMERS
373static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, 375static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
@@ -393,65 +395,10 @@ static void __init omap4_timer_init(void)
393OMAP_SYS_TIMER(4) 395OMAP_SYS_TIMER(4)
394#endif 396#endif
395 397
396/** 398#ifdef CONFIG_SOC_OMAP5
397 * omap2_dm_timer_set_src - change the timer input clock source 399OMAP_SYS_TIMER_INIT(5, 1, OMAP4_CLKEV_SOURCE, 2, OMAP4_MPU_SOURCE)
398 * @pdev: timer platform device pointer 400OMAP_SYS_TIMER(5)
399 * @source: array index of parent clock source 401#endif
400 */
401static int omap2_dm_timer_set_src(struct platform_device *pdev, int source)
402{
403 int ret;
404 struct dmtimer_platform_data *pdata = pdev->dev.platform_data;
405 struct clk *fclk, *parent;
406 char *parent_name = NULL;
407
408 fclk = clk_get(&pdev->dev, "fck");
409 if (IS_ERR_OR_NULL(fclk)) {
410 dev_err(&pdev->dev, "%s: %d: clk_get() FAILED\n",
411 __func__, __LINE__);
412 return -EINVAL;
413 }
414
415 switch (source) {
416 case OMAP_TIMER_SRC_SYS_CLK:
417 parent_name = "sys_ck";
418 break;
419
420 case OMAP_TIMER_SRC_32_KHZ:
421 parent_name = "32k_ck";
422 break;
423
424 case OMAP_TIMER_SRC_EXT_CLK:
425 if (pdata->timer_ip_version == OMAP_TIMER_IP_VERSION_1) {
426 parent_name = "alt_ck";
427 break;
428 }
429 dev_err(&pdev->dev, "%s: %d: invalid clk src.\n",
430 __func__, __LINE__);
431 clk_put(fclk);
432 return -EINVAL;
433 }
434
435 parent = clk_get(&pdev->dev, parent_name);
436 if (IS_ERR_OR_NULL(parent)) {
437 dev_err(&pdev->dev, "%s: %d: clk_get() %s FAILED\n",
438 __func__, __LINE__, parent_name);
439 clk_put(fclk);
440 return -EINVAL;
441 }
442
443 ret = clk_set_parent(fclk, parent);
444 if (IS_ERR_VALUE(ret)) {
445 dev_err(&pdev->dev, "%s: clk_set_parent() to %s FAILED\n",
446 __func__, parent_name);
447 ret = -EINVAL;
448 }
449
450 clk_put(parent);
451 clk_put(fclk);
452
453 return ret;
454}
455 402
456/** 403/**
457 * omap_timer_init - build and register timer device with an 404 * omap_timer_init - build and register timer device with an
@@ -473,7 +420,6 @@ static int __init omap_timer_init(struct omap_hwmod *oh, void *unused)
473 struct dmtimer_platform_data *pdata; 420 struct dmtimer_platform_data *pdata;
474 struct platform_device *pdev; 421 struct platform_device *pdev;
475 struct omap_timer_capability_dev_attr *timer_dev_attr; 422 struct omap_timer_capability_dev_attr *timer_dev_attr;
476 struct powerdomain *pwrdm;
477 423
478 pr_debug("%s: %s\n", __func__, oh->name); 424 pr_debug("%s: %s\n", __func__, oh->name);
479 425
@@ -501,18 +447,9 @@ static int __init omap_timer_init(struct omap_hwmod *oh, void *unused)
501 */ 447 */
502 sscanf(oh->name, "timer%2d", &id); 448 sscanf(oh->name, "timer%2d", &id);
503 449
504 pdata->set_timer_src = omap2_dm_timer_set_src; 450 if (timer_dev_attr)
505 pdata->timer_ip_version = oh->class->rev; 451 pdata->timer_capability = timer_dev_attr->timer_capability;
506 452
507 /* Mark clocksource and clockevent timers as reserved */
508 if ((sys_timer_reserved >> (id - 1)) & 0x1)
509 pdata->reserved = 1;
510
511 pwrdm = omap_hwmod_get_pwrdm(oh);
512 pdata->loses_context = pwrdm_can_ever_lose_context(pwrdm);
513#ifdef CONFIG_PM
514 pdata->get_context_loss_count = omap_pm_get_dev_context_loss_count;
515#endif
516 pdev = omap_device_build(name, id, oh, pdata, sizeof(*pdata), 453 pdev = omap_device_build(name, id, oh, pdata, sizeof(*pdata),
517 NULL, 0, 0); 454 NULL, 0, 0);
518 455
diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c
index 43a97907533..db5ff664237 100644
--- a/arch/arm/mach-omap2/twl-common.c
+++ b/arch/arm/mach-omap2/twl-common.c
@@ -49,6 +49,7 @@ static struct i2c_board_info __initdata omap4_i2c1_board_info[] = {
49 }, 49 },
50}; 50};
51 51
52#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
52static int twl_set_voltage(void *data, int target_uV) 53static int twl_set_voltage(void *data, int target_uV)
53{ 54{
54 struct voltagedomain *voltdm = (struct voltagedomain *)data; 55 struct voltagedomain *voltdm = (struct voltagedomain *)data;
@@ -60,11 +61,13 @@ static int twl_get_voltage(void *data)
60 struct voltagedomain *voltdm = (struct voltagedomain *)data; 61 struct voltagedomain *voltdm = (struct voltagedomain *)data;
61 return voltdm_get_voltage(voltdm); 62 return voltdm_get_voltage(voltdm);
62} 63}
64#endif
63 65
64void __init omap_pmic_init(int bus, u32 clkrate, 66void __init omap_pmic_init(int bus, u32 clkrate,
65 const char *pmic_type, int pmic_irq, 67 const char *pmic_type, int pmic_irq,
66 struct twl4030_platform_data *pmic_data) 68 struct twl4030_platform_data *pmic_data)
67{ 69{
70 omap_mux_init_signal("sys_nirq", OMAP_PIN_INPUT_PULLUP | OMAP_PIN_OFF_WAKEUPENABLE);
68 strncpy(pmic_i2c_board_info.type, pmic_type, 71 strncpy(pmic_i2c_board_info.type, pmic_type,
69 sizeof(pmic_i2c_board_info.type)); 72 sizeof(pmic_i2c_board_info.type));
70 pmic_i2c_board_info.irq = pmic_irq; 73 pmic_i2c_board_info.irq = pmic_irq;
@@ -94,7 +97,7 @@ void __init omap4_pmic_init(const char *pmic_type,
94 97
95void __init omap_pmic_late_init(void) 98void __init omap_pmic_late_init(void)
96{ 99{
97 /* Init the OMAP TWL parameters (if PMIC has been registerd) */ 100 /* Init the OMAP TWL parameters (if PMIC has been registered) */
98 if (pmic_i2c_board_info.irq) 101 if (pmic_i2c_board_info.irq)
99 omap3_twl_init(); 102 omap3_twl_init();
100 if (omap4_i2c1_board_info[0].irq) 103 if (omap4_i2c1_board_info[0].irq)
@@ -213,10 +216,6 @@ static struct twl_regulator_driver_data omap3_vdd2_drvdata = {
213void __init omap3_pmic_get_config(struct twl4030_platform_data *pmic_data, 216void __init omap3_pmic_get_config(struct twl4030_platform_data *pmic_data,
214 u32 pdata_flags, u32 regulators_flags) 217 u32 pdata_flags, u32 regulators_flags)
215{ 218{
216 if (!pmic_data->irq_base)
217 pmic_data->irq_base = TWL4030_IRQ_BASE;
218 if (!pmic_data->irq_end)
219 pmic_data->irq_end = TWL4030_IRQ_END;
220 if (!pmic_data->vdd1) { 219 if (!pmic_data->vdd1) {
221 omap3_vdd1.driver_data = &omap3_vdd1_drvdata; 220 omap3_vdd1.driver_data = &omap3_vdd1_drvdata;
222 omap3_vdd1_drvdata.data = voltdm_lookup("mpu_iva"); 221 omap3_vdd1_drvdata.data = voltdm_lookup("mpu_iva");
@@ -481,11 +480,6 @@ static struct regulator_init_data omap4_v2v1_idata = {
481void __init omap4_pmic_get_config(struct twl4030_platform_data *pmic_data, 480void __init omap4_pmic_get_config(struct twl4030_platform_data *pmic_data,
482 u32 pdata_flags, u32 regulators_flags) 481 u32 pdata_flags, u32 regulators_flags)
483{ 482{
484 if (!pmic_data->irq_base)
485 pmic_data->irq_base = TWL6030_IRQ_BASE;
486 if (!pmic_data->irq_end)
487 pmic_data->irq_end = TWL6030_IRQ_END;
488
489 if (!pmic_data->vdd1) { 483 if (!pmic_data->vdd1) {
490 omap4_vdd1.driver_data = &omap4_vdd1_drvdata; 484 omap4_vdd1.driver_data = &omap4_vdd1_drvdata;
491 omap4_vdd1_drvdata.data = voltdm_lookup("mpu"); 485 omap4_vdd1_drvdata.data = voltdm_lookup("mpu");
diff --git a/arch/arm/mach-omap2/usb-fs.c b/arch/arm/mach-omap2/usb-fs.c
deleted file mode 100644
index 1481078763b..00000000000
--- a/arch/arm/mach-omap2/usb-fs.c
+++ /dev/null
@@ -1,359 +0,0 @@
1/*
2 * Platform level USB initialization for FS USB OTG controller on omap1 and 24xx
3 *
4 * Copyright (C) 2004 Texas Instruments, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/module.h>
22#include <linux/kernel.h>
23#include <linux/types.h>
24#include <linux/errno.h>
25#include <linux/init.h>
26#include <linux/platform_device.h>
27#include <linux/clk.h>
28#include <linux/err.h>
29
30#include <asm/irq.h>
31
32#include <plat/usb.h>
33#include <plat/board.h>
34
35#include "control.h"
36#include "mux.h"
37
38#define INT_USB_IRQ_GEN INT_24XX_USB_IRQ_GEN
39#define INT_USB_IRQ_NISO INT_24XX_USB_IRQ_NISO
40#define INT_USB_IRQ_ISO INT_24XX_USB_IRQ_ISO
41#define INT_USB_IRQ_HGEN INT_24XX_USB_IRQ_HGEN
42#define INT_USB_IRQ_OTG INT_24XX_USB_IRQ_OTG
43
44#if defined(CONFIG_ARCH_OMAP2)
45
46#ifdef CONFIG_USB_GADGET_OMAP
47
48static struct resource udc_resources[] = {
49 /* order is significant! */
50 { /* registers */
51 .start = UDC_BASE,
52 .end = UDC_BASE + 0xff,
53 .flags = IORESOURCE_MEM,
54 }, { /* general IRQ */
55 .start = INT_USB_IRQ_GEN,
56 .flags = IORESOURCE_IRQ,
57 }, { /* PIO IRQ */
58 .start = INT_USB_IRQ_NISO,
59 .flags = IORESOURCE_IRQ,
60 }, { /* SOF IRQ */
61 .start = INT_USB_IRQ_ISO,
62 .flags = IORESOURCE_IRQ,
63 },
64};
65
66static u64 udc_dmamask = ~(u32)0;
67
68static struct platform_device udc_device = {
69 .name = "omap_udc",
70 .id = -1,
71 .dev = {
72 .dma_mask = &udc_dmamask,
73 .coherent_dma_mask = 0xffffffff,
74 },
75 .num_resources = ARRAY_SIZE(udc_resources),
76 .resource = udc_resources,
77};
78
79static inline void udc_device_init(struct omap_usb_config *pdata)
80{
81 pdata->udc_device = &udc_device;
82}
83
84#else
85
86static inline void udc_device_init(struct omap_usb_config *pdata)
87{
88}
89
90#endif
91
92#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
93
94/* The dmamask must be set for OHCI to work */
95static u64 ohci_dmamask = ~(u32)0;
96
97static struct resource ohci_resources[] = {
98 {
99 .start = OMAP_OHCI_BASE,
100 .end = OMAP_OHCI_BASE + 0xff,
101 .flags = IORESOURCE_MEM,
102 },
103 {
104 .start = INT_USB_IRQ_HGEN,
105 .flags = IORESOURCE_IRQ,
106 },
107};
108
109static struct platform_device ohci_device = {
110 .name = "ohci",
111 .id = -1,
112 .dev = {
113 .dma_mask = &ohci_dmamask,
114 .coherent_dma_mask = 0xffffffff,
115 },
116 .num_resources = ARRAY_SIZE(ohci_resources),
117 .resource = ohci_resources,
118};
119
120static inline void ohci_device_init(struct omap_usb_config *pdata)
121{
122 pdata->ohci_device = &ohci_device;
123}
124
125#else
126
127static inline void ohci_device_init(struct omap_usb_config *pdata)
128{
129}
130
131#endif
132
133#if defined(CONFIG_USB_OTG) && defined(CONFIG_ARCH_OMAP_OTG)
134
135static struct resource otg_resources[] = {
136 /* order is significant! */
137 {
138 .start = OTG_BASE,
139 .end = OTG_BASE + 0xff,
140 .flags = IORESOURCE_MEM,
141 }, {
142 .start = INT_USB_IRQ_OTG,
143 .flags = IORESOURCE_IRQ,
144 },
145};
146
147static struct platform_device otg_device = {
148 .name = "omap_otg",
149 .id = -1,
150 .num_resources = ARRAY_SIZE(otg_resources),
151 .resource = otg_resources,
152};
153
154static inline void otg_device_init(struct omap_usb_config *pdata)
155{
156 pdata->otg_device = &otg_device;
157}
158
159#else
160
161static inline void otg_device_init(struct omap_usb_config *pdata)
162{
163}
164
165#endif
166
167static void omap2_usb_devconf_clear(u8 port, u32 mask)
168{
169 u32 r;
170
171 r = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
172 r &= ~USBTXWRMODEI(port, mask);
173 omap_ctrl_writel(r, OMAP2_CONTROL_DEVCONF0);
174}
175
176static void omap2_usb_devconf_set(u8 port, u32 mask)
177{
178 u32 r;
179
180 r = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
181 r |= USBTXWRMODEI(port, mask);
182 omap_ctrl_writel(r, OMAP2_CONTROL_DEVCONF0);
183}
184
185static void omap2_usb2_disable_5pinbitll(void)
186{
187 u32 r;
188
189 r = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
190 r &= ~(USBTXWRMODEI(2, USB_BIDIR_TLL) | USBT2TLL5PI);
191 omap_ctrl_writel(r, OMAP2_CONTROL_DEVCONF0);
192}
193
194static void omap2_usb2_enable_5pinunitll(void)
195{
196 u32 r;
197
198 r = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
199 r |= USBTXWRMODEI(2, USB_UNIDIR_TLL) | USBT2TLL5PI;
200 omap_ctrl_writel(r, OMAP2_CONTROL_DEVCONF0);
201}
202
203static u32 __init omap2_usb0_init(unsigned nwires, unsigned is_device)
204{
205 u32 syscon1 = 0;
206
207 omap2_usb_devconf_clear(0, USB_BIDIR_TLL);
208
209 if (nwires == 0)
210 return 0;
211
212 if (is_device)
213 omap_mux_init_signal("usb0_puen", 0);
214
215 omap_mux_init_signal("usb0_dat", 0);
216 omap_mux_init_signal("usb0_txen", 0);
217 omap_mux_init_signal("usb0_se0", 0);
218 if (nwires != 3)
219 omap_mux_init_signal("usb0_rcv", 0);
220
221 switch (nwires) {
222 case 3:
223 syscon1 = 2;
224 omap2_usb_devconf_set(0, USB_BIDIR);
225 break;
226 case 4:
227 syscon1 = 1;
228 omap2_usb_devconf_set(0, USB_BIDIR);
229 break;
230 case 6:
231 syscon1 = 3;
232 omap_mux_init_signal("usb0_vp", 0);
233 omap_mux_init_signal("usb0_vm", 0);
234 omap2_usb_devconf_set(0, USB_UNIDIR);
235 break;
236 default:
237 printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
238 0, nwires);
239 }
240
241 return syscon1 << 16;
242}
243
244static u32 __init omap2_usb1_init(unsigned nwires)
245{
246 u32 syscon1 = 0;
247
248 omap2_usb_devconf_clear(1, USB_BIDIR_TLL);
249
250 if (nwires == 0)
251 return 0;
252
253 /* NOTE: board-specific code must set up pin muxing for usb1,
254 * since each signal could come out on either of two balls.
255 */
256
257 switch (nwires) {
258 case 2:
259 /* NOTE: board-specific code must override this setting if
260 * this TLL link is not using DP/DM
261 */
262 syscon1 = 1;
263 omap2_usb_devconf_set(1, USB_BIDIR_TLL);
264 break;
265 case 3:
266 syscon1 = 2;
267 omap2_usb_devconf_set(1, USB_BIDIR);
268 break;
269 case 4:
270 syscon1 = 1;
271 omap2_usb_devconf_set(1, USB_BIDIR);
272 break;
273 case 6:
274 default:
275 printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
276 1, nwires);
277 }
278
279 return syscon1 << 20;
280}
281
282static u32 __init omap2_usb2_init(unsigned nwires, unsigned alt_pingroup)
283{
284 u32 syscon1 = 0;
285
286 omap2_usb2_disable_5pinbitll();
287 alt_pingroup = 0;
288
289 /* NOTE omap1 erratum: must leave USB2_UNI_R set if usb0 in use */
290 if (alt_pingroup || nwires == 0)
291 return 0;
292
293 omap_mux_init_signal("usb2_dat", 0);
294 omap_mux_init_signal("usb2_se0", 0);
295 if (nwires > 2)
296 omap_mux_init_signal("usb2_txen", 0);
297 if (nwires > 3)
298 omap_mux_init_signal("usb2_rcv", 0);
299
300 switch (nwires) {
301 case 2:
302 /* NOTE: board-specific code must override this setting if
303 * this TLL link is not using DP/DM
304 */
305 syscon1 = 1;
306 omap2_usb_devconf_set(2, USB_BIDIR_TLL);
307 break;
308 case 3:
309 syscon1 = 2;
310 omap2_usb_devconf_set(2, USB_BIDIR);
311 break;
312 case 4:
313 syscon1 = 1;
314 omap2_usb_devconf_set(2, USB_BIDIR);
315 break;
316 case 5:
317 /* NOTE: board-specific code must mux this setting depending
318 * on TLL link using DP/DM. Something must also
319 * set up OTG_SYSCON2.HMC_TLL{ATTACH,SPEED}
320 * 2420: hdq_sio.usb2_tllse0 or vlynq_rx0.usb2_tllse0
321 * 2430: hdq_sio.usb2_tllse0 or sdmmc2_dat0.usb2_tllse0
322 */
323
324 syscon1 = 3;
325 omap2_usb2_enable_5pinunitll();
326 break;
327 case 6:
328 default:
329 printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
330 2, nwires);
331 }
332
333 return syscon1 << 24;
334}
335
336void __init omap2_usbfs_init(struct omap_usb_config *pdata)
337{
338 struct clk *ick;
339
340 if (!cpu_is_omap24xx())
341 return;
342
343 ick = clk_get(NULL, "usb_l4_ick");
344 if (IS_ERR(ick))
345 return;
346
347 clk_enable(ick);
348 pdata->usb0_init = omap2_usb0_init;
349 pdata->usb1_init = omap2_usb1_init;
350 pdata->usb2_init = omap2_usb2_init;
351 udc_device_init(pdata);
352 ohci_device_init(pdata);
353 otg_device_init(pdata);
354 omap_otg_init(pdata);
355 clk_disable(ick);
356 clk_put(ick);
357}
358
359#endif
diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h
index 16a1b092cf3..0ac2caf1594 100644
--- a/arch/arm/mach-omap2/voltage.h
+++ b/arch/arm/mach-omap2/voltage.h
@@ -16,6 +16,8 @@
16 16
17#include <linux/err.h> 17#include <linux/err.h>
18 18
19#include <plat/voltage.h>
20
19#include "vc.h" 21#include "vc.h"
20#include "vp.h" 22#include "vp.h"
21 23
@@ -91,25 +93,6 @@ struct voltagedomain {
91}; 93};
92 94
93/** 95/**
94 * struct omap_volt_data - Omap voltage specific data.
95 * @voltage_nominal: The possible voltage value in uV
96 * @sr_efuse_offs: The offset of the efuse register(from system
97 * control module base address) from where to read
98 * the n-target value for the smartreflex module.
99 * @sr_errminlimit: Error min limit value for smartreflex. This value
100 * differs at differnet opp and thus is linked
101 * with voltage.
102 * @vp_errorgain: Error gain value for the voltage processor. This
103 * field also differs according to the voltage/opp.
104 */
105struct omap_volt_data {
106 u32 volt_nominal;
107 u32 sr_efuse_offs;
108 u8 sr_errminlimit;
109 u8 vp_errgain;
110};
111
112/**
113 * struct omap_voltdm_pmic - PMIC specific data required by voltage driver. 96 * struct omap_voltdm_pmic - PMIC specific data required by voltage driver.
114 * @slew_rate: PMIC slew rate (in uv/us) 97 * @slew_rate: PMIC slew rate (in uv/us)
115 * @step_size: PMIC voltage step size (in uv) 98 * @step_size: PMIC voltage step size (in uv)
@@ -156,6 +139,7 @@ int omap_voltage_late_init(void);
156 139
157extern void omap2xxx_voltagedomains_init(void); 140extern void omap2xxx_voltagedomains_init(void);
158extern void omap3xxx_voltagedomains_init(void); 141extern void omap3xxx_voltagedomains_init(void);
142extern void am33xx_voltagedomains_init(void);
159extern void omap44xx_voltagedomains_init(void); 143extern void omap44xx_voltagedomains_init(void);
160 144
161struct voltagedomain *voltdm_lookup(const char *name); 145struct voltagedomain *voltdm_lookup(const char *name);
diff --git a/arch/arm/mach-omap2/voltagedomains33xx_data.c b/arch/arm/mach-omap2/voltagedomains33xx_data.c
new file mode 100644
index 00000000000..965458dc0cb
--- /dev/null
+++ b/arch/arm/mach-omap2/voltagedomains33xx_data.c
@@ -0,0 +1,43 @@
1/*
2 * AM33XX voltage domain data
3 *
4 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.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 as
8 * published by the Free Software Foundation version 2.
9 *
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/kernel.h>
17#include <linux/init.h>
18
19#include "voltage.h"
20
21static struct voltagedomain am33xx_voltdm_mpu = {
22 .name = "mpu",
23};
24
25static struct voltagedomain am33xx_voltdm_core = {
26 .name = "core",
27};
28
29static struct voltagedomain am33xx_voltdm_rtc = {
30 .name = "rtc",
31};
32
33static struct voltagedomain *voltagedomains_am33xx[] __initdata = {
34 &am33xx_voltdm_mpu,
35 &am33xx_voltdm_core,
36 &am33xx_voltdm_rtc,
37 NULL,
38};
39
40void __init am33xx_voltagedomains_init(void)
41{
42 voltdm_init(voltagedomains_am33xx);
43}
diff --git a/arch/arm/mach-orion5x/common.c b/arch/arm/mach-orion5x/common.c
index 9148b229d0d..410291c6766 100644
--- a/arch/arm/mach-orion5x/common.c
+++ b/arch/arm/mach-orion5x/common.c
@@ -109,7 +109,8 @@ void __init orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data)
109{ 109{
110 orion_ge00_init(eth_data, 110 orion_ge00_init(eth_data,
111 ORION5X_ETH_PHYS_BASE, IRQ_ORION5X_ETH_SUM, 111 ORION5X_ETH_PHYS_BASE, IRQ_ORION5X_ETH_SUM,
112 IRQ_ORION5X_ETH_ERR); 112 IRQ_ORION5X_ETH_ERR,
113 MV643XX_TX_CSUM_DEFAULT_LIMIT);
113} 114}
114 115
115 116
diff --git a/arch/arm/mach-orion5x/irq.c b/arch/arm/mach-orion5x/irq.c
index b1b45fff776..17da7091d31 100644
--- a/arch/arm/mach-orion5x/irq.c
+++ b/arch/arm/mach-orion5x/irq.c
@@ -11,19 +11,16 @@
11 */ 11 */
12#include <linux/gpio.h> 12#include <linux/gpio.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/irq.h> 14#include <linux/irq.h>
16#include <linux/io.h>
17#include <mach/bridge-regs.h> 15#include <mach/bridge-regs.h>
18#include <plat/irq.h> 16#include <plat/irq.h>
19#include "common.h"
20 17
21static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc) 18static int __initdata gpio0_irqs[4] = {
22{ 19 IRQ_ORION5X_GPIO_0_7,
23 BUG_ON(irq < IRQ_ORION5X_GPIO_0_7 || irq > IRQ_ORION5X_GPIO_24_31); 20 IRQ_ORION5X_GPIO_8_15,
24 21 IRQ_ORION5X_GPIO_16_23,
25 orion_gpio_irq_handler((irq - IRQ_ORION5X_GPIO_0_7) << 3); 22 IRQ_ORION5X_GPIO_24_31,
26} 23};
27 24
28void __init orion5x_init_irq(void) 25void __init orion5x_init_irq(void)
29{ 26{
@@ -32,9 +29,6 @@ void __init orion5x_init_irq(void)
32 /* 29 /*
33 * Initialize gpiolib for GPIOs 0-31. 30 * Initialize gpiolib for GPIOs 0-31.
34 */ 31 */
35 orion_gpio_init(0, 32, GPIO_VIRT_BASE, 0, IRQ_ORION5X_GPIO_START); 32 orion_gpio_init(NULL, 0, 32, (void __iomem *)GPIO_VIRT_BASE, 0,
36 irq_set_chained_handler(IRQ_ORION5X_GPIO_0_7, gpio_irq_handler); 33 IRQ_ORION5X_GPIO_START, gpio0_irqs);
37 irq_set_chained_handler(IRQ_ORION5X_GPIO_8_15, gpio_irq_handler);
38 irq_set_chained_handler(IRQ_ORION5X_GPIO_16_23, gpio_irq_handler);
39 irq_set_chained_handler(IRQ_ORION5X_GPIO_24_31, gpio_irq_handler);
40} 34}
diff --git a/arch/arm/mach-picoxcell/Makefile b/arch/arm/mach-picoxcell/Makefile
index e5ec4a8d9bc..8e39f80fce1 100644
--- a/arch/arm/mach-picoxcell/Makefile
+++ b/arch/arm/mach-picoxcell/Makefile
@@ -1,2 +1 @@
1obj-y := common.o obj-y := common.o
2obj-y += time.o
diff --git a/arch/arm/mach-picoxcell/common.c b/arch/arm/mach-picoxcell/common.c
index a2e8ae8b582..8f9a0b47a7f 100644
--- a/arch/arm/mach-picoxcell/common.c
+++ b/arch/arm/mach-picoxcell/common.c
@@ -14,6 +14,7 @@
14#include <linux/of_address.h> 14#include <linux/of_address.h>
15#include <linux/of_irq.h> 15#include <linux/of_irq.h>
16#include <linux/of_platform.h> 16#include <linux/of_platform.h>
17#include <linux/dw_apb_timer.h>
17 18
18#include <asm/mach/arch.h> 19#include <asm/mach/arch.h>
19#include <asm/hardware/vic.h> 20#include <asm/hardware/vic.h>
@@ -97,7 +98,7 @@ DT_MACHINE_START(PICOXCELL, "Picochip picoXcell")
97 .nr_irqs = NR_IRQS_LEGACY, 98 .nr_irqs = NR_IRQS_LEGACY,
98 .init_irq = picoxcell_init_irq, 99 .init_irq = picoxcell_init_irq,
99 .handle_irq = vic_handle_irq, 100 .handle_irq = vic_handle_irq,
100 .timer = &picoxcell_timer, 101 .timer = &dw_apb_timer,
101 .init_machine = picoxcell_init_machine, 102 .init_machine = picoxcell_init_machine,
102 .dt_compat = picoxcell_dt_match, 103 .dt_compat = picoxcell_dt_match,
103 .restart = picoxcell_wdt_restart, 104 .restart = picoxcell_wdt_restart,
diff --git a/arch/arm/mach-picoxcell/common.h b/arch/arm/mach-picoxcell/common.h
index 83d55ab956a..a65cb02f84c 100644
--- a/arch/arm/mach-picoxcell/common.h
+++ b/arch/arm/mach-picoxcell/common.h
@@ -12,6 +12,6 @@
12 12
13#include <asm/mach/time.h> 13#include <asm/mach/time.h>
14 14
15extern struct sys_timer picoxcell_timer; 15extern struct sys_timer dw_apb_timer;
16 16
17#endif /* __PICOXCELL_COMMON_H__ */ 17#endif /* __PICOXCELL_COMMON_H__ */
diff --git a/arch/arm/mach-picoxcell/time.c b/arch/arm/mach-picoxcell/time.c
deleted file mode 100644
index 2ecba6743b8..00000000000
--- a/arch/arm/mach-picoxcell/time.c
+++ /dev/null
@@ -1,121 +0,0 @@
1/*
2 * Copyright (c) 2011 Picochip Ltd., Jamie Iles
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 * All enquiries to support@picochip.com
9 */
10#include <linux/dw_apb_timer.h>
11#include <linux/of.h>
12#include <linux/of_address.h>
13#include <linux/of_irq.h>
14
15#include <asm/mach/time.h>
16#include <asm/sched_clock.h>
17
18#include "common.h"
19
20static void timer_get_base_and_rate(struct device_node *np,
21 void __iomem **base, u32 *rate)
22{
23 *base = of_iomap(np, 0);
24
25 if (!*base)
26 panic("Unable to map regs for %s", np->name);
27
28 if (of_property_read_u32(np, "clock-freq", rate))
29 panic("No clock-freq property for %s", np->name);
30}
31
32static void picoxcell_add_clockevent(struct device_node *event_timer)
33{
34 void __iomem *iobase;
35 struct dw_apb_clock_event_device *ced;
36 u32 irq, rate;
37
38 irq = irq_of_parse_and_map(event_timer, 0);
39 if (irq == NO_IRQ)
40 panic("No IRQ for clock event timer");
41
42 timer_get_base_and_rate(event_timer, &iobase, &rate);
43
44 ced = dw_apb_clockevent_init(0, event_timer->name, 300, iobase, irq,
45 rate);
46 if (!ced)
47 panic("Unable to initialise clockevent device");
48
49 dw_apb_clockevent_register(ced);
50}
51
52static void picoxcell_add_clocksource(struct device_node *source_timer)
53{
54 void __iomem *iobase;
55 struct dw_apb_clocksource *cs;
56 u32 rate;
57
58 timer_get_base_and_rate(source_timer, &iobase, &rate);
59
60 cs = dw_apb_clocksource_init(300, source_timer->name, iobase, rate);
61 if (!cs)
62 panic("Unable to initialise clocksource device");
63
64 dw_apb_clocksource_start(cs);
65 dw_apb_clocksource_register(cs);
66}
67
68static void __iomem *sched_io_base;
69
70static u32 picoxcell_read_sched_clock(void)
71{
72 return __raw_readl(sched_io_base);
73}
74
75static const struct of_device_id picoxcell_rtc_ids[] __initconst = {
76 { .compatible = "picochip,pc3x2-rtc" },
77 { /* Sentinel */ },
78};
79
80static void picoxcell_init_sched_clock(void)
81{
82 struct device_node *sched_timer;
83 u32 rate;
84
85 sched_timer = of_find_matching_node(NULL, picoxcell_rtc_ids);
86 if (!sched_timer)
87 panic("No RTC for sched clock to use");
88
89 timer_get_base_and_rate(sched_timer, &sched_io_base, &rate);
90 of_node_put(sched_timer);
91
92 setup_sched_clock(picoxcell_read_sched_clock, 32, rate);
93}
94
95static const struct of_device_id picoxcell_timer_ids[] __initconst = {
96 { .compatible = "picochip,pc3x2-timer" },
97 {},
98};
99
100static void __init picoxcell_timer_init(void)
101{
102 struct device_node *event_timer, *source_timer;
103
104 event_timer = of_find_matching_node(NULL, picoxcell_timer_ids);
105 if (!event_timer)
106 panic("No timer for clockevent");
107 picoxcell_add_clockevent(event_timer);
108
109 source_timer = of_find_matching_node(event_timer, picoxcell_timer_ids);
110 if (!source_timer)
111 panic("No timer for clocksource");
112 picoxcell_add_clocksource(source_timer);
113
114 of_node_put(source_timer);
115
116 picoxcell_init_sched_clock();
117}
118
119struct sys_timer picoxcell_timer = {
120 .init = picoxcell_timer_init,
121};
diff --git a/arch/arm/mach-prima2/include/mach/gpio.h b/arch/arm/mach-prima2/include/mach/gpio.h
new file mode 100644
index 00000000000..1904bb03876
--- /dev/null
+++ b/arch/arm/mach-prima2/include/mach/gpio.h
@@ -0,0 +1,13 @@
1#ifndef __MACH_GPIO_H
2#define __MACH_GPIO_H
3
4/* Pull up/down values */
5enum sirfsoc_gpio_pull {
6 SIRFSOC_GPIO_PULL_NONE,
7 SIRFSOC_GPIO_PULL_UP,
8 SIRFSOC_GPIO_PULL_DOWN,
9};
10
11void sirfsoc_gpio_set_pull(unsigned gpio, unsigned mode);
12
13#endif
diff --git a/arch/arm/mach-prima2/include/mach/irqs.h b/arch/arm/mach-prima2/include/mach/irqs.h
index bb354f952fd..f6014a07541 100644
--- a/arch/arm/mach-prima2/include/mach/irqs.h
+++ b/arch/arm/mach-prima2/include/mach/irqs.h
@@ -11,7 +11,7 @@
11 11
12#define SIRFSOC_INTENAL_IRQ_START 0 12#define SIRFSOC_INTENAL_IRQ_START 0
13#define SIRFSOC_INTENAL_IRQ_END 59 13#define SIRFSOC_INTENAL_IRQ_END 59
14 14#define SIRFSOC_GPIO_IRQ_START (SIRFSOC_INTENAL_IRQ_END + 1)
15#define NR_IRQS 220 15#define NR_IRQS 220
16 16
17#endif 17#endif
diff --git a/arch/arm/mach-prima2/timer.c b/arch/arm/mach-prima2/timer.c
index 0d024b1e916..f224107de7b 100644
--- a/arch/arm/mach-prima2/timer.c
+++ b/arch/arm/mach-prima2/timer.c
@@ -132,11 +132,11 @@ static void sirfsoc_clocksource_resume(struct clocksource *cs)
132{ 132{
133 int i; 133 int i;
134 134
135 for (i = 0; i < SIRFSOC_TIMER_REG_CNT; i++) 135 for (i = 0; i < SIRFSOC_TIMER_REG_CNT - 2; i++)
136 writel_relaxed(sirfsoc_timer_reg_val[i], sirfsoc_timer_base + sirfsoc_timer_reg_list[i]); 136 writel_relaxed(sirfsoc_timer_reg_val[i], sirfsoc_timer_base + sirfsoc_timer_reg_list[i]);
137 137
138 writel_relaxed(sirfsoc_timer_reg_val[i - 2], sirfsoc_timer_base + SIRFSOC_TIMER_COUNTER_LO); 138 writel_relaxed(sirfsoc_timer_reg_val[SIRFSOC_TIMER_REG_CNT - 2], sirfsoc_timer_base + SIRFSOC_TIMER_COUNTER_LO);
139 writel_relaxed(sirfsoc_timer_reg_val[i - 1], sirfsoc_timer_base + SIRFSOC_TIMER_COUNTER_HI); 139 writel_relaxed(sirfsoc_timer_reg_val[SIRFSOC_TIMER_REG_CNT - 1], sirfsoc_timer_base + SIRFSOC_TIMER_COUNTER_HI);
140} 140}
141 141
142static struct clock_event_device sirfsoc_clockevent = { 142static struct clock_event_device sirfsoc_clockevent = {
diff --git a/arch/arm/mach-pxa/eseries.h b/arch/arm/mach-pxa/eseries.h
deleted file mode 100644
index b96949dd5ad..00000000000
--- a/arch/arm/mach-pxa/eseries.h
+++ /dev/null
@@ -1,14 +0,0 @@
1void __init eseries_fixup(struct tag *tags, char **cmdline, struct meminfo *mi);
2
3extern struct pxa2xx_udc_mach_info e7xx_udc_mach_info;
4extern struct pxaficp_platform_data e7xx_ficp_platform_data;
5extern int e7xx_irda_init(void);
6
7extern int eseries_tmio_enable(struct platform_device *dev);
8extern int eseries_tmio_disable(struct platform_device *dev);
9extern int eseries_tmio_suspend(struct platform_device *dev);
10extern int eseries_tmio_resume(struct platform_device *dev);
11extern void eseries_get_tmio_gpios(void);
12extern struct resource eseries_tmio_resources[];
13extern struct platform_device e300_tc6387xb_device;
14
diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c
index d3de84b0dcb..e6311988add 100644
--- a/arch/arm/mach-pxa/hx4700.c
+++ b/arch/arm/mach-pxa/hx4700.c
@@ -296,27 +296,11 @@ static struct asic3_led asic3_leds[ASIC3_NUM_LEDS] = {
296 296
297static struct resource asic3_resources[] = { 297static struct resource asic3_resources[] = {
298 /* GPIO part */ 298 /* GPIO part */
299 [0] = { 299 [0] = DEFINE_RES_MEM(ASIC3_PHYS, ASIC3_MAP_SIZE_16BIT),
300 .start = ASIC3_PHYS, 300 [1] = DEFINE_RES_IRQ(PXA_GPIO_TO_IRQ(GPIO12_HX4700_ASIC3_IRQ)),
301 .end = ASIC3_PHYS + ASIC3_MAP_SIZE_16BIT - 1,
302 .flags = IORESOURCE_MEM,
303 },
304 [1] = {
305 .start = PXA_GPIO_TO_IRQ(GPIO12_HX4700_ASIC3_IRQ),
306 .end = PXA_GPIO_TO_IRQ(GPIO12_HX4700_ASIC3_IRQ),
307 .flags = IORESOURCE_IRQ,
308 },
309 /* SD part */ 301 /* SD part */
310 [2] = { 302 [2] = DEFINE_RES_MEM(ASIC3_SD_PHYS, ASIC3_MAP_SIZE_16BIT),
311 .start = ASIC3_SD_PHYS, 303 [3] = DEFINE_RES_IRQ(PXA_GPIO_TO_IRQ(GPIO66_HX4700_ASIC3_nSDIO_IRQ)),
312 .end = ASIC3_SD_PHYS + ASIC3_MAP_SIZE_16BIT - 1,
313 .flags = IORESOURCE_MEM,
314 },
315 [3] = {
316 .start = PXA_GPIO_TO_IRQ(GPIO66_HX4700_ASIC3_nSDIO_IRQ),
317 .end = PXA_GPIO_TO_IRQ(GPIO66_HX4700_ASIC3_nSDIO_IRQ),
318 .flags = IORESOURCE_IRQ,
319 },
320}; 304};
321 305
322static struct asic3_platform_data asic3_platform_data = { 306static struct asic3_platform_data asic3_platform_data = {
@@ -343,11 +327,7 @@ static struct platform_device asic3 = {
343 */ 327 */
344 328
345static struct resource egpio_resources[] = { 329static struct resource egpio_resources[] = {
346 [0] = { 330 [0] = DEFINE_RES_MEM(PXA_CS5_PHYS, 0x4),
347 .start = PXA_CS5_PHYS,
348 .end = PXA_CS5_PHYS + 0x4 - 1,
349 .flags = IORESOURCE_MEM,
350 },
351}; 331};
352 332
353static struct htc_egpio_chip egpio_chips[] = { 333static struct htc_egpio_chip egpio_chips[] = {
@@ -537,11 +517,7 @@ static struct w100fb_mach_info w3220_info = {
537}; 517};
538 518
539static struct resource w3220_resources[] = { 519static struct resource w3220_resources[] = {
540 [0] = { 520 [0] = DEFINE_RES_MEM(ATI_W3220_PHYS, SZ_16M),
541 .start = ATI_W3220_PHYS,
542 .end = ATI_W3220_PHYS + 0x00ffffff,
543 .flags = IORESOURCE_MEM,
544 },
545}; 521};
546 522
547static struct platform_device w3220 = { 523static struct platform_device w3220 = {
@@ -683,20 +659,12 @@ static struct pda_power_pdata power_supply_info = {
683}; 659};
684 660
685static struct resource power_supply_resources[] = { 661static struct resource power_supply_resources[] = {
686 [0] = { 662 [0] = DEFINE_RES_NAMED(PXA_GPIO_TO_IRQ(GPIOD9_nAC_IN), 1, "ac",
687 .name = "ac", 663 IORESOURCE_IRQ |
688 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE | 664 IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE),
689 IORESOURCE_IRQ_LOWEDGE, 665 [1] = DEFINE_RES_NAMED(PXA_GPIO_TO_IRQ(GPIOD14_nUSBC_DETECT), 1, "usb",
690 .start = PXA_GPIO_TO_IRQ(GPIOD9_nAC_IN), 666 IORESOURCE_IRQ |
691 .end = PXA_GPIO_TO_IRQ(GPIOD9_nAC_IN), 667 IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE),
692 },
693 [1] = {
694 .name = "usb",
695 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
696 IORESOURCE_IRQ_LOWEDGE,
697 .start = PXA_GPIO_TO_IRQ(GPIOD14_nUSBC_DETECT),
698 .end = PXA_GPIO_TO_IRQ(GPIOD14_nUSBC_DETECT),
699 },
700}; 668};
701 669
702static struct platform_device power_supply = { 670static struct platform_device power_supply = {
diff --git a/arch/arm/mach-pxa/include/mach/regs-ost.h b/arch/arm/mach-pxa/include/mach/regs-ost.h
index a3e5f86ef67..628819995c5 100644
--- a/arch/arm/mach-pxa/include/mach/regs-ost.h
+++ b/arch/arm/mach-pxa/include/mach/regs-ost.h
@@ -7,17 +7,17 @@
7 * OS Timer & Match Registers 7 * OS Timer & Match Registers
8 */ 8 */
9 9
10#define OSMR0 __REG(0x40A00000) /* */ 10#define OSMR0 io_p2v(0x40A00000) /* */
11#define OSMR1 __REG(0x40A00004) /* */ 11#define OSMR1 io_p2v(0x40A00004) /* */
12#define OSMR2 __REG(0x40A00008) /* */ 12#define OSMR2 io_p2v(0x40A00008) /* */
13#define OSMR3 __REG(0x40A0000C) /* */ 13#define OSMR3 io_p2v(0x40A0000C) /* */
14#define OSMR4 __REG(0x40A00080) /* */ 14#define OSMR4 io_p2v(0x40A00080) /* */
15#define OSCR __REG(0x40A00010) /* OS Timer Counter Register */ 15#define OSCR io_p2v(0x40A00010) /* OS Timer Counter Register */
16#define OSCR4 __REG(0x40A00040) /* OS Timer Counter Register */ 16#define OSCR4 io_p2v(0x40A00040) /* OS Timer Counter Register */
17#define OMCR4 __REG(0x40A000C0) /* */ 17#define OMCR4 io_p2v(0x40A000C0) /* */
18#define OSSR __REG(0x40A00014) /* OS Timer Status Register */ 18#define OSSR io_p2v(0x40A00014) /* OS Timer Status Register */
19#define OWER __REG(0x40A00018) /* OS Timer Watchdog Enable Register */ 19#define OWER io_p2v(0x40A00018) /* OS Timer Watchdog Enable Register */
20#define OIER __REG(0x40A0001C) /* OS Timer Interrupt Enable Register */ 20#define OIER io_p2v(0x40A0001C) /* OS Timer Interrupt Enable Register */
21 21
22#define OSSR_M3 (1 << 3) /* Match status channel 3 */ 22#define OSSR_M3 (1 << 3) /* Match status channel 3 */
23#define OSSR_M2 (1 << 2) /* Match status channel 2 */ 23#define OSSR_M2 (1 << 2) /* Match status channel 2 */
diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c
index 6bb3f47b1f1..0ca0db78790 100644
--- a/arch/arm/mach-pxa/lubbock.c
+++ b/arch/arm/mach-pxa/lubbock.c
@@ -456,7 +456,7 @@ static int lubbock_mci_init(struct device *dev,
456 init_timer(&mmc_timer); 456 init_timer(&mmc_timer);
457 mmc_timer.data = (unsigned long) data; 457 mmc_timer.data = (unsigned long) data;
458 return request_irq(LUBBOCK_SD_IRQ, lubbock_detect_int, 458 return request_irq(LUBBOCK_SD_IRQ, lubbock_detect_int,
459 IRQF_SAMPLE_RANDOM, "lubbock-sd-detect", data); 459 0, "lubbock-sd-detect", data);
460} 460}
461 461
462static int lubbock_mci_get_ro(struct device *dev) 462static int lubbock_mci_get_ro(struct device *dev)
diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c
index 2db697cd2b4..39561dcf65f 100644
--- a/arch/arm/mach-pxa/magician.c
+++ b/arch/arm/mach-pxa/magician.c
@@ -633,9 +633,8 @@ static struct platform_device bq24022 = {
633static int magician_mci_init(struct device *dev, 633static int magician_mci_init(struct device *dev,
634 irq_handler_t detect_irq, void *data) 634 irq_handler_t detect_irq, void *data)
635{ 635{
636 return request_irq(IRQ_MAGICIAN_SD, detect_irq, 636 return request_irq(IRQ_MAGICIAN_SD, detect_irq, IRQF_DISABLED,
637 IRQF_DISABLED | IRQF_SAMPLE_RANDOM, 637 "mmc card detect", data);
638 "mmc card detect", data);
639} 638}
640 639
641static void magician_mci_exit(struct device *dev, void *data) 640static void magician_mci_exit(struct device *dev, void *data)
diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c
index 5905ed130e9..d89d87ae144 100644
--- a/arch/arm/mach-pxa/raumfeld.c
+++ b/arch/arm/mach-pxa/raumfeld.c
@@ -953,12 +953,12 @@ static struct i2c_board_info raumfeld_connector_i2c_board_info __initdata = {
953 953
954static struct eeti_ts_platform_data eeti_ts_pdata = { 954static struct eeti_ts_platform_data eeti_ts_pdata = {
955 .irq_active_high = 1, 955 .irq_active_high = 1,
956 .irq_gpio = GPIO_TOUCH_IRQ,
956}; 957};
957 958
958static struct i2c_board_info raumfeld_controller_i2c_board_info __initdata = { 959static struct i2c_board_info raumfeld_controller_i2c_board_info __initdata = {
959 .type = "eeti_ts", 960 .type = "eeti_ts",
960 .addr = 0x0a, 961 .addr = 0x0a,
961 .irq = PXA_GPIO_TO_IRQ(GPIO_TOUCH_IRQ),
962 .platform_data = &eeti_ts_pdata, 962 .platform_data = &eeti_ts_pdata,
963}; 963};
964 964
diff --git a/arch/arm/mach-pxa/reset.c b/arch/arm/mach-pxa/reset.c
index b4528899ef0..3fab583755d 100644
--- a/arch/arm/mach-pxa/reset.c
+++ b/arch/arm/mach-pxa/reset.c
@@ -77,9 +77,10 @@ static void do_gpio_reset(void)
77static void do_hw_reset(void) 77static void do_hw_reset(void)
78{ 78{
79 /* Initialize the watchdog and let it fire */ 79 /* Initialize the watchdog and let it fire */
80 OWER = OWER_WME; 80 writel_relaxed(OWER_WME, OWER);
81 OSSR = OSSR_M3; 81 writel_relaxed(OSSR_M3, OSSR);
82 OSMR3 = OSCR + 368640; /* ... in 100 ms */ 82 /* ... in 100 ms */
83 writel_relaxed(readl_relaxed(OSCR) + 368640, OSMR3);
83} 84}
84 85
85void pxa_restart(char mode, const char *cmd) 86void pxa_restart(char mode, const char *cmd)
diff --git a/arch/arm/mach-pxa/time.c b/arch/arm/mach-pxa/time.c
index 3d6c9bd90de..4bc47d63698 100644
--- a/arch/arm/mach-pxa/time.c
+++ b/arch/arm/mach-pxa/time.c
@@ -35,7 +35,7 @@
35 35
36static u32 notrace pxa_read_sched_clock(void) 36static u32 notrace pxa_read_sched_clock(void)
37{ 37{
38 return OSCR; 38 return readl_relaxed(OSCR);
39} 39}
40 40
41 41
@@ -47,8 +47,8 @@ pxa_ost0_interrupt(int irq, void *dev_id)
47 struct clock_event_device *c = dev_id; 47 struct clock_event_device *c = dev_id;
48 48
49 /* Disarm the compare/match, signal the event. */ 49 /* Disarm the compare/match, signal the event. */
50 OIER &= ~OIER_E0; 50 writel_relaxed(readl_relaxed(OIER) & ~OIER_E0, OIER);
51 OSSR = OSSR_M0; 51 writel_relaxed(OSSR_M0, OSSR);
52 c->event_handler(c); 52 c->event_handler(c);
53 53
54 return IRQ_HANDLED; 54 return IRQ_HANDLED;
@@ -59,10 +59,10 @@ pxa_osmr0_set_next_event(unsigned long delta, struct clock_event_device *dev)
59{ 59{
60 unsigned long next, oscr; 60 unsigned long next, oscr;
61 61
62 OIER |= OIER_E0; 62 writel_relaxed(readl_relaxed(OIER) | OIER_E0, OIER);
63 next = OSCR + delta; 63 next = readl_relaxed(OSCR) + delta;
64 OSMR0 = next; 64 writel_relaxed(next, OSMR0);
65 oscr = OSCR; 65 oscr = readl_relaxed(OSCR);
66 66
67 return (signed)(next - oscr) <= MIN_OSCR_DELTA ? -ETIME : 0; 67 return (signed)(next - oscr) <= MIN_OSCR_DELTA ? -ETIME : 0;
68} 68}
@@ -72,15 +72,15 @@ pxa_osmr0_set_mode(enum clock_event_mode mode, struct clock_event_device *dev)
72{ 72{
73 switch (mode) { 73 switch (mode) {
74 case CLOCK_EVT_MODE_ONESHOT: 74 case CLOCK_EVT_MODE_ONESHOT:
75 OIER &= ~OIER_E0; 75 writel_relaxed(readl_relaxed(OIER) & ~OIER_E0, OIER);
76 OSSR = OSSR_M0; 76 writel_relaxed(OSSR_M0, OSSR);
77 break; 77 break;
78 78
79 case CLOCK_EVT_MODE_UNUSED: 79 case CLOCK_EVT_MODE_UNUSED:
80 case CLOCK_EVT_MODE_SHUTDOWN: 80 case CLOCK_EVT_MODE_SHUTDOWN:
81 /* initializing, released, or preparing for suspend */ 81 /* initializing, released, or preparing for suspend */
82 OIER &= ~OIER_E0; 82 writel_relaxed(readl_relaxed(OIER) & ~OIER_E0, OIER);
83 OSSR = OSSR_M0; 83 writel_relaxed(OSSR_M0, OSSR);
84 break; 84 break;
85 85
86 case CLOCK_EVT_MODE_RESUME: 86 case CLOCK_EVT_MODE_RESUME:
@@ -108,8 +108,8 @@ static void __init pxa_timer_init(void)
108{ 108{
109 unsigned long clock_tick_rate = get_clock_tick_rate(); 109 unsigned long clock_tick_rate = get_clock_tick_rate();
110 110
111 OIER = 0; 111 writel_relaxed(0, OIER);
112 OSSR = OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3; 112 writel_relaxed(OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3, OSSR);
113 113
114 setup_sched_clock(pxa_read_sched_clock, 32, clock_tick_rate); 114 setup_sched_clock(pxa_read_sched_clock, 32, clock_tick_rate);
115 115
@@ -122,7 +122,7 @@ static void __init pxa_timer_init(void)
122 122
123 setup_irq(IRQ_OST0, &pxa_ost0_irq); 123 setup_irq(IRQ_OST0, &pxa_ost0_irq);
124 124
125 clocksource_mmio_init(&OSCR, "oscr0", clock_tick_rate, 200, 32, 125 clocksource_mmio_init(OSCR, "oscr0", clock_tick_rate, 200, 32,
126 clocksource_mmio_readl_up); 126 clocksource_mmio_readl_up);
127 clockevents_register_device(&ckevt_pxa_osmr0); 127 clockevents_register_device(&ckevt_pxa_osmr0);
128} 128}
@@ -132,12 +132,12 @@ static unsigned long osmr[4], oier, oscr;
132 132
133static void pxa_timer_suspend(void) 133static void pxa_timer_suspend(void)
134{ 134{
135 osmr[0] = OSMR0; 135 osmr[0] = readl_relaxed(OSMR0);
136 osmr[1] = OSMR1; 136 osmr[1] = readl_relaxed(OSMR1);
137 osmr[2] = OSMR2; 137 osmr[2] = readl_relaxed(OSMR2);
138 osmr[3] = OSMR3; 138 osmr[3] = readl_relaxed(OSMR3);
139 oier = OIER; 139 oier = readl_relaxed(OIER);
140 oscr = OSCR; 140 oscr = readl_relaxed(OSCR);
141} 141}
142 142
143static void pxa_timer_resume(void) 143static void pxa_timer_resume(void)
@@ -151,12 +151,12 @@ static void pxa_timer_resume(void)
151 if (osmr[0] - oscr < MIN_OSCR_DELTA) 151 if (osmr[0] - oscr < MIN_OSCR_DELTA)
152 osmr[0] += MIN_OSCR_DELTA; 152 osmr[0] += MIN_OSCR_DELTA;
153 153
154 OSMR0 = osmr[0]; 154 writel_relaxed(osmr[0], OSMR0);
155 OSMR1 = osmr[1]; 155 writel_relaxed(osmr[1], OSMR1);
156 OSMR2 = osmr[2]; 156 writel_relaxed(osmr[2], OSMR2);
157 OSMR3 = osmr[3]; 157 writel_relaxed(osmr[3], OSMR3);
158 OIER = oier; 158 writel_relaxed(oier, OIER);
159 OSCR = oscr; 159 writel_relaxed(oscr, OSCR);
160} 160}
161#else 161#else
162#define pxa_timer_suspend NULL 162#define pxa_timer_suspend NULL
diff --git a/arch/arm/mach-pxa/trizeps4.c b/arch/arm/mach-pxa/trizeps4.c
index 2b6ac00b2cd..166dd32cc1d 100644
--- a/arch/arm/mach-pxa/trizeps4.c
+++ b/arch/arm/mach-pxa/trizeps4.c
@@ -332,8 +332,8 @@ static int trizeps4_mci_init(struct device *dev, irq_handler_t mci_detect_int,
332 int err; 332 int err;
333 333
334 err = request_irq(TRIZEPS4_MMC_IRQ, mci_detect_int, 334 err = request_irq(TRIZEPS4_MMC_IRQ, mci_detect_int,
335 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_SAMPLE_RANDOM, 335 IRQF_DISABLED | IRQF_TRIGGER_RISING,
336 "MMC card detect", data); 336 "MMC card detect", data);
337 if (err) { 337 if (err) {
338 printk(KERN_ERR "trizeps4_mci_init: MMC/SD: can't request" 338 printk(KERN_ERR "trizeps4_mci_init: MMC/SD: can't request"
339 "MMC card detect IRQ\n"); 339 "MMC card detect IRQ\n");
diff --git a/arch/arm/mach-rpc/irq.c b/arch/arm/mach-rpc/irq.c
index cf0e669eaf1..3e4fa849c64 100644
--- a/arch/arm/mach-rpc/irq.c
+++ b/arch/arm/mach-rpc/irq.c
@@ -163,6 +163,6 @@ void __init rpc_init_irq(void)
163 } 163 }
164 } 164 }
165 165
166 init_FIQ(); 166 init_FIQ(FIQ_START);
167} 167}
168 168
diff --git a/arch/arm/mach-s3c24xx/Kconfig b/arch/arm/mach-s3c24xx/Kconfig
index e24961109b7..d56b0f7f2b2 100644
--- a/arch/arm/mach-s3c24xx/Kconfig
+++ b/arch/arm/mach-s3c24xx/Kconfig
@@ -483,7 +483,7 @@ config MACH_NEO1973_GTA02
483 select I2C 483 select I2C
484 select POWER_SUPPLY 484 select POWER_SUPPLY
485 select MACH_NEO1973 485 select MACH_NEO1973
486 select S3C2410_PWM 486 select S3C24XX_PWM
487 select S3C_DEV_USB_HOST 487 select S3C_DEV_USB_HOST
488 help 488 help
489 Say Y here if you are using the Openmoko GTA02 / Freerunner GSM Phone 489 Say Y here if you are using the Openmoko GTA02 / Freerunner GSM Phone
@@ -493,7 +493,7 @@ config MACH_RX1950
493 select S3C24XX_DCLK 493 select S3C24XX_DCLK
494 select PM_H1940 if PM 494 select PM_H1940 if PM
495 select I2C 495 select I2C
496 select S3C2410_PWM 496 select S3C24XX_PWM
497 select S3C_DEV_NAND 497 select S3C_DEV_NAND
498 select S3C2410_IOTIMING if S3C2440_CPUFREQ 498 select S3C2410_IOTIMING if S3C2440_CPUFREQ
499 select S3C2440_XTAL_16934400 499 select S3C2440_XTAL_16934400
diff --git a/arch/arm/mach-s3c24xx/clock-s3c2416.c b/arch/arm/mach-s3c24xx/clock-s3c2416.c
index 8702ecfaab3..14a81c2317a 100644
--- a/arch/arm/mach-s3c24xx/clock-s3c2416.c
+++ b/arch/arm/mach-s3c24xx/clock-s3c2416.c
@@ -144,7 +144,8 @@ static struct clk_lookup s3c2416_clk_lookup[] = {
144 CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.0", &hsmmc0_clk), 144 CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.0", &hsmmc0_clk),
145 CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &hsmmc_mux0.clk), 145 CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &hsmmc_mux0.clk),
146 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &hsmmc_mux1.clk), 146 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &hsmmc_mux1.clk),
147 CLKDEV_INIT("s3c64xx-spi.0", "spi_busclk2", &hsspi_mux.clk), 147 /* s3c2443-spi.0 is used on s3c2416 and s3c2450 as well */
148 CLKDEV_INIT("s3c2443-spi.0", "spi_busclk2", &hsspi_mux.clk),
148}; 149};
149 150
150void __init s3c2416_init_clocks(int xtal) 151void __init s3c2416_init_clocks(int xtal)
diff --git a/arch/arm/mach-s3c24xx/clock-s3c2443.c b/arch/arm/mach-s3c24xx/clock-s3c2443.c
index a4c5a520d99..7f689ce1be6 100644
--- a/arch/arm/mach-s3c24xx/clock-s3c2443.c
+++ b/arch/arm/mach-s3c24xx/clock-s3c2443.c
@@ -181,7 +181,7 @@ static struct clk *clks[] __initdata = {
181 181
182static struct clk_lookup s3c2443_clk_lookup[] = { 182static struct clk_lookup s3c2443_clk_lookup[] = {
183 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_hsmmc), 183 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_hsmmc),
184 CLKDEV_INIT("s3c64xx-spi.0", "spi_busclk2", &clk_hsspi.clk), 184 CLKDEV_INIT("s3c2443-spi.0", "spi_busclk2", &clk_hsspi.clk),
185}; 185};
186 186
187void __init s3c2443_init_clocks(int xtal) 187void __init s3c2443_init_clocks(int xtal)
diff --git a/arch/arm/mach-s3c24xx/common-s3c2443.c b/arch/arm/mach-s3c24xx/common-s3c2443.c
index aeeb2be283f..aeb4a24ff3e 100644
--- a/arch/arm/mach-s3c24xx/common-s3c2443.c
+++ b/arch/arm/mach-s3c24xx/common-s3c2443.c
@@ -559,7 +559,7 @@ static struct clk hsmmc1_clk = {
559 559
560static struct clk hsspi_clk = { 560static struct clk hsspi_clk = {
561 .name = "spi", 561 .name = "spi",
562 .devname = "s3c64xx-spi.0", 562 .devname = "s3c2443-spi.0",
563 .parent = &clk_p, 563 .parent = &clk_p,
564 .enable = s3c2443_clkcon_enable_p, 564 .enable = s3c2443_clkcon_enable_p,
565 .ctrlbit = S3C2443_PCLKCON_HSSPI, 565 .ctrlbit = S3C2443_PCLKCON_HSSPI,
@@ -633,7 +633,7 @@ static struct clk_lookup s3c2443_clk_lookup[] = {
633 CLKDEV_INIT(NULL, "clk_uart_baud2", &clk_p), 633 CLKDEV_INIT(NULL, "clk_uart_baud2", &clk_p),
634 CLKDEV_INIT(NULL, "clk_uart_baud3", &clk_esys_uart.clk), 634 CLKDEV_INIT(NULL, "clk_uart_baud3", &clk_esys_uart.clk),
635 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.0", &hsmmc1_clk), 635 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.0", &hsmmc1_clk),
636 CLKDEV_INIT("s3c64xx-spi.0", "spi_busclk0", &hsspi_clk), 636 CLKDEV_INIT("s3c2443-spi.0", "spi_busclk0", &hsspi_clk),
637}; 637};
638 638
639void __init s3c2443_common_init_clocks(int xtal, pll_fn get_mpll, 639void __init s3c2443_common_init_clocks(int xtal, pll_fn get_mpll,
diff --git a/arch/arm/mach-s3c24xx/common-smdk.c b/arch/arm/mach-s3c24xx/common-smdk.c
index 084604be6ad..87e75a250d5 100644
--- a/arch/arm/mach-s3c24xx/common-smdk.c
+++ b/arch/arm/mach-s3c24xx/common-smdk.c
@@ -182,19 +182,21 @@ static struct platform_device __initdata *smdk_devs[] = {
182 &smdk_led7, 182 &smdk_led7,
183}; 183};
184 184
185static const struct gpio smdk_led_gpios[] = {
186 { S3C2410_GPF(4), GPIOF_OUT_INIT_HIGH, NULL },
187 { S3C2410_GPF(5), GPIOF_OUT_INIT_HIGH, NULL },
188 { S3C2410_GPF(6), GPIOF_OUT_INIT_HIGH, NULL },
189 { S3C2410_GPF(7), GPIOF_OUT_INIT_HIGH, NULL },
190};
191
185void __init smdk_machine_init(void) 192void __init smdk_machine_init(void)
186{ 193{
187 /* Configure the LEDs (even if we have no LED support)*/ 194 /* Configure the LEDs (even if we have no LED support)*/
188 195
189 s3c_gpio_cfgpin(S3C2410_GPF(4), S3C2410_GPIO_OUTPUT); 196 int ret = gpio_request_array(smdk_led_gpios,
190 s3c_gpio_cfgpin(S3C2410_GPF(5), S3C2410_GPIO_OUTPUT); 197 ARRAY_SIZE(smdk_led_gpios));
191 s3c_gpio_cfgpin(S3C2410_GPF(6), S3C2410_GPIO_OUTPUT); 198 if (!WARN_ON(ret < 0))
192 s3c_gpio_cfgpin(S3C2410_GPF(7), S3C2410_GPIO_OUTPUT); 199 gpio_free_array(smdk_led_gpios, ARRAY_SIZE(smdk_led_gpios));
193
194 s3c2410_gpio_setpin(S3C2410_GPF(4), 1);
195 s3c2410_gpio_setpin(S3C2410_GPF(5), 1);
196 s3c2410_gpio_setpin(S3C2410_GPF(6), 1);
197 s3c2410_gpio_setpin(S3C2410_GPF(7), 1);
198 200
199 if (machine_is_smdk2443()) 201 if (machine_is_smdk2443())
200 smdk_nand_info.twrph0 = 50; 202 smdk_nand_info.twrph0 = 50;
diff --git a/arch/arm/mach-s3c24xx/common.c b/arch/arm/mach-s3c24xx/common.c
index 56cdd34cce4..0c9e9a785ef 100644
--- a/arch/arm/mach-s3c24xx/common.c
+++ b/arch/arm/mach-s3c24xx/common.c
@@ -41,7 +41,6 @@
41#include <asm/mach/arch.h> 41#include <asm/mach/arch.h>
42#include <asm/mach/map.h> 42#include <asm/mach/map.h>
43 43
44#include <mach/regs-clock.h>
45#include <mach/regs-gpio.h> 44#include <mach/regs-gpio.h>
46#include <plat/regs-serial.h> 45#include <plat/regs-serial.h>
47 46
diff --git a/arch/arm/mach-s3c24xx/include/mach/bast-pmu.h b/arch/arm/mach-s3c24xx/include/mach/bast-pmu.h
deleted file mode 100644
index 4c38b39b741..00000000000
--- a/arch/arm/mach-s3c24xx/include/mach/bast-pmu.h
+++ /dev/null
@@ -1,40 +0,0 @@
1/* arch/arm/mach-s3c2410/include/mach/bast-pmu.h
2 *
3 * Copyright (c) 2003-2004 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 * Vincent Sanders <vince@simtec.co.uk>
6 *
7 * Machine BAST - Power Management chip
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_BASTPMU_H
15#define __ASM_ARCH_BASTPMU_H "08_OCT_2004"
16
17#define BASTPMU_REG_IDENT (0x00)
18#define BASTPMU_REG_VERSION (0x01)
19#define BASTPMU_REG_DDCCTRL (0x02)
20#define BASTPMU_REG_POWER (0x03)
21#define BASTPMU_REG_RESET (0x04)
22#define BASTPMU_REG_GWO (0x05)
23#define BASTPMU_REG_WOL (0x06)
24#define BASTPMU_REG_WOR (0x07)
25#define BASTPMU_REG_UID (0x09)
26
27#define BASTPMU_EEPROM (0xC0)
28
29#define BASTPMU_EEP_UID (BASTPMU_EEPROM + 0)
30#define BASTPMU_EEP_WOL (BASTPMU_EEPROM + 8)
31#define BASTPMU_EEP_WOR (BASTPMU_EEPROM + 9)
32
33#define BASTPMU_IDENT_0 0x53
34#define BASTPMU_IDENT_1 0x42
35#define BASTPMU_IDENT_2 0x50
36#define BASTPMU_IDENT_3 0x4d
37
38#define BASTPMU_RESET_GUARD (0x55)
39
40#endif /* __ASM_ARCH_BASTPMU_H */
diff --git a/arch/arm/mach-s3c24xx/include/mach/dma.h b/arch/arm/mach-s3c24xx/include/mach/dma.h
index 454831b6603..ee99fd56c04 100644
--- a/arch/arm/mach-s3c24xx/include/mach/dma.h
+++ b/arch/arm/mach-s3c24xx/include/mach/dma.h
@@ -24,7 +24,8 @@
24*/ 24*/
25 25
26enum dma_ch { 26enum dma_ch {
27 DMACH_XD0, 27 DMACH_DT_PROP = -1, /* not yet supported, do not use */
28 DMACH_XD0 = 0,
28 DMACH_XD1, 29 DMACH_XD1,
29 DMACH_SDI, 30 DMACH_SDI,
30 DMACH_SPI0, 31 DMACH_SPI0,
diff --git a/arch/arm/mach-s3c24xx/include/mach/gpio-nrs.h b/arch/arm/mach-s3c24xx/include/mach/gpio-nrs.h
index 019ea86057f..3890a05948f 100644
--- a/arch/arm/mach-s3c24xx/include/mach/gpio-nrs.h
+++ b/arch/arm/mach-s3c24xx/include/mach/gpio-nrs.h
@@ -93,26 +93,5 @@ enum s3c_gpio_number {
93#define S3C2410_GPL(_nr) (S3C2410_GPIO_L_START + (_nr)) 93#define S3C2410_GPL(_nr) (S3C2410_GPIO_L_START + (_nr))
94#define S3C2410_GPM(_nr) (S3C2410_GPIO_M_START + (_nr)) 94#define S3C2410_GPM(_nr) (S3C2410_GPIO_M_START + (_nr))
95 95
96/* compatibility until drivers can be modified */
97
98#define S3C2410_GPA0 S3C2410_GPA(0)
99#define S3C2410_GPA1 S3C2410_GPA(1)
100#define S3C2410_GPA3 S3C2410_GPA(3)
101#define S3C2410_GPA7 S3C2410_GPA(7)
102
103#define S3C2410_GPE0 S3C2410_GPE(0)
104#define S3C2410_GPE1 S3C2410_GPE(1)
105#define S3C2410_GPE2 S3C2410_GPE(2)
106#define S3C2410_GPE3 S3C2410_GPE(3)
107#define S3C2410_GPE4 S3C2410_GPE(4)
108#define S3C2410_GPE5 S3C2410_GPE(5)
109#define S3C2410_GPE6 S3C2410_GPE(6)
110#define S3C2410_GPE7 S3C2410_GPE(7)
111#define S3C2410_GPE8 S3C2410_GPE(8)
112#define S3C2410_GPE9 S3C2410_GPE(9)
113#define S3C2410_GPE10 S3C2410_GPE(10)
114
115#define S3C2410_GPH10 S3C2410_GPH(10)
116
117#endif /* __MACH_GPIONRS_H */ 96#endif /* __MACH_GPIONRS_H */
118 97
diff --git a/arch/arm/mach-s3c24xx/include/mach/gta02.h b/arch/arm/mach-s3c24xx/include/mach/gta02.h
index 3a56a229cac..21739348215 100644
--- a/arch/arm/mach-s3c24xx/include/mach/gta02.h
+++ b/arch/arm/mach-s3c24xx/include/mach/gta02.h
@@ -3,82 +3,13 @@
3 3
4#include <mach/regs-gpio.h> 4#include <mach/regs-gpio.h>
5 5
6/* Different hardware revisions, passed in ATAG_REVISION by u-boot */
7#define GTA02v1_SYSTEM_REV 0x00000310
8#define GTA02v2_SYSTEM_REV 0x00000320
9#define GTA02v3_SYSTEM_REV 0x00000330
10#define GTA02v4_SYSTEM_REV 0x00000340
11#define GTA02v5_SYSTEM_REV 0x00000350
12/* since A7 is basically same as A6, we use A6 PCB ID */
13#define GTA02v6_SYSTEM_REV 0x00000360
14
15#define GTA02_GPIO_n3DL_GSM S3C2410_GPA(13) /* v1 + v2 + v3 only */
16
17#define GTA02_GPIO_PWR_LED1 S3C2410_GPB(0)
18#define GTA02_GPIO_PWR_LED2 S3C2410_GPB(1)
19#define GTA02_GPIO_AUX_LED S3C2410_GPB(2) 6#define GTA02_GPIO_AUX_LED S3C2410_GPB(2)
20#define GTA02_GPIO_VIBRATOR_ON S3C2410_GPB(3)
21#define GTA02_GPIO_MODEM_RST S3C2410_GPB(5)
22#define GTA02_GPIO_BT_EN S3C2410_GPB(6)
23#define GTA02_GPIO_MODEM_ON S3C2410_GPB(7)
24#define GTA02_GPIO_EXTINT8 S3C2410_GPB(8)
25#define GTA02_GPIO_USB_PULLUP S3C2410_GPB(9) 7#define GTA02_GPIO_USB_PULLUP S3C2410_GPB(9)
26
27#define GTA02_GPIO_PIO5 S3C2410_GPC(5) /* v3 + v4 only */
28
29#define GTA02v3_GPIO_nG1_CS S3C2410_GPD(12) /* v3 + v4 only */
30#define GTA02v3_GPIO_nG2_CS S3C2410_GPD(13) /* v3 + v4 only */
31#define GTA02v5_GPIO_HDQ S3C2410_GPD(14) /* v5 + */
32
33#define GTA02_GPIO_nG1_INT S3C2410_GPF(0)
34#define GTA02_GPIO_IO1 S3C2410_GPF(1)
35#define GTA02_GPIO_PIO_2 S3C2410_GPF(2) /* v2 + v3 + v4 only */
36#define GTA02_GPIO_JACK_INSERT S3C2410_GPF(4)
37#define GTA02_GPIO_WLAN_GPIO1 S3C2410_GPF(5) /* v2 + v3 + v4 only */
38#define GTA02_GPIO_AUX_KEY S3C2410_GPF(6) 8#define GTA02_GPIO_AUX_KEY S3C2410_GPF(6)
39#define GTA02_GPIO_HOLD_KEY S3C2410_GPF(7) 9#define GTA02_GPIO_HOLD_KEY S3C2410_GPF(7)
40
41#define GTA02_GPIO_3D_IRQ S3C2410_GPG(4)
42#define GTA02v2_GPIO_nG2_INT S3C2410_GPG(8) /* v2 + v3 + v4 only */
43#define GTA02v3_GPIO_nUSB_OC S3C2410_GPG(9) /* v3 + v4 only */
44#define GTA02v3_GPIO_nUSB_FLT S3C2410_GPG(10) /* v3 + v4 only */
45#define GTA02v3_GPIO_nGSM_OC S3C2410_GPG(11) /* v3 + v4 only */
46
47#define GTA02_GPIO_AMP_SHUT S3C2410_GPJ(1) /* v2 + v3 + v4 only */ 10#define GTA02_GPIO_AMP_SHUT S3C2410_GPJ(1) /* v2 + v3 + v4 only */
48#define GTA02v1_GPIO_WLAN_GPIO10 S3C2410_GPJ(2)
49#define GTA02_GPIO_HP_IN S3C2410_GPJ(2) /* v2 + v3 + v4 only */ 11#define GTA02_GPIO_HP_IN S3C2410_GPJ(2) /* v2 + v3 + v4 only */
50#define GTA02_GPIO_INT0 S3C2410_GPJ(3) /* v2 + v3 + v4 only */
51#define GTA02_GPIO_nGSM_EN S3C2410_GPJ(4)
52#define GTA02_GPIO_3D_RESET S3C2410_GPJ(5)
53#define GTA02_GPIO_nDL_GSM S3C2410_GPJ(6) /* v4 + v5 only */
54#define GTA02_GPIO_WLAN_GPIO0 S3C2410_GPJ(7)
55#define GTA02v1_GPIO_BAT_ID S3C2410_GPJ(8)
56#define GTA02_GPIO_KEEPACT S3C2410_GPJ(8)
57#define GTA02v1_GPIO_HP_IN S3C2410_GPJ(10)
58#define GTA02_CHIP_PWD S3C2410_GPJ(11) /* v2 + v3 + v4 only */
59#define GTA02_GPIO_nWLAN_RESET S3C2410_GPJ(12) /* v2 + v3 + v4 only */
60 12
61#define GTA02_IRQ_GSENSOR_1 IRQ_EINT0
62#define GTA02_IRQ_MODEM IRQ_EINT1
63#define GTA02_IRQ_PIO_2 IRQ_EINT2 /* v2 + v3 + v4 only */
64#define GTA02_IRQ_nJACK_INSERT IRQ_EINT4
65#define GTA02_IRQ_WLAN_GPIO1 IRQ_EINT5
66#define GTA02_IRQ_AUX IRQ_EINT6
67#define GTA02_IRQ_nHOLD IRQ_EINT7
68#define GTA02_IRQ_PCF50633 IRQ_EINT9 13#define GTA02_IRQ_PCF50633 IRQ_EINT9
69#define GTA02_IRQ_3D IRQ_EINT12
70#define GTA02_IRQ_GSENSOR_2 IRQ_EINT16 /* v2 + v3 + v4 only */
71#define GTA02v3_IRQ_nUSB_OC IRQ_EINT17 /* v3 + v4 only */
72#define GTA02v3_IRQ_nUSB_FLT IRQ_EINT18 /* v3 + v4 only */
73#define GTA02v3_IRQ_nGSM_OC IRQ_EINT19 /* v3 + v4 only */
74
75/* returns 00 000 on GTA02 A5 and earlier, A6 returns 01 001 */
76#define GTA02_PCB_ID1_0 S3C2410_GPC(13)
77#define GTA02_PCB_ID1_1 S3C2410_GPC(15)
78#define GTA02_PCB_ID1_2 S3C2410_GPD(0)
79#define GTA02_PCB_ID2_0 S3C2410_GPD(3)
80#define GTA02_PCB_ID2_1 S3C2410_GPD(4)
81
82int gta02_get_pcb_revision(void);
83 14
84#endif /* _GTA02_H */ 15#endif /* _GTA02_H */
diff --git a/arch/arm/mach-s3c24xx/include/mach/regs-gpio.h b/arch/arm/mach-s3c24xx/include/mach/regs-gpio.h
index cac1ad6b582..a11a638bd59 100644
--- a/arch/arm/mach-s3c24xx/include/mach/regs-gpio.h
+++ b/arch/arm/mach-s3c24xx/include/mach/regs-gpio.h
@@ -302,7 +302,7 @@
302/* S3C2410: 302/* S3C2410:
303 * Port G consists of 8 GPIO/IRQ/Special function 303 * Port G consists of 8 GPIO/IRQ/Special function
304 * 304 *
305 * GPGCON has 2 bits for each of the input pins on port F 305 * GPGCON has 2 bits for each of the input pins on port G
306 * 00 = 0 input, 1 output, 2 interrupt (EINT0..7), 3 special func 306 * 00 = 0 input, 1 output, 2 interrupt (EINT0..7), 3 special func
307 * 307 *
308 * pull up works like all other ports. 308 * pull up works like all other ports.
@@ -366,7 +366,7 @@
366 366
367/* Port H consists of11 GPIO/serial/Misc pins 367/* Port H consists of11 GPIO/serial/Misc pins
368 * 368 *
369 * GPGCON has 2 bits for each of the input pins on port F 369 * GPHCON has 2 bits for each of the input pins on port H
370 * 00 = 0 input, 1 output, 2 interrupt (EINT0..7), 3 special func 370 * 00 = 0 input, 1 output, 2 interrupt (EINT0..7), 3 special func
371 * 371 *
372 * pull up works like all other ports. 372 * pull up works like all other ports.
@@ -427,6 +427,19 @@
427 * for the 2412/2413 from the 2410/2440/2442 427 * for the 2412/2413 from the 2410/2440/2442
428*/ 428*/
429 429
430/*
431 * Port J consists of 13 GPIO/Camera pins. GPJCON has 2 bits
432 * for each of the pins on port J.
433 * 00 - input, 01 output, 10 - camera
434 *
435 * Pull up works like all other ports.
436 */
437
438#define S3C2413_GPJCON S3C2410_GPIOREG(0x80)
439#define S3C2413_GPJDAT S3C2410_GPIOREG(0x84)
440#define S3C2413_GPJUP S3C2410_GPIOREG(0x88)
441#define S3C2413_GPJSLPCON S3C2410_GPIOREG(0x8C)
442
430/* S3C2443 and above */ 443/* S3C2443 and above */
431#define S3C2440_GPJCON S3C2410_GPIOREG(0xD0) 444#define S3C2440_GPJCON S3C2410_GPIOREG(0xD0)
432#define S3C2440_GPJDAT S3C2410_GPIOREG(0xD4) 445#define S3C2440_GPJDAT S3C2410_GPIOREG(0xD4)
diff --git a/arch/arm/mach-s3c24xx/include/mach/regs-gpioj.h b/arch/arm/mach-s3c24xx/include/mach/regs-gpioj.h
deleted file mode 100644
index 19575e06111..00000000000
--- a/arch/arm/mach-s3c24xx/include/mach/regs-gpioj.h
+++ /dev/null
@@ -1,70 +0,0 @@
1/* arch/arm/mach-s3c2410/include/mach/regs-gpioj.h
2 *
3 * Copyright (c) 2004 Simtec Electronics <linux@simtec.co.uk>
4 * http://www.simtec.co.uk/products/SWLINUX/
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 * S3C2440 GPIO J register definitions
11*/
12
13
14#ifndef __ASM_ARCH_REGS_GPIOJ_H
15#define __ASM_ARCH_REGS_GPIOJ_H "gpioj"
16
17/* Port J consists of 13 GPIO/Camera pins
18 *
19 * GPJCON has 2 bits for each of the input pins on port F
20 * 00 = 0 input, 1 output, 2 Camera
21 *
22 * pull up works like all other ports.
23*/
24
25#define S3C2413_GPJCON S3C2410_GPIOREG(0x80)
26#define S3C2413_GPJDAT S3C2410_GPIOREG(0x84)
27#define S3C2413_GPJUP S3C2410_GPIOREG(0x88)
28#define S3C2413_GPJSLPCON S3C2410_GPIOREG(0x8C)
29
30#define S3C2440_GPJ0_OUTP (0x01 << 0)
31#define S3C2440_GPJ0_CAMDATA0 (0x02 << 0)
32
33#define S3C2440_GPJ1_OUTP (0x01 << 2)
34#define S3C2440_GPJ1_CAMDATA1 (0x02 << 2)
35
36#define S3C2440_GPJ2_OUTP (0x01 << 4)
37#define S3C2440_GPJ2_CAMDATA2 (0x02 << 4)
38
39#define S3C2440_GPJ3_OUTP (0x01 << 6)
40#define S3C2440_GPJ3_CAMDATA3 (0x02 << 6)
41
42#define S3C2440_GPJ4_OUTP (0x01 << 8)
43#define S3C2440_GPJ4_CAMDATA4 (0x02 << 8)
44
45#define S3C2440_GPJ5_OUTP (0x01 << 10)
46#define S3C2440_GPJ5_CAMDATA5 (0x02 << 10)
47
48#define S3C2440_GPJ6_OUTP (0x01 << 12)
49#define S3C2440_GPJ6_CAMDATA6 (0x02 << 12)
50
51#define S3C2440_GPJ7_OUTP (0x01 << 14)
52#define S3C2440_GPJ7_CAMDATA7 (0x02 << 14)
53
54#define S3C2440_GPJ8_OUTP (0x01 << 16)
55#define S3C2440_GPJ8_CAMPCLK (0x02 << 16)
56
57#define S3C2440_GPJ9_OUTP (0x01 << 18)
58#define S3C2440_GPJ9_CAMVSYNC (0x02 << 18)
59
60#define S3C2440_GPJ10_OUTP (0x01 << 20)
61#define S3C2440_GPJ10_CAMHREF (0x02 << 20)
62
63#define S3C2440_GPJ11_OUTP (0x01 << 22)
64#define S3C2440_GPJ11_CAMCLKOUT (0x02 << 22)
65
66#define S3C2440_GPJ12_OUTP (0x01 << 24)
67#define S3C2440_GPJ12_CAMRESET (0x02 << 24)
68
69#endif /* __ASM_ARCH_REGS_GPIOJ_H */
70
diff --git a/arch/arm/mach-s3c24xx/mach-gta02.c b/arch/arm/mach-s3c24xx/mach-gta02.c
index 0f29f64a3ee..92e1f93a6bc 100644
--- a/arch/arm/mach-s3c24xx/mach-gta02.c
+++ b/arch/arm/mach-s3c24xx/mach-gta02.c
@@ -71,7 +71,6 @@
71 71
72#include <mach/regs-irq.h> 72#include <mach/regs-irq.h>
73#include <mach/regs-gpio.h> 73#include <mach/regs-gpio.h>
74#include <mach/regs-gpioj.h>
75#include <mach/fb.h> 74#include <mach/fb.h>
76 75
77#include <plat/usb-control.h> 76#include <plat/usb-control.h>
diff --git a/arch/arm/mach-s3c24xx/mach-mini2440.c b/arch/arm/mach-s3c24xx/mach-mini2440.c
index f092b188ab7..bd6d2525deb 100644
--- a/arch/arm/mach-s3c24xx/mach-mini2440.c
+++ b/arch/arm/mach-s3c24xx/mach-mini2440.c
@@ -634,8 +634,8 @@ static void __init mini2440_init(void)
634 s3c_gpio_cfgpin(S3C2410_GPC(0), S3C2410_GPC0_LEND); 634 s3c_gpio_cfgpin(S3C2410_GPC(0), S3C2410_GPC0_LEND);
635 635
636 /* Turn the backlight early on */ 636 /* Turn the backlight early on */
637 WARN_ON(gpio_request(S3C2410_GPG(4), "backlight")); 637 WARN_ON(gpio_request_one(S3C2410_GPG(4), GPIOF_OUT_INIT_HIGH, NULL));
638 gpio_direction_output(S3C2410_GPG(4), 1); 638 gpio_free(S3C2410_GPG(4));
639 639
640 /* remove pullup on optional PWM backlight -- unused on 3.5 and 7"s */ 640 /* remove pullup on optional PWM backlight -- unused on 3.5 and 7"s */
641 s3c_gpio_setpull(S3C2410_GPB(1), S3C_GPIO_PULL_UP); 641 s3c_gpio_setpull(S3C2410_GPB(1), S3C_GPIO_PULL_UP);
diff --git a/arch/arm/mach-s3c24xx/mach-qt2410.c b/arch/arm/mach-s3c24xx/mach-qt2410.c
index b868dddcb83..678bbca2b5e 100644
--- a/arch/arm/mach-s3c24xx/mach-qt2410.c
+++ b/arch/arm/mach-s3c24xx/mach-qt2410.c
@@ -47,7 +47,6 @@
47#include <asm/irq.h> 47#include <asm/irq.h>
48#include <asm/mach-types.h> 48#include <asm/mach-types.h>
49 49
50#include <mach/regs-gpio.h>
51#include <mach/leds-gpio.h> 50#include <mach/leds-gpio.h>
52#include <mach/regs-lcd.h> 51#include <mach/regs-lcd.h>
53#include <plat/regs-serial.h> 52#include <plat/regs-serial.h>
@@ -325,8 +324,9 @@ static void __init qt2410_machine_init(void)
325 } 324 }
326 s3c24xx_fb_set_platdata(&qt2410_fb_info); 325 s3c24xx_fb_set_platdata(&qt2410_fb_info);
327 326
328 s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPIO_OUTPUT); 327 /* set initial state of the LED GPIO */
329 s3c2410_gpio_setpin(S3C2410_GPB(0), 1); 328 WARN_ON(gpio_request_one(S3C2410_GPB(0), GPIOF_OUT_INIT_HIGH, NULL));
329 gpio_free(S3C2410_GPB(0));
330 330
331 s3c24xx_udc_set_platdata(&qt2410_udc_cfg); 331 s3c24xx_udc_set_platdata(&qt2410_udc_cfg);
332 s3c_i2c0_set_platdata(NULL); 332 s3c_i2c0_set_platdata(NULL);
diff --git a/arch/arm/mach-s3c24xx/mach-rx1950.c b/arch/arm/mach-s3c24xx/mach-rx1950.c
index a6762aae472..7ee73f27f20 100644
--- a/arch/arm/mach-s3c24xx/mach-rx1950.c
+++ b/arch/arm/mach-s3c24xx/mach-rx1950.c
@@ -42,7 +42,6 @@
42#include <asm/mach-types.h> 42#include <asm/mach-types.h>
43 43
44#include <mach/regs-gpio.h> 44#include <mach/regs-gpio.h>
45#include <mach/regs-gpioj.h>
46#include <mach/regs-lcd.h> 45#include <mach/regs-lcd.h>
47#include <mach/h1940.h> 46#include <mach/h1940.h>
48#include <mach/fb.h> 47#include <mach/fb.h>
diff --git a/arch/arm/mach-s3c24xx/pm-s3c2410.c b/arch/arm/mach-s3c24xx/pm-s3c2410.c
index 03f706dd600..949ae05e07c 100644
--- a/arch/arm/mach-s3c24xx/pm-s3c2410.c
+++ b/arch/arm/mach-s3c24xx/pm-s3c2410.c
@@ -77,8 +77,10 @@ static void s3c2410_pm_prepare(void)
77 __raw_writel(calc, phys_to_virt(H1940_SUSPEND_CHECKSUM)); 77 __raw_writel(calc, phys_to_virt(H1940_SUSPEND_CHECKSUM));
78 } 78 }
79 79
80 if ( machine_is_aml_m5900() ) 80 if (machine_is_aml_m5900()) {
81 s3c2410_gpio_setpin(S3C2410_GPF(2), 1); 81 gpio_request_one(S3C2410_GPF(2), GPIOF_OUT_INIT_HIGH, NULL);
82 gpio_free(S3C2410_GPF(2));
83 }
82 84
83 if (machine_is_rx1950()) { 85 if (machine_is_rx1950()) {
84 /* According to S3C2442 user's manual, page 7-17, 86 /* According to S3C2442 user's manual, page 7-17,
@@ -103,8 +105,10 @@ static void s3c2410_pm_resume(void)
103 tmp &= S3C2410_GSTATUS2_OFFRESET; 105 tmp &= S3C2410_GSTATUS2_OFFRESET;
104 __raw_writel(tmp, S3C2410_GSTATUS2); 106 __raw_writel(tmp, S3C2410_GSTATUS2);
105 107
106 if ( machine_is_aml_m5900() ) 108 if (machine_is_aml_m5900()) {
107 s3c2410_gpio_setpin(S3C2410_GPF(2), 0); 109 gpio_request_one(S3C2410_GPF(2), GPIOF_OUT_INIT_LOW, NULL);
110 gpio_free(S3C2410_GPF(2));
111 }
108} 112}
109 113
110struct syscore_ops s3c2410_pm_syscore_ops = { 114struct syscore_ops s3c2410_pm_syscore_ops = {
diff --git a/arch/arm/mach-s3c24xx/pm-s3c2412.c b/arch/arm/mach-s3c24xx/pm-s3c2412.c
index d04588506ec..c60f67a75af 100644
--- a/arch/arm/mach-s3c24xx/pm-s3c2412.c
+++ b/arch/arm/mach-s3c24xx/pm-s3c2412.c
@@ -26,7 +26,6 @@
26#include <asm/irq.h> 26#include <asm/irq.h>
27 27
28#include <mach/regs-power.h> 28#include <mach/regs-power.h>
29#include <mach/regs-gpioj.h>
30#include <mach/regs-gpio.h> 29#include <mach/regs-gpio.h>
31#include <mach/regs-dsc.h> 30#include <mach/regs-dsc.h>
32 31
diff --git a/arch/arm/mach-s3c24xx/s3c2412.c b/arch/arm/mach-s3c24xx/s3c2412.c
index d4bc7f960bb..6c5f4031ff0 100644
--- a/arch/arm/mach-s3c24xx/s3c2412.c
+++ b/arch/arm/mach-s3c24xx/s3c2412.c
@@ -39,7 +39,6 @@
39#include <plat/regs-serial.h> 39#include <plat/regs-serial.h>
40#include <mach/regs-power.h> 40#include <mach/regs-power.h>
41#include <mach/regs-gpio.h> 41#include <mach/regs-gpio.h>
42#include <mach/regs-gpioj.h>
43#include <mach/regs-dsc.h> 42#include <mach/regs-dsc.h>
44#include <plat/regs-spi.h> 43#include <plat/regs-spi.h>
45#include <mach/regs-s3c2412.h> 44#include <mach/regs-s3c2412.h>
diff --git a/arch/arm/mach-s3c24xx/s3c244x.c b/arch/arm/mach-s3c24xx/s3c244x.c
index 6f74118f60c..b0b60a1154d 100644
--- a/arch/arm/mach-s3c24xx/s3c244x.c
+++ b/arch/arm/mach-s3c24xx/s3c244x.c
@@ -36,7 +36,6 @@
36#include <mach/regs-clock.h> 36#include <mach/regs-clock.h>
37#include <plat/regs-serial.h> 37#include <plat/regs-serial.h>
38#include <mach/regs-gpio.h> 38#include <mach/regs-gpio.h>
39#include <mach/regs-gpioj.h>
40#include <mach/regs-dsc.h> 39#include <mach/regs-dsc.h>
41 40
42#include <plat/s3c2410.h> 41#include <plat/s3c2410.h>
diff --git a/arch/arm/mach-s3c24xx/setup-spi.c b/arch/arm/mach-s3c24xx/setup-spi.c
index 5712c85f39b..3d47e023ce9 100644
--- a/arch/arm/mach-s3c24xx/setup-spi.c
+++ b/arch/arm/mach-s3c24xx/setup-spi.c
@@ -13,20 +13,12 @@
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14 14
15#include <plat/gpio-cfg.h> 15#include <plat/gpio-cfg.h>
16#include <plat/s3c64xx-spi.h>
17 16
18#include <mach/hardware.h> 17#include <mach/hardware.h>
19#include <mach/regs-gpio.h> 18#include <mach/regs-gpio.h>
20 19
21#ifdef CONFIG_S3C64XX_DEV_SPI0 20#ifdef CONFIG_S3C64XX_DEV_SPI0
22struct s3c64xx_spi_info s3c64xx_spi0_pdata __initdata = { 21int s3c64xx_spi0_cfg_gpio(void)
23 .fifo_lvl_mask = 0x7f,
24 .rx_lvl_offset = 13,
25 .tx_st_done = 21,
26 .high_speed = 1,
27};
28
29int s3c64xx_spi0_cfg_gpio(struct platform_device *pdev)
30{ 22{
31 /* enable hsspi bit in misccr */ 23 /* enable hsspi bit in misccr */
32 s3c2410_modify_misccr(S3C2416_MISCCR_HSSPI_EN2, 1); 24 s3c2410_modify_misccr(S3C2416_MISCCR_HSSPI_EN2, 1);
diff --git a/arch/arm/mach-s3c24xx/setup-ts.c b/arch/arm/mach-s3c24xx/setup-ts.c
index ed263866367..4e11affce3a 100644
--- a/arch/arm/mach-s3c24xx/setup-ts.c
+++ b/arch/arm/mach-s3c24xx/setup-ts.c
@@ -16,7 +16,6 @@
16struct platform_device; /* don't need the contents */ 16struct platform_device; /* don't need the contents */
17 17
18#include <mach/hardware.h> 18#include <mach/hardware.h>
19#include <mach/regs-gpio.h>
20 19
21/** 20/**
22 * s3c24xx_ts_cfg_gpio - configure gpio for s3c2410 systems 21 * s3c24xx_ts_cfg_gpio - configure gpio for s3c2410 systems
@@ -27,8 +26,5 @@ struct platform_device; /* don't need the contents */
27 */ 26 */
28void s3c24xx_ts_cfg_gpio(struct platform_device *dev) 27void s3c24xx_ts_cfg_gpio(struct platform_device *dev)
29{ 28{
30 s3c2410_gpio_cfgpin(S3C2410_GPG(12), S3C2410_GPG12_XMON); 29 s3c_gpio_cfgpin_range(S3C2410_GPG(12), 4, S3C_GPIO_SFN(3));
31 s3c2410_gpio_cfgpin(S3C2410_GPG(13), S3C2410_GPG13_nXPON);
32 s3c2410_gpio_cfgpin(S3C2410_GPG(14), S3C2410_GPG14_YMON);
33 s3c2410_gpio_cfgpin(S3C2410_GPG(15), S3C2410_GPG15_nYPON);
34} 30}
diff --git a/arch/arm/mach-s3c64xx/clock.c b/arch/arm/mach-s3c64xx/clock.c
index 52f079a691c..28041e83dc8 100644
--- a/arch/arm/mach-s3c64xx/clock.c
+++ b/arch/arm/mach-s3c64xx/clock.c
@@ -178,13 +178,13 @@ static struct clk init_clocks_off[] = {
178 .ctrlbit = S3C_CLKCON_PCLK_KEYPAD, 178 .ctrlbit = S3C_CLKCON_PCLK_KEYPAD,
179 }, { 179 }, {
180 .name = "spi", 180 .name = "spi",
181 .devname = "s3c64xx-spi.0", 181 .devname = "s3c6410-spi.0",
182 .parent = &clk_p, 182 .parent = &clk_p,
183 .enable = s3c64xx_pclk_ctrl, 183 .enable = s3c64xx_pclk_ctrl,
184 .ctrlbit = S3C_CLKCON_PCLK_SPI0, 184 .ctrlbit = S3C_CLKCON_PCLK_SPI0,
185 }, { 185 }, {
186 .name = "spi", 186 .name = "spi",
187 .devname = "s3c64xx-spi.1", 187 .devname = "s3c6410-spi.1",
188 .parent = &clk_p, 188 .parent = &clk_p,
189 .enable = s3c64xx_pclk_ctrl, 189 .enable = s3c64xx_pclk_ctrl,
190 .ctrlbit = S3C_CLKCON_PCLK_SPI1, 190 .ctrlbit = S3C_CLKCON_PCLK_SPI1,
@@ -331,7 +331,7 @@ static struct clk init_clocks_off[] = {
331 331
332static struct clk clk_48m_spi0 = { 332static struct clk clk_48m_spi0 = {
333 .name = "spi_48m", 333 .name = "spi_48m",
334 .devname = "s3c64xx-spi.0", 334 .devname = "s3c6410-spi.0",
335 .parent = &clk_48m, 335 .parent = &clk_48m,
336 .enable = s3c64xx_sclk_ctrl, 336 .enable = s3c64xx_sclk_ctrl,
337 .ctrlbit = S3C_CLKCON_SCLK_SPI0_48, 337 .ctrlbit = S3C_CLKCON_SCLK_SPI0_48,
@@ -339,7 +339,7 @@ static struct clk clk_48m_spi0 = {
339 339
340static struct clk clk_48m_spi1 = { 340static struct clk clk_48m_spi1 = {
341 .name = "spi_48m", 341 .name = "spi_48m",
342 .devname = "s3c64xx-spi.1", 342 .devname = "s3c6410-spi.1",
343 .parent = &clk_48m, 343 .parent = &clk_48m,
344 .enable = s3c64xx_sclk_ctrl, 344 .enable = s3c64xx_sclk_ctrl,
345 .ctrlbit = S3C_CLKCON_SCLK_SPI1_48, 345 .ctrlbit = S3C_CLKCON_SCLK_SPI1_48,
@@ -802,7 +802,7 @@ static struct clksrc_clk clk_sclk_mmc2 = {
802static struct clksrc_clk clk_sclk_spi0 = { 802static struct clksrc_clk clk_sclk_spi0 = {
803 .clk = { 803 .clk = {
804 .name = "spi-bus", 804 .name = "spi-bus",
805 .devname = "s3c64xx-spi.0", 805 .devname = "s3c6410-spi.0",
806 .ctrlbit = S3C_CLKCON_SCLK_SPI0, 806 .ctrlbit = S3C_CLKCON_SCLK_SPI0,
807 .enable = s3c64xx_sclk_ctrl, 807 .enable = s3c64xx_sclk_ctrl,
808 }, 808 },
@@ -814,7 +814,7 @@ static struct clksrc_clk clk_sclk_spi0 = {
814static struct clksrc_clk clk_sclk_spi1 = { 814static struct clksrc_clk clk_sclk_spi1 = {
815 .clk = { 815 .clk = {
816 .name = "spi-bus", 816 .name = "spi-bus",
817 .devname = "s3c64xx-spi.1", 817 .devname = "s3c6410-spi.1",
818 .ctrlbit = S3C_CLKCON_SCLK_SPI1, 818 .ctrlbit = S3C_CLKCON_SCLK_SPI1,
819 .enable = s3c64xx_sclk_ctrl, 819 .enable = s3c64xx_sclk_ctrl,
820 }, 820 },
@@ -858,10 +858,10 @@ static struct clk_lookup s3c64xx_clk_lookup[] = {
858 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_sclk_mmc1.clk), 858 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_sclk_mmc1.clk),
859 CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2.clk), 859 CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2.clk),
860 CLKDEV_INIT(NULL, "spi_busclk0", &clk_p), 860 CLKDEV_INIT(NULL, "spi_busclk0", &clk_p),
861 CLKDEV_INIT("s3c64xx-spi.0", "spi_busclk1", &clk_sclk_spi0.clk), 861 CLKDEV_INIT("s3c6410-spi.0", "spi_busclk1", &clk_sclk_spi0.clk),
862 CLKDEV_INIT("s3c64xx-spi.0", "spi_busclk2", &clk_48m_spi0), 862 CLKDEV_INIT("s3c6410-spi.0", "spi_busclk2", &clk_48m_spi0),
863 CLKDEV_INIT("s3c64xx-spi.1", "spi_busclk1", &clk_sclk_spi1.clk), 863 CLKDEV_INIT("s3c6410-spi.1", "spi_busclk1", &clk_sclk_spi1.clk),
864 CLKDEV_INIT("s3c64xx-spi.1", "spi_busclk2", &clk_48m_spi1), 864 CLKDEV_INIT("s3c6410-spi.1", "spi_busclk2", &clk_48m_spi1),
865}; 865};
866 866
867#define GET_DIV(clk, field) ((((clk) & field##_MASK) >> field##_SHIFT) + 1) 867#define GET_DIV(clk, field) ((((clk) & field##_MASK) >> field##_SHIFT) + 1)
diff --git a/arch/arm/mach-s3c64xx/include/mach/crag6410.h b/arch/arm/mach-s3c64xx/include/mach/crag6410.h
index 4cb2f951f1e..4c3c9994fc2 100644
--- a/arch/arm/mach-s3c64xx/include/mach/crag6410.h
+++ b/arch/arm/mach-s3c64xx/include/mach/crag6410.h
@@ -13,9 +13,7 @@
13 13
14#include <linux/gpio.h> 14#include <linux/gpio.h>
15 15
16#define BANFF_PMIC_IRQ_BASE IRQ_BOARD_START 16#define GLENFARCLAS_PMIC_IRQ_BASE IRQ_BOARD_START
17#define GLENFARCLAS_PMIC_IRQ_BASE (IRQ_BOARD_START + 64)
18#define CODEC_IRQ_BASE (IRQ_BOARD_START + 128)
19 17
20#define PCA935X_GPIO_BASE GPIO_BOARD_START 18#define PCA935X_GPIO_BASE GPIO_BOARD_START
21#define CODEC_GPIO_BASE (GPIO_BOARD_START + 8) 19#define CODEC_GPIO_BASE (GPIO_BOARD_START + 8)
diff --git a/arch/arm/mach-s3c64xx/include/mach/dma.h b/arch/arm/mach-s3c64xx/include/mach/dma.h
index fe1a98cf0e4..57b1ff4b2d7 100644
--- a/arch/arm/mach-s3c64xx/include/mach/dma.h
+++ b/arch/arm/mach-s3c64xx/include/mach/dma.h
@@ -21,6 +21,7 @@
21 */ 21 */
22enum dma_ch { 22enum dma_ch {
23 /* DMA0/SDMA0 */ 23 /* DMA0/SDMA0 */
24 DMACH_DT_PROP = -1, /* not yet supported, do not use */
24 DMACH_UART0 = 0, 25 DMACH_UART0 = 0,
25 DMACH_UART0_SRC2, 26 DMACH_UART0_SRC2,
26 DMACH_UART1, 27 DMACH_UART1,
diff --git a/arch/arm/mach-s3c64xx/include/mach/pm-core.h b/arch/arm/mach-s3c64xx/include/mach/pm-core.h
index fcf3dcabb69..c0537f40a3d 100644
--- a/arch/arm/mach-s3c64xx/include/mach/pm-core.h
+++ b/arch/arm/mach-s3c64xx/include/mach/pm-core.h
@@ -12,6 +12,9 @@
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13 */ 13 */
14 14
15#ifndef __MACH_S3C64XX_PM_CORE_H
16#define __MACH_S3C64XX_PM_CORE_H __FILE__
17
15#include <mach/regs-gpio.h> 18#include <mach/regs-gpio.h>
16 19
17static inline void s3c_pm_debug_init_uart(void) 20static inline void s3c_pm_debug_init_uart(void)
@@ -113,3 +116,4 @@ static inline void samsung_pm_saved_gpios(void)
113 116
114 __raw_writel(S3C64XX_SLPEN_USE_xSLP, S3C64XX_SLPEN); 117 __raw_writel(S3C64XX_SLPEN_USE_xSLP, S3C64XX_SLPEN);
115} 118}
119#endif /* __MACH_S3C64XX_PM_CORE_H */
diff --git a/arch/arm/mach-s3c64xx/include/mach/spi-clocks.h b/arch/arm/mach-s3c64xx/include/mach/spi-clocks.h
deleted file mode 100644
index 9d0c43b4b68..00000000000
--- a/arch/arm/mach-s3c64xx/include/mach/spi-clocks.h
+++ /dev/null
@@ -1,18 +0,0 @@
1/* linux/arch/arm/mach-s3c64xx/include/mach/spi-clocks.h
2 *
3 * Copyright (C) 2009 Samsung Electronics Ltd.
4 * Jaswinder Singh <jassi.brar@samsung.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __S3C64XX_PLAT_SPI_CLKS_H
12#define __S3C64XX_PLAT_SPI_CLKS_H __FILE__
13
14#define S3C64XX_SPI_SRCCLK_PCLK 0
15#define S3C64XX_SPI_SRCCLK_SPIBUS 1
16#define S3C64XX_SPI_SRCCLK_48M 2
17
18#endif /* __S3C64XX_PLAT_SPI_CLKS_H */
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c
index 7a27f5603c7..9e382e7c77c 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410-module.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410-module.c
@@ -29,7 +29,6 @@
29#include <mach/crag6410.h> 29#include <mach/crag6410.h>
30 30
31static struct s3c64xx_spi_csinfo wm0010_spi_csinfo = { 31static struct s3c64xx_spi_csinfo wm0010_spi_csinfo = {
32 .set_level = gpio_set_value,
33 .line = S3C64XX_GPC(3), 32 .line = S3C64XX_GPC(3),
34}; 33};
35 34
@@ -39,6 +38,7 @@ static struct spi_board_info wm1253_devs[] = {
39 .bus_num = 0, 38 .bus_num = 0,
40 .chip_select = 0, 39 .chip_select = 0,
41 .mode = SPI_MODE_0, 40 .mode = SPI_MODE_0,
41 .irq = S3C_EINT(5),
42 .controller_data = &wm0010_spi_csinfo, 42 .controller_data = &wm0010_spi_csinfo,
43 }, 43 },
44}; 44};
@@ -168,7 +168,6 @@ static struct wm8994_pdata wm8994_pdata = {
168 .gpio_defaults = { 168 .gpio_defaults = {
169 0x3, /* IRQ out, active high, CMOS */ 169 0x3, /* IRQ out, active high, CMOS */
170 }, 170 },
171 .irq_base = CODEC_IRQ_BASE,
172 .ldo = { 171 .ldo = {
173 { .init_data = &wm8994_ldo1, }, 172 { .init_data = &wm8994_ldo1, },
174 { .init_data = &wm8994_ldo2, }, 173 { .init_data = &wm8994_ldo2, },
@@ -182,6 +181,11 @@ static const struct i2c_board_info wm1277_devs[] = {
182 }, 181 },
183}; 182};
184 183
184static const struct i2c_board_info wm5102_devs[] = {
185 { I2C_BOARD_INFO("wm5102", 0x1a),
186 .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, },
187};
188
185static const struct i2c_board_info wm6230_i2c_devs[] = { 189static const struct i2c_board_info wm6230_i2c_devs[] = {
186 { I2C_BOARD_INFO("wm9081", 0x6c), 190 { I2C_BOARD_INFO("wm9081", 0x6c),
187 .platform_data = &wm9081_pdata, }, 191 .platform_data = &wm9081_pdata, },
@@ -209,6 +213,7 @@ static __devinitdata const struct {
209 .spi_devs = wm1253_devs, .num_spi_devs = ARRAY_SIZE(wm1253_devs) }, 213 .spi_devs = wm1253_devs, .num_spi_devs = ARRAY_SIZE(wm1253_devs) },
210 { .id = 0x32, .name = "XXXX-EV1 Caol Illa" }, 214 { .id = 0x32, .name = "XXXX-EV1 Caol Illa" },
211 { .id = 0x33, .name = "XXXX-EV1 Oban" }, 215 { .id = 0x33, .name = "XXXX-EV1 Oban" },
216 { .id = 0x34, .name = "WM0010-6320-CS42 Balblair" },
212 { .id = 0x39, .name = "1254-EV1 Dallas Dhu", 217 { .id = 0x39, .name = "1254-EV1 Dallas Dhu",
213 .i2c_devs = wm1254_devs, .num_i2c_devs = ARRAY_SIZE(wm1254_devs) }, 218 .i2c_devs = wm1254_devs, .num_i2c_devs = ARRAY_SIZE(wm1254_devs) },
214 { .id = 0x3a, .name = "1259-EV1 Tobermory", 219 { .id = 0x3a, .name = "1259-EV1 Tobermory",
@@ -218,6 +223,8 @@ static __devinitdata const struct {
218 { .id = 0x3c, .name = "1273-EV1 Longmorn" }, 223 { .id = 0x3c, .name = "1273-EV1 Longmorn" },
219 { .id = 0x3d, .name = "1277-EV1 Littlemill", 224 { .id = 0x3d, .name = "1277-EV1 Littlemill",
220 .i2c_devs = wm1277_devs, .num_i2c_devs = ARRAY_SIZE(wm1277_devs) }, 225 .i2c_devs = wm1277_devs, .num_i2c_devs = ARRAY_SIZE(wm1277_devs) },
226 { .id = 0x3e, .name = "WM5102-6271-EV1-CS127",
227 .i2c_devs = wm5102_devs, .num_i2c_devs = ARRAY_SIZE(wm5102_devs) },
221}; 228};
222 229
223static __devinit int wlf_gf_module_probe(struct i2c_client *i2c, 230static __devinit int wlf_gf_module_probe(struct i2c_client *i2c,
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c b/arch/arm/mach-s3c64xx/mach-crag6410.c
index d0c352d861f..09cd81207a3 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -171,7 +171,7 @@ static struct fb_videomode crag6410_lcd_timing = {
171}; 171};
172 172
173/* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */ 173/* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */
174static struct s3c_fb_platdata crag6410_lcd_pdata __initdata = { 174static struct s3c_fb_platdata crag6410_lcd_pdata __devinitdata = {
175 .setup_gpio = s3c64xx_fb_gpio_setup_24bpp, 175 .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
176 .vtiming = &crag6410_lcd_timing, 176 .vtiming = &crag6410_lcd_timing,
177 .win[0] = &crag6410_fb_win0, 177 .win[0] = &crag6410_fb_win0,
@@ -181,7 +181,7 @@ static struct s3c_fb_platdata crag6410_lcd_pdata __initdata = {
181 181
182/* 2x6 keypad */ 182/* 2x6 keypad */
183 183
184static uint32_t crag6410_keymap[] __initdata = { 184static uint32_t crag6410_keymap[] __devinitdata = {
185 /* KEY(row, col, keycode) */ 185 /* KEY(row, col, keycode) */
186 KEY(0, 0, KEY_VOLUMEUP), 186 KEY(0, 0, KEY_VOLUMEUP),
187 KEY(0, 1, KEY_HOME), 187 KEY(0, 1, KEY_HOME),
@@ -197,12 +197,12 @@ static uint32_t crag6410_keymap[] __initdata = {
197 KEY(1, 5, KEY_CAMERA), 197 KEY(1, 5, KEY_CAMERA),
198}; 198};
199 199
200static struct matrix_keymap_data crag6410_keymap_data __initdata = { 200static struct matrix_keymap_data crag6410_keymap_data __devinitdata = {
201 .keymap = crag6410_keymap, 201 .keymap = crag6410_keymap,
202 .keymap_size = ARRAY_SIZE(crag6410_keymap), 202 .keymap_size = ARRAY_SIZE(crag6410_keymap),
203}; 203};
204 204
205static struct samsung_keypad_platdata crag6410_keypad_data __initdata = { 205static struct samsung_keypad_platdata crag6410_keypad_data __devinitdata = {
206 .keymap_data = &crag6410_keymap_data, 206 .keymap_data = &crag6410_keymap_data,
207 .rows = 2, 207 .rows = 2,
208 .cols = 6, 208 .cols = 6,
@@ -373,11 +373,11 @@ static struct wm831x_buckv_pdata vddarm_pdata = {
373 .dvs_gpio = S3C64XX_GPK(0), 373 .dvs_gpio = S3C64XX_GPK(0),
374}; 374};
375 375
376static struct regulator_consumer_supply vddarm_consumers[] __initdata = { 376static struct regulator_consumer_supply vddarm_consumers[] __devinitdata = {
377 REGULATOR_SUPPLY("vddarm", NULL), 377 REGULATOR_SUPPLY("vddarm", NULL),
378}; 378};
379 379
380static struct regulator_init_data vddarm __initdata = { 380static struct regulator_init_data vddarm __devinitdata = {
381 .constraints = { 381 .constraints = {
382 .name = "VDDARM", 382 .name = "VDDARM",
383 .min_uV = 1000000, 383 .min_uV = 1000000,
@@ -391,11 +391,11 @@ static struct regulator_init_data vddarm __initdata = {
391 .driver_data = &vddarm_pdata, 391 .driver_data = &vddarm_pdata,
392}; 392};
393 393
394static struct regulator_consumer_supply vddint_consumers[] __initdata = { 394static struct regulator_consumer_supply vddint_consumers[] __devinitdata = {
395 REGULATOR_SUPPLY("vddint", NULL), 395 REGULATOR_SUPPLY("vddint", NULL),
396}; 396};
397 397
398static struct regulator_init_data vddint __initdata = { 398static struct regulator_init_data vddint __devinitdata = {
399 .constraints = { 399 .constraints = {
400 .name = "VDDINT", 400 .name = "VDDINT",
401 .min_uV = 1000000, 401 .min_uV = 1000000,
@@ -408,27 +408,27 @@ static struct regulator_init_data vddint __initdata = {
408 .supply_regulator = "WALLVDD", 408 .supply_regulator = "WALLVDD",
409}; 409};
410 410
411static struct regulator_init_data vddmem __initdata = { 411static struct regulator_init_data vddmem __devinitdata = {
412 .constraints = { 412 .constraints = {
413 .name = "VDDMEM", 413 .name = "VDDMEM",
414 .always_on = 1, 414 .always_on = 1,
415 }, 415 },
416}; 416};
417 417
418static struct regulator_init_data vddsys __initdata = { 418static struct regulator_init_data vddsys __devinitdata = {
419 .constraints = { 419 .constraints = {
420 .name = "VDDSYS,VDDEXT,VDDPCM,VDDSS", 420 .name = "VDDSYS,VDDEXT,VDDPCM,VDDSS",
421 .always_on = 1, 421 .always_on = 1,
422 }, 422 },
423}; 423};
424 424
425static struct regulator_consumer_supply vddmmc_consumers[] __initdata = { 425static struct regulator_consumer_supply vddmmc_consumers[] __devinitdata = {
426 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"), 426 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),
427 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.1"), 427 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.1"),
428 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.2"), 428 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.2"),
429}; 429};
430 430
431static struct regulator_init_data vddmmc __initdata = { 431static struct regulator_init_data vddmmc __devinitdata = {
432 .constraints = { 432 .constraints = {
433 .name = "VDDMMC,UH", 433 .name = "VDDMMC,UH",
434 .always_on = 1, 434 .always_on = 1,
@@ -438,7 +438,7 @@ static struct regulator_init_data vddmmc __initdata = {
438 .supply_regulator = "WALLVDD", 438 .supply_regulator = "WALLVDD",
439}; 439};
440 440
441static struct regulator_init_data vddotgi __initdata = { 441static struct regulator_init_data vddotgi __devinitdata = {
442 .constraints = { 442 .constraints = {
443 .name = "VDDOTGi", 443 .name = "VDDOTGi",
444 .always_on = 1, 444 .always_on = 1,
@@ -446,7 +446,7 @@ static struct regulator_init_data vddotgi __initdata = {
446 .supply_regulator = "WALLVDD", 446 .supply_regulator = "WALLVDD",
447}; 447};
448 448
449static struct regulator_init_data vddotg __initdata = { 449static struct regulator_init_data vddotg __devinitdata = {
450 .constraints = { 450 .constraints = {
451 .name = "VDDOTG", 451 .name = "VDDOTG",
452 .always_on = 1, 452 .always_on = 1,
@@ -454,7 +454,7 @@ static struct regulator_init_data vddotg __initdata = {
454 .supply_regulator = "WALLVDD", 454 .supply_regulator = "WALLVDD",
455}; 455};
456 456
457static struct regulator_init_data vddhi __initdata = { 457static struct regulator_init_data vddhi __devinitdata = {
458 .constraints = { 458 .constraints = {
459 .name = "VDDHI", 459 .name = "VDDHI",
460 .always_on = 1, 460 .always_on = 1,
@@ -462,7 +462,7 @@ static struct regulator_init_data vddhi __initdata = {
462 .supply_regulator = "WALLVDD", 462 .supply_regulator = "WALLVDD",
463}; 463};
464 464
465static struct regulator_init_data vddadc __initdata = { 465static struct regulator_init_data vddadc __devinitdata = {
466 .constraints = { 466 .constraints = {
467 .name = "VDDADC,VDDDAC", 467 .name = "VDDADC,VDDDAC",
468 .always_on = 1, 468 .always_on = 1,
@@ -470,7 +470,7 @@ static struct regulator_init_data vddadc __initdata = {
470 .supply_regulator = "WALLVDD", 470 .supply_regulator = "WALLVDD",
471}; 471};
472 472
473static struct regulator_init_data vddmem0 __initdata = { 473static struct regulator_init_data vddmem0 __devinitdata = {
474 .constraints = { 474 .constraints = {
475 .name = "VDDMEM0", 475 .name = "VDDMEM0",
476 .always_on = 1, 476 .always_on = 1,
@@ -478,7 +478,7 @@ static struct regulator_init_data vddmem0 __initdata = {
478 .supply_regulator = "WALLVDD", 478 .supply_regulator = "WALLVDD",
479}; 479};
480 480
481static struct regulator_init_data vddpll __initdata = { 481static struct regulator_init_data vddpll __devinitdata = {
482 .constraints = { 482 .constraints = {
483 .name = "VDDPLL", 483 .name = "VDDPLL",
484 .always_on = 1, 484 .always_on = 1,
@@ -486,7 +486,7 @@ static struct regulator_init_data vddpll __initdata = {
486 .supply_regulator = "WALLVDD", 486 .supply_regulator = "WALLVDD",
487}; 487};
488 488
489static struct regulator_init_data vddlcd __initdata = { 489static struct regulator_init_data vddlcd __devinitdata = {
490 .constraints = { 490 .constraints = {
491 .name = "VDDLCD", 491 .name = "VDDLCD",
492 .always_on = 1, 492 .always_on = 1,
@@ -494,7 +494,7 @@ static struct regulator_init_data vddlcd __initdata = {
494 .supply_regulator = "WALLVDD", 494 .supply_regulator = "WALLVDD",
495}; 495};
496 496
497static struct regulator_init_data vddalive __initdata = { 497static struct regulator_init_data vddalive __devinitdata = {
498 .constraints = { 498 .constraints = {
499 .name = "VDDALIVE", 499 .name = "VDDALIVE",
500 .always_on = 1, 500 .always_on = 1,
@@ -502,30 +502,29 @@ static struct regulator_init_data vddalive __initdata = {
502 .supply_regulator = "WALLVDD", 502 .supply_regulator = "WALLVDD",
503}; 503};
504 504
505static struct wm831x_backup_pdata banff_backup_pdata __initdata = { 505static struct wm831x_backup_pdata banff_backup_pdata __devinitdata = {
506 .charger_enable = 1, 506 .charger_enable = 1,
507 .vlim = 2500, /* mV */ 507 .vlim = 2500, /* mV */
508 .ilim = 200, /* uA */ 508 .ilim = 200, /* uA */
509}; 509};
510 510
511static struct wm831x_status_pdata banff_red_led __initdata = { 511static struct wm831x_status_pdata banff_red_led __devinitdata = {
512 .name = "banff:red:", 512 .name = "banff:red:",
513 .default_src = WM831X_STATUS_MANUAL, 513 .default_src = WM831X_STATUS_MANUAL,
514}; 514};
515 515
516static struct wm831x_status_pdata banff_green_led __initdata = { 516static struct wm831x_status_pdata banff_green_led __devinitdata = {
517 .name = "banff:green:", 517 .name = "banff:green:",
518 .default_src = WM831X_STATUS_MANUAL, 518 .default_src = WM831X_STATUS_MANUAL,
519}; 519};
520 520
521static struct wm831x_touch_pdata touch_pdata __initdata = { 521static struct wm831x_touch_pdata touch_pdata __devinitdata = {
522 .data_irq = S3C_EINT(26), 522 .data_irq = S3C_EINT(26),
523 .pd_irq = S3C_EINT(27), 523 .pd_irq = S3C_EINT(27),
524}; 524};
525 525
526static struct wm831x_pdata crag_pmic_pdata __initdata = { 526static struct wm831x_pdata crag_pmic_pdata __devinitdata = {
527 .wm831x_num = 1, 527 .wm831x_num = 1,
528 .irq_base = BANFF_PMIC_IRQ_BASE,
529 .gpio_base = BANFF_PMIC_GPIO_BASE, 528 .gpio_base = BANFF_PMIC_GPIO_BASE,
530 .soft_shutdown = true, 529 .soft_shutdown = true,
531 530
@@ -568,7 +567,7 @@ static struct wm831x_pdata crag_pmic_pdata __initdata = {
568 .touch = &touch_pdata, 567 .touch = &touch_pdata,
569}; 568};
570 569
571static struct i2c_board_info i2c_devs0[] __initdata = { 570static struct i2c_board_info i2c_devs0[] __devinitdata = {
572 { I2C_BOARD_INFO("24c08", 0x50), }, 571 { I2C_BOARD_INFO("24c08", 0x50), },
573 { I2C_BOARD_INFO("tca6408", 0x20), 572 { I2C_BOARD_INFO("tca6408", 0x20),
574 .platform_data = &crag6410_pca_data, 573 .platform_data = &crag6410_pca_data,
@@ -583,12 +582,12 @@ static struct s3c2410_platform_i2c i2c0_pdata = {
583 .frequency = 400000, 582 .frequency = 400000,
584}; 583};
585 584
586static struct regulator_consumer_supply pvdd_1v2_consumers[] __initdata = { 585static struct regulator_consumer_supply pvdd_1v2_consumers[] __devinitdata = {
587 REGULATOR_SUPPLY("DCVDD", "spi0.0"), 586 REGULATOR_SUPPLY("DCVDD", "spi0.0"),
588 REGULATOR_SUPPLY("AVDD", "spi0.0"), 587 REGULATOR_SUPPLY("AVDD", "spi0.0"),
589}; 588};
590 589
591static struct regulator_init_data pvdd_1v2 __initdata = { 590static struct regulator_init_data pvdd_1v2 __devinitdata = {
592 .constraints = { 591 .constraints = {
593 .name = "PVDD_1V2", 592 .name = "PVDD_1V2",
594 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 593 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
@@ -598,7 +597,7 @@ static struct regulator_init_data pvdd_1v2 __initdata = {
598 .num_consumer_supplies = ARRAY_SIZE(pvdd_1v2_consumers), 597 .num_consumer_supplies = ARRAY_SIZE(pvdd_1v2_consumers),
599}; 598};
600 599
601static struct regulator_consumer_supply pvdd_1v8_consumers[] __initdata = { 600static struct regulator_consumer_supply pvdd_1v8_consumers[] __devinitdata = {
602 REGULATOR_SUPPLY("LDOVDD", "1-001a"), 601 REGULATOR_SUPPLY("LDOVDD", "1-001a"),
603 REGULATOR_SUPPLY("PLLVDD", "1-001a"), 602 REGULATOR_SUPPLY("PLLVDD", "1-001a"),
604 REGULATOR_SUPPLY("DBVDD", "1-001a"), 603 REGULATOR_SUPPLY("DBVDD", "1-001a"),
@@ -612,7 +611,7 @@ static struct regulator_consumer_supply pvdd_1v8_consumers[] __initdata = {
612 REGULATOR_SUPPLY("DBVDD", "spi0.0"), 611 REGULATOR_SUPPLY("DBVDD", "spi0.0"),
613}; 612};
614 613
615static struct regulator_init_data pvdd_1v8 __initdata = { 614static struct regulator_init_data pvdd_1v8 __devinitdata = {
616 .constraints = { 615 .constraints = {
617 .name = "PVDD_1V8", 616 .name = "PVDD_1V8",
618 .always_on = 1, 617 .always_on = 1,
@@ -622,12 +621,12 @@ static struct regulator_init_data pvdd_1v8 __initdata = {
622 .num_consumer_supplies = ARRAY_SIZE(pvdd_1v8_consumers), 621 .num_consumer_supplies = ARRAY_SIZE(pvdd_1v8_consumers),
623}; 622};
624 623
625static struct regulator_consumer_supply pvdd_3v3_consumers[] __initdata = { 624static struct regulator_consumer_supply pvdd_3v3_consumers[] __devinitdata = {
626 REGULATOR_SUPPLY("MICVDD", "1-001a"), 625 REGULATOR_SUPPLY("MICVDD", "1-001a"),
627 REGULATOR_SUPPLY("AVDD1", "1-001a"), 626 REGULATOR_SUPPLY("AVDD1", "1-001a"),
628}; 627};
629 628
630static struct regulator_init_data pvdd_3v3 __initdata = { 629static struct regulator_init_data pvdd_3v3 __devinitdata = {
631 .constraints = { 630 .constraints = {
632 .name = "PVDD_3V3", 631 .name = "PVDD_3V3",
633 .always_on = 1, 632 .always_on = 1,
@@ -637,7 +636,7 @@ static struct regulator_init_data pvdd_3v3 __initdata = {
637 .num_consumer_supplies = ARRAY_SIZE(pvdd_3v3_consumers), 636 .num_consumer_supplies = ARRAY_SIZE(pvdd_3v3_consumers),
638}; 637};
639 638
640static struct wm831x_pdata glenfarclas_pmic_pdata __initdata = { 639static struct wm831x_pdata glenfarclas_pmic_pdata __devinitdata = {
641 .wm831x_num = 2, 640 .wm831x_num = 2,
642 .irq_base = GLENFARCLAS_PMIC_IRQ_BASE, 641 .irq_base = GLENFARCLAS_PMIC_IRQ_BASE,
643 .gpio_base = GLENFARCLAS_PMIC_GPIO_BASE, 642 .gpio_base = GLENFARCLAS_PMIC_GPIO_BASE,
@@ -669,7 +668,7 @@ static struct wm1250_ev1_pdata wm1250_ev1_pdata = {
669 }, 668 },
670}; 669};
671 670
672static struct i2c_board_info i2c_devs1[] __initdata = { 671static struct i2c_board_info i2c_devs1[] __devinitdata = {
673 { I2C_BOARD_INFO("wm8311", 0x34), 672 { I2C_BOARD_INFO("wm8311", 0x34),
674 .irq = S3C_EINT(0), 673 .irq = S3C_EINT(0),
675 .platform_data = &glenfarclas_pmic_pdata }, 674 .platform_data = &glenfarclas_pmic_pdata },
@@ -799,7 +798,7 @@ static void __init crag6410_machine_init(void)
799 i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1)); 798 i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
800 799
801 samsung_keypad_set_platdata(&crag6410_keypad_data); 800 samsung_keypad_set_platdata(&crag6410_keypad_data);
802 s3c64xx_spi0_set_platdata(&s3c64xx_spi0_pdata, 0, 1); 801 s3c64xx_spi0_set_platdata(NULL, 0, 1);
803 802
804 platform_add_devices(crag6410_devices, ARRAY_SIZE(crag6410_devices)); 803 platform_add_devices(crag6410_devices, ARRAY_SIZE(crag6410_devices));
805 804
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index df3103d450e..0fe4f1503f4 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -566,7 +566,6 @@ static struct wm831x_status_pdata wm1192_led8_pdata = {
566 566
567static struct wm831x_pdata smdk6410_wm1192_pdata = { 567static struct wm831x_pdata smdk6410_wm1192_pdata = {
568 .pre_init = wm1192_pre_init, 568 .pre_init = wm1192_pre_init,
569 .irq_base = IRQ_BOARD_START,
570 569
571 .backlight = &wm1192_backlight_pdata, 570 .backlight = &wm1192_backlight_pdata,
572 .dcdc = { 571 .dcdc = {
diff --git a/arch/arm/mach-s3c64xx/setup-spi.c b/arch/arm/mach-s3c64xx/setup-spi.c
index d9592ad7a82..4dc53450d71 100644
--- a/arch/arm/mach-s3c64xx/setup-spi.c
+++ b/arch/arm/mach-s3c64xx/setup-spi.c
@@ -9,19 +9,10 @@
9 */ 9 */
10 10
11#include <linux/gpio.h> 11#include <linux/gpio.h>
12#include <linux/platform_device.h>
13
14#include <plat/gpio-cfg.h> 12#include <plat/gpio-cfg.h>
15#include <plat/s3c64xx-spi.h>
16 13
17#ifdef CONFIG_S3C64XX_DEV_SPI0 14#ifdef CONFIG_S3C64XX_DEV_SPI0
18struct s3c64xx_spi_info s3c64xx_spi0_pdata __initdata = { 15int s3c64xx_spi0_cfg_gpio(void)
19 .fifo_lvl_mask = 0x7f,
20 .rx_lvl_offset = 13,
21 .tx_st_done = 21,
22};
23
24int s3c64xx_spi0_cfg_gpio(struct platform_device *dev)
25{ 16{
26 s3c_gpio_cfgall_range(S3C64XX_GPC(0), 3, 17 s3c_gpio_cfgall_range(S3C64XX_GPC(0), 3,
27 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP); 18 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
@@ -30,13 +21,7 @@ int s3c64xx_spi0_cfg_gpio(struct platform_device *dev)
30#endif 21#endif
31 22
32#ifdef CONFIG_S3C64XX_DEV_SPI1 23#ifdef CONFIG_S3C64XX_DEV_SPI1
33struct s3c64xx_spi_info s3c64xx_spi1_pdata __initdata = { 24int s3c64xx_spi1_cfg_gpio(void)
34 .fifo_lvl_mask = 0x7f,
35 .rx_lvl_offset = 13,
36 .tx_st_done = 21,
37};
38
39int s3c64xx_spi1_cfg_gpio(struct platform_device *dev)
40{ 25{
41 s3c_gpio_cfgall_range(S3C64XX_GPC(4), 3, 26 s3c_gpio_cfgall_range(S3C64XX_GPC(4), 3,
42 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP); 27 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
diff --git a/arch/arm/mach-s5p64x0/clock-s5p6440.c b/arch/arm/mach-s5p64x0/clock-s5p6440.c
index ee1e8e7f563..000445596ec 100644
--- a/arch/arm/mach-s5p64x0/clock-s5p6440.c
+++ b/arch/arm/mach-s5p64x0/clock-s5p6440.c
@@ -227,13 +227,13 @@ static struct clk init_clocks_off[] = {
227 .ctrlbit = (1 << 17), 227 .ctrlbit = (1 << 17),
228 }, { 228 }, {
229 .name = "spi", 229 .name = "spi",
230 .devname = "s3c64xx-spi.0", 230 .devname = "s5p64x0-spi.0",
231 .parent = &clk_pclk_low.clk, 231 .parent = &clk_pclk_low.clk,
232 .enable = s5p64x0_pclk_ctrl, 232 .enable = s5p64x0_pclk_ctrl,
233 .ctrlbit = (1 << 21), 233 .ctrlbit = (1 << 21),
234 }, { 234 }, {
235 .name = "spi", 235 .name = "spi",
236 .devname = "s3c64xx-spi.1", 236 .devname = "s5p64x0-spi.1",
237 .parent = &clk_pclk_low.clk, 237 .parent = &clk_pclk_low.clk,
238 .enable = s5p64x0_pclk_ctrl, 238 .enable = s5p64x0_pclk_ctrl,
239 .ctrlbit = (1 << 22), 239 .ctrlbit = (1 << 22),
@@ -467,7 +467,7 @@ static struct clksrc_clk clk_sclk_uclk = {
467static struct clksrc_clk clk_sclk_spi0 = { 467static struct clksrc_clk clk_sclk_spi0 = {
468 .clk = { 468 .clk = {
469 .name = "sclk_spi", 469 .name = "sclk_spi",
470 .devname = "s3c64xx-spi.0", 470 .devname = "s5p64x0-spi.0",
471 .ctrlbit = (1 << 20), 471 .ctrlbit = (1 << 20),
472 .enable = s5p64x0_sclk_ctrl, 472 .enable = s5p64x0_sclk_ctrl,
473 }, 473 },
@@ -479,7 +479,7 @@ static struct clksrc_clk clk_sclk_spi0 = {
479static struct clksrc_clk clk_sclk_spi1 = { 479static struct clksrc_clk clk_sclk_spi1 = {
480 .clk = { 480 .clk = {
481 .name = "sclk_spi", 481 .name = "sclk_spi",
482 .devname = "s3c64xx-spi.1", 482 .devname = "s5p64x0-spi.1",
483 .ctrlbit = (1 << 21), 483 .ctrlbit = (1 << 21),
484 .enable = s5p64x0_sclk_ctrl, 484 .enable = s5p64x0_sclk_ctrl,
485 }, 485 },
@@ -519,8 +519,8 @@ static struct clk_lookup s5p6440_clk_lookup[] = {
519 CLKDEV_INIT(NULL, "clk_uart_baud2", &clk_pclk_low.clk), 519 CLKDEV_INIT(NULL, "clk_uart_baud2", &clk_pclk_low.clk),
520 CLKDEV_INIT(NULL, "clk_uart_baud3", &clk_sclk_uclk.clk), 520 CLKDEV_INIT(NULL, "clk_uart_baud3", &clk_sclk_uclk.clk),
521 CLKDEV_INIT(NULL, "spi_busclk0", &clk_p), 521 CLKDEV_INIT(NULL, "spi_busclk0", &clk_p),
522 CLKDEV_INIT("s3c64xx-spi.0", "spi_busclk1", &clk_sclk_spi0.clk), 522 CLKDEV_INIT("s5p64x0-spi.0", "spi_busclk1", &clk_sclk_spi0.clk),
523 CLKDEV_INIT("s3c64xx-spi.1", "spi_busclk1", &clk_sclk_spi1.clk), 523 CLKDEV_INIT("s5p64x0-spi.1", "spi_busclk1", &clk_sclk_spi1.clk),
524 CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &clk_sclk_mmc0.clk), 524 CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &clk_sclk_mmc0.clk),
525 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_sclk_mmc1.clk), 525 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_sclk_mmc1.clk),
526 CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2.clk), 526 CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2.clk),
diff --git a/arch/arm/mach-s5p64x0/clock-s5p6450.c b/arch/arm/mach-s5p64x0/clock-s5p6450.c
index dae6a13f43b..f3e0ef3d27c 100644
--- a/arch/arm/mach-s5p64x0/clock-s5p6450.c
+++ b/arch/arm/mach-s5p64x0/clock-s5p6450.c
@@ -236,13 +236,13 @@ static struct clk init_clocks_off[] = {
236 .ctrlbit = (1 << 17), 236 .ctrlbit = (1 << 17),
237 }, { 237 }, {
238 .name = "spi", 238 .name = "spi",
239 .devname = "s3c64xx-spi.0", 239 .devname = "s5p64x0-spi.0",
240 .parent = &clk_pclk_low.clk, 240 .parent = &clk_pclk_low.clk,
241 .enable = s5p64x0_pclk_ctrl, 241 .enable = s5p64x0_pclk_ctrl,
242 .ctrlbit = (1 << 21), 242 .ctrlbit = (1 << 21),
243 }, { 243 }, {
244 .name = "spi", 244 .name = "spi",
245 .devname = "s3c64xx-spi.1", 245 .devname = "s5p64x0-spi.1",
246 .parent = &clk_pclk_low.clk, 246 .parent = &clk_pclk_low.clk,
247 .enable = s5p64x0_pclk_ctrl, 247 .enable = s5p64x0_pclk_ctrl,
248 .ctrlbit = (1 << 22), 248 .ctrlbit = (1 << 22),
@@ -528,7 +528,7 @@ static struct clksrc_clk clk_sclk_uclk = {
528static struct clksrc_clk clk_sclk_spi0 = { 528static struct clksrc_clk clk_sclk_spi0 = {
529 .clk = { 529 .clk = {
530 .name = "sclk_spi", 530 .name = "sclk_spi",
531 .devname = "s3c64xx-spi.0", 531 .devname = "s5p64x0-spi.0",
532 .ctrlbit = (1 << 20), 532 .ctrlbit = (1 << 20),
533 .enable = s5p64x0_sclk_ctrl, 533 .enable = s5p64x0_sclk_ctrl,
534 }, 534 },
@@ -540,7 +540,7 @@ static struct clksrc_clk clk_sclk_spi0 = {
540static struct clksrc_clk clk_sclk_spi1 = { 540static struct clksrc_clk clk_sclk_spi1 = {
541 .clk = { 541 .clk = {
542 .name = "sclk_spi", 542 .name = "sclk_spi",
543 .devname = "s3c64xx-spi.1", 543 .devname = "s5p64x0-spi.1",
544 .ctrlbit = (1 << 21), 544 .ctrlbit = (1 << 21),
545 .enable = s5p64x0_sclk_ctrl, 545 .enable = s5p64x0_sclk_ctrl,
546 }, 546 },
@@ -562,8 +562,8 @@ static struct clk_lookup s5p6450_clk_lookup[] = {
562 CLKDEV_INIT(NULL, "clk_uart_baud2", &clk_pclk_low.clk), 562 CLKDEV_INIT(NULL, "clk_uart_baud2", &clk_pclk_low.clk),
563 CLKDEV_INIT(NULL, "clk_uart_baud3", &clk_sclk_uclk.clk), 563 CLKDEV_INIT(NULL, "clk_uart_baud3", &clk_sclk_uclk.clk),
564 CLKDEV_INIT(NULL, "spi_busclk0", &clk_p), 564 CLKDEV_INIT(NULL, "spi_busclk0", &clk_p),
565 CLKDEV_INIT("s3c64xx-spi.0", "spi_busclk1", &clk_sclk_spi0.clk), 565 CLKDEV_INIT("s5p64x0-spi.0", "spi_busclk1", &clk_sclk_spi0.clk),
566 CLKDEV_INIT("s3c64xx-spi.1", "spi_busclk1", &clk_sclk_spi1.clk), 566 CLKDEV_INIT("s5p64x0-spi.1", "spi_busclk1", &clk_sclk_spi1.clk),
567 CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &clk_sclk_mmc0.clk), 567 CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &clk_sclk_mmc0.clk),
568 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_sclk_mmc1.clk), 568 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_sclk_mmc1.clk),
569 CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2.clk), 569 CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2.clk),
diff --git a/arch/arm/mach-s5p64x0/dma.c b/arch/arm/mach-s5p64x0/dma.c
index 2ee5dc069b3..9c4ce085f58 100644
--- a/arch/arm/mach-s5p64x0/dma.c
+++ b/arch/arm/mach-s5p64x0/dma.c
@@ -36,8 +36,6 @@
36#include <plat/devs.h> 36#include <plat/devs.h>
37#include <plat/irqs.h> 37#include <plat/irqs.h>
38 38
39static u64 dma_dmamask = DMA_BIT_MASK(32);
40
41static u8 s5p6440_pdma_peri[] = { 39static u8 s5p6440_pdma_peri[] = {
42 DMACH_UART0_RX, 40 DMACH_UART0_RX,
43 DMACH_UART0_TX, 41 DMACH_UART0_TX,
diff --git a/arch/arm/mach-s5p64x0/include/mach/spi-clocks.h b/arch/arm/mach-s5p64x0/include/mach/spi-clocks.h
deleted file mode 100644
index 170a20a9643..00000000000
--- a/arch/arm/mach-s5p64x0/include/mach/spi-clocks.h
+++ /dev/null
@@ -1,20 +0,0 @@
1/* linux/arch/arm/mach-s5p64x0/include/mach/spi-clocks.h
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * Copyright (C) 2010 Samsung Electronics Co. Ltd.
7 * Jaswinder Singh <jassi.brar@samsung.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12*/
13
14#ifndef __ASM_ARCH_SPI_CLKS_H
15#define __ASM_ARCH_SPI_CLKS_H __FILE__
16
17#define S5P64X0_SPI_SRCCLK_PCLK 0
18#define S5P64X0_SPI_SRCCLK_SCLK 1
19
20#endif /* __ASM_ARCH_SPI_CLKS_H */
diff --git a/arch/arm/mach-s5p64x0/setup-spi.c b/arch/arm/mach-s5p64x0/setup-spi.c
index e9b84124035..7664356720c 100644
--- a/arch/arm/mach-s5p64x0/setup-spi.c
+++ b/arch/arm/mach-s5p64x0/setup-spi.c
@@ -9,21 +9,10 @@
9 */ 9 */
10 10
11#include <linux/gpio.h> 11#include <linux/gpio.h>
12#include <linux/platform_device.h>
13#include <linux/io.h>
14
15#include <plat/gpio-cfg.h> 12#include <plat/gpio-cfg.h>
16#include <plat/cpu.h>
17#include <plat/s3c64xx-spi.h>
18 13
19#ifdef CONFIG_S3C64XX_DEV_SPI0 14#ifdef CONFIG_S3C64XX_DEV_SPI0
20struct s3c64xx_spi_info s3c64xx_spi0_pdata __initdata = { 15int s3c64xx_spi0_cfg_gpio(void)
21 .fifo_lvl_mask = 0x1ff,
22 .rx_lvl_offset = 15,
23 .tx_st_done = 25,
24};
25
26int s3c64xx_spi0_cfg_gpio(struct platform_device *dev)
27{ 16{
28 if (soc_is_s5p6450()) 17 if (soc_is_s5p6450())
29 s3c_gpio_cfgall_range(S5P6450_GPC(0), 3, 18 s3c_gpio_cfgall_range(S5P6450_GPC(0), 3,
@@ -36,13 +25,7 @@ int s3c64xx_spi0_cfg_gpio(struct platform_device *dev)
36#endif 25#endif
37 26
38#ifdef CONFIG_S3C64XX_DEV_SPI1 27#ifdef CONFIG_S3C64XX_DEV_SPI1
39struct s3c64xx_spi_info s3c64xx_spi1_pdata __initdata = { 28int s3c64xx_spi1_cfg_gpio(void)
40 .fifo_lvl_mask = 0x7f,
41 .rx_lvl_offset = 15,
42 .tx_st_done = 25,
43};
44
45int s3c64xx_spi1_cfg_gpio(struct platform_device *dev)
46{ 29{
47 if (soc_is_s5p6450()) 30 if (soc_is_s5p6450())
48 s3c_gpio_cfgall_range(S5P6450_GPC(4), 3, 31 s3c_gpio_cfgall_range(S5P6450_GPC(4), 3,
diff --git a/arch/arm/mach-s5pc100/clock.c b/arch/arm/mach-s5pc100/clock.c
index 16eca4ea201..926219791f0 100644
--- a/arch/arm/mach-s5pc100/clock.c
+++ b/arch/arm/mach-s5pc100/clock.c
@@ -564,19 +564,19 @@ static struct clk init_clocks_off[] = {
564 .ctrlbit = (1 << 5), 564 .ctrlbit = (1 << 5),
565 }, { 565 }, {
566 .name = "spi", 566 .name = "spi",
567 .devname = "s3c64xx-spi.0", 567 .devname = "s5pc100-spi.0",
568 .parent = &clk_div_d1_bus.clk, 568 .parent = &clk_div_d1_bus.clk,
569 .enable = s5pc100_d1_4_ctrl, 569 .enable = s5pc100_d1_4_ctrl,
570 .ctrlbit = (1 << 6), 570 .ctrlbit = (1 << 6),
571 }, { 571 }, {
572 .name = "spi", 572 .name = "spi",
573 .devname = "s3c64xx-spi.1", 573 .devname = "s5pc100-spi.1",
574 .parent = &clk_div_d1_bus.clk, 574 .parent = &clk_div_d1_bus.clk,
575 .enable = s5pc100_d1_4_ctrl, 575 .enable = s5pc100_d1_4_ctrl,
576 .ctrlbit = (1 << 7), 576 .ctrlbit = (1 << 7),
577 }, { 577 }, {
578 .name = "spi", 578 .name = "spi",
579 .devname = "s3c64xx-spi.2", 579 .devname = "s5pc100-spi.2",
580 .parent = &clk_div_d1_bus.clk, 580 .parent = &clk_div_d1_bus.clk,
581 .enable = s5pc100_d1_4_ctrl, 581 .enable = s5pc100_d1_4_ctrl,
582 .ctrlbit = (1 << 8), 582 .ctrlbit = (1 << 8),
@@ -702,7 +702,7 @@ static struct clk clk_hsmmc0 = {
702 702
703static struct clk clk_48m_spi0 = { 703static struct clk clk_48m_spi0 = {
704 .name = "spi_48m", 704 .name = "spi_48m",
705 .devname = "s3c64xx-spi.0", 705 .devname = "s5pc100-spi.0",
706 .parent = &clk_mout_48m.clk, 706 .parent = &clk_mout_48m.clk,
707 .enable = s5pc100_sclk0_ctrl, 707 .enable = s5pc100_sclk0_ctrl,
708 .ctrlbit = (1 << 7), 708 .ctrlbit = (1 << 7),
@@ -710,7 +710,7 @@ static struct clk clk_48m_spi0 = {
710 710
711static struct clk clk_48m_spi1 = { 711static struct clk clk_48m_spi1 = {
712 .name = "spi_48m", 712 .name = "spi_48m",
713 .devname = "s3c64xx-spi.1", 713 .devname = "s5pc100-spi.1",
714 .parent = &clk_mout_48m.clk, 714 .parent = &clk_mout_48m.clk,
715 .enable = s5pc100_sclk0_ctrl, 715 .enable = s5pc100_sclk0_ctrl,
716 .ctrlbit = (1 << 8), 716 .ctrlbit = (1 << 8),
@@ -718,7 +718,7 @@ static struct clk clk_48m_spi1 = {
718 718
719static struct clk clk_48m_spi2 = { 719static struct clk clk_48m_spi2 = {
720 .name = "spi_48m", 720 .name = "spi_48m",
721 .devname = "s3c64xx-spi.2", 721 .devname = "s5pc100-spi.2",
722 .parent = &clk_mout_48m.clk, 722 .parent = &clk_mout_48m.clk,
723 .enable = s5pc100_sclk0_ctrl, 723 .enable = s5pc100_sclk0_ctrl,
724 .ctrlbit = (1 << 9), 724 .ctrlbit = (1 << 9),
@@ -1085,7 +1085,7 @@ static struct clksrc_clk clk_sclk_mmc2 = {
1085static struct clksrc_clk clk_sclk_spi0 = { 1085static struct clksrc_clk clk_sclk_spi0 = {
1086 .clk = { 1086 .clk = {
1087 .name = "sclk_spi", 1087 .name = "sclk_spi",
1088 .devname = "s3c64xx-spi.0", 1088 .devname = "s5pc100-spi.0",
1089 .ctrlbit = (1 << 4), 1089 .ctrlbit = (1 << 4),
1090 .enable = s5pc100_sclk0_ctrl, 1090 .enable = s5pc100_sclk0_ctrl,
1091 }, 1091 },
@@ -1097,7 +1097,7 @@ static struct clksrc_clk clk_sclk_spi0 = {
1097static struct clksrc_clk clk_sclk_spi1 = { 1097static struct clksrc_clk clk_sclk_spi1 = {
1098 .clk = { 1098 .clk = {
1099 .name = "sclk_spi", 1099 .name = "sclk_spi",
1100 .devname = "s3c64xx-spi.1", 1100 .devname = "s5pc100-spi.1",
1101 .ctrlbit = (1 << 5), 1101 .ctrlbit = (1 << 5),
1102 .enable = s5pc100_sclk0_ctrl, 1102 .enable = s5pc100_sclk0_ctrl,
1103 }, 1103 },
@@ -1109,7 +1109,7 @@ static struct clksrc_clk clk_sclk_spi1 = {
1109static struct clksrc_clk clk_sclk_spi2 = { 1109static struct clksrc_clk clk_sclk_spi2 = {
1110 .clk = { 1110 .clk = {
1111 .name = "sclk_spi", 1111 .name = "sclk_spi",
1112 .devname = "s3c64xx-spi.2", 1112 .devname = "s5pc100-spi.2",
1113 .ctrlbit = (1 << 6), 1113 .ctrlbit = (1 << 6),
1114 .enable = s5pc100_sclk0_ctrl, 1114 .enable = s5pc100_sclk0_ctrl,
1115 }, 1115 },
@@ -1315,12 +1315,12 @@ static struct clk_lookup s5pc100_clk_lookup[] = {
1315 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_sclk_mmc1.clk), 1315 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_sclk_mmc1.clk),
1316 CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2.clk), 1316 CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2.clk),
1317 CLKDEV_INIT(NULL, "spi_busclk0", &clk_p), 1317 CLKDEV_INIT(NULL, "spi_busclk0", &clk_p),
1318 CLKDEV_INIT("s3c64xx-spi.0", "spi_busclk1", &clk_48m_spi0), 1318 CLKDEV_INIT("s5pc100-spi.0", "spi_busclk1", &clk_48m_spi0),
1319 CLKDEV_INIT("s3c64xx-spi.0", "spi_busclk2", &clk_sclk_spi0.clk), 1319 CLKDEV_INIT("s5pc100-spi.0", "spi_busclk2", &clk_sclk_spi0.clk),
1320 CLKDEV_INIT("s3c64xx-spi.1", "spi_busclk1", &clk_48m_spi1), 1320 CLKDEV_INIT("s5pc100-spi.1", "spi_busclk1", &clk_48m_spi1),
1321 CLKDEV_INIT("s3c64xx-spi.1", "spi_busclk2", &clk_sclk_spi1.clk), 1321 CLKDEV_INIT("s5pc100-spi.1", "spi_busclk2", &clk_sclk_spi1.clk),
1322 CLKDEV_INIT("s3c64xx-spi.2", "spi_busclk1", &clk_48m_spi2), 1322 CLKDEV_INIT("s5pc100-spi.2", "spi_busclk1", &clk_48m_spi2),
1323 CLKDEV_INIT("s3c64xx-spi.2", "spi_busclk2", &clk_sclk_spi2.clk), 1323 CLKDEV_INIT("s5pc100-spi.2", "spi_busclk2", &clk_sclk_spi2.clk),
1324}; 1324};
1325 1325
1326void __init s5pc100_register_clocks(void) 1326void __init s5pc100_register_clocks(void)
diff --git a/arch/arm/mach-s5pc100/dma.c b/arch/arm/mach-s5pc100/dma.c
index afd8db2d599..b1418409709 100644
--- a/arch/arm/mach-s5pc100/dma.c
+++ b/arch/arm/mach-s5pc100/dma.c
@@ -33,8 +33,6 @@
33#include <mach/irqs.h> 33#include <mach/irqs.h>
34#include <mach/dma.h> 34#include <mach/dma.h>
35 35
36static u64 dma_dmamask = DMA_BIT_MASK(32);
37
38static u8 pdma0_peri[] = { 36static u8 pdma0_peri[] = {
39 DMACH_UART0_RX, 37 DMACH_UART0_RX,
40 DMACH_UART0_TX, 38 DMACH_UART0_TX,
diff --git a/arch/arm/mach-s5pc100/include/mach/spi-clocks.h b/arch/arm/mach-s5pc100/include/mach/spi-clocks.h
deleted file mode 100644
index 65e426370bb..00000000000
--- a/arch/arm/mach-s5pc100/include/mach/spi-clocks.h
+++ /dev/null
@@ -1,18 +0,0 @@
1/* linux/arch/arm/mach-s5pc100/include/mach/spi-clocks.h
2 *
3 * Copyright (C) 2010 Samsung Electronics Co. Ltd.
4 * Jaswinder Singh <jassi.brar@samsung.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __S5PC100_PLAT_SPI_CLKS_H
12#define __S5PC100_PLAT_SPI_CLKS_H __FILE__
13
14#define S5PC100_SPI_SRCCLK_PCLK 0
15#define S5PC100_SPI_SRCCLK_48M 1
16#define S5PC100_SPI_SRCCLK_SPIBUS 2
17
18#endif /* __S5PC100_PLAT_SPI_CLKS_H */
diff --git a/arch/arm/mach-s5pc100/setup-spi.c b/arch/arm/mach-s5pc100/setup-spi.c
index 431a6f747ca..183567961de 100644
--- a/arch/arm/mach-s5pc100/setup-spi.c
+++ b/arch/arm/mach-s5pc100/setup-spi.c
@@ -9,20 +9,10 @@
9 */ 9 */
10 10
11#include <linux/gpio.h> 11#include <linux/gpio.h>
12#include <linux/platform_device.h>
13
14#include <plat/gpio-cfg.h> 12#include <plat/gpio-cfg.h>
15#include <plat/s3c64xx-spi.h>
16 13
17#ifdef CONFIG_S3C64XX_DEV_SPI0 14#ifdef CONFIG_S3C64XX_DEV_SPI0
18struct s3c64xx_spi_info s3c64xx_spi0_pdata __initdata = { 15int s3c64xx_spi0_cfg_gpio(void)
19 .fifo_lvl_mask = 0x7f,
20 .rx_lvl_offset = 13,
21 .high_speed = 1,
22 .tx_st_done = 21,
23};
24
25int s3c64xx_spi0_cfg_gpio(struct platform_device *dev)
26{ 16{
27 s3c_gpio_cfgall_range(S5PC100_GPB(0), 3, 17 s3c_gpio_cfgall_range(S5PC100_GPB(0), 3,
28 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP); 18 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
@@ -31,14 +21,7 @@ int s3c64xx_spi0_cfg_gpio(struct platform_device *dev)
31#endif 21#endif
32 22
33#ifdef CONFIG_S3C64XX_DEV_SPI1 23#ifdef CONFIG_S3C64XX_DEV_SPI1
34struct s3c64xx_spi_info s3c64xx_spi1_pdata __initdata = { 24int s3c64xx_spi1_cfg_gpio(void)
35 .fifo_lvl_mask = 0x7f,
36 .rx_lvl_offset = 13,
37 .high_speed = 1,
38 .tx_st_done = 21,
39};
40
41int s3c64xx_spi1_cfg_gpio(struct platform_device *dev)
42{ 25{
43 s3c_gpio_cfgall_range(S5PC100_GPB(4), 3, 26 s3c_gpio_cfgall_range(S5PC100_GPB(4), 3,
44 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP); 27 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
@@ -47,14 +30,7 @@ int s3c64xx_spi1_cfg_gpio(struct platform_device *dev)
47#endif 30#endif
48 31
49#ifdef CONFIG_S3C64XX_DEV_SPI2 32#ifdef CONFIG_S3C64XX_DEV_SPI2
50struct s3c64xx_spi_info s3c64xx_spi2_pdata __initdata = { 33int s3c64xx_spi2_cfg_gpio(void)
51 .fifo_lvl_mask = 0x7f,
52 .rx_lvl_offset = 13,
53 .high_speed = 1,
54 .tx_st_done = 21,
55};
56
57int s3c64xx_spi2_cfg_gpio(struct platform_device *dev)
58{ 34{
59 s3c_gpio_cfgpin(S5PC100_GPG3(0), S3C_GPIO_SFN(3)); 35 s3c_gpio_cfgpin(S5PC100_GPG3(0), S3C_GPIO_SFN(3));
60 s3c_gpio_setpull(S5PC100_GPG3(0), S3C_GPIO_PULL_UP); 36 s3c_gpio_setpull(S5PC100_GPG3(0), S3C_GPIO_PULL_UP);
diff --git a/arch/arm/mach-s5pv210/Kconfig b/arch/arm/mach-s5pv210/Kconfig
index 88e983b0c82..77185c38188 100644
--- a/arch/arm/mach-s5pv210/Kconfig
+++ b/arch/arm/mach-s5pv210/Kconfig
@@ -152,6 +152,7 @@ config MACH_SMDKV210
152 select S3C_DEV_I2C1 152 select S3C_DEV_I2C1
153 select S3C_DEV_I2C2 153 select S3C_DEV_I2C2
154 select S3C_DEV_RTC 154 select S3C_DEV_RTC
155 select S3C_DEV_USB_HSOTG
155 select S3C_DEV_WDT 156 select S3C_DEV_WDT
156 select S5P_DEV_FIMC0 157 select S5P_DEV_FIMC0
157 select S5P_DEV_FIMC1 158 select S5P_DEV_FIMC1
@@ -170,6 +171,7 @@ config MACH_SMDKV210
170 select S5PV210_SETUP_IDE 171 select S5PV210_SETUP_IDE
171 select S5PV210_SETUP_KEYPAD 172 select S5PV210_SETUP_KEYPAD
172 select S5PV210_SETUP_SDHCI 173 select S5PV210_SETUP_SDHCI
174 select S5PV210_SETUP_USB_PHY
173 help 175 help
174 Machine support for Samsung SMDKV210 176 Machine support for Samsung SMDKV210
175 177
diff --git a/arch/arm/mach-s5pv210/clock.c b/arch/arm/mach-s5pv210/clock.c
index 09609d50961..fcdf52dbcc4 100644
--- a/arch/arm/mach-s5pv210/clock.c
+++ b/arch/arm/mach-s5pv210/clock.c
@@ -445,19 +445,19 @@ static struct clk init_clocks_off[] = {
445 .ctrlbit = (1 << 11), 445 .ctrlbit = (1 << 11),
446 }, { 446 }, {
447 .name = "spi", 447 .name = "spi",
448 .devname = "s3c64xx-spi.0", 448 .devname = "s5pv210-spi.0",
449 .parent = &clk_pclk_psys.clk, 449 .parent = &clk_pclk_psys.clk,
450 .enable = s5pv210_clk_ip3_ctrl, 450 .enable = s5pv210_clk_ip3_ctrl,
451 .ctrlbit = (1<<12), 451 .ctrlbit = (1<<12),
452 }, { 452 }, {
453 .name = "spi", 453 .name = "spi",
454 .devname = "s3c64xx-spi.1", 454 .devname = "s5pv210-spi.1",
455 .parent = &clk_pclk_psys.clk, 455 .parent = &clk_pclk_psys.clk,
456 .enable = s5pv210_clk_ip3_ctrl, 456 .enable = s5pv210_clk_ip3_ctrl,
457 .ctrlbit = (1<<13), 457 .ctrlbit = (1<<13),
458 }, { 458 }, {
459 .name = "spi", 459 .name = "spi",
460 .devname = "s3c64xx-spi.2", 460 .devname = "s5pv210-spi.2",
461 .parent = &clk_pclk_psys.clk, 461 .parent = &clk_pclk_psys.clk,
462 .enable = s5pv210_clk_ip3_ctrl, 462 .enable = s5pv210_clk_ip3_ctrl,
463 .ctrlbit = (1<<14), 463 .ctrlbit = (1<<14),
@@ -1035,7 +1035,7 @@ static struct clksrc_clk clk_sclk_mmc3 = {
1035static struct clksrc_clk clk_sclk_spi0 = { 1035static struct clksrc_clk clk_sclk_spi0 = {
1036 .clk = { 1036 .clk = {
1037 .name = "sclk_spi", 1037 .name = "sclk_spi",
1038 .devname = "s3c64xx-spi.0", 1038 .devname = "s5pv210-spi.0",
1039 .enable = s5pv210_clk_mask0_ctrl, 1039 .enable = s5pv210_clk_mask0_ctrl,
1040 .ctrlbit = (1 << 16), 1040 .ctrlbit = (1 << 16),
1041 }, 1041 },
@@ -1047,7 +1047,7 @@ static struct clksrc_clk clk_sclk_spi0 = {
1047static struct clksrc_clk clk_sclk_spi1 = { 1047static struct clksrc_clk clk_sclk_spi1 = {
1048 .clk = { 1048 .clk = {
1049 .name = "sclk_spi", 1049 .name = "sclk_spi",
1050 .devname = "s3c64xx-spi.1", 1050 .devname = "s5pv210-spi.1",
1051 .enable = s5pv210_clk_mask0_ctrl, 1051 .enable = s5pv210_clk_mask0_ctrl,
1052 .ctrlbit = (1 << 17), 1052 .ctrlbit = (1 << 17),
1053 }, 1053 },
@@ -1331,8 +1331,8 @@ static struct clk_lookup s5pv210_clk_lookup[] = {
1331 CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2.clk), 1331 CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2.clk),
1332 CLKDEV_INIT("s3c-sdhci.3", "mmc_busclk.2", &clk_sclk_mmc3.clk), 1332 CLKDEV_INIT("s3c-sdhci.3", "mmc_busclk.2", &clk_sclk_mmc3.clk),
1333 CLKDEV_INIT(NULL, "spi_busclk0", &clk_p), 1333 CLKDEV_INIT(NULL, "spi_busclk0", &clk_p),
1334 CLKDEV_INIT("s3c64xx-spi.0", "spi_busclk1", &clk_sclk_spi0.clk), 1334 CLKDEV_INIT("s5pv210-spi.0", "spi_busclk1", &clk_sclk_spi0.clk),
1335 CLKDEV_INIT("s3c64xx-spi.1", "spi_busclk1", &clk_sclk_spi1.clk), 1335 CLKDEV_INIT("s5pv210-spi.1", "spi_busclk1", &clk_sclk_spi1.clk),
1336}; 1336};
1337 1337
1338void __init s5pv210_register_clocks(void) 1338void __init s5pv210_register_clocks(void)
diff --git a/arch/arm/mach-s5pv210/include/mach/spi-clocks.h b/arch/arm/mach-s5pv210/include/mach/spi-clocks.h
deleted file mode 100644
index 02acded5f73..00000000000
--- a/arch/arm/mach-s5pv210/include/mach/spi-clocks.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/* linux/arch/arm/mach-s5pv210/include/mach/spi-clocks.h
2 *
3 * Copyright (C) 2010 Samsung Electronics Co. Ltd.
4 * Jaswinder Singh <jassi.brar@samsung.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __S5PV210_PLAT_SPI_CLKS_H
12#define __S5PV210_PLAT_SPI_CLKS_H __FILE__
13
14#define S5PV210_SPI_SRCCLK_PCLK 0
15#define S5PV210_SPI_SRCCLK_SCLK 1
16
17#endif /* __S5PV210_PLAT_SPI_CLKS_H */
diff --git a/arch/arm/mach-s5pv210/mach-aquila.c b/arch/arm/mach-s5pv210/mach-aquila.c
index af528f9e97f..78028df86c5 100644
--- a/arch/arm/mach-s5pv210/mach-aquila.c
+++ b/arch/arm/mach-s5pv210/mach-aquila.c
@@ -600,10 +600,17 @@ static void aquila_setup_sdhci(void)
600 s3c_sdhci2_set_platdata(&aquila_hsmmc2_data); 600 s3c_sdhci2_set_platdata(&aquila_hsmmc2_data);
601}; 601};
602 602
603/* Audio device */
604static struct platform_device aquila_device_audio = {
605 .name = "smdk-audio",
606 .id = -1,
607};
608
603static struct platform_device *aquila_devices[] __initdata = { 609static struct platform_device *aquila_devices[] __initdata = {
604 &aquila_i2c_gpio_pmic, 610 &aquila_i2c_gpio_pmic,
605 &aquila_i2c_gpio5, 611 &aquila_i2c_gpio5,
606 &aquila_device_gpiokeys, 612 &aquila_device_gpiokeys,
613 &aquila_device_audio,
607 &s3c_device_fb, 614 &s3c_device_fb,
608 &s5p_device_onenand, 615 &s5p_device_onenand,
609 &s3c_device_hsmmc0, 616 &s3c_device_hsmmc0,
diff --git a/arch/arm/mach-s5pv210/mach-goni.c b/arch/arm/mach-s5pv210/mach-goni.c
index bf5087c2b7f..822a5595068 100644
--- a/arch/arm/mach-s5pv210/mach-goni.c
+++ b/arch/arm/mach-s5pv210/mach-goni.c
@@ -859,12 +859,19 @@ static struct s5p_platform_fimc goni_fimc_md_platdata __initdata = {
859 .num_clients = ARRAY_SIZE(goni_camera_sensors), 859 .num_clients = ARRAY_SIZE(goni_camera_sensors),
860}; 860};
861 861
862/* Audio device */
863static struct platform_device goni_device_audio = {
864 .name = "smdk-audio",
865 .id = -1,
866};
867
862static struct platform_device *goni_devices[] __initdata = { 868static struct platform_device *goni_devices[] __initdata = {
863 &s3c_device_fb, 869 &s3c_device_fb,
864 &s5p_device_onenand, 870 &s5p_device_onenand,
865 &goni_spi_gpio, 871 &goni_spi_gpio,
866 &goni_i2c_gpio_pmic, 872 &goni_i2c_gpio_pmic,
867 &goni_i2c_gpio5, 873 &goni_i2c_gpio5,
874 &goni_device_audio,
868 &mmc2_fixed_voltage, 875 &mmc2_fixed_voltage,
869 &goni_device_gpiokeys, 876 &goni_device_gpiokeys,
870 &s5p_device_mfc, 877 &s5p_device_mfc,
@@ -901,7 +908,7 @@ static void __init goni_sound_init(void)
901static void __init goni_map_io(void) 908static void __init goni_map_io(void)
902{ 909{
903 s5pv210_init_io(NULL, 0); 910 s5pv210_init_io(NULL, 0);
904 s3c24xx_init_clocks(24000000); 911 s3c24xx_init_clocks(clk_xusbxti.rate);
905 s3c24xx_init_uarts(goni_uartcfgs, ARRAY_SIZE(goni_uartcfgs)); 912 s3c24xx_init_uarts(goni_uartcfgs, ARRAY_SIZE(goni_uartcfgs));
906 s5p_set_timer_source(S5P_PWM3, S5P_PWM4); 913 s5p_set_timer_source(S5P_PWM3, S5P_PWM4);
907} 914}
@@ -959,8 +966,6 @@ static void __init goni_machine_init(void)
959 /* KEYPAD */ 966 /* KEYPAD */
960 samsung_keypad_set_platdata(&keypad_data); 967 samsung_keypad_set_platdata(&keypad_data);
961 968
962 clk_xusbxti.rate = 24000000;
963
964 platform_add_devices(goni_devices, ARRAY_SIZE(goni_devices)); 969 platform_add_devices(goni_devices, ARRAY_SIZE(goni_devices));
965} 970}
966 971
diff --git a/arch/arm/mach-s5pv210/mach-smdkv210.c b/arch/arm/mach-s5pv210/mach-smdkv210.c
index 0d7ddec88eb..918b23d71fd 100644
--- a/arch/arm/mach-s5pv210/mach-smdkv210.c
+++ b/arch/arm/mach-s5pv210/mach-smdkv210.c
@@ -19,6 +19,7 @@
19#include <linux/gpio.h> 19#include <linux/gpio.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/pwm_backlight.h> 21#include <linux/pwm_backlight.h>
22#include <linux/platform_data/s3c-hsotg.h>
22 23
23#include <asm/hardware/vic.h> 24#include <asm/hardware/vic.h>
24#include <asm/mach/arch.h> 25#include <asm/mach/arch.h>
@@ -47,6 +48,7 @@
47#include <plat/backlight.h> 48#include <plat/backlight.h>
48#include <plat/regs-fb-v4.h> 49#include <plat/regs-fb-v4.h>
49#include <plat/mfc.h> 50#include <plat/mfc.h>
51#include <plat/clock.h>
50 52
51#include "common.h" 53#include "common.h"
52 54
@@ -203,6 +205,9 @@ static struct s3c_fb_platdata smdkv210_lcd0_pdata __initdata = {
203 .setup_gpio = s5pv210_fb_gpio_setup_24bpp, 205 .setup_gpio = s5pv210_fb_gpio_setup_24bpp,
204}; 206};
205 207
208/* USB OTG */
209static struct s3c_hsotg_plat smdkv210_hsotg_pdata;
210
206static struct platform_device *smdkv210_devices[] __initdata = { 211static struct platform_device *smdkv210_devices[] __initdata = {
207 &s3c_device_adc, 212 &s3c_device_adc,
208 &s3c_device_cfcon, 213 &s3c_device_cfcon,
@@ -216,6 +221,7 @@ static struct platform_device *smdkv210_devices[] __initdata = {
216 &s3c_device_i2c2, 221 &s3c_device_i2c2,
217 &s3c_device_rtc, 222 &s3c_device_rtc,
218 &s3c_device_ts, 223 &s3c_device_ts,
224 &s3c_device_usb_hsotg,
219 &s3c_device_wdt, 225 &s3c_device_wdt,
220 &s5p_device_fimc0, 226 &s5p_device_fimc0,
221 &s5p_device_fimc1, 227 &s5p_device_fimc1,
@@ -279,7 +285,7 @@ static struct platform_pwm_backlight_data smdkv210_bl_data = {
279static void __init smdkv210_map_io(void) 285static void __init smdkv210_map_io(void)
280{ 286{
281 s5pv210_init_io(NULL, 0); 287 s5pv210_init_io(NULL, 0);
282 s3c24xx_init_clocks(24000000); 288 s3c24xx_init_clocks(clk_xusbxti.rate);
283 s3c24xx_init_uarts(smdkv210_uartcfgs, ARRAY_SIZE(smdkv210_uartcfgs)); 289 s3c24xx_init_uarts(smdkv210_uartcfgs, ARRAY_SIZE(smdkv210_uartcfgs));
284 s5p_set_timer_source(S5P_PWM2, S5P_PWM4); 290 s5p_set_timer_source(S5P_PWM2, S5P_PWM4);
285} 291}
@@ -314,6 +320,8 @@ static void __init smdkv210_machine_init(void)
314 320
315 samsung_bl_set(&smdkv210_bl_gpio_info, &smdkv210_bl_data); 321 samsung_bl_set(&smdkv210_bl_gpio_info, &smdkv210_bl_data);
316 322
323 s3c_hsotg_set_platdata(&smdkv210_hsotg_pdata);
324
317 platform_add_devices(smdkv210_devices, ARRAY_SIZE(smdkv210_devices)); 325 platform_add_devices(smdkv210_devices, ARRAY_SIZE(smdkv210_devices));
318} 326}
319 327
diff --git a/arch/arm/mach-s5pv210/setup-spi.c b/arch/arm/mach-s5pv210/setup-spi.c
index f43c5048a37..81aecc162f8 100644
--- a/arch/arm/mach-s5pv210/setup-spi.c
+++ b/arch/arm/mach-s5pv210/setup-spi.c
@@ -9,20 +9,10 @@
9 */ 9 */
10 10
11#include <linux/gpio.h> 11#include <linux/gpio.h>
12#include <linux/platform_device.h>
13
14#include <plat/gpio-cfg.h> 12#include <plat/gpio-cfg.h>
15#include <plat/s3c64xx-spi.h>
16 13
17#ifdef CONFIG_S3C64XX_DEV_SPI0 14#ifdef CONFIG_S3C64XX_DEV_SPI0
18struct s3c64xx_spi_info s3c64xx_spi0_pdata = { 15int s3c64xx_spi0_cfg_gpio(void)
19 .fifo_lvl_mask = 0x1ff,
20 .rx_lvl_offset = 15,
21 .high_speed = 1,
22 .tx_st_done = 25,
23};
24
25int s3c64xx_spi0_cfg_gpio(struct platform_device *dev)
26{ 16{
27 s3c_gpio_cfgpin(S5PV210_GPB(0), S3C_GPIO_SFN(2)); 17 s3c_gpio_cfgpin(S5PV210_GPB(0), S3C_GPIO_SFN(2));
28 s3c_gpio_setpull(S5PV210_GPB(0), S3C_GPIO_PULL_UP); 18 s3c_gpio_setpull(S5PV210_GPB(0), S3C_GPIO_PULL_UP);
@@ -33,14 +23,7 @@ int s3c64xx_spi0_cfg_gpio(struct platform_device *dev)
33#endif 23#endif
34 24
35#ifdef CONFIG_S3C64XX_DEV_SPI1 25#ifdef CONFIG_S3C64XX_DEV_SPI1
36struct s3c64xx_spi_info s3c64xx_spi1_pdata = { 26int s3c64xx_spi1_cfg_gpio(void)
37 .fifo_lvl_mask = 0x7f,
38 .rx_lvl_offset = 15,
39 .high_speed = 1,
40 .tx_st_done = 25,
41};
42
43int s3c64xx_spi1_cfg_gpio(struct platform_device *dev)
44{ 27{
45 s3c_gpio_cfgpin(S5PV210_GPB(4), S3C_GPIO_SFN(2)); 28 s3c_gpio_cfgpin(S5PV210_GPB(4), S3C_GPIO_SFN(2));
46 s3c_gpio_setpull(S5PV210_GPB(4), S3C_GPIO_PULL_UP); 29 s3c_gpio_setpull(S5PV210_GPB(4), S3C_GPIO_PULL_UP);
diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c
index d1dc7f1a239..d673211f121 100644
--- a/arch/arm/mach-sa1100/assabet.c
+++ b/arch/arm/mach-sa1100/assabet.c
@@ -362,7 +362,7 @@ static void __init assabet_init(void)
362static void __init map_sa1100_gpio_regs( void ) 362static void __init map_sa1100_gpio_regs( void )
363{ 363{
364 unsigned long phys = __PREG(GPLR) & PMD_MASK; 364 unsigned long phys = __PREG(GPLR) & PMD_MASK;
365 unsigned long virt = io_p2v(phys); 365 unsigned long virt = (unsigned long)io_p2v(phys);
366 int prot = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_DOMAIN(DOMAIN_IO); 366 int prot = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_DOMAIN(DOMAIN_IO);
367 pmd_t *pmd; 367 pmd_t *pmd;
368 368
diff --git a/arch/arm/mach-sa1100/cpu-sa1100.c b/arch/arm/mach-sa1100/cpu-sa1100.c
index 19b2053f5af..e8f4d1e1923 100644
--- a/arch/arm/mach-sa1100/cpu-sa1100.c
+++ b/arch/arm/mach-sa1100/cpu-sa1100.c
@@ -87,6 +87,7 @@
87#include <linux/types.h> 87#include <linux/types.h>
88#include <linux/init.h> 88#include <linux/init.h>
89#include <linux/cpufreq.h> 89#include <linux/cpufreq.h>
90#include <linux/io.h>
90 91
91#include <asm/cputype.h> 92#include <asm/cputype.h>
92 93
diff --git a/arch/arm/mach-sa1100/cpu-sa1110.c b/arch/arm/mach-sa1100/cpu-sa1110.c
index 675bf8ef97e..48c45b0c92b 100644
--- a/arch/arm/mach-sa1100/cpu-sa1110.c
+++ b/arch/arm/mach-sa1100/cpu-sa1110.c
@@ -19,6 +19,7 @@
19#include <linux/cpufreq.h> 19#include <linux/cpufreq.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/io.h>
22#include <linux/kernel.h> 23#include <linux/kernel.h>
23#include <linux/moduleparam.h> 24#include <linux/moduleparam.h>
24#include <linux/types.h> 25#include <linux/types.h>
diff --git a/arch/arm/mach-sa1100/include/mach/SA-1100.h b/arch/arm/mach-sa1100/include/mach/SA-1100.h
index 3f2d1b60188..0ac6cc08a19 100644
--- a/arch/arm/mach-sa1100/include/mach/SA-1100.h
+++ b/arch/arm/mach-sa1100/include/mach/SA-1100.h
@@ -830,14 +830,14 @@
830 * (read/write). 830 * (read/write).
831 */ 831 */
832 832
833#define OSMR0 __REG(0x90000000) /* OS timer Match Reg. 0 */ 833#define OSMR0 io_p2v(0x90000000) /* OS timer Match Reg. 0 */
834#define OSMR1 __REG(0x90000004) /* OS timer Match Reg. 1 */ 834#define OSMR1 io_p2v(0x90000004) /* OS timer Match Reg. 1 */
835#define OSMR2 __REG(0x90000008) /* OS timer Match Reg. 2 */ 835#define OSMR2 io_p2v(0x90000008) /* OS timer Match Reg. 2 */
836#define OSMR3 __REG(0x9000000c) /* OS timer Match Reg. 3 */ 836#define OSMR3 io_p2v(0x9000000c) /* OS timer Match Reg. 3 */
837#define OSCR __REG(0x90000010) /* OS timer Counter Reg. */ 837#define OSCR io_p2v(0x90000010) /* OS timer Counter Reg. */
838#define OSSR __REG(0x90000014 ) /* OS timer Status Reg. */ 838#define OSSR io_p2v(0x90000014) /* OS timer Status Reg. */
839#define OWER __REG(0x90000018 ) /* OS timer Watch-dog Enable Reg. */ 839#define OWER io_p2v(0x90000018) /* OS timer Watch-dog Enable Reg. */
840#define OIER __REG(0x9000001C ) /* OS timer Interrupt Enable Reg. */ 840#define OIER io_p2v(0x9000001C) /* OS timer Interrupt Enable Reg. */
841 841
842#define OSSR_M(Nb) /* Match detected [0..3] */ \ 842#define OSSR_M(Nb) /* Match detected [0..3] */ \
843 (0x00000001 << (Nb)) 843 (0x00000001 << (Nb))
diff --git a/arch/arm/mach-sa1100/include/mach/gpio.h b/arch/arm/mach-sa1100/include/mach/gpio.h
index a38fc4f5424..6a9eecf3137 100644
--- a/arch/arm/mach-sa1100/include/mach/gpio.h
+++ b/arch/arm/mach-sa1100/include/mach/gpio.h
@@ -24,6 +24,7 @@
24#ifndef __ASM_ARCH_SA1100_GPIO_H 24#ifndef __ASM_ARCH_SA1100_GPIO_H
25#define __ASM_ARCH_SA1100_GPIO_H 25#define __ASM_ARCH_SA1100_GPIO_H
26 26
27#include <linux/io.h>
27#include <mach/hardware.h> 28#include <mach/hardware.h>
28#include <asm/irq.h> 29#include <asm/irq.h>
29#include <asm-generic/gpio.h> 30#include <asm-generic/gpio.h>
diff --git a/arch/arm/mach-sa1100/include/mach/hardware.h b/arch/arm/mach-sa1100/include/mach/hardware.h
index 99f5856d8de..cbedd75a9d6 100644
--- a/arch/arm/mach-sa1100/include/mach/hardware.h
+++ b/arch/arm/mach-sa1100/include/mach/hardware.h
@@ -32,7 +32,7 @@
32#define PIO_START 0x80000000 /* physical start of IO space */ 32#define PIO_START 0x80000000 /* physical start of IO space */
33 33
34#define io_p2v( x ) \ 34#define io_p2v( x ) \
35 ( (((x)&0x00ffffff) | (((x)&0x30000000)>>VIO_SHIFT)) + VIO_BASE ) 35 IOMEM( (((x)&0x00ffffff) | (((x)&0x30000000)>>VIO_SHIFT)) + VIO_BASE )
36#define io_v2p( x ) \ 36#define io_v2p( x ) \
37 ( (((x)&0x00ffffff) | (((x)&(0x30000000>>VIO_SHIFT))<<VIO_SHIFT)) + PIO_START ) 37 ( (((x)&0x00ffffff) | (((x)&(0x30000000>>VIO_SHIFT))<<VIO_SHIFT)) + PIO_START )
38 38
@@ -47,6 +47,8 @@
47#define CPU_SA1110_ID (0x6901b110) 47#define CPU_SA1110_ID (0x6901b110)
48#define CPU_SA1110_MASK (0xfffffff0) 48#define CPU_SA1110_MASK (0xfffffff0)
49 49
50#define __MREG(x) IOMEM(io_p2v(x))
51
50#ifndef __ASSEMBLY__ 52#ifndef __ASSEMBLY__
51 53
52#include <asm/cputype.h> 54#include <asm/cputype.h>
@@ -56,7 +58,7 @@
56#define cpu_is_sa1100() ((read_cpuid_id() & CPU_SA1100_MASK) == CPU_SA1100_ID) 58#define cpu_is_sa1100() ((read_cpuid_id() & CPU_SA1100_MASK) == CPU_SA1100_ID)
57#define cpu_is_sa1110() ((read_cpuid_id() & CPU_SA1110_MASK) == CPU_SA1110_ID) 59#define cpu_is_sa1110() ((read_cpuid_id() & CPU_SA1110_MASK) == CPU_SA1110_ID)
58 60
59# define __REG(x) (*((volatile unsigned long *)io_p2v(x))) 61# define __REG(x) (*((volatile unsigned long __iomem *)io_p2v(x)))
60# define __PREG(x) (io_v2p((unsigned long)&(x))) 62# define __PREG(x) (io_v2p((unsigned long)&(x)))
61 63
62static inline unsigned long get_clock_tick_rate(void) 64static inline unsigned long get_clock_tick_rate(void)
diff --git a/arch/arm/mach-sa1100/include/mach/uncompress.h b/arch/arm/mach-sa1100/include/mach/uncompress.h
index 6cb39ddde65..5cf71da60e4 100644
--- a/arch/arm/mach-sa1100/include/mach/uncompress.h
+++ b/arch/arm/mach-sa1100/include/mach/uncompress.h
@@ -8,6 +8,8 @@
8 8
9#include "hardware.h" 9#include "hardware.h"
10 10
11#define IOMEM(x) (x)
12
11/* 13/*
12 * The following code assumes the serial port has already been 14 * The following code assumes the serial port has already been
13 * initialized by the bootloader. We search for the first enabled 15 * initialized by the bootloader. We search for the first enabled
diff --git a/arch/arm/mach-sa1100/irq.c b/arch/arm/mach-sa1100/irq.c
index 516ccc25d7f..2124f1fc2fb 100644
--- a/arch/arm/mach-sa1100/irq.c
+++ b/arch/arm/mach-sa1100/irq.c
@@ -12,6 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/io.h>
15#include <linux/irq.h> 16#include <linux/irq.h>
16#include <linux/ioport.h> 17#include <linux/ioport.h>
17#include <linux/syscore_ops.h> 18#include <linux/syscore_ops.h>
diff --git a/arch/arm/mach-sa1100/jornada720_ssp.c b/arch/arm/mach-sa1100/jornada720_ssp.c
index b412fc09c80..7f07f08d896 100644
--- a/arch/arm/mach-sa1100/jornada720_ssp.c
+++ b/arch/arm/mach-sa1100/jornada720_ssp.c
@@ -18,6 +18,7 @@
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/sched.h> 20#include <linux/sched.h>
21#include <linux/io.h>
21 22
22#include <mach/hardware.h> 23#include <mach/hardware.h>
23#include <mach/jornada720.h> 24#include <mach/jornada720.h>
diff --git a/arch/arm/mach-sa1100/leds-cerf.c b/arch/arm/mach-sa1100/leds-cerf.c
index 040540fb7d8..30fc3b2bf55 100644
--- a/arch/arm/mach-sa1100/leds-cerf.c
+++ b/arch/arm/mach-sa1100/leds-cerf.c
@@ -4,6 +4,7 @@
4 * Author: ??? 4 * Author: ???
5 */ 5 */
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/io.h>
7 8
8#include <mach/hardware.h> 9#include <mach/hardware.h>
9#include <asm/leds.h> 10#include <asm/leds.h>
diff --git a/arch/arm/mach-sa1100/leds-hackkit.c b/arch/arm/mach-sa1100/leds-hackkit.c
index 6a2352436e6..f8e47235bab 100644
--- a/arch/arm/mach-sa1100/leds-hackkit.c
+++ b/arch/arm/mach-sa1100/leds-hackkit.c
@@ -10,6 +10,7 @@
10 * as cpu led, the green one is used as timer led. 10 * as cpu led, the green one is used as timer led.
11 */ 11 */
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/io.h>
13 14
14#include <mach/hardware.h> 15#include <mach/hardware.h>
15#include <asm/leds.h> 16#include <asm/leds.h>
diff --git a/arch/arm/mach-sa1100/leds-lart.c b/arch/arm/mach-sa1100/leds-lart.c
index a51830c60e5..50a5b143b46 100644
--- a/arch/arm/mach-sa1100/leds-lart.c
+++ b/arch/arm/mach-sa1100/leds-lart.c
@@ -10,6 +10,7 @@
10 * pace of the LED. 10 * pace of the LED.
11 */ 11 */
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/io.h>
13 14
14#include <mach/hardware.h> 15#include <mach/hardware.h>
15#include <asm/leds.h> 16#include <asm/leds.h>
diff --git a/arch/arm/mach-sa1100/pm.c b/arch/arm/mach-sa1100/pm.c
index 690cf0ce5c0..6645d1e31f1 100644
--- a/arch/arm/mach-sa1100/pm.c
+++ b/arch/arm/mach-sa1100/pm.c
@@ -23,6 +23,7 @@
23 * Storage is local on the stack now. 23 * Storage is local on the stack now.
24 */ 24 */
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/io.h>
26#include <linux/suspend.h> 27#include <linux/suspend.h>
27#include <linux/errno.h> 28#include <linux/errno.h>
28#include <linux/time.h> 29#include <linux/time.h>
diff --git a/arch/arm/mach-sa1100/sleep.S b/arch/arm/mach-sa1100/sleep.S
index 30cc6721665..85863741ef8 100644
--- a/arch/arm/mach-sa1100/sleep.S
+++ b/arch/arm/mach-sa1100/sleep.S
@@ -38,9 +38,9 @@ ENTRY(sa1100_finish_suspend)
38 orr r4, r4, #MDREFR_K1DB2 38 orr r4, r4, #MDREFR_K1DB2
39 ldr r5, =PPCR 39 ldr r5, =PPCR
40 40
41 @ Pre-load __udelay into the I-cache 41 @ Pre-load __loop_udelay into the I-cache
42 mov r0, #1 42 mov r0, #1
43 bl __udelay 43 bl __loop_udelay
44 mov r0, r0 44 mov r0, r0
45 45
46 @ The following must all exist in a single cache line to 46 @ The following must all exist in a single cache line to
@@ -53,11 +53,11 @@ ENTRY(sa1100_finish_suspend)
53 @ delay 90us and set CPU PLL to lowest speed 53 @ delay 90us and set CPU PLL to lowest speed
54 @ fixes resume problem on high speed SA1110 54 @ fixes resume problem on high speed SA1110
55 mov r0, #90 55 mov r0, #90
56 bl __udelay 56 bl __loop_udelay
57 mov r1, #0 57 mov r1, #0
58 str r1, [r5] 58 str r1, [r5]
59 mov r0, #90 59 mov r0, #90
60 bl __udelay 60 bl __loop_udelay
61 61
62 /* 62 /*
63 * SA1110 SDRAM controller workaround. register values: 63 * SA1110 SDRAM controller workaround. register values:
diff --git a/arch/arm/mach-sa1100/time.c b/arch/arm/mach-sa1100/time.c
index 6af26e8d55e..80702c9ecc7 100644
--- a/arch/arm/mach-sa1100/time.c
+++ b/arch/arm/mach-sa1100/time.c
@@ -22,7 +22,7 @@
22 22
23static u32 notrace sa1100_read_sched_clock(void) 23static u32 notrace sa1100_read_sched_clock(void)
24{ 24{
25 return OSCR; 25 return readl_relaxed(OSCR);
26} 26}
27 27
28#define MIN_OSCR_DELTA 2 28#define MIN_OSCR_DELTA 2
@@ -32,8 +32,8 @@ static irqreturn_t sa1100_ost0_interrupt(int irq, void *dev_id)
32 struct clock_event_device *c = dev_id; 32 struct clock_event_device *c = dev_id;
33 33
34 /* Disarm the compare/match, signal the event. */ 34 /* Disarm the compare/match, signal the event. */
35 OIER &= ~OIER_E0; 35 writel_relaxed(readl_relaxed(OIER) & ~OIER_E0, OIER);
36 OSSR = OSSR_M0; 36 writel_relaxed(OSSR_M0, OSSR);
37 c->event_handler(c); 37 c->event_handler(c);
38 38
39 return IRQ_HANDLED; 39 return IRQ_HANDLED;
@@ -44,10 +44,10 @@ sa1100_osmr0_set_next_event(unsigned long delta, struct clock_event_device *c)
44{ 44{
45 unsigned long next, oscr; 45 unsigned long next, oscr;
46 46
47 OIER |= OIER_E0; 47 writel_relaxed(readl_relaxed(OIER) | OIER_E0, OIER);
48 next = OSCR + delta; 48 next = readl_relaxed(OSCR) + delta;
49 OSMR0 = next; 49 writel_relaxed(next, OSMR0);
50 oscr = OSCR; 50 oscr = readl_relaxed(OSCR);
51 51
52 return (signed)(next - oscr) <= MIN_OSCR_DELTA ? -ETIME : 0; 52 return (signed)(next - oscr) <= MIN_OSCR_DELTA ? -ETIME : 0;
53} 53}
@@ -59,8 +59,8 @@ sa1100_osmr0_set_mode(enum clock_event_mode mode, struct clock_event_device *c)
59 case CLOCK_EVT_MODE_ONESHOT: 59 case CLOCK_EVT_MODE_ONESHOT:
60 case CLOCK_EVT_MODE_UNUSED: 60 case CLOCK_EVT_MODE_UNUSED:
61 case CLOCK_EVT_MODE_SHUTDOWN: 61 case CLOCK_EVT_MODE_SHUTDOWN:
62 OIER &= ~OIER_E0; 62 writel_relaxed(readl_relaxed(OIER) & ~OIER_E0, OIER);
63 OSSR = OSSR_M0; 63 writel_relaxed(OSSR_M0, OSSR);
64 break; 64 break;
65 65
66 case CLOCK_EVT_MODE_RESUME: 66 case CLOCK_EVT_MODE_RESUME:
@@ -86,8 +86,8 @@ static struct irqaction sa1100_timer_irq = {
86 86
87static void __init sa1100_timer_init(void) 87static void __init sa1100_timer_init(void)
88{ 88{
89 OIER = 0; 89 writel_relaxed(0, OIER);
90 OSSR = OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3; 90 writel_relaxed(OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3, OSSR);
91 91
92 setup_sched_clock(sa1100_read_sched_clock, 32, 3686400); 92 setup_sched_clock(sa1100_read_sched_clock, 32, 3686400);
93 93
@@ -100,7 +100,7 @@ static void __init sa1100_timer_init(void)
100 100
101 setup_irq(IRQ_OST0, &sa1100_timer_irq); 101 setup_irq(IRQ_OST0, &sa1100_timer_irq);
102 102
103 clocksource_mmio_init(&OSCR, "oscr", CLOCK_TICK_RATE, 200, 32, 103 clocksource_mmio_init(OSCR, "oscr", CLOCK_TICK_RATE, 200, 32,
104 clocksource_mmio_readl_up); 104 clocksource_mmio_readl_up);
105 clockevents_register_device(&ckevt_sa1100_osmr0); 105 clockevents_register_device(&ckevt_sa1100_osmr0);
106} 106}
@@ -110,26 +110,26 @@ unsigned long osmr[4], oier;
110 110
111static void sa1100_timer_suspend(void) 111static void sa1100_timer_suspend(void)
112{ 112{
113 osmr[0] = OSMR0; 113 osmr[0] = readl_relaxed(OSMR0);
114 osmr[1] = OSMR1; 114 osmr[1] = readl_relaxed(OSMR1);
115 osmr[2] = OSMR2; 115 osmr[2] = readl_relaxed(OSMR2);
116 osmr[3] = OSMR3; 116 osmr[3] = readl_relaxed(OSMR3);
117 oier = OIER; 117 oier = readl_relaxed(OIER);
118} 118}
119 119
120static void sa1100_timer_resume(void) 120static void sa1100_timer_resume(void)
121{ 121{
122 OSSR = 0x0f; 122 writel_relaxed(0x0f, OSSR);
123 OSMR0 = osmr[0]; 123 writel_relaxed(osmr[0], OSMR0);
124 OSMR1 = osmr[1]; 124 writel_relaxed(osmr[1], OSMR1);
125 OSMR2 = osmr[2]; 125 writel_relaxed(osmr[2], OSMR2);
126 OSMR3 = osmr[3]; 126 writel_relaxed(osmr[3], OSMR3);
127 OIER = oier; 127 writel_relaxed(oier, OIER);
128 128
129 /* 129 /*
130 * OSMR0 is the system timer: make sure OSCR is sufficiently behind 130 * OSMR0 is the system timer: make sure OSCR is sufficiently behind
131 */ 131 */
132 OSCR = OSMR0 - LATCH; 132 writel_relaxed(OSMR0 - LATCH, OSCR);
133} 133}
134#else 134#else
135#define sa1100_timer_suspend NULL 135#define sa1100_timer_suspend NULL
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index df33909205e..4cacc2d22fb 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -19,6 +19,7 @@ config ARCH_SH7372
19 select CPU_V7 19 select CPU_V7
20 select SH_CLK_CPG 20 select SH_CLK_CPG
21 select ARCH_WANT_OPTIONAL_GPIOLIB 21 select ARCH_WANT_OPTIONAL_GPIOLIB
22 select ARM_CPU_SUSPEND if PM || CPU_IDLE
22 23
23config ARCH_SH73A0 24config ARCH_SH73A0
24 bool "SH-Mobile AG5 (R8A73A00)" 25 bool "SH-Mobile AG5 (R8A73A00)"
@@ -58,6 +59,7 @@ config MACH_G4EVM
58 bool "G4EVM board" 59 bool "G4EVM board"
59 depends on ARCH_SH7377 60 depends on ARCH_SH7377
60 select ARCH_REQUIRE_GPIOLIB 61 select ARCH_REQUIRE_GPIOLIB
62 select REGULATOR_FIXED_VOLTAGE if REGULATOR
61 63
62config MACH_AP4EVB 64config MACH_AP4EVB
63 bool "AP4EVB board" 65 bool "AP4EVB board"
@@ -65,6 +67,7 @@ config MACH_AP4EVB
65 select ARCH_REQUIRE_GPIOLIB 67 select ARCH_REQUIRE_GPIOLIB
66 select SH_LCD_MIPI_DSI 68 select SH_LCD_MIPI_DSI
67 select SND_SOC_AK4642 if SND_SIMPLE_CARD 69 select SND_SOC_AK4642 if SND_SIMPLE_CARD
70 select REGULATOR_FIXED_VOLTAGE if REGULATOR
68 71
69choice 72choice
70 prompt "AP4EVB LCD panel selection" 73 prompt "AP4EVB LCD panel selection"
@@ -83,6 +86,7 @@ config MACH_AG5EVM
83 bool "AG5EVM board" 86 bool "AG5EVM board"
84 select ARCH_REQUIRE_GPIOLIB 87 select ARCH_REQUIRE_GPIOLIB
85 select SH_LCD_MIPI_DSI 88 select SH_LCD_MIPI_DSI
89 select REGULATOR_FIXED_VOLTAGE if REGULATOR
86 depends on ARCH_SH73A0 90 depends on ARCH_SH73A0
87 91
88config MACH_MACKEREL 92config MACH_MACKEREL
@@ -90,15 +94,18 @@ config MACH_MACKEREL
90 depends on ARCH_SH7372 94 depends on ARCH_SH7372
91 select ARCH_REQUIRE_GPIOLIB 95 select ARCH_REQUIRE_GPIOLIB
92 select SND_SOC_AK4642 if SND_SIMPLE_CARD 96 select SND_SOC_AK4642 if SND_SIMPLE_CARD
97 select REGULATOR_FIXED_VOLTAGE if REGULATOR
93 98
94config MACH_KOTA2 99config MACH_KOTA2
95 bool "KOTA2 board" 100 bool "KOTA2 board"
96 select ARCH_REQUIRE_GPIOLIB 101 select ARCH_REQUIRE_GPIOLIB
102 select REGULATOR_FIXED_VOLTAGE if REGULATOR
97 depends on ARCH_SH73A0 103 depends on ARCH_SH73A0
98 104
99config MACH_BONITO 105config MACH_BONITO
100 bool "bonito board" 106 bool "bonito board"
101 select ARCH_REQUIRE_GPIOLIB 107 select ARCH_REQUIRE_GPIOLIB
108 select REGULATOR_FIXED_VOLTAGE if REGULATOR
102 depends on ARCH_R8A7740 109 depends on ARCH_R8A7740
103 110
104config MACH_ARMADILLO800EVA 111config MACH_ARMADILLO800EVA
@@ -106,22 +113,28 @@ config MACH_ARMADILLO800EVA
106 depends on ARCH_R8A7740 113 depends on ARCH_R8A7740
107 select ARCH_REQUIRE_GPIOLIB 114 select ARCH_REQUIRE_GPIOLIB
108 select USE_OF 115 select USE_OF
116 select REGULATOR_FIXED_VOLTAGE if REGULATOR
117 select SND_SOC_WM8978 if SND_SIMPLE_CARD
109 118
110config MACH_MARZEN 119config MACH_MARZEN
111 bool "MARZEN board" 120 bool "MARZEN board"
112 depends on ARCH_R8A7779 121 depends on ARCH_R8A7779
113 select ARCH_REQUIRE_GPIOLIB 122 select ARCH_REQUIRE_GPIOLIB
123 select REGULATOR_FIXED_VOLTAGE if REGULATOR
114 124
115config MACH_KZM9D 125config MACH_KZM9D
116 bool "KZM9D board" 126 bool "KZM9D board"
117 depends on ARCH_EMEV2 127 depends on ARCH_EMEV2
118 select USE_OF 128 select USE_OF
129 select REGULATOR_FIXED_VOLTAGE if REGULATOR
119 130
120config MACH_KZM9G 131config MACH_KZM9G
121 bool "KZM-A9-GT board" 132 bool "KZM-A9-GT board"
122 depends on ARCH_SH73A0 133 depends on ARCH_SH73A0
123 select ARCH_REQUIRE_GPIOLIB 134 select ARCH_REQUIRE_GPIOLIB
124 select USE_OF 135 select USE_OF
136 select SND_SOC_AK4642 if SND_SIMPLE_CARD
137 select REGULATOR_FIXED_VOLTAGE if REGULATOR
125 138
126comment "SH-Mobile System Configuration" 139comment "SH-Mobile System Configuration"
127 140
diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile
index 8aa1962c22a..0df5ae6740c 100644
--- a/arch/arm/mach-shmobile/Makefile
+++ b/arch/arm/mach-shmobile/Makefile
@@ -39,7 +39,9 @@ obj-$(CONFIG_ARCH_R8A7740) += entry-intc.o
39# PM objects 39# PM objects
40obj-$(CONFIG_SUSPEND) += suspend.o 40obj-$(CONFIG_SUSPEND) += suspend.o
41obj-$(CONFIG_CPU_IDLE) += cpuidle.o 41obj-$(CONFIG_CPU_IDLE) += cpuidle.o
42obj-$(CONFIG_ARCH_SHMOBILE) += pm-rmobile.o
42obj-$(CONFIG_ARCH_SH7372) += pm-sh7372.o sleep-sh7372.o 43obj-$(CONFIG_ARCH_SH7372) += pm-sh7372.o sleep-sh7372.o
44obj-$(CONFIG_ARCH_R8A7740) += pm-r8a7740.o
43obj-$(CONFIG_ARCH_R8A7779) += pm-r8a7779.o 45obj-$(CONFIG_ARCH_R8A7779) += pm-r8a7779.o
44 46
45# Board objects 47# Board objects
diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index 5a6f22f05e9..d82c010fdfc 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -27,6 +27,8 @@
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/dma-mapping.h> 29#include <linux/dma-mapping.h>
30#include <linux/regulator/fixed.h>
31#include <linux/regulator/machine.h>
30#include <linux/serial_sci.h> 32#include <linux/serial_sci.h>
31#include <linux/smsc911x.h> 33#include <linux/smsc911x.h>
32#include <linux/gpio.h> 34#include <linux/gpio.h>
@@ -52,6 +54,12 @@
52#include <asm/hardware/cache-l2x0.h> 54#include <asm/hardware/cache-l2x0.h>
53#include <asm/traps.h> 55#include <asm/traps.h>
54 56
57/* Dummy supplies, where voltage doesn't matter */
58static struct regulator_consumer_supply dummy_supplies[] = {
59 REGULATOR_SUPPLY("vddvario", "smsc911x"),
60 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
61};
62
55static struct resource smsc9220_resources[] = { 63static struct resource smsc9220_resources[] = {
56 [0] = { 64 [0] = {
57 .start = 0x14000000, 65 .start = 0x14000000,
@@ -142,6 +150,13 @@ static struct platform_device fsi_device = {
142 .resource = fsi_resources, 150 .resource = fsi_resources,
143}; 151};
144 152
153/* Fixed 1.8V regulator to be used by MMCIF */
154static struct regulator_consumer_supply fixed1v8_power_consumers[] =
155{
156 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
157 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
158};
159
145static struct resource sh_mmcif_resources[] = { 160static struct resource sh_mmcif_resources[] = {
146 [0] = { 161 [0] = {
147 .name = "MMCIF", 162 .name = "MMCIF",
@@ -364,6 +379,13 @@ static struct platform_device mipidsi0_device = {
364 }, 379 },
365}; 380};
366 381
382/* Fixed 2.8V regulators to be used by SDHI0 */
383static struct regulator_consumer_supply fixed2v8_power_consumers[] =
384{
385 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
386 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
387};
388
367/* SDHI0 */ 389/* SDHI0 */
368static struct sh_mobile_sdhi_info sdhi0_info = { 390static struct sh_mobile_sdhi_info sdhi0_info = {
369 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, 391 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
@@ -408,8 +430,57 @@ static struct platform_device sdhi0_device = {
408 }, 430 },
409}; 431};
410 432
411void ag5evm_sdhi1_set_pwr(struct platform_device *pdev, int state) 433/* Fixed 3.3V regulator to be used by SDHI1 */
434static struct regulator_consumer_supply cn4_power_consumers[] =
412{ 435{
436 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
437 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
438};
439
440static struct regulator_init_data cn4_power_init_data = {
441 .constraints = {
442 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
443 },
444 .num_consumer_supplies = ARRAY_SIZE(cn4_power_consumers),
445 .consumer_supplies = cn4_power_consumers,
446};
447
448static struct fixed_voltage_config cn4_power_info = {
449 .supply_name = "CN4 SD/MMC Vdd",
450 .microvolts = 3300000,
451 .gpio = GPIO_PORT114,
452 .enable_high = 1,
453 .init_data = &cn4_power_init_data,
454};
455
456static struct platform_device cn4_power = {
457 .name = "reg-fixed-voltage",
458 .id = 2,
459 .dev = {
460 .platform_data = &cn4_power_info,
461 },
462};
463
464static void ag5evm_sdhi1_set_pwr(struct platform_device *pdev, int state)
465{
466 static int power_gpio = -EINVAL;
467
468 if (power_gpio < 0) {
469 int ret = gpio_request(GPIO_PORT114, "sdhi1_power");
470 if (!ret) {
471 power_gpio = GPIO_PORT114;
472 gpio_direction_output(power_gpio, 0);
473 }
474 }
475
476 /*
477 * If requesting the GPIO above failed, it means, that the regulator got
478 * probed and grabbed the GPIO, but we don't know, whether the sdhi
479 * driver already uses the regulator. If it doesn't, we have to toggle
480 * the GPIO ourselves, even though it is now owned by the fixed
481 * regulator driver. We have to live with the race in case the driver
482 * gets unloaded and the GPIO freed between these two steps.
483 */
413 gpio_set_value(GPIO_PORT114, state); 484 gpio_set_value(GPIO_PORT114, state);
414} 485}
415 486
@@ -455,6 +526,7 @@ static struct platform_device sdhi1_device = {
455}; 526};
456 527
457static struct platform_device *ag5evm_devices[] __initdata = { 528static struct platform_device *ag5evm_devices[] __initdata = {
529 &cn4_power,
458 &eth_device, 530 &eth_device,
459 &keysc_device, 531 &keysc_device,
460 &fsi_device, 532 &fsi_device,
@@ -468,6 +540,12 @@ static struct platform_device *ag5evm_devices[] __initdata = {
468 540
469static void __init ag5evm_init(void) 541static void __init ag5evm_init(void)
470{ 542{
543 regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
544 ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
545 regulator_register_always_on(1, "fixed-2.8V", fixed2v8_power_consumers,
546 ARRAY_SIZE(fixed2v8_power_consumers), 3300000);
547 regulator_register_fixed(3, dummy_supplies, ARRAY_SIZE(dummy_supplies));
548
471 sh73a0_pinmux_init(); 549 sh73a0_pinmux_init();
472 550
473 /* enable SCIFA2 */ 551 /* enable SCIFA2 */
@@ -562,8 +640,6 @@ static void __init ag5evm_init(void)
562 gpio_request(GPIO_FN_SDHID1_2_PU, NULL); 640 gpio_request(GPIO_FN_SDHID1_2_PU, NULL);
563 gpio_request(GPIO_FN_SDHID1_1_PU, NULL); 641 gpio_request(GPIO_FN_SDHID1_1_PU, NULL);
564 gpio_request(GPIO_FN_SDHID1_0_PU, NULL); 642 gpio_request(GPIO_FN_SDHID1_0_PU, NULL);
565 gpio_request(GPIO_PORT114, "sdhi1_power");
566 gpio_direction_output(GPIO_PORT114, 0);
567 643
568#ifdef CONFIG_CACHE_L2X0 644#ifdef CONFIG_CACHE_L2X0
569 /* Shared attribute override enable, 64K*8way */ 645 /* Shared attribute override enable, 64K*8way */
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index ace60246a5d..f172ca85905 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -34,6 +34,8 @@
34#include <linux/i2c.h> 34#include <linux/i2c.h>
35#include <linux/i2c/tsc2007.h> 35#include <linux/i2c/tsc2007.h>
36#include <linux/io.h> 36#include <linux/io.h>
37#include <linux/regulator/fixed.h>
38#include <linux/regulator/machine.h>
37#include <linux/smsc911x.h> 39#include <linux/smsc911x.h>
38#include <linux/sh_intc.h> 40#include <linux/sh_intc.h>
39#include <linux/sh_clk.h> 41#include <linux/sh_clk.h>
@@ -159,6 +161,27 @@
159 * CN12: 3.3v 161 * CN12: 3.3v
160 */ 162 */
161 163
164/* Dummy supplies, where voltage doesn't matter */
165static struct regulator_consumer_supply fixed1v8_power_consumers[] =
166{
167 /* J22 default position: 1.8V */
168 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
169 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
170 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
171 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
172};
173
174static struct regulator_consumer_supply fixed3v3_power_consumers[] =
175{
176 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
177 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
178};
179
180static struct regulator_consumer_supply dummy_supplies[] = {
181 REGULATOR_SUPPLY("vddvario", "smsc911x"),
182 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
183};
184
162/* MTD */ 185/* MTD */
163static struct mtd_partition nor_flash_partitions[] = { 186static struct mtd_partition nor_flash_partitions[] = {
164 { 187 {
@@ -1138,21 +1161,6 @@ static void __init fsi_init_pm_clock(void)
1138 clk_put(fsia_ick); 1161 clk_put(fsia_ick);
1139} 1162}
1140 1163
1141/*
1142 * FIXME !!
1143 *
1144 * gpio_no_direction
1145 * are quick_hack.
1146 *
1147 * current gpio frame work doesn't have
1148 * the method to control only pull up/down/free.
1149 * this function should be replaced by correct gpio function
1150 */
1151static void __init gpio_no_direction(u32 addr)
1152{
1153 __raw_writeb(0x00, addr);
1154}
1155
1156/* TouchScreen */ 1164/* TouchScreen */
1157#ifdef CONFIG_AP4EVB_QHD 1165#ifdef CONFIG_AP4EVB_QHD
1158# define GPIO_TSC_IRQ GPIO_FN_IRQ28_123 1166# define GPIO_TSC_IRQ GPIO_FN_IRQ28_123
@@ -1224,6 +1232,12 @@ static void __init ap4evb_init(void)
1224 u32 srcr4; 1232 u32 srcr4;
1225 struct clk *clk; 1233 struct clk *clk;
1226 1234
1235 regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
1236 ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
1237 regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers,
1238 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
1239 regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
1240
1227 /* External clock source */ 1241 /* External clock source */
1228 clk_set_rate(&sh7372_dv_clki_clk, 27000000); 1242 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
1229 1243
@@ -1302,8 +1316,8 @@ static void __init ap4evb_init(void)
1302 1316
1303 gpio_request(GPIO_PORT9, NULL); 1317 gpio_request(GPIO_PORT9, NULL);
1304 gpio_request(GPIO_PORT10, NULL); 1318 gpio_request(GPIO_PORT10, NULL);
1305 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */ 1319 gpio_direction_none(GPIO_PORT9CR); /* FSIAOBT needs no direction */
1306 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */ 1320 gpio_direction_none(GPIO_PORT10CR); /* FSIAOLR needs no direction */
1307 1321
1308 /* card detect pin for MMC slot (CN7) */ 1322 /* card detect pin for MMC slot (CN7) */
1309 gpio_request(GPIO_PORT41, NULL); 1323 gpio_request(GPIO_PORT41, NULL);
@@ -1447,14 +1461,14 @@ static void __init ap4evb_init(void)
1447 1461
1448 platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices)); 1462 platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
1449 1463
1450 sh7372_add_device_to_domain(&sh7372_a4lc, &lcdc1_device); 1464 rmobile_add_device_to_domain(&sh7372_pd_a4lc, &lcdc1_device);
1451 sh7372_add_device_to_domain(&sh7372_a4lc, &lcdc_device); 1465 rmobile_add_device_to_domain(&sh7372_pd_a4lc, &lcdc_device);
1452 sh7372_add_device_to_domain(&sh7372_a4mp, &fsi_device); 1466 rmobile_add_device_to_domain(&sh7372_pd_a4mp, &fsi_device);
1453 1467
1454 sh7372_add_device_to_domain(&sh7372_a3sp, &sh_mmcif_device); 1468 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &sh_mmcif_device);
1455 sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi0_device); 1469 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &sdhi0_device);
1456 sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi1_device); 1470 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &sdhi1_device);
1457 sh7372_add_device_to_domain(&sh7372_a4r, &ceu_device); 1471 rmobile_add_device_to_domain(&sh7372_pd_a4r, &ceu_device);
1458 1472
1459 hdmi_init_pm_clock(); 1473 hdmi_init_pm_clock();
1460 fsi_init_pm_clock(); 1474 fsi_init_pm_clock();
diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c
index 9bd135531d7..453a6e50db8 100644
--- a/arch/arm/mach-shmobile/board-armadillo800eva.c
+++ b/arch/arm/mach-shmobile/board-armadillo800eva.c
@@ -28,6 +28,8 @@
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/gpio.h> 29#include <linux/gpio.h>
30#include <linux/gpio_keys.h> 30#include <linux/gpio_keys.h>
31#include <linux/regulator/fixed.h>
32#include <linux/regulator/machine.h>
31#include <linux/sh_eth.h> 33#include <linux/sh_eth.h>
32#include <linux/videodev2.h> 34#include <linux/videodev2.h>
33#include <linux/usb/renesas_usbhs.h> 35#include <linux/usb/renesas_usbhs.h>
@@ -37,14 +39,20 @@
37#include <linux/mmc/sh_mobile_sdhi.h> 39#include <linux/mmc/sh_mobile_sdhi.h>
38#include <mach/common.h> 40#include <mach/common.h>
39#include <mach/irqs.h> 41#include <mach/irqs.h>
42#include <mach/r8a7740.h>
43#include <media/mt9t112.h>
44#include <media/sh_mobile_ceu.h>
45#include <media/soc_camera.h>
40#include <asm/page.h> 46#include <asm/page.h>
41#include <asm/mach-types.h> 47#include <asm/mach-types.h>
42#include <asm/mach/arch.h> 48#include <asm/mach/arch.h>
43#include <asm/mach/map.h> 49#include <asm/mach/map.h>
44#include <asm/mach/time.h> 50#include <asm/mach/time.h>
45#include <asm/hardware/cache-l2x0.h> 51#include <asm/hardware/cache-l2x0.h>
46#include <mach/r8a7740.h>
47#include <video/sh_mobile_lcdc.h> 52#include <video/sh_mobile_lcdc.h>
53#include <video/sh_mobile_hdmi.h>
54#include <sound/sh_fsi.h>
55#include <sound/simple_card.h>
48 56
49/* 57/*
50 * CON1 Camera Module 58 * CON1 Camera Module
@@ -108,6 +116,14 @@
108 */ 116 */
109 117
110/* 118/*
119 * FSI-WM8978
120 *
121 * this command is required when playback.
122 *
123 * # amixer set "Headphone" 50
124 */
125
126/*
111 * USB function 127 * USB function
112 * 128 *
113 * When you use USB Function, 129 * When you use USB Function,
@@ -117,14 +133,8 @@
117 * These are a little bit complex. 133 * These are a little bit complex.
118 * see 134 * see
119 * usbhsf_power_ctrl() 135 * usbhsf_power_ctrl()
120 *
121 * CAUTION
122 *
123 * It uses autonomy mode for USB hotplug at this point
124 * (= usbhs_private.platform_callback.get_vbus is NULL),
125 * since we don't know what's happen on PM control
126 * on this workaround.
127 */ 136 */
137#define IRQ7 evt2irq(0x02e0)
128#define USBCR1 0xe605810a 138#define USBCR1 0xe605810a
129#define USBH 0xC6700000 139#define USBH 0xC6700000
130#define USBH_USBCTR 0x10834 140#define USBH_USBCTR 0x10834
@@ -204,6 +214,20 @@ static void usbhsf_power_ctrl(struct platform_device *pdev,
204 } 214 }
205} 215}
206 216
217static int usbhsf_get_vbus(struct platform_device *pdev)
218{
219 return gpio_get_value(GPIO_PORT209);
220}
221
222static irqreturn_t usbhsf_interrupt(int irq, void *data)
223{
224 struct platform_device *pdev = data;
225
226 renesas_usbhs_call_notify_hotplug(pdev);
227
228 return IRQ_HANDLED;
229}
230
207static void usbhsf_hardware_exit(struct platform_device *pdev) 231static void usbhsf_hardware_exit(struct platform_device *pdev)
208{ 232{
209 struct usbhsf_private *priv = usbhsf_get_priv(pdev); 233 struct usbhsf_private *priv = usbhsf_get_priv(pdev);
@@ -227,11 +251,14 @@ static void usbhsf_hardware_exit(struct platform_device *pdev)
227 priv->host = NULL; 251 priv->host = NULL;
228 priv->func = NULL; 252 priv->func = NULL;
229 priv->usbh_base = NULL; 253 priv->usbh_base = NULL;
254
255 free_irq(IRQ7, pdev);
230} 256}
231 257
232static int usbhsf_hardware_init(struct platform_device *pdev) 258static int usbhsf_hardware_init(struct platform_device *pdev)
233{ 259{
234 struct usbhsf_private *priv = usbhsf_get_priv(pdev); 260 struct usbhsf_private *priv = usbhsf_get_priv(pdev);
261 int ret;
235 262
236 priv->phy = clk_get(&pdev->dev, "phy"); 263 priv->phy = clk_get(&pdev->dev, "phy");
237 priv->usb24 = clk_get(&pdev->dev, "usb24"); 264 priv->usb24 = clk_get(&pdev->dev, "usb24");
@@ -251,6 +278,14 @@ static int usbhsf_hardware_init(struct platform_device *pdev)
251 return -EIO; 278 return -EIO;
252 } 279 }
253 280
281 ret = request_irq(IRQ7, usbhsf_interrupt, IRQF_TRIGGER_NONE,
282 dev_name(&pdev->dev), pdev);
283 if (ret) {
284 dev_err(&pdev->dev, "request_irq err\n");
285 return ret;
286 }
287 irq_set_irq_type(IRQ7, IRQ_TYPE_EDGE_BOTH);
288
254 /* usb24 use 1/1 of parent clock (= usb24s = 24MHz) */ 289 /* usb24 use 1/1 of parent clock (= usb24s = 24MHz) */
255 clk_set_rate(priv->usb24, 290 clk_set_rate(priv->usb24,
256 clk_get_rate(clk_get_parent(priv->usb24))); 291 clk_get_rate(clk_get_parent(priv->usb24)));
@@ -262,6 +297,7 @@ static struct usbhsf_private usbhsf_private = {
262 .info = { 297 .info = {
263 .platform_callback = { 298 .platform_callback = {
264 .get_id = usbhsf_get_id, 299 .get_id = usbhsf_get_id,
300 .get_vbus = usbhsf_get_vbus,
265 .hardware_init = usbhsf_hardware_init, 301 .hardware_init = usbhsf_hardware_init,
266 .hardware_exit = usbhsf_hardware_exit, 302 .hardware_exit = usbhsf_hardware_exit,
267 .power_ctrl = usbhsf_power_ctrl, 303 .power_ctrl = usbhsf_power_ctrl,
@@ -269,6 +305,8 @@ static struct usbhsf_private usbhsf_private = {
269 .driver_param = { 305 .driver_param = {
270 .buswait_bwait = 5, 306 .buswait_bwait = 5,
271 .detection_delay = 5, 307 .detection_delay = 5,
308 .d0_rx_id = SHDMA_SLAVE_USBHS_RX,
309 .d1_tx_id = SHDMA_SLAVE_USBHS_TX,
272 }, 310 },
273 } 311 }
274}; 312};
@@ -384,14 +422,112 @@ static struct platform_device lcdc0_device = {
384 }, 422 },
385}; 423};
386 424
425/*
426 * LCDC1/HDMI
427 */
428static struct sh_mobile_hdmi_info hdmi_info = {
429 .flags = HDMI_OUTPUT_PUSH_PULL |
430 HDMI_OUTPUT_POLARITY_HI |
431 HDMI_32BIT_REG |
432 HDMI_HAS_HTOP1 |
433 HDMI_SND_SRC_SPDIF,
434};
435
436static struct resource hdmi_resources[] = {
437 [0] = {
438 .name = "HDMI",
439 .start = 0xe6be0000,
440 .end = 0xe6be03ff,
441 .flags = IORESOURCE_MEM,
442 },
443 [1] = {
444 .start = evt2irq(0x1700),
445 .flags = IORESOURCE_IRQ,
446 },
447 [2] = {
448 .name = "HDMI emma3pf",
449 .start = 0xe6be4000,
450 .end = 0xe6be43ff,
451 .flags = IORESOURCE_MEM,
452 },
453};
454
455static struct platform_device hdmi_device = {
456 .name = "sh-mobile-hdmi",
457 .num_resources = ARRAY_SIZE(hdmi_resources),
458 .resource = hdmi_resources,
459 .id = -1,
460 .dev = {
461 .platform_data = &hdmi_info,
462 },
463};
464
465static const struct fb_videomode lcdc1_mode = {
466 .name = "HDMI 720p",
467 .xres = 1280,
468 .yres = 720,
469 .pixclock = 13468,
470 .left_margin = 220,
471 .right_margin = 110,
472 .hsync_len = 40,
473 .upper_margin = 20,
474 .lower_margin = 5,
475 .vsync_len = 5,
476 .refresh = 60,
477 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
478};
479
480static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
481 .clock_source = LCDC_CLK_PERIPHERAL, /* HDMI clock */
482 .ch[0] = {
483 .chan = LCDC_CHAN_MAINLCD,
484 .fourcc = V4L2_PIX_FMT_RGB565,
485 .interface_type = RGB24,
486 .clock_divider = 1,
487 .flags = LCDC_FLAGS_DWPOL,
488 .lcd_modes = &lcdc1_mode,
489 .num_modes = 1,
490 .tx_dev = &hdmi_device,
491 .panel_cfg = {
492 .width = 1280,
493 .height = 720,
494 },
495 },
496};
497
498static struct resource hdmi_lcdc_resources[] = {
499 [0] = {
500 .name = "LCDC1",
501 .start = 0xfe944000,
502 .end = 0xfe948000 - 1,
503 .flags = IORESOURCE_MEM,
504 },
505 [1] = {
506 .start = intcs_evt2irq(0x1780),
507 .flags = IORESOURCE_IRQ,
508 },
509};
510
511static struct platform_device hdmi_lcdc_device = {
512 .name = "sh_mobile_lcdc_fb",
513 .num_resources = ARRAY_SIZE(hdmi_lcdc_resources),
514 .resource = hdmi_lcdc_resources,
515 .id = 1,
516 .dev = {
517 .platform_data = &hdmi_lcdc_info,
518 .coherent_dma_mask = ~0,
519 },
520};
521
387/* GPIO KEY */ 522/* GPIO KEY */
388#define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 } 523#define GPIO_KEY(c, g, d, ...) \
524 { .code = c, .gpio = g, .desc = d, .active_low = 1, __VA_ARGS__ }
389 525
390static struct gpio_keys_button gpio_buttons[] = { 526static struct gpio_keys_button gpio_buttons[] = {
391 GPIO_KEY(KEY_POWER, GPIO_PORT99, "SW1"), 527 GPIO_KEY(KEY_POWER, GPIO_PORT99, "SW3", .wakeup = 1),
392 GPIO_KEY(KEY_BACK, GPIO_PORT100, "SW2"), 528 GPIO_KEY(KEY_BACK, GPIO_PORT100, "SW4"),
393 GPIO_KEY(KEY_MENU, GPIO_PORT97, "SW3"), 529 GPIO_KEY(KEY_MENU, GPIO_PORT97, "SW5"),
394 GPIO_KEY(KEY_HOME, GPIO_PORT98, "SW4"), 530 GPIO_KEY(KEY_HOME, GPIO_PORT98, "SW6"),
395}; 531};
396 532
397static struct gpio_keys_platform_data gpio_key_info = { 533static struct gpio_keys_platform_data gpio_key_info = {
@@ -407,6 +543,17 @@ static struct platform_device gpio_keys_device = {
407 }, 543 },
408}; 544};
409 545
546/* Fixed 3.3V regulator to be used by SDHI0, SDHI1, MMCIF */
547static struct regulator_consumer_supply fixed3v3_power_consumers[] =
548{
549 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
550 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
551 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
552 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
553 REGULATOR_SUPPLY("vmmc", "sh_mmcif"),
554 REGULATOR_SUPPLY("vqmmc", "sh_mmcif"),
555};
556
410/* SDHI0 */ 557/* SDHI0 */
411/* 558/*
412 * FIXME 559 * FIXME
@@ -418,6 +565,8 @@ static struct platform_device gpio_keys_device = {
418 */ 565 */
419#define IRQ31 evt2irq(0x33E0) 566#define IRQ31 evt2irq(0x33E0)
420static struct sh_mobile_sdhi_info sdhi0_info = { 567static struct sh_mobile_sdhi_info sdhi0_info = {
568 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
569 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
421 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |\ 570 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |\
422 MMC_CAP_NEEDS_POLL, 571 MMC_CAP_NEEDS_POLL,
423 .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, 572 .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
@@ -458,6 +607,8 @@ static struct platform_device sdhi0_device = {
458 607
459/* SDHI1 */ 608/* SDHI1 */
460static struct sh_mobile_sdhi_info sdhi1_info = { 609static struct sh_mobile_sdhi_info sdhi1_info = {
610 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
611 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
461 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ, 612 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
462 .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, 613 .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
463 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT, 614 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
@@ -532,12 +683,209 @@ static struct platform_device sh_mmcif_device = {
532 .resource = sh_mmcif_resources, 683 .resource = sh_mmcif_resources,
533}; 684};
534 685
686/* Camera */
687static int mt9t111_power(struct device *dev, int mode)
688{
689 struct clk *mclk = clk_get(NULL, "video1");
690
691 if (IS_ERR(mclk)) {
692 dev_err(dev, "can't get video1 clock\n");
693 return -EINVAL;
694 }
695
696 if (mode) {
697 /* video1 (= CON1 camera) expect 24MHz */
698 clk_set_rate(mclk, clk_round_rate(mclk, 24000000));
699 clk_enable(mclk);
700 gpio_direction_output(GPIO_PORT158, 1);
701 } else {
702 gpio_direction_output(GPIO_PORT158, 0);
703 clk_disable(mclk);
704 }
705
706 clk_put(mclk);
707
708 return 0;
709}
710
711static struct i2c_board_info i2c_camera_mt9t111 = {
712 I2C_BOARD_INFO("mt9t112", 0x3d),
713};
714
715static struct mt9t112_camera_info mt9t111_info = {
716 .divider = { 16, 0, 0, 7, 0, 10, 14, 7, 7 },
717};
718
719static struct soc_camera_link mt9t111_link = {
720 .i2c_adapter_id = 0,
721 .bus_id = 0,
722 .board_info = &i2c_camera_mt9t111,
723 .power = mt9t111_power,
724 .priv = &mt9t111_info,
725};
726
727static struct platform_device camera_device = {
728 .name = "soc-camera-pdrv",
729 .id = 0,
730 .dev = {
731 .platform_data = &mt9t111_link,
732 },
733};
734
735/* CEU0 */
736static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
737 .flags = SH_CEU_FLAG_LOWER_8BIT,
738};
739
740static struct resource ceu0_resources[] = {
741 [0] = {
742 .name = "CEU",
743 .start = 0xfe910000,
744 .end = 0xfe91009f,
745 .flags = IORESOURCE_MEM,
746 },
747 [1] = {
748 .start = intcs_evt2irq(0x0500),
749 .flags = IORESOURCE_IRQ,
750 },
751 [2] = {
752 /* place holder for contiguous memory */
753 },
754};
755
756static struct platform_device ceu0_device = {
757 .name = "sh_mobile_ceu",
758 .id = 0,
759 .num_resources = ARRAY_SIZE(ceu0_resources),
760 .resource = ceu0_resources,
761 .dev = {
762 .platform_data = &sh_mobile_ceu0_info,
763 .coherent_dma_mask = 0xffffffff,
764 },
765};
766
767/* FSI */
768static int fsi_hdmi_set_rate(struct device *dev, int rate, int enable)
769{
770 struct clk *fsib;
771 int ret;
772
773 /* it support 48KHz only */
774 if (48000 != rate)
775 return -EINVAL;
776
777 fsib = clk_get(dev, "ickb");
778 if (IS_ERR(fsib))
779 return -EINVAL;
780
781 if (enable) {
782 ret = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
783 clk_enable(fsib);
784 } else {
785 ret = 0;
786 clk_disable(fsib);
787 }
788
789 clk_put(fsib);
790
791 return ret;
792}
793
794static struct sh_fsi_platform_info fsi_info = {
795 /* FSI-WM8978 */
796 .port_a = {
797 .tx_id = SHDMA_SLAVE_FSIA_TX,
798 },
799 /* FSI-HDMI */
800 .port_b = {
801 .flags = SH_FSI_FMT_SPDIF |
802 SH_FSI_ENABLE_STREAM_MODE,
803 .set_rate = fsi_hdmi_set_rate,
804 .tx_id = SHDMA_SLAVE_FSIB_TX,
805 }
806};
807
808static struct resource fsi_resources[] = {
809 [0] = {
810 .name = "FSI",
811 .start = 0xfe1f0000,
812 .end = 0xfe1f8400 - 1,
813 .flags = IORESOURCE_MEM,
814 },
815 [1] = {
816 .start = evt2irq(0x1840),
817 .flags = IORESOURCE_IRQ,
818 },
819};
820
821static struct platform_device fsi_device = {
822 .name = "sh_fsi2",
823 .id = -1,
824 .num_resources = ARRAY_SIZE(fsi_resources),
825 .resource = fsi_resources,
826 .dev = {
827 .platform_data = &fsi_info,
828 },
829};
830
831/* FSI-WM8978 */
832static struct asoc_simple_dai_init_info fsi_wm8978_init_info = {
833 .fmt = SND_SOC_DAIFMT_I2S,
834 .codec_daifmt = SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_NB_NF,
835 .cpu_daifmt = SND_SOC_DAIFMT_CBS_CFS,
836 .sysclk = 12288000,
837};
838
839static struct asoc_simple_card_info fsi_wm8978_info = {
840 .name = "wm8978",
841 .card = "FSI2A-WM8978",
842 .cpu_dai = "fsia-dai",
843 .codec = "wm8978.0-001a",
844 .platform = "sh_fsi2",
845 .codec_dai = "wm8978-hifi",
846 .init = &fsi_wm8978_init_info,
847};
848
849static struct platform_device fsi_wm8978_device = {
850 .name = "asoc-simple-card",
851 .id = 0,
852 .dev = {
853 .platform_data = &fsi_wm8978_info,
854 },
855};
856
857/* FSI-HDMI */
858static struct asoc_simple_dai_init_info fsi2_hdmi_init_info = {
859 .cpu_daifmt = SND_SOC_DAIFMT_CBM_CFM,
860};
861
862static struct asoc_simple_card_info fsi2_hdmi_info = {
863 .name = "HDMI",
864 .card = "FSI2B-HDMI",
865 .cpu_dai = "fsib-dai",
866 .codec = "sh-mobile-hdmi",
867 .platform = "sh_fsi2",
868 .codec_dai = "sh_mobile_hdmi-hifi",
869 .init = &fsi2_hdmi_init_info,
870};
871
872static struct platform_device fsi_hdmi_device = {
873 .name = "asoc-simple-card",
874 .id = 1,
875 .dev = {
876 .platform_data = &fsi2_hdmi_info,
877 },
878};
879
535/* I2C */ 880/* I2C */
536static struct i2c_board_info i2c0_devices[] = { 881static struct i2c_board_info i2c0_devices[] = {
537 { 882 {
538 I2C_BOARD_INFO("st1232-ts", 0x55), 883 I2C_BOARD_INFO("st1232-ts", 0x55),
539 .irq = evt2irq(0x0340), 884 .irq = evt2irq(0x0340),
540 }, 885 },
886 {
887 I2C_BOARD_INFO("wm8978", 0x1a),
888 },
541}; 889};
542 890
543/* 891/*
@@ -549,6 +897,13 @@ static struct platform_device *eva_devices[] __initdata = {
549 &sh_eth_device, 897 &sh_eth_device,
550 &sdhi0_device, 898 &sdhi0_device,
551 &sh_mmcif_device, 899 &sh_mmcif_device,
900 &hdmi_device,
901 &hdmi_lcdc_device,
902 &camera_device,
903 &ceu0_device,
904 &fsi_device,
905 &fsi_wm8978_device,
906 &fsi_hdmi_device,
552}; 907};
553 908
554static void __init eva_clock_init(void) 909static void __init eva_clock_init(void)
@@ -556,10 +911,14 @@ static void __init eva_clock_init(void)
556 struct clk *system = clk_get(NULL, "system_clk"); 911 struct clk *system = clk_get(NULL, "system_clk");
557 struct clk *xtal1 = clk_get(NULL, "extal1"); 912 struct clk *xtal1 = clk_get(NULL, "extal1");
558 struct clk *usb24s = clk_get(NULL, "usb24s"); 913 struct clk *usb24s = clk_get(NULL, "usb24s");
914 struct clk *fsibck = clk_get(NULL, "fsibck");
915 struct clk *fsib = clk_get(&fsi_device.dev, "ickb");
559 916
560 if (IS_ERR(system) || 917 if (IS_ERR(system) ||
561 IS_ERR(xtal1) || 918 IS_ERR(xtal1) ||
562 IS_ERR(usb24s)) { 919 IS_ERR(usb24s) ||
920 IS_ERR(fsibck) ||
921 IS_ERR(fsib)) {
563 pr_err("armadillo800eva board clock init failed\n"); 922 pr_err("armadillo800eva board clock init failed\n");
564 goto clock_error; 923 goto clock_error;
565 } 924 }
@@ -570,6 +929,11 @@ static void __init eva_clock_init(void)
570 /* usb24s use extal1 (= system) clock (= 24MHz) */ 929 /* usb24s use extal1 (= system) clock (= 24MHz) */
571 clk_set_parent(usb24s, system); 930 clk_set_parent(usb24s, system);
572 931
932 /* FSIBCK is 12.288MHz, and it is parent of FSI-B */
933 clk_set_parent(fsib, fsibck);
934 clk_set_rate(fsibck, 12288000);
935 clk_set_rate(fsib, 12288000);
936
573clock_error: 937clock_error:
574 if (!IS_ERR(system)) 938 if (!IS_ERR(system))
575 clk_put(system); 939 clk_put(system);
@@ -577,16 +941,26 @@ clock_error:
577 clk_put(xtal1); 941 clk_put(xtal1);
578 if (!IS_ERR(usb24s)) 942 if (!IS_ERR(usb24s))
579 clk_put(usb24s); 943 clk_put(usb24s);
944 if (!IS_ERR(fsibck))
945 clk_put(fsibck);
946 if (!IS_ERR(fsib))
947 clk_put(fsib);
580} 948}
581 949
582/* 950/*
583 * board init 951 * board init
584 */ 952 */
953#define GPIO_PORT7CR 0xe6050007
954#define GPIO_PORT8CR 0xe6050008
585static void __init eva_init(void) 955static void __init eva_init(void)
586{ 956{
587 eva_clock_init(); 957 struct platform_device *usb = NULL;
958
959 regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
960 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
588 961
589 r8a7740_pinmux_init(); 962 r8a7740_pinmux_init();
963 r8a7740_meram_workaround();
590 964
591 /* SCIFA1 */ 965 /* SCIFA1 */
592 gpio_request(GPIO_FN_SCIFA1_RXD, NULL); 966 gpio_request(GPIO_FN_SCIFA1_RXD, NULL);
@@ -667,8 +1041,19 @@ static void __init eva_init(void)
667 /* USB Host */ 1041 /* USB Host */
668 } else { 1042 } else {
669 /* USB Func */ 1043 /* USB Func */
670 gpio_request(GPIO_FN_VBUS, NULL); 1044 /*
1045 * A1 chip has 2 IRQ7 pin and it was controled by MSEL register.
1046 * OTOH, usbhs interrupt needs its value (HI/LOW) to decide
1047 * USB connection/disconnection (usbhsf_get_vbus()).
1048 * This means we needs to select GPIO_FN_IRQ7_PORT209 first,
1049 * and select GPIO_PORT209 here
1050 */
1051 gpio_request(GPIO_FN_IRQ7_PORT209, NULL);
1052 gpio_request(GPIO_PORT209, NULL);
1053 gpio_direction_input(GPIO_PORT209);
1054
671 platform_device_register(&usbhsf_device); 1055 platform_device_register(&usbhsf_device);
1056 usb = &usbhsf_device;
672 } 1057 }
673 1058
674 /* SDHI0 */ 1059 /* SDHI0 */
@@ -706,6 +1091,48 @@ static void __init eva_init(void)
706 gpio_request(GPIO_FN_MMC1_D6_PORT143, NULL); 1091 gpio_request(GPIO_FN_MMC1_D6_PORT143, NULL);
707 gpio_request(GPIO_FN_MMC1_D7_PORT142, NULL); 1092 gpio_request(GPIO_FN_MMC1_D7_PORT142, NULL);
708 1093
1094 /* CEU0 */
1095 gpio_request(GPIO_FN_VIO0_D7, NULL);
1096 gpio_request(GPIO_FN_VIO0_D6, NULL);
1097 gpio_request(GPIO_FN_VIO0_D5, NULL);
1098 gpio_request(GPIO_FN_VIO0_D4, NULL);
1099 gpio_request(GPIO_FN_VIO0_D3, NULL);
1100 gpio_request(GPIO_FN_VIO0_D2, NULL);
1101 gpio_request(GPIO_FN_VIO0_D1, NULL);
1102 gpio_request(GPIO_FN_VIO0_D0, NULL);
1103 gpio_request(GPIO_FN_VIO0_CLK, NULL);
1104 gpio_request(GPIO_FN_VIO0_HD, NULL);
1105 gpio_request(GPIO_FN_VIO0_VD, NULL);
1106 gpio_request(GPIO_FN_VIO0_FIELD, NULL);
1107 gpio_request(GPIO_FN_VIO_CKO, NULL);
1108
1109 /* CON1/CON15 Camera */
1110 gpio_request(GPIO_PORT173, NULL); /* STANDBY */
1111 gpio_request(GPIO_PORT172, NULL); /* RST */
1112 gpio_request(GPIO_PORT158, NULL); /* CAM_PON */
1113 gpio_direction_output(GPIO_PORT173, 0);
1114 gpio_direction_output(GPIO_PORT172, 1);
1115 gpio_direction_output(GPIO_PORT158, 0); /* see mt9t111_power() */
1116
1117 /* FSI-WM8978 */
1118 gpio_request(GPIO_FN_FSIAIBT, NULL);
1119 gpio_request(GPIO_FN_FSIAILR, NULL);
1120 gpio_request(GPIO_FN_FSIAOMC, NULL);
1121 gpio_request(GPIO_FN_FSIAOSLD, NULL);
1122 gpio_request(GPIO_FN_FSIAISLD_PORT5, NULL);
1123
1124 gpio_request(GPIO_PORT7, NULL);
1125 gpio_request(GPIO_PORT8, NULL);
1126 gpio_direction_none(GPIO_PORT7CR); /* FSIAOBT needs no direction */
1127 gpio_direction_none(GPIO_PORT8CR); /* FSIAOLR needs no direction */
1128
1129 /* FSI-HDMI */
1130 gpio_request(GPIO_FN_FSIBCK, NULL);
1131
1132 /* HDMI */
1133 gpio_request(GPIO_FN_HDMI_HPD, NULL);
1134 gpio_request(GPIO_FN_HDMI_CEC, NULL);
1135
709 /* 1136 /*
710 * CAUTION 1137 * CAUTION
711 * 1138 *
@@ -752,6 +1179,13 @@ static void __init eva_init(void)
752 1179
753 platform_add_devices(eva_devices, 1180 platform_add_devices(eva_devices,
754 ARRAY_SIZE(eva_devices)); 1181 ARRAY_SIZE(eva_devices));
1182
1183 eva_clock_init();
1184
1185 rmobile_add_device_to_domain(&r8a7740_pd_a4lc, &lcdc0_device);
1186 rmobile_add_device_to_domain(&r8a7740_pd_a4lc, &hdmi_lcdc_device);
1187 if (usb)
1188 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, usb);
755} 1189}
756 1190
757static void __init eva_earlytimer_init(void) 1191static void __init eva_earlytimer_init(void)
diff --git a/arch/arm/mach-shmobile/board-bonito.c b/arch/arm/mach-shmobile/board-bonito.c
index e9b32cfbf74..4129008eae2 100644
--- a/arch/arm/mach-shmobile/board-bonito.c
+++ b/arch/arm/mach-shmobile/board-bonito.c
@@ -26,6 +26,8 @@
26#include <linux/irq.h> 26#include <linux/irq.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/gpio.h> 28#include <linux/gpio.h>
29#include <linux/regulator/fixed.h>
30#include <linux/regulator/machine.h>
29#include <linux/smsc911x.h> 31#include <linux/smsc911x.h>
30#include <linux/videodev2.h> 32#include <linux/videodev2.h>
31#include <mach/common.h> 33#include <mach/common.h>
@@ -75,6 +77,12 @@
75 * S38.2 = OFF 77 * S38.2 = OFF
76 */ 78 */
77 79
80/* Dummy supplies, where voltage doesn't matter */
81static struct regulator_consumer_supply dummy_supplies[] = {
82 REGULATOR_SUPPLY("vddvario", "smsc911x"),
83 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
84};
85
78/* 86/*
79 * FPGA 87 * FPGA
80 */ 88 */
@@ -360,6 +368,8 @@ static void __init bonito_init(void)
360{ 368{
361 u16 val; 369 u16 val;
362 370
371 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
372
363 r8a7740_pinmux_init(); 373 r8a7740_pinmux_init();
364 bonito_fpga_init(); 374 bonito_fpga_init();
365 375
diff --git a/arch/arm/mach-shmobile/board-g4evm.c b/arch/arm/mach-shmobile/board-g4evm.c
index f1257321999..fa5dfc5c8ed 100644
--- a/arch/arm/mach-shmobile/board-g4evm.c
+++ b/arch/arm/mach-shmobile/board-g4evm.c
@@ -26,6 +26,8 @@
26#include <linux/mtd/mtd.h> 26#include <linux/mtd/mtd.h>
27#include <linux/mtd/partitions.h> 27#include <linux/mtd/partitions.h>
28#include <linux/mtd/physmap.h> 28#include <linux/mtd/physmap.h>
29#include <linux/regulator/fixed.h>
30#include <linux/regulator/machine.h>
29#include <linux/usb/r8a66597.h> 31#include <linux/usb/r8a66597.h>
30#include <linux/io.h> 32#include <linux/io.h>
31#include <linux/input.h> 33#include <linux/input.h>
@@ -196,6 +198,15 @@ static struct platform_device keysc_device = {
196 }, 198 },
197}; 199};
198 200
201/* Fixed 3.3V regulator to be used by SDHI0 and SDHI1 */
202static struct regulator_consumer_supply fixed3v3_power_consumers[] =
203{
204 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
205 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
206 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
207 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
208};
209
199/* SDHI */ 210/* SDHI */
200static struct sh_mobile_sdhi_info sdhi0_info = { 211static struct sh_mobile_sdhi_info sdhi0_info = {
201 .tmio_caps = MMC_CAP_SDIO_IRQ, 212 .tmio_caps = MMC_CAP_SDIO_IRQ,
@@ -271,26 +282,11 @@ static struct platform_device *g4evm_devices[] __initdata = {
271#define GPIO_SDHID1_D3 0xe6052106 282#define GPIO_SDHID1_D3 0xe6052106
272#define GPIO_SDHICMD1 0xe6052107 283#define GPIO_SDHICMD1 0xe6052107
273 284
274/*
275 * FIXME !!
276 *
277 * gpio_pull_up is quick_hack.
278 *
279 * current gpio frame work doesn't have
280 * the method to control only pull up/down/free.
281 * this function should be replaced by correct gpio function
282 */
283static void __init gpio_pull_up(u32 addr)
284{
285 u8 data = __raw_readb(addr);
286
287 data &= 0x0F;
288 data |= 0xC0;
289 __raw_writeb(data, addr);
290}
291
292static void __init g4evm_init(void) 285static void __init g4evm_init(void)
293{ 286{
287 regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
288 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
289
294 sh7377_pinmux_init(); 290 sh7377_pinmux_init();
295 291
296 /* Lit DS14 LED */ 292 /* Lit DS14 LED */
@@ -351,11 +347,11 @@ static void __init g4evm_init(void)
351 gpio_request(GPIO_FN_SDHID0_3, NULL); 347 gpio_request(GPIO_FN_SDHID0_3, NULL);
352 gpio_request(GPIO_FN_SDHICMD0, NULL); 348 gpio_request(GPIO_FN_SDHICMD0, NULL);
353 gpio_request(GPIO_FN_SDHIWP0, NULL); 349 gpio_request(GPIO_FN_SDHIWP0, NULL);
354 gpio_pull_up(GPIO_SDHID0_D0); 350 gpio_request_pullup(GPIO_SDHID0_D0);
355 gpio_pull_up(GPIO_SDHID0_D1); 351 gpio_request_pullup(GPIO_SDHID0_D1);
356 gpio_pull_up(GPIO_SDHID0_D2); 352 gpio_request_pullup(GPIO_SDHID0_D2);
357 gpio_pull_up(GPIO_SDHID0_D3); 353 gpio_request_pullup(GPIO_SDHID0_D3);
358 gpio_pull_up(GPIO_SDHICMD0); 354 gpio_request_pullup(GPIO_SDHICMD0);
359 355
360 /* SDHI1 */ 356 /* SDHI1 */
361 gpio_request(GPIO_FN_SDHICLK1, NULL); 357 gpio_request(GPIO_FN_SDHICLK1, NULL);
@@ -364,11 +360,11 @@ static void __init g4evm_init(void)
364 gpio_request(GPIO_FN_SDHID1_2, NULL); 360 gpio_request(GPIO_FN_SDHID1_2, NULL);
365 gpio_request(GPIO_FN_SDHID1_3, NULL); 361 gpio_request(GPIO_FN_SDHID1_3, NULL);
366 gpio_request(GPIO_FN_SDHICMD1, NULL); 362 gpio_request(GPIO_FN_SDHICMD1, NULL);
367 gpio_pull_up(GPIO_SDHID1_D0); 363 gpio_request_pullup(GPIO_SDHID1_D0);
368 gpio_pull_up(GPIO_SDHID1_D1); 364 gpio_request_pullup(GPIO_SDHID1_D1);
369 gpio_pull_up(GPIO_SDHID1_D2); 365 gpio_request_pullup(GPIO_SDHID1_D2);
370 gpio_pull_up(GPIO_SDHID1_D3); 366 gpio_request_pullup(GPIO_SDHID1_D3);
371 gpio_pull_up(GPIO_SDHICMD1); 367 gpio_request_pullup(GPIO_SDHICMD1);
372 368
373 sh7377_add_standard_devices(); 369 sh7377_add_standard_devices();
374 370
diff --git a/arch/arm/mach-shmobile/board-kota2.c b/arch/arm/mach-shmobile/board-kota2.c
index f60f1b281cc..21dbe54304d 100644
--- a/arch/arm/mach-shmobile/board-kota2.c
+++ b/arch/arm/mach-shmobile/board-kota2.c
@@ -27,6 +27,8 @@
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/io.h> 29#include <linux/io.h>
30#include <linux/regulator/fixed.h>
31#include <linux/regulator/machine.h>
30#include <linux/smsc911x.h> 32#include <linux/smsc911x.h>
31#include <linux/gpio.h> 33#include <linux/gpio.h>
32#include <linux/input.h> 34#include <linux/input.h>
@@ -49,6 +51,12 @@
49#include <asm/hardware/cache-l2x0.h> 51#include <asm/hardware/cache-l2x0.h>
50#include <asm/traps.h> 52#include <asm/traps.h>
51 53
54/* Dummy supplies, where voltage doesn't matter */
55static struct regulator_consumer_supply dummy_supplies[] = {
56 REGULATOR_SUPPLY("vddvario", "smsc911x"),
57 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
58};
59
52/* SMSC 9220 */ 60/* SMSC 9220 */
53static struct resource smsc9220_resources[] = { 61static struct resource smsc9220_resources[] = {
54 [0] = { 62 [0] = {
@@ -288,6 +296,13 @@ static struct platform_device leds_tpu30_device = {
288 .resource = tpu30_resources, 296 .resource = tpu30_resources,
289}; 297};
290 298
299/* Fixed 1.8V regulator to be used by MMCIF */
300static struct regulator_consumer_supply fixed1v8_power_consumers[] =
301{
302 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
303 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
304};
305
291/* MMCIF */ 306/* MMCIF */
292static struct resource mmcif_resources[] = { 307static struct resource mmcif_resources[] = {
293 [0] = { 308 [0] = {
@@ -321,6 +336,15 @@ static struct platform_device mmcif_device = {
321 .resource = mmcif_resources, 336 .resource = mmcif_resources,
322}; 337};
323 338
339/* Fixed 3.3V regulator to be used by SDHI0 and SDHI1 */
340static struct regulator_consumer_supply fixed3v3_power_consumers[] =
341{
342 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
343 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
344 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
345 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
346};
347
324/* SDHI0 */ 348/* SDHI0 */
325static struct sh_mobile_sdhi_info sdhi0_info = { 349static struct sh_mobile_sdhi_info sdhi0_info = {
326 .tmio_caps = MMC_CAP_SD_HIGHSPEED, 350 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
@@ -411,6 +435,12 @@ static struct platform_device *kota2_devices[] __initdata = {
411 435
412static void __init kota2_init(void) 436static void __init kota2_init(void)
413{ 437{
438 regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
439 ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
440 regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers,
441 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
442 regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
443
414 sh73a0_pinmux_init(); 444 sh73a0_pinmux_init();
415 445
416 /* SCIFA2 (UART2) */ 446 /* SCIFA2 (UART2) */
diff --git a/arch/arm/mach-shmobile/board-kzm9d.c b/arch/arm/mach-shmobile/board-kzm9d.c
index 6a33cf39342..2c986eaae7b 100644
--- a/arch/arm/mach-shmobile/board-kzm9d.c
+++ b/arch/arm/mach-shmobile/board-kzm9d.c
@@ -21,6 +21,8 @@
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/regulator/fixed.h>
25#include <linux/regulator/machine.h>
24#include <linux/smsc911x.h> 26#include <linux/smsc911x.h>
25#include <mach/common.h> 27#include <mach/common.h>
26#include <mach/emev2.h> 28#include <mach/emev2.h>
@@ -28,6 +30,12 @@
28#include <asm/mach/arch.h> 30#include <asm/mach/arch.h>
29#include <asm/hardware/gic.h> 31#include <asm/hardware/gic.h>
30 32
33/* Dummy supplies, where voltage doesn't matter */
34static struct regulator_consumer_supply dummy_supplies[] = {
35 REGULATOR_SUPPLY("vddvario", "smsc911x"),
36 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
37};
38
31/* Ether */ 39/* Ether */
32static struct resource smsc911x_resources[] = { 40static struct resource smsc911x_resources[] = {
33 [0] = { 41 [0] = {
@@ -63,6 +71,8 @@ static struct platform_device *kzm9d_devices[] __initdata = {
63 71
64void __init kzm9d_add_standard_devices(void) 72void __init kzm9d_add_standard_devices(void)
65{ 73{
74 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
75
66 emev2_add_standard_devices(); 76 emev2_add_standard_devices();
67 77
68 platform_add_devices(kzm9d_devices, ARRAY_SIZE(kzm9d_devices)); 78 platform_add_devices(kzm9d_devices, ARRAY_SIZE(kzm9d_devices));
diff --git a/arch/arm/mach-shmobile/board-kzm9g.c b/arch/arm/mach-shmobile/board-kzm9g.c
index c0ae815e7be..53b7ea92c32 100644
--- a/arch/arm/mach-shmobile/board-kzm9g.c
+++ b/arch/arm/mach-shmobile/board-kzm9g.c
@@ -30,9 +30,14 @@
30#include <linux/mmc/sh_mobile_sdhi.h> 30#include <linux/mmc/sh_mobile_sdhi.h>
31#include <linux/mfd/tmio.h> 31#include <linux/mfd/tmio.h>
32#include <linux/platform_device.h> 32#include <linux/platform_device.h>
33#include <linux/regulator/fixed.h>
34#include <linux/regulator/machine.h>
33#include <linux/smsc911x.h> 35#include <linux/smsc911x.h>
34#include <linux/usb/r8a66597.h> 36#include <linux/usb/r8a66597.h>
37#include <linux/usb/renesas_usbhs.h>
35#include <linux/videodev2.h> 38#include <linux/videodev2.h>
39#include <sound/sh_fsi.h>
40#include <sound/simple_card.h>
36#include <mach/irqs.h> 41#include <mach/irqs.h>
37#include <mach/sh73a0.h> 42#include <mach/sh73a0.h>
38#include <mach/common.h> 43#include <mach/common.h>
@@ -54,6 +59,20 @@
54#define GPIO_PCF8575_PORT15 (GPIO_NR + 13) 59#define GPIO_PCF8575_PORT15 (GPIO_NR + 13)
55#define GPIO_PCF8575_PORT16 (GPIO_NR + 14) 60#define GPIO_PCF8575_PORT16 (GPIO_NR + 14)
56 61
62/* Dummy supplies, where voltage doesn't matter */
63static struct regulator_consumer_supply dummy_supplies[] = {
64 REGULATOR_SUPPLY("vddvario", "smsc911x"),
65 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
66};
67
68/*
69 * FSI-AK4648
70 *
71 * this command is required when playback.
72 *
73 * # amixer set "LINEOUT Mixer DACL" on
74 */
75
57/* SMSC 9221 */ 76/* SMSC 9221 */
58static struct resource smsc9221_resources[] = { 77static struct resource smsc9221_resources[] = {
59 [0] = { 78 [0] = {
@@ -112,6 +131,151 @@ static struct platform_device usb_host_device = {
112 .resource = usb_resources, 131 .resource = usb_resources,
113}; 132};
114 133
134/* USB Func CN17 */
135struct usbhs_private {
136 unsigned int phy;
137 unsigned int cr2;
138 struct renesas_usbhs_platform_info info;
139};
140
141#define IRQ15 intcs_evt2irq(0x03e0)
142#define USB_PHY_MODE (1 << 4)
143#define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
144#define USB_PHY_ON (1 << 1)
145#define USB_PHY_OFF (1 << 0)
146#define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF)
147
148#define usbhs_get_priv(pdev) \
149 container_of(renesas_usbhs_get_info(pdev), struct usbhs_private, info)
150
151static int usbhs_get_vbus(struct platform_device *pdev)
152{
153 struct usbhs_private *priv = usbhs_get_priv(pdev);
154
155 return !((1 << 7) & __raw_readw(priv->cr2));
156}
157
158static void usbhs_phy_reset(struct platform_device *pdev)
159{
160 struct usbhs_private *priv = usbhs_get_priv(pdev);
161
162 /* init phy */
163 __raw_writew(0x8a0a, priv->cr2);
164}
165
166static int usbhs_get_id(struct platform_device *pdev)
167{
168 return USBHS_GADGET;
169}
170
171static irqreturn_t usbhs_interrupt(int irq, void *data)
172{
173 struct platform_device *pdev = data;
174 struct usbhs_private *priv = usbhs_get_priv(pdev);
175
176 renesas_usbhs_call_notify_hotplug(pdev);
177
178 /* clear status */
179 __raw_writew(__raw_readw(priv->phy) | USB_PHY_INT_CLR, priv->phy);
180
181 return IRQ_HANDLED;
182}
183
184static int usbhs_hardware_init(struct platform_device *pdev)
185{
186 struct usbhs_private *priv = usbhs_get_priv(pdev);
187 int ret;
188
189 /* clear interrupt status */
190 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
191
192 ret = request_irq(IRQ15, usbhs_interrupt, IRQF_TRIGGER_HIGH,
193 dev_name(&pdev->dev), pdev);
194 if (ret) {
195 dev_err(&pdev->dev, "request_irq err\n");
196 return ret;
197 }
198
199 /* enable USB phy interrupt */
200 __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->phy);
201
202 return 0;
203}
204
205static void usbhs_hardware_exit(struct platform_device *pdev)
206{
207 struct usbhs_private *priv = usbhs_get_priv(pdev);
208
209 /* clear interrupt status */
210 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
211
212 free_irq(IRQ15, pdev);
213}
214
215static u32 usbhs_pipe_cfg[] = {
216 USB_ENDPOINT_XFER_CONTROL,
217 USB_ENDPOINT_XFER_ISOC,
218 USB_ENDPOINT_XFER_ISOC,
219 USB_ENDPOINT_XFER_BULK,
220 USB_ENDPOINT_XFER_BULK,
221 USB_ENDPOINT_XFER_BULK,
222 USB_ENDPOINT_XFER_INT,
223 USB_ENDPOINT_XFER_INT,
224 USB_ENDPOINT_XFER_INT,
225 USB_ENDPOINT_XFER_BULK,
226 USB_ENDPOINT_XFER_BULK,
227 USB_ENDPOINT_XFER_BULK,
228 USB_ENDPOINT_XFER_BULK,
229 USB_ENDPOINT_XFER_BULK,
230 USB_ENDPOINT_XFER_BULK,
231 USB_ENDPOINT_XFER_BULK,
232};
233
234static struct usbhs_private usbhs_private = {
235 .phy = 0xe60781e0, /* USBPHYINT */
236 .cr2 = 0xe605810c, /* USBCR2 */
237 .info = {
238 .platform_callback = {
239 .hardware_init = usbhs_hardware_init,
240 .hardware_exit = usbhs_hardware_exit,
241 .get_id = usbhs_get_id,
242 .phy_reset = usbhs_phy_reset,
243 .get_vbus = usbhs_get_vbus,
244 },
245 .driver_param = {
246 .buswait_bwait = 4,
247 .has_otg = 1,
248 .pipe_type = usbhs_pipe_cfg,
249 .pipe_size = ARRAY_SIZE(usbhs_pipe_cfg),
250 },
251 },
252};
253
254static struct resource usbhs_resources[] = {
255 [0] = {
256 .start = 0xE6890000,
257 .end = 0xE68900e6 - 1,
258 .flags = IORESOURCE_MEM,
259 },
260 [1] = {
261 .start = gic_spi(62),
262 .end = gic_spi(62),
263 .flags = IORESOURCE_IRQ,
264 },
265};
266
267static struct platform_device usbhs_device = {
268 .name = "renesas_usbhs",
269 .id = -1,
270 .dev = {
271 .dma_mask = NULL,
272 .coherent_dma_mask = 0xffffffff,
273 .platform_data = &usbhs_private.info,
274 },
275 .num_resources = ARRAY_SIZE(usbhs_resources),
276 .resource = usbhs_resources,
277};
278
115/* LCDC */ 279/* LCDC */
116static struct fb_videomode kzm_lcdc_mode = { 280static struct fb_videomode kzm_lcdc_mode = {
117 .name = "WVGA Panel", 281 .name = "WVGA Panel",
@@ -166,6 +330,13 @@ static struct platform_device lcdc_device = {
166 }, 330 },
167}; 331};
168 332
333/* Fixed 1.8V regulator to be used by MMCIF */
334static struct regulator_consumer_supply fixed1v8_power_consumers[] =
335{
336 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
337 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
338};
339
169/* MMCIF */ 340/* MMCIF */
170static struct resource sh_mmcif_resources[] = { 341static struct resource sh_mmcif_resources[] = {
171 [0] = { 342 [0] = {
@@ -187,6 +358,8 @@ static struct resource sh_mmcif_resources[] = {
187static struct sh_mmcif_plat_data sh_mmcif_platdata = { 358static struct sh_mmcif_plat_data sh_mmcif_platdata = {
188 .ocr = MMC_VDD_165_195, 359 .ocr = MMC_VDD_165_195,
189 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE, 360 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
361 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
362 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
190}; 363};
191 364
192static struct platform_device mmc_device = { 365static struct platform_device mmc_device = {
@@ -200,6 +373,15 @@ static struct platform_device mmc_device = {
200 .resource = sh_mmcif_resources, 373 .resource = sh_mmcif_resources,
201}; 374};
202 375
376/* Fixed 2.8V regulators to be used by SDHI0 and SDHI2 */
377static struct regulator_consumer_supply fixed2v8_power_consumers[] =
378{
379 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
380 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
381 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.2"),
382 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.2"),
383};
384
203/* SDHI */ 385/* SDHI */
204static struct sh_mobile_sdhi_info sdhi0_info = { 386static struct sh_mobile_sdhi_info sdhi0_info = {
205 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT, 387 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
@@ -240,6 +422,50 @@ static struct platform_device sdhi0_device = {
240 }, 422 },
241}; 423};
242 424
425/* Micro SD */
426static struct sh_mobile_sdhi_info sdhi2_info = {
427 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT |
428 TMIO_MMC_USE_GPIO_CD |
429 TMIO_MMC_WRPROTECT_DISABLE,
430 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
431 .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
432 .cd_gpio = GPIO_PORT13,
433};
434
435static struct resource sdhi2_resources[] = {
436 [0] = {
437 .name = "SDHI2",
438 .start = 0xee140000,
439 .end = 0xee1400ff,
440 .flags = IORESOURCE_MEM,
441 },
442 [1] = {
443 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
444 .start = gic_spi(103),
445 .flags = IORESOURCE_IRQ,
446 },
447 [2] = {
448 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
449 .start = gic_spi(104),
450 .flags = IORESOURCE_IRQ,
451 },
452 [3] = {
453 .name = SH_MOBILE_SDHI_IRQ_SDIO,
454 .start = gic_spi(105),
455 .flags = IORESOURCE_IRQ,
456 },
457};
458
459static struct platform_device sdhi2_device = {
460 .name = "sh_mobile_sdhi",
461 .id = 2,
462 .num_resources = ARRAY_SIZE(sdhi2_resources),
463 .resource = sdhi2_resources,
464 .dev = {
465 .platform_data = &sdhi2_info,
466 },
467};
468
243/* KEY */ 469/* KEY */
244#define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 } 470#define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
245 471
@@ -267,11 +493,74 @@ static struct platform_device gpio_keys_device = {
267 }, 493 },
268}; 494};
269 495
496/* FSI-AK4648 */
497static struct sh_fsi_platform_info fsi_info = {
498 .port_a = {
499 .tx_id = SHDMA_SLAVE_FSI2A_TX,
500 },
501};
502
503static struct resource fsi_resources[] = {
504 [0] = {
505 .name = "FSI",
506 .start = 0xEC230000,
507 .end = 0xEC230400 - 1,
508 .flags = IORESOURCE_MEM,
509 },
510 [1] = {
511 .start = gic_spi(146),
512 .flags = IORESOURCE_IRQ,
513 },
514};
515
516static struct platform_device fsi_device = {
517 .name = "sh_fsi2",
518 .id = -1,
519 .num_resources = ARRAY_SIZE(fsi_resources),
520 .resource = fsi_resources,
521 .dev = {
522 .platform_data = &fsi_info,
523 },
524};
525
526static struct asoc_simple_dai_init_info fsi2_ak4648_init_info = {
527 .fmt = SND_SOC_DAIFMT_LEFT_J,
528 .codec_daifmt = SND_SOC_DAIFMT_CBM_CFM,
529 .cpu_daifmt = SND_SOC_DAIFMT_CBS_CFS,
530 .sysclk = 11289600,
531};
532
533static struct asoc_simple_card_info fsi2_ak4648_info = {
534 .name = "AK4648",
535 .card = "FSI2A-AK4648",
536 .cpu_dai = "fsia-dai",
537 .codec = "ak4642-codec.0-0012",
538 .platform = "sh_fsi2",
539 .codec_dai = "ak4642-hifi",
540 .init = &fsi2_ak4648_init_info,
541};
542
543static struct platform_device fsi_ak4648_device = {
544 .name = "asoc-simple-card",
545 .dev = {
546 .platform_data = &fsi2_ak4648_info,
547 },
548};
549
270/* I2C */ 550/* I2C */
271static struct pcf857x_platform_data pcf8575_pdata = { 551static struct pcf857x_platform_data pcf8575_pdata = {
272 .gpio_base = GPIO_PCF8575_BASE, 552 .gpio_base = GPIO_PCF8575_BASE,
273}; 553};
274 554
555static struct i2c_board_info i2c0_devices[] = {
556 {
557 I2C_BOARD_INFO("ak4648", 0x12),
558 },
559 {
560 I2C_BOARD_INFO("r2025sd", 0x32),
561 }
562};
563
275static struct i2c_board_info i2c1_devices[] = { 564static struct i2c_board_info i2c1_devices[] = {
276 { 565 {
277 I2C_BOARD_INFO("st1232-ts", 0x55), 566 I2C_BOARD_INFO("st1232-ts", 0x55),
@@ -289,10 +578,14 @@ static struct i2c_board_info i2c3_devices[] = {
289static struct platform_device *kzm_devices[] __initdata = { 578static struct platform_device *kzm_devices[] __initdata = {
290 &smsc_device, 579 &smsc_device,
291 &usb_host_device, 580 &usb_host_device,
581 &usbhs_device,
292 &lcdc_device, 582 &lcdc_device,
293 &mmc_device, 583 &mmc_device,
294 &sdhi0_device, 584 &sdhi0_device,
585 &sdhi2_device,
295 &gpio_keys_device, 586 &gpio_keys_device,
587 &fsi_device,
588 &fsi_ak4648_device,
296}; 589};
297 590
298/* 591/*
@@ -350,6 +643,12 @@ device_initcall(as3711_enable_lcdc_backlight);
350 643
351static void __init kzm_init(void) 644static void __init kzm_init(void)
352{ 645{
646 regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
647 ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
648 regulator_register_always_on(1, "fixed-2.8V", fixed2v8_power_consumers,
649 ARRAY_SIZE(fixed2v8_power_consumers), 2800000);
650 regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
651
353 sh73a0_pinmux_init(); 652 sh73a0_pinmux_init();
354 653
355 /* enable SCIFA4 */ 654 /* enable SCIFA4 */
@@ -427,15 +726,36 @@ static void __init kzm_init(void)
427 gpio_request(GPIO_PORT15, NULL); 726 gpio_request(GPIO_PORT15, NULL);
428 gpio_direction_output(GPIO_PORT15, 1); /* power */ 727 gpio_direction_output(GPIO_PORT15, 1); /* power */
429 728
729 /* enable Micro SD */
730 gpio_request(GPIO_FN_SDHID2_0, NULL);
731 gpio_request(GPIO_FN_SDHID2_1, NULL);
732 gpio_request(GPIO_FN_SDHID2_2, NULL);
733 gpio_request(GPIO_FN_SDHID2_3, NULL);
734 gpio_request(GPIO_FN_SDHICMD2, NULL);
735 gpio_request(GPIO_FN_SDHICLK2, NULL);
736 gpio_request(GPIO_PORT14, NULL);
737 gpio_direction_output(GPIO_PORT14, 1); /* power */
738
430 /* I2C 3 */ 739 /* I2C 3 */
431 gpio_request(GPIO_FN_PORT27_I2C_SCL3, NULL); 740 gpio_request(GPIO_FN_PORT27_I2C_SCL3, NULL);
432 gpio_request(GPIO_FN_PORT28_I2C_SDA3, NULL); 741 gpio_request(GPIO_FN_PORT28_I2C_SDA3, NULL);
433 742
743 /* enable FSI2 port A (ak4648) */
744 gpio_request(GPIO_FN_FSIACK, NULL);
745 gpio_request(GPIO_FN_FSIAILR, NULL);
746 gpio_request(GPIO_FN_FSIAIBT, NULL);
747 gpio_request(GPIO_FN_FSIAISLD, NULL);
748 gpio_request(GPIO_FN_FSIAOSLD, NULL);
749
750 /* enable USB */
751 gpio_request(GPIO_FN_VBUS_0, NULL);
752
434#ifdef CONFIG_CACHE_L2X0 753#ifdef CONFIG_CACHE_L2X0
435 /* Early BRESP enable, Shared attribute override enable, 64K*8way */ 754 /* Early BRESP enable, Shared attribute override enable, 64K*8way */
436 l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff); 755 l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
437#endif 756#endif
438 757
758 i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
439 i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices)); 759 i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices));
440 i2c_register_board_info(3, i2c3_devices, ARRAY_SIZE(i2c3_devices)); 760 i2c_register_board_info(3, i2c3_devices, ARRAY_SIZE(i2c3_devices));
441 761
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index 150122a4463..c129542f6ae 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -41,6 +41,8 @@
41#include <linux/mtd/physmap.h> 41#include <linux/mtd/physmap.h>
42#include <linux/mtd/sh_flctl.h> 42#include <linux/mtd/sh_flctl.h>
43#include <linux/pm_clock.h> 43#include <linux/pm_clock.h>
44#include <linux/regulator/fixed.h>
45#include <linux/regulator/machine.h>
44#include <linux/smsc911x.h> 46#include <linux/smsc911x.h>
45#include <linux/sh_intc.h> 47#include <linux/sh_intc.h>
46#include <linux/tca6416_keypad.h> 48#include <linux/tca6416_keypad.h>
@@ -203,31 +205,32 @@
203 * amixer set "HPOUTR Mixer DACH" on 205 * amixer set "HPOUTR Mixer DACH" on
204 */ 206 */
205 207
206/* 208/* Fixed 3.3V and 1.8V regulators to be used by multiple devices */
207 * FIXME !! 209static struct regulator_consumer_supply fixed1v8_power_consumers[] =
208 *
209 * gpio_no_direction
210 * gpio_pull_down
211 * are quick_hack.
212 *
213 * current gpio frame work doesn't have
214 * the method to control only pull up/down/free.
215 * this function should be replaced by correct gpio function
216 */
217static void __init gpio_no_direction(u32 addr)
218{ 210{
219 __raw_writeb(0x00, addr); 211 /*
220} 212 * J22 on mackerel switches mmcif.0 and sdhi.1 between 1.8V and 3.3V
213 * Since we cannot support both voltages, we support the default 1.8V
214 */
215 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
216 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
217 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
218 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
219};
221 220
222static void __init gpio_pull_down(u32 addr) 221static struct regulator_consumer_supply fixed3v3_power_consumers[] =
223{ 222{
224 u8 data = __raw_readb(addr); 223 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
225 224 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
226 data &= 0x0F; 225 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.2"),
227 data |= 0xA0; 226 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.2"),
227};
228 228
229 __raw_writeb(data, addr); 229/* Dummy supplies, where voltage doesn't matter */
230} 230static struct regulator_consumer_supply dummy_supplies[] = {
231 REGULATOR_SUPPLY("vddvario", "smsc911x"),
232 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
233};
231 234
232/* MTD */ 235/* MTD */
233static struct mtd_partition nor_flash_partitions[] = { 236static struct mtd_partition nor_flash_partitions[] = {
@@ -692,6 +695,7 @@ static struct platform_device usbhs0_device = {
692 * - J30 "open" 695 * - J30 "open"
693 * - modify usbhs1_get_id() USBHS_HOST -> USBHS_GADGET 696 * - modify usbhs1_get_id() USBHS_HOST -> USBHS_GADGET
694 * - add .get_vbus = usbhs_get_vbus in usbhs1_private 697 * - add .get_vbus = usbhs_get_vbus in usbhs1_private
698 * - check usbhs0_device(pio)/usbhs1_device(irq) order in mackerel_devices.
695 */ 699 */
696#define IRQ8 evt2irq(0x0300) 700#define IRQ8 evt2irq(0x0300)
697#define USB_PHY_MODE (1 << 4) 701#define USB_PHY_MODE (1 << 4)
@@ -1322,8 +1326,8 @@ static struct platform_device *mackerel_devices[] __initdata = {
1322 &nor_flash_device, 1326 &nor_flash_device,
1323 &smc911x_device, 1327 &smc911x_device,
1324 &lcdc_device, 1328 &lcdc_device,
1325 &usbhs1_device,
1326 &usbhs0_device, 1329 &usbhs0_device,
1330 &usbhs1_device,
1327 &leds_device, 1331 &leds_device,
1328 &fsi_device, 1332 &fsi_device,
1329 &fsi_ak4643_device, 1333 &fsi_ak4643_device,
@@ -1409,6 +1413,12 @@ static void __init mackerel_init(void)
1409 u32 srcr4; 1413 u32 srcr4;
1410 struct clk *clk; 1414 struct clk *clk;
1411 1415
1416 regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
1417 ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
1418 regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers,
1419 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
1420 regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
1421
1412 /* External clock source */ 1422 /* External clock source */
1413 clk_set_rate(&sh7372_dv_clki_clk, 27000000); 1423 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
1414 1424
@@ -1458,11 +1468,11 @@ static void __init mackerel_init(void)
1458 1468
1459 /* USBHS0 */ 1469 /* USBHS0 */
1460 gpio_request(GPIO_FN_VBUS0_0, NULL); 1470 gpio_request(GPIO_FN_VBUS0_0, NULL);
1461 gpio_pull_down(GPIO_PORT168CR); /* VBUS0_0 pull down */ 1471 gpio_request_pulldown(GPIO_PORT168CR); /* VBUS0_0 pull down */
1462 1472
1463 /* USBHS1 */ 1473 /* USBHS1 */
1464 gpio_request(GPIO_FN_VBUS0_1, NULL); 1474 gpio_request(GPIO_FN_VBUS0_1, NULL);
1465 gpio_pull_down(GPIO_PORT167CR); /* VBUS0_1 pull down */ 1475 gpio_request_pulldown(GPIO_PORT167CR); /* VBUS0_1 pull down */
1466 gpio_request(GPIO_FN_IDIN_1_113, NULL); 1476 gpio_request(GPIO_FN_IDIN_1_113, NULL);
1467 1477
1468 /* enable FSI2 port A (ak4643) */ 1478 /* enable FSI2 port A (ak4643) */
@@ -1475,8 +1485,8 @@ static void __init mackerel_init(void)
1475 1485
1476 gpio_request(GPIO_PORT9, NULL); 1486 gpio_request(GPIO_PORT9, NULL);
1477 gpio_request(GPIO_PORT10, NULL); 1487 gpio_request(GPIO_PORT10, NULL);
1478 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */ 1488 gpio_direction_none(GPIO_PORT9CR); /* FSIAOBT needs no direction */
1479 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */ 1489 gpio_direction_none(GPIO_PORT10CR); /* FSIAOLR needs no direction */
1480 1490
1481 intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */ 1491 intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */
1482 1492
@@ -1614,20 +1624,20 @@ static void __init mackerel_init(void)
1614 1624
1615 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices)); 1625 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
1616 1626
1617 sh7372_add_device_to_domain(&sh7372_a4lc, &lcdc_device); 1627 rmobile_add_device_to_domain(&sh7372_pd_a4lc, &lcdc_device);
1618 sh7372_add_device_to_domain(&sh7372_a4lc, &hdmi_lcdc_device); 1628 rmobile_add_device_to_domain(&sh7372_pd_a4lc, &hdmi_lcdc_device);
1619 sh7372_add_device_to_domain(&sh7372_a4lc, &meram_device); 1629 rmobile_add_device_to_domain(&sh7372_pd_a4lc, &meram_device);
1620 sh7372_add_device_to_domain(&sh7372_a4mp, &fsi_device); 1630 rmobile_add_device_to_domain(&sh7372_pd_a4mp, &fsi_device);
1621 sh7372_add_device_to_domain(&sh7372_a3sp, &usbhs0_device); 1631 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &usbhs0_device);
1622 sh7372_add_device_to_domain(&sh7372_a3sp, &usbhs1_device); 1632 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &usbhs1_device);
1623 sh7372_add_device_to_domain(&sh7372_a3sp, &nand_flash_device); 1633 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &nand_flash_device);
1624 sh7372_add_device_to_domain(&sh7372_a3sp, &sh_mmcif_device); 1634 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &sh_mmcif_device);
1625 sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi0_device); 1635 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &sdhi0_device);
1626#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) 1636#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
1627 sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi1_device); 1637 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &sdhi1_device);
1628#endif 1638#endif
1629 sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi2_device); 1639 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &sdhi2_device);
1630 sh7372_add_device_to_domain(&sh7372_a4r, &ceu_device); 1640 rmobile_add_device_to_domain(&sh7372_pd_a4r, &ceu_device);
1631 1641
1632 hdmi_init_pm_clock(); 1642 hdmi_init_pm_clock();
1633 sh7372_pm_init(); 1643 sh7372_pm_init();
diff --git a/arch/arm/mach-shmobile/board-marzen.c b/arch/arm/mach-shmobile/board-marzen.c
index 14de3787caf..fcf5a47f477 100644
--- a/arch/arm/mach-shmobile/board-marzen.c
+++ b/arch/arm/mach-shmobile/board-marzen.c
@@ -27,6 +27,8 @@
27#include <linux/io.h> 27#include <linux/io.h>
28#include <linux/gpio.h> 28#include <linux/gpio.h>
29#include <linux/dma-mapping.h> 29#include <linux/dma-mapping.h>
30#include <linux/regulator/fixed.h>
31#include <linux/regulator/machine.h>
30#include <linux/smsc911x.h> 32#include <linux/smsc911x.h>
31#include <mach/hardware.h> 33#include <mach/hardware.h>
32#include <mach/r8a7779.h> 34#include <mach/r8a7779.h>
@@ -37,6 +39,12 @@
37#include <asm/hardware/gic.h> 39#include <asm/hardware/gic.h>
38#include <asm/traps.h> 40#include <asm/traps.h>
39 41
42/* Dummy supplies, where voltage doesn't matter */
43static struct regulator_consumer_supply dummy_supplies[] = {
44 REGULATOR_SUPPLY("vddvario", "smsc911x"),
45 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
46};
47
40/* SMSC LAN89218 */ 48/* SMSC LAN89218 */
41static struct resource smsc911x_resources[] = { 49static struct resource smsc911x_resources[] = {
42 [0] = { 50 [0] = {
@@ -59,7 +67,7 @@ static struct smsc911x_platform_config smsc911x_platdata = {
59 67
60static struct platform_device eth_device = { 68static struct platform_device eth_device = {
61 .name = "smsc911x", 69 .name = "smsc911x",
62 .id = 0, 70 .id = -1,
63 .dev = { 71 .dev = {
64 .platform_data = &smsc911x_platdata, 72 .platform_data = &smsc911x_platdata,
65 }, 73 },
@@ -73,6 +81,8 @@ static struct platform_device *marzen_devices[] __initdata = {
73 81
74static void __init marzen_init(void) 82static void __init marzen_init(void)
75{ 83{
84 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
85
76 r8a7779_pinmux_init(); 86 r8a7779_pinmux_init();
77 87
78 /* SCIF2 (CN18: DEBUG0) */ 88 /* SCIF2 (CN18: DEBUG0) */
diff --git a/arch/arm/mach-shmobile/clock-r8a7740.c b/arch/arm/mach-shmobile/clock-r8a7740.c
index 26eea5f2105..ad5fccc7b5e 100644
--- a/arch/arm/mach-shmobile/clock-r8a7740.c
+++ b/arch/arm/mach-shmobile/clock-r8a7740.c
@@ -43,7 +43,10 @@
43/* CPG registers */ 43/* CPG registers */
44#define FRQCRA 0xe6150000 44#define FRQCRA 0xe6150000
45#define FRQCRB 0xe6150004 45#define FRQCRB 0xe6150004
46#define VCLKCR1 0xE6150008
47#define VCLKCR2 0xE615000c
46#define FRQCRC 0xe61500e0 48#define FRQCRC 0xe61500e0
49#define FSIACKCR 0xe6150018
47#define PLLC01CR 0xe6150028 50#define PLLC01CR 0xe6150028
48 51
49#define SUBCKCR 0xe6150080 52#define SUBCKCR 0xe6150080
@@ -54,6 +57,8 @@
54#define MSTPSR2 0xe6150040 57#define MSTPSR2 0xe6150040
55#define MSTPSR3 0xe6150048 58#define MSTPSR3 0xe6150048
56#define MSTPSR4 0xe615004c 59#define MSTPSR4 0xe615004c
60#define FSIBCKCR 0xe6150090
61#define HDMICKCR 0xe6150094
57#define SMSTPCR0 0xe6150130 62#define SMSTPCR0 0xe6150130
58#define SMSTPCR1 0xe6150134 63#define SMSTPCR1 0xe6150134
59#define SMSTPCR2 0xe6150138 64#define SMSTPCR2 0xe6150138
@@ -271,6 +276,13 @@ static struct clk usb24_clk = {
271 .parent = &usb24s_clk, 276 .parent = &usb24s_clk,
272}; 277};
273 278
279/* External FSIACK/FSIBCK clock */
280static struct clk fsiack_clk = {
281};
282
283static struct clk fsibck_clk = {
284};
285
274struct clk *main_clks[] = { 286struct clk *main_clks[] = {
275 &extalr_clk, 287 &extalr_clk,
276 &extal1_clk, 288 &extal1_clk,
@@ -288,6 +300,8 @@ struct clk *main_clks[] = {
288 &pllc1_div2_clk, 300 &pllc1_div2_clk,
289 &usb24s_clk, 301 &usb24s_clk,
290 &usb24_clk, 302 &usb24_clk,
303 &fsiack_clk,
304 &fsibck_clk,
291}; 305};
292 306
293static void div4_kick(struct clk *clk) 307static void div4_kick(struct clk *clk)
@@ -313,6 +327,107 @@ static struct clk_div4_table div4_table = {
313 .kick = div4_kick, 327 .kick = div4_kick,
314}; 328};
315 329
330/* DIV6 reparent */
331enum {
332 DIV6_HDMI,
333 DIV6_VCLK1, DIV6_VCLK2,
334 DIV6_FSIA, DIV6_FSIB,
335 DIV6_REPARENT_NR,
336};
337
338static struct clk *hdmi_parent[] = {
339 [0] = &pllc1_div2_clk,
340 [1] = &system_clk,
341 [2] = &dv_clk
342};
343
344static struct clk *vclk_parents[8] = {
345 [0] = &pllc1_div2_clk,
346 [2] = &dv_clk,
347 [3] = &usb24s_clk,
348 [4] = &extal1_div2_clk,
349 [5] = &extalr_clk,
350};
351
352static struct clk *fsia_parents[] = {
353 [0] = &pllc1_div2_clk,
354 [1] = &fsiack_clk, /* external clock */
355};
356
357static struct clk *fsib_parents[] = {
358 [0] = &pllc1_div2_clk,
359 [1] = &fsibck_clk, /* external clock */
360};
361
362static struct clk div6_reparent_clks[DIV6_REPARENT_NR] = {
363 [DIV6_HDMI] = SH_CLK_DIV6_EXT(HDMICKCR, 0,
364 hdmi_parent, ARRAY_SIZE(hdmi_parent), 6, 2),
365 [DIV6_VCLK1] = SH_CLK_DIV6_EXT(VCLKCR1, 0,
366 vclk_parents, ARRAY_SIZE(vclk_parents), 12, 3),
367 [DIV6_VCLK2] = SH_CLK_DIV6_EXT(VCLKCR2, 0,
368 vclk_parents, ARRAY_SIZE(vclk_parents), 12, 3),
369 [DIV6_FSIA] = SH_CLK_DIV6_EXT(FSIACKCR, 0,
370 fsia_parents, ARRAY_SIZE(fsia_parents), 6, 2),
371 [DIV6_FSIB] = SH_CLK_DIV6_EXT(FSIBCKCR, 0,
372 fsib_parents, ARRAY_SIZE(fsib_parents), 6, 2),
373};
374
375/* HDMI1/2 clock */
376static unsigned long hdmi12_recalc(struct clk *clk)
377{
378 u32 val = __raw_readl(HDMICKCR);
379 int shift = (int)clk->priv;
380
381 val >>= shift;
382 val &= 0x3;
383
384 return clk->parent->rate / (1 << val);
385};
386
387static int hdmi12_set_rate(struct clk *clk, unsigned long rate)
388{
389 u32 val, mask;
390 int i, shift;
391
392 for (i = 0; i < 3; i++)
393 if (rate == clk->parent->rate / (1 << i))
394 goto find;
395 return -ENODEV;
396
397find:
398 shift = (int)clk->priv;
399
400 val = __raw_readl(HDMICKCR);
401 mask = ~(0x3 << shift);
402 val = (val & mask) | i << shift;
403 __raw_writel(val, HDMICKCR);
404
405 return 0;
406};
407
408static struct sh_clk_ops hdmi12_clk_ops = {
409 .recalc = hdmi12_recalc,
410 .set_rate = hdmi12_set_rate,
411};
412
413static struct clk hdmi1_clk = {
414 .ops = &hdmi12_clk_ops,
415 .priv = (void *)9,
416 .parent = &div6_reparent_clks[DIV6_HDMI], /* late install */
417};
418
419static struct clk hdmi2_clk = {
420 .ops = &hdmi12_clk_ops,
421 .priv = (void *)11,
422 .parent = &div6_reparent_clks[DIV6_HDMI], /* late install */
423};
424
425static struct clk *late_main_clks[] = {
426 &hdmi1_clk,
427 &hdmi2_clk,
428};
429
430/* MSTP */
316enum { 431enum {
317 DIV4_I, DIV4_ZG, DIV4_B, DIV4_M1, DIV4_HP, 432 DIV4_I, DIV4_ZG, DIV4_B, DIV4_M1, DIV4_HP,
318 DIV4_HPP, DIV4_USBP, DIV4_S, DIV4_ZB, DIV4_M3, DIV4_CP, 433 DIV4_HPP, DIV4_USBP, DIV4_S, DIV4_ZB, DIV4_M3, DIV4_CP,
@@ -343,11 +458,12 @@ static struct clk div6_clks[DIV6_NR] = {
343}; 458};
344 459
345enum { 460enum {
346 MSTP125, 461 MSTP128, MSTP127, MSTP125,
347 MSTP116, MSTP111, MSTP100, MSTP117, 462 MSTP116, MSTP111, MSTP100, MSTP117,
348 463
349 MSTP230, 464 MSTP230,
350 MSTP222, 465 MSTP222,
466 MSTP218, MSTP217, MSTP216, MSTP214,
351 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200, 467 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200,
352 468
353 MSTP329, MSTP328, MSTP323, MSTP320, 469 MSTP329, MSTP328, MSTP323, MSTP320,
@@ -360,6 +476,8 @@ enum {
360}; 476};
361 477
362static struct clk mstp_clks[MSTP_NR] = { 478static struct clk mstp_clks[MSTP_NR] = {
479 [MSTP128] = SH_CLK_MSTP32(&div4_clks[DIV4_S], SMSTPCR1, 28, 0), /* CEU21 */
480 [MSTP127] = SH_CLK_MSTP32(&div4_clks[DIV4_S], SMSTPCR1, 27, 0), /* CEU20 */
363 [MSTP125] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR1, 25, 0), /* TMU0 */ 481 [MSTP125] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR1, 25, 0), /* TMU0 */
364 [MSTP117] = SH_CLK_MSTP32(&div4_clks[DIV4_B], SMSTPCR1, 17, 0), /* LCDC1 */ 482 [MSTP117] = SH_CLK_MSTP32(&div4_clks[DIV4_B], SMSTPCR1, 17, 0), /* LCDC1 */
365 [MSTP116] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR1, 16, 0), /* IIC0 */ 483 [MSTP116] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR1, 16, 0), /* IIC0 */
@@ -368,6 +486,10 @@ static struct clk mstp_clks[MSTP_NR] = {
368 486
369 [MSTP230] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 30, 0), /* SCIFA6 */ 487 [MSTP230] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 30, 0), /* SCIFA6 */
370 [MSTP222] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 22, 0), /* SCIFA7 */ 488 [MSTP222] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 22, 0), /* SCIFA7 */
489 [MSTP218] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 18, 0), /* DMAC1 */
490 [MSTP217] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 17, 0), /* DMAC2 */
491 [MSTP216] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 16, 0), /* DMAC3 */
492 [MSTP214] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 14, 0), /* USBDMAC */
371 [MSTP207] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 7, 0), /* SCIFA5 */ 493 [MSTP207] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 7, 0), /* SCIFA5 */
372 [MSTP206] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 6, 0), /* SCIFB */ 494 [MSTP206] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 6, 0), /* SCIFB */
373 [MSTP204] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 4, 0), /* SCIFA0 */ 495 [MSTP204] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 4, 0), /* SCIFA0 */
@@ -408,6 +530,12 @@ static struct clk_lookup lookups[] = {
408 CLKDEV_CON_ID("pllc1_clk", &pllc1_clk), 530 CLKDEV_CON_ID("pllc1_clk", &pllc1_clk),
409 CLKDEV_CON_ID("pllc1_div2_clk", &pllc1_div2_clk), 531 CLKDEV_CON_ID("pllc1_div2_clk", &pllc1_div2_clk),
410 CLKDEV_CON_ID("usb24s", &usb24s_clk), 532 CLKDEV_CON_ID("usb24s", &usb24s_clk),
533 CLKDEV_CON_ID("hdmi1", &hdmi1_clk),
534 CLKDEV_CON_ID("hdmi2", &hdmi2_clk),
535 CLKDEV_CON_ID("video1", &div6_reparent_clks[DIV6_VCLK1]),
536 CLKDEV_CON_ID("video2", &div6_reparent_clks[DIV6_VCLK2]),
537 CLKDEV_CON_ID("fsiack", &fsiack_clk),
538 CLKDEV_CON_ID("fsibck", &fsibck_clk),
411 539
412 /* DIV4 clocks */ 540 /* DIV4 clocks */
413 CLKDEV_CON_ID("i_clk", &div4_clks[DIV4_I]), 541 CLKDEV_CON_ID("i_clk", &div4_clks[DIV4_I]),
@@ -430,6 +558,8 @@ static struct clk_lookup lookups[] = {
430 CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), 558 CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]),
431 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.1", &mstp_clks[MSTP117]), 559 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.1", &mstp_clks[MSTP117]),
432 CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]), 560 CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]),
561 CLKDEV_DEV_ID("sh_mobile_ceu.0", &mstp_clks[MSTP127]),
562 CLKDEV_DEV_ID("sh_mobile_ceu.1", &mstp_clks[MSTP128]),
433 563
434 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]), 564 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]),
435 CLKDEV_DEV_ID("sh-sci.3", &mstp_clks[MSTP201]), 565 CLKDEV_DEV_ID("sh-sci.3", &mstp_clks[MSTP201]),
@@ -438,7 +568,10 @@ static struct clk_lookup lookups[] = {
438 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]), 568 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]),
439 CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP206]), 569 CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP206]),
440 CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP207]), 570 CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP207]),
441 571 CLKDEV_DEV_ID("sh-dma-engine.3", &mstp_clks[MSTP214]),
572 CLKDEV_DEV_ID("sh-dma-engine.2", &mstp_clks[MSTP216]),
573 CLKDEV_DEV_ID("sh-dma-engine.1", &mstp_clks[MSTP217]),
574 CLKDEV_DEV_ID("sh-dma-engine.0", &mstp_clks[MSTP218]),
442 CLKDEV_DEV_ID("sh-sci.7", &mstp_clks[MSTP222]), 575 CLKDEV_DEV_ID("sh-sci.7", &mstp_clks[MSTP222]),
443 CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP230]), 576 CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP230]),
444 577
@@ -459,6 +592,10 @@ static struct clk_lookup lookups[] = {
459 CLKDEV_ICK_ID("phy", "renesas_usbhs", &mstp_clks[MSTP406]), 592 CLKDEV_ICK_ID("phy", "renesas_usbhs", &mstp_clks[MSTP406]),
460 CLKDEV_ICK_ID("pci", "renesas_usbhs", &div4_clks[DIV4_USBP]), 593 CLKDEV_ICK_ID("pci", "renesas_usbhs", &div4_clks[DIV4_USBP]),
461 CLKDEV_ICK_ID("usb24", "renesas_usbhs", &usb24_clk), 594 CLKDEV_ICK_ID("usb24", "renesas_usbhs", &usb24_clk),
595 CLKDEV_ICK_ID("ick", "sh-mobile-hdmi", &div6_reparent_clks[DIV6_HDMI]),
596
597 CLKDEV_ICK_ID("icka", "sh_fsi2", &div6_reparent_clks[DIV6_FSIA]),
598 CLKDEV_ICK_ID("ickb", "sh_fsi2", &div6_reparent_clks[DIV6_FSIB]),
462}; 599};
463 600
464void __init r8a7740_clock_init(u8 md_ck) 601void __init r8a7740_clock_init(u8 md_ck)
@@ -495,7 +632,14 @@ void __init r8a7740_clock_init(u8 md_ck)
495 ret = sh_clk_div6_register(div6_clks, DIV6_NR); 632 ret = sh_clk_div6_register(div6_clks, DIV6_NR);
496 633
497 if (!ret) 634 if (!ret)
498 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR); 635 ret = sh_clk_div6_reparent_register(div6_reparent_clks,
636 DIV6_REPARENT_NR);
637
638 if (!ret)
639 ret = sh_clk_mstp_register(mstp_clks, MSTP_NR);
640
641 for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++)
642 ret = clk_register(late_main_clks[k]);
499 643
500 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 644 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
501 645
diff --git a/arch/arm/mach-shmobile/clock-r8a7779.c b/arch/arm/mach-shmobile/clock-r8a7779.c
index 7d6e9fe47b5..339c62c824d 100644
--- a/arch/arm/mach-shmobile/clock-r8a7779.c
+++ b/arch/arm/mach-shmobile/clock-r8a7779.c
@@ -162,7 +162,7 @@ void __init r8a7779_clock_init(void)
162 ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table); 162 ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table);
163 163
164 if (!ret) 164 if (!ret)
165 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR); 165 ret = sh_clk_mstp_register(mstp_clks, MSTP_NR);
166 166
167 for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++) 167 for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++)
168 ret = clk_register(late_main_clks[k]); 168 ret = clk_register(late_main_clks[k]);
diff --git a/arch/arm/mach-shmobile/clock-sh7367.c b/arch/arm/mach-shmobile/clock-sh7367.c
index 006e7b5d304..162b791b898 100644
--- a/arch/arm/mach-shmobile/clock-sh7367.c
+++ b/arch/arm/mach-shmobile/clock-sh7367.c
@@ -344,7 +344,7 @@ void __init sh7367_clock_init(void)
344 ret = sh_clk_div6_register(div6_clks, DIV6_NR); 344 ret = sh_clk_div6_register(div6_clks, DIV6_NR);
345 345
346 if (!ret) 346 if (!ret)
347 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR); 347 ret = sh_clk_mstp_register(mstp_clks, MSTP_NR);
348 348
349 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 349 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
350 350
diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c
index 94d1f88246d..5a2894b1c96 100644
--- a/arch/arm/mach-shmobile/clock-sh7372.c
+++ b/arch/arm/mach-shmobile/clock-sh7372.c
@@ -704,7 +704,7 @@ void __init sh7372_clock_init(void)
704 ret = sh_clk_div6_reparent_register(div6_reparent_clks, DIV6_REPARENT_NR); 704 ret = sh_clk_div6_reparent_register(div6_reparent_clks, DIV6_REPARENT_NR);
705 705
706 if (!ret) 706 if (!ret)
707 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR); 707 ret = sh_clk_mstp_register(mstp_clks, MSTP_NR);
708 708
709 for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++) 709 for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++)
710 ret = clk_register(late_main_clks[k]); 710 ret = clk_register(late_main_clks[k]);
diff --git a/arch/arm/mach-shmobile/clock-sh7377.c b/arch/arm/mach-shmobile/clock-sh7377.c
index 0798a15936c..85f2a3ec2c4 100644
--- a/arch/arm/mach-shmobile/clock-sh7377.c
+++ b/arch/arm/mach-shmobile/clock-sh7377.c
@@ -355,7 +355,7 @@ void __init sh7377_clock_init(void)
355 ret = sh_clk_div6_register(div6_clks, DIV6_NR); 355 ret = sh_clk_div6_register(div6_clks, DIV6_NR);
356 356
357 if (!ret) 357 if (!ret)
358 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR); 358 ret = sh_clk_mstp_register(mstp_clks, MSTP_NR);
359 359
360 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 360 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
361 361
diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c
index 3946c4ba2aa..7f8da18a858 100644
--- a/arch/arm/mach-shmobile/clock-sh73a0.c
+++ b/arch/arm/mach-shmobile/clock-sh73a0.c
@@ -475,9 +475,9 @@ static struct clk *late_main_clks[] = {
475 475
476enum { MSTP001, 476enum { MSTP001,
477 MSTP129, MSTP128, MSTP127, MSTP126, MSTP125, MSTP118, MSTP116, MSTP100, 477 MSTP129, MSTP128, MSTP127, MSTP126, MSTP125, MSTP118, MSTP116, MSTP100,
478 MSTP219, MSTP218, 478 MSTP219, MSTP218, MSTP217,
479 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200, 479 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200,
480 MSTP331, MSTP329, MSTP325, MSTP323, 480 MSTP331, MSTP329, MSTP328, MSTP325, MSTP323, MSTP322,
481 MSTP314, MSTP313, MSTP312, MSTP311, 481 MSTP314, MSTP313, MSTP312, MSTP311,
482 MSTP303, MSTP302, MSTP301, MSTP300, 482 MSTP303, MSTP302, MSTP301, MSTP300,
483 MSTP411, MSTP410, MSTP403, 483 MSTP411, MSTP410, MSTP403,
@@ -498,6 +498,7 @@ static struct clk mstp_clks[MSTP_NR] = {
498 [MSTP100] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 0, 0), /* LCDC0 */ 498 [MSTP100] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 0, 0), /* LCDC0 */
499 [MSTP219] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 19, 0), /* SCIFA7 */ 499 [MSTP219] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 19, 0), /* SCIFA7 */
500 [MSTP218] = MSTP(&div4_clks[DIV4_HP], SMSTPCR2, 18, 0), /* SY-DMAC */ 500 [MSTP218] = MSTP(&div4_clks[DIV4_HP], SMSTPCR2, 18, 0), /* SY-DMAC */
501 [MSTP217] = MSTP(&div4_clks[DIV4_HP], SMSTPCR2, 17, 0), /* MP-DMAC */
501 [MSTP207] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 7, 0), /* SCIFA5 */ 502 [MSTP207] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 7, 0), /* SCIFA5 */
502 [MSTP206] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 6, 0), /* SCIFB */ 503 [MSTP206] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 6, 0), /* SCIFB */
503 [MSTP204] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 4, 0), /* SCIFA0 */ 504 [MSTP204] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 4, 0), /* SCIFA0 */
@@ -507,8 +508,10 @@ static struct clk mstp_clks[MSTP_NR] = {
507 [MSTP200] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 0, 0), /* SCIFA4 */ 508 [MSTP200] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 0, 0), /* SCIFA4 */
508 [MSTP331] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR3, 31, 0), /* SCIFA6 */ 509 [MSTP331] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR3, 31, 0), /* SCIFA6 */
509 [MSTP329] = MSTP(&r_clk, SMSTPCR3, 29, 0), /* CMT10 */ 510 [MSTP329] = MSTP(&r_clk, SMSTPCR3, 29, 0), /* CMT10 */
511 [MSTP328] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 28, 0), /*FSI*/
510 [MSTP325] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR3, 25, 0), /* IrDA */ 512 [MSTP325] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR3, 25, 0), /* IrDA */
511 [MSTP323] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 23, 0), /* IIC1 */ 513 [MSTP323] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 23, 0), /* IIC1 */
514 [MSTP322] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 22, 0), /* USB */
512 [MSTP314] = MSTP(&div6_clks[DIV6_SDHI0], SMSTPCR3, 14, 0), /* SDHI0 */ 515 [MSTP314] = MSTP(&div6_clks[DIV6_SDHI0], SMSTPCR3, 14, 0), /* SDHI0 */
513 [MSTP313] = MSTP(&div6_clks[DIV6_SDHI1], SMSTPCR3, 13, 0), /* SDHI1 */ 516 [MSTP313] = MSTP(&div6_clks[DIV6_SDHI1], SMSTPCR3, 13, 0), /* SDHI1 */
514 [MSTP312] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 12, 0), /* MMCIF0 */ 517 [MSTP312] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 12, 0), /* MMCIF0 */
@@ -553,6 +556,7 @@ static struct clk_lookup lookups[] = {
553 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.0", &mstp_clks[MSTP100]), /* LCDC0 */ 556 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.0", &mstp_clks[MSTP100]), /* LCDC0 */
554 CLKDEV_DEV_ID("sh-sci.7", &mstp_clks[MSTP219]), /* SCIFA7 */ 557 CLKDEV_DEV_ID("sh-sci.7", &mstp_clks[MSTP219]), /* SCIFA7 */
555 CLKDEV_DEV_ID("sh-dma-engine.0", &mstp_clks[MSTP218]), /* SY-DMAC */ 558 CLKDEV_DEV_ID("sh-dma-engine.0", &mstp_clks[MSTP218]), /* SY-DMAC */
559 CLKDEV_DEV_ID("sh-dma-engine.1", &mstp_clks[MSTP217]), /* MP-DMAC */
556 CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP207]), /* SCIFA5 */ 560 CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP207]), /* SCIFA5 */
557 CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP206]), /* SCIFB */ 561 CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP206]), /* SCIFB */
558 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]), /* SCIFA0 */ 562 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]), /* SCIFA0 */
@@ -562,8 +566,10 @@ static struct clk_lookup lookups[] = {
562 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]), /* SCIFA4 */ 566 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]), /* SCIFA4 */
563 CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP331]), /* SCIFA6 */ 567 CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP331]), /* SCIFA6 */
564 CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), /* CMT10 */ 568 CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), /* CMT10 */
569 CLKDEV_DEV_ID("sh_fsi2", &mstp_clks[MSTP328]), /* FSI */
565 CLKDEV_DEV_ID("sh_irda.0", &mstp_clks[MSTP325]), /* IrDA */ 570 CLKDEV_DEV_ID("sh_irda.0", &mstp_clks[MSTP325]), /* IrDA */
566 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]), /* I2C1 */ 571 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]), /* I2C1 */
572 CLKDEV_DEV_ID("renesas_usbhs", &mstp_clks[MSTP322]), /* USB */
567 CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP314]), /* SDHI0 */ 573 CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP314]), /* SDHI0 */
568 CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP313]), /* SDHI1 */ 574 CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP313]), /* SDHI1 */
569 CLKDEV_DEV_ID("sh_mmcif.0", &mstp_clks[MSTP312]), /* MMCIF0 */ 575 CLKDEV_DEV_ID("sh_mmcif.0", &mstp_clks[MSTP312]), /* MMCIF0 */
@@ -612,7 +618,7 @@ void __init sh73a0_clock_init(void)
612 ret = sh_clk_div6_reparent_register(div6_clks, DIV6_NR); 618 ret = sh_clk_div6_reparent_register(div6_clks, DIV6_NR);
613 619
614 if (!ret) 620 if (!ret)
615 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR); 621 ret = sh_clk_mstp_register(mstp_clks, MSTP_NR);
616 622
617 for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++) 623 for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++)
618 ret = clk_register(late_main_clks[k]); 624 ret = clk_register(late_main_clks[k]);
diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
index 01e2bc014f1..45e61dada03 100644
--- a/arch/arm/mach-shmobile/include/mach/common.h
+++ b/arch/arm/mach-shmobile/include/mach/common.h
@@ -77,6 +77,7 @@ extern void r8a7779_add_standard_devices(void);
77extern void r8a7779_clock_init(void); 77extern void r8a7779_clock_init(void);
78extern void r8a7779_pinmux_init(void); 78extern void r8a7779_pinmux_init(void);
79extern void r8a7779_pm_init(void); 79extern void r8a7779_pm_init(void);
80extern void r8a7740_meram_workaround(void);
80 81
81extern unsigned int r8a7779_get_core_count(void); 82extern unsigned int r8a7779_get_core_count(void);
82extern int r8a7779_platform_cpu_kill(unsigned int cpu); 83extern int r8a7779_platform_cpu_kill(unsigned int cpu);
diff --git a/arch/arm/mach-shmobile/include/mach/dma-register.h b/arch/arm/mach-shmobile/include/mach/dma-register.h
new file mode 100644
index 00000000000..97c40bd9b94
--- /dev/null
+++ b/arch/arm/mach-shmobile/include/mach/dma-register.h
@@ -0,0 +1,84 @@
1/*
2 * SH-ARM CPU-specific DMA definitions, used by both DMA drivers
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp
5 *
6 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
7 *
8 * Based on arch/sh/include/cpu-sh4/cpu/dma-register.h
9 * Copyright (C) 2010 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#ifndef DMA_REGISTER_H
17#define DMA_REGISTER_H
18
19/*
20 * Direct Memory Access Controller
21 */
22
23/* Transmit sizes and respective CHCR register values */
24enum {
25 XMIT_SZ_8BIT = 0,
26 XMIT_SZ_16BIT = 1,
27 XMIT_SZ_32BIT = 2,
28 XMIT_SZ_64BIT = 7,
29 XMIT_SZ_128BIT = 3,
30 XMIT_SZ_256BIT = 4,
31 XMIT_SZ_512BIT = 5,
32};
33
34/* log2(size / 8) - used to calculate number of transfers */
35static const unsigned int dma_ts_shift[] = {
36 [XMIT_SZ_8BIT] = 0,
37 [XMIT_SZ_16BIT] = 1,
38 [XMIT_SZ_32BIT] = 2,
39 [XMIT_SZ_64BIT] = 3,
40 [XMIT_SZ_128BIT] = 4,
41 [XMIT_SZ_256BIT] = 5,
42 [XMIT_SZ_512BIT] = 6,
43};
44
45#define TS_LOW_BIT 0x3 /* --xx */
46#define TS_HI_BIT 0xc /* xx-- */
47
48#define TS_LOW_SHIFT (3)
49#define TS_HI_SHIFT (20 - 2) /* 2 bits for shifted low TS */
50
51#define TS_INDEX2VAL(i) \
52 ((((i) & TS_LOW_BIT) << TS_LOW_SHIFT) |\
53 (((i) & TS_HI_BIT) << TS_HI_SHIFT))
54
55#define CHCR_TX(xmit_sz) (DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL((xmit_sz)))
56#define CHCR_RX(xmit_sz) (DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL((xmit_sz)))
57
58
59/*
60 * USB High-Speed DMAC
61 */
62/* Transmit sizes and respective CHCR register values */
63enum {
64 USBTS_XMIT_SZ_8BYTE = 0,
65 USBTS_XMIT_SZ_16BYTE = 1,
66 USBTS_XMIT_SZ_32BYTE = 2,
67};
68
69/* log2(size / 8) - used to calculate number of transfers */
70static const unsigned int dma_usbts_shift[] = {
71 [USBTS_XMIT_SZ_8BYTE] = 3,
72 [USBTS_XMIT_SZ_16BYTE] = 4,
73 [USBTS_XMIT_SZ_32BYTE] = 5,
74};
75
76#define USBTS_LOW_BIT 0x3 /* --xx */
77#define USBTS_HI_BIT 0x0 /* ---- */
78
79#define USBTS_LOW_SHIFT 6
80#define USBTS_HI_SHIFT 0
81
82#define USBTS_INDEX2VAL(i) (((i) & 3) << 6)
83
84#endif /* DMA_REGISTER_H */
diff --git a/arch/arm/mach-shmobile/include/mach/gpio.h b/arch/arm/mach-shmobile/include/mach/gpio.h
index de795b42232..844507d937c 100644
--- a/arch/arm/mach-shmobile/include/mach/gpio.h
+++ b/arch/arm/mach-shmobile/include/mach/gpio.h
@@ -13,6 +13,7 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/sh_pfc.h> 15#include <linux/sh_pfc.h>
16#include <linux/io.h>
16 17
17#ifdef CONFIG_GPIOLIB 18#ifdef CONFIG_GPIOLIB
18 19
@@ -27,4 +28,35 @@ static inline int irq_to_gpio(unsigned int irq)
27 28
28#endif /* CONFIG_GPIOLIB */ 29#endif /* CONFIG_GPIOLIB */
29 30
31/*
32 * FIXME !!
33 *
34 * current gpio frame work doesn't have
35 * the method to control only pull up/down/free.
36 * this function should be replaced by correct gpio function
37 */
38static inline void __init gpio_direction_none(u32 addr)
39{
40 __raw_writeb(0x00, addr);
41}
42
43static inline void __init gpio_request_pullup(u32 addr)
44{
45 u8 data = __raw_readb(addr);
46
47 data &= 0x0F;
48 data |= 0xC0;
49 __raw_writeb(data, addr);
50}
51
52static inline void __init gpio_request_pulldown(u32 addr)
53{
54 u8 data = __raw_readb(addr);
55
56 data &= 0x0F;
57 data |= 0xA0;
58
59 __raw_writeb(data, addr);
60}
61
30#endif /* __ASM_ARCH_GPIO_H */ 62#endif /* __ASM_ARCH_GPIO_H */
diff --git a/arch/arm/mach-shmobile/include/mach/pm-rmobile.h b/arch/arm/mach-shmobile/include/mach/pm-rmobile.h
new file mode 100644
index 00000000000..5a402840fe2
--- /dev/null
+++ b/arch/arm/mach-shmobile/include/mach/pm-rmobile.h
@@ -0,0 +1,44 @@
1/*
2 * Copyright (C) 2012 Renesas Solutions Corp.
3 *
4 * Kuninori Morimoto <morimoto.kuninori@renesas.com>
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#ifndef PM_RMOBILE_H
11#define PM_RMOBILE_H
12
13#include <linux/pm_domain.h>
14
15struct platform_device;
16
17struct rmobile_pm_domain {
18 struct generic_pm_domain genpd;
19 struct dev_power_governor *gov;
20 int (*suspend)(void);
21 void (*resume)(void);
22 unsigned int bit_shift;
23 bool no_debug;
24};
25
26static inline
27struct rmobile_pm_domain *to_rmobile_pd(struct generic_pm_domain *d)
28{
29 return container_of(d, struct rmobile_pm_domain, genpd);
30}
31
32#ifdef CONFIG_PM
33extern void rmobile_init_pm_domain(struct rmobile_pm_domain *rmobile_pd);
34extern void rmobile_add_device_to_domain(struct rmobile_pm_domain *rmobile_pd,
35 struct platform_device *pdev);
36extern void rmobile_pm_add_subdomain(struct rmobile_pm_domain *rmobile_pd,
37 struct rmobile_pm_domain *rmobile_sd);
38#else
39#define rmobile_init_pm_domain(pd) do { } while (0)
40#define rmobile_add_device_to_domain(pd, pdev) do { } while (0)
41#define rmobile_pm_add_subdomain(pd, sd) do { } while (0)
42#endif /* CONFIG_PM */
43
44#endif /* PM_RMOBILE_H */
diff --git a/arch/arm/mach-shmobile/include/mach/r8a7740.h b/arch/arm/mach-shmobile/include/mach/r8a7740.h
index 9d447abb969..7143147780d 100644
--- a/arch/arm/mach-shmobile/include/mach/r8a7740.h
+++ b/arch/arm/mach-shmobile/include/mach/r8a7740.h
@@ -19,6 +19,8 @@
19#ifndef __ASM_R8A7740_H__ 19#ifndef __ASM_R8A7740_H__
20#define __ASM_R8A7740_H__ 20#define __ASM_R8A7740_H__
21 21
22#include <mach/pm-rmobile.h>
23
22/* 24/*
23 * MD_CKx pin 25 * MD_CKx pin
24 */ 26 */
@@ -139,7 +141,7 @@ enum {
139 GPIO_FN_DBGMD10, GPIO_FN_DBGMD11, GPIO_FN_DBGMD20, 141 GPIO_FN_DBGMD10, GPIO_FN_DBGMD11, GPIO_FN_DBGMD20,
140 GPIO_FN_DBGMD21, 142 GPIO_FN_DBGMD21,
141 143
142 /* FSI */ 144 /* FSI-A */
143 GPIO_FN_FSIAISLD_PORT0, /* FSIAISLD Port 0/5 */ 145 GPIO_FN_FSIAISLD_PORT0, /* FSIAISLD Port 0/5 */
144 GPIO_FN_FSIAISLD_PORT5, 146 GPIO_FN_FSIAISLD_PORT5,
145 GPIO_FN_FSIASPDIF_PORT9, /* FSIASPDIF Port 9/18 */ 147 GPIO_FN_FSIASPDIF_PORT9, /* FSIASPDIF Port 9/18 */
@@ -150,6 +152,9 @@ enum {
150 GPIO_FN_FSIACK, GPIO_FN_FSIAILR, 152 GPIO_FN_FSIACK, GPIO_FN_FSIAILR,
151 GPIO_FN_FSIAIBT, 153 GPIO_FN_FSIAIBT,
152 154
155 /* FSI-B */
156 GPIO_FN_FSIBCK,
157
153 /* FMSI */ 158 /* FMSI */
154 GPIO_FN_FMSISLD_PORT1, /* FMSISLD Port 1/6 */ 159 GPIO_FN_FMSISLD_PORT1, /* FMSISLD Port 1/6 */
155 GPIO_FN_FMSISLD_PORT6, 160 GPIO_FN_FMSISLD_PORT6,
@@ -565,6 +570,10 @@ enum {
565 GPIO_FN_RESETP_PULLUP, 570 GPIO_FN_RESETP_PULLUP,
566 GPIO_FN_RESETP_PLAIN, 571 GPIO_FN_RESETP_PLAIN,
567 572
573 /* HDMI */
574 GPIO_FN_HDMI_HPD,
575 GPIO_FN_HDMI_CEC,
576
568 /* SDENC */ 577 /* SDENC */
569 GPIO_FN_SDENC_CPG, 578 GPIO_FN_SDENC_CPG,
570 GPIO_FN_SDENC_DV_CLKI, 579 GPIO_FN_SDENC_DV_CLKI,
@@ -581,4 +590,26 @@ enum {
581 GPIO_FN_TRACEAUD_FROM_MEMC, 590 GPIO_FN_TRACEAUD_FROM_MEMC,
582}; 591};
583 592
593/* DMA slave IDs */
594enum {
595 SHDMA_SLAVE_INVALID,
596 SHDMA_SLAVE_SDHI0_RX,
597 SHDMA_SLAVE_SDHI0_TX,
598 SHDMA_SLAVE_SDHI1_RX,
599 SHDMA_SLAVE_SDHI1_TX,
600 SHDMA_SLAVE_SDHI2_RX,
601 SHDMA_SLAVE_SDHI2_TX,
602 SHDMA_SLAVE_FSIA_RX,
603 SHDMA_SLAVE_FSIA_TX,
604 SHDMA_SLAVE_FSIB_TX,
605 SHDMA_SLAVE_USBHS_TX,
606 SHDMA_SLAVE_USBHS_RX,
607};
608
609#ifdef CONFIG_PM
610extern struct rmobile_pm_domain r8a7740_pd_a4s;
611extern struct rmobile_pm_domain r8a7740_pd_a3sp;
612extern struct rmobile_pm_domain r8a7740_pd_a4lc;
613#endif /* CONFIG_PM */
614
584#endif /* __ASM_R8A7740_H__ */ 615#endif /* __ASM_R8A7740_H__ */
diff --git a/arch/arm/mach-shmobile/include/mach/sh7372.h b/arch/arm/mach-shmobile/include/mach/sh7372.h
index 915d0093da0..b59048e6d8f 100644
--- a/arch/arm/mach-shmobile/include/mach/sh7372.h
+++ b/arch/arm/mach-shmobile/include/mach/sh7372.h
@@ -13,6 +13,7 @@
13 13
14#include <linux/sh_clk.h> 14#include <linux/sh_clk.h>
15#include <linux/pm_domain.h> 15#include <linux/pm_domain.h>
16#include <mach/pm-rmobile.h>
16 17
17/* 18/*
18 * Pin Function Controller: 19 * Pin Function Controller:
@@ -477,42 +478,16 @@ extern struct clk sh7372_fsibck_clk;
477extern struct clk sh7372_fsidiva_clk; 478extern struct clk sh7372_fsidiva_clk;
478extern struct clk sh7372_fsidivb_clk; 479extern struct clk sh7372_fsidivb_clk;
479 480
480struct platform_device;
481
482struct sh7372_pm_domain {
483 struct generic_pm_domain genpd;
484 struct dev_power_governor *gov;
485 int (*suspend)(void);
486 void (*resume)(void);
487 unsigned int bit_shift;
488 bool no_debug;
489};
490
491static inline struct sh7372_pm_domain *to_sh7372_pd(struct generic_pm_domain *d)
492{
493 return container_of(d, struct sh7372_pm_domain, genpd);
494}
495
496#ifdef CONFIG_PM 481#ifdef CONFIG_PM
497extern struct sh7372_pm_domain sh7372_a4lc; 482extern struct rmobile_pm_domain sh7372_pd_a4lc;
498extern struct sh7372_pm_domain sh7372_a4mp; 483extern struct rmobile_pm_domain sh7372_pd_a4mp;
499extern struct sh7372_pm_domain sh7372_d4; 484extern struct rmobile_pm_domain sh7372_pd_d4;
500extern struct sh7372_pm_domain sh7372_a4r; 485extern struct rmobile_pm_domain sh7372_pd_a4r;
501extern struct sh7372_pm_domain sh7372_a3rv; 486extern struct rmobile_pm_domain sh7372_pd_a3rv;
502extern struct sh7372_pm_domain sh7372_a3ri; 487extern struct rmobile_pm_domain sh7372_pd_a3ri;
503extern struct sh7372_pm_domain sh7372_a4s; 488extern struct rmobile_pm_domain sh7372_pd_a4s;
504extern struct sh7372_pm_domain sh7372_a3sp; 489extern struct rmobile_pm_domain sh7372_pd_a3sp;
505extern struct sh7372_pm_domain sh7372_a3sg; 490extern struct rmobile_pm_domain sh7372_pd_a3sg;
506
507extern void sh7372_init_pm_domain(struct sh7372_pm_domain *sh7372_pd);
508extern void sh7372_add_device_to_domain(struct sh7372_pm_domain *sh7372_pd,
509 struct platform_device *pdev);
510extern void sh7372_pm_add_subdomain(struct sh7372_pm_domain *sh7372_pd,
511 struct sh7372_pm_domain *sh7372_sd);
512#else
513#define sh7372_init_pm_domain(pd) do { } while(0)
514#define sh7372_add_device_to_domain(pd, pdev) do { } while(0)
515#define sh7372_pm_add_subdomain(pd, sd) do { } while(0)
516#endif /* CONFIG_PM */ 491#endif /* CONFIG_PM */
517 492
518extern void sh7372_intcs_suspend(void); 493extern void sh7372_intcs_suspend(void);
diff --git a/arch/arm/mach-shmobile/include/mach/sh73a0.h b/arch/arm/mach-shmobile/include/mach/sh73a0.h
index 398e2c10913..fe950f25d79 100644
--- a/arch/arm/mach-shmobile/include/mach/sh73a0.h
+++ b/arch/arm/mach-shmobile/include/mach/sh73a0.h
@@ -516,6 +516,13 @@ enum {
516 SHDMA_SLAVE_SDHI2_RX, 516 SHDMA_SLAVE_SDHI2_RX,
517 SHDMA_SLAVE_MMCIF_TX, 517 SHDMA_SLAVE_MMCIF_TX,
518 SHDMA_SLAVE_MMCIF_RX, 518 SHDMA_SLAVE_MMCIF_RX,
519 SHDMA_SLAVE_FSI2A_TX,
520 SHDMA_SLAVE_FSI2A_RX,
521 SHDMA_SLAVE_FSI2B_TX,
522 SHDMA_SLAVE_FSI2B_RX,
523 SHDMA_SLAVE_FSI2C_TX,
524 SHDMA_SLAVE_FSI2C_RX,
525 SHDMA_SLAVE_FSI2D_RX,
519}; 526};
520 527
521/* 528/*
diff --git a/arch/arm/mach-shmobile/intc-r8a7740.c b/arch/arm/mach-shmobile/intc-r8a7740.c
index 09c42afcb22..9a69a31918b 100644
--- a/arch/arm/mach-shmobile/intc-r8a7740.c
+++ b/arch/arm/mach-shmobile/intc-r8a7740.c
@@ -71,10 +71,12 @@ enum {
71 DMAC3_1_DEI0, DMAC3_1_DEI1, DMAC3_1_DEI2, DMAC3_1_DEI3, 71 DMAC3_1_DEI0, DMAC3_1_DEI1, DMAC3_1_DEI2, DMAC3_1_DEI3,
72 DMAC3_2_DEI4, DMAC3_2_DEI5, DMAC3_2_DADERR, 72 DMAC3_2_DEI4, DMAC3_2_DEI5, DMAC3_2_DADERR,
73 SHWYSTAT_RT, SHWYSTAT_HS, SHWYSTAT_COM, 73 SHWYSTAT_RT, SHWYSTAT_HS, SHWYSTAT_COM,
74 HDMI,
74 USBH_INT, USBH_OHCI, USBH_EHCI, USBH_PME, USBH_BIND, 75 USBH_INT, USBH_OHCI, USBH_EHCI, USBH_PME, USBH_BIND,
75 RSPI_OVRF, RSPI_SPTEF, RSPI_SPRF, 76 RSPI_OVRF, RSPI_SPTEF, RSPI_SPRF,
76 SPU2_0, SPU2_1, 77 SPU2_0, SPU2_1,
77 FSI, FMSI, 78 FSI, FMSI,
79 HDMI_SSS, HDMI_KEY,
78 IPMMU, 80 IPMMU,
79 AP_ARM_CTIIRQ, AP_ARM_PMURQ, 81 AP_ARM_CTIIRQ, AP_ARM_PMURQ,
80 MFIS2, 82 MFIS2,
@@ -182,6 +184,7 @@ static struct intc_vect intca_vectors[] __initdata = {
182 INTC_VECT(USBH_EHCI, 0x1580), 184 INTC_VECT(USBH_EHCI, 0x1580),
183 INTC_VECT(USBH_PME, 0x15A0), 185 INTC_VECT(USBH_PME, 0x15A0),
184 INTC_VECT(USBH_BIND, 0x15C0), 186 INTC_VECT(USBH_BIND, 0x15C0),
187 INTC_VECT(HDMI, 0x1700),
185 INTC_VECT(RSPI_OVRF, 0x1780), 188 INTC_VECT(RSPI_OVRF, 0x1780),
186 INTC_VECT(RSPI_SPTEF, 0x17A0), 189 INTC_VECT(RSPI_SPTEF, 0x17A0),
187 INTC_VECT(RSPI_SPRF, 0x17C0), 190 INTC_VECT(RSPI_SPRF, 0x17C0),
@@ -189,6 +192,8 @@ static struct intc_vect intca_vectors[] __initdata = {
189 INTC_VECT(SPU2_1, 0x1820), 192 INTC_VECT(SPU2_1, 0x1820),
190 INTC_VECT(FSI, 0x1840), 193 INTC_VECT(FSI, 0x1840),
191 INTC_VECT(FMSI, 0x1860), 194 INTC_VECT(FMSI, 0x1860),
195 INTC_VECT(HDMI_SSS, 0x18A0),
196 INTC_VECT(HDMI_KEY, 0x18C0),
192 INTC_VECT(IPMMU, 0x1920), 197 INTC_VECT(IPMMU, 0x1920),
193 INTC_VECT(AP_ARM_CTIIRQ, 0x1980), 198 INTC_VECT(AP_ARM_CTIIRQ, 0x1980),
194 INTC_VECT(AP_ARM_PMURQ, 0x19A0), 199 INTC_VECT(AP_ARM_PMURQ, 0x19A0),
@@ -304,11 +309,11 @@ static struct intc_mask_reg intca_mask_registers[] __initdata = {
304 USBH_EHCI, USBH_PME, USBH_BIND, 0 } }, 309 USBH_EHCI, USBH_PME, USBH_BIND, 0 } },
305 /* IMR3A3 / IMCR3A3 */ 310 /* IMR3A3 / IMCR3A3 */
306 { /* IMR4A3 / IMCR4A3 */ 0xe6950090, 0xe69500d0, 8, 311 { /* IMR4A3 / IMCR4A3 */ 0xe6950090, 0xe69500d0, 8,
307 { 0, 0, 0, 0, 312 { HDMI, 0, 0, 0,
308 RSPI_OVRF, RSPI_SPTEF, RSPI_SPRF, 0 } }, 313 RSPI_OVRF, RSPI_SPTEF, RSPI_SPRF, 0 } },
309 { /* IMR5A3 / IMCR5A3 */ 0xe6950094, 0xe69500d4, 8, 314 { /* IMR5A3 / IMCR5A3 */ 0xe6950094, 0xe69500d4, 8,
310 { SPU2_0, SPU2_1, FSI, FMSI, 315 { SPU2_0, SPU2_1, FSI, FMSI,
311 0, 0, 0, 0 } }, 316 0, HDMI_SSS, HDMI_KEY, 0 } },
312 { /* IMR6A3 / IMCR6A3 */ 0xe6950098, 0xe69500d8, 8, 317 { /* IMR6A3 / IMCR6A3 */ 0xe6950098, 0xe69500d8, 8,
313 { 0, IPMMU, 0, 0, 318 { 0, IPMMU, 0, 0,
314 AP_ARM_CTIIRQ, AP_ARM_PMURQ, 0, 0 } }, 319 AP_ARM_CTIIRQ, AP_ARM_PMURQ, 0, 0 } },
@@ -353,10 +358,10 @@ static struct intc_prio_reg intca_prio_registers[] __initdata = {
353 { 0xe6950014, 0, 16, 4, /* IPRFA3 */ { USBH2, 0, 0, 0 } }, 358 { 0xe6950014, 0, 16, 4, /* IPRFA3 */ { USBH2, 0, 0, 0 } },
354 /* IPRGA3 */ 359 /* IPRGA3 */
355 /* IPRHA3 */ 360 /* IPRHA3 */
356 /* IPRIA3 */ 361 { 0xe6950020, 0, 16, 4, /* IPRIA3 */ { HDMI, 0, 0, 0 } },
357 { 0xe6950024, 0, 16, 4, /* IPRJA3 */ { RSPI, 0, 0, 0 } }, 362 { 0xe6950024, 0, 16, 4, /* IPRJA3 */ { RSPI, 0, 0, 0 } },
358 { 0xe6950028, 0, 16, 4, /* IPRKA3 */ { SPU2, 0, FSI, FMSI } }, 363 { 0xe6950028, 0, 16, 4, /* IPRKA3 */ { SPU2, 0, FSI, FMSI } },
359 /* IPRLA3 */ 364 { 0xe695002c, 0, 16, 4, /* IPRLA3 */ { 0, HDMI_SSS, HDMI_KEY, 0 } },
360 { 0xe6950030, 0, 16, 4, /* IPRMA3 */ { IPMMU, 0, 0, 0 } }, 365 { 0xe6950030, 0, 16, 4, /* IPRMA3 */ { IPMMU, 0, 0, 0 } },
361 { 0xe6950034, 0, 16, 4, /* IPRNA3 */ { AP_ARM2, 0, 0, 0 } }, 366 { 0xe6950034, 0, 16, 4, /* IPRNA3 */ { AP_ARM2, 0, 0, 0 } },
362 { 0xe6950038, 0, 16, 4, /* IPROA3 */ { MFIS2, CPORTR2S, 367 { 0xe6950038, 0, 16, 4, /* IPROA3 */ { MFIS2, CPORTR2S,
diff --git a/arch/arm/mach-shmobile/intc-sh73a0.c b/arch/arm/mach-shmobile/intc-sh73a0.c
index ee447404c85..588555a67d9 100644
--- a/arch/arm/mach-shmobile/intc-sh73a0.c
+++ b/arch/arm/mach-shmobile/intc-sh73a0.c
@@ -259,9 +259,9 @@ static int sh73a0_set_wake(struct irq_data *data, unsigned int on)
259 return 0; /* always allow wakeup */ 259 return 0; /* always allow wakeup */
260} 260}
261 261
262#define RELOC_BASE 0x1000 262#define RELOC_BASE 0x1200
263 263
264/* INTCA IRQ pins at INTCS + 0x1000 to make space for GIC+INTC handling */ 264/* INTCA IRQ pins at INTCS + RELOC_BASE to make space for GIC+INTC handling */
265#define INTCS_VECT_RELOC(n, vect) INTCS_VECT((n), (vect) + RELOC_BASE) 265#define INTCS_VECT_RELOC(n, vect) INTCS_VECT((n), (vect) + RELOC_BASE)
266 266
267INTC_IRQ_PINS_32(intca_irq_pins, 0xe6900000, 267INTC_IRQ_PINS_32(intca_irq_pins, 0xe6900000,
diff --git a/arch/arm/mach-shmobile/pfc-r8a7740.c b/arch/arm/mach-shmobile/pfc-r8a7740.c
index 670fe1869db..ce9e7fa5cc8 100644
--- a/arch/arm/mach-shmobile/pfc-r8a7740.c
+++ b/arch/arm/mach-shmobile/pfc-r8a7740.c
@@ -169,7 +169,7 @@ enum {
169 DBGMD10_MARK, DBGMD11_MARK, DBGMD20_MARK, 169 DBGMD10_MARK, DBGMD11_MARK, DBGMD20_MARK,
170 DBGMD21_MARK, 170 DBGMD21_MARK,
171 171
172 /* FSI */ 172 /* FSI-A */
173 FSIAISLD_PORT0_MARK, /* FSIAISLD Port 0/5 */ 173 FSIAISLD_PORT0_MARK, /* FSIAISLD Port 0/5 */
174 FSIAISLD_PORT5_MARK, 174 FSIAISLD_PORT5_MARK,
175 FSIASPDIF_PORT9_MARK, /* FSIASPDIF Port 9/18 */ 175 FSIASPDIF_PORT9_MARK, /* FSIASPDIF Port 9/18 */
@@ -178,6 +178,9 @@ enum {
178 FSIAOBT_MARK, FSIAOSLD_MARK, FSIAOMC_MARK, 178 FSIAOBT_MARK, FSIAOSLD_MARK, FSIAOMC_MARK,
179 FSIACK_MARK, FSIAILR_MARK, FSIAIBT_MARK, 179 FSIACK_MARK, FSIAILR_MARK, FSIAIBT_MARK,
180 180
181 /* FSI-B */
182 FSIBCK_MARK,
183
181 /* FMSI */ 184 /* FMSI */
182 FMSISLD_PORT1_MARK, /* FMSISLD Port 1/6 */ 185 FMSISLD_PORT1_MARK, /* FMSISLD Port 1/6 */
183 FMSISLD_PORT6_MARK, 186 FMSISLD_PORT6_MARK,
@@ -560,6 +563,9 @@ enum {
560 /* SDENC */ 563 /* SDENC */
561 SDENC_CPG_MARK, SDENC_DV_CLKI_MARK, 564 SDENC_CPG_MARK, SDENC_DV_CLKI_MARK,
562 565
566 /* HDMI */
567 HDMI_HPD_MARK, HDMI_CEC_MARK,
568
563 /* DEBUG */ 569 /* DEBUG */
564 EDEBGREQ_PULLUP_MARK, /* for JTAG */ 570 EDEBGREQ_PULLUP_MARK, /* for JTAG */
565 EDEBGREQ_PULLDOWN_MARK, 571 EDEBGREQ_PULLDOWN_MARK,
@@ -771,6 +777,7 @@ static pinmux_enum_t pinmux_data[] = {
771 777
772 /* Port11 */ 778 /* Port11 */
773 PINMUX_DATA(FSIACK_MARK, PORT11_FN1), 779 PINMUX_DATA(FSIACK_MARK, PORT11_FN1),
780 PINMUX_DATA(FSIBCK_MARK, PORT11_FN2),
774 PINMUX_DATA(IRQ2_PORT11_MARK, PORT11_FN0, MSEL1CR_2_0), 781 PINMUX_DATA(IRQ2_PORT11_MARK, PORT11_FN0, MSEL1CR_2_0),
775 782
776 /* Port12 */ 783 /* Port12 */
@@ -1254,7 +1261,7 @@ static pinmux_enum_t pinmux_data[] = {
1254 PINMUX_DATA(A21_MARK, PORT120_FN1), 1261 PINMUX_DATA(A21_MARK, PORT120_FN1),
1255 PINMUX_DATA(MSIOF0_RSYNC_MARK, PORT120_FN2), 1262 PINMUX_DATA(MSIOF0_RSYNC_MARK, PORT120_FN2),
1256 PINMUX_DATA(MSIOF1_TSYNC_PORT120_MARK, PORT120_FN3, MSEL4CR_10_0), 1263 PINMUX_DATA(MSIOF1_TSYNC_PORT120_MARK, PORT120_FN3, MSEL4CR_10_0),
1257 PINMUX_DATA(IRQ7_PORT120_MARK, PORT120_FN0, MSEL1CR_7_0), 1264 PINMUX_DATA(IRQ7_PORT120_MARK, PORT120_FN0, MSEL1CR_7_1),
1258 1265
1259 /* Port121 */ 1266 /* Port121 */
1260 PINMUX_DATA(A20_MARK, PORT121_FN1), 1267 PINMUX_DATA(A20_MARK, PORT121_FN1),
@@ -1616,13 +1623,15 @@ static pinmux_enum_t pinmux_data[] = {
1616 1623
1617 /* Port209 */ 1624 /* Port209 */
1618 PINMUX_DATA(VBUS_MARK, PORT209_FN1), 1625 PINMUX_DATA(VBUS_MARK, PORT209_FN1),
1619 PINMUX_DATA(IRQ7_PORT209_MARK, PORT209_FN0, MSEL1CR_7_1), 1626 PINMUX_DATA(IRQ7_PORT209_MARK, PORT209_FN0, MSEL1CR_7_0),
1620 1627
1621 /* Port210 */ 1628 /* Port210 */
1622 PINMUX_DATA(IRQ9_PORT210_MARK, PORT210_FN0, MSEL1CR_9_1), 1629 PINMUX_DATA(IRQ9_PORT210_MARK, PORT210_FN0, MSEL1CR_9_1),
1630 PINMUX_DATA(HDMI_HPD_MARK, PORT210_FN1),
1623 1631
1624 /* Port211 */ 1632 /* Port211 */
1625 PINMUX_DATA(IRQ16_PORT211_MARK, PORT211_FN0, MSEL1CR_16_1), 1633 PINMUX_DATA(IRQ16_PORT211_MARK, PORT211_FN0, MSEL1CR_16_1),
1634 PINMUX_DATA(HDMI_CEC_MARK, PORT211_FN1),
1626 1635
1627 /* LCDC select */ 1636 /* LCDC select */
1628 PINMUX_DATA(LCDC0_SELECT_MARK, MSEL3CR_6_0), 1637 PINMUX_DATA(LCDC0_SELECT_MARK, MSEL3CR_6_0),
@@ -1691,7 +1700,7 @@ static struct pinmux_gpio pinmux_gpios[] = {
1691 GPIO_FN(DBGMD10), GPIO_FN(DBGMD11), GPIO_FN(DBGMD20), 1700 GPIO_FN(DBGMD10), GPIO_FN(DBGMD11), GPIO_FN(DBGMD20),
1692 GPIO_FN(DBGMD21), 1701 GPIO_FN(DBGMD21),
1693 1702
1694 /* FSI */ 1703 /* FSI-A */
1695 GPIO_FN(FSIAISLD_PORT0), /* FSIAISLD Port 0/5 */ 1704 GPIO_FN(FSIAISLD_PORT0), /* FSIAISLD Port 0/5 */
1696 GPIO_FN(FSIAISLD_PORT5), 1705 GPIO_FN(FSIAISLD_PORT5),
1697 GPIO_FN(FSIASPDIF_PORT9), /* FSIASPDIF Port 9/18 */ 1706 GPIO_FN(FSIASPDIF_PORT9), /* FSIASPDIF Port 9/18 */
@@ -1700,6 +1709,9 @@ static struct pinmux_gpio pinmux_gpios[] = {
1700 GPIO_FN(FSIAOBT), GPIO_FN(FSIAOSLD), GPIO_FN(FSIAOMC), 1709 GPIO_FN(FSIAOBT), GPIO_FN(FSIAOSLD), GPIO_FN(FSIAOMC),
1701 GPIO_FN(FSIACK), GPIO_FN(FSIAILR), GPIO_FN(FSIAIBT), 1710 GPIO_FN(FSIACK), GPIO_FN(FSIAILR), GPIO_FN(FSIAIBT),
1702 1711
1712 /* FSI-B */
1713 GPIO_FN(FSIBCK),
1714
1703 /* FMSI */ 1715 /* FMSI */
1704 GPIO_FN(FMSISLD_PORT1), /* FMSISLD Port 1/6 */ 1716 GPIO_FN(FMSISLD_PORT1), /* FMSISLD Port 1/6 */
1705 GPIO_FN(FMSISLD_PORT6), 1717 GPIO_FN(FMSISLD_PORT6),
@@ -2097,6 +2109,10 @@ static struct pinmux_gpio pinmux_gpios[] = {
2097 GPIO_FN(SDENC_CPG), 2109 GPIO_FN(SDENC_CPG),
2098 GPIO_FN(SDENC_DV_CLKI), 2110 GPIO_FN(SDENC_DV_CLKI),
2099 2111
2112 /* HDMI */
2113 GPIO_FN(HDMI_HPD),
2114 GPIO_FN(HDMI_CEC),
2115
2100 /* SYSC */ 2116 /* SYSC */
2101 GPIO_FN(RESETP_PULLUP), 2117 GPIO_FN(RESETP_PULLUP),
2102 GPIO_FN(RESETP_PLAIN), 2118 GPIO_FN(RESETP_PLAIN),
diff --git a/arch/arm/mach-shmobile/pm-r8a7740.c b/arch/arm/mach-shmobile/pm-r8a7740.c
new file mode 100644
index 00000000000..893504d012a
--- /dev/null
+++ b/arch/arm/mach-shmobile/pm-r8a7740.c
@@ -0,0 +1,54 @@
1/*
2 * r8a7740 power management support
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp.
5 * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 */
11#include <linux/console.h>
12#include <mach/pm-rmobile.h>
13
14#ifdef CONFIG_PM
15static int r8a7740_pd_a4s_suspend(void)
16{
17 /*
18 * The A4S domain contains the CPU core and therefore it should
19 * only be turned off if the CPU is in use.
20 */
21 return -EBUSY;
22}
23
24struct rmobile_pm_domain r8a7740_pd_a4s = {
25 .genpd.name = "A4S",
26 .bit_shift = 10,
27 .gov = &pm_domain_always_on_gov,
28 .no_debug = true,
29 .suspend = r8a7740_pd_a4s_suspend,
30};
31
32static int r8a7740_pd_a3sp_suspend(void)
33{
34 /*
35 * Serial consoles make use of SCIF hardware located in A3SP,
36 * keep such power domain on if "no_console_suspend" is set.
37 */
38 return console_suspend_enabled ? 0 : -EBUSY;
39}
40
41struct rmobile_pm_domain r8a7740_pd_a3sp = {
42 .genpd.name = "A3SP",
43 .bit_shift = 11,
44 .gov = &pm_domain_always_on_gov,
45 .no_debug = true,
46 .suspend = r8a7740_pd_a3sp_suspend,
47};
48
49struct rmobile_pm_domain r8a7740_pd_a4lc = {
50 .genpd.name = "A4LC",
51 .bit_shift = 1,
52};
53
54#endif /* CONFIG_PM */
diff --git a/arch/arm/mach-shmobile/pm-rmobile.c b/arch/arm/mach-shmobile/pm-rmobile.c
new file mode 100644
index 00000000000..a8562540f1d
--- /dev/null
+++ b/arch/arm/mach-shmobile/pm-rmobile.c
@@ -0,0 +1,167 @@
1/*
2 * rmobile power management support
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp.
5 * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * based on pm-sh7372.c
8 * Copyright (C) 2011 Magnus Damm
9 *
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
12 * for more details.
13 */
14#include <linux/console.h>
15#include <linux/delay.h>
16#include <linux/platform_device.h>
17#include <linux/pm.h>
18#include <linux/pm_clock.h>
19#include <asm/io.h>
20#include <mach/pm-rmobile.h>
21
22/* SYSC */
23#define SPDCR 0xe6180008
24#define SWUCR 0xe6180014
25#define PSTR 0xe6180080
26
27#define PSTR_RETRIES 100
28#define PSTR_DELAY_US 10
29
30#ifdef CONFIG_PM
31static int rmobile_pd_power_down(struct generic_pm_domain *genpd)
32{
33 struct rmobile_pm_domain *rmobile_pd = to_rmobile_pd(genpd);
34 unsigned int mask = 1 << rmobile_pd->bit_shift;
35
36 if (rmobile_pd->suspend) {
37 int ret = rmobile_pd->suspend();
38
39 if (ret)
40 return ret;
41 }
42
43 if (__raw_readl(PSTR) & mask) {
44 unsigned int retry_count;
45 __raw_writel(mask, SPDCR);
46
47 for (retry_count = PSTR_RETRIES; retry_count; retry_count--) {
48 if (!(__raw_readl(SPDCR) & mask))
49 break;
50 cpu_relax();
51 }
52 }
53
54 if (!rmobile_pd->no_debug)
55 pr_debug("%s: Power off, 0x%08x -> PSTR = 0x%08x\n",
56 genpd->name, mask, __raw_readl(PSTR));
57
58 return 0;
59}
60
61static int __rmobile_pd_power_up(struct rmobile_pm_domain *rmobile_pd,
62 bool do_resume)
63{
64 unsigned int mask = 1 << rmobile_pd->bit_shift;
65 unsigned int retry_count;
66 int ret = 0;
67
68 if (__raw_readl(PSTR) & mask)
69 goto out;
70
71 __raw_writel(mask, SWUCR);
72
73 for (retry_count = 2 * PSTR_RETRIES; retry_count; retry_count--) {
74 if (!(__raw_readl(SWUCR) & mask))
75 break;
76 if (retry_count > PSTR_RETRIES)
77 udelay(PSTR_DELAY_US);
78 else
79 cpu_relax();
80 }
81 if (!retry_count)
82 ret = -EIO;
83
84 if (!rmobile_pd->no_debug)
85 pr_debug("%s: Power on, 0x%08x -> PSTR = 0x%08x\n",
86 rmobile_pd->genpd.name, mask, __raw_readl(PSTR));
87
88out:
89 if (ret == 0 && rmobile_pd->resume && do_resume)
90 rmobile_pd->resume();
91
92 return ret;
93}
94
95static int rmobile_pd_power_up(struct generic_pm_domain *genpd)
96{
97 return __rmobile_pd_power_up(to_rmobile_pd(genpd), true);
98}
99
100static bool rmobile_pd_active_wakeup(struct device *dev)
101{
102 bool (*active_wakeup)(struct device *dev);
103
104 active_wakeup = dev_gpd_data(dev)->ops.active_wakeup;
105 return active_wakeup ? active_wakeup(dev) : true;
106}
107
108static int rmobile_pd_stop_dev(struct device *dev)
109{
110 int (*stop)(struct device *dev);
111
112 stop = dev_gpd_data(dev)->ops.stop;
113 if (stop) {
114 int ret = stop(dev);
115 if (ret)
116 return ret;
117 }
118 return pm_clk_suspend(dev);
119}
120
121static int rmobile_pd_start_dev(struct device *dev)
122{
123 int (*start)(struct device *dev);
124 int ret;
125
126 ret = pm_clk_resume(dev);
127 if (ret)
128 return ret;
129
130 start = dev_gpd_data(dev)->ops.start;
131 if (start)
132 ret = start(dev);
133
134 return ret;
135}
136
137void rmobile_init_pm_domain(struct rmobile_pm_domain *rmobile_pd)
138{
139 struct generic_pm_domain *genpd = &rmobile_pd->genpd;
140 struct dev_power_governor *gov = rmobile_pd->gov;
141
142 pm_genpd_init(genpd, gov ? : &simple_qos_governor, false);
143 genpd->dev_ops.stop = rmobile_pd_stop_dev;
144 genpd->dev_ops.start = rmobile_pd_start_dev;
145 genpd->dev_ops.active_wakeup = rmobile_pd_active_wakeup;
146 genpd->dev_irq_safe = true;
147 genpd->power_off = rmobile_pd_power_down;
148 genpd->power_on = rmobile_pd_power_up;
149 __rmobile_pd_power_up(rmobile_pd, false);
150}
151
152void rmobile_add_device_to_domain(struct rmobile_pm_domain *rmobile_pd,
153 struct platform_device *pdev)
154{
155 struct device *dev = &pdev->dev;
156
157 pm_genpd_add_device(&rmobile_pd->genpd, dev);
158 if (pm_clk_no_clocks(dev))
159 pm_clk_add(dev, NULL);
160}
161
162void rmobile_pm_add_subdomain(struct rmobile_pm_domain *rmobile_pd,
163 struct rmobile_pm_domain *rmobile_sd)
164{
165 pm_genpd_add_subdomain(&rmobile_pd->genpd, &rmobile_sd->genpd);
166}
167#endif /* CONFIG_PM */
diff --git a/arch/arm/mach-shmobile/pm-sh7372.c b/arch/arm/mach-shmobile/pm-sh7372.c
index a3bdb12acde..79203706922 100644
--- a/arch/arm/mach-shmobile/pm-sh7372.c
+++ b/arch/arm/mach-shmobile/pm-sh7372.c
@@ -26,6 +26,7 @@
26#include <asm/suspend.h> 26#include <asm/suspend.h>
27#include <mach/common.h> 27#include <mach/common.h>
28#include <mach/sh7372.h> 28#include <mach/sh7372.h>
29#include <mach/pm-rmobile.h>
29 30
30/* DBG */ 31/* DBG */
31#define DBGREG1 0xe6100020 32#define DBGREG1 0xe6100020
@@ -41,13 +42,10 @@
41#define PLLC01STPCR 0xe61500c8 42#define PLLC01STPCR 0xe61500c8
42 43
43/* SYSC */ 44/* SYSC */
44#define SPDCR 0xe6180008
45#define SWUCR 0xe6180014
46#define SBAR 0xe6180020 45#define SBAR 0xe6180020
47#define WUPRMSK 0xe6180028 46#define WUPRMSK 0xe6180028
48#define WUPSMSK 0xe618002c 47#define WUPSMSK 0xe618002c
49#define WUPSMSK2 0xe6180048 48#define WUPSMSK2 0xe6180048
50#define PSTR 0xe6180080
51#define WUPSFAC 0xe6180098 49#define WUPSFAC 0xe6180098
52#define IRQCR 0xe618022c 50#define IRQCR 0xe618022c
53#define IRQCR2 0xe6180238 51#define IRQCR2 0xe6180238
@@ -71,188 +69,48 @@
71/* AP-System Core */ 69/* AP-System Core */
72#define APARMBAREA 0xe6f10020 70#define APARMBAREA 0xe6f10020
73 71
74#define PSTR_RETRIES 100
75#define PSTR_DELAY_US 10
76
77#ifdef CONFIG_PM 72#ifdef CONFIG_PM
78 73
79static int pd_power_down(struct generic_pm_domain *genpd) 74struct rmobile_pm_domain sh7372_pd_a4lc = {
80{
81 struct sh7372_pm_domain *sh7372_pd = to_sh7372_pd(genpd);
82 unsigned int mask = 1 << sh7372_pd->bit_shift;
83
84 if (sh7372_pd->suspend) {
85 int ret = sh7372_pd->suspend();
86
87 if (ret)
88 return ret;
89 }
90
91 if (__raw_readl(PSTR) & mask) {
92 unsigned int retry_count;
93
94 __raw_writel(mask, SPDCR);
95
96 for (retry_count = PSTR_RETRIES; retry_count; retry_count--) {
97 if (!(__raw_readl(SPDCR) & mask))
98 break;
99 cpu_relax();
100 }
101 }
102
103 if (!sh7372_pd->no_debug)
104 pr_debug("%s: Power off, 0x%08x -> PSTR = 0x%08x\n",
105 genpd->name, mask, __raw_readl(PSTR));
106
107 return 0;
108}
109
110static int __pd_power_up(struct sh7372_pm_domain *sh7372_pd, bool do_resume)
111{
112 unsigned int mask = 1 << sh7372_pd->bit_shift;
113 unsigned int retry_count;
114 int ret = 0;
115
116 if (__raw_readl(PSTR) & mask)
117 goto out;
118
119 __raw_writel(mask, SWUCR);
120
121 for (retry_count = 2 * PSTR_RETRIES; retry_count; retry_count--) {
122 if (!(__raw_readl(SWUCR) & mask))
123 break;
124 if (retry_count > PSTR_RETRIES)
125 udelay(PSTR_DELAY_US);
126 else
127 cpu_relax();
128 }
129 if (!retry_count)
130 ret = -EIO;
131
132 if (!sh7372_pd->no_debug)
133 pr_debug("%s: Power on, 0x%08x -> PSTR = 0x%08x\n",
134 sh7372_pd->genpd.name, mask, __raw_readl(PSTR));
135
136 out:
137 if (ret == 0 && sh7372_pd->resume && do_resume)
138 sh7372_pd->resume();
139
140 return ret;
141}
142
143static int pd_power_up(struct generic_pm_domain *genpd)
144{
145 return __pd_power_up(to_sh7372_pd(genpd), true);
146}
147
148static int sh7372_a4r_suspend(void)
149{
150 sh7372_intcs_suspend();
151 __raw_writel(0x300fffff, WUPRMSK); /* avoid wakeup */
152 return 0;
153}
154
155static bool pd_active_wakeup(struct device *dev)
156{
157 bool (*active_wakeup)(struct device *dev);
158
159 active_wakeup = dev_gpd_data(dev)->ops.active_wakeup;
160 return active_wakeup ? active_wakeup(dev) : true;
161}
162
163static int sh7372_stop_dev(struct device *dev)
164{
165 int (*stop)(struct device *dev);
166
167 stop = dev_gpd_data(dev)->ops.stop;
168 if (stop) {
169 int ret = stop(dev);
170 if (ret)
171 return ret;
172 }
173 return pm_clk_suspend(dev);
174}
175
176static int sh7372_start_dev(struct device *dev)
177{
178 int (*start)(struct device *dev);
179 int ret;
180
181 ret = pm_clk_resume(dev);
182 if (ret)
183 return ret;
184
185 start = dev_gpd_data(dev)->ops.start;
186 if (start)
187 ret = start(dev);
188
189 return ret;
190}
191
192void sh7372_init_pm_domain(struct sh7372_pm_domain *sh7372_pd)
193{
194 struct generic_pm_domain *genpd = &sh7372_pd->genpd;
195 struct dev_power_governor *gov = sh7372_pd->gov;
196
197 pm_genpd_init(genpd, gov ? : &simple_qos_governor, false);
198 genpd->dev_ops.stop = sh7372_stop_dev;
199 genpd->dev_ops.start = sh7372_start_dev;
200 genpd->dev_ops.active_wakeup = pd_active_wakeup;
201 genpd->dev_irq_safe = true;
202 genpd->power_off = pd_power_down;
203 genpd->power_on = pd_power_up;
204 __pd_power_up(sh7372_pd, false);
205}
206
207void sh7372_add_device_to_domain(struct sh7372_pm_domain *sh7372_pd,
208 struct platform_device *pdev)
209{
210 struct device *dev = &pdev->dev;
211
212 pm_genpd_add_device(&sh7372_pd->genpd, dev);
213 if (pm_clk_no_clocks(dev))
214 pm_clk_add(dev, NULL);
215}
216
217void sh7372_pm_add_subdomain(struct sh7372_pm_domain *sh7372_pd,
218 struct sh7372_pm_domain *sh7372_sd)
219{
220 pm_genpd_add_subdomain(&sh7372_pd->genpd, &sh7372_sd->genpd);
221}
222
223struct sh7372_pm_domain sh7372_a4lc = {
224 .genpd.name = "A4LC", 75 .genpd.name = "A4LC",
225 .bit_shift = 1, 76 .bit_shift = 1,
226}; 77};
227 78
228struct sh7372_pm_domain sh7372_a4mp = { 79struct rmobile_pm_domain sh7372_pd_a4mp = {
229 .genpd.name = "A4MP", 80 .genpd.name = "A4MP",
230 .bit_shift = 2, 81 .bit_shift = 2,
231}; 82};
232 83
233struct sh7372_pm_domain sh7372_d4 = { 84struct rmobile_pm_domain sh7372_pd_d4 = {
234 .genpd.name = "D4", 85 .genpd.name = "D4",
235 .bit_shift = 3, 86 .bit_shift = 3,
236}; 87};
237 88
238struct sh7372_pm_domain sh7372_a4r = { 89static int sh7372_a4r_pd_suspend(void)
90{
91 sh7372_intcs_suspend();
92 __raw_writel(0x300fffff, WUPRMSK); /* avoid wakeup */
93 return 0;
94}
95
96struct rmobile_pm_domain sh7372_pd_a4r = {
239 .genpd.name = "A4R", 97 .genpd.name = "A4R",
240 .bit_shift = 5, 98 .bit_shift = 5,
241 .suspend = sh7372_a4r_suspend, 99 .suspend = sh7372_a4r_pd_suspend,
242 .resume = sh7372_intcs_resume, 100 .resume = sh7372_intcs_resume,
243}; 101};
244 102
245struct sh7372_pm_domain sh7372_a3rv = { 103struct rmobile_pm_domain sh7372_pd_a3rv = {
246 .genpd.name = "A3RV", 104 .genpd.name = "A3RV",
247 .bit_shift = 6, 105 .bit_shift = 6,
248}; 106};
249 107
250struct sh7372_pm_domain sh7372_a3ri = { 108struct rmobile_pm_domain sh7372_pd_a3ri = {
251 .genpd.name = "A3RI", 109 .genpd.name = "A3RI",
252 .bit_shift = 8, 110 .bit_shift = 8,
253}; 111};
254 112
255static int sh7372_a4s_suspend(void) 113static int sh7372_pd_a4s_suspend(void)
256{ 114{
257 /* 115 /*
258 * The A4S domain contains the CPU core and therefore it should 116 * The A4S domain contains the CPU core and therefore it should
@@ -261,15 +119,15 @@ static int sh7372_a4s_suspend(void)
261 return -EBUSY; 119 return -EBUSY;
262} 120}
263 121
264struct sh7372_pm_domain sh7372_a4s = { 122struct rmobile_pm_domain sh7372_pd_a4s = {
265 .genpd.name = "A4S", 123 .genpd.name = "A4S",
266 .bit_shift = 10, 124 .bit_shift = 10,
267 .gov = &pm_domain_always_on_gov, 125 .gov = &pm_domain_always_on_gov,
268 .no_debug = true, 126 .no_debug = true,
269 .suspend = sh7372_a4s_suspend, 127 .suspend = sh7372_pd_a4s_suspend,
270}; 128};
271 129
272static int sh7372_a3sp_suspend(void) 130static int sh7372_a3sp_pd_suspend(void)
273{ 131{
274 /* 132 /*
275 * Serial consoles make use of SCIF hardware located in A3SP, 133 * Serial consoles make use of SCIF hardware located in A3SP,
@@ -278,32 +136,22 @@ static int sh7372_a3sp_suspend(void)
278 return console_suspend_enabled ? 0 : -EBUSY; 136 return console_suspend_enabled ? 0 : -EBUSY;
279} 137}
280 138
281struct sh7372_pm_domain sh7372_a3sp = { 139struct rmobile_pm_domain sh7372_pd_a3sp = {
282 .genpd.name = "A3SP", 140 .genpd.name = "A3SP",
283 .bit_shift = 11, 141 .bit_shift = 11,
284 .gov = &pm_domain_always_on_gov, 142 .gov = &pm_domain_always_on_gov,
285 .no_debug = true, 143 .no_debug = true,
286 .suspend = sh7372_a3sp_suspend, 144 .suspend = sh7372_a3sp_pd_suspend,
287}; 145};
288 146
289struct sh7372_pm_domain sh7372_a3sg = { 147struct rmobile_pm_domain sh7372_pd_a3sg = {
290 .genpd.name = "A3SG", 148 .genpd.name = "A3SG",
291 .bit_shift = 13, 149 .bit_shift = 13,
292}; 150};
293 151
294#else /* !CONFIG_PM */ 152#endif /* CONFIG_PM */
295
296static inline void sh7372_a3sp_init(void) {}
297
298#endif /* !CONFIG_PM */
299 153
300#if defined(CONFIG_SUSPEND) || defined(CONFIG_CPU_IDLE) 154#if defined(CONFIG_SUSPEND) || defined(CONFIG_CPU_IDLE)
301static int sh7372_do_idle_core_standby(unsigned long unused)
302{
303 cpu_do_idle(); /* WFI when SYSTBCR == 0x10 -> Core Standby */
304 return 0;
305}
306
307static void sh7372_set_reset_vector(unsigned long address) 155static void sh7372_set_reset_vector(unsigned long address)
308{ 156{
309 /* set reset vector, translate 4k */ 157 /* set reset vector, translate 4k */
@@ -311,21 +159,6 @@ static void sh7372_set_reset_vector(unsigned long address)
311 __raw_writel(0, APARMBAREA); 159 __raw_writel(0, APARMBAREA);
312} 160}
313 161
314static void sh7372_enter_core_standby(void)
315{
316 sh7372_set_reset_vector(__pa(sh7372_resume_core_standby_sysc));
317
318 /* enter sleep mode with SYSTBCR to 0x10 */
319 __raw_writel(0x10, SYSTBCR);
320 cpu_suspend(0, sh7372_do_idle_core_standby);
321 __raw_writel(0, SYSTBCR);
322
323 /* disable reset vector translation */
324 __raw_writel(0, SBAR);
325}
326#endif
327
328#ifdef CONFIG_SUSPEND
329static void sh7372_enter_sysc(int pllc0_on, unsigned long sleep_mode) 162static void sh7372_enter_sysc(int pllc0_on, unsigned long sleep_mode)
330{ 163{
331 if (pllc0_on) 164 if (pllc0_on)
@@ -465,22 +298,42 @@ static void sh7372_setup_sysc(unsigned long msk, unsigned long msk2)
465 298
466static void sh7372_enter_a3sm_common(int pllc0_on) 299static void sh7372_enter_a3sm_common(int pllc0_on)
467{ 300{
301 /* use INTCA together with SYSC for wakeup */
302 sh7372_setup_sysc(1 << 0, 0);
468 sh7372_set_reset_vector(__pa(sh7372_resume_core_standby_sysc)); 303 sh7372_set_reset_vector(__pa(sh7372_resume_core_standby_sysc));
469 sh7372_enter_sysc(pllc0_on, 1 << 12); 304 sh7372_enter_sysc(pllc0_on, 1 << 12);
470} 305}
306#endif /* CONFIG_SUSPEND || CONFIG_CPU_IDLE */
471 307
472static void sh7372_enter_a4s_common(int pllc0_on) 308#ifdef CONFIG_CPU_IDLE
309static int sh7372_do_idle_core_standby(unsigned long unused)
473{ 310{
474 sh7372_intca_suspend(); 311 cpu_do_idle(); /* WFI when SYSTBCR == 0x10 -> Core Standby */
475 memcpy((void *)SMFRAM, sh7372_resume_core_standby_sysc, 0x100); 312 return 0;
476 sh7372_set_reset_vector(SMFRAM);
477 sh7372_enter_sysc(pllc0_on, 1 << 10);
478 sh7372_intca_resume();
479} 313}
480 314
481#endif 315static void sh7372_enter_core_standby(void)
316{
317 sh7372_set_reset_vector(__pa(sh7372_resume_core_standby_sysc));
482 318
483#ifdef CONFIG_CPU_IDLE 319 /* enter sleep mode with SYSTBCR to 0x10 */
320 __raw_writel(0x10, SYSTBCR);
321 cpu_suspend(0, sh7372_do_idle_core_standby);
322 __raw_writel(0, SYSTBCR);
323
324 /* disable reset vector translation */
325 __raw_writel(0, SBAR);
326}
327
328static void sh7372_enter_a3sm_pll_on(void)
329{
330 sh7372_enter_a3sm_common(1);
331}
332
333static void sh7372_enter_a3sm_pll_off(void)
334{
335 sh7372_enter_a3sm_common(0);
336}
484 337
485static void sh7372_cpuidle_setup(struct cpuidle_driver *drv) 338static void sh7372_cpuidle_setup(struct cpuidle_driver *drv)
486{ 339{
@@ -492,7 +345,24 @@ static void sh7372_cpuidle_setup(struct cpuidle_driver *drv)
492 state->target_residency = 20 + 10; 345 state->target_residency = 20 + 10;
493 state->flags = CPUIDLE_FLAG_TIME_VALID; 346 state->flags = CPUIDLE_FLAG_TIME_VALID;
494 shmobile_cpuidle_modes[drv->state_count] = sh7372_enter_core_standby; 347 shmobile_cpuidle_modes[drv->state_count] = sh7372_enter_core_standby;
348 drv->state_count++;
349
350 state = &drv->states[drv->state_count];
351 snprintf(state->name, CPUIDLE_NAME_LEN, "C3");
352 strncpy(state->desc, "A3SM PLL ON", CPUIDLE_DESC_LEN);
353 state->exit_latency = 20;
354 state->target_residency = 30 + 20;
355 state->flags = CPUIDLE_FLAG_TIME_VALID;
356 shmobile_cpuidle_modes[drv->state_count] = sh7372_enter_a3sm_pll_on;
357 drv->state_count++;
495 358
359 state = &drv->states[drv->state_count];
360 snprintf(state->name, CPUIDLE_NAME_LEN, "C4");
361 strncpy(state->desc, "A3SM PLL OFF", CPUIDLE_DESC_LEN);
362 state->exit_latency = 120;
363 state->target_residency = 30 + 120;
364 state->flags = CPUIDLE_FLAG_TIME_VALID;
365 shmobile_cpuidle_modes[drv->state_count] = sh7372_enter_a3sm_pll_off;
496 drv->state_count++; 366 drv->state_count++;
497} 367}
498 368
@@ -505,6 +375,14 @@ static void sh7372_cpuidle_init(void) {}
505#endif 375#endif
506 376
507#ifdef CONFIG_SUSPEND 377#ifdef CONFIG_SUSPEND
378static void sh7372_enter_a4s_common(int pllc0_on)
379{
380 sh7372_intca_suspend();
381 memcpy((void *)SMFRAM, sh7372_resume_core_standby_sysc, 0x100);
382 sh7372_set_reset_vector(SMFRAM);
383 sh7372_enter_sysc(pllc0_on, 1 << 10);
384 sh7372_intca_resume();
385}
508 386
509static int sh7372_enter_suspend(suspend_state_t suspend_state) 387static int sh7372_enter_suspend(suspend_state_t suspend_state)
510{ 388{
@@ -512,24 +390,21 @@ static int sh7372_enter_suspend(suspend_state_t suspend_state)
512 390
513 /* check active clocks to determine potential wakeup sources */ 391 /* check active clocks to determine potential wakeup sources */
514 if (sh7372_sysc_valid(&msk, &msk2)) { 392 if (sh7372_sysc_valid(&msk, &msk2)) {
515 /* convert INTC mask and sense to SYSC mask and sense */
516 sh7372_setup_sysc(msk, msk2);
517
518 if (!console_suspend_enabled && 393 if (!console_suspend_enabled &&
519 sh7372_a4s.genpd.status == GPD_STATE_POWER_OFF) { 394 sh7372_pd_a4s.genpd.status == GPD_STATE_POWER_OFF) {
395 /* convert INTC mask/sense to SYSC mask/sense */
396 sh7372_setup_sysc(msk, msk2);
397
520 /* enter A4S sleep with PLLC0 off */ 398 /* enter A4S sleep with PLLC0 off */
521 pr_debug("entering A4S\n"); 399 pr_debug("entering A4S\n");
522 sh7372_enter_a4s_common(0); 400 sh7372_enter_a4s_common(0);
523 } else { 401 return 0;
524 /* enter A3SM sleep with PLLC0 off */
525 pr_debug("entering A3SM\n");
526 sh7372_enter_a3sm_common(0);
527 } 402 }
528 } else {
529 /* default to Core Standby that supports all wakeup sources */
530 pr_debug("entering Core Standby\n");
531 sh7372_enter_core_standby();
532 } 403 }
404
405 /* default to enter A3SM sleep with PLLC0 off */
406 pr_debug("entering A3SM\n");
407 sh7372_enter_a3sm_common(0);
533 return 0; 408 return 0;
534} 409}
535 410
@@ -550,7 +425,7 @@ static int sh7372_pm_notifier_fn(struct notifier_block *notifier,
550 * executed during system suspend and resume, respectively, so 425 * executed during system suspend and resume, respectively, so
551 * that those functions don't crash while accessing the INTCS. 426 * that those functions don't crash while accessing the INTCS.
552 */ 427 */
553 pm_genpd_poweron(&sh7372_a4r.genpd); 428 pm_genpd_poweron(&sh7372_pd_a4r.genpd);
554 break; 429 break;
555 case PM_POST_SUSPEND: 430 case PM_POST_SUSPEND:
556 pm_genpd_poweroff_unused(); 431 pm_genpd_poweroff_unused();
diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
index ec4eb49c169..78948a9dba0 100644
--- a/arch/arm/mach-shmobile/setup-r8a7740.c
+++ b/arch/arm/mach-shmobile/setup-r8a7740.c
@@ -23,9 +23,14 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/of_platform.h>
26#include <linux/serial_sci.h> 27#include <linux/serial_sci.h>
28#include <linux/sh_dma.h>
27#include <linux/sh_timer.h> 29#include <linux/sh_timer.h>
30#include <linux/dma-mapping.h>
31#include <mach/dma-register.h>
28#include <mach/r8a7740.h> 32#include <mach/r8a7740.h>
33#include <mach/pm-rmobile.h>
29#include <mach/common.h> 34#include <mach/common.h>
30#include <mach/irqs.h> 35#include <mach/irqs.h>
31#include <asm/mach-types.h> 36#include <asm/mach-types.h>
@@ -276,6 +281,272 @@ static struct platform_device *r8a7740_early_devices[] __initdata = {
276 &cmt10_device, 281 &cmt10_device,
277}; 282};
278 283
284/* DMA */
285static const struct sh_dmae_slave_config r8a7740_dmae_slaves[] = {
286 {
287 .slave_id = SHDMA_SLAVE_SDHI0_TX,
288 .addr = 0xe6850030,
289 .chcr = CHCR_TX(XMIT_SZ_16BIT),
290 .mid_rid = 0xc1,
291 }, {
292 .slave_id = SHDMA_SLAVE_SDHI0_RX,
293 .addr = 0xe6850030,
294 .chcr = CHCR_RX(XMIT_SZ_16BIT),
295 .mid_rid = 0xc2,
296 }, {
297 .slave_id = SHDMA_SLAVE_SDHI1_TX,
298 .addr = 0xe6860030,
299 .chcr = CHCR_TX(XMIT_SZ_16BIT),
300 .mid_rid = 0xc9,
301 }, {
302 .slave_id = SHDMA_SLAVE_SDHI1_RX,
303 .addr = 0xe6860030,
304 .chcr = CHCR_RX(XMIT_SZ_16BIT),
305 .mid_rid = 0xca,
306 }, {
307 .slave_id = SHDMA_SLAVE_SDHI2_TX,
308 .addr = 0xe6870030,
309 .chcr = CHCR_TX(XMIT_SZ_16BIT),
310 .mid_rid = 0xcd,
311 }, {
312 .slave_id = SHDMA_SLAVE_SDHI2_RX,
313 .addr = 0xe6870030,
314 .chcr = CHCR_RX(XMIT_SZ_16BIT),
315 .mid_rid = 0xce,
316 }, {
317 .slave_id = SHDMA_SLAVE_FSIA_TX,
318 .addr = 0xfe1f0024,
319 .chcr = CHCR_TX(XMIT_SZ_32BIT),
320 .mid_rid = 0xb1,
321 }, {
322 .slave_id = SHDMA_SLAVE_FSIA_RX,
323 .addr = 0xfe1f0020,
324 .chcr = CHCR_RX(XMIT_SZ_32BIT),
325 .mid_rid = 0xb2,
326 }, {
327 .slave_id = SHDMA_SLAVE_FSIB_TX,
328 .addr = 0xfe1f0064,
329 .chcr = CHCR_TX(XMIT_SZ_32BIT),
330 .mid_rid = 0xb5,
331 },
332};
333
334#define DMA_CHANNEL(a, b, c) \
335{ \
336 .offset = a, \
337 .dmars = b, \
338 .dmars_bit = c, \
339 .chclr_offset = (0x220 - 0x20) + a \
340}
341
342static const struct sh_dmae_channel r8a7740_dmae_channels[] = {
343 DMA_CHANNEL(0x00, 0, 0),
344 DMA_CHANNEL(0x10, 0, 8),
345 DMA_CHANNEL(0x20, 4, 0),
346 DMA_CHANNEL(0x30, 4, 8),
347 DMA_CHANNEL(0x50, 8, 0),
348 DMA_CHANNEL(0x60, 8, 8),
349};
350
351static struct sh_dmae_pdata dma_platform_data = {
352 .slave = r8a7740_dmae_slaves,
353 .slave_num = ARRAY_SIZE(r8a7740_dmae_slaves),
354 .channel = r8a7740_dmae_channels,
355 .channel_num = ARRAY_SIZE(r8a7740_dmae_channels),
356 .ts_low_shift = TS_LOW_SHIFT,
357 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
358 .ts_high_shift = TS_HI_SHIFT,
359 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
360 .ts_shift = dma_ts_shift,
361 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
362 .dmaor_init = DMAOR_DME,
363 .chclr_present = 1,
364};
365
366/* Resource order important! */
367static struct resource r8a7740_dmae0_resources[] = {
368 {
369 /* Channel registers and DMAOR */
370 .start = 0xfe008020,
371 .end = 0xfe00828f,
372 .flags = IORESOURCE_MEM,
373 },
374 {
375 /* DMARSx */
376 .start = 0xfe009000,
377 .end = 0xfe00900b,
378 .flags = IORESOURCE_MEM,
379 },
380 {
381 .name = "error_irq",
382 .start = evt2irq(0x20c0),
383 .end = evt2irq(0x20c0),
384 .flags = IORESOURCE_IRQ,
385 },
386 {
387 /* IRQ for channels 0-5 */
388 .start = evt2irq(0x2000),
389 .end = evt2irq(0x20a0),
390 .flags = IORESOURCE_IRQ,
391 },
392};
393
394/* Resource order important! */
395static struct resource r8a7740_dmae1_resources[] = {
396 {
397 /* Channel registers and DMAOR */
398 .start = 0xfe018020,
399 .end = 0xfe01828f,
400 .flags = IORESOURCE_MEM,
401 },
402 {
403 /* DMARSx */
404 .start = 0xfe019000,
405 .end = 0xfe01900b,
406 .flags = IORESOURCE_MEM,
407 },
408 {
409 .name = "error_irq",
410 .start = evt2irq(0x21c0),
411 .end = evt2irq(0x21c0),
412 .flags = IORESOURCE_IRQ,
413 },
414 {
415 /* IRQ for channels 0-5 */
416 .start = evt2irq(0x2100),
417 .end = evt2irq(0x21a0),
418 .flags = IORESOURCE_IRQ,
419 },
420};
421
422/* Resource order important! */
423static struct resource r8a7740_dmae2_resources[] = {
424 {
425 /* Channel registers and DMAOR */
426 .start = 0xfe028020,
427 .end = 0xfe02828f,
428 .flags = IORESOURCE_MEM,
429 },
430 {
431 /* DMARSx */
432 .start = 0xfe029000,
433 .end = 0xfe02900b,
434 .flags = IORESOURCE_MEM,
435 },
436 {
437 .name = "error_irq",
438 .start = evt2irq(0x22c0),
439 .end = evt2irq(0x22c0),
440 .flags = IORESOURCE_IRQ,
441 },
442 {
443 /* IRQ for channels 0-5 */
444 .start = evt2irq(0x2200),
445 .end = evt2irq(0x22a0),
446 .flags = IORESOURCE_IRQ,
447 },
448};
449
450static struct platform_device dma0_device = {
451 .name = "sh-dma-engine",
452 .id = 0,
453 .resource = r8a7740_dmae0_resources,
454 .num_resources = ARRAY_SIZE(r8a7740_dmae0_resources),
455 .dev = {
456 .platform_data = &dma_platform_data,
457 },
458};
459
460static struct platform_device dma1_device = {
461 .name = "sh-dma-engine",
462 .id = 1,
463 .resource = r8a7740_dmae1_resources,
464 .num_resources = ARRAY_SIZE(r8a7740_dmae1_resources),
465 .dev = {
466 .platform_data = &dma_platform_data,
467 },
468};
469
470static struct platform_device dma2_device = {
471 .name = "sh-dma-engine",
472 .id = 2,
473 .resource = r8a7740_dmae2_resources,
474 .num_resources = ARRAY_SIZE(r8a7740_dmae2_resources),
475 .dev = {
476 .platform_data = &dma_platform_data,
477 },
478};
479
480/* USB-DMAC */
481static const struct sh_dmae_channel r8a7740_usb_dma_channels[] = {
482 {
483 .offset = 0,
484 }, {
485 .offset = 0x20,
486 },
487};
488
489static const struct sh_dmae_slave_config r8a7740_usb_dma_slaves[] = {
490 {
491 .slave_id = SHDMA_SLAVE_USBHS_TX,
492 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
493 }, {
494 .slave_id = SHDMA_SLAVE_USBHS_RX,
495 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
496 },
497};
498
499static struct sh_dmae_pdata usb_dma_platform_data = {
500 .slave = r8a7740_usb_dma_slaves,
501 .slave_num = ARRAY_SIZE(r8a7740_usb_dma_slaves),
502 .channel = r8a7740_usb_dma_channels,
503 .channel_num = ARRAY_SIZE(r8a7740_usb_dma_channels),
504 .ts_low_shift = USBTS_LOW_SHIFT,
505 .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
506 .ts_high_shift = USBTS_HI_SHIFT,
507 .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
508 .ts_shift = dma_usbts_shift,
509 .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
510 .dmaor_init = DMAOR_DME,
511 .chcr_offset = 0x14,
512 .chcr_ie_bit = 1 << 5,
513 .dmaor_is_32bit = 1,
514 .needs_tend_set = 1,
515 .no_dmars = 1,
516 .slave_only = 1,
517};
518
519static struct resource r8a7740_usb_dma_resources[] = {
520 {
521 /* Channel registers and DMAOR */
522 .start = 0xe68a0020,
523 .end = 0xe68a0064 - 1,
524 .flags = IORESOURCE_MEM,
525 },
526 {
527 /* VCR/SWR/DMICR */
528 .start = 0xe68a0000,
529 .end = 0xe68a0014 - 1,
530 .flags = IORESOURCE_MEM,
531 },
532 {
533 /* IRQ for channels */
534 .start = evt2irq(0x0a00),
535 .end = evt2irq(0x0a00),
536 .flags = IORESOURCE_IRQ,
537 },
538};
539
540static struct platform_device usb_dma_device = {
541 .name = "sh-dma-engine",
542 .id = 3,
543 .resource = r8a7740_usb_dma_resources,
544 .num_resources = ARRAY_SIZE(r8a7740_usb_dma_resources),
545 .dev = {
546 .platform_data = &usb_dma_platform_data,
547 },
548};
549
279/* I2C */ 550/* I2C */
280static struct resource i2c0_resources[] = { 551static struct resource i2c0_resources[] = {
281 [0] = { 552 [0] = {
@@ -322,8 +593,30 @@ static struct platform_device i2c1_device = {
322static struct platform_device *r8a7740_late_devices[] __initdata = { 593static struct platform_device *r8a7740_late_devices[] __initdata = {
323 &i2c0_device, 594 &i2c0_device,
324 &i2c1_device, 595 &i2c1_device,
596 &dma0_device,
597 &dma1_device,
598 &dma2_device,
599 &usb_dma_device,
325}; 600};
326 601
602/*
603 * r8a7740 chip has lasting errata on MERAM buffer.
604 * this is work-around for it.
605 * see
606 * "Media RAM (MERAM)" on r8a7740 documentation
607 */
608#define MEBUFCNTR 0xFE950098
609void r8a7740_meram_workaround(void)
610{
611 void __iomem *reg;
612
613 reg = ioremap_nocache(MEBUFCNTR, 4);
614 if (reg) {
615 iowrite32(0x01600164, reg);
616 iounmap(reg);
617 }
618}
619
327#define ICCR 0x0004 620#define ICCR 0x0004
328#define ICSTART 0x0070 621#define ICSTART 0x0070
329 622
@@ -380,10 +673,31 @@ void __init r8a7740_add_standard_devices(void)
380 r8a7740_i2c_workaround(&i2c0_device); 673 r8a7740_i2c_workaround(&i2c0_device);
381 r8a7740_i2c_workaround(&i2c1_device); 674 r8a7740_i2c_workaround(&i2c1_device);
382 675
676 /* PM domain */
677 rmobile_init_pm_domain(&r8a7740_pd_a4s);
678 rmobile_init_pm_domain(&r8a7740_pd_a3sp);
679 rmobile_init_pm_domain(&r8a7740_pd_a4lc);
680
681 rmobile_pm_add_subdomain(&r8a7740_pd_a4s, &r8a7740_pd_a3sp);
682
683 /* add devices */
383 platform_add_devices(r8a7740_early_devices, 684 platform_add_devices(r8a7740_early_devices,
384 ARRAY_SIZE(r8a7740_early_devices)); 685 ARRAY_SIZE(r8a7740_early_devices));
385 platform_add_devices(r8a7740_late_devices, 686 platform_add_devices(r8a7740_late_devices,
386 ARRAY_SIZE(r8a7740_late_devices)); 687 ARRAY_SIZE(r8a7740_late_devices));
688
689 /* add devices to PM domain */
690
691 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scif0_device);
692 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scif1_device);
693 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scif2_device);
694 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scif3_device);
695 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scif4_device);
696 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scif5_device);
697 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scif6_device);
698 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scif7_device);
699 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scifb_device);
700 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &i2c1_device);
387} 701}
388 702
389static void __init r8a7740_earlytimer_init(void) 703static void __init r8a7740_earlytimer_init(void)
@@ -403,3 +717,49 @@ void __init r8a7740_add_early_devices(void)
403 /* override timer setup with soc-specific code */ 717 /* override timer setup with soc-specific code */
404 shmobile_timer.init = r8a7740_earlytimer_init; 718 shmobile_timer.init = r8a7740_earlytimer_init;
405} 719}
720
721#ifdef CONFIG_USE_OF
722
723void __init r8a7740_add_early_devices_dt(void)
724{
725 shmobile_setup_delay(800, 1, 3); /* Cortex-A9 @ 800MHz */
726
727 early_platform_add_devices(r8a7740_early_devices,
728 ARRAY_SIZE(r8a7740_early_devices));
729
730 /* setup early console here as well */
731 shmobile_setup_console();
732}
733
734static const struct of_dev_auxdata r8a7740_auxdata_lookup[] __initconst = {
735 { }
736};
737
738void __init r8a7740_add_standard_devices_dt(void)
739{
740 /* clocks are setup late during boot in the case of DT */
741 r8a7740_clock_init(0);
742
743 platform_add_devices(r8a7740_early_devices,
744 ARRAY_SIZE(r8a7740_early_devices));
745
746 of_platform_populate(NULL, of_default_bus_match_table,
747 r8a7740_auxdata_lookup, NULL);
748}
749
750static const char *r8a7740_boards_compat_dt[] __initdata = {
751 "renesas,r8a7740",
752 NULL,
753};
754
755DT_MACHINE_START(SH7372_DT, "Generic R8A7740 (Flattened Device Tree)")
756 .map_io = r8a7740_map_io,
757 .init_early = r8a7740_add_early_devices_dt,
758 .init_irq = r8a7740_init_irq,
759 .handle_irq = shmobile_handle_irq_intc,
760 .init_machine = r8a7740_add_standard_devices_dt,
761 .timer = &shmobile_timer,
762 .dt_compat = r8a7740_boards_compat_dt,
763MACHINE_END
764
765#endif /* CONFIG_USE_OF */
diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
index fafce9ce821..838a87be1d5 100644
--- a/arch/arm/mach-shmobile/setup-sh7372.c
+++ b/arch/arm/mach-shmobile/setup-sh7372.c
@@ -33,6 +33,7 @@
33#include <linux/sh_timer.h> 33#include <linux/sh_timer.h>
34#include <linux/pm_domain.h> 34#include <linux/pm_domain.h>
35#include <linux/dma-mapping.h> 35#include <linux/dma-mapping.h>
36#include <mach/dma-register.h>
36#include <mach/hardware.h> 37#include <mach/hardware.h>
37#include <mach/irqs.h> 38#include <mach/irqs.h>
38#include <mach/sh7372.h> 39#include <mach/sh7372.h>
@@ -335,151 +336,126 @@ static struct platform_device iic1_device = {
335}; 336};
336 337
337/* DMA */ 338/* DMA */
338/* Transmit sizes and respective CHCR register values */
339enum {
340 XMIT_SZ_8BIT = 0,
341 XMIT_SZ_16BIT = 1,
342 XMIT_SZ_32BIT = 2,
343 XMIT_SZ_64BIT = 7,
344 XMIT_SZ_128BIT = 3,
345 XMIT_SZ_256BIT = 4,
346 XMIT_SZ_512BIT = 5,
347};
348
349/* log2(size / 8) - used to calculate number of transfers */
350#define TS_SHIFT { \
351 [XMIT_SZ_8BIT] = 0, \
352 [XMIT_SZ_16BIT] = 1, \
353 [XMIT_SZ_32BIT] = 2, \
354 [XMIT_SZ_64BIT] = 3, \
355 [XMIT_SZ_128BIT] = 4, \
356 [XMIT_SZ_256BIT] = 5, \
357 [XMIT_SZ_512BIT] = 6, \
358}
359
360#define TS_INDEX2VAL(i) ((((i) & 3) << 3) | \
361 (((i) & 0xc) << (20 - 2)))
362
363static const struct sh_dmae_slave_config sh7372_dmae_slaves[] = { 339static const struct sh_dmae_slave_config sh7372_dmae_slaves[] = {
364 { 340 {
365 .slave_id = SHDMA_SLAVE_SCIF0_TX, 341 .slave_id = SHDMA_SLAVE_SCIF0_TX,
366 .addr = 0xe6c40020, 342 .addr = 0xe6c40020,
367 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 343 .chcr = CHCR_TX(XMIT_SZ_8BIT),
368 .mid_rid = 0x21, 344 .mid_rid = 0x21,
369 }, { 345 }, {
370 .slave_id = SHDMA_SLAVE_SCIF0_RX, 346 .slave_id = SHDMA_SLAVE_SCIF0_RX,
371 .addr = 0xe6c40024, 347 .addr = 0xe6c40024,
372 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 348 .chcr = CHCR_RX(XMIT_SZ_8BIT),
373 .mid_rid = 0x22, 349 .mid_rid = 0x22,
374 }, { 350 }, {
375 .slave_id = SHDMA_SLAVE_SCIF1_TX, 351 .slave_id = SHDMA_SLAVE_SCIF1_TX,
376 .addr = 0xe6c50020, 352 .addr = 0xe6c50020,
377 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 353 .chcr = CHCR_TX(XMIT_SZ_8BIT),
378 .mid_rid = 0x25, 354 .mid_rid = 0x25,
379 }, { 355 }, {
380 .slave_id = SHDMA_SLAVE_SCIF1_RX, 356 .slave_id = SHDMA_SLAVE_SCIF1_RX,
381 .addr = 0xe6c50024, 357 .addr = 0xe6c50024,
382 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 358 .chcr = CHCR_RX(XMIT_SZ_8BIT),
383 .mid_rid = 0x26, 359 .mid_rid = 0x26,
384 }, { 360 }, {
385 .slave_id = SHDMA_SLAVE_SCIF2_TX, 361 .slave_id = SHDMA_SLAVE_SCIF2_TX,
386 .addr = 0xe6c60020, 362 .addr = 0xe6c60020,
387 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 363 .chcr = CHCR_TX(XMIT_SZ_8BIT),
388 .mid_rid = 0x29, 364 .mid_rid = 0x29,
389 }, { 365 }, {
390 .slave_id = SHDMA_SLAVE_SCIF2_RX, 366 .slave_id = SHDMA_SLAVE_SCIF2_RX,
391 .addr = 0xe6c60024, 367 .addr = 0xe6c60024,
392 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 368 .chcr = CHCR_RX(XMIT_SZ_8BIT),
393 .mid_rid = 0x2a, 369 .mid_rid = 0x2a,
394 }, { 370 }, {
395 .slave_id = SHDMA_SLAVE_SCIF3_TX, 371 .slave_id = SHDMA_SLAVE_SCIF3_TX,
396 .addr = 0xe6c70020, 372 .addr = 0xe6c70020,
397 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 373 .chcr = CHCR_TX(XMIT_SZ_8BIT),
398 .mid_rid = 0x2d, 374 .mid_rid = 0x2d,
399 }, { 375 }, {
400 .slave_id = SHDMA_SLAVE_SCIF3_RX, 376 .slave_id = SHDMA_SLAVE_SCIF3_RX,
401 .addr = 0xe6c70024, 377 .addr = 0xe6c70024,
402 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 378 .chcr = CHCR_RX(XMIT_SZ_8BIT),
403 .mid_rid = 0x2e, 379 .mid_rid = 0x2e,
404 }, { 380 }, {
405 .slave_id = SHDMA_SLAVE_SCIF4_TX, 381 .slave_id = SHDMA_SLAVE_SCIF4_TX,
406 .addr = 0xe6c80020, 382 .addr = 0xe6c80020,
407 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 383 .chcr = CHCR_TX(XMIT_SZ_8BIT),
408 .mid_rid = 0x39, 384 .mid_rid = 0x39,
409 }, { 385 }, {
410 .slave_id = SHDMA_SLAVE_SCIF4_RX, 386 .slave_id = SHDMA_SLAVE_SCIF4_RX,
411 .addr = 0xe6c80024, 387 .addr = 0xe6c80024,
412 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 388 .chcr = CHCR_RX(XMIT_SZ_8BIT),
413 .mid_rid = 0x3a, 389 .mid_rid = 0x3a,
414 }, { 390 }, {
415 .slave_id = SHDMA_SLAVE_SCIF5_TX, 391 .slave_id = SHDMA_SLAVE_SCIF5_TX,
416 .addr = 0xe6cb0020, 392 .addr = 0xe6cb0020,
417 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 393 .chcr = CHCR_TX(XMIT_SZ_8BIT),
418 .mid_rid = 0x35, 394 .mid_rid = 0x35,
419 }, { 395 }, {
420 .slave_id = SHDMA_SLAVE_SCIF5_RX, 396 .slave_id = SHDMA_SLAVE_SCIF5_RX,
421 .addr = 0xe6cb0024, 397 .addr = 0xe6cb0024,
422 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 398 .chcr = CHCR_RX(XMIT_SZ_8BIT),
423 .mid_rid = 0x36, 399 .mid_rid = 0x36,
424 }, { 400 }, {
425 .slave_id = SHDMA_SLAVE_SCIF6_TX, 401 .slave_id = SHDMA_SLAVE_SCIF6_TX,
426 .addr = 0xe6c30040, 402 .addr = 0xe6c30040,
427 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 403 .chcr = CHCR_TX(XMIT_SZ_8BIT),
428 .mid_rid = 0x3d, 404 .mid_rid = 0x3d,
429 }, { 405 }, {
430 .slave_id = SHDMA_SLAVE_SCIF6_RX, 406 .slave_id = SHDMA_SLAVE_SCIF6_RX,
431 .addr = 0xe6c30060, 407 .addr = 0xe6c30060,
432 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 408 .chcr = CHCR_RX(XMIT_SZ_8BIT),
433 .mid_rid = 0x3e, 409 .mid_rid = 0x3e,
434 }, { 410 }, {
435 .slave_id = SHDMA_SLAVE_SDHI0_TX, 411 .slave_id = SHDMA_SLAVE_SDHI0_TX,
436 .addr = 0xe6850030, 412 .addr = 0xe6850030,
437 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT), 413 .chcr = CHCR_TX(XMIT_SZ_16BIT),
438 .mid_rid = 0xc1, 414 .mid_rid = 0xc1,
439 }, { 415 }, {
440 .slave_id = SHDMA_SLAVE_SDHI0_RX, 416 .slave_id = SHDMA_SLAVE_SDHI0_RX,
441 .addr = 0xe6850030, 417 .addr = 0xe6850030,
442 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT), 418 .chcr = CHCR_RX(XMIT_SZ_16BIT),
443 .mid_rid = 0xc2, 419 .mid_rid = 0xc2,
444 }, { 420 }, {
445 .slave_id = SHDMA_SLAVE_SDHI1_TX, 421 .slave_id = SHDMA_SLAVE_SDHI1_TX,
446 .addr = 0xe6860030, 422 .addr = 0xe6860030,
447 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT), 423 .chcr = CHCR_TX(XMIT_SZ_16BIT),
448 .mid_rid = 0xc9, 424 .mid_rid = 0xc9,
449 }, { 425 }, {
450 .slave_id = SHDMA_SLAVE_SDHI1_RX, 426 .slave_id = SHDMA_SLAVE_SDHI1_RX,
451 .addr = 0xe6860030, 427 .addr = 0xe6860030,
452 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT), 428 .chcr = CHCR_RX(XMIT_SZ_16BIT),
453 .mid_rid = 0xca, 429 .mid_rid = 0xca,
454 }, { 430 }, {
455 .slave_id = SHDMA_SLAVE_SDHI2_TX, 431 .slave_id = SHDMA_SLAVE_SDHI2_TX,
456 .addr = 0xe6870030, 432 .addr = 0xe6870030,
457 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT), 433 .chcr = CHCR_TX(XMIT_SZ_16BIT),
458 .mid_rid = 0xcd, 434 .mid_rid = 0xcd,
459 }, { 435 }, {
460 .slave_id = SHDMA_SLAVE_SDHI2_RX, 436 .slave_id = SHDMA_SLAVE_SDHI2_RX,
461 .addr = 0xe6870030, 437 .addr = 0xe6870030,
462 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT), 438 .chcr = CHCR_RX(XMIT_SZ_16BIT),
463 .mid_rid = 0xce, 439 .mid_rid = 0xce,
464 }, { 440 }, {
465 .slave_id = SHDMA_SLAVE_FSIA_TX, 441 .slave_id = SHDMA_SLAVE_FSIA_TX,
466 .addr = 0xfe1f0024, 442 .addr = 0xfe1f0024,
467 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT), 443 .chcr = CHCR_TX(XMIT_SZ_32BIT),
468 .mid_rid = 0xb1, 444 .mid_rid = 0xb1,
469 }, { 445 }, {
470 .slave_id = SHDMA_SLAVE_FSIA_RX, 446 .slave_id = SHDMA_SLAVE_FSIA_RX,
471 .addr = 0xfe1f0020, 447 .addr = 0xfe1f0020,
472 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT), 448 .chcr = CHCR_RX(XMIT_SZ_32BIT),
473 .mid_rid = 0xb2, 449 .mid_rid = 0xb2,
474 }, { 450 }, {
475 .slave_id = SHDMA_SLAVE_MMCIF_TX, 451 .slave_id = SHDMA_SLAVE_MMCIF_TX,
476 .addr = 0xe6bd0034, 452 .addr = 0xe6bd0034,
477 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT), 453 .chcr = CHCR_TX(XMIT_SZ_32BIT),
478 .mid_rid = 0xd1, 454 .mid_rid = 0xd1,
479 }, { 455 }, {
480 .slave_id = SHDMA_SLAVE_MMCIF_RX, 456 .slave_id = SHDMA_SLAVE_MMCIF_RX,
481 .addr = 0xe6bd0034, 457 .addr = 0xe6bd0034,
482 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT), 458 .chcr = CHCR_RX(XMIT_SZ_32BIT),
483 .mid_rid = 0xd2, 459 .mid_rid = 0xd2,
484 }, 460 },
485}; 461};
@@ -520,19 +496,17 @@ static const struct sh_dmae_channel sh7372_dmae_channels[] = {
520 } 496 }
521}; 497};
522 498
523static const unsigned int ts_shift[] = TS_SHIFT;
524
525static struct sh_dmae_pdata dma_platform_data = { 499static struct sh_dmae_pdata dma_platform_data = {
526 .slave = sh7372_dmae_slaves, 500 .slave = sh7372_dmae_slaves,
527 .slave_num = ARRAY_SIZE(sh7372_dmae_slaves), 501 .slave_num = ARRAY_SIZE(sh7372_dmae_slaves),
528 .channel = sh7372_dmae_channels, 502 .channel = sh7372_dmae_channels,
529 .channel_num = ARRAY_SIZE(sh7372_dmae_channels), 503 .channel_num = ARRAY_SIZE(sh7372_dmae_channels),
530 .ts_low_shift = 3, 504 .ts_low_shift = TS_LOW_SHIFT,
531 .ts_low_mask = 0x18, 505 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
532 .ts_high_shift = (20 - 2), /* 2 bits for shifted low TS */ 506 .ts_high_shift = TS_HI_SHIFT,
533 .ts_high_mask = 0x00300000, 507 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
534 .ts_shift = ts_shift, 508 .ts_shift = dma_ts_shift,
535 .ts_shift_num = ARRAY_SIZE(ts_shift), 509 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
536 .dmaor_init = DMAOR_DME, 510 .dmaor_init = DMAOR_DME,
537 .chclr_present = 1, 511 .chclr_present = 1,
538}; 512};
@@ -654,17 +628,6 @@ static struct platform_device dma2_device = {
654/* 628/*
655 * USB-DMAC 629 * USB-DMAC
656 */ 630 */
657
658unsigned int usbts_shift[] = {3, 4, 5};
659
660enum {
661 XMIT_SZ_8BYTE = 0,
662 XMIT_SZ_16BYTE = 1,
663 XMIT_SZ_32BYTE = 2,
664};
665
666#define USBTS_INDEX2VAL(i) (((i) & 3) << 6)
667
668static const struct sh_dmae_channel sh7372_usb_dmae_channels[] = { 631static const struct sh_dmae_channel sh7372_usb_dmae_channels[] = {
669 { 632 {
670 .offset = 0, 633 .offset = 0,
@@ -677,10 +640,10 @@ static const struct sh_dmae_channel sh7372_usb_dmae_channels[] = {
677static const struct sh_dmae_slave_config sh7372_usb_dmae0_slaves[] = { 640static const struct sh_dmae_slave_config sh7372_usb_dmae0_slaves[] = {
678 { 641 {
679 .slave_id = SHDMA_SLAVE_USB0_TX, 642 .slave_id = SHDMA_SLAVE_USB0_TX,
680 .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE), 643 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
681 }, { 644 }, {
682 .slave_id = SHDMA_SLAVE_USB0_RX, 645 .slave_id = SHDMA_SLAVE_USB0_RX,
683 .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE), 646 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
684 }, 647 },
685}; 648};
686 649
@@ -689,12 +652,12 @@ static struct sh_dmae_pdata usb_dma0_platform_data = {
689 .slave_num = ARRAY_SIZE(sh7372_usb_dmae0_slaves), 652 .slave_num = ARRAY_SIZE(sh7372_usb_dmae0_slaves),
690 .channel = sh7372_usb_dmae_channels, 653 .channel = sh7372_usb_dmae_channels,
691 .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels), 654 .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
692 .ts_low_shift = 6, 655 .ts_low_shift = USBTS_LOW_SHIFT,
693 .ts_low_mask = 0xc0, 656 .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
694 .ts_high_shift = 0, 657 .ts_high_shift = USBTS_HI_SHIFT,
695 .ts_high_mask = 0, 658 .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
696 .ts_shift = usbts_shift, 659 .ts_shift = dma_usbts_shift,
697 .ts_shift_num = ARRAY_SIZE(usbts_shift), 660 .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
698 .dmaor_init = DMAOR_DME, 661 .dmaor_init = DMAOR_DME,
699 .chcr_offset = 0x14, 662 .chcr_offset = 0x14,
700 .chcr_ie_bit = 1 << 5, 663 .chcr_ie_bit = 1 << 5,
@@ -739,10 +702,10 @@ static struct platform_device usb_dma0_device = {
739static const struct sh_dmae_slave_config sh7372_usb_dmae1_slaves[] = { 702static const struct sh_dmae_slave_config sh7372_usb_dmae1_slaves[] = {
740 { 703 {
741 .slave_id = SHDMA_SLAVE_USB1_TX, 704 .slave_id = SHDMA_SLAVE_USB1_TX,
742 .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE), 705 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
743 }, { 706 }, {
744 .slave_id = SHDMA_SLAVE_USB1_RX, 707 .slave_id = SHDMA_SLAVE_USB1_RX,
745 .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE), 708 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
746 }, 709 },
747}; 710};
748 711
@@ -751,12 +714,12 @@ static struct sh_dmae_pdata usb_dma1_platform_data = {
751 .slave_num = ARRAY_SIZE(sh7372_usb_dmae1_slaves), 714 .slave_num = ARRAY_SIZE(sh7372_usb_dmae1_slaves),
752 .channel = sh7372_usb_dmae_channels, 715 .channel = sh7372_usb_dmae_channels,
753 .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels), 716 .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
754 .ts_low_shift = 6, 717 .ts_low_shift = USBTS_LOW_SHIFT,
755 .ts_low_mask = 0xc0, 718 .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
756 .ts_high_shift = 0, 719 .ts_high_shift = USBTS_HI_SHIFT,
757 .ts_high_mask = 0, 720 .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
758 .ts_shift = usbts_shift, 721 .ts_shift = dma_usbts_shift,
759 .ts_shift_num = ARRAY_SIZE(usbts_shift), 722 .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
760 .dmaor_init = DMAOR_DME, 723 .dmaor_init = DMAOR_DME,
761 .chcr_offset = 0x14, 724 .chcr_offset = 0x14,
762 .chcr_ie_bit = 1 << 5, 725 .chcr_ie_bit = 1 << 5,
@@ -1038,21 +1001,21 @@ static struct platform_device *sh7372_late_devices[] __initdata = {
1038 1001
1039void __init sh7372_add_standard_devices(void) 1002void __init sh7372_add_standard_devices(void)
1040{ 1003{
1041 sh7372_init_pm_domain(&sh7372_a4lc); 1004 rmobile_init_pm_domain(&sh7372_pd_a4lc);
1042 sh7372_init_pm_domain(&sh7372_a4mp); 1005 rmobile_init_pm_domain(&sh7372_pd_a4mp);
1043 sh7372_init_pm_domain(&sh7372_d4); 1006 rmobile_init_pm_domain(&sh7372_pd_d4);
1044 sh7372_init_pm_domain(&sh7372_a4r); 1007 rmobile_init_pm_domain(&sh7372_pd_a4r);
1045 sh7372_init_pm_domain(&sh7372_a3rv); 1008 rmobile_init_pm_domain(&sh7372_pd_a3rv);
1046 sh7372_init_pm_domain(&sh7372_a3ri); 1009 rmobile_init_pm_domain(&sh7372_pd_a3ri);
1047 sh7372_init_pm_domain(&sh7372_a4s); 1010 rmobile_init_pm_domain(&sh7372_pd_a4s);
1048 sh7372_init_pm_domain(&sh7372_a3sp); 1011 rmobile_init_pm_domain(&sh7372_pd_a3sp);
1049 sh7372_init_pm_domain(&sh7372_a3sg); 1012 rmobile_init_pm_domain(&sh7372_pd_a3sg);
1050 1013
1051 sh7372_pm_add_subdomain(&sh7372_a4lc, &sh7372_a3rv); 1014 rmobile_pm_add_subdomain(&sh7372_pd_a4lc, &sh7372_pd_a3rv);
1052 sh7372_pm_add_subdomain(&sh7372_a4r, &sh7372_a4lc); 1015 rmobile_pm_add_subdomain(&sh7372_pd_a4r, &sh7372_pd_a4lc);
1053 1016
1054 sh7372_pm_add_subdomain(&sh7372_a4s, &sh7372_a3sg); 1017 rmobile_pm_add_subdomain(&sh7372_pd_a4s, &sh7372_pd_a3sg);
1055 sh7372_pm_add_subdomain(&sh7372_a4s, &sh7372_a3sp); 1018 rmobile_pm_add_subdomain(&sh7372_pd_a4s, &sh7372_pd_a3sp);
1056 1019
1057 platform_add_devices(sh7372_early_devices, 1020 platform_add_devices(sh7372_early_devices,
1058 ARRAY_SIZE(sh7372_early_devices)); 1021 ARRAY_SIZE(sh7372_early_devices));
@@ -1060,30 +1023,30 @@ void __init sh7372_add_standard_devices(void)
1060 platform_add_devices(sh7372_late_devices, 1023 platform_add_devices(sh7372_late_devices,
1061 ARRAY_SIZE(sh7372_late_devices)); 1024 ARRAY_SIZE(sh7372_late_devices));
1062 1025
1063 sh7372_add_device_to_domain(&sh7372_a3rv, &vpu_device); 1026 rmobile_add_device_to_domain(&sh7372_pd_a3rv, &vpu_device);
1064 sh7372_add_device_to_domain(&sh7372_a4mp, &spu0_device); 1027 rmobile_add_device_to_domain(&sh7372_pd_a4mp, &spu0_device);
1065 sh7372_add_device_to_domain(&sh7372_a4mp, &spu1_device); 1028 rmobile_add_device_to_domain(&sh7372_pd_a4mp, &spu1_device);
1066 sh7372_add_device_to_domain(&sh7372_a3sp, &scif0_device); 1029 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &scif0_device);
1067 sh7372_add_device_to_domain(&sh7372_a3sp, &scif1_device); 1030 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &scif1_device);
1068 sh7372_add_device_to_domain(&sh7372_a3sp, &scif2_device); 1031 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &scif2_device);
1069 sh7372_add_device_to_domain(&sh7372_a3sp, &scif3_device); 1032 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &scif3_device);
1070 sh7372_add_device_to_domain(&sh7372_a3sp, &scif4_device); 1033 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &scif4_device);
1071 sh7372_add_device_to_domain(&sh7372_a3sp, &scif5_device); 1034 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &scif5_device);
1072 sh7372_add_device_to_domain(&sh7372_a3sp, &scif6_device); 1035 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &scif6_device);
1073 sh7372_add_device_to_domain(&sh7372_a3sp, &iic1_device); 1036 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &iic1_device);
1074 sh7372_add_device_to_domain(&sh7372_a3sp, &dma0_device); 1037 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &dma0_device);
1075 sh7372_add_device_to_domain(&sh7372_a3sp, &dma1_device); 1038 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &dma1_device);
1076 sh7372_add_device_to_domain(&sh7372_a3sp, &dma2_device); 1039 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &dma2_device);
1077 sh7372_add_device_to_domain(&sh7372_a3sp, &usb_dma0_device); 1040 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &usb_dma0_device);
1078 sh7372_add_device_to_domain(&sh7372_a3sp, &usb_dma1_device); 1041 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &usb_dma1_device);
1079 sh7372_add_device_to_domain(&sh7372_a4r, &iic0_device); 1042 rmobile_add_device_to_domain(&sh7372_pd_a4r, &iic0_device);
1080 sh7372_add_device_to_domain(&sh7372_a4r, &veu0_device); 1043 rmobile_add_device_to_domain(&sh7372_pd_a4r, &veu0_device);
1081 sh7372_add_device_to_domain(&sh7372_a4r, &veu1_device); 1044 rmobile_add_device_to_domain(&sh7372_pd_a4r, &veu1_device);
1082 sh7372_add_device_to_domain(&sh7372_a4r, &veu2_device); 1045 rmobile_add_device_to_domain(&sh7372_pd_a4r, &veu2_device);
1083 sh7372_add_device_to_domain(&sh7372_a4r, &veu3_device); 1046 rmobile_add_device_to_domain(&sh7372_pd_a4r, &veu3_device);
1084 sh7372_add_device_to_domain(&sh7372_a4r, &jpu_device); 1047 rmobile_add_device_to_domain(&sh7372_pd_a4r, &jpu_device);
1085 sh7372_add_device_to_domain(&sh7372_a4r, &tmu00_device); 1048 rmobile_add_device_to_domain(&sh7372_pd_a4r, &tmu00_device);
1086 sh7372_add_device_to_domain(&sh7372_a4r, &tmu01_device); 1049 rmobile_add_device_to_domain(&sh7372_pd_a4r, &tmu01_device);
1087} 1050}
1088 1051
1089static void __init sh7372_earlytimer_init(void) 1052static void __init sh7372_earlytimer_init(void)
diff --git a/arch/arm/mach-shmobile/setup-sh7377.c b/arch/arm/mach-shmobile/setup-sh7377.c
index d576a6abbad..855b1506caf 100644
--- a/arch/arm/mach-shmobile/setup-sh7377.c
+++ b/arch/arm/mach-shmobile/setup-sh7377.c
@@ -22,6 +22,7 @@
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/irq.h> 23#include <linux/irq.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/of_platform.h>
25#include <linux/uio_driver.h> 26#include <linux/uio_driver.h>
26#include <linux/delay.h> 27#include <linux/delay.h>
27#include <linux/input.h> 28#include <linux/input.h>
@@ -500,3 +501,49 @@ void __init sh7377_add_early_devices(void)
500 /* override timer setup with soc-specific code */ 501 /* override timer setup with soc-specific code */
501 shmobile_timer.init = sh7377_earlytimer_init; 502 shmobile_timer.init = sh7377_earlytimer_init;
502} 503}
504
505#ifdef CONFIG_USE_OF
506
507void __init sh7377_add_early_devices_dt(void)
508{
509 shmobile_setup_delay(600, 1, 3); /* Cortex-A8 @ 600MHz */
510
511 early_platform_add_devices(sh7377_early_devices,
512 ARRAY_SIZE(sh7377_early_devices));
513
514 /* setup early console here as well */
515 shmobile_setup_console();
516}
517
518static const struct of_dev_auxdata sh7377_auxdata_lookup[] __initconst = {
519 { }
520};
521
522void __init sh7377_add_standard_devices_dt(void)
523{
524 /* clocks are setup late during boot in the case of DT */
525 sh7377_clock_init();
526
527 platform_add_devices(sh7377_early_devices,
528 ARRAY_SIZE(sh7377_early_devices));
529
530 of_platform_populate(NULL, of_default_bus_match_table,
531 sh7377_auxdata_lookup, NULL);
532}
533
534static const char *sh7377_boards_compat_dt[] __initdata = {
535 "renesas,sh7377",
536 NULL,
537};
538
539DT_MACHINE_START(SH7377_DT, "Generic SH7377 (Flattened Device Tree)")
540 .map_io = sh7377_map_io,
541 .init_early = sh7377_add_early_devices_dt,
542 .init_irq = sh7377_init_irq,
543 .handle_irq = shmobile_handle_irq_intc,
544 .init_machine = sh7377_add_standard_devices_dt,
545 .timer = &shmobile_timer,
546 .dt_compat = sh7377_boards_compat_dt,
547MACHINE_END
548
549#endif /* CONFIG_USE_OF */
diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
index 04a0dfe7549..d230af656fc 100644
--- a/arch/arm/mach-shmobile/setup-sh73a0.c
+++ b/arch/arm/mach-shmobile/setup-sh73a0.c
@@ -30,6 +30,7 @@
30#include <linux/sh_dma.h> 30#include <linux/sh_dma.h>
31#include <linux/sh_intc.h> 31#include <linux/sh_intc.h>
32#include <linux/sh_timer.h> 32#include <linux/sh_timer.h>
33#include <mach/dma-register.h>
33#include <mach/hardware.h> 34#include <mach/hardware.h>
34#include <mach/irqs.h> 35#include <mach/irqs.h>
35#include <mach/sh73a0.h> 36#include <mach/sh73a0.h>
@@ -415,32 +416,6 @@ static struct platform_device i2c4_device = {
415 .num_resources = ARRAY_SIZE(i2c4_resources), 416 .num_resources = ARRAY_SIZE(i2c4_resources),
416}; 417};
417 418
418/* Transmit sizes and respective CHCR register values */
419enum {
420 XMIT_SZ_8BIT = 0,
421 XMIT_SZ_16BIT = 1,
422 XMIT_SZ_32BIT = 2,
423 XMIT_SZ_64BIT = 7,
424 XMIT_SZ_128BIT = 3,
425 XMIT_SZ_256BIT = 4,
426 XMIT_SZ_512BIT = 5,
427};
428
429/* log2(size / 8) - used to calculate number of transfers */
430#define TS_SHIFT { \
431 [XMIT_SZ_8BIT] = 0, \
432 [XMIT_SZ_16BIT] = 1, \
433 [XMIT_SZ_32BIT] = 2, \
434 [XMIT_SZ_64BIT] = 3, \
435 [XMIT_SZ_128BIT] = 4, \
436 [XMIT_SZ_256BIT] = 5, \
437 [XMIT_SZ_512BIT] = 6, \
438}
439
440#define TS_INDEX2VAL(i) ((((i) & 3) << 3) | (((i) & 0xc) << (20 - 2)))
441#define CHCR_TX(xmit_sz) (DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL((xmit_sz)))
442#define CHCR_RX(xmit_sz) (DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL((xmit_sz)))
443
444static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = { 419static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = {
445 { 420 {
446 .slave_id = SHDMA_SLAVE_SCIF0_TX, 421 .slave_id = SHDMA_SLAVE_SCIF0_TX,
@@ -604,19 +579,17 @@ static const struct sh_dmae_channel sh73a0_dmae_channels[] = {
604 DMAE_CHANNEL(0x8980), 579 DMAE_CHANNEL(0x8980),
605}; 580};
606 581
607static const unsigned int ts_shift[] = TS_SHIFT;
608
609static struct sh_dmae_pdata sh73a0_dmae_platform_data = { 582static struct sh_dmae_pdata sh73a0_dmae_platform_data = {
610 .slave = sh73a0_dmae_slaves, 583 .slave = sh73a0_dmae_slaves,
611 .slave_num = ARRAY_SIZE(sh73a0_dmae_slaves), 584 .slave_num = ARRAY_SIZE(sh73a0_dmae_slaves),
612 .channel = sh73a0_dmae_channels, 585 .channel = sh73a0_dmae_channels,
613 .channel_num = ARRAY_SIZE(sh73a0_dmae_channels), 586 .channel_num = ARRAY_SIZE(sh73a0_dmae_channels),
614 .ts_low_shift = 3, 587 .ts_low_shift = TS_LOW_SHIFT,
615 .ts_low_mask = 0x18, 588 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
616 .ts_high_shift = (20 - 2), /* 2 bits for shifted low TS */ 589 .ts_high_shift = TS_HI_SHIFT,
617 .ts_high_mask = 0x00300000, 590 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
618 .ts_shift = ts_shift, 591 .ts_shift = dma_ts_shift,
619 .ts_shift_num = ARRAY_SIZE(ts_shift), 592 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
620 .dmaor_init = DMAOR_DME, 593 .dmaor_init = DMAOR_DME,
621}; 594};
622 595
@@ -651,6 +624,116 @@ static struct platform_device dma0_device = {
651 }, 624 },
652}; 625};
653 626
627/* MPDMAC */
628static const struct sh_dmae_slave_config sh73a0_mpdma_slaves[] = {
629 {
630 .slave_id = SHDMA_SLAVE_FSI2A_RX,
631 .addr = 0xec230020,
632 .chcr = CHCR_RX(XMIT_SZ_32BIT),
633 .mid_rid = 0xd6, /* CHECK ME */
634 }, {
635 .slave_id = SHDMA_SLAVE_FSI2A_TX,
636 .addr = 0xec230024,
637 .chcr = CHCR_TX(XMIT_SZ_32BIT),
638 .mid_rid = 0xd5, /* CHECK ME */
639 }, {
640 .slave_id = SHDMA_SLAVE_FSI2C_RX,
641 .addr = 0xec230060,
642 .chcr = CHCR_RX(XMIT_SZ_32BIT),
643 .mid_rid = 0xda, /* CHECK ME */
644 }, {
645 .slave_id = SHDMA_SLAVE_FSI2C_TX,
646 .addr = 0xec230064,
647 .chcr = CHCR_TX(XMIT_SZ_32BIT),
648 .mid_rid = 0xd9, /* CHECK ME */
649 }, {
650 .slave_id = SHDMA_SLAVE_FSI2B_RX,
651 .addr = 0xec240020,
652 .chcr = CHCR_RX(XMIT_SZ_32BIT),
653 .mid_rid = 0x8e, /* CHECK ME */
654 }, {
655 .slave_id = SHDMA_SLAVE_FSI2B_TX,
656 .addr = 0xec240024,
657 .chcr = CHCR_RX(XMIT_SZ_32BIT),
658 .mid_rid = 0x8d, /* CHECK ME */
659 }, {
660 .slave_id = SHDMA_SLAVE_FSI2D_RX,
661 .addr = 0xec240060,
662 .chcr = CHCR_RX(XMIT_SZ_32BIT),
663 .mid_rid = 0x9a, /* CHECK ME */
664 },
665};
666
667#define MPDMA_CHANNEL(a, b, c) \
668{ \
669 .offset = a, \
670 .dmars = b, \
671 .dmars_bit = c, \
672 .chclr_offset = (0x220 - 0x20) + a \
673}
674
675static const struct sh_dmae_channel sh73a0_mpdma_channels[] = {
676 MPDMA_CHANNEL(0x00, 0, 0),
677 MPDMA_CHANNEL(0x10, 0, 8),
678 MPDMA_CHANNEL(0x20, 4, 0),
679 MPDMA_CHANNEL(0x30, 4, 8),
680 MPDMA_CHANNEL(0x50, 8, 0),
681 MPDMA_CHANNEL(0x70, 8, 8),
682};
683
684static struct sh_dmae_pdata sh73a0_mpdma_platform_data = {
685 .slave = sh73a0_mpdma_slaves,
686 .slave_num = ARRAY_SIZE(sh73a0_mpdma_slaves),
687 .channel = sh73a0_mpdma_channels,
688 .channel_num = ARRAY_SIZE(sh73a0_mpdma_channels),
689 .ts_low_shift = TS_LOW_SHIFT,
690 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
691 .ts_high_shift = TS_HI_SHIFT,
692 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
693 .ts_shift = dma_ts_shift,
694 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
695 .dmaor_init = DMAOR_DME,
696 .chclr_present = 1,
697};
698
699/* Resource order important! */
700static struct resource sh73a0_mpdma_resources[] = {
701 {
702 /* Channel registers and DMAOR */
703 .start = 0xec618020,
704 .end = 0xec61828f,
705 .flags = IORESOURCE_MEM,
706 },
707 {
708 /* DMARSx */
709 .start = 0xec619000,
710 .end = 0xec61900b,
711 .flags = IORESOURCE_MEM,
712 },
713 {
714 .name = "error_irq",
715 .start = gic_spi(181),
716 .end = gic_spi(181),
717 .flags = IORESOURCE_IRQ,
718 },
719 {
720 /* IRQ for channels 0-5 */
721 .start = gic_spi(175),
722 .end = gic_spi(180),
723 .flags = IORESOURCE_IRQ,
724 },
725};
726
727static struct platform_device mpdma0_device = {
728 .name = "sh-dma-engine",
729 .id = 1,
730 .resource = sh73a0_mpdma_resources,
731 .num_resources = ARRAY_SIZE(sh73a0_mpdma_resources),
732 .dev = {
733 .platform_data = &sh73a0_mpdma_platform_data,
734 },
735};
736
654static struct platform_device *sh73a0_early_devices[] __initdata = { 737static struct platform_device *sh73a0_early_devices[] __initdata = {
655 &scif0_device, 738 &scif0_device,
656 &scif1_device, 739 &scif1_device,
@@ -673,6 +756,7 @@ static struct platform_device *sh73a0_late_devices[] __initdata = {
673 &i2c3_device, 756 &i2c3_device,
674 &i2c4_device, 757 &i2c4_device,
675 &dma0_device, 758 &dma0_device,
759 &mpdma0_device,
676}; 760};
677 761
678#define SRCR2 0xe61580b0 762#define SRCR2 0xe61580b0
diff --git a/arch/arm/mach-socfpga/Makefile b/arch/arm/mach-socfpga/Makefile
new file mode 100644
index 00000000000..4fb93240971
--- /dev/null
+++ b/arch/arm/mach-socfpga/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for the linux kernel.
3#
4
5obj-y := socfpga.o
diff --git a/arch/arm/mach-socfpga/Makefile.boot b/arch/arm/mach-socfpga/Makefile.boot
new file mode 100644
index 00000000000..dae9661a768
--- /dev/null
+++ b/arch/arm/mach-socfpga/Makefile.boot
@@ -0,0 +1 @@
zreladdr-y := 0x00008000
diff --git a/arch/arm/mach-socfpga/include/mach/debug-macro.S b/arch/arm/mach-socfpga/include/mach/debug-macro.S
new file mode 100644
index 00000000000..d6f26d23374
--- /dev/null
+++ b/arch/arm/mach-socfpga/include/mach/debug-macro.S
@@ -0,0 +1,16 @@
1/*
2 * Copyright (C) 1994-1999 Russell King
3 * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
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 version 2 as
7 * published by the Free Software Foundation.
8 */
9
10 .macro addruart, rp, rv, tmp
11 mov \rp, #DEBUG_LL_UART_OFFSET
12 orr \rp, \rp, #0x00c00000
13 orr \rv, \rp, #0xfe000000 @ virtual base
14 orr \rp, \rp, #0xff000000 @ physical base
15 .endm
16
diff --git a/arch/arm/mach-at91/include/mach/irqs.h b/arch/arm/mach-socfpga/include/mach/timex.h
index ac8b7dfc85e..43df4354e46 100644
--- a/arch/arm/mach-at91/include/mach/irqs.h
+++ b/arch/arm/mach-socfpga/include/mach/timex.h
@@ -1,7 +1,5 @@
1/* 1/*
2 * arch/arm/mach-at91/include/mach/irqs.h 2 * Copyright (C) 2003 ARM Limited
3 *
4 * Copyright (C) 2004 SAN People
5 * 3 *
6 * This program is free software; you can redistribute it and/or modify 4 * 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 5 * it under the terms of the GNU General Public License as published by
@@ -18,31 +16,4 @@
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 17 */
20 18
21#ifndef __ASM_ARCH_IRQS_H 19#define CLOCK_TICK_RATE (50000000 / 16)
22#define __ASM_ARCH_IRQS_H
23
24#include <linux/io.h>
25#include <mach/at91_aic.h>
26
27#define NR_AIC_IRQS 32
28
29
30/*
31 * Acknowledge interrupt with AIC after interrupt has been handled.
32 * (by kernel/irq.c)
33 */
34#define irq_finish(irq) do { at91_aic_write(AT91_AIC_EOICR, 0); } while (0)
35
36
37/*
38 * IRQ interrupt symbols are the AT91xxx_ID_* symbols
39 * for IRQs handled directly through the AIC, or else the AT91_PIN_*
40 * symbols in gpio.h for ones handled indirectly as GPIOs.
41 * We make provision for 5 banks of GPIO.
42 */
43#define NR_IRQS (NR_AIC_IRQS + (5 * 32))
44
45/* FIQ is AIC source 0. */
46#define FIQ_START AT91_ID_FIQ
47
48#endif
diff --git a/arch/arm/mach-socfpga/include/mach/uncompress.h b/arch/arm/mach-socfpga/include/mach/uncompress.h
new file mode 100644
index 00000000000..bbe20e69632
--- /dev/null
+++ b/arch/arm/mach-socfpga/include/mach/uncompress.h
@@ -0,0 +1,9 @@
1#ifndef __MACH_UNCOMPRESS_H
2#define __MACH_UNCOMPRESS_H
3
4#define putc(c)
5#define flush()
6#define arch_decomp_setup()
7#define arch_decomp_wdog()
8
9#endif
diff --git a/arch/arm/mach-socfpga/socfpga.c b/arch/arm/mach-socfpga/socfpga.c
new file mode 100644
index 00000000000..f01e1ebf539
--- /dev/null
+++ b/arch/arm/mach-socfpga/socfpga.c
@@ -0,0 +1,62 @@
1/*
2 * Copyright (C) 2012 Altera Corporation
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 as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17#include <linux/dw_apb_timer.h>
18#include <linux/of_irq.h>
19#include <linux/of_platform.h>
20
21#include <asm/hardware/cache-l2x0.h>
22#include <asm/hardware/gic.h>
23#include <asm/mach/arch.h>
24
25extern void socfpga_init_clocks(void);
26
27const static struct of_device_id irq_match[] = {
28 { .compatible = "arm,cortex-a9-gic", .data = gic_of_init, },
29 {}
30};
31
32static void __init gic_init_irq(void)
33{
34 of_irq_init(irq_match);
35}
36
37static void socfpga_cyclone5_restart(char mode, const char *cmd)
38{
39 /* TODO: */
40}
41
42static void __init socfpga_cyclone5_init(void)
43{
44 l2x0_of_init(0, ~0UL);
45 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
46 socfpga_init_clocks();
47}
48
49static const char *altera_dt_match[] = {
50 "altr,socfpga",
51 "altr,socfpga-cyclone5",
52 NULL
53};
54
55DT_MACHINE_START(SOCFPGA, "Altera SOCFPGA")
56 .init_irq = gic_init_irq,
57 .handle_irq = gic_handle_irq,
58 .timer = &dw_apb_timer,
59 .init_machine = socfpga_cyclone5_init,
60 .restart = socfpga_cyclone5_restart,
61 .dt_compat = altera_dt_match,
62MACHINE_END
diff --git a/arch/arm/mach-spear3xx/spear300.c b/arch/arm/mach-spear3xx/spear300.c
index 0f882ecb7d8..6ec30054996 100644
--- a/arch/arm/mach-spear3xx/spear300.c
+++ b/arch/arm/mach-spear3xx/spear300.c
@@ -120,182 +120,156 @@ struct pl08x_channel_data spear300_dma_info[] = {
120 .min_signal = 2, 120 .min_signal = 2,
121 .max_signal = 2, 121 .max_signal = 2,
122 .muxval = 0, 122 .muxval = 0,
123 .cctl = 0,
124 .periph_buses = PL08X_AHB1, 123 .periph_buses = PL08X_AHB1,
125 }, { 124 }, {
126 .bus_id = "uart0_tx", 125 .bus_id = "uart0_tx",
127 .min_signal = 3, 126 .min_signal = 3,
128 .max_signal = 3, 127 .max_signal = 3,
129 .muxval = 0, 128 .muxval = 0,
130 .cctl = 0,
131 .periph_buses = PL08X_AHB1, 129 .periph_buses = PL08X_AHB1,
132 }, { 130 }, {
133 .bus_id = "ssp0_rx", 131 .bus_id = "ssp0_rx",
134 .min_signal = 8, 132 .min_signal = 8,
135 .max_signal = 8, 133 .max_signal = 8,
136 .muxval = 0, 134 .muxval = 0,
137 .cctl = 0,
138 .periph_buses = PL08X_AHB1, 135 .periph_buses = PL08X_AHB1,
139 }, { 136 }, {
140 .bus_id = "ssp0_tx", 137 .bus_id = "ssp0_tx",
141 .min_signal = 9, 138 .min_signal = 9,
142 .max_signal = 9, 139 .max_signal = 9,
143 .muxval = 0, 140 .muxval = 0,
144 .cctl = 0,
145 .periph_buses = PL08X_AHB1, 141 .periph_buses = PL08X_AHB1,
146 }, { 142 }, {
147 .bus_id = "i2c_rx", 143 .bus_id = "i2c_rx",
148 .min_signal = 10, 144 .min_signal = 10,
149 .max_signal = 10, 145 .max_signal = 10,
150 .muxval = 0, 146 .muxval = 0,
151 .cctl = 0,
152 .periph_buses = PL08X_AHB1, 147 .periph_buses = PL08X_AHB1,
153 }, { 148 }, {
154 .bus_id = "i2c_tx", 149 .bus_id = "i2c_tx",
155 .min_signal = 11, 150 .min_signal = 11,
156 .max_signal = 11, 151 .max_signal = 11,
157 .muxval = 0, 152 .muxval = 0,
158 .cctl = 0,
159 .periph_buses = PL08X_AHB1, 153 .periph_buses = PL08X_AHB1,
160 }, { 154 }, {
161 .bus_id = "irda", 155 .bus_id = "irda",
162 .min_signal = 12, 156 .min_signal = 12,
163 .max_signal = 12, 157 .max_signal = 12,
164 .muxval = 0, 158 .muxval = 0,
165 .cctl = 0,
166 .periph_buses = PL08X_AHB1, 159 .periph_buses = PL08X_AHB1,
167 }, { 160 }, {
168 .bus_id = "adc", 161 .bus_id = "adc",
169 .min_signal = 13, 162 .min_signal = 13,
170 .max_signal = 13, 163 .max_signal = 13,
171 .muxval = 0, 164 .muxval = 0,
172 .cctl = 0,
173 .periph_buses = PL08X_AHB1, 165 .periph_buses = PL08X_AHB1,
174 }, { 166 }, {
175 .bus_id = "to_jpeg", 167 .bus_id = "to_jpeg",
176 .min_signal = 14, 168 .min_signal = 14,
177 .max_signal = 14, 169 .max_signal = 14,
178 .muxval = 0, 170 .muxval = 0,
179 .cctl = 0,
180 .periph_buses = PL08X_AHB1, 171 .periph_buses = PL08X_AHB1,
181 }, { 172 }, {
182 .bus_id = "from_jpeg", 173 .bus_id = "from_jpeg",
183 .min_signal = 15, 174 .min_signal = 15,
184 .max_signal = 15, 175 .max_signal = 15,
185 .muxval = 0, 176 .muxval = 0,
186 .cctl = 0,
187 .periph_buses = PL08X_AHB1, 177 .periph_buses = PL08X_AHB1,
188 }, { 178 }, {
189 .bus_id = "ras0_rx", 179 .bus_id = "ras0_rx",
190 .min_signal = 0, 180 .min_signal = 0,
191 .max_signal = 0, 181 .max_signal = 0,
192 .muxval = 1, 182 .muxval = 1,
193 .cctl = 0,
194 .periph_buses = PL08X_AHB1, 183 .periph_buses = PL08X_AHB1,
195 }, { 184 }, {
196 .bus_id = "ras0_tx", 185 .bus_id = "ras0_tx",
197 .min_signal = 1, 186 .min_signal = 1,
198 .max_signal = 1, 187 .max_signal = 1,
199 .muxval = 1, 188 .muxval = 1,
200 .cctl = 0,
201 .periph_buses = PL08X_AHB1, 189 .periph_buses = PL08X_AHB1,
202 }, { 190 }, {
203 .bus_id = "ras1_rx", 191 .bus_id = "ras1_rx",
204 .min_signal = 2, 192 .min_signal = 2,
205 .max_signal = 2, 193 .max_signal = 2,
206 .muxval = 1, 194 .muxval = 1,
207 .cctl = 0,
208 .periph_buses = PL08X_AHB1, 195 .periph_buses = PL08X_AHB1,
209 }, { 196 }, {
210 .bus_id = "ras1_tx", 197 .bus_id = "ras1_tx",
211 .min_signal = 3, 198 .min_signal = 3,
212 .max_signal = 3, 199 .max_signal = 3,
213 .muxval = 1, 200 .muxval = 1,
214 .cctl = 0,
215 .periph_buses = PL08X_AHB1, 201 .periph_buses = PL08X_AHB1,
216 }, { 202 }, {
217 .bus_id = "ras2_rx", 203 .bus_id = "ras2_rx",
218 .min_signal = 4, 204 .min_signal = 4,
219 .max_signal = 4, 205 .max_signal = 4,
220 .muxval = 1, 206 .muxval = 1,
221 .cctl = 0,
222 .periph_buses = PL08X_AHB1, 207 .periph_buses = PL08X_AHB1,
223 }, { 208 }, {
224 .bus_id = "ras2_tx", 209 .bus_id = "ras2_tx",
225 .min_signal = 5, 210 .min_signal = 5,
226 .max_signal = 5, 211 .max_signal = 5,
227 .muxval = 1, 212 .muxval = 1,
228 .cctl = 0,
229 .periph_buses = PL08X_AHB1, 213 .periph_buses = PL08X_AHB1,
230 }, { 214 }, {
231 .bus_id = "ras3_rx", 215 .bus_id = "ras3_rx",
232 .min_signal = 6, 216 .min_signal = 6,
233 .max_signal = 6, 217 .max_signal = 6,
234 .muxval = 1, 218 .muxval = 1,
235 .cctl = 0,
236 .periph_buses = PL08X_AHB1, 219 .periph_buses = PL08X_AHB1,
237 }, { 220 }, {
238 .bus_id = "ras3_tx", 221 .bus_id = "ras3_tx",
239 .min_signal = 7, 222 .min_signal = 7,
240 .max_signal = 7, 223 .max_signal = 7,
241 .muxval = 1, 224 .muxval = 1,
242 .cctl = 0,
243 .periph_buses = PL08X_AHB1, 225 .periph_buses = PL08X_AHB1,
244 }, { 226 }, {
245 .bus_id = "ras4_rx", 227 .bus_id = "ras4_rx",
246 .min_signal = 8, 228 .min_signal = 8,
247 .max_signal = 8, 229 .max_signal = 8,
248 .muxval = 1, 230 .muxval = 1,
249 .cctl = 0,
250 .periph_buses = PL08X_AHB1, 231 .periph_buses = PL08X_AHB1,
251 }, { 232 }, {
252 .bus_id = "ras4_tx", 233 .bus_id = "ras4_tx",
253 .min_signal = 9, 234 .min_signal = 9,
254 .max_signal = 9, 235 .max_signal = 9,
255 .muxval = 1, 236 .muxval = 1,
256 .cctl = 0,
257 .periph_buses = PL08X_AHB1, 237 .periph_buses = PL08X_AHB1,
258 }, { 238 }, {
259 .bus_id = "ras5_rx", 239 .bus_id = "ras5_rx",
260 .min_signal = 10, 240 .min_signal = 10,
261 .max_signal = 10, 241 .max_signal = 10,
262 .muxval = 1, 242 .muxval = 1,
263 .cctl = 0,
264 .periph_buses = PL08X_AHB1, 243 .periph_buses = PL08X_AHB1,
265 }, { 244 }, {
266 .bus_id = "ras5_tx", 245 .bus_id = "ras5_tx",
267 .min_signal = 11, 246 .min_signal = 11,
268 .max_signal = 11, 247 .max_signal = 11,
269 .muxval = 1, 248 .muxval = 1,
270 .cctl = 0,
271 .periph_buses = PL08X_AHB1, 249 .periph_buses = PL08X_AHB1,
272 }, { 250 }, {
273 .bus_id = "ras6_rx", 251 .bus_id = "ras6_rx",
274 .min_signal = 12, 252 .min_signal = 12,
275 .max_signal = 12, 253 .max_signal = 12,
276 .muxval = 1, 254 .muxval = 1,
277 .cctl = 0,
278 .periph_buses = PL08X_AHB1, 255 .periph_buses = PL08X_AHB1,
279 }, { 256 }, {
280 .bus_id = "ras6_tx", 257 .bus_id = "ras6_tx",
281 .min_signal = 13, 258 .min_signal = 13,
282 .max_signal = 13, 259 .max_signal = 13,
283 .muxval = 1, 260 .muxval = 1,
284 .cctl = 0,
285 .periph_buses = PL08X_AHB1, 261 .periph_buses = PL08X_AHB1,
286 }, { 262 }, {
287 .bus_id = "ras7_rx", 263 .bus_id = "ras7_rx",
288 .min_signal = 14, 264 .min_signal = 14,
289 .max_signal = 14, 265 .max_signal = 14,
290 .muxval = 1, 266 .muxval = 1,
291 .cctl = 0,
292 .periph_buses = PL08X_AHB1, 267 .periph_buses = PL08X_AHB1,
293 }, { 268 }, {
294 .bus_id = "ras7_tx", 269 .bus_id = "ras7_tx",
295 .min_signal = 15, 270 .min_signal = 15,
296 .max_signal = 15, 271 .max_signal = 15,
297 .muxval = 1, 272 .muxval = 1,
298 .cctl = 0,
299 .periph_buses = PL08X_AHB1, 273 .periph_buses = PL08X_AHB1,
300 }, 274 },
301}; 275};
diff --git a/arch/arm/mach-spear3xx/spear310.c b/arch/arm/mach-spear3xx/spear310.c
index bbcf4571d36..1d0e435b904 100644
--- a/arch/arm/mach-spear3xx/spear310.c
+++ b/arch/arm/mach-spear3xx/spear310.c
@@ -205,182 +205,156 @@ struct pl08x_channel_data spear310_dma_info[] = {
205 .min_signal = 2, 205 .min_signal = 2,
206 .max_signal = 2, 206 .max_signal = 2,
207 .muxval = 0, 207 .muxval = 0,
208 .cctl = 0,
209 .periph_buses = PL08X_AHB1, 208 .periph_buses = PL08X_AHB1,
210 }, { 209 }, {
211 .bus_id = "uart0_tx", 210 .bus_id = "uart0_tx",
212 .min_signal = 3, 211 .min_signal = 3,
213 .max_signal = 3, 212 .max_signal = 3,
214 .muxval = 0, 213 .muxval = 0,
215 .cctl = 0,
216 .periph_buses = PL08X_AHB1, 214 .periph_buses = PL08X_AHB1,
217 }, { 215 }, {
218 .bus_id = "ssp0_rx", 216 .bus_id = "ssp0_rx",
219 .min_signal = 8, 217 .min_signal = 8,
220 .max_signal = 8, 218 .max_signal = 8,
221 .muxval = 0, 219 .muxval = 0,
222 .cctl = 0,
223 .periph_buses = PL08X_AHB1, 220 .periph_buses = PL08X_AHB1,
224 }, { 221 }, {
225 .bus_id = "ssp0_tx", 222 .bus_id = "ssp0_tx",
226 .min_signal = 9, 223 .min_signal = 9,
227 .max_signal = 9, 224 .max_signal = 9,
228 .muxval = 0, 225 .muxval = 0,
229 .cctl = 0,
230 .periph_buses = PL08X_AHB1, 226 .periph_buses = PL08X_AHB1,
231 }, { 227 }, {
232 .bus_id = "i2c_rx", 228 .bus_id = "i2c_rx",
233 .min_signal = 10, 229 .min_signal = 10,
234 .max_signal = 10, 230 .max_signal = 10,
235 .muxval = 0, 231 .muxval = 0,
236 .cctl = 0,
237 .periph_buses = PL08X_AHB1, 232 .periph_buses = PL08X_AHB1,
238 }, { 233 }, {
239 .bus_id = "i2c_tx", 234 .bus_id = "i2c_tx",
240 .min_signal = 11, 235 .min_signal = 11,
241 .max_signal = 11, 236 .max_signal = 11,
242 .muxval = 0, 237 .muxval = 0,
243 .cctl = 0,
244 .periph_buses = PL08X_AHB1, 238 .periph_buses = PL08X_AHB1,
245 }, { 239 }, {
246 .bus_id = "irda", 240 .bus_id = "irda",
247 .min_signal = 12, 241 .min_signal = 12,
248 .max_signal = 12, 242 .max_signal = 12,
249 .muxval = 0, 243 .muxval = 0,
250 .cctl = 0,
251 .periph_buses = PL08X_AHB1, 244 .periph_buses = PL08X_AHB1,
252 }, { 245 }, {
253 .bus_id = "adc", 246 .bus_id = "adc",
254 .min_signal = 13, 247 .min_signal = 13,
255 .max_signal = 13, 248 .max_signal = 13,
256 .muxval = 0, 249 .muxval = 0,
257 .cctl = 0,
258 .periph_buses = PL08X_AHB1, 250 .periph_buses = PL08X_AHB1,
259 }, { 251 }, {
260 .bus_id = "to_jpeg", 252 .bus_id = "to_jpeg",
261 .min_signal = 14, 253 .min_signal = 14,
262 .max_signal = 14, 254 .max_signal = 14,
263 .muxval = 0, 255 .muxval = 0,
264 .cctl = 0,
265 .periph_buses = PL08X_AHB1, 256 .periph_buses = PL08X_AHB1,
266 }, { 257 }, {
267 .bus_id = "from_jpeg", 258 .bus_id = "from_jpeg",
268 .min_signal = 15, 259 .min_signal = 15,
269 .max_signal = 15, 260 .max_signal = 15,
270 .muxval = 0, 261 .muxval = 0,
271 .cctl = 0,
272 .periph_buses = PL08X_AHB1, 262 .periph_buses = PL08X_AHB1,
273 }, { 263 }, {
274 .bus_id = "uart1_rx", 264 .bus_id = "uart1_rx",
275 .min_signal = 0, 265 .min_signal = 0,
276 .max_signal = 0, 266 .max_signal = 0,
277 .muxval = 1, 267 .muxval = 1,
278 .cctl = 0,
279 .periph_buses = PL08X_AHB1, 268 .periph_buses = PL08X_AHB1,
280 }, { 269 }, {
281 .bus_id = "uart1_tx", 270 .bus_id = "uart1_tx",
282 .min_signal = 1, 271 .min_signal = 1,
283 .max_signal = 1, 272 .max_signal = 1,
284 .muxval = 1, 273 .muxval = 1,
285 .cctl = 0,
286 .periph_buses = PL08X_AHB1, 274 .periph_buses = PL08X_AHB1,
287 }, { 275 }, {
288 .bus_id = "uart2_rx", 276 .bus_id = "uart2_rx",
289 .min_signal = 2, 277 .min_signal = 2,
290 .max_signal = 2, 278 .max_signal = 2,
291 .muxval = 1, 279 .muxval = 1,
292 .cctl = 0,
293 .periph_buses = PL08X_AHB1, 280 .periph_buses = PL08X_AHB1,
294 }, { 281 }, {
295 .bus_id = "uart2_tx", 282 .bus_id = "uart2_tx",
296 .min_signal = 3, 283 .min_signal = 3,
297 .max_signal = 3, 284 .max_signal = 3,
298 .muxval = 1, 285 .muxval = 1,
299 .cctl = 0,
300 .periph_buses = PL08X_AHB1, 286 .periph_buses = PL08X_AHB1,
301 }, { 287 }, {
302 .bus_id = "uart3_rx", 288 .bus_id = "uart3_rx",
303 .min_signal = 4, 289 .min_signal = 4,
304 .max_signal = 4, 290 .max_signal = 4,
305 .muxval = 1, 291 .muxval = 1,
306 .cctl = 0,
307 .periph_buses = PL08X_AHB1, 292 .periph_buses = PL08X_AHB1,
308 }, { 293 }, {
309 .bus_id = "uart3_tx", 294 .bus_id = "uart3_tx",
310 .min_signal = 5, 295 .min_signal = 5,
311 .max_signal = 5, 296 .max_signal = 5,
312 .muxval = 1, 297 .muxval = 1,
313 .cctl = 0,
314 .periph_buses = PL08X_AHB1, 298 .periph_buses = PL08X_AHB1,
315 }, { 299 }, {
316 .bus_id = "uart4_rx", 300 .bus_id = "uart4_rx",
317 .min_signal = 6, 301 .min_signal = 6,
318 .max_signal = 6, 302 .max_signal = 6,
319 .muxval = 1, 303 .muxval = 1,
320 .cctl = 0,
321 .periph_buses = PL08X_AHB1, 304 .periph_buses = PL08X_AHB1,
322 }, { 305 }, {
323 .bus_id = "uart4_tx", 306 .bus_id = "uart4_tx",
324 .min_signal = 7, 307 .min_signal = 7,
325 .max_signal = 7, 308 .max_signal = 7,
326 .muxval = 1, 309 .muxval = 1,
327 .cctl = 0,
328 .periph_buses = PL08X_AHB1, 310 .periph_buses = PL08X_AHB1,
329 }, { 311 }, {
330 .bus_id = "uart5_rx", 312 .bus_id = "uart5_rx",
331 .min_signal = 8, 313 .min_signal = 8,
332 .max_signal = 8, 314 .max_signal = 8,
333 .muxval = 1, 315 .muxval = 1,
334 .cctl = 0,
335 .periph_buses = PL08X_AHB1, 316 .periph_buses = PL08X_AHB1,
336 }, { 317 }, {
337 .bus_id = "uart5_tx", 318 .bus_id = "uart5_tx",
338 .min_signal = 9, 319 .min_signal = 9,
339 .max_signal = 9, 320 .max_signal = 9,
340 .muxval = 1, 321 .muxval = 1,
341 .cctl = 0,
342 .periph_buses = PL08X_AHB1, 322 .periph_buses = PL08X_AHB1,
343 }, { 323 }, {
344 .bus_id = "ras5_rx", 324 .bus_id = "ras5_rx",
345 .min_signal = 10, 325 .min_signal = 10,
346 .max_signal = 10, 326 .max_signal = 10,
347 .muxval = 1, 327 .muxval = 1,
348 .cctl = 0,
349 .periph_buses = PL08X_AHB1, 328 .periph_buses = PL08X_AHB1,
350 }, { 329 }, {
351 .bus_id = "ras5_tx", 330 .bus_id = "ras5_tx",
352 .min_signal = 11, 331 .min_signal = 11,
353 .max_signal = 11, 332 .max_signal = 11,
354 .muxval = 1, 333 .muxval = 1,
355 .cctl = 0,
356 .periph_buses = PL08X_AHB1, 334 .periph_buses = PL08X_AHB1,
357 }, { 335 }, {
358 .bus_id = "ras6_rx", 336 .bus_id = "ras6_rx",
359 .min_signal = 12, 337 .min_signal = 12,
360 .max_signal = 12, 338 .max_signal = 12,
361 .muxval = 1, 339 .muxval = 1,
362 .cctl = 0,
363 .periph_buses = PL08X_AHB1, 340 .periph_buses = PL08X_AHB1,
364 }, { 341 }, {
365 .bus_id = "ras6_tx", 342 .bus_id = "ras6_tx",
366 .min_signal = 13, 343 .min_signal = 13,
367 .max_signal = 13, 344 .max_signal = 13,
368 .muxval = 1, 345 .muxval = 1,
369 .cctl = 0,
370 .periph_buses = PL08X_AHB1, 346 .periph_buses = PL08X_AHB1,
371 }, { 347 }, {
372 .bus_id = "ras7_rx", 348 .bus_id = "ras7_rx",
373 .min_signal = 14, 349 .min_signal = 14,
374 .max_signal = 14, 350 .max_signal = 14,
375 .muxval = 1, 351 .muxval = 1,
376 .cctl = 0,
377 .periph_buses = PL08X_AHB1, 352 .periph_buses = PL08X_AHB1,
378 }, { 353 }, {
379 .bus_id = "ras7_tx", 354 .bus_id = "ras7_tx",
380 .min_signal = 15, 355 .min_signal = 15,
381 .max_signal = 15, 356 .max_signal = 15,
382 .muxval = 1, 357 .muxval = 1,
383 .cctl = 0,
384 .periph_buses = PL08X_AHB1, 358 .periph_buses = PL08X_AHB1,
385 }, 359 },
386}; 360};
diff --git a/arch/arm/mach-spear3xx/spear320.c b/arch/arm/mach-spear3xx/spear320.c
index 88d483bcd66..fd823c62457 100644
--- a/arch/arm/mach-spear3xx/spear320.c
+++ b/arch/arm/mach-spear3xx/spear320.c
@@ -213,182 +213,156 @@ struct pl08x_channel_data spear320_dma_info[] = {
213 .min_signal = 2, 213 .min_signal = 2,
214 .max_signal = 2, 214 .max_signal = 2,
215 .muxval = 0, 215 .muxval = 0,
216 .cctl = 0,
217 .periph_buses = PL08X_AHB1, 216 .periph_buses = PL08X_AHB1,
218 }, { 217 }, {
219 .bus_id = "uart0_tx", 218 .bus_id = "uart0_tx",
220 .min_signal = 3, 219 .min_signal = 3,
221 .max_signal = 3, 220 .max_signal = 3,
222 .muxval = 0, 221 .muxval = 0,
223 .cctl = 0,
224 .periph_buses = PL08X_AHB1, 222 .periph_buses = PL08X_AHB1,
225 }, { 223 }, {
226 .bus_id = "ssp0_rx", 224 .bus_id = "ssp0_rx",
227 .min_signal = 8, 225 .min_signal = 8,
228 .max_signal = 8, 226 .max_signal = 8,
229 .muxval = 0, 227 .muxval = 0,
230 .cctl = 0,
231 .periph_buses = PL08X_AHB1, 228 .periph_buses = PL08X_AHB1,
232 }, { 229 }, {
233 .bus_id = "ssp0_tx", 230 .bus_id = "ssp0_tx",
234 .min_signal = 9, 231 .min_signal = 9,
235 .max_signal = 9, 232 .max_signal = 9,
236 .muxval = 0, 233 .muxval = 0,
237 .cctl = 0,
238 .periph_buses = PL08X_AHB1, 234 .periph_buses = PL08X_AHB1,
239 }, { 235 }, {
240 .bus_id = "i2c0_rx", 236 .bus_id = "i2c0_rx",
241 .min_signal = 10, 237 .min_signal = 10,
242 .max_signal = 10, 238 .max_signal = 10,
243 .muxval = 0, 239 .muxval = 0,
244 .cctl = 0,
245 .periph_buses = PL08X_AHB1, 240 .periph_buses = PL08X_AHB1,
246 }, { 241 }, {
247 .bus_id = "i2c0_tx", 242 .bus_id = "i2c0_tx",
248 .min_signal = 11, 243 .min_signal = 11,
249 .max_signal = 11, 244 .max_signal = 11,
250 .muxval = 0, 245 .muxval = 0,
251 .cctl = 0,
252 .periph_buses = PL08X_AHB1, 246 .periph_buses = PL08X_AHB1,
253 }, { 247 }, {
254 .bus_id = "irda", 248 .bus_id = "irda",
255 .min_signal = 12, 249 .min_signal = 12,
256 .max_signal = 12, 250 .max_signal = 12,
257 .muxval = 0, 251 .muxval = 0,
258 .cctl = 0,
259 .periph_buses = PL08X_AHB1, 252 .periph_buses = PL08X_AHB1,
260 }, { 253 }, {
261 .bus_id = "adc", 254 .bus_id = "adc",
262 .min_signal = 13, 255 .min_signal = 13,
263 .max_signal = 13, 256 .max_signal = 13,
264 .muxval = 0, 257 .muxval = 0,
265 .cctl = 0,
266 .periph_buses = PL08X_AHB1, 258 .periph_buses = PL08X_AHB1,
267 }, { 259 }, {
268 .bus_id = "to_jpeg", 260 .bus_id = "to_jpeg",
269 .min_signal = 14, 261 .min_signal = 14,
270 .max_signal = 14, 262 .max_signal = 14,
271 .muxval = 0, 263 .muxval = 0,
272 .cctl = 0,
273 .periph_buses = PL08X_AHB1, 264 .periph_buses = PL08X_AHB1,
274 }, { 265 }, {
275 .bus_id = "from_jpeg", 266 .bus_id = "from_jpeg",
276 .min_signal = 15, 267 .min_signal = 15,
277 .max_signal = 15, 268 .max_signal = 15,
278 .muxval = 0, 269 .muxval = 0,
279 .cctl = 0,
280 .periph_buses = PL08X_AHB1, 270 .periph_buses = PL08X_AHB1,
281 }, { 271 }, {
282 .bus_id = "ssp1_rx", 272 .bus_id = "ssp1_rx",
283 .min_signal = 0, 273 .min_signal = 0,
284 .max_signal = 0, 274 .max_signal = 0,
285 .muxval = 1, 275 .muxval = 1,
286 .cctl = 0,
287 .periph_buses = PL08X_AHB2, 276 .periph_buses = PL08X_AHB2,
288 }, { 277 }, {
289 .bus_id = "ssp1_tx", 278 .bus_id = "ssp1_tx",
290 .min_signal = 1, 279 .min_signal = 1,
291 .max_signal = 1, 280 .max_signal = 1,
292 .muxval = 1, 281 .muxval = 1,
293 .cctl = 0,
294 .periph_buses = PL08X_AHB2, 282 .periph_buses = PL08X_AHB2,
295 }, { 283 }, {
296 .bus_id = "ssp2_rx", 284 .bus_id = "ssp2_rx",
297 .min_signal = 2, 285 .min_signal = 2,
298 .max_signal = 2, 286 .max_signal = 2,
299 .muxval = 1, 287 .muxval = 1,
300 .cctl = 0,
301 .periph_buses = PL08X_AHB2, 288 .periph_buses = PL08X_AHB2,
302 }, { 289 }, {
303 .bus_id = "ssp2_tx", 290 .bus_id = "ssp2_tx",
304 .min_signal = 3, 291 .min_signal = 3,
305 .max_signal = 3, 292 .max_signal = 3,
306 .muxval = 1, 293 .muxval = 1,
307 .cctl = 0,
308 .periph_buses = PL08X_AHB2, 294 .periph_buses = PL08X_AHB2,
309 }, { 295 }, {
310 .bus_id = "uart1_rx", 296 .bus_id = "uart1_rx",
311 .min_signal = 4, 297 .min_signal = 4,
312 .max_signal = 4, 298 .max_signal = 4,
313 .muxval = 1, 299 .muxval = 1,
314 .cctl = 0,
315 .periph_buses = PL08X_AHB2, 300 .periph_buses = PL08X_AHB2,
316 }, { 301 }, {
317 .bus_id = "uart1_tx", 302 .bus_id = "uart1_tx",
318 .min_signal = 5, 303 .min_signal = 5,
319 .max_signal = 5, 304 .max_signal = 5,
320 .muxval = 1, 305 .muxval = 1,
321 .cctl = 0,
322 .periph_buses = PL08X_AHB2, 306 .periph_buses = PL08X_AHB2,
323 }, { 307 }, {
324 .bus_id = "uart2_rx", 308 .bus_id = "uart2_rx",
325 .min_signal = 6, 309 .min_signal = 6,
326 .max_signal = 6, 310 .max_signal = 6,
327 .muxval = 1, 311 .muxval = 1,
328 .cctl = 0,
329 .periph_buses = PL08X_AHB2, 312 .periph_buses = PL08X_AHB2,
330 }, { 313 }, {
331 .bus_id = "uart2_tx", 314 .bus_id = "uart2_tx",
332 .min_signal = 7, 315 .min_signal = 7,
333 .max_signal = 7, 316 .max_signal = 7,
334 .muxval = 1, 317 .muxval = 1,
335 .cctl = 0,
336 .periph_buses = PL08X_AHB2, 318 .periph_buses = PL08X_AHB2,
337 }, { 319 }, {
338 .bus_id = "i2c1_rx", 320 .bus_id = "i2c1_rx",
339 .min_signal = 8, 321 .min_signal = 8,
340 .max_signal = 8, 322 .max_signal = 8,
341 .muxval = 1, 323 .muxval = 1,
342 .cctl = 0,
343 .periph_buses = PL08X_AHB2, 324 .periph_buses = PL08X_AHB2,
344 }, { 325 }, {
345 .bus_id = "i2c1_tx", 326 .bus_id = "i2c1_tx",
346 .min_signal = 9, 327 .min_signal = 9,
347 .max_signal = 9, 328 .max_signal = 9,
348 .muxval = 1, 329 .muxval = 1,
349 .cctl = 0,
350 .periph_buses = PL08X_AHB2, 330 .periph_buses = PL08X_AHB2,
351 }, { 331 }, {
352 .bus_id = "i2c2_rx", 332 .bus_id = "i2c2_rx",
353 .min_signal = 10, 333 .min_signal = 10,
354 .max_signal = 10, 334 .max_signal = 10,
355 .muxval = 1, 335 .muxval = 1,
356 .cctl = 0,
357 .periph_buses = PL08X_AHB2, 336 .periph_buses = PL08X_AHB2,
358 }, { 337 }, {
359 .bus_id = "i2c2_tx", 338 .bus_id = "i2c2_tx",
360 .min_signal = 11, 339 .min_signal = 11,
361 .max_signal = 11, 340 .max_signal = 11,
362 .muxval = 1, 341 .muxval = 1,
363 .cctl = 0,
364 .periph_buses = PL08X_AHB2, 342 .periph_buses = PL08X_AHB2,
365 }, { 343 }, {
366 .bus_id = "i2s_rx", 344 .bus_id = "i2s_rx",
367 .min_signal = 12, 345 .min_signal = 12,
368 .max_signal = 12, 346 .max_signal = 12,
369 .muxval = 1, 347 .muxval = 1,
370 .cctl = 0,
371 .periph_buses = PL08X_AHB2, 348 .periph_buses = PL08X_AHB2,
372 }, { 349 }, {
373 .bus_id = "i2s_tx", 350 .bus_id = "i2s_tx",
374 .min_signal = 13, 351 .min_signal = 13,
375 .max_signal = 13, 352 .max_signal = 13,
376 .muxval = 1, 353 .muxval = 1,
377 .cctl = 0,
378 .periph_buses = PL08X_AHB2, 354 .periph_buses = PL08X_AHB2,
379 }, { 355 }, {
380 .bus_id = "rs485_rx", 356 .bus_id = "rs485_rx",
381 .min_signal = 14, 357 .min_signal = 14,
382 .max_signal = 14, 358 .max_signal = 14,
383 .muxval = 1, 359 .muxval = 1,
384 .cctl = 0,
385 .periph_buses = PL08X_AHB2, 360 .periph_buses = PL08X_AHB2,
386 }, { 361 }, {
387 .bus_id = "rs485_tx", 362 .bus_id = "rs485_tx",
388 .min_signal = 15, 363 .min_signal = 15,
389 .max_signal = 15, 364 .max_signal = 15,
390 .muxval = 1, 365 .muxval = 1,
391 .cctl = 0,
392 .periph_buses = PL08X_AHB2, 366 .periph_buses = PL08X_AHB2,
393 }, 367 },
394}; 368};
diff --git a/arch/arm/mach-spear3xx/spear3xx.c b/arch/arm/mach-spear3xx/spear3xx.c
index 66db5f13af8..98144baf888 100644
--- a/arch/arm/mach-spear3xx/spear3xx.c
+++ b/arch/arm/mach-spear3xx/spear3xx.c
@@ -46,7 +46,8 @@ struct pl022_ssp_controller pl022_plat_data = {
46struct pl08x_platform_data pl080_plat_data = { 46struct pl08x_platform_data pl080_plat_data = {
47 .memcpy_channel = { 47 .memcpy_channel = {
48 .bus_id = "memcpy", 48 .bus_id = "memcpy",
49 .cctl = (PL080_BSIZE_16 << PL080_CONTROL_SB_SIZE_SHIFT | \ 49 .cctl_memcpy =
50 (PL080_BSIZE_16 << PL080_CONTROL_SB_SIZE_SHIFT | \
50 PL080_BSIZE_16 << PL080_CONTROL_DB_SIZE_SHIFT | \ 51 PL080_BSIZE_16 << PL080_CONTROL_DB_SIZE_SHIFT | \
51 PL080_WIDTH_32BIT << PL080_CONTROL_SWIDTH_SHIFT | \ 52 PL080_WIDTH_32BIT << PL080_CONTROL_SWIDTH_SHIFT | \
52 PL080_WIDTH_32BIT << PL080_CONTROL_DWIDTH_SHIFT | \ 53 PL080_WIDTH_32BIT << PL080_CONTROL_DWIDTH_SHIFT | \
diff --git a/arch/arm/mach-spear6xx/spear6xx.c b/arch/arm/mach-spear6xx/spear6xx.c
index 9af67d003c6..5a5a52db252 100644
--- a/arch/arm/mach-spear6xx/spear6xx.c
+++ b/arch/arm/mach-spear6xx/spear6xx.c
@@ -36,336 +36,288 @@ static struct pl08x_channel_data spear600_dma_info[] = {
36 .min_signal = 0, 36 .min_signal = 0,
37 .max_signal = 0, 37 .max_signal = 0,
38 .muxval = 0, 38 .muxval = 0,
39 .cctl = 0,
40 .periph_buses = PL08X_AHB1, 39 .periph_buses = PL08X_AHB1,
41 }, { 40 }, {
42 .bus_id = "ssp1_tx", 41 .bus_id = "ssp1_tx",
43 .min_signal = 1, 42 .min_signal = 1,
44 .max_signal = 1, 43 .max_signal = 1,
45 .muxval = 0, 44 .muxval = 0,
46 .cctl = 0,
47 .periph_buses = PL08X_AHB1, 45 .periph_buses = PL08X_AHB1,
48 }, { 46 }, {
49 .bus_id = "uart0_rx", 47 .bus_id = "uart0_rx",
50 .min_signal = 2, 48 .min_signal = 2,
51 .max_signal = 2, 49 .max_signal = 2,
52 .muxval = 0, 50 .muxval = 0,
53 .cctl = 0,
54 .periph_buses = PL08X_AHB1, 51 .periph_buses = PL08X_AHB1,
55 }, { 52 }, {
56 .bus_id = "uart0_tx", 53 .bus_id = "uart0_tx",
57 .min_signal = 3, 54 .min_signal = 3,
58 .max_signal = 3, 55 .max_signal = 3,
59 .muxval = 0, 56 .muxval = 0,
60 .cctl = 0,
61 .periph_buses = PL08X_AHB1, 57 .periph_buses = PL08X_AHB1,
62 }, { 58 }, {
63 .bus_id = "uart1_rx", 59 .bus_id = "uart1_rx",
64 .min_signal = 4, 60 .min_signal = 4,
65 .max_signal = 4, 61 .max_signal = 4,
66 .muxval = 0, 62 .muxval = 0,
67 .cctl = 0,
68 .periph_buses = PL08X_AHB1, 63 .periph_buses = PL08X_AHB1,
69 }, { 64 }, {
70 .bus_id = "uart1_tx", 65 .bus_id = "uart1_tx",
71 .min_signal = 5, 66 .min_signal = 5,
72 .max_signal = 5, 67 .max_signal = 5,
73 .muxval = 0, 68 .muxval = 0,
74 .cctl = 0,
75 .periph_buses = PL08X_AHB1, 69 .periph_buses = PL08X_AHB1,
76 }, { 70 }, {
77 .bus_id = "ssp2_rx", 71 .bus_id = "ssp2_rx",
78 .min_signal = 6, 72 .min_signal = 6,
79 .max_signal = 6, 73 .max_signal = 6,
80 .muxval = 0, 74 .muxval = 0,
81 .cctl = 0,
82 .periph_buses = PL08X_AHB2, 75 .periph_buses = PL08X_AHB2,
83 }, { 76 }, {
84 .bus_id = "ssp2_tx", 77 .bus_id = "ssp2_tx",
85 .min_signal = 7, 78 .min_signal = 7,
86 .max_signal = 7, 79 .max_signal = 7,
87 .muxval = 0, 80 .muxval = 0,
88 .cctl = 0,
89 .periph_buses = PL08X_AHB2, 81 .periph_buses = PL08X_AHB2,
90 }, { 82 }, {
91 .bus_id = "ssp0_rx", 83 .bus_id = "ssp0_rx",
92 .min_signal = 8, 84 .min_signal = 8,
93 .max_signal = 8, 85 .max_signal = 8,
94 .muxval = 0, 86 .muxval = 0,
95 .cctl = 0,
96 .periph_buses = PL08X_AHB1, 87 .periph_buses = PL08X_AHB1,
97 }, { 88 }, {
98 .bus_id = "ssp0_tx", 89 .bus_id = "ssp0_tx",
99 .min_signal = 9, 90 .min_signal = 9,
100 .max_signal = 9, 91 .max_signal = 9,
101 .muxval = 0, 92 .muxval = 0,
102 .cctl = 0,
103 .periph_buses = PL08X_AHB1, 93 .periph_buses = PL08X_AHB1,
104 }, { 94 }, {
105 .bus_id = "i2c_rx", 95 .bus_id = "i2c_rx",
106 .min_signal = 10, 96 .min_signal = 10,
107 .max_signal = 10, 97 .max_signal = 10,
108 .muxval = 0, 98 .muxval = 0,
109 .cctl = 0,
110 .periph_buses = PL08X_AHB1, 99 .periph_buses = PL08X_AHB1,
111 }, { 100 }, {
112 .bus_id = "i2c_tx", 101 .bus_id = "i2c_tx",
113 .min_signal = 11, 102 .min_signal = 11,
114 .max_signal = 11, 103 .max_signal = 11,
115 .muxval = 0, 104 .muxval = 0,
116 .cctl = 0,
117 .periph_buses = PL08X_AHB1, 105 .periph_buses = PL08X_AHB1,
118 }, { 106 }, {
119 .bus_id = "irda", 107 .bus_id = "irda",
120 .min_signal = 12, 108 .min_signal = 12,
121 .max_signal = 12, 109 .max_signal = 12,
122 .muxval = 0, 110 .muxval = 0,
123 .cctl = 0,
124 .periph_buses = PL08X_AHB1, 111 .periph_buses = PL08X_AHB1,
125 }, { 112 }, {
126 .bus_id = "adc", 113 .bus_id = "adc",
127 .min_signal = 13, 114 .min_signal = 13,
128 .max_signal = 13, 115 .max_signal = 13,
129 .muxval = 0, 116 .muxval = 0,
130 .cctl = 0,
131 .periph_buses = PL08X_AHB2, 117 .periph_buses = PL08X_AHB2,
132 }, { 118 }, {
133 .bus_id = "to_jpeg", 119 .bus_id = "to_jpeg",
134 .min_signal = 14, 120 .min_signal = 14,
135 .max_signal = 14, 121 .max_signal = 14,
136 .muxval = 0, 122 .muxval = 0,
137 .cctl = 0,
138 .periph_buses = PL08X_AHB1, 123 .periph_buses = PL08X_AHB1,
139 }, { 124 }, {
140 .bus_id = "from_jpeg", 125 .bus_id = "from_jpeg",
141 .min_signal = 15, 126 .min_signal = 15,
142 .max_signal = 15, 127 .max_signal = 15,
143 .muxval = 0, 128 .muxval = 0,
144 .cctl = 0,
145 .periph_buses = PL08X_AHB1, 129 .periph_buses = PL08X_AHB1,
146 }, { 130 }, {
147 .bus_id = "ras0_rx", 131 .bus_id = "ras0_rx",
148 .min_signal = 0, 132 .min_signal = 0,
149 .max_signal = 0, 133 .max_signal = 0,
150 .muxval = 1, 134 .muxval = 1,
151 .cctl = 0,
152 .periph_buses = PL08X_AHB1, 135 .periph_buses = PL08X_AHB1,
153 }, { 136 }, {
154 .bus_id = "ras0_tx", 137 .bus_id = "ras0_tx",
155 .min_signal = 1, 138 .min_signal = 1,
156 .max_signal = 1, 139 .max_signal = 1,
157 .muxval = 1, 140 .muxval = 1,
158 .cctl = 0,
159 .periph_buses = PL08X_AHB1, 141 .periph_buses = PL08X_AHB1,
160 }, { 142 }, {
161 .bus_id = "ras1_rx", 143 .bus_id = "ras1_rx",
162 .min_signal = 2, 144 .min_signal = 2,
163 .max_signal = 2, 145 .max_signal = 2,
164 .muxval = 1, 146 .muxval = 1,
165 .cctl = 0,
166 .periph_buses = PL08X_AHB1, 147 .periph_buses = PL08X_AHB1,
167 }, { 148 }, {
168 .bus_id = "ras1_tx", 149 .bus_id = "ras1_tx",
169 .min_signal = 3, 150 .min_signal = 3,
170 .max_signal = 3, 151 .max_signal = 3,
171 .muxval = 1, 152 .muxval = 1,
172 .cctl = 0,
173 .periph_buses = PL08X_AHB1, 153 .periph_buses = PL08X_AHB1,
174 }, { 154 }, {
175 .bus_id = "ras2_rx", 155 .bus_id = "ras2_rx",
176 .min_signal = 4, 156 .min_signal = 4,
177 .max_signal = 4, 157 .max_signal = 4,
178 .muxval = 1, 158 .muxval = 1,
179 .cctl = 0,
180 .periph_buses = PL08X_AHB1, 159 .periph_buses = PL08X_AHB1,
181 }, { 160 }, {
182 .bus_id = "ras2_tx", 161 .bus_id = "ras2_tx",
183 .min_signal = 5, 162 .min_signal = 5,
184 .max_signal = 5, 163 .max_signal = 5,
185 .muxval = 1, 164 .muxval = 1,
186 .cctl = 0,
187 .periph_buses = PL08X_AHB1, 165 .periph_buses = PL08X_AHB1,
188 }, { 166 }, {
189 .bus_id = "ras3_rx", 167 .bus_id = "ras3_rx",
190 .min_signal = 6, 168 .min_signal = 6,
191 .max_signal = 6, 169 .max_signal = 6,
192 .muxval = 1, 170 .muxval = 1,
193 .cctl = 0,
194 .periph_buses = PL08X_AHB1, 171 .periph_buses = PL08X_AHB1,
195 }, { 172 }, {
196 .bus_id = "ras3_tx", 173 .bus_id = "ras3_tx",
197 .min_signal = 7, 174 .min_signal = 7,
198 .max_signal = 7, 175 .max_signal = 7,
199 .muxval = 1, 176 .muxval = 1,
200 .cctl = 0,
201 .periph_buses = PL08X_AHB1, 177 .periph_buses = PL08X_AHB1,
202 }, { 178 }, {
203 .bus_id = "ras4_rx", 179 .bus_id = "ras4_rx",
204 .min_signal = 8, 180 .min_signal = 8,
205 .max_signal = 8, 181 .max_signal = 8,
206 .muxval = 1, 182 .muxval = 1,
207 .cctl = 0,
208 .periph_buses = PL08X_AHB1, 183 .periph_buses = PL08X_AHB1,
209 }, { 184 }, {
210 .bus_id = "ras4_tx", 185 .bus_id = "ras4_tx",
211 .min_signal = 9, 186 .min_signal = 9,
212 .max_signal = 9, 187 .max_signal = 9,
213 .muxval = 1, 188 .muxval = 1,
214 .cctl = 0,
215 .periph_buses = PL08X_AHB1, 189 .periph_buses = PL08X_AHB1,
216 }, { 190 }, {
217 .bus_id = "ras5_rx", 191 .bus_id = "ras5_rx",
218 .min_signal = 10, 192 .min_signal = 10,
219 .max_signal = 10, 193 .max_signal = 10,
220 .muxval = 1, 194 .muxval = 1,
221 .cctl = 0,
222 .periph_buses = PL08X_AHB1, 195 .periph_buses = PL08X_AHB1,
223 }, { 196 }, {
224 .bus_id = "ras5_tx", 197 .bus_id = "ras5_tx",
225 .min_signal = 11, 198 .min_signal = 11,
226 .max_signal = 11, 199 .max_signal = 11,
227 .muxval = 1, 200 .muxval = 1,
228 .cctl = 0,
229 .periph_buses = PL08X_AHB1, 201 .periph_buses = PL08X_AHB1,
230 }, { 202 }, {
231 .bus_id = "ras6_rx", 203 .bus_id = "ras6_rx",
232 .min_signal = 12, 204 .min_signal = 12,
233 .max_signal = 12, 205 .max_signal = 12,
234 .muxval = 1, 206 .muxval = 1,
235 .cctl = 0,
236 .periph_buses = PL08X_AHB1, 207 .periph_buses = PL08X_AHB1,
237 }, { 208 }, {
238 .bus_id = "ras6_tx", 209 .bus_id = "ras6_tx",
239 .min_signal = 13, 210 .min_signal = 13,
240 .max_signal = 13, 211 .max_signal = 13,
241 .muxval = 1, 212 .muxval = 1,
242 .cctl = 0,
243 .periph_buses = PL08X_AHB1, 213 .periph_buses = PL08X_AHB1,
244 }, { 214 }, {
245 .bus_id = "ras7_rx", 215 .bus_id = "ras7_rx",
246 .min_signal = 14, 216 .min_signal = 14,
247 .max_signal = 14, 217 .max_signal = 14,
248 .muxval = 1, 218 .muxval = 1,
249 .cctl = 0,
250 .periph_buses = PL08X_AHB1, 219 .periph_buses = PL08X_AHB1,
251 }, { 220 }, {
252 .bus_id = "ras7_tx", 221 .bus_id = "ras7_tx",
253 .min_signal = 15, 222 .min_signal = 15,
254 .max_signal = 15, 223 .max_signal = 15,
255 .muxval = 1, 224 .muxval = 1,
256 .cctl = 0,
257 .periph_buses = PL08X_AHB1, 225 .periph_buses = PL08X_AHB1,
258 }, { 226 }, {
259 .bus_id = "ext0_rx", 227 .bus_id = "ext0_rx",
260 .min_signal = 0, 228 .min_signal = 0,
261 .max_signal = 0, 229 .max_signal = 0,
262 .muxval = 2, 230 .muxval = 2,
263 .cctl = 0,
264 .periph_buses = PL08X_AHB2, 231 .periph_buses = PL08X_AHB2,
265 }, { 232 }, {
266 .bus_id = "ext0_tx", 233 .bus_id = "ext0_tx",
267 .min_signal = 1, 234 .min_signal = 1,
268 .max_signal = 1, 235 .max_signal = 1,
269 .muxval = 2, 236 .muxval = 2,
270 .cctl = 0,
271 .periph_buses = PL08X_AHB2, 237 .periph_buses = PL08X_AHB2,
272 }, { 238 }, {
273 .bus_id = "ext1_rx", 239 .bus_id = "ext1_rx",
274 .min_signal = 2, 240 .min_signal = 2,
275 .max_signal = 2, 241 .max_signal = 2,
276 .muxval = 2, 242 .muxval = 2,
277 .cctl = 0,
278 .periph_buses = PL08X_AHB2, 243 .periph_buses = PL08X_AHB2,
279 }, { 244 }, {
280 .bus_id = "ext1_tx", 245 .bus_id = "ext1_tx",
281 .min_signal = 3, 246 .min_signal = 3,
282 .max_signal = 3, 247 .max_signal = 3,
283 .muxval = 2, 248 .muxval = 2,
284 .cctl = 0,
285 .periph_buses = PL08X_AHB2, 249 .periph_buses = PL08X_AHB2,
286 }, { 250 }, {
287 .bus_id = "ext2_rx", 251 .bus_id = "ext2_rx",
288 .min_signal = 4, 252 .min_signal = 4,
289 .max_signal = 4, 253 .max_signal = 4,
290 .muxval = 2, 254 .muxval = 2,
291 .cctl = 0,
292 .periph_buses = PL08X_AHB2, 255 .periph_buses = PL08X_AHB2,
293 }, { 256 }, {
294 .bus_id = "ext2_tx", 257 .bus_id = "ext2_tx",
295 .min_signal = 5, 258 .min_signal = 5,
296 .max_signal = 5, 259 .max_signal = 5,
297 .muxval = 2, 260 .muxval = 2,
298 .cctl = 0,
299 .periph_buses = PL08X_AHB2, 261 .periph_buses = PL08X_AHB2,
300 }, { 262 }, {
301 .bus_id = "ext3_rx", 263 .bus_id = "ext3_rx",
302 .min_signal = 6, 264 .min_signal = 6,
303 .max_signal = 6, 265 .max_signal = 6,
304 .muxval = 2, 266 .muxval = 2,
305 .cctl = 0,
306 .periph_buses = PL08X_AHB2, 267 .periph_buses = PL08X_AHB2,
307 }, { 268 }, {
308 .bus_id = "ext3_tx", 269 .bus_id = "ext3_tx",
309 .min_signal = 7, 270 .min_signal = 7,
310 .max_signal = 7, 271 .max_signal = 7,
311 .muxval = 2, 272 .muxval = 2,
312 .cctl = 0,
313 .periph_buses = PL08X_AHB2, 273 .periph_buses = PL08X_AHB2,
314 }, { 274 }, {
315 .bus_id = "ext4_rx", 275 .bus_id = "ext4_rx",
316 .min_signal = 8, 276 .min_signal = 8,
317 .max_signal = 8, 277 .max_signal = 8,
318 .muxval = 2, 278 .muxval = 2,
319 .cctl = 0,
320 .periph_buses = PL08X_AHB2, 279 .periph_buses = PL08X_AHB2,
321 }, { 280 }, {
322 .bus_id = "ext4_tx", 281 .bus_id = "ext4_tx",
323 .min_signal = 9, 282 .min_signal = 9,
324 .max_signal = 9, 283 .max_signal = 9,
325 .muxval = 2, 284 .muxval = 2,
326 .cctl = 0,
327 .periph_buses = PL08X_AHB2, 285 .periph_buses = PL08X_AHB2,
328 }, { 286 }, {
329 .bus_id = "ext5_rx", 287 .bus_id = "ext5_rx",
330 .min_signal = 10, 288 .min_signal = 10,
331 .max_signal = 10, 289 .max_signal = 10,
332 .muxval = 2, 290 .muxval = 2,
333 .cctl = 0,
334 .periph_buses = PL08X_AHB2, 291 .periph_buses = PL08X_AHB2,
335 }, { 292 }, {
336 .bus_id = "ext5_tx", 293 .bus_id = "ext5_tx",
337 .min_signal = 11, 294 .min_signal = 11,
338 .max_signal = 11, 295 .max_signal = 11,
339 .muxval = 2, 296 .muxval = 2,
340 .cctl = 0,
341 .periph_buses = PL08X_AHB2, 297 .periph_buses = PL08X_AHB2,
342 }, { 298 }, {
343 .bus_id = "ext6_rx", 299 .bus_id = "ext6_rx",
344 .min_signal = 12, 300 .min_signal = 12,
345 .max_signal = 12, 301 .max_signal = 12,
346 .muxval = 2, 302 .muxval = 2,
347 .cctl = 0,
348 .periph_buses = PL08X_AHB2, 303 .periph_buses = PL08X_AHB2,
349 }, { 304 }, {
350 .bus_id = "ext6_tx", 305 .bus_id = "ext6_tx",
351 .min_signal = 13, 306 .min_signal = 13,
352 .max_signal = 13, 307 .max_signal = 13,
353 .muxval = 2, 308 .muxval = 2,
354 .cctl = 0,
355 .periph_buses = PL08X_AHB2, 309 .periph_buses = PL08X_AHB2,
356 }, { 310 }, {
357 .bus_id = "ext7_rx", 311 .bus_id = "ext7_rx",
358 .min_signal = 14, 312 .min_signal = 14,
359 .max_signal = 14, 313 .max_signal = 14,
360 .muxval = 2, 314 .muxval = 2,
361 .cctl = 0,
362 .periph_buses = PL08X_AHB2, 315 .periph_buses = PL08X_AHB2,
363 }, { 316 }, {
364 .bus_id = "ext7_tx", 317 .bus_id = "ext7_tx",
365 .min_signal = 15, 318 .min_signal = 15,
366 .max_signal = 15, 319 .max_signal = 15,
367 .muxval = 2, 320 .muxval = 2,
368 .cctl = 0,
369 .periph_buses = PL08X_AHB2, 321 .periph_buses = PL08X_AHB2,
370 }, 322 },
371}; 323};
@@ -373,7 +325,8 @@ static struct pl08x_channel_data spear600_dma_info[] = {
373struct pl08x_platform_data pl080_plat_data = { 325struct pl08x_platform_data pl080_plat_data = {
374 .memcpy_channel = { 326 .memcpy_channel = {
375 .bus_id = "memcpy", 327 .bus_id = "memcpy",
376 .cctl = (PL080_BSIZE_16 << PL080_CONTROL_SB_SIZE_SHIFT | \ 328 .cctl_memcpy =
329 (PL080_BSIZE_16 << PL080_CONTROL_SB_SIZE_SHIFT | \
377 PL080_BSIZE_16 << PL080_CONTROL_DB_SIZE_SHIFT | \ 330 PL080_BSIZE_16 << PL080_CONTROL_DB_SIZE_SHIFT | \
378 PL080_WIDTH_32BIT << PL080_CONTROL_SWIDTH_SHIFT | \ 331 PL080_WIDTH_32BIT << PL080_CONTROL_SWIDTH_SHIFT | \
379 PL080_WIDTH_32BIT << PL080_CONTROL_DWIDTH_SHIFT | \ 332 PL080_WIDTH_32BIT << PL080_CONTROL_DWIDTH_SHIFT | \
diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index 6a113a9bb87..9077aaa398d 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -63,40 +63,15 @@ comment "Tegra board type"
63config MACH_HARMONY 63config MACH_HARMONY
64 bool "Harmony board" 64 bool "Harmony board"
65 depends on ARCH_TEGRA_2x_SOC 65 depends on ARCH_TEGRA_2x_SOC
66 select MACH_HAS_SND_SOC_TEGRA_WM8903 if SND_SOC
67 help 66 help
68 Support for nVidia Harmony development platform 67 Support for nVidia Harmony development platform
69 68
70config MACH_KAEN
71 bool "Kaen board"
72 depends on ARCH_TEGRA_2x_SOC
73 select MACH_SEABOARD
74 select MACH_HAS_SND_SOC_TEGRA_WM8903 if SND_SOC
75 help
76 Support for the Kaen version of Seaboard
77
78config MACH_PAZ00 69config MACH_PAZ00
79 bool "Paz00 board" 70 bool "Paz00 board"
80 depends on ARCH_TEGRA_2x_SOC 71 depends on ARCH_TEGRA_2x_SOC
81 help 72 help
82 Support for the Toshiba AC100/Dynabook AZ netbook 73 Support for the Toshiba AC100/Dynabook AZ netbook
83 74
84config MACH_SEABOARD
85 bool "Seaboard board"
86 depends on ARCH_TEGRA_2x_SOC
87 select MACH_HAS_SND_SOC_TEGRA_WM8903 if SND_SOC
88 help
89 Support for nVidia Seaboard development platform. It will
90 also be included for some of the derivative boards that
91 have large similarities with the seaboard design.
92
93config MACH_TEGRA_DT
94 bool "Generic Tegra20 board (FDT support)"
95 depends on ARCH_TEGRA_2x_SOC
96 select USE_OF
97 help
98 Support for generic NVIDIA Tegra20 boards using Flattened Device Tree
99
100config MACH_TRIMSLICE 75config MACH_TRIMSLICE
101 bool "TrimSlice board" 76 bool "TrimSlice board"
102 depends on ARCH_TEGRA_2x_SOC 77 depends on ARCH_TEGRA_2x_SOC
@@ -104,20 +79,6 @@ config MACH_TRIMSLICE
104 help 79 help
105 Support for CompuLab TrimSlice platform 80 Support for CompuLab TrimSlice platform
106 81
107config MACH_WARIO
108 bool "Wario board"
109 depends on ARCH_TEGRA_2x_SOC
110 select MACH_SEABOARD
111 help
112 Support for the Wario version of Seaboard
113
114config MACH_VENTANA
115 bool "Ventana board"
116 depends on ARCH_TEGRA_2x_SOC
117 select MACH_TEGRA_DT
118 help
119 Support for the nVidia Ventana development platform
120
121choice 82choice
122 prompt "Default low-level debug console UART" 83 prompt "Default low-level debug console UART"
123 default TEGRA_DEBUG_UART_NONE 84 default TEGRA_DEBUG_UART_NONE
diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile
index 2eb4445ddb1..c3d7303b9ac 100644
--- a/arch/arm/mach-tegra/Makefile
+++ b/arch/arm/mach-tegra/Makefile
@@ -8,21 +8,24 @@ obj-y += timer.o
8obj-y += fuse.o 8obj-y += fuse.o
9obj-y += pmc.o 9obj-y += pmc.o
10obj-y += flowctrl.o 10obj-y += flowctrl.o
11obj-y += powergate.o
12obj-y += apbio.o
11obj-$(CONFIG_CPU_IDLE) += cpuidle.o 13obj-$(CONFIG_CPU_IDLE) += cpuidle.o
12obj-$(CONFIG_CPU_IDLE) += sleep.o 14obj-$(CONFIG_CPU_IDLE) += sleep.o
13obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += powergate.o
14obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra2_clocks.o 15obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra2_clocks.o
15obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra2_emc.o 16obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra2_emc.o
16obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += board-dt-tegra30.o
17obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += tegra30_clocks.o 17obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += tegra30_clocks.o
18obj-$(CONFIG_SMP) += platsmp.o headsmp.o 18obj-$(CONFIG_SMP) += platsmp.o headsmp.o
19obj-$(CONFIG_SMP) += reset.o 19obj-$(CONFIG_SMP) += reset.o
20obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o 20obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
21obj-$(CONFIG_TEGRA_SYSTEM_DMA) += dma.o apbio.o 21obj-$(CONFIG_TEGRA_SYSTEM_DMA) += dma.o
22obj-$(CONFIG_CPU_FREQ) += cpu-tegra.o 22obj-$(CONFIG_CPU_FREQ) += cpu-tegra.o
23obj-$(CONFIG_TEGRA_PCI) += pcie.o 23obj-$(CONFIG_TEGRA_PCI) += pcie.o
24obj-$(CONFIG_USB_SUPPORT) += usb_phy.o 24obj-$(CONFIG_USB_SUPPORT) += usb_phy.o
25 25
26obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += board-dt-tegra20.o
27obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += board-dt-tegra30.o
28
26obj-$(CONFIG_MACH_HARMONY) += board-harmony.o 29obj-$(CONFIG_MACH_HARMONY) += board-harmony.o
27obj-$(CONFIG_MACH_HARMONY) += board-harmony-pinmux.o 30obj-$(CONFIG_MACH_HARMONY) += board-harmony-pinmux.o
28obj-$(CONFIG_MACH_HARMONY) += board-harmony-pcie.o 31obj-$(CONFIG_MACH_HARMONY) += board-harmony-pcie.o
@@ -31,14 +34,5 @@ obj-$(CONFIG_MACH_HARMONY) += board-harmony-power.o
31obj-$(CONFIG_MACH_PAZ00) += board-paz00.o 34obj-$(CONFIG_MACH_PAZ00) += board-paz00.o
32obj-$(CONFIG_MACH_PAZ00) += board-paz00-pinmux.o 35obj-$(CONFIG_MACH_PAZ00) += board-paz00-pinmux.o
33 36
34obj-$(CONFIG_MACH_SEABOARD) += board-seaboard.o
35obj-$(CONFIG_MACH_SEABOARD) += board-seaboard-pinmux.o
36
37obj-$(CONFIG_MACH_TEGRA_DT) += board-dt-tegra20.o
38obj-$(CONFIG_MACH_TEGRA_DT) += board-harmony-pinmux.o
39obj-$(CONFIG_MACH_TEGRA_DT) += board-seaboard-pinmux.o
40obj-$(CONFIG_MACH_TEGRA_DT) += board-paz00-pinmux.o
41obj-$(CONFIG_MACH_TEGRA_DT) += board-trimslice-pinmux.o
42
43obj-$(CONFIG_MACH_TRIMSLICE) += board-trimslice.o 37obj-$(CONFIG_MACH_TRIMSLICE) += board-trimslice.o
44obj-$(CONFIG_MACH_TRIMSLICE) += board-trimslice-pinmux.o 38obj-$(CONFIG_MACH_TRIMSLICE) += board-trimslice-pinmux.o
diff --git a/arch/arm/mach-tegra/Makefile.boot b/arch/arm/mach-tegra/Makefile.boot
index 9a82094092d..7a1bb62ddcf 100644
--- a/arch/arm/mach-tegra/Makefile.boot
+++ b/arch/arm/mach-tegra/Makefile.boot
@@ -2,9 +2,10 @@ zreladdr-$(CONFIG_ARCH_TEGRA_2x_SOC) += 0x00008000
2params_phys-$(CONFIG_ARCH_TEGRA_2x_SOC) := 0x00000100 2params_phys-$(CONFIG_ARCH_TEGRA_2x_SOC) := 0x00000100
3initrd_phys-$(CONFIG_ARCH_TEGRA_2x_SOC) := 0x00800000 3initrd_phys-$(CONFIG_ARCH_TEGRA_2x_SOC) := 0x00800000
4 4
5dtb-$(CONFIG_MACH_HARMONY) += tegra-harmony.dtb 5dtb-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra20-harmony.dtb
6dtb-$(CONFIG_MACH_PAZ00) += tegra-paz00.dtb 6dtb-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra20-paz00.dtb
7dtb-$(CONFIG_MACH_SEABOARD) += tegra-seaboard.dtb 7dtb-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra20-seaboard.dtb
8dtb-$(CONFIG_MACH_TRIMSLICE) += tegra-trimslice.dtb 8dtb-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra20-trimslice.dtb
9dtb-$(CONFIG_MACH_VENTANA) += tegra-ventana.dtb 9dtb-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra20-ventana.dtb
10dtb-$(CONFIG_ARCH_TEGRA_3x_SOC) += tegra-cardhu.dtb 10dtb-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra20-whistler.dtb
11dtb-$(CONFIG_ARCH_TEGRA_3x_SOC) += tegra30-cardhu.dtb
diff --git a/arch/arm/mach-tegra/apbio.c b/arch/arm/mach-tegra/apbio.c
index e75451e517b..dc0fe389be5 100644
--- a/arch/arm/mach-tegra/apbio.c
+++ b/arch/arm/mach-tegra/apbio.c
@@ -15,6 +15,9 @@
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <mach/iomap.h>
19#include <linux/of.h>
20#include <linux/dmaengine.h>
18#include <linux/dma-mapping.h> 21#include <linux/dma-mapping.h>
19#include <linux/spinlock.h> 22#include <linux/spinlock.h>
20#include <linux/completion.h> 23#include <linux/completion.h>
@@ -22,17 +25,21 @@
22#include <linux/mutex.h> 25#include <linux/mutex.h>
23 26
24#include <mach/dma.h> 27#include <mach/dma.h>
25#include <mach/iomap.h>
26 28
27#include "apbio.h" 29#include "apbio.h"
28 30
31#if defined(CONFIG_TEGRA_SYSTEM_DMA) || defined(CONFIG_TEGRA20_APB_DMA)
29static DEFINE_MUTEX(tegra_apb_dma_lock); 32static DEFINE_MUTEX(tegra_apb_dma_lock);
30
31static struct tegra_dma_channel *tegra_apb_dma;
32static u32 *tegra_apb_bb; 33static u32 *tegra_apb_bb;
33static dma_addr_t tegra_apb_bb_phys; 34static dma_addr_t tegra_apb_bb_phys;
34static DECLARE_COMPLETION(tegra_apb_wait); 35static DECLARE_COMPLETION(tegra_apb_wait);
35 36
37static u32 tegra_apb_readl_direct(unsigned long offset);
38static void tegra_apb_writel_direct(u32 value, unsigned long offset);
39
40#if defined(CONFIG_TEGRA_SYSTEM_DMA)
41static struct tegra_dma_channel *tegra_apb_dma;
42
36bool tegra_apb_init(void) 43bool tegra_apb_init(void)
37{ 44{
38 struct tegra_dma_channel *ch; 45 struct tegra_dma_channel *ch;
@@ -72,13 +79,13 @@ static void apb_dma_complete(struct tegra_dma_req *req)
72 complete(&tegra_apb_wait); 79 complete(&tegra_apb_wait);
73} 80}
74 81
75u32 tegra_apb_readl(unsigned long offset) 82static u32 tegra_apb_readl_using_dma(unsigned long offset)
76{ 83{
77 struct tegra_dma_req req; 84 struct tegra_dma_req req;
78 int ret; 85 int ret;
79 86
80 if (!tegra_apb_dma && !tegra_apb_init()) 87 if (!tegra_apb_dma && !tegra_apb_init())
81 return readl(IO_TO_VIRT(offset)); 88 return tegra_apb_readl_direct(offset);
82 89
83 mutex_lock(&tegra_apb_dma_lock); 90 mutex_lock(&tegra_apb_dma_lock);
84 req.complete = apb_dma_complete; 91 req.complete = apb_dma_complete;
@@ -108,13 +115,13 @@ u32 tegra_apb_readl(unsigned long offset)
108 return *((u32 *)tegra_apb_bb); 115 return *((u32 *)tegra_apb_bb);
109} 116}
110 117
111void tegra_apb_writel(u32 value, unsigned long offset) 118static void tegra_apb_writel_using_dma(u32 value, unsigned long offset)
112{ 119{
113 struct tegra_dma_req req; 120 struct tegra_dma_req req;
114 int ret; 121 int ret;
115 122
116 if (!tegra_apb_dma && !tegra_apb_init()) { 123 if (!tegra_apb_dma && !tegra_apb_init()) {
117 writel(value, IO_TO_VIRT(offset)); 124 tegra_apb_writel_direct(value, offset);
118 return; 125 return;
119 } 126 }
120 127
@@ -143,3 +150,176 @@ void tegra_apb_writel(u32 value, unsigned long offset)
143 150
144 mutex_unlock(&tegra_apb_dma_lock); 151 mutex_unlock(&tegra_apb_dma_lock);
145} 152}
153
154#else
155static struct dma_chan *tegra_apb_dma_chan;
156static struct dma_slave_config dma_sconfig;
157
158bool tegra_apb_dma_init(void)
159{
160 dma_cap_mask_t mask;
161
162 mutex_lock(&tegra_apb_dma_lock);
163
164 /* Check to see if we raced to setup */
165 if (tegra_apb_dma_chan)
166 goto skip_init;
167
168 dma_cap_zero(mask);
169 dma_cap_set(DMA_SLAVE, mask);
170 tegra_apb_dma_chan = dma_request_channel(mask, NULL, NULL);
171 if (!tegra_apb_dma_chan) {
172 /*
173 * This is common until the device is probed, so don't
174 * shout about it.
175 */
176 pr_debug("%s: can not allocate dma channel\n", __func__);
177 goto err_dma_alloc;
178 }
179
180 tegra_apb_bb = dma_alloc_coherent(NULL, sizeof(u32),
181 &tegra_apb_bb_phys, GFP_KERNEL);
182 if (!tegra_apb_bb) {
183 pr_err("%s: can not allocate bounce buffer\n", __func__);
184 goto err_buff_alloc;
185 }
186
187 dma_sconfig.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
188 dma_sconfig.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
189 dma_sconfig.slave_id = TEGRA_DMA_REQ_SEL_CNTR;
190 dma_sconfig.src_maxburst = 1;
191 dma_sconfig.dst_maxburst = 1;
192
193skip_init:
194 mutex_unlock(&tegra_apb_dma_lock);
195 return true;
196
197err_buff_alloc:
198 dma_release_channel(tegra_apb_dma_chan);
199 tegra_apb_dma_chan = NULL;
200
201err_dma_alloc:
202 mutex_unlock(&tegra_apb_dma_lock);
203 return false;
204}
205
206static void apb_dma_complete(void *args)
207{
208 complete(&tegra_apb_wait);
209}
210
211static int do_dma_transfer(unsigned long apb_add,
212 enum dma_transfer_direction dir)
213{
214 struct dma_async_tx_descriptor *dma_desc;
215 int ret;
216
217 if (dir == DMA_DEV_TO_MEM)
218 dma_sconfig.src_addr = apb_add;
219 else
220 dma_sconfig.dst_addr = apb_add;
221
222 ret = dmaengine_slave_config(tegra_apb_dma_chan, &dma_sconfig);
223 if (ret)
224 return ret;
225
226 dma_desc = dmaengine_prep_slave_single(tegra_apb_dma_chan,
227 tegra_apb_bb_phys, sizeof(u32), dir,
228 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
229 if (!dma_desc)
230 return -EINVAL;
231
232 dma_desc->callback = apb_dma_complete;
233 dma_desc->callback_param = NULL;
234
235 INIT_COMPLETION(tegra_apb_wait);
236
237 dmaengine_submit(dma_desc);
238 dma_async_issue_pending(tegra_apb_dma_chan);
239 ret = wait_for_completion_timeout(&tegra_apb_wait,
240 msecs_to_jiffies(50));
241
242 if (WARN(ret == 0, "apb read dma timed out")) {
243 dmaengine_terminate_all(tegra_apb_dma_chan);
244 return -EFAULT;
245 }
246 return 0;
247}
248
249static u32 tegra_apb_readl_using_dma(unsigned long offset)
250{
251 int ret;
252
253 if (!tegra_apb_dma_chan && !tegra_apb_dma_init())
254 return tegra_apb_readl_direct(offset);
255
256 mutex_lock(&tegra_apb_dma_lock);
257 ret = do_dma_transfer(offset, DMA_DEV_TO_MEM);
258 if (ret < 0) {
259 pr_err("error in reading offset 0x%08lx using dma\n", offset);
260 *(u32 *)tegra_apb_bb = 0;
261 }
262 mutex_unlock(&tegra_apb_dma_lock);
263 return *((u32 *)tegra_apb_bb);
264}
265
266static void tegra_apb_writel_using_dma(u32 value, unsigned long offset)
267{
268 int ret;
269
270 if (!tegra_apb_dma_chan && !tegra_apb_dma_init()) {
271 tegra_apb_writel_direct(value, offset);
272 return;
273 }
274
275 mutex_lock(&tegra_apb_dma_lock);
276 *((u32 *)tegra_apb_bb) = value;
277 ret = do_dma_transfer(offset, DMA_MEM_TO_DEV);
278 if (ret < 0)
279 pr_err("error in writing offset 0x%08lx using dma\n", offset);
280 mutex_unlock(&tegra_apb_dma_lock);
281}
282#endif
283#else
284#define tegra_apb_readl_using_dma tegra_apb_readl_direct
285#define tegra_apb_writel_using_dma tegra_apb_writel_direct
286#endif
287
288typedef u32 (*apbio_read_fptr)(unsigned long offset);
289typedef void (*apbio_write_fptr)(u32 value, unsigned long offset);
290
291static apbio_read_fptr apbio_read;
292static apbio_write_fptr apbio_write;
293
294static u32 tegra_apb_readl_direct(unsigned long offset)
295{
296 return readl(IO_TO_VIRT(offset));
297}
298
299static void tegra_apb_writel_direct(u32 value, unsigned long offset)
300{
301 writel(value, IO_TO_VIRT(offset));
302}
303
304void tegra_apb_io_init(void)
305{
306 /* Need to use dma only when it is Tegra20 based platform */
307 if (of_machine_is_compatible("nvidia,tegra20") ||
308 !of_have_populated_dt()) {
309 apbio_read = tegra_apb_readl_using_dma;
310 apbio_write = tegra_apb_writel_using_dma;
311 } else {
312 apbio_read = tegra_apb_readl_direct;
313 apbio_write = tegra_apb_writel_direct;
314 }
315}
316
317u32 tegra_apb_readl(unsigned long offset)
318{
319 return apbio_read(offset);
320}
321
322void tegra_apb_writel(u32 value, unsigned long offset)
323{
324 apbio_write(value, offset);
325}
diff --git a/arch/arm/mach-tegra/apbio.h b/arch/arm/mach-tegra/apbio.h
index 8b49e8c89a6..f05d71c303c 100644
--- a/arch/arm/mach-tegra/apbio.h
+++ b/arch/arm/mach-tegra/apbio.h
@@ -16,24 +16,7 @@
16#ifndef __MACH_TEGRA_APBIO_H 16#ifndef __MACH_TEGRA_APBIO_H
17#define __MACH_TEGRA_APBIO_H 17#define __MACH_TEGRA_APBIO_H
18 18
19#ifdef CONFIG_TEGRA_SYSTEM_DMA 19void tegra_apb_io_init(void);
20
21u32 tegra_apb_readl(unsigned long offset); 20u32 tegra_apb_readl(unsigned long offset);
22void tegra_apb_writel(u32 value, unsigned long offset); 21void tegra_apb_writel(u32 value, unsigned long offset);
23
24#else
25#include <asm/io.h>
26#include <mach/io.h>
27
28static inline u32 tegra_apb_readl(unsigned long offset)
29{
30 return readl(IO_TO_VIRT(offset));
31}
32
33static inline void tegra_apb_writel(u32 value, unsigned long offset)
34{
35 writel(value, IO_TO_VIRT(offset));
36}
37#endif
38
39#endif 22#endif
diff --git a/arch/arm/mach-tegra/board-dt-tegra20.c b/arch/arm/mach-tegra/board-dt-tegra20.c
index eb7249db50a..c0999633a9a 100644
--- a/arch/arm/mach-tegra/board-dt-tegra20.c
+++ b/arch/arm/mach-tegra/board-dt-tegra20.c
@@ -64,6 +64,8 @@ struct of_dev_auxdata tegra20_auxdata_lookup[] __initdata = {
64 &tegra_ehci2_pdata), 64 &tegra_ehci2_pdata),
65 OF_DEV_AUXDATA("nvidia,tegra20-ehci", TEGRA_USB3_BASE, "tegra-ehci.2", 65 OF_DEV_AUXDATA("nvidia,tegra20-ehci", TEGRA_USB3_BASE, "tegra-ehci.2",
66 &tegra_ehci3_pdata), 66 &tegra_ehci3_pdata),
67 OF_DEV_AUXDATA("nvidia,tegra20-apbdma", TEGRA_APB_DMA_BASE, "tegra-apbdma", NULL),
68 OF_DEV_AUXDATA("nvidia,tegra20-pwm", TEGRA_PWFM_BASE, "tegra-pwm", NULL),
67 {} 69 {}
68}; 70};
69 71
@@ -81,11 +83,6 @@ static __initdata struct tegra_clk_init_table tegra_dt_clk_init_table[] = {
81 { NULL, NULL, 0, 0}, 83 { NULL, NULL, 0, 0},
82}; 84};
83 85
84static struct of_device_id tegra_dt_match_table[] __initdata = {
85 { .compatible = "simple-bus", },
86 {}
87};
88
89static void __init tegra_dt_init(void) 86static void __init tegra_dt_init(void)
90{ 87{
91 tegra_clk_init_from_table(tegra_dt_clk_init_table); 88 tegra_clk_init_from_table(tegra_dt_clk_init_table);
@@ -94,10 +91,74 @@ static void __init tegra_dt_init(void)
94 * Finished with the static registrations now; fill in the missing 91 * Finished with the static registrations now; fill in the missing
95 * devices 92 * devices
96 */ 93 */
97 of_platform_populate(NULL, tegra_dt_match_table, 94 of_platform_populate(NULL, of_default_bus_match_table,
98 tegra20_auxdata_lookup, NULL); 95 tegra20_auxdata_lookup, NULL);
99} 96}
100 97
98#ifdef CONFIG_MACH_TRIMSLICE
99static void __init trimslice_init(void)
100{
101 int ret;
102
103 ret = tegra_pcie_init(true, true);
104 if (ret)
105 pr_err("tegra_pci_init() failed: %d\n", ret);
106}
107#endif
108
109#ifdef CONFIG_MACH_HARMONY
110static void __init harmony_init(void)
111{
112 int ret;
113
114 ret = harmony_regulator_init();
115 if (ret) {
116 pr_err("harmony_regulator_init() failed: %d\n", ret);
117 return;
118 }
119
120 ret = harmony_pcie_init();
121 if (ret)
122 pr_err("harmony_pcie_init() failed: %d\n", ret);
123}
124#endif
125
126#ifdef CONFIG_MACH_PAZ00
127static void __init paz00_init(void)
128{
129 tegra_paz00_wifikill_init();
130}
131#endif
132
133static struct {
134 char *machine;
135 void (*init)(void);
136} board_init_funcs[] = {
137#ifdef CONFIG_MACH_TRIMSLICE
138 { "compulab,trimslice", trimslice_init },
139#endif
140#ifdef CONFIG_MACH_HARMONY
141 { "nvidia,harmony", harmony_init },
142#endif
143#ifdef CONFIG_MACH_PAZ00
144 { "compal,paz00", paz00_init },
145#endif
146};
147
148static void __init tegra_dt_init_late(void)
149{
150 int i;
151
152 tegra_init_late();
153
154 for (i = 0; i < ARRAY_SIZE(board_init_funcs); i++) {
155 if (of_machine_is_compatible(board_init_funcs[i].machine)) {
156 board_init_funcs[i].init();
157 break;
158 }
159 }
160}
161
101static const char *tegra20_dt_board_compat[] = { 162static const char *tegra20_dt_board_compat[] = {
102 "nvidia,tegra20", 163 "nvidia,tegra20",
103 NULL 164 NULL
@@ -110,7 +171,7 @@ DT_MACHINE_START(TEGRA_DT, "nVidia Tegra20 (Flattened Device Tree)")
110 .handle_irq = gic_handle_irq, 171 .handle_irq = gic_handle_irq,
111 .timer = &tegra_timer, 172 .timer = &tegra_timer,
112 .init_machine = tegra_dt_init, 173 .init_machine = tegra_dt_init,
113 .init_late = tegra_init_late, 174 .init_late = tegra_dt_init_late,
114 .restart = tegra_assert_system_reset, 175 .restart = tegra_assert_system_reset,
115 .dt_compat = tegra20_dt_board_compat, 176 .dt_compat = tegra20_dt_board_compat,
116MACHINE_END 177MACHINE_END
diff --git a/arch/arm/mach-tegra/board-dt-tegra30.c b/arch/arm/mach-tegra/board-dt-tegra30.c
index 4f76fa7a5da..53bf60f1158 100644
--- a/arch/arm/mach-tegra/board-dt-tegra30.c
+++ b/arch/arm/mach-tegra/board-dt-tegra30.c
@@ -33,14 +33,11 @@
33#include <asm/mach/arch.h> 33#include <asm/mach/arch.h>
34#include <asm/hardware/gic.h> 34#include <asm/hardware/gic.h>
35 35
36#include <mach/iomap.h>
37
36#include "board.h" 38#include "board.h"
37#include "clock.h" 39#include "clock.h"
38 40
39static struct of_device_id tegra_dt_match_table[] __initdata = {
40 { .compatible = "simple-bus", },
41 {}
42};
43
44struct of_dev_auxdata tegra30_auxdata_lookup[] __initdata = { 41struct of_dev_auxdata tegra30_auxdata_lookup[] __initdata = {
45 OF_DEV_AUXDATA("nvidia,tegra20-sdhci", 0x78000000, "sdhci-tegra.0", NULL), 42 OF_DEV_AUXDATA("nvidia,tegra20-sdhci", 0x78000000, "sdhci-tegra.0", NULL),
46 OF_DEV_AUXDATA("nvidia,tegra20-sdhci", 0x78000200, "sdhci-tegra.1", NULL), 43 OF_DEV_AUXDATA("nvidia,tegra20-sdhci", 0x78000200, "sdhci-tegra.1", NULL),
@@ -52,6 +49,8 @@ struct of_dev_auxdata tegra30_auxdata_lookup[] __initdata = {
52 OF_DEV_AUXDATA("nvidia,tegra20-i2c", 0x7000C700, "tegra-i2c.3", NULL), 49 OF_DEV_AUXDATA("nvidia,tegra20-i2c", 0x7000C700, "tegra-i2c.3", NULL),
53 OF_DEV_AUXDATA("nvidia,tegra20-i2c", 0x7000D000, "tegra-i2c.4", NULL), 50 OF_DEV_AUXDATA("nvidia,tegra20-i2c", 0x7000D000, "tegra-i2c.4", NULL),
54 OF_DEV_AUXDATA("nvidia,tegra30-ahub", 0x70080000, "tegra30-ahub", NULL), 51 OF_DEV_AUXDATA("nvidia,tegra30-ahub", 0x70080000, "tegra30-ahub", NULL),
52 OF_DEV_AUXDATA("nvidia,tegra30-apbdma", 0x6000a000, "tegra-apbdma", NULL),
53 OF_DEV_AUXDATA("nvidia,tegra30-pwm", TEGRA_PWFM_BASE, "tegra-pwm", NULL),
55 {} 54 {}
56}; 55};
57 56
@@ -74,7 +73,7 @@ static void __init tegra30_dt_init(void)
74{ 73{
75 tegra_clk_init_from_table(tegra_dt_clk_init_table); 74 tegra_clk_init_from_table(tegra_dt_clk_init_table);
76 75
77 of_platform_populate(NULL, tegra_dt_match_table, 76 of_platform_populate(NULL, of_default_bus_match_table,
78 tegra30_auxdata_lookup, NULL); 77 tegra30_auxdata_lookup, NULL);
79} 78}
80 79
diff --git a/arch/arm/mach-tegra/board-harmony-pcie.c b/arch/arm/mach-tegra/board-harmony-pcie.c
index 33c4fedab84..e8c3fda9bec 100644
--- a/arch/arm/mach-tegra/board-harmony-pcie.c
+++ b/arch/arm/mach-tegra/board-harmony-pcie.c
@@ -27,14 +27,11 @@
27 27
28#ifdef CONFIG_TEGRA_PCI 28#ifdef CONFIG_TEGRA_PCI
29 29
30static int __init harmony_pcie_init(void) 30int __init harmony_pcie_init(void)
31{ 31{
32 struct regulator *regulator = NULL; 32 struct regulator *regulator = NULL;
33 int err; 33 int err;
34 34
35 if (!machine_is_harmony())
36 return 0;
37
38 err = gpio_request(TEGRA_GPIO_EN_VDD_1V05_GPIO, "EN_VDD_1V05"); 35 err = gpio_request(TEGRA_GPIO_EN_VDD_1V05_GPIO, "EN_VDD_1V05");
39 if (err) 36 if (err)
40 return err; 37 return err;
@@ -62,7 +59,15 @@ err_reg:
62 return err; 59 return err;
63} 60}
64 61
62static int __init harmony_pcie_initcall(void)
63{
64 if (!machine_is_harmony())
65 return 0;
66
67 return harmony_pcie_init();
68}
69
65/* PCI should be initialized after I2C, mfd and regulators */ 70/* PCI should be initialized after I2C, mfd and regulators */
66subsys_initcall_sync(harmony_pcie_init); 71subsys_initcall_sync(harmony_pcie_initcall);
67 72
68#endif 73#endif
diff --git a/arch/arm/mach-tegra/board-harmony-power.c b/arch/arm/mach-tegra/board-harmony-power.c
index 82f32300796..b7344beec10 100644
--- a/arch/arm/mach-tegra/board-harmony-power.c
+++ b/arch/arm/mach-tegra/board-harmony-power.c
@@ -19,7 +19,12 @@
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/gpio.h> 20#include <linux/gpio.h>
21#include <linux/regulator/machine.h> 21#include <linux/regulator/machine.h>
22#include <linux/regulator/fixed.h>
22#include <linux/mfd/tps6586x.h> 23#include <linux/mfd/tps6586x.h>
24#include <linux/of.h>
25#include <linux/of_i2c.h>
26
27#include <asm/mach-types.h>
23 28
24#include <mach/irqs.h> 29#include <mach/irqs.h>
25 30
@@ -30,7 +35,9 @@ static struct regulator_consumer_supply tps658621_ldo0_supply[] = {
30}; 35};
31 36
32static struct regulator_init_data ldo0_data = { 37static struct regulator_init_data ldo0_data = {
38 .supply_regulator = "vdd_sm2",
33 .constraints = { 39 .constraints = {
40 .name = "vdd_ldo0",
34 .min_uV = 3300 * 1000, 41 .min_uV = 3300 * 1000,
35 .max_uV = 3300 * 1000, 42 .max_uV = 3300 * 1000,
36 .valid_modes_mask = (REGULATOR_MODE_NORMAL | 43 .valid_modes_mask = (REGULATOR_MODE_NORMAL |
@@ -44,9 +51,11 @@ static struct regulator_init_data ldo0_data = {
44 .consumer_supplies = tps658621_ldo0_supply, 51 .consumer_supplies = tps658621_ldo0_supply,
45}; 52};
46 53
47#define HARMONY_REGULATOR_INIT(_id, _minmv, _maxmv) \ 54#define HARMONY_REGULATOR_INIT(_id, _name, _supply, _minmv, _maxmv, _on)\
48 static struct regulator_init_data _id##_data = { \ 55 static struct regulator_init_data _id##_data = { \
56 .supply_regulator = _supply, \
49 .constraints = { \ 57 .constraints = { \
58 .name = _name, \
50 .min_uV = (_minmv)*1000, \ 59 .min_uV = (_minmv)*1000, \
51 .max_uV = (_maxmv)*1000, \ 60 .max_uV = (_maxmv)*1000, \
52 .valid_modes_mask = (REGULATOR_MODE_NORMAL | \ 61 .valid_modes_mask = (REGULATOR_MODE_NORMAL | \
@@ -54,21 +63,22 @@ static struct regulator_init_data ldo0_data = {
54 .valid_ops_mask = (REGULATOR_CHANGE_MODE | \ 63 .valid_ops_mask = (REGULATOR_CHANGE_MODE | \
55 REGULATOR_CHANGE_STATUS | \ 64 REGULATOR_CHANGE_STATUS | \
56 REGULATOR_CHANGE_VOLTAGE), \ 65 REGULATOR_CHANGE_VOLTAGE), \
66 .always_on = _on, \
57 }, \ 67 }, \
58 } 68 }
59 69
60HARMONY_REGULATOR_INIT(sm0, 725, 1500); 70HARMONY_REGULATOR_INIT(sm0, "vdd_sm0", "vdd_sys", 725, 1500, 1);
61HARMONY_REGULATOR_INIT(sm1, 725, 1500); 71HARMONY_REGULATOR_INIT(sm1, "vdd_sm1", "vdd_sys", 725, 1500, 1);
62HARMONY_REGULATOR_INIT(sm2, 3000, 4550); 72HARMONY_REGULATOR_INIT(sm2, "vdd_sm2", "vdd_sys", 3000, 4550, 1);
63HARMONY_REGULATOR_INIT(ldo1, 725, 1500); 73HARMONY_REGULATOR_INIT(ldo1, "vdd_ldo1", "vdd_sm2", 725, 1500, 1);
64HARMONY_REGULATOR_INIT(ldo2, 725, 1500); 74HARMONY_REGULATOR_INIT(ldo2, "vdd_ldo2", "vdd_sm2", 725, 1500, 0);
65HARMONY_REGULATOR_INIT(ldo3, 1250, 3300); 75HARMONY_REGULATOR_INIT(ldo3, "vdd_ldo3", "vdd_sm2", 1250, 3300, 1);
66HARMONY_REGULATOR_INIT(ldo4, 1700, 2475); 76HARMONY_REGULATOR_INIT(ldo4, "vdd_ldo4", "vdd_sm2", 1700, 2475, 1);
67HARMONY_REGULATOR_INIT(ldo5, 1250, 3300); 77HARMONY_REGULATOR_INIT(ldo5, "vdd_ldo5", NULL, 1250, 3300, 1);
68HARMONY_REGULATOR_INIT(ldo6, 1250, 3300); 78HARMONY_REGULATOR_INIT(ldo6, "vdd_ldo6", "vdd_sm2", 1250, 3300, 0);
69HARMONY_REGULATOR_INIT(ldo7, 1250, 3300); 79HARMONY_REGULATOR_INIT(ldo7, "vdd_ldo7", "vdd_sm2", 1250, 3300, 0);
70HARMONY_REGULATOR_INIT(ldo8, 1250, 3300); 80HARMONY_REGULATOR_INIT(ldo8, "vdd_ldo8", "vdd_sm2", 1250, 3300, 0);
71HARMONY_REGULATOR_INIT(ldo9, 1250, 3300); 81HARMONY_REGULATOR_INIT(ldo9, "vdd_ldo9", "vdd_sm2", 1250, 3300, 1);
72 82
73#define TPS_REG(_id, _data) \ 83#define TPS_REG(_id, _data) \
74 { \ 84 { \
@@ -110,7 +120,29 @@ static struct i2c_board_info __initdata harmony_regulators[] = {
110 120
111int __init harmony_regulator_init(void) 121int __init harmony_regulator_init(void)
112{ 122{
113 i2c_register_board_info(3, harmony_regulators, 1); 123 regulator_register_always_on(0, "vdd_sys",
124 NULL, 0, 5000000);
125
126 if (machine_is_harmony()) {
127 i2c_register_board_info(3, harmony_regulators, 1);
128 } else { /* Harmony, booted using device tree */
129 struct device_node *np;
130 struct i2c_adapter *adapter;
131
132 np = of_find_node_by_path("/i2c@7000d000");
133 if (np == NULL) {
134 pr_err("Could not find device_node for DVC I2C\n");
135 return -ENODEV;
136 }
137
138 adapter = of_find_i2c_adapter_by_node(np);
139 if (!adapter) {
140 pr_err("Could not find i2c_adapter for DVC I2C\n");
141 return -ENODEV;
142 }
143
144 i2c_new_device(adapter, harmony_regulators);
145 }
114 146
115 return 0; 147 return 0;
116} 148}
diff --git a/arch/arm/mach-tegra/board-paz00.c b/arch/arm/mach-tegra/board-paz00.c
index bbc1907e98a..4b64af5cab2 100644
--- a/arch/arm/mach-tegra/board-paz00.c
+++ b/arch/arm/mach-tegra/board-paz00.c
@@ -148,7 +148,6 @@ static struct platform_device *paz00_devices[] __initdata = {
148 &debug_uart, 148 &debug_uart,
149 &tegra_sdhci_device4, 149 &tegra_sdhci_device4,
150 &tegra_sdhci_device1, 150 &tegra_sdhci_device1,
151 &wifi_rfkill_device,
152 &leds_gpio, 151 &leds_gpio,
153 &gpio_keys_device, 152 &gpio_keys_device,
154}; 153};
@@ -201,6 +200,11 @@ static struct tegra_sdhci_platform_data sdhci_pdata4 = {
201 .is_8bit = 1, 200 .is_8bit = 1,
202}; 201};
203 202
203void __init tegra_paz00_wifikill_init(void)
204{
205 platform_device_register(&wifi_rfkill_device);
206}
207
204static void __init tegra_paz00_init(void) 208static void __init tegra_paz00_init(void)
205{ 209{
206 tegra_clk_init_from_table(paz00_clk_init_table); 210 tegra_clk_init_from_table(paz00_clk_init_table);
@@ -211,6 +215,7 @@ static void __init tegra_paz00_init(void)
211 tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4; 215 tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
212 216
213 platform_add_devices(paz00_devices, ARRAY_SIZE(paz00_devices)); 217 platform_add_devices(paz00_devices, ARRAY_SIZE(paz00_devices));
218 tegra_paz00_wifikill_init();
214 219
215 paz00_i2c_init(); 220 paz00_i2c_init();
216 paz00_usb_init(); 221 paz00_usb_init();
diff --git a/arch/arm/mach-tegra/board-seaboard-pinmux.c b/arch/arm/mach-tegra/board-seaboard-pinmux.c
deleted file mode 100644
index 11fc8a568c6..00000000000
--- a/arch/arm/mach-tegra/board-seaboard-pinmux.c
+++ /dev/null
@@ -1,197 +0,0 @@
1/*
2 * Copyright (C) 2010-2012 NVIDIA Corporation
3 * Copyright (C) 2011 Google, Inc.
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#include <linux/kernel.h>
17
18#include "board-seaboard.h"
19#include "board-pinmux.h"
20
21static unsigned long seaboard_pincfg_drive_sdio1[] = {
22 TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_HIGH_SPEED_MODE, 0),
23 TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_SCHMITT, 0),
24 TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_LOW_POWER_MODE, 3),
25 TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_DRIVE_DOWN_STRENGTH, 31),
26 TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_DRIVE_UP_STRENGTH, 31),
27 TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_SLEW_RATE_FALLING, 3),
28 TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_SLEW_RATE_RISING, 3),
29};
30
31static struct pinctrl_map common_map[] = {
32 TEGRA_MAP_MUXCONF("ata", "ide", none, driven),
33 TEGRA_MAP_MUXCONF("atb", "sdio4", none, driven),
34 TEGRA_MAP_MUXCONF("atc", "nand", none, driven),
35 TEGRA_MAP_MUXCONF("atd", "gmi", none, driven),
36 TEGRA_MAP_MUXCONF("ate", "gmi", none, tristate),
37 TEGRA_MAP_MUXCONF("cdev1", "plla_out", none, driven),
38 TEGRA_MAP_MUXCONF("cdev2", "pllp_out4", none, driven),
39 TEGRA_MAP_MUXCONF("crtp", "crt", up, tristate),
40 TEGRA_MAP_MUXCONF("csus", "vi_sensor_clk", none, tristate),
41 TEGRA_MAP_MUXCONF("dap1", "dap1", none, driven),
42 TEGRA_MAP_MUXCONF("dap2", "dap2", none, driven),
43 TEGRA_MAP_MUXCONF("dap3", "dap3", none, tristate),
44 TEGRA_MAP_MUXCONF("dap4", "dap4", none, driven),
45 TEGRA_MAP_MUXCONF("dta", "vi", down, driven),
46 TEGRA_MAP_MUXCONF("dtb", "vi", down, driven),
47 TEGRA_MAP_MUXCONF("dtc", "vi", down, driven),
48 TEGRA_MAP_MUXCONF("dtd", "vi", down, driven),
49 TEGRA_MAP_MUXCONF("dte", "vi", down, tristate),
50 TEGRA_MAP_MUXCONF("dtf", "i2c3", none, driven),
51 TEGRA_MAP_MUXCONF("gma", "sdio4", none, driven),
52 TEGRA_MAP_MUXCONF("gmb", "gmi", up, tristate),
53 TEGRA_MAP_MUXCONF("gmc", "uartd", none, driven),
54 TEGRA_MAP_MUXCONF("gme", "sdio4", none, driven),
55 TEGRA_MAP_MUXCONF("gpu", "pwm", none, driven),
56 TEGRA_MAP_MUXCONF("gpu7", "rtck", none, driven),
57 TEGRA_MAP_MUXCONF("gpv", "pcie", none, tristate),
58 TEGRA_MAP_MUXCONF("hdint", "hdmi", na, tristate),
59 TEGRA_MAP_MUXCONF("i2cp", "i2cp", none, driven),
60 TEGRA_MAP_MUXCONF("irrx", "uartb", none, driven),
61 TEGRA_MAP_MUXCONF("irtx", "uartb", none, driven),
62 TEGRA_MAP_MUXCONF("kbca", "kbc", up, driven),
63 TEGRA_MAP_MUXCONF("kbcb", "kbc", up, driven),
64 TEGRA_MAP_MUXCONF("kbcc", "kbc", up, driven),
65 TEGRA_MAP_MUXCONF("kbcd", "kbc", up, driven),
66 TEGRA_MAP_MUXCONF("kbce", "kbc", up, driven),
67 TEGRA_MAP_MUXCONF("kbcf", "kbc", up, driven),
68 TEGRA_MAP_MUXCONF("lcsn", "rsvd4", na, tristate),
69 TEGRA_MAP_MUXCONF("ld0", "displaya", na, driven),
70 TEGRA_MAP_MUXCONF("ld1", "displaya", na, driven),
71 TEGRA_MAP_MUXCONF("ld10", "displaya", na, driven),
72 TEGRA_MAP_MUXCONF("ld11", "displaya", na, driven),
73 TEGRA_MAP_MUXCONF("ld12", "displaya", na, driven),
74 TEGRA_MAP_MUXCONF("ld13", "displaya", na, driven),
75 TEGRA_MAP_MUXCONF("ld14", "displaya", na, driven),
76 TEGRA_MAP_MUXCONF("ld15", "displaya", na, driven),
77 TEGRA_MAP_MUXCONF("ld16", "displaya", na, driven),
78 TEGRA_MAP_MUXCONF("ld17", "displaya", na, driven),
79 TEGRA_MAP_MUXCONF("ld2", "displaya", na, driven),
80 TEGRA_MAP_MUXCONF("ld3", "displaya", na, driven),
81 TEGRA_MAP_MUXCONF("ld4", "displaya", na, driven),
82 TEGRA_MAP_MUXCONF("ld5", "displaya", na, driven),
83 TEGRA_MAP_MUXCONF("ld6", "displaya", na, driven),
84 TEGRA_MAP_MUXCONF("ld7", "displaya", na, driven),
85 TEGRA_MAP_MUXCONF("ld8", "displaya", na, driven),
86 TEGRA_MAP_MUXCONF("ld9", "displaya", na, driven),
87 TEGRA_MAP_MUXCONF("ldc", "rsvd4", na, tristate),
88 TEGRA_MAP_MUXCONF("ldi", "displaya", na, driven),
89 TEGRA_MAP_MUXCONF("lhp0", "displaya", na, driven),
90 TEGRA_MAP_MUXCONF("lhp1", "displaya", na, driven),
91 TEGRA_MAP_MUXCONF("lhp2", "displaya", na, driven),
92 TEGRA_MAP_MUXCONF("lhs", "displaya", na, driven),
93 TEGRA_MAP_MUXCONF("lm0", "rsvd4", na, driven),
94 TEGRA_MAP_MUXCONF("lm1", "crt", na, tristate),
95 TEGRA_MAP_MUXCONF("lpp", "displaya", na, driven),
96 TEGRA_MAP_MUXCONF("lpw1", "rsvd4", na, tristate),
97 TEGRA_MAP_MUXCONF("lsc0", "displaya", na, driven),
98 TEGRA_MAP_MUXCONF("lsdi", "rsvd4", na, tristate),
99 TEGRA_MAP_MUXCONF("lspi", "displaya", na, driven),
100 TEGRA_MAP_MUXCONF("lvp0", "rsvd4", na, tristate),
101 TEGRA_MAP_MUXCONF("lvp1", "displaya", na, driven),
102 TEGRA_MAP_MUXCONF("lvs", "displaya", na, driven),
103 TEGRA_MAP_MUXCONF("owc", "rsvd2", none, tristate),
104 TEGRA_MAP_MUXCONF("pmc", "pwr_on", na, driven),
105 TEGRA_MAP_MUXCONF("pta", "hdmi", none, driven),
106 TEGRA_MAP_MUXCONF("rm", "i2c1", none, driven),
107 TEGRA_MAP_MUXCONF("sdb", "sdio3", na, driven),
108 TEGRA_MAP_MUXCONF("sdc", "sdio3", none, driven),
109 TEGRA_MAP_MUXCONF("sdd", "sdio3", none, driven),
110 TEGRA_MAP_MUXCONF("sdio1", "sdio1", up, driven),
111 TEGRA_MAP_MUXCONF("slxa", "pcie", up, tristate),
112 TEGRA_MAP_MUXCONF("slxd", "spdif", none, driven),
113 TEGRA_MAP_MUXCONF("slxk", "pcie", none, driven),
114 TEGRA_MAP_MUXCONF("spdi", "rsvd2", none, driven),
115 TEGRA_MAP_MUXCONF("spdo", "rsvd2", none, driven),
116 TEGRA_MAP_MUXCONF("spib", "gmi", none, tristate),
117 TEGRA_MAP_MUXCONF("spid", "spi1", none, tristate),
118 TEGRA_MAP_MUXCONF("spie", "spi1", none, tristate),
119 TEGRA_MAP_MUXCONF("spif", "spi1", down, tristate),
120 TEGRA_MAP_MUXCONF("spih", "spi2_alt", up, tristate),
121 TEGRA_MAP_MUXCONF("uaa", "ulpi", up, driven),
122 TEGRA_MAP_MUXCONF("uab", "ulpi", up, driven),
123 TEGRA_MAP_MUXCONF("uac", "rsvd2", none, driven),
124 TEGRA_MAP_MUXCONF("uad", "irda", none, driven),
125 TEGRA_MAP_MUXCONF("uca", "uartc", none, driven),
126 TEGRA_MAP_MUXCONF("ucb", "uartc", none, driven),
127 TEGRA_MAP_MUXCONF("uda", "ulpi", none, driven),
128 TEGRA_MAP_CONF("ck32", none, na),
129 TEGRA_MAP_CONF("ddrc", none, na),
130 TEGRA_MAP_CONF("pmca", none, na),
131 TEGRA_MAP_CONF("pmcb", none, na),
132 TEGRA_MAP_CONF("pmcc", none, na),
133 TEGRA_MAP_CONF("pmcd", none, na),
134 TEGRA_MAP_CONF("pmce", none, na),
135 TEGRA_MAP_CONF("xm2c", none, na),
136 TEGRA_MAP_CONF("xm2d", none, na),
137 TEGRA_MAP_CONF("ls", up, na),
138 TEGRA_MAP_CONF("lc", up, na),
139 TEGRA_MAP_CONF("ld17_0", down, na),
140 TEGRA_MAP_CONF("ld19_18", down, na),
141 TEGRA_MAP_CONF("ld21_20", down, na),
142 TEGRA_MAP_CONF("ld23_22", down, na),
143};
144
145static struct pinctrl_map seaboard_map[] = {
146 TEGRA_MAP_MUXCONF("ddc", "rsvd2", none, tristate),
147 TEGRA_MAP_MUXCONF("gmd", "sflash", none, driven),
148 TEGRA_MAP_MUXCONF("lpw0", "hdmi", na, driven),
149 TEGRA_MAP_MUXCONF("lpw2", "hdmi", na, driven),
150 TEGRA_MAP_MUXCONF("lsc1", "hdmi", na, tristate),
151 TEGRA_MAP_MUXCONF("lsck", "hdmi", na, tristate),
152 TEGRA_MAP_MUXCONF("lsda", "hdmi", na, tristate),
153 TEGRA_MAP_MUXCONF("slxc", "spdif", none, tristate),
154 TEGRA_MAP_MUXCONF("spia", "gmi", up, tristate),
155 TEGRA_MAP_MUXCONF("spic", "gmi", up, driven),
156 TEGRA_MAP_MUXCONF("spig", "spi2_alt", up, tristate),
157 PIN_MAP_CONFIGS_GROUP_HOG_DEFAULT(PINMUX_DEV, "drive_sdio1", seaboard_pincfg_drive_sdio1),
158};
159
160static struct pinctrl_map ventana_map[] = {
161 TEGRA_MAP_MUXCONF("ddc", "rsvd2", none, driven),
162 TEGRA_MAP_MUXCONF("gmd", "sflash", none, tristate),
163 TEGRA_MAP_MUXCONF("lpw0", "displaya", na, driven),
164 TEGRA_MAP_MUXCONF("lpw2", "displaya", na, driven),
165 TEGRA_MAP_MUXCONF("lsc1", "displaya", na, driven),
166 TEGRA_MAP_MUXCONF("lsck", "displaya", na, tristate),
167 TEGRA_MAP_MUXCONF("lsda", "displaya", na, tristate),
168 TEGRA_MAP_MUXCONF("slxc", "sdio3", none, driven),
169 TEGRA_MAP_MUXCONF("spia", "gmi", none, tristate),
170 TEGRA_MAP_MUXCONF("spic", "gmi", none, tristate),
171 TEGRA_MAP_MUXCONF("spig", "spi2_alt", none, tristate),
172};
173
174static struct tegra_board_pinmux_conf common_conf = {
175 .maps = common_map,
176 .map_count = ARRAY_SIZE(common_map),
177};
178
179static struct tegra_board_pinmux_conf seaboard_conf = {
180 .maps = seaboard_map,
181 .map_count = ARRAY_SIZE(seaboard_map),
182};
183
184static struct tegra_board_pinmux_conf ventana_conf = {
185 .maps = ventana_map,
186 .map_count = ARRAY_SIZE(ventana_map),
187};
188
189void seaboard_pinmux_init(void)
190{
191 tegra_board_pinmux_init(&common_conf, &seaboard_conf);
192}
193
194void ventana_pinmux_init(void)
195{
196 tegra_board_pinmux_init(&common_conf, &ventana_conf);
197}
diff --git a/arch/arm/mach-tegra/board-seaboard.c b/arch/arm/mach-tegra/board-seaboard.c
deleted file mode 100644
index 71e9f3fc7fb..00000000000
--- a/arch/arm/mach-tegra/board-seaboard.c
+++ /dev/null
@@ -1,306 +0,0 @@
1/*
2 * Copyright (c) 2010, 2011 NVIDIA Corporation.
3 * Copyright (C) 2010, 2011 Google, Inc.
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, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/platform_device.h>
20#include <linux/serial_8250.h>
21#include <linux/of_serial.h>
22#include <linux/i2c.h>
23#include <linux/delay.h>
24#include <linux/input.h>
25#include <linux/io.h>
26#include <linux/gpio.h>
27#include <linux/gpio_keys.h>
28#include <linux/platform_data/tegra_usb.h>
29
30#include <sound/wm8903.h>
31
32#include <mach/iomap.h>
33#include <mach/irqs.h>
34#include <mach/sdhci.h>
35#include <mach/tegra_wm8903_pdata.h>
36
37#include <asm/mach-types.h>
38#include <asm/mach/arch.h>
39#include <asm/hardware/gic.h>
40
41#include "board.h"
42#include "board-seaboard.h"
43#include "clock.h"
44#include "devices.h"
45#include "gpio-names.h"
46
47static struct plat_serial8250_port debug_uart_platform_data[] = {
48 {
49 /* Memory and IRQ filled in before registration */
50 .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE,
51 .type = PORT_TEGRA,
52 .handle_break = tegra_serial_handle_break,
53 .iotype = UPIO_MEM,
54 .regshift = 2,
55 .uartclk = 216000000,
56 }, {
57 .flags = 0,
58 }
59};
60
61static struct platform_device debug_uart = {
62 .name = "serial8250",
63 .id = PLAT8250_DEV_PLATFORM,
64 .dev = {
65 .platform_data = debug_uart_platform_data,
66 },
67};
68
69static __initdata struct tegra_clk_init_table seaboard_clk_init_table[] = {
70 /* name parent rate enabled */
71 { "uartb", "pll_p", 216000000, true},
72 { "uartd", "pll_p", 216000000, true},
73 { "pll_a", "pll_p_out1", 56448000, true },
74 { "pll_a_out0", "pll_a", 11289600, true },
75 { "cdev1", NULL, 0, true },
76 { "i2s1", "pll_a_out0", 11289600, false},
77 { "usbd", "clk_m", 12000000, true},
78 { "usb3", "clk_m", 12000000, true},
79 { NULL, NULL, 0, 0},
80};
81
82static struct gpio_keys_button seaboard_gpio_keys_buttons[] = {
83 {
84 .code = SW_LID,
85 .gpio = TEGRA_GPIO_LIDSWITCH,
86 .active_low = 0,
87 .desc = "Lid",
88 .type = EV_SW,
89 .wakeup = 1,
90 .debounce_interval = 1,
91 },
92 {
93 .code = KEY_POWER,
94 .gpio = TEGRA_GPIO_POWERKEY,
95 .active_low = 1,
96 .desc = "Power",
97 .type = EV_KEY,
98 .wakeup = 1,
99 },
100};
101
102static struct gpio_keys_platform_data seaboard_gpio_keys = {
103 .buttons = seaboard_gpio_keys_buttons,
104 .nbuttons = ARRAY_SIZE(seaboard_gpio_keys_buttons),
105};
106
107static struct platform_device seaboard_gpio_keys_device = {
108 .name = "gpio-keys",
109 .id = -1,
110 .dev = {
111 .platform_data = &seaboard_gpio_keys,
112 }
113};
114
115static struct tegra_sdhci_platform_data sdhci_pdata1 = {
116 .cd_gpio = -1,
117 .wp_gpio = -1,
118 .power_gpio = -1,
119};
120
121static struct tegra_sdhci_platform_data sdhci_pdata3 = {
122 .cd_gpio = TEGRA_GPIO_SD2_CD,
123 .wp_gpio = TEGRA_GPIO_SD2_WP,
124 .power_gpio = TEGRA_GPIO_SD2_POWER,
125};
126
127static struct tegra_sdhci_platform_data sdhci_pdata4 = {
128 .cd_gpio = -1,
129 .wp_gpio = -1,
130 .power_gpio = -1,
131 .is_8bit = 1,
132};
133
134static struct tegra_wm8903_platform_data seaboard_audio_pdata = {
135 .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
136 .gpio_hp_det = TEGRA_GPIO_HP_DET,
137 .gpio_hp_mute = -1,
138 .gpio_int_mic_en = -1,
139 .gpio_ext_mic_en = -1,
140};
141
142static struct platform_device seaboard_audio_device = {
143 .name = "tegra-snd-wm8903",
144 .id = 0,
145 .dev = {
146 .platform_data = &seaboard_audio_pdata,
147 },
148};
149
150static struct platform_device *seaboard_devices[] __initdata = {
151 &debug_uart,
152 &tegra_pmu_device,
153 &tegra_sdhci_device4,
154 &tegra_sdhci_device3,
155 &tegra_sdhci_device1,
156 &seaboard_gpio_keys_device,
157 &tegra_i2s_device1,
158 &tegra_das_device,
159 &seaboard_audio_device,
160};
161
162static struct i2c_board_info __initdata isl29018_device = {
163 I2C_BOARD_INFO("isl29018", 0x44),
164};
165
166static struct i2c_board_info __initdata adt7461_device = {
167 I2C_BOARD_INFO("adt7461", 0x4c),
168};
169
170static struct wm8903_platform_data wm8903_pdata = {
171 .irq_active_low = 0,
172 .micdet_cfg = 0,
173 .micdet_delay = 100,
174 .gpio_base = SEABOARD_GPIO_WM8903(0),
175 .gpio_cfg = {
176 0,
177 0,
178 WM8903_GPIO_CONFIG_ZERO,
179 0,
180 0,
181 },
182};
183
184static struct i2c_board_info __initdata wm8903_device = {
185 I2C_BOARD_INFO("wm8903", 0x1a),
186 .platform_data = &wm8903_pdata,
187};
188
189static int seaboard_ehci_init(void)
190{
191 struct tegra_ehci_platform_data *pdata;
192
193 pdata = tegra_ehci1_device.dev.platform_data;
194 pdata->vbus_gpio = TEGRA_GPIO_USB1;
195
196 platform_device_register(&tegra_ehci1_device);
197 platform_device_register(&tegra_ehci3_device);
198
199 return 0;
200}
201
202static void __init seaboard_i2c_init(void)
203{
204 isl29018_device.irq = gpio_to_irq(TEGRA_GPIO_ISL29018_IRQ);
205 i2c_register_board_info(0, &isl29018_device, 1);
206
207 wm8903_device.irq = gpio_to_irq(TEGRA_GPIO_CDC_IRQ);
208 i2c_register_board_info(0, &wm8903_device, 1);
209
210 i2c_register_board_info(3, &adt7461_device, 1);
211
212 platform_device_register(&tegra_i2c_device1);
213 platform_device_register(&tegra_i2c_device2);
214 platform_device_register(&tegra_i2c_device3);
215 platform_device_register(&tegra_i2c_device4);
216}
217
218static void __init seaboard_common_init(void)
219{
220 seaboard_pinmux_init();
221
222 tegra_clk_init_from_table(seaboard_clk_init_table);
223
224 tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
225 tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3;
226 tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
227
228 platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices));
229
230 seaboard_ehci_init();
231}
232
233static void __init tegra_seaboard_init(void)
234{
235 /* Seaboard uses UARTD for the debug port. */
236 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE);
237 debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE;
238 debug_uart_platform_data[0].irq = INT_UARTD;
239
240 seaboard_common_init();
241
242 seaboard_i2c_init();
243}
244
245static void __init tegra_kaen_init(void)
246{
247 /* Kaen uses UARTB for the debug port. */
248 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
249 debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
250 debug_uart_platform_data[0].irq = INT_UARTB;
251
252 seaboard_audio_pdata.gpio_hp_mute = TEGRA_GPIO_KAEN_HP_MUTE;
253
254 seaboard_common_init();
255
256 seaboard_i2c_init();
257}
258
259static void __init tegra_wario_init(void)
260{
261 /* Wario uses UARTB for the debug port. */
262 debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
263 debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
264 debug_uart_platform_data[0].irq = INT_UARTB;
265
266 seaboard_common_init();
267
268 seaboard_i2c_init();
269}
270
271
272MACHINE_START(SEABOARD, "seaboard")
273 .atag_offset = 0x100,
274 .map_io = tegra_map_common_io,
275 .init_early = tegra20_init_early,
276 .init_irq = tegra_init_irq,
277 .handle_irq = gic_handle_irq,
278 .timer = &tegra_timer,
279 .init_machine = tegra_seaboard_init,
280 .init_late = tegra_init_late,
281 .restart = tegra_assert_system_reset,
282MACHINE_END
283
284MACHINE_START(KAEN, "kaen")
285 .atag_offset = 0x100,
286 .map_io = tegra_map_common_io,
287 .init_early = tegra20_init_early,
288 .init_irq = tegra_init_irq,
289 .handle_irq = gic_handle_irq,
290 .timer = &tegra_timer,
291 .init_machine = tegra_kaen_init,
292 .init_late = tegra_init_late,
293 .restart = tegra_assert_system_reset,
294MACHINE_END
295
296MACHINE_START(WARIO, "wario")
297 .atag_offset = 0x100,
298 .map_io = tegra_map_common_io,
299 .init_early = tegra20_init_early,
300 .init_irq = tegra_init_irq,
301 .handle_irq = gic_handle_irq,
302 .timer = &tegra_timer,
303 .init_machine = tegra_wario_init,
304 .init_late = tegra_init_late,
305 .restart = tegra_assert_system_reset,
306MACHINE_END
diff --git a/arch/arm/mach-tegra/board-seaboard.h b/arch/arm/mach-tegra/board-seaboard.h
deleted file mode 100644
index 4c45d4ca3c4..00000000000
--- a/arch/arm/mach-tegra/board-seaboard.h
+++ /dev/null
@@ -1,47 +0,0 @@
1/*
2 * arch/arm/mach-tegra/board-seaboard.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_BOARD_SEABOARD_H
18#define _MACH_TEGRA_BOARD_SEABOARD_H
19
20#include <mach/gpio-tegra.h>
21
22#define SEABOARD_GPIO_TPS6586X(_x_) (TEGRA_NR_GPIOS + (_x_))
23#define SEABOARD_GPIO_WM8903(_x_) (SEABOARD_GPIO_TPS6586X(4) + (_x_))
24
25#define TEGRA_GPIO_SD2_CD TEGRA_GPIO_PI5
26#define TEGRA_GPIO_SD2_WP TEGRA_GPIO_PH1
27#define TEGRA_GPIO_SD2_POWER TEGRA_GPIO_PI6
28#define TEGRA_GPIO_LIDSWITCH TEGRA_GPIO_PC7
29#define TEGRA_GPIO_USB1 TEGRA_GPIO_PD0
30#define TEGRA_GPIO_POWERKEY TEGRA_GPIO_PV2
31#define TEGRA_GPIO_BACKLIGHT TEGRA_GPIO_PD4
32#define TEGRA_GPIO_LVDS_SHUTDOWN TEGRA_GPIO_PB2
33#define TEGRA_GPIO_BACKLIGHT_PWM TEGRA_GPIO_PU5
34#define TEGRA_GPIO_BACKLIGHT_VDD TEGRA_GPIO_PW0
35#define TEGRA_GPIO_EN_VDD_PNL TEGRA_GPIO_PC6
36#define TEGRA_GPIO_MAGNETOMETER TEGRA_GPIO_PN5
37#define TEGRA_GPIO_ISL29018_IRQ TEGRA_GPIO_PZ2
38#define TEGRA_GPIO_AC_ONLINE TEGRA_GPIO_PV3
39#define TEGRA_GPIO_WWAN_PWR SEABOARD_GPIO_TPS6586X(2)
40#define TEGRA_GPIO_CDC_IRQ TEGRA_GPIO_PX3
41#define TEGRA_GPIO_SPKR_EN SEABOARD_GPIO_WM8903(2)
42#define TEGRA_GPIO_HP_DET TEGRA_GPIO_PX1
43#define TEGRA_GPIO_KAEN_HP_MUTE TEGRA_GPIO_PA5
44
45void seaboard_pinmux_init(void);
46
47#endif
diff --git a/arch/arm/mach-tegra/board.h b/arch/arm/mach-tegra/board.h
index 65014968fc6..f88e5143c76 100644
--- a/arch/arm/mach-tegra/board.h
+++ b/arch/arm/mach-tegra/board.h
@@ -46,5 +46,14 @@ int __init tegra_powergate_debugfs_init(void);
46static inline int tegra_powergate_debugfs_init(void) { return 0; } 46static inline int tegra_powergate_debugfs_init(void) { return 0; }
47#endif 47#endif
48 48
49int __init harmony_regulator_init(void);
50#ifdef CONFIG_TEGRA_PCI
51int __init harmony_pcie_init(void);
52#else
53static inline int harmony_pcie_init(void) { return 0; }
54#endif
55
56void __init tegra_paz00_wifikill_init(void);
57
49extern struct sys_timer tegra_timer; 58extern struct sys_timer tegra_timer;
50#endif 59#endif
diff --git a/arch/arm/mach-tegra/common.c b/arch/arm/mach-tegra/common.c
index 204a5c8b0b5..96fef6bcc65 100644
--- a/arch/arm/mach-tegra/common.c
+++ b/arch/arm/mach-tegra/common.c
@@ -33,6 +33,7 @@
33#include "clock.h" 33#include "clock.h"
34#include "fuse.h" 34#include "fuse.h"
35#include "pmc.h" 35#include "pmc.h"
36#include "apbio.h"
36 37
37/* 38/*
38 * Storage for debug-macro.S's state. 39 * Storage for debug-macro.S's state.
@@ -127,6 +128,7 @@ static void __init tegra_init_cache(u32 tag_latency, u32 data_latency)
127#ifdef CONFIG_ARCH_TEGRA_2x_SOC 128#ifdef CONFIG_ARCH_TEGRA_2x_SOC
128void __init tegra20_init_early(void) 129void __init tegra20_init_early(void)
129{ 130{
131 tegra_apb_io_init();
130 tegra_init_fuse(); 132 tegra_init_fuse();
131 tegra2_init_clocks(); 133 tegra2_init_clocks();
132 tegra_clk_init_from_table(tegra20_clk_init_table); 134 tegra_clk_init_from_table(tegra20_clk_init_table);
@@ -138,6 +140,7 @@ void __init tegra20_init_early(void)
138#ifdef CONFIG_ARCH_TEGRA_3x_SOC 140#ifdef CONFIG_ARCH_TEGRA_3x_SOC
139void __init tegra30_init_early(void) 141void __init tegra30_init_early(void)
140{ 142{
143 tegra_apb_io_init();
141 tegra_init_fuse(); 144 tegra_init_fuse();
142 tegra30_init_clocks(); 145 tegra30_init_clocks();
143 tegra_clk_init_from_table(tegra30_clk_init_table); 146 tegra_clk_init_from_table(tegra30_clk_init_table);
diff --git a/arch/arm/mach-tegra/cpu-tegra.c b/arch/arm/mach-tegra/cpu-tegra.c
index 7a065f0cf63..ceb52db1e2f 100644
--- a/arch/arm/mach-tegra/cpu-tegra.c
+++ b/arch/arm/mach-tegra/cpu-tegra.c
@@ -189,8 +189,8 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)
189 return PTR_ERR(emc_clk); 189 return PTR_ERR(emc_clk);
190 } 190 }
191 191
192 clk_enable(emc_clk); 192 clk_prepare_enable(emc_clk);
193 clk_enable(cpu_clk); 193 clk_prepare_enable(cpu_clk);
194 194
195 cpufreq_frequency_table_cpuinfo(policy, freq_table); 195 cpufreq_frequency_table_cpuinfo(policy, freq_table);
196 cpufreq_frequency_table_get_attr(freq_table, policy->cpu); 196 cpufreq_frequency_table_get_attr(freq_table, policy->cpu);
@@ -212,7 +212,7 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)
212static int tegra_cpu_exit(struct cpufreq_policy *policy) 212static int tegra_cpu_exit(struct cpufreq_policy *policy)
213{ 213{
214 cpufreq_frequency_table_cpuinfo(policy, freq_table); 214 cpufreq_frequency_table_cpuinfo(policy, freq_table);
215 clk_disable(emc_clk); 215 clk_disable_unprepare(emc_clk);
216 clk_put(emc_clk); 216 clk_put(emc_clk);
217 clk_put(cpu_clk); 217 clk_put(cpu_clk);
218 return 0; 218 return 0;
diff --git a/arch/arm/mach-tegra/cpuidle.c b/arch/arm/mach-tegra/cpuidle.c
index d83a8c0296f..566e2f88899 100644
--- a/arch/arm/mach-tegra/cpuidle.c
+++ b/arch/arm/mach-tegra/cpuidle.c
@@ -27,9 +27,9 @@
27#include <linux/cpuidle.h> 27#include <linux/cpuidle.h>
28#include <linux/hrtimer.h> 28#include <linux/hrtimer.h>
29 29
30#include <mach/iomap.h> 30#include <asm/proc-fns.h>
31 31
32extern void tegra_cpu_wfi(void); 32#include <mach/iomap.h>
33 33
34static int tegra_idle_enter_lp3(struct cpuidle_device *dev, 34static int tegra_idle_enter_lp3(struct cpuidle_device *dev,
35 struct cpuidle_driver *drv, int index); 35 struct cpuidle_driver *drv, int index);
@@ -64,7 +64,7 @@ static int tegra_idle_enter_lp3(struct cpuidle_device *dev,
64 64
65 enter = ktime_get(); 65 enter = ktime_get();
66 66
67 tegra_cpu_wfi(); 67 cpu_do_idle();
68 68
69 exit = ktime_sub(ktime_get(), enter); 69 exit = ktime_sub(ktime_get(), enter);
70 us = ktime_to_us(exit); 70 us = ktime_to_us(exit);
diff --git a/arch/arm/mach-tegra/dma.c b/arch/arm/mach-tegra/dma.c
index abea4f6e2dd..29c5114d607 100644
--- a/arch/arm/mach-tegra/dma.c
+++ b/arch/arm/mach-tegra/dma.c
@@ -714,13 +714,13 @@ int __init tegra_dma_init(void)
714 714
715 bitmap_fill(channel_usage, NV_DMA_MAX_CHANNELS); 715 bitmap_fill(channel_usage, NV_DMA_MAX_CHANNELS);
716 716
717 c = clk_get_sys("tegra-dma", NULL); 717 c = clk_get_sys("tegra-apbdma", NULL);
718 if (IS_ERR(c)) { 718 if (IS_ERR(c)) {
719 pr_err("Unable to get clock for APB DMA\n"); 719 pr_err("Unable to get clock for APB DMA\n");
720 ret = PTR_ERR(c); 720 ret = PTR_ERR(c);
721 goto fail; 721 goto fail;
722 } 722 }
723 ret = clk_enable(c); 723 ret = clk_prepare_enable(c);
724 if (ret != 0) { 724 if (ret != 0) {
725 pr_err("Unable to enable clock for APB DMA\n"); 725 pr_err("Unable to enable clock for APB DMA\n");
726 goto fail; 726 goto fail;
diff --git a/arch/arm/mach-tegra/pcie.c b/arch/arm/mach-tegra/pcie.c
index 0e09137506e..d3ad5150d66 100644
--- a/arch/arm/mach-tegra/pcie.c
+++ b/arch/arm/mach-tegra/pcie.c
@@ -723,9 +723,9 @@ static int tegra_pcie_power_regate(void)
723 723
724 tegra_pcie_xclk_clamp(false); 724 tegra_pcie_xclk_clamp(false);
725 725
726 clk_enable(tegra_pcie.afi_clk); 726 clk_prepare_enable(tegra_pcie.afi_clk);
727 clk_enable(tegra_pcie.pex_clk); 727 clk_prepare_enable(tegra_pcie.pex_clk);
728 return clk_enable(tegra_pcie.pll_e); 728 return clk_prepare_enable(tegra_pcie.pll_e);
729} 729}
730 730
731static int tegra_pcie_clocks_get(void) 731static int tegra_pcie_clocks_get(void)
diff --git a/arch/arm/mach-tegra/powergate.c b/arch/arm/mach-tegra/powergate.c
index f5b12fb4ff1..15d506501cc 100644
--- a/arch/arm/mach-tegra/powergate.c
+++ b/arch/arm/mach-tegra/powergate.c
@@ -146,7 +146,7 @@ int tegra_powergate_sequence_power_up(int id, struct clk *clk)
146 if (ret) 146 if (ret)
147 goto err_power; 147 goto err_power;
148 148
149 ret = clk_enable(clk); 149 ret = clk_prepare_enable(clk);
150 if (ret) 150 if (ret)
151 goto err_clk; 151 goto err_clk;
152 152
@@ -162,7 +162,7 @@ int tegra_powergate_sequence_power_up(int id, struct clk *clk)
162 return 0; 162 return 0;
163 163
164err_clamp: 164err_clamp:
165 clk_disable(clk); 165 clk_disable_unprepare(clk);
166err_clk: 166err_clk:
167 tegra_powergate_power_off(id); 167 tegra_powergate_power_off(id);
168err_power: 168err_power:
diff --git a/arch/arm/mach-tegra/sleep.S b/arch/arm/mach-tegra/sleep.S
index 5b20197bae7..d29b156a801 100644
--- a/arch/arm/mach-tegra/sleep.S
+++ b/arch/arm/mach-tegra/sleep.S
@@ -62,32 +62,3 @@
62 movw \reg, #:lower16:\val 62 movw \reg, #:lower16:\val
63 movt \reg, #:upper16:\val 63 movt \reg, #:upper16:\val
64.endm 64.endm
65
66/*
67 * tegra_cpu_wfi
68 *
69 * puts current CPU in clock-gated wfi using the flow controller
70 *
71 * corrupts r0-r3
72 * must be called with MMU on
73 */
74
75ENTRY(tegra_cpu_wfi)
76 cpu_id r0
77 cpu_to_halt_reg r1, r0
78 cpu_to_csr_reg r2, r0
79 mov32 r0, TEGRA_FLOW_CTRL_VIRT
80 mov r3, #FLOW_CTRL_CSR_INTR_FLAG | FLOW_CTRL_CSR_EVENT_FLAG
81 str r3, [r0, r2] @ clear event & interrupt status
82 mov r3, #FLOW_CTRL_WAIT_FOR_INTERRUPT | FLOW_CTRL_JTAG_RESUME
83 str r3, [r0, r1] @ put flow controller in wait irq mode
84 dsb
85 wfi
86 mov r3, #0
87 str r3, [r0, r1] @ clear flow controller halt status
88 mov r3, #FLOW_CTRL_CSR_INTR_FLAG | FLOW_CTRL_CSR_EVENT_FLAG
89 str r3, [r0, r2] @ clear event & interrupt status
90 dsb
91 mov pc, lr
92ENDPROC(tegra_cpu_wfi)
93
diff --git a/arch/arm/mach-tegra/tegra2_clocks.c b/arch/arm/mach-tegra/tegra2_clocks.c
index b59315ce369..a703844b206 100644
--- a/arch/arm/mach-tegra/tegra2_clocks.c
+++ b/arch/arm/mach-tegra/tegra2_clocks.c
@@ -69,6 +69,8 @@
69 69
70#define PERIPH_CLK_SOURCE_MASK (3<<30) 70#define PERIPH_CLK_SOURCE_MASK (3<<30)
71#define PERIPH_CLK_SOURCE_SHIFT 30 71#define PERIPH_CLK_SOURCE_SHIFT 30
72#define PERIPH_CLK_SOURCE_PWM_MASK (7<<28)
73#define PERIPH_CLK_SOURCE_PWM_SHIFT 28
72#define PERIPH_CLK_SOURCE_ENABLE (1<<28) 74#define PERIPH_CLK_SOURCE_ENABLE (1<<28)
73#define PERIPH_CLK_SOURCE_DIVU71_MASK 0xFF 75#define PERIPH_CLK_SOURCE_DIVU71_MASK 0xFF
74#define PERIPH_CLK_SOURCE_DIVU16_MASK 0xFFFF 76#define PERIPH_CLK_SOURCE_DIVU16_MASK 0xFFFF
@@ -908,9 +910,20 @@ static void tegra2_periph_clk_init(struct clk *c)
908 u32 val = clk_readl(c->reg); 910 u32 val = clk_readl(c->reg);
909 const struct clk_mux_sel *mux = NULL; 911 const struct clk_mux_sel *mux = NULL;
910 const struct clk_mux_sel *sel; 912 const struct clk_mux_sel *sel;
913 u32 shift;
914 u32 mask;
915
916 if (c->flags & MUX_PWM) {
917 shift = PERIPH_CLK_SOURCE_PWM_SHIFT;
918 mask = PERIPH_CLK_SOURCE_PWM_MASK;
919 } else {
920 shift = PERIPH_CLK_SOURCE_SHIFT;
921 mask = PERIPH_CLK_SOURCE_MASK;
922 }
923
911 if (c->flags & MUX) { 924 if (c->flags & MUX) {
912 for (sel = c->inputs; sel->input != NULL; sel++) { 925 for (sel = c->inputs; sel->input != NULL; sel++) {
913 if (val >> PERIPH_CLK_SOURCE_SHIFT == sel->value) 926 if ((val & mask) >> shift == sel->value)
914 mux = sel; 927 mux = sel;
915 } 928 }
916 BUG_ON(!mux); 929 BUG_ON(!mux);
@@ -1023,12 +1036,23 @@ static int tegra2_periph_clk_set_parent(struct clk *c, struct clk *p)
1023{ 1036{
1024 u32 val; 1037 u32 val;
1025 const struct clk_mux_sel *sel; 1038 const struct clk_mux_sel *sel;
1039 u32 mask, shift;
1040
1026 pr_debug("%s: %s %s\n", __func__, c->name, p->name); 1041 pr_debug("%s: %s %s\n", __func__, c->name, p->name);
1042
1043 if (c->flags & MUX_PWM) {
1044 shift = PERIPH_CLK_SOURCE_PWM_SHIFT;
1045 mask = PERIPH_CLK_SOURCE_PWM_MASK;
1046 } else {
1047 shift = PERIPH_CLK_SOURCE_SHIFT;
1048 mask = PERIPH_CLK_SOURCE_MASK;
1049 }
1050
1027 for (sel = c->inputs; sel->input != NULL; sel++) { 1051 for (sel = c->inputs; sel->input != NULL; sel++) {
1028 if (sel->input == p) { 1052 if (sel->input == p) {
1029 val = clk_readl(c->reg); 1053 val = clk_readl(c->reg);
1030 val &= ~PERIPH_CLK_SOURCE_MASK; 1054 val &= ~mask;
1031 val |= (sel->value) << PERIPH_CLK_SOURCE_SHIFT; 1055 val |= (sel->value) << shift;
1032 1056
1033 if (c->refcnt) 1057 if (c->refcnt)
1034 clk_enable(p); 1058 clk_enable(p);
@@ -2149,14 +2173,14 @@ static struct clk tegra_clk_emc = {
2149 } 2173 }
2150 2174
2151static struct clk tegra_list_clks[] = { 2175static struct clk tegra_list_clks[] = {
2152 PERIPH_CLK("apbdma", "tegra-dma", NULL, 34, 0, 108000000, mux_pclk, 0), 2176 PERIPH_CLK("apbdma", "tegra-apbdma", NULL, 34, 0, 108000000, mux_pclk, 0),
2153 PERIPH_CLK("rtc", "rtc-tegra", NULL, 4, 0, 32768, mux_clk_32k, PERIPH_NO_RESET), 2177 PERIPH_CLK("rtc", "rtc-tegra", NULL, 4, 0, 32768, mux_clk_32k, PERIPH_NO_RESET),
2154 PERIPH_CLK("timer", "timer", NULL, 5, 0, 26000000, mux_clk_m, 0), 2178 PERIPH_CLK("timer", "timer", NULL, 5, 0, 26000000, mux_clk_m, 0),
2155 PERIPH_CLK("i2s1", "tegra20-i2s.0", NULL, 11, 0x100, 26000000, mux_pllaout0_audio2x_pllp_clkm, MUX | DIV_U71), 2179 PERIPH_CLK("i2s1", "tegra20-i2s.0", NULL, 11, 0x100, 26000000, mux_pllaout0_audio2x_pllp_clkm, MUX | DIV_U71),
2156 PERIPH_CLK("i2s2", "tegra20-i2s.1", NULL, 18, 0x104, 26000000, mux_pllaout0_audio2x_pllp_clkm, MUX | DIV_U71), 2180 PERIPH_CLK("i2s2", "tegra20-i2s.1", NULL, 18, 0x104, 26000000, mux_pllaout0_audio2x_pllp_clkm, MUX | DIV_U71),
2157 PERIPH_CLK("spdif_out", "spdif_out", NULL, 10, 0x108, 100000000, mux_pllaout0_audio2x_pllp_clkm, MUX | DIV_U71), 2181 PERIPH_CLK("spdif_out", "spdif_out", NULL, 10, 0x108, 100000000, mux_pllaout0_audio2x_pllp_clkm, MUX | DIV_U71),
2158 PERIPH_CLK("spdif_in", "spdif_in", NULL, 10, 0x10c, 100000000, mux_pllp_pllc_pllm, MUX | DIV_U71), 2182 PERIPH_CLK("spdif_in", "spdif_in", NULL, 10, 0x10c, 100000000, mux_pllp_pllc_pllm, MUX | DIV_U71),
2159 PERIPH_CLK("pwm", "pwm", NULL, 17, 0x110, 432000000, mux_pllp_pllc_audio_clkm_clk32, MUX | DIV_U71), 2183 PERIPH_CLK("pwm", "tegra-pwm", NULL, 17, 0x110, 432000000, mux_pllp_pllc_audio_clkm_clk32, MUX | DIV_U71 | MUX_PWM),
2160 PERIPH_CLK("spi", "spi", NULL, 43, 0x114, 40000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 2184 PERIPH_CLK("spi", "spi", NULL, 43, 0x114, 40000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
2161 PERIPH_CLK("xio", "xio", NULL, 45, 0x120, 150000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 2185 PERIPH_CLK("xio", "xio", NULL, 45, 0x120, 150000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
2162 PERIPH_CLK("twc", "twc", NULL, 16, 0x12c, 150000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 2186 PERIPH_CLK("twc", "twc", NULL, 16, 0x12c, 150000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
@@ -2189,11 +2213,11 @@ static struct clk tegra_list_clks[] = {
2189 PERIPH_CLK("i2c2_i2c", "tegra-i2c.1", "i2c", 0, 0, 72000000, mux_pllp_out3, 0), 2213 PERIPH_CLK("i2c2_i2c", "tegra-i2c.1", "i2c", 0, 0, 72000000, mux_pllp_out3, 0),
2190 PERIPH_CLK("i2c3_i2c", "tegra-i2c.2", "i2c", 0, 0, 72000000, mux_pllp_out3, 0), 2214 PERIPH_CLK("i2c3_i2c", "tegra-i2c.2", "i2c", 0, 0, 72000000, mux_pllp_out3, 0),
2191 PERIPH_CLK("dvc_i2c", "tegra-i2c.3", "i2c", 0, 0, 72000000, mux_pllp_out3, 0), 2215 PERIPH_CLK("dvc_i2c", "tegra-i2c.3", "i2c", 0, 0, 72000000, mux_pllp_out3, 0),
2192 PERIPH_CLK("uarta", "uart.0", NULL, 6, 0x178, 600000000, mux_pllp_pllc_pllm_clkm, MUX), 2216 PERIPH_CLK("uarta", "tegra-uart.0", NULL, 6, 0x178, 600000000, mux_pllp_pllc_pllm_clkm, MUX),
2193 PERIPH_CLK("uartb", "uart.1", NULL, 7, 0x17c, 600000000, mux_pllp_pllc_pllm_clkm, MUX), 2217 PERIPH_CLK("uartb", "tegra-uart.1", NULL, 7, 0x17c, 600000000, mux_pllp_pllc_pllm_clkm, MUX),
2194 PERIPH_CLK("uartc", "uart.2", NULL, 55, 0x1a0, 600000000, mux_pllp_pllc_pllm_clkm, MUX), 2218 PERIPH_CLK("uartc", "tegra-uart.2", NULL, 55, 0x1a0, 600000000, mux_pllp_pllc_pllm_clkm, MUX),
2195 PERIPH_CLK("uartd", "uart.3", NULL, 65, 0x1c0, 600000000, mux_pllp_pllc_pllm_clkm, MUX), 2219 PERIPH_CLK("uartd", "tegra-uart.3", NULL, 65, 0x1c0, 600000000, mux_pllp_pllc_pllm_clkm, MUX),
2196 PERIPH_CLK("uarte", "uart.4", NULL, 66, 0x1c4, 600000000, mux_pllp_pllc_pllm_clkm, MUX), 2220 PERIPH_CLK("uarte", "tegra-uart.4", NULL, 66, 0x1c4, 600000000, mux_pllp_pllc_pllm_clkm, MUX),
2197 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 */ 2221 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 */
2198 PERIPH_CLK("2d", "2d", NULL, 21, 0x15c, 300000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71), /* scales with voltage and process_id */ 2222 PERIPH_CLK("2d", "2d", NULL, 21, 0x15c, 300000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71), /* scales with voltage and process_id */
2199 PERIPH_CLK("vi", "tegra_camera", "vi", 20, 0x148, 150000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71), /* scales with voltage and process_id */ 2223 PERIPH_CLK("vi", "tegra_camera", "vi", 20, 0x148, 150000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71), /* scales with voltage and process_id */
@@ -2245,20 +2269,16 @@ static struct clk tegra_list_clks[] = {
2245 * table under two names. 2269 * table under two names.
2246 */ 2270 */
2247static struct clk_duplicate tegra_clk_duplicates[] = { 2271static struct clk_duplicate tegra_clk_duplicates[] = {
2248 CLK_DUPLICATE("uarta", "tegra_uart.0", NULL), 2272 CLK_DUPLICATE("uarta", "serial8250.0", NULL),
2249 CLK_DUPLICATE("uartb", "tegra_uart.1", NULL), 2273 CLK_DUPLICATE("uartb", "serial8250.1", NULL),
2250 CLK_DUPLICATE("uartc", "tegra_uart.2", NULL), 2274 CLK_DUPLICATE("uartc", "serial8250.2", NULL),
2251 CLK_DUPLICATE("uartd", "tegra_uart.3", NULL), 2275 CLK_DUPLICATE("uartd", "serial8250.3", NULL),
2252 CLK_DUPLICATE("uarte", "tegra_uart.4", NULL), 2276 CLK_DUPLICATE("uarte", "serial8250.4", NULL),
2253 CLK_DUPLICATE("usbd", "utmip-pad", NULL), 2277 CLK_DUPLICATE("usbd", "utmip-pad", NULL),
2254 CLK_DUPLICATE("usbd", "tegra-ehci.0", NULL), 2278 CLK_DUPLICATE("usbd", "tegra-ehci.0", NULL),
2255 CLK_DUPLICATE("usbd", "tegra-otg", NULL), 2279 CLK_DUPLICATE("usbd", "tegra-otg", NULL),
2256 CLK_DUPLICATE("hdmi", "tegradc.0", "hdmi"), 2280 CLK_DUPLICATE("hdmi", "tegradc.0", "hdmi"),
2257 CLK_DUPLICATE("hdmi", "tegradc.1", "hdmi"), 2281 CLK_DUPLICATE("hdmi", "tegradc.1", "hdmi"),
2258 CLK_DUPLICATE("pwm", "tegra_pwm.0", NULL),
2259 CLK_DUPLICATE("pwm", "tegra_pwm.1", NULL),
2260 CLK_DUPLICATE("pwm", "tegra_pwm.2", NULL),
2261 CLK_DUPLICATE("pwm", "tegra_pwm.3", NULL),
2262 CLK_DUPLICATE("host1x", "tegra_grhost", "host1x"), 2282 CLK_DUPLICATE("host1x", "tegra_grhost", "host1x"),
2263 CLK_DUPLICATE("2d", "tegra_grhost", "gr2d"), 2283 CLK_DUPLICATE("2d", "tegra_grhost", "gr2d"),
2264 CLK_DUPLICATE("3d", "tegra_grhost", "gr3d"), 2284 CLK_DUPLICATE("3d", "tegra_grhost", "gr3d"),
diff --git a/arch/arm/mach-tegra/tegra30_clocks.c b/arch/arm/mach-tegra/tegra30_clocks.c
index e33fe4b14a2..6674f100e16 100644
--- a/arch/arm/mach-tegra/tegra30_clocks.c
+++ b/arch/arm/mach-tegra/tegra30_clocks.c
@@ -2871,7 +2871,7 @@ static struct clk tegra30_clk_twd = {
2871 }, \ 2871 }, \
2872 } 2872 }
2873struct clk tegra_list_clks[] = { 2873struct clk tegra_list_clks[] = {
2874 PERIPH_CLK("apbdma", "tegra-dma", NULL, 34, 0, 26000000, mux_clk_m, 0), 2874 PERIPH_CLK("apbdma", "tegra-apbdma", NULL, 34, 0, 26000000, mux_clk_m, 0),
2875 PERIPH_CLK("rtc", "rtc-tegra", NULL, 4, 0, 32768, mux_clk_32k, PERIPH_NO_RESET | PERIPH_ON_APB), 2875 PERIPH_CLK("rtc", "rtc-tegra", NULL, 4, 0, 32768, mux_clk_32k, PERIPH_NO_RESET | PERIPH_ON_APB),
2876 PERIPH_CLK("kbc", "tegra-kbc", NULL, 36, 0, 32768, mux_clk_32k, PERIPH_NO_RESET | PERIPH_ON_APB), 2876 PERIPH_CLK("kbc", "tegra-kbc", NULL, 36, 0, 32768, mux_clk_32k, PERIPH_NO_RESET | PERIPH_ON_APB),
2877 PERIPH_CLK("timer", "timer", NULL, 5, 0, 26000000, mux_clk_m, 0), 2877 PERIPH_CLK("timer", "timer", NULL, 5, 0, 26000000, mux_clk_m, 0),
@@ -2886,7 +2886,7 @@ struct clk tegra_list_clks[] = {
2886 PERIPH_CLK("i2s4", "tegra30-i2s.4", NULL, 102, 0x3c0, 26000000, mux_pllaout0_audio4_2x_pllp_clkm, MUX | DIV_U71 | PERIPH_ON_APB), 2886 PERIPH_CLK("i2s4", "tegra30-i2s.4", NULL, 102, 0x3c0, 26000000, mux_pllaout0_audio4_2x_pllp_clkm, MUX | DIV_U71 | PERIPH_ON_APB),
2887 PERIPH_CLK("spdif_out", "tegra30-spdif", "spdif_out", 10, 0x108, 100000000, mux_pllaout0_audio_2x_pllp_clkm, MUX | DIV_U71 | PERIPH_ON_APB), 2887 PERIPH_CLK("spdif_out", "tegra30-spdif", "spdif_out", 10, 0x108, 100000000, mux_pllaout0_audio_2x_pllp_clkm, MUX | DIV_U71 | PERIPH_ON_APB),
2888 PERIPH_CLK("spdif_in", "tegra30-spdif", "spdif_in", 10, 0x10c, 100000000, mux_pllp_pllc_pllm, MUX | DIV_U71 | PERIPH_ON_APB), 2888 PERIPH_CLK("spdif_in", "tegra30-spdif", "spdif_in", 10, 0x10c, 100000000, mux_pllp_pllc_pllm, MUX | DIV_U71 | PERIPH_ON_APB),
2889 PERIPH_CLK("pwm", "pwm", NULL, 17, 0x110, 432000000, mux_pllp_pllc_clk32_clkm, MUX | MUX_PWM | DIV_U71 | PERIPH_ON_APB), 2889 PERIPH_CLK("pwm", "tegra-pwm", NULL, 17, 0x110, 432000000, mux_pllp_pllc_clk32_clkm, MUX | MUX_PWM | DIV_U71 | PERIPH_ON_APB),
2890 PERIPH_CLK("d_audio", "tegra30-ahub", "d_audio", 106, 0x3d0, 48000000, mux_plla_pllc_pllp_clkm, MUX | DIV_U71), 2890 PERIPH_CLK("d_audio", "tegra30-ahub", "d_audio", 106, 0x3d0, 48000000, mux_plla_pllc_pllp_clkm, MUX | DIV_U71),
2891 PERIPH_CLK("dam0", "tegra30-dam.0", NULL, 108, 0x3d8, 48000000, mux_plla_pllc_pllp_clkm, MUX | DIV_U71), 2891 PERIPH_CLK("dam0", "tegra30-dam.0", NULL, 108, 0x3d8, 48000000, mux_plla_pllc_pllp_clkm, MUX | DIV_U71),
2892 PERIPH_CLK("dam1", "tegra30-dam.1", NULL, 109, 0x3dc, 48000000, mux_plla_pllc_pllp_clkm, MUX | DIV_U71), 2892 PERIPH_CLK("dam1", "tegra30-dam.1", NULL, 109, 0x3dc, 48000000, mux_plla_pllc_pllp_clkm, MUX | DIV_U71),
@@ -2924,16 +2924,11 @@ struct clk tegra_list_clks[] = {
2924 PERIPH_CLK("i2c3", "tegra-i2c.2", NULL, 67, 0x1b8, 26000000, mux_pllp_clkm, MUX | DIV_U16 | PERIPH_ON_APB), 2924 PERIPH_CLK("i2c3", "tegra-i2c.2", NULL, 67, 0x1b8, 26000000, mux_pllp_clkm, MUX | DIV_U16 | PERIPH_ON_APB),
2925 PERIPH_CLK("i2c4", "tegra-i2c.3", NULL, 103, 0x3c4, 26000000, mux_pllp_clkm, MUX | DIV_U16 | PERIPH_ON_APB), 2925 PERIPH_CLK("i2c4", "tegra-i2c.3", NULL, 103, 0x3c4, 26000000, mux_pllp_clkm, MUX | DIV_U16 | PERIPH_ON_APB),
2926 PERIPH_CLK("i2c5", "tegra-i2c.4", NULL, 47, 0x128, 26000000, mux_pllp_clkm, MUX | DIV_U16 | PERIPH_ON_APB), 2926 PERIPH_CLK("i2c5", "tegra-i2c.4", NULL, 47, 0x128, 26000000, mux_pllp_clkm, MUX | DIV_U16 | PERIPH_ON_APB),
2927 PERIPH_CLK("uarta", "tegra_uart.0", NULL, 6, 0x178, 800000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB), 2927 PERIPH_CLK("uarta", "tegra-uart.0", NULL, 6, 0x178, 800000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB),
2928 PERIPH_CLK("uartb", "tegra_uart.1", NULL, 7, 0x17c, 800000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB), 2928 PERIPH_CLK("uartb", "tegra-uart.1", NULL, 7, 0x17c, 800000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB),
2929 PERIPH_CLK("uartc", "tegra_uart.2", NULL, 55, 0x1a0, 800000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB), 2929 PERIPH_CLK("uartc", "tegra-uart.2", NULL, 55, 0x1a0, 800000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB),
2930 PERIPH_CLK("uartd", "tegra_uart.3", NULL, 65, 0x1c0, 800000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB), 2930 PERIPH_CLK("uartd", "tegra-uart.3", NULL, 65, 0x1c0, 800000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB),
2931 PERIPH_CLK("uarte", "tegra_uart.4", NULL, 66, 0x1c4, 800000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB), 2931 PERIPH_CLK("uarte", "tegra-uart.4", NULL, 66, 0x1c4, 800000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB),
2932 PERIPH_CLK("uarta_dbg", "serial8250.0", "uarta", 6, 0x178, 800000000, mux_pllp_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB),
2933 PERIPH_CLK("uartb_dbg", "serial8250.0", "uartb", 7, 0x17c, 800000000, mux_pllp_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB),
2934 PERIPH_CLK("uartc_dbg", "serial8250.0", "uartc", 55, 0x1a0, 800000000, mux_pllp_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB),
2935 PERIPH_CLK("uartd_dbg", "serial8250.0", "uartd", 65, 0x1c0, 800000000, mux_pllp_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB),
2936 PERIPH_CLK("uarte_dbg", "serial8250.0", "uarte", 66, 0x1c4, 800000000, mux_pllp_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB),
2937 PERIPH_CLK_EX("vi", "tegra_camera", "vi", 20, 0x148, 425000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | DIV_U71_INT, &tegra_vi_clk_ops), 2932 PERIPH_CLK_EX("vi", "tegra_camera", "vi", 20, 0x148, 425000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | DIV_U71_INT, &tegra_vi_clk_ops),
2938 PERIPH_CLK("3d", "3d", NULL, 24, 0x158, 520000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | DIV_U71_INT | DIV_U71_IDLE | PERIPH_MANUAL_RESET), 2933 PERIPH_CLK("3d", "3d", NULL, 24, 0x158, 520000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | DIV_U71_INT | DIV_U71_IDLE | PERIPH_MANUAL_RESET),
2939 PERIPH_CLK("3d2", "3d2", NULL, 98, 0x3b0, 520000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | DIV_U71_INT | DIV_U71_IDLE | PERIPH_MANUAL_RESET), 2934 PERIPH_CLK("3d2", "3d2", NULL, 98, 0x3b0, 520000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | DIV_U71_INT | DIV_U71_IDLE | PERIPH_MANUAL_RESET),
@@ -2983,6 +2978,11 @@ struct clk tegra_list_clks[] = {
2983 * table under two names. 2978 * table under two names.
2984 */ 2979 */
2985struct clk_duplicate tegra_clk_duplicates[] = { 2980struct clk_duplicate tegra_clk_duplicates[] = {
2981 CLK_DUPLICATE("uarta", "serial8250.0", NULL),
2982 CLK_DUPLICATE("uartb", "serial8250.1", NULL),
2983 CLK_DUPLICATE("uartc", "serial8250.2", NULL),
2984 CLK_DUPLICATE("uartd", "serial8250.3", NULL),
2985 CLK_DUPLICATE("uarte", "serial8250.4", NULL),
2986 CLK_DUPLICATE("usbd", "utmip-pad", NULL), 2986 CLK_DUPLICATE("usbd", "utmip-pad", NULL),
2987 CLK_DUPLICATE("usbd", "tegra-ehci.0", NULL), 2987 CLK_DUPLICATE("usbd", "tegra-ehci.0", NULL),
2988 CLK_DUPLICATE("usbd", "tegra-otg", NULL), 2988 CLK_DUPLICATE("usbd", "tegra-otg", NULL),
@@ -2990,10 +2990,6 @@ struct clk_duplicate tegra_clk_duplicates[] = {
2990 CLK_DUPLICATE("hdmi", "tegradc.1", "hdmi"), 2990 CLK_DUPLICATE("hdmi", "tegradc.1", "hdmi"),
2991 CLK_DUPLICATE("dsib", "tegradc.0", "dsib"), 2991 CLK_DUPLICATE("dsib", "tegradc.0", "dsib"),
2992 CLK_DUPLICATE("dsia", "tegradc.1", "dsia"), 2992 CLK_DUPLICATE("dsia", "tegradc.1", "dsia"),
2993 CLK_DUPLICATE("pwm", "tegra_pwm.0", NULL),
2994 CLK_DUPLICATE("pwm", "tegra_pwm.1", NULL),
2995 CLK_DUPLICATE("pwm", "tegra_pwm.2", NULL),
2996 CLK_DUPLICATE("pwm", "tegra_pwm.3", NULL),
2997 CLK_DUPLICATE("bsev", "tegra-avp", "bsev"), 2993 CLK_DUPLICATE("bsev", "tegra-avp", "bsev"),
2998 CLK_DUPLICATE("bsev", "nvavp", "bsev"), 2994 CLK_DUPLICATE("bsev", "nvavp", "bsev"),
2999 CLK_DUPLICATE("vde", "tegra-aes", "vde"), 2995 CLK_DUPLICATE("vde", "tegra-aes", "vde"),
diff --git a/arch/arm/mach-tegra/timer.c b/arch/arm/mach-tegra/timer.c
index 315672c7bd4..57b5bdc13b9 100644
--- a/arch/arm/mach-tegra/timer.c
+++ b/arch/arm/mach-tegra/timer.c
@@ -189,7 +189,7 @@ static void __init tegra_init_timer(void)
189 " Assuming 12Mhz input clock.\n"); 189 " Assuming 12Mhz input clock.\n");
190 rate = 12000000; 190 rate = 12000000;
191 } else { 191 } else {
192 clk_enable(clk); 192 clk_prepare_enable(clk);
193 rate = clk_get_rate(clk); 193 rate = clk_get_rate(clk);
194 } 194 }
195 195
@@ -201,7 +201,7 @@ static void __init tegra_init_timer(void)
201 if (IS_ERR(clk)) 201 if (IS_ERR(clk))
202 pr_warn("Unable to get rtc-tegra clock\n"); 202 pr_warn("Unable to get rtc-tegra clock\n");
203 else 203 else
204 clk_enable(clk); 204 clk_prepare_enable(clk);
205 205
206 switch (rate) { 206 switch (rate) {
207 case 12000000: 207 case 12000000:
diff --git a/arch/arm/mach-tegra/usb_phy.c b/arch/arm/mach-tegra/usb_phy.c
index 54e353c8e30..022b33a05c3 100644
--- a/arch/arm/mach-tegra/usb_phy.c
+++ b/arch/arm/mach-tegra/usb_phy.c
@@ -247,7 +247,7 @@ static void utmip_pad_power_on(struct tegra_usb_phy *phy)
247 unsigned long val, flags; 247 unsigned long val, flags;
248 void __iomem *base = phy->pad_regs; 248 void __iomem *base = phy->pad_regs;
249 249
250 clk_enable(phy->pad_clk); 250 clk_prepare_enable(phy->pad_clk);
251 251
252 spin_lock_irqsave(&utmip_pad_lock, flags); 252 spin_lock_irqsave(&utmip_pad_lock, flags);
253 253
@@ -259,7 +259,7 @@ static void utmip_pad_power_on(struct tegra_usb_phy *phy)
259 259
260 spin_unlock_irqrestore(&utmip_pad_lock, flags); 260 spin_unlock_irqrestore(&utmip_pad_lock, flags);
261 261
262 clk_disable(phy->pad_clk); 262 clk_disable_unprepare(phy->pad_clk);
263} 263}
264 264
265static int utmip_pad_power_off(struct tegra_usb_phy *phy) 265static int utmip_pad_power_off(struct tegra_usb_phy *phy)
@@ -272,7 +272,7 @@ static int utmip_pad_power_off(struct tegra_usb_phy *phy)
272 return -EINVAL; 272 return -EINVAL;
273 } 273 }
274 274
275 clk_enable(phy->pad_clk); 275 clk_prepare_enable(phy->pad_clk);
276 276
277 spin_lock_irqsave(&utmip_pad_lock, flags); 277 spin_lock_irqsave(&utmip_pad_lock, flags);
278 278
@@ -284,7 +284,7 @@ static int utmip_pad_power_off(struct tegra_usb_phy *phy)
284 284
285 spin_unlock_irqrestore(&utmip_pad_lock, flags); 285 spin_unlock_irqrestore(&utmip_pad_lock, flags);
286 286
287 clk_disable(phy->pad_clk); 287 clk_disable_unprepare(phy->pad_clk);
288 288
289 return 0; 289 return 0;
290} 290}
@@ -580,7 +580,7 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy)
580 msleep(5); 580 msleep(5);
581 gpio_direction_output(config->reset_gpio, 1); 581 gpio_direction_output(config->reset_gpio, 1);
582 582
583 clk_enable(phy->clk); 583 clk_prepare_enable(phy->clk);
584 msleep(1); 584 msleep(1);
585 585
586 val = readl(base + USB_SUSP_CTRL); 586 val = readl(base + USB_SUSP_CTRL);
@@ -689,7 +689,7 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
689 err = PTR_ERR(phy->pll_u); 689 err = PTR_ERR(phy->pll_u);
690 goto err0; 690 goto err0;
691 } 691 }
692 clk_enable(phy->pll_u); 692 clk_prepare_enable(phy->pll_u);
693 693
694 parent_rate = clk_get_rate(clk_get_parent(phy->pll_u)); 694 parent_rate = clk_get_rate(clk_get_parent(phy->pll_u));
695 for (i = 0; i < ARRAY_SIZE(tegra_freq_table); i++) { 695 for (i = 0; i < ARRAY_SIZE(tegra_freq_table); i++) {
@@ -735,7 +735,7 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
735 return phy; 735 return phy;
736 736
737err1: 737err1:
738 clk_disable(phy->pll_u); 738 clk_disable_unprepare(phy->pll_u);
739 clk_put(phy->pll_u); 739 clk_put(phy->pll_u);
740err0: 740err0:
741 kfree(phy); 741 kfree(phy);
@@ -810,7 +810,7 @@ void tegra_usb_phy_close(struct tegra_usb_phy *phy)
810 clk_put(phy->clk); 810 clk_put(phy->clk);
811 else 811 else
812 utmip_pad_close(phy); 812 utmip_pad_close(phy);
813 clk_disable(phy->pll_u); 813 clk_disable_unprepare(phy->pll_u);
814 clk_put(phy->pll_u); 814 clk_put(phy->pll_u);
815 kfree(phy); 815 kfree(phy);
816} 816}
diff --git a/arch/arm/mach-u300/Makefile b/arch/arm/mach-u300/Makefile
index fd3a5c382f4..7e47d37aeb0 100644
--- a/arch/arm/mach-u300/Makefile
+++ b/arch/arm/mach-u300/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the linux kernel, U300 machine. 2# Makefile for the linux kernel, U300 machine.
3# 3#
4 4
5obj-y := core.o clock.o timer.o 5obj-y := core.o timer.o
6obj-m := 6obj-m :=
7obj-n := 7obj-n :=
8obj- := 8obj- :=
diff --git a/arch/arm/mach-u300/clock.c b/arch/arm/mach-u300/clock.c
deleted file mode 100644
index 5535dd0a78c..00000000000
--- a/arch/arm/mach-u300/clock.c
+++ /dev/null
@@ -1,1504 +0,0 @@
1/*
2 *
3 * arch/arm/mach-u300/clock.c
4 *
5 *
6 * Copyright (C) 2007-2009 ST-Ericsson AB
7 * License terms: GNU General Public License (GPL) version 2
8 * Define clocks in the app platform.
9 * Author: Linus Walleij <linus.walleij@stericsson.com>
10 * Author: Jonas Aaberg <jonas.aberg@stericsson.com>
11 *
12 */
13#include <linux/module.h>
14#include <linux/kernel.h>
15#include <linux/list.h>
16#include <linux/errno.h>
17#include <linux/err.h>
18#include <linux/string.h>
19#include <linux/clk.h>
20#include <linux/mutex.h>
21#include <linux/spinlock.h>
22#include <linux/debugfs.h>
23#include <linux/device.h>
24#include <linux/init.h>
25#include <linux/timer.h>
26#include <linux/io.h>
27#include <linux/seq_file.h>
28#include <linux/clkdev.h>
29
30#include <mach/hardware.h>
31#include <mach/syscon.h>
32
33#include "clock.h"
34
35/*
36 * TODO:
37 * - move all handling of the CCR register into this file and create
38 * a spinlock for the CCR register
39 * - switch to the clkdevice lookup mechanism that maps clocks to
40 * device ID:s instead when it becomes available in kernel 2.6.29.
41 * - implement rate get/set for all clocks that need it.
42 */
43
44/*
45 * Syscon clock I/O registers lock so clock requests don't collide
46 * NOTE: this is a local lock only used to lock access to clock and
47 * reset registers in syscon.
48 */
49static DEFINE_SPINLOCK(syscon_clkreg_lock);
50static DEFINE_SPINLOCK(syscon_resetreg_lock);
51
52/*
53 * The clocking hierarchy currently looks like this.
54 * NOTE: the idea is NOT to show how the clocks are routed on the chip!
55 * The ideas is to show dependencies, so a clock higher up in the
56 * hierarchy has to be on in order for another clock to be on. Now,
57 * both CPU and DMA can actually be on top of the hierarchy, and that
58 * is not modeled currently. Instead we have the backbone AMBA bus on
59 * top. This bus cannot be programmed in any way but conceptually it
60 * needs to be active for the bridges and devices to transport data.
61 *
62 * Please be aware that a few clocks are hw controlled, which mean that
63 * the hw itself can turn on/off or change the rate of the clock when
64 * needed!
65 *
66 * AMBA bus
67 * |
68 * +- CPU
69 * +- FSMC NANDIF NAND Flash interface
70 * +- SEMI Shared Memory interface
71 * +- ISP Image Signal Processor (U335 only)
72 * +- CDS (U335 only)
73 * +- DMA Direct Memory Access Controller
74 * +- AAIF APP/ACC Inteface (Mobile Scalable Link, MSL)
75 * +- APEX
76 * +- VIDEO_ENC AVE2/3 Video Encoder
77 * +- XGAM Graphics Accelerator Controller
78 * +- AHB
79 * |
80 * +- ahb:0 AHB Bridge
81 * | |
82 * | +- ahb:1 INTCON Interrupt controller
83 * | +- ahb:3 MSPRO Memory Stick Pro controller
84 * | +- ahb:4 EMIF External Memory interface
85 * |
86 * +- fast:0 FAST bridge
87 * | |
88 * | +- fast:1 MMCSD MMC/SD card reader controller
89 * | +- fast:2 I2S0 PCM I2S channel 0 controller
90 * | +- fast:3 I2S1 PCM I2S channel 1 controller
91 * | +- fast:4 I2C0 I2C channel 0 controller
92 * | +- fast:5 I2C1 I2C channel 1 controller
93 * | +- fast:6 SPI SPI controller
94 * | +- fast:7 UART1 Secondary UART (U335 only)
95 * |
96 * +- slow:0 SLOW bridge
97 * |
98 * +- slow:1 SYSCON (not possible to control)
99 * +- slow:2 WDOG Watchdog
100 * +- slow:3 UART0 primary UART
101 * +- slow:4 TIMER_APP Application timer - used in Linux
102 * +- slow:5 KEYPAD controller
103 * +- slow:6 GPIO controller
104 * +- slow:7 RTC controller
105 * +- slow:8 BT Bus Tracer (not used currently)
106 * +- slow:9 EH Event Handler (not used currently)
107 * +- slow:a TIMER_ACC Access style timer (not used currently)
108 * +- slow:b PPM (U335 only, what is that?)
109 */
110
111/*
112 * Reset control functions. We remember if a block has been
113 * taken out of reset and don't remove the reset assertion again
114 * and vice versa. Currently we only remove resets so the
115 * enablement function is defined out.
116 */
117static void syscon_block_reset_enable(struct clk *clk)
118{
119 u16 val;
120 unsigned long iflags;
121
122 /* Not all blocks support resetting */
123 if (!clk->res_reg || !clk->res_mask)
124 return;
125 spin_lock_irqsave(&syscon_resetreg_lock, iflags);
126 val = readw(clk->res_reg);
127 val |= clk->res_mask;
128 writew(val, clk->res_reg);
129 spin_unlock_irqrestore(&syscon_resetreg_lock, iflags);
130 clk->reset = true;
131}
132
133static void syscon_block_reset_disable(struct clk *clk)
134{
135 u16 val;
136 unsigned long iflags;
137
138 /* Not all blocks support resetting */
139 if (!clk->res_reg || !clk->res_mask)
140 return;
141 spin_lock_irqsave(&syscon_resetreg_lock, iflags);
142 val = readw(clk->res_reg);
143 val &= ~clk->res_mask;
144 writew(val, clk->res_reg);
145 spin_unlock_irqrestore(&syscon_resetreg_lock, iflags);
146 clk->reset = false;
147}
148
149int __clk_get(struct clk *clk)
150{
151 u16 val;
152
153 /* The MMC and MSPRO clocks need some special set-up */
154 if (!strcmp(clk->name, "MCLK")) {
155 /* Set default MMC clock divisor to 18.9 MHz */
156 writew(0x0054U, U300_SYSCON_VBASE + U300_SYSCON_MMF0R);
157 val = readw(U300_SYSCON_VBASE + U300_SYSCON_MMCR);
158 /* Disable the MMC feedback clock */
159 val &= ~U300_SYSCON_MMCR_MMC_FB_CLK_SEL_ENABLE;
160 /* Disable MSPRO frequency */
161 val &= ~U300_SYSCON_MMCR_MSPRO_FREQSEL_ENABLE;
162 writew(val, U300_SYSCON_VBASE + U300_SYSCON_MMCR);
163 }
164 if (!strcmp(clk->name, "MSPRO")) {
165 val = readw(U300_SYSCON_VBASE + U300_SYSCON_MMCR);
166 /* Disable the MMC feedback clock */
167 val &= ~U300_SYSCON_MMCR_MMC_FB_CLK_SEL_ENABLE;
168 /* Enable MSPRO frequency */
169 val |= U300_SYSCON_MMCR_MSPRO_FREQSEL_ENABLE;
170 writew(val, U300_SYSCON_VBASE + U300_SYSCON_MMCR);
171 }
172 return 1;
173}
174EXPORT_SYMBOL(__clk_get);
175
176void __clk_put(struct clk *clk)
177{
178}
179EXPORT_SYMBOL(__clk_put);
180
181static void syscon_clk_disable(struct clk *clk)
182{
183 unsigned long iflags;
184
185 /* Don't touch the hardware controlled clocks */
186 if (clk->hw_ctrld)
187 return;
188
189 spin_lock_irqsave(&syscon_clkreg_lock, iflags);
190 writew(clk->clk_val, U300_SYSCON_VBASE + U300_SYSCON_SBCDR);
191 spin_unlock_irqrestore(&syscon_clkreg_lock, iflags);
192}
193
194static void syscon_clk_enable(struct clk *clk)
195{
196 unsigned long iflags;
197
198 /* Don't touch the hardware controlled clocks */
199 if (clk->hw_ctrld)
200 return;
201
202 spin_lock_irqsave(&syscon_clkreg_lock, iflags);
203 writew(clk->clk_val, U300_SYSCON_VBASE + U300_SYSCON_SBCER);
204 spin_unlock_irqrestore(&syscon_clkreg_lock, iflags);
205}
206
207static u16 syscon_clk_get_rate(void)
208{
209 u16 val;
210 unsigned long iflags;
211
212 spin_lock_irqsave(&syscon_clkreg_lock, iflags);
213 val = readw(U300_SYSCON_VBASE + U300_SYSCON_CCR);
214 val &= U300_SYSCON_CCR_CLKING_PERFORMANCE_MASK;
215 spin_unlock_irqrestore(&syscon_clkreg_lock, iflags);
216 return val;
217}
218
219#ifdef CONFIG_MACH_U300_USE_I2S_AS_MASTER
220static void enable_i2s0_vcxo(void)
221{
222 u16 val;
223 unsigned long iflags;
224
225 spin_lock_irqsave(&syscon_clkreg_lock, iflags);
226 /* Set I2S0 to use the VCXO 26 MHz clock */
227 val = readw(U300_SYSCON_VBASE + U300_SYSCON_CCR);
228 val |= U300_SYSCON_CCR_TURN_VCXO_ON;
229 writew(val, U300_SYSCON_VBASE + U300_SYSCON_CCR);
230 val |= U300_SYSCON_CCR_I2S0_USE_VCXO;
231 writew(val, U300_SYSCON_VBASE + U300_SYSCON_CCR);
232 val = readw(U300_SYSCON_VBASE + U300_SYSCON_CEFR);
233 val |= U300_SYSCON_CEFR_I2S0_CLK_EN;
234 writew(val, U300_SYSCON_VBASE + U300_SYSCON_CEFR);
235 spin_unlock_irqrestore(&syscon_clkreg_lock, iflags);
236}
237
238static void enable_i2s1_vcxo(void)
239{
240 u16 val;
241 unsigned long iflags;
242
243 spin_lock_irqsave(&syscon_clkreg_lock, iflags);
244 /* Set I2S1 to use the VCXO 26 MHz clock */
245 val = readw(U300_SYSCON_VBASE + U300_SYSCON_CCR);
246 val |= U300_SYSCON_CCR_TURN_VCXO_ON;
247 writew(val, U300_SYSCON_VBASE + U300_SYSCON_CCR);
248 val |= U300_SYSCON_CCR_I2S1_USE_VCXO;
249 writew(val, U300_SYSCON_VBASE + U300_SYSCON_CCR);
250 val = readw(U300_SYSCON_VBASE + U300_SYSCON_CEFR);
251 val |= U300_SYSCON_CEFR_I2S1_CLK_EN;
252 writew(val, U300_SYSCON_VBASE + U300_SYSCON_CEFR);
253 spin_unlock_irqrestore(&syscon_clkreg_lock, iflags);
254}
255
256static void disable_i2s0_vcxo(void)
257{
258 u16 val;
259 unsigned long iflags;
260
261 spin_lock_irqsave(&syscon_clkreg_lock, iflags);
262 /* Disable I2S0 use of the VCXO 26 MHz clock */
263 val = readw(U300_SYSCON_VBASE + U300_SYSCON_CCR);
264 val &= ~U300_SYSCON_CCR_I2S0_USE_VCXO;
265 writew(val, U300_SYSCON_VBASE + U300_SYSCON_CCR);
266 /* Deactivate VCXO if no one else is using VCXO */
267 if (!(val & U300_SYSCON_CCR_I2S1_USE_VCXO))
268 val &= ~U300_SYSCON_CCR_TURN_VCXO_ON;
269 writew(val, U300_SYSCON_VBASE + U300_SYSCON_CCR);
270 val = readw(U300_SYSCON_VBASE + U300_SYSCON_CEFR);
271 val &= ~U300_SYSCON_CEFR_I2S0_CLK_EN;
272 writew(val, U300_SYSCON_VBASE + U300_SYSCON_CEFR);
273 spin_unlock_irqrestore(&syscon_clkreg_lock, iflags);
274}
275
276static void disable_i2s1_vcxo(void)
277{
278 u16 val;
279 unsigned long iflags;
280
281 spin_lock_irqsave(&syscon_clkreg_lock, iflags);
282 /* Disable I2S1 use of the VCXO 26 MHz clock */
283 val = readw(U300_SYSCON_VBASE + U300_SYSCON_CCR);
284 val &= ~U300_SYSCON_CCR_I2S1_USE_VCXO;
285 writew(val, U300_SYSCON_VBASE + U300_SYSCON_CCR);
286 /* Deactivate VCXO if no one else is using VCXO */
287 if (!(val & U300_SYSCON_CCR_I2S0_USE_VCXO))
288 val &= ~U300_SYSCON_CCR_TURN_VCXO_ON;
289 writew(val, U300_SYSCON_VBASE + U300_SYSCON_CCR);
290 val = readw(U300_SYSCON_VBASE + U300_SYSCON_CEFR);
291 val &= ~U300_SYSCON_CEFR_I2S0_CLK_EN;
292 writew(val, U300_SYSCON_VBASE + U300_SYSCON_CEFR);
293 spin_unlock_irqrestore(&syscon_clkreg_lock, iflags);
294}
295#endif /* CONFIG_MACH_U300_USE_I2S_AS_MASTER */
296
297
298static void syscon_clk_rate_set_mclk(unsigned long rate)
299{
300 u16 val;
301 u32 reg;
302 unsigned long iflags;
303
304 switch (rate) {
305 case 18900000:
306 val = 0x0054;
307 break;
308 case 20800000:
309 val = 0x0044;
310 break;
311 case 23100000:
312 val = 0x0043;
313 break;
314 case 26000000:
315 val = 0x0033;
316 break;
317 case 29700000:
318 val = 0x0032;
319 break;
320 case 34700000:
321 val = 0x0022;
322 break;
323 case 41600000:
324 val = 0x0021;
325 break;
326 case 52000000:
327 val = 0x0011;
328 break;
329 case 104000000:
330 val = 0x0000;
331 break;
332 default:
333 printk(KERN_ERR "Trying to set MCLK to unknown speed! %ld\n",
334 rate);
335 return;
336 }
337
338 spin_lock_irqsave(&syscon_clkreg_lock, iflags);
339 reg = readw(U300_SYSCON_VBASE + U300_SYSCON_MMF0R) &
340 ~U300_SYSCON_MMF0R_MASK;
341 writew(reg | val, U300_SYSCON_VBASE + U300_SYSCON_MMF0R);
342 spin_unlock_irqrestore(&syscon_clkreg_lock, iflags);
343}
344
345void syscon_clk_rate_set_cpuclk(unsigned long rate)
346{
347 u16 val;
348 unsigned long iflags;
349
350 switch (rate) {
351 case 13000000:
352 val = U300_SYSCON_CCR_CLKING_PERFORMANCE_LOW_POWER;
353 break;
354 case 52000000:
355 val = U300_SYSCON_CCR_CLKING_PERFORMANCE_INTERMEDIATE;
356 break;
357 case 104000000:
358 val = U300_SYSCON_CCR_CLKING_PERFORMANCE_HIGH;
359 break;
360 case 208000000:
361 val = U300_SYSCON_CCR_CLKING_PERFORMANCE_BEST;
362 break;
363 default:
364 return;
365 }
366 spin_lock_irqsave(&syscon_clkreg_lock, iflags);
367 val |= readw(U300_SYSCON_VBASE + U300_SYSCON_CCR) &
368 ~U300_SYSCON_CCR_CLKING_PERFORMANCE_MASK ;
369 writew(val, U300_SYSCON_VBASE + U300_SYSCON_CCR);
370 spin_unlock_irqrestore(&syscon_clkreg_lock, iflags);
371}
372EXPORT_SYMBOL(syscon_clk_rate_set_cpuclk);
373
374void clk_disable(struct clk *clk)
375{
376 unsigned long iflags;
377
378 spin_lock_irqsave(&clk->lock, iflags);
379 if (clk->usecount > 0 && !(--clk->usecount)) {
380 /* some blocks lack clocking registers and cannot be disabled */
381 if (clk->disable)
382 clk->disable(clk);
383 if (likely((u32)clk->parent))
384 clk_disable(clk->parent);
385 }
386#ifdef CONFIG_MACH_U300_USE_I2S_AS_MASTER
387 if (unlikely(!strcmp(clk->name, "I2S0")))
388 disable_i2s0_vcxo();
389 if (unlikely(!strcmp(clk->name, "I2S1")))
390 disable_i2s1_vcxo();
391#endif
392 spin_unlock_irqrestore(&clk->lock, iflags);
393}
394EXPORT_SYMBOL(clk_disable);
395
396int clk_enable(struct clk *clk)
397{
398 int ret = 0;
399 unsigned long iflags;
400
401 spin_lock_irqsave(&clk->lock, iflags);
402 if (clk->usecount++ == 0) {
403 if (likely((u32)clk->parent))
404 ret = clk_enable(clk->parent);
405
406 if (unlikely(ret != 0))
407 clk->usecount--;
408 else {
409 /* remove reset line (we never enable reset again) */
410 syscon_block_reset_disable(clk);
411 /* clocks without enable function are always on */
412 if (clk->enable)
413 clk->enable(clk);
414#ifdef CONFIG_MACH_U300_USE_I2S_AS_MASTER
415 if (unlikely(!strcmp(clk->name, "I2S0")))
416 enable_i2s0_vcxo();
417 if (unlikely(!strcmp(clk->name, "I2S1")))
418 enable_i2s1_vcxo();
419#endif
420 }
421 }
422 spin_unlock_irqrestore(&clk->lock, iflags);
423 return ret;
424
425}
426EXPORT_SYMBOL(clk_enable);
427
428/* Returns the clock rate in Hz */
429static unsigned long clk_get_rate_cpuclk(struct clk *clk)
430{
431 u16 val;
432
433 val = syscon_clk_get_rate();
434
435 switch (val) {
436 case U300_SYSCON_CCR_CLKING_PERFORMANCE_LOW_POWER:
437 case U300_SYSCON_CCR_CLKING_PERFORMANCE_LOW:
438 return 13000000;
439 case U300_SYSCON_CCR_CLKING_PERFORMANCE_INTERMEDIATE:
440 return 52000000;
441 case U300_SYSCON_CCR_CLKING_PERFORMANCE_HIGH:
442 return 104000000;
443 case U300_SYSCON_CCR_CLKING_PERFORMANCE_BEST:
444 return 208000000;
445 default:
446 break;
447 }
448 return clk->rate;
449}
450
451static unsigned long clk_get_rate_ahb_clk(struct clk *clk)
452{
453 u16 val;
454
455 val = syscon_clk_get_rate();
456
457 switch (val) {
458 case U300_SYSCON_CCR_CLKING_PERFORMANCE_LOW_POWER:
459 case U300_SYSCON_CCR_CLKING_PERFORMANCE_LOW:
460 return 6500000;
461 case U300_SYSCON_CCR_CLKING_PERFORMANCE_INTERMEDIATE:
462 return 26000000;
463 case U300_SYSCON_CCR_CLKING_PERFORMANCE_HIGH:
464 case U300_SYSCON_CCR_CLKING_PERFORMANCE_BEST:
465 return 52000000;
466 default:
467 break;
468 }
469 return clk->rate;
470
471}
472
473static unsigned long clk_get_rate_emif_clk(struct clk *clk)
474{
475 u16 val;
476
477 val = syscon_clk_get_rate();
478
479 switch (val) {
480 case U300_SYSCON_CCR_CLKING_PERFORMANCE_LOW_POWER:
481 case U300_SYSCON_CCR_CLKING_PERFORMANCE_LOW:
482 return 13000000;
483 case U300_SYSCON_CCR_CLKING_PERFORMANCE_INTERMEDIATE:
484 return 52000000;
485 case U300_SYSCON_CCR_CLKING_PERFORMANCE_HIGH:
486 case U300_SYSCON_CCR_CLKING_PERFORMANCE_BEST:
487 return 104000000;
488 default:
489 break;
490 }
491 return clk->rate;
492
493}
494
495static unsigned long clk_get_rate_xgamclk(struct clk *clk)
496{
497 u16 val;
498
499 val = syscon_clk_get_rate();
500
501 switch (val) {
502 case U300_SYSCON_CCR_CLKING_PERFORMANCE_LOW_POWER:
503 case U300_SYSCON_CCR_CLKING_PERFORMANCE_LOW:
504 return 6500000;
505 case U300_SYSCON_CCR_CLKING_PERFORMANCE_INTERMEDIATE:
506 return 26000000;
507 case U300_SYSCON_CCR_CLKING_PERFORMANCE_HIGH:
508 case U300_SYSCON_CCR_CLKING_PERFORMANCE_BEST:
509 return 52000000;
510 default:
511 break;
512 }
513
514 return clk->rate;
515}
516
517static unsigned long clk_get_rate_mclk(struct clk *clk)
518{
519 u16 val;
520
521 val = syscon_clk_get_rate();
522
523 switch (val) {
524 case U300_SYSCON_CCR_CLKING_PERFORMANCE_LOW_POWER:
525 /*
526 * Here, the 208 MHz PLL gets shut down and the always
527 * on 13 MHz PLL used for RTC etc kicks into use
528 * instead.
529 */
530 return 13000000;
531 case U300_SYSCON_CCR_CLKING_PERFORMANCE_LOW:
532 case U300_SYSCON_CCR_CLKING_PERFORMANCE_INTERMEDIATE:
533 case U300_SYSCON_CCR_CLKING_PERFORMANCE_HIGH:
534 case U300_SYSCON_CCR_CLKING_PERFORMANCE_BEST:
535 {
536 /*
537 * This clock is under program control. The register is
538 * divided in two nybbles, bit 7-4 gives cycles-1 to count
539 * high, bit 3-0 gives cycles-1 to count low. Distribute
540 * these with no more than 1 cycle difference between
541 * low and high and add low and high to get the actual
542 * divisor. The base PLL is 208 MHz. Writing 0x00 will
543 * divide by 1 and 1 so the highest frequency possible
544 * is 104 MHz.
545 *
546 * e.g. 0x54 =>
547 * f = 208 / ((5+1) + (4+1)) = 208 / 11 = 18.9 MHz
548 */
549 u16 val = readw(U300_SYSCON_VBASE + U300_SYSCON_MMF0R) &
550 U300_SYSCON_MMF0R_MASK;
551 switch (val) {
552 case 0x0054:
553 return 18900000;
554 case 0x0044:
555 return 20800000;
556 case 0x0043:
557 return 23100000;
558 case 0x0033:
559 return 26000000;
560 case 0x0032:
561 return 29700000;
562 case 0x0022:
563 return 34700000;
564 case 0x0021:
565 return 41600000;
566 case 0x0011:
567 return 52000000;
568 case 0x0000:
569 return 104000000;
570 default:
571 break;
572 }
573 }
574 default:
575 break;
576 }
577
578 return clk->rate;
579}
580
581static unsigned long clk_get_rate_i2s_i2c_spi(struct clk *clk)
582{
583 u16 val;
584
585 val = syscon_clk_get_rate();
586
587 switch (val) {
588 case U300_SYSCON_CCR_CLKING_PERFORMANCE_LOW_POWER:
589 case U300_SYSCON_CCR_CLKING_PERFORMANCE_LOW:
590 return 13000000;
591 case U300_SYSCON_CCR_CLKING_PERFORMANCE_INTERMEDIATE:
592 case U300_SYSCON_CCR_CLKING_PERFORMANCE_HIGH:
593 case U300_SYSCON_CCR_CLKING_PERFORMANCE_BEST:
594 return 26000000;
595 default:
596 break;
597 }
598
599 return clk->rate;
600}
601
602unsigned long clk_get_rate(struct clk *clk)
603{
604 if (clk->get_rate)
605 return clk->get_rate(clk);
606 else
607 return clk->rate;
608}
609EXPORT_SYMBOL(clk_get_rate);
610
611static unsigned long clk_round_rate_mclk(struct clk *clk, unsigned long rate)
612{
613 if (rate <= 18900000)
614 return 18900000;
615 if (rate <= 20800000)
616 return 20800000;
617 if (rate <= 23100000)
618 return 23100000;
619 if (rate <= 26000000)
620 return 26000000;
621 if (rate <= 29700000)
622 return 29700000;
623 if (rate <= 34700000)
624 return 34700000;
625 if (rate <= 41600000)
626 return 41600000;
627 if (rate <= 52000000)
628 return 52000000;
629 return -EINVAL;
630}
631
632static unsigned long clk_round_rate_cpuclk(struct clk *clk, unsigned long rate)
633{
634 if (rate <= 13000000)
635 return 13000000;
636 if (rate <= 52000000)
637 return 52000000;
638 if (rate <= 104000000)
639 return 104000000;
640 if (rate <= 208000000)
641 return 208000000;
642 return -EINVAL;
643}
644
645/*
646 * This adjusts a requested rate to the closest exact rate
647 * a certain clock can provide. For a fixed clock it's
648 * mostly clk->rate.
649 */
650long clk_round_rate(struct clk *clk, unsigned long rate)
651{
652 /* TODO: get appropriate switches for EMIFCLK, AHBCLK and MCLK */
653 /* Else default to fixed value */
654
655 if (clk->round_rate) {
656 return (long) clk->round_rate(clk, rate);
657 } else {
658 printk(KERN_ERR "clock: Failed to round rate of %s\n",
659 clk->name);
660 }
661 return (long) clk->rate;
662}
663EXPORT_SYMBOL(clk_round_rate);
664
665static int clk_set_rate_mclk(struct clk *clk, unsigned long rate)
666{
667 syscon_clk_rate_set_mclk(clk_round_rate(clk, rate));
668 return 0;
669}
670
671static int clk_set_rate_cpuclk(struct clk *clk, unsigned long rate)
672{
673 syscon_clk_rate_set_cpuclk(clk_round_rate(clk, rate));
674 return 0;
675}
676
677int clk_set_rate(struct clk *clk, unsigned long rate)
678{
679 /* TODO: set for EMIFCLK and AHBCLK */
680 /* Else assume the clock is fixed and fail */
681 if (clk->set_rate) {
682 return clk->set_rate(clk, rate);
683 } else {
684 printk(KERN_ERR "clock: Failed to set %s to %ld hz\n",
685 clk->name, rate);
686 return -EINVAL;
687 }
688}
689EXPORT_SYMBOL(clk_set_rate);
690
691/*
692 * Clock definitions. The clock parents are set to respective
693 * bridge and the clock framework makes sure that the clocks have
694 * parents activated and are brought out of reset when in use.
695 *
696 * Clocks that have hw_ctrld = true are hw controlled, and the hw
697 * can by itself turn these clocks on and off.
698 * So in other words, we don't really have to care about them.
699 */
700
701static struct clk amba_clk = {
702 .name = "AMBA",
703 .rate = 52000000, /* this varies! */
704 .hw_ctrld = true,
705 .reset = false,
706 .lock = __SPIN_LOCK_UNLOCKED(amba_clk.lock),
707};
708
709/*
710 * These blocks are connected directly to the AMBA bus
711 * with no bridge.
712 */
713
714static struct clk cpu_clk = {
715 .name = "CPU",
716 .parent = &amba_clk,
717 .rate = 208000000, /* this varies! */
718 .hw_ctrld = true,
719 .reset = true,
720 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RRR,
721 .res_mask = U300_SYSCON_RRR_CPU_RESET_EN,
722 .set_rate = clk_set_rate_cpuclk,
723 .get_rate = clk_get_rate_cpuclk,
724 .round_rate = clk_round_rate_cpuclk,
725 .lock = __SPIN_LOCK_UNLOCKED(cpu_clk.lock),
726};
727
728static struct clk nandif_clk = {
729 .name = "FSMC",
730 .parent = &amba_clk,
731 .hw_ctrld = false,
732 .reset = true,
733 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RRR,
734 .res_mask = U300_SYSCON_RRR_NANDIF_RESET_EN,
735 .clk_val = U300_SYSCON_SBCER_NANDIF_CLK_EN,
736 .enable = syscon_clk_enable,
737 .disable = syscon_clk_disable,
738 .lock = __SPIN_LOCK_UNLOCKED(nandif_clk.lock),
739};
740
741static struct clk semi_clk = {
742 .name = "SEMI",
743 .parent = &amba_clk,
744 .rate = 0, /* FIXME */
745 /* It is not possible to reset SEMI */
746 .hw_ctrld = false,
747 .reset = false,
748 .clk_val = U300_SYSCON_SBCER_SEMI_CLK_EN,
749 .enable = syscon_clk_enable,
750 .disable = syscon_clk_disable,
751 .lock = __SPIN_LOCK_UNLOCKED(semi_clk.lock),
752};
753
754#ifdef CONFIG_MACH_U300_BS335
755static struct clk isp_clk = {
756 .name = "ISP",
757 .parent = &amba_clk,
758 .rate = 0, /* FIXME */
759 .hw_ctrld = false,
760 .reset = true,
761 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RRR,
762 .res_mask = U300_SYSCON_RRR_ISP_RESET_EN,
763 .clk_val = U300_SYSCON_SBCER_ISP_CLK_EN,
764 .enable = syscon_clk_enable,
765 .disable = syscon_clk_disable,
766 .lock = __SPIN_LOCK_UNLOCKED(isp_clk.lock),
767};
768
769static struct clk cds_clk = {
770 .name = "CDS",
771 .parent = &amba_clk,
772 .rate = 0, /* FIXME */
773 .hw_ctrld = false,
774 .reset = true,
775 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RRR,
776 .res_mask = U300_SYSCON_RRR_CDS_RESET_EN,
777 .clk_val = U300_SYSCON_SBCER_CDS_CLK_EN,
778 .enable = syscon_clk_enable,
779 .disable = syscon_clk_disable,
780 .lock = __SPIN_LOCK_UNLOCKED(cds_clk.lock),
781};
782#endif
783
784static struct clk dma_clk = {
785 .name = "DMA",
786 .parent = &amba_clk,
787 .rate = 52000000, /* this varies! */
788 .hw_ctrld = true,
789 .reset = true,
790 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RRR,
791 .res_mask = U300_SYSCON_RRR_DMAC_RESET_EN,
792 .clk_val = U300_SYSCON_SBCER_DMAC_CLK_EN,
793 .enable = syscon_clk_enable,
794 .disable = syscon_clk_disable,
795 .lock = __SPIN_LOCK_UNLOCKED(dma_clk.lock),
796};
797
798static struct clk aaif_clk = {
799 .name = "AAIF",
800 .parent = &amba_clk,
801 .rate = 52000000, /* this varies! */
802 .hw_ctrld = true,
803 .reset = true,
804 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RRR,
805 .res_mask = U300_SYSCON_RRR_AAIF_RESET_EN,
806 .clk_val = U300_SYSCON_SBCER_AAIF_CLK_EN,
807 .enable = syscon_clk_enable,
808 .disable = syscon_clk_disable,
809 .lock = __SPIN_LOCK_UNLOCKED(aaif_clk.lock),
810};
811
812static struct clk apex_clk = {
813 .name = "APEX",
814 .parent = &amba_clk,
815 .rate = 0, /* FIXME */
816 .hw_ctrld = true,
817 .reset = true,
818 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RRR,
819 .res_mask = U300_SYSCON_RRR_APEX_RESET_EN,
820 .clk_val = U300_SYSCON_SBCER_APEX_CLK_EN,
821 .enable = syscon_clk_enable,
822 .disable = syscon_clk_disable,
823 .lock = __SPIN_LOCK_UNLOCKED(apex_clk.lock),
824};
825
826static struct clk video_enc_clk = {
827 .name = "VIDEO_ENC",
828 .parent = &amba_clk,
829 .rate = 208000000, /* this varies! */
830 .hw_ctrld = false,
831 .reset = false,
832 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RRR,
833 /* This has XGAM in the name but refers to the video encoder */
834 .res_mask = U300_SYSCON_RRR_XGAM_VC_SYNC_RESET_EN,
835 .clk_val = U300_SYSCON_SBCER_VIDEO_ENC_CLK_EN,
836 .enable = syscon_clk_enable,
837 .disable = syscon_clk_disable,
838 .lock = __SPIN_LOCK_UNLOCKED(video_enc_clk.lock),
839};
840
841static struct clk xgam_clk = {
842 .name = "XGAMCLK",
843 .parent = &amba_clk,
844 .rate = 52000000, /* this varies! */
845 .hw_ctrld = false,
846 .reset = true,
847 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RRR,
848 .res_mask = U300_SYSCON_RRR_XGAM_RESET_EN,
849 .clk_val = U300_SYSCON_SBCER_XGAM_CLK_EN,
850 .get_rate = clk_get_rate_xgamclk,
851 .enable = syscon_clk_enable,
852 .disable = syscon_clk_disable,
853 .lock = __SPIN_LOCK_UNLOCKED(xgam_clk.lock),
854};
855
856/* This clock is used to activate the video encoder */
857static struct clk ahb_clk = {
858 .name = "AHB",
859 .parent = &amba_clk,
860 .rate = 52000000, /* this varies! */
861 .hw_ctrld = false, /* This one is set to false due to HW bug */
862 .reset = true,
863 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RRR,
864 .res_mask = U300_SYSCON_RRR_AHB_RESET_EN,
865 .clk_val = U300_SYSCON_SBCER_AHB_CLK_EN,
866 .enable = syscon_clk_enable,
867 .disable = syscon_clk_disable,
868 .get_rate = clk_get_rate_ahb_clk,
869 .lock = __SPIN_LOCK_UNLOCKED(ahb_clk.lock),
870};
871
872
873/*
874 * Clocks on the AHB bridge
875 */
876
877static struct clk ahb_subsys_clk = {
878 .name = "AHB_SUBSYS",
879 .parent = &amba_clk,
880 .rate = 52000000, /* this varies! */
881 .hw_ctrld = true,
882 .reset = false,
883 .clk_val = U300_SYSCON_SBCER_AHB_SUBSYS_BRIDGE_CLK_EN,
884 .enable = syscon_clk_enable,
885 .disable = syscon_clk_disable,
886 .get_rate = clk_get_rate_ahb_clk,
887 .lock = __SPIN_LOCK_UNLOCKED(ahb_subsys_clk.lock),
888};
889
890static struct clk intcon_clk = {
891 .name = "INTCON",
892 .parent = &ahb_subsys_clk,
893 .rate = 52000000, /* this varies! */
894 .hw_ctrld = false,
895 .reset = true,
896 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RRR,
897 .res_mask = U300_SYSCON_RRR_INTCON_RESET_EN,
898 /* INTCON can be reset but not clock-gated */
899 .lock = __SPIN_LOCK_UNLOCKED(intcon_clk.lock),
900
901};
902
903static struct clk mspro_clk = {
904 .name = "MSPRO",
905 .parent = &ahb_subsys_clk,
906 .rate = 0, /* FIXME */
907 .hw_ctrld = false,
908 .reset = true,
909 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RRR,
910 .res_mask = U300_SYSCON_RRR_MSPRO_RESET_EN,
911 .clk_val = U300_SYSCON_SBCER_MSPRO_CLK_EN,
912 .enable = syscon_clk_enable,
913 .disable = syscon_clk_disable,
914 .lock = __SPIN_LOCK_UNLOCKED(mspro_clk.lock),
915};
916
917static struct clk emif_clk = {
918 .name = "EMIF",
919 .parent = &ahb_subsys_clk,
920 .rate = 104000000, /* this varies! */
921 .hw_ctrld = false,
922 .reset = true,
923 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RRR,
924 .res_mask = U300_SYSCON_RRR_EMIF_RESET_EN,
925 .clk_val = U300_SYSCON_SBCER_EMIF_CLK_EN,
926 .enable = syscon_clk_enable,
927 .disable = syscon_clk_disable,
928 .get_rate = clk_get_rate_emif_clk,
929 .lock = __SPIN_LOCK_UNLOCKED(emif_clk.lock),
930};
931
932
933/*
934 * Clocks on the FAST bridge
935 */
936static struct clk fast_clk = {
937 .name = "FAST_BRIDGE",
938 .parent = &amba_clk,
939 .rate = 13000000, /* this varies! */
940 .hw_ctrld = true,
941 .reset = true,
942 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RFR,
943 .res_mask = U300_SYSCON_RFR_FAST_BRIDGE_RESET_ENABLE,
944 .clk_val = U300_SYSCON_SBCER_FAST_BRIDGE_CLK_EN,
945 .enable = syscon_clk_enable,
946 .disable = syscon_clk_disable,
947 .lock = __SPIN_LOCK_UNLOCKED(fast_clk.lock),
948};
949
950/*
951 * The MMCI apb_pclk is hardwired to the same terminal as the
952 * external MCI clock. Thus this will be referenced twice.
953 */
954static struct clk mmcsd_clk = {
955 .name = "MCLK",
956 .parent = &fast_clk,
957 .rate = 18900000, /* this varies! */
958 .hw_ctrld = false,
959 .reset = true,
960 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RFR,
961 .res_mask = U300_SYSCON_RFR_MMC_RESET_ENABLE,
962 .clk_val = U300_SYSCON_SBCER_MMC_CLK_EN,
963 .get_rate = clk_get_rate_mclk,
964 .set_rate = clk_set_rate_mclk,
965 .round_rate = clk_round_rate_mclk,
966 .disable = syscon_clk_disable,
967 .enable = syscon_clk_enable,
968 .lock = __SPIN_LOCK_UNLOCKED(mmcsd_clk.lock),
969};
970
971static struct clk i2s0_clk = {
972 .name = "i2s0",
973 .parent = &fast_clk,
974 .rate = 26000000, /* this varies! */
975 .hw_ctrld = true,
976 .reset = true,
977 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RFR,
978 .res_mask = U300_SYSCON_RFR_PCM_I2S0_RESET_ENABLE,
979 .clk_val = U300_SYSCON_SBCER_I2S0_CORE_CLK_EN,
980 .enable = syscon_clk_enable,
981 .disable = syscon_clk_disable,
982 .get_rate = clk_get_rate_i2s_i2c_spi,
983 .lock = __SPIN_LOCK_UNLOCKED(i2s0_clk.lock),
984};
985
986static struct clk i2s1_clk = {
987 .name = "i2s1",
988 .parent = &fast_clk,
989 .rate = 26000000, /* this varies! */
990 .hw_ctrld = true,
991 .reset = true,
992 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RFR,
993 .res_mask = U300_SYSCON_RFR_PCM_I2S1_RESET_ENABLE,
994 .clk_val = U300_SYSCON_SBCER_I2S1_CORE_CLK_EN,
995 .enable = syscon_clk_enable,
996 .disable = syscon_clk_disable,
997 .get_rate = clk_get_rate_i2s_i2c_spi,
998 .lock = __SPIN_LOCK_UNLOCKED(i2s1_clk.lock),
999};
1000
1001static struct clk i2c0_clk = {
1002 .name = "I2C0",
1003 .parent = &fast_clk,
1004 .rate = 26000000, /* this varies! */
1005 .hw_ctrld = false,
1006 .reset = true,
1007 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RFR,
1008 .res_mask = U300_SYSCON_RFR_I2C0_RESET_ENABLE,
1009 .clk_val = U300_SYSCON_SBCER_I2C0_CLK_EN,
1010 .enable = syscon_clk_enable,
1011 .disable = syscon_clk_disable,
1012 .get_rate = clk_get_rate_i2s_i2c_spi,
1013 .lock = __SPIN_LOCK_UNLOCKED(i2c0_clk.lock),
1014};
1015
1016static struct clk i2c1_clk = {
1017 .name = "I2C1",
1018 .parent = &fast_clk,
1019 .rate = 26000000, /* this varies! */
1020 .hw_ctrld = false,
1021 .reset = true,
1022 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RFR,
1023 .res_mask = U300_SYSCON_RFR_I2C1_RESET_ENABLE,
1024 .clk_val = U300_SYSCON_SBCER_I2C1_CLK_EN,
1025 .enable = syscon_clk_enable,
1026 .disable = syscon_clk_disable,
1027 .get_rate = clk_get_rate_i2s_i2c_spi,
1028 .lock = __SPIN_LOCK_UNLOCKED(i2c1_clk.lock),
1029};
1030
1031/*
1032 * The SPI apb_pclk is hardwired to the same terminal as the
1033 * external SPI clock. Thus this will be referenced twice.
1034 */
1035static struct clk spi_clk = {
1036 .name = "SPI",
1037 .parent = &fast_clk,
1038 .rate = 26000000, /* this varies! */
1039 .hw_ctrld = false,
1040 .reset = true,
1041 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RFR,
1042 .res_mask = U300_SYSCON_RFR_SPI_RESET_ENABLE,
1043 .clk_val = U300_SYSCON_SBCER_SPI_CLK_EN,
1044 .enable = syscon_clk_enable,
1045 .disable = syscon_clk_disable,
1046 .get_rate = clk_get_rate_i2s_i2c_spi,
1047 .lock = __SPIN_LOCK_UNLOCKED(spi_clk.lock),
1048};
1049
1050#ifdef CONFIG_MACH_U300_BS335
1051static struct clk uart1_pclk = {
1052 .name = "UART1_PCLK",
1053 .parent = &fast_clk,
1054 .hw_ctrld = false,
1055 .reset = true,
1056 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RFR,
1057 .res_mask = U300_SYSCON_RFR_UART1_RESET_ENABLE,
1058 .clk_val = U300_SYSCON_SBCER_UART1_CLK_EN,
1059 .enable = syscon_clk_enable,
1060 .disable = syscon_clk_disable,
1061 .lock = __SPIN_LOCK_UNLOCKED(uart1_pclk.lock),
1062};
1063
1064/* This one is hardwired to PLL13 */
1065static struct clk uart1_clk = {
1066 .name = "UART1_CLK",
1067 .rate = 13000000,
1068 .hw_ctrld = true,
1069 .lock = __SPIN_LOCK_UNLOCKED(uart1_clk.lock),
1070};
1071#endif
1072
1073
1074/*
1075 * Clocks on the SLOW bridge
1076 */
1077static struct clk slow_clk = {
1078 .name = "SLOW_BRIDGE",
1079 .parent = &amba_clk,
1080 .rate = 13000000,
1081 .hw_ctrld = true,
1082 .reset = true,
1083 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RSR,
1084 .res_mask = U300_SYSCON_RSR_SLOW_BRIDGE_RESET_EN,
1085 .clk_val = U300_SYSCON_SBCER_SLOW_BRIDGE_CLK_EN,
1086 .enable = syscon_clk_enable,
1087 .disable = syscon_clk_disable,
1088 .lock = __SPIN_LOCK_UNLOCKED(slow_clk.lock),
1089};
1090
1091/* TODO: implement SYSCON clock? */
1092
1093static struct clk wdog_clk = {
1094 .name = "WDOG",
1095 .parent = &slow_clk,
1096 .hw_ctrld = false,
1097 .rate = 32768,
1098 .reset = false,
1099 /* This is always on, cannot be enabled/disabled or reset */
1100 .lock = __SPIN_LOCK_UNLOCKED(wdog_clk.lock),
1101};
1102
1103static struct clk uart0_pclk = {
1104 .name = "UART0_PCLK",
1105 .parent = &slow_clk,
1106 .hw_ctrld = false,
1107 .reset = true,
1108 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RSR,
1109 .res_mask = U300_SYSCON_RSR_UART_RESET_EN,
1110 .clk_val = U300_SYSCON_SBCER_UART_CLK_EN,
1111 .enable = syscon_clk_enable,
1112 .disable = syscon_clk_disable,
1113 .lock = __SPIN_LOCK_UNLOCKED(uart0_pclk.lock),
1114};
1115
1116/* This one is hardwired to PLL13 */
1117static struct clk uart0_clk = {
1118 .name = "UART0_CLK",
1119 .parent = &slow_clk,
1120 .rate = 13000000,
1121 .hw_ctrld = true,
1122 .lock = __SPIN_LOCK_UNLOCKED(uart0_clk.lock),
1123};
1124
1125static struct clk keypad_clk = {
1126 .name = "KEYPAD",
1127 .parent = &slow_clk,
1128 .rate = 32768,
1129 .hw_ctrld = false,
1130 .reset = true,
1131 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RSR,
1132 .res_mask = U300_SYSCON_RSR_KEYPAD_RESET_EN,
1133 .clk_val = U300_SYSCON_SBCER_KEYPAD_CLK_EN,
1134 .enable = syscon_clk_enable,
1135 .disable = syscon_clk_disable,
1136 .lock = __SPIN_LOCK_UNLOCKED(keypad_clk.lock),
1137};
1138
1139static struct clk gpio_clk = {
1140 .name = "GPIO",
1141 .parent = &slow_clk,
1142 .rate = 13000000,
1143 .hw_ctrld = true,
1144 .reset = true,
1145 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RSR,
1146 .res_mask = U300_SYSCON_RSR_GPIO_RESET_EN,
1147 .clk_val = U300_SYSCON_SBCER_GPIO_CLK_EN,
1148 .enable = syscon_clk_enable,
1149 .disable = syscon_clk_disable,
1150 .lock = __SPIN_LOCK_UNLOCKED(gpio_clk.lock),
1151};
1152
1153static struct clk rtc_clk = {
1154 .name = "RTC",
1155 .parent = &slow_clk,
1156 .rate = 32768,
1157 .hw_ctrld = true,
1158 .reset = true,
1159 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RSR,
1160 .res_mask = U300_SYSCON_RSR_RTC_RESET_EN,
1161 /* This clock is always on, cannot be enabled/disabled */
1162 .lock = __SPIN_LOCK_UNLOCKED(rtc_clk.lock),
1163};
1164
1165static struct clk bustr_clk = {
1166 .name = "BUSTR",
1167 .parent = &slow_clk,
1168 .rate = 13000000,
1169 .hw_ctrld = true,
1170 .reset = true,
1171 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RSR,
1172 .res_mask = U300_SYSCON_RSR_BTR_RESET_EN,
1173 .clk_val = U300_SYSCON_SBCER_BTR_CLK_EN,
1174 .enable = syscon_clk_enable,
1175 .disable = syscon_clk_disable,
1176 .lock = __SPIN_LOCK_UNLOCKED(bustr_clk.lock),
1177};
1178
1179static struct clk evhist_clk = {
1180 .name = "EVHIST",
1181 .parent = &slow_clk,
1182 .rate = 13000000,
1183 .hw_ctrld = true,
1184 .reset = true,
1185 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RSR,
1186 .res_mask = U300_SYSCON_RSR_EH_RESET_EN,
1187 .clk_val = U300_SYSCON_SBCER_EH_CLK_EN,
1188 .enable = syscon_clk_enable,
1189 .disable = syscon_clk_disable,
1190 .lock = __SPIN_LOCK_UNLOCKED(evhist_clk.lock),
1191};
1192
1193static struct clk timer_clk = {
1194 .name = "TIMER",
1195 .parent = &slow_clk,
1196 .rate = 13000000,
1197 .hw_ctrld = true,
1198 .reset = true,
1199 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RSR,
1200 .res_mask = U300_SYSCON_RSR_ACC_TMR_RESET_EN,
1201 .clk_val = U300_SYSCON_SBCER_ACC_TMR_CLK_EN,
1202 .enable = syscon_clk_enable,
1203 .disable = syscon_clk_disable,
1204 .lock = __SPIN_LOCK_UNLOCKED(timer_clk.lock),
1205};
1206
1207/*
1208 * There is a binary divider in the hardware that divides
1209 * the 13MHz PLL by 13 down to 1 MHz.
1210 */
1211static struct clk app_timer_clk = {
1212 .name = "TIMER_APP",
1213 .parent = &slow_clk,
1214 .rate = 1000000,
1215 .hw_ctrld = true,
1216 .reset = true,
1217 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RSR,
1218 .res_mask = U300_SYSCON_RSR_APP_TMR_RESET_EN,
1219 .clk_val = U300_SYSCON_SBCER_APP_TMR_CLK_EN,
1220 .enable = syscon_clk_enable,
1221 .disable = syscon_clk_disable,
1222 .lock = __SPIN_LOCK_UNLOCKED(app_timer_clk.lock),
1223};
1224
1225#ifdef CONFIG_MACH_U300_BS335
1226static struct clk ppm_clk = {
1227 .name = "PPM",
1228 .parent = &slow_clk,
1229 .rate = 0, /* FIXME */
1230 .hw_ctrld = true, /* TODO: Look up if it is hw ctrld or not */
1231 .reset = true,
1232 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RSR,
1233 .res_mask = U300_SYSCON_RSR_PPM_RESET_EN,
1234 .clk_val = U300_SYSCON_SBCER_PPM_CLK_EN,
1235 .enable = syscon_clk_enable,
1236 .disable = syscon_clk_disable,
1237 .lock = __SPIN_LOCK_UNLOCKED(ppm_clk.lock),
1238};
1239#endif
1240
1241#define DEF_LOOKUP(devid, clkref) \
1242 { \
1243 .dev_id = devid, \
1244 .clk = clkref, \
1245 }
1246
1247#define DEF_LOOKUP_CON(devid, conid, clkref) \
1248 { \
1249 .dev_id = devid, \
1250 .con_id = conid, \
1251 .clk = clkref, \
1252 }
1253
1254/*
1255 * Here we only define clocks that are meaningful to
1256 * look up through clockdevice.
1257 */
1258static struct clk_lookup lookups[] = {
1259 /* Connected directly to the AMBA bus */
1260 DEF_LOOKUP("amba", &amba_clk),
1261 DEF_LOOKUP("cpu", &cpu_clk),
1262 DEF_LOOKUP("fsmc-nand", &nandif_clk),
1263 DEF_LOOKUP("semi", &semi_clk),
1264#ifdef CONFIG_MACH_U300_BS335
1265 DEF_LOOKUP("isp", &isp_clk),
1266 DEF_LOOKUP("cds", &cds_clk),
1267#endif
1268 DEF_LOOKUP("dma", &dma_clk),
1269 DEF_LOOKUP("msl", &aaif_clk),
1270 DEF_LOOKUP("apex", &apex_clk),
1271 DEF_LOOKUP("video_enc", &video_enc_clk),
1272 DEF_LOOKUP("xgam", &xgam_clk),
1273 DEF_LOOKUP("ahb", &ahb_clk),
1274 /* AHB bridge clocks */
1275 DEF_LOOKUP("ahb_subsys", &ahb_subsys_clk),
1276 DEF_LOOKUP("intcon", &intcon_clk),
1277 DEF_LOOKUP_CON("intcon", "apb_pclk", &intcon_clk),
1278 DEF_LOOKUP("mspro", &mspro_clk),
1279 DEF_LOOKUP("pl172", &emif_clk),
1280 DEF_LOOKUP_CON("pl172", "apb_pclk", &emif_clk),
1281 /* FAST bridge clocks */
1282 DEF_LOOKUP("fast", &fast_clk),
1283 DEF_LOOKUP("mmci", &mmcsd_clk),
1284 DEF_LOOKUP_CON("mmci", "apb_pclk", &mmcsd_clk),
1285 /*
1286 * The .0 and .1 identifiers on these comes from the platform device
1287 * .id field and are assigned when the platform devices are registered.
1288 */
1289 DEF_LOOKUP("i2s.0", &i2s0_clk),
1290 DEF_LOOKUP("i2s.1", &i2s1_clk),
1291 DEF_LOOKUP("stu300.0", &i2c0_clk),
1292 DEF_LOOKUP("stu300.1", &i2c1_clk),
1293 DEF_LOOKUP("pl022", &spi_clk),
1294 DEF_LOOKUP_CON("pl022", "apb_pclk", &spi_clk),
1295#ifdef CONFIG_MACH_U300_BS335
1296 DEF_LOOKUP("uart1", &uart1_clk),
1297 DEF_LOOKUP_CON("uart1", "apb_pclk", &uart1_pclk),
1298#endif
1299 /* SLOW bridge clocks */
1300 DEF_LOOKUP("slow", &slow_clk),
1301 DEF_LOOKUP("coh901327_wdog", &wdog_clk),
1302 DEF_LOOKUP("uart0", &uart0_clk),
1303 DEF_LOOKUP_CON("uart0", "apb_pclk", &uart0_pclk),
1304 DEF_LOOKUP("apptimer", &app_timer_clk),
1305 DEF_LOOKUP("coh901461-keypad", &keypad_clk),
1306 DEF_LOOKUP("u300-gpio", &gpio_clk),
1307 DEF_LOOKUP("rtc-coh901331", &rtc_clk),
1308 DEF_LOOKUP("bustr", &bustr_clk),
1309 DEF_LOOKUP("evhist", &evhist_clk),
1310 DEF_LOOKUP("timer", &timer_clk),
1311#ifdef CONFIG_MACH_U300_BS335
1312 DEF_LOOKUP("ppm", &ppm_clk),
1313#endif
1314};
1315
1316static void __init clk_register(void)
1317{
1318 /* Register the lookups */
1319 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
1320}
1321
1322#if (defined(CONFIG_DEBUG_FS) && defined(CONFIG_U300_DEBUG))
1323/*
1324 * The following makes it possible to view the status (especially
1325 * reference count and reset status) for the clocks in the platform
1326 * by looking into the special file <debugfs>/u300_clocks
1327 */
1328
1329/* A list of all clocks in the platform */
1330static struct clk *clks[] = {
1331 /* Top node clock for the AMBA bus */
1332 &amba_clk,
1333 /* Connected directly to the AMBA bus */
1334 &cpu_clk,
1335 &nandif_clk,
1336 &semi_clk,
1337#ifdef CONFIG_MACH_U300_BS335
1338 &isp_clk,
1339 &cds_clk,
1340#endif
1341 &dma_clk,
1342 &aaif_clk,
1343 &apex_clk,
1344 &video_enc_clk,
1345 &xgam_clk,
1346 &ahb_clk,
1347
1348 /* AHB bridge clocks */
1349 &ahb_subsys_clk,
1350 &intcon_clk,
1351 &mspro_clk,
1352 &emif_clk,
1353 /* FAST bridge clocks */
1354 &fast_clk,
1355 &mmcsd_clk,
1356 &i2s0_clk,
1357 &i2s1_clk,
1358 &i2c0_clk,
1359 &i2c1_clk,
1360 &spi_clk,
1361#ifdef CONFIG_MACH_U300_BS335
1362 &uart1_clk,
1363 &uart1_pclk,
1364#endif
1365 /* SLOW bridge clocks */
1366 &slow_clk,
1367 &wdog_clk,
1368 &uart0_clk,
1369 &uart0_pclk,
1370 &app_timer_clk,
1371 &keypad_clk,
1372 &gpio_clk,
1373 &rtc_clk,
1374 &bustr_clk,
1375 &evhist_clk,
1376 &timer_clk,
1377#ifdef CONFIG_MACH_U300_BS335
1378 &ppm_clk,
1379#endif
1380};
1381
1382static int u300_clocks_show(struct seq_file *s, void *data)
1383{
1384 struct clk *clk;
1385 int i;
1386
1387 seq_printf(s, "CLOCK DEVICE RESET STATE\t" \
1388 "ACTIVE\tUSERS\tHW CTRL FREQ\n");
1389 seq_printf(s, "---------------------------------------------" \
1390 "-----------------------------------------\n");
1391 for (i = 0; i < ARRAY_SIZE(clks); i++) {
1392 clk = clks[i];
1393 if (clk != ERR_PTR(-ENOENT)) {
1394 /* Format clock and device name nicely */
1395 char cdp[33];
1396 int chars;
1397
1398 chars = snprintf(&cdp[0], 17, "%s", clk->name);
1399 while (chars < 16) {
1400 cdp[chars] = ' ';
1401 chars++;
1402 }
1403 chars = snprintf(&cdp[16], 17, "%s", clk->dev ?
1404 dev_name(clk->dev) : "N/A");
1405 while (chars < 16) {
1406 cdp[chars+16] = ' ';
1407 chars++;
1408 }
1409 cdp[32] = '\0';
1410 if (clk->get_rate || clk->rate != 0)
1411 seq_printf(s,
1412 "%s%s\t%s\t%d\t%s\t%lu Hz\n",
1413 &cdp[0],
1414 clk->reset ?
1415 "ASSERTED" : "RELEASED",
1416 clk->usecount ? "ON" : "OFF",
1417 clk->usecount,
1418 clk->hw_ctrld ? "YES" : "NO ",
1419 clk_get_rate(clk));
1420 else
1421 seq_printf(s,
1422 "%s%s\t%s\t%d\t%s\t" \
1423 "(unknown rate)\n",
1424 &cdp[0],
1425 clk->reset ?
1426 "ASSERTED" : "RELEASED",
1427 clk->usecount ? "ON" : "OFF",
1428 clk->usecount,
1429 clk->hw_ctrld ? "YES" : "NO ");
1430 }
1431 }
1432 return 0;
1433}
1434
1435static int u300_clocks_open(struct inode *inode, struct file *file)
1436{
1437 return single_open(file, u300_clocks_show, NULL);
1438}
1439
1440static const struct file_operations u300_clocks_operations = {
1441 .open = u300_clocks_open,
1442 .read = seq_read,
1443 .llseek = seq_lseek,
1444 .release = single_release,
1445};
1446
1447static int __init init_clk_read_debugfs(void)
1448{
1449 /* Expose a simple debugfs interface to view all clocks */
1450 (void) debugfs_create_file("u300_clocks", S_IFREG | S_IRUGO,
1451 NULL, NULL,
1452 &u300_clocks_operations);
1453 return 0;
1454}
1455/*
1456 * This needs to come in after the core_initcall() for the
1457 * overall clocks, because debugfs is not available until
1458 * the subsystems come up.
1459 */
1460module_init(init_clk_read_debugfs);
1461#endif
1462
1463int __init u300_clock_init(void)
1464{
1465 u16 val;
1466
1467 /*
1468 * FIXME: shall all this powermanagement stuff really live here???
1469 */
1470
1471 /* Set system to run at PLL208, max performance, a known state. */
1472 val = readw(U300_SYSCON_VBASE + U300_SYSCON_CCR);
1473 val &= ~U300_SYSCON_CCR_CLKING_PERFORMANCE_MASK;
1474 writew(val, U300_SYSCON_VBASE + U300_SYSCON_CCR);
1475 /* Wait for the PLL208 to lock if not locked in yet */
1476 while (!(readw(U300_SYSCON_VBASE + U300_SYSCON_CSR) &
1477 U300_SYSCON_CSR_PLL208_LOCK_IND));
1478
1479 /* Power management enable */
1480 val = readw(U300_SYSCON_VBASE + U300_SYSCON_PMCR);
1481 val |= U300_SYSCON_PMCR_PWR_MGNT_ENABLE;
1482 writew(val, U300_SYSCON_VBASE + U300_SYSCON_PMCR);
1483
1484 clk_register();
1485
1486 /*
1487 * Some of these may be on when we boot the system so make sure they
1488 * are turned OFF.
1489 */
1490 syscon_block_reset_enable(&timer_clk);
1491 timer_clk.disable(&timer_clk);
1492
1493 /*
1494 * These shall be turned on by default when we boot the system
1495 * so make sure they are ON. (Adding CPU here is a bit too much.)
1496 * These clocks will be claimed by drivers later.
1497 */
1498 syscon_block_reset_disable(&semi_clk);
1499 syscon_block_reset_disable(&emif_clk);
1500 clk_enable(&semi_clk);
1501 clk_enable(&emif_clk);
1502
1503 return 0;
1504}
diff --git a/arch/arm/mach-u300/clock.h b/arch/arm/mach-u300/clock.h
deleted file mode 100644
index 4f50ca8f901..00000000000
--- a/arch/arm/mach-u300/clock.h
+++ /dev/null
@@ -1,50 +0,0 @@
1/*
2 * arch/arm/mach-u300/include/mach/clock.h
3 *
4 * Copyright (C) 2004 - 2005 Nokia corporation
5 * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
6 * Based on clocks.h by Tony Lindgren, Gordon McNutt and RidgeRun, Inc
7 * Copyright (C) 2007-2009 ST-Ericsson AB
8 * Adopted to ST-Ericsson U300 platforms by
9 * Jonas Aaberg <jonas.aberg@stericsson.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 */
16
17#ifndef __MACH_CLOCK_H
18#define __MACH_CLOCK_H
19
20#include <linux/clk.h>
21
22struct clk {
23 struct list_head node;
24 struct module *owner;
25 struct device *dev;
26 const char *name;
27 struct clk *parent;
28
29 spinlock_t lock;
30 unsigned long rate;
31 bool reset;
32 __u16 clk_val;
33 __s8 usecount;
34 void __iomem * res_reg;
35 __u16 res_mask;
36
37 bool hw_ctrld;
38
39 void (*recalc) (struct clk *);
40 int (*set_rate) (struct clk *, unsigned long);
41 unsigned long (*get_rate) (struct clk *);
42 unsigned long (*round_rate) (struct clk *, unsigned long);
43 void (*init) (struct clk *);
44 void (*enable) (struct clk *);
45 void (*disable) (struct clk *);
46};
47
48int u300_clock_init(void);
49
50#endif
diff --git a/arch/arm/mach-u300/core.c b/arch/arm/mach-u300/core.c
index 33339745d43..03acf1883ec 100644
--- a/arch/arm/mach-u300/core.c
+++ b/arch/arm/mach-u300/core.c
@@ -30,6 +30,7 @@
30#include <linux/pinctrl/consumer.h> 30#include <linux/pinctrl/consumer.h>
31#include <linux/pinctrl/pinconf-generic.h> 31#include <linux/pinctrl/pinconf-generic.h>
32#include <linux/dma-mapping.h> 32#include <linux/dma-mapping.h>
33#include <linux/platform_data/clk-u300.h>
33 34
34#include <asm/types.h> 35#include <asm/types.h>
35#include <asm/setup.h> 36#include <asm/setup.h>
@@ -44,7 +45,6 @@
44#include <mach/dma_channels.h> 45#include <mach/dma_channels.h>
45#include <mach/gpio-u300.h> 46#include <mach/gpio-u300.h>
46 47
47#include "clock.h"
48#include "spi.h" 48#include "spi.h"
49#include "i2c.h" 49#include "i2c.h"
50#include "u300-gpio.h" 50#include "u300-gpio.h"
@@ -1658,12 +1658,20 @@ void __init u300_init_irq(void)
1658 int i; 1658 int i;
1659 1659
1660 /* initialize clocking early, we want to clock the INTCON */ 1660 /* initialize clocking early, we want to clock the INTCON */
1661 u300_clock_init(); 1661 u300_clk_init(U300_SYSCON_VBASE);
1662
1663 /* Bootstrap EMIF and SEMI clocks */
1664 clk = clk_get_sys("pl172", NULL);
1665 BUG_ON(IS_ERR(clk));
1666 clk_prepare_enable(clk);
1667 clk = clk_get_sys("semi", NULL);
1668 BUG_ON(IS_ERR(clk));
1669 clk_prepare_enable(clk);
1662 1670
1663 /* Clock the interrupt controller */ 1671 /* Clock the interrupt controller */
1664 clk = clk_get_sys("intcon", NULL); 1672 clk = clk_get_sys("intcon", NULL);
1665 BUG_ON(IS_ERR(clk)); 1673 BUG_ON(IS_ERR(clk));
1666 clk_enable(clk); 1674 clk_prepare_enable(clk);
1667 1675
1668 for (i = 0; i < U300_VIC_IRQS_END; i++) 1676 for (i = 0; i < U300_VIC_IRQS_END; i++)
1669 set_bit(i, (unsigned long *) &mask[0]); 1677 set_bit(i, (unsigned long *) &mask[0]);
@@ -1811,13 +1819,6 @@ void __init u300_init_devices(void)
1811 /* Check what platform we run and print some status information */ 1819 /* Check what platform we run and print some status information */
1812 u300_init_check_chip(); 1820 u300_init_check_chip();
1813 1821
1814 /* Set system to run at PLL208, max performance, a known state. */
1815 val = readw(U300_SYSCON_VBASE + U300_SYSCON_CCR);
1816 val &= ~U300_SYSCON_CCR_CLKING_PERFORMANCE_MASK;
1817 writew(val, U300_SYSCON_VBASE + U300_SYSCON_CCR);
1818 /* Wait for the PLL208 to lock if not locked in yet */
1819 while (!(readw(U300_SYSCON_VBASE + U300_SYSCON_CSR) &
1820 U300_SYSCON_CSR_PLL208_LOCK_IND));
1821 /* Initialize SPI device with some board specifics */ 1822 /* Initialize SPI device with some board specifics */
1822 u300_spi_init(&pl022_device); 1823 u300_spi_init(&pl022_device);
1823 1824
diff --git a/arch/arm/mach-u300/timer.c b/arch/arm/mach-u300/timer.c
index bc1c7897e82..56ac06d38ec 100644
--- a/arch/arm/mach-u300/timer.c
+++ b/arch/arm/mach-u300/timer.c
@@ -354,7 +354,7 @@ static void __init u300_timer_init(void)
354 /* Clock the interrupt controller */ 354 /* Clock the interrupt controller */
355 clk = clk_get_sys("apptimer", NULL); 355 clk = clk_get_sys("apptimer", NULL);
356 BUG_ON(IS_ERR(clk)); 356 BUG_ON(IS_ERR(clk));
357 clk_enable(clk); 357 clk_prepare_enable(clk);
358 rate = clk_get_rate(clk); 358 rate = clk_get_rate(clk);
359 359
360 setup_sched_clock(u300_read_sched_clock, 32, rate); 360 setup_sched_clock(u300_read_sched_clock, 32, rate);
diff --git a/arch/arm/mach-ux500/board-mop500-msp.c b/arch/arm/mach-ux500/board-mop500-msp.c
index 99604803874..df15646036a 100644
--- a/arch/arm/mach-ux500/board-mop500-msp.c
+++ b/arch/arm/mach-ux500/board-mop500-msp.c
@@ -191,9 +191,9 @@ static struct platform_device *db8500_add_msp_i2s(struct device *parent,
191 return pdev; 191 return pdev;
192} 192}
193 193
194/* Platform device for ASoC U8500 machine */ 194/* Platform device for ASoC MOP500 machine */
195static struct platform_device snd_soc_u8500 = { 195static struct platform_device snd_soc_mop500 = {
196 .name = "snd-soc-u8500", 196 .name = "snd-soc-mop500",
197 .id = 0, 197 .id = 0,
198 .dev = { 198 .dev = {
199 .platform_data = NULL, 199 .platform_data = NULL,
@@ -227,8 +227,8 @@ int mop500_msp_init(struct device *parent)
227{ 227{
228 struct platform_device *msp1; 228 struct platform_device *msp1;
229 229
230 pr_info("%s: Register platform-device 'snd-soc-u8500'.\n", __func__); 230 pr_info("%s: Register platform-device 'snd-soc-mop500'.\n", __func__);
231 platform_device_register(&snd_soc_u8500); 231 platform_device_register(&snd_soc_mop500);
232 232
233 pr_info("Initialize MSP I2S-devices.\n"); 233 pr_info("Initialize MSP I2S-devices.\n");
234 db8500_add_msp_i2s(parent, 0, U8500_MSP0_BASE, IRQ_DB8500_MSP0, 234 db8500_add_msp_i2s(parent, 0, U8500_MSP0_BASE, IRQ_DB8500_MSP0,
diff --git a/arch/arm/mach-ux500/board-mop500-sdi.c b/arch/arm/mach-ux500/board-mop500-sdi.c
index 920251cf834..18ff781cfbe 100644
--- a/arch/arm/mach-ux500/board-mop500-sdi.c
+++ b/arch/arm/mach-ux500/board-mop500-sdi.c
@@ -80,7 +80,7 @@ static struct stedma40_chan_cfg mop500_sdi0_dma_cfg_tx = {
80}; 80};
81#endif 81#endif
82 82
83static struct mmci_platform_data mop500_sdi0_data = { 83struct mmci_platform_data mop500_sdi0_data = {
84 .ios_handler = mop500_sdi0_ios_handler, 84 .ios_handler = mop500_sdi0_ios_handler,
85 .ocr_mask = MMC_VDD_29_30, 85 .ocr_mask = MMC_VDD_29_30,
86 .f_max = 50000000, 86 .f_max = 50000000,
@@ -227,7 +227,7 @@ static struct stedma40_chan_cfg mop500_sdi4_dma_cfg_tx = {
227}; 227};
228#endif 228#endif
229 229
230static struct mmci_platform_data mop500_sdi4_data = { 230struct mmci_platform_data mop500_sdi4_data = {
231 .ocr_mask = MMC_VDD_29_30, 231 .ocr_mask = MMC_VDD_29_30,
232 .f_max = 50000000, 232 .f_max = 50000000,
233 .capabilities = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA | 233 .capabilities = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA |
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c
index 4fd93f5c49e..a534d8880de 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -15,6 +15,7 @@
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/i2c.h> 17#include <linux/i2c.h>
18#include <linux/platform_data/i2c-nomadik.h>
18#include <linux/gpio.h> 19#include <linux/gpio.h>
19#include <linux/amba/bus.h> 20#include <linux/amba/bus.h>
20#include <linux/amba/pl022.h> 21#include <linux/amba/pl022.h>
@@ -25,6 +26,7 @@
25#include <linux/mfd/tc3589x.h> 26#include <linux/mfd/tc3589x.h>
26#include <linux/mfd/tps6105x.h> 27#include <linux/mfd/tps6105x.h>
27#include <linux/mfd/abx500/ab8500-gpio.h> 28#include <linux/mfd/abx500/ab8500-gpio.h>
29#include <linux/mfd/abx500/ab8500-codec.h>
28#include <linux/leds-lp5521.h> 30#include <linux/leds-lp5521.h>
29#include <linux/input.h> 31#include <linux/input.h>
30#include <linux/smsc911x.h> 32#include <linux/smsc911x.h>
@@ -39,7 +41,6 @@
39#include <asm/mach/arch.h> 41#include <asm/mach/arch.h>
40#include <asm/hardware/gic.h> 42#include <asm/hardware/gic.h>
41 43
42#include <plat/i2c.h>
43#include <plat/ste_dma40.h> 44#include <plat/ste_dma40.h>
44#include <plat/gpio-nomadik.h> 45#include <plat/gpio-nomadik.h>
45 46
@@ -58,7 +59,7 @@
58static struct gpio_led snowball_led_array[] = { 59static struct gpio_led snowball_led_array[] = {
59 { 60 {
60 .name = "user_led", 61 .name = "user_led",
61 .default_trigger = "none", 62 .default_trigger = "heartbeat",
62 .gpio = 142, 63 .gpio = 142,
63 }, 64 },
64}; 65};
@@ -97,6 +98,18 @@ static struct ab8500_gpio_platform_data ab8500_gpio_pdata = {
97 0x7A, 0x00, 0x00}, 98 0x7A, 0x00, 0x00},
98}; 99};
99 100
101/* ab8500-codec */
102static struct ab8500_codec_platform_data ab8500_codec_pdata = {
103 .amics = {
104 .mic1_type = AMIC_TYPE_DIFFERENTIAL,
105 .mic2_type = AMIC_TYPE_DIFFERENTIAL,
106 .mic1a_micbias = AMIC_MICBIAS_VAMIC1,
107 .mic1b_micbias = AMIC_MICBIAS_VAMIC1,
108 .mic2_micbias = AMIC_MICBIAS_VAMIC2
109 },
110 .ear_cmv = EAR_CMV_0_95V
111};
112
100static struct gpio_keys_button snowball_key_array[] = { 113static struct gpio_keys_button snowball_key_array[] = {
101 { 114 {
102 .gpio = 32, 115 .gpio = 32,
@@ -195,24 +208,7 @@ static struct ab8500_platform_data ab8500_platdata = {
195 .regulator = ab8500_regulators, 208 .regulator = ab8500_regulators,
196 .num_regulator = ARRAY_SIZE(ab8500_regulators), 209 .num_regulator = ARRAY_SIZE(ab8500_regulators),
197 .gpio = &ab8500_gpio_pdata, 210 .gpio = &ab8500_gpio_pdata,
198}; 211 .codec = &ab8500_codec_pdata,
199
200static struct resource ab8500_resources[] = {
201 [0] = {
202 .start = IRQ_DB8500_AB8500,
203 .end = IRQ_DB8500_AB8500,
204 .flags = IORESOURCE_IRQ
205 }
206};
207
208struct platform_device ab8500_device = {
209 .name = "ab8500-core",
210 .id = 0,
211 .dev = {
212 .platform_data = &ab8500_platdata,
213 },
214 .num_resources = 1,
215 .resource = ab8500_resources,
216}; 212};
217 213
218/* 214/*
@@ -331,43 +327,12 @@ static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
331 }, 327 },
332}; 328};
333 329
334#define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, t_out, _sm) \
335static struct nmk_i2c_controller u8500_i2c##id##_data = { \
336 /* \
337 * slave data setup time, which is \
338 * 250 ns,100ns,10ns which is 14,6,2 \
339 * respectively for a 48 Mhz \
340 * i2c clock \
341 */ \
342 .slsu = _slsu, \
343 /* Tx FIFO threshold */ \
344 .tft = _tft, \
345 /* Rx FIFO threshold */ \
346 .rft = _rft, \
347 /* std. mode operation */ \
348 .clk_freq = clk, \
349 /* Slave response timeout(ms) */\
350 .timeout = t_out, \
351 .sm = _sm, \
352}
353
354/*
355 * The board uses 4 i2c controllers, initialize all of
356 * them with slave data setup time of 250 ns,
357 * Tx & Rx FIFO threshold values as 8 and standard
358 * mode of operation
359 */
360U8500_I2C_CONTROLLER(0, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
361U8500_I2C_CONTROLLER(1, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
362U8500_I2C_CONTROLLER(2, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
363U8500_I2C_CONTROLLER(3, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
364
365static void __init mop500_i2c_init(struct device *parent) 330static void __init mop500_i2c_init(struct device *parent)
366{ 331{
367 db8500_add_i2c0(parent, &u8500_i2c0_data); 332 db8500_add_i2c0(parent, NULL);
368 db8500_add_i2c1(parent, &u8500_i2c1_data); 333 db8500_add_i2c1(parent, NULL);
369 db8500_add_i2c2(parent, &u8500_i2c2_data); 334 db8500_add_i2c2(parent, NULL);
370 db8500_add_i2c3(parent, &u8500_i2c3_data); 335 db8500_add_i2c3(parent, NULL);
371} 336}
372 337
373static struct gpio_keys_button mop500_gpio_keys[] = { 338static struct gpio_keys_button mop500_gpio_keys[] = {
@@ -460,7 +425,6 @@ static struct hash_platform_data u8500_hash1_platform_data = {
460/* add any platform devices here - TODO */ 425/* add any platform devices here - TODO */
461static struct platform_device *mop500_platform_devs[] __initdata = { 426static struct platform_device *mop500_platform_devs[] __initdata = {
462 &mop500_gpio_keys_device, 427 &mop500_gpio_keys_device,
463 &ab8500_device,
464}; 428};
465 429
466#ifdef CONFIG_STE_DMA40 430#ifdef CONFIG_STE_DMA40
@@ -622,7 +586,6 @@ static struct platform_device *snowball_platform_devs[] __initdata = {
622 &snowball_led_dev, 586 &snowball_led_dev,
623 &snowball_key_dev, 587 &snowball_key_dev,
624 &snowball_sbnet_dev, 588 &snowball_sbnet_dev,
625 &ab8500_device,
626}; 589};
627 590
628static void __init mop500_init_machine(void) 591static void __init mop500_init_machine(void)
@@ -634,9 +597,8 @@ static void __init mop500_init_machine(void)
634 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR; 597 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
635 598
636 mop500_pinmaps_init(); 599 mop500_pinmaps_init();
637 parent = u8500_init_devices(); 600 parent = u8500_init_devices(&ab8500_platdata);
638 601
639 /* FIXME: parent of ab8500 should be prcmu */
640 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++) 602 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
641 mop500_platform_devs[i]->dev.parent = parent; 603 mop500_platform_devs[i]->dev.parent = parent;
642 604
@@ -669,7 +631,7 @@ static void __init snowball_init_machine(void)
669 int i; 631 int i;
670 632
671 snowball_pinmaps_init(); 633 snowball_pinmaps_init();
672 parent = u8500_init_devices(); 634 parent = u8500_init_devices(&ab8500_platdata);
673 635
674 for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++) 636 for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
675 snowball_platform_devs[i]->dev.parent = parent; 637 snowball_platform_devs[i]->dev.parent = parent;
@@ -701,7 +663,7 @@ static void __init hrefv60_init_machine(void)
701 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO; 663 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
702 664
703 hrefv60_pinmaps_init(); 665 hrefv60_pinmaps_init();
704 parent = u8500_init_devices(); 666 parent = u8500_init_devices(&ab8500_platdata);
705 667
706 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++) 668 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
707 mop500_platform_devs[i]->dev.parent = parent; 669 mop500_platform_devs[i]->dev.parent = parent;
@@ -776,6 +738,8 @@ struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = {
776 OF_DEV_AUXDATA("arm,pl011", 0x80007000, "uart2", &uart2_plat), 738 OF_DEV_AUXDATA("arm,pl011", 0x80007000, "uart2", &uart2_plat),
777 /* Requires DMA bindings. */ 739 /* Requires DMA bindings. */
778 OF_DEV_AUXDATA("arm,pl022", 0x80002000, "ssp0", &ssp0_plat), 740 OF_DEV_AUXDATA("arm,pl022", 0x80002000, "ssp0", &ssp0_plat),
741 OF_DEV_AUXDATA("arm,pl18x", 0x80126000, "sdi0", &mop500_sdi0_data),
742 OF_DEV_AUXDATA("arm,pl18x", 0x80114000, "sdi4", &mop500_sdi4_data),
779 /* Requires clock name bindings. */ 743 /* Requires clock name bindings. */
780 OF_DEV_AUXDATA("st,nomadik-gpio", 0x8012e000, "gpio.0", NULL), 744 OF_DEV_AUXDATA("st,nomadik-gpio", 0x8012e000, "gpio.0", NULL),
781 OF_DEV_AUXDATA("st,nomadik-gpio", 0x8012e080, "gpio.1", NULL), 745 OF_DEV_AUXDATA("st,nomadik-gpio", 0x8012e080, "gpio.1", NULL),
@@ -786,6 +750,11 @@ struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = {
786 OF_DEV_AUXDATA("st,nomadik-gpio", 0x8011e000, "gpio.6", NULL), 750 OF_DEV_AUXDATA("st,nomadik-gpio", 0x8011e000, "gpio.6", NULL),
787 OF_DEV_AUXDATA("st,nomadik-gpio", 0x8011e080, "gpio.7", NULL), 751 OF_DEV_AUXDATA("st,nomadik-gpio", 0x8011e080, "gpio.7", NULL),
788 OF_DEV_AUXDATA("st,nomadik-gpio", 0xa03fe000, "gpio.8", NULL), 752 OF_DEV_AUXDATA("st,nomadik-gpio", 0xa03fe000, "gpio.8", NULL),
753 OF_DEV_AUXDATA("st,nomadik-i2c", 0x80004000, "nmk-i2c.0", NULL),
754 OF_DEV_AUXDATA("st,nomadik-i2c", 0x80122000, "nmk-i2c.1", NULL),
755 OF_DEV_AUXDATA("st,nomadik-i2c", 0x80128000, "nmk-i2c.2", NULL),
756 OF_DEV_AUXDATA("st,nomadik-i2c", 0x80110000, "nmk-i2c.3", NULL),
757 OF_DEV_AUXDATA("st,nomadik-i2c", 0x8012a000, "nmk-i2c.4", NULL),
789 /* Requires device name bindings. */ 758 /* Requires device name bindings. */
790 OF_DEV_AUXDATA("stericsson,nmk_pinctrl", 0, "pinctrl-db8500", NULL), 759 OF_DEV_AUXDATA("stericsson,nmk_pinctrl", 0, "pinctrl-db8500", NULL),
791 {}, 760 {},
@@ -795,9 +764,6 @@ static const struct of_device_id u8500_local_bus_nodes[] = {
795 /* only create devices below soc node */ 764 /* only create devices below soc node */
796 { .compatible = "stericsson,db8500", }, 765 { .compatible = "stericsson,db8500", },
797 { .compatible = "stericsson,db8500-prcmu", }, 766 { .compatible = "stericsson,db8500-prcmu", },
798 { .compatible = "stericsson,db8500-prcmu-regulator", },
799 { .compatible = "stericsson,ab8500", },
800 { .compatible = "stericsson,ab8500-regulator", },
801 { .compatible = "simple-bus"}, 767 { .compatible = "simple-bus"},
802 { }, 768 { },
803}; 769};
@@ -820,8 +786,6 @@ static void __init u8500_init_machine(void)
820 786
821 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++) 787 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
822 mop500_platform_devs[i]->dev.parent = parent; 788 mop500_platform_devs[i]->dev.parent = parent;
823 for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
824 snowball_platform_devs[i]->dev.parent = parent;
825 789
826 /* automatically probe child nodes of db8500 device */ 790 /* automatically probe child nodes of db8500 device */
827 of_platform_populate(NULL, u8500_local_bus_nodes, u8500_auxdata_lookup, parent); 791 of_platform_populate(NULL, u8500_local_bus_nodes, u8500_auxdata_lookup, parent);
@@ -833,6 +797,7 @@ static void __init u8500_init_machine(void)
833 ARRAY_SIZE(mop500_platform_devs)); 797 ARRAY_SIZE(mop500_platform_devs));
834 798
835 mop500_sdi_init(parent); 799 mop500_sdi_init(parent);
800 mop500_msp_init(parent);
836 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices); 801 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
837 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs); 802 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
838 i2c_register_board_info(2, mop500_i2c2_devices, 803 i2c_register_board_info(2, mop500_i2c2_devices,
@@ -841,17 +806,7 @@ static void __init u8500_init_machine(void)
841 mop500_uib_init(); 806 mop500_uib_init();
842 807
843 } else if (of_machine_is_compatible("calaosystems,snowball-a9500")) { 808 } else if (of_machine_is_compatible("calaosystems,snowball-a9500")) {
844 /* 809 mop500_msp_init(parent);
845 * Devices to be DT:ed:
846 * snowball_led_dev = todo
847 * snowball_key_dev = todo
848 * snowball_sbnet_dev = done
849 * ab8500_device = done
850 */
851 platform_add_devices(snowball_of_platform_devs,
852 ARRAY_SIZE(snowball_of_platform_devs));
853
854 snowball_sdi_init(parent);
855 } else if (of_machine_is_compatible("st-ericsson,hrefv60+")) { 810 } else if (of_machine_is_compatible("st-ericsson,hrefv60+")) {
856 /* 811 /*
857 * The HREFv60 board removed a GPIO expander and routed 812 * The HREFv60 board removed a GPIO expander and routed
@@ -863,6 +818,7 @@ static void __init u8500_init_machine(void)
863 ARRAY_SIZE(mop500_platform_devs)); 818 ARRAY_SIZE(mop500_platform_devs));
864 819
865 hrefv60_sdi_init(parent); 820 hrefv60_sdi_init(parent);
821 mop500_msp_init(parent);
866 822
867 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices); 823 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
868 i2c0_devs -= NUM_PRE_V60_I2C0_DEVICES; 824 i2c0_devs -= NUM_PRE_V60_I2C0_DEVICES;
@@ -873,7 +829,6 @@ static void __init u8500_init_machine(void)
873 829
874 mop500_uib_init(); 830 mop500_uib_init();
875 } 831 }
876 mop500_i2c_init(parent);
877 832
878 /* This board has full regulator constraints */ 833 /* This board has full regulator constraints */
879 regulator_has_full_constraints(); 834 regulator_has_full_constraints();
diff --git a/arch/arm/mach-ux500/board-mop500.h b/arch/arm/mach-ux500/board-mop500.h
index 2f87b25a908..b5bfc1a78b1 100644
--- a/arch/arm/mach-ux500/board-mop500.h
+++ b/arch/arm/mach-ux500/board-mop500.h
@@ -9,6 +9,7 @@
9 9
10/* For NOMADIK_NR_GPIO */ 10/* For NOMADIK_NR_GPIO */
11#include <mach/irqs.h> 11#include <mach/irqs.h>
12#include <linux/amba/mmci.h>
12 13
13/* Snowball specific GPIO assignments, this board has no GPIO expander */ 14/* Snowball specific GPIO assignments, this board has no GPIO expander */
14#define SNOWBALL_ACCEL_INT1_GPIO 163 15#define SNOWBALL_ACCEL_INT1_GPIO 163
@@ -78,6 +79,8 @@
78 79
79struct device; 80struct device;
80struct i2c_board_info; 81struct i2c_board_info;
82extern struct mmci_platform_data mop500_sdi0_data;
83extern struct mmci_platform_data mop500_sdi4_data;
81 84
82extern void mop500_sdi_init(struct device *parent); 85extern void mop500_sdi_init(struct device *parent);
83extern void snowball_sdi_init(struct device *parent); 86extern void snowball_sdi_init(struct device *parent);
diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index 33275eb4c68..db3c52d56ca 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -16,6 +16,7 @@
16#include <linux/irq.h> 16#include <linux/irq.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/mfd/abx500/ab8500.h>
19 20
20#include <asm/mach/map.h> 21#include <asm/mach/map.h>
21#include <asm/pmu.h> 22#include <asm/pmu.h>
@@ -115,7 +116,7 @@ static irqreturn_t db8500_pmu_handler(int irq, void *dev, irq_handler_t handler)
115 return ret; 116 return ret;
116} 117}
117 118
118static struct arm_pmu_platdata db8500_pmu_platdata = { 119struct arm_pmu_platdata db8500_pmu_platdata = {
119 .handle_irq = db8500_pmu_handler, 120 .handle_irq = db8500_pmu_handler,
120}; 121};
121 122
@@ -139,7 +140,6 @@ static struct platform_device *platform_devs[] __initdata = {
139 140
140static struct platform_device *of_platform_devs[] __initdata = { 141static struct platform_device *of_platform_devs[] __initdata = {
141 &u8500_dma40_device, 142 &u8500_dma40_device,
142 &db8500_pmu_device,
143}; 143};
144 144
145static resource_size_t __initdata db8500_gpio_base[] = { 145static resource_size_t __initdata db8500_gpio_base[] = {
@@ -207,7 +207,7 @@ static struct device * __init db8500_soc_device_init(void)
207/* 207/*
208 * This function is called from the board init 208 * This function is called from the board init
209 */ 209 */
210struct device * __init u8500_init_devices(void) 210struct device * __init u8500_init_devices(struct ab8500_platform_data *ab8500)
211{ 211{
212 struct device *parent; 212 struct device *parent;
213 int i; 213 int i;
@@ -224,6 +224,8 @@ struct device * __init u8500_init_devices(void)
224 for (i = 0; i < ARRAY_SIZE(platform_devs); i++) 224 for (i = 0; i < ARRAY_SIZE(platform_devs); i++)
225 platform_devs[i]->dev.parent = parent; 225 platform_devs[i]->dev.parent = parent;
226 226
227 db8500_prcmu_device.dev.platform_data = ab8500;
228
227 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); 229 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
228 230
229 return parent; 231 return parent;
@@ -237,7 +239,6 @@ struct device * __init u8500_of_init_devices(void)
237 239
238 parent = db8500_soc_device_init(); 240 parent = db8500_soc_device_init();
239 241
240 db8500_add_rtc(parent);
241 db8500_add_usb(parent, usb_db8500_rx_dma_cfg, usb_db8500_tx_dma_cfg); 242 db8500_add_usb(parent, usb_db8500_rx_dma_cfg, usb_db8500_tx_dma_cfg);
242 243
243 platform_device_register_data(parent, 244 platform_device_register_data(parent,
@@ -249,7 +250,7 @@ struct device * __init u8500_of_init_devices(void)
249 /* 250 /*
250 * Devices to be DT:ed: 251 * Devices to be DT:ed:
251 * u8500_dma40_device = todo 252 * u8500_dma40_device = todo
252 * db8500_pmu_device = todo 253 * db8500_pmu_device = done
253 * db8500_prcmu_device = done 254 * db8500_prcmu_device = done
254 */ 255 */
255 platform_add_devices(of_platform_devs, ARRAY_SIZE(of_platform_devs)); 256 platform_add_devices(of_platform_devs, ARRAY_SIZE(of_platform_devs));
diff --git a/arch/arm/mach-ux500/devices-common.h b/arch/arm/mach-ux500/devices-common.h
index 6e470656026..ecdd8386cff 100644
--- a/arch/arm/mach-ux500/devices-common.h
+++ b/arch/arm/mach-ux500/devices-common.h
@@ -12,7 +12,7 @@
12#include <linux/dma-mapping.h> 12#include <linux/dma-mapping.h>
13#include <linux/sys_soc.h> 13#include <linux/sys_soc.h>
14#include <linux/amba/bus.h> 14#include <linux/amba/bus.h>
15#include <plat/i2c.h> 15#include <linux/platform_data/i2c-nomadik.h>
16#include <mach/crypto-ux500.h> 16#include <mach/crypto-ux500.h>
17 17
18struct spi_master_cntlr; 18struct spi_master_cntlr;
@@ -56,27 +56,15 @@ dbx500_add_uart(struct device *parent, const char *name, resource_size_t base,
56 56
57struct nmk_i2c_controller; 57struct nmk_i2c_controller;
58 58
59static inline struct platform_device * 59static inline struct amba_device *
60dbx500_add_i2c(struct device *parent, int id, resource_size_t base, int irq, 60dbx500_add_i2c(struct device *parent, int id, resource_size_t base, int irq,
61 struct nmk_i2c_controller *data) 61 struct nmk_i2c_controller *data)
62{ 62{
63 struct resource res[] = { 63 /* Conjure a name similar to what the platform device used to have */
64 DEFINE_RES_MEM(base, SZ_4K), 64 char name[16];
65 DEFINE_RES_IRQ(irq),
66 };
67 65
68 struct platform_device_info pdevinfo = { 66 snprintf(name, sizeof(name), "nmk-i2c.%d", id);
69 .parent = parent, 67 return amba_apb_device_add(parent, name, base, SZ_4K, irq, 0, data, 0);
70 .name = "nmk-i2c",
71 .id = id,
72 .res = res,
73 .num_res = ARRAY_SIZE(res),
74 .data = data,
75 .size_data = sizeof(*data),
76 .dma_mask = DMA_BIT_MASK(32),
77 };
78
79 return platform_device_register_full(&pdevinfo);
80} 68}
81 69
82static inline struct amba_device * 70static inline struct amba_device *
diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
index 8b7ed82a286..7914e5eaa9c 100644
--- a/arch/arm/mach-ux500/include/mach/setup.h
+++ b/arch/arm/mach-ux500/include/mach/setup.h
@@ -13,11 +13,12 @@
13 13
14#include <asm/mach/time.h> 14#include <asm/mach/time.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/mfd/abx500/ab8500.h>
16 17
17void __init ux500_map_io(void); 18void __init ux500_map_io(void);
18extern void __init u8500_map_io(void); 19extern void __init u8500_map_io(void);
19 20
20extern struct device * __init u8500_init_devices(void); 21extern struct device * __init u8500_init_devices(struct ab8500_platform_data *ab8500);
21 22
22extern void __init ux500_init_irq(void); 23extern void __init ux500_init_irq(void);
23extern void __init ux500_init_late(void); 24extern void __init ux500_init_late(void);
diff --git a/arch/arm/mach-vexpress/Kconfig b/arch/arm/mach-vexpress/Kconfig
index cf8730d35e7..fc3730f0165 100644
--- a/arch/arm/mach-vexpress/Kconfig
+++ b/arch/arm/mach-vexpress/Kconfig
@@ -2,7 +2,8 @@ menu "Versatile Express platform type"
2 depends on ARCH_VEXPRESS 2 depends on ARCH_VEXPRESS
3 3
4config ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA 4config ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA
5 bool 5 bool "Enable A5 and A9 only errata work-arounds"
6 default y
6 select ARM_ERRATA_720789 7 select ARM_ERRATA_720789
7 select ARM_ERRATA_751472 8 select ARM_ERRATA_751472
8 select PL310_ERRATA_753970 if CACHE_PL310 9 select PL310_ERRATA_753970 if CACHE_PL310
@@ -14,7 +15,6 @@ config ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA
14 15
15config ARCH_VEXPRESS_CA9X4 16config ARCH_VEXPRESS_CA9X4
16 bool "Versatile Express Cortex-A9x4 tile" 17 bool "Versatile Express Cortex-A9x4 tile"
17 select ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA
18 select ARM_GIC 18 select ARM_GIC
19 select CPU_V7 19 select CPU_V7
20 select HAVE_SMP 20 select HAVE_SMP
@@ -22,7 +22,6 @@ config ARCH_VEXPRESS_CA9X4
22 22
23config ARCH_VEXPRESS_DT 23config ARCH_VEXPRESS_DT
24 bool "Device Tree support for Versatile Express platforms" 24 bool "Device Tree support for Versatile Express platforms"
25 select ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA
26 select ARM_GIC 25 select ARM_GIC
27 select ARM_PATCH_PHYS_VIRT 26 select ARM_PATCH_PHYS_VIRT
28 select AUTO_ZRELADDR 27 select AUTO_ZRELADDR
diff --git a/arch/arm/mach-vexpress/Makefile.boot b/arch/arm/mach-vexpress/Makefile.boot
index 909f85ebf5f..318d308dfb9 100644
--- a/arch/arm/mach-vexpress/Makefile.boot
+++ b/arch/arm/mach-vexpress/Makefile.boot
@@ -6,4 +6,5 @@ initrd_phys-y := 0x60800000
6 6
7dtb-$(CONFIG_ARCH_VEXPRESS_DT) += vexpress-v2p-ca5s.dtb \ 7dtb-$(CONFIG_ARCH_VEXPRESS_DT) += vexpress-v2p-ca5s.dtb \
8 vexpress-v2p-ca9.dtb \ 8 vexpress-v2p-ca9.dtb \
9 vexpress-v2p-ca15-tc1.dtb 9 vexpress-v2p-ca15-tc1.dtb \
10 vexpress-v2p-ca15_a7.dtb
diff --git a/arch/arm/mach-vexpress/ct-ca9x4.c b/arch/arm/mach-vexpress/ct-ca9x4.c
index c65cc3b462a..61c492403b0 100644
--- a/arch/arm/mach-vexpress/ct-ca9x4.c
+++ b/arch/arm/mach-vexpress/ct-ca9x4.c
@@ -66,8 +66,15 @@ static void __init ct_ca9x4_init_irq(void)
66 66
67static void ct_ca9x4_clcd_enable(struct clcd_fb *fb) 67static void ct_ca9x4_clcd_enable(struct clcd_fb *fb)
68{ 68{
69 v2m_cfg_write(SYS_CFG_MUXFPGA | SYS_CFG_SITE_DB1, 0); 69 u32 site = v2m_get_master_site();
70 v2m_cfg_write(SYS_CFG_DVIMODE | SYS_CFG_SITE_DB1, 2); 70
71 /*
72 * Old firmware was using the "site" component of the command
73 * to control the DVI muxer (while it should be always 0 ie. MB).
74 * Newer firmware uses the data register. Keep both for compatibility.
75 */
76 v2m_cfg_write(SYS_CFG_MUXFPGA | SYS_CFG_SITE(site), site);
77 v2m_cfg_write(SYS_CFG_DVIMODE | SYS_CFG_SITE(SYS_CFG_SITE_MB), 2);
71} 78}
72 79
73static int ct_ca9x4_clcd_setup(struct clcd_fb *fb) 80static int ct_ca9x4_clcd_setup(struct clcd_fb *fb)
@@ -105,43 +112,11 @@ static struct amba_device *ct_ca9x4_amba_devs[] __initdata = {
105}; 112};
106 113
107 114
108static long ct_round(struct clk *clk, unsigned long rate) 115static struct v2m_osc ct_osc1 = {
109{ 116 .osc = 1,
110 return rate; 117 .rate_min = 10000000,
111} 118 .rate_max = 80000000,
112 119 .rate_default = 23750000,
113static int ct_set(struct clk *clk, unsigned long rate)
114{
115 return v2m_cfg_write(SYS_CFG_OSC | SYS_CFG_SITE_DB1 | 1, rate);
116}
117
118static const struct clk_ops osc1_clk_ops = {
119 .round = ct_round,
120 .set = ct_set,
121};
122
123static struct clk osc1_clk = {
124 .ops = &osc1_clk_ops,
125 .rate = 24000000,
126};
127
128static struct clk ct_sp804_clk = {
129 .rate = 1000000,
130};
131
132static struct clk_lookup lookups[] = {
133 { /* CLCD */
134 .dev_id = "ct:clcd",
135 .clk = &osc1_clk,
136 }, { /* SP804 timers */
137 .dev_id = "sp804",
138 .con_id = "ct-timer0",
139 .clk = &ct_sp804_clk,
140 }, { /* SP804 timers */
141 .dev_id = "sp804",
142 .con_id = "ct-timer1",
143 .clk = &ct_sp804_clk,
144 },
145}; 120};
146 121
147static struct resource pmu_resources[] = { 122static struct resource pmu_resources[] = {
@@ -174,14 +149,10 @@ static struct platform_device pmu_device = {
174 .resource = pmu_resources, 149 .resource = pmu_resources,
175}; 150};
176 151
177static void __init ct_ca9x4_init_early(void)
178{
179 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
180}
181
182static void __init ct_ca9x4_init(void) 152static void __init ct_ca9x4_init(void)
183{ 153{
184 int i; 154 int i;
155 struct clk *clk;
185 156
186#ifdef CONFIG_CACHE_L2X0 157#ifdef CONFIG_CACHE_L2X0
187 void __iomem *l2x0_base = ioremap(CT_CA9X4_L2CC, SZ_4K); 158 void __iomem *l2x0_base = ioremap(CT_CA9X4_L2CC, SZ_4K);
@@ -193,6 +164,10 @@ static void __init ct_ca9x4_init(void)
193 l2x0_init(l2x0_base, 0x00400000, 0xfe0fffff); 164 l2x0_init(l2x0_base, 0x00400000, 0xfe0fffff);
194#endif 165#endif
195 166
167 ct_osc1.site = v2m_get_master_site();
168 clk = v2m_osc_register("ct:osc1", &ct_osc1);
169 clk_register_clkdev(clk, NULL, "ct:clcd");
170
196 for (i = 0; i < ARRAY_SIZE(ct_ca9x4_amba_devs); i++) 171 for (i = 0; i < ARRAY_SIZE(ct_ca9x4_amba_devs); i++)
197 amba_device_register(ct_ca9x4_amba_devs[i], &iomem_resource); 172 amba_device_register(ct_ca9x4_amba_devs[i], &iomem_resource);
198 173
@@ -234,7 +209,6 @@ struct ct_desc ct_ca9x4_desc __initdata = {
234 .id = V2M_CT_ID_CA9, 209 .id = V2M_CT_ID_CA9,
235 .name = "CA9x4", 210 .name = "CA9x4",
236 .map_io = ct_ca9x4_map_io, 211 .map_io = ct_ca9x4_map_io,
237 .init_early = ct_ca9x4_init_early,
238 .init_irq = ct_ca9x4_init_irq, 212 .init_irq = ct_ca9x4_init_irq,
239 .init_tile = ct_ca9x4_init, 213 .init_tile = ct_ca9x4_init,
240#ifdef CONFIG_SMP 214#ifdef CONFIG_SMP
diff --git a/arch/arm/mach-vexpress/include/mach/clkdev.h b/arch/arm/mach-vexpress/include/mach/clkdev.h
deleted file mode 100644
index 3f8307d73ca..00000000000
--- a/arch/arm/mach-vexpress/include/mach/clkdev.h
+++ /dev/null
@@ -1,15 +0,0 @@
1#ifndef __ASM_MACH_CLKDEV_H
2#define __ASM_MACH_CLKDEV_H
3
4#include <plat/clock.h>
5
6struct clk {
7 const struct clk_ops *ops;
8 unsigned long rate;
9 const struct icst_params *params;
10};
11
12#define __clk_get(clk) ({ 1; })
13#define __clk_put(clk) do { } while (0)
14
15#endif
diff --git a/arch/arm/mach-vexpress/include/mach/debug-macro.S b/arch/arm/mach-vexpress/include/mach/debug-macro.S
index fa8224794e0..9f509f55d07 100644
--- a/arch/arm/mach-vexpress/include/mach/debug-macro.S
+++ b/arch/arm/mach-vexpress/include/mach/debug-macro.S
@@ -18,6 +18,8 @@
18 18
19#define DEBUG_LL_VIRT_BASE 0xf8000000 19#define DEBUG_LL_VIRT_BASE 0xf8000000
20 20
21#if defined(CONFIG_DEBUG_VEXPRESS_UART0_DETECT)
22
21 .macro addruart,rp,rv,tmp 23 .macro addruart,rp,rv,tmp
22 24
23 @ Make an educated guess regarding the memory map: 25 @ Make an educated guess regarding the memory map:
@@ -41,3 +43,42 @@
41 .endm 43 .endm
42 44
43#include <asm/hardware/debug-pl01x.S> 45#include <asm/hardware/debug-pl01x.S>
46
47#elif defined(CONFIG_DEBUG_VEXPRESS_UART0_CA9)
48
49 .macro addruart,rp,rv,tmp
50 mov \rp, #DEBUG_LL_UART_OFFSET
51 orr \rv, \rp, #DEBUG_LL_VIRT_BASE
52 orr \rp, \rp, #DEBUG_LL_PHYS_BASE
53 .endm
54
55#include <asm/hardware/debug-pl01x.S>
56
57#elif defined(CONFIG_DEBUG_VEXPRESS_UART0_RS1)
58
59 .macro addruart,rp,rv,tmp
60 mov \rp, #DEBUG_LL_UART_OFFSET_RS1
61 orr \rv, \rp, #DEBUG_LL_VIRT_BASE
62 orr \rp, \rp, #DEBUG_LL_PHYS_BASE_RS1
63 .endm
64
65#include <asm/hardware/debug-pl01x.S>
66
67#else /* CONFIG_DEBUG_LL_UART_NONE */
68
69 .macro addruart, rp, rv, tmp
70 /* Safe dummy values */
71 mov \rp, #0
72 mov \rv, #DEBUG_LL_VIRT_BASE
73 .endm
74
75 .macro senduart,rd,rx
76 .endm
77
78 .macro waituart,rd,rx
79 .endm
80
81 .macro busyuart,rd,rx
82 .endm
83
84#endif
diff --git a/arch/arm/mach-vexpress/include/mach/motherboard.h b/arch/arm/mach-vexpress/include/mach/motherboard.h
index 31a92890893..1e388c7bf4d 100644
--- a/arch/arm/mach-vexpress/include/mach/motherboard.h
+++ b/arch/arm/mach-vexpress/include/mach/motherboard.h
@@ -1,6 +1,8 @@
1#ifndef __MACH_MOTHERBOARD_H 1#ifndef __MACH_MOTHERBOARD_H
2#define __MACH_MOTHERBOARD_H 2#define __MACH_MOTHERBOARD_H
3 3
4#include <linux/clk-provider.h>
5
4/* 6/*
5 * Physical addresses, offset from V2M_PA_CS0-3 7 * Physical addresses, offset from V2M_PA_CS0-3
6 */ 8 */
@@ -104,9 +106,10 @@
104#define SYS_CFG_REBOOT (9 << 20) 106#define SYS_CFG_REBOOT (9 << 20)
105#define SYS_CFG_DVIMODE (11 << 20) 107#define SYS_CFG_DVIMODE (11 << 20)
106#define SYS_CFG_POWER (12 << 20) 108#define SYS_CFG_POWER (12 << 20)
107#define SYS_CFG_SITE_MB (0 << 16) 109#define SYS_CFG_SITE(n) ((n) << 16)
108#define SYS_CFG_SITE_DB1 (1 << 16) 110#define SYS_CFG_SITE_MB 0
109#define SYS_CFG_SITE_DB2 (2 << 16) 111#define SYS_CFG_SITE_DB1 1
112#define SYS_CFG_SITE_DB2 2
110#define SYS_CFG_STACK(n) ((n) << 12) 113#define SYS_CFG_STACK(n) ((n) << 12)
111 114
112#define SYS_CFG_ERR (1 << 1) 115#define SYS_CFG_ERR (1 << 1)
@@ -122,6 +125,8 @@ void v2m_flags_set(u32 data);
122#define SYS_MISC_MASTERSITE (1 << 14) 125#define SYS_MISC_MASTERSITE (1 << 14)
123#define SYS_PROCIDx_HBI_MASK 0xfff 126#define SYS_PROCIDx_HBI_MASK 0xfff
124 127
128int v2m_get_master_site(void);
129
125/* 130/*
126 * Core tile IDs 131 * Core tile IDs
127 */ 132 */
@@ -144,4 +149,21 @@ struct ct_desc {
144 149
145extern struct ct_desc *ct_desc; 150extern struct ct_desc *ct_desc;
146 151
152/*
153 * OSC clock provider
154 */
155struct v2m_osc {
156 struct clk_hw hw;
157 u8 site; /* 0 = motherboard, 1 = site 1, 2 = site 2 */
158 u8 stack; /* board stack position */
159 u16 osc;
160 unsigned long rate_min;
161 unsigned long rate_max;
162 unsigned long rate_default;
163};
164
165#define to_v2m_osc(osc) container_of(osc, struct v2m_osc, hw)
166
167struct clk *v2m_osc_register(const char *name, struct v2m_osc *osc);
168
147#endif 169#endif
diff --git a/arch/arm/mach-vexpress/include/mach/uncompress.h b/arch/arm/mach-vexpress/include/mach/uncompress.h
index 7dab5596b86..1e472eb0bbd 100644
--- a/arch/arm/mach-vexpress/include/mach/uncompress.h
+++ b/arch/arm/mach-vexpress/include/mach/uncompress.h
@@ -27,6 +27,7 @@
27 27
28static unsigned long get_uart_base(void) 28static unsigned long get_uart_base(void)
29{ 29{
30#if defined(CONFIG_DEBUG_VEXPRESS_UART0_DETECT)
30 unsigned long mpcore_periph; 31 unsigned long mpcore_periph;
31 32
32 /* 33 /*
@@ -42,6 +43,13 @@ static unsigned long get_uart_base(void)
42 return UART_BASE; 43 return UART_BASE;
43 else 44 else
44 return UART_BASE_RS1; 45 return UART_BASE_RS1;
46#elif defined(CONFIG_DEBUG_VEXPRESS_UART0_CA9)
47 return UART_BASE;
48#elif defined(CONFIG_DEBUG_VEXPRESS_UART0_RS1)
49 return UART_BASE_RS1;
50#else
51 return 0;
52#endif
45} 53}
46 54
47/* 55/*
@@ -51,6 +59,9 @@ static inline void putc(int c)
51{ 59{
52 unsigned long base = get_uart_base(); 60 unsigned long base = get_uart_base();
53 61
62 if (!base)
63 return;
64
54 while (AMBA_UART_FR(base) & (1 << 5)) 65 while (AMBA_UART_FR(base) & (1 << 5))
55 barrier(); 66 barrier();
56 67
@@ -61,6 +72,9 @@ static inline void flush(void)
61{ 72{
62 unsigned long base = get_uart_base(); 73 unsigned long base = get_uart_base();
63 74
75 if (!base)
76 return;
77
64 while (AMBA_UART_FR(base) & (1 << 3)) 78 while (AMBA_UART_FR(base) & (1 << 3))
65 barrier(); 79 barrier();
66} 80}
diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index fde26adaef3..37608f22ee3 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -16,7 +16,10 @@
16#include <linux/spinlock.h> 16#include <linux/spinlock.h>
17#include <linux/usb/isp1760.h> 17#include <linux/usb/isp1760.h>
18#include <linux/clkdev.h> 18#include <linux/clkdev.h>
19#include <linux/clk-provider.h>
19#include <linux/mtd/physmap.h> 20#include <linux/mtd/physmap.h>
21#include <linux/regulator/fixed.h>
22#include <linux/regulator/machine.h>
20 23
21#include <asm/arch_timer.h> 24#include <asm/arch_timer.h>
22#include <asm/mach-types.h> 25#include <asm/mach-types.h>
@@ -81,16 +84,6 @@ static void __init v2m_sp804_init(void __iomem *base, unsigned int irq)
81 sp804_clockevents_init(base + TIMER_1_BASE, irq, "v2m-timer0"); 84 sp804_clockevents_init(base + TIMER_1_BASE, irq, "v2m-timer0");
82} 85}
83 86
84static void __init v2m_timer_init(void)
85{
86 v2m_sysctl_init(ioremap(V2M_SYSCTL, SZ_4K));
87 v2m_sp804_init(ioremap(V2M_TIMER01, SZ_4K), IRQ_V2M_TIMER0);
88}
89
90static struct sys_timer v2m_timer = {
91 .init = v2m_timer_init,
92};
93
94 87
95static DEFINE_SPINLOCK(v2m_cfg_lock); 88static DEFINE_SPINLOCK(v2m_cfg_lock);
96 89
@@ -147,6 +140,13 @@ void __init v2m_flags_set(u32 data)
147 writel(data, v2m_sysreg_base + V2M_SYS_FLAGSSET); 140 writel(data, v2m_sysreg_base + V2M_SYS_FLAGSSET);
148} 141}
149 142
143int v2m_get_master_site(void)
144{
145 u32 misc = readl(v2m_sysreg_base + V2M_SYS_MISC);
146
147 return misc & SYS_MISC_MASTERSITE ? SYS_CFG_SITE_DB2 : SYS_CFG_SITE_DB1;
148}
149
150 150
151static struct resource v2m_pcie_i2c_resource = { 151static struct resource v2m_pcie_i2c_resource = {
152 .start = V2M_SERIAL_BUS_PCI, 152 .start = V2M_SERIAL_BUS_PCI,
@@ -201,6 +201,11 @@ static struct platform_device v2m_eth_device = {
201 .dev.platform_data = &v2m_eth_config, 201 .dev.platform_data = &v2m_eth_config,
202}; 202};
203 203
204static struct regulator_consumer_supply v2m_eth_supplies[] = {
205 REGULATOR_SUPPLY("vddvario", "smsc911x"),
206 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
207};
208
204static struct resource v2m_usb_resources[] = { 209static struct resource v2m_usb_resources[] = {
205 { 210 {
206 .start = V2M_ISP1761, 211 .start = V2M_ISP1761,
@@ -319,98 +324,145 @@ static struct amba_device *v2m_amba_devs[] __initdata = {
319}; 324};
320 325
321 326
322static long v2m_osc_round(struct clk *clk, unsigned long rate) 327static unsigned long v2m_osc_recalc_rate(struct clk_hw *hw,
328 unsigned long parent_rate)
329{
330 struct v2m_osc *osc = to_v2m_osc(hw);
331
332 return !parent_rate ? osc->rate_default : parent_rate;
333}
334
335static long v2m_osc_round_rate(struct clk_hw *hw, unsigned long rate,
336 unsigned long *parent_rate)
323{ 337{
338 struct v2m_osc *osc = to_v2m_osc(hw);
339
340 if (WARN_ON(rate < osc->rate_min))
341 rate = osc->rate_min;
342
343 if (WARN_ON(rate > osc->rate_max))
344 rate = osc->rate_max;
345
324 return rate; 346 return rate;
325} 347}
326 348
327static int v2m_osc1_set(struct clk *clk, unsigned long rate) 349static int v2m_osc_set_rate(struct clk_hw *hw, unsigned long rate,
350 unsigned long parent_rate)
328{ 351{
329 return v2m_cfg_write(SYS_CFG_OSC | SYS_CFG_SITE_MB | 1, rate); 352 struct v2m_osc *osc = to_v2m_osc(hw);
353
354 v2m_cfg_write(SYS_CFG_OSC | SYS_CFG_SITE(osc->site) |
355 SYS_CFG_STACK(osc->stack) | osc->osc, rate);
356
357 return 0;
330} 358}
331 359
332static const struct clk_ops osc1_clk_ops = { 360static struct clk_ops v2m_osc_ops = {
333 .round = v2m_osc_round, 361 .recalc_rate = v2m_osc_recalc_rate,
334 .set = v2m_osc1_set, 362 .round_rate = v2m_osc_round_rate,
335}; 363 .set_rate = v2m_osc_set_rate,
336 364};
337static struct clk osc1_clk = { 365
338 .ops = &osc1_clk_ops, 366struct clk * __init v2m_osc_register(const char *name, struct v2m_osc *osc)
339 .rate = 24000000, 367{
340}; 368 struct clk_init_data init;
341 369
342static struct clk osc2_clk = { 370 WARN_ON(osc->site > 2);
343 .rate = 24000000, 371 WARN_ON(osc->stack > 15);
344}; 372 WARN_ON(osc->osc > 4095);
345 373
346static struct clk v2m_sp804_clk = { 374 init.name = name;
347 .rate = 1000000, 375 init.ops = &v2m_osc_ops;
348}; 376 init.flags = CLK_IS_ROOT;
349 377 init.num_parents = 0;
350static struct clk v2m_ref_clk = { 378
351 .rate = 32768, 379 osc->hw.init = &init;
352}; 380
353 381 return clk_register(NULL, &osc->hw);
354static struct clk dummy_apb_pclk; 382}
355 383
356static struct clk_lookup v2m_lookups[] = { 384static struct v2m_osc v2m_mb_osc1 = {
357 { /* AMBA bus clock */ 385 .site = SYS_CFG_SITE_MB,
358 .con_id = "apb_pclk", 386 .osc = 1,
359 .clk = &dummy_apb_pclk, 387 .rate_min = 23750000,
360 }, { /* UART0 */ 388 .rate_max = 63500000,
361 .dev_id = "mb:uart0", 389 .rate_default = 23750000,
362 .clk = &osc2_clk, 390};
363 }, { /* UART1 */ 391
364 .dev_id = "mb:uart1", 392static const char *v2m_ref_clk_periphs[] __initconst = {
365 .clk = &osc2_clk, 393 "mb:wdt", "1000f000.wdt", "1c0f0000.wdt", /* SP805 WDT */
366 }, { /* UART2 */ 394};
367 .dev_id = "mb:uart2", 395
368 .clk = &osc2_clk, 396static const char *v2m_osc1_periphs[] __initconst = {
369 }, { /* UART3 */ 397 "mb:clcd", "1001f000.clcd", "1c1f0000.clcd", /* PL111 CLCD */
370 .dev_id = "mb:uart3", 398};
371 .clk = &osc2_clk, 399
372 }, { /* KMI0 */ 400static const char *v2m_osc2_periphs[] __initconst = {
373 .dev_id = "mb:kmi0", 401 "mb:mmci", "10005000.mmci", "1c050000.mmci", /* PL180 MMCI */
374 .clk = &osc2_clk, 402 "mb:kmi0", "10006000.kmi", "1c060000.kmi", /* PL050 KMI0 */
375 }, { /* KMI1 */ 403 "mb:kmi1", "10007000.kmi", "1c070000.kmi", /* PL050 KMI1 */
376 .dev_id = "mb:kmi1", 404 "mb:uart0", "10009000.uart", "1c090000.uart", /* PL011 UART0 */
377 .clk = &osc2_clk, 405 "mb:uart1", "1000a000.uart", "1c0a0000.uart", /* PL011 UART1 */
378 }, { /* MMC0 */ 406 "mb:uart2", "1000b000.uart", "1c0b0000.uart", /* PL011 UART2 */
379 .dev_id = "mb:mmci", 407 "mb:uart3", "1000c000.uart", "1c0c0000.uart", /* PL011 UART3 */
380 .clk = &osc2_clk, 408};
381 }, { /* CLCD */ 409
382 .dev_id = "mb:clcd", 410static void __init v2m_clk_init(void)
383 .clk = &osc1_clk, 411{
384 }, { /* SP805 WDT */ 412 struct clk *clk;
385 .dev_id = "mb:wdt", 413 int i;
386 .clk = &v2m_ref_clk, 414
387 }, { /* SP804 timers */ 415 clk = clk_register_fixed_rate(NULL, "dummy_apb_pclk", NULL,
388 .dev_id = "sp804", 416 CLK_IS_ROOT, 0);
389 .con_id = "v2m-timer0", 417 WARN_ON(clk_register_clkdev(clk, "apb_pclk", NULL));
390 .clk = &v2m_sp804_clk, 418
391 }, { /* SP804 timers */ 419 clk = clk_register_fixed_rate(NULL, "mb:ref_clk", NULL,
392 .dev_id = "sp804", 420 CLK_IS_ROOT, 32768);
393 .con_id = "v2m-timer1", 421 for (i = 0; i < ARRAY_SIZE(v2m_ref_clk_periphs); i++)
394 .clk = &v2m_sp804_clk, 422 WARN_ON(clk_register_clkdev(clk, NULL, v2m_ref_clk_periphs[i]));
395 }, 423
424 clk = clk_register_fixed_rate(NULL, "mb:sp804_clk", NULL,
425 CLK_IS_ROOT, 1000000);
426 WARN_ON(clk_register_clkdev(clk, "v2m-timer0", "sp804"));
427 WARN_ON(clk_register_clkdev(clk, "v2m-timer1", "sp804"));
428
429 clk = v2m_osc_register("mb:osc1", &v2m_mb_osc1);
430 for (i = 0; i < ARRAY_SIZE(v2m_osc1_periphs); i++)
431 WARN_ON(clk_register_clkdev(clk, NULL, v2m_osc1_periphs[i]));
432
433 clk = clk_register_fixed_rate(NULL, "mb:osc2", NULL,
434 CLK_IS_ROOT, 24000000);
435 for (i = 0; i < ARRAY_SIZE(v2m_osc2_periphs); i++)
436 WARN_ON(clk_register_clkdev(clk, NULL, v2m_osc2_periphs[i]));
437}
438
439static void __init v2m_timer_init(void)
440{
441 v2m_sysctl_init(ioremap(V2M_SYSCTL, SZ_4K));
442 v2m_clk_init();
443 v2m_sp804_init(ioremap(V2M_TIMER01, SZ_4K), IRQ_V2M_TIMER0);
444}
445
446static struct sys_timer v2m_timer = {
447 .init = v2m_timer_init,
396}; 448};
397 449
398static void __init v2m_init_early(void) 450static void __init v2m_init_early(void)
399{ 451{
400 ct_desc->init_early(); 452 if (ct_desc->init_early)
401 clkdev_add_table(v2m_lookups, ARRAY_SIZE(v2m_lookups)); 453 ct_desc->init_early();
402 versatile_sched_clock_init(v2m_sysreg_base + V2M_SYS_24MHZ, 24000000); 454 versatile_sched_clock_init(v2m_sysreg_base + V2M_SYS_24MHZ, 24000000);
403} 455}
404 456
405static void v2m_power_off(void) 457static void v2m_power_off(void)
406{ 458{
407 if (v2m_cfg_write(SYS_CFG_SHUTDOWN | SYS_CFG_SITE_MB, 0)) 459 if (v2m_cfg_write(SYS_CFG_SHUTDOWN | SYS_CFG_SITE(SYS_CFG_SITE_MB), 0))
408 printk(KERN_EMERG "Unable to shutdown\n"); 460 printk(KERN_EMERG "Unable to shutdown\n");
409} 461}
410 462
411static void v2m_restart(char str, const char *cmd) 463static void v2m_restart(char str, const char *cmd)
412{ 464{
413 if (v2m_cfg_write(SYS_CFG_REBOOT | SYS_CFG_SITE_MB, 0)) 465 if (v2m_cfg_write(SYS_CFG_REBOOT | SYS_CFG_SITE(SYS_CFG_SITE_MB), 0))
414 printk(KERN_EMERG "Unable to reboot\n"); 466 printk(KERN_EMERG "Unable to reboot\n");
415} 467}
416 468
@@ -458,6 +510,9 @@ static void __init v2m_init(void)
458{ 510{
459 int i; 511 int i;
460 512
513 regulator_register_fixed(0, v2m_eth_supplies,
514 ARRAY_SIZE(v2m_eth_supplies));
515
461 platform_device_register(&v2m_pcie_i2c_device); 516 platform_device_register(&v2m_pcie_i2c_device);
462 platform_device_register(&v2m_ddc_i2c_device); 517 platform_device_register(&v2m_ddc_i2c_device);
463 platform_device_register(&v2m_flash_device); 518 platform_device_register(&v2m_flash_device);
@@ -522,77 +577,6 @@ void __init v2m_dt_map_io(void)
522#endif 577#endif
523} 578}
524 579
525static struct clk_lookup v2m_dt_lookups[] = {
526 { /* AMBA bus clock */
527 .con_id = "apb_pclk",
528 .clk = &dummy_apb_pclk,
529 }, { /* SP804 timers */
530 .dev_id = "sp804",
531 .con_id = "v2m-timer0",
532 .clk = &v2m_sp804_clk,
533 }, { /* SP804 timers */
534 .dev_id = "sp804",
535 .con_id = "v2m-timer1",
536 .clk = &v2m_sp804_clk,
537 }, { /* PL180 MMCI */
538 .dev_id = "mb:mmci", /* 10005000.mmci */
539 .clk = &osc2_clk,
540 }, { /* PL050 KMI0 */
541 .dev_id = "10006000.kmi",
542 .clk = &osc2_clk,
543 }, { /* PL050 KMI1 */
544 .dev_id = "10007000.kmi",
545 .clk = &osc2_clk,
546 }, { /* PL011 UART0 */
547 .dev_id = "10009000.uart",
548 .clk = &osc2_clk,
549 }, { /* PL011 UART1 */
550 .dev_id = "1000a000.uart",
551 .clk = &osc2_clk,
552 }, { /* PL011 UART2 */
553 .dev_id = "1000b000.uart",
554 .clk = &osc2_clk,
555 }, { /* PL011 UART3 */
556 .dev_id = "1000c000.uart",
557 .clk = &osc2_clk,
558 }, { /* SP805 WDT */
559 .dev_id = "1000f000.wdt",
560 .clk = &v2m_ref_clk,
561 }, { /* PL111 CLCD */
562 .dev_id = "1001f000.clcd",
563 .clk = &osc1_clk,
564 },
565 /* RS1 memory map */
566 { /* PL180 MMCI */
567 .dev_id = "mb:mmci", /* 1c050000.mmci */
568 .clk = &osc2_clk,
569 }, { /* PL050 KMI0 */
570 .dev_id = "1c060000.kmi",
571 .clk = &osc2_clk,
572 }, { /* PL050 KMI1 */
573 .dev_id = "1c070000.kmi",
574 .clk = &osc2_clk,
575 }, { /* PL011 UART0 */
576 .dev_id = "1c090000.uart",
577 .clk = &osc2_clk,
578 }, { /* PL011 UART1 */
579 .dev_id = "1c0a0000.uart",
580 .clk = &osc2_clk,
581 }, { /* PL011 UART2 */
582 .dev_id = "1c0b0000.uart",
583 .clk = &osc2_clk,
584 }, { /* PL011 UART3 */
585 .dev_id = "1c0c0000.uart",
586 .clk = &osc2_clk,
587 }, { /* SP805 WDT */
588 .dev_id = "1c0f0000.wdt",
589 .clk = &v2m_ref_clk,
590 }, { /* PL111 CLCD */
591 .dev_id = "1c1f0000.clcd",
592 .clk = &osc1_clk,
593 },
594};
595
596void __init v2m_dt_init_early(void) 580void __init v2m_dt_init_early(void)
597{ 581{
598 struct device_node *node; 582 struct device_node *node;
@@ -605,8 +589,8 @@ void __init v2m_dt_init_early(void)
605 589
606 /* Confirm board type against DT property, if available */ 590 /* Confirm board type against DT property, if available */
607 if (of_property_read_u32(allnodes, "arm,hbi", &dt_hbi) == 0) { 591 if (of_property_read_u32(allnodes, "arm,hbi", &dt_hbi) == 0) {
608 u32 misc = readl(v2m_sysreg_base + V2M_SYS_MISC); 592 int site = v2m_get_master_site();
609 u32 id = readl(v2m_sysreg_base + (misc & SYS_MISC_MASTERSITE ? 593 u32 id = readl(v2m_sysreg_base + (site == SYS_CFG_SITE_DB2 ?
610 V2M_SYS_PROCID1 : V2M_SYS_PROCID0)); 594 V2M_SYS_PROCID1 : V2M_SYS_PROCID0));
611 u32 hbi = id & SYS_PROCIDx_HBI_MASK; 595 u32 hbi = id & SYS_PROCIDx_HBI_MASK;
612 596
@@ -614,8 +598,6 @@ void __init v2m_dt_init_early(void)
614 pr_warning("vexpress: DT HBI (%x) is not matching " 598 pr_warning("vexpress: DT HBI (%x) is not matching "
615 "hardware (%x)!\n", dt_hbi, hbi); 599 "hardware (%x)!\n", dt_hbi, hbi);
616 } 600 }
617
618 clkdev_add_table(v2m_dt_lookups, ARRAY_SIZE(v2m_dt_lookups));
619} 601}
620 602
621static struct of_device_id vexpress_irq_match[] __initdata = { 603static struct of_device_id vexpress_irq_match[] __initdata = {
@@ -637,6 +619,8 @@ static void __init v2m_dt_timer_init(void)
637 node = of_find_compatible_node(NULL, NULL, "arm,sp810"); 619 node = of_find_compatible_node(NULL, NULL, "arm,sp810");
638 v2m_sysctl_init(of_iomap(node, 0)); 620 v2m_sysctl_init(of_iomap(node, 0));
639 621
622 v2m_clk_init();
623
640 err = of_property_read_string(of_aliases, "arm,v2m_timer", &path); 624 err = of_property_read_string(of_aliases, "arm,v2m_timer", &path);
641 if (WARN_ON(err)) 625 if (WARN_ON(err))
642 return; 626 return;
diff --git a/arch/arm/mach-vt8500/Makefile b/arch/arm/mach-vt8500/Makefile
index 81aedb7c893..7ce51767c99 100644
--- a/arch/arm/mach-vt8500/Makefile
+++ b/arch/arm/mach-vt8500/Makefile
@@ -1,9 +1,7 @@
1obj-y += devices.o gpio.o irq.o timer.o 1obj-y += devices.o gpio.o irq.o timer.o restart.o
2 2
3obj-$(CONFIG_VTWM_VERSION_VT8500) += devices-vt8500.o 3obj-$(CONFIG_VTWM_VERSION_VT8500) += devices-vt8500.o
4obj-$(CONFIG_VTWM_VERSION_WM8505) += devices-wm8505.o 4obj-$(CONFIG_VTWM_VERSION_WM8505) += devices-wm8505.o
5 5
6obj-$(CONFIG_MACH_BV07) += bv07.o 6obj-$(CONFIG_MACH_BV07) += bv07.o
7obj-$(CONFIG_MACH_WM8505_7IN_NETBOOK) += wm8505_7in.o 7obj-$(CONFIG_MACH_WM8505_7IN_NETBOOK) += wm8505_7in.o
8
9obj-$(CONFIG_HAVE_PWM) += pwm.o
diff --git a/arch/arm/mach-vt8500/bv07.c b/arch/arm/mach-vt8500/bv07.c
index a464c758441..f9fbeb2d10e 100644
--- a/arch/arm/mach-vt8500/bv07.c
+++ b/arch/arm/mach-vt8500/bv07.c
@@ -23,6 +23,7 @@
23 23
24#include <asm/mach-types.h> 24#include <asm/mach-types.h>
25#include <asm/mach/arch.h> 25#include <asm/mach/arch.h>
26#include <mach/restart.h>
26 27
27#include "devices.h" 28#include "devices.h"
28 29
@@ -62,6 +63,7 @@ void __init bv07_init(void)
62 else 63 else
63 printk(KERN_ERR "PMC Hibernation register could not be remapped, not enabling power off!\n"); 64 printk(KERN_ERR "PMC Hibernation register could not be remapped, not enabling power off!\n");
64 65
66 wmt_setup_restart();
65 vt8500_set_resources(); 67 vt8500_set_resources();
66 platform_add_devices(devices, ARRAY_SIZE(devices)); 68 platform_add_devices(devices, ARRAY_SIZE(devices));
67 vt8500_gpio_init(); 69 vt8500_gpio_init();
@@ -69,6 +71,7 @@ void __init bv07_init(void)
69 71
70MACHINE_START(BV07, "Benign BV07 Mini Netbook") 72MACHINE_START(BV07, "Benign BV07 Mini Netbook")
71 .atag_offset = 0x100, 73 .atag_offset = 0x100,
74 .restart = wmt_restart,
72 .reserve = vt8500_reserve_mem, 75 .reserve = vt8500_reserve_mem,
73 .map_io = vt8500_map_io, 76 .map_io = vt8500_map_io,
74 .init_irq = vt8500_init_irq, 77 .init_irq = vt8500_init_irq,
diff --git a/arch/arm/mach-vt8500/include/mach/restart.h b/arch/arm/mach-vt8500/include/mach/restart.h
new file mode 100644
index 00000000000..89f9b787d2a
--- /dev/null
+++ b/arch/arm/mach-vt8500/include/mach/restart.h
@@ -0,0 +1,17 @@
1/* linux/arch/arm/mach-vt8500/restart.h
2 *
3 * Copyright (C) 2012 Tony Prisk <linux@prisktech.co.nz>
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16void wmt_setup_restart(void);
17void wmt_restart(char mode, const char *cmd);
diff --git a/arch/arm/mach-vt8500/include/mach/system.h b/arch/arm/mach-vt8500/include/mach/system.h
deleted file mode 100644
index 58fa8010ee6..00000000000
--- a/arch/arm/mach-vt8500/include/mach/system.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * arch/arm/mach-vt8500/include/mach/system.h
3 *
4 */
5#include <asm/io.h>
6
7/* PM Software Reset request register */
8#define VT8500_PMSR_VIRT 0xf8130060
9
10static inline void arch_reset(char mode, const char *cmd)
11{
12 writel(1, VT8500_PMSR_VIRT);
13}
diff --git a/arch/arm/mach-vt8500/pwm.c b/arch/arm/mach-vt8500/pwm.c
deleted file mode 100644
index 8ad825e9359..00000000000
--- a/arch/arm/mach-vt8500/pwm.c
+++ /dev/null
@@ -1,265 +0,0 @@
1/*
2 * arch/arm/mach-vt8500/pwm.c
3 *
4 * Copyright (C) 2010 Alexey Charkov <alchark@gmail.com>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/module.h>
17#include <linux/kernel.h>
18#include <linux/platform_device.h>
19#include <linux/slab.h>
20#include <linux/err.h>
21#include <linux/io.h>
22#include <linux/pwm.h>
23#include <linux/delay.h>
24
25#include <asm/div64.h>
26
27#define VT8500_NR_PWMS 4
28
29static DEFINE_MUTEX(pwm_lock);
30static LIST_HEAD(pwm_list);
31
32struct pwm_device {
33 struct list_head node;
34 struct platform_device *pdev;
35
36 const char *label;
37
38 void __iomem *regbase;
39
40 unsigned int use_count;
41 unsigned int pwm_id;
42};
43
44#define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t)
45static inline void pwm_busy_wait(void __iomem *reg, u8 bitmask)
46{
47 int loops = msecs_to_loops(10);
48 while ((readb(reg) & bitmask) && --loops)
49 cpu_relax();
50
51 if (unlikely(!loops))
52 pr_warning("Waiting for status bits 0x%x to clear timed out\n",
53 bitmask);
54}
55
56int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
57{
58 unsigned long long c;
59 unsigned long period_cycles, prescale, pv, dc;
60
61 if (pwm == NULL || period_ns == 0 || duty_ns > period_ns)
62 return -EINVAL;
63
64 c = 25000000/2; /* wild guess --- need to implement clocks */
65 c = c * period_ns;
66 do_div(c, 1000000000);
67 period_cycles = c;
68
69 if (period_cycles < 1)
70 period_cycles = 1;
71 prescale = (period_cycles - 1) / 4096;
72 pv = period_cycles / (prescale + 1) - 1;
73 if (pv > 4095)
74 pv = 4095;
75
76 if (prescale > 1023)
77 return -EINVAL;
78
79 c = (unsigned long long)pv * duty_ns;
80 do_div(c, period_ns);
81 dc = c;
82
83 pwm_busy_wait(pwm->regbase + 0x40 + pwm->pwm_id, (1 << 1));
84 writel(prescale, pwm->regbase + 0x4 + (pwm->pwm_id << 4));
85
86 pwm_busy_wait(pwm->regbase + 0x40 + pwm->pwm_id, (1 << 2));
87 writel(pv, pwm->regbase + 0x8 + (pwm->pwm_id << 4));
88
89 pwm_busy_wait(pwm->regbase + 0x40 + pwm->pwm_id, (1 << 3));
90 writel(dc, pwm->regbase + 0xc + (pwm->pwm_id << 4));
91
92 return 0;
93}
94EXPORT_SYMBOL(pwm_config);
95
96int pwm_enable(struct pwm_device *pwm)
97{
98 pwm_busy_wait(pwm->regbase + 0x40 + pwm->pwm_id, (1 << 0));
99 writel(5, pwm->regbase + (pwm->pwm_id << 4));
100 return 0;
101}
102EXPORT_SYMBOL(pwm_enable);
103
104void pwm_disable(struct pwm_device *pwm)
105{
106 pwm_busy_wait(pwm->regbase + 0x40 + pwm->pwm_id, (1 << 0));
107 writel(0, pwm->regbase + (pwm->pwm_id << 4));
108}
109EXPORT_SYMBOL(pwm_disable);
110
111struct pwm_device *pwm_request(int pwm_id, const char *label)
112{
113 struct pwm_device *pwm;
114 int found = 0;
115
116 mutex_lock(&pwm_lock);
117
118 list_for_each_entry(pwm, &pwm_list, node) {
119 if (pwm->pwm_id == pwm_id) {
120 found = 1;
121 break;
122 }
123 }
124
125 if (found) {
126 if (pwm->use_count == 0) {
127 pwm->use_count++;
128 pwm->label = label;
129 } else {
130 pwm = ERR_PTR(-EBUSY);
131 }
132 } else {
133 pwm = ERR_PTR(-ENOENT);
134 }
135
136 mutex_unlock(&pwm_lock);
137 return pwm;
138}
139EXPORT_SYMBOL(pwm_request);
140
141void pwm_free(struct pwm_device *pwm)
142{
143 mutex_lock(&pwm_lock);
144
145 if (pwm->use_count) {
146 pwm->use_count--;
147 pwm->label = NULL;
148 } else {
149 pr_warning("PWM device already freed\n");
150 }
151
152 mutex_unlock(&pwm_lock);
153}
154EXPORT_SYMBOL(pwm_free);
155
156static inline void __add_pwm(struct pwm_device *pwm)
157{
158 mutex_lock(&pwm_lock);
159 list_add_tail(&pwm->node, &pwm_list);
160 mutex_unlock(&pwm_lock);
161}
162
163static int __devinit pwm_probe(struct platform_device *pdev)
164{
165 struct pwm_device *pwms;
166 struct resource *r;
167 int ret = 0;
168 int i;
169
170 pwms = kzalloc(sizeof(struct pwm_device) * VT8500_NR_PWMS, GFP_KERNEL);
171 if (pwms == NULL) {
172 dev_err(&pdev->dev, "failed to allocate memory\n");
173 return -ENOMEM;
174 }
175
176 for (i = 0; i < VT8500_NR_PWMS; i++) {
177 pwms[i].use_count = 0;
178 pwms[i].pwm_id = i;
179 pwms[i].pdev = pdev;
180 }
181
182 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
183 if (r == NULL) {
184 dev_err(&pdev->dev, "no memory resource defined\n");
185 ret = -ENODEV;
186 goto err_free;
187 }
188
189 r = request_mem_region(r->start, resource_size(r), pdev->name);
190 if (r == NULL) {
191 dev_err(&pdev->dev, "failed to request memory resource\n");
192 ret = -EBUSY;
193 goto err_free;
194 }
195
196 pwms[0].regbase = ioremap(r->start, resource_size(r));
197 if (pwms[0].regbase == NULL) {
198 dev_err(&pdev->dev, "failed to ioremap() registers\n");
199 ret = -ENODEV;
200 goto err_free_mem;
201 }
202
203 for (i = 1; i < VT8500_NR_PWMS; i++)
204 pwms[i].regbase = pwms[0].regbase;
205
206 for (i = 0; i < VT8500_NR_PWMS; i++)
207 __add_pwm(&pwms[i]);
208
209 platform_set_drvdata(pdev, pwms);
210 return 0;
211
212err_free_mem:
213 release_mem_region(r->start, resource_size(r));
214err_free:
215 kfree(pwms);
216 return ret;
217}
218
219static int __devexit pwm_remove(struct platform_device *pdev)
220{
221 struct pwm_device *pwms;
222 struct resource *r;
223 int i;
224
225 pwms = platform_get_drvdata(pdev);
226 if (pwms == NULL)
227 return -ENODEV;
228
229 mutex_lock(&pwm_lock);
230
231 for (i = 0; i < VT8500_NR_PWMS; i++)
232 list_del(&pwms[i].node);
233 mutex_unlock(&pwm_lock);
234
235 iounmap(pwms[0].regbase);
236
237 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
238 release_mem_region(r->start, resource_size(r));
239
240 kfree(pwms);
241 return 0;
242}
243
244static struct platform_driver pwm_driver = {
245 .driver = {
246 .name = "vt8500-pwm",
247 .owner = THIS_MODULE,
248 },
249 .probe = pwm_probe,
250 .remove = __devexit_p(pwm_remove),
251};
252
253static int __init pwm_init(void)
254{
255 return platform_driver_register(&pwm_driver);
256}
257arch_initcall(pwm_init);
258
259static void __exit pwm_exit(void)
260{
261 platform_driver_unregister(&pwm_driver);
262}
263module_exit(pwm_exit);
264
265MODULE_LICENSE("GPL");
diff --git a/arch/arm/mach-vt8500/restart.c b/arch/arm/mach-vt8500/restart.c
new file mode 100644
index 00000000000..497e89a5e13
--- /dev/null
+++ b/arch/arm/mach-vt8500/restart.c
@@ -0,0 +1,54 @@
1/* linux/arch/arm/mach-vt8500/restart.c
2 *
3 * Copyright (C) 2012 Tony Prisk <linux@prisktech.co.nz>
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15#include <asm/io.h>
16#include <linux/of.h>
17#include <linux/of_address.h>
18
19#define LEGACY_PMC_BASE 0xD8130000
20#define WMT_PRIZM_PMSR_REG 0x60
21
22static void __iomem *pmc_base;
23
24void wmt_setup_restart(void)
25{
26 struct device_node *np;
27
28 /*
29 * Check if Power Mgmt Controller node is present in device tree. If no
30 * device tree node, use the legacy PMSR value (valid for all current
31 * SoCs).
32 */
33 np = of_find_compatible_node(NULL, NULL, "wmt,prizm-pmc");
34 if (np) {
35 pmc_base = of_iomap(np, 0);
36
37 if (!pmc_base)
38 pr_err("%s:of_iomap(pmc) failed\n", __func__);
39
40 of_node_put(np);
41 } else {
42 pmc_base = ioremap(LEGACY_PMC_BASE, 0x1000);
43 if (!pmc_base) {
44 pr_err("%s:ioremap(rstc) failed\n", __func__);
45 return;
46 }
47 }
48}
49
50void wmt_restart(char mode, const char *cmd)
51{
52 if (pmc_base)
53 writel(1, pmc_base + WMT_PRIZM_PMSR_REG);
54}
diff --git a/arch/arm/mach-vt8500/wm8505_7in.c b/arch/arm/mach-vt8500/wm8505_7in.c
index cf910a95608..db19886caf7 100644
--- a/arch/arm/mach-vt8500/wm8505_7in.c
+++ b/arch/arm/mach-vt8500/wm8505_7in.c
@@ -23,6 +23,7 @@
23 23
24#include <asm/mach-types.h> 24#include <asm/mach-types.h>
25#include <asm/mach/arch.h> 25#include <asm/mach/arch.h>
26#include <mach/restart.h>
26 27
27#include "devices.h" 28#include "devices.h"
28 29
@@ -61,7 +62,7 @@ void __init wm8505_7in_init(void)
61 pm_power_off = &vt8500_power_off; 62 pm_power_off = &vt8500_power_off;
62 else 63 else
63 printk(KERN_ERR "PMC Hibernation register could not be remapped, not enabling power off!\n"); 64 printk(KERN_ERR "PMC Hibernation register could not be remapped, not enabling power off!\n");
64 65 wmt_setup_restart();
65 wm8505_set_resources(); 66 wm8505_set_resources();
66 platform_add_devices(devices, ARRAY_SIZE(devices)); 67 platform_add_devices(devices, ARRAY_SIZE(devices));
67 vt8500_gpio_init(); 68 vt8500_gpio_init();
@@ -69,6 +70,7 @@ void __init wm8505_7in_init(void)
69 70
70MACHINE_START(WM8505_7IN_NETBOOK, "WM8505 7-inch generic netbook") 71MACHINE_START(WM8505_7IN_NETBOOK, "WM8505 7-inch generic netbook")
71 .atag_offset = 0x100, 72 .atag_offset = 0x100,
73 .restart = wmt_restart,
72 .reserve = wm8505_reserve_mem, 74 .reserve = wm8505_reserve_mem,
73 .map_io = wm8505_map_io, 75 .map_io = wm8505_map_io,
74 .init_irq = wm8505_init_irq, 76 .init_irq = wm8505_init_irq,
diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
index 806cc4f6351..119bc52ab93 100644
--- a/arch/arm/mm/context.c
+++ b/arch/arm/mm/context.c
@@ -14,6 +14,7 @@
14#include <linux/percpu.h> 14#include <linux/percpu.h>
15 15
16#include <asm/mmu_context.h> 16#include <asm/mmu_context.h>
17#include <asm/thread_notify.h>
17#include <asm/tlbflush.h> 18#include <asm/tlbflush.h>
18 19
19static DEFINE_RAW_SPINLOCK(cpu_asid_lock); 20static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
@@ -48,6 +49,40 @@ void cpu_set_reserved_ttbr0(void)
48} 49}
49#endif 50#endif
50 51
52#ifdef CONFIG_PID_IN_CONTEXTIDR
53static int contextidr_notifier(struct notifier_block *unused, unsigned long cmd,
54 void *t)
55{
56 u32 contextidr;
57 pid_t pid;
58 struct thread_info *thread = t;
59
60 if (cmd != THREAD_NOTIFY_SWITCH)
61 return NOTIFY_DONE;
62
63 pid = task_pid_nr(thread->task) << ASID_BITS;
64 asm volatile(
65 " mrc p15, 0, %0, c13, c0, 1\n"
66 " bfi %1, %0, #0, %2\n"
67 " mcr p15, 0, %1, c13, c0, 1\n"
68 : "=r" (contextidr), "+r" (pid)
69 : "I" (ASID_BITS));
70 isb();
71
72 return NOTIFY_OK;
73}
74
75static struct notifier_block contextidr_notifier_block = {
76 .notifier_call = contextidr_notifier,
77};
78
79static int __init contextidr_notifier_init(void)
80{
81 return thread_register_notifier(&contextidr_notifier_block);
82}
83arch_initcall(contextidr_notifier_init);
84#endif
85
51/* 86/*
52 * We fork()ed a process, and we need a new context for the child 87 * We fork()ed a process, and we need a new context for the child
53 * to run in. 88 * to run in.
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 655878bcc96..051204fc461 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -22,13 +22,14 @@
22#include <linux/memblock.h> 22#include <linux/memblock.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/iommu.h> 24#include <linux/iommu.h>
25#include <linux/io.h>
25#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
27#include <linux/sizes.h>
26 28
27#include <asm/memory.h> 29#include <asm/memory.h>
28#include <asm/highmem.h> 30#include <asm/highmem.h>
29#include <asm/cacheflush.h> 31#include <asm/cacheflush.h>
30#include <asm/tlbflush.h> 32#include <asm/tlbflush.h>
31#include <asm/sizes.h>
32#include <asm/mach/arch.h> 33#include <asm/mach/arch.h>
33#include <asm/dma-iommu.h> 34#include <asm/dma-iommu.h>
34#include <asm/mach/map.h> 35#include <asm/mach/map.h>
@@ -72,7 +73,7 @@ static dma_addr_t arm_dma_map_page(struct device *dev, struct page *page,
72 unsigned long offset, size_t size, enum dma_data_direction dir, 73 unsigned long offset, size_t size, enum dma_data_direction dir,
73 struct dma_attrs *attrs) 74 struct dma_attrs *attrs)
74{ 75{
75 if (!arch_is_coherent()) 76 if (!arch_is_coherent() && !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
76 __dma_page_cpu_to_dev(page, offset, size, dir); 77 __dma_page_cpu_to_dev(page, offset, size, dir);
77 return pfn_to_dma(dev, page_to_pfn(page)) + offset; 78 return pfn_to_dma(dev, page_to_pfn(page)) + offset;
78} 79}
@@ -95,7 +96,7 @@ static void arm_dma_unmap_page(struct device *dev, dma_addr_t handle,
95 size_t size, enum dma_data_direction dir, 96 size_t size, enum dma_data_direction dir,
96 struct dma_attrs *attrs) 97 struct dma_attrs *attrs)
97{ 98{
98 if (!arch_is_coherent()) 99 if (!arch_is_coherent() && !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
99 __dma_page_dev_to_cpu(pfn_to_page(dma_to_pfn(dev, handle)), 100 __dma_page_dev_to_cpu(pfn_to_page(dma_to_pfn(dev, handle)),
100 handle & ~PAGE_MASK, size, dir); 101 handle & ~PAGE_MASK, size, dir);
101} 102}
@@ -124,6 +125,7 @@ struct dma_map_ops arm_dma_ops = {
124 .alloc = arm_dma_alloc, 125 .alloc = arm_dma_alloc,
125 .free = arm_dma_free, 126 .free = arm_dma_free,
126 .mmap = arm_dma_mmap, 127 .mmap = arm_dma_mmap,
128 .get_sgtable = arm_dma_get_sgtable,
127 .map_page = arm_dma_map_page, 129 .map_page = arm_dma_map_page,
128 .unmap_page = arm_dma_unmap_page, 130 .unmap_page = arm_dma_unmap_page,
129 .map_sg = arm_dma_map_sg, 131 .map_sg = arm_dma_map_sg,
@@ -217,148 +219,144 @@ static void __dma_free_buffer(struct page *page, size_t size)
217} 219}
218 220
219#ifdef CONFIG_MMU 221#ifdef CONFIG_MMU
222#ifdef CONFIG_HUGETLB_PAGE
223#error ARM Coherent DMA allocator does not (yet) support huge TLB
224#endif
220 225
221#define CONSISTENT_OFFSET(x) (((unsigned long)(x) - consistent_base) >> PAGE_SHIFT) 226static void *__alloc_from_contiguous(struct device *dev, size_t size,
222#define CONSISTENT_PTE_INDEX(x) (((unsigned long)(x) - consistent_base) >> PMD_SHIFT) 227 pgprot_t prot, struct page **ret_page);
223
224/*
225 * These are the page tables (2MB each) covering uncached, DMA consistent allocations
226 */
227static pte_t **consistent_pte;
228
229#define DEFAULT_CONSISTENT_DMA_SIZE SZ_2M
230 228
231static unsigned long consistent_base = CONSISTENT_END - DEFAULT_CONSISTENT_DMA_SIZE; 229static void *__alloc_remap_buffer(struct device *dev, size_t size, gfp_t gfp,
230 pgprot_t prot, struct page **ret_page,
231 const void *caller);
232 232
233void __init init_consistent_dma_size(unsigned long size) 233static void *
234__dma_alloc_remap(struct page *page, size_t size, gfp_t gfp, pgprot_t prot,
235 const void *caller)
234{ 236{
235 unsigned long base = CONSISTENT_END - ALIGN(size, SZ_2M); 237 struct vm_struct *area;
238 unsigned long addr;
236 239
237 BUG_ON(consistent_pte); /* Check we're called before DMA region init */ 240 /*
238 BUG_ON(base < VMALLOC_END); 241 * DMA allocation can be mapped to user space, so lets
242 * set VM_USERMAP flags too.
243 */
244 area = get_vm_area_caller(size, VM_ARM_DMA_CONSISTENT | VM_USERMAP,
245 caller);
246 if (!area)
247 return NULL;
248 addr = (unsigned long)area->addr;
249 area->phys_addr = __pfn_to_phys(page_to_pfn(page));
239 250
240 /* Grow region to accommodate specified size */ 251 if (ioremap_page_range(addr, addr + size, area->phys_addr, prot)) {
241 if (base < consistent_base) 252 vunmap((void *)addr);
242 consistent_base = base; 253 return NULL;
254 }
255 return (void *)addr;
243} 256}
244 257
245#include "vmregion.h" 258static void __dma_free_remap(void *cpu_addr, size_t size)
246
247static struct arm_vmregion_head consistent_head = {
248 .vm_lock = __SPIN_LOCK_UNLOCKED(&consistent_head.vm_lock),
249 .vm_list = LIST_HEAD_INIT(consistent_head.vm_list),
250 .vm_end = CONSISTENT_END,
251};
252
253#ifdef CONFIG_HUGETLB_PAGE
254#error ARM Coherent DMA allocator does not (yet) support huge TLB
255#endif
256
257/*
258 * Initialise the consistent memory allocation.
259 */
260static int __init consistent_init(void)
261{ 259{
262 int ret = 0; 260 unsigned int flags = VM_ARM_DMA_CONSISTENT | VM_USERMAP;
263 pgd_t *pgd; 261 struct vm_struct *area = find_vm_area(cpu_addr);
264 pud_t *pud; 262 if (!area || (area->flags & flags) != flags) {
265 pmd_t *pmd; 263 WARN(1, "trying to free invalid coherent area: %p\n", cpu_addr);
266 pte_t *pte; 264 return;
267 int i = 0;
268 unsigned long base = consistent_base;
269 unsigned long num_ptes = (CONSISTENT_END - base) >> PMD_SHIFT;
270
271 if (IS_ENABLED(CONFIG_CMA) && !IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU))
272 return 0;
273
274 consistent_pte = kmalloc(num_ptes * sizeof(pte_t), GFP_KERNEL);
275 if (!consistent_pte) {
276 pr_err("%s: no memory\n", __func__);
277 return -ENOMEM;
278 } 265 }
279 266 unmap_kernel_range((unsigned long)cpu_addr, size);
280 pr_debug("DMA memory: 0x%08lx - 0x%08lx:\n", base, CONSISTENT_END); 267 vunmap(cpu_addr);
281 consistent_head.vm_start = base;
282
283 do {
284 pgd = pgd_offset(&init_mm, base);
285
286 pud = pud_alloc(&init_mm, pgd, base);
287 if (!pud) {
288 pr_err("%s: no pud tables\n", __func__);
289 ret = -ENOMEM;
290 break;
291 }
292
293 pmd = pmd_alloc(&init_mm, pud, base);
294 if (!pmd) {
295 pr_err("%s: no pmd tables\n", __func__);
296 ret = -ENOMEM;
297 break;
298 }
299 WARN_ON(!pmd_none(*pmd));
300
301 pte = pte_alloc_kernel(pmd, base);
302 if (!pte) {
303 pr_err("%s: no pte tables\n", __func__);
304 ret = -ENOMEM;
305 break;
306 }
307
308 consistent_pte[i++] = pte;
309 base += PMD_SIZE;
310 } while (base < CONSISTENT_END);
311
312 return ret;
313} 268}
314core_initcall(consistent_init);
315 269
316static void *__alloc_from_contiguous(struct device *dev, size_t size, 270#define DEFAULT_DMA_COHERENT_POOL_SIZE SZ_256K
317 pgprot_t prot, struct page **ret_page);
318 271
319static struct arm_vmregion_head coherent_head = { 272struct dma_pool {
320 .vm_lock = __SPIN_LOCK_UNLOCKED(&coherent_head.vm_lock), 273 size_t size;
321 .vm_list = LIST_HEAD_INIT(coherent_head.vm_list), 274 spinlock_t lock;
275 unsigned long *bitmap;
276 unsigned long nr_pages;
277 void *vaddr;
278 struct page **pages;
322}; 279};
323 280
324static size_t coherent_pool_size = DEFAULT_CONSISTENT_DMA_SIZE / 8; 281static struct dma_pool atomic_pool = {
282 .size = DEFAULT_DMA_COHERENT_POOL_SIZE,
283};
325 284
326static int __init early_coherent_pool(char *p) 285static int __init early_coherent_pool(char *p)
327{ 286{
328 coherent_pool_size = memparse(p, &p); 287 atomic_pool.size = memparse(p, &p);
329 return 0; 288 return 0;
330} 289}
331early_param("coherent_pool", early_coherent_pool); 290early_param("coherent_pool", early_coherent_pool);
332 291
292void __init init_dma_coherent_pool_size(unsigned long size)
293{
294 /*
295 * Catch any attempt to set the pool size too late.
296 */
297 BUG_ON(atomic_pool.vaddr);
298
299 /*
300 * Set architecture specific coherent pool size only if
301 * it has not been changed by kernel command line parameter.
302 */
303 if (atomic_pool.size == DEFAULT_DMA_COHERENT_POOL_SIZE)
304 atomic_pool.size = size;
305}
306
333/* 307/*
334 * Initialise the coherent pool for atomic allocations. 308 * Initialise the coherent pool for atomic allocations.
335 */ 309 */
336static int __init coherent_init(void) 310static int __init atomic_pool_init(void)
337{ 311{
312 struct dma_pool *pool = &atomic_pool;
338 pgprot_t prot = pgprot_dmacoherent(pgprot_kernel); 313 pgprot_t prot = pgprot_dmacoherent(pgprot_kernel);
339 size_t size = coherent_pool_size; 314 unsigned long nr_pages = pool->size >> PAGE_SHIFT;
315 unsigned long *bitmap;
340 struct page *page; 316 struct page *page;
317 struct page **pages;
341 void *ptr; 318 void *ptr;
319 int bitmap_size = BITS_TO_LONGS(nr_pages) * sizeof(long);
342 320
343 if (!IS_ENABLED(CONFIG_CMA)) 321 bitmap = kzalloc(bitmap_size, GFP_KERNEL);
344 return 0; 322 if (!bitmap)
323 goto no_bitmap;
324
325 pages = kzalloc(nr_pages * sizeof(struct page *), GFP_KERNEL);
326 if (!pages)
327 goto no_pages;
345 328
346 ptr = __alloc_from_contiguous(NULL, size, prot, &page); 329 if (IS_ENABLED(CONFIG_CMA))
330 ptr = __alloc_from_contiguous(NULL, pool->size, prot, &page);
331 else
332 ptr = __alloc_remap_buffer(NULL, pool->size, GFP_KERNEL, prot,
333 &page, NULL);
347 if (ptr) { 334 if (ptr) {
348 coherent_head.vm_start = (unsigned long) ptr; 335 int i;
349 coherent_head.vm_end = (unsigned long) ptr + size; 336
350 printk(KERN_INFO "DMA: preallocated %u KiB pool for atomic coherent allocations\n", 337 for (i = 0; i < nr_pages; i++)
351 (unsigned)size / 1024); 338 pages[i] = page + i;
339
340 spin_lock_init(&pool->lock);
341 pool->vaddr = ptr;
342 pool->pages = pages;
343 pool->bitmap = bitmap;
344 pool->nr_pages = nr_pages;
345 pr_info("DMA: preallocated %u KiB pool for atomic coherent allocations\n",
346 (unsigned)pool->size / 1024);
352 return 0; 347 return 0;
353 } 348 }
354 printk(KERN_ERR "DMA: failed to allocate %u KiB pool for atomic coherent allocation\n", 349no_pages:
355 (unsigned)size / 1024); 350 kfree(bitmap);
351no_bitmap:
352 pr_err("DMA: failed to allocate %u KiB pool for atomic coherent allocation\n",
353 (unsigned)pool->size / 1024);
356 return -ENOMEM; 354 return -ENOMEM;
357} 355}
358/* 356/*
359 * CMA is activated by core_initcall, so we must be called after it. 357 * CMA is activated by core_initcall, so we must be called after it.
360 */ 358 */
361postcore_initcall(coherent_init); 359postcore_initcall(atomic_pool_init);
362 360
363struct dma_contig_early_reserve { 361struct dma_contig_early_reserve {
364 phys_addr_t base; 362 phys_addr_t base;
@@ -388,7 +386,7 @@ void __init dma_contiguous_remap(void)
388 if (end > arm_lowmem_limit) 386 if (end > arm_lowmem_limit)
389 end = arm_lowmem_limit; 387 end = arm_lowmem_limit;
390 if (start >= end) 388 if (start >= end)
391 return; 389 continue;
392 390
393 map.pfn = __phys_to_pfn(start); 391 map.pfn = __phys_to_pfn(start);
394 map.virtual = __phys_to_virt(start); 392 map.virtual = __phys_to_virt(start);
@@ -406,112 +404,6 @@ void __init dma_contiguous_remap(void)
406 } 404 }
407} 405}
408 406
409static void *
410__dma_alloc_remap(struct page *page, size_t size, gfp_t gfp, pgprot_t prot,
411 const void *caller)
412{
413 struct arm_vmregion *c;
414 size_t align;
415 int bit;
416
417 if (!consistent_pte) {
418 pr_err("%s: not initialised\n", __func__);
419 dump_stack();
420 return NULL;
421 }
422
423 /*
424 * Align the virtual region allocation - maximum alignment is
425 * a section size, minimum is a page size. This helps reduce
426 * fragmentation of the DMA space, and also prevents allocations
427 * smaller than a section from crossing a section boundary.
428 */
429 bit = fls(size - 1);
430 if (bit > SECTION_SHIFT)
431 bit = SECTION_SHIFT;
432 align = 1 << bit;
433
434 /*
435 * Allocate a virtual address in the consistent mapping region.
436 */
437 c = arm_vmregion_alloc(&consistent_head, align, size,
438 gfp & ~(__GFP_DMA | __GFP_HIGHMEM), caller);
439 if (c) {
440 pte_t *pte;
441 int idx = CONSISTENT_PTE_INDEX(c->vm_start);
442 u32 off = CONSISTENT_OFFSET(c->vm_start) & (PTRS_PER_PTE-1);
443
444 pte = consistent_pte[idx] + off;
445 c->priv = page;
446
447 do {
448 BUG_ON(!pte_none(*pte));
449
450 set_pte_ext(pte, mk_pte(page, prot), 0);
451 page++;
452 pte++;
453 off++;
454 if (off >= PTRS_PER_PTE) {
455 off = 0;
456 pte = consistent_pte[++idx];
457 }
458 } while (size -= PAGE_SIZE);
459
460 dsb();
461
462 return (void *)c->vm_start;
463 }
464 return NULL;
465}
466
467static void __dma_free_remap(void *cpu_addr, size_t size)
468{
469 struct arm_vmregion *c;
470 unsigned long addr;
471 pte_t *ptep;
472 int idx;
473 u32 off;
474
475 c = arm_vmregion_find_remove(&consistent_head, (unsigned long)cpu_addr);
476 if (!c) {
477 pr_err("%s: trying to free invalid coherent area: %p\n",
478 __func__, cpu_addr);
479 dump_stack();
480 return;
481 }
482
483 if ((c->vm_end - c->vm_start) != size) {
484 pr_err("%s: freeing wrong coherent size (%ld != %d)\n",
485 __func__, c->vm_end - c->vm_start, size);
486 dump_stack();
487 size = c->vm_end - c->vm_start;
488 }
489
490 idx = CONSISTENT_PTE_INDEX(c->vm_start);
491 off = CONSISTENT_OFFSET(c->vm_start) & (PTRS_PER_PTE-1);
492 ptep = consistent_pte[idx] + off;
493 addr = c->vm_start;
494 do {
495 pte_t pte = ptep_get_and_clear(&init_mm, addr, ptep);
496
497 ptep++;
498 addr += PAGE_SIZE;
499 off++;
500 if (off >= PTRS_PER_PTE) {
501 off = 0;
502 ptep = consistent_pte[++idx];
503 }
504
505 if (pte_none(pte) || !pte_present(pte))
506 pr_crit("%s: bad page in kernel page table\n",
507 __func__);
508 } while (size -= PAGE_SIZE);
509
510 flush_tlb_kernel_range(c->vm_start, c->vm_end);
511
512 arm_vmregion_free(&consistent_head, c);
513}
514
515static int __dma_update_pte(pte_t *pte, pgtable_t token, unsigned long addr, 407static int __dma_update_pte(pte_t *pte, pgtable_t token, unsigned long addr,
516 void *data) 408 void *data)
517{ 409{
@@ -552,16 +444,17 @@ static void *__alloc_remap_buffer(struct device *dev, size_t size, gfp_t gfp,
552 return ptr; 444 return ptr;
553} 445}
554 446
555static void *__alloc_from_pool(struct device *dev, size_t size, 447static void *__alloc_from_pool(size_t size, struct page **ret_page)
556 struct page **ret_page, const void *caller)
557{ 448{
558 struct arm_vmregion *c; 449 struct dma_pool *pool = &atomic_pool;
559 size_t align; 450 unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
451 unsigned int pageno;
452 unsigned long flags;
453 void *ptr = NULL;
454 unsigned long align_mask;
560 455
561 if (!coherent_head.vm_start) { 456 if (!pool->vaddr) {
562 printk(KERN_ERR "%s: coherent pool not initialised!\n", 457 WARN(1, "coherent pool not initialised!\n");
563 __func__);
564 dump_stack();
565 return NULL; 458 return NULL;
566 } 459 }
567 460
@@ -570,36 +463,60 @@ static void *__alloc_from_pool(struct device *dev, size_t size,
570 * small, so align them to their order in pages, minimum is a page 463 * small, so align them to their order in pages, minimum is a page
571 * size. This helps reduce fragmentation of the DMA space. 464 * size. This helps reduce fragmentation of the DMA space.
572 */ 465 */
573 align = PAGE_SIZE << get_order(size); 466 align_mask = (1 << get_order(size)) - 1;
574 c = arm_vmregion_alloc(&coherent_head, align, size, 0, caller); 467
575 if (c) { 468 spin_lock_irqsave(&pool->lock, flags);
576 void *ptr = (void *)c->vm_start; 469 pageno = bitmap_find_next_zero_area(pool->bitmap, pool->nr_pages,
577 struct page *page = virt_to_page(ptr); 470 0, count, align_mask);
578 *ret_page = page; 471 if (pageno < pool->nr_pages) {
579 return ptr; 472 bitmap_set(pool->bitmap, pageno, count);
473 ptr = pool->vaddr + PAGE_SIZE * pageno;
474 *ret_page = pool->pages[pageno];
475 } else {
476 pr_err_once("ERROR: %u KiB atomic DMA coherent pool is too small!\n"
477 "Please increase it with coherent_pool= kernel parameter!\n",
478 (unsigned)pool->size / 1024);
580 } 479 }
581 return NULL; 480 spin_unlock_irqrestore(&pool->lock, flags);
481
482 return ptr;
483}
484
485static bool __in_atomic_pool(void *start, size_t size)
486{
487 struct dma_pool *pool = &atomic_pool;
488 void *end = start + size;
489 void *pool_start = pool->vaddr;
490 void *pool_end = pool->vaddr + pool->size;
491
492 if (start < pool_start || start > pool_end)
493 return false;
494
495 if (end <= pool_end)
496 return true;
497
498 WARN(1, "Wrong coherent size(%p-%p) from atomic pool(%p-%p)\n",
499 start, end - 1, pool_start, pool_end - 1);
500
501 return false;
582} 502}
583 503
584static int __free_from_pool(void *cpu_addr, size_t size) 504static int __free_from_pool(void *start, size_t size)
585{ 505{
586 unsigned long start = (unsigned long)cpu_addr; 506 struct dma_pool *pool = &atomic_pool;
587 unsigned long end = start + size; 507 unsigned long pageno, count;
588 struct arm_vmregion *c; 508 unsigned long flags;
589 509
590 if (start < coherent_head.vm_start || end > coherent_head.vm_end) 510 if (!__in_atomic_pool(start, size))
591 return 0; 511 return 0;
592 512
593 c = arm_vmregion_find_remove(&coherent_head, (unsigned long)start); 513 pageno = (start - pool->vaddr) >> PAGE_SHIFT;
514 count = size >> PAGE_SHIFT;
594 515
595 if ((c->vm_end - c->vm_start) != size) { 516 spin_lock_irqsave(&pool->lock, flags);
596 printk(KERN_ERR "%s: freeing wrong coherent size (%ld != %d)\n", 517 bitmap_clear(pool->bitmap, pageno, count);
597 __func__, c->vm_end - c->vm_start, size); 518 spin_unlock_irqrestore(&pool->lock, flags);
598 dump_stack();
599 size = c->vm_end - c->vm_start;
600 }
601 519
602 arm_vmregion_free(&coherent_head, c);
603 return 1; 520 return 1;
604} 521}
605 522
@@ -644,7 +561,7 @@ static inline pgprot_t __get_dma_pgprot(struct dma_attrs *attrs, pgprot_t prot)
644 561
645#define __get_dma_pgprot(attrs, prot) __pgprot(0) 562#define __get_dma_pgprot(attrs, prot) __pgprot(0)
646#define __alloc_remap_buffer(dev, size, gfp, prot, ret, c) NULL 563#define __alloc_remap_buffer(dev, size, gfp, prot, ret, c) NULL
647#define __alloc_from_pool(dev, size, ret_page, c) NULL 564#define __alloc_from_pool(size, ret_page) NULL
648#define __alloc_from_contiguous(dev, size, prot, ret) NULL 565#define __alloc_from_contiguous(dev, size, prot, ret) NULL
649#define __free_from_pool(cpu_addr, size) 0 566#define __free_from_pool(cpu_addr, size) 0
650#define __free_from_contiguous(dev, page, size) do { } while (0) 567#define __free_from_contiguous(dev, page, size) do { } while (0)
@@ -702,10 +619,10 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
702 619
703 if (arch_is_coherent() || nommu()) 620 if (arch_is_coherent() || nommu())
704 addr = __alloc_simple_buffer(dev, size, gfp, &page); 621 addr = __alloc_simple_buffer(dev, size, gfp, &page);
622 else if (gfp & GFP_ATOMIC)
623 addr = __alloc_from_pool(size, &page);
705 else if (!IS_ENABLED(CONFIG_CMA)) 624 else if (!IS_ENABLED(CONFIG_CMA))
706 addr = __alloc_remap_buffer(dev, size, gfp, prot, &page, caller); 625 addr = __alloc_remap_buffer(dev, size, gfp, prot, &page, caller);
707 else if (gfp & GFP_ATOMIC)
708 addr = __alloc_from_pool(dev, size, &page, caller);
709 else 626 else
710 addr = __alloc_from_contiguous(dev, size, prot, &page); 627 addr = __alloc_from_contiguous(dev, size, prot, &page);
711 628
@@ -741,16 +658,22 @@ int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma,
741{ 658{
742 int ret = -ENXIO; 659 int ret = -ENXIO;
743#ifdef CONFIG_MMU 660#ifdef CONFIG_MMU
661 unsigned long nr_vma_pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
662 unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
744 unsigned long pfn = dma_to_pfn(dev, dma_addr); 663 unsigned long pfn = dma_to_pfn(dev, dma_addr);
664 unsigned long off = vma->vm_pgoff;
665
745 vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot); 666 vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot);
746 667
747 if (dma_mmap_from_coherent(dev, vma, cpu_addr, size, &ret)) 668 if (dma_mmap_from_coherent(dev, vma, cpu_addr, size, &ret))
748 return ret; 669 return ret;
749 670
750 ret = remap_pfn_range(vma, vma->vm_start, 671 if (off < nr_pages && nr_vma_pages <= (nr_pages - off)) {
751 pfn + vma->vm_pgoff, 672 ret = remap_pfn_range(vma, vma->vm_start,
752 vma->vm_end - vma->vm_start, 673 pfn + off,
753 vma->vm_page_prot); 674 vma->vm_end - vma->vm_start,
675 vma->vm_page_prot);
676 }
754#endif /* CONFIG_MMU */ 677#endif /* CONFIG_MMU */
755 678
756 return ret; 679 return ret;
@@ -771,12 +694,12 @@ void arm_dma_free(struct device *dev, size_t size, void *cpu_addr,
771 694
772 if (arch_is_coherent() || nommu()) { 695 if (arch_is_coherent() || nommu()) {
773 __dma_free_buffer(page, size); 696 __dma_free_buffer(page, size);
697 } else if (__free_from_pool(cpu_addr, size)) {
698 return;
774 } else if (!IS_ENABLED(CONFIG_CMA)) { 699 } else if (!IS_ENABLED(CONFIG_CMA)) {
775 __dma_free_remap(cpu_addr, size); 700 __dma_free_remap(cpu_addr, size);
776 __dma_free_buffer(page, size); 701 __dma_free_buffer(page, size);
777 } else { 702 } else {
778 if (__free_from_pool(cpu_addr, size))
779 return;
780 /* 703 /*
781 * Non-atomic allocations cannot be freed with IRQs disabled 704 * Non-atomic allocations cannot be freed with IRQs disabled
782 */ 705 */
@@ -785,6 +708,21 @@ void arm_dma_free(struct device *dev, size_t size, void *cpu_addr,
785 } 708 }
786} 709}
787 710
711int arm_dma_get_sgtable(struct device *dev, struct sg_table *sgt,
712 void *cpu_addr, dma_addr_t handle, size_t size,
713 struct dma_attrs *attrs)
714{
715 struct page *page = pfn_to_page(dma_to_pfn(dev, handle));
716 int ret;
717
718 ret = sg_alloc_table(sgt, 1, GFP_KERNEL);
719 if (unlikely(ret))
720 return ret;
721
722 sg_set_page(sgt->sgl, page, PAGE_ALIGN(size), 0);
723 return 0;
724}
725
788static void dma_cache_maint_page(struct page *page, unsigned long offset, 726static void dma_cache_maint_page(struct page *page, unsigned long offset,
789 size_t size, enum dma_data_direction dir, 727 size_t size, enum dma_data_direction dir,
790 void (*op)(const void *, size_t, int)) 728 void (*op)(const void *, size_t, int))
@@ -998,9 +936,6 @@ static int arm_dma_set_mask(struct device *dev, u64 dma_mask)
998 936
999static int __init dma_debug_do_init(void) 937static int __init dma_debug_do_init(void)
1000{ 938{
1001#ifdef CONFIG_MMU
1002 arm_vmregion_create_proc("dma-mappings", &consistent_head);
1003#endif
1004 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES); 939 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
1005 return 0; 940 return 0;
1006} 941}
@@ -1088,7 +1023,7 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size, gfp_t
1088 1023
1089 return pages; 1024 return pages;
1090error: 1025error:
1091 while (--i) 1026 while (i--)
1092 if (pages[i]) 1027 if (pages[i])
1093 __free_pages(pages[i], 0); 1028 __free_pages(pages[i], 0);
1094 if (array_size <= PAGE_SIZE) 1029 if (array_size <= PAGE_SIZE)
@@ -1117,61 +1052,32 @@ static int __iommu_free_buffer(struct device *dev, struct page **pages, size_t s
1117 * Create a CPU mapping for a specified pages 1052 * Create a CPU mapping for a specified pages
1118 */ 1053 */
1119static void * 1054static void *
1120__iommu_alloc_remap(struct page **pages, size_t size, gfp_t gfp, pgprot_t prot) 1055__iommu_alloc_remap(struct page **pages, size_t size, gfp_t gfp, pgprot_t prot,
1056 const void *caller)
1121{ 1057{
1122 struct arm_vmregion *c; 1058 unsigned int i, nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
1123 size_t align; 1059 struct vm_struct *area;
1124 size_t count = size >> PAGE_SHIFT; 1060 unsigned long p;
1125 int bit;
1126 1061
1127 if (!consistent_pte[0]) { 1062 area = get_vm_area_caller(size, VM_ARM_DMA_CONSISTENT | VM_USERMAP,
1128 pr_err("%s: not initialised\n", __func__); 1063 caller);
1129 dump_stack(); 1064 if (!area)
1130 return NULL; 1065 return NULL;
1131 }
1132 1066
1133 /* 1067 area->pages = pages;
1134 * Align the virtual region allocation - maximum alignment is 1068 area->nr_pages = nr_pages;
1135 * a section size, minimum is a page size. This helps reduce 1069 p = (unsigned long)area->addr;
1136 * fragmentation of the DMA space, and also prevents allocations
1137 * smaller than a section from crossing a section boundary.
1138 */
1139 bit = fls(size - 1);
1140 if (bit > SECTION_SHIFT)
1141 bit = SECTION_SHIFT;
1142 align = 1 << bit;
1143 1070
1144 /* 1071 for (i = 0; i < nr_pages; i++) {
1145 * Allocate a virtual address in the consistent mapping region. 1072 phys_addr_t phys = __pfn_to_phys(page_to_pfn(pages[i]));
1146 */ 1073 if (ioremap_page_range(p, p + PAGE_SIZE, phys, prot))
1147 c = arm_vmregion_alloc(&consistent_head, align, size, 1074 goto err;
1148 gfp & ~(__GFP_DMA | __GFP_HIGHMEM), NULL); 1075 p += PAGE_SIZE;
1149 if (c) {
1150 pte_t *pte;
1151 int idx = CONSISTENT_PTE_INDEX(c->vm_start);
1152 int i = 0;
1153 u32 off = CONSISTENT_OFFSET(c->vm_start) & (PTRS_PER_PTE-1);
1154
1155 pte = consistent_pte[idx] + off;
1156 c->priv = pages;
1157
1158 do {
1159 BUG_ON(!pte_none(*pte));
1160
1161 set_pte_ext(pte, mk_pte(pages[i], prot), 0);
1162 pte++;
1163 off++;
1164 i++;
1165 if (off >= PTRS_PER_PTE) {
1166 off = 0;
1167 pte = consistent_pte[++idx];
1168 }
1169 } while (i < count);
1170
1171 dsb();
1172
1173 return (void *)c->vm_start;
1174 } 1076 }
1077 return area->addr;
1078err:
1079 unmap_kernel_range((unsigned long)area->addr, size);
1080 vunmap(area->addr);
1175 return NULL; 1081 return NULL;
1176} 1082}
1177 1083
@@ -1230,6 +1136,59 @@ static int __iommu_remove_mapping(struct device *dev, dma_addr_t iova, size_t si
1230 return 0; 1136 return 0;
1231} 1137}
1232 1138
1139static struct page **__atomic_get_pages(void *addr)
1140{
1141 struct dma_pool *pool = &atomic_pool;
1142 struct page **pages = pool->pages;
1143 int offs = (addr - pool->vaddr) >> PAGE_SHIFT;
1144
1145 return pages + offs;
1146}
1147
1148static struct page **__iommu_get_pages(void *cpu_addr, struct dma_attrs *attrs)
1149{
1150 struct vm_struct *area;
1151
1152 if (__in_atomic_pool(cpu_addr, PAGE_SIZE))
1153 return __atomic_get_pages(cpu_addr);
1154
1155 if (dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, attrs))
1156 return cpu_addr;
1157
1158 area = find_vm_area(cpu_addr);
1159 if (area && (area->flags & VM_ARM_DMA_CONSISTENT))
1160 return area->pages;
1161 return NULL;
1162}
1163
1164static void *__iommu_alloc_atomic(struct device *dev, size_t size,
1165 dma_addr_t *handle)
1166{
1167 struct page *page;
1168 void *addr;
1169
1170 addr = __alloc_from_pool(size, &page);
1171 if (!addr)
1172 return NULL;
1173
1174 *handle = __iommu_create_mapping(dev, &page, size);
1175 if (*handle == DMA_ERROR_CODE)
1176 goto err_mapping;
1177
1178 return addr;
1179
1180err_mapping:
1181 __free_from_pool(addr, size);
1182 return NULL;
1183}
1184
1185static void __iommu_free_atomic(struct device *dev, struct page **pages,
1186 dma_addr_t handle, size_t size)
1187{
1188 __iommu_remove_mapping(dev, handle, size);
1189 __free_from_pool(page_address(pages[0]), size);
1190}
1191
1233static void *arm_iommu_alloc_attrs(struct device *dev, size_t size, 1192static void *arm_iommu_alloc_attrs(struct device *dev, size_t size,
1234 dma_addr_t *handle, gfp_t gfp, struct dma_attrs *attrs) 1193 dma_addr_t *handle, gfp_t gfp, struct dma_attrs *attrs)
1235{ 1194{
@@ -1240,6 +1199,9 @@ static void *arm_iommu_alloc_attrs(struct device *dev, size_t size,
1240 *handle = DMA_ERROR_CODE; 1199 *handle = DMA_ERROR_CODE;
1241 size = PAGE_ALIGN(size); 1200 size = PAGE_ALIGN(size);
1242 1201
1202 if (gfp & GFP_ATOMIC)
1203 return __iommu_alloc_atomic(dev, size, handle);
1204
1243 pages = __iommu_alloc_buffer(dev, size, gfp); 1205 pages = __iommu_alloc_buffer(dev, size, gfp);
1244 if (!pages) 1206 if (!pages)
1245 return NULL; 1207 return NULL;
@@ -1248,7 +1210,11 @@ static void *arm_iommu_alloc_attrs(struct device *dev, size_t size,
1248 if (*handle == DMA_ERROR_CODE) 1210 if (*handle == DMA_ERROR_CODE)
1249 goto err_buffer; 1211 goto err_buffer;
1250 1212
1251 addr = __iommu_alloc_remap(pages, size, gfp, prot); 1213 if (dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, attrs))
1214 return pages;
1215
1216 addr = __iommu_alloc_remap(pages, size, gfp, prot,
1217 __builtin_return_address(0));
1252 if (!addr) 1218 if (!addr)
1253 goto err_mapping; 1219 goto err_mapping;
1254 1220
@@ -1265,31 +1231,25 @@ static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
1265 void *cpu_addr, dma_addr_t dma_addr, size_t size, 1231 void *cpu_addr, dma_addr_t dma_addr, size_t size,
1266 struct dma_attrs *attrs) 1232 struct dma_attrs *attrs)
1267{ 1233{
1268 struct arm_vmregion *c; 1234 unsigned long uaddr = vma->vm_start;
1235 unsigned long usize = vma->vm_end - vma->vm_start;
1236 struct page **pages = __iommu_get_pages(cpu_addr, attrs);
1269 1237
1270 vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot); 1238 vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot);
1271 c = arm_vmregion_find(&consistent_head, (unsigned long)cpu_addr);
1272
1273 if (c) {
1274 struct page **pages = c->priv;
1275
1276 unsigned long uaddr = vma->vm_start;
1277 unsigned long usize = vma->vm_end - vma->vm_start;
1278 int i = 0;
1279 1239
1280 do { 1240 if (!pages)
1281 int ret; 1241 return -ENXIO;
1282 1242
1283 ret = vm_insert_page(vma, uaddr, pages[i++]); 1243 do {
1284 if (ret) { 1244 int ret = vm_insert_page(vma, uaddr, *pages++);
1285 pr_err("Remapping memory, error: %d\n", ret); 1245 if (ret) {
1286 return ret; 1246 pr_err("Remapping memory failed: %d\n", ret);
1287 } 1247 return ret;
1248 }
1249 uaddr += PAGE_SIZE;
1250 usize -= PAGE_SIZE;
1251 } while (usize > 0);
1288 1252
1289 uaddr += PAGE_SIZE;
1290 usize -= PAGE_SIZE;
1291 } while (usize > 0);
1292 }
1293 return 0; 1253 return 0;
1294} 1254}
1295 1255
@@ -1300,16 +1260,40 @@ static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
1300void arm_iommu_free_attrs(struct device *dev, size_t size, void *cpu_addr, 1260void arm_iommu_free_attrs(struct device *dev, size_t size, void *cpu_addr,
1301 dma_addr_t handle, struct dma_attrs *attrs) 1261 dma_addr_t handle, struct dma_attrs *attrs)
1302{ 1262{
1303 struct arm_vmregion *c; 1263 struct page **pages = __iommu_get_pages(cpu_addr, attrs);
1304 size = PAGE_ALIGN(size); 1264 size = PAGE_ALIGN(size);
1305 1265
1306 c = arm_vmregion_find(&consistent_head, (unsigned long)cpu_addr); 1266 if (!pages) {
1307 if (c) { 1267 WARN(1, "trying to free invalid coherent area: %p\n", cpu_addr);
1308 struct page **pages = c->priv; 1268 return;
1309 __dma_free_remap(cpu_addr, size);
1310 __iommu_remove_mapping(dev, handle, size);
1311 __iommu_free_buffer(dev, pages, size);
1312 } 1269 }
1270
1271 if (__in_atomic_pool(cpu_addr, size)) {
1272 __iommu_free_atomic(dev, pages, handle, size);
1273 return;
1274 }
1275
1276 if (!dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, attrs)) {
1277 unmap_kernel_range((unsigned long)cpu_addr, size);
1278 vunmap(cpu_addr);
1279 }
1280
1281 __iommu_remove_mapping(dev, handle, size);
1282 __iommu_free_buffer(dev, pages, size);
1283}
1284
1285static int arm_iommu_get_sgtable(struct device *dev, struct sg_table *sgt,
1286 void *cpu_addr, dma_addr_t dma_addr,
1287 size_t size, struct dma_attrs *attrs)
1288{
1289 unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
1290 struct page **pages = __iommu_get_pages(cpu_addr, attrs);
1291
1292 if (!pages)
1293 return -ENXIO;
1294
1295 return sg_alloc_table_from_pages(sgt, pages, count, 0, size,
1296 GFP_KERNEL);
1313} 1297}
1314 1298
1315/* 1299/*
@@ -1317,7 +1301,7 @@ void arm_iommu_free_attrs(struct device *dev, size_t size, void *cpu_addr,
1317 */ 1301 */
1318static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, 1302static int __map_sg_chunk(struct device *dev, struct scatterlist *sg,
1319 size_t size, dma_addr_t *handle, 1303 size_t size, dma_addr_t *handle,
1320 enum dma_data_direction dir) 1304 enum dma_data_direction dir, struct dma_attrs *attrs)
1321{ 1305{
1322 struct dma_iommu_mapping *mapping = dev->archdata.mapping; 1306 struct dma_iommu_mapping *mapping = dev->archdata.mapping;
1323 dma_addr_t iova, iova_base; 1307 dma_addr_t iova, iova_base;
@@ -1336,7 +1320,8 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg,
1336 phys_addr_t phys = page_to_phys(sg_page(s)); 1320 phys_addr_t phys = page_to_phys(sg_page(s));
1337 unsigned int len = PAGE_ALIGN(s->offset + s->length); 1321 unsigned int len = PAGE_ALIGN(s->offset + s->length);
1338 1322
1339 if (!arch_is_coherent()) 1323 if (!arch_is_coherent() &&
1324 !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
1340 __dma_page_cpu_to_dev(sg_page(s), s->offset, s->length, dir); 1325 __dma_page_cpu_to_dev(sg_page(s), s->offset, s->length, dir);
1341 1326
1342 ret = iommu_map(mapping->domain, iova, phys, len, 0); 1327 ret = iommu_map(mapping->domain, iova, phys, len, 0);
@@ -1383,7 +1368,7 @@ int arm_iommu_map_sg(struct device *dev, struct scatterlist *sg, int nents,
1383 1368
1384 if (s->offset || (size & ~PAGE_MASK) || size + s->length > max) { 1369 if (s->offset || (size & ~PAGE_MASK) || size + s->length > max) {
1385 if (__map_sg_chunk(dev, start, size, &dma->dma_address, 1370 if (__map_sg_chunk(dev, start, size, &dma->dma_address,
1386 dir) < 0) 1371 dir, attrs) < 0)
1387 goto bad_mapping; 1372 goto bad_mapping;
1388 1373
1389 dma->dma_address += offset; 1374 dma->dma_address += offset;
@@ -1396,7 +1381,7 @@ int arm_iommu_map_sg(struct device *dev, struct scatterlist *sg, int nents,
1396 } 1381 }
1397 size += s->length; 1382 size += s->length;
1398 } 1383 }
1399 if (__map_sg_chunk(dev, start, size, &dma->dma_address, dir) < 0) 1384 if (__map_sg_chunk(dev, start, size, &dma->dma_address, dir, attrs) < 0)
1400 goto bad_mapping; 1385 goto bad_mapping;
1401 1386
1402 dma->dma_address += offset; 1387 dma->dma_address += offset;
@@ -1430,7 +1415,8 @@ void arm_iommu_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
1430 if (sg_dma_len(s)) 1415 if (sg_dma_len(s))
1431 __iommu_remove_mapping(dev, sg_dma_address(s), 1416 __iommu_remove_mapping(dev, sg_dma_address(s),
1432 sg_dma_len(s)); 1417 sg_dma_len(s));
1433 if (!arch_is_coherent()) 1418 if (!arch_is_coherent() &&
1419 !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
1434 __dma_page_dev_to_cpu(sg_page(s), s->offset, 1420 __dma_page_dev_to_cpu(sg_page(s), s->offset,
1435 s->length, dir); 1421 s->length, dir);
1436 } 1422 }
@@ -1492,7 +1478,7 @@ static dma_addr_t arm_iommu_map_page(struct device *dev, struct page *page,
1492 dma_addr_t dma_addr; 1478 dma_addr_t dma_addr;
1493 int ret, len = PAGE_ALIGN(size + offset); 1479 int ret, len = PAGE_ALIGN(size + offset);
1494 1480
1495 if (!arch_is_coherent()) 1481 if (!arch_is_coherent() && !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
1496 __dma_page_cpu_to_dev(page, offset, size, dir); 1482 __dma_page_cpu_to_dev(page, offset, size, dir);
1497 1483
1498 dma_addr = __alloc_iova(mapping, len); 1484 dma_addr = __alloc_iova(mapping, len);
@@ -1531,7 +1517,7 @@ static void arm_iommu_unmap_page(struct device *dev, dma_addr_t handle,
1531 if (!iova) 1517 if (!iova)
1532 return; 1518 return;
1533 1519
1534 if (!arch_is_coherent()) 1520 if (!arch_is_coherent() && !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
1535 __dma_page_dev_to_cpu(page, offset, size, dir); 1521 __dma_page_dev_to_cpu(page, offset, size, dir);
1536 1522
1537 iommu_unmap(mapping->domain, iova, len); 1523 iommu_unmap(mapping->domain, iova, len);
@@ -1571,6 +1557,7 @@ struct dma_map_ops iommu_ops = {
1571 .alloc = arm_iommu_alloc_attrs, 1557 .alloc = arm_iommu_alloc_attrs,
1572 .free = arm_iommu_free_attrs, 1558 .free = arm_iommu_free_attrs,
1573 .mmap = arm_iommu_mmap_attrs, 1559 .mmap = arm_iommu_mmap_attrs,
1560 .get_sgtable = arm_iommu_get_sgtable,
1574 1561
1575 .map_page = arm_iommu_map_page, 1562 .map_page = arm_iommu_map_page,
1576 .unmap_page = arm_iommu_unmap_page, 1563 .unmap_page = arm_iommu_unmap_page,
diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c
index 77458548e03..40ca11ed6e5 100644
--- a/arch/arm/mm/flush.c
+++ b/arch/arm/mm/flush.c
@@ -231,8 +231,6 @@ void __sync_icache_dcache(pte_t pteval)
231 struct page *page; 231 struct page *page;
232 struct address_space *mapping; 232 struct address_space *mapping;
233 233
234 if (!pte_present_user(pteval))
235 return;
236 if (cache_is_vipt_nonaliasing() && !pte_exec(pteval)) 234 if (cache_is_vipt_nonaliasing() && !pte_exec(pteval))
237 /* only flush non-aliasing VIPT caches for exec mappings */ 235 /* only flush non-aliasing VIPT caches for exec mappings */
238 return; 236 return;
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index f54d5921976..9aec41fa80a 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -21,13 +21,13 @@
21#include <linux/gfp.h> 21#include <linux/gfp.h>
22#include <linux/memblock.h> 22#include <linux/memblock.h>
23#include <linux/dma-contiguous.h> 23#include <linux/dma-contiguous.h>
24#include <linux/sizes.h>
24 25
25#include <asm/mach-types.h> 26#include <asm/mach-types.h>
26#include <asm/memblock.h> 27#include <asm/memblock.h>
27#include <asm/prom.h> 28#include <asm/prom.h>
28#include <asm/sections.h> 29#include <asm/sections.h>
29#include <asm/setup.h> 30#include <asm/setup.h>
30#include <asm/sizes.h>
31#include <asm/tlb.h> 31#include <asm/tlb.h>
32#include <asm/fixmap.h> 32#include <asm/fixmap.h>
33 33
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index 4f55f5062ab..566750fa57d 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -25,6 +25,7 @@
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
27#include <linux/io.h> 27#include <linux/io.h>
28#include <linux/sizes.h>
28 29
29#include <asm/cp15.h> 30#include <asm/cp15.h>
30#include <asm/cputype.h> 31#include <asm/cputype.h>
@@ -32,7 +33,6 @@
32#include <asm/mmu_context.h> 33#include <asm/mmu_context.h>
33#include <asm/pgalloc.h> 34#include <asm/pgalloc.h>
34#include <asm/tlbflush.h> 35#include <asm/tlbflush.h>
35#include <asm/sizes.h>
36#include <asm/system_info.h> 36#include <asm/system_info.h>
37 37
38#include <asm/mach/map.h> 38#include <asm/mach/map.h>
diff --git a/arch/arm/mm/mm.h b/arch/arm/mm/mm.h
index 2e8a1efdf7b..6776160618e 100644
--- a/arch/arm/mm/mm.h
+++ b/arch/arm/mm/mm.h
@@ -59,6 +59,9 @@ extern void __flush_dcache_page(struct address_space *mapping, struct page *page
59#define VM_ARM_MTYPE(mt) ((mt) << 20) 59#define VM_ARM_MTYPE(mt) ((mt) << 20)
60#define VM_ARM_MTYPE_MASK (0x1f << 20) 60#define VM_ARM_MTYPE_MASK (0x1f << 20)
61 61
62/* consistent regions used by dma_alloc_attrs() */
63#define VM_ARM_DMA_CONSISTENT 0x20000000
64
62#endif 65#endif
63 66
64#ifdef CONFIG_ZONE_DMA 67#ifdef CONFIG_ZONE_DMA
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index cf4528d5177..4c2d0451e84 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -16,13 +16,13 @@
16#include <linux/memblock.h> 16#include <linux/memblock.h>
17#include <linux/fs.h> 17#include <linux/fs.h>
18#include <linux/vmalloc.h> 18#include <linux/vmalloc.h>
19#include <linux/sizes.h>
19 20
20#include <asm/cp15.h> 21#include <asm/cp15.h>
21#include <asm/cputype.h> 22#include <asm/cputype.h>
22#include <asm/sections.h> 23#include <asm/sections.h>
23#include <asm/cachetype.h> 24#include <asm/cachetype.h>
24#include <asm/setup.h> 25#include <asm/setup.h>
25#include <asm/sizes.h>
26#include <asm/smp_plat.h> 26#include <asm/smp_plat.h>
27#include <asm/tlb.h> 27#include <asm/tlb.h>
28#include <asm/highmem.h> 28#include <asm/highmem.h>
@@ -422,12 +422,6 @@ static void __init build_mem_type_table(void)
422 vecs_pgprot = kern_pgprot = user_pgprot = cp->pte; 422 vecs_pgprot = kern_pgprot = user_pgprot = cp->pte;
423 423
424 /* 424 /*
425 * Only use write-through for non-SMP systems
426 */
427 if (!is_smp() && cpu_arch >= CPU_ARCH_ARMv5 && cachepolicy > CPOLICY_WRITETHROUGH)
428 vecs_pgprot = cache_policies[CPOLICY_WRITETHROUGH].pte;
429
430 /*
431 * Enable CPU-specific coherency if supported. 425 * Enable CPU-specific coherency if supported.
432 * (Only available on XSC3 at the moment.) 426 * (Only available on XSC3 at the moment.)
433 */ 427 */
diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S
index 5900cd520e8..86b8b480634 100644
--- a/arch/arm/mm/proc-v6.S
+++ b/arch/arm/mm/proc-v6.S
@@ -107,6 +107,12 @@ ENTRY(cpu_v6_switch_mm)
107 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB 107 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB
108 mcr p15, 0, r2, c7, c10, 4 @ drain write buffer 108 mcr p15, 0, r2, c7, c10, 4 @ drain write buffer
109 mcr p15, 0, r0, c2, c0, 0 @ set TTB 0 109 mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
110#ifdef CONFIG_PID_IN_CONTEXTIDR
111 mrc p15, 0, r2, c13, c0, 1 @ read current context ID
112 bic r2, r2, #0xff @ extract the PID
113 and r1, r1, #0xff
114 orr r1, r1, r2 @ insert into new context ID
115#endif
110 mcr p15, 0, r1, c13, c0, 1 @ set context ID 116 mcr p15, 0, r1, c13, c0, 1 @ set context ID
111#endif 117#endif
112 mov pc, lr 118 mov pc, lr
diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
index 42ac069c801..fd045e70639 100644
--- a/arch/arm/mm/proc-v7-2level.S
+++ b/arch/arm/mm/proc-v7-2level.S
@@ -46,6 +46,11 @@ ENTRY(cpu_v7_switch_mm)
46#ifdef CONFIG_ARM_ERRATA_430973 46#ifdef CONFIG_ARM_ERRATA_430973
47 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB 47 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB
48#endif 48#endif
49#ifdef CONFIG_PID_IN_CONTEXTIDR
50 mrc p15, 0, r2, c13, c0, 1 @ read current context ID
51 lsr r2, r2, #8 @ extract the PID
52 bfi r1, r2, #8, #24 @ insert into new context ID
53#endif
49#ifdef CONFIG_ARM_ERRATA_754322 54#ifdef CONFIG_ARM_ERRATA_754322
50 dsb 55 dsb
51#endif 56#endif
diff --git a/arch/arm/mm/tlb-v7.S b/arch/arm/mm/tlb-v7.S
index 845f461f8ec..ea94765acf9 100644
--- a/arch/arm/mm/tlb-v7.S
+++ b/arch/arm/mm/tlb-v7.S
@@ -39,10 +39,18 @@ ENTRY(v7wbi_flush_user_tlb_range)
39 mov r0, r0, lsr #PAGE_SHIFT @ align address 39 mov r0, r0, lsr #PAGE_SHIFT @ align address
40 mov r1, r1, lsr #PAGE_SHIFT 40 mov r1, r1, lsr #PAGE_SHIFT
41 asid r3, r3 @ mask ASID 41 asid r3, r3 @ mask ASID
42#ifdef CONFIG_ARM_ERRATA_720789
43 ALT_SMP(W(mov) r3, #0 )
44 ALT_UP(W(nop) )
45#endif
42 orr r0, r3, r0, lsl #PAGE_SHIFT @ Create initial MVA 46 orr r0, r3, r0, lsl #PAGE_SHIFT @ Create initial MVA
43 mov r1, r1, lsl #PAGE_SHIFT 47 mov r1, r1, lsl #PAGE_SHIFT
441: 481:
49#ifdef CONFIG_ARM_ERRATA_720789
50 ALT_SMP(mcr p15, 0, r0, c8, c3, 3) @ TLB invalidate U MVA all ASID (shareable)
51#else
45 ALT_SMP(mcr p15, 0, r0, c8, c3, 1) @ TLB invalidate U MVA (shareable) 52 ALT_SMP(mcr p15, 0, r0, c8, c3, 1) @ TLB invalidate U MVA (shareable)
53#endif
46 ALT_UP(mcr p15, 0, r0, c8, c7, 1) @ TLB invalidate U MVA 54 ALT_UP(mcr p15, 0, r0, c8, c7, 1) @ TLB invalidate U MVA
47 55
48 add r0, r0, #PAGE_SZ 56 add r0, r0, #PAGE_SZ
@@ -67,7 +75,11 @@ ENTRY(v7wbi_flush_kern_tlb_range)
67 mov r0, r0, lsl #PAGE_SHIFT 75 mov r0, r0, lsl #PAGE_SHIFT
68 mov r1, r1, lsl #PAGE_SHIFT 76 mov r1, r1, lsl #PAGE_SHIFT
691: 771:
78#ifdef CONFIG_ARM_ERRATA_720789
79 ALT_SMP(mcr p15, 0, r0, c8, c3, 3) @ TLB invalidate U MVA all ASID (shareable)
80#else
70 ALT_SMP(mcr p15, 0, r0, c8, c3, 1) @ TLB invalidate U MVA (shareable) 81 ALT_SMP(mcr p15, 0, r0, c8, c3, 1) @ TLB invalidate U MVA (shareable)
82#endif
71 ALT_UP(mcr p15, 0, r0, c8, c7, 1) @ TLB invalidate U MVA 83 ALT_UP(mcr p15, 0, r0, c8, c7, 1) @ TLB invalidate U MVA
72 add r0, r0, #PAGE_SZ 84 add r0, r0, #PAGE_SZ
73 cmp r0, r1 85 cmp r0, r1
diff --git a/arch/arm/oprofile/common.c b/arch/arm/oprofile/common.c
index 4e0a371630b..99c63d4b6af 100644
--- a/arch/arm/oprofile/common.c
+++ b/arch/arm/oprofile/common.c
@@ -23,26 +23,37 @@
23#include <asm/ptrace.h> 23#include <asm/ptrace.h>
24 24
25#ifdef CONFIG_HW_PERF_EVENTS 25#ifdef CONFIG_HW_PERF_EVENTS
26
27/*
28 * OProfile has a curious naming scheme for the ARM PMUs, but they are
29 * part of the user ABI so we need to map from the perf PMU name for
30 * supported PMUs.
31 */
32static struct op_perf_name {
33 char *perf_name;
34 char *op_name;
35} op_perf_name_map[] = {
36 { "xscale1", "arm/xscale1" },
37 { "xscale1", "arm/xscale2" },
38 { "v6", "arm/armv6" },
39 { "v6mpcore", "arm/mpcore" },
40 { "ARMv7 Cortex-A8", "arm/armv7" },
41 { "ARMv7 Cortex-A9", "arm/armv7-ca9" },
42};
43
26char *op_name_from_perf_id(void) 44char *op_name_from_perf_id(void)
27{ 45{
28 enum arm_perf_pmu_ids id = armpmu_get_pmu_id(); 46 int i;
29 47 struct op_perf_name names;
30 switch (id) { 48 const char *perf_name = perf_pmu_name();
31 case ARM_PERF_PMU_ID_XSCALE1: 49
32 return "arm/xscale1"; 50 for (i = 0; i < ARRAY_SIZE(op_perf_name_map); ++i) {
33 case ARM_PERF_PMU_ID_XSCALE2: 51 names = op_perf_name_map[i];
34 return "arm/xscale2"; 52 if (!strcmp(names.perf_name, perf_name))
35 case ARM_PERF_PMU_ID_V6: 53 return names.op_name;
36 return "arm/armv6";
37 case ARM_PERF_PMU_ID_V6MP:
38 return "arm/mpcore";
39 case ARM_PERF_PMU_ID_CA8:
40 return "arm/armv7";
41 case ARM_PERF_PMU_ID_CA9:
42 return "arm/armv7-ca9";
43 default:
44 return NULL;
45 } 54 }
55
56 return NULL;
46} 57}
47#endif 58#endif
48 59
diff --git a/arch/arm/plat-mxc/3ds_debugboard.c b/arch/arm/plat-mxc/3ds_debugboard.c
index 5cac2c540f4..5c10ad05df7 100644
--- a/arch/arm/plat-mxc/3ds_debugboard.c
+++ b/arch/arm/plat-mxc/3ds_debugboard.c
@@ -12,9 +12,11 @@
12 12
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/irq.h> 14#include <linux/irq.h>
15#include <linux/irqdomain.h>
15#include <linux/io.h> 16#include <linux/io.h>
16#include <linux/platform_device.h> 17#include <linux/platform_device.h>
17#include <linux/gpio.h> 18#include <linux/gpio.h>
19#include <linux/module.h>
18#include <linux/smsc911x.h> 20#include <linux/smsc911x.h>
19#include <linux/regulator/machine.h> 21#include <linux/regulator/machine.h>
20#include <linux/regulator/fixed.h> 22#include <linux/regulator/fixed.h>
@@ -48,27 +50,22 @@
48/* CPU ID and Personality ID */ 50/* CPU ID and Personality ID */
49#define MCU_BOARD_ID_REG 0x68 51#define MCU_BOARD_ID_REG 0x68
50 52
51#define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_BOARD_IRQ_START)
52#define MXC_IRQ_TO_GPIO(irq) ((irq) - MXC_INTERNAL_IRQS)
53
54#define MXC_EXP_IO_BASE (MXC_BOARD_IRQ_START)
55#define MXC_MAX_EXP_IO_LINES 16 53#define MXC_MAX_EXP_IO_LINES 16
56 54
57/* interrupts like external uart , external ethernet etc*/ 55/* interrupts like external uart , external ethernet etc*/
58#define EXPIO_INT_ENET (MXC_BOARD_IRQ_START + 0) 56#define EXPIO_INT_ENET 0
59#define EXPIO_INT_XUART_A (MXC_BOARD_IRQ_START + 1) 57#define EXPIO_INT_XUART_A 1
60#define EXPIO_INT_XUART_B (MXC_BOARD_IRQ_START + 2) 58#define EXPIO_INT_XUART_B 2
61#define EXPIO_INT_BUTTON_A (MXC_BOARD_IRQ_START + 3) 59#define EXPIO_INT_BUTTON_A 3
62#define EXPIO_INT_BUTTON_B (MXC_BOARD_IRQ_START + 4) 60#define EXPIO_INT_BUTTON_B 4
63 61
64static void __iomem *brd_io; 62static void __iomem *brd_io;
63static struct irq_domain *domain;
65 64
66static struct resource smsc911x_resources[] = { 65static struct resource smsc911x_resources[] = {
67 { 66 {
68 .flags = IORESOURCE_MEM, 67 .flags = IORESOURCE_MEM,
69 } , { 68 } , {
70 .start = EXPIO_INT_ENET,
71 .end = EXPIO_INT_ENET,
72 .flags = IORESOURCE_IRQ, 69 .flags = IORESOURCE_IRQ,
73 }, 70 },
74}; 71};
@@ -100,11 +97,11 @@ static void mxc_expio_irq_handler(u32 irq, struct irq_desc *desc)
100 imr_val = __raw_readw(brd_io + INTR_MASK_REG); 97 imr_val = __raw_readw(brd_io + INTR_MASK_REG);
101 int_valid = __raw_readw(brd_io + INTR_STATUS_REG) & ~imr_val; 98 int_valid = __raw_readw(brd_io + INTR_STATUS_REG) & ~imr_val;
102 99
103 expio_irq = MXC_BOARD_IRQ_START; 100 expio_irq = 0;
104 for (; int_valid != 0; int_valid >>= 1, expio_irq++) { 101 for (; int_valid != 0; int_valid >>= 1, expio_irq++) {
105 if ((int_valid & 1) == 0) 102 if ((int_valid & 1) == 0)
106 continue; 103 continue;
107 generic_handle_irq(expio_irq); 104 generic_handle_irq(irq_find_mapping(domain, expio_irq));
108 } 105 }
109 106
110 desc->irq_data.chip->irq_ack(&desc->irq_data); 107 desc->irq_data.chip->irq_ack(&desc->irq_data);
@@ -118,7 +115,7 @@ static void mxc_expio_irq_handler(u32 irq, struct irq_desc *desc)
118static void expio_mask_irq(struct irq_data *d) 115static void expio_mask_irq(struct irq_data *d)
119{ 116{
120 u16 reg; 117 u16 reg;
121 u32 expio = MXC_IRQ_TO_EXPIO(d->irq); 118 u32 expio = d->hwirq;
122 119
123 reg = __raw_readw(brd_io + INTR_MASK_REG); 120 reg = __raw_readw(brd_io + INTR_MASK_REG);
124 reg |= (1 << expio); 121 reg |= (1 << expio);
@@ -127,7 +124,7 @@ static void expio_mask_irq(struct irq_data *d)
127 124
128static void expio_ack_irq(struct irq_data *d) 125static void expio_ack_irq(struct irq_data *d)
129{ 126{
130 u32 expio = MXC_IRQ_TO_EXPIO(d->irq); 127 u32 expio = d->hwirq;
131 128
132 __raw_writew(1 << expio, brd_io + INTR_RESET_REG); 129 __raw_writew(1 << expio, brd_io + INTR_RESET_REG);
133 __raw_writew(0, brd_io + INTR_RESET_REG); 130 __raw_writew(0, brd_io + INTR_RESET_REG);
@@ -137,7 +134,7 @@ static void expio_ack_irq(struct irq_data *d)
137static void expio_unmask_irq(struct irq_data *d) 134static void expio_unmask_irq(struct irq_data *d)
138{ 135{
139 u16 reg; 136 u16 reg;
140 u32 expio = MXC_IRQ_TO_EXPIO(d->irq); 137 u32 expio = d->hwirq;
141 138
142 reg = __raw_readw(brd_io + INTR_MASK_REG); 139 reg = __raw_readw(brd_io + INTR_MASK_REG);
143 reg &= ~(1 << expio); 140 reg &= ~(1 << expio);
@@ -155,8 +152,10 @@ static struct regulator_consumer_supply dummy_supplies[] = {
155 REGULATOR_SUPPLY("vddvario", "smsc911x"), 152 REGULATOR_SUPPLY("vddvario", "smsc911x"),
156}; 153};
157 154
158int __init mxc_expio_init(u32 base, u32 p_irq) 155int __init mxc_expio_init(u32 base, u32 intr_gpio)
159{ 156{
157 u32 p_irq = gpio_to_irq(intr_gpio);
158 int irq_base;
160 int i; 159 int i;
161 160
162 brd_io = ioremap(BOARD_IO_ADDR(base), SZ_4K); 161 brd_io = ioremap(BOARD_IO_ADDR(base), SZ_4K);
@@ -178,16 +177,23 @@ int __init mxc_expio_init(u32 base, u32 p_irq)
178 /* 177 /*
179 * Configure INT line as GPIO input 178 * Configure INT line as GPIO input
180 */ 179 */
181 gpio_request(MXC_IRQ_TO_GPIO(p_irq), "expio_pirq"); 180 gpio_request(intr_gpio, "expio_pirq");
182 gpio_direction_input(MXC_IRQ_TO_GPIO(p_irq)); 181 gpio_direction_input(intr_gpio);
183 182
184 /* disable the interrupt and clear the status */ 183 /* disable the interrupt and clear the status */
185 __raw_writew(0, brd_io + INTR_MASK_REG); 184 __raw_writew(0, brd_io + INTR_MASK_REG);
186 __raw_writew(0xFFFF, brd_io + INTR_RESET_REG); 185 __raw_writew(0xFFFF, brd_io + INTR_RESET_REG);
187 __raw_writew(0, brd_io + INTR_RESET_REG); 186 __raw_writew(0, brd_io + INTR_RESET_REG);
188 __raw_writew(0x1F, brd_io + INTR_MASK_REG); 187 __raw_writew(0x1F, brd_io + INTR_MASK_REG);
189 for (i = MXC_EXP_IO_BASE; 188
190 i < (MXC_EXP_IO_BASE + MXC_MAX_EXP_IO_LINES); i++) { 189 irq_base = irq_alloc_descs(-1, 0, MXC_MAX_EXP_IO_LINES, numa_node_id());
190 WARN_ON(irq_base < 0);
191
192 domain = irq_domain_add_legacy(NULL, MXC_MAX_EXP_IO_LINES, irq_base, 0,
193 &irq_domain_simple_ops, NULL);
194 WARN_ON(!domain);
195
196 for (i = irq_base; i < irq_base + MXC_MAX_EXP_IO_LINES; i++) {
191 irq_set_chip_and_handler(i, &expio_irq_chip, handle_level_irq); 197 irq_set_chip_and_handler(i, &expio_irq_chip, handle_level_irq);
192 set_irq_flags(i, IRQF_VALID); 198 set_irq_flags(i, IRQF_VALID);
193 } 199 }
@@ -199,6 +205,8 @@ int __init mxc_expio_init(u32 base, u32 p_irq)
199 205
200 smsc911x_resources[0].start = LAN9217_BASE_ADDR(base); 206 smsc911x_resources[0].start = LAN9217_BASE_ADDR(base);
201 smsc911x_resources[0].end = LAN9217_BASE_ADDR(base) + 0x100 - 1; 207 smsc911x_resources[0].end = LAN9217_BASE_ADDR(base) + 0x100 - 1;
208 smsc911x_resources[1].start = irq_find_mapping(domain, EXPIO_INT_ENET);
209 smsc911x_resources[1].end = irq_find_mapping(domain, EXPIO_INT_ENET);
202 platform_device_register(&smsc_lan9217_device); 210 platform_device_register(&smsc_lan9217_device);
203 211
204 return 0; 212 return 0;
diff --git a/arch/arm/plat-mxc/Kconfig b/arch/arm/plat-mxc/Kconfig
index c722f9ce691..baf9064c084 100644
--- a/arch/arm/plat-mxc/Kconfig
+++ b/arch/arm/plat-mxc/Kconfig
@@ -47,12 +47,6 @@ config MXC_TZIC
47config MXC_AVIC 47config MXC_AVIC
48 bool 48 bool
49 49
50config MXC_PWM
51 tristate "Enable PWM driver"
52 select HAVE_PWM
53 help
54 Enable support for the i.MX PWM controller(s).
55
56config MXC_DEBUG_BOARD 50config MXC_DEBUG_BOARD
57 bool "Enable MXC debug board(for 3-stack)" 51 bool "Enable MXC debug board(for 3-stack)"
58 help 52 help
diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile
index e81290c27c6..6ac72003115 100644
--- a/arch/arm/plat-mxc/Makefile
+++ b/arch/arm/plat-mxc/Makefile
@@ -11,11 +11,11 @@ obj-$(CONFIG_MXC_AVIC) += avic.o
11obj-$(CONFIG_IMX_HAVE_IOMUX_V1) += iomux-v1.o 11obj-$(CONFIG_IMX_HAVE_IOMUX_V1) += iomux-v1.o
12obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o 12obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o
13obj-$(CONFIG_IRAM_ALLOC) += iram_alloc.o 13obj-$(CONFIG_IRAM_ALLOC) += iram_alloc.o
14obj-$(CONFIG_MXC_PWM) += pwm.o
15obj-$(CONFIG_MXC_ULPI) += ulpi.o 14obj-$(CONFIG_MXC_ULPI) += ulpi.o
16obj-$(CONFIG_MXC_USE_EPIT) += epit.o 15obj-$(CONFIG_MXC_USE_EPIT) += epit.o
17obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o 16obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o
18obj-$(CONFIG_CPU_FREQ_IMX) += cpufreq.o 17obj-$(CONFIG_CPU_FREQ_IMX) += cpufreq.o
18obj-$(CONFIG_CPU_IDLE) += cpuidle.o
19ifdef CONFIG_SND_IMX_SOC 19ifdef CONFIG_SND_IMX_SOC
20obj-y += ssi-fiq.o 20obj-y += ssi-fiq.o
21obj-y += ssi-fiq-ksym.o 21obj-y += ssi-fiq-ksym.o
diff --git a/arch/arm/plat-mxc/avic.c b/arch/arm/plat-mxc/avic.c
index 689f81f9593..cbd55c36def 100644
--- a/arch/arm/plat-mxc/avic.c
+++ b/arch/arm/plat-mxc/avic.c
@@ -19,11 +19,14 @@
19 19
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/irq.h> 21#include <linux/irq.h>
22#include <linux/irqdomain.h>
22#include <linux/io.h> 23#include <linux/io.h>
24#include <linux/of.h>
23#include <mach/common.h> 25#include <mach/common.h>
24#include <asm/mach/irq.h> 26#include <asm/mach/irq.h>
25#include <asm/exception.h> 27#include <asm/exception.h>
26#include <mach/hardware.h> 28#include <mach/hardware.h>
29#include <mach/irqs.h>
27 30
28#include "irq-common.h" 31#include "irq-common.h"
29 32
@@ -50,15 +53,19 @@
50#define AVIC_NUM_IRQS 64 53#define AVIC_NUM_IRQS 64
51 54
52void __iomem *avic_base; 55void __iomem *avic_base;
56static struct irq_domain *domain;
53 57
54static u32 avic_saved_mask_reg[2]; 58static u32 avic_saved_mask_reg[2];
55 59
56#ifdef CONFIG_MXC_IRQ_PRIOR 60#ifdef CONFIG_MXC_IRQ_PRIOR
57static int avic_irq_set_priority(unsigned char irq, unsigned char prio) 61static int avic_irq_set_priority(unsigned char irq, unsigned char prio)
58{ 62{
63 struct irq_data *d = irq_get_irq_data(irq);
59 unsigned int temp; 64 unsigned int temp;
60 unsigned int mask = 0x0F << irq % 8 * 4; 65 unsigned int mask = 0x0F << irq % 8 * 4;
61 66
67 irq = d->hwirq;
68
62 if (irq >= AVIC_NUM_IRQS) 69 if (irq >= AVIC_NUM_IRQS)
63 return -EINVAL; 70 return -EINVAL;
64 71
@@ -75,8 +82,11 @@ static int avic_irq_set_priority(unsigned char irq, unsigned char prio)
75#ifdef CONFIG_FIQ 82#ifdef CONFIG_FIQ
76static int avic_set_irq_fiq(unsigned int irq, unsigned int type) 83static int avic_set_irq_fiq(unsigned int irq, unsigned int type)
77{ 84{
85 struct irq_data *d = irq_get_irq_data(irq);
78 unsigned int irqt; 86 unsigned int irqt;
79 87
88 irq = d->hwirq;
89
80 if (irq >= AVIC_NUM_IRQS) 90 if (irq >= AVIC_NUM_IRQS)
81 return -EINVAL; 91 return -EINVAL;
82 92
@@ -108,7 +118,7 @@ static void avic_irq_suspend(struct irq_data *d)
108{ 118{
109 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); 119 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
110 struct irq_chip_type *ct = gc->chip_types; 120 struct irq_chip_type *ct = gc->chip_types;
111 int idx = gc->irq_base >> 5; 121 int idx = d->hwirq >> 5;
112 122
113 avic_saved_mask_reg[idx] = __raw_readl(avic_base + ct->regs.mask); 123 avic_saved_mask_reg[idx] = __raw_readl(avic_base + ct->regs.mask);
114 __raw_writel(gc->wake_active, avic_base + ct->regs.mask); 124 __raw_writel(gc->wake_active, avic_base + ct->regs.mask);
@@ -118,7 +128,7 @@ static void avic_irq_resume(struct irq_data *d)
118{ 128{
119 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); 129 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
120 struct irq_chip_type *ct = gc->chip_types; 130 struct irq_chip_type *ct = gc->chip_types;
121 int idx = gc->irq_base >> 5; 131 int idx = d->hwirq >> 5;
122 132
123 __raw_writel(avic_saved_mask_reg[idx], avic_base + ct->regs.mask); 133 __raw_writel(avic_saved_mask_reg[idx], avic_base + ct->regs.mask);
124} 134}
@@ -128,11 +138,10 @@ static void avic_irq_resume(struct irq_data *d)
128#define avic_irq_resume NULL 138#define avic_irq_resume NULL
129#endif 139#endif
130 140
131static __init void avic_init_gc(unsigned int irq_start) 141static __init void avic_init_gc(int idx, unsigned int irq_start)
132{ 142{
133 struct irq_chip_generic *gc; 143 struct irq_chip_generic *gc;
134 struct irq_chip_type *ct; 144 struct irq_chip_type *ct;
135 int idx = irq_start >> 5;
136 145
137 gc = irq_alloc_generic_chip("mxc-avic", 1, irq_start, avic_base, 146 gc = irq_alloc_generic_chip("mxc-avic", 1, irq_start, avic_base,
138 handle_level_irq); 147 handle_level_irq);
@@ -161,7 +170,7 @@ asmlinkage void __exception_irq_entry avic_handle_irq(struct pt_regs *regs)
161 if (nivector == 0xffff) 170 if (nivector == 0xffff)
162 break; 171 break;
163 172
164 handle_IRQ(nivector, regs); 173 handle_IRQ(irq_find_mapping(domain, nivector), regs);
165 } while (1); 174 } while (1);
166} 175}
167 176
@@ -172,6 +181,8 @@ asmlinkage void __exception_irq_entry avic_handle_irq(struct pt_regs *regs)
172 */ 181 */
173void __init mxc_init_irq(void __iomem *irqbase) 182void __init mxc_init_irq(void __iomem *irqbase)
174{ 183{
184 struct device_node *np;
185 int irq_base;
175 int i; 186 int i;
176 187
177 avic_base = irqbase; 188 avic_base = irqbase;
@@ -190,8 +201,16 @@ void __init mxc_init_irq(void __iomem *irqbase)
190 __raw_writel(0, avic_base + AVIC_INTTYPEH); 201 __raw_writel(0, avic_base + AVIC_INTTYPEH);
191 __raw_writel(0, avic_base + AVIC_INTTYPEL); 202 __raw_writel(0, avic_base + AVIC_INTTYPEL);
192 203
193 for (i = 0; i < AVIC_NUM_IRQS; i += 32) 204 irq_base = irq_alloc_descs(-1, 0, AVIC_NUM_IRQS, numa_node_id());
194 avic_init_gc(i); 205 WARN_ON(irq_base < 0);
206
207 np = of_find_compatible_node(NULL, NULL, "fsl,avic");
208 domain = irq_domain_add_legacy(np, AVIC_NUM_IRQS, irq_base, 0,
209 &irq_domain_simple_ops, NULL);
210 WARN_ON(!domain);
211
212 for (i = 0; i < AVIC_NUM_IRQS / 32; i++, irq_base += 32)
213 avic_init_gc(i, irq_base);
195 214
196 /* Set default priority value (0) for all IRQ's */ 215 /* Set default priority value (0) for all IRQ's */
197 for (i = 0; i < 8; i++) 216 for (i = 0; i < 8; i++)
@@ -199,7 +218,7 @@ void __init mxc_init_irq(void __iomem *irqbase)
199 218
200#ifdef CONFIG_FIQ 219#ifdef CONFIG_FIQ
201 /* Initialize FIQ */ 220 /* Initialize FIQ */
202 init_FIQ(); 221 init_FIQ(FIQ_START);
203#endif 222#endif
204 223
205 printk(KERN_INFO "MXC IRQ initialized\n"); 224 printk(KERN_INFO "MXC IRQ initialized\n");
diff --git a/arch/arm/plat-mxc/cpuidle.c b/arch/arm/plat-mxc/cpuidle.c
new file mode 100644
index 00000000000..d4cb511a44a
--- /dev/null
+++ b/arch/arm/plat-mxc/cpuidle.c
@@ -0,0 +1,80 @@
1/*
2 * Copyright 2012 Freescale Semiconductor, Inc.
3 * Copyright 2012 Linaro Ltd.
4 *
5 * The code contained herein is licensed under the GNU General Public
6 * License. You may obtain a copy of the GNU General Public License
7 * Version 2 or later at the following locations:
8 *
9 * http://www.opensource.org/licenses/gpl-license.html
10 * http://www.gnu.org/copyleft/gpl.html
11 */
12
13#include <linux/cpuidle.h>
14#include <linux/err.h>
15#include <linux/hrtimer.h>
16#include <linux/io.h>
17#include <linux/kernel.h>
18#include <linux/slab.h>
19
20static struct cpuidle_device __percpu * imx_cpuidle_devices;
21
22static void __init imx_cpuidle_devices_uninit(void)
23{
24 int cpu_id;
25 struct cpuidle_device *dev;
26
27 for_each_possible_cpu(cpu_id) {
28 dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id);
29 cpuidle_unregister_device(dev);
30 }
31
32 free_percpu(imx_cpuidle_devices);
33}
34
35int __init imx_cpuidle_init(struct cpuidle_driver *drv)
36{
37 struct cpuidle_device *dev;
38 int cpu_id, ret;
39
40 if (drv->state_count > CPUIDLE_STATE_MAX) {
41 pr_err("%s: state_count exceeds maximum\n", __func__);
42 return -EINVAL;
43 }
44
45 ret = cpuidle_register_driver(drv);
46 if (ret) {
47 pr_err("%s: Failed to register cpuidle driver with error: %d\n",
48 __func__, ret);
49 return ret;
50 }
51
52 imx_cpuidle_devices = alloc_percpu(struct cpuidle_device);
53 if (imx_cpuidle_devices == NULL) {
54 ret = -ENOMEM;
55 goto unregister_drv;
56 }
57
58 /* initialize state data for each cpuidle_device */
59 for_each_possible_cpu(cpu_id) {
60 dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id);
61 dev->cpu = cpu_id;
62 dev->state_count = drv->state_count;
63
64 ret = cpuidle_register_device(dev);
65 if (ret) {
66 pr_err("%s: Failed to register cpu %u, error: %d\n",
67 __func__, cpu_id, ret);
68 goto uninit;
69 }
70 }
71
72 return 0;
73
74uninit:
75 imx_cpuidle_devices_uninit();
76
77unregister_drv:
78 cpuidle_unregister_driver(drv);
79 return ret;
80}
diff --git a/arch/arm/plat-mxc/devices/platform-ipu-core.c b/arch/arm/plat-mxc/devices/platform-ipu-core.c
index 79d340ae0af..d1e33cc6f12 100644
--- a/arch/arm/plat-mxc/devices/platform-ipu-core.c
+++ b/arch/arm/plat-mxc/devices/platform-ipu-core.c
@@ -30,8 +30,7 @@ const struct imx_ipu_core_data imx35_ipu_core_data __initconst =
30static struct platform_device *imx_ipu_coredev __initdata; 30static struct platform_device *imx_ipu_coredev __initdata;
31 31
32struct platform_device *__init imx_add_ipu_core( 32struct platform_device *__init imx_add_ipu_core(
33 const struct imx_ipu_core_data *data, 33 const struct imx_ipu_core_data *data)
34 const struct ipu_platform_data *pdata)
35{ 34{
36 /* The resource order is important! */ 35 /* The resource order is important! */
37 struct resource res[] = { 36 struct resource res[] = {
@@ -55,7 +54,7 @@ struct platform_device *__init imx_add_ipu_core(
55 }; 54 };
56 55
57 return imx_ipu_coredev = imx_add_platform_device("ipu-core", -1, 56 return imx_ipu_coredev = imx_add_platform_device("ipu-core", -1,
58 res, ARRAY_SIZE(res), pdata, sizeof(*pdata)); 57 res, ARRAY_SIZE(res), NULL, 0);
59} 58}
60 59
61struct platform_device *__init imx_alloc_mx3_camera( 60struct platform_device *__init imx_alloc_mx3_camera(
diff --git a/arch/arm/plat-mxc/devices/platform-mxc_rtc.c b/arch/arm/plat-mxc/devices/platform-mxc_rtc.c
index 16d0ec4df5f..a5c9ad5721c 100644
--- a/arch/arm/plat-mxc/devices/platform-mxc_rtc.c
+++ b/arch/arm/plat-mxc/devices/platform-mxc_rtc.c
@@ -20,6 +20,11 @@ const struct imx_mxc_rtc_data imx31_mxc_rtc_data __initconst =
20 imx_mxc_rtc_data_entry_single(MX31); 20 imx_mxc_rtc_data_entry_single(MX31);
21#endif /* ifdef CONFIG_SOC_IMX31 */ 21#endif /* ifdef CONFIG_SOC_IMX31 */
22 22
23#ifdef CONFIG_SOC_IMX35
24const struct imx_mxc_rtc_data imx35_mxc_rtc_data __initconst =
25 imx_mxc_rtc_data_entry_single(MX35);
26#endif /* ifdef CONFIG_SOC_IMX35 */
27
23struct platform_device *__init imx_add_mxc_rtc( 28struct platform_device *__init imx_add_mxc_rtc(
24 const struct imx_mxc_rtc_data *data) 29 const struct imx_mxc_rtc_data *data)
25{ 30{
diff --git a/arch/arm/plat-mxc/devices/platform-spi_imx.c b/arch/arm/plat-mxc/devices/platform-spi_imx.c
index 9bfae8bd5b8..9c50c14c8f9 100644
--- a/arch/arm/plat-mxc/devices/platform-spi_imx.c
+++ b/arch/arm/plat-mxc/devices/platform-spi_imx.c
@@ -95,7 +95,7 @@ const struct imx_spi_imx_data imx51_ecspi_data[] __initconst = {
95#ifdef CONFIG_SOC_IMX53 95#ifdef CONFIG_SOC_IMX53
96/* i.mx53 has the i.mx35 type cspi */ 96/* i.mx53 has the i.mx35 type cspi */
97const struct imx_spi_imx_data imx53_cspi_data __initconst = 97const struct imx_spi_imx_data imx53_cspi_data __initconst =
98 imx_spi_imx_data_entry_single(MX53, CSPI, "imx35-cspi", 0, , SZ_4K); 98 imx_spi_imx_data_entry_single(MX53, CSPI, "imx35-cspi", 2, , SZ_4K);
99 99
100/* i.mx53 has the i.mx51 type ecspi */ 100/* i.mx53 has the i.mx51 type ecspi */
101const struct imx_spi_imx_data imx53_ecspi_data[] __initconst = { 101const struct imx_spi_imx_data imx53_ecspi_data[] __initconst = {
diff --git a/arch/arm/plat-mxc/include/mach/3ds_debugboard.h b/arch/arm/plat-mxc/include/mach/3ds_debugboard.h
index a384fdd49c6..9fd6cb3f8fa 100644
--- a/arch/arm/plat-mxc/include/mach/3ds_debugboard.h
+++ b/arch/arm/plat-mxc/include/mach/3ds_debugboard.h
@@ -13,6 +13,6 @@
13#ifndef __ASM_ARCH_MXC_3DS_DB_H__ 13#ifndef __ASM_ARCH_MXC_3DS_DB_H__
14#define __ASM_ARCH_MXC_3DS_DB_H__ 14#define __ASM_ARCH_MXC_3DS_DB_H__
15 15
16extern int __init mxc_expio_init(u32 base, u32 p_irq); 16extern int __init mxc_expio_init(u32 base, u32 intr_gpio);
17 17
18#endif /* __ASM_ARCH_MXC_3DS_DB_H__ */ 18#endif /* __ASM_ARCH_MXC_3DS_DB_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/common.h b/arch/arm/plat-mxc/include/mach/common.h
index e429ca1b814..7128e971041 100644
--- a/arch/arm/plat-mxc/include/mach/common.h
+++ b/arch/arm/plat-mxc/include/mach/common.h
@@ -54,6 +54,7 @@ extern void imx50_soc_init(void);
54extern void imx51_soc_init(void); 54extern void imx51_soc_init(void);
55extern void imx53_soc_init(void); 55extern void imx53_soc_init(void);
56extern void imx51_init_late(void); 56extern void imx51_init_late(void);
57extern void imx53_init_late(void);
57extern void epit_timer_init(void __iomem *base, int irq); 58extern void epit_timer_init(void __iomem *base, int irq);
58extern void mxc_timer_init(void __iomem *, int); 59extern void mxc_timer_init(void __iomem *, int);
59extern int mx1_clocks_init(unsigned long fref); 60extern int mx1_clocks_init(unsigned long fref);
@@ -67,6 +68,7 @@ extern int mx51_clocks_init(unsigned long ckil, unsigned long osc,
67extern int mx53_clocks_init(unsigned long ckil, unsigned long osc, 68extern int mx53_clocks_init(unsigned long ckil, unsigned long osc,
68 unsigned long ckih1, unsigned long ckih2); 69 unsigned long ckih1, unsigned long ckih2);
69extern int mx27_clocks_init_dt(void); 70extern int mx27_clocks_init_dt(void);
71extern int mx31_clocks_init_dt(void);
70extern int mx51_clocks_init_dt(void); 72extern int mx51_clocks_init_dt(void);
71extern int mx53_clocks_init_dt(void); 73extern int mx53_clocks_init_dt(void);
72extern int mx6q_clocks_init(void); 74extern int mx6q_clocks_init(void);
@@ -95,7 +97,6 @@ enum mx3_cpu_pwr_mode {
95}; 97};
96 98
97extern void mx3_cpu_lp_set(enum mx3_cpu_pwr_mode mode); 99extern void mx3_cpu_lp_set(enum mx3_cpu_pwr_mode mode);
98extern void mx5_cpu_lp_set(enum mxc_cpu_pwr_mode mode);
99extern void imx_print_silicon_rev(const char *cpu, int srev); 100extern void imx_print_silicon_rev(const char *cpu, int srev);
100 101
101void avic_handle_irq(struct pt_regs *); 102void avic_handle_irq(struct pt_regs *);
@@ -146,8 +147,12 @@ extern void imx6q_clock_map_io(void);
146 147
147#ifdef CONFIG_PM 148#ifdef CONFIG_PM
148extern void imx6q_pm_init(void); 149extern void imx6q_pm_init(void);
150extern void imx51_pm_init(void);
151extern void imx53_pm_init(void);
149#else 152#else
150static inline void imx6q_pm_init(void) {} 153static inline void imx6q_pm_init(void) {}
154static inline void imx51_pm_init(void) {}
155static inline void imx53_pm_init(void) {}
151#endif 156#endif
152 157
153#ifdef CONFIG_NEON 158#ifdef CONFIG_NEON
diff --git a/arch/arm/plat-mxc/include/mach/cpuidle.h b/arch/arm/plat-mxc/include/mach/cpuidle.h
new file mode 100644
index 00000000000..bc932d1af37
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/cpuidle.h
@@ -0,0 +1,22 @@
1/*
2 * Copyright 2012 Freescale Semiconductor, Inc.
3 * Copyright 2012 Linaro Ltd.
4 *
5 * The code contained herein is licensed under the GNU General Public
6 * License. You may obtain a copy of the GNU General Public License
7 * Version 2 or later at the following locations:
8 *
9 * http://www.opensource.org/licenses/gpl-license.html
10 * http://www.gnu.org/copyleft/gpl.html
11 */
12
13#include <linux/cpuidle.h>
14
15#ifdef CONFIG_CPU_IDLE
16extern int imx_cpuidle_init(struct cpuidle_driver *drv);
17#else
18static inline int imx_cpuidle_init(struct cpuidle_driver *drv)
19{
20 return -ENODEV;
21}
22#endif
diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
index 1b2258daa05..a7f5bb1084d 100644
--- a/arch/arm/plat-mxc/include/mach/devices-common.h
+++ b/arch/arm/plat-mxc/include/mach/devices-common.h
@@ -183,7 +183,6 @@ struct platform_device *__init imx_add_imx_udc(
183 const struct imx_imx_udc_data *data, 183 const struct imx_imx_udc_data *data,
184 const struct imxusb_platform_data *pdata); 184 const struct imxusb_platform_data *pdata);
185 185
186#include <mach/ipu.h>
187#include <mach/mx3fb.h> 186#include <mach/mx3fb.h>
188#include <mach/mx3_camera.h> 187#include <mach/mx3_camera.h>
189struct imx_ipu_core_data { 188struct imx_ipu_core_data {
@@ -192,8 +191,7 @@ struct imx_ipu_core_data {
192 resource_size_t errirq; 191 resource_size_t errirq;
193}; 192};
194struct platform_device *__init imx_add_ipu_core( 193struct platform_device *__init imx_add_ipu_core(
195 const struct imx_ipu_core_data *data, 194 const struct imx_ipu_core_data *data);
196 const struct ipu_platform_data *pdata);
197struct platform_device *__init imx_alloc_mx3_camera( 195struct platform_device *__init imx_alloc_mx3_camera(
198 const struct imx_ipu_core_data *data, 196 const struct imx_ipu_core_data *data,
199 const struct mx3_camera_pdata *pdata); 197 const struct mx3_camera_pdata *pdata);
diff --git a/arch/arm/plat-mxc/include/mach/hardware.h b/arch/arm/plat-mxc/include/mach/hardware.h
index 0630513554d..ebf10654bb4 100644
--- a/arch/arm/plat-mxc/include/mach/hardware.h
+++ b/arch/arm/plat-mxc/include/mach/hardware.h
@@ -50,7 +50,7 @@
50 * IO 0x00200000+0x100000 -> 0xf4000000+0x100000 50 * IO 0x00200000+0x100000 -> 0xf4000000+0x100000
51 * mx21: 51 * mx21:
52 * AIPI 0x10000000+0x100000 -> 0xf4400000+0x100000 52 * AIPI 0x10000000+0x100000 -> 0xf4400000+0x100000
53 * SAHB1 0x80000000+0x100000 -> 0xf4000000+0x100000 53 * SAHB1 0x80000000+0x100000 -> 0xf5000000+0x100000
54 * X_MEMC 0xdf000000+0x004000 -> 0xf5f00000+0x004000 54 * X_MEMC 0xdf000000+0x004000 -> 0xf5f00000+0x004000
55 * mx25: 55 * mx25:
56 * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000 56 * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000
@@ -58,47 +58,50 @@
58 * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000 58 * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000
59 * mx27: 59 * mx27:
60 * AIPI 0x10000000+0x100000 -> 0xf4400000+0x100000 60 * AIPI 0x10000000+0x100000 -> 0xf4400000+0x100000
61 * SAHB1 0x80000000+0x100000 -> 0xf4000000+0x100000 61 * SAHB1 0x80000000+0x100000 -> 0xf5000000+0x100000
62 * X_MEMC 0xd8000000+0x100000 -> 0xf5c00000+0x100000 62 * X_MEMC 0xd8000000+0x100000 -> 0xf5c00000+0x100000
63 * mx31: 63 * mx31:
64 * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000 64 * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000
65 * AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000 65 * AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000
66 * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000 66 * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000
67 * X_MEMC 0xb8000000+0x010000 -> 0xf4c00000+0x010000 67 * X_MEMC 0xb8000000+0x010000 -> 0xf5c00000+0x010000
68 * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000 68 * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000
69 * mx35: 69 * mx35:
70 * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000 70 * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000
71 * AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000 71 * AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000
72 * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000 72 * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000
73 * X_MEMC 0xb8000000+0x010000 -> 0xf4c00000+0x010000 73 * X_MEMC 0xb8000000+0x010000 -> 0xf5c00000+0x010000
74 * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000 74 * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000
75 * mx50: 75 * mx50:
76 * TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x004000 76 * TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x004000
77 * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000
78 * AIPS1 0x53f00000+0x100000 -> 0xf5700000+0x100000 77 * AIPS1 0x53f00000+0x100000 -> 0xf5700000+0x100000
78 * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000
79 * AIPS2 0x63f00000+0x100000 -> 0xf5300000+0x100000 79 * AIPS2 0x63f00000+0x100000 -> 0xf5300000+0x100000
80 * mx51: 80 * mx51:
81 * TZIC 0xe0000000+0x004000 -> 0xf5000000+0x004000 81 * TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x004000
82 * IRAM 0x1ffe0000+0x020000 -> 0xf4fe0000+0x020000 82 * IRAM 0x1ffe0000+0x020000 -> 0xf4fe0000+0x020000
83 * DEBUG 0x60000000+0x100000 -> 0xf5000000+0x100000
83 * SPBA0 0x70000000+0x100000 -> 0xf5400000+0x100000 84 * SPBA0 0x70000000+0x100000 -> 0xf5400000+0x100000
84 * AIPS1 0x73f00000+0x100000 -> 0xf5700000+0x100000 85 * AIPS1 0x73f00000+0x100000 -> 0xf5700000+0x100000
85 * AIPS2 0x83f00000+0x100000 -> 0xf4300000+0x100000 86 * AIPS2 0x83f00000+0x100000 -> 0xf5300000+0x100000
86 * mx53: 87 * mx53:
87 * TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x004000 88 * TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x004000
89 * DEBUG 0x40000000+0x100000 -> 0xf5000000+0x100000
88 * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000 90 * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000
89 * AIPS1 0x53f00000+0x100000 -> 0xf5700000+0x100000 91 * AIPS1 0x53f00000+0x100000 -> 0xf5700000+0x100000
90 * AIPS2 0x63f00000+0x100000 -> 0xf5300000+0x100000 92 * AIPS2 0x63f00000+0x100000 -> 0xf5300000+0x100000
91 * mx6q: 93 * mx6q:
92 * SCU 0x00a00000+0x001000 -> 0xf4000000+0x001000 94 * SCU 0x00a00000+0x004000 -> 0xf4000000+0x004000
93 * CCM 0x020c4000+0x004000 -> 0xf42c4000+0x004000 95 * CCM 0x020c4000+0x004000 -> 0xf42c4000+0x004000
94 * ANATOP 0x020c8000+0x001000 -> 0xf42c8000+0x001000 96 * ANATOP 0x020c8000+0x004000 -> 0xf42c8000+0x004000
95 * UART4 0x021f0000+0x004000 -> 0xf42f0000+0x004000 97 * UART4 0x021f0000+0x004000 -> 0xf42f0000+0x004000
96 */ 98 */
97#define IMX_IO_P2V(x) ( \ 99#define IMX_IO_P2V(x) ( \
98 0xf4000000 + \ 100 (((x) & 0x80000000) >> 7) | \
101 (0xf4000000 + \
99 (((x) & 0x50000000) >> 6) + \ 102 (((x) & 0x50000000) >> 6) + \
100 (((x) & 0x0b000000) >> 4) + \ 103 (((x) & 0x0b000000) >> 4) + \
101 (((x) & 0x000fffff))) 104 (((x) & 0x000fffff))))
102 105
103#define IMX_IO_ADDRESS(x) IOMEM(IMX_IO_P2V(x)) 106#define IMX_IO_ADDRESS(x) IOMEM(IMX_IO_P2V(x))
104 107
@@ -128,6 +131,4 @@
128/* range e.g. GPIO_1_5 is gpio 5 under linux */ 131/* range e.g. GPIO_1_5 is gpio 5 under linux */
129#define IMX_GPIO_NR(bank, nr) (((bank) - 1) * 32 + (nr)) 132#define IMX_GPIO_NR(bank, nr) (((bank) - 1) * 32 + (nr))
130 133
131#define IMX_GPIO_TO_IRQ(gpio) (MXC_GPIO_IRQ_START + (gpio))
132
133#endif /* __ASM_ARCH_MXC_HARDWARE_H__ */ 134#endif /* __ASM_ARCH_MXC_HARDWARE_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/i2c.h b/arch/arm/plat-mxc/include/mach/i2c.h
index 375cdd0cf87..8289d915e61 100644
--- a/arch/arm/plat-mxc/include/mach/i2c.h
+++ b/arch/arm/plat-mxc/include/mach/i2c.h
@@ -15,7 +15,7 @@
15 * 15 *
16 **/ 16 **/
17struct imxi2c_platform_data { 17struct imxi2c_platform_data {
18 int bitrate; 18 u32 bitrate;
19}; 19};
20 20
21#endif /* __ASM_ARCH_I2C_H_ */ 21#endif /* __ASM_ARCH_I2C_H_ */
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx3.h b/arch/arm/plat-mxc/include/mach/iomux-mx3.h
index 63f22a009a6..d8b65b51f2a 100644
--- a/arch/arm/plat-mxc/include/mach/iomux-mx3.h
+++ b/arch/arm/plat-mxc/include/mach/iomux-mx3.h
@@ -160,9 +160,6 @@ int mxc_iomux_mode(unsigned int pin_mode);
160 160
161#define IOMUX_TO_GPIO(iomux_pin) \ 161#define IOMUX_TO_GPIO(iomux_pin) \
162 ((iomux_pin & IOMUX_GPIONUM_MASK) >> IOMUX_GPIONUM_SHIFT) 162 ((iomux_pin & IOMUX_GPIONUM_MASK) >> IOMUX_GPIONUM_SHIFT)
163#define IOMUX_TO_IRQ(iomux_pin) \
164 (((iomux_pin & IOMUX_GPIONUM_MASK) >> IOMUX_GPIONUM_SHIFT) + \
165 MXC_GPIO_IRQ_START)
166 163
167/* 164/*
168 * This enumeration is constructed based on the Section 165 * This enumeration is constructed based on the Section
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx51.h b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
index 36c8989d9de..2623e7a2e19 100644
--- a/arch/arm/plat-mxc/include/mach/iomux-mx51.h
+++ b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
@@ -107,11 +107,13 @@
107#define MX51_PAD_EIM_D25__UART2_CTS IOMUX_PAD(0x414, 0x080, 4, __NA_, 0, MX51_UART_PAD_CTRL) 107#define MX51_PAD_EIM_D25__UART2_CTS IOMUX_PAD(0x414, 0x080, 4, __NA_, 0, MX51_UART_PAD_CTRL)
108#define MX51_PAD_EIM_D25__UART3_RXD IOMUX_PAD(0x414, 0x080, 3, 0x9f4, 0, MX51_UART_PAD_CTRL) 108#define MX51_PAD_EIM_D25__UART3_RXD IOMUX_PAD(0x414, 0x080, 3, 0x9f4, 0, MX51_UART_PAD_CTRL)
109#define MX51_PAD_EIM_D25__USBOTG_DATA1 IOMUX_PAD(0x414, 0x080, 2, __NA_, 0, NO_PAD_CTRL) 109#define MX51_PAD_EIM_D25__USBOTG_DATA1 IOMUX_PAD(0x414, 0x080, 2, __NA_, 0, NO_PAD_CTRL)
110#define MX51_PAD_EIM_D25__GPT_CMPOUT1 IOMUX_PAD(0x414, 0x080, 5, __NA_, 0, NO_PAD_CTRL)
110#define MX51_PAD_EIM_D26__EIM_D26 IOMUX_PAD(0x418, 0x084, 0, __NA_, 0, NO_PAD_CTRL) 111#define MX51_PAD_EIM_D26__EIM_D26 IOMUX_PAD(0x418, 0x084, 0, __NA_, 0, NO_PAD_CTRL)
111#define MX51_PAD_EIM_D26__KEY_COL7 IOMUX_PAD(0x418, 0x084, 1, 0x9cc, 0, NO_PAD_CTRL) 112#define MX51_PAD_EIM_D26__KEY_COL7 IOMUX_PAD(0x418, 0x084, 1, 0x9cc, 0, NO_PAD_CTRL)
112#define MX51_PAD_EIM_D26__UART2_RTS IOMUX_PAD(0x418, 0x084, 4, 0x9e8, 3, MX51_UART_PAD_CTRL) 113#define MX51_PAD_EIM_D26__UART2_RTS IOMUX_PAD(0x418, 0x084, 4, 0x9e8, 3, MX51_UART_PAD_CTRL)
113#define MX51_PAD_EIM_D26__UART3_TXD IOMUX_PAD(0x418, 0x084, 3, __NA_, 0, MX51_UART_PAD_CTRL) 114#define MX51_PAD_EIM_D26__UART3_TXD IOMUX_PAD(0x418, 0x084, 3, __NA_, 0, MX51_UART_PAD_CTRL)
114#define MX51_PAD_EIM_D26__USBOTG_DATA2 IOMUX_PAD(0x418, 0x084, 2, __NA_, 0, NO_PAD_CTRL) 115#define MX51_PAD_EIM_D26__USBOTG_DATA2 IOMUX_PAD(0x418, 0x084, 2, __NA_, 0, NO_PAD_CTRL)
116#define MX51_PAD_EIM_D26__GPT_CMPOUT2 IOMUX_PAD(0x418, 0x084, 5, __NA_, 0, NO_PAD_CTRL)
115#define MX51_PAD_EIM_D27__AUD6_RXC IOMUX_PAD(0x41c, 0x088, 5, 0x8f4, 0, NO_PAD_CTRL) 117#define MX51_PAD_EIM_D27__AUD6_RXC IOMUX_PAD(0x41c, 0x088, 5, 0x8f4, 0, NO_PAD_CTRL)
116#define MX51_PAD_EIM_D27__EIM_D27 IOMUX_PAD(0x41c, 0x088, 0, __NA_, 0, NO_PAD_CTRL) 118#define MX51_PAD_EIM_D27__EIM_D27 IOMUX_PAD(0x41c, 0x088, 0, __NA_, 0, NO_PAD_CTRL)
117#define MX51_PAD_EIM_D27__GPIO2_9 IOMUX_PAD(0x41c, 0x088, 1, __NA_, 0, MX51_GPIO_PAD_CTRL) 119#define MX51_PAD_EIM_D27__GPIO2_9 IOMUX_PAD(0x41c, 0x088, 1, __NA_, 0, MX51_GPIO_PAD_CTRL)
@@ -228,6 +230,7 @@
228#define MX51_PAD_EIM_CRE__EIM_CRE IOMUX_PAD(0x4a0, 0x100, 0, __NA_, 0, NO_PAD_CTRL) 230#define MX51_PAD_EIM_CRE__EIM_CRE IOMUX_PAD(0x4a0, 0x100, 0, __NA_, 0, NO_PAD_CTRL)
229#define MX51_PAD_EIM_CRE__GPIO3_2 IOMUX_PAD(0x4a0, 0x100, 1, 0x97c, 0, MX51_GPIO_PAD_CTRL) 231#define MX51_PAD_EIM_CRE__GPIO3_2 IOMUX_PAD(0x4a0, 0x100, 1, 0x97c, 0, MX51_GPIO_PAD_CTRL)
230#define MX51_PAD_DRAM_CS1__DRAM_CS1 IOMUX_PAD(0x4d0, 0x104, 0, __NA_, 0, NO_PAD_CTRL) 232#define MX51_PAD_DRAM_CS1__DRAM_CS1 IOMUX_PAD(0x4d0, 0x104, 0, __NA_, 0, NO_PAD_CTRL)
233#define MX51_PAD_DRAM_CS1__CCM_CLKO IOMUX_PAD(0x4d0, 0x104, 1, __NA_, 0, NO_PAD_CTRL)
231#define MX51_PAD_NANDF_WE_B__GPIO3_3 IOMUX_PAD(0x4e4, 0x108, 3, 0x980, 0, MX51_GPIO_PAD_CTRL) 234#define MX51_PAD_NANDF_WE_B__GPIO3_3 IOMUX_PAD(0x4e4, 0x108, 3, 0x980, 0, MX51_GPIO_PAD_CTRL)
232#define MX51_PAD_NANDF_WE_B__NANDF_WE_B IOMUX_PAD(0x4e4, 0x108, 0, __NA_, 0, NO_PAD_CTRL) 235#define MX51_PAD_NANDF_WE_B__NANDF_WE_B IOMUX_PAD(0x4e4, 0x108, 0, __NA_, 0, NO_PAD_CTRL)
233#define MX51_PAD_NANDF_WE_B__PATA_DIOW IOMUX_PAD(0x4e4, 0x108, 1, __NA_, 0, NO_PAD_CTRL) 236#define MX51_PAD_NANDF_WE_B__PATA_DIOW IOMUX_PAD(0x4e4, 0x108, 1, __NA_, 0, NO_PAD_CTRL)
@@ -256,12 +259,14 @@
256#define MX51_PAD_NANDF_RB1__GPIO3_9 IOMUX_PAD(0x4fc, 0x120, 3, __NA_, 0, MX51_GPIO_PAD_CTRL) 259#define MX51_PAD_NANDF_RB1__GPIO3_9 IOMUX_PAD(0x4fc, 0x120, 3, __NA_, 0, MX51_GPIO_PAD_CTRL)
257#define MX51_PAD_NANDF_RB1__NANDF_RB1 IOMUX_PAD(0x4fc, 0x120, 0, __NA_, 0, NO_PAD_CTRL) 260#define MX51_PAD_NANDF_RB1__NANDF_RB1 IOMUX_PAD(0x4fc, 0x120, 0, __NA_, 0, NO_PAD_CTRL)
258#define MX51_PAD_NANDF_RB1__PATA_IORDY IOMUX_PAD(0x4fc, 0x120, 1, __NA_, 0, NO_PAD_CTRL) 261#define MX51_PAD_NANDF_RB1__PATA_IORDY IOMUX_PAD(0x4fc, 0x120, 1, __NA_, 0, NO_PAD_CTRL)
262#define MX51_PAD_NANDF_RB1__GPT_CMPOUT2 IOMUX_PAD(0x4fc, 0x120, 4, __NA_, 0, NO_PAD_CTRL)
259#define MX51_PAD_NANDF_RB1__SD4_CMD IOMUX_PAD(0x4fc, 0x120, 0x15, __NA_, 0, MX51_SDHCI_PAD_CTRL) 263#define MX51_PAD_NANDF_RB1__SD4_CMD IOMUX_PAD(0x4fc, 0x120, 0x15, __NA_, 0, MX51_SDHCI_PAD_CTRL)
260#define MX51_PAD_NANDF_RB2__DISP2_WAIT IOMUX_PAD(0x500, 0x124, 5, 0x9a8, 0, NO_PAD_CTRL) 264#define MX51_PAD_NANDF_RB2__DISP2_WAIT IOMUX_PAD(0x500, 0x124, 5, 0x9a8, 0, NO_PAD_CTRL)
261#define MX51_PAD_NANDF_RB2__ECSPI2_SCLK IOMUX_PAD(0x500, 0x124, 2, __NA_, 0, MX51_ECSPI_PAD_CTRL) 265#define MX51_PAD_NANDF_RB2__ECSPI2_SCLK IOMUX_PAD(0x500, 0x124, 2, __NA_, 0, MX51_ECSPI_PAD_CTRL)
262#define MX51_PAD_NANDF_RB2__FEC_COL IOMUX_PAD(0x500, 0x124, 1, 0x94c, 0, MX51_PAD_CTRL_2) 266#define MX51_PAD_NANDF_RB2__FEC_COL IOMUX_PAD(0x500, 0x124, 1, 0x94c, 0, MX51_PAD_CTRL_2)
263#define MX51_PAD_NANDF_RB2__GPIO3_10 IOMUX_PAD(0x500, 0x124, 3, __NA_, 0, MX51_GPIO_PAD_CTRL) 267#define MX51_PAD_NANDF_RB2__GPIO3_10 IOMUX_PAD(0x500, 0x124, 3, __NA_, 0, MX51_GPIO_PAD_CTRL)
264#define MX51_PAD_NANDF_RB2__NANDF_RB2 IOMUX_PAD(0x500, 0x124, 0, __NA_, 0, NO_PAD_CTRL) 268#define MX51_PAD_NANDF_RB2__NANDF_RB2 IOMUX_PAD(0x500, 0x124, 0, __NA_, 0, NO_PAD_CTRL)
269#define MX51_PAD_NANDF_RB2__GPT_CMPOUT3 IOMUX_PAD(0x500, 0x124, 4, __NA_, 0, NO_PAD_CTRL)
265#define MX51_PAD_NANDF_RB2__USBH3_H3_DP IOMUX_PAD(0x500, 0x124, 0x17, __NA_, 0, NO_PAD_CTRL) 270#define MX51_PAD_NANDF_RB2__USBH3_H3_DP IOMUX_PAD(0x500, 0x124, 0x17, __NA_, 0, NO_PAD_CTRL)
266#define MX51_PAD_NANDF_RB2__USBH3_NXT IOMUX_PAD(0x500, 0x124, 6, 0xa20, 0, NO_PAD_CTRL) 271#define MX51_PAD_NANDF_RB2__USBH3_NXT IOMUX_PAD(0x500, 0x124, 6, 0xa20, 0, NO_PAD_CTRL)
267#define MX51_PAD_NANDF_RB3__DISP1_WAIT IOMUX_PAD(0x504, 0x128, 5, __NA_, 0, NO_PAD_CTRL) 272#define MX51_PAD_NANDF_RB3__DISP1_WAIT IOMUX_PAD(0x504, 0x128, 5, __NA_, 0, NO_PAD_CTRL)
@@ -637,7 +642,9 @@
637#define MX51_PAD_DISP1_DAT23__DISP2_DAT17 IOMUX_PAD(0x728, 0x328, 5, __NA_, 0, NO_PAD_CTRL) 642#define MX51_PAD_DISP1_DAT23__DISP2_DAT17 IOMUX_PAD(0x728, 0x328, 5, __NA_, 0, NO_PAD_CTRL)
638#define MX51_PAD_DISP1_DAT23__DISP2_SER_CS IOMUX_PAD(0x728, 0x328, 4, __NA_, 0, NO_PAD_CTRL) 643#define MX51_PAD_DISP1_DAT23__DISP2_SER_CS IOMUX_PAD(0x728, 0x328, 4, __NA_, 0, NO_PAD_CTRL)
639#define MX51_PAD_DI1_PIN3__DI1_PIN3 IOMUX_PAD(0x72c, 0x32c, 0, __NA_, 0, NO_PAD_CTRL) 644#define MX51_PAD_DI1_PIN3__DI1_PIN3 IOMUX_PAD(0x72c, 0x32c, 0, __NA_, 0, NO_PAD_CTRL)
645#define MX51_PAD_DI1_DISP_CLK__DI1_DISP_CLK IOMUX_PAD(0x730, __NA_, 0, __NA_, 0, NO_PAD_CTRL)
640#define MX51_PAD_DI1_PIN2__DI1_PIN2 IOMUX_PAD(0x734, 0x330, 0, __NA_, 0, NO_PAD_CTRL) 646#define MX51_PAD_DI1_PIN2__DI1_PIN2 IOMUX_PAD(0x734, 0x330, 0, __NA_, 0, NO_PAD_CTRL)
647#define MX51_PAD_DI1_PIN15__DI1_PIN15 IOMUX_PAD(0x738, __NA_, 0, __NA_, 0, NO_PAD_CTRL)
641#define MX51_PAD_DI_GP2__DISP1_SER_CLK IOMUX_PAD(0x740, 0x338, 0, __NA_, 0, NO_PAD_CTRL) 648#define MX51_PAD_DI_GP2__DISP1_SER_CLK IOMUX_PAD(0x740, 0x338, 0, __NA_, 0, NO_PAD_CTRL)
642#define MX51_PAD_DI_GP2__DISP2_WAIT IOMUX_PAD(0x740, 0x338, 2, 0x9a8, 1, NO_PAD_CTRL) 649#define MX51_PAD_DI_GP2__DISP2_WAIT IOMUX_PAD(0x740, 0x338, 2, 0x9a8, 1, NO_PAD_CTRL)
643#define MX51_PAD_DI_GP3__CSI1_DATA_EN IOMUX_PAD(0x744, 0x33c, 3, 0x9a0, 1, NO_PAD_CTRL) 650#define MX51_PAD_DI_GP3__CSI1_DATA_EN IOMUX_PAD(0x744, 0x33c, 3, 0x9a0, 1, NO_PAD_CTRL)
@@ -780,6 +787,8 @@
780#define MX51_PAD_GPIO1_2__PWM1_PWMO IOMUX_PAD(0x7d4, 0x3cc, 1, __NA_, 0, NO_PAD_CTRL) 787#define MX51_PAD_GPIO1_2__PWM1_PWMO IOMUX_PAD(0x7d4, 0x3cc, 1, __NA_, 0, NO_PAD_CTRL)
781#define MX51_PAD_GPIO1_3__GPIO1_3 IOMUX_PAD(0x7d8, 0x3d0, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) 788#define MX51_PAD_GPIO1_3__GPIO1_3 IOMUX_PAD(0x7d8, 0x3d0, 0, __NA_, 0, MX51_GPIO_PAD_CTRL)
782#define MX51_PAD_GPIO1_3__I2C2_SDA IOMUX_PAD(0x7d8, 0x3d0, 0x12, 0x9bc, 3, MX51_I2C_PAD_CTRL) 789#define MX51_PAD_GPIO1_3__I2C2_SDA IOMUX_PAD(0x7d8, 0x3d0, 0x12, 0x9bc, 3, MX51_I2C_PAD_CTRL)
790#define MX51_PAD_GPIO1_3__CCM_CLKO2 IOMUX_PAD(0x7d8, 0x3d0, 5, __NA_, 0, NO_PAD_CTRL)
791#define MX51_PAD_GPIO1_3__GPT_CLKIN IOMUX_PAD(0x7d8, 0x3d0, 6, __NA_, 0, NO_PAD_CTRL)
783#define MX51_PAD_GPIO1_3__PLL2_BYP IOMUX_PAD(0x7d8, 0x3d0, 7, 0x910, 1, NO_PAD_CTRL) 792#define MX51_PAD_GPIO1_3__PLL2_BYP IOMUX_PAD(0x7d8, 0x3d0, 7, 0x910, 1, NO_PAD_CTRL)
784#define MX51_PAD_GPIO1_3__PWM2_PWMO IOMUX_PAD(0x7d8, 0x3d0, 1, __NA_, 0, NO_PAD_CTRL) 793#define MX51_PAD_GPIO1_3__PWM2_PWMO IOMUX_PAD(0x7d8, 0x3d0, 1, __NA_, 0, NO_PAD_CTRL)
785#define MX51_PAD_PMIC_INT_REQ__PMIC_INT_REQ IOMUX_PAD(0x7fc, 0x3d4, 0, __NA_, 0, NO_PAD_CTRL) 794#define MX51_PAD_PMIC_INT_REQ__PMIC_INT_REQ IOMUX_PAD(0x7fc, 0x3d4, 0, __NA_, 0, NO_PAD_CTRL)
@@ -788,13 +797,16 @@
788#define MX51_PAD_GPIO1_4__EIM_RDY IOMUX_PAD(0x804, 0x3d8, 3, 0x938, 1, NO_PAD_CTRL) 797#define MX51_PAD_GPIO1_4__EIM_RDY IOMUX_PAD(0x804, 0x3d8, 3, 0x938, 1, NO_PAD_CTRL)
789#define MX51_PAD_GPIO1_4__GPIO1_4 IOMUX_PAD(0x804, 0x3d8, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) 798#define MX51_PAD_GPIO1_4__GPIO1_4 IOMUX_PAD(0x804, 0x3d8, 0, __NA_, 0, MX51_GPIO_PAD_CTRL)
790#define MX51_PAD_GPIO1_4__WDOG1_WDOG_B IOMUX_PAD(0x804, 0x3d8, 2, __NA_, 0, NO_PAD_CTRL) 799#define MX51_PAD_GPIO1_4__WDOG1_WDOG_B IOMUX_PAD(0x804, 0x3d8, 2, __NA_, 0, NO_PAD_CTRL)
800#define MX51_PAD_GPIO1_4__GPT_CAPIN1 IOMUX_PAD(0x804, 0x3d8, 6, __NA_, 0, NO_PAD_CTRL)
791#define MX51_PAD_GPIO1_5__CSI2_MCLK IOMUX_PAD(0x808, 0x3dc, 6, __NA_, 0, NO_PAD_CTRL) 801#define MX51_PAD_GPIO1_5__CSI2_MCLK IOMUX_PAD(0x808, 0x3dc, 6, __NA_, 0, NO_PAD_CTRL)
792#define MX51_PAD_GPIO1_5__DISP2_PIN16 IOMUX_PAD(0x808, 0x3dc, 3, __NA_, 0, NO_PAD_CTRL) 802#define MX51_PAD_GPIO1_5__DISP2_PIN16 IOMUX_PAD(0x808, 0x3dc, 3, __NA_, 0, NO_PAD_CTRL)
793#define MX51_PAD_GPIO1_5__GPIO1_5 IOMUX_PAD(0x808, 0x3dc, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) 803#define MX51_PAD_GPIO1_5__GPIO1_5 IOMUX_PAD(0x808, 0x3dc, 0, __NA_, 0, MX51_GPIO_PAD_CTRL)
794#define MX51_PAD_GPIO1_5__WDOG2_WDOG_B IOMUX_PAD(0x808, 0x3dc, 2, __NA_, 0, NO_PAD_CTRL) 804#define MX51_PAD_GPIO1_5__WDOG2_WDOG_B IOMUX_PAD(0x808, 0x3dc, 2, __NA_, 0, NO_PAD_CTRL)
805#define MX51_PAD_GPIO1_5__CCM_CLKO IOMUX_PAD(0x808, 0x3dc, 5, __NA_, 0, NO_PAD_CTRL)
795#define MX51_PAD_GPIO1_6__DISP2_PIN17 IOMUX_PAD(0x80c, 0x3e0, 4, __NA_, 0, NO_PAD_CTRL) 806#define MX51_PAD_GPIO1_6__DISP2_PIN17 IOMUX_PAD(0x80c, 0x3e0, 4, __NA_, 0, NO_PAD_CTRL)
796#define MX51_PAD_GPIO1_6__GPIO1_6 IOMUX_PAD(0x80c, 0x3e0, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) 807#define MX51_PAD_GPIO1_6__GPIO1_6 IOMUX_PAD(0x80c, 0x3e0, 0, __NA_, 0, MX51_GPIO_PAD_CTRL)
797#define MX51_PAD_GPIO1_6__REF_EN_B IOMUX_PAD(0x80c, 0x3e0, 3, __NA_, 0, NO_PAD_CTRL) 808#define MX51_PAD_GPIO1_6__REF_EN_B IOMUX_PAD(0x80c, 0x3e0, 3, __NA_, 0, NO_PAD_CTRL)
809#define MX51_PAD_GPIO1_6__GPT_CAPIN2 IOMUX_PAD(0x80c, 0x3e0, 6, __NA_, 0, NO_PAD_CTRL)
798#define MX51_PAD_GPIO1_7__CCM_OUT_0 IOMUX_PAD(0x810, 0x3e4, 3, __NA_, 0, NO_PAD_CTRL) 810#define MX51_PAD_GPIO1_7__CCM_OUT_0 IOMUX_PAD(0x810, 0x3e4, 3, __NA_, 0, NO_PAD_CTRL)
799#define MX51_PAD_GPIO1_7__GPIO1_7 IOMUX_PAD(0x810, 0x3e4, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) 811#define MX51_PAD_GPIO1_7__GPIO1_7 IOMUX_PAD(0x810, 0x3e4, 0, __NA_, 0, MX51_GPIO_PAD_CTRL)
800#define MX51_PAD_GPIO1_7__SD2_WP IOMUX_PAD(0x810, 0x3e4, 6, __NA_, 0, MX51_ESDHC_PAD_CTRL) 812#define MX51_PAD_GPIO1_7__SD2_WP IOMUX_PAD(0x810, 0x3e4, 6, __NA_, 0, MX51_ESDHC_PAD_CTRL)
@@ -803,11 +815,13 @@
803#define MX51_PAD_GPIO1_8__GPIO1_8 IOMUX_PAD(0x814, 0x3e8, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) 815#define MX51_PAD_GPIO1_8__GPIO1_8 IOMUX_PAD(0x814, 0x3e8, 0, __NA_, 0, MX51_GPIO_PAD_CTRL)
804#define MX51_PAD_GPIO1_8__SD2_CD IOMUX_PAD(0x814, 0x3e8, 6, __NA_, 0, MX51_ESDHC_PAD_CTRL) 816#define MX51_PAD_GPIO1_8__SD2_CD IOMUX_PAD(0x814, 0x3e8, 6, __NA_, 0, MX51_ESDHC_PAD_CTRL)
805#define MX51_PAD_GPIO1_8__USBH3_PWR IOMUX_PAD(0x814, 0x3e8, 1, __NA_, 0, NO_PAD_CTRL) 817#define MX51_PAD_GPIO1_8__USBH3_PWR IOMUX_PAD(0x814, 0x3e8, 1, __NA_, 0, NO_PAD_CTRL)
818#define MX51_PAD_GPIO1_8__CCM_CLKO2 IOMUX_PAD(0x814, 0x3e8, 4, __NA_, 0, NO_PAD_CTRL)
806#define MX51_PAD_GPIO1_9__CCM_OUT_1 IOMUX_PAD(0x818, 0x3ec, 3, __NA_, 0, NO_PAD_CTRL) 819#define MX51_PAD_GPIO1_9__CCM_OUT_1 IOMUX_PAD(0x818, 0x3ec, 3, __NA_, 0, NO_PAD_CTRL)
807#define MX51_PAD_GPIO1_9__DISP2_D1_CS IOMUX_PAD(0x818, 0x3ec, 2, __NA_, 0, NO_PAD_CTRL) 820#define MX51_PAD_GPIO1_9__DISP2_D1_CS IOMUX_PAD(0x818, 0x3ec, 2, __NA_, 0, NO_PAD_CTRL)
808#define MX51_PAD_GPIO1_9__DISP2_SER_CS IOMUX_PAD(0x818, 0x3ec, 7, __NA_, 0, NO_PAD_CTRL) 821#define MX51_PAD_GPIO1_9__DISP2_SER_CS IOMUX_PAD(0x818, 0x3ec, 7, __NA_, 0, NO_PAD_CTRL)
809#define MX51_PAD_GPIO1_9__GPIO1_9 IOMUX_PAD(0x818, 0x3ec, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) 822#define MX51_PAD_GPIO1_9__GPIO1_9 IOMUX_PAD(0x818, 0x3ec, 0, __NA_, 0, MX51_GPIO_PAD_CTRL)
810#define MX51_PAD_GPIO1_9__SD2_LCTL IOMUX_PAD(0x818, 0x3ec, 6, __NA_, 0, NO_PAD_CTRL) 823#define MX51_PAD_GPIO1_9__SD2_LCTL IOMUX_PAD(0x818, 0x3ec, 6, __NA_, 0, NO_PAD_CTRL)
811#define MX51_PAD_GPIO1_9__USBH3_OC IOMUX_PAD(0x818, 0x3ec, 1, __NA_, 0, NO_PAD_CTRL) 824#define MX51_PAD_GPIO1_9__USBH3_OC IOMUX_PAD(0x818, 0x3ec, 1, __NA_, 0, NO_PAD_CTRL)
825#define MX51_PAD_GPIO1_9__CCM_CLKO IOMUX_PAD(0x818, 0x3ec, 4, __NA_, 0, NO_PAD_CTRL)
812 826
813#endif /* __MACH_IOMUX_MX51_H__ */ 827#endif /* __MACH_IOMUX_MX51_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/iomux-v1.h b/arch/arm/plat-mxc/include/mach/iomux-v1.h
index f7d18046c04..02651a40fe2 100644
--- a/arch/arm/plat-mxc/include/mach/iomux-v1.h
+++ b/arch/arm/plat-mxc/include/mach/iomux-v1.h
@@ -85,13 +85,6 @@
85#define GPIO_BOUT_0 (2 << GPIO_BOUT_SHIFT) 85#define GPIO_BOUT_0 (2 << GPIO_BOUT_SHIFT)
86#define GPIO_BOUT_1 (3 << GPIO_BOUT_SHIFT) 86#define GPIO_BOUT_1 (3 << GPIO_BOUT_SHIFT)
87 87
88#define IRQ_GPIOA(x) (MXC_GPIO_IRQ_START + x)
89#define IRQ_GPIOB(x) (IRQ_GPIOA(32) + x)
90#define IRQ_GPIOC(x) (IRQ_GPIOB(32) + x)
91#define IRQ_GPIOD(x) (IRQ_GPIOC(32) + x)
92#define IRQ_GPIOE(x) (IRQ_GPIOD(32) + x)
93#define IRQ_GPIOF(x) (IRQ_GPIOE(32) + x)
94
95extern int mxc_gpio_mode(int gpio_mode); 88extern int mxc_gpio_mode(int gpio_mode);
96extern int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count, 89extern int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count,
97 const char *label); 90 const char *label);
diff --git a/arch/arm/plat-mxc/include/mach/ipu.h b/arch/arm/plat-mxc/include/mach/ipu.h
index a9221f1cc1a..539e559d18b 100644
--- a/arch/arm/plat-mxc/include/mach/ipu.h
+++ b/arch/arm/plat-mxc/include/mach/ipu.h
@@ -110,10 +110,6 @@ enum ipu_rotate_mode {
110 IPU_ROTATE_90_LEFT = 7, 110 IPU_ROTATE_90_LEFT = 7,
111}; 111};
112 112
113struct ipu_platform_data {
114 unsigned int irq_base;
115};
116
117/* 113/*
118 * Enumeration of DI ports for ADC. 114 * Enumeration of DI ports for ADC.
119 */ 115 */
diff --git a/arch/arm/plat-mxc/include/mach/irqs.h b/arch/arm/plat-mxc/include/mach/irqs.h
index fd9efb04465..d73f5e8ea9c 100644
--- a/arch/arm/plat-mxc/include/mach/irqs.h
+++ b/arch/arm/plat-mxc/include/mach/irqs.h
@@ -11,50 +11,6 @@
11#ifndef __ASM_ARCH_MXC_IRQS_H__ 11#ifndef __ASM_ARCH_MXC_IRQS_H__
12#define __ASM_ARCH_MXC_IRQS_H__ 12#define __ASM_ARCH_MXC_IRQS_H__
13 13
14#include <asm-generic/gpio.h>
15
16/*
17 * SoCs with GIC interrupt controller have 160 IRQs, those with TZIC
18 * have 128 IRQs, and those with AVIC have 64.
19 *
20 * To support single image, the biggest number should be defined on
21 * top of the list.
22 */
23#if defined CONFIG_ARM_GIC
24#define MXC_INTERNAL_IRQS 160
25#elif defined CONFIG_MXC_TZIC
26#define MXC_INTERNAL_IRQS 128
27#else
28#define MXC_INTERNAL_IRQS 64
29#endif
30
31#define MXC_GPIO_IRQ_START MXC_INTERNAL_IRQS
32
33/*
34 * The next 16 interrupts are for board specific purposes. Since
35 * the kernel can only run on one machine at a time, we can re-use
36 * these. If you need more, increase MXC_BOARD_IRQS, but keep it
37 * within sensible limits.
38 */
39#define MXC_BOARD_IRQ_START (MXC_INTERNAL_IRQS + ARCH_NR_GPIOS)
40
41#ifdef CONFIG_MACH_MX31ADS_WM1133_EV1
42#define MXC_BOARD_IRQS 80
43#else
44#define MXC_BOARD_IRQS 16
45#endif
46
47#define MXC_IPU_IRQ_START (MXC_BOARD_IRQ_START + MXC_BOARD_IRQS)
48
49#ifdef CONFIG_MX3_IPU_IRQS
50#define MX3_IPU_IRQS CONFIG_MX3_IPU_IRQS
51#else
52#define MX3_IPU_IRQS 0
53#endif
54/* REVISIT: Add IPU irqs on IMX51 */
55
56#define NR_IRQS (MXC_IPU_IRQ_START + MX3_IPU_IRQS)
57
58extern int imx_irq_set_priority(unsigned char irq, unsigned char prio); 14extern int imx_irq_set_priority(unsigned char irq, unsigned char prio);
59 15
60/* all normal IRQs can be FIQs */ 16/* all normal IRQs can be FIQs */
diff --git a/arch/arm/plat-mxc/include/mach/mx1.h b/arch/arm/plat-mxc/include/mach/mx1.h
index 2b7c08d13e8..45bd31cc34d 100644
--- a/arch/arm/plat-mxc/include/mach/mx1.h
+++ b/arch/arm/plat-mxc/include/mach/mx1.h
@@ -78,61 +78,62 @@
78#define MX1_IO_ADDRESS(x) IOMEM(MX1_IO_P2V(x)) 78#define MX1_IO_ADDRESS(x) IOMEM(MX1_IO_P2V(x))
79 79
80/* fixed interrput numbers */ 80/* fixed interrput numbers */
81#define MX1_INT_SOFTINT 0 81#include <asm/irq.h>
82#define MX1_INT_CSI 6 82#define MX1_INT_SOFTINT (NR_IRQS_LEGACY + 0)
83#define MX1_DSPA_MAC_INT 7 83#define MX1_INT_CSI (NR_IRQS_LEGACY + 6)
84#define MX1_DSPA_INT 8 84#define MX1_DSPA_MAC_INT (NR_IRQS_LEGACY + 7)
85#define MX1_COMP_INT 9 85#define MX1_DSPA_INT (NR_IRQS_LEGACY + 8)
86#define MX1_MSHC_XINT 10 86#define MX1_COMP_INT (NR_IRQS_LEGACY + 9)
87#define MX1_GPIO_INT_PORTA 11 87#define MX1_MSHC_XINT (NR_IRQS_LEGACY + 10)
88#define MX1_GPIO_INT_PORTB 12 88#define MX1_GPIO_INT_PORTA (NR_IRQS_LEGACY + 11)
89#define MX1_GPIO_INT_PORTC 13 89#define MX1_GPIO_INT_PORTB (NR_IRQS_LEGACY + 12)
90#define MX1_INT_LCDC 14 90#define MX1_GPIO_INT_PORTC (NR_IRQS_LEGACY + 13)
91#define MX1_SIM_INT 15 91#define MX1_INT_LCDC (NR_IRQS_LEGACY + 14)
92#define MX1_SIM_DATA_INT 16 92#define MX1_SIM_INT (NR_IRQS_LEGACY + 15)
93#define MX1_RTC_INT 17 93#define MX1_SIM_DATA_INT (NR_IRQS_LEGACY + 16)
94#define MX1_RTC_SAMINT 18 94#define MX1_RTC_INT (NR_IRQS_LEGACY + 17)
95#define MX1_INT_UART2PFERR 19 95#define MX1_RTC_SAMINT (NR_IRQS_LEGACY + 18)
96#define MX1_INT_UART2RTS 20 96#define MX1_INT_UART2PFERR (NR_IRQS_LEGACY + 19)
97#define MX1_INT_UART2DTR 21 97#define MX1_INT_UART2RTS (NR_IRQS_LEGACY + 20)
98#define MX1_INT_UART2UARTC 22 98#define MX1_INT_UART2DTR (NR_IRQS_LEGACY + 21)
99#define MX1_INT_UART2TX 23 99#define MX1_INT_UART2UARTC (NR_IRQS_LEGACY + 22)
100#define MX1_INT_UART2RX 24 100#define MX1_INT_UART2TX (NR_IRQS_LEGACY + 23)
101#define MX1_INT_UART1PFERR 25 101#define MX1_INT_UART2RX (NR_IRQS_LEGACY + 24)
102#define MX1_INT_UART1RTS 26 102#define MX1_INT_UART1PFERR (NR_IRQS_LEGACY + 25)
103#define MX1_INT_UART1DTR 27 103#define MX1_INT_UART1RTS (NR_IRQS_LEGACY + 26)
104#define MX1_INT_UART1UARTC 28 104#define MX1_INT_UART1DTR (NR_IRQS_LEGACY + 27)
105#define MX1_INT_UART1TX 29 105#define MX1_INT_UART1UARTC (NR_IRQS_LEGACY + 28)
106#define MX1_INT_UART1RX 30 106#define MX1_INT_UART1TX (NR_IRQS_LEGACY + 29)
107#define MX1_VOICE_DAC_INT 31 107#define MX1_INT_UART1RX (NR_IRQS_LEGACY + 30)
108#define MX1_VOICE_ADC_INT 32 108#define MX1_VOICE_DAC_INT (NR_IRQS_LEGACY + 31)
109#define MX1_PEN_DATA_INT 33 109#define MX1_VOICE_ADC_INT (NR_IRQS_LEGACY + 32)
110#define MX1_PWM_INT 34 110#define MX1_PEN_DATA_INT (NR_IRQS_LEGACY + 33)
111#define MX1_SDHC_INT 35 111#define MX1_PWM_INT (NR_IRQS_LEGACY + 34)
112#define MX1_INT_I2C 39 112#define MX1_SDHC_INT (NR_IRQS_LEGACY + 35)
113#define MX1_INT_CSPI2 40 113#define MX1_INT_I2C (NR_IRQS_LEGACY + 39)
114#define MX1_INT_CSPI1 41 114#define MX1_INT_CSPI2 (NR_IRQS_LEGACY + 40)
115#define MX1_SSI_TX_INT 42 115#define MX1_INT_CSPI1 (NR_IRQS_LEGACY + 41)
116#define MX1_SSI_TX_ERR_INT 43 116#define MX1_SSI_TX_INT (NR_IRQS_LEGACY + 42)
117#define MX1_SSI_RX_INT 44 117#define MX1_SSI_TX_ERR_INT (NR_IRQS_LEGACY + 43)
118#define MX1_SSI_RX_ERR_INT 45 118#define MX1_SSI_RX_INT (NR_IRQS_LEGACY + 44)
119#define MX1_TOUCH_INT 46 119#define MX1_SSI_RX_ERR_INT (NR_IRQS_LEGACY + 45)
120#define MX1_INT_USBD0 47 120#define MX1_TOUCH_INT (NR_IRQS_LEGACY + 46)
121#define MX1_INT_USBD1 48 121#define MX1_INT_USBD0 (NR_IRQS_LEGACY + 47)
122#define MX1_INT_USBD2 49 122#define MX1_INT_USBD1 (NR_IRQS_LEGACY + 48)
123#define MX1_INT_USBD3 50 123#define MX1_INT_USBD2 (NR_IRQS_LEGACY + 49)
124#define MX1_INT_USBD4 51 124#define MX1_INT_USBD3 (NR_IRQS_LEGACY + 50)
125#define MX1_INT_USBD5 52 125#define MX1_INT_USBD4 (NR_IRQS_LEGACY + 51)
126#define MX1_INT_USBD6 53 126#define MX1_INT_USBD5 (NR_IRQS_LEGACY + 52)
127#define MX1_BTSYS_INT 55 127#define MX1_INT_USBD6 (NR_IRQS_LEGACY + 53)
128#define MX1_BTTIM_INT 56 128#define MX1_BTSYS_INT (NR_IRQS_LEGACY + 55)
129#define MX1_BTWUI_INT 57 129#define MX1_BTTIM_INT (NR_IRQS_LEGACY + 56)
130#define MX1_TIM2_INT 58 130#define MX1_BTWUI_INT (NR_IRQS_LEGACY + 57)
131#define MX1_TIM1_INT 59 131#define MX1_TIM2_INT (NR_IRQS_LEGACY + 58)
132#define MX1_DMA_ERR 60 132#define MX1_TIM1_INT (NR_IRQS_LEGACY + 59)
133#define MX1_DMA_INT 61 133#define MX1_DMA_ERR (NR_IRQS_LEGACY + 60)
134#define MX1_GPIO_INT_PORTD 62 134#define MX1_DMA_INT (NR_IRQS_LEGACY + 61)
135#define MX1_WDT_INT 63 135#define MX1_GPIO_INT_PORTD (NR_IRQS_LEGACY + 62)
136#define MX1_WDT_INT (NR_IRQS_LEGACY + 63)
136 137
137/* DMA */ 138/* DMA */
138#define MX1_DMA_REQ_UART3_T 2 139#define MX1_DMA_REQ_UART3_T 2
diff --git a/arch/arm/plat-mxc/include/mach/mx21.h b/arch/arm/plat-mxc/include/mach/mx21.h
index 6cd049ebbd8..468738aa997 100644
--- a/arch/arm/plat-mxc/include/mach/mx21.h
+++ b/arch/arm/plat-mxc/include/mach/mx21.h
@@ -99,59 +99,60 @@
99#define MX21_IO_ADDRESS(x) IOMEM(MX21_IO_P2V(x)) 99#define MX21_IO_ADDRESS(x) IOMEM(MX21_IO_P2V(x))
100 100
101/* fixed interrupt numbers */ 101/* fixed interrupt numbers */
102#define MX21_INT_CSPI3 6 102#include <asm/irq.h>
103#define MX21_INT_GPIO 8 103#define MX21_INT_CSPI3 (NR_IRQS_LEGACY + 6)
104#define MX21_INT_FIRI 9 104#define MX21_INT_GPIO (NR_IRQS_LEGACY + 8)
105#define MX21_INT_SDHC2 10 105#define MX21_INT_FIRI (NR_IRQS_LEGACY + 9)
106#define MX21_INT_SDHC1 11 106#define MX21_INT_SDHC2 (NR_IRQS_LEGACY + 10)
107#define MX21_INT_I2C 12 107#define MX21_INT_SDHC1 (NR_IRQS_LEGACY + 11)
108#define MX21_INT_SSI2 13 108#define MX21_INT_I2C (NR_IRQS_LEGACY + 12)
109#define MX21_INT_SSI1 14 109#define MX21_INT_SSI2 (NR_IRQS_LEGACY + 13)
110#define MX21_INT_CSPI2 15 110#define MX21_INT_SSI1 (NR_IRQS_LEGACY + 14)
111#define MX21_INT_CSPI1 16 111#define MX21_INT_CSPI2 (NR_IRQS_LEGACY + 15)
112#define MX21_INT_UART4 17 112#define MX21_INT_CSPI1 (NR_IRQS_LEGACY + 16)
113#define MX21_INT_UART3 18 113#define MX21_INT_UART4 (NR_IRQS_LEGACY + 17)
114#define MX21_INT_UART2 19 114#define MX21_INT_UART3 (NR_IRQS_LEGACY + 18)
115#define MX21_INT_UART1 20 115#define MX21_INT_UART2 (NR_IRQS_LEGACY + 19)
116#define MX21_INT_KPP 21 116#define MX21_INT_UART1 (NR_IRQS_LEGACY + 20)
117#define MX21_INT_RTC 22 117#define MX21_INT_KPP (NR_IRQS_LEGACY + 21)
118#define MX21_INT_PWM 23 118#define MX21_INT_RTC (NR_IRQS_LEGACY + 22)
119#define MX21_INT_GPT3 24 119#define MX21_INT_PWM (NR_IRQS_LEGACY + 23)
120#define MX21_INT_GPT2 25 120#define MX21_INT_GPT3 (NR_IRQS_LEGACY + 24)
121#define MX21_INT_GPT1 26 121#define MX21_INT_GPT2 (NR_IRQS_LEGACY + 25)
122#define MX21_INT_WDOG 27 122#define MX21_INT_GPT1 (NR_IRQS_LEGACY + 26)
123#define MX21_INT_PCMCIA 28 123#define MX21_INT_WDOG (NR_IRQS_LEGACY + 27)
124#define MX21_INT_NFC 29 124#define MX21_INT_PCMCIA (NR_IRQS_LEGACY + 28)
125#define MX21_INT_BMI 30 125#define MX21_INT_NFC (NR_IRQS_LEGACY + 29)
126#define MX21_INT_CSI 31 126#define MX21_INT_BMI (NR_IRQS_LEGACY + 30)
127#define MX21_INT_DMACH0 32 127#define MX21_INT_CSI (NR_IRQS_LEGACY + 31)
128#define MX21_INT_DMACH1 33 128#define MX21_INT_DMACH0 (NR_IRQS_LEGACY + 32)
129#define MX21_INT_DMACH2 34 129#define MX21_INT_DMACH1 (NR_IRQS_LEGACY + 33)
130#define MX21_INT_DMACH3 35 130#define MX21_INT_DMACH2 (NR_IRQS_LEGACY + 34)
131#define MX21_INT_DMACH4 36 131#define MX21_INT_DMACH3 (NR_IRQS_LEGACY + 35)
132#define MX21_INT_DMACH5 37 132#define MX21_INT_DMACH4 (NR_IRQS_LEGACY + 36)
133#define MX21_INT_DMACH6 38 133#define MX21_INT_DMACH5 (NR_IRQS_LEGACY + 37)
134#define MX21_INT_DMACH7 39 134#define MX21_INT_DMACH6 (NR_IRQS_LEGACY + 38)
135#define MX21_INT_DMACH8 40 135#define MX21_INT_DMACH7 (NR_IRQS_LEGACY + 39)
136#define MX21_INT_DMACH9 41 136#define MX21_INT_DMACH8 (NR_IRQS_LEGACY + 40)
137#define MX21_INT_DMACH10 42 137#define MX21_INT_DMACH9 (NR_IRQS_LEGACY + 41)
138#define MX21_INT_DMACH11 43 138#define MX21_INT_DMACH10 (NR_IRQS_LEGACY + 42)
139#define MX21_INT_DMACH12 44 139#define MX21_INT_DMACH11 (NR_IRQS_LEGACY + 43)
140#define MX21_INT_DMACH13 45 140#define MX21_INT_DMACH12 (NR_IRQS_LEGACY + 44)
141#define MX21_INT_DMACH14 46 141#define MX21_INT_DMACH13 (NR_IRQS_LEGACY + 45)
142#define MX21_INT_DMACH15 47 142#define MX21_INT_DMACH14 (NR_IRQS_LEGACY + 46)
143#define MX21_INT_EMMAENC 49 143#define MX21_INT_DMACH15 (NR_IRQS_LEGACY + 47)
144#define MX21_INT_EMMADEC 50 144#define MX21_INT_EMMAENC (NR_IRQS_LEGACY + 49)
145#define MX21_INT_EMMAPRP 51 145#define MX21_INT_EMMADEC (NR_IRQS_LEGACY + 50)
146#define MX21_INT_EMMAPP 52 146#define MX21_INT_EMMAPRP (NR_IRQS_LEGACY + 51)
147#define MX21_INT_USBWKUP 53 147#define MX21_INT_EMMAPP (NR_IRQS_LEGACY + 52)
148#define MX21_INT_USBDMA 54 148#define MX21_INT_USBWKUP (NR_IRQS_LEGACY + 53)
149#define MX21_INT_USBHOST 55 149#define MX21_INT_USBDMA (NR_IRQS_LEGACY + 54)
150#define MX21_INT_USBFUNC 56 150#define MX21_INT_USBHOST (NR_IRQS_LEGACY + 55)
151#define MX21_INT_USBMNP 57 151#define MX21_INT_USBFUNC (NR_IRQS_LEGACY + 56)
152#define MX21_INT_USBCTRL 58 152#define MX21_INT_USBMNP (NR_IRQS_LEGACY + 57)
153#define MX21_INT_SLCDC 60 153#define MX21_INT_USBCTRL (NR_IRQS_LEGACY + 58)
154#define MX21_INT_LCDC 61 154#define MX21_INT_SLCDC (NR_IRQS_LEGACY + 60)
155#define MX21_INT_LCDC (NR_IRQS_LEGACY + 61)
155 156
156/* fixed DMA request numbers */ 157/* fixed DMA request numbers */
157#define MX21_DMA_REQ_CSPI3_RX 1 158#define MX21_DMA_REQ_CSPI3_RX 1
diff --git a/arch/arm/plat-mxc/include/mach/mx25.h b/arch/arm/plat-mxc/include/mach/mx25.h
index ccebf5ba12f..627d94f1b01 100644
--- a/arch/arm/plat-mxc/include/mach/mx25.h
+++ b/arch/arm/plat-mxc/include/mach/mx25.h
@@ -61,40 +61,44 @@
61#define MX25_IO_P2V(x) IMX_IO_P2V(x) 61#define MX25_IO_P2V(x) IMX_IO_P2V(x)
62#define MX25_IO_ADDRESS(x) IOMEM(MX25_IO_P2V(x)) 62#define MX25_IO_ADDRESS(x) IOMEM(MX25_IO_P2V(x))
63 63
64#define MX25_INT_CSPI3 0 64/*
65#define MX25_INT_I2C1 3 65 * Interrupt numbers
66#define MX25_INT_I2C2 4 66 */
67#define MX25_INT_UART4 5 67#include <asm/irq.h>
68#define MX25_INT_ESDHC2 8 68#define MX25_INT_CSPI3 (NR_IRQS_LEGACY + 0)
69#define MX25_INT_ESDHC1 9 69#define MX25_INT_I2C1 (NR_IRQS_LEGACY + 3)
70#define MX25_INT_I2C3 10 70#define MX25_INT_I2C2 (NR_IRQS_LEGACY + 4)
71#define MX25_INT_SSI2 11 71#define MX25_INT_UART4 (NR_IRQS_LEGACY + 5)
72#define MX25_INT_SSI1 12 72#define MX25_INT_ESDHC2 (NR_IRQS_LEGACY + 8)
73#define MX25_INT_CSPI2 13 73#define MX25_INT_ESDHC1 (NR_IRQS_LEGACY + 9)
74#define MX25_INT_CSPI1 14 74#define MX25_INT_I2C3 (NR_IRQS_LEGACY + 10)
75#define MX25_INT_GPIO3 16 75#define MX25_INT_SSI2 (NR_IRQS_LEGACY + 11)
76#define MX25_INT_CSI 17 76#define MX25_INT_SSI1 (NR_IRQS_LEGACY + 12)
77#define MX25_INT_UART3 18 77#define MX25_INT_CSPI2 (NR_IRQS_LEGACY + 13)
78#define MX25_INT_GPIO4 23 78#define MX25_INT_CSPI1 (NR_IRQS_LEGACY + 14)
79#define MX25_INT_KPP 24 79#define MX25_INT_GPIO3 (NR_IRQS_LEGACY + 16)
80#define MX25_INT_DRYICE 25 80#define MX25_INT_CSI (NR_IRQS_LEGACY + 17)
81#define MX25_INT_PWM1 26 81#define MX25_INT_UART3 (NR_IRQS_LEGACY + 18)
82#define MX25_INT_UART2 32 82#define MX25_INT_GPIO4 (NR_IRQS_LEGACY + 23)
83#define MX25_INT_NFC 33 83#define MX25_INT_KPP (NR_IRQS_LEGACY + 24)
84#define MX25_INT_SDMA 34 84#define MX25_INT_DRYICE (NR_IRQS_LEGACY + 25)
85#define MX25_INT_USB_HS 35 85#define MX25_INT_PWM1 (NR_IRQS_LEGACY + 26)
86#define MX25_INT_PWM2 36 86#define MX25_INT_UART2 (NR_IRQS_LEGACY + 32)
87#define MX25_INT_USB_OTG 37 87#define MX25_INT_NFC (NR_IRQS_LEGACY + 33)
88#define MX25_INT_LCDC 39 88#define MX25_INT_SDMA (NR_IRQS_LEGACY + 34)
89#define MX25_INT_UART5 40 89#define MX25_INT_USB_HS (NR_IRQS_LEGACY + 35)
90#define MX25_INT_PWM3 41 90#define MX25_INT_PWM2 (NR_IRQS_LEGACY + 36)
91#define MX25_INT_PWM4 42 91#define MX25_INT_USB_OTG (NR_IRQS_LEGACY + 37)
92#define MX25_INT_CAN1 43 92#define MX25_INT_LCDC (NR_IRQS_LEGACY + 39)
93#define MX25_INT_CAN2 44 93#define MX25_INT_UART5 (NR_IRQS_LEGACY + 40)
94#define MX25_INT_UART1 45 94#define MX25_INT_PWM3 (NR_IRQS_LEGACY + 41)
95#define MX25_INT_GPIO2 51 95#define MX25_INT_PWM4 (NR_IRQS_LEGACY + 42)
96#define MX25_INT_GPIO1 52 96#define MX25_INT_CAN1 (NR_IRQS_LEGACY + 43)
97#define MX25_INT_FEC 57 97#define MX25_INT_CAN2 (NR_IRQS_LEGACY + 44)
98#define MX25_INT_UART1 (NR_IRQS_LEGACY + 45)
99#define MX25_INT_GPIO2 (NR_IRQS_LEGACY + 51)
100#define MX25_INT_GPIO1 (NR_IRQS_LEGACY + 52)
101#define MX25_INT_FEC (NR_IRQS_LEGACY + 57)
98 102
99#define MX25_DMA_REQ_SSI2_RX1 22 103#define MX25_DMA_REQ_SSI2_RX1 22
100#define MX25_DMA_REQ_SSI2_TX1 23 104#define MX25_DMA_REQ_SSI2_TX1 23
diff --git a/arch/arm/plat-mxc/include/mach/mx27.h b/arch/arm/plat-mxc/include/mach/mx27.h
index 6265357284d..e074616d54c 100644
--- a/arch/arm/plat-mxc/include/mach/mx27.h
+++ b/arch/arm/plat-mxc/include/mach/mx27.h
@@ -128,69 +128,70 @@
128#define MX27_IO_ADDRESS(x) IOMEM(MX27_IO_P2V(x)) 128#define MX27_IO_ADDRESS(x) IOMEM(MX27_IO_P2V(x))
129 129
130/* fixed interrupt numbers */ 130/* fixed interrupt numbers */
131#define MX27_INT_I2C2 1 131#include <asm/irq.h>
132#define MX27_INT_GPT6 2 132#define MX27_INT_I2C2 (NR_IRQS_LEGACY + 1)
133#define MX27_INT_GPT5 3 133#define MX27_INT_GPT6 (NR_IRQS_LEGACY + 2)
134#define MX27_INT_GPT4 4 134#define MX27_INT_GPT5 (NR_IRQS_LEGACY + 3)
135#define MX27_INT_RTIC 5 135#define MX27_INT_GPT4 (NR_IRQS_LEGACY + 4)
136#define MX27_INT_CSPI3 6 136#define MX27_INT_RTIC (NR_IRQS_LEGACY + 5)
137#define MX27_INT_SDHC 7 137#define MX27_INT_CSPI3 (NR_IRQS_LEGACY + 6)
138#define MX27_INT_GPIO 8 138#define MX27_INT_SDHC (NR_IRQS_LEGACY + 7)
139#define MX27_INT_SDHC3 9 139#define MX27_INT_GPIO (NR_IRQS_LEGACY + 8)
140#define MX27_INT_SDHC2 10 140#define MX27_INT_SDHC3 (NR_IRQS_LEGACY + 9)
141#define MX27_INT_SDHC1 11 141#define MX27_INT_SDHC2 (NR_IRQS_LEGACY + 10)
142#define MX27_INT_I2C1 12 142#define MX27_INT_SDHC1 (NR_IRQS_LEGACY + 11)
143#define MX27_INT_SSI2 13 143#define MX27_INT_I2C1 (NR_IRQS_LEGACY + 12)
144#define MX27_INT_SSI1 14 144#define MX27_INT_SSI2 (NR_IRQS_LEGACY + 13)
145#define MX27_INT_CSPI2 15 145#define MX27_INT_SSI1 (NR_IRQS_LEGACY + 14)
146#define MX27_INT_CSPI1 16 146#define MX27_INT_CSPI2 (NR_IRQS_LEGACY + 15)
147#define MX27_INT_UART4 17 147#define MX27_INT_CSPI1 (NR_IRQS_LEGACY + 16)
148#define MX27_INT_UART3 18 148#define MX27_INT_UART4 (NR_IRQS_LEGACY + 17)
149#define MX27_INT_UART2 19 149#define MX27_INT_UART3 (NR_IRQS_LEGACY + 18)
150#define MX27_INT_UART1 20 150#define MX27_INT_UART2 (NR_IRQS_LEGACY + 19)
151#define MX27_INT_KPP 21 151#define MX27_INT_UART1 (NR_IRQS_LEGACY + 20)
152#define MX27_INT_RTC 22 152#define MX27_INT_KPP (NR_IRQS_LEGACY + 21)
153#define MX27_INT_PWM 23 153#define MX27_INT_RTC (NR_IRQS_LEGACY + 22)
154#define MX27_INT_GPT3 24 154#define MX27_INT_PWM (NR_IRQS_LEGACY + 23)
155#define MX27_INT_GPT2 25 155#define MX27_INT_GPT3 (NR_IRQS_LEGACY + 24)
156#define MX27_INT_GPT1 26 156#define MX27_INT_GPT2 (NR_IRQS_LEGACY + 25)
157#define MX27_INT_WDOG 27 157#define MX27_INT_GPT1 (NR_IRQS_LEGACY + 26)
158#define MX27_INT_PCMCIA 28 158#define MX27_INT_WDOG (NR_IRQS_LEGACY + 27)
159#define MX27_INT_NFC 29 159#define MX27_INT_PCMCIA (NR_IRQS_LEGACY + 28)
160#define MX27_INT_ATA 30 160#define MX27_INT_NFC (NR_IRQS_LEGACY + 29)
161#define MX27_INT_CSI 31 161#define MX27_INT_ATA (NR_IRQS_LEGACY + 30)
162#define MX27_INT_DMACH0 32 162#define MX27_INT_CSI (NR_IRQS_LEGACY + 31)
163#define MX27_INT_DMACH1 33 163#define MX27_INT_DMACH0 (NR_IRQS_LEGACY + 32)
164#define MX27_INT_DMACH2 34 164#define MX27_INT_DMACH1 (NR_IRQS_LEGACY + 33)
165#define MX27_INT_DMACH3 35 165#define MX27_INT_DMACH2 (NR_IRQS_LEGACY + 34)
166#define MX27_INT_DMACH4 36 166#define MX27_INT_DMACH3 (NR_IRQS_LEGACY + 35)
167#define MX27_INT_DMACH5 37 167#define MX27_INT_DMACH4 (NR_IRQS_LEGACY + 36)
168#define MX27_INT_DMACH6 38 168#define MX27_INT_DMACH5 (NR_IRQS_LEGACY + 37)
169#define MX27_INT_DMACH7 39 169#define MX27_INT_DMACH6 (NR_IRQS_LEGACY + 38)
170#define MX27_INT_DMACH8 40 170#define MX27_INT_DMACH7 (NR_IRQS_LEGACY + 39)
171#define MX27_INT_DMACH9 41 171#define MX27_INT_DMACH8 (NR_IRQS_LEGACY + 40)
172#define MX27_INT_DMACH10 42 172#define MX27_INT_DMACH9 (NR_IRQS_LEGACY + 41)
173#define MX27_INT_DMACH11 43 173#define MX27_INT_DMACH10 (NR_IRQS_LEGACY + 42)
174#define MX27_INT_DMACH12 44 174#define MX27_INT_DMACH11 (NR_IRQS_LEGACY + 43)
175#define MX27_INT_DMACH13 45 175#define MX27_INT_DMACH12 (NR_IRQS_LEGACY + 44)
176#define MX27_INT_DMACH14 46 176#define MX27_INT_DMACH13 (NR_IRQS_LEGACY + 45)
177#define MX27_INT_DMACH15 47 177#define MX27_INT_DMACH14 (NR_IRQS_LEGACY + 46)
178#define MX27_INT_UART6 48 178#define MX27_INT_DMACH15 (NR_IRQS_LEGACY + 47)
179#define MX27_INT_UART5 49 179#define MX27_INT_UART6 (NR_IRQS_LEGACY + 48)
180#define MX27_INT_FEC 50 180#define MX27_INT_UART5 (NR_IRQS_LEGACY + 49)
181#define MX27_INT_EMMAPRP 51 181#define MX27_INT_FEC (NR_IRQS_LEGACY + 50)
182#define MX27_INT_EMMAPP 52 182#define MX27_INT_EMMAPRP (NR_IRQS_LEGACY + 51)
183#define MX27_INT_VPU 53 183#define MX27_INT_EMMAPP (NR_IRQS_LEGACY + 52)
184#define MX27_INT_USB_HS1 54 184#define MX27_INT_VPU (NR_IRQS_LEGACY + 53)
185#define MX27_INT_USB_HS2 55 185#define MX27_INT_USB_HS1 (NR_IRQS_LEGACY + 54)
186#define MX27_INT_USB_OTG 56 186#define MX27_INT_USB_HS2 (NR_IRQS_LEGACY + 55)
187#define MX27_INT_SCC_SMN 57 187#define MX27_INT_USB_OTG (NR_IRQS_LEGACY + 56)
188#define MX27_INT_SCC_SCM 58 188#define MX27_INT_SCC_SMN (NR_IRQS_LEGACY + 57)
189#define MX27_INT_SAHARA 59 189#define MX27_INT_SCC_SCM (NR_IRQS_LEGACY + 58)
190#define MX27_INT_SLCDC 60 190#define MX27_INT_SAHARA (NR_IRQS_LEGACY + 59)
191#define MX27_INT_LCDC 61 191#define MX27_INT_SLCDC (NR_IRQS_LEGACY + 60)
192#define MX27_INT_IIM 62 192#define MX27_INT_LCDC (NR_IRQS_LEGACY + 61)
193#define MX27_INT_CCM 63 193#define MX27_INT_IIM (NR_IRQS_LEGACY + 62)
194#define MX27_INT_CCM (NR_IRQS_LEGACY + 63)
194 195
195/* fixed DMA request numbers */ 196/* fixed DMA request numbers */
196#define MX27_DMA_REQ_CSPI3_RX 1 197#define MX27_DMA_REQ_CSPI3_RX 1
diff --git a/arch/arm/plat-mxc/include/mach/mx2x.h b/arch/arm/plat-mxc/include/mach/mx2x.h
index 6d07839fdec..11642f5b224 100644
--- a/arch/arm/plat-mxc/include/mach/mx2x.h
+++ b/arch/arm/plat-mxc/include/mach/mx2x.h
@@ -68,49 +68,50 @@
68#define MX2x_CSI_BASE_ADDR (MX2x_SAHB1_BASE_ADDR + 0x0000) 68#define MX2x_CSI_BASE_ADDR (MX2x_SAHB1_BASE_ADDR + 0x0000)
69 69
70/* fixed interrupt numbers */ 70/* fixed interrupt numbers */
71#define MX2x_INT_CSPI3 6 71#include <asm/irq.h>
72#define MX2x_INT_GPIO 8 72#define MX2x_INT_CSPI3 (NR_IRQS_LEGACY + 6)
73#define MX2x_INT_SDHC2 10 73#define MX2x_INT_GPIO (NR_IRQS_LEGACY + 8)
74#define MX2x_INT_SDHC1 11 74#define MX2x_INT_SDHC2 (NR_IRQS_LEGACY + 10)
75#define MX2x_INT_I2C 12 75#define MX2x_INT_SDHC1 (NR_IRQS_LEGACY + 11)
76#define MX2x_INT_SSI2 13 76#define MX2x_INT_I2C (NR_IRQS_LEGACY + 12)
77#define MX2x_INT_SSI1 14 77#define MX2x_INT_SSI2 (NR_IRQS_LEGACY + 13)
78#define MX2x_INT_CSPI2 15 78#define MX2x_INT_SSI1 (NR_IRQS_LEGACY + 14)
79#define MX2x_INT_CSPI1 16 79#define MX2x_INT_CSPI2 (NR_IRQS_LEGACY + 15)
80#define MX2x_INT_UART4 17 80#define MX2x_INT_CSPI1 (NR_IRQS_LEGACY + 16)
81#define MX2x_INT_UART3 18 81#define MX2x_INT_UART4 (NR_IRQS_LEGACY + 17)
82#define MX2x_INT_UART2 19 82#define MX2x_INT_UART3 (NR_IRQS_LEGACY + 18)
83#define MX2x_INT_UART1 20 83#define MX2x_INT_UART2 (NR_IRQS_LEGACY + 19)
84#define MX2x_INT_KPP 21 84#define MX2x_INT_UART1 (NR_IRQS_LEGACY + 20)
85#define MX2x_INT_RTC 22 85#define MX2x_INT_KPP (NR_IRQS_LEGACY + 21)
86#define MX2x_INT_PWM 23 86#define MX2x_INT_RTC (NR_IRQS_LEGACY + 22)
87#define MX2x_INT_GPT3 24 87#define MX2x_INT_PWM (NR_IRQS_LEGACY + 23)
88#define MX2x_INT_GPT2 25 88#define MX2x_INT_GPT3 (NR_IRQS_LEGACY + 24)
89#define MX2x_INT_GPT1 26 89#define MX2x_INT_GPT2 (NR_IRQS_LEGACY + 25)
90#define MX2x_INT_WDOG 27 90#define MX2x_INT_GPT1 (NR_IRQS_LEGACY + 26)
91#define MX2x_INT_PCMCIA 28 91#define MX2x_INT_WDOG (NR_IRQS_LEGACY + 27)
92#define MX2x_INT_NANDFC 29 92#define MX2x_INT_PCMCIA (NR_IRQS_LEGACY + 28)
93#define MX2x_INT_CSI 31 93#define MX2x_INT_NANDFC (NR_IRQS_LEGACY + 29)
94#define MX2x_INT_DMACH0 32 94#define MX2x_INT_CSI (NR_IRQS_LEGACY + 31)
95#define MX2x_INT_DMACH1 33 95#define MX2x_INT_DMACH0 (NR_IRQS_LEGACY + 32)
96#define MX2x_INT_DMACH2 34 96#define MX2x_INT_DMACH1 (NR_IRQS_LEGACY + 33)
97#define MX2x_INT_DMACH3 35 97#define MX2x_INT_DMACH2 (NR_IRQS_LEGACY + 34)
98#define MX2x_INT_DMACH4 36 98#define MX2x_INT_DMACH3 (NR_IRQS_LEGACY + 35)
99#define MX2x_INT_DMACH5 37 99#define MX2x_INT_DMACH4 (NR_IRQS_LEGACY + 36)
100#define MX2x_INT_DMACH6 38 100#define MX2x_INT_DMACH5 (NR_IRQS_LEGACY + 37)
101#define MX2x_INT_DMACH7 39 101#define MX2x_INT_DMACH6 (NR_IRQS_LEGACY + 38)
102#define MX2x_INT_DMACH8 40 102#define MX2x_INT_DMACH7 (NR_IRQS_LEGACY + 39)
103#define MX2x_INT_DMACH9 41 103#define MX2x_INT_DMACH8 (NR_IRQS_LEGACY + 40)
104#define MX2x_INT_DMACH10 42 104#define MX2x_INT_DMACH9 (NR_IRQS_LEGACY + 41)
105#define MX2x_INT_DMACH11 43 105#define MX2x_INT_DMACH10 (NR_IRQS_LEGACY + 42)
106#define MX2x_INT_DMACH12 44 106#define MX2x_INT_DMACH11 (NR_IRQS_LEGACY + 43)
107#define MX2x_INT_DMACH13 45 107#define MX2x_INT_DMACH12 (NR_IRQS_LEGACY + 44)
108#define MX2x_INT_DMACH14 46 108#define MX2x_INT_DMACH13 (NR_IRQS_LEGACY + 45)
109#define MX2x_INT_DMACH15 47 109#define MX2x_INT_DMACH14 (NR_IRQS_LEGACY + 46)
110#define MX2x_INT_EMMAPRP 51 110#define MX2x_INT_DMACH15 (NR_IRQS_LEGACY + 47)
111#define MX2x_INT_EMMAPP 52 111#define MX2x_INT_EMMAPRP (NR_IRQS_LEGACY + 51)
112#define MX2x_INT_SLCDC 60 112#define MX2x_INT_EMMAPP (NR_IRQS_LEGACY + 52)
113#define MX2x_INT_LCDC 61 113#define MX2x_INT_SLCDC (NR_IRQS_LEGACY + 60)
114#define MX2x_INT_LCDC (NR_IRQS_LEGACY + 61)
114 115
115/* fixed DMA request numbers */ 116/* fixed DMA request numbers */
116#define MX2x_DMA_REQ_CSPI3_RX 1 117#define MX2x_DMA_REQ_CSPI3_RX 1
diff --git a/arch/arm/plat-mxc/include/mach/mx31.h b/arch/arm/plat-mxc/include/mach/mx31.h
index e27619e442c..dbced61d9fd 100644
--- a/arch/arm/plat-mxc/include/mach/mx31.h
+++ b/arch/arm/plat-mxc/include/mach/mx31.h
@@ -118,63 +118,67 @@
118#define MX31_IO_P2V(x) IMX_IO_P2V(x) 118#define MX31_IO_P2V(x) IMX_IO_P2V(x)
119#define MX31_IO_ADDRESS(x) IOMEM(MX31_IO_P2V(x)) 119#define MX31_IO_ADDRESS(x) IOMEM(MX31_IO_P2V(x))
120 120
121#define MX31_INT_I2C3 3 121/*
122#define MX31_INT_I2C2 4 122 * Interrupt numbers
123#define MX31_INT_MPEG4_ENCODER 5 123 */
124#define MX31_INT_RTIC 6 124#include <asm/irq.h>
125#define MX31_INT_FIRI 7 125#define MX31_INT_I2C3 (NR_IRQS_LEGACY + 3)
126#define MX31_INT_SDHC2 8 126#define MX31_INT_I2C2 (NR_IRQS_LEGACY + 4)
127#define MX31_INT_SDHC1 9 127#define MX31_INT_MPEG4_ENCODER (NR_IRQS_LEGACY + 5)
128#define MX31_INT_I2C1 10 128#define MX31_INT_RTIC (NR_IRQS_LEGACY + 6)
129#define MX31_INT_SSI2 11 129#define MX31_INT_FIRI (NR_IRQS_LEGACY + 7)
130#define MX31_INT_SSI1 12 130#define MX31_INT_SDHC2 (NR_IRQS_LEGACY + 8)
131#define MX31_INT_CSPI2 13 131#define MX31_INT_SDHC1 (NR_IRQS_LEGACY + 9)
132#define MX31_INT_CSPI1 14 132#define MX31_INT_I2C1 (NR_IRQS_LEGACY + 10)
133#define MX31_INT_ATA 15 133#define MX31_INT_SSI2 (NR_IRQS_LEGACY + 11)
134#define MX31_INT_MBX 16 134#define MX31_INT_SSI1 (NR_IRQS_LEGACY + 12)
135#define MX31_INT_CSPI3 17 135#define MX31_INT_CSPI2 (NR_IRQS_LEGACY + 13)
136#define MX31_INT_UART3 18 136#define MX31_INT_CSPI1 (NR_IRQS_LEGACY + 14)
137#define MX31_INT_IIM 19 137#define MX31_INT_ATA (NR_IRQS_LEGACY + 15)
138#define MX31_INT_SIM2 20 138#define MX31_INT_MBX (NR_IRQS_LEGACY + 16)
139#define MX31_INT_SIM1 21 139#define MX31_INT_CSPI3 (NR_IRQS_LEGACY + 17)
140#define MX31_INT_RNGA 22 140#define MX31_INT_UART3 (NR_IRQS_LEGACY + 18)
141#define MX31_INT_EVTMON 23 141#define MX31_INT_IIM (NR_IRQS_LEGACY + 19)
142#define MX31_INT_KPP 24 142#define MX31_INT_SIM2 (NR_IRQS_LEGACY + 20)
143#define MX31_INT_RTC 25 143#define MX31_INT_SIM1 (NR_IRQS_LEGACY + 21)
144#define MX31_INT_PWM 26 144#define MX31_INT_RNGA (NR_IRQS_LEGACY + 22)
145#define MX31_INT_EPIT2 27 145#define MX31_INT_EVTMON (NR_IRQS_LEGACY + 23)
146#define MX31_INT_EPIT1 28 146#define MX31_INT_KPP (NR_IRQS_LEGACY + 24)
147#define MX31_INT_GPT 29 147#define MX31_INT_RTC (NR_IRQS_LEGACY + 25)
148#define MX31_INT_POWER_FAIL 30 148#define MX31_INT_PWM (NR_IRQS_LEGACY + 26)
149#define MX31_INT_CCM_DVFS 31 149#define MX31_INT_EPIT2 (NR_IRQS_LEGACY + 27)
150#define MX31_INT_UART2 32 150#define MX31_INT_EPIT1 (NR_IRQS_LEGACY + 28)
151#define MX31_INT_NFC 33 151#define MX31_INT_GPT (NR_IRQS_LEGACY + 29)
152#define MX31_INT_SDMA 34 152#define MX31_INT_POWER_FAIL (NR_IRQS_LEGACY + 30)
153#define MX31_INT_USB_HS1 35 153#define MX31_INT_CCM_DVFS (NR_IRQS_LEGACY + 31)
154#define MX31_INT_USB_HS2 36 154#define MX31_INT_UART2 (NR_IRQS_LEGACY + 32)
155#define MX31_INT_USB_OTG 37 155#define MX31_INT_NFC (NR_IRQS_LEGACY + 33)
156#define MX31_INT_MSHC1 39 156#define MX31_INT_SDMA (NR_IRQS_LEGACY + 34)
157#define MX31_INT_MSHC2 40 157#define MX31_INT_USB_HS1 (NR_IRQS_LEGACY + 35)
158#define MX31_INT_IPU_ERR 41 158#define MX31_INT_USB_HS2 (NR_IRQS_LEGACY + 36)
159#define MX31_INT_IPU_SYN 42 159#define MX31_INT_USB_OTG (NR_IRQS_LEGACY + 37)
160#define MX31_INT_UART1 45 160#define MX31_INT_MSHC1 (NR_IRQS_LEGACY + 39)
161#define MX31_INT_UART4 46 161#define MX31_INT_MSHC2 (NR_IRQS_LEGACY + 40)
162#define MX31_INT_UART5 47 162#define MX31_INT_IPU_ERR (NR_IRQS_LEGACY + 41)
163#define MX31_INT_ECT 48 163#define MX31_INT_IPU_SYN (NR_IRQS_LEGACY + 42)
164#define MX31_INT_SCC_SCM 49 164#define MX31_INT_UART1 (NR_IRQS_LEGACY + 45)
165#define MX31_INT_SCC_SMN 50 165#define MX31_INT_UART4 (NR_IRQS_LEGACY + 46)
166#define MX31_INT_GPIO2 51 166#define MX31_INT_UART5 (NR_IRQS_LEGACY + 47)
167#define MX31_INT_GPIO1 52 167#define MX31_INT_ECT (NR_IRQS_LEGACY + 48)
168#define MX31_INT_CCM 53 168#define MX31_INT_SCC_SCM (NR_IRQS_LEGACY + 49)
169#define MX31_INT_PCMCIA 54 169#define MX31_INT_SCC_SMN (NR_IRQS_LEGACY + 50)
170#define MX31_INT_WDOG 55 170#define MX31_INT_GPIO2 (NR_IRQS_LEGACY + 51)
171#define MX31_INT_GPIO3 56 171#define MX31_INT_GPIO1 (NR_IRQS_LEGACY + 52)
172#define MX31_INT_EXT_POWER 58 172#define MX31_INT_CCM (NR_IRQS_LEGACY + 53)
173#define MX31_INT_EXT_TEMPER 59 173#define MX31_INT_PCMCIA (NR_IRQS_LEGACY + 54)
174#define MX31_INT_EXT_SENSOR60 60 174#define MX31_INT_WDOG (NR_IRQS_LEGACY + 55)
175#define MX31_INT_EXT_SENSOR61 61 175#define MX31_INT_GPIO3 (NR_IRQS_LEGACY + 56)
176#define MX31_INT_EXT_WDOG 62 176#define MX31_INT_EXT_POWER (NR_IRQS_LEGACY + 58)
177#define MX31_INT_EXT_TV 63 177#define MX31_INT_EXT_TEMPER (NR_IRQS_LEGACY + 59)
178#define MX31_INT_EXT_SENSOR60 (NR_IRQS_LEGACY + 60)
179#define MX31_INT_EXT_SENSOR61 (NR_IRQS_LEGACY + 61)
180#define MX31_INT_EXT_WDOG (NR_IRQS_LEGACY + 62)
181#define MX31_INT_EXT_TV (NR_IRQS_LEGACY + 63)
178 182
179#define MX31_DMA_REQ_SDHC1 20 183#define MX31_DMA_REQ_SDHC1 20
180#define MX31_DMA_REQ_SDHC2 21 184#define MX31_DMA_REQ_SDHC2 21
diff --git a/arch/arm/plat-mxc/include/mach/mx35.h b/arch/arm/plat-mxc/include/mach/mx35.h
index 80965a99aa5..2af5d3a699c 100644
--- a/arch/arm/plat-mxc/include/mach/mx35.h
+++ b/arch/arm/plat-mxc/include/mach/mx35.h
@@ -120,60 +120,61 @@
120/* 120/*
121 * Interrupt numbers 121 * Interrupt numbers
122 */ 122 */
123#define MX35_INT_OWIRE 2 123#include <asm/irq.h>
124#define MX35_INT_I2C3 3 124#define MX35_INT_OWIRE (NR_IRQS_LEGACY + 2)
125#define MX35_INT_I2C2 4 125#define MX35_INT_I2C3 (NR_IRQS_LEGACY + 3)
126#define MX35_INT_RTIC 6 126#define MX35_INT_I2C2 (NR_IRQS_LEGACY + 4)
127#define MX35_INT_ESDHC1 7 127#define MX35_INT_RTIC (NR_IRQS_LEGACY + 6)
128#define MX35_INT_ESDHC2 8 128#define MX35_INT_ESDHC1 (NR_IRQS_LEGACY + 7)
129#define MX35_INT_ESDHC3 9 129#define MX35_INT_ESDHC2 (NR_IRQS_LEGACY + 8)
130#define MX35_INT_I2C1 10 130#define MX35_INT_ESDHC3 (NR_IRQS_LEGACY + 9)
131#define MX35_INT_SSI1 11 131#define MX35_INT_I2C1 (NR_IRQS_LEGACY + 10)
132#define MX35_INT_SSI2 12 132#define MX35_INT_SSI1 (NR_IRQS_LEGACY + 11)
133#define MX35_INT_CSPI2 13 133#define MX35_INT_SSI2 (NR_IRQS_LEGACY + 12)
134#define MX35_INT_CSPI1 14 134#define MX35_INT_CSPI2 (NR_IRQS_LEGACY + 13)
135#define MX35_INT_ATA 15 135#define MX35_INT_CSPI1 (NR_IRQS_LEGACY + 14)
136#define MX35_INT_GPU2D 16 136#define MX35_INT_ATA (NR_IRQS_LEGACY + 15)
137#define MX35_INT_ASRC 17 137#define MX35_INT_GPU2D (NR_IRQS_LEGACY + 16)
138#define MX35_INT_UART3 18 138#define MX35_INT_ASRC (NR_IRQS_LEGACY + 17)
139#define MX35_INT_IIM 19 139#define MX35_INT_UART3 (NR_IRQS_LEGACY + 18)
140#define MX35_INT_RNGA 22 140#define MX35_INT_IIM (NR_IRQS_LEGACY + 19)
141#define MX35_INT_EVTMON 23 141#define MX35_INT_RNGA (NR_IRQS_LEGACY + 22)
142#define MX35_INT_KPP 24 142#define MX35_INT_EVTMON (NR_IRQS_LEGACY + 23)
143#define MX35_INT_RTC 25 143#define MX35_INT_KPP (NR_IRQS_LEGACY + 24)
144#define MX35_INT_PWM 26 144#define MX35_INT_RTC (NR_IRQS_LEGACY + 25)
145#define MX35_INT_EPIT2 27 145#define MX35_INT_PWM (NR_IRQS_LEGACY + 26)
146#define MX35_INT_EPIT1 28 146#define MX35_INT_EPIT2 (NR_IRQS_LEGACY + 27)
147#define MX35_INT_GPT 29 147#define MX35_INT_EPIT1 (NR_IRQS_LEGACY + 28)
148#define MX35_INT_POWER_FAIL 30 148#define MX35_INT_GPT (NR_IRQS_LEGACY + 29)
149#define MX35_INT_UART2 32 149#define MX35_INT_POWER_FAIL (NR_IRQS_LEGACY + 30)
150#define MX35_INT_NFC 33 150#define MX35_INT_UART2 (NR_IRQS_LEGACY + 32)
151#define MX35_INT_SDMA 34 151#define MX35_INT_NFC (NR_IRQS_LEGACY + 33)
152#define MX35_INT_USB_HS 35 152#define MX35_INT_SDMA (NR_IRQS_LEGACY + 34)
153#define MX35_INT_USB_OTG 37 153#define MX35_INT_USB_HS (NR_IRQS_LEGACY + 35)
154#define MX35_INT_MSHC1 39 154#define MX35_INT_USB_OTG (NR_IRQS_LEGACY + 37)
155#define MX35_INT_ESAI 40 155#define MX35_INT_MSHC1 (NR_IRQS_LEGACY + 39)
156#define MX35_INT_IPU_ERR 41 156#define MX35_INT_ESAI (NR_IRQS_LEGACY + 40)
157#define MX35_INT_IPU_SYN 42 157#define MX35_INT_IPU_ERR (NR_IRQS_LEGACY + 41)
158#define MX35_INT_CAN1 43 158#define MX35_INT_IPU_SYN (NR_IRQS_LEGACY + 42)
159#define MX35_INT_CAN2 44 159#define MX35_INT_CAN1 (NR_IRQS_LEGACY + 43)
160#define MX35_INT_UART1 45 160#define MX35_INT_CAN2 (NR_IRQS_LEGACY + 44)
161#define MX35_INT_MLB 46 161#define MX35_INT_UART1 (NR_IRQS_LEGACY + 45)
162#define MX35_INT_SPDIF 47 162#define MX35_INT_MLB (NR_IRQS_LEGACY + 46)
163#define MX35_INT_ECT 48 163#define MX35_INT_SPDIF (NR_IRQS_LEGACY + 47)
164#define MX35_INT_SCC_SCM 49 164#define MX35_INT_ECT (NR_IRQS_LEGACY + 48)
165#define MX35_INT_SCC_SMN 50 165#define MX35_INT_SCC_SCM (NR_IRQS_LEGACY + 49)
166#define MX35_INT_GPIO2 51 166#define MX35_INT_SCC_SMN (NR_IRQS_LEGACY + 50)
167#define MX35_INT_GPIO1 52 167#define MX35_INT_GPIO2 (NR_IRQS_LEGACY + 51)
168#define MX35_INT_WDOG 55 168#define MX35_INT_GPIO1 (NR_IRQS_LEGACY + 52)
169#define MX35_INT_GPIO3 56 169#define MX35_INT_WDOG (NR_IRQS_LEGACY + 55)
170#define MX35_INT_FEC 57 170#define MX35_INT_GPIO3 (NR_IRQS_LEGACY + 56)
171#define MX35_INT_EXT_POWER 58 171#define MX35_INT_FEC (NR_IRQS_LEGACY + 57)
172#define MX35_INT_EXT_TEMPER 59 172#define MX35_INT_EXT_POWER (NR_IRQS_LEGACY + 58)
173#define MX35_INT_EXT_SENSOR60 60 173#define MX35_INT_EXT_TEMPER (NR_IRQS_LEGACY + 59)
174#define MX35_INT_EXT_SENSOR61 61 174#define MX35_INT_EXT_SENSOR60 (NR_IRQS_LEGACY + 60)
175#define MX35_INT_EXT_WDOG 62 175#define MX35_INT_EXT_SENSOR61 (NR_IRQS_LEGACY + 61)
176#define MX35_INT_EXT_TV 63 176#define MX35_INT_EXT_WDOG (NR_IRQS_LEGACY + 62)
177#define MX35_INT_EXT_TV (NR_IRQS_LEGACY + 63)
177 178
178#define MX35_DMA_REQ_SSI2_RX1 22 179#define MX35_DMA_REQ_SSI2_RX1 22
179#define MX35_DMA_REQ_SSI2_TX1 23 180#define MX35_DMA_REQ_SSI2_TX1 23
diff --git a/arch/arm/plat-mxc/include/mach/mx3x.h b/arch/arm/plat-mxc/include/mach/mx3x.h
index 30dbf424583..96fb4fbc8ad 100644
--- a/arch/arm/plat-mxc/include/mach/mx3x.h
+++ b/arch/arm/plat-mxc/include/mach/mx3x.h
@@ -143,44 +143,45 @@
143/* 143/*
144 * Interrupt numbers 144 * Interrupt numbers
145 */ 145 */
146#define MX3x_INT_I2C3 3 146#include <asm/irq.h>
147#define MX3x_INT_I2C2 4 147#define MX3x_INT_I2C3 (NR_IRQS_LEGACY + 3)
148#define MX3x_INT_RTIC 6 148#define MX3x_INT_I2C2 (NR_IRQS_LEGACY + 4)
149#define MX3x_INT_I2C 10 149#define MX3x_INT_RTIC (NR_IRQS_LEGACY + 6)
150#define MX3x_INT_CSPI2 13 150#define MX3x_INT_I2C (NR_IRQS_LEGACY + 10)
151#define MX3x_INT_CSPI1 14 151#define MX3x_INT_CSPI2 (NR_IRQS_LEGACY + 13)
152#define MX3x_INT_ATA 15 152#define MX3x_INT_CSPI1 (NR_IRQS_LEGACY + 14)
153#define MX3x_INT_UART3 18 153#define MX3x_INT_ATA (NR_IRQS_LEGACY + 15)
154#define MX3x_INT_IIM 19 154#define MX3x_INT_UART3 (NR_IRQS_LEGACY + 18)
155#define MX3x_INT_RNGA 22 155#define MX3x_INT_IIM (NR_IRQS_LEGACY + 19)
156#define MX3x_INT_EVTMON 23 156#define MX3x_INT_RNGA (NR_IRQS_LEGACY + 22)
157#define MX3x_INT_KPP 24 157#define MX3x_INT_EVTMON (NR_IRQS_LEGACY + 23)
158#define MX3x_INT_RTC 25 158#define MX3x_INT_KPP (NR_IRQS_LEGACY + 24)
159#define MX3x_INT_PWM 26 159#define MX3x_INT_RTC (NR_IRQS_LEGACY + 25)
160#define MX3x_INT_EPIT2 27 160#define MX3x_INT_PWM (NR_IRQS_LEGACY + 26)
161#define MX3x_INT_EPIT1 28 161#define MX3x_INT_EPIT2 (NR_IRQS_LEGACY + 27)
162#define MX3x_INT_GPT 29 162#define MX3x_INT_EPIT1 (NR_IRQS_LEGACY + 28)
163#define MX3x_INT_POWER_FAIL 30 163#define MX3x_INT_GPT (NR_IRQS_LEGACY + 29)
164#define MX3x_INT_UART2 32 164#define MX3x_INT_POWER_FAIL (NR_IRQS_LEGACY + 30)
165#define MX3x_INT_NANDFC 33 165#define MX3x_INT_UART2 (NR_IRQS_LEGACY + 32)
166#define MX3x_INT_SDMA 34 166#define MX3x_INT_NANDFC (NR_IRQS_LEGACY + 33)
167#define MX3x_INT_MSHC1 39 167#define MX3x_INT_SDMA (NR_IRQS_LEGACY + 34)
168#define MX3x_INT_IPU_ERR 41 168#define MX3x_INT_MSHC1 (NR_IRQS_LEGACY + 39)
169#define MX3x_INT_IPU_SYN 42 169#define MX3x_INT_IPU_ERR (NR_IRQS_LEGACY + 41)
170#define MX3x_INT_UART1 45 170#define MX3x_INT_IPU_SYN (NR_IRQS_LEGACY + 42)
171#define MX3x_INT_ECT 48 171#define MX3x_INT_UART1 (NR_IRQS_LEGACY + 45)
172#define MX3x_INT_SCC_SCM 49 172#define MX3x_INT_ECT (NR_IRQS_LEGACY + 48)
173#define MX3x_INT_SCC_SMN 50 173#define MX3x_INT_SCC_SCM (NR_IRQS_LEGACY + 49)
174#define MX3x_INT_GPIO2 51 174#define MX3x_INT_SCC_SMN (NR_IRQS_LEGACY + 50)
175#define MX3x_INT_GPIO1 52 175#define MX3x_INT_GPIO2 (NR_IRQS_LEGACY + 51)
176#define MX3x_INT_WDOG 55 176#define MX3x_INT_GPIO1 (NR_IRQS_LEGACY + 52)
177#define MX3x_INT_GPIO3 56 177#define MX3x_INT_WDOG (NR_IRQS_LEGACY + 55)
178#define MX3x_INT_EXT_POWER 58 178#define MX3x_INT_GPIO3 (NR_IRQS_LEGACY + 56)
179#define MX3x_INT_EXT_TEMPER 59 179#define MX3x_INT_EXT_POWER (NR_IRQS_LEGACY + 58)
180#define MX3x_INT_EXT_SENSOR60 60 180#define MX3x_INT_EXT_TEMPER (NR_IRQS_LEGACY + 59)
181#define MX3x_INT_EXT_SENSOR61 61 181#define MX3x_INT_EXT_SENSOR60 (NR_IRQS_LEGACY + 60)
182#define MX3x_INT_EXT_WDOG 62 182#define MX3x_INT_EXT_SENSOR61 (NR_IRQS_LEGACY + 61)
183#define MX3x_INT_EXT_TV 63 183#define MX3x_INT_EXT_WDOG (NR_IRQS_LEGACY + 62)
184#define MX3x_INT_EXT_TV (NR_IRQS_LEGACY + 63)
184 185
185#define MX3x_PROD_SIGNATURE 0x1 /* For MX31 */ 186#define MX3x_PROD_SIGNATURE 0x1 /* For MX31 */
186 187
diff --git a/arch/arm/plat-mxc/include/mach/mx50.h b/arch/arm/plat-mxc/include/mach/mx50.h
index 5f2da75a47f..09ac19c1570 100644
--- a/arch/arm/plat-mxc/include/mach/mx50.h
+++ b/arch/arm/plat-mxc/include/mach/mx50.h
@@ -188,99 +188,100 @@
188/* 188/*
189 * Interrupt numbers 189 * Interrupt numbers
190 */ 190 */
191#define MX50_INT_MMC_SDHC1 1 191#include <asm/irq.h>
192#define MX50_INT_MMC_SDHC2 2 192#define MX50_INT_MMC_SDHC1 (NR_IRQS_LEGACY + 1)
193#define MX50_INT_MMC_SDHC3 3 193#define MX50_INT_MMC_SDHC2 (NR_IRQS_LEGACY + 2)
194#define MX50_INT_MMC_SDHC4 4 194#define MX50_INT_MMC_SDHC3 (NR_IRQS_LEGACY + 3)
195#define MX50_INT_DAP 5 195#define MX50_INT_MMC_SDHC4 (NR_IRQS_LEGACY + 4)
196#define MX50_INT_SDMA 6 196#define MX50_INT_DAP (NR_IRQS_LEGACY + 5)
197#define MX50_INT_IOMUX 7 197#define MX50_INT_SDMA (NR_IRQS_LEGACY + 6)
198#define MX50_INT_UART4 13 198#define MX50_INT_IOMUX (NR_IRQS_LEGACY + 7)
199#define MX50_INT_USB_H1 14 199#define MX50_INT_UART4 (NR_IRQS_LEGACY + 13)
200#define MX50_INT_USB_OTG 18 200#define MX50_INT_USB_H1 (NR_IRQS_LEGACY + 14)
201#define MX50_INT_DATABAHN 19 201#define MX50_INT_USB_OTG (NR_IRQS_LEGACY + 18)
202#define MX50_INT_ELCDIF 20 202#define MX50_INT_DATABAHN (NR_IRQS_LEGACY + 19)
203#define MX50_INT_EPXP 21 203#define MX50_INT_ELCDIF (NR_IRQS_LEGACY + 20)
204#define MX50_INT_SRTC_NTZ 24 204#define MX50_INT_EPXP (NR_IRQS_LEGACY + 21)
205#define MX50_INT_SRTC_TZ 25 205#define MX50_INT_SRTC_NTZ (NR_IRQS_LEGACY + 24)
206#define MX50_INT_EPDC 27 206#define MX50_INT_SRTC_TZ (NR_IRQS_LEGACY + 25)
207#define MX50_INT_NIC 28 207#define MX50_INT_EPDC (NR_IRQS_LEGACY + 27)
208#define MX50_INT_SSI1 29 208#define MX50_INT_NIC (NR_IRQS_LEGACY + 28)
209#define MX50_INT_SSI2 30 209#define MX50_INT_SSI1 (NR_IRQS_LEGACY + 29)
210#define MX50_INT_UART1 31 210#define MX50_INT_SSI2 (NR_IRQS_LEGACY + 30)
211#define MX50_INT_UART2 32 211#define MX50_INT_UART1 (NR_IRQS_LEGACY + 31)
212#define MX50_INT_UART3 33 212#define MX50_INT_UART2 (NR_IRQS_LEGACY + 32)
213#define MX50_INT_RESV34 34 213#define MX50_INT_UART3 (NR_IRQS_LEGACY + 33)
214#define MX50_INT_RESV35 35 214#define MX50_INT_RESV34 (NR_IRQS_LEGACY + 34)
215#define MX50_INT_CSPI1 36 215#define MX50_INT_RESV35 (NR_IRQS_LEGACY + 35)
216#define MX50_INT_CSPI2 37 216#define MX50_INT_CSPI1 (NR_IRQS_LEGACY + 36)
217#define MX50_INT_CSPI 38 217#define MX50_INT_CSPI2 (NR_IRQS_LEGACY + 37)
218#define MX50_INT_GPT 39 218#define MX50_INT_CSPI (NR_IRQS_LEGACY + 38)
219#define MX50_INT_EPIT1 40 219#define MX50_INT_GPT (NR_IRQS_LEGACY + 39)
220#define MX50_INT_GPIO1_INT7 42 220#define MX50_INT_EPIT1 (NR_IRQS_LEGACY + 40)
221#define MX50_INT_GPIO1_INT6 43 221#define MX50_INT_GPIO1_INT7 (NR_IRQS_LEGACY + 42)
222#define MX50_INT_GPIO1_INT5 44 222#define MX50_INT_GPIO1_INT6 (NR_IRQS_LEGACY + 43)
223#define MX50_INT_GPIO1_INT4 45 223#define MX50_INT_GPIO1_INT5 (NR_IRQS_LEGACY + 44)
224#define MX50_INT_GPIO1_INT3 46 224#define MX50_INT_GPIO1_INT4 (NR_IRQS_LEGACY + 45)
225#define MX50_INT_GPIO1_INT2 47 225#define MX50_INT_GPIO1_INT3 (NR_IRQS_LEGACY + 46)
226#define MX50_INT_GPIO1_INT1 48 226#define MX50_INT_GPIO1_INT2 (NR_IRQS_LEGACY + 47)
227#define MX50_INT_GPIO1_INT0 49 227#define MX50_INT_GPIO1_INT1 (NR_IRQS_LEGACY + 48)
228#define MX50_INT_GPIO1_LOW 50 228#define MX50_INT_GPIO1_INT0 (NR_IRQS_LEGACY + 49)
229#define MX50_INT_GPIO1_HIGH 51 229#define MX50_INT_GPIO1_LOW (NR_IRQS_LEGACY + 50)
230#define MX50_INT_GPIO2_LOW 52 230#define MX50_INT_GPIO1_HIGH (NR_IRQS_LEGACY + 51)
231#define MX50_INT_GPIO2_HIGH 53 231#define MX50_INT_GPIO2_LOW (NR_IRQS_LEGACY + 52)
232#define MX50_INT_GPIO3_LOW 54 232#define MX50_INT_GPIO2_HIGH (NR_IRQS_LEGACY + 53)
233#define MX50_INT_GPIO3_HIGH 55 233#define MX50_INT_GPIO3_LOW (NR_IRQS_LEGACY + 54)
234#define MX50_INT_GPIO4_LOW 56 234#define MX50_INT_GPIO3_HIGH (NR_IRQS_LEGACY + 55)
235#define MX50_INT_GPIO4_HIGH 57 235#define MX50_INT_GPIO4_LOW (NR_IRQS_LEGACY + 56)
236#define MX50_INT_WDOG1 58 236#define MX50_INT_GPIO4_HIGH (NR_IRQS_LEGACY + 57)
237#define MX50_INT_KPP 60 237#define MX50_INT_WDOG1 (NR_IRQS_LEGACY + 58)
238#define MX50_INT_PWM1 61 238#define MX50_INT_KPP (NR_IRQS_LEGACY + 60)
239#define MX50_INT_I2C1 62 239#define MX50_INT_PWM1 (NR_IRQS_LEGACY + 61)
240#define MX50_INT_I2C2 63 240#define MX50_INT_I2C1 (NR_IRQS_LEGACY + 62)
241#define MX50_INT_I2C3 64 241#define MX50_INT_I2C2 (NR_IRQS_LEGACY + 63)
242#define MX50_INT_RESV65 65 242#define MX50_INT_I2C3 (NR_IRQS_LEGACY + 64)
243#define MX50_INT_DCDC 66 243#define MX50_INT_RESV65 (NR_IRQS_LEGACY + 65)
244#define MX50_INT_THERMAL_ALARM 67 244#define MX50_INT_DCDC (NR_IRQS_LEGACY + 66)
245#define MX50_INT_ANA3 68 245#define MX50_INT_THERMAL_ALARM (NR_IRQS_LEGACY + 67)
246#define MX50_INT_ANA4 69 246#define MX50_INT_ANA3 (NR_IRQS_LEGACY + 68)
247#define MX50_INT_CCM1 71 247#define MX50_INT_ANA4 (NR_IRQS_LEGACY + 69)
248#define MX50_INT_CCM2 72 248#define MX50_INT_CCM1 (NR_IRQS_LEGACY + 71)
249#define MX50_INT_GPC1 73 249#define MX50_INT_CCM2 (NR_IRQS_LEGACY + 72)
250#define MX50_INT_GPC2 74 250#define MX50_INT_GPC1 (NR_IRQS_LEGACY + 73)
251#define MX50_INT_SRC 75 251#define MX50_INT_GPC2 (NR_IRQS_LEGACY + 74)
252#define MX50_INT_NM 76 252#define MX50_INT_SRC (NR_IRQS_LEGACY + 75)
253#define MX50_INT_PMU 77 253#define MX50_INT_NM (NR_IRQS_LEGACY + 76)
254#define MX50_INT_CTI_IRQ 78 254#define MX50_INT_PMU (NR_IRQS_LEGACY + 77)
255#define MX50_INT_CTI1_TG0 79 255#define MX50_INT_CTI_IRQ (NR_IRQS_LEGACY + 78)
256#define MX50_INT_CTI1_TG1 80 256#define MX50_INT_CTI1_TG0 (NR_IRQS_LEGACY + 79)
257#define MX50_INT_GPU2_IRQ 84 257#define MX50_INT_CTI1_TG1 (NR_IRQS_LEGACY + 80)
258#define MX50_INT_GPU2_BUSY 85 258#define MX50_INT_GPU2_IRQ (NR_IRQS_LEGACY + 84)
259#define MX50_INT_UART5 86 259#define MX50_INT_GPU2_BUSY (NR_IRQS_LEGACY + 85)
260#define MX50_INT_FEC 87 260#define MX50_INT_UART5 (NR_IRQS_LEGACY + 86)
261#define MX50_INT_OWIRE 88 261#define MX50_INT_FEC (NR_IRQS_LEGACY + 87)
262#define MX50_INT_CTI1_TG2 89 262#define MX50_INT_OWIRE (NR_IRQS_LEGACY + 88)
263#define MX50_INT_SJC 90 263#define MX50_INT_CTI1_TG2 (NR_IRQS_LEGACY + 89)
264#define MX50_INT_DCP_CHAN1_3 91 264#define MX50_INT_SJC (NR_IRQS_LEGACY + 90)
265#define MX50_INT_DCP_CHAN0 92 265#define MX50_INT_DCP_CHAN1_3 (NR_IRQS_LEGACY + 91)
266#define MX50_INT_PWM2 94 266#define MX50_INT_DCP_CHAN0 (NR_IRQS_LEGACY + 92)
267#define MX50_INT_RNGB 97 267#define MX50_INT_PWM2 (NR_IRQS_LEGACY + 94)
268#define MX50_INT_CTI1_TG3 98 268#define MX50_INT_RNGB (NR_IRQS_LEGACY + 97)
269#define MX50_INT_RAWNAND_BCH 100 269#define MX50_INT_CTI1_TG3 (NR_IRQS_LEGACY + 98)
270#define MX50_INT_RAWNAND_GPMI 102 270#define MX50_INT_RAWNAND_BCH (NR_IRQS_LEGACY + 100)
271#define MX50_INT_GPIO5_LOW 103 271#define MX50_INT_RAWNAND_GPMI (NR_IRQS_LEGACY + 102)
272#define MX50_INT_GPIO5_HIGH 104 272#define MX50_INT_GPIO5_LOW (NR_IRQS_LEGACY + 103)
273#define MX50_INT_GPIO6_LOW 105 273#define MX50_INT_GPIO5_HIGH (NR_IRQS_LEGACY + 104)
274#define MX50_INT_GPIO6_HIGH 106 274#define MX50_INT_GPIO6_LOW (NR_IRQS_LEGACY + 105)
275#define MX50_INT_MSHC 109 275#define MX50_INT_GPIO6_HIGH (NR_IRQS_LEGACY + 106)
276#define MX50_INT_APBHDMA_CHAN0 110 276#define MX50_INT_MSHC (NR_IRQS_LEGACY + 109)
277#define MX50_INT_APBHDMA_CHAN1 111 277#define MX50_INT_APBHDMA_CHAN0 (NR_IRQS_LEGACY + 110)
278#define MX50_INT_APBHDMA_CHAN2 112 278#define MX50_INT_APBHDMA_CHAN1 (NR_IRQS_LEGACY + 111)
279#define MX50_INT_APBHDMA_CHAN3 113 279#define MX50_INT_APBHDMA_CHAN2 (NR_IRQS_LEGACY + 112)
280#define MX50_INT_APBHDMA_CHAN4 114 280#define MX50_INT_APBHDMA_CHAN3 (NR_IRQS_LEGACY + 113)
281#define MX50_INT_APBHDMA_CHAN5 115 281#define MX50_INT_APBHDMA_CHAN4 (NR_IRQS_LEGACY + 114)
282#define MX50_INT_APBHDMA_CHAN6 116 282#define MX50_INT_APBHDMA_CHAN5 (NR_IRQS_LEGACY + 115)
283#define MX50_INT_APBHDMA_CHAN7 117 283#define MX50_INT_APBHDMA_CHAN6 (NR_IRQS_LEGACY + 116)
284#define MX50_INT_APBHDMA_CHAN7 (NR_IRQS_LEGACY + 117)
284 285
285#if !defined(__ASSEMBLY__) && !defined(__MXC_BOOT_UNCOMPRESS) 286#if !defined(__ASSEMBLY__) && !defined(__MXC_BOOT_UNCOMPRESS)
286extern int mx50_revision(void); 287extern int mx50_revision(void);
diff --git a/arch/arm/plat-mxc/include/mach/mx51.h b/arch/arm/plat-mxc/include/mach/mx51.h
index cdf07c65ec1..af844f76261 100644
--- a/arch/arm/plat-mxc/include/mach/mx51.h
+++ b/arch/arm/plat-mxc/include/mach/mx51.h
@@ -232,110 +232,111 @@
232/* 232/*
233 * Interrupt numbers 233 * Interrupt numbers
234 */ 234 */
235#define MX51_INT_BASE 0 235#include <asm/irq.h>
236#define MX51_INT_RESV0 0 236#define MX51_INT_BASE (NR_IRQS_LEGACY + 0)
237#define MX51_INT_ESDHC1 1 237#define MX51_INT_RESV0 (NR_IRQS_LEGACY + 0)
238#define MX51_INT_ESDHC2 2 238#define MX51_INT_ESDHC1 (NR_IRQS_LEGACY + 1)
239#define MX51_INT_ESDHC3 3 239#define MX51_INT_ESDHC2 (NR_IRQS_LEGACY + 2)
240#define MX51_INT_ESDHC4 4 240#define MX51_INT_ESDHC3 (NR_IRQS_LEGACY + 3)
241#define MX51_INT_RESV5 5 241#define MX51_INT_ESDHC4 (NR_IRQS_LEGACY + 4)
242#define MX51_INT_SDMA 6 242#define MX51_INT_RESV5 (NR_IRQS_LEGACY + 5)
243#define MX51_INT_IOMUX 7 243#define MX51_INT_SDMA (NR_IRQS_LEGACY + 6)
244#define MX51_INT_NFC 8 244#define MX51_INT_IOMUX (NR_IRQS_LEGACY + 7)
245#define MX51_INT_VPU 9 245#define MX51_INT_NFC (NR_IRQS_LEGACY + 8)
246#define MX51_INT_IPU_ERR 10 246#define MX51_INT_VPU (NR_IRQS_LEGACY + 9)
247#define MX51_INT_IPU_SYN 11 247#define MX51_INT_IPU_ERR (NR_IRQS_LEGACY + 10)
248#define MX51_INT_GPU 12 248#define MX51_INT_IPU_SYN (NR_IRQS_LEGACY + 11)
249#define MX51_INT_RESV13 13 249#define MX51_INT_GPU (NR_IRQS_LEGACY + 12)
250#define MX51_INT_USB_HS1 14 250#define MX51_INT_RESV13 (NR_IRQS_LEGACY + 13)
251#define MX51_INT_EMI 15 251#define MX51_INT_USB_HS1 (NR_IRQS_LEGACY + 14)
252#define MX51_INT_USB_HS2 16 252#define MX51_INT_EMI (NR_IRQS_LEGACY + 15)
253#define MX51_INT_USB_HS3 17 253#define MX51_INT_USB_HS2 (NR_IRQS_LEGACY + 16)
254#define MX51_INT_USB_OTG 18 254#define MX51_INT_USB_HS3 (NR_IRQS_LEGACY + 17)
255#define MX51_INT_SAHARA_H0 19 255#define MX51_INT_USB_OTG (NR_IRQS_LEGACY + 18)
256#define MX51_INT_SAHARA_H1 20 256#define MX51_INT_SAHARA_H0 (NR_IRQS_LEGACY + 19)
257#define MX51_INT_SCC_SMN 21 257#define MX51_INT_SAHARA_H1 (NR_IRQS_LEGACY + 20)
258#define MX51_INT_SCC_STZ 22 258#define MX51_INT_SCC_SMN (NR_IRQS_LEGACY + 21)
259#define MX51_INT_SCC_SCM 23 259#define MX51_INT_SCC_STZ (NR_IRQS_LEGACY + 22)
260#define MX51_INT_SRTC_NTZ 24 260#define MX51_INT_SCC_SCM (NR_IRQS_LEGACY + 23)
261#define MX51_INT_SRTC_TZ 25 261#define MX51_INT_SRTC_NTZ (NR_IRQS_LEGACY + 24)
262#define MX51_INT_RTIC 26 262#define MX51_INT_SRTC_TZ (NR_IRQS_LEGACY + 25)
263#define MX51_INT_CSU 27 263#define MX51_INT_RTIC (NR_IRQS_LEGACY + 26)
264#define MX51_INT_SLIM_B 28 264#define MX51_INT_CSU (NR_IRQS_LEGACY + 27)
265#define MX51_INT_SSI1 29 265#define MX51_INT_SLIM_B (NR_IRQS_LEGACY + 28)
266#define MX51_INT_SSI2 30 266#define MX51_INT_SSI1 (NR_IRQS_LEGACY + 29)
267#define MX51_INT_UART1 31 267#define MX51_INT_SSI2 (NR_IRQS_LEGACY + 30)
268#define MX51_INT_UART2 32 268#define MX51_INT_UART1 (NR_IRQS_LEGACY + 31)
269#define MX51_INT_UART3 33 269#define MX51_INT_UART2 (NR_IRQS_LEGACY + 32)
270#define MX51_INT_RESV34 34 270#define MX51_INT_UART3 (NR_IRQS_LEGACY + 33)
271#define MX51_INT_RESV35 35 271#define MX51_INT_RESV34 (NR_IRQS_LEGACY + 34)
272#define MX51_INT_ECSPI1 36 272#define MX51_INT_RESV35 (NR_IRQS_LEGACY + 35)
273#define MX51_INT_ECSPI2 37 273#define MX51_INT_ECSPI1 (NR_IRQS_LEGACY + 36)
274#define MX51_INT_CSPI 38 274#define MX51_INT_ECSPI2 (NR_IRQS_LEGACY + 37)
275#define MX51_INT_GPT 39 275#define MX51_INT_CSPI (NR_IRQS_LEGACY + 38)
276#define MX51_INT_EPIT1 40 276#define MX51_INT_GPT (NR_IRQS_LEGACY + 39)
277#define MX51_INT_EPIT2 41 277#define MX51_INT_EPIT1 (NR_IRQS_LEGACY + 40)
278#define MX51_INT_GPIO1_INT7 42 278#define MX51_INT_EPIT2 (NR_IRQS_LEGACY + 41)
279#define MX51_INT_GPIO1_INT6 43 279#define MX51_INT_GPIO1_INT7 (NR_IRQS_LEGACY + 42)
280#define MX51_INT_GPIO1_INT5 44 280#define MX51_INT_GPIO1_INT6 (NR_IRQS_LEGACY + 43)
281#define MX51_INT_GPIO1_INT4 45 281#define MX51_INT_GPIO1_INT5 (NR_IRQS_LEGACY + 44)
282#define MX51_INT_GPIO1_INT3 46 282#define MX51_INT_GPIO1_INT4 (NR_IRQS_LEGACY + 45)
283#define MX51_INT_GPIO1_INT2 47 283#define MX51_INT_GPIO1_INT3 (NR_IRQS_LEGACY + 46)
284#define MX51_INT_GPIO1_INT1 48 284#define MX51_INT_GPIO1_INT2 (NR_IRQS_LEGACY + 47)
285#define MX51_INT_GPIO1_INT0 49 285#define MX51_INT_GPIO1_INT1 (NR_IRQS_LEGACY + 48)
286#define MX51_INT_GPIO1_LOW 50 286#define MX51_INT_GPIO1_INT0 (NR_IRQS_LEGACY + 49)
287#define MX51_INT_GPIO1_HIGH 51 287#define MX51_INT_GPIO1_LOW (NR_IRQS_LEGACY + 50)
288#define MX51_INT_GPIO2_LOW 52 288#define MX51_INT_GPIO1_HIGH (NR_IRQS_LEGACY + 51)
289#define MX51_INT_GPIO2_HIGH 53 289#define MX51_INT_GPIO2_LOW (NR_IRQS_LEGACY + 52)
290#define MX51_INT_GPIO3_LOW 54 290#define MX51_INT_GPIO2_HIGH (NR_IRQS_LEGACY + 53)
291#define MX51_INT_GPIO3_HIGH 55 291#define MX51_INT_GPIO3_LOW (NR_IRQS_LEGACY + 54)
292#define MX51_INT_GPIO4_LOW 56 292#define MX51_INT_GPIO3_HIGH (NR_IRQS_LEGACY + 55)
293#define MX51_INT_GPIO4_HIGH 57 293#define MX51_INT_GPIO4_LOW (NR_IRQS_LEGACY + 56)
294#define MX51_INT_WDOG1 58 294#define MX51_INT_GPIO4_HIGH (NR_IRQS_LEGACY + 57)
295#define MX51_INT_WDOG2 59 295#define MX51_INT_WDOG1 (NR_IRQS_LEGACY + 58)
296#define MX51_INT_KPP 60 296#define MX51_INT_WDOG2 (NR_IRQS_LEGACY + 59)
297#define MX51_INT_PWM1 61 297#define MX51_INT_KPP (NR_IRQS_LEGACY + 60)
298#define MX51_INT_I2C1 62 298#define MX51_INT_PWM1 (NR_IRQS_LEGACY + 61)
299#define MX51_INT_I2C2 63 299#define MX51_INT_I2C1 (NR_IRQS_LEGACY + 62)
300#define MX51_INT_HS_I2C 64 300#define MX51_INT_I2C2 (NR_IRQS_LEGACY + 63)
301#define MX51_INT_RESV65 65 301#define MX51_INT_HS_I2C (NR_IRQS_LEGACY + 64)
302#define MX51_INT_RESV66 66 302#define MX51_INT_RESV65 (NR_IRQS_LEGACY + 65)
303#define MX51_INT_SIM_IPB 67 303#define MX51_INT_RESV66 (NR_IRQS_LEGACY + 66)
304#define MX51_INT_SIM_DAT 68 304#define MX51_INT_SIM_IPB (NR_IRQS_LEGACY + 67)
305#define MX51_INT_IIM 69 305#define MX51_INT_SIM_DAT (NR_IRQS_LEGACY + 68)
306#define MX51_INT_ATA 70 306#define MX51_INT_IIM (NR_IRQS_LEGACY + 69)
307#define MX51_INT_CCM1 71 307#define MX51_INT_ATA (NR_IRQS_LEGACY + 70)
308#define MX51_INT_CCM2 72 308#define MX51_INT_CCM1 (NR_IRQS_LEGACY + 71)
309#define MX51_INT_GPC1 73 309#define MX51_INT_CCM2 (NR_IRQS_LEGACY + 72)
310#define MX51_INT_GPC2 74 310#define MX51_INT_GPC1 (NR_IRQS_LEGACY + 73)
311#define MX51_INT_SRC 75 311#define MX51_INT_GPC2 (NR_IRQS_LEGACY + 74)
312#define MX51_INT_NM 76 312#define MX51_INT_SRC (NR_IRQS_LEGACY + 75)
313#define MX51_INT_PMU 77 313#define MX51_INT_NM (NR_IRQS_LEGACY + 76)
314#define MX51_INT_CTI_IRQ 78 314#define MX51_INT_PMU (NR_IRQS_LEGACY + 77)
315#define MX51_INT_CTI1_TG0 79 315#define MX51_INT_CTI_IRQ (NR_IRQS_LEGACY + 78)
316#define MX51_INT_CTI1_TG1 80 316#define MX51_INT_CTI1_TG0 (NR_IRQS_LEGACY + 79)
317#define MX51_INT_MCG_ERR 81 317#define MX51_INT_CTI1_TG1 (NR_IRQS_LEGACY + 80)
318#define MX51_INT_MCG_TMR 82 318#define MX51_INT_MCG_ERR (NR_IRQS_LEGACY + 81)
319#define MX51_INT_MCG_FUNC 83 319#define MX51_INT_MCG_TMR (NR_IRQS_LEGACY + 82)
320#define MX51_INT_GPU2_IRQ 84 320#define MX51_INT_MCG_FUNC (NR_IRQS_LEGACY + 83)
321#define MX51_INT_GPU2_BUSY 85 321#define MX51_INT_GPU2_IRQ (NR_IRQS_LEGACY + 84)
322#define MX51_INT_RESV86 86 322#define MX51_INT_GPU2_BUSY (NR_IRQS_LEGACY + 85)
323#define MX51_INT_FEC 87 323#define MX51_INT_RESV86 (NR_IRQS_LEGACY + 86)
324#define MX51_INT_OWIRE 88 324#define MX51_INT_FEC (NR_IRQS_LEGACY + 87)
325#define MX51_INT_CTI1_TG2 89 325#define MX51_INT_OWIRE (NR_IRQS_LEGACY + 88)
326#define MX51_INT_SJC 90 326#define MX51_INT_CTI1_TG2 (NR_IRQS_LEGACY + 89)
327#define MX51_INT_SPDIF 91 327#define MX51_INT_SJC (NR_IRQS_LEGACY + 90)
328#define MX51_INT_TVE 92 328#define MX51_INT_SPDIF (NR_IRQS_LEGACY + 91)
329#define MX51_INT_FIRI 93 329#define MX51_INT_TVE (NR_IRQS_LEGACY + 92)
330#define MX51_INT_PWM2 94 330#define MX51_INT_FIRI (NR_IRQS_LEGACY + 93)
331#define MX51_INT_SLIM_EXP 95 331#define MX51_INT_PWM2 (NR_IRQS_LEGACY + 94)
332#define MX51_INT_SSI3 96 332#define MX51_INT_SLIM_EXP (NR_IRQS_LEGACY + 95)
333#define MX51_INT_EMI_BOOT 97 333#define MX51_INT_SSI3 (NR_IRQS_LEGACY + 96)
334#define MX51_INT_CTI1_TG3 98 334#define MX51_INT_EMI_BOOT (NR_IRQS_LEGACY + 97)
335#define MX51_INT_SMC_RX 99 335#define MX51_INT_CTI1_TG3 (NR_IRQS_LEGACY + 98)
336#define MX51_INT_VPU_IDLE 100 336#define MX51_INT_SMC_RX (NR_IRQS_LEGACY + 99)
337#define MX51_INT_EMI_NFC 101 337#define MX51_INT_VPU_IDLE (NR_IRQS_LEGACY + 100)
338#define MX51_INT_GPU_IDLE 102 338#define MX51_INT_EMI_NFC (NR_IRQS_LEGACY + 101)
339#define MX51_INT_GPU_IDLE (NR_IRQS_LEGACY + 102)
339 340
340#if !defined(__ASSEMBLY__) && !defined(__MXC_BOOT_UNCOMPRESS) 341#if !defined(__ASSEMBLY__) && !defined(__MXC_BOOT_UNCOMPRESS)
341extern int mx51_revision(void); 342extern int mx51_revision(void);
diff --git a/arch/arm/plat-mxc/include/mach/mx53.h b/arch/arm/plat-mxc/include/mach/mx53.h
index a37e8c35399..f829d1c2250 100644
--- a/arch/arm/plat-mxc/include/mach/mx53.h
+++ b/arch/arm/plat-mxc/include/mach/mx53.h
@@ -229,113 +229,114 @@
229/* 229/*
230 * Interrupt numbers 230 * Interrupt numbers
231 */ 231 */
232#define MX53_INT_RESV0 0 232#include <asm/irq.h>
233#define MX53_INT_ESDHC1 1 233#define MX53_INT_RESV0 (NR_IRQS_LEGACY + 0)
234#define MX53_INT_ESDHC2 2 234#define MX53_INT_ESDHC1 (NR_IRQS_LEGACY + 1)
235#define MX53_INT_ESDHC3 3 235#define MX53_INT_ESDHC2 (NR_IRQS_LEGACY + 2)
236#define MX53_INT_ESDHC4 4 236#define MX53_INT_ESDHC3 (NR_IRQS_LEGACY + 3)
237#define MX53_INT_DAP 5 237#define MX53_INT_ESDHC4 (NR_IRQS_LEGACY + 4)
238#define MX53_INT_SDMA 6 238#define MX53_INT_DAP (NR_IRQS_LEGACY + 5)
239#define MX53_INT_IOMUX 7 239#define MX53_INT_SDMA (NR_IRQS_LEGACY + 6)
240#define MX53_INT_NFC 8 240#define MX53_INT_IOMUX (NR_IRQS_LEGACY + 7)
241#define MX53_INT_VPU 9 241#define MX53_INT_NFC (NR_IRQS_LEGACY + 8)
242#define MX53_INT_IPU_ERR 10 242#define MX53_INT_VPU (NR_IRQS_LEGACY + 9)
243#define MX53_INT_IPU_SYN 11 243#define MX53_INT_IPU_ERR (NR_IRQS_LEGACY + 10)
244#define MX53_INT_GPU 12 244#define MX53_INT_IPU_SYN (NR_IRQS_LEGACY + 11)
245#define MX53_INT_UART4 13 245#define MX53_INT_GPU (NR_IRQS_LEGACY + 12)
246#define MX53_INT_USB_H1 14 246#define MX53_INT_UART4 (NR_IRQS_LEGACY + 13)
247#define MX53_INT_EMI 15 247#define MX53_INT_USB_H1 (NR_IRQS_LEGACY + 14)
248#define MX53_INT_USB_H2 16 248#define MX53_INT_EMI (NR_IRQS_LEGACY + 15)
249#define MX53_INT_USB_H3 17 249#define MX53_INT_USB_H2 (NR_IRQS_LEGACY + 16)
250#define MX53_INT_USB_OTG 18 250#define MX53_INT_USB_H3 (NR_IRQS_LEGACY + 17)
251#define MX53_INT_SAHARA_H0 19 251#define MX53_INT_USB_OTG (NR_IRQS_LEGACY + 18)
252#define MX53_INT_SAHARA_H1 20 252#define MX53_INT_SAHARA_H0 (NR_IRQS_LEGACY + 19)
253#define MX53_INT_SCC_SMN 21 253#define MX53_INT_SAHARA_H1 (NR_IRQS_LEGACY + 20)
254#define MX53_INT_SCC_STZ 22 254#define MX53_INT_SCC_SMN (NR_IRQS_LEGACY + 21)
255#define MX53_INT_SCC_SCM 23 255#define MX53_INT_SCC_STZ (NR_IRQS_LEGACY + 22)
256#define MX53_INT_SRTC_NTZ 24 256#define MX53_INT_SCC_SCM (NR_IRQS_LEGACY + 23)
257#define MX53_INT_SRTC_TZ 25 257#define MX53_INT_SRTC_NTZ (NR_IRQS_LEGACY + 24)
258#define MX53_INT_RTIC 26 258#define MX53_INT_SRTC_TZ (NR_IRQS_LEGACY + 25)
259#define MX53_INT_CSU 27 259#define MX53_INT_RTIC (NR_IRQS_LEGACY + 26)
260#define MX53_INT_SATA 28 260#define MX53_INT_CSU (NR_IRQS_LEGACY + 27)
261#define MX53_INT_SSI1 29 261#define MX53_INT_SATA (NR_IRQS_LEGACY + 28)
262#define MX53_INT_SSI2 30 262#define MX53_INT_SSI1 (NR_IRQS_LEGACY + 29)
263#define MX53_INT_UART1 31 263#define MX53_INT_SSI2 (NR_IRQS_LEGACY + 30)
264#define MX53_INT_UART2 32 264#define MX53_INT_UART1 (NR_IRQS_LEGACY + 31)
265#define MX53_INT_UART3 33 265#define MX53_INT_UART2 (NR_IRQS_LEGACY + 32)
266#define MX53_INT_RTC 34 266#define MX53_INT_UART3 (NR_IRQS_LEGACY + 33)
267#define MX53_INT_PTP 35 267#define MX53_INT_RTC (NR_IRQS_LEGACY + 34)
268#define MX53_INT_ECSPI1 36 268#define MX53_INT_PTP (NR_IRQS_LEGACY + 35)
269#define MX53_INT_ECSPI2 37 269#define MX53_INT_ECSPI1 (NR_IRQS_LEGACY + 36)
270#define MX53_INT_CSPI 38 270#define MX53_INT_ECSPI2 (NR_IRQS_LEGACY + 37)
271#define MX53_INT_GPT 39 271#define MX53_INT_CSPI (NR_IRQS_LEGACY + 38)
272#define MX53_INT_EPIT1 40 272#define MX53_INT_GPT (NR_IRQS_LEGACY + 39)
273#define MX53_INT_EPIT2 41 273#define MX53_INT_EPIT1 (NR_IRQS_LEGACY + 40)
274#define MX53_INT_GPIO1_INT7 42 274#define MX53_INT_EPIT2 (NR_IRQS_LEGACY + 41)
275#define MX53_INT_GPIO1_INT6 43 275#define MX53_INT_GPIO1_INT7 (NR_IRQS_LEGACY + 42)
276#define MX53_INT_GPIO1_INT5 44 276#define MX53_INT_GPIO1_INT6 (NR_IRQS_LEGACY + 43)
277#define MX53_INT_GPIO1_INT4 45 277#define MX53_INT_GPIO1_INT5 (NR_IRQS_LEGACY + 44)
278#define MX53_INT_GPIO1_INT3 46 278#define MX53_INT_GPIO1_INT4 (NR_IRQS_LEGACY + 45)
279#define MX53_INT_GPIO1_INT2 47 279#define MX53_INT_GPIO1_INT3 (NR_IRQS_LEGACY + 46)
280#define MX53_INT_GPIO1_INT1 48 280#define MX53_INT_GPIO1_INT2 (NR_IRQS_LEGACY + 47)
281#define MX53_INT_GPIO1_INT0 49 281#define MX53_INT_GPIO1_INT1 (NR_IRQS_LEGACY + 48)
282#define MX53_INT_GPIO1_LOW 50 282#define MX53_INT_GPIO1_INT0 (NR_IRQS_LEGACY + 49)
283#define MX53_INT_GPIO1_HIGH 51 283#define MX53_INT_GPIO1_LOW (NR_IRQS_LEGACY + 50)
284#define MX53_INT_GPIO2_LOW 52 284#define MX53_INT_GPIO1_HIGH (NR_IRQS_LEGACY + 51)
285#define MX53_INT_GPIO2_HIGH 53 285#define MX53_INT_GPIO2_LOW (NR_IRQS_LEGACY + 52)
286#define MX53_INT_GPIO3_LOW 54 286#define MX53_INT_GPIO2_HIGH (NR_IRQS_LEGACY + 53)
287#define MX53_INT_GPIO3_HIGH 55 287#define MX53_INT_GPIO3_LOW (NR_IRQS_LEGACY + 54)
288#define MX53_INT_GPIO4_LOW 56 288#define MX53_INT_GPIO3_HIGH (NR_IRQS_LEGACY + 55)
289#define MX53_INT_GPIO4_HIGH 57 289#define MX53_INT_GPIO4_LOW (NR_IRQS_LEGACY + 56)
290#define MX53_INT_WDOG1 58 290#define MX53_INT_GPIO4_HIGH (NR_IRQS_LEGACY + 57)
291#define MX53_INT_WDOG2 59 291#define MX53_INT_WDOG1 (NR_IRQS_LEGACY + 58)
292#define MX53_INT_KPP 60 292#define MX53_INT_WDOG2 (NR_IRQS_LEGACY + 59)
293#define MX53_INT_PWM1 61 293#define MX53_INT_KPP (NR_IRQS_LEGACY + 60)
294#define MX53_INT_I2C1 62 294#define MX53_INT_PWM1 (NR_IRQS_LEGACY + 61)
295#define MX53_INT_I2C2 63 295#define MX53_INT_I2C1 (NR_IRQS_LEGACY + 62)
296#define MX53_INT_I2C3 64 296#define MX53_INT_I2C2 (NR_IRQS_LEGACY + 63)
297#define MX53_INT_MLB 65 297#define MX53_INT_I2C3 (NR_IRQS_LEGACY + 64)
298#define MX53_INT_ASRC 66 298#define MX53_INT_MLB (NR_IRQS_LEGACY + 65)
299#define MX53_INT_SPDIF 67 299#define MX53_INT_ASRC (NR_IRQS_LEGACY + 66)
300#define MX53_INT_SIM_DAT 68 300#define MX53_INT_SPDIF (NR_IRQS_LEGACY + 67)
301#define MX53_INT_IIM 69 301#define MX53_INT_SIM_DAT (NR_IRQS_LEGACY + 68)
302#define MX53_INT_ATA 70 302#define MX53_INT_IIM (NR_IRQS_LEGACY + 69)
303#define MX53_INT_CCM1 71 303#define MX53_INT_ATA (NR_IRQS_LEGACY + 70)
304#define MX53_INT_CCM2 72 304#define MX53_INT_CCM1 (NR_IRQS_LEGACY + 71)
305#define MX53_INT_GPC1 73 305#define MX53_INT_CCM2 (NR_IRQS_LEGACY + 72)
306#define MX53_INT_GPC2 74 306#define MX53_INT_GPC1 (NR_IRQS_LEGACY + 73)
307#define MX53_INT_SRC 75 307#define MX53_INT_GPC2 (NR_IRQS_LEGACY + 74)
308#define MX53_INT_NM 76 308#define MX53_INT_SRC (NR_IRQS_LEGACY + 75)
309#define MX53_INT_PMU 77 309#define MX53_INT_NM (NR_IRQS_LEGACY + 76)
310#define MX53_INT_CTI_IRQ 78 310#define MX53_INT_PMU (NR_IRQS_LEGACY + 77)
311#define MX53_INT_CTI1_TG0 79 311#define MX53_INT_CTI_IRQ (NR_IRQS_LEGACY + 78)
312#define MX53_INT_CTI1_TG1 80 312#define MX53_INT_CTI1_TG0 (NR_IRQS_LEGACY + 79)
313#define MX53_INT_ESAI 81 313#define MX53_INT_CTI1_TG1 (NR_IRQS_LEGACY + 80)
314#define MX53_INT_CAN1 82 314#define MX53_INT_ESAI (NR_IRQS_LEGACY + 81)
315#define MX53_INT_CAN2 83 315#define MX53_INT_CAN1 (NR_IRQS_LEGACY + 82)
316#define MX53_INT_GPU2_IRQ 84 316#define MX53_INT_CAN2 (NR_IRQS_LEGACY + 83)
317#define MX53_INT_GPU2_BUSY 85 317#define MX53_INT_GPU2_IRQ (NR_IRQS_LEGACY + 84)
318#define MX53_INT_UART5 86 318#define MX53_INT_GPU2_BUSY (NR_IRQS_LEGACY + 85)
319#define MX53_INT_FEC 87 319#define MX53_INT_UART5 (NR_IRQS_LEGACY + 86)
320#define MX53_INT_OWIRE 88 320#define MX53_INT_FEC (NR_IRQS_LEGACY + 87)
321#define MX53_INT_CTI1_TG2 89 321#define MX53_INT_OWIRE (NR_IRQS_LEGACY + 88)
322#define MX53_INT_SJC 90 322#define MX53_INT_CTI1_TG2 (NR_IRQS_LEGACY + 89)
323#define MX53_INT_TVE 92 323#define MX53_INT_SJC (NR_IRQS_LEGACY + 90)
324#define MX53_INT_FIRI 93 324#define MX53_INT_TVE (NR_IRQS_LEGACY + 92)
325#define MX53_INT_PWM2 94 325#define MX53_INT_FIRI (NR_IRQS_LEGACY + 93)
326#define MX53_INT_SLIM_EXP 95 326#define MX53_INT_PWM2 (NR_IRQS_LEGACY + 94)
327#define MX53_INT_SSI3 96 327#define MX53_INT_SLIM_EXP (NR_IRQS_LEGACY + 95)
328#define MX53_INT_EMI_BOOT 97 328#define MX53_INT_SSI3 (NR_IRQS_LEGACY + 96)
329#define MX53_INT_CTI1_TG3 98 329#define MX53_INT_EMI_BOOT (NR_IRQS_LEGACY + 97)
330#define MX53_INT_SMC_RX 99 330#define MX53_INT_CTI1_TG3 (NR_IRQS_LEGACY + 98)
331#define MX53_INT_VPU_IDLE 100 331#define MX53_INT_SMC_RX (NR_IRQS_LEGACY + 99)
332#define MX53_INT_EMI_NFC 101 332#define MX53_INT_VPU_IDLE (NR_IRQS_LEGACY + 100)
333#define MX53_INT_GPU_IDLE 102 333#define MX53_INT_EMI_NFC (NR_IRQS_LEGACY + 101)
334#define MX53_INT_GPIO5_LOW 103 334#define MX53_INT_GPU_IDLE (NR_IRQS_LEGACY + 102)
335#define MX53_INT_GPIO5_HIGH 104 335#define MX53_INT_GPIO5_LOW (NR_IRQS_LEGACY + 103)
336#define MX53_INT_GPIO6_LOW 105 336#define MX53_INT_GPIO5_HIGH (NR_IRQS_LEGACY + 104)
337#define MX53_INT_GPIO6_HIGH 106 337#define MX53_INT_GPIO6_LOW (NR_IRQS_LEGACY + 105)
338#define MX53_INT_GPIO7_LOW 107 338#define MX53_INT_GPIO6_HIGH (NR_IRQS_LEGACY + 106)
339#define MX53_INT_GPIO7_HIGH 108 339#define MX53_INT_GPIO7_LOW (NR_IRQS_LEGACY + 107)
340#define MX53_INT_GPIO7_HIGH (NR_IRQS_LEGACY + 108)
340 341
341#endif /* ifndef __MACH_MX53_H__ */ 342#endif /* ifndef __MACH_MX53_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/mxc_ehci.h b/arch/arm/plat-mxc/include/mach/mxc_ehci.h
index 9ffd1bbe615..7eb9d132967 100644
--- a/arch/arm/plat-mxc/include/mach/mxc_ehci.h
+++ b/arch/arm/plat-mxc/include/mach/mxc_ehci.h
@@ -20,13 +20,15 @@
20#define MXC_EHCI_INTERFACE_MASK (0xf) 20#define MXC_EHCI_INTERFACE_MASK (0xf)
21 21
22#define MXC_EHCI_POWER_PINS_ENABLED (1 << 5) 22#define MXC_EHCI_POWER_PINS_ENABLED (1 << 5)
23#define MXC_EHCI_TTL_ENABLED (1 << 6) 23#define MXC_EHCI_PWR_PIN_ACTIVE_HIGH (1 << 6)
24 24#define MXC_EHCI_OC_PIN_ACTIVE_LOW (1 << 7)
25#define MXC_EHCI_INTERNAL_PHY (1 << 7) 25#define MXC_EHCI_TTL_ENABLED (1 << 8)
26#define MXC_EHCI_IPPUE_DOWN (1 << 8) 26
27#define MXC_EHCI_IPPUE_UP (1 << 9) 27#define MXC_EHCI_INTERNAL_PHY (1 << 9)
28#define MXC_EHCI_WAKEUP_ENABLED (1 << 10) 28#define MXC_EHCI_IPPUE_DOWN (1 << 10)
29#define MXC_EHCI_ITC_NO_THRESHOLD (1 << 11) 29#define MXC_EHCI_IPPUE_UP (1 << 11)
30#define MXC_EHCI_WAKEUP_ENABLED (1 << 12)
31#define MXC_EHCI_ITC_NO_THRESHOLD (1 << 13)
30 32
31#define MXC_USBCTRL_OFFSET 0 33#define MXC_USBCTRL_OFFSET 0
32#define MXC_USB_PHY_CTR_FUNC_OFFSET 0x8 34#define MXC_USB_PHY_CTR_FUNC_OFFSET 0x8
diff --git a/arch/arm/plat-mxc/pwm.c b/arch/arm/plat-mxc/pwm.c
deleted file mode 100644
index c0cab2270dd..00000000000
--- a/arch/arm/plat-mxc/pwm.c
+++ /dev/null
@@ -1,306 +0,0 @@
1/*
2 * simple driver for PWM (Pulse Width Modulator) controller
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 * Derived from pxa PWM driver by eric miao <eric.miao@marvell.com>
9 */
10
11#include <linux/module.h>
12#include <linux/kernel.h>
13#include <linux/platform_device.h>
14#include <linux/slab.h>
15#include <linux/err.h>
16#include <linux/clk.h>
17#include <linux/io.h>
18#include <linux/pwm.h>
19#include <mach/hardware.h>
20
21
22/* i.MX1 and i.MX21 share the same PWM function block: */
23
24#define MX1_PWMC 0x00 /* PWM Control Register */
25#define MX1_PWMS 0x04 /* PWM Sample Register */
26#define MX1_PWMP 0x08 /* PWM Period Register */
27
28
29/* i.MX27, i.MX31, i.MX35 share the same PWM function block: */
30
31#define MX3_PWMCR 0x00 /* PWM Control Register */
32#define MX3_PWMSAR 0x0C /* PWM Sample Register */
33#define MX3_PWMPR 0x10 /* PWM Period Register */
34#define MX3_PWMCR_PRESCALER(x) (((x - 1) & 0xFFF) << 4)
35#define MX3_PWMCR_DOZEEN (1 << 24)
36#define MX3_PWMCR_WAITEN (1 << 23)
37#define MX3_PWMCR_DBGEN (1 << 22)
38#define MX3_PWMCR_CLKSRC_IPG_HIGH (2 << 16)
39#define MX3_PWMCR_CLKSRC_IPG (1 << 16)
40#define MX3_PWMCR_EN (1 << 0)
41
42
43
44struct pwm_device {
45 struct list_head node;
46 struct platform_device *pdev;
47
48 const char *label;
49 struct clk *clk;
50
51 int clk_enabled;
52 void __iomem *mmio_base;
53
54 unsigned int use_count;
55 unsigned int pwm_id;
56};
57
58int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
59{
60 if (pwm == NULL || period_ns == 0 || duty_ns > period_ns)
61 return -EINVAL;
62
63 if (!(cpu_is_mx1() || cpu_is_mx21())) {
64 unsigned long long c;
65 unsigned long period_cycles, duty_cycles, prescale;
66 u32 cr;
67
68 c = clk_get_rate(pwm->clk);
69 c = c * period_ns;
70 do_div(c, 1000000000);
71 period_cycles = c;
72
73 prescale = period_cycles / 0x10000 + 1;
74
75 period_cycles /= prescale;
76 c = (unsigned long long)period_cycles * duty_ns;
77 do_div(c, period_ns);
78 duty_cycles = c;
79
80 /*
81 * according to imx pwm RM, the real period value should be
82 * PERIOD value in PWMPR plus 2.
83 */
84 if (period_cycles > 2)
85 period_cycles -= 2;
86 else
87 period_cycles = 0;
88
89 writel(duty_cycles, pwm->mmio_base + MX3_PWMSAR);
90 writel(period_cycles, pwm->mmio_base + MX3_PWMPR);
91
92 cr = MX3_PWMCR_PRESCALER(prescale) |
93 MX3_PWMCR_DOZEEN | MX3_PWMCR_WAITEN |
94 MX3_PWMCR_DBGEN | MX3_PWMCR_EN;
95
96 if (cpu_is_mx25())
97 cr |= MX3_PWMCR_CLKSRC_IPG;
98 else
99 cr |= MX3_PWMCR_CLKSRC_IPG_HIGH;
100
101 writel(cr, pwm->mmio_base + MX3_PWMCR);
102 } else if (cpu_is_mx1() || cpu_is_mx21()) {
103 /* The PWM subsystem allows for exact frequencies. However,
104 * I cannot connect a scope on my device to the PWM line and
105 * thus cannot provide the program the PWM controller
106 * exactly. Instead, I'm relying on the fact that the
107 * Bootloader (u-boot or WinCE+haret) has programmed the PWM
108 * function group already. So I'll just modify the PWM sample
109 * register to follow the ratio of duty_ns vs. period_ns
110 * accordingly.
111 *
112 * This is good enough for programming the brightness of
113 * the LCD backlight.
114 *
115 * The real implementation would divide PERCLK[0] first by
116 * both the prescaler (/1 .. /128) and then by CLKSEL
117 * (/2 .. /16).
118 */
119 u32 max = readl(pwm->mmio_base + MX1_PWMP);
120 u32 p = max * duty_ns / period_ns;
121 writel(max - p, pwm->mmio_base + MX1_PWMS);
122 } else {
123 BUG();
124 }
125
126 return 0;
127}
128EXPORT_SYMBOL(pwm_config);
129
130int pwm_enable(struct pwm_device *pwm)
131{
132 int rc = 0;
133
134 if (!pwm->clk_enabled) {
135 rc = clk_prepare_enable(pwm->clk);
136 if (!rc)
137 pwm->clk_enabled = 1;
138 }
139 return rc;
140}
141EXPORT_SYMBOL(pwm_enable);
142
143void pwm_disable(struct pwm_device *pwm)
144{
145 writel(0, pwm->mmio_base + MX3_PWMCR);
146
147 if (pwm->clk_enabled) {
148 clk_disable_unprepare(pwm->clk);
149 pwm->clk_enabled = 0;
150 }
151}
152EXPORT_SYMBOL(pwm_disable);
153
154static DEFINE_MUTEX(pwm_lock);
155static LIST_HEAD(pwm_list);
156
157struct pwm_device *pwm_request(int pwm_id, const char *label)
158{
159 struct pwm_device *pwm;
160 int found = 0;
161
162 mutex_lock(&pwm_lock);
163
164 list_for_each_entry(pwm, &pwm_list, node) {
165 if (pwm->pwm_id == pwm_id) {
166 found = 1;
167 break;
168 }
169 }
170
171 if (found) {
172 if (pwm->use_count == 0) {
173 pwm->use_count++;
174 pwm->label = label;
175 } else
176 pwm = ERR_PTR(-EBUSY);
177 } else
178 pwm = ERR_PTR(-ENOENT);
179
180 mutex_unlock(&pwm_lock);
181 return pwm;
182}
183EXPORT_SYMBOL(pwm_request);
184
185void pwm_free(struct pwm_device *pwm)
186{
187 mutex_lock(&pwm_lock);
188
189 if (pwm->use_count) {
190 pwm->use_count--;
191 pwm->label = NULL;
192 } else
193 pr_warning("PWM device already freed\n");
194
195 mutex_unlock(&pwm_lock);
196}
197EXPORT_SYMBOL(pwm_free);
198
199static int __devinit mxc_pwm_probe(struct platform_device *pdev)
200{
201 struct pwm_device *pwm;
202 struct resource *r;
203 int ret = 0;
204
205 pwm = kzalloc(sizeof(struct pwm_device), GFP_KERNEL);
206 if (pwm == NULL) {
207 dev_err(&pdev->dev, "failed to allocate memory\n");
208 return -ENOMEM;
209 }
210
211 pwm->clk = clk_get(&pdev->dev, "pwm");
212
213 if (IS_ERR(pwm->clk)) {
214 ret = PTR_ERR(pwm->clk);
215 goto err_free;
216 }
217
218 pwm->clk_enabled = 0;
219
220 pwm->use_count = 0;
221 pwm->pwm_id = pdev->id;
222 pwm->pdev = pdev;
223
224 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
225 if (r == NULL) {
226 dev_err(&pdev->dev, "no memory resource defined\n");
227 ret = -ENODEV;
228 goto err_free_clk;
229 }
230
231 r = request_mem_region(r->start, resource_size(r), pdev->name);
232 if (r == NULL) {
233 dev_err(&pdev->dev, "failed to request memory resource\n");
234 ret = -EBUSY;
235 goto err_free_clk;
236 }
237
238 pwm->mmio_base = ioremap(r->start, resource_size(r));
239 if (pwm->mmio_base == NULL) {
240 dev_err(&pdev->dev, "failed to ioremap() registers\n");
241 ret = -ENODEV;
242 goto err_free_mem;
243 }
244
245 mutex_lock(&pwm_lock);
246 list_add_tail(&pwm->node, &pwm_list);
247 mutex_unlock(&pwm_lock);
248
249 platform_set_drvdata(pdev, pwm);
250 return 0;
251
252err_free_mem:
253 release_mem_region(r->start, resource_size(r));
254err_free_clk:
255 clk_put(pwm->clk);
256err_free:
257 kfree(pwm);
258 return ret;
259}
260
261static int __devexit mxc_pwm_remove(struct platform_device *pdev)
262{
263 struct pwm_device *pwm;
264 struct resource *r;
265
266 pwm = platform_get_drvdata(pdev);
267 if (pwm == NULL)
268 return -ENODEV;
269
270 mutex_lock(&pwm_lock);
271 list_del(&pwm->node);
272 mutex_unlock(&pwm_lock);
273
274 iounmap(pwm->mmio_base);
275
276 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
277 release_mem_region(r->start, resource_size(r));
278
279 clk_put(pwm->clk);
280
281 kfree(pwm);
282 return 0;
283}
284
285static struct platform_driver mxc_pwm_driver = {
286 .driver = {
287 .name = "mxc_pwm",
288 },
289 .probe = mxc_pwm_probe,
290 .remove = __devexit_p(mxc_pwm_remove),
291};
292
293static int __init mxc_pwm_init(void)
294{
295 return platform_driver_register(&mxc_pwm_driver);
296}
297arch_initcall(mxc_pwm_init);
298
299static void __exit mxc_pwm_exit(void)
300{
301 platform_driver_unregister(&mxc_pwm_driver);
302}
303module_exit(mxc_pwm_exit);
304
305MODULE_LICENSE("GPL v2");
306MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
diff --git a/arch/arm/plat-mxc/time.c b/arch/arm/plat-mxc/time.c
index 00e8e659e66..a17abcf9832 100644
--- a/arch/arm/plat-mxc/time.c
+++ b/arch/arm/plat-mxc/time.c
@@ -160,7 +160,8 @@ static const char *clock_event_mode_label[] = {
160 [CLOCK_EVT_MODE_PERIODIC] = "CLOCK_EVT_MODE_PERIODIC", 160 [CLOCK_EVT_MODE_PERIODIC] = "CLOCK_EVT_MODE_PERIODIC",
161 [CLOCK_EVT_MODE_ONESHOT] = "CLOCK_EVT_MODE_ONESHOT", 161 [CLOCK_EVT_MODE_ONESHOT] = "CLOCK_EVT_MODE_ONESHOT",
162 [CLOCK_EVT_MODE_SHUTDOWN] = "CLOCK_EVT_MODE_SHUTDOWN", 162 [CLOCK_EVT_MODE_SHUTDOWN] = "CLOCK_EVT_MODE_SHUTDOWN",
163 [CLOCK_EVT_MODE_UNUSED] = "CLOCK_EVT_MODE_UNUSED" 163 [CLOCK_EVT_MODE_UNUSED] = "CLOCK_EVT_MODE_UNUSED",
164 [CLOCK_EVT_MODE_RESUME] = "CLOCK_EVT_MODE_RESUME",
164}; 165};
165#endif /* DEBUG */ 166#endif /* DEBUG */
166 167
diff --git a/arch/arm/plat-mxc/tzic.c b/arch/arm/plat-mxc/tzic.c
index 98308ec1f32..3ed1adbc09f 100644
--- a/arch/arm/plat-mxc/tzic.c
+++ b/arch/arm/plat-mxc/tzic.c
@@ -15,12 +15,15 @@
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/irqdomain.h>
19#include <linux/of.h>
18 20
19#include <asm/mach/irq.h> 21#include <asm/mach/irq.h>
20#include <asm/exception.h> 22#include <asm/exception.h>
21 23
22#include <mach/hardware.h> 24#include <mach/hardware.h>
23#include <mach/common.h> 25#include <mach/common.h>
26#include <mach/irqs.h>
24 27
25#include "irq-common.h" 28#include "irq-common.h"
26 29
@@ -49,6 +52,7 @@
49#define TZIC_ID0 0x0FD0 /* Indentification Register 0 */ 52#define TZIC_ID0 0x0FD0 /* Indentification Register 0 */
50 53
51void __iomem *tzic_base; /* Used as irq controller base in entry-macro.S */ 54void __iomem *tzic_base; /* Used as irq controller base in entry-macro.S */
55static struct irq_domain *domain;
52 56
53#define TZIC_NUM_IRQS 128 57#define TZIC_NUM_IRQS 128
54 58
@@ -77,15 +81,14 @@ static int tzic_set_irq_fiq(unsigned int irq, unsigned int type)
77static void tzic_irq_suspend(struct irq_data *d) 81static void tzic_irq_suspend(struct irq_data *d)
78{ 82{
79 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); 83 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
80 int idx = gc->irq_base >> 5; 84 int idx = d->hwirq >> 5;
81 85
82 __raw_writel(gc->wake_active, tzic_base + TZIC_WAKEUP0(idx)); 86 __raw_writel(gc->wake_active, tzic_base + TZIC_WAKEUP0(idx));
83} 87}
84 88
85static void tzic_irq_resume(struct irq_data *d) 89static void tzic_irq_resume(struct irq_data *d)
86{ 90{
87 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); 91 int idx = d->hwirq >> 5;
88 int idx = gc->irq_base >> 5;
89 92
90 __raw_writel(__raw_readl(tzic_base + TZIC_ENSET0(idx)), 93 __raw_writel(__raw_readl(tzic_base + TZIC_ENSET0(idx)),
91 tzic_base + TZIC_WAKEUP0(idx)); 94 tzic_base + TZIC_WAKEUP0(idx));
@@ -102,11 +105,10 @@ static struct mxc_extra_irq tzic_extra_irq = {
102#endif 105#endif
103}; 106};
104 107
105static __init void tzic_init_gc(unsigned int irq_start) 108static __init void tzic_init_gc(int idx, unsigned int irq_start)
106{ 109{
107 struct irq_chip_generic *gc; 110 struct irq_chip_generic *gc;
108 struct irq_chip_type *ct; 111 struct irq_chip_type *ct;
109 int idx = irq_start >> 5;
110 112
111 gc = irq_alloc_generic_chip("tzic", 1, irq_start, tzic_base, 113 gc = irq_alloc_generic_chip("tzic", 1, irq_start, tzic_base,
112 handle_level_irq); 114 handle_level_irq);
@@ -140,7 +142,8 @@ asmlinkage void __exception_irq_entry tzic_handle_irq(struct pt_regs *regs)
140 while (stat) { 142 while (stat) {
141 handled = 1; 143 handled = 1;
142 irqofs = fls(stat) - 1; 144 irqofs = fls(stat) - 1;
143 handle_IRQ(irqofs + i * 32, regs); 145 handle_IRQ(irq_find_mapping(domain,
146 irqofs + i * 32), regs);
144 stat &= ~(1 << irqofs); 147 stat &= ~(1 << irqofs);
145 } 148 }
146 } 149 }
@@ -154,6 +157,8 @@ asmlinkage void __exception_irq_entry tzic_handle_irq(struct pt_regs *regs)
154 */ 157 */
155void __init tzic_init_irq(void __iomem *irqbase) 158void __init tzic_init_irq(void __iomem *irqbase)
156{ 159{
160 struct device_node *np;
161 int irq_base;
157 int i; 162 int i;
158 163
159 tzic_base = irqbase; 164 tzic_base = irqbase;
@@ -175,12 +180,20 @@ void __init tzic_init_irq(void __iomem *irqbase)
175 180
176 /* all IRQ no FIQ Warning :: No selection */ 181 /* all IRQ no FIQ Warning :: No selection */
177 182
178 for (i = 0; i < TZIC_NUM_IRQS; i += 32) 183 irq_base = irq_alloc_descs(-1, 0, TZIC_NUM_IRQS, numa_node_id());
179 tzic_init_gc(i); 184 WARN_ON(irq_base < 0);
185
186 np = of_find_compatible_node(NULL, NULL, "fsl,tzic");
187 domain = irq_domain_add_legacy(np, TZIC_NUM_IRQS, irq_base, 0,
188 &irq_domain_simple_ops, NULL);
189 WARN_ON(!domain);
190
191 for (i = 0; i < 4; i++, irq_base += 32)
192 tzic_init_gc(i, irq_base);
180 193
181#ifdef CONFIG_FIQ 194#ifdef CONFIG_FIQ
182 /* Initialize FIQ */ 195 /* Initialize FIQ */
183 init_FIQ(); 196 init_FIQ(FIQ_START);
184#endif 197#endif
185 198
186 pr_info("TrustZone Interrupt Controller (TZIC) initialized\n"); 199 pr_info("TrustZone Interrupt Controller (TZIC) initialized\n");
@@ -190,6 +203,10 @@ void __init tzic_init_irq(void __iomem *irqbase)
190 * tzic_enable_wake() - enable wakeup interrupt 203 * tzic_enable_wake() - enable wakeup interrupt
191 * 204 *
192 * @return 0 if successful; non-zero otherwise 205 * @return 0 if successful; non-zero otherwise
206 *
207 * This function provides an interrupt synchronization point that is required
208 * by tzic enabled platforms before entering imx specific low power modes (ie,
209 * those low power modes beyond the WAIT_CLOCKED basic ARM WFI only mode).
193 */ 210 */
194int tzic_enable_wake(void) 211int tzic_enable_wake(void)
195{ 212{
diff --git a/arch/arm/plat-nomadik/include/plat/i2c.h b/arch/arm/plat-nomadik/include/plat/i2c.h
deleted file mode 100644
index 8ba70ffc31e..00000000000
--- a/arch/arm/plat-nomadik/include/plat/i2c.h
+++ /dev/null
@@ -1,39 +0,0 @@
1/*
2 * Copyright (C) 2009 ST-Ericsson
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#ifndef __PLAT_I2C_H
9#define __PLAT_I2C_H
10
11enum i2c_freq_mode {
12 I2C_FREQ_MODE_STANDARD, /* up to 100 Kb/s */
13 I2C_FREQ_MODE_FAST, /* up to 400 Kb/s */
14 I2C_FREQ_MODE_HIGH_SPEED, /* up to 3.4 Mb/s */
15 I2C_FREQ_MODE_FAST_PLUS, /* up to 1 Mb/s */
16};
17
18/**
19 * struct nmk_i2c_controller - client specific controller configuration
20 * @clk_freq: clock frequency for the operation mode
21 * @slsu: Slave data setup time in ns.
22 * The needed setup time for three modes of operation
23 * are 250ns, 100ns and 10ns respectively thus leading
24 * to the values of 14, 6, 2 for a 48 MHz i2c clk
25 * @tft: Tx FIFO Threshold in bytes
26 * @rft: Rx FIFO Threshold in bytes
27 * @timeout Slave response timeout(ms)
28 * @sm: speed mode
29 */
30struct nmk_i2c_controller {
31 unsigned long clk_freq;
32 unsigned short slsu;
33 unsigned char tft;
34 unsigned char rft;
35 int timeout;
36 enum i2c_freq_mode sm;
37};
38
39#endif /* __PLAT_I2C_H */
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index ad95c7a5d00..dd36eba9506 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -29,7 +29,7 @@ config ARCH_OMAP2PLUS
29 select USE_OF 29 select USE_OF
30 select PROC_DEVICETREE if PROC_FS 30 select PROC_DEVICETREE if PROC_FS
31 help 31 help
32 "Systems based on OMAP2, OMAP3 or OMAP4" 32 "Systems based on OMAP2, OMAP3, OMAP4 or OMAP5"
33 33
34endchoice 34endchoice
35 35
@@ -45,31 +45,30 @@ config OMAP_DEBUG_LEDS
45 depends on OMAP_DEBUG_DEVICES 45 depends on OMAP_DEBUG_DEVICES
46 default y if LEDS_CLASS 46 default y if LEDS_CLASS
47 47
48config OMAP_SMARTREFLEX 48config POWER_AVS_OMAP
49 bool "SmartReflex support" 49 bool "AVS(Adaptive Voltage Scaling) support for OMAP IP versions 1&2"
50 depends on (ARCH_OMAP3 || ARCH_OMAP4) && PM 50 depends on POWER_AVS && (ARCH_OMAP3 || ARCH_OMAP4) && PM
51 help 51 help
52 Say Y if you want to enable SmartReflex. 52 Say Y to enable AVS(Adaptive Voltage Scaling)
53 53 support on OMAP containing the version 1 or
54 SmartReflex can perform continuous dynamic voltage 54 version 2 of the SmartReflex IP.
55 scaling around the nominal operating point voltage 55 V1 is the 65nm version used in OMAP3430.
56 according to silicon characteristics and operating 56 V2 is the update for the 45nm version of the IP used in OMAP3630
57 conditions. Enabling SmartReflex reduces power 57 and OMAP4430
58 consumption.
59 58
60 Please note, that by default SmartReflex is only 59 Please note, that by default SmartReflex is only
61 initialized. To enable the automatic voltage 60 initialized and not enabled. To enable the automatic voltage
62 compensation for vdd mpu and vdd core from user space, 61 compensation for vdd mpu and vdd core from user space,
63 user must write 1 to 62 user must write 1 to
64 /debug/voltage/vdd_<X>/smartreflex/autocomp, 63 /debug/smartreflex/sr_<X>/autocomp,
65 where X is mpu or core for OMAP3. 64 where X is mpu_iva or core for OMAP3.
66 Optionally autocompensation can be enabled in the kernel 65 Optionally autocompensation can be enabled in the kernel
67 by default during system init via the enable_on_init flag 66 by default during system init via the enable_on_init flag
68 which an be passed as platform data to the smartreflex driver. 67 which an be passed as platform data to the smartreflex driver.
69 68
70config OMAP_SMARTREFLEX_CLASS3 69config POWER_AVS_OMAP_CLASS3
71 bool "Class 3 mode of Smartreflex Implementation" 70 bool "Class 3 mode of Smartreflex Implementation"
72 depends on OMAP_SMARTREFLEX && TWL4030_CORE 71 depends on POWER_AVS_OMAP && TWL4030_CORE
73 help 72 help
74 Say Y to enable Class 3 implementation of Smartreflex 73 Say Y to enable Class 3 implementation of Smartreflex
75 74
@@ -150,7 +149,7 @@ config OMAP_32K_TIMER
150 This timer saves power compared to the OMAP_MPU_TIMER, and has 149 This timer saves power compared to the OMAP_MPU_TIMER, and has
151 support for no tick during idle. The 32KHz timer provides less 150 support for no tick during idle. The 32KHz timer provides less
152 intra-tick resolution than OMAP_MPU_TIMER. The 32KHz timer is 151 intra-tick resolution than OMAP_MPU_TIMER. The 32KHz timer is
153 currently only available for OMAP16XX, 24XX, 34XX and OMAP4. 152 currently only available for OMAP16XX, 24XX, 34XX and OMAP4/5.
154 153
155config OMAP3_L2_AUX_SECURE_SAVE_RESTORE 154config OMAP3_L2_AUX_SECURE_SAVE_RESTORE
156 bool "OMAP3 HS/EMU save and restore for L2 AUX control register" 155 bool "OMAP3 HS/EMU save and restore for L2 AUX control register"
diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
index ed8605f0115..961bf859bc0 100644
--- a/arch/arm/plat-omap/Makefile
+++ b/arch/arm/plat-omap/Makefile
@@ -4,15 +4,13 @@
4 4
5# Common support 5# Common support
6obj-y := common.o sram.o clock.o devices.o dma.o mux.o \ 6obj-y := common.o sram.o clock.o devices.o dma.o mux.o \
7 usb.o fb.o counter_32k.o 7 fb.o counter_32k.o
8obj-m := 8obj-m :=
9obj-n := 9obj-n :=
10obj- := 10obj- :=
11 11
12# omap_device support (OMAP2+ only at the moment) 12# omap_device support (OMAP2+ only at the moment)
13obj-$(CONFIG_ARCH_OMAP2) += omap_device.o 13obj-$(CONFIG_ARCH_OMAP2PLUS) += omap_device.o
14obj-$(CONFIG_ARCH_OMAP3) += omap_device.o
15obj-$(CONFIG_ARCH_OMAP4) += omap_device.o
16 14
17obj-$(CONFIG_OMAP_DM_TIMER) += dmtimer.o 15obj-$(CONFIG_OMAP_DM_TIMER) += dmtimer.o
18obj-$(CONFIG_OMAP_DEBUG_DEVICES) += debug-devices.o 16obj-$(CONFIG_OMAP_DEBUG_DEVICES) += debug-devices.o
diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index 0a9b9a97011..89a3723b353 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -77,3 +77,12 @@ void __init omap_init_consistent_dma_size(void)
77 init_consistent_dma_size(CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE << 20); 77 init_consistent_dma_size(CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE << 20);
78#endif 78#endif
79} 79}
80
81/*
82 * Stub function for OMAP2 so that common files
83 * continue to build when custom builds are used
84 */
85int __weak omap_secure_ram_reserve_memblock(void)
86{
87 return 0;
88}
diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c
index 2132c4f389e..dbf1e03029a 100644
--- a/arch/arm/plat-omap/counter_32k.c
+++ b/arch/arm/plat-omap/counter_32k.c
@@ -29,7 +29,10 @@
29#include <plat/clock.h> 29#include <plat/clock.h>
30 30
31/* OMAP2_32KSYNCNT_CR_OFF: offset of 32ksync counter register */ 31/* OMAP2_32KSYNCNT_CR_OFF: offset of 32ksync counter register */
32#define OMAP2_32KSYNCNT_CR_OFF 0x10 32#define OMAP2_32KSYNCNT_REV_OFF 0x0
33#define OMAP2_32KSYNCNT_REV_SCHEME (0x3 << 30)
34#define OMAP2_32KSYNCNT_CR_OFF_LOW 0x10
35#define OMAP2_32KSYNCNT_CR_OFF_HIGH 0x30
33 36
34/* 37/*
35 * 32KHz clocksource ... always available, on pretty most chips except 38 * 32KHz clocksource ... always available, on pretty most chips except
@@ -84,9 +87,16 @@ int __init omap_init_clocksource_32k(void __iomem *vbase)
84 int ret; 87 int ret;
85 88
86 /* 89 /*
87 * 32k sync Counter register offset is at 0x10 90 * 32k sync Counter IP register offsets vary between the
91 * highlander version and the legacy ones.
92 * The 'SCHEME' bits(30-31) of the revision register is used
93 * to identify the version.
88 */ 94 */
89 sync32k_cnt_reg = vbase + OMAP2_32KSYNCNT_CR_OFF; 95 if (__raw_readl(vbase + OMAP2_32KSYNCNT_REV_OFF) &
96 OMAP2_32KSYNCNT_REV_SCHEME)
97 sync32k_cnt_reg = vbase + OMAP2_32KSYNCNT_CR_OFF_HIGH;
98 else
99 sync32k_cnt_reg = vbase + OMAP2_32KSYNCNT_CR_OFF_LOW;
90 100
91 /* 101 /*
92 * 120000 rough estimate from the calculations in 102 * 120000 rough estimate from the calculations in
diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c
index cb16ade437c..7fe626761e5 100644
--- a/arch/arm/plat-omap/dma.c
+++ b/arch/arm/plat-omap/dma.c
@@ -573,22 +573,25 @@ EXPORT_SYMBOL(omap_set_dma_dest_burst_mode);
573 573
574static inline void omap_enable_channel_irq(int lch) 574static inline void omap_enable_channel_irq(int lch)
575{ 575{
576 u32 status;
577
578 /* Clear CSR */ 576 /* Clear CSR */
579 if (cpu_class_is_omap1()) 577 if (cpu_class_is_omap1())
580 status = p->dma_read(CSR, lch); 578 p->dma_read(CSR, lch);
581 else if (cpu_class_is_omap2()) 579 else
582 p->dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR, lch); 580 p->dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR, lch);
583 581
584 /* Enable some nice interrupts. */ 582 /* Enable some nice interrupts. */
585 p->dma_write(dma_chan[lch].enabled_irqs, CICR, lch); 583 p->dma_write(dma_chan[lch].enabled_irqs, CICR, lch);
586} 584}
587 585
588static void omap_disable_channel_irq(int lch) 586static inline void omap_disable_channel_irq(int lch)
589{ 587{
590 if (cpu_class_is_omap2()) 588 /* disable channel interrupts */
591 p->dma_write(0, CICR, lch); 589 p->dma_write(0, CICR, lch);
590 /* Clear CSR */
591 if (cpu_class_is_omap1())
592 p->dma_read(CSR, lch);
593 else
594 p->dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR, lch);
592} 595}
593 596
594void omap_enable_dma_irq(int lch, u16 bits) 597void omap_enable_dma_irq(int lch, u16 bits)
@@ -632,14 +635,14 @@ static inline void disable_lnk(int lch)
632 l = p->dma_read(CLNK_CTRL, lch); 635 l = p->dma_read(CLNK_CTRL, lch);
633 636
634 /* Disable interrupts */ 637 /* Disable interrupts */
638 omap_disable_channel_irq(lch);
639
635 if (cpu_class_is_omap1()) { 640 if (cpu_class_is_omap1()) {
636 p->dma_write(0, CICR, lch);
637 /* Set the STOP_LNK bit */ 641 /* Set the STOP_LNK bit */
638 l |= 1 << 14; 642 l |= 1 << 14;
639 } 643 }
640 644
641 if (cpu_class_is_omap2()) { 645 if (cpu_class_is_omap2()) {
642 omap_disable_channel_irq(lch);
643 /* Clear the ENABLE_LNK bit */ 646 /* Clear the ENABLE_LNK bit */
644 l &= ~(1 << 15); 647 l &= ~(1 << 15);
645 } 648 }
@@ -657,6 +660,9 @@ static inline void omap2_enable_irq_lch(int lch)
657 return; 660 return;
658 661
659 spin_lock_irqsave(&dma_chan_lock, flags); 662 spin_lock_irqsave(&dma_chan_lock, flags);
663 /* clear IRQ STATUS */
664 p->dma_write(1 << lch, IRQSTATUS_L0, lch);
665 /* Enable interrupt */
660 val = p->dma_read(IRQENABLE_L0, lch); 666 val = p->dma_read(IRQENABLE_L0, lch);
661 val |= 1 << lch; 667 val |= 1 << lch;
662 p->dma_write(val, IRQENABLE_L0, lch); 668 p->dma_write(val, IRQENABLE_L0, lch);
@@ -672,9 +678,12 @@ static inline void omap2_disable_irq_lch(int lch)
672 return; 678 return;
673 679
674 spin_lock_irqsave(&dma_chan_lock, flags); 680 spin_lock_irqsave(&dma_chan_lock, flags);
681 /* Disable interrupt */
675 val = p->dma_read(IRQENABLE_L0, lch); 682 val = p->dma_read(IRQENABLE_L0, lch);
676 val &= ~(1 << lch); 683 val &= ~(1 << lch);
677 p->dma_write(val, IRQENABLE_L0, lch); 684 p->dma_write(val, IRQENABLE_L0, lch);
685 /* clear IRQ STATUS */
686 p->dma_write(1 << lch, IRQSTATUS_L0, lch);
678 spin_unlock_irqrestore(&dma_chan_lock, flags); 687 spin_unlock_irqrestore(&dma_chan_lock, flags);
679} 688}
680 689
@@ -745,11 +754,8 @@ int omap_request_dma(int dev_id, const char *dev_name,
745 } 754 }
746 755
747 if (cpu_class_is_omap2()) { 756 if (cpu_class_is_omap2()) {
748 omap2_enable_irq_lch(free_ch);
749 omap_enable_channel_irq(free_ch); 757 omap_enable_channel_irq(free_ch);
750 /* Clear the CSR register and IRQ status register */ 758 omap2_enable_irq_lch(free_ch);
751 p->dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR, free_ch);
752 p->dma_write(1 << free_ch, IRQSTATUS_L0, 0);
753 } 759 }
754 760
755 *dma_ch_out = free_ch; 761 *dma_ch_out = free_ch;
@@ -768,27 +774,19 @@ void omap_free_dma(int lch)
768 return; 774 return;
769 } 775 }
770 776
771 if (cpu_class_is_omap1()) { 777 /* Disable interrupt for logical channel */
772 /* Disable all DMA interrupts for the channel. */ 778 if (cpu_class_is_omap2())
773 p->dma_write(0, CICR, lch);
774 /* Make sure the DMA transfer is stopped. */
775 p->dma_write(0, CCR, lch);
776 }
777
778 if (cpu_class_is_omap2()) {
779 omap2_disable_irq_lch(lch); 779 omap2_disable_irq_lch(lch);
780 780
781 /* Clear the CSR register and IRQ status register */ 781 /* Disable all DMA interrupts for the channel. */
782 p->dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR, lch); 782 omap_disable_channel_irq(lch);
783 p->dma_write(1 << lch, IRQSTATUS_L0, lch);
784 783
785 /* Disable all DMA interrupts for the channel. */ 784 /* Make sure the DMA transfer is stopped. */
786 p->dma_write(0, CICR, lch); 785 p->dma_write(0, CCR, lch);
787 786
788 /* Make sure the DMA transfer is stopped. */ 787 /* Clear registers */
789 p->dma_write(0, CCR, lch); 788 if (cpu_class_is_omap2())
790 omap_clear_dma(lch); 789 omap_clear_dma(lch);
791 }
792 790
793 spin_lock_irqsave(&dma_chan_lock, flags); 791 spin_lock_irqsave(&dma_chan_lock, flags);
794 dma_chan[lch].dev_id = -1; 792 dma_chan[lch].dev_id = -1;
@@ -943,8 +941,7 @@ void omap_stop_dma(int lch)
943 u32 l; 941 u32 l;
944 942
945 /* Disable all interrupts on the channel */ 943 /* Disable all interrupts on the channel */
946 if (cpu_class_is_omap1()) 944 omap_disable_channel_irq(lch);
947 p->dma_write(0, CICR, lch);
948 945
949 l = p->dma_read(CCR, lch); 946 l = p->dma_read(CCR, lch);
950 if (IS_DMA_ERRATA(DMA_ERRATA_i541) && 947 if (IS_DMA_ERRATA(DMA_ERRATA_i541) &&
diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 3b0cfeb33d0..938b50a3343 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -37,14 +37,16 @@
37 37
38#include <linux/module.h> 38#include <linux/module.h>
39#include <linux/io.h> 39#include <linux/io.h>
40#include <linux/slab.h> 40#include <linux/device.h>
41#include <linux/err.h> 41#include <linux/err.h>
42#include <linux/pm_runtime.h> 42#include <linux/pm_runtime.h>
43 43
44#include <plat/dmtimer.h> 44#include <plat/dmtimer.h>
45#include <plat/omap-pm.h>
45 46
46#include <mach/hardware.h> 47#include <mach/hardware.h>
47 48
49static u32 omap_reserved_systimers;
48static LIST_HEAD(omap_timer_list); 50static LIST_HEAD(omap_timer_list);
49static DEFINE_SPINLOCK(dm_timer_lock); 51static DEFINE_SPINLOCK(dm_timer_lock);
50 52
@@ -133,17 +135,22 @@ static void omap_dm_timer_reset(struct omap_dm_timer *timer)
133 135
134int omap_dm_timer_prepare(struct omap_dm_timer *timer) 136int omap_dm_timer_prepare(struct omap_dm_timer *timer)
135{ 137{
136 struct dmtimer_platform_data *pdata = timer->pdev->dev.platform_data;
137 int ret; 138 int ret;
138 139
139 timer->fclk = clk_get(&timer->pdev->dev, "fck"); 140 /*
140 if (WARN_ON_ONCE(IS_ERR_OR_NULL(timer->fclk))) { 141 * FIXME: OMAP1 devices do not use the clock framework for dmtimers so
141 timer->fclk = NULL; 142 * do not call clk_get() for these devices.
142 dev_err(&timer->pdev->dev, ": No fclk handle.\n"); 143 */
143 return -EINVAL; 144 if (!(timer->capability & OMAP_TIMER_NEEDS_RESET)) {
145 timer->fclk = clk_get(&timer->pdev->dev, "fck");
146 if (WARN_ON_ONCE(IS_ERR_OR_NULL(timer->fclk))) {
147 timer->fclk = NULL;
148 dev_err(&timer->pdev->dev, ": No fclk handle.\n");
149 return -EINVAL;
150 }
144 } 151 }
145 152
146 if (pdata->needs_manual_reset) 153 if (timer->capability & OMAP_TIMER_NEEDS_RESET)
147 omap_dm_timer_reset(timer); 154 omap_dm_timer_reset(timer);
148 155
149 ret = omap_dm_timer_set_source(timer, OMAP_TIMER_SRC_32_KHZ); 156 ret = omap_dm_timer_set_source(timer, OMAP_TIMER_SRC_32_KHZ);
@@ -152,6 +159,21 @@ int omap_dm_timer_prepare(struct omap_dm_timer *timer)
152 return ret; 159 return ret;
153} 160}
154 161
162static inline u32 omap_dm_timer_reserved_systimer(int id)
163{
164 return (omap_reserved_systimers & (1 << (id - 1))) ? 1 : 0;
165}
166
167int omap_dm_timer_reserve_systimer(int id)
168{
169 if (omap_dm_timer_reserved_systimer(id))
170 return -ENODEV;
171
172 omap_reserved_systimers |= (1 << (id - 1));
173
174 return 0;
175}
176
155struct omap_dm_timer *omap_dm_timer_request(void) 177struct omap_dm_timer *omap_dm_timer_request(void)
156{ 178{
157 struct omap_dm_timer *timer = NULL, *t; 179 struct omap_dm_timer *timer = NULL, *t;
@@ -167,6 +189,7 @@ struct omap_dm_timer *omap_dm_timer_request(void)
167 timer->reserved = 1; 189 timer->reserved = 1;
168 break; 190 break;
169 } 191 }
192 spin_unlock_irqrestore(&dm_timer_lock, flags);
170 193
171 if (timer) { 194 if (timer) {
172 ret = omap_dm_timer_prepare(timer); 195 ret = omap_dm_timer_prepare(timer);
@@ -175,7 +198,6 @@ struct omap_dm_timer *omap_dm_timer_request(void)
175 timer = NULL; 198 timer = NULL;
176 } 199 }
177 } 200 }
178 spin_unlock_irqrestore(&dm_timer_lock, flags);
179 201
180 if (!timer) 202 if (!timer)
181 pr_debug("%s: timer request failed!\n", __func__); 203 pr_debug("%s: timer request failed!\n", __func__);
@@ -198,6 +220,7 @@ struct omap_dm_timer *omap_dm_timer_request_specific(int id)
198 break; 220 break;
199 } 221 }
200 } 222 }
223 spin_unlock_irqrestore(&dm_timer_lock, flags);
201 224
202 if (timer) { 225 if (timer) {
203 ret = omap_dm_timer_prepare(timer); 226 ret = omap_dm_timer_prepare(timer);
@@ -206,7 +229,6 @@ struct omap_dm_timer *omap_dm_timer_request_specific(int id)
206 timer = NULL; 229 timer = NULL;
207 } 230 }
208 } 231 }
209 spin_unlock_irqrestore(&dm_timer_lock, flags);
210 232
211 if (!timer) 233 if (!timer)
212 pr_debug("%s: timer%d request failed!\n", __func__, id); 234 pr_debug("%s: timer%d request failed!\n", __func__, id);
@@ -236,7 +258,7 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_enable);
236 258
237void omap_dm_timer_disable(struct omap_dm_timer *timer) 259void omap_dm_timer_disable(struct omap_dm_timer *timer)
238{ 260{
239 pm_runtime_put(&timer->pdev->dev); 261 pm_runtime_put_sync(&timer->pdev->dev);
240} 262}
241EXPORT_SYMBOL_GPL(omap_dm_timer_disable); 263EXPORT_SYMBOL_GPL(omap_dm_timer_disable);
242 264
@@ -325,10 +347,9 @@ int omap_dm_timer_start(struct omap_dm_timer *timer)
325 347
326 omap_dm_timer_enable(timer); 348 omap_dm_timer_enable(timer);
327 349
328 if (timer->loses_context) { 350 if (!(timer->capability & OMAP_TIMER_ALWON)) {
329 u32 ctx_loss_cnt_after = 351 if (omap_pm_get_dev_context_loss_count(&timer->pdev->dev) !=
330 timer->get_context_loss_count(&timer->pdev->dev); 352 timer->ctx_loss_count)
331 if (ctx_loss_cnt_after != timer->ctx_loss_count)
332 omap_timer_restore_context(timer); 353 omap_timer_restore_context(timer);
333 } 354 }
334 355
@@ -347,20 +368,18 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_start);
347int omap_dm_timer_stop(struct omap_dm_timer *timer) 368int omap_dm_timer_stop(struct omap_dm_timer *timer)
348{ 369{
349 unsigned long rate = 0; 370 unsigned long rate = 0;
350 struct dmtimer_platform_data *pdata;
351 371
352 if (unlikely(!timer)) 372 if (unlikely(!timer))
353 return -EINVAL; 373 return -EINVAL;
354 374
355 pdata = timer->pdev->dev.platform_data; 375 if (!(timer->capability & OMAP_TIMER_NEEDS_RESET))
356 if (!pdata->needs_manual_reset)
357 rate = clk_get_rate(timer->fclk); 376 rate = clk_get_rate(timer->fclk);
358 377
359 __omap_dm_timer_stop(timer, timer->posted, rate); 378 __omap_dm_timer_stop(timer, timer->posted, rate);
360 379
361 if (timer->loses_context && timer->get_context_loss_count) 380 if (!(timer->capability & OMAP_TIMER_ALWON))
362 timer->ctx_loss_count = 381 timer->ctx_loss_count =
363 timer->get_context_loss_count(&timer->pdev->dev); 382 omap_pm_get_dev_context_loss_count(&timer->pdev->dev);
364 383
365 /* 384 /*
366 * Since the register values are computed and written within 385 * Since the register values are computed and written within
@@ -378,6 +397,8 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_stop);
378int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source) 397int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
379{ 398{
380 int ret; 399 int ret;
400 char *parent_name = NULL;
401 struct clk *fclk, *parent;
381 struct dmtimer_platform_data *pdata; 402 struct dmtimer_platform_data *pdata;
382 403
383 if (unlikely(!timer)) 404 if (unlikely(!timer))
@@ -388,7 +409,49 @@ int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
388 if (source < 0 || source >= 3) 409 if (source < 0 || source >= 3)
389 return -EINVAL; 410 return -EINVAL;
390 411
391 ret = pdata->set_timer_src(timer->pdev, source); 412 /*
413 * FIXME: Used for OMAP1 devices only because they do not currently
414 * use the clock framework to set the parent clock. To be removed
415 * once OMAP1 migrated to using clock framework for dmtimers
416 */
417 if (pdata->set_timer_src)
418 return pdata->set_timer_src(timer->pdev, source);
419
420 fclk = clk_get(&timer->pdev->dev, "fck");
421 if (IS_ERR_OR_NULL(fclk)) {
422 pr_err("%s: fck not found\n", __func__);
423 return -EINVAL;
424 }
425
426 switch (source) {
427 case OMAP_TIMER_SRC_SYS_CLK:
428 parent_name = "timer_sys_ck";
429 break;
430
431 case OMAP_TIMER_SRC_32_KHZ:
432 parent_name = "timer_32k_ck";
433 break;
434
435 case OMAP_TIMER_SRC_EXT_CLK:
436 parent_name = "timer_ext_ck";
437 break;
438 }
439
440 parent = clk_get(&timer->pdev->dev, parent_name);
441 if (IS_ERR_OR_NULL(parent)) {
442 pr_err("%s: %s not found\n", __func__, parent_name);
443 ret = -EINVAL;
444 goto out;
445 }
446
447 ret = clk_set_parent(fclk, parent);
448 if (IS_ERR_VALUE(ret))
449 pr_err("%s: failed to set %s as parent\n", __func__,
450 parent_name);
451
452 clk_put(parent);
453out:
454 clk_put(fclk);
392 455
393 return ret; 456 return ret;
394} 457}
@@ -431,10 +494,9 @@ int omap_dm_timer_set_load_start(struct omap_dm_timer *timer, int autoreload,
431 494
432 omap_dm_timer_enable(timer); 495 omap_dm_timer_enable(timer);
433 496
434 if (timer->loses_context) { 497 if (!(timer->capability & OMAP_TIMER_ALWON)) {
435 u32 ctx_loss_cnt_after = 498 if (omap_pm_get_dev_context_loss_count(&timer->pdev->dev) !=
436 timer->get_context_loss_count(&timer->pdev->dev); 499 timer->ctx_loss_count)
437 if (ctx_loss_cnt_after != timer->ctx_loss_count)
438 omap_timer_restore_context(timer); 500 omap_timer_restore_context(timer);
439 } 501 }
440 502
@@ -627,68 +689,57 @@ EXPORT_SYMBOL_GPL(omap_dm_timers_active);
627 */ 689 */
628static int __devinit omap_dm_timer_probe(struct platform_device *pdev) 690static int __devinit omap_dm_timer_probe(struct platform_device *pdev)
629{ 691{
630 int ret;
631 unsigned long flags; 692 unsigned long flags;
632 struct omap_dm_timer *timer; 693 struct omap_dm_timer *timer;
633 struct resource *mem, *irq, *ioarea; 694 struct resource *mem, *irq;
695 struct device *dev = &pdev->dev;
634 struct dmtimer_platform_data *pdata = pdev->dev.platform_data; 696 struct dmtimer_platform_data *pdata = pdev->dev.platform_data;
635 697
636 if (!pdata) { 698 if (!pdata) {
637 dev_err(&pdev->dev, "%s: no platform data.\n", __func__); 699 dev_err(dev, "%s: no platform data.\n", __func__);
638 return -ENODEV; 700 return -ENODEV;
639 } 701 }
640 702
641 irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 703 irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
642 if (unlikely(!irq)) { 704 if (unlikely(!irq)) {
643 dev_err(&pdev->dev, "%s: no IRQ resource.\n", __func__); 705 dev_err(dev, "%s: no IRQ resource.\n", __func__);
644 return -ENODEV; 706 return -ENODEV;
645 } 707 }
646 708
647 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 709 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
648 if (unlikely(!mem)) { 710 if (unlikely(!mem)) {
649 dev_err(&pdev->dev, "%s: no memory resource.\n", __func__); 711 dev_err(dev, "%s: no memory resource.\n", __func__);
650 return -ENODEV; 712 return -ENODEV;
651 } 713 }
652 714
653 ioarea = request_mem_region(mem->start, resource_size(mem), 715 timer = devm_kzalloc(dev, sizeof(struct omap_dm_timer), GFP_KERNEL);
654 pdev->name);
655 if (!ioarea) {
656 dev_err(&pdev->dev, "%s: region already claimed.\n", __func__);
657 return -EBUSY;
658 }
659
660 timer = kzalloc(sizeof(struct omap_dm_timer), GFP_KERNEL);
661 if (!timer) { 716 if (!timer) {
662 dev_err(&pdev->dev, "%s: no memory for omap_dm_timer.\n", 717 dev_err(dev, "%s: memory alloc failed!\n", __func__);
663 __func__); 718 return -ENOMEM;
664 ret = -ENOMEM;
665 goto err_free_ioregion;
666 } 719 }
667 720
668 timer->io_base = ioremap(mem->start, resource_size(mem)); 721 timer->io_base = devm_request_and_ioremap(dev, mem);
669 if (!timer->io_base) { 722 if (!timer->io_base) {
670 dev_err(&pdev->dev, "%s: ioremap failed.\n", __func__); 723 dev_err(dev, "%s: region already claimed.\n", __func__);
671 ret = -ENOMEM; 724 return -ENOMEM;
672 goto err_free_mem;
673 } 725 }
674 726
675 timer->id = pdev->id; 727 timer->id = pdev->id;
676 timer->irq = irq->start; 728 timer->irq = irq->start;
677 timer->reserved = pdata->reserved; 729 timer->reserved = omap_dm_timer_reserved_systimer(timer->id);
678 timer->pdev = pdev; 730 timer->pdev = pdev;
679 timer->loses_context = pdata->loses_context; 731 timer->capability = pdata->timer_capability;
680 timer->get_context_loss_count = pdata->get_context_loss_count;
681 732
682 /* Skip pm_runtime_enable for OMAP1 */ 733 /* Skip pm_runtime_enable for OMAP1 */
683 if (!pdata->needs_manual_reset) { 734 if (!(timer->capability & OMAP_TIMER_NEEDS_RESET)) {
684 pm_runtime_enable(&pdev->dev); 735 pm_runtime_enable(dev);
685 pm_runtime_irq_safe(&pdev->dev); 736 pm_runtime_irq_safe(dev);
686 } 737 }
687 738
688 if (!timer->reserved) { 739 if (!timer->reserved) {
689 pm_runtime_get_sync(&pdev->dev); 740 pm_runtime_get_sync(dev);
690 __omap_dm_timer_init_regs(timer); 741 __omap_dm_timer_init_regs(timer);
691 pm_runtime_put(&pdev->dev); 742 pm_runtime_put(dev);
692 } 743 }
693 744
694 /* add the timer element to the list */ 745 /* add the timer element to the list */
@@ -696,17 +747,9 @@ static int __devinit omap_dm_timer_probe(struct platform_device *pdev)
696 list_add_tail(&timer->node, &omap_timer_list); 747 list_add_tail(&timer->node, &omap_timer_list);
697 spin_unlock_irqrestore(&dm_timer_lock, flags); 748 spin_unlock_irqrestore(&dm_timer_lock, flags);
698 749
699 dev_dbg(&pdev->dev, "Device Probed.\n"); 750 dev_dbg(dev, "Device Probed.\n");
700 751
701 return 0; 752 return 0;
702
703err_free_mem:
704 kfree(timer);
705
706err_free_ioregion:
707 release_mem_region(mem->start, resource_size(mem));
708
709 return ret;
710} 753}
711 754
712/** 755/**
@@ -727,7 +770,6 @@ static int __devexit omap_dm_timer_remove(struct platform_device *pdev)
727 list_for_each_entry(timer, &omap_timer_list, node) 770 list_for_each_entry(timer, &omap_timer_list, node)
728 if (timer->pdev->id == pdev->id) { 771 if (timer->pdev->id == pdev->id) {
729 list_del(&timer->node); 772 list_del(&timer->node);
730 kfree(timer);
731 ret = 0; 773 ret = 0;
732 break; 774 break;
733 } 775 }
diff --git a/arch/arm/plat-omap/include/plat/board.h b/arch/arm/plat-omap/include/plat/board.h
index 4814c5b6530..e62f20a5c0a 100644
--- a/arch/arm/plat-omap/include/plat/board.h
+++ b/arch/arm/plat-omap/include/plat/board.h
@@ -57,44 +57,6 @@ struct omap_camera_sensor_config {
57 int (*power_off)(void * data); 57 int (*power_off)(void * data);
58}; 58};
59 59
60struct omap_usb_config {
61 /* Configure drivers according to the connectors on your board:
62 * - "A" connector (rectagular)
63 * ... for host/OHCI use, set "register_host".
64 * - "B" connector (squarish) or "Mini-B"
65 * ... for device/gadget use, set "register_dev".
66 * - "Mini-AB" connector (very similar to Mini-B)
67 * ... for OTG use as device OR host, initialize "otg"
68 */
69 unsigned register_host:1;
70 unsigned register_dev:1;
71 u8 otg; /* port number, 1-based: usb1 == 2 */
72
73 u8 hmc_mode;
74
75 /* implicitly true if otg: host supports remote wakeup? */
76 u8 rwc;
77
78 /* signaling pins used to talk to transceiver on usbN:
79 * 0 == usbN unused
80 * 2 == usb0-only, using internal transceiver
81 * 3 == 3 wire bidirectional
82 * 4 == 4 wire bidirectional
83 * 6 == 6 wire unidirectional (or TLL)
84 */
85 u8 pins[3];
86
87 struct platform_device *udc_device;
88 struct platform_device *ohci_device;
89 struct platform_device *otg_device;
90
91 u32 (*usb0_init)(unsigned nwires, unsigned is_device);
92 u32 (*usb1_init)(unsigned nwires);
93 u32 (*usb2_init)(unsigned nwires, unsigned alt_pingroup);
94
95 int (*ocpi_enable)(void);
96};
97
98struct omap_lcd_config { 60struct omap_lcd_config {
99 char panel_name[16]; 61 char panel_name[16];
100 char ctrl_name[16]; 62 char ctrl_name[16];
diff --git a/arch/arm/plat-omap/include/plat/clkdev_omap.h b/arch/arm/plat-omap/include/plat/clkdev_omap.h
index d0ed8c443a6..025d85a3ee8 100644
--- a/arch/arm/plat-omap/include/plat/clkdev_omap.h
+++ b/arch/arm/plat-omap/include/plat/clkdev_omap.h
@@ -39,6 +39,7 @@ struct omap_clk {
39#define CK_443X (1 << 11) 39#define CK_443X (1 << 11)
40#define CK_TI816X (1 << 12) 40#define CK_TI816X (1 << 12)
41#define CK_446X (1 << 13) 41#define CK_446X (1 << 13)
42#define CK_AM33XX (1 << 14) /* AM33xx specific clocks */
42#define CK_1710 (1 << 15) /* 1710 extra for rate selection */ 43#define CK_1710 (1 << 15) /* 1710 extra for rate selection */
43 44
44 45
diff --git a/arch/arm/plat-omap/include/plat/clock.h b/arch/arm/plat-omap/include/plat/clock.h
index d0ef57c1d71..656b9862279 100644
--- a/arch/arm/plat-omap/include/plat/clock.h
+++ b/arch/arm/plat-omap/include/plat/clock.h
@@ -156,7 +156,6 @@ struct dpll_data {
156 u8 min_divider; 156 u8 min_divider;
157 u16 max_divider; 157 u16 max_divider;
158 u8 modes; 158 u8 modes;
159#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
160 void __iomem *autoidle_reg; 159 void __iomem *autoidle_reg;
161 void __iomem *idlest_reg; 160 void __iomem *idlest_reg;
162 u32 autoidle_mask; 161 u32 autoidle_mask;
@@ -167,7 +166,6 @@ struct dpll_data {
167 u8 auto_recal_bit; 166 u8 auto_recal_bit;
168 u8 recal_en_bit; 167 u8 recal_en_bit;
169 u8 recal_st_bit; 168 u8 recal_st_bit;
170# endif
171 u8 flags; 169 u8 flags;
172}; 170};
173 171
diff --git a/arch/arm/plat-omap/include/plat/cpu.h b/arch/arm/plat-omap/include/plat/cpu.h
index de6c0a08f46..bb5d08a70db 100644
--- a/arch/arm/plat-omap/include/plat/cpu.h
+++ b/arch/arm/plat-omap/include/plat/cpu.h
@@ -9,7 +9,7 @@
9 * 9 *
10 * Written by Tony Lindgren <tony.lindgren@nokia.com> 10 * Written by Tony Lindgren <tony.lindgren@nokia.com>
11 * 11 *
12 * Added OMAP4 specific defines - Santosh Shilimkar<santosh.shilimkar@ti.com> 12 * Added OMAP4/5 specific defines - Santosh Shilimkar<santosh.shilimkar@ti.com>
13 * 13 *
14 * This program is free software; you can redistribute it and/or modify 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 15 * it under the terms of the GNU General Public License as published by
@@ -70,6 +70,7 @@ unsigned int omap_rev(void);
70 * cpu_is_omap443x(): True for OMAP4430 70 * cpu_is_omap443x(): True for OMAP4430
71 * cpu_is_omap446x(): True for OMAP4460 71 * cpu_is_omap446x(): True for OMAP4460
72 * cpu_is_omap447x(): True for OMAP4470 72 * cpu_is_omap447x(): True for OMAP4470
73 * soc_is_omap543x(): True for OMAP5430, OMAP5432
73 */ 74 */
74#define GET_OMAP_CLASS (omap_rev() & 0xff) 75#define GET_OMAP_CLASS (omap_rev() & 0xff)
75 76
@@ -122,6 +123,7 @@ IS_OMAP_CLASS(24xx, 0x24)
122IS_OMAP_CLASS(34xx, 0x34) 123IS_OMAP_CLASS(34xx, 0x34)
123IS_OMAP_CLASS(44xx, 0x44) 124IS_OMAP_CLASS(44xx, 0x44)
124IS_AM_CLASS(35xx, 0x35) 125IS_AM_CLASS(35xx, 0x35)
126IS_OMAP_CLASS(54xx, 0x54)
125IS_AM_CLASS(33xx, 0x33) 127IS_AM_CLASS(33xx, 0x33)
126 128
127IS_TI_CLASS(81xx, 0x81) 129IS_TI_CLASS(81xx, 0x81)
@@ -133,6 +135,7 @@ IS_OMAP_SUBCLASS(363x, 0x363)
133IS_OMAP_SUBCLASS(443x, 0x443) 135IS_OMAP_SUBCLASS(443x, 0x443)
134IS_OMAP_SUBCLASS(446x, 0x446) 136IS_OMAP_SUBCLASS(446x, 0x446)
135IS_OMAP_SUBCLASS(447x, 0x447) 137IS_OMAP_SUBCLASS(447x, 0x447)
138IS_OMAP_SUBCLASS(543x, 0x543)
136 139
137IS_TI_SUBCLASS(816x, 0x816) 140IS_TI_SUBCLASS(816x, 0x816)
138IS_TI_SUBCLASS(814x, 0x814) 141IS_TI_SUBCLASS(814x, 0x814)
@@ -150,12 +153,14 @@ IS_AM_SUBCLASS(335x, 0x335)
150#define cpu_is_ti816x() 0 153#define cpu_is_ti816x() 0
151#define cpu_is_ti814x() 0 154#define cpu_is_ti814x() 0
152#define soc_is_am35xx() 0 155#define soc_is_am35xx() 0
153#define cpu_is_am33xx() 0 156#define soc_is_am33xx() 0
154#define cpu_is_am335x() 0 157#define soc_is_am335x() 0
155#define cpu_is_omap44xx() 0 158#define cpu_is_omap44xx() 0
156#define cpu_is_omap443x() 0 159#define cpu_is_omap443x() 0
157#define cpu_is_omap446x() 0 160#define cpu_is_omap446x() 0
158#define cpu_is_omap447x() 0 161#define cpu_is_omap447x() 0
162#define soc_is_omap54xx() 0
163#define soc_is_omap543x() 0
159 164
160#if defined(MULTI_OMAP1) 165#if defined(MULTI_OMAP1)
161# if defined(CONFIG_ARCH_OMAP730) 166# if defined(CONFIG_ARCH_OMAP730)
@@ -238,9 +243,7 @@ IS_AM_SUBCLASS(335x, 0x335)
238/* 243/*
239 * Macros to detect individual cpu types. 244 * Macros to detect individual cpu types.
240 * These are only rarely needed. 245 * These are only rarely needed.
241 * cpu_is_omap330(): True for OMAP330 246 * cpu_is_omap310(): True for OMAP310
242 * cpu_is_omap730(): True for OMAP730
243 * cpu_is_omap850(): True for OMAP850
244 * cpu_is_omap1510(): True for OMAP1510 247 * cpu_is_omap1510(): True for OMAP1510
245 * cpu_is_omap1610(): True for OMAP1610 248 * cpu_is_omap1610(): True for OMAP1610
246 * cpu_is_omap1611(): True for OMAP1611 249 * cpu_is_omap1611(): True for OMAP1611
@@ -262,8 +265,6 @@ static inline int is_omap ##type (void) \
262} 265}
263 266
264IS_OMAP_TYPE(310, 0x0310) 267IS_OMAP_TYPE(310, 0x0310)
265IS_OMAP_TYPE(730, 0x0730)
266IS_OMAP_TYPE(850, 0x0850)
267IS_OMAP_TYPE(1510, 0x1510) 268IS_OMAP_TYPE(1510, 0x1510)
268IS_OMAP_TYPE(1610, 0x1610) 269IS_OMAP_TYPE(1610, 0x1610)
269IS_OMAP_TYPE(1611, 0x1611) 270IS_OMAP_TYPE(1611, 0x1611)
@@ -277,8 +278,6 @@ IS_OMAP_TYPE(2430, 0x2430)
277IS_OMAP_TYPE(3430, 0x3430) 278IS_OMAP_TYPE(3430, 0x3430)
278 279
279#define cpu_is_omap310() 0 280#define cpu_is_omap310() 0
280#define cpu_is_omap730() 0
281#define cpu_is_omap850() 0
282#define cpu_is_omap1510() 0 281#define cpu_is_omap1510() 0
283#define cpu_is_omap1610() 0 282#define cpu_is_omap1610() 0
284#define cpu_is_omap5912() 0 283#define cpu_is_omap5912() 0
@@ -291,22 +290,13 @@ IS_OMAP_TYPE(3430, 0x3430)
291#define cpu_is_omap2430() 0 290#define cpu_is_omap2430() 0
292#define cpu_is_omap3430() 0 291#define cpu_is_omap3430() 0
293#define cpu_is_omap3630() 0 292#define cpu_is_omap3630() 0
293#define soc_is_omap5430() 0
294 294
295/* 295/*
296 * Whether we have MULTI_OMAP1 or not, we still need to distinguish 296 * Whether we have MULTI_OMAP1 or not, we still need to distinguish
297 * between 730 vs 850, 330 vs. 1510 and 1611B/5912 vs. 1710. 297 * between 310 vs. 1510 and 1611B/5912 vs. 1710.
298 */ 298 */
299 299
300#if defined(CONFIG_ARCH_OMAP730)
301# undef cpu_is_omap730
302# define cpu_is_omap730() is_omap730()
303#endif
304
305#if defined(CONFIG_ARCH_OMAP850)
306# undef cpu_is_omap850
307# define cpu_is_omap850() is_omap850()
308#endif
309
310#if defined(CONFIG_ARCH_OMAP15XX) 300#if defined(CONFIG_ARCH_OMAP15XX)
311# undef cpu_is_omap310 301# undef cpu_is_omap310
312# undef cpu_is_omap1510 302# undef cpu_is_omap1510
@@ -344,8 +334,6 @@ IS_OMAP_TYPE(3430, 0x3430)
344# undef cpu_is_ti816x 334# undef cpu_is_ti816x
345# undef cpu_is_ti814x 335# undef cpu_is_ti814x
346# undef soc_is_am35xx 336# undef soc_is_am35xx
347# undef cpu_is_am33xx
348# undef cpu_is_am335x
349# define cpu_is_omap3430() is_omap3430() 337# define cpu_is_omap3430() is_omap3430()
350# undef cpu_is_omap3630 338# undef cpu_is_omap3630
351# define cpu_is_omap3630() is_omap363x() 339# define cpu_is_omap3630() is_omap363x()
@@ -353,8 +341,13 @@ IS_OMAP_TYPE(3430, 0x3430)
353# define cpu_is_ti816x() is_ti816x() 341# define cpu_is_ti816x() is_ti816x()
354# define cpu_is_ti814x() is_ti814x() 342# define cpu_is_ti814x() is_ti814x()
355# define soc_is_am35xx() is_am35xx() 343# define soc_is_am35xx() is_am35xx()
356# define cpu_is_am33xx() is_am33xx() 344#endif
357# define cpu_is_am335x() is_am335x() 345
346# if defined(CONFIG_SOC_AM33XX)
347# undef soc_is_am33xx
348# undef soc_is_am335x
349# define soc_is_am33xx() is_am33xx()
350# define soc_is_am335x() is_am335x()
358#endif 351#endif
359 352
360# if defined(CONFIG_ARCH_OMAP4) 353# if defined(CONFIG_ARCH_OMAP4)
@@ -368,11 +361,19 @@ IS_OMAP_TYPE(3430, 0x3430)
368# define cpu_is_omap447x() is_omap447x() 361# define cpu_is_omap447x() is_omap447x()
369# endif 362# endif
370 363
364# if defined(CONFIG_SOC_OMAP5)
365# undef soc_is_omap54xx
366# undef soc_is_omap543x
367# define soc_is_omap54xx() is_omap54xx()
368# define soc_is_omap543x() is_omap543x()
369#endif
370
371/* Macros to detect if we have OMAP1 or OMAP2 */ 371/* Macros to detect if we have OMAP1 or OMAP2 */
372#define cpu_class_is_omap1() (cpu_is_omap7xx() || cpu_is_omap15xx() || \ 372#define cpu_class_is_omap1() (cpu_is_omap7xx() || cpu_is_omap15xx() || \
373 cpu_is_omap16xx()) 373 cpu_is_omap16xx())
374#define cpu_class_is_omap2() (cpu_is_omap24xx() || cpu_is_omap34xx() || \ 374#define cpu_class_is_omap2() (cpu_is_omap24xx() || cpu_is_omap34xx() || \
375 cpu_is_omap44xx()) 375 cpu_is_omap44xx() || soc_is_omap54xx() || \
376 soc_is_am33xx())
376 377
377/* Various silicon revisions for omap2 */ 378/* Various silicon revisions for omap2 */
378#define OMAP242X_CLASS 0x24200024 379#define OMAP242X_CLASS 0x24200024
@@ -408,7 +409,7 @@ IS_OMAP_TYPE(3430, 0x3430)
408#define AM35XX_REV_ES1_0 AM35XX_CLASS 409#define AM35XX_REV_ES1_0 AM35XX_CLASS
409#define AM35XX_REV_ES1_1 (AM35XX_CLASS | (0x1 << 8)) 410#define AM35XX_REV_ES1_1 (AM35XX_CLASS | (0x1 << 8))
410 411
411#define AM335X_CLASS 0x33500034 412#define AM335X_CLASS 0x33500033
412#define AM335X_REV_ES1_0 AM335X_CLASS 413#define AM335X_REV_ES1_0 AM335X_CLASS
413 414
414#define OMAP443X_CLASS 0x44300044 415#define OMAP443X_CLASS 0x44300044
@@ -425,9 +426,14 @@ IS_OMAP_TYPE(3430, 0x3430)
425#define OMAP447X_CLASS 0x44700044 426#define OMAP447X_CLASS 0x44700044
426#define OMAP4470_REV_ES1_0 (OMAP447X_CLASS | (0x10 << 8)) 427#define OMAP4470_REV_ES1_0 (OMAP447X_CLASS | (0x10 << 8))
427 428
429#define OMAP54XX_CLASS 0x54000054
430#define OMAP5430_REV_ES1_0 (OMAP54XX_CLASS | (0x30 << 16) | (0x10 << 8))
431#define OMAP5432_REV_ES1_0 (OMAP54XX_CLASS | (0x32 << 16) | (0x10 << 8))
432
428void omap2xxx_check_revision(void); 433void omap2xxx_check_revision(void);
429void omap3xxx_check_revision(void); 434void omap3xxx_check_revision(void);
430void omap4xxx_check_revision(void); 435void omap4xxx_check_revision(void);
436void omap5xxx_check_revision(void);
431void omap3xxx_check_features(void); 437void omap3xxx_check_features(void);
432void ti81xx_check_features(void); 438void ti81xx_check_features(void);
433void omap4xxx_check_features(void); 439void omap4xxx_check_features(void);
diff --git a/arch/arm/plat-omap/include/plat/dmtimer.h b/arch/arm/plat-omap/include/plat/dmtimer.h
index 5da73562e48..19e7fa577bd 100644
--- a/arch/arm/plat-omap/include/plat/dmtimer.h
+++ b/arch/arm/plat-omap/include/plat/dmtimer.h
@@ -55,23 +55,17 @@
55#define OMAP_TIMER_TRIGGER_OVERFLOW 0x01 55#define OMAP_TIMER_TRIGGER_OVERFLOW 0x01
56#define OMAP_TIMER_TRIGGER_OVERFLOW_AND_COMPARE 0x02 56#define OMAP_TIMER_TRIGGER_OVERFLOW_AND_COMPARE 0x02
57 57
58/*
59 * IP revision identifier so that Highlander IP
60 * in OMAP4 can be distinguished.
61 */
62#define OMAP_TIMER_IP_VERSION_1 0x1
63
64/* timer capabilities used in hwmod database */ 58/* timer capabilities used in hwmod database */
65#define OMAP_TIMER_SECURE 0x80000000 59#define OMAP_TIMER_SECURE 0x80000000
66#define OMAP_TIMER_ALWON 0x40000000 60#define OMAP_TIMER_ALWON 0x40000000
67#define OMAP_TIMER_HAS_PWM 0x20000000 61#define OMAP_TIMER_HAS_PWM 0x20000000
62#define OMAP_TIMER_NEEDS_RESET 0x10000000
68 63
69struct omap_timer_capability_dev_attr { 64struct omap_timer_capability_dev_attr {
70 u32 timer_capability; 65 u32 timer_capability;
71}; 66};
72 67
73struct omap_dm_timer; 68struct omap_dm_timer;
74struct clk;
75 69
76struct timer_regs { 70struct timer_regs {
77 u32 tidr; 71 u32 tidr;
@@ -96,16 +90,12 @@ struct timer_regs {
96}; 90};
97 91
98struct dmtimer_platform_data { 92struct dmtimer_platform_data {
93 /* set_timer_src - Only used for OMAP1 devices */
99 int (*set_timer_src)(struct platform_device *pdev, int source); 94 int (*set_timer_src)(struct platform_device *pdev, int source);
100 int timer_ip_version; 95 u32 timer_capability;
101 u32 needs_manual_reset:1;
102 bool reserved;
103
104 bool loses_context;
105
106 int (*get_context_loss_count)(struct device *dev);
107}; 96};
108 97
98int omap_dm_timer_reserve_systimer(int id);
109struct omap_dm_timer *omap_dm_timer_request(void); 99struct omap_dm_timer *omap_dm_timer_request(void);
110struct omap_dm_timer *omap_dm_timer_request_specific(int timer_id); 100struct omap_dm_timer *omap_dm_timer_request_specific(int timer_id);
111int omap_dm_timer_free(struct omap_dm_timer *timer); 101int omap_dm_timer_free(struct omap_dm_timer *timer);
@@ -272,13 +262,11 @@ struct omap_dm_timer {
272 unsigned reserved:1; 262 unsigned reserved:1;
273 unsigned posted:1; 263 unsigned posted:1;
274 struct timer_regs context; 264 struct timer_regs context;
275 bool loses_context;
276 int ctx_loss_count; 265 int ctx_loss_count;
277 int revision; 266 int revision;
267 u32 capability;
278 struct platform_device *pdev; 268 struct platform_device *pdev;
279 struct list_head node; 269 struct list_head node;
280
281 int (*get_context_loss_count)(struct device *dev);
282}; 270};
283 271
284int omap_dm_timer_prepare(struct omap_dm_timer *timer); 272int omap_dm_timer_prepare(struct omap_dm_timer *timer);
diff --git a/arch/arm/plat-omap/include/plat/dsp.h b/arch/arm/plat-omap/include/plat/dsp.h
index 9c604b390f9..5927709b190 100644
--- a/arch/arm/plat-omap/include/plat/dsp.h
+++ b/arch/arm/plat-omap/include/plat/dsp.h
@@ -18,6 +18,9 @@ struct omap_dsp_platform_data {
18 u32 (*dsp_cm_read)(s16 , u16); 18 u32 (*dsp_cm_read)(s16 , u16);
19 u32 (*dsp_cm_rmw_bits)(u32, u32, s16, s16); 19 u32 (*dsp_cm_rmw_bits)(u32, u32, s16, s16);
20 20
21 void (*set_bootaddr)(u32);
22 void (*set_bootmode)(u8);
23
21 phys_addr_t phys_mempool_base; 24 phys_addr_t phys_mempool_base;
22 phys_addr_t phys_mempool_size; 25 phys_addr_t phys_mempool_size;
23}; 26};
diff --git a/arch/arm/plat-omap/include/plat/hardware.h b/arch/arm/plat-omap/include/plat/hardware.h
index e897978371c..ddbde38e1e3 100644
--- a/arch/arm/plat-omap/include/plat/hardware.h
+++ b/arch/arm/plat-omap/include/plat/hardware.h
@@ -288,5 +288,6 @@
288#include <plat/omap44xx.h> 288#include <plat/omap44xx.h>
289#include <plat/ti81xx.h> 289#include <plat/ti81xx.h>
290#include <plat/am33xx.h> 290#include <plat/am33xx.h>
291#include <plat/omap54xx.h>
291 292
292#endif /* __ASM_ARCH_OMAP_HARDWARE_H */ 293#endif /* __ASM_ARCH_OMAP_HARDWARE_H */
diff --git a/arch/arm/plat-omap/include/plat/mmc.h b/arch/arm/plat-omap/include/plat/mmc.h
index 5493bd95da5..eb3e4d55534 100644
--- a/arch/arm/plat-omap/include/plat/mmc.h
+++ b/arch/arm/plat-omap/include/plat/mmc.h
@@ -81,8 +81,6 @@ struct omap_mmc_platform_data {
81 /* Return context loss count due to PM states changing */ 81 /* Return context loss count due to PM states changing */
82 int (*get_context_loss_count)(struct device *dev); 82 int (*get_context_loss_count)(struct device *dev);
83 83
84 u64 dma_mask;
85
86 /* Integrating attributes from the omap_hwmod layer */ 84 /* Integrating attributes from the omap_hwmod layer */
87 u8 controller_flags; 85 u8 controller_flags;
88 86
diff --git a/arch/arm/plat-omap/include/plat/multi.h b/arch/arm/plat-omap/include/plat/multi.h
index 999ffba2690..324d31b1485 100644
--- a/arch/arm/plat-omap/include/plat/multi.h
+++ b/arch/arm/plat-omap/include/plat/multi.h
@@ -99,4 +99,22 @@
99# endif 99# endif
100#endif 100#endif
101 101
102#ifdef CONFIG_SOC_OMAP5
103# ifdef OMAP_NAME
104# undef MULTI_OMAP2
105# define MULTI_OMAP2
106# else
107# define OMAP_NAME omap5
108# endif
109#endif
110
111#ifdef CONFIG_SOC_AM33XX
112# ifdef OMAP_NAME
113# undef MULTI_OMAP2
114# define MULTI_OMAP2
115# else
116# define OMAP_NAME am33xx
117# endif
118#endif
119
102#endif /* __PLAT_OMAP_MULTI_H */ 120#endif /* __PLAT_OMAP_MULTI_H */
diff --git a/arch/arm/plat-omap/include/plat/mux.h b/arch/arm/plat-omap/include/plat/mux.h
index aeba71796ad..32394895920 100644
--- a/arch/arm/plat-omap/include/plat/mux.h
+++ b/arch/arm/plat-omap/include/plat/mux.h
@@ -99,7 +99,7 @@
99 99
100/* 100/*
101 * OMAP730/850 has a slightly different config for the pin mux. 101 * OMAP730/850 has a slightly different config for the pin mux.
102 * - config regs are the OMAP7XX_IO_CONF_x regs (see omap730.h) regs and 102 * - config regs are the OMAP7XX_IO_CONF_x regs (see omap7xx.h) regs and
103 * not the FUNC_MUX_CTRL_x regs from hardware.h 103 * not the FUNC_MUX_CTRL_x regs from hardware.h
104 * - for pull-up/down, only has one enable bit which is is in the same register 104 * - for pull-up/down, only has one enable bit which is is in the same register
105 * as mux config 105 * as mux config
diff --git a/arch/arm/plat-omap/include/plat/omap-secure.h b/arch/arm/plat-omap/include/plat/omap-secure.h
index 8c7994ce986..0e4acd2d2de 100644
--- a/arch/arm/plat-omap/include/plat/omap-secure.h
+++ b/arch/arm/plat-omap/include/plat/omap-secure.h
@@ -3,12 +3,7 @@
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5 5
6#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
7extern int omap_secure_ram_reserve_memblock(void); 6extern int omap_secure_ram_reserve_memblock(void);
8#else
9static inline void omap_secure_ram_reserve_memblock(void)
10{ }
11#endif
12 7
13#ifdef CONFIG_OMAP4_ERRATA_I688 8#ifdef CONFIG_OMAP4_ERRATA_I688
14extern int omap_barrier_reserve_memblock(void); 9extern int omap_barrier_reserve_memblock(void);
diff --git a/arch/arm/plat-omap/include/plat/omap54xx.h b/arch/arm/plat-omap/include/plat/omap54xx.h
new file mode 100644
index 00000000000..a2582bb3cab
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/omap54xx.h
@@ -0,0 +1,32 @@
1/*:
2 * Address mappings and base address for OMAP5 interconnects
3 * and peripherals.
4 *
5 * Copyright (C) 2012 Texas Instruments
6 * Santosh Shilimkar <santosh.shilimkar@ti.com>
7 * Sricharan <r.sricharan@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#ifndef __ASM_SOC_OMAP54XX_H
14#define __ASM_SOC_OMAP54XX_H
15
16/*
17 * Please place only base defines here and put the rest in device
18 * specific headers.
19 */
20#define L4_54XX_BASE 0x4a000000
21#define L4_WK_54XX_BASE 0x4ae00000
22#define L4_PER_54XX_BASE 0x48000000
23#define L3_54XX_BASE 0x44000000
24#define OMAP54XX_32KSYNCT_BASE 0x4ae04000
25#define OMAP54XX_CM_CORE_AON_BASE 0x4a004000
26#define OMAP54XX_CM_CORE_BASE 0x4a008000
27#define OMAP54XX_PRM_BASE 0x4ae06000
28#define OMAP54XX_PRCM_MPU_BASE 0x48243000
29#define OMAP54XX_SCM_BASE 0x4a002000
30#define OMAP54XX_CTRL_BASE 0x4a002800
31
32#endif /* __ASM_SOC_OMAP555554XX_H */
diff --git a/arch/arm/plat-omap/include/plat/omap730.h b/arch/arm/plat-omap/include/plat/omap730.h
deleted file mode 100644
index 14272bc1a6f..00000000000
--- a/arch/arm/plat-omap/include/plat/omap730.h
+++ /dev/null
@@ -1,102 +0,0 @@
1/* arch/arm/plat-omap/include/mach/omap730.h
2 *
3 * Hardware definitions for TI OMAP730 processor.
4 *
5 * Cleanup for Linux-2.6 by Dirk Behme <dirk.behme@de.bosch.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
15 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
18 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 675 Mass Ave, Cambridge, MA 02139, USA.
26 */
27
28#ifndef __ASM_ARCH_OMAP730_H
29#define __ASM_ARCH_OMAP730_H
30
31/*
32 * ----------------------------------------------------------------------------
33 * Base addresses
34 * ----------------------------------------------------------------------------
35 */
36
37/* Syntax: XX_BASE = Virtual base address, XX_START = Physical base address */
38
39#define OMAP730_DSP_BASE 0xE0000000
40#define OMAP730_DSP_SIZE 0x50000
41#define OMAP730_DSP_START 0xE0000000
42
43#define OMAP730_DSPREG_BASE 0xE1000000
44#define OMAP730_DSPREG_SIZE SZ_128K
45#define OMAP730_DSPREG_START 0xE1000000
46
47/*
48 * ----------------------------------------------------------------------------
49 * OMAP730 specific configuration registers
50 * ----------------------------------------------------------------------------
51 */
52#define OMAP730_CONFIG_BASE 0xfffe1000
53#define OMAP730_IO_CONF_0 0xfffe1070
54#define OMAP730_IO_CONF_1 0xfffe1074
55#define OMAP730_IO_CONF_2 0xfffe1078
56#define OMAP730_IO_CONF_3 0xfffe107c
57#define OMAP730_IO_CONF_4 0xfffe1080
58#define OMAP730_IO_CONF_5 0xfffe1084
59#define OMAP730_IO_CONF_6 0xfffe1088
60#define OMAP730_IO_CONF_7 0xfffe108c
61#define OMAP730_IO_CONF_8 0xfffe1090
62#define OMAP730_IO_CONF_9 0xfffe1094
63#define OMAP730_IO_CONF_10 0xfffe1098
64#define OMAP730_IO_CONF_11 0xfffe109c
65#define OMAP730_IO_CONF_12 0xfffe10a0
66#define OMAP730_IO_CONF_13 0xfffe10a4
67
68#define OMAP730_MODE_1 0xfffe1010
69#define OMAP730_MODE_2 0xfffe1014
70
71/* CSMI specials: in terms of base + offset */
72#define OMAP730_MODE2_OFFSET 0x14
73
74/*
75 * ----------------------------------------------------------------------------
76 * OMAP730 traffic controller configuration registers
77 * ----------------------------------------------------------------------------
78 */
79#define OMAP730_FLASH_CFG_0 0xfffecc10
80#define OMAP730_FLASH_ACFG_0 0xfffecc50
81#define OMAP730_FLASH_CFG_1 0xfffecc14
82#define OMAP730_FLASH_ACFG_1 0xfffecc54
83
84/*
85 * ----------------------------------------------------------------------------
86 * OMAP730 DSP control registers
87 * ----------------------------------------------------------------------------
88 */
89#define OMAP730_ICR_BASE 0xfffbb800
90#define OMAP730_DSP_M_CTL 0xfffbb804
91#define OMAP730_DSP_MMU_BASE 0xfffed200
92
93/*
94 * ----------------------------------------------------------------------------
95 * OMAP730 PCC_UPLD configuration registers
96 * ----------------------------------------------------------------------------
97 */
98#define OMAP730_PCC_UPLD_CTRL_BASE (0xfffe0900)
99#define OMAP730_PCC_UPLD_CTRL (OMAP730_PCC_UPLD_CTRL_BASE + 0x00)
100
101#endif /* __ASM_ARCH_OMAP730_H */
102
diff --git a/arch/arm/plat-omap/include/plat/omap850.h b/arch/arm/plat-omap/include/plat/omap850.h
deleted file mode 100644
index c33f6798171..00000000000
--- a/arch/arm/plat-omap/include/plat/omap850.h
+++ /dev/null
@@ -1,102 +0,0 @@
1/* arch/arm/plat-omap/include/mach/omap850.h
2 *
3 * Hardware definitions for TI OMAP850 processor.
4 *
5 * Derived from omap730.h by Zebediah C. McClure <zmc@lurian.net>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
15 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
18 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 675 Mass Ave, Cambridge, MA 02139, USA.
26 */
27
28#ifndef __ASM_ARCH_OMAP850_H
29#define __ASM_ARCH_OMAP850_H
30
31/*
32 * ----------------------------------------------------------------------------
33 * Base addresses
34 * ----------------------------------------------------------------------------
35 */
36
37/* Syntax: XX_BASE = Virtual base address, XX_START = Physical base address */
38
39#define OMAP850_DSP_BASE 0xE0000000
40#define OMAP850_DSP_SIZE 0x50000
41#define OMAP850_DSP_START 0xE0000000
42
43#define OMAP850_DSPREG_BASE 0xE1000000
44#define OMAP850_DSPREG_SIZE SZ_128K
45#define OMAP850_DSPREG_START 0xE1000000
46
47/*
48 * ----------------------------------------------------------------------------
49 * OMAP850 specific configuration registers
50 * ----------------------------------------------------------------------------
51 */
52#define OMAP850_CONFIG_BASE 0xfffe1000
53#define OMAP850_IO_CONF_0 0xfffe1070
54#define OMAP850_IO_CONF_1 0xfffe1074
55#define OMAP850_IO_CONF_2 0xfffe1078
56#define OMAP850_IO_CONF_3 0xfffe107c
57#define OMAP850_IO_CONF_4 0xfffe1080
58#define OMAP850_IO_CONF_5 0xfffe1084
59#define OMAP850_IO_CONF_6 0xfffe1088
60#define OMAP850_IO_CONF_7 0xfffe108c
61#define OMAP850_IO_CONF_8 0xfffe1090
62#define OMAP850_IO_CONF_9 0xfffe1094
63#define OMAP850_IO_CONF_10 0xfffe1098
64#define OMAP850_IO_CONF_11 0xfffe109c
65#define OMAP850_IO_CONF_12 0xfffe10a0
66#define OMAP850_IO_CONF_13 0xfffe10a4
67
68#define OMAP850_MODE_1 0xfffe1010
69#define OMAP850_MODE_2 0xfffe1014
70
71/* CSMI specials: in terms of base + offset */
72#define OMAP850_MODE2_OFFSET 0x14
73
74/*
75 * ----------------------------------------------------------------------------
76 * OMAP850 traffic controller configuration registers
77 * ----------------------------------------------------------------------------
78 */
79#define OMAP850_FLASH_CFG_0 0xfffecc10
80#define OMAP850_FLASH_ACFG_0 0xfffecc50
81#define OMAP850_FLASH_CFG_1 0xfffecc14
82#define OMAP850_FLASH_ACFG_1 0xfffecc54
83
84/*
85 * ----------------------------------------------------------------------------
86 * OMAP850 DSP control registers
87 * ----------------------------------------------------------------------------
88 */
89#define OMAP850_ICR_BASE 0xfffbb800
90#define OMAP850_DSP_M_CTL 0xfffbb804
91#define OMAP850_DSP_MMU_BASE 0xfffed200
92
93/*
94 * ----------------------------------------------------------------------------
95 * OMAP850 PCC_UPLD configuration registers
96 * ----------------------------------------------------------------------------
97 */
98#define OMAP850_PCC_UPLD_CTRL_BASE (0xfffe0900)
99#define OMAP850_PCC_UPLD_CTRL (OMAP850_PCC_UPLD_CTRL_BASE + 0x00)
100
101#endif /* __ASM_ARCH_OMAP850_H */
102
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index c835b7194ff..6132972aff3 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -41,6 +41,7 @@ struct omap_device;
41 41
42extern struct omap_hwmod_sysc_fields omap_hwmod_sysc_type1; 42extern struct omap_hwmod_sysc_fields omap_hwmod_sysc_type1;
43extern struct omap_hwmod_sysc_fields omap_hwmod_sysc_type2; 43extern struct omap_hwmod_sysc_fields omap_hwmod_sysc_type2;
44extern struct omap_hwmod_sysc_fields omap_hwmod_sysc_type3;
44 45
45/* 46/*
46 * OCP SYSCONFIG bit shifts/masks TYPE1. These are for IPs compliant 47 * OCP SYSCONFIG bit shifts/masks TYPE1. These are for IPs compliant
@@ -69,6 +70,17 @@ extern struct omap_hwmod_sysc_fields omap_hwmod_sysc_type2;
69#define SYSC_TYPE2_SIDLEMODE_MASK (0x3 << SYSC_TYPE2_SIDLEMODE_SHIFT) 70#define SYSC_TYPE2_SIDLEMODE_MASK (0x3 << SYSC_TYPE2_SIDLEMODE_SHIFT)
70#define SYSC_TYPE2_MIDLEMODE_SHIFT 4 71#define SYSC_TYPE2_MIDLEMODE_SHIFT 4
71#define SYSC_TYPE2_MIDLEMODE_MASK (0x3 << SYSC_TYPE2_MIDLEMODE_SHIFT) 72#define SYSC_TYPE2_MIDLEMODE_MASK (0x3 << SYSC_TYPE2_MIDLEMODE_SHIFT)
73#define SYSC_TYPE2_DMADISABLE_SHIFT 16
74#define SYSC_TYPE2_DMADISABLE_MASK (0x1 << SYSC_TYPE2_DMADISABLE_SHIFT)
75
76/*
77 * OCP SYSCONFIG bit shifts/masks TYPE3.
78 * This is applicable for some IPs present in AM33XX
79 */
80#define SYSC_TYPE3_SIDLEMODE_SHIFT 0
81#define SYSC_TYPE3_SIDLEMODE_MASK (0x3 << SYSC_TYPE3_SIDLEMODE_SHIFT)
82#define SYSC_TYPE3_MIDLEMODE_SHIFT 2
83#define SYSC_TYPE3_MIDLEMODE_MASK (0x3 << SYSC_TYPE3_MIDLEMODE_SHIFT)
72 84
73/* OCP SYSSTATUS bit shifts/masks */ 85/* OCP SYSSTATUS bit shifts/masks */
74#define SYSS_RESETDONE_SHIFT 0 86#define SYSS_RESETDONE_SHIFT 0
@@ -283,6 +295,7 @@ struct omap_hwmod_ocp_if {
283#define SYSS_HAS_RESET_STATUS (1 << 7) 295#define SYSS_HAS_RESET_STATUS (1 << 7)
284#define SYSC_NO_CACHE (1 << 8) /* XXX SW flag, belongs elsewhere */ 296#define SYSC_NO_CACHE (1 << 8) /* XXX SW flag, belongs elsewhere */
285#define SYSC_HAS_RESET_STATUS (1 << 9) 297#define SYSC_HAS_RESET_STATUS (1 << 9)
298#define SYSC_HAS_DMADISABLE (1 << 10)
286 299
287/* omap_hwmod_sysconfig.clockact flags */ 300/* omap_hwmod_sysconfig.clockact flags */
288#define CLOCKACT_TEST_BOTH 0x0 301#define CLOCKACT_TEST_BOTH 0x0
@@ -298,6 +311,7 @@ struct omap_hwmod_ocp_if {
298 * @enwkup_shift: Offset of the enawakeup bit 311 * @enwkup_shift: Offset of the enawakeup bit
299 * @srst_shift: Offset of the softreset bit 312 * @srst_shift: Offset of the softreset bit
300 * @autoidle_shift: Offset of the autoidle bit 313 * @autoidle_shift: Offset of the autoidle bit
314 * @dmadisable_shift: Offset of the dmadisable bit
301 */ 315 */
302struct omap_hwmod_sysc_fields { 316struct omap_hwmod_sysc_fields {
303 u8 midle_shift; 317 u8 midle_shift;
@@ -306,6 +320,7 @@ struct omap_hwmod_sysc_fields {
306 u8 enwkup_shift; 320 u8 enwkup_shift;
307 u8 srst_shift; 321 u8 srst_shift;
308 u8 autoidle_shift; 322 u8 autoidle_shift;
323 u8 dmadisable_shift;
309}; 324};
310 325
311/** 326/**
@@ -374,11 +389,13 @@ struct omap_hwmod_omap2_prcm {
374 * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data 389 * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data
375 * @clkctrl_reg: PRCM address of the clock control register 390 * @clkctrl_reg: PRCM address of the clock control register
376 * @rstctrl_reg: address of the XXX_RSTCTRL register located in the PRM 391 * @rstctrl_reg: address of the XXX_RSTCTRL register located in the PRM
392 * @rstst_reg: (AM33XX only) address of the XXX_RSTST register in the PRM
377 * @submodule_wkdep_bit: bit shift of the WKDEP range 393 * @submodule_wkdep_bit: bit shift of the WKDEP range
378 */ 394 */
379struct omap_hwmod_omap4_prcm { 395struct omap_hwmod_omap4_prcm {
380 u16 clkctrl_offs; 396 u16 clkctrl_offs;
381 u16 rstctrl_offs; 397 u16 rstctrl_offs;
398 u16 rstst_offs;
382 u16 context_offs; 399 u16 context_offs;
383 u8 submodule_wkdep_bit; 400 u8 submodule_wkdep_bit;
384 u8 modulemode; 401 u8 modulemode;
@@ -629,6 +646,10 @@ int omap_hwmod_no_setup_reset(struct omap_hwmod *oh);
629 646
630int omap_hwmod_pad_route_irq(struct omap_hwmod *oh, int pad_idx, int irq_idx); 647int omap_hwmod_pad_route_irq(struct omap_hwmod *oh, int pad_idx, int irq_idx);
631 648
649extern void __init omap_hwmod_init(void);
650
651const char *omap_hwmod_get_main_clk(struct omap_hwmod *oh);
652
632/* 653/*
633 * Chip variant-specific hwmod init routines - XXX should be converted 654 * Chip variant-specific hwmod init routines - XXX should be converted
634 * to use initcalls once the initial boot ordering is straightened out 655 * to use initcalls once the initial boot ordering is straightened out
diff --git a/arch/arm/plat-omap/include/plat/sdrc.h b/arch/arm/plat-omap/include/plat/sdrc.h
index 9bb978ecd88..36d6a766621 100644
--- a/arch/arm/plat-omap/include/plat/sdrc.h
+++ b/arch/arm/plat-omap/include/plat/sdrc.h
@@ -123,7 +123,7 @@ struct omap_sdrc_params {
123 u32 mr; 123 u32 mr;
124}; 124};
125 125
126#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 126#ifdef CONFIG_SOC_HAS_OMAP2_SDRC
127void omap2_sdrc_init(struct omap_sdrc_params *sdrc_cs0, 127void omap2_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
128 struct omap_sdrc_params *sdrc_cs1); 128 struct omap_sdrc_params *sdrc_cs1);
129#else 129#else
diff --git a/arch/arm/plat-omap/include/plat/serial.h b/arch/arm/plat-omap/include/plat/serial.h
index b073e5f2b19..65fce44dce3 100644
--- a/arch/arm/plat-omap/include/plat/serial.h
+++ b/arch/arm/plat-omap/include/plat/serial.h
@@ -60,6 +60,17 @@
60/* AM3505/3517 UART4 */ 60/* AM3505/3517 UART4 */
61#define AM35XX_UART4_BASE 0x4809E000 /* Only on AM3505/3517 */ 61#define AM35XX_UART4_BASE 0x4809E000 /* Only on AM3505/3517 */
62 62
63/* AM33XX serial port */
64#define AM33XX_UART1_BASE 0x44E09000
65
66/* OMAP5 serial ports */
67#define OMAP5_UART1_BASE OMAP2_UART1_BASE
68#define OMAP5_UART2_BASE OMAP2_UART2_BASE
69#define OMAP5_UART3_BASE OMAP4_UART3_BASE
70#define OMAP5_UART4_BASE OMAP4_UART4_BASE
71#define OMAP5_UART5_BASE 0x48066000
72#define OMAP5_UART6_BASE 0x48068000
73
63/* External port on Zoom2/3 */ 74/* External port on Zoom2/3 */
64#define ZOOM_UART_BASE 0x10000000 75#define ZOOM_UART_BASE 0x10000000
65#define ZOOM_UART_VIRT 0xfa400000 76#define ZOOM_UART_VIRT 0xfa400000
@@ -93,6 +104,9 @@
93#define TI81XXUART1 81 104#define TI81XXUART1 81
94#define TI81XXUART2 82 105#define TI81XXUART2 82
95#define TI81XXUART3 83 106#define TI81XXUART3 83
107#define AM33XXUART1 84
108#define OMAP5UART3 OMAP4UART3
109#define OMAP5UART4 OMAP4UART4
96#define ZOOM_UART 95 /* Only on zoom2/3 */ 110#define ZOOM_UART 95 /* Only on zoom2/3 */
97 111
98/* This is only used by 8250.c for omap1510 */ 112/* This is only used by 8250.c for omap1510 */
diff --git a/arch/arm/plat-omap/include/plat/uncompress.h b/arch/arm/plat-omap/include/plat/uncompress.h
index cc3f11ba7a9..7f7b112accc 100644
--- a/arch/arm/plat-omap/include/plat/uncompress.h
+++ b/arch/arm/plat-omap/include/plat/uncompress.h
@@ -95,6 +95,9 @@ static inline void flush(void)
95 _DEBUG_LL_ENTRY(mach, OMAP4_UART##p##_BASE, OMAP_PORT_SHIFT, \ 95 _DEBUG_LL_ENTRY(mach, OMAP4_UART##p##_BASE, OMAP_PORT_SHIFT, \
96 OMAP4UART##p) 96 OMAP4UART##p)
97 97
98#define DEBUG_LL_OMAP5(p, mach) \
99 _DEBUG_LL_ENTRY(mach, OMAP5_UART##p##_BASE, OMAP_PORT_SHIFT, \
100 OMAP5UART##p)
98/* Zoom2/3 shift is different for UART1 and external port */ 101/* Zoom2/3 shift is different for UART1 and external port */
99#define DEBUG_LL_ZOOM(mach) \ 102#define DEBUG_LL_ZOOM(mach) \
100 _DEBUG_LL_ENTRY(mach, ZOOM_UART_BASE, ZOOM_PORT_SHIFT, ZOOM_UART) 103 _DEBUG_LL_ENTRY(mach, ZOOM_UART_BASE, ZOOM_PORT_SHIFT, ZOOM_UART)
@@ -103,7 +106,11 @@ static inline void flush(void)
103 _DEBUG_LL_ENTRY(mach, TI81XX_UART##p##_BASE, OMAP_PORT_SHIFT, \ 106 _DEBUG_LL_ENTRY(mach, TI81XX_UART##p##_BASE, OMAP_PORT_SHIFT, \
104 TI81XXUART##p) 107 TI81XXUART##p)
105 108
106static inline void __arch_decomp_setup(unsigned long arch_id) 109#define DEBUG_LL_AM33XX(p, mach) \
110 _DEBUG_LL_ENTRY(mach, AM33XX_UART##p##_BASE, OMAP_PORT_SHIFT, \
111 AM33XXUART##p)
112
113static inline void arch_decomp_setup(void)
107{ 114{
108 int port = 0; 115 int port = 0;
109 116
@@ -173,6 +180,9 @@ static inline void __arch_decomp_setup(unsigned long arch_id)
173 DEBUG_LL_OMAP4(3, omap_4430sdp); 180 DEBUG_LL_OMAP4(3, omap_4430sdp);
174 DEBUG_LL_OMAP4(3, omap4_panda); 181 DEBUG_LL_OMAP4(3, omap4_panda);
175 182
183 /* omap5 based boards using UART3 */
184 DEBUG_LL_OMAP5(3, omap5_sevm);
185
176 /* zoom2/3 external uart */ 186 /* zoom2/3 external uart */
177 DEBUG_LL_ZOOM(omap_zoom2); 187 DEBUG_LL_ZOOM(omap_zoom2);
178 DEBUG_LL_ZOOM(omap_zoom3); 188 DEBUG_LL_ZOOM(omap_zoom3);
@@ -183,11 +193,11 @@ static inline void __arch_decomp_setup(unsigned long arch_id)
183 /* TI8148 base boards using UART1 */ 193 /* TI8148 base boards using UART1 */
184 DEBUG_LL_TI81XX(1, ti8148evm); 194 DEBUG_LL_TI81XX(1, ti8148evm);
185 195
196 /* AM33XX base boards using UART1 */
197 DEBUG_LL_AM33XX(1, am335xevm);
186 } while (0); 198 } while (0);
187} 199}
188 200
189#define arch_decomp_setup() __arch_decomp_setup(arch_id)
190
191/* 201/*
192 * nothing to do 202 * nothing to do
193 */ 203 */
diff --git a/arch/arm/plat-omap/include/plat/usb.h b/arch/arm/plat-omap/include/plat/usb.h
index 762eeb0626c..548a4c8d63d 100644
--- a/arch/arm/plat-omap/include/plat/usb.h
+++ b/arch/arm/plat-omap/include/plat/usb.h
@@ -44,6 +44,8 @@ struct usbhs_omap_board_data {
44 struct regulator *regulator[OMAP3_HS_USB_PORTS]; 44 struct regulator *regulator[OMAP3_HS_USB_PORTS];
45}; 45};
46 46
47#ifdef CONFIG_ARCH_OMAP2PLUS
48
47struct ehci_hcd_omap_platform_data { 49struct ehci_hcd_omap_platform_data {
48 enum usbhs_omap_port_mode port_mode[OMAP3_HS_USB_PORTS]; 50 enum usbhs_omap_port_mode port_mode[OMAP3_HS_USB_PORTS];
49 int reset_gpio_port[OMAP3_HS_USB_PORTS]; 51 int reset_gpio_port[OMAP3_HS_USB_PORTS];
@@ -64,26 +66,6 @@ struct usbhs_omap_platform_data {
64}; 66};
65/*-------------------------------------------------------------------------*/ 67/*-------------------------------------------------------------------------*/
66 68
67#define OMAP1_OTG_BASE 0xfffb0400
68#define OMAP1_UDC_BASE 0xfffb4000
69#define OMAP1_OHCI_BASE 0xfffba000
70
71#define OMAP2_OHCI_BASE 0x4805e000
72#define OMAP2_UDC_BASE 0x4805e200
73#define OMAP2_OTG_BASE 0x4805e300
74
75#ifdef CONFIG_ARCH_OMAP1
76
77#define OTG_BASE OMAP1_OTG_BASE
78#define UDC_BASE OMAP1_UDC_BASE
79#define OMAP_OHCI_BASE OMAP1_OHCI_BASE
80
81#else
82
83#define OTG_BASE OMAP2_OTG_BASE
84#define UDC_BASE OMAP2_UDC_BASE
85#define OMAP_OHCI_BASE OMAP2_OHCI_BASE
86
87struct omap_musb_board_data { 69struct omap_musb_board_data {
88 u8 interface_type; 70 u8 interface_type;
89 u8 mode; 71 u8 mode;
@@ -107,44 +89,6 @@ extern int omap4430_phy_init(struct device *dev);
107extern int omap4430_phy_exit(struct device *dev); 89extern int omap4430_phy_exit(struct device *dev);
108extern int omap4430_phy_suspend(struct device *dev, int suspend); 90extern int omap4430_phy_suspend(struct device *dev, int suspend);
109 91
110/*
111 * NOTE: Please update omap USB drivers to use ioremap + read/write
112 */
113
114#define OMAP2_L4_IO_OFFSET 0xb2000000
115#define OMAP2_L4_IO_ADDRESS(pa) IOMEM((pa) + OMAP2_L4_IO_OFFSET)
116
117static inline u8 omap_readb(u32 pa)
118{
119 return __raw_readb(OMAP2_L4_IO_ADDRESS(pa));
120}
121
122static inline u16 omap_readw(u32 pa)
123{
124 return __raw_readw(OMAP2_L4_IO_ADDRESS(pa));
125}
126
127static inline u32 omap_readl(u32 pa)
128{
129 return __raw_readl(OMAP2_L4_IO_ADDRESS(pa));
130}
131
132static inline void omap_writeb(u8 v, u32 pa)
133{
134 __raw_writeb(v, OMAP2_L4_IO_ADDRESS(pa));
135}
136
137
138static inline void omap_writew(u16 v, u32 pa)
139{
140 __raw_writew(v, OMAP2_L4_IO_ADDRESS(pa));
141}
142
143static inline void omap_writel(u32 v, u32 pa)
144{
145 __raw_writel(v, OMAP2_L4_IO_ADDRESS(pa));
146}
147
148#endif 92#endif
149 93
150extern void am35x_musb_reset(void); 94extern void am35x_musb_reset(void);
@@ -153,142 +97,6 @@ extern void am35x_musb_clear_irq(void);
153extern void am35x_set_mode(u8 musb_mode); 97extern void am35x_set_mode(u8 musb_mode);
154extern void ti81xx_musb_phy_power(u8 on); 98extern void ti81xx_musb_phy_power(u8 on);
155 99
156/*
157 * FIXME correct answer depends on hmc_mode,
158 * as does (on omap1) any nonzero value for config->otg port number
159 */
160#ifdef CONFIG_USB_GADGET_OMAP
161#define is_usb0_device(config) 1
162#else
163#define is_usb0_device(config) 0
164#endif
165
166void omap_otg_init(struct omap_usb_config *config);
167
168#if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE)
169void omap1_usb_init(struct omap_usb_config *pdata);
170#else
171static inline void omap1_usb_init(struct omap_usb_config *pdata)
172{
173}
174#endif
175
176#if defined(CONFIG_ARCH_OMAP_OTG) || defined(CONFIG_ARCH_OMAP_OTG_MODULE)
177void omap2_usbfs_init(struct omap_usb_config *pdata);
178#else
179static inline void omap2_usbfs_init(struct omap_usb_config *pdata)
180{
181}
182#endif
183
184/*-------------------------------------------------------------------------*/
185
186/*
187 * OTG and transceiver registers, for OMAPs starting with ARM926
188 */
189#define OTG_REV (OTG_BASE + 0x00)
190#define OTG_SYSCON_1 (OTG_BASE + 0x04)
191# define USB2_TRX_MODE(w) (((w)>>24)&0x07)
192# define USB1_TRX_MODE(w) (((w)>>20)&0x07)
193# define USB0_TRX_MODE(w) (((w)>>16)&0x07)
194# define OTG_IDLE_EN (1 << 15)
195# define HST_IDLE_EN (1 << 14)
196# define DEV_IDLE_EN (1 << 13)
197# define OTG_RESET_DONE (1 << 2)
198# define OTG_SOFT_RESET (1 << 1)
199#define OTG_SYSCON_2 (OTG_BASE + 0x08)
200# define OTG_EN (1 << 31)
201# define USBX_SYNCHRO (1 << 30)
202# define OTG_MST16 (1 << 29)
203# define SRP_GPDATA (1 << 28)
204# define SRP_GPDVBUS (1 << 27)
205# define SRP_GPUVBUS(w) (((w)>>24)&0x07)
206# define A_WAIT_VRISE(w) (((w)>>20)&0x07)
207# define B_ASE_BRST(w) (((w)>>16)&0x07)
208# define SRP_DPW (1 << 14)
209# define SRP_DATA (1 << 13)
210# define SRP_VBUS (1 << 12)
211# define OTG_PADEN (1 << 10)
212# define HMC_PADEN (1 << 9)
213# define UHOST_EN (1 << 8)
214# define HMC_TLLSPEED (1 << 7)
215# define HMC_TLLATTACH (1 << 6)
216# define OTG_HMC(w) (((w)>>0)&0x3f)
217#define OTG_CTRL (OTG_BASE + 0x0c)
218# define OTG_USB2_EN (1 << 29)
219# define OTG_USB2_DP (1 << 28)
220# define OTG_USB2_DM (1 << 27)
221# define OTG_USB1_EN (1 << 26)
222# define OTG_USB1_DP (1 << 25)
223# define OTG_USB1_DM (1 << 24)
224# define OTG_USB0_EN (1 << 23)
225# define OTG_USB0_DP (1 << 22)
226# define OTG_USB0_DM (1 << 21)
227# define OTG_ASESSVLD (1 << 20)
228# define OTG_BSESSEND (1 << 19)
229# define OTG_BSESSVLD (1 << 18)
230# define OTG_VBUSVLD (1 << 17)
231# define OTG_ID (1 << 16)
232# define OTG_DRIVER_SEL (1 << 15)
233# define OTG_A_SETB_HNPEN (1 << 12)
234# define OTG_A_BUSREQ (1 << 11)
235# define OTG_B_HNPEN (1 << 9)
236# define OTG_B_BUSREQ (1 << 8)
237# define OTG_BUSDROP (1 << 7)
238# define OTG_PULLDOWN (1 << 5)
239# define OTG_PULLUP (1 << 4)
240# define OTG_DRV_VBUS (1 << 3)
241# define OTG_PD_VBUS (1 << 2)
242# define OTG_PU_VBUS (1 << 1)
243# define OTG_PU_ID (1 << 0)
244#define OTG_IRQ_EN (OTG_BASE + 0x10) /* 16-bit */
245# define DRIVER_SWITCH (1 << 15)
246# define A_VBUS_ERR (1 << 13)
247# define A_REQ_TMROUT (1 << 12)
248# define A_SRP_DETECT (1 << 11)
249# define B_HNP_FAIL (1 << 10)
250# define B_SRP_TMROUT (1 << 9)
251# define B_SRP_DONE (1 << 8)
252# define B_SRP_STARTED (1 << 7)
253# define OPRT_CHG (1 << 0)
254#define OTG_IRQ_SRC (OTG_BASE + 0x14) /* 16-bit */
255 // same bits as in IRQ_EN
256#define OTG_OUTCTRL (OTG_BASE + 0x18) /* 16-bit */
257# define OTGVPD (1 << 14)
258# define OTGVPU (1 << 13)
259# define OTGPUID (1 << 12)
260# define USB2VDR (1 << 10)
261# define USB2PDEN (1 << 9)
262# define USB2PUEN (1 << 8)
263# define USB1VDR (1 << 6)
264# define USB1PDEN (1 << 5)
265# define USB1PUEN (1 << 4)
266# define USB0VDR (1 << 2)
267# define USB0PDEN (1 << 1)
268# define USB0PUEN (1 << 0)
269#define OTG_TEST (OTG_BASE + 0x20) /* 16-bit */
270#define OTG_VENDOR_CODE (OTG_BASE + 0xfc) /* 16-bit */
271
272/*-------------------------------------------------------------------------*/
273
274/* OMAP1 */
275#define USB_TRANSCEIVER_CTRL (0xfffe1000 + 0x0064)
276# define CONF_USB2_UNI_R (1 << 8)
277# define CONF_USB1_UNI_R (1 << 7)
278# define CONF_USB_PORT0_R(x) (((x)>>4)&0x7)
279# define CONF_USB0_ISOLATE_R (1 << 3)
280# define CONF_USB_PWRDN_DM_R (1 << 2)
281# define CONF_USB_PWRDN_DP_R (1 << 1)
282
283/* OMAP2 */
284# define USB_UNIDIR 0x0
285# define USB_UNIDIR_TLL 0x1
286# define USB_BIDIR 0x2
287# define USB_BIDIR_TLL 0x3
288# define USBTXWRMODEI(port, x) ((x) << (22 - (port * 2)))
289# define USBT2TLL5PI (1 << 17)
290# define USB0PUENACTLOI (1 << 16)
291# define USBSTANDBYCTRL (1 << 15)
292/* AM35x */ 100/* AM35x */
293/* USB 2.0 PHY Control */ 101/* USB 2.0 PHY Control */
294#define CONF2_PHY_GPIOMODE (1 << 23) 102#define CONF2_PHY_GPIOMODE (1 << 23)
diff --git a/arch/arm/plat-omap/include/plat/voltage.h b/arch/arm/plat-omap/include/plat/voltage.h
index 0a6a482ec01..5be4d5def42 100644
--- a/arch/arm/plat-omap/include/plat/voltage.h
+++ b/arch/arm/plat-omap/include/plat/voltage.h
@@ -11,10 +11,29 @@
11#ifndef __ARCH_ARM_OMAP_VOLTAGE_H 11#ifndef __ARCH_ARM_OMAP_VOLTAGE_H
12#define __ARCH_ARM_OMAP_VOLTAGE_H 12#define __ARCH_ARM_OMAP_VOLTAGE_H
13 13
14/**
15 * struct omap_volt_data - Omap voltage specific data.
16 * @voltage_nominal: The possible voltage value in uV
17 * @sr_efuse_offs: The offset of the efuse register(from system
18 * control module base address) from where to read
19 * the n-target value for the smartreflex module.
20 * @sr_errminlimit: Error min limit value for smartreflex. This value
21 * differs at differnet opp and thus is linked
22 * with voltage.
23 * @vp_errorgain: Error gain value for the voltage processor. This
24 * field also differs according to the voltage/opp.
25 */
26struct omap_volt_data {
27 u32 volt_nominal;
28 u32 sr_efuse_offs;
29 u8 sr_errminlimit;
30 u8 vp_errgain;
31};
14struct voltagedomain; 32struct voltagedomain;
15 33
16struct voltagedomain *voltdm_lookup(const char *name); 34struct voltagedomain *voltdm_lookup(const char *name);
17int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt); 35int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt);
18unsigned long voltdm_get_voltage(struct voltagedomain *voltdm); 36unsigned long voltdm_get_voltage(struct voltagedomain *voltdm);
19 37struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
38 unsigned long volt);
20#endif 39#endif
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index ad32621aa52..5e13c3884aa 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -282,6 +282,8 @@ static int omap_mbox_startup(struct omap_mbox *mbox)
282 } 282 }
283 mbox->rxq = mq; 283 mbox->rxq = mq;
284 mq->mbox = mbox; 284 mq->mbox = mbox;
285
286 omap_mbox_enable_irq(mbox, IRQ_RX);
285 } 287 }
286 mutex_unlock(&mbox_configured_lock); 288 mutex_unlock(&mbox_configured_lock);
287 return 0; 289 return 0;
@@ -305,6 +307,7 @@ static void omap_mbox_fini(struct omap_mbox *mbox)
305 mutex_lock(&mbox_configured_lock); 307 mutex_lock(&mbox_configured_lock);
306 308
307 if (!--mbox->use_count) { 309 if (!--mbox->use_count) {
310 omap_mbox_disable_irq(mbox, IRQ_RX);
308 free_irq(mbox->irq, mbox); 311 free_irq(mbox->irq, mbox);
309 tasklet_kill(&mbox->txq->tasklet); 312 tasklet_kill(&mbox->txq->tasklet);
310 flush_work_sync(&mbox->rxq->work); 313 flush_work_sync(&mbox->rxq->work);
@@ -338,13 +341,15 @@ struct omap_mbox *omap_mbox_get(const char *name, struct notifier_block *nb)
338 if (!mbox) 341 if (!mbox)
339 return ERR_PTR(-ENOENT); 342 return ERR_PTR(-ENOENT);
340 343
341 ret = omap_mbox_startup(mbox);
342 if (ret)
343 return ERR_PTR(-ENODEV);
344
345 if (nb) 344 if (nb)
346 blocking_notifier_chain_register(&mbox->notifier, nb); 345 blocking_notifier_chain_register(&mbox->notifier, nb);
347 346
347 ret = omap_mbox_startup(mbox);
348 if (ret) {
349 blocking_notifier_chain_unregister(&mbox->notifier, nb);
350 return ERR_PTR(-ENODEV);
351 }
352
348 return mbox; 353 return mbox;
349} 354}
350EXPORT_SYMBOL(omap_mbox_get); 355EXPORT_SYMBOL(omap_mbox_get);
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
index 477363c163e..766181cb5c9 100644
--- a/arch/arm/plat-omap/sram.c
+++ b/arch/arm/plat-omap/sram.c
@@ -6,8 +6,8 @@
6 * Copyright (C) 2005 Nokia Corporation 6 * Copyright (C) 2005 Nokia Corporation
7 * Written by Tony Lindgren <tony@atomide.com> 7 * Written by Tony Lindgren <tony@atomide.com>
8 * 8 *
9 * Copyright (C) 2009 Texas Instruments 9 * Copyright (C) 2009-2012 Texas Instruments
10 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com> 10 * Added OMAP4/5 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify 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 13 * it under the terms of the GNU General Public License version 2 as
@@ -44,6 +44,7 @@
44#else 44#else
45#define OMAP4_SRAM_PUB_PA (OMAP4_SRAM_PA + 0x4000) 45#define OMAP4_SRAM_PUB_PA (OMAP4_SRAM_PA + 0x4000)
46#endif 46#endif
47#define OMAP5_SRAM_PA 0x40300000
47 48
48#if defined(CONFIG_ARCH_OMAP2PLUS) 49#if defined(CONFIG_ARCH_OMAP2PLUS)
49#define SRAM_BOOTLOADER_SZ 0x00 50#define SRAM_BOOTLOADER_SZ 0x00
@@ -85,7 +86,7 @@ static int is_sram_locked(void)
85 __raw_writel(0xCFDE, OMAP24XX_VA_READPERM0); /* all i-read */ 86 __raw_writel(0xCFDE, OMAP24XX_VA_READPERM0); /* all i-read */
86 __raw_writel(0xCFDE, OMAP24XX_VA_WRITEPERM0); /* all i-write */ 87 __raw_writel(0xCFDE, OMAP24XX_VA_WRITEPERM0); /* all i-write */
87 } 88 }
88 if (cpu_is_omap34xx() && !cpu_is_am33xx()) { 89 if (cpu_is_omap34xx()) {
89 __raw_writel(0xFFFF, OMAP34XX_VA_REQINFOPERM0); /* all q-vects */ 90 __raw_writel(0xFFFF, OMAP34XX_VA_REQINFOPERM0); /* all q-vects */
90 __raw_writel(0xFFFF, OMAP34XX_VA_READPERM0); /* all i-read */ 91 __raw_writel(0xFFFF, OMAP34XX_VA_READPERM0); /* all i-read */
91 __raw_writel(0xFFFF, OMAP34XX_VA_WRITEPERM0); /* all i-write */ 92 __raw_writel(0xFFFF, OMAP34XX_VA_WRITEPERM0); /* all i-write */
@@ -118,12 +119,15 @@ static void __init omap_detect_sram(void)
118 } else if (cpu_is_omap44xx()) { 119 } else if (cpu_is_omap44xx()) {
119 omap_sram_start = OMAP4_SRAM_PUB_PA; 120 omap_sram_start = OMAP4_SRAM_PUB_PA;
120 omap_sram_size = 0xa000; /* 40K */ 121 omap_sram_size = 0xa000; /* 40K */
122 } else if (soc_is_omap54xx()) {
123 omap_sram_start = OMAP5_SRAM_PA;
124 omap_sram_size = SZ_128K; /* 128KB */
121 } else { 125 } else {
122 omap_sram_start = OMAP2_SRAM_PUB_PA; 126 omap_sram_start = OMAP2_SRAM_PUB_PA;
123 omap_sram_size = 0x800; /* 2K */ 127 omap_sram_size = 0x800; /* 2K */
124 } 128 }
125 } else { 129 } else {
126 if (cpu_is_am33xx()) { 130 if (soc_is_am33xx()) {
127 omap_sram_start = AM33XX_SRAM_PA; 131 omap_sram_start = AM33XX_SRAM_PA;
128 omap_sram_size = 0x10000; /* 64K */ 132 omap_sram_size = 0x10000; /* 64K */
129 } else if (cpu_is_omap34xx()) { 133 } else if (cpu_is_omap34xx()) {
@@ -132,6 +136,9 @@ static void __init omap_detect_sram(void)
132 } else if (cpu_is_omap44xx()) { 136 } else if (cpu_is_omap44xx()) {
133 omap_sram_start = OMAP4_SRAM_PA; 137 omap_sram_start = OMAP4_SRAM_PA;
134 omap_sram_size = 0xe000; /* 56K */ 138 omap_sram_size = 0xe000; /* 56K */
139 } else if (soc_is_omap54xx()) {
140 omap_sram_start = OMAP5_SRAM_PA;
141 omap_sram_size = SZ_128K; /* 128KB */
135 } else { 142 } else {
136 omap_sram_start = OMAP2_SRAM_PA; 143 omap_sram_start = OMAP2_SRAM_PA;
137 if (cpu_is_omap242x()) 144 if (cpu_is_omap242x())
@@ -386,7 +393,7 @@ int __init omap_sram_init(void)
386 omap242x_sram_init(); 393 omap242x_sram_init();
387 else if (cpu_is_omap2430()) 394 else if (cpu_is_omap2430())
388 omap243x_sram_init(); 395 omap243x_sram_init();
389 else if (cpu_is_am33xx()) 396 else if (soc_is_am33xx())
390 am33xx_sram_init(); 397 am33xx_sram_init();
391 else if (cpu_is_omap34xx()) 398 else if (cpu_is_omap34xx())
392 omap34xx_sram_init(); 399 omap34xx_sram_init();
diff --git a/arch/arm/plat-omap/usb.c b/arch/arm/plat-omap/usb.c
deleted file mode 100644
index daa0327381b..00000000000
--- a/arch/arm/plat-omap/usb.c
+++ /dev/null
@@ -1,145 +0,0 @@
1 /*
2 * arch/arm/plat-omap/usb.c -- platform level USB initialization
3 *
4 * Copyright (C) 2004 Texas Instruments, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#undef DEBUG
22
23#include <linux/module.h>
24#include <linux/kernel.h>
25#include <linux/init.h>
26#include <linux/platform_device.h>
27#include <linux/io.h>
28
29#include <plat/usb.h>
30#include <plat/board.h>
31
32#include <mach/hardware.h>
33
34#ifdef CONFIG_ARCH_OMAP_OTG
35
36void __init
37omap_otg_init(struct omap_usb_config *config)
38{
39 u32 syscon;
40 int alt_pingroup = 0;
41
42 /* NOTE: no bus or clock setup (yet?) */
43
44 syscon = omap_readl(OTG_SYSCON_1) & 0xffff;
45 if (!(syscon & OTG_RESET_DONE))
46 pr_debug("USB resets not complete?\n");
47
48 //omap_writew(0, OTG_IRQ_EN);
49
50 /* pin muxing and transceiver pinouts */
51 if (config->pins[0] > 2) /* alt pingroup 2 */
52 alt_pingroup = 1;
53 syscon |= config->usb0_init(config->pins[0], is_usb0_device(config));
54 syscon |= config->usb1_init(config->pins[1]);
55 syscon |= config->usb2_init(config->pins[2], alt_pingroup);
56 pr_debug("OTG_SYSCON_1 = %08x\n", omap_readl(OTG_SYSCON_1));
57 omap_writel(syscon, OTG_SYSCON_1);
58
59 syscon = config->hmc_mode;
60 syscon |= USBX_SYNCHRO | (4 << 16) /* B_ASE0_BRST */;
61#ifdef CONFIG_USB_OTG
62 if (config->otg)
63 syscon |= OTG_EN;
64#endif
65 if (cpu_class_is_omap1())
66 pr_debug("USB_TRANSCEIVER_CTRL = %03x\n",
67 omap_readl(USB_TRANSCEIVER_CTRL));
68 pr_debug("OTG_SYSCON_2 = %08x\n", omap_readl(OTG_SYSCON_2));
69 omap_writel(syscon, OTG_SYSCON_2);
70
71 printk("USB: hmc %d", config->hmc_mode);
72 if (!alt_pingroup)
73 printk(", usb2 alt %d wires", config->pins[2]);
74 else if (config->pins[0])
75 printk(", usb0 %d wires%s", config->pins[0],
76 is_usb0_device(config) ? " (dev)" : "");
77 if (config->pins[1])
78 printk(", usb1 %d wires", config->pins[1]);
79 if (!alt_pingroup && config->pins[2])
80 printk(", usb2 %d wires", config->pins[2]);
81 if (config->otg)
82 printk(", Mini-AB on usb%d", config->otg - 1);
83 printk("\n");
84
85 if (cpu_class_is_omap1()) {
86 u16 w;
87
88 /* leave USB clocks/controllers off until needed */
89 w = omap_readw(ULPD_SOFT_REQ);
90 w &= ~SOFT_USB_CLK_REQ;
91 omap_writew(w, ULPD_SOFT_REQ);
92
93 w = omap_readw(ULPD_CLOCK_CTRL);
94 w &= ~USB_MCLK_EN;
95 w |= DIS_USB_PVCI_CLK;
96 omap_writew(w, ULPD_CLOCK_CTRL);
97 }
98 syscon = omap_readl(OTG_SYSCON_1);
99 syscon |= HST_IDLE_EN|DEV_IDLE_EN|OTG_IDLE_EN;
100
101#ifdef CONFIG_USB_GADGET_OMAP
102 if (config->otg || config->register_dev) {
103 struct platform_device *udc_device = config->udc_device;
104 int status;
105
106 syscon &= ~DEV_IDLE_EN;
107 udc_device->dev.platform_data = config;
108 status = platform_device_register(udc_device);
109 if (status)
110 pr_debug("can't register UDC device, %d\n", status);
111 }
112#endif
113
114#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
115 if (config->otg || config->register_host) {
116 struct platform_device *ohci_device = config->ohci_device;
117 int status;
118
119 syscon &= ~HST_IDLE_EN;
120 ohci_device->dev.platform_data = config;
121 status = platform_device_register(ohci_device);
122 if (status)
123 pr_debug("can't register OHCI device, %d\n", status);
124 }
125#endif
126
127#ifdef CONFIG_USB_OTG
128 if (config->otg) {
129 struct platform_device *otg_device = config->otg_device;
130 int status;
131
132 syscon &= ~OTG_IDLE_EN;
133 otg_device->dev.platform_data = config;
134 status = platform_device_register(otg_device);
135 if (status)
136 pr_debug("can't register OTG device, %d\n", status);
137 }
138#endif
139 pr_debug("OTG_SYSCON_1 = %08x\n", omap_readl(OTG_SYSCON_1));
140 omap_writel(syscon, OTG_SYSCON_1);
141}
142
143#else
144void omap_otg_init(struct omap_usb_config *config) {}
145#endif
diff --git a/arch/arm/plat-orion/common.c b/arch/arm/plat-orion/common.c
index c1793786aea..b8b747a9d36 100644
--- a/arch/arm/plat-orion/common.c
+++ b/arch/arm/plat-orion/common.c
@@ -47,6 +47,7 @@ void __init orion_clkdev_init(struct clk *tclk)
47 orion_clkdev_add(NULL, MV643XX_ETH_NAME ".2", tclk); 47 orion_clkdev_add(NULL, MV643XX_ETH_NAME ".2", tclk);
48 orion_clkdev_add(NULL, MV643XX_ETH_NAME ".3", tclk); 48 orion_clkdev_add(NULL, MV643XX_ETH_NAME ".3", tclk);
49 orion_clkdev_add(NULL, "orion_wdt", tclk); 49 orion_clkdev_add(NULL, "orion_wdt", tclk);
50 orion_clkdev_add(NULL, MV64XXX_I2C_CTLR_NAME ".0", tclk);
50} 51}
51 52
52/* Fill in the resources structure and link it into the platform 53/* Fill in the resources structure and link it into the platform
@@ -290,10 +291,12 @@ static struct platform_device orion_ge00 = {
290void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data, 291void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data,
291 unsigned long mapbase, 292 unsigned long mapbase,
292 unsigned long irq, 293 unsigned long irq,
293 unsigned long irq_err) 294 unsigned long irq_err,
295 unsigned int tx_csum_limit)
294{ 296{
295 fill_resources(&orion_ge00_shared, orion_ge00_shared_resources, 297 fill_resources(&orion_ge00_shared, orion_ge00_shared_resources,
296 mapbase + 0x2000, SZ_16K - 1, irq_err); 298 mapbase + 0x2000, SZ_16K - 1, irq_err);
299 orion_ge00_shared_data.tx_csum_limit = tx_csum_limit;
297 ge_complete(&orion_ge00_shared_data, 300 ge_complete(&orion_ge00_shared_data,
298 orion_ge00_resources, irq, &orion_ge00_shared, 301 orion_ge00_resources, irq, &orion_ge00_shared,
299 eth_data, &orion_ge00); 302 eth_data, &orion_ge00);
@@ -342,10 +345,12 @@ static struct platform_device orion_ge01 = {
342void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data, 345void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data,
343 unsigned long mapbase, 346 unsigned long mapbase,
344 unsigned long irq, 347 unsigned long irq,
345 unsigned long irq_err) 348 unsigned long irq_err,
349 unsigned int tx_csum_limit)
346{ 350{
347 fill_resources(&orion_ge01_shared, orion_ge01_shared_resources, 351 fill_resources(&orion_ge01_shared, orion_ge01_shared_resources,
348 mapbase + 0x2000, SZ_16K - 1, irq_err); 352 mapbase + 0x2000, SZ_16K - 1, irq_err);
353 orion_ge01_shared_data.tx_csum_limit = tx_csum_limit;
349 ge_complete(&orion_ge01_shared_data, 354 ge_complete(&orion_ge01_shared_data,
350 orion_ge01_resources, irq, &orion_ge01_shared, 355 orion_ge01_resources, irq, &orion_ge01_shared,
351 eth_data, &orion_ge01); 356 eth_data, &orion_ge01);
diff --git a/arch/arm/plat-orion/gpio.c b/arch/arm/plat-orion/gpio.c
index af95af25730..dfda74fae6f 100644
--- a/arch/arm/plat-orion/gpio.c
+++ b/arch/arm/plat-orion/gpio.c
@@ -8,15 +8,22 @@
8 * warranty of any kind, whether express or implied. 8 * warranty of any kind, whether express or implied.
9 */ 9 */
10 10
11#define DEBUG
12
11#include <linux/kernel.h> 13#include <linux/kernel.h>
12#include <linux/init.h> 14#include <linux/init.h>
13#include <linux/irq.h> 15#include <linux/irq.h>
16#include <linux/irqdomain.h>
14#include <linux/module.h> 17#include <linux/module.h>
15#include <linux/spinlock.h> 18#include <linux/spinlock.h>
16#include <linux/bitops.h> 19#include <linux/bitops.h>
17#include <linux/io.h> 20#include <linux/io.h>
18#include <linux/gpio.h> 21#include <linux/gpio.h>
19#include <linux/leds.h> 22#include <linux/leds.h>
23#include <linux/of.h>
24#include <linux/of_irq.h>
25#include <linux/of_address.h>
26#include <plat/gpio.h>
20 27
21/* 28/*
22 * GPIO unit register offsets. 29 * GPIO unit register offsets.
@@ -38,6 +45,7 @@ struct orion_gpio_chip {
38 unsigned long valid_output; 45 unsigned long valid_output;
39 int mask_offset; 46 int mask_offset;
40 int secondary_irq_base; 47 int secondary_irq_base;
48 struct irq_domain *domain;
41}; 49};
42 50
43static void __iomem *GPIO_OUT(struct orion_gpio_chip *ochip) 51static void __iomem *GPIO_OUT(struct orion_gpio_chip *ochip)
@@ -222,10 +230,10 @@ static int orion_gpio_to_irq(struct gpio_chip *chip, unsigned pin)
222 struct orion_gpio_chip *ochip = 230 struct orion_gpio_chip *ochip =
223 container_of(chip, struct orion_gpio_chip, chip); 231 container_of(chip, struct orion_gpio_chip, chip);
224 232
225 return ochip->secondary_irq_base + pin; 233 return irq_create_mapping(ochip->domain,
234 ochip->secondary_irq_base + pin);
226} 235}
227 236
228
229/* 237/*
230 * Orion-specific GPIO API extensions. 238 * Orion-specific GPIO API extensions.
231 */ 239 */
@@ -353,12 +361,10 @@ static int gpio_irq_set_type(struct irq_data *d, u32 type)
353 int pin; 361 int pin;
354 u32 u; 362 u32 u;
355 363
356 pin = d->irq - gc->irq_base; 364 pin = d->hwirq - ochip->secondary_irq_base;
357 365
358 u = readl(GPIO_IO_CONF(ochip)) & (1 << pin); 366 u = readl(GPIO_IO_CONF(ochip)) & (1 << pin);
359 if (!u) { 367 if (!u) {
360 printk(KERN_ERR "orion gpio_irq_set_type failed "
361 "(irq %d, pin %d).\n", d->irq, pin);
362 return -EINVAL; 368 return -EINVAL;
363 } 369 }
364 370
@@ -397,17 +403,53 @@ static int gpio_irq_set_type(struct irq_data *d, u32 type)
397 u &= ~(1 << pin); /* rising */ 403 u &= ~(1 << pin); /* rising */
398 writel(u, GPIO_IN_POL(ochip)); 404 writel(u, GPIO_IN_POL(ochip));
399 } 405 }
400
401 return 0; 406 return 0;
402} 407}
403 408
404void __init orion_gpio_init(int gpio_base, int ngpio, 409static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
405 u32 base, int mask_offset, int secondary_irq_base) 410{
411 struct orion_gpio_chip *ochip = irq_get_handler_data(irq);
412 u32 cause, type;
413 int i;
414
415 if (ochip == NULL)
416 return;
417
418 cause = readl(GPIO_DATA_IN(ochip)) & readl(GPIO_LEVEL_MASK(ochip));
419 cause |= readl(GPIO_EDGE_CAUSE(ochip)) & readl(GPIO_EDGE_MASK(ochip));
420
421 for (i = 0; i < ochip->chip.ngpio; i++) {
422 int irq;
423
424 irq = ochip->secondary_irq_base + i;
425
426 if (!(cause & (1 << i)))
427 continue;
428
429 type = irqd_get_trigger_type(irq_get_irq_data(irq));
430 if ((type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) {
431 /* Swap polarity (race with GPIO line) */
432 u32 polarity;
433
434 polarity = readl(GPIO_IN_POL(ochip));
435 polarity ^= 1 << i;
436 writel(polarity, GPIO_IN_POL(ochip));
437 }
438 generic_handle_irq(irq);
439 }
440}
441
442void __init orion_gpio_init(struct device_node *np,
443 int gpio_base, int ngpio,
444 void __iomem *base, int mask_offset,
445 int secondary_irq_base,
446 int irqs[4])
406{ 447{
407 struct orion_gpio_chip *ochip; 448 struct orion_gpio_chip *ochip;
408 struct irq_chip_generic *gc; 449 struct irq_chip_generic *gc;
409 struct irq_chip_type *ct; 450 struct irq_chip_type *ct;
410 char gc_label[16]; 451 char gc_label[16];
452 int i;
411 453
412 if (orion_gpio_chip_count == ARRAY_SIZE(orion_gpio_chips)) 454 if (orion_gpio_chip_count == ARRAY_SIZE(orion_gpio_chips))
413 return; 455 return;
@@ -426,6 +468,10 @@ void __init orion_gpio_init(int gpio_base, int ngpio,
426 ochip->chip.base = gpio_base; 468 ochip->chip.base = gpio_base;
427 ochip->chip.ngpio = ngpio; 469 ochip->chip.ngpio = ngpio;
428 ochip->chip.can_sleep = 0; 470 ochip->chip.can_sleep = 0;
471#ifdef CONFIG_OF
472 ochip->chip.of_node = np;
473#endif
474
429 spin_lock_init(&ochip->lock); 475 spin_lock_init(&ochip->lock);
430 ochip->base = (void __iomem *)base; 476 ochip->base = (void __iomem *)base;
431 ochip->valid_input = 0; 477 ochip->valid_input = 0;
@@ -435,8 +481,6 @@ void __init orion_gpio_init(int gpio_base, int ngpio,
435 481
436 gpiochip_add(&ochip->chip); 482 gpiochip_add(&ochip->chip);
437 483
438 orion_gpio_chip_count++;
439
440 /* 484 /*
441 * Mask and clear GPIO interrupts. 485 * Mask and clear GPIO interrupts.
442 */ 486 */
@@ -444,16 +488,28 @@ void __init orion_gpio_init(int gpio_base, int ngpio,
444 writel(0, GPIO_EDGE_MASK(ochip)); 488 writel(0, GPIO_EDGE_MASK(ochip));
445 writel(0, GPIO_LEVEL_MASK(ochip)); 489 writel(0, GPIO_LEVEL_MASK(ochip));
446 490
447 gc = irq_alloc_generic_chip("orion_gpio_irq", 2, secondary_irq_base, 491 /* Setup the interrupt handlers. Each chip can have up to 4
492 * interrupt handlers, with each handler dealing with 8 GPIO
493 * pins. */
494
495 for (i = 0; i < 4; i++) {
496 if (irqs[i]) {
497 irq_set_handler_data(irqs[i], ochip);
498 irq_set_chained_handler(irqs[i], gpio_irq_handler);
499 }
500 }
501
502 gc = irq_alloc_generic_chip("orion_gpio_irq", 2,
503 secondary_irq_base,
448 ochip->base, handle_level_irq); 504 ochip->base, handle_level_irq);
449 gc->private = ochip; 505 gc->private = ochip;
450
451 ct = gc->chip_types; 506 ct = gc->chip_types;
452 ct->regs.mask = ochip->mask_offset + GPIO_LEVEL_MASK_OFF; 507 ct->regs.mask = ochip->mask_offset + GPIO_LEVEL_MASK_OFF;
453 ct->type = IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW; 508 ct->type = IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW;
454 ct->chip.irq_mask = irq_gc_mask_clr_bit; 509 ct->chip.irq_mask = irq_gc_mask_clr_bit;
455 ct->chip.irq_unmask = irq_gc_mask_set_bit; 510 ct->chip.irq_unmask = irq_gc_mask_set_bit;
456 ct->chip.irq_set_type = gpio_irq_set_type; 511 ct->chip.irq_set_type = gpio_irq_set_type;
512 ct->chip.name = ochip->chip.label;
457 513
458 ct++; 514 ct++;
459 ct->regs.mask = ochip->mask_offset + GPIO_EDGE_MASK_OFF; 515 ct->regs.mask = ochip->mask_offset + GPIO_EDGE_MASK_OFF;
@@ -464,41 +520,69 @@ void __init orion_gpio_init(int gpio_base, int ngpio,
464 ct->chip.irq_unmask = irq_gc_mask_set_bit; 520 ct->chip.irq_unmask = irq_gc_mask_set_bit;
465 ct->chip.irq_set_type = gpio_irq_set_type; 521 ct->chip.irq_set_type = gpio_irq_set_type;
466 ct->handler = handle_edge_irq; 522 ct->handler = handle_edge_irq;
523 ct->chip.name = ochip->chip.label;
467 524
468 irq_setup_generic_chip(gc, IRQ_MSK(ngpio), IRQ_GC_INIT_MASK_CACHE, 525 irq_setup_generic_chip(gc, IRQ_MSK(ngpio), IRQ_GC_INIT_MASK_CACHE,
469 IRQ_NOREQUEST, IRQ_LEVEL | IRQ_NOPROBE); 526 IRQ_NOREQUEST, IRQ_LEVEL | IRQ_NOPROBE);
470}
471 527
472void orion_gpio_irq_handler(int pinoff) 528 /* Setup irq domain on top of the generic chip. */
473{ 529 ochip->domain = irq_domain_add_legacy(np,
474 struct orion_gpio_chip *ochip; 530 ochip->chip.ngpio,
475 u32 cause, type; 531 ochip->secondary_irq_base,
476 int i; 532 ochip->secondary_irq_base,
477 533 &irq_domain_simple_ops,
478 ochip = orion_gpio_chip_find(pinoff); 534 ochip);
479 if (ochip == NULL) 535 if (!ochip->domain)
480 return; 536 panic("%s: couldn't allocate irq domain (DT).\n",
481 537 ochip->chip.label);
482 cause = readl(GPIO_DATA_IN(ochip)) & readl(GPIO_LEVEL_MASK(ochip));
483 cause |= readl(GPIO_EDGE_CAUSE(ochip)) & readl(GPIO_EDGE_MASK(ochip));
484
485 for (i = 0; i < ochip->chip.ngpio; i++) {
486 int irq;
487 538
488 irq = ochip->secondary_irq_base + i; 539 orion_gpio_chip_count++;
540}
489 541
490 if (!(cause & (1 << i))) 542#ifdef CONFIG_OF
491 continue; 543static void __init orion_gpio_of_init_one(struct device_node *np,
544 int irq_gpio_base)
545{
546 int ngpio, gpio_base, mask_offset;
547 void __iomem *base;
548 int ret, i;
549 int irqs[4];
550 int secondary_irq_base;
551
552 ret = of_property_read_u32(np, "ngpio", &ngpio);
553 if (ret)
554 goto out;
555 ret = of_property_read_u32(np, "mask-offset", &mask_offset);
556 if (ret == -EINVAL)
557 mask_offset = 0;
558 else
559 goto out;
560 base = of_iomap(np, 0);
561 if (!base)
562 goto out;
563
564 secondary_irq_base = irq_gpio_base + (32 * orion_gpio_chip_count);
565 gpio_base = 32 * orion_gpio_chip_count;
566
567 /* Get the interrupt numbers. Each chip can have up to 4
568 * interrupt handlers, with each handler dealing with 8 GPIO
569 * pins. */
570
571 for (i = 0; i < 4; i++)
572 irqs[i] = irq_of_parse_and_map(np, i);
573
574 orion_gpio_init(np, gpio_base, ngpio, base, mask_offset,
575 secondary_irq_base, irqs);
576 return;
577out:
578 pr_err("%s: %s: missing mandatory property\n", __func__, np->name);
579}
492 580
493 type = irqd_get_trigger_type(irq_get_irq_data(irq)); 581void __init orion_gpio_of_init(int irq_gpio_base)
494 if ((type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) { 582{
495 /* Swap polarity (race with GPIO line) */ 583 struct device_node *np;
496 u32 polarity;
497 584
498 polarity = readl(GPIO_IN_POL(ochip)); 585 for_each_compatible_node(np, NULL, "marvell,orion-gpio")
499 polarity ^= 1 << i; 586 orion_gpio_of_init_one(np, irq_gpio_base);
500 writel(polarity, GPIO_IN_POL(ochip));
501 }
502 generic_handle_irq(irq);
503 }
504} 587}
588#endif
diff --git a/arch/arm/plat-orion/include/plat/common.h b/arch/arm/plat-orion/include/plat/common.h
index e00fdb21360..ae2377ef63e 100644
--- a/arch/arm/plat-orion/include/plat/common.h
+++ b/arch/arm/plat-orion/include/plat/common.h
@@ -39,12 +39,14 @@ void __init orion_rtc_init(unsigned long mapbase,
39void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data, 39void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data,
40 unsigned long mapbase, 40 unsigned long mapbase,
41 unsigned long irq, 41 unsigned long irq,
42 unsigned long irq_err); 42 unsigned long irq_err,
43 unsigned int tx_csum_limit);
43 44
44void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data, 45void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data,
45 unsigned long mapbase, 46 unsigned long mapbase,
46 unsigned long irq, 47 unsigned long irq,
47 unsigned long irq_err); 48 unsigned long irq_err,
49 unsigned int tx_csum_limit);
48 50
49void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data, 51void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data,
50 unsigned long mapbase, 52 unsigned long mapbase,
diff --git a/arch/arm/plat-orion/include/plat/gpio.h b/arch/arm/plat-orion/include/plat/gpio.h
index bec0c98ce41..81c6fc8a7b2 100644
--- a/arch/arm/plat-orion/include/plat/gpio.h
+++ b/arch/arm/plat-orion/include/plat/gpio.h
@@ -13,7 +13,7 @@
13 13
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/types.h> 15#include <linux/types.h>
16 16#include <linux/irqdomain.h>
17/* 17/*
18 * Orion-specific GPIO API extensions. 18 * Orion-specific GPIO API extensions.
19 */ 19 */
@@ -27,13 +27,11 @@ int orion_gpio_led_blink_set(unsigned gpio, int state,
27void orion_gpio_set_valid(unsigned pin, int mode); 27void orion_gpio_set_valid(unsigned pin, int mode);
28 28
29/* Initialize gpiolib. */ 29/* Initialize gpiolib. */
30void __init orion_gpio_init(int gpio_base, int ngpio, 30void __init orion_gpio_init(struct device_node *np,
31 u32 base, int mask_offset, int secondary_irq_base); 31 int gpio_base, int ngpio,
32 32 void __iomem *base, int mask_offset,
33/* 33 int secondary_irq_base,
34 * GPIO interrupt handling. 34 int irq[4]);
35 */
36void orion_gpio_irq_handler(int irqoff);
37
38 35
36void __init orion_gpio_of_init(int irq_gpio_base);
39#endif 37#endif
diff --git a/arch/arm/plat-orion/include/plat/irq.h b/arch/arm/plat-orion/include/plat/irq.h
index f05eeab9496..50547e41793 100644
--- a/arch/arm/plat-orion/include/plat/irq.h
+++ b/arch/arm/plat-orion/include/plat/irq.h
@@ -12,6 +12,5 @@
12#define __PLAT_IRQ_H 12#define __PLAT_IRQ_H
13 13
14void orion_irq_init(unsigned int irq_start, void __iomem *maskaddr); 14void orion_irq_init(unsigned int irq_start, void __iomem *maskaddr);
15 15void __init orion_dt_init_irq(void);
16
17#endif 16#endif
diff --git a/arch/arm/plat-orion/irq.c b/arch/arm/plat-orion/irq.c
index 2d5b9c1ef38..d751964def4 100644
--- a/arch/arm/plat-orion/irq.c
+++ b/arch/arm/plat-orion/irq.c
@@ -11,8 +11,12 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/irq.h> 13#include <linux/irq.h>
14#include <linux/irqdomain.h>
14#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/of_address.h>
17#include <linux/of_irq.h>
15#include <plat/irq.h> 18#include <plat/irq.h>
19#include <plat/gpio.h>
16 20
17void __init orion_irq_init(unsigned int irq_start, void __iomem *maskaddr) 21void __init orion_irq_init(unsigned int irq_start, void __iomem *maskaddr)
18{ 22{
@@ -32,3 +36,39 @@ void __init orion_irq_init(unsigned int irq_start, void __iomem *maskaddr)
32 irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_MASK_CACHE, 36 irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_MASK_CACHE,
33 IRQ_NOREQUEST, IRQ_LEVEL | IRQ_NOPROBE); 37 IRQ_NOREQUEST, IRQ_LEVEL | IRQ_NOPROBE);
34} 38}
39
40#ifdef CONFIG_OF
41static int __init orion_add_irq_domain(struct device_node *np,
42 struct device_node *interrupt_parent)
43{
44 int i = 0, irq_gpio;
45 void __iomem *base;
46
47 do {
48 base = of_iomap(np, i);
49 if (base) {
50 orion_irq_init(i * 32, base);
51 i++;
52 }
53 } while (base);
54
55 irq_domain_add_legacy(np, i * 32, 0, 0,
56 &irq_domain_simple_ops, NULL);
57
58 irq_gpio = i * 32;
59 orion_gpio_of_init(irq_gpio);
60
61 return 0;
62}
63
64static const struct of_device_id orion_irq_match[] = {
65 { .compatible = "marvell,orion-intc",
66 .data = orion_add_irq_domain, },
67 {},
68};
69
70void __init orion_dt_init_irq(void)
71{
72 of_irq_init(orion_irq_match);
73}
74#endif
diff --git a/arch/arm/plat-pxa/Makefile b/arch/arm/plat-pxa/Makefile
index f302d048392..af8e484001e 100644
--- a/arch/arm/plat-pxa/Makefile
+++ b/arch/arm/plat-pxa/Makefile
@@ -8,5 +8,4 @@ obj-$(CONFIG_PXA3xx) += mfp.o
8obj-$(CONFIG_PXA95x) += mfp.o 8obj-$(CONFIG_PXA95x) += mfp.o
9obj-$(CONFIG_ARCH_MMP) += mfp.o 9obj-$(CONFIG_ARCH_MMP) += mfp.o
10 10
11obj-$(CONFIG_HAVE_PWM) += pwm.o
12obj-$(CONFIG_PXA_SSP) += ssp.o 11obj-$(CONFIG_PXA_SSP) += ssp.o
diff --git a/arch/arm/plat-pxa/pwm.c b/arch/arm/plat-pxa/pwm.c
deleted file mode 100644
index ef32686feef..00000000000
--- a/arch/arm/plat-pxa/pwm.c
+++ /dev/null
@@ -1,304 +0,0 @@
1/*
2 * linux/arch/arm/mach-pxa/pwm.c
3 *
4 * simple driver for PWM (Pulse Width Modulator) controller
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 * 2008-02-13 initial version
11 * eric miao <eric.miao@marvell.com>
12 */
13
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/platform_device.h>
17#include <linux/slab.h>
18#include <linux/err.h>
19#include <linux/clk.h>
20#include <linux/io.h>
21#include <linux/pwm.h>
22
23#include <asm/div64.h>
24
25#define HAS_SECONDARY_PWM 0x10
26#define PWM_ID_BASE(d) ((d) & 0xf)
27
28static const struct platform_device_id pwm_id_table[] = {
29 /* PWM has_secondary_pwm? */
30 { "pxa25x-pwm", 0 },
31 { "pxa27x-pwm", 0 | HAS_SECONDARY_PWM },
32 { "pxa168-pwm", 1 },
33 { "pxa910-pwm", 1 },
34 { },
35};
36MODULE_DEVICE_TABLE(platform, pwm_id_table);
37
38/* PWM registers and bits definitions */
39#define PWMCR (0x00)
40#define PWMDCR (0x04)
41#define PWMPCR (0x08)
42
43#define PWMCR_SD (1 << 6)
44#define PWMDCR_FD (1 << 10)
45
46struct pwm_device {
47 struct list_head node;
48 struct pwm_device *secondary;
49 struct platform_device *pdev;
50
51 const char *label;
52 struct clk *clk;
53 int clk_enabled;
54 void __iomem *mmio_base;
55
56 unsigned int use_count;
57 unsigned int pwm_id;
58};
59
60/*
61 * period_ns = 10^9 * (PRESCALE + 1) * (PV + 1) / PWM_CLK_RATE
62 * duty_ns = 10^9 * (PRESCALE + 1) * DC / PWM_CLK_RATE
63 */
64int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
65{
66 unsigned long long c;
67 unsigned long period_cycles, prescale, pv, dc;
68
69 if (pwm == NULL || period_ns == 0 || duty_ns > period_ns)
70 return -EINVAL;
71
72 c = clk_get_rate(pwm->clk);
73 c = c * period_ns;
74 do_div(c, 1000000000);
75 period_cycles = c;
76
77 if (period_cycles < 1)
78 period_cycles = 1;
79 prescale = (period_cycles - 1) / 1024;
80 pv = period_cycles / (prescale + 1) - 1;
81
82 if (prescale > 63)
83 return -EINVAL;
84
85 if (duty_ns == period_ns)
86 dc = PWMDCR_FD;
87 else
88 dc = (pv + 1) * duty_ns / period_ns;
89
90 /* NOTE: the clock to PWM has to be enabled first
91 * before writing to the registers
92 */
93 clk_enable(pwm->clk);
94 __raw_writel(prescale, pwm->mmio_base + PWMCR);
95 __raw_writel(dc, pwm->mmio_base + PWMDCR);
96 __raw_writel(pv, pwm->mmio_base + PWMPCR);
97 clk_disable(pwm->clk);
98
99 return 0;
100}
101EXPORT_SYMBOL(pwm_config);
102
103int pwm_enable(struct pwm_device *pwm)
104{
105 int rc = 0;
106
107 if (!pwm->clk_enabled) {
108 rc = clk_enable(pwm->clk);
109 if (!rc)
110 pwm->clk_enabled = 1;
111 }
112 return rc;
113}
114EXPORT_SYMBOL(pwm_enable);
115
116void pwm_disable(struct pwm_device *pwm)
117{
118 if (pwm->clk_enabled) {
119 clk_disable(pwm->clk);
120 pwm->clk_enabled = 0;
121 }
122}
123EXPORT_SYMBOL(pwm_disable);
124
125static DEFINE_MUTEX(pwm_lock);
126static LIST_HEAD(pwm_list);
127
128struct pwm_device *pwm_request(int pwm_id, const char *label)
129{
130 struct pwm_device *pwm;
131 int found = 0;
132
133 mutex_lock(&pwm_lock);
134
135 list_for_each_entry(pwm, &pwm_list, node) {
136 if (pwm->pwm_id == pwm_id) {
137 found = 1;
138 break;
139 }
140 }
141
142 if (found) {
143 if (pwm->use_count == 0) {
144 pwm->use_count++;
145 pwm->label = label;
146 } else
147 pwm = ERR_PTR(-EBUSY);
148 } else
149 pwm = ERR_PTR(-ENOENT);
150
151 mutex_unlock(&pwm_lock);
152 return pwm;
153}
154EXPORT_SYMBOL(pwm_request);
155
156void pwm_free(struct pwm_device *pwm)
157{
158 mutex_lock(&pwm_lock);
159
160 if (pwm->use_count) {
161 pwm->use_count--;
162 pwm->label = NULL;
163 } else
164 pr_warning("PWM device already freed\n");
165
166 mutex_unlock(&pwm_lock);
167}
168EXPORT_SYMBOL(pwm_free);
169
170static inline void __add_pwm(struct pwm_device *pwm)
171{
172 mutex_lock(&pwm_lock);
173 list_add_tail(&pwm->node, &pwm_list);
174 mutex_unlock(&pwm_lock);
175}
176
177static int __devinit pwm_probe(struct platform_device *pdev)
178{
179 const struct platform_device_id *id = platform_get_device_id(pdev);
180 struct pwm_device *pwm, *secondary = NULL;
181 struct resource *r;
182 int ret = 0;
183
184 pwm = kzalloc(sizeof(struct pwm_device), GFP_KERNEL);
185 if (pwm == NULL) {
186 dev_err(&pdev->dev, "failed to allocate memory\n");
187 return -ENOMEM;
188 }
189
190 pwm->clk = clk_get(&pdev->dev, NULL);
191 if (IS_ERR(pwm->clk)) {
192 ret = PTR_ERR(pwm->clk);
193 goto err_free;
194 }
195 pwm->clk_enabled = 0;
196
197 pwm->use_count = 0;
198 pwm->pwm_id = PWM_ID_BASE(id->driver_data) + pdev->id;
199 pwm->pdev = pdev;
200
201 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
202 if (r == NULL) {
203 dev_err(&pdev->dev, "no memory resource defined\n");
204 ret = -ENODEV;
205 goto err_free_clk;
206 }
207
208 r = request_mem_region(r->start, resource_size(r), pdev->name);
209 if (r == NULL) {
210 dev_err(&pdev->dev, "failed to request memory resource\n");
211 ret = -EBUSY;
212 goto err_free_clk;
213 }
214
215 pwm->mmio_base = ioremap(r->start, resource_size(r));
216 if (pwm->mmio_base == NULL) {
217 dev_err(&pdev->dev, "failed to ioremap() registers\n");
218 ret = -ENODEV;
219 goto err_free_mem;
220 }
221
222 if (id->driver_data & HAS_SECONDARY_PWM) {
223 secondary = kzalloc(sizeof(struct pwm_device), GFP_KERNEL);
224 if (secondary == NULL) {
225 ret = -ENOMEM;
226 goto err_free_mem;
227 }
228
229 *secondary = *pwm;
230 pwm->secondary = secondary;
231
232 /* registers for the second PWM has offset of 0x10 */
233 secondary->mmio_base = pwm->mmio_base + 0x10;
234 secondary->pwm_id = pdev->id + 2;
235 }
236
237 __add_pwm(pwm);
238 if (secondary)
239 __add_pwm(secondary);
240
241 platform_set_drvdata(pdev, pwm);
242 return 0;
243
244err_free_mem:
245 release_mem_region(r->start, resource_size(r));
246err_free_clk:
247 clk_put(pwm->clk);
248err_free:
249 kfree(pwm);
250 return ret;
251}
252
253static int __devexit pwm_remove(struct platform_device *pdev)
254{
255 struct pwm_device *pwm;
256 struct resource *r;
257
258 pwm = platform_get_drvdata(pdev);
259 if (pwm == NULL)
260 return -ENODEV;
261
262 mutex_lock(&pwm_lock);
263
264 if (pwm->secondary) {
265 list_del(&pwm->secondary->node);
266 kfree(pwm->secondary);
267 }
268
269 list_del(&pwm->node);
270 mutex_unlock(&pwm_lock);
271
272 iounmap(pwm->mmio_base);
273
274 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
275 release_mem_region(r->start, resource_size(r));
276
277 clk_put(pwm->clk);
278 kfree(pwm);
279 return 0;
280}
281
282static struct platform_driver pwm_driver = {
283 .driver = {
284 .name = "pxa25x-pwm",
285 .owner = THIS_MODULE,
286 },
287 .probe = pwm_probe,
288 .remove = __devexit_p(pwm_remove),
289 .id_table = pwm_id_table,
290};
291
292static int __init pwm_init(void)
293{
294 return platform_driver_register(&pwm_driver);
295}
296arch_initcall(pwm_init);
297
298static void __exit pwm_exit(void)
299{
300 platform_driver_unregister(&pwm_driver);
301}
302module_exit(pwm_exit);
303
304MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/plat-s3c24xx/dma.c b/arch/arm/plat-s3c24xx/dma.c
index 28f898f7538..db98e7021f0 100644
--- a/arch/arm/plat-s3c24xx/dma.c
+++ b/arch/arm/plat-s3c24xx/dma.c
@@ -430,7 +430,7 @@ s3c2410_dma_canload(struct s3c2410_dma_chan *chan)
430 * when necessary. 430 * when necessary.
431*/ 431*/
432 432
433int s3c2410_dma_enqueue(unsigned int channel, void *id, 433int s3c2410_dma_enqueue(enum dma_ch channel, void *id,
434 dma_addr_t data, int size) 434 dma_addr_t data, int size)
435{ 435{
436 struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel); 436 struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
diff --git a/arch/arm/plat-s3c24xx/irq.c b/arch/arm/plat-s3c24xx/irq.c
index bc42c04091f..fe57bbbf166 100644
--- a/arch/arm/plat-s3c24xx/irq.c
+++ b/arch/arm/plat-s3c24xx/irq.c
@@ -533,7 +533,7 @@ void __init s3c24xx_init_irq(void)
533 int i; 533 int i;
534 534
535#ifdef CONFIG_FIQ 535#ifdef CONFIG_FIQ
536 init_FIQ(); 536 init_FIQ(FIQ_START);
537#endif 537#endif
538 538
539 irqdbf("s3c2410_init_irq: clearing interrupt status flags\n"); 539 irqdbf("s3c2410_init_irq: clearing interrupt status flags\n");
diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig
index a2fae4ea093..9c3b90c3538 100644
--- a/arch/arm/plat-samsung/Kconfig
+++ b/arch/arm/plat-samsung/Kconfig
@@ -78,6 +78,10 @@ config S5P_HRT
78 78
79# clock options 79# clock options
80 80
81config SAMSUNG_CLOCK
82 bool
83 default y if !COMMON_CLK
84
81config SAMSUNG_CLKSRC 85config SAMSUNG_CLKSRC
82 bool 86 bool
83 help 87 help
@@ -399,7 +403,8 @@ config S5P_DEV_USB_EHCI
399 403
400config S3C24XX_PWM 404config S3C24XX_PWM
401 bool "PWM device support" 405 bool "PWM device support"
402 select HAVE_PWM 406 select PWM
407 select PWM_SAMSUNG
403 help 408 help
404 Support for exporting the PWM timer blocks via the pwm device 409 Support for exporting the PWM timer blocks via the pwm device
405 system 410 system
@@ -491,14 +496,6 @@ config S5P_SLEEP
491 Internal config node to apply common S5P sleep management code. 496 Internal config node to apply common S5P sleep management code.
492 Can be selected by S5P and newer SoCs with similar sleep procedure. 497 Can be selected by S5P and newer SoCs with similar sleep procedure.
493 498
494comment "Power Domain"
495
496config SAMSUNG_PD
497 bool "Samsung Power Domain"
498 depends on PM_RUNTIME
499 help
500 Say Y here if you want to control Power Domain by Runtime PM.
501
502config DEBUG_S3C_UART 499config DEBUG_S3C_UART
503 depends on PLAT_SAMSUNG 500 depends on PLAT_SAMSUNG
504 int 501 int
diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-samsung/Makefile
index 860b2db4db1..9e40e8d0074 100644
--- a/arch/arm/plat-samsung/Makefile
+++ b/arch/arm/plat-samsung/Makefile
@@ -15,8 +15,8 @@ obj-y += init.o cpu.o
15obj-$(CONFIG_ARCH_USES_GETTIMEOFFSET) += time.o 15obj-$(CONFIG_ARCH_USES_GETTIMEOFFSET) += time.o
16obj-$(CONFIG_S5P_HRT) += s5p-time.o 16obj-$(CONFIG_S5P_HRT) += s5p-time.o
17 17
18obj-y += clock.o 18obj-$(CONFIG_SAMSUNG_CLOCK) += clock.o
19obj-y += pwm-clock.o 19obj-$(CONFIG_SAMSUNG_CLOCK) += pwm-clock.o
20 20
21obj-$(CONFIG_SAMSUNG_CLKSRC) += clock-clksrc.o 21obj-$(CONFIG_SAMSUNG_CLKSRC) += clock-clksrc.o
22obj-$(CONFIG_S5P_CLOCK) += s5p-clock.o 22obj-$(CONFIG_S5P_CLOCK) += s5p-clock.o
@@ -59,11 +59,3 @@ obj-$(CONFIG_SAMSUNG_WAKEMASK) += wakeup-mask.o
59 59
60obj-$(CONFIG_S5P_PM) += s5p-pm.o s5p-irq-pm.o 60obj-$(CONFIG_S5P_PM) += s5p-pm.o s5p-irq-pm.o
61obj-$(CONFIG_S5P_SLEEP) += s5p-sleep.o 61obj-$(CONFIG_S5P_SLEEP) += s5p-sleep.o
62
63# PD support
64
65obj-$(CONFIG_SAMSUNG_PD) += pd.o
66
67# PWM support
68
69obj-$(CONFIG_HAVE_PWM) += pwm.o
diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c
index 6303974c2ee..fc49f3dabd7 100644
--- a/arch/arm/plat-samsung/devs.c
+++ b/arch/arm/plat-samsung/devs.c
@@ -32,6 +32,8 @@
32#include <linux/platform_data/s3c-hsudc.h> 32#include <linux/platform_data/s3c-hsudc.h>
33#include <linux/platform_data/s3c-hsotg.h> 33#include <linux/platform_data/s3c-hsotg.h>
34 34
35#include <media/s5p_hdmi.h>
36
35#include <asm/irq.h> 37#include <asm/irq.h>
36#include <asm/pmu.h> 38#include <asm/pmu.h>
37#include <asm/mach/arch.h> 39#include <asm/mach/arch.h>
@@ -748,7 +750,8 @@ void __init s5p_i2c_hdmiphy_set_platdata(struct s3c2410_platform_i2c *pd)
748 if (!pd) { 750 if (!pd) {
749 pd = &default_i2c_data; 751 pd = &default_i2c_data;
750 752
751 if (soc_is_exynos4210()) 753 if (soc_is_exynos4210() ||
754 soc_is_exynos4212() || soc_is_exynos4412())
752 pd->bus_num = 8; 755 pd->bus_num = 8;
753 else if (soc_is_s5pv210()) 756 else if (soc_is_s5pv210())
754 pd->bus_num = 3; 757 pd->bus_num = 3;
@@ -759,6 +762,30 @@ void __init s5p_i2c_hdmiphy_set_platdata(struct s3c2410_platform_i2c *pd)
759 npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c), 762 npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
760 &s5p_device_i2c_hdmiphy); 763 &s5p_device_i2c_hdmiphy);
761} 764}
765
766struct s5p_hdmi_platform_data s5p_hdmi_def_platdata;
767
768void __init s5p_hdmi_set_platdata(struct i2c_board_info *hdmiphy_info,
769 struct i2c_board_info *mhl_info, int mhl_bus)
770{
771 struct s5p_hdmi_platform_data *pd = &s5p_hdmi_def_platdata;
772
773 if (soc_is_exynos4210() ||
774 soc_is_exynos4212() || soc_is_exynos4412())
775 pd->hdmiphy_bus = 8;
776 else if (soc_is_s5pv210())
777 pd->hdmiphy_bus = 3;
778 else
779 pd->hdmiphy_bus = 0;
780
781 pd->hdmiphy_info = hdmiphy_info;
782 pd->mhl_info = mhl_info;
783 pd->mhl_bus = mhl_bus;
784
785 s3c_set_platdata(pd, sizeof(struct s5p_hdmi_platform_data),
786 &s5p_device_hdmi);
787}
788
762#endif /* CONFIG_S5P_DEV_I2C_HDMIPHY */ 789#endif /* CONFIG_S5P_DEV_I2C_HDMIPHY */
763 790
764/* I2S */ 791/* I2S */
@@ -1513,7 +1540,7 @@ static struct resource s3c64xx_spi0_resource[] = {
1513}; 1540};
1514 1541
1515struct platform_device s3c64xx_device_spi0 = { 1542struct platform_device s3c64xx_device_spi0 = {
1516 .name = "s3c64xx-spi", 1543 .name = "s3c6410-spi",
1517 .id = 0, 1544 .id = 0,
1518 .num_resources = ARRAY_SIZE(s3c64xx_spi0_resource), 1545 .num_resources = ARRAY_SIZE(s3c64xx_spi0_resource),
1519 .resource = s3c64xx_spi0_resource, 1546 .resource = s3c64xx_spi0_resource,
@@ -1523,13 +1550,10 @@ struct platform_device s3c64xx_device_spi0 = {
1523 }, 1550 },
1524}; 1551};
1525 1552
1526void __init s3c64xx_spi0_set_platdata(struct s3c64xx_spi_info *pd, 1553void __init s3c64xx_spi0_set_platdata(int (*cfg_gpio)(void), int src_clk_nr,
1527 int src_clk_nr, int num_cs) 1554 int num_cs)
1528{ 1555{
1529 if (!pd) { 1556 struct s3c64xx_spi_info pd;
1530 pr_err("%s:Need to pass platform data\n", __func__);
1531 return;
1532 }
1533 1557
1534 /* Reject invalid configuration */ 1558 /* Reject invalid configuration */
1535 if (!num_cs || src_clk_nr < 0) { 1559 if (!num_cs || src_clk_nr < 0) {
@@ -1537,12 +1561,11 @@ void __init s3c64xx_spi0_set_platdata(struct s3c64xx_spi_info *pd,
1537 return; 1561 return;
1538 } 1562 }
1539 1563
1540 pd->num_cs = num_cs; 1564 pd.num_cs = num_cs;
1541 pd->src_clk_nr = src_clk_nr; 1565 pd.src_clk_nr = src_clk_nr;
1542 if (!pd->cfg_gpio) 1566 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi0_cfg_gpio;
1543 pd->cfg_gpio = s3c64xx_spi0_cfg_gpio;
1544 1567
1545 s3c_set_platdata(pd, sizeof(*pd), &s3c64xx_device_spi0); 1568 s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi0);
1546} 1569}
1547#endif /* CONFIG_S3C64XX_DEV_SPI0 */ 1570#endif /* CONFIG_S3C64XX_DEV_SPI0 */
1548 1571
@@ -1555,7 +1578,7 @@ static struct resource s3c64xx_spi1_resource[] = {
1555}; 1578};
1556 1579
1557struct platform_device s3c64xx_device_spi1 = { 1580struct platform_device s3c64xx_device_spi1 = {
1558 .name = "s3c64xx-spi", 1581 .name = "s3c6410-spi",
1559 .id = 1, 1582 .id = 1,
1560 .num_resources = ARRAY_SIZE(s3c64xx_spi1_resource), 1583 .num_resources = ARRAY_SIZE(s3c64xx_spi1_resource),
1561 .resource = s3c64xx_spi1_resource, 1584 .resource = s3c64xx_spi1_resource,
@@ -1565,26 +1588,20 @@ struct platform_device s3c64xx_device_spi1 = {
1565 }, 1588 },
1566}; 1589};
1567 1590
1568void __init s3c64xx_spi1_set_platdata(struct s3c64xx_spi_info *pd, 1591void __init s3c64xx_spi1_set_platdata(int (*cfg_gpio)(void), int src_clk_nr,
1569 int src_clk_nr, int num_cs) 1592 int num_cs)
1570{ 1593{
1571 if (!pd) {
1572 pr_err("%s:Need to pass platform data\n", __func__);
1573 return;
1574 }
1575
1576 /* Reject invalid configuration */ 1594 /* Reject invalid configuration */
1577 if (!num_cs || src_clk_nr < 0) { 1595 if (!num_cs || src_clk_nr < 0) {
1578 pr_err("%s: Invalid SPI configuration\n", __func__); 1596 pr_err("%s: Invalid SPI configuration\n", __func__);
1579 return; 1597 return;
1580 } 1598 }
1581 1599
1582 pd->num_cs = num_cs; 1600 pd.num_cs = num_cs;
1583 pd->src_clk_nr = src_clk_nr; 1601 pd.src_clk_nr = src_clk_nr;
1584 if (!pd->cfg_gpio) 1602 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi1_cfg_gpio;
1585 pd->cfg_gpio = s3c64xx_spi1_cfg_gpio;
1586 1603
1587 s3c_set_platdata(pd, sizeof(*pd), &s3c64xx_device_spi1); 1604 s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi1);
1588} 1605}
1589#endif /* CONFIG_S3C64XX_DEV_SPI1 */ 1606#endif /* CONFIG_S3C64XX_DEV_SPI1 */
1590 1607
@@ -1597,7 +1614,7 @@ static struct resource s3c64xx_spi2_resource[] = {
1597}; 1614};
1598 1615
1599struct platform_device s3c64xx_device_spi2 = { 1616struct platform_device s3c64xx_device_spi2 = {
1600 .name = "s3c64xx-spi", 1617 .name = "s3c6410-spi",
1601 .id = 2, 1618 .id = 2,
1602 .num_resources = ARRAY_SIZE(s3c64xx_spi2_resource), 1619 .num_resources = ARRAY_SIZE(s3c64xx_spi2_resource),
1603 .resource = s3c64xx_spi2_resource, 1620 .resource = s3c64xx_spi2_resource,
@@ -1607,13 +1624,10 @@ struct platform_device s3c64xx_device_spi2 = {
1607 }, 1624 },
1608}; 1625};
1609 1626
1610void __init s3c64xx_spi2_set_platdata(struct s3c64xx_spi_info *pd, 1627void __init s3c64xx_spi2_set_platdata(int (*cfg_gpio)(void), int src_clk_nr,
1611 int src_clk_nr, int num_cs) 1628 int num_cs)
1612{ 1629{
1613 if (!pd) { 1630 struct s3c64xx_spi_info pd;
1614 pr_err("%s:Need to pass platform data\n", __func__);
1615 return;
1616 }
1617 1631
1618 /* Reject invalid configuration */ 1632 /* Reject invalid configuration */
1619 if (!num_cs || src_clk_nr < 0) { 1633 if (!num_cs || src_clk_nr < 0) {
@@ -1621,11 +1635,10 @@ void __init s3c64xx_spi2_set_platdata(struct s3c64xx_spi_info *pd,
1621 return; 1635 return;
1622 } 1636 }
1623 1637
1624 pd->num_cs = num_cs; 1638 pd.num_cs = num_cs;
1625 pd->src_clk_nr = src_clk_nr; 1639 pd.src_clk_nr = src_clk_nr;
1626 if (!pd->cfg_gpio) 1640 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi2_cfg_gpio;
1627 pd->cfg_gpio = s3c64xx_spi2_cfg_gpio;
1628 1641
1629 s3c_set_platdata(pd, sizeof(*pd), &s3c64xx_device_spi2); 1642 s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi2);
1630} 1643}
1631#endif /* CONFIG_S3C64XX_DEV_SPI2 */ 1644#endif /* CONFIG_S3C64XX_DEV_SPI2 */
diff --git a/arch/arm/plat-samsung/dma-ops.c b/arch/arm/plat-samsung/dma-ops.c
index eb9f4f53400..c38d7548924 100644
--- a/arch/arm/plat-samsung/dma-ops.c
+++ b/arch/arm/plat-samsung/dma-ops.c
@@ -19,72 +19,79 @@
19#include <mach/dma.h> 19#include <mach/dma.h>
20 20
21static unsigned samsung_dmadev_request(enum dma_ch dma_ch, 21static unsigned samsung_dmadev_request(enum dma_ch dma_ch,
22 struct samsung_dma_info *info) 22 struct samsung_dma_req *param)
23{ 23{
24 struct dma_chan *chan;
25 dma_cap_mask_t mask; 24 dma_cap_mask_t mask;
26 struct dma_slave_config slave_config;
27 void *filter_param; 25 void *filter_param;
28 26
29 dma_cap_zero(mask); 27 dma_cap_zero(mask);
30 dma_cap_set(info->cap, mask); 28 dma_cap_set(param->cap, mask);
31 29
32 /* 30 /*
33 * If a dma channel property of a device node from device tree is 31 * If a dma channel property of a device node from device tree is
34 * specified, use that as the fliter parameter. 32 * specified, use that as the fliter parameter.
35 */ 33 */
36 filter_param = (dma_ch == DMACH_DT_PROP) ? (void *)info->dt_dmach_prop : 34 filter_param = (dma_ch == DMACH_DT_PROP) ?
37 (void *)dma_ch; 35 (void *)param->dt_dmach_prop : (void *)dma_ch;
38 chan = dma_request_channel(mask, pl330_filter, filter_param); 36 return (unsigned)dma_request_channel(mask, pl330_filter, filter_param);
37}
38
39static int samsung_dmadev_release(unsigned ch, void *param)
40{
41 dma_release_channel((struct dma_chan *)ch);
39 42
40 if (info->direction == DMA_DEV_TO_MEM) { 43 return 0;
44}
45
46static int samsung_dmadev_config(unsigned ch,
47 struct samsung_dma_config *param)
48{
49 struct dma_chan *chan = (struct dma_chan *)ch;
50 struct dma_slave_config slave_config;
51
52 if (param->direction == DMA_DEV_TO_MEM) {
41 memset(&slave_config, 0, sizeof(struct dma_slave_config)); 53 memset(&slave_config, 0, sizeof(struct dma_slave_config));
42 slave_config.direction = info->direction; 54 slave_config.direction = param->direction;
43 slave_config.src_addr = info->fifo; 55 slave_config.src_addr = param->fifo;
44 slave_config.src_addr_width = info->width; 56 slave_config.src_addr_width = param->width;
45 slave_config.src_maxburst = 1; 57 slave_config.src_maxburst = 1;
46 dmaengine_slave_config(chan, &slave_config); 58 dmaengine_slave_config(chan, &slave_config);
47 } else if (info->direction == DMA_MEM_TO_DEV) { 59 } else if (param->direction == DMA_MEM_TO_DEV) {
48 memset(&slave_config, 0, sizeof(struct dma_slave_config)); 60 memset(&slave_config, 0, sizeof(struct dma_slave_config));
49 slave_config.direction = info->direction; 61 slave_config.direction = param->direction;
50 slave_config.dst_addr = info->fifo; 62 slave_config.dst_addr = param->fifo;
51 slave_config.dst_addr_width = info->width; 63 slave_config.dst_addr_width = param->width;
52 slave_config.dst_maxburst = 1; 64 slave_config.dst_maxburst = 1;
53 dmaengine_slave_config(chan, &slave_config); 65 dmaengine_slave_config(chan, &slave_config);
66 } else {
67 pr_warn("unsupported direction\n");
68 return -EINVAL;
54 } 69 }
55 70
56 return (unsigned)chan;
57}
58
59static int samsung_dmadev_release(unsigned ch,
60 struct s3c2410_dma_client *client)
61{
62 dma_release_channel((struct dma_chan *)ch);
63
64 return 0; 71 return 0;
65} 72}
66 73
67static int samsung_dmadev_prepare(unsigned ch, 74static int samsung_dmadev_prepare(unsigned ch,
68 struct samsung_dma_prep_info *info) 75 struct samsung_dma_prep *param)
69{ 76{
70 struct scatterlist sg; 77 struct scatterlist sg;
71 struct dma_chan *chan = (struct dma_chan *)ch; 78 struct dma_chan *chan = (struct dma_chan *)ch;
72 struct dma_async_tx_descriptor *desc; 79 struct dma_async_tx_descriptor *desc;
73 80
74 switch (info->cap) { 81 switch (param->cap) {
75 case DMA_SLAVE: 82 case DMA_SLAVE:
76 sg_init_table(&sg, 1); 83 sg_init_table(&sg, 1);
77 sg_dma_len(&sg) = info->len; 84 sg_dma_len(&sg) = param->len;
78 sg_set_page(&sg, pfn_to_page(PFN_DOWN(info->buf)), 85 sg_set_page(&sg, pfn_to_page(PFN_DOWN(param->buf)),
79 info->len, offset_in_page(info->buf)); 86 param->len, offset_in_page(param->buf));
80 sg_dma_address(&sg) = info->buf; 87 sg_dma_address(&sg) = param->buf;
81 88
82 desc = dmaengine_prep_slave_sg(chan, 89 desc = dmaengine_prep_slave_sg(chan,
83 &sg, 1, info->direction, DMA_PREP_INTERRUPT); 90 &sg, 1, param->direction, DMA_PREP_INTERRUPT);
84 break; 91 break;
85 case DMA_CYCLIC: 92 case DMA_CYCLIC:
86 desc = dmaengine_prep_dma_cyclic(chan, 93 desc = dmaengine_prep_dma_cyclic(chan, param->buf,
87 info->buf, info->len, info->period, info->direction); 94 param->len, param->period, param->direction);
88 break; 95 break;
89 default: 96 default:
90 dev_err(&chan->dev->device, "unsupported format\n"); 97 dev_err(&chan->dev->device, "unsupported format\n");
@@ -96,8 +103,8 @@ static int samsung_dmadev_prepare(unsigned ch,
96 return -EFAULT; 103 return -EFAULT;
97 } 104 }
98 105
99 desc->callback = info->fp; 106 desc->callback = param->fp;
100 desc->callback_param = info->fp_param; 107 desc->callback_param = param->fp_param;
101 108
102 dmaengine_submit((struct dma_async_tx_descriptor *)desc); 109 dmaengine_submit((struct dma_async_tx_descriptor *)desc);
103 110
@@ -119,6 +126,7 @@ static inline int samsung_dmadev_flush(unsigned ch)
119static struct samsung_dma_ops dmadev_ops = { 126static struct samsung_dma_ops dmadev_ops = {
120 .request = samsung_dmadev_request, 127 .request = samsung_dmadev_request,
121 .release = samsung_dmadev_release, 128 .release = samsung_dmadev_release,
129 .config = samsung_dmadev_config,
122 .prepare = samsung_dmadev_prepare, 130 .prepare = samsung_dmadev_prepare,
123 .trigger = samsung_dmadev_trigger, 131 .trigger = samsung_dmadev_trigger,
124 .started = NULL, 132 .started = NULL,
diff --git a/arch/arm/plat-samsung/include/plat/cpu.h b/arch/arm/plat-samsung/include/plat/cpu.h
index 0721293fad6..ace4451b765 100644
--- a/arch/arm/plat-samsung/include/plat/cpu.h
+++ b/arch/arm/plat-samsung/include/plat/cpu.h
@@ -132,6 +132,10 @@ IS_SAMSUNG_CPU(exynos5250, EXYNOS5250_SOC_ID, EXYNOS5_SOC_MASK)
132 132
133#define IODESC_ENT(x) { (unsigned long)S3C24XX_VA_##x, __phys_to_pfn(S3C24XX_PA_##x), S3C24XX_SZ_##x, MT_DEVICE } 133#define IODESC_ENT(x) { (unsigned long)S3C24XX_VA_##x, __phys_to_pfn(S3C24XX_PA_##x), S3C24XX_SZ_##x, MT_DEVICE }
134 134
135#ifndef KHZ
136#define KHZ (1000)
137#endif
138
135#ifndef MHZ 139#ifndef MHZ
136#define MHZ (1000*1000) 140#define MHZ (1000*1000)
137#endif 141#endif
diff --git a/arch/arm/plat-samsung/include/plat/devs.h b/arch/arm/plat-samsung/include/plat/devs.h
index 61ca2f356c5..5da4b4f38f4 100644
--- a/arch/arm/plat-samsung/include/plat/devs.h
+++ b/arch/arm/plat-samsung/include/plat/devs.h
@@ -131,7 +131,6 @@ extern struct platform_device exynos4_device_ohci;
131extern struct platform_device exynos4_device_pcm0; 131extern struct platform_device exynos4_device_pcm0;
132extern struct platform_device exynos4_device_pcm1; 132extern struct platform_device exynos4_device_pcm1;
133extern struct platform_device exynos4_device_pcm2; 133extern struct platform_device exynos4_device_pcm2;
134extern struct platform_device exynos4_device_pd[];
135extern struct platform_device exynos4_device_spdif; 134extern struct platform_device exynos4_device_spdif;
136 135
137extern struct platform_device exynos_device_drm; 136extern struct platform_device exynos_device_drm;
diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
index 71a6827c770..f5144cdd300 100644
--- a/arch/arm/plat-samsung/include/plat/dma-ops.h
+++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
@@ -16,7 +16,13 @@
16#include <linux/dmaengine.h> 16#include <linux/dmaengine.h>
17#include <mach/dma.h> 17#include <mach/dma.h>
18 18
19struct samsung_dma_prep_info { 19struct samsung_dma_req {
20 enum dma_transaction_type cap;
21 struct property *dt_dmach_prop;
22 struct s3c2410_dma_client *client;
23};
24
25struct samsung_dma_prep {
20 enum dma_transaction_type cap; 26 enum dma_transaction_type cap;
21 enum dma_transfer_direction direction; 27 enum dma_transfer_direction direction;
22 dma_addr_t buf; 28 dma_addr_t buf;
@@ -26,19 +32,17 @@ struct samsung_dma_prep_info {
26 void *fp_param; 32 void *fp_param;
27}; 33};
28 34
29struct samsung_dma_info { 35struct samsung_dma_config {
30 enum dma_transaction_type cap;
31 enum dma_transfer_direction direction; 36 enum dma_transfer_direction direction;
32 enum dma_slave_buswidth width; 37 enum dma_slave_buswidth width;
33 dma_addr_t fifo; 38 dma_addr_t fifo;
34 struct s3c2410_dma_client *client;
35 struct property *dt_dmach_prop;
36}; 39};
37 40
38struct samsung_dma_ops { 41struct samsung_dma_ops {
39 unsigned (*request)(enum dma_ch ch, struct samsung_dma_info *info); 42 unsigned (*request)(enum dma_ch ch, struct samsung_dma_req *param);
40 int (*release)(unsigned ch, struct s3c2410_dma_client *client); 43 int (*release)(unsigned ch, void *param);
41 int (*prepare)(unsigned ch, struct samsung_dma_prep_info *info); 44 int (*config)(unsigned ch, struct samsung_dma_config *param);
45 int (*prepare)(unsigned ch, struct samsung_dma_prep *param);
42 int (*trigger)(unsigned ch); 46 int (*trigger)(unsigned ch);
43 int (*started)(unsigned ch); 47 int (*started)(unsigned ch);
44 int (*flush)(unsigned ch); 48 int (*flush)(unsigned ch);
diff --git a/arch/arm/plat-samsung/include/plat/fb.h b/arch/arm/plat-samsung/include/plat/fb.h
index 536002ff2ab..b885322717a 100644
--- a/arch/arm/plat-samsung/include/plat/fb.h
+++ b/arch/arm/plat-samsung/include/plat/fb.h
@@ -43,7 +43,6 @@ struct s3c_fb_pd_win {
43 * @setup_gpio: Setup the external GPIO pins to the right state to transfer 43 * @setup_gpio: Setup the external GPIO pins to the right state to transfer
44 * the data from the display system to the connected display 44 * the data from the display system to the connected display
45 * device. 45 * device.
46 * @default_win: default window layer number to be used for UI layer.
47 * @vidcon0: The base vidcon0 values to control the panel data format. 46 * @vidcon0: The base vidcon0 values to control the panel data format.
48 * @vidcon1: The base vidcon1 values to control the panel data output. 47 * @vidcon1: The base vidcon1 values to control the panel data output.
49 * @vtiming: Video timing when connected to a RGB type panel. 48 * @vtiming: Video timing when connected to a RGB type panel.
diff --git a/arch/arm/plat-samsung/include/plat/gpio-cfg.h b/arch/arm/plat-samsung/include/plat/gpio-cfg.h
index df8155b9d4d..08740eed050 100644
--- a/arch/arm/plat-samsung/include/plat/gpio-cfg.h
+++ b/arch/arm/plat-samsung/include/plat/gpio-cfg.h
@@ -24,7 +24,7 @@
24#ifndef __PLAT_GPIO_CFG_H 24#ifndef __PLAT_GPIO_CFG_H
25#define __PLAT_GPIO_CFG_H __FILE__ 25#define __PLAT_GPIO_CFG_H __FILE__
26 26
27#include<linux/types.h> 27#include <linux/types.h>
28 28
29typedef unsigned int __bitwise__ samsung_gpio_pull_t; 29typedef unsigned int __bitwise__ samsung_gpio_pull_t;
30typedef unsigned int __bitwise__ s5p_gpio_drvstr_t; 30typedef unsigned int __bitwise__ s5p_gpio_drvstr_t;
diff --git a/arch/arm/plat-samsung/include/plat/hdmi.h b/arch/arm/plat-samsung/include/plat/hdmi.h
new file mode 100644
index 00000000000..331d046ac2c
--- /dev/null
+++ b/arch/arm/plat-samsung/include/plat/hdmi.h
@@ -0,0 +1,16 @@
1/*
2 * Copyright (C) 2012 Samsung Electronics Co.Ltd
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#ifndef __PLAT_SAMSUNG_HDMI_H
11#define __PLAT_SAMSUNG_HDMI_H __FILE__
12
13extern void s5p_hdmi_set_platdata(struct i2c_board_info *hdmiphy_info,
14 struct i2c_board_info *mhl_info, int mhl_bus);
15
16#endif /* __PLAT_SAMSUNG_HDMI_H */
diff --git a/arch/arm/plat-samsung/include/plat/pd.h b/arch/arm/plat-samsung/include/plat/pd.h
deleted file mode 100644
index abb4bc32716..00000000000
--- a/arch/arm/plat-samsung/include/plat/pd.h
+++ /dev/null
@@ -1,30 +0,0 @@
1/* linux/arch/arm/plat-samsung/include/plat/pd.h
2 *
3 * Copyright (c) 2010-2011 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#ifndef __ASM_PLAT_SAMSUNG_PD_H
12#define __ASM_PLAT_SAMSUNG_PD_H __FILE__
13
14struct samsung_pd_info {
15 int (*enable)(struct device *dev);
16 int (*disable)(struct device *dev);
17 void __iomem *base;
18};
19
20enum exynos4_pd_block {
21 PD_MFC,
22 PD_G3D,
23 PD_LCD0,
24 PD_LCD1,
25 PD_TV,
26 PD_CAM,
27 PD_GPS
28};
29
30#endif /* __ASM_PLAT_SAMSUNG_PD_H */
diff --git a/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h b/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h
index fa95e9a0097..ceba18d23a5 100644
--- a/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h
+++ b/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h
@@ -18,7 +18,6 @@ struct platform_device;
18 * @fb_delay: Slave specific feedback delay. 18 * @fb_delay: Slave specific feedback delay.
19 * Refer to FB_CLK_SEL register definition in SPI chapter. 19 * Refer to FB_CLK_SEL register definition in SPI chapter.
20 * @line: Custom 'identity' of the CS line. 20 * @line: Custom 'identity' of the CS line.
21 * @set_level: CS line control.
22 * 21 *
23 * This is per SPI-Slave Chipselect information. 22 * This is per SPI-Slave Chipselect information.
24 * Allocate and initialize one in machine init code and make the 23 * Allocate and initialize one in machine init code and make the
@@ -27,57 +26,41 @@ struct platform_device;
27struct s3c64xx_spi_csinfo { 26struct s3c64xx_spi_csinfo {
28 u8 fb_delay; 27 u8 fb_delay;
29 unsigned line; 28 unsigned line;
30 void (*set_level)(unsigned line_id, int lvl);
31}; 29};
32 30
33/** 31/**
34 * struct s3c64xx_spi_info - SPI Controller defining structure 32 * struct s3c64xx_spi_info - SPI Controller defining structure
35 * @src_clk_nr: Clock source index for the CLK_CFG[SPI_CLKSEL] field. 33 * @src_clk_nr: Clock source index for the CLK_CFG[SPI_CLKSEL] field.
36 * @clk_from_cmu: If the SPI clock/prescalar control block is present
37 * by the platform's clock-management-unit and not in SPI controller.
38 * @num_cs: Number of CS this controller emulates. 34 * @num_cs: Number of CS this controller emulates.
39 * @cfg_gpio: Configure pins for this SPI controller. 35 * @cfg_gpio: Configure pins for this SPI controller.
40 * @fifo_lvl_mask: All tx fifo_lvl fields start at offset-6
41 * @rx_lvl_offset: Depends on tx fifo_lvl field and bus number
42 * @high_speed: If the controller supports HIGH_SPEED_EN bit
43 * @tx_st_done: Depends on tx fifo_lvl field
44 */ 36 */
45struct s3c64xx_spi_info { 37struct s3c64xx_spi_info {
46 int src_clk_nr; 38 int src_clk_nr;
47 bool clk_from_cmu;
48
49 int num_cs; 39 int num_cs;
50 40 int (*cfg_gpio)(void);
51 int (*cfg_gpio)(struct platform_device *pdev);
52
53 /* Following two fields are for future compatibility */
54 int fifo_lvl_mask;
55 int rx_lvl_offset;
56 int high_speed;
57 int tx_st_done;
58}; 41};
59 42
60/** 43/**
61 * s3c64xx_spi_set_platdata - SPI Controller configure callback by the board 44 * s3c64xx_spi_set_platdata - SPI Controller configure callback by the board
62 * initialization code. 45 * initialization code.
63 * @pd: SPI platform data to set. 46 * @cfg_gpio: Pointer to gpio setup function.
64 * @src_clk_nr: Clock the SPI controller is to use to generate SPI clocks. 47 * @src_clk_nr: Clock the SPI controller is to use to generate SPI clocks.
65 * @num_cs: Number of elements in the 'cs' array. 48 * @num_cs: Number of elements in the 'cs' array.
66 * 49 *
67 * Call this from machine init code for each SPI Controller that 50 * Call this from machine init code for each SPI Controller that
68 * has some chips attached to it. 51 * has some chips attached to it.
69 */ 52 */
70extern void s3c64xx_spi0_set_platdata(struct s3c64xx_spi_info *pd, 53extern void s3c64xx_spi0_set_platdata(int (*cfg_gpio)(void), int src_clk_nr,
71 int src_clk_nr, int num_cs); 54 int num_cs);
72extern void s3c64xx_spi1_set_platdata(struct s3c64xx_spi_info *pd, 55extern void s3c64xx_spi1_set_platdata(int (*cfg_gpio)(void), int src_clk_nr,
73 int src_clk_nr, int num_cs); 56 int num_cs);
74extern void s3c64xx_spi2_set_platdata(struct s3c64xx_spi_info *pd, 57extern void s3c64xx_spi2_set_platdata(int (*cfg_gpio)(void), int src_clk_nr,
75 int src_clk_nr, int num_cs); 58 int num_cs);
76 59
77/* defined by architecture to configure gpio */ 60/* defined by architecture to configure gpio */
78extern int s3c64xx_spi0_cfg_gpio(struct platform_device *dev); 61extern int s3c64xx_spi0_cfg_gpio(void);
79extern int s3c64xx_spi1_cfg_gpio(struct platform_device *dev); 62extern int s3c64xx_spi1_cfg_gpio(void);
80extern int s3c64xx_spi2_cfg_gpio(struct platform_device *dev); 63extern int s3c64xx_spi2_cfg_gpio(void);
81 64
82extern struct s3c64xx_spi_info s3c64xx_spi0_pdata; 65extern struct s3c64xx_spi_info s3c64xx_spi0_pdata;
83extern struct s3c64xx_spi_info s3c64xx_spi1_pdata; 66extern struct s3c64xx_spi_info s3c64xx_spi1_pdata;
diff --git a/arch/arm/plat-samsung/pd.c b/arch/arm/plat-samsung/pd.c
deleted file mode 100644
index 312b510d86b..00000000000
--- a/arch/arm/plat-samsung/pd.c
+++ /dev/null
@@ -1,95 +0,0 @@
1/* linux/arch/arm/plat-samsung/pd.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * Samsung Power domain support
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#include <linux/init.h>
14#include <linux/export.h>
15#include <linux/platform_device.h>
16#include <linux/err.h>
17#include <linux/pm_runtime.h>
18
19#include <plat/pd.h>
20
21static int samsung_pd_probe(struct platform_device *pdev)
22{
23 struct samsung_pd_info *pdata = pdev->dev.platform_data;
24 struct device *dev = &pdev->dev;
25
26 if (!pdata) {
27 dev_err(dev, "no device data specified\n");
28 return -ENOENT;
29 }
30
31 pm_runtime_set_active(dev);
32 pm_runtime_enable(dev);
33
34 dev_info(dev, "power domain registered\n");
35 return 0;
36}
37
38static int __devexit samsung_pd_remove(struct platform_device *pdev)
39{
40 struct device *dev = &pdev->dev;
41
42 pm_runtime_disable(dev);
43 return 0;
44}
45
46static int samsung_pd_runtime_suspend(struct device *dev)
47{
48 struct samsung_pd_info *pdata = dev->platform_data;
49 int ret = 0;
50
51 if (pdata->disable)
52 ret = pdata->disable(dev);
53
54 dev_dbg(dev, "suspended\n");
55 return ret;
56}
57
58static int samsung_pd_runtime_resume(struct device *dev)
59{
60 struct samsung_pd_info *pdata = dev->platform_data;
61 int ret = 0;
62
63 if (pdata->enable)
64 ret = pdata->enable(dev);
65
66 dev_dbg(dev, "resumed\n");
67 return ret;
68}
69
70static const struct dev_pm_ops samsung_pd_pm_ops = {
71 .runtime_suspend = samsung_pd_runtime_suspend,
72 .runtime_resume = samsung_pd_runtime_resume,
73};
74
75static struct platform_driver samsung_pd_driver = {
76 .driver = {
77 .name = "samsung-pd",
78 .owner = THIS_MODULE,
79 .pm = &samsung_pd_pm_ops,
80 },
81 .probe = samsung_pd_probe,
82 .remove = __devexit_p(samsung_pd_remove),
83};
84
85static int __init samsung_pd_init(void)
86{
87 int ret;
88
89 ret = platform_driver_register(&samsung_pd_driver);
90 if (ret)
91 printk(KERN_ERR "%s: failed to add PD driver\n", __func__);
92
93 return ret;
94}
95arch_initcall(samsung_pd_init);
diff --git a/arch/arm/plat-samsung/pm.c b/arch/arm/plat-samsung/pm.c
index 64ab65f0fdb..15070284343 100644
--- a/arch/arm/plat-samsung/pm.c
+++ b/arch/arm/plat-samsung/pm.c
@@ -74,7 +74,7 @@ unsigned char pm_uart_udivslot;
74 74
75#ifdef CONFIG_SAMSUNG_PM_DEBUG 75#ifdef CONFIG_SAMSUNG_PM_DEBUG
76 76
77struct pm_uart_save uart_save[CONFIG_SERIAL_SAMSUNG_UARTS]; 77static struct pm_uart_save uart_save[CONFIG_SERIAL_SAMSUNG_UARTS];
78 78
79static void s3c_pm_save_uart(unsigned int uart, struct pm_uart_save *save) 79static void s3c_pm_save_uart(unsigned int uart, struct pm_uart_save *save)
80{ 80{
diff --git a/arch/arm/plat-samsung/pwm.c b/arch/arm/plat-samsung/pwm.c
deleted file mode 100644
index c559d8438c7..00000000000
--- a/arch/arm/plat-samsung/pwm.c
+++ /dev/null
@@ -1,420 +0,0 @@
1/* arch/arm/plat-s3c/pwm.c
2 *
3 * Copyright (c) 2007 Ben Dooks
4 * Copyright (c) 2008 Simtec Electronics
5 * Ben Dooks <ben@simtec.co.uk>, <ben-linux@fluff.org>
6 *
7 * S3C series PWM device core
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 as published by
11 * the Free Software Foundation; either version 2 of the License.
12*/
13
14#include <linux/export.h>
15#include <linux/kernel.h>
16#include <linux/platform_device.h>
17#include <linux/slab.h>
18#include <linux/err.h>
19#include <linux/clk.h>
20#include <linux/io.h>
21#include <linux/pwm.h>
22
23#include <mach/map.h>
24
25#include <plat/regs-timer.h>
26
27struct pwm_device {
28 struct list_head list;
29 struct platform_device *pdev;
30
31 struct clk *clk_div;
32 struct clk *clk;
33 const char *label;
34
35 unsigned int period_ns;
36 unsigned int duty_ns;
37
38 unsigned char tcon_base;
39 unsigned char running;
40 unsigned char use_count;
41 unsigned char pwm_id;
42};
43
44#define pwm_dbg(_pwm, msg...) dev_dbg(&(_pwm)->pdev->dev, msg)
45
46static struct clk *clk_scaler[2];
47
48static inline int pwm_is_tdiv(struct pwm_device *pwm)
49{
50 return clk_get_parent(pwm->clk) == pwm->clk_div;
51}
52
53static DEFINE_MUTEX(pwm_lock);
54static LIST_HEAD(pwm_list);
55
56struct pwm_device *pwm_request(int pwm_id, const char *label)
57{
58 struct pwm_device *pwm;
59 int found = 0;
60
61 mutex_lock(&pwm_lock);
62
63 list_for_each_entry(pwm, &pwm_list, list) {
64 if (pwm->pwm_id == pwm_id) {
65 found = 1;
66 break;
67 }
68 }
69
70 if (found) {
71 if (pwm->use_count == 0) {
72 pwm->use_count = 1;
73 pwm->label = label;
74 } else
75 pwm = ERR_PTR(-EBUSY);
76 } else
77 pwm = ERR_PTR(-ENOENT);
78
79 mutex_unlock(&pwm_lock);
80 return pwm;
81}
82
83EXPORT_SYMBOL(pwm_request);
84
85
86void pwm_free(struct pwm_device *pwm)
87{
88 mutex_lock(&pwm_lock);
89
90 if (pwm->use_count) {
91 pwm->use_count--;
92 pwm->label = NULL;
93 } else
94 printk(KERN_ERR "PWM%d device already freed\n", pwm->pwm_id);
95
96 mutex_unlock(&pwm_lock);
97}
98
99EXPORT_SYMBOL(pwm_free);
100
101#define pwm_tcon_start(pwm) (1 << (pwm->tcon_base + 0))
102#define pwm_tcon_invert(pwm) (1 << (pwm->tcon_base + 2))
103#define pwm_tcon_autoreload(pwm) (1 << (pwm->tcon_base + 3))
104#define pwm_tcon_manulupdate(pwm) (1 << (pwm->tcon_base + 1))
105
106int pwm_enable(struct pwm_device *pwm)
107{
108 unsigned long flags;
109 unsigned long tcon;
110
111 local_irq_save(flags);
112
113 tcon = __raw_readl(S3C2410_TCON);
114 tcon |= pwm_tcon_start(pwm);
115 __raw_writel(tcon, S3C2410_TCON);
116
117 local_irq_restore(flags);
118
119 pwm->running = 1;
120 return 0;
121}
122
123EXPORT_SYMBOL(pwm_enable);
124
125void pwm_disable(struct pwm_device *pwm)
126{
127 unsigned long flags;
128 unsigned long tcon;
129
130 local_irq_save(flags);
131
132 tcon = __raw_readl(S3C2410_TCON);
133 tcon &= ~pwm_tcon_start(pwm);
134 __raw_writel(tcon, S3C2410_TCON);
135
136 local_irq_restore(flags);
137
138 pwm->running = 0;
139}
140
141EXPORT_SYMBOL(pwm_disable);
142
143static unsigned long pwm_calc_tin(struct pwm_device *pwm, unsigned long freq)
144{
145 unsigned long tin_parent_rate;
146 unsigned int div;
147
148 tin_parent_rate = clk_get_rate(clk_get_parent(pwm->clk_div));
149 pwm_dbg(pwm, "tin parent at %lu\n", tin_parent_rate);
150
151 for (div = 2; div <= 16; div *= 2) {
152 if ((tin_parent_rate / (div << 16)) < freq)
153 return tin_parent_rate / div;
154 }
155
156 return tin_parent_rate / 16;
157}
158
159#define NS_IN_HZ (1000000000UL)
160
161int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
162{
163 unsigned long tin_rate;
164 unsigned long tin_ns;
165 unsigned long period;
166 unsigned long flags;
167 unsigned long tcon;
168 unsigned long tcnt;
169 long tcmp;
170
171 /* We currently avoid using 64bit arithmetic by using the
172 * fact that anything faster than 1Hz is easily representable
173 * by 32bits. */
174
175 if (period_ns > NS_IN_HZ || duty_ns > NS_IN_HZ)
176 return -ERANGE;
177
178 if (duty_ns > period_ns)
179 return -EINVAL;
180
181 if (period_ns == pwm->period_ns &&
182 duty_ns == pwm->duty_ns)
183 return 0;
184
185 /* The TCMP and TCNT can be read without a lock, they're not
186 * shared between the timers. */
187
188 tcmp = __raw_readl(S3C2410_TCMPB(pwm->pwm_id));
189 tcnt = __raw_readl(S3C2410_TCNTB(pwm->pwm_id));
190
191 period = NS_IN_HZ / period_ns;
192
193 pwm_dbg(pwm, "duty_ns=%d, period_ns=%d (%lu)\n",
194 duty_ns, period_ns, period);
195
196 /* Check to see if we are changing the clock rate of the PWM */
197
198 if (pwm->period_ns != period_ns) {
199 if (pwm_is_tdiv(pwm)) {
200 tin_rate = pwm_calc_tin(pwm, period);
201 clk_set_rate(pwm->clk_div, tin_rate);
202 } else
203 tin_rate = clk_get_rate(pwm->clk);
204
205 pwm->period_ns = period_ns;
206
207 pwm_dbg(pwm, "tin_rate=%lu\n", tin_rate);
208
209 tin_ns = NS_IN_HZ / tin_rate;
210 tcnt = period_ns / tin_ns;
211 } else
212 tin_ns = NS_IN_HZ / clk_get_rate(pwm->clk);
213
214 /* Note, counters count down */
215
216 tcmp = duty_ns / tin_ns;
217 tcmp = tcnt - tcmp;
218 /* the pwm hw only checks the compare register after a decrement,
219 so the pin never toggles if tcmp = tcnt */
220 if (tcmp == tcnt)
221 tcmp--;
222
223 pwm_dbg(pwm, "tin_ns=%lu, tcmp=%ld/%lu\n", tin_ns, tcmp, tcnt);
224
225 if (tcmp < 0)
226 tcmp = 0;
227
228 /* Update the PWM register block. */
229
230 local_irq_save(flags);
231
232 __raw_writel(tcmp, S3C2410_TCMPB(pwm->pwm_id));
233 __raw_writel(tcnt, S3C2410_TCNTB(pwm->pwm_id));
234
235 tcon = __raw_readl(S3C2410_TCON);
236 tcon |= pwm_tcon_manulupdate(pwm);
237 tcon |= pwm_tcon_autoreload(pwm);
238 __raw_writel(tcon, S3C2410_TCON);
239
240 tcon &= ~pwm_tcon_manulupdate(pwm);
241 __raw_writel(tcon, S3C2410_TCON);
242
243 local_irq_restore(flags);
244
245 return 0;
246}
247
248EXPORT_SYMBOL(pwm_config);
249
250static int pwm_register(struct pwm_device *pwm)
251{
252 pwm->duty_ns = -1;
253 pwm->period_ns = -1;
254
255 mutex_lock(&pwm_lock);
256 list_add_tail(&pwm->list, &pwm_list);
257 mutex_unlock(&pwm_lock);
258
259 return 0;
260}
261
262static int s3c_pwm_probe(struct platform_device *pdev)
263{
264 struct device *dev = &pdev->dev;
265 struct pwm_device *pwm;
266 unsigned long flags;
267 unsigned long tcon;
268 unsigned int id = pdev->id;
269 int ret;
270
271 if (id == 4) {
272 dev_err(dev, "TIMER4 is currently not supported\n");
273 return -ENXIO;
274 }
275
276 pwm = kzalloc(sizeof(struct pwm_device), GFP_KERNEL);
277 if (pwm == NULL) {
278 dev_err(dev, "failed to allocate pwm_device\n");
279 return -ENOMEM;
280 }
281
282 pwm->pdev = pdev;
283 pwm->pwm_id = id;
284
285 /* calculate base of control bits in TCON */
286 pwm->tcon_base = id == 0 ? 0 : (id * 4) + 4;
287
288 pwm->clk = clk_get(dev, "pwm-tin");
289 if (IS_ERR(pwm->clk)) {
290 dev_err(dev, "failed to get pwm tin clk\n");
291 ret = PTR_ERR(pwm->clk);
292 goto err_alloc;
293 }
294
295 pwm->clk_div = clk_get(dev, "pwm-tdiv");
296 if (IS_ERR(pwm->clk_div)) {
297 dev_err(dev, "failed to get pwm tdiv clk\n");
298 ret = PTR_ERR(pwm->clk_div);
299 goto err_clk_tin;
300 }
301
302 clk_enable(pwm->clk);
303 clk_enable(pwm->clk_div);
304
305 local_irq_save(flags);
306
307 tcon = __raw_readl(S3C2410_TCON);
308 tcon |= pwm_tcon_invert(pwm);
309 __raw_writel(tcon, S3C2410_TCON);
310
311 local_irq_restore(flags);
312
313
314 ret = pwm_register(pwm);
315 if (ret) {
316 dev_err(dev, "failed to register pwm\n");
317 goto err_clk_tdiv;
318 }
319
320 pwm_dbg(pwm, "config bits %02x\n",
321 (__raw_readl(S3C2410_TCON) >> pwm->tcon_base) & 0x0f);
322
323 dev_info(dev, "tin at %lu, tdiv at %lu, tin=%sclk, base %d\n",
324 clk_get_rate(pwm->clk),
325 clk_get_rate(pwm->clk_div),
326 pwm_is_tdiv(pwm) ? "div" : "ext", pwm->tcon_base);
327
328 platform_set_drvdata(pdev, pwm);
329 return 0;
330
331 err_clk_tdiv:
332 clk_disable(pwm->clk_div);
333 clk_disable(pwm->clk);
334 clk_put(pwm->clk_div);
335
336 err_clk_tin:
337 clk_put(pwm->clk);
338
339 err_alloc:
340 kfree(pwm);
341 return ret;
342}
343
344static int __devexit s3c_pwm_remove(struct platform_device *pdev)
345{
346 struct pwm_device *pwm = platform_get_drvdata(pdev);
347
348 clk_disable(pwm->clk_div);
349 clk_disable(pwm->clk);
350 clk_put(pwm->clk_div);
351 clk_put(pwm->clk);
352 kfree(pwm);
353
354 return 0;
355}
356
357#ifdef CONFIG_PM
358static int s3c_pwm_suspend(struct platform_device *pdev, pm_message_t state)
359{
360 struct pwm_device *pwm = platform_get_drvdata(pdev);
361
362 /* No one preserve these values during suspend so reset them
363 * Otherwise driver leaves PWM unconfigured if same values
364 * passed to pwm_config
365 */
366 pwm->period_ns = 0;
367 pwm->duty_ns = 0;
368
369 return 0;
370}
371
372static int s3c_pwm_resume(struct platform_device *pdev)
373{
374 struct pwm_device *pwm = platform_get_drvdata(pdev);
375 unsigned long tcon;
376
377 /* Restore invertion */
378 tcon = __raw_readl(S3C2410_TCON);
379 tcon |= pwm_tcon_invert(pwm);
380 __raw_writel(tcon, S3C2410_TCON);
381
382 return 0;
383}
384
385#else
386#define s3c_pwm_suspend NULL
387#define s3c_pwm_resume NULL
388#endif
389
390static struct platform_driver s3c_pwm_driver = {
391 .driver = {
392 .name = "s3c24xx-pwm",
393 .owner = THIS_MODULE,
394 },
395 .probe = s3c_pwm_probe,
396 .remove = __devexit_p(s3c_pwm_remove),
397 .suspend = s3c_pwm_suspend,
398 .resume = s3c_pwm_resume,
399};
400
401static int __init pwm_init(void)
402{
403 int ret;
404
405 clk_scaler[0] = clk_get(NULL, "pwm-scaler0");
406 clk_scaler[1] = clk_get(NULL, "pwm-scaler1");
407
408 if (IS_ERR(clk_scaler[0]) || IS_ERR(clk_scaler[1])) {
409 printk(KERN_ERR "%s: failed to get scaler clocks\n", __func__);
410 return -EINVAL;
411 }
412
413 ret = platform_driver_register(&s3c_pwm_driver);
414 if (ret)
415 printk(KERN_ERR "%s: failed to add pwm driver\n", __func__);
416
417 return ret;
418}
419
420arch_initcall(pwm_init);
diff --git a/arch/arm/plat-samsung/s3c-dma-ops.c b/arch/arm/plat-samsung/s3c-dma-ops.c
index 78149491282..f99448c48d3 100644
--- a/arch/arm/plat-samsung/s3c-dma-ops.c
+++ b/arch/arm/plat-samsung/s3c-dma-ops.c
@@ -36,30 +36,26 @@ static void s3c_dma_cb(struct s3c2410_dma_chan *channel, void *param,
36} 36}
37 37
38static unsigned s3c_dma_request(enum dma_ch dma_ch, 38static unsigned s3c_dma_request(enum dma_ch dma_ch,
39 struct samsung_dma_info *info) 39 struct samsung_dma_req *param)
40{ 40{
41 struct cb_data *data; 41 struct cb_data *data;
42 42
43 if (s3c2410_dma_request(dma_ch, info->client, NULL) < 0) { 43 if (s3c2410_dma_request(dma_ch, param->client, NULL) < 0) {
44 s3c2410_dma_free(dma_ch, info->client); 44 s3c2410_dma_free(dma_ch, param->client);
45 return 0; 45 return 0;
46 } 46 }
47 47
48 if (param->cap == DMA_CYCLIC)
49 s3c2410_dma_setflags(dma_ch, S3C2410_DMAF_CIRCULAR);
50
48 data = kzalloc(sizeof(struct cb_data), GFP_KERNEL); 51 data = kzalloc(sizeof(struct cb_data), GFP_KERNEL);
49 data->ch = dma_ch; 52 data->ch = dma_ch;
50 list_add_tail(&data->node, &dma_list); 53 list_add_tail(&data->node, &dma_list);
51 54
52 s3c2410_dma_devconfig(dma_ch, info->direction, info->fifo);
53
54 if (info->cap == DMA_CYCLIC)
55 s3c2410_dma_setflags(dma_ch, S3C2410_DMAF_CIRCULAR);
56
57 s3c2410_dma_config(dma_ch, info->width);
58
59 return (unsigned)dma_ch; 55 return (unsigned)dma_ch;
60} 56}
61 57
62static int s3c_dma_release(unsigned ch, struct s3c2410_dma_client *client) 58static int s3c_dma_release(unsigned ch, void *param)
63{ 59{
64 struct cb_data *data; 60 struct cb_data *data;
65 61
@@ -68,16 +64,24 @@ static int s3c_dma_release(unsigned ch, struct s3c2410_dma_client *client)
68 break; 64 break;
69 list_del(&data->node); 65 list_del(&data->node);
70 66
71 s3c2410_dma_free(ch, client); 67 s3c2410_dma_free(ch, param);
72 kfree(data); 68 kfree(data);
73 69
74 return 0; 70 return 0;
75} 71}
76 72
77static int s3c_dma_prepare(unsigned ch, struct samsung_dma_prep_info *info) 73static int s3c_dma_config(unsigned ch, struct samsung_dma_config *param)
74{
75 s3c2410_dma_devconfig(ch, param->direction, param->fifo);
76 s3c2410_dma_config(ch, param->width);
77
78 return 0;
79}
80
81static int s3c_dma_prepare(unsigned ch, struct samsung_dma_prep *param)
78{ 82{
79 struct cb_data *data; 83 struct cb_data *data;
80 int len = (info->cap == DMA_CYCLIC) ? info->period : info->len; 84 int len = (param->cap == DMA_CYCLIC) ? param->period : param->len;
81 85
82 list_for_each_entry(data, &dma_list, node) 86 list_for_each_entry(data, &dma_list, node)
83 if (data->ch == ch) 87 if (data->ch == ch)
@@ -85,11 +89,11 @@ static int s3c_dma_prepare(unsigned ch, struct samsung_dma_prep_info *info)
85 89
86 if (!data->fp) { 90 if (!data->fp) {
87 s3c2410_dma_set_buffdone_fn(ch, s3c_dma_cb); 91 s3c2410_dma_set_buffdone_fn(ch, s3c_dma_cb);
88 data->fp = info->fp; 92 data->fp = param->fp;
89 data->fp_param = info->fp_param; 93 data->fp_param = param->fp_param;
90 } 94 }
91 95
92 s3c2410_dma_enqueue(ch, (void *)data, info->buf, len); 96 s3c2410_dma_enqueue(ch, (void *)data, param->buf, len);
93 97
94 return 0; 98 return 0;
95} 99}
@@ -117,6 +121,7 @@ static inline int s3c_dma_stop(unsigned ch)
117static struct samsung_dma_ops s3c_dma_ops = { 121static struct samsung_dma_ops s3c_dma_ops = {
118 .request = s3c_dma_request, 122 .request = s3c_dma_request,
119 .release = s3c_dma_release, 123 .release = s3c_dma_release,
124 .config = s3c_dma_config,
120 .prepare = s3c_dma_prepare, 125 .prepare = s3c_dma_prepare,
121 .trigger = s3c_dma_trigger, 126 .trigger = s3c_dma_trigger,
122 .started = s3c_dma_started, 127 .started = s3c_dma_started,
diff --git a/arch/arm/plat-spear/include/plat/keyboard.h b/arch/arm/plat-spear/include/plat/keyboard.h
index 0562f134621..9248e3a7e33 100644
--- a/arch/arm/plat-spear/include/plat/keyboard.h
+++ b/arch/arm/plat-spear/include/plat/keyboard.h
@@ -149,6 +149,7 @@ int _name[] = { \
149 * keymap: pointer to keymap data (table and size) 149 * keymap: pointer to keymap data (table and size)
150 * rep: enables key autorepeat 150 * rep: enables key autorepeat
151 * mode: choose keyboard support(9x9, 6x6, 2x2) 151 * mode: choose keyboard support(9x9, 6x6, 2x2)
152 * suspended_rate: rate at which keyboard would operate in suspended mode
152 * 153 *
153 * This structure is supposed to be used by platform code to supply 154 * This structure is supposed to be used by platform code to supply
154 * keymaps to drivers that implement keyboards. 155 * keymaps to drivers that implement keyboards.
@@ -157,6 +158,7 @@ struct kbd_platform_data {
157 const struct matrix_keymap_data *keymap; 158 const struct matrix_keymap_data *keymap;
158 bool rep; 159 bool rep;
159 unsigned int mode; 160 unsigned int mode;
161 unsigned int suspended_rate;
160}; 162};
161 163
162#endif /* __PLAT_KEYBOARD_H */ 164#endif /* __PLAT_KEYBOARD_H */
diff --git a/arch/arm/plat-spear/include/plat/pl080.h b/arch/arm/plat-spear/include/plat/pl080.h
index 2bc6b54460a..eb6590ded40 100644
--- a/arch/arm/plat-spear/include/plat/pl080.h
+++ b/arch/arm/plat-spear/include/plat/pl080.h
@@ -14,8 +14,8 @@
14#ifndef __PLAT_PL080_H 14#ifndef __PLAT_PL080_H
15#define __PLAT_PL080_H 15#define __PLAT_PL080_H
16 16
17struct pl08x_dma_chan; 17struct pl08x_channel_data;
18int pl080_get_signal(struct pl08x_dma_chan *ch); 18int pl080_get_signal(const struct pl08x_channel_data *cd);
19void pl080_put_signal(struct pl08x_dma_chan *ch); 19void pl080_put_signal(const struct pl08x_channel_data *cd, int signal);
20 20
21#endif /* __PLAT_PL080_H */ 21#endif /* __PLAT_PL080_H */
diff --git a/arch/arm/plat-spear/pl080.c b/arch/arm/plat-spear/pl080.c
index 12cf27f935f..cfa1199d0f4 100644
--- a/arch/arm/plat-spear/pl080.c
+++ b/arch/arm/plat-spear/pl080.c
@@ -27,9 +27,8 @@ struct {
27 unsigned char val; 27 unsigned char val;
28} signals[16] = {{0, 0}, }; 28} signals[16] = {{0, 0}, };
29 29
30int pl080_get_signal(struct pl08x_dma_chan *ch) 30int pl080_get_signal(const struct pl08x_channel_data *cd)
31{ 31{
32 const struct pl08x_channel_data *cd = ch->cd;
33 unsigned int signal = cd->min_signal, val; 32 unsigned int signal = cd->min_signal, val;
34 unsigned long flags; 33 unsigned long flags;
35 34
@@ -63,18 +62,17 @@ int pl080_get_signal(struct pl08x_dma_chan *ch)
63 return signal; 62 return signal;
64} 63}
65 64
66void pl080_put_signal(struct pl08x_dma_chan *ch) 65void pl080_put_signal(const struct pl08x_channel_data *cd, int signal)
67{ 66{
68 const struct pl08x_channel_data *cd = ch->cd;
69 unsigned long flags; 67 unsigned long flags;
70 68
71 spin_lock_irqsave(&lock, flags); 69 spin_lock_irqsave(&lock, flags);
72 70
73 /* if signal is not used */ 71 /* if signal is not used */
74 if (!signals[cd->min_signal].busy) 72 if (!signals[signal].busy)
75 BUG(); 73 BUG();
76 74
77 signals[cd->min_signal].busy--; 75 signals[signal].busy--;
78 76
79 spin_unlock_irqrestore(&lock, flags); 77 spin_unlock_irqrestore(&lock, flags);
80} 78}
diff --git a/arch/arm/plat-versatile/Kconfig b/arch/arm/plat-versatile/Kconfig
index 81ee7cc3445..8d5c10a5084 100644
--- a/arch/arm/plat-versatile/Kconfig
+++ b/arch/arm/plat-versatile/Kconfig
@@ -1,5 +1,8 @@
1if PLAT_VERSATILE 1if PLAT_VERSATILE
2 2
3config PLAT_VERSATILE_CLOCK
4 bool
5
3config PLAT_VERSATILE_CLCD 6config PLAT_VERSATILE_CLCD
4 bool 7 bool
5 8
diff --git a/arch/arm/plat-versatile/Makefile b/arch/arm/plat-versatile/Makefile
index a5cb1945bdc..272769a8a7d 100644
--- a/arch/arm/plat-versatile/Makefile
+++ b/arch/arm/plat-versatile/Makefile
@@ -1,4 +1,4 @@
1obj-y := clock.o 1obj-$(CONFIG_PLAT_VERSATILE_CLOCK) += clock.o
2obj-$(CONFIG_PLAT_VERSATILE_CLCD) += clcd.o 2obj-$(CONFIG_PLAT_VERSATILE_CLCD) += clcd.o
3obj-$(CONFIG_PLAT_VERSATILE_FPGA_IRQ) += fpga-irq.o 3obj-$(CONFIG_PLAT_VERSATILE_FPGA_IRQ) += fpga-irq.o
4obj-$(CONFIG_PLAT_VERSATILE_LEDS) += leds.o 4obj-$(CONFIG_PLAT_VERSATILE_LEDS) += leds.o
diff --git a/arch/arm/plat-versatile/platsmp.c b/arch/arm/plat-versatile/platsmp.c
index 49c7db48c7f..d7c5c171f5a 100644
--- a/arch/arm/plat-versatile/platsmp.c
+++ b/arch/arm/plat-versatile/platsmp.c
@@ -85,7 +85,7 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
85 * the boot monitor to read the system wide flags register, 85 * the boot monitor to read the system wide flags register,
86 * and branch to the address found there. 86 * and branch to the address found there.
87 */ 87 */
88 gic_raise_softirq(cpumask_of(cpu), 1); 88 gic_raise_softirq(cpumask_of(cpu), 0);
89 89
90 timeout = jiffies + (1 * HZ); 90 timeout = jiffies + (1 * HZ);
91 while (time_before(jiffies, timeout)) { 91 while (time_before(jiffies, timeout)) {
diff --git a/arch/arm/vfp/entry.S b/arch/arm/vfp/entry.S
index 4fa9903b83c..cc926c98598 100644
--- a/arch/arm/vfp/entry.S
+++ b/arch/arm/vfp/entry.S
@@ -7,18 +7,20 @@
7 * This program is free software; you can redistribute it and/or modify 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 8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 *
11 * Basic entry code, called from the kernel's undefined instruction trap.
12 * r0 = faulted instruction
13 * r5 = faulted PC+4
14 * r9 = successful return
15 * r10 = thread_info structure
16 * lr = failure return
17 */ 10 */
18#include <asm/thread_info.h> 11#include <asm/thread_info.h>
19#include <asm/vfpmacros.h> 12#include <asm/vfpmacros.h>
20#include "../kernel/entry-header.S" 13#include "../kernel/entry-header.S"
21 14
15@ VFP entry point.
16@
17@ r0 = instruction opcode (32-bit ARM or two 16-bit Thumb)
18@ r2 = PC value to resume execution after successful emulation
19@ r9 = normal "successful" return address
20@ r10 = this threads thread_info structure
21@ lr = unrecognised instruction return address
22@ IRQs disabled.
23@
22ENTRY(do_vfp) 24ENTRY(do_vfp)
23#ifdef CONFIG_PREEMPT 25#ifdef CONFIG_PREEMPT
24 ldr r4, [r10, #TI_PREEMPT] @ get preempt count 26 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
diff --git a/arch/arm/vfp/vfphw.S b/arch/arm/vfp/vfphw.S
index 2d30c7f6edd..ea0349f6358 100644
--- a/arch/arm/vfp/vfphw.S
+++ b/arch/arm/vfp/vfphw.S
@@ -16,6 +16,7 @@
16 */ 16 */
17#include <asm/thread_info.h> 17#include <asm/thread_info.h>
18#include <asm/vfpmacros.h> 18#include <asm/vfpmacros.h>
19#include <linux/kern_levels.h>
19#include "../kernel/entry-header.S" 20#include "../kernel/entry-header.S"
20 21
21 .macro DBGSTR, str 22 .macro DBGSTR, str
@@ -24,7 +25,7 @@
24 add r0, pc, #4 25 add r0, pc, #4
25 bl printk 26 bl printk
26 b 1f 27 b 1f
27 .asciz "<7>VFP: \str\n" 28 .asciz KERN_DEBUG "VFP: \str\n"
28 .balign 4 29 .balign 4
291: ldmfd sp!, {r0-r3, ip, lr} 301: ldmfd sp!, {r0-r3, ip, lr}
30#endif 31#endif
@@ -37,7 +38,7 @@
37 add r0, pc, #4 38 add r0, pc, #4
38 bl printk 39 bl printk
39 b 1f 40 b 1f
40 .asciz "<7>VFP: \str\n" 41 .asciz KERN_DEBUG "VFP: \str\n"
41 .balign 4 42 .balign 4
421: ldmfd sp!, {r0-r3, ip, lr} 431: ldmfd sp!, {r0-r3, ip, lr}
43#endif 44#endif
@@ -52,7 +53,7 @@
52 add r0, pc, #4 53 add r0, pc, #4
53 bl printk 54 bl printk
54 b 1f 55 b 1f
55 .asciz "<7>VFP: \str\n" 56 .asciz KERN_DEBUG "VFP: \str\n"
56 .balign 4 57 .balign 4
571: ldmfd sp!, {r0-r3, ip, lr} 581: ldmfd sp!, {r0-r3, ip, lr}
58#endif 59#endif
@@ -61,13 +62,13 @@
61 62
62@ VFP hardware support entry point. 63@ VFP hardware support entry point.
63@ 64@
64@ r0 = faulted instruction 65@ r0 = instruction opcode (32-bit ARM or two 16-bit Thumb)
65@ r2 = faulted PC+4 66@ r2 = PC value to resume execution after successful emulation
66@ r9 = successful return 67@ r9 = normal "successful" return address
67@ r10 = vfp_state union 68@ r10 = vfp_state union
68@ r11 = CPU number 69@ r11 = CPU number
69@ lr = failure return 70@ lr = unrecognised instruction return address
70 71@ IRQs enabled.
71ENTRY(vfp_support_entry) 72ENTRY(vfp_support_entry)
72 DBGSTR3 "instr %08x pc %08x state %p", r0, r2, r10 73 DBGSTR3 "instr %08x pc %08x state %p", r0, r2, r10
73 74
@@ -161,9 +162,12 @@ vfp_hw_state_valid:
161 @ exception before retrying branch 162 @ exception before retrying branch
162 @ out before setting an FPEXC that 163 @ out before setting an FPEXC that
163 @ stops us reading stuff 164 @ stops us reading stuff
164 VFPFMXR FPEXC, r1 @ restore FPEXC last 165 VFPFMXR FPEXC, r1 @ Restore FPEXC last
165 sub r2, r2, #4 166 sub r2, r2, #4 @ Retry current instruction - if Thumb
166 str r2, [sp, #S_PC] @ retry the instruction 167 str r2, [sp, #S_PC] @ mode it's two 16-bit instructions,
168 @ else it's one 32-bit instruction, so
169 @ always subtract 4 from the following
170 @ instruction address.
167#ifdef CONFIG_PREEMPT 171#ifdef CONFIG_PREEMPT
168 get_thread_info r10 172 get_thread_info r10
169 ldr r4, [r10, #TI_PREEMPT] @ get preempt count 173 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index 586961929e9..c834b32af27 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -457,10 +457,16 @@ static int vfp_pm_suspend(void)
457 457
458 /* disable, just in case */ 458 /* disable, just in case */
459 fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN); 459 fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN);
460 } else if (vfp_current_hw_state[ti->cpu]) {
461#ifndef CONFIG_SMP
462 fmxr(FPEXC, fpexc | FPEXC_EN);
463 vfp_save_state(vfp_current_hw_state[ti->cpu], fpexc);
464 fmxr(FPEXC, fpexc);
465#endif
460 } 466 }
461 467
462 /* clear any information we had about last context state */ 468 /* clear any information we had about last context state */
463 memset(vfp_current_hw_state, 0, sizeof(vfp_current_hw_state)); 469 vfp_current_hw_state[ti->cpu] = NULL;
464 470
465 return 0; 471 return 0;
466} 472}
@@ -713,8 +719,10 @@ static int __init vfp_init(void)
713 if ((fmrx(MVFR1) & 0x000fff00) == 0x00011100) 719 if ((fmrx(MVFR1) & 0x000fff00) == 0x00011100)
714 elf_hwcap |= HWCAP_NEON; 720 elf_hwcap |= HWCAP_NEON;
715#endif 721#endif
722#ifdef CONFIG_VFPv3
716 if ((fmrx(MVFR1) & 0xf0000000) == 0x10000000) 723 if ((fmrx(MVFR1) & 0xf0000000) == 0x10000000)
717 elf_hwcap |= HWCAP_VFPv4; 724 elf_hwcap |= HWCAP_VFPv4;
725#endif
718 } 726 }
719 } 727 }
720 return 0; 728 return 0;
diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig
index 71d38c76726..5ade51c8a87 100644
--- a/arch/avr32/Kconfig
+++ b/arch/avr32/Kconfig
@@ -12,6 +12,7 @@ config AVR32
12 select HARDIRQS_SW_RESEND 12 select HARDIRQS_SW_RESEND
13 select GENERIC_IRQ_SHOW 13 select GENERIC_IRQ_SHOW
14 select ARCH_HAVE_CUSTOM_GPIO_H 14 select ARCH_HAVE_CUSTOM_GPIO_H
15 select ARCH_WANT_IPC_PARSE_VERSION
15 select ARCH_HAVE_NMI_SAFE_CMPXCHG 16 select ARCH_HAVE_NMI_SAFE_CMPXCHG
16 select GENERIC_CLOCKEVENTS 17 select GENERIC_CLOCKEVENTS
17 help 18 help
diff --git a/arch/avr32/boards/atstk1000/atstk1002.c b/arch/avr32/boards/atstk1000/atstk1002.c
index dc526332148..6c80aba7bf9 100644
--- a/arch/avr32/boards/atstk1000/atstk1002.c
+++ b/arch/avr32/boards/atstk1000/atstk1002.c
@@ -97,7 +97,7 @@ static struct atmel_nand_data atstk1006_nand_data __initdata = {
97 .enable_pin = GPIO_PIN_PB(29), 97 .enable_pin = GPIO_PIN_PB(29),
98 .ecc_mode = NAND_ECC_SOFT, 98 .ecc_mode = NAND_ECC_SOFT,
99 .parts = nand_partitions, 99 .parts = nand_partitions,
100 .num_parts = ARRAY_SIZE(num_partitions), 100 .num_parts = ARRAY_SIZE(nand_partitions),
101}; 101};
102#endif 102#endif
103 103
diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
index b7f5c687010..479330b8979 100644
--- a/arch/avr32/include/asm/kmap_types.h
+++ b/arch/avr32/include/asm/kmap_types.h
@@ -2,29 +2,9 @@
2#define __ASM_AVR32_KMAP_TYPES_H 2#define __ASM_AVR32_KMAP_TYPES_H
3 3
4#ifdef CONFIG_DEBUG_HIGHMEM 4#ifdef CONFIG_DEBUG_HIGHMEM
5# define D(n) __KM_FENCE_##n , 5# define KM_TYPE_NR 29
6#else 6#else
7# define D(n) 7# define KM_TYPE_NR 14
8#endif 8#endif
9 9
10enum km_type {
11D(0) KM_BOUNCE_READ,
12D(1) KM_SKB_SUNRPC_DATA,
13D(2) KM_SKB_DATA_SOFTIRQ,
14D(3) KM_USER0,
15D(4) KM_USER1,
16D(5) KM_BIO_SRC_IRQ,
17D(6) KM_BIO_DST_IRQ,
18D(7) KM_PTE0,
19D(8) KM_PTE1,
20D(9) KM_PTE2,
21D(10) KM_IRQ0,
22D(11) KM_IRQ1,
23D(12) KM_SOFTIRQ0,
24D(13) KM_SOFTIRQ1,
25D(14) KM_TYPE_NR
26};
27
28#undef D
29
30#endif /* __ASM_AVR32_KMAP_TYPES_H */ 10#endif /* __ASM_AVR32_KMAP_TYPES_H */
diff --git a/arch/avr32/include/asm/unistd.h b/arch/avr32/include/asm/unistd.h
index f714544e556..1358e366f4b 100644
--- a/arch/avr32/include/asm/unistd.h
+++ b/arch/avr32/include/asm/unistd.h
@@ -318,7 +318,6 @@
318/* SMP stuff */ 318/* SMP stuff */
319#define __IGNORE_getcpu 319#define __IGNORE_getcpu
320 320
321#define __ARCH_WANT_IPC_PARSE_VERSION
322#define __ARCH_WANT_STAT64 321#define __ARCH_WANT_STAT64
323#define __ARCH_WANT_SYS_ALARM 322#define __ARCH_WANT_SYS_ALARM
324#define __ARCH_WANT_SYS_GETHOSTNAME 323#define __ARCH_WANT_SYS_GETHOSTNAME
diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
index f7040a1e399..b92e6095861 100644
--- a/arch/avr32/mm/fault.c
+++ b/arch/avr32/mm/fault.c
@@ -61,10 +61,10 @@ asmlinkage void do_page_fault(unsigned long ecr, struct pt_regs *regs)
61 const struct exception_table_entry *fixup; 61 const struct exception_table_entry *fixup;
62 unsigned long address; 62 unsigned long address;
63 unsigned long page; 63 unsigned long page;
64 int writeaccess;
65 long signr; 64 long signr;
66 int code; 65 int code;
67 int fault; 66 int fault;
67 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
68 68
69 if (notify_page_fault(regs, ecr)) 69 if (notify_page_fault(regs, ecr))
70 return; 70 return;
@@ -86,6 +86,7 @@ asmlinkage void do_page_fault(unsigned long ecr, struct pt_regs *regs)
86 86
87 local_irq_enable(); 87 local_irq_enable();
88 88
89retry:
89 down_read(&mm->mmap_sem); 90 down_read(&mm->mmap_sem);
90 91
91 vma = find_vma(mm, address); 92 vma = find_vma(mm, address);
@@ -104,7 +105,6 @@ asmlinkage void do_page_fault(unsigned long ecr, struct pt_regs *regs)
104 */ 105 */
105good_area: 106good_area:
106 code = SEGV_ACCERR; 107 code = SEGV_ACCERR;
107 writeaccess = 0;
108 108
109 switch (ecr) { 109 switch (ecr) {
110 case ECR_PROTECTION_X: 110 case ECR_PROTECTION_X:
@@ -121,7 +121,7 @@ good_area:
121 case ECR_TLB_MISS_W: 121 case ECR_TLB_MISS_W:
122 if (!(vma->vm_flags & VM_WRITE)) 122 if (!(vma->vm_flags & VM_WRITE))
123 goto bad_area; 123 goto bad_area;
124 writeaccess = 1; 124 flags |= FAULT_FLAG_WRITE;
125 break; 125 break;
126 default: 126 default:
127 panic("Unhandled case %lu in do_page_fault!", ecr); 127 panic("Unhandled case %lu in do_page_fault!", ecr);
@@ -132,7 +132,11 @@ good_area:
132 * sure we exit gracefully rather than endlessly redo the 132 * sure we exit gracefully rather than endlessly redo the
133 * fault. 133 * fault.
134 */ 134 */
135 fault = handle_mm_fault(mm, vma, address, writeaccess ? FAULT_FLAG_WRITE : 0); 135 fault = handle_mm_fault(mm, vma, address, flags);
136
137 if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
138 return;
139
136 if (unlikely(fault & VM_FAULT_ERROR)) { 140 if (unlikely(fault & VM_FAULT_ERROR)) {
137 if (fault & VM_FAULT_OOM) 141 if (fault & VM_FAULT_OOM)
138 goto out_of_memory; 142 goto out_of_memory;
@@ -140,10 +144,23 @@ good_area:
140 goto do_sigbus; 144 goto do_sigbus;
141 BUG(); 145 BUG();
142 } 146 }
143 if (fault & VM_FAULT_MAJOR) 147
144 tsk->maj_flt++; 148 if (flags & FAULT_FLAG_ALLOW_RETRY) {
145 else 149 if (fault & VM_FAULT_MAJOR)
146 tsk->min_flt++; 150 tsk->maj_flt++;
151 else
152 tsk->min_flt++;
153 if (fault & VM_FAULT_RETRY) {
154 flags &= ~FAULT_FLAG_ALLOW_RETRY;
155
156 /*
157 * No need to up_read(&mm->mmap_sem) as we would have
158 * already released it in __lock_page_or_retry() in
159 * mm/filemap.c.
160 */
161 goto retry;
162 }
163 }
147 164
148 up_read(&mm->mmap_sem); 165 up_read(&mm->mmap_sem);
149 return; 166 return;
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index fef96f47876..f3486192063 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -33,6 +33,7 @@ config BLACKFIN
33 select HAVE_PERF_EVENTS 33 select HAVE_PERF_EVENTS
34 select ARCH_HAVE_CUSTOM_GPIO_H 34 select ARCH_HAVE_CUSTOM_GPIO_H
35 select ARCH_WANT_OPTIONAL_GPIOLIB 35 select ARCH_WANT_OPTIONAL_GPIOLIB
36 select ARCH_WANT_IPC_PARSE_VERSION
36 select HAVE_GENERIC_HARDIRQS 37 select HAVE_GENERIC_HARDIRQS
37 select GENERIC_ATOMIC64 38 select GENERIC_ATOMIC64
38 select GENERIC_IRQ_PROBE 39 select GENERIC_IRQ_PROBE
@@ -352,6 +353,11 @@ config MEM_MT48H32M16LFCJ_75
352 depends on (BFIN526_EZBRD) 353 depends on (BFIN526_EZBRD)
353 default y 354 default y
354 355
356config MEM_MT47H64M16
357 bool
358 depends on (BFIN609_EZKIT)
359 default y
360
355source "arch/blackfin/mach-bf518/Kconfig" 361source "arch/blackfin/mach-bf518/Kconfig"
356source "arch/blackfin/mach-bf527/Kconfig" 362source "arch/blackfin/mach-bf527/Kconfig"
357source "arch/blackfin/mach-bf533/Kconfig" 363source "arch/blackfin/mach-bf533/Kconfig"
@@ -399,8 +405,9 @@ config ROM_BASE
399 hex "Kernel ROM Base" 405 hex "Kernel ROM Base"
400 depends on ROMKERNEL 406 depends on ROMKERNEL
401 default "0x20040040" 407 default "0x20040040"
402 range 0x20000000 0x20400000 if !(BF54x || BF561) 408 range 0x20000000 0x20400000 if !(BF54x || BF561 || BF60x)
403 range 0x20000000 0x30000000 if (BF54x || BF561) 409 range 0x20000000 0x30000000 if (BF54x || BF561)
410 range 0xB0000000 0xC0000000 if (BF60x)
404 help 411 help
405 Make sure your ROM base does not include any file-header 412 Make sure your ROM base does not include any file-header
406 information that is prepended to the kernel. 413 information that is prepended to the kernel.
@@ -996,19 +1003,15 @@ config BFIN_GPTIMERS
996 To compile this driver as a module, choose M here: the module 1003 To compile this driver as a module, choose M here: the module
997 will be called gptimers. 1004 will be called gptimers.
998 1005
999config HAVE_PWM
1000 tristate "Enable PWM API support"
1001 depends on BFIN_GPTIMERS
1002 help
1003 Enable support for the Pulse Width Modulation framework (as
1004 found in linux/pwm.h).
1005
1006 To compile this driver as a module, choose M here: the module
1007 will be called pwm.
1008
1009choice 1006choice
1010 prompt "Uncached DMA region" 1007 prompt "Uncached DMA region"
1011 default DMA_UNCACHED_1M 1008 default DMA_UNCACHED_1M
1009config DMA_UNCACHED_32M
1010 bool "Enable 32M DMA region"
1011config DMA_UNCACHED_16M
1012 bool "Enable 16M DMA region"
1013config DMA_UNCACHED_8M
1014 bool "Enable 8M DMA region"
1012config DMA_UNCACHED_4M 1015config DMA_UNCACHED_4M
1013 bool "Enable 4M DMA region" 1016 bool "Enable 4M DMA region"
1014config DMA_UNCACHED_2M 1017config DMA_UNCACHED_2M
@@ -1038,7 +1041,7 @@ config BFIN_EXTMEM_ICACHEABLE
1038config BFIN_L2_ICACHEABLE 1041config BFIN_L2_ICACHEABLE
1039 bool "Enable ICACHE for L2 SRAM" 1042 bool "Enable ICACHE for L2 SRAM"
1040 depends on BFIN_ICACHE 1043 depends on BFIN_ICACHE
1041 depends on BF54x || BF561 1044 depends on (BF54x || BF561 || BF60x) && !SMP
1042 default n 1045 default n
1043 1046
1044config BFIN_DCACHE 1047config BFIN_DCACHE
diff --git a/arch/blackfin/configs/BF609-EZKIT_defconfig b/arch/blackfin/configs/BF609-EZKIT_defconfig
index be9526bee4f..f4b02350e41 100644
--- a/arch/blackfin/configs/BF609-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF609-EZKIT_defconfig
@@ -90,6 +90,7 @@ CONFIG_INPUT_BFIN_ROTARY=y
90# CONFIG_SERIO is not set 90# CONFIG_SERIO is not set
91# CONFIG_LEGACY_PTYS is not set 91# CONFIG_LEGACY_PTYS is not set
92CONFIG_BFIN_SIMPLE_TIMER=m 92CONFIG_BFIN_SIMPLE_TIMER=m
93# CONFIG_BFIN_CRC is not set
93CONFIG_BFIN_LINKPORT=y 94CONFIG_BFIN_LINKPORT=y
94# CONFIG_DEVKMEM is not set 95# CONFIG_DEVKMEM is not set
95CONFIG_SERIAL_BFIN=y 96CONFIG_SERIAL_BFIN=y
@@ -153,3 +154,4 @@ CONFIG_CRYPTO_MD4=y
153CONFIG_CRYPTO_MD5=y 154CONFIG_CRYPTO_MD5=y
154CONFIG_CRYPTO_ARC4=y 155CONFIG_CRYPTO_ARC4=y
155# CONFIG_CRYPTO_ANSI_CPRNG is not set 156# CONFIG_CRYPTO_ANSI_CPRNG is not set
157CONFIG_CRYPTO_DEV_BFIN_CRC=y
diff --git a/arch/blackfin/include/asm/bfin-global.h b/arch/blackfin/include/asm/bfin-global.h
index 608be5e6d25..dc47d79287f 100644
--- a/arch/blackfin/include/asm/bfin-global.h
+++ b/arch/blackfin/include/asm/bfin-global.h
@@ -14,7 +14,13 @@
14#include <linux/linkage.h> 14#include <linux/linkage.h>
15#include <linux/types.h> 15#include <linux/types.h>
16 16
17#if defined(CONFIG_DMA_UNCACHED_4M) 17#if defined(CONFIG_DMA_UNCACHED_32M)
18# define DMA_UNCACHED_REGION (32 * 1024 * 1024)
19#elif defined(CONFIG_DMA_UNCACHED_16M)
20# define DMA_UNCACHED_REGION (16 * 1024 * 1024)
21#elif defined(CONFIG_DMA_UNCACHED_8M)
22# define DMA_UNCACHED_REGION (8 * 1024 * 1024)
23#elif defined(CONFIG_DMA_UNCACHED_4M)
18# define DMA_UNCACHED_REGION (4 * 1024 * 1024) 24# define DMA_UNCACHED_REGION (4 * 1024 * 1024)
19#elif defined(CONFIG_DMA_UNCACHED_2M) 25#elif defined(CONFIG_DMA_UNCACHED_2M)
20# define DMA_UNCACHED_REGION (2 * 1024 * 1024) 26# define DMA_UNCACHED_REGION (2 * 1024 * 1024)
diff --git a/arch/blackfin/include/asm/bfin_crc.h b/arch/blackfin/include/asm/bfin_crc.h
index 3deb4452cee..75cef4dc85a 100644
--- a/arch/blackfin/include/asm/bfin_crc.h
+++ b/arch/blackfin/include/asm/bfin_crc.h
@@ -79,20 +79,6 @@ struct crc_register {
79 u32 revid; 79 u32 revid;
80}; 80};
81 81
82struct bfin_crc {
83 struct miscdevice mdev;
84 struct list_head list;
85 int irq;
86 int dma_ch_src;
87 int dma_ch_dest;
88 volatile struct crc_register *regs;
89 struct crc_info *info;
90 struct mutex mutex;
91 struct completion c;
92 unsigned short opmode;
93 char name[20];
94};
95
96/* CRC_STATUS Masks */ 82/* CRC_STATUS Masks */
97#define CMPERR 0x00000002 /* Compare error */ 83#define CMPERR 0x00000002 /* Compare error */
98#define DCNTEXP 0x00000010 /* datacnt register expired */ 84#define DCNTEXP 0x00000010 /* datacnt register expired */
diff --git a/arch/blackfin/include/asm/bfin_serial.h b/arch/blackfin/include/asm/bfin_serial.h
index 8597158010b..2d90d62edc9 100644
--- a/arch/blackfin/include/asm/bfin_serial.h
+++ b/arch/blackfin/include/asm/bfin_serial.h
@@ -282,7 +282,7 @@ struct bfin_uart_regs {
282#define UART_GET_GCTL(p) UART_GET_CTL(p) 282#define UART_GET_GCTL(p) UART_GET_CTL(p)
283#define UART_GET_LCR(p) UART_GET_CTL(p) 283#define UART_GET_LCR(p) UART_GET_CTL(p)
284#define UART_GET_MCR(p) UART_GET_CTL(p) 284#define UART_GET_MCR(p) UART_GET_CTL(p)
285#if ANOMALY_05001001 285#if ANOMALY_16000030
286#define UART_GET_STAT(p) \ 286#define UART_GET_STAT(p) \
287({ \ 287({ \
288 u32 __ret; \ 288 u32 __ret; \
diff --git a/arch/blackfin/include/asm/bfin_simple_timer.h b/arch/blackfin/include/asm/bfin_simple_timer.h
index aadfb1ad1fa..b2d5e733079 100644
--- a/arch/blackfin/include/asm/bfin_simple_timer.h
+++ b/arch/blackfin/include/asm/bfin_simple_timer.h
@@ -17,5 +17,11 @@
17#define BFIN_SIMPLE_TIMER_START _IO(BFIN_SIMPLE_TIMER_IOCTL_MAGIC, 6) 17#define BFIN_SIMPLE_TIMER_START _IO(BFIN_SIMPLE_TIMER_IOCTL_MAGIC, 6)
18#define BFIN_SIMPLE_TIMER_STOP _IO(BFIN_SIMPLE_TIMER_IOCTL_MAGIC, 8) 18#define BFIN_SIMPLE_TIMER_STOP _IO(BFIN_SIMPLE_TIMER_IOCTL_MAGIC, 8)
19#define BFIN_SIMPLE_TIMER_READ _IO(BFIN_SIMPLE_TIMER_IOCTL_MAGIC, 10) 19#define BFIN_SIMPLE_TIMER_READ _IO(BFIN_SIMPLE_TIMER_IOCTL_MAGIC, 10)
20#define BFIN_SIMPLE_TIMER_READ_COUNTER _IO(BFIN_SIMPLE_TIMER_IOCTL_MAGIC, 11)
21
22#define BFIN_SIMPLE_TIMER_MODE_PWM_ONESHOT 0
23#define BFIN_SIMPLE_TIMER_MODE_PWMOUT_CONT 1
24#define BFIN_SIMPLE_TIMER_MODE_WDTH_CAP 2
25#define BFIN_SIMPLE_TIMER_MODE_PWMOUT_CONT_NOIRQ 3
20 26
21#endif 27#endif
diff --git a/arch/blackfin/include/asm/bfin_twi.h b/arch/blackfin/include/asm/bfin_twi.h
index 2f3339a4762..f4a07278743 100644
--- a/arch/blackfin/include/asm/bfin_twi.h
+++ b/arch/blackfin/include/asm/bfin_twi.h
@@ -66,9 +66,9 @@ struct bfin_twi_iface {
66 66
67#define DEFINE_TWI_REG(reg_name, reg) \ 67#define DEFINE_TWI_REG(reg_name, reg) \
68static inline u16 read_##reg_name(struct bfin_twi_iface *iface) \ 68static inline u16 read_##reg_name(struct bfin_twi_iface *iface) \
69 { return iface->regs_base->reg; } \ 69 { return bfin_read16(&iface->regs_base->reg); } \
70static inline void write_##reg_name(struct bfin_twi_iface *iface, u16 v) \ 70static inline void write_##reg_name(struct bfin_twi_iface *iface, u16 v) \
71 { iface->regs_base->reg = v; } 71 { bfin_write16(&iface->regs_base->reg, v); }
72 72
73DEFINE_TWI_REG(CLKDIV, clkdiv) 73DEFINE_TWI_REG(CLKDIV, clkdiv)
74DEFINE_TWI_REG(CONTROL, control) 74DEFINE_TWI_REG(CONTROL, control)
@@ -84,7 +84,7 @@ DEFINE_TWI_REG(FIFO_CTL, fifo_ctl)
84DEFINE_TWI_REG(FIFO_STAT, fifo_stat) 84DEFINE_TWI_REG(FIFO_STAT, fifo_stat)
85DEFINE_TWI_REG(XMT_DATA8, xmt_data8) 85DEFINE_TWI_REG(XMT_DATA8, xmt_data8)
86DEFINE_TWI_REG(XMT_DATA16, xmt_data16) 86DEFINE_TWI_REG(XMT_DATA16, xmt_data16)
87#if !ANOMALY_05001001 87#if !ANOMALY_16000030
88DEFINE_TWI_REG(RCV_DATA8, rcv_data8) 88DEFINE_TWI_REG(RCV_DATA8, rcv_data8)
89DEFINE_TWI_REG(RCV_DATA16, rcv_data16) 89DEFINE_TWI_REG(RCV_DATA16, rcv_data16)
90#else 90#else
@@ -94,7 +94,7 @@ static inline u16 read_RCV_DATA8(struct bfin_twi_iface *iface)
94 unsigned long flags; 94 unsigned long flags;
95 95
96 flags = hard_local_irq_save(); 96 flags = hard_local_irq_save();
97 ret = iface->regs_base->rcv_data8; 97 ret = bfin_read16(&iface->regs_base->rcv_data8);
98 hard_local_irq_restore(flags); 98 hard_local_irq_restore(flags);
99 99
100 return ret; 100 return ret;
@@ -106,7 +106,7 @@ static inline u16 read_RCV_DATA16(struct bfin_twi_iface *iface)
106 unsigned long flags; 106 unsigned long flags;
107 107
108 flags = hard_local_irq_save(); 108 flags = hard_local_irq_save();
109 ret = iface->regs_base->rcv_data16; 109 ret = bfin_read16(&iface->regs_base->rcv_data16);
110 hard_local_irq_restore(flags); 110 hard_local_irq_restore(flags);
111 111
112 return ret; 112 return ret;
diff --git a/arch/blackfin/include/asm/context.S b/arch/blackfin/include/asm/context.S
index 1f9060395a0..507e7aa6a56 100644
--- a/arch/blackfin/include/asm/context.S
+++ b/arch/blackfin/include/asm/context.S
@@ -396,3 +396,12 @@
396 call \func; 396 call \func;
397#endif 397#endif
398.endm 398.endm
399
400#if defined(CONFIG_BFIN_SCRATCH_REG_RETN)
401# define EX_SCRATCH_REG RETN
402#elif defined(CONFIG_BFIN_SCRATCH_REG_RETE)
403# define EX_SCRATCH_REG RETE
404#else
405# define EX_SCRATCH_REG CYCLES
406#endif
407
diff --git a/arch/blackfin/include/asm/dpmc.h b/arch/blackfin/include/asm/dpmc.h
index e91eae8330a..2673b11376f 100644
--- a/arch/blackfin/include/asm/dpmc.h
+++ b/arch/blackfin/include/asm/dpmc.h
@@ -280,7 +280,7 @@
280 PM_POP_SYNC(9) 280 PM_POP_SYNC(9)
281#endif 281#endif
282 282
283#ifdef EBIU_AMBCTL 283#ifdef EBIU_AMGCTL
284 PM_SYS_POP(9, EBIU_AMBCTL1) 284 PM_SYS_POP(9, EBIU_AMBCTL1)
285 PM_SYS_POP(8, EBIU_AMBCTL0) 285 PM_SYS_POP(8, EBIU_AMBCTL0)
286 PM_SYS_POP16(7, EBIU_AMGCTL) 286 PM_SYS_POP16(7, EBIU_AMGCTL)
diff --git a/arch/blackfin/include/asm/gpio.h b/arch/blackfin/include/asm/gpio.h
index 3d84d96f7c2..98d0133346b 100644
--- a/arch/blackfin/include/asm/gpio.h
+++ b/arch/blackfin/include/asm/gpio.h
@@ -141,6 +141,8 @@ static inline void bfin_pm_standby_restore(void)
141 141
142void bfin_gpio_pm_hibernate_restore(void); 142void bfin_gpio_pm_hibernate_restore(void);
143void bfin_gpio_pm_hibernate_suspend(void); 143void bfin_gpio_pm_hibernate_suspend(void);
144void bfin_pint_suspend(void);
145void bfin_pint_resume(void);
144 146
145# if !BFIN_GPIO_PINT 147# if !BFIN_GPIO_PINT
146int gpio_pm_wakeup_ctrl(unsigned gpio, unsigned ctrl); 148int gpio_pm_wakeup_ctrl(unsigned gpio, unsigned ctrl);
diff --git a/arch/blackfin/include/asm/irq.h b/arch/blackfin/include/asm/irq.h
index 89de539ed01..4ae1144a457 100644
--- a/arch/blackfin/include/asm/irq.h
+++ b/arch/blackfin/include/asm/irq.h
@@ -20,6 +20,16 @@
20/* SYS_IRQS and NR_IRQS are defined in <mach-bf5xx/irq.h> */ 20/* SYS_IRQS and NR_IRQS are defined in <mach-bf5xx/irq.h> */
21#include <mach/irq.h> 21#include <mach/irq.h>
22 22
23/*
24 * pm save bfin pint registers
25 */
26struct bfin_pm_pint_save {
27 u32 mask_set;
28 u32 assign;
29 u32 edge_set;
30 u32 invert_set;
31};
32
23#if ANOMALY_05000244 && defined(CONFIG_BFIN_ICACHE) 33#if ANOMALY_05000244 && defined(CONFIG_BFIN_ICACHE)
24# define NOP_PAD_ANOMALY_05000244 "nop; nop;" 34# define NOP_PAD_ANOMALY_05000244 "nop; nop;"
25#else 35#else
diff --git a/arch/blackfin/include/asm/mem_init.h b/arch/blackfin/include/asm/mem_init.h
index 237579935e2..f019e9bcefe 100644
--- a/arch/blackfin/include/asm/mem_init.h
+++ b/arch/blackfin/include/asm/mem_init.h
@@ -6,6 +6,9 @@
6 * Licensed under the GPL-2 or later. 6 * Licensed under the GPL-2 or later.
7 */ 7 */
8 8
9#ifndef __MEM_INIT_H__
10#define __MEM_INIT_H__
11
9#if defined(EBIU_SDGCTL) 12#if defined(EBIU_SDGCTL)
10#if defined(CONFIG_MEM_MT48LC16M16A2TG_75) || \ 13#if defined(CONFIG_MEM_MT48LC16M16A2TG_75) || \
11 defined(CONFIG_MEM_MT48LC64M4A2FB_7E) || \ 14 defined(CONFIG_MEM_MT48LC64M4A2FB_7E) || \
@@ -277,3 +280,212 @@
277#else 280#else
278#define PLL_BYPASS 0 281#define PLL_BYPASS 0
279#endif 282#endif
283
284#ifdef CONFIG_BF60x
285
286/* DMC status bits */
287#define IDLE 0x1
288#define MEMINITDONE 0x4
289#define SRACK 0x8
290#define PDACK 0x10
291#define DPDACK 0x20
292#define DLLCALDONE 0x2000
293#define PENDREF 0xF0000
294#define PHYRDPHASE 0xF00000
295#define PHYRDPHASE_OFFSET 20
296
297/* DMC control bits */
298#define LPDDR 0x2
299#define INIT 0x4
300#define SRREQ 0x8
301#define PDREQ 0x10
302#define DPDREQ 0x20
303#define PREC 0x40
304#define ADDRMODE 0x100
305#define RDTOWR 0xE00
306#define PPREF 0x1000
307#define DLLCAL 0x2000
308
309/* DMC DLL control bits */
310#define DLLCALRDCNT 0xFF
311#define DATACYC 0xF00
312#define DATACYC_OFFSET 8
313
314/* CGU Divisor bits */
315#define CSEL_OFFSET 0
316#define S0SEL_OFFSET 5
317#define SYSSEL_OFFSET 8
318#define S1SEL_OFFSET 13
319#define DSEL_OFFSET 16
320#define OSEL_OFFSET 22
321#define ALGN 0x20000000
322#define UPDT 0x40000000
323#define LOCK 0x80000000
324
325/* CGU Status bits */
326#define PLLEN 0x1
327#define PLLBP 0x2
328#define PLOCK 0x4
329#define CLKSALGN 0x8
330
331/* CGU Control bits */
332#define MSEL_MASK 0x7F00
333#define DF_MASK 0x1
334
335struct ddr_config {
336 u32 ddr_clk;
337 u32 dmc_ddrctl;
338 u32 dmc_ddrcfg;
339 u32 dmc_ddrtr0;
340 u32 dmc_ddrtr1;
341 u32 dmc_ddrtr2;
342 u32 dmc_ddrmr;
343 u32 dmc_ddrmr1;
344};
345
346#if defined(CONFIG_MEM_MT47H64M16)
347static struct ddr_config ddr_config_table[] __attribute__((section(".data_l1"))) = {
348 [0] = {
349 .ddr_clk = 125,
350 .dmc_ddrctl = 0x00000904,
351 .dmc_ddrcfg = 0x00000422,
352 .dmc_ddrtr0 = 0x20705212,
353 .dmc_ddrtr1 = 0x201003CF,
354 .dmc_ddrtr2 = 0x00320107,
355 .dmc_ddrmr = 0x00000422,
356 .dmc_ddrmr1 = 0x4,
357 },
358 [1] = {
359 .ddr_clk = 133,
360 .dmc_ddrctl = 0x00000904,
361 .dmc_ddrcfg = 0x00000422,
362 .dmc_ddrtr0 = 0x20806313,
363 .dmc_ddrtr1 = 0x2013040D,
364 .dmc_ddrtr2 = 0x00320108,
365 .dmc_ddrmr = 0x00000632,
366 .dmc_ddrmr1 = 0x4,
367 },
368 [2] = {
369 .ddr_clk = 150,
370 .dmc_ddrctl = 0x00000904,
371 .dmc_ddrcfg = 0x00000422,
372 .dmc_ddrtr0 = 0x20A07323,
373 .dmc_ddrtr1 = 0x20160492,
374 .dmc_ddrtr2 = 0x00320209,
375 .dmc_ddrmr = 0x00000632,
376 .dmc_ddrmr1 = 0x4,
377 },
378 [3] = {
379 .ddr_clk = 166,
380 .dmc_ddrctl = 0x00000904,
381 .dmc_ddrcfg = 0x00000422,
382 .dmc_ddrtr0 = 0x20A07323,
383 .dmc_ddrtr1 = 0x2016050E,
384 .dmc_ddrtr2 = 0x00320209,
385 .dmc_ddrmr = 0x00000632,
386 .dmc_ddrmr1 = 0x4,
387 },
388 [4] = {
389 .ddr_clk = 200,
390 .dmc_ddrctl = 0x00000904,
391 .dmc_ddrcfg = 0x00000422,
392 .dmc_ddrtr0 = 0x20a07323,
393 .dmc_ddrtr1 = 0x2016050f,
394 .dmc_ddrtr2 = 0x00320509,
395 .dmc_ddrmr = 0x00000632,
396 .dmc_ddrmr1 = 0x4,
397 },
398 [5] = {
399 .ddr_clk = 225,
400 .dmc_ddrctl = 0x00000904,
401 .dmc_ddrcfg = 0x00000422,
402 .dmc_ddrtr0 = 0x20E0A424,
403 .dmc_ddrtr1 = 0x302006DB,
404 .dmc_ddrtr2 = 0x0032020D,
405 .dmc_ddrmr = 0x00000842,
406 .dmc_ddrmr1 = 0x4,
407 },
408 [6] = {
409 .ddr_clk = 250,
410 .dmc_ddrctl = 0x00000904,
411 .dmc_ddrcfg = 0x00000422,
412 .dmc_ddrtr0 = 0x20E0A424,
413 .dmc_ddrtr1 = 0x3020079E,
414 .dmc_ddrtr2 = 0x0032020D,
415 .dmc_ddrmr = 0x00000842,
416 .dmc_ddrmr1 = 0x4,
417 },
418};
419#endif
420
421static inline void dmc_enter_self_refresh(void)
422{
423 if (bfin_read_DMC0_STAT() & MEMINITDONE) {
424 bfin_write_DMC0_CTL(bfin_read_DMC0_CTL() | SRREQ);
425 while (!(bfin_read_DMC0_STAT() & SRACK))
426 continue;
427 }
428}
429
430static inline void dmc_exit_self_refresh(void)
431{
432 if (bfin_read_DMC0_STAT() & MEMINITDONE) {
433 bfin_write_DMC0_CTL(bfin_read_DMC0_CTL() & ~SRREQ);
434 while (bfin_read_DMC0_STAT() & SRACK)
435 continue;
436 }
437}
438
439static inline void init_cgu(u32 cgu_div, u32 cgu_ctl)
440{
441 dmc_enter_self_refresh();
442
443 /* Don't set the same value of MSEL and DF to CGU_CTL */
444 if ((bfin_read32(CGU0_CTL) & (MSEL_MASK | DF_MASK))
445 != cgu_ctl) {
446 bfin_write32(CGU0_DIV, cgu_div);
447 bfin_write32(CGU0_CTL, cgu_ctl);
448 while ((bfin_read32(CGU0_STAT) & (CLKSALGN | PLLBP)) ||
449 !(bfin_read32(CGU0_STAT) & PLOCK))
450 continue;
451 }
452
453 bfin_write32(CGU0_DIV, cgu_div | UPDT);
454 while (bfin_read32(CGU0_STAT) & CLKSALGN)
455 continue;
456
457 dmc_exit_self_refresh();
458}
459
460static inline void init_dmc(u32 dmc_clk)
461{
462 int i, dlldatacycle, dll_ctl;
463
464 for (i = 0; i < 7; i++) {
465 if (ddr_config_table[i].ddr_clk == dmc_clk) {
466 bfin_write_DMC0_CFG(ddr_config_table[i].dmc_ddrcfg);
467 bfin_write_DMC0_TR0(ddr_config_table[i].dmc_ddrtr0);
468 bfin_write_DMC0_TR1(ddr_config_table[i].dmc_ddrtr1);
469 bfin_write_DMC0_TR2(ddr_config_table[i].dmc_ddrtr2);
470 bfin_write_DMC0_MR(ddr_config_table[i].dmc_ddrmr);
471 bfin_write_DMC0_EMR1(ddr_config_table[i].dmc_ddrmr1);
472 bfin_write_DMC0_CTL(ddr_config_table[i].dmc_ddrctl);
473 break;
474 }
475 }
476
477 while (!(bfin_read_DMC0_STAT() & MEMINITDONE))
478 continue;
479
480 dlldatacycle = (bfin_read_DMC0_STAT() & PHYRDPHASE) >> PHYRDPHASE_OFFSET;
481 dll_ctl = bfin_read_DMC0_DLLCTL();
482 dll_ctl &= ~DATACYC;
483 bfin_write_DMC0_DLLCTL(dll_ctl | (dlldatacycle << DATACYC_OFFSET));
484
485 while (!(bfin_read_DMC0_STAT() & DLLCALDONE))
486 continue;
487}
488#endif
489
490#endif /*__MEM_INIT_H__*/
491
diff --git a/arch/blackfin/include/asm/traps.h b/arch/blackfin/include/asm/traps.h
index 70c4e511cae..cec771b8100 100644
--- a/arch/blackfin/include/asm/traps.h
+++ b/arch/blackfin/include/asm/traps.h
@@ -125,5 +125,7 @@
125 level " for Supervisor use: Supervisor only registers, all MMRs, and Supervisor\n" \ 125 level " for Supervisor use: Supervisor only registers, all MMRs, and Supervisor\n" \
126 level " only instructions.\n" 126 level " only instructions.\n"
127 127
128extern void double_fault_c(struct pt_regs *fp);
129
128#endif /* __ASSEMBLY__ */ 130#endif /* __ASSEMBLY__ */
129#endif /* _BFIN_TRAPS_H */ 131#endif /* _BFIN_TRAPS_H */
diff --git a/arch/blackfin/include/asm/unistd.h b/arch/blackfin/include/asm/unistd.h
index 3287222cba3..5b2a0748d7d 100644
--- a/arch/blackfin/include/asm/unistd.h
+++ b/arch/blackfin/include/asm/unistd.h
@@ -434,7 +434,6 @@
434#define __IGNORE_getcpu 434#define __IGNORE_getcpu
435 435
436#ifdef __KERNEL__ 436#ifdef __KERNEL__
437#define __ARCH_WANT_IPC_PARSE_VERSION
438#define __ARCH_WANT_STAT64 437#define __ARCH_WANT_STAT64
439#define __ARCH_WANT_SYS_ALARM 438#define __ARCH_WANT_SYS_ALARM
440#define __ARCH_WANT_SYS_GETHOSTNAME 439#define __ARCH_WANT_SYS_GETHOSTNAME
diff --git a/arch/blackfin/kernel/Makefile b/arch/blackfin/kernel/Makefile
index 08e6625106b..735f24e0742 100644
--- a/arch/blackfin/kernel/Makefile
+++ b/arch/blackfin/kernel/Makefile
@@ -21,7 +21,6 @@ obj-$(CONFIG_FUNCTION_TRACER) += ftrace-entry.o
21obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o 21obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
22CFLAGS_REMOVE_ftrace.o = -pg 22CFLAGS_REMOVE_ftrace.o = -pg
23 23
24obj-$(CONFIG_HAVE_PWM) += pwm.o
25obj-$(CONFIG_IPIPE) += ipipe.o 24obj-$(CONFIG_IPIPE) += ipipe.o
26obj-$(CONFIG_BFIN_GPTIMERS) += gptimers.o 25obj-$(CONFIG_BFIN_GPTIMERS) += gptimers.o
27obj-$(CONFIG_CPLB_INFO) += cplbinfo.o 26obj-$(CONFIG_CPLB_INFO) += cplbinfo.o
diff --git a/arch/blackfin/kernel/bfin_dma.c b/arch/blackfin/kernel/bfin_dma.c
index c166939ffb2..4a32f2dd5dd 100644
--- a/arch/blackfin/kernel/bfin_dma.c
+++ b/arch/blackfin/kernel/bfin_dma.c
@@ -45,7 +45,7 @@ static int __init blackfin_dma_init(void)
45 atomic_set(&dma_ch[i].chan_status, 0); 45 atomic_set(&dma_ch[i].chan_status, 0);
46 dma_ch[i].regs = dma_io_base_addr[i]; 46 dma_ch[i].regs = dma_io_base_addr[i];
47 } 47 }
48#ifdef CH_MEM_STREAM3_SRC 48#if defined(CH_MEM_STREAM3_SRC) && defined(CONFIG_BF60x)
49 /* Mark MEMDMA Channel 3 as requested since we're using it internally */ 49 /* Mark MEMDMA Channel 3 as requested since we're using it internally */
50 request_dma(CH_MEM_STREAM3_DEST, "Blackfin dma_memcpy"); 50 request_dma(CH_MEM_STREAM3_DEST, "Blackfin dma_memcpy");
51 request_dma(CH_MEM_STREAM3_SRC, "Blackfin dma_memcpy"); 51 request_dma(CH_MEM_STREAM3_SRC, "Blackfin dma_memcpy");
@@ -361,7 +361,7 @@ void __init early_dma_memcpy_done(void)
361 __builtin_bfin_ssync(); 361 __builtin_bfin_ssync();
362} 362}
363 363
364#ifdef CH_MEM_STREAM3_SRC 364#if defined(CH_MEM_STREAM3_SRC) && defined(CONFIG_BF60x)
365#define bfin_read_MDMA_S_CONFIG bfin_read_MDMA_S3_CONFIG 365#define bfin_read_MDMA_S_CONFIG bfin_read_MDMA_S3_CONFIG
366#define bfin_write_MDMA_S_CONFIG bfin_write_MDMA_S3_CONFIG 366#define bfin_write_MDMA_S_CONFIG bfin_write_MDMA_S3_CONFIG
367#define bfin_write_MDMA_S_START_ADDR bfin_write_MDMA_S3_START_ADDR 367#define bfin_write_MDMA_S_START_ADDR bfin_write_MDMA_S3_START_ADDR
diff --git a/arch/blackfin/kernel/cplb-nompu/cplbinit.c b/arch/blackfin/kernel/cplb-nompu/cplbinit.c
index 3e366dc2d6e..34e96ce02aa 100644
--- a/arch/blackfin/kernel/cplb-nompu/cplbinit.c
+++ b/arch/blackfin/kernel/cplb-nompu/cplbinit.c
@@ -58,12 +58,20 @@ void __init generate_cplb_tables_cpu(unsigned int cpu)
58 58
59#ifdef CONFIG_ROMKERNEL 59#ifdef CONFIG_ROMKERNEL
60 /* Cover kernel XIP flash area */ 60 /* Cover kernel XIP flash area */
61#ifdef CONFIG_BF60x
62 addr = CONFIG_ROM_BASE & ~(16 * 1024 * 1024 - 1);
63 d_tbl[i_d].addr = addr;
64 d_tbl[i_d++].data = SDRAM_DGENERIC | PAGE_SIZE_16MB;
65 i_tbl[i_i].addr = addr;
66 i_tbl[i_i++].data = SDRAM_IGENERIC | PAGE_SIZE_16MB;
67#else
61 addr = CONFIG_ROM_BASE & ~(4 * 1024 * 1024 - 1); 68 addr = CONFIG_ROM_BASE & ~(4 * 1024 * 1024 - 1);
62 d_tbl[i_d].addr = addr; 69 d_tbl[i_d].addr = addr;
63 d_tbl[i_d++].data = SDRAM_DGENERIC | PAGE_SIZE_4MB; 70 d_tbl[i_d++].data = SDRAM_DGENERIC | PAGE_SIZE_4MB;
64 i_tbl[i_i].addr = addr; 71 i_tbl[i_i].addr = addr;
65 i_tbl[i_i++].data = SDRAM_IGENERIC | PAGE_SIZE_4MB; 72 i_tbl[i_i++].data = SDRAM_IGENERIC | PAGE_SIZE_4MB;
66#endif 73#endif
74#endif
67 75
68 /* Cover L1 memory. One 4M area for code and data each is enough. */ 76 /* Cover L1 memory. One 4M area for code and data each is enough. */
69 if (cpu == 0) { 77 if (cpu == 0) {
diff --git a/arch/blackfin/kernel/dma-mapping.c b/arch/blackfin/kernel/dma-mapping.c
index f0d1118f182..e7be6532d6a 100644
--- a/arch/blackfin/kernel/dma-mapping.c
+++ b/arch/blackfin/kernel/dma-mapping.c
@@ -122,12 +122,13 @@ void __dma_sync(dma_addr_t addr, size_t size,
122EXPORT_SYMBOL(__dma_sync); 122EXPORT_SYMBOL(__dma_sync);
123 123
124int 124int
125dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, 125dma_map_sg(struct device *dev, struct scatterlist *sg_list, int nents,
126 enum dma_data_direction direction) 126 enum dma_data_direction direction)
127{ 127{
128 struct scatterlist *sg;
128 int i; 129 int i;
129 130
130 for (i = 0; i < nents; i++, sg++) { 131 for_each_sg(sg_list, sg, nents, i) {
131 sg->dma_address = (dma_addr_t) sg_virt(sg); 132 sg->dma_address = (dma_addr_t) sg_virt(sg);
132 __dma_sync(sg_dma_address(sg), sg_dma_len(sg), direction); 133 __dma_sync(sg_dma_address(sg), sg_dma_len(sg), direction);
133 } 134 }
@@ -136,12 +137,13 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
136} 137}
137EXPORT_SYMBOL(dma_map_sg); 138EXPORT_SYMBOL(dma_map_sg);
138 139
139void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, 140void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg_list,
140 int nelems, enum dma_data_direction direction) 141 int nelems, enum dma_data_direction direction)
141{ 142{
143 struct scatterlist *sg;
142 int i; 144 int i;
143 145
144 for (i = 0; i < nelems; i++, sg++) { 146 for_each_sg(sg_list, sg, nelems, i) {
145 sg->dma_address = (dma_addr_t) sg_virt(sg); 147 sg->dma_address = (dma_addr_t) sg_virt(sg);
146 __dma_sync(sg_dma_address(sg), sg_dma_len(sg), direction); 148 __dma_sync(sg_dma_address(sg), sg_dma_len(sg), direction);
147 } 149 }
diff --git a/arch/blackfin/kernel/pwm.c b/arch/blackfin/kernel/pwm.c
deleted file mode 100644
index 33f5942733b..00000000000
--- a/arch/blackfin/kernel/pwm.c
+++ /dev/null
@@ -1,100 +0,0 @@
1/*
2 * Blackfin Pulse Width Modulation (PWM) core
3 *
4 * Copyright (c) 2011 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#include <linux/module.h>
10#include <linux/pwm.h>
11#include <linux/slab.h>
12
13#include <asm/gptimers.h>
14#include <asm/portmux.h>
15
16struct pwm_device {
17 unsigned id;
18 unsigned short pin;
19};
20
21static const unsigned short pwm_to_gptimer_per[] = {
22 P_TMR0, P_TMR1, P_TMR2, P_TMR3, P_TMR4, P_TMR5,
23 P_TMR6, P_TMR7, P_TMR8, P_TMR9, P_TMR10, P_TMR11,
24};
25
26struct pwm_device *pwm_request(int pwm_id, const char *label)
27{
28 struct pwm_device *pwm;
29 int ret;
30
31 /* XXX: pwm_id really should be unsigned */
32 if (pwm_id < 0)
33 return NULL;
34
35 pwm = kzalloc(sizeof(*pwm), GFP_KERNEL);
36 if (!pwm)
37 return pwm;
38
39 pwm->id = pwm_id;
40 if (pwm->id >= ARRAY_SIZE(pwm_to_gptimer_per))
41 goto err;
42
43 pwm->pin = pwm_to_gptimer_per[pwm->id];
44 ret = peripheral_request(pwm->pin, label);
45 if (ret)
46 goto err;
47
48 return pwm;
49 err:
50 kfree(pwm);
51 return NULL;
52}
53EXPORT_SYMBOL(pwm_request);
54
55void pwm_free(struct pwm_device *pwm)
56{
57 peripheral_free(pwm->pin);
58 kfree(pwm);
59}
60EXPORT_SYMBOL(pwm_free);
61
62int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
63{
64 unsigned long period, duty;
65 unsigned long long val;
66
67 if (duty_ns < 0 || duty_ns > period_ns)
68 return -EINVAL;
69
70 val = (unsigned long long)get_sclk() * period_ns;
71 do_div(val, NSEC_PER_SEC);
72 period = val;
73
74 val = (unsigned long long)period * duty_ns;
75 do_div(val, period_ns);
76 duty = period - val;
77
78 if (duty >= period)
79 duty = period - 1;
80
81 set_gptimer_config(pwm->id, TIMER_MODE_PWM | TIMER_PERIOD_CNT);
82 set_gptimer_pwidth(pwm->id, duty);
83 set_gptimer_period(pwm->id, period);
84
85 return 0;
86}
87EXPORT_SYMBOL(pwm_config);
88
89int pwm_enable(struct pwm_device *pwm)
90{
91 enable_gptimer(pwm->id);
92 return 0;
93}
94EXPORT_SYMBOL(pwm_enable);
95
96void pwm_disable(struct pwm_device *pwm)
97{
98 disable_gptimer(pwm->id);
99}
100EXPORT_SYMBOL(pwm_disable);
diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c
index ada8f0fc71e..fb96e607adc 100644
--- a/arch/blackfin/kernel/setup.c
+++ b/arch/blackfin/kernel/setup.c
@@ -52,7 +52,6 @@ EXPORT_SYMBOL(reserved_mem_dcache_on);
52#ifdef CONFIG_MTD_UCLINUX 52#ifdef CONFIG_MTD_UCLINUX
53extern struct map_info uclinux_ram_map; 53extern struct map_info uclinux_ram_map;
54unsigned long memory_mtd_end, memory_mtd_start, mtd_size; 54unsigned long memory_mtd_end, memory_mtd_start, mtd_size;
55unsigned long _ebss;
56EXPORT_SYMBOL(memory_mtd_end); 55EXPORT_SYMBOL(memory_mtd_end);
57EXPORT_SYMBOL(memory_mtd_start); 56EXPORT_SYMBOL(memory_mtd_start);
58EXPORT_SYMBOL(mtd_size); 57EXPORT_SYMBOL(mtd_size);
diff --git a/arch/blackfin/mach-bf527/boards/ezkit.c b/arch/blackfin/mach-bf527/boards/ezkit.c
index af732eb3a68..fc179ca0779 100644
--- a/arch/blackfin/mach-bf527/boards/ezkit.c
+++ b/arch/blackfin/mach-bf527/boards/ezkit.c
@@ -114,9 +114,9 @@ static struct musb_hdrc_config musb_config = {
114}; 114};
115 115
116static struct musb_hdrc_platform_data musb_plat = { 116static struct musb_hdrc_platform_data musb_plat = {
117#if defined(CONFIG_USB_MUSB_OTG) 117#if defined(CONFIG_USB_MUSB_HDRC) && defined(CONFIG_USB_GADGET_MUSB_HDRC)
118 .mode = MUSB_OTG, 118 .mode = MUSB_OTG,
119#elif defined(CONFIG_USB_MUSB_HDRC_HCD) 119#elif defined(CONFIG_USB_MUSB_HDRC)
120 .mode = MUSB_HOST, 120 .mode = MUSB_HOST,
121#elif defined(CONFIG_USB_GADGET_MUSB_HDRC) 121#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
122 .mode = MUSB_PERIPHERAL, 122 .mode = MUSB_PERIPHERAL,
diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c
index c9d9473a5ab..5ed654ae66e 100644
--- a/arch/blackfin/mach-bf537/boards/stamp.c
+++ b/arch/blackfin/mach-bf537/boards/stamp.c
@@ -873,7 +873,7 @@ static struct adf702x_platform_data adf7021_platform_data = {
873}; 873};
874static inline void adf702x_mac_init(void) 874static inline void adf702x_mac_init(void)
875{ 875{
876 random_ether_addr(adf7021_platform_data.mac_addr); 876 eth_random_addr(adf7021_platform_data.mac_addr);
877} 877}
878#else 878#else
879static inline void adf702x_mac_init(void) {} 879static inline void adf702x_mac_init(void) {}
diff --git a/arch/blackfin/mach-bf548/boards/ezkit.c b/arch/blackfin/mach-bf548/boards/ezkit.c
index 3bd75bae750..c4d07f04094 100644
--- a/arch/blackfin/mach-bf548/boards/ezkit.c
+++ b/arch/blackfin/mach-bf548/boards/ezkit.c
@@ -635,9 +635,9 @@ static struct musb_hdrc_config musb_config = {
635}; 635};
636 636
637static struct musb_hdrc_platform_data musb_plat = { 637static struct musb_hdrc_platform_data musb_plat = {
638#if defined(CONFIG_USB_MUSB_OTG) 638#if defined(CONFIG_USB_MUSB_HDRC) && defined(CONFIG_USB_GADGET_MUSB_HDRC)
639 .mode = MUSB_OTG, 639 .mode = MUSB_OTG,
640#elif defined(CONFIG_USB_MUSB_HDRC_HCD) 640#elif defined(CONFIG_USB_MUSB_HDRC)
641 .mode = MUSB_HOST, 641 .mode = MUSB_HOST,
642#elif defined(CONFIG_USB_GADGET_MUSB_HDRC) 642#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
643 .mode = MUSB_PERIPHERAL, 643 .mode = MUSB_PERIPHERAL,
diff --git a/arch/blackfin/mach-bf548/include/mach/gpio.h b/arch/blackfin/mach-bf548/include/mach/gpio.h
index 35c8ced4615..be9edb28f96 100644
--- a/arch/blackfin/mach-bf548/include/mach/gpio.h
+++ b/arch/blackfin/mach-bf548/include/mach/gpio.h
@@ -171,6 +171,8 @@
171#define MAX_BLACKFIN_GPIOS 160 171#define MAX_BLACKFIN_GPIOS 160
172 172
173#define BFIN_GPIO_PINT 1 173#define BFIN_GPIO_PINT 1
174#define NR_PINT_SYS_IRQS 4
175#define NR_PINTS 160
174 176
175#ifndef __ASSEMBLY__ 177#ifndef __ASSEMBLY__
176 178
diff --git a/arch/blackfin/mach-bf561/boards/ezkit.c b/arch/blackfin/mach-bf561/boards/ezkit.c
index 838978808a1..7c36777c645 100644
--- a/arch/blackfin/mach-bf561/boards/ezkit.c
+++ b/arch/blackfin/mach-bf561/boards/ezkit.c
@@ -452,18 +452,21 @@ static struct v4l2_input adv7183_inputs[] = {
452 .name = "Composite", 452 .name = "Composite",
453 .type = V4L2_INPUT_TYPE_CAMERA, 453 .type = V4L2_INPUT_TYPE_CAMERA,
454 .std = V4L2_STD_ALL, 454 .std = V4L2_STD_ALL,
455 .capabilities = V4L2_IN_CAP_STD,
455 }, 456 },
456 { 457 {
457 .index = 1, 458 .index = 1,
458 .name = "S-Video", 459 .name = "S-Video",
459 .type = V4L2_INPUT_TYPE_CAMERA, 460 .type = V4L2_INPUT_TYPE_CAMERA,
460 .std = V4L2_STD_ALL, 461 .std = V4L2_STD_ALL,
462 .capabilities = V4L2_IN_CAP_STD,
461 }, 463 },
462 { 464 {
463 .index = 2, 465 .index = 2,
464 .name = "Component", 466 .name = "Component",
465 .type = V4L2_INPUT_TYPE_CAMERA, 467 .type = V4L2_INPUT_TYPE_CAMERA,
466 .std = V4L2_STD_ALL, 468 .std = V4L2_STD_ALL,
469 .capabilities = V4L2_IN_CAP_STD,
467 }, 470 },
468}; 471};
469 472
diff --git a/arch/blackfin/mach-bf609/Kconfig b/arch/blackfin/mach-bf609/Kconfig
index 2cb72724377..101b33ee9bb 100644
--- a/arch/blackfin/mach-bf609/Kconfig
+++ b/arch/blackfin/mach-bf609/Kconfig
@@ -51,6 +51,14 @@ config PINT5_ASSIGN
51 51
52endmenu 52endmenu
53 53
54config SEC_IRQ_PRIORITY_LEVELS
55 int "SEC interrupt priority levels"
56 default 7
57 range 0 7
58 help
59 Devide the total number of interrupt priority levels into sub-levels.
60 There is 2 ^ (SEC_IRQ_PRIORITY_LEVELS + 1) different levels.
61
54endmenu 62endmenu
55 63
56endif 64endif
diff --git a/arch/blackfin/mach-bf609/Makefile b/arch/blackfin/mach-bf609/Makefile
index 2a27f817454..234fe1b4bb0 100644
--- a/arch/blackfin/mach-bf609/Makefile
+++ b/arch/blackfin/mach-bf609/Makefile
@@ -2,5 +2,5 @@
2# arch/blackfin/mach-bf609/Makefile 2# arch/blackfin/mach-bf609/Makefile
3# 3#
4 4
5obj-y := dma.o clock.o 5obj-y := dma.o clock.o ints-priority.o
6obj-$(CONFIG_PM) += pm.o hibernate.o 6obj-$(CONFIG_PM) += pm.o dpm.o
diff --git a/arch/blackfin/mach-bf609/boards/ezkit.c b/arch/blackfin/mach-bf609/boards/ezkit.c
index ac64f47217c..c2cf1ae3118 100644
--- a/arch/blackfin/mach-bf609/boards/ezkit.c
+++ b/arch/blackfin/mach-bf609/boards/ezkit.c
@@ -677,11 +677,28 @@ int bf609_nor_flash_init(struct platform_device *dev)
677 return 0; 677 return 0;
678} 678}
679 679
680void bf609_nor_flash_exit(struct platform_device *dev)
681{
682 const unsigned short pins[] = {
683 P_A3, P_A4, P_A5, P_A6, P_A7, P_A8, P_A9, P_A10, P_A11, P_A12,
684 P_A13, P_A14, P_A15, P_A16, P_A17, P_A18, P_A19, P_A20, P_A21,
685 P_A22, P_A23, P_A24, P_A25, P_NORCK, 0,
686 };
687
688 peripheral_free_list(pins);
689
690 bfin_write32(SMC_GCTL, 0);
691}
692
680static struct physmap_flash_data ezkit_flash_data = { 693static struct physmap_flash_data ezkit_flash_data = {
681 .width = 2, 694 .width = 2,
682 .parts = ezkit_partitions, 695 .parts = ezkit_partitions,
683 .init = bf609_nor_flash_init, 696 .init = bf609_nor_flash_init,
697 .exit = bf609_nor_flash_exit,
684 .nr_parts = ARRAY_SIZE(ezkit_partitions), 698 .nr_parts = ARRAY_SIZE(ezkit_partitions),
699#ifdef CONFIG_ROMKERNEL
700 .probe_type = "map_rom",
701#endif
685}; 702};
686 703
687static struct resource ezkit_flash_resource = { 704static struct resource ezkit_flash_resource = {
@@ -739,7 +756,7 @@ static struct bfin6xx_spi_chip spidev_chip_info = {
739}; 756};
740#endif 757#endif
741 758
742#if defined(CONFIG_SND_BF6XX_I2S) || defined(CONFIG_SND_BF6XX_I2S_MODULE) 759#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
743static struct platform_device bfin_i2s_pcm = { 760static struct platform_device bfin_i2s_pcm = {
744 .name = "bfin-i2s-pcm-audio", 761 .name = "bfin-i2s-pcm-audio",
745 .id = -1, 762 .id = -1,
@@ -825,6 +842,12 @@ static struct adau1761_platform_data adau1761_info = {
825static const unsigned short ppi_req[] = { 842static const unsigned short ppi_req[] = {
826 P_PPI0_D0, P_PPI0_D1, P_PPI0_D2, P_PPI0_D3, 843 P_PPI0_D0, P_PPI0_D1, P_PPI0_D2, P_PPI0_D3,
827 P_PPI0_D4, P_PPI0_D5, P_PPI0_D6, P_PPI0_D7, 844 P_PPI0_D4, P_PPI0_D5, P_PPI0_D6, P_PPI0_D7,
845 P_PPI0_D8, P_PPI0_D9, P_PPI0_D10, P_PPI0_D11,
846 P_PPI0_D12, P_PPI0_D13, P_PPI0_D14, P_PPI0_D15,
847#if !defined(CONFIG_VIDEO_VS6624) && !defined(CONFIG_VIDEO_VS6624_MODULE)
848 P_PPI0_D16, P_PPI0_D17, P_PPI0_D18, P_PPI0_D19,
849 P_PPI0_D20, P_PPI0_D21, P_PPI0_D22, P_PPI0_D23,
850#endif
828 P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2, 851 P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
829 0, 852 0,
830}; 853};
@@ -855,7 +878,7 @@ static struct bcap_route vs6624_routes[] = {
855 }, 878 },
856}; 879};
857 880
858static const unsigned vs6624_ce_pin = GPIO_PD1; 881static const unsigned vs6624_ce_pin = GPIO_PE4;
859 882
860static struct bfin_capture_config bfin_capture_data = { 883static struct bfin_capture_config bfin_capture_data = {
861 .card_name = "BF609", 884 .card_name = "BF609",
@@ -871,7 +894,128 @@ static struct bfin_capture_config bfin_capture_data = {
871 .ppi_info = &ppi_info, 894 .ppi_info = &ppi_info,
872 .ppi_control = (PACK_EN | DLEN_8 | EPPI_CTL_FS1HI_FS2HI 895 .ppi_control = (PACK_EN | DLEN_8 | EPPI_CTL_FS1HI_FS2HI
873 | EPPI_CTL_POLC3 | EPPI_CTL_SYNC2 | EPPI_CTL_NON656), 896 | EPPI_CTL_POLC3 | EPPI_CTL_SYNC2 | EPPI_CTL_NON656),
874 .blank_clocks = 8, 897 .blank_pixels = 4,
898};
899#endif
900
901#if defined(CONFIG_VIDEO_ADV7842) \
902 || defined(CONFIG_VIDEO_ADV7842_MODULE)
903#include <media/adv7842.h>
904
905static struct v4l2_input adv7842_inputs[] = {
906 {
907 .index = 0,
908 .name = "Composite",
909 .type = V4L2_INPUT_TYPE_CAMERA,
910 .std = V4L2_STD_ALL,
911 .capabilities = V4L2_IN_CAP_STD,
912 },
913 {
914 .index = 1,
915 .name = "S-Video",
916 .type = V4L2_INPUT_TYPE_CAMERA,
917 .std = V4L2_STD_ALL,
918 .capabilities = V4L2_IN_CAP_STD,
919 },
920 {
921 .index = 2,
922 .name = "Component",
923 .type = V4L2_INPUT_TYPE_CAMERA,
924 .capabilities = V4L2_IN_CAP_CUSTOM_TIMINGS,
925 },
926 {
927 .index = 3,
928 .name = "VGA",
929 .type = V4L2_INPUT_TYPE_CAMERA,
930 .capabilities = V4L2_IN_CAP_CUSTOM_TIMINGS,
931 },
932 {
933 .index = 4,
934 .name = "HDMI",
935 .type = V4L2_INPUT_TYPE_CAMERA,
936 .capabilities = V4L2_IN_CAP_CUSTOM_TIMINGS,
937 },
938};
939
940static struct bcap_route adv7842_routes[] = {
941 {
942 .input = 3,
943 .output = 0,
944 .ppi_control = (PACK_EN | DLEN_8 | EPPI_CTL_FLDSEL
945 | EPPI_CTL_ACTIVE656),
946 },
947 {
948 .input = 4,
949 .output = 0,
950 },
951 {
952 .input = 2,
953 .output = 0,
954 },
955 {
956 .input = 1,
957 .output = 0,
958 },
959 {
960 .input = 0,
961 .output = 1,
962 .ppi_control = (EPPI_CTL_SPLTWRD | PACK_EN | DLEN_16
963 | EPPI_CTL_FS1LO_FS2LO | EPPI_CTL_POLC2
964 | EPPI_CTL_SYNC2 | EPPI_CTL_NON656),
965 },
966};
967
968static struct adv7842_output_format adv7842_opf[] = {
969 {
970 .op_ch_sel = ADV7842_OP_CH_SEL_BRG,
971 .op_format_sel = ADV7842_OP_FORMAT_SEL_SDR_ITU656_8,
972 .op_656_range = 1,
973 .blank_data = 1,
974 .insert_av_codes = 1,
975 },
976 {
977 .op_ch_sel = ADV7842_OP_CH_SEL_RGB,
978 .op_format_sel = ADV7842_OP_FORMAT_SEL_SDR_ITU656_16,
979 .op_656_range = 1,
980 .blank_data = 1,
981 },
982};
983
984static struct adv7842_platform_data adv7842_data = {
985 .opf = adv7842_opf,
986 .num_opf = ARRAY_SIZE(adv7842_opf),
987 .ain_sel = ADV7842_AIN10_11_12_NC_SYNC_4_1,
988 .prim_mode = ADV7842_PRIM_MODE_SDP,
989 .vid_std_select = ADV7842_SDP_VID_STD_CVBS_SD_4x1,
990 .inp_color_space = ADV7842_INP_COLOR_SPACE_AUTO,
991 .i2c_sdp_io = 0x40,
992 .i2c_sdp = 0x41,
993 .i2c_cp = 0x42,
994 .i2c_vdp = 0x43,
995 .i2c_afe = 0x44,
996 .i2c_hdmi = 0x45,
997 .i2c_repeater = 0x46,
998 .i2c_edid = 0x47,
999 .i2c_infoframe = 0x48,
1000 .i2c_cec = 0x49,
1001 .i2c_avlink = 0x4a,
1002 .i2c_ex = 0x26,
1003};
1004
1005static struct bfin_capture_config bfin_capture_data = {
1006 .card_name = "BF609",
1007 .inputs = adv7842_inputs,
1008 .num_inputs = ARRAY_SIZE(adv7842_inputs),
1009 .routes = adv7842_routes,
1010 .i2c_adapter_id = 0,
1011 .board_info = {
1012 .type = "adv7842",
1013 .addr = 0x20,
1014 .platform_data = (void *)&adv7842_data,
1015 },
1016 .ppi_info = &ppi_info,
1017 .ppi_control = (PACK_EN | DLEN_8 | EPPI_CTL_FLDSEL
1018 | EPPI_CTL_ACTIVE656),
875}; 1019};
876#endif 1020#endif
877 1021
@@ -883,6 +1027,80 @@ static struct platform_device bfin_capture_device = {
883}; 1027};
884#endif 1028#endif
885 1029
1030#if defined(CONFIG_VIDEO_BLACKFIN_DISPLAY) \
1031 || defined(CONFIG_VIDEO_BLACKFIN_DISPLAY_MODULE)
1032#include <linux/videodev2.h>
1033#include <media/blackfin/bfin_display.h>
1034#include <media/blackfin/ppi.h>
1035
1036static const unsigned short ppi_req_disp[] = {
1037 P_PPI0_D0, P_PPI0_D1, P_PPI0_D2, P_PPI0_D3,
1038 P_PPI0_D4, P_PPI0_D5, P_PPI0_D6, P_PPI0_D7,
1039 P_PPI0_D8, P_PPI0_D9, P_PPI0_D10, P_PPI0_D11,
1040 P_PPI0_D12, P_PPI0_D13, P_PPI0_D14, P_PPI0_D15,
1041 P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
1042 0,
1043};
1044
1045static const struct ppi_info ppi_info = {
1046 .type = PPI_TYPE_EPPI3,
1047 .dma_ch = CH_EPPI0_CH0,
1048 .irq_err = IRQ_EPPI0_STAT,
1049 .base = (void __iomem *)EPPI0_STAT,
1050 .pin_req = ppi_req_disp,
1051};
1052
1053#if defined(CONFIG_VIDEO_ADV7511) \
1054 || defined(CONFIG_VIDEO_ADV7511_MODULE)
1055#include <media/adv7511.h>
1056
1057static struct v4l2_output adv7511_outputs[] = {
1058 {
1059 .index = 0,
1060 .name = "HDMI",
1061 .type = V4L2_INPUT_TYPE_CAMERA,
1062 .capabilities = V4L2_OUT_CAP_CUSTOM_TIMINGS,
1063 },
1064};
1065
1066static struct disp_route adv7511_routes[] = {
1067 {
1068 .output = 0,
1069 },
1070};
1071
1072static struct adv7511_platform_data adv7511_data = {
1073 .edid_addr = 0x7e,
1074 .i2c_ex = 0x25,
1075};
1076
1077static struct bfin_display_config bfin_display_data = {
1078 .card_name = "BF609",
1079 .outputs = adv7511_outputs,
1080 .num_outputs = ARRAY_SIZE(adv7511_outputs),
1081 .routes = adv7511_routes,
1082 .i2c_adapter_id = 0,
1083 .board_info = {
1084 .type = "adv7511",
1085 .addr = 0x39,
1086 .platform_data = (void *)&adv7511_data,
1087 },
1088 .ppi_info = &ppi_info,
1089 .ppi_control = (EPPI_CTL_SPLTWRD | PACK_EN | DLEN_16
1090 | EPPI_CTL_FS1LO_FS2LO | EPPI_CTL_POLC3
1091 | EPPI_CTL_IFSGEN | EPPI_CTL_SYNC2
1092 | EPPI_CTL_NON656 | EPPI_CTL_DIR),
1093};
1094#endif
1095
1096static struct platform_device bfin_display_device = {
1097 .name = "bfin_display",
1098 .dev = {
1099 .platform_data = &bfin_display_data,
1100 },
1101};
1102#endif
1103
886#if defined(CONFIG_BFIN_CRC) 1104#if defined(CONFIG_BFIN_CRC)
887#define BFIN_CRC_NAME "bfin-crc" 1105#define BFIN_CRC_NAME "bfin-crc"
888 1106
@@ -947,6 +1165,39 @@ static struct platform_device bfin_crc1_device = {
947}; 1165};
948#endif 1166#endif
949 1167
1168#if defined(CONFIG_CRYPTO_DEV_BFIN_CRC)
1169#define BFIN_CRYPTO_CRC_NAME "bfin-hmac-crc"
1170#define BFIN_CRYPTO_CRC_POLY_DATA 0x5c5c5c5c
1171
1172static struct resource bfin_crypto_crc_resources[] = {
1173 {
1174 .start = REG_CRC0_CTL,
1175 .end = REG_CRC0_REVID+4,
1176 .flags = IORESOURCE_MEM,
1177 },
1178 {
1179 .start = IRQ_CRC0_DCNTEXP,
1180 .end = IRQ_CRC0_DCNTEXP,
1181 .flags = IORESOURCE_IRQ,
1182 },
1183 {
1184 .start = CH_MEM_STREAM0_SRC_CRC0,
1185 .end = CH_MEM_STREAM0_SRC_CRC0,
1186 .flags = IORESOURCE_DMA,
1187 },
1188};
1189
1190static struct platform_device bfin_crypto_crc_device = {
1191 .name = BFIN_CRYPTO_CRC_NAME,
1192 .id = 0,
1193 .num_resources = ARRAY_SIZE(bfin_crypto_crc_resources),
1194 .resource = bfin_crypto_crc_resources,
1195 .dev = {
1196 .platform_data = (void *)BFIN_CRYPTO_CRC_POLY_DATA,
1197 },
1198};
1199#endif
1200
950#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 1201#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
951static const struct ad7877_platform_data bfin_ad7877_ts_info = { 1202static const struct ad7877_platform_data bfin_ad7877_ts_info = {
952 .model = 7877, 1203 .model = 7877,
@@ -963,6 +1214,28 @@ static const struct ad7877_platform_data bfin_ad7877_ts_info = {
963}; 1214};
964#endif 1215#endif
965 1216
1217#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
1218#include <linux/input.h>
1219#include <linux/gpio_keys.h>
1220
1221static struct gpio_keys_button bfin_gpio_keys_table[] = {
1222 {BTN_0, GPIO_PB10, 1, "gpio-keys: BTN0"},
1223 {BTN_1, GPIO_PE1, 1, "gpio-keys: BTN1"},
1224};
1225
1226static struct gpio_keys_platform_data bfin_gpio_keys_data = {
1227 .buttons = bfin_gpio_keys_table,
1228 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
1229};
1230
1231static struct platform_device bfin_device_gpiokeys = {
1232 .name = "gpio-keys",
1233 .dev = {
1234 .platform_data = &bfin_gpio_keys_data,
1235 },
1236};
1237#endif
1238
966static struct spi_board_info bfin_spi_board_info[] __initdata = { 1239static struct spi_board_info bfin_spi_board_info[] __initdata = {
967#if defined(CONFIG_MTD_M25P80) \ 1240#if defined(CONFIG_MTD_M25P80) \
968 || defined(CONFIG_MTD_M25P80_MODULE) 1241 || defined(CONFIG_MTD_M25P80_MODULE)
@@ -981,10 +1254,10 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
981 { 1254 {
982 .modalias = "ad7877", 1255 .modalias = "ad7877",
983 .platform_data = &bfin_ad7877_ts_info, 1256 .platform_data = &bfin_ad7877_ts_info,
984 .irq = IRQ_PB4, /* old boards (<=Rev 1.3) use IRQ_PJ11 */ 1257 .irq = IRQ_PD9,
985 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */ 1258 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
986 .bus_num = 0, 1259 .bus_num = 0,
987 .chip_select = 2, 1260 .chip_select = 4,
988 }, 1261 },
989#endif 1262#endif
990#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 1263#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
@@ -1050,7 +1323,7 @@ static struct resource bfin_spi1_resource[] = {
1050 1323
1051/* SPI controller data */ 1324/* SPI controller data */
1052static struct bfin6xx_spi_master bf60x_spi_master_info0 = { 1325static struct bfin6xx_spi_master bf60x_spi_master_info0 = {
1053 .num_chipselect = 4, 1326 .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS,
1054 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0}, 1327 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
1055}; 1328};
1056 1329
@@ -1065,7 +1338,7 @@ static struct platform_device bf60x_spi_master0 = {
1065}; 1338};
1066 1339
1067static struct bfin6xx_spi_master bf60x_spi_master_info1 = { 1340static struct bfin6xx_spi_master bf60x_spi_master_info1 = {
1068 .num_chipselect = 4, 1341 .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS,
1069 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0}, 1342 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
1070}; 1343};
1071 1344
@@ -1146,6 +1419,11 @@ static struct i2c_board_info __initdata bfin_i2c_board_info0[] = {
1146 .platform_data = (void *)&adau1761_info 1419 .platform_data = (void *)&adau1761_info
1147 }, 1420 },
1148#endif 1421#endif
1422#if defined(CONFIG_SND_SOC_SSM2602) || defined(CONFIG_SND_SOC_SSM2602_MODULE)
1423 {
1424 I2C_BOARD_INFO("ssm2602", 0x1b),
1425 },
1426#endif
1149}; 1427};
1150 1428
1151static struct i2c_board_info __initdata bfin_i2c_board_info1[] = { 1429static struct i2c_board_info __initdata bfin_i2c_board_info1[] = {
@@ -1261,6 +1539,9 @@ static struct platform_device *ezkit_devices[] __initdata = {
1261 &bfin_crc0_device, 1539 &bfin_crc0_device,
1262 &bfin_crc1_device, 1540 &bfin_crc1_device,
1263#endif 1541#endif
1542#if defined(CONFIG_CRYPTO_DEV_BFIN_CRC)
1543 &bfin_crypto_crc_device,
1544#endif
1264 1545
1265#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 1546#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
1266 &bfin_device_gpiokeys, 1547 &bfin_device_gpiokeys,
@@ -1269,7 +1550,7 @@ static struct platform_device *ezkit_devices[] __initdata = {
1269#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 1550#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
1270 &ezkit_flash_device, 1551 &ezkit_flash_device,
1271#endif 1552#endif
1272#if defined(CONFIG_SND_BF6XX_I2S) || defined(CONFIG_SND_BF6XX_I2S_MODULE) 1553#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
1273 &bfin_i2s_pcm, 1554 &bfin_i2s_pcm,
1274#endif 1555#endif
1275#if defined(CONFIG_SND_BF6XX_SOC_I2S) || \ 1556#if defined(CONFIG_SND_BF6XX_SOC_I2S) || \
@@ -1284,6 +1565,11 @@ static struct platform_device *ezkit_devices[] __initdata = {
1284 || defined(CONFIG_VIDEO_BLACKFIN_CAPTURE_MODULE) 1565 || defined(CONFIG_VIDEO_BLACKFIN_CAPTURE_MODULE)
1285 &bfin_capture_device, 1566 &bfin_capture_device,
1286#endif 1567#endif
1568#if defined(CONFIG_VIDEO_BLACKFIN_DISPLAY) \
1569 || defined(CONFIG_VIDEO_BLACKFIN_DISPLAY_MODULE)
1570 &bfin_display_device,
1571#endif
1572
1287}; 1573};
1288 1574
1289static int __init ezkit_init(void) 1575static int __init ezkit_init(void)
diff --git a/arch/blackfin/mach-bf609/clock.c b/arch/blackfin/mach-bf609/clock.c
index 7f8f529693a..437d56c8228 100644
--- a/arch/blackfin/mach-bf609/clock.c
+++ b/arch/blackfin/mach-bf609/clock.c
@@ -97,9 +97,10 @@ int wait_for_pll_align(void)
97 while (i-- && (bfin_read32(CGU0_STAT) & CGU0_STAT_CLKSALGN)); 97 while (i-- && (bfin_read32(CGU0_STAT) & CGU0_STAT_CLKSALGN));
98 98
99 if (bfin_read32(CGU0_STAT) & CGU0_STAT_CLKSALGN) { 99 if (bfin_read32(CGU0_STAT) & CGU0_STAT_CLKSALGN) {
100 printk(KERN_DEBUG "fail to align clk\n"); 100 printk(KERN_CRIT "fail to align clk\n");
101 return -1; 101 return -1;
102 } 102 }
103
103 return 0; 104 return 0;
104} 105}
105 106
diff --git a/arch/blackfin/mach-bf609/dpm.S b/arch/blackfin/mach-bf609/dpm.S
new file mode 100644
index 00000000000..54d50c689db
--- /dev/null
+++ b/arch/blackfin/mach-bf609/dpm.S
@@ -0,0 +1,157 @@
1#include <linux/linkage.h>
2#include <asm/blackfin.h>
3#include <asm/dpmc.h>
4
5#include <asm/context.S>
6
7#define PM_STACK (COREA_L1_SCRATCH_START + L1_SCRATCH_LENGTH - 12)
8
9.section .l1.text
10ENTRY(_enter_hibernate)
11 /* switch stack to L1 scratch, prepare for ddr srfr */
12 P0.H = HI(PM_STACK);
13 P0.L = LO(PM_STACK);
14 SP = P0;
15
16 call _bf609_ddr_sr;
17 call _bfin_hibernate_syscontrol;
18
19 P0.H = HI(DPM0_RESTORE4);
20 P0.L = LO(DPM0_RESTORE4);
21 P1.H = _bf609_pm_data;
22 P1.L = _bf609_pm_data;
23 [P0] = P1;
24
25 P0.H = HI(DPM0_CTL);
26 P0.L = LO(DPM0_CTL);
27 R3.H = HI(0x00000010);
28 R3.L = LO(0x00000010);
29
30 bfin_init_pm_bench_cycles;
31
32 [P0] = R3;
33
34 SSYNC;
35ENDPROC(_enter_hibernate)
36
37/* DPM wake up interrupt won't wake up core on bf60x if its core IMASK
38 * is disabled. This behavior differ from bf5xx serial processor.
39 */
40ENTRY(_dummy_deepsleep)
41 [--sp] = SYSCFG;
42 [--sp] = (R7:0,P5:0);
43 cli r0;
44
45 /* get wake up interrupt ID */
46 P0.l = LO(SEC_SCI_BASE + SEC_CSID);
47 P0.h = HI(SEC_SCI_BASE + SEC_CSID);
48 R0 = [P0];
49
50 /* ACK wake up interrupt in SEC */
51 P1.l = LO(SEC_END);
52 P1.h = HI(SEC_END);
53
54 [P1] = R0;
55 SSYNC;
56
57 /* restore EVT 11 entry */
58 p0.h = hi(EVT11);
59 p0.l = lo(EVT11);
60 p1.h = _evt_evt11;
61 p1.l = _evt_evt11;
62
63 [p0] = p1;
64 SSYNC;
65
66 (R7:0,P5:0) = [sp++];
67 SYSCFG = [sp++];
68 RTI;
69ENDPROC(_dummy_deepsleep)
70
71ENTRY(_enter_deepsleep)
72 LINK 0xC;
73 [--sp] = (R7:0,P5:0);
74
75 /* Change EVT 11 entry to dummy handler for wake up event */
76 p0.h = hi(EVT11);
77 p0.l = lo(EVT11);
78 p1.h = _dummy_deepsleep;
79 p1.l = _dummy_deepsleep;
80
81 [p0] = p1;
82
83 P0.H = HI(PM_STACK);
84 P0.L = LO(PM_STACK);
85
86 EX_SCRATCH_REG = SP;
87 SP = P0;
88
89 SSYNC;
90
91 /* should put ddr to self refresh mode before sleep */
92 call _bf609_ddr_sr;
93
94 /* Set DPM controller to deep sleep mode */
95 P0.H = HI(DPM0_CTL);
96 P0.L = LO(DPM0_CTL);
97 R3.H = HI(0x00000008);
98 R3.L = LO(0x00000008);
99 [P0] = R3;
100 CSYNC;
101
102 /* Enable evt 11 in IMASK before idle, otherwise core doesn't wake up. */
103 r0.l = 0x800;
104 r0.h = 0;
105 sti r0;
106 SSYNC;
107
108 bfin_init_pm_bench_cycles;
109
110 /* Fall into deep sleep in idle*/
111 idle;
112 SSYNC;
113
114 /* Restore PLL after wake up from deep sleep */
115 call _bf609_resume_ccbuf;
116
117 /* turn ddr out of self refresh mode */
118 call _bf609_ddr_sr_exit;
119
120 SP = EX_SCRATCH_REG;
121
122 (R7:0,P5:0) = [SP++];
123 UNLINK;
124 RTS;
125ENDPROC(_enter_deepsleep)
126
127.section .text
128ENTRY(_bf609_hibernate)
129 bfin_cpu_reg_save;
130 bfin_core_mmr_save;
131
132 P0.H = _bf609_pm_data;
133 P0.L = _bf609_pm_data;
134 R1.H = 0xDEAD;
135 R1.L = 0xBEEF;
136 R2.H = .Lpm_resume_here;
137 R2.L = .Lpm_resume_here;
138 [P0++] = R1;
139 [P0++] = R2;
140 [P0++] = SP;
141
142 P1.H = _enter_hibernate;
143 P1.L = _enter_hibernate;
144
145 call (P1);
146.Lpm_resume_here:
147
148 bfin_core_mmr_restore;
149 bfin_cpu_reg_restore;
150
151 [--sp] = RETI; /* Clear Global Interrupt Disable */
152 SP += 4;
153
154 RTS;
155
156ENDPROC(_bf609_hibernate)
157
diff --git a/arch/blackfin/mach-bf609/hibernate.S b/arch/blackfin/mach-bf609/hibernate.S
deleted file mode 100644
index d37a532519c..00000000000
--- a/arch/blackfin/mach-bf609/hibernate.S
+++ /dev/null
@@ -1,65 +0,0 @@
1#include <linux/linkage.h>
2#include <asm/blackfin.h>
3#include <asm/dpmc.h>
4
5#define PM_STACK (COREA_L1_SCRATCH_START + L1_SCRATCH_LENGTH - 12)
6
7.section .l1.text
8ENTRY(_enter_hibernate)
9 /* switch stack to L1 scratch, prepare for ddr srfr */
10 P0.H = HI(PM_STACK);
11 P0.L = LO(PM_STACK);
12 SP = P0;
13
14 call _bf609_ddr_sr;
15 call _bfin_hibernate_syscontrol;
16
17 P0.H = HI(DPM0_RESTORE4);
18 P0.L = LO(DPM0_RESTORE4);
19 P1.H = _bf609_pm_data;
20 P1.L = _bf609_pm_data;
21 [P0] = P1;
22
23 P0.H = HI(DPM0_CTL);
24 P0.L = LO(DPM0_CTL);
25 R3.H = HI(0x00000010);
26 R3.L = LO(0x00000010);
27
28 bfin_init_pm_bench_cycles;
29
30 [P0] = R3;
31
32 SSYNC;
33ENDPROC(_enter_hibernate_mode)
34
35.section .text
36ENTRY(_bf609_hibernate)
37 bfin_cpu_reg_save;
38 bfin_core_mmr_save;
39
40 P0.H = _bf609_pm_data;
41 P0.L = _bf609_pm_data;
42 R1.H = 0xDEAD;
43 R1.L = 0xBEEF;
44 R2.H = .Lpm_resume_here;
45 R2.L = .Lpm_resume_here;
46 [P0++] = R1;
47 [P0++] = R2;
48 [P0++] = SP;
49
50 P1.H = _enter_hibernate;
51 P1.L = _enter_hibernate;
52
53 call (P1);
54.Lpm_resume_here:
55
56 bfin_core_mmr_restore;
57 bfin_cpu_reg_restore;
58
59 [--sp] = RETI; /* Clear Global Interrupt Disable */
60 SP += 4;
61
62 RTS;
63
64ENDPROC(_bf609_hibernate)
65
diff --git a/arch/blackfin/mach-bf609/include/mach/anomaly.h b/arch/blackfin/mach-bf609/include/mach/anomaly.h
index bdd39aefb56..7a07374308a 100644
--- a/arch/blackfin/mach-bf609/include/mach/anomaly.h
+++ b/arch/blackfin/mach-bf609/include/mach/anomaly.h
@@ -5,126 +5,99 @@
5 * and can be replaced with that version at any time 5 * and can be replaced with that version at any time
6 * DO NOT EDIT THIS FILE 6 * DO NOT EDIT THIS FILE
7 * 7 *
8 * Copyright 2004-2011 Analog Devices Inc. 8 * Copyright 2004-2012 Analog Devices Inc.
9 * Licensed under the Clear BSD license. 9 * Licensed under the Clear BSD license.
10 */ 10 */
11 11
12/* This file should be up to date with: 12/* This file should be up to date with:
13 * - Revision A, 15/06/2012; ADSP-BF609 Blackfin Processor Anomaly List
13 */ 14 */
14 15
15#if __SILICON_REVISION__ < 0 16#if __SILICON_REVISION__ < 0
16# error will not work on BF506 silicon version 17# error will not work on BF609 silicon version
17#endif 18#endif
18 19
19#ifndef _MACH_ANOMALY_H_ 20#ifndef _MACH_ANOMALY_H_
20#define _MACH_ANOMALY_H_ 21#define _MACH_ANOMALY_H_
21 22
22/* Multi-Issue Instruction with dsp32shiftimm in slot1 and P-reg Store in slot2 Not Supported */ 23/* TRU_STAT.ADDRERR and TRU_ERRADDR.ADDR May Not Reflect the Correct Status */
23#define ANOMALY_05000074 (1) 24#define ANOMALY_16000003 (1)
24/* DMA_RUN Bit Is Not Valid after a Peripheral Receive Channel DMA Stops */ 25/* The EPPI Data Enable (DEN) Signal is Not Functional */
25#define ANOMALY_05000119 (1) 26#define ANOMALY_16000004 (1)
26/* Rx.H Cannot Be Used to Access 16-bit System MMR Registers */ 27/* Using L1 Instruction Cache with Parity Enabled is Unreliable */
27#define ANOMALY_05000122 (1) 28#define ANOMALY_16000005 (1)
28/* False Hardware Error from an Access in the Shadow of a Conditional Branch */ 29/* SEQSTAT.SYSNMI Clears Upon Entering the NMI ISR */
29#define ANOMALY_05000245 (1) 30#define ANOMALY_16000006 (1)
30/* Incorrect Timer Pulse Width in Single-Shot PWM_OUT Mode with External Clock */ 31/* DDR2 Memory Reads May Fail Intermittently */
31#define ANOMALY_05000254 (1) 32#define ANOMALY_16000007 (1)
32/* Sensitivity To Noise with Slow Input Edge Rates on External SPORT TX and RX Clocks */ 33/* Instruction Memory Stalls Can Cause IFLUSH to Fail */
33#define ANOMALY_05000265 (1) 34#define ANOMALY_16000008 (1)
34/* False Hardware Errors Caused by Fetches at the Boundary of Reserved Memory */ 35/* TestSET Instruction Cannot Be Interrupted */
35#define ANOMALY_05000310 (1) 36#define ANOMALY_16000009 (1)
36/* PPI Underflow Error Goes Undetected in ITU-R 656 Mode */
37#define ANOMALY_05000366 (1)
38/* Speculative Fetches Can Cause Undesired External FIFO Operations */
39#define ANOMALY_05000416 (1)
40/* Speculative Fetches of Indirect-Pointer Instructions Can Cause False Hardware Errors */
41#define ANOMALY_05000426 (1)
42/* IFLUSH Instruction at End of Hardware Loop Causes Infinite Stall */ 37/* IFLUSH Instruction at End of Hardware Loop Causes Infinite Stall */
43#define ANOMALY_05000443 (1) 38#define ANOMALY_16000010 (1)
44/* UART IrDA Receiver Fails on Extended Bit Pulses */
45#define ANOMALY_05000447 (1)
46/* False Hardware Error when RETI Points to Invalid Memory */ 39/* False Hardware Error when RETI Points to Invalid Memory */
47#define ANOMALY_05000461 (1) 40#define ANOMALY_16000011 (1)
48/* PLL Latches Incorrect Settings During Reset */ 41/* Speculative Fetches of Indirect-Pointer Instructions Can Cause False Hardware Errors */
49#define ANOMALY_05000469 (1) 42#define ANOMALY_16000012 (1)
50/* Incorrect Default MSEL Value in PLL_CTL */ 43/* False Hardware Errors Caused by Fetches at the Boundary of Reserved Memory */
51#define ANOMALY_05000472 (1) 44#define ANOMALY_16000013 (1)
52/* Interrupted SPORT Receive Data Register Read Results In Underflow when SLEN > 15 */ 45/* False Hardware Error from an Access in the Shadow of a Conditional Branch */
53#define ANOMALY_05000473 (1) 46#define ANOMALY_16000014 (1)
54/* TESTSET Instruction Cannot Be Interrupted */ 47/* Multi-Issue Instruction with dsp32shiftimm in slot1 and P-reg Store in slot2 Not Supported */
55#define ANOMALY_05000477 (1) 48#define ANOMALY_16000015 (1)
56/* Reads of ITEST_COMMAND and ITEST_DATA Registers Cause Cache Corruption */ 49/* Speculative Fetches Can Cause Undesired External FIFO Operations */
57#define ANOMALY_05000481 (1) 50#define ANOMALY_16000017 (1)
58/* IFLUSH sucks at life */ 51/* RSI Boot Cleanup Routine Does Not Clear Registers */
59#define ANOMALY_05000491 (1) 52#define ANOMALY_16000018 (1)
60/* Tempopary anomaly ID for data loss in MMR read operation if interrupted */ 53/* SPI Master Boot Device Auto-detection Frequency is Set Incorrectly */
61#define ANOMALY_05001001 (__SILICON_REVISION__ < 1) 54#define ANOMALY_16000019 (1)
55/* rom_SysControl() Fails to Set DDR0_CTL.INIT for Wakeup From Hibernate */
56#define ANOMALY_16000020 (1)
57/* rom_SysControl() Fails to Save and Restore DDR0_PHYCTL3 for Hibernate/Wakeup Sequence */
58#define ANOMALY_16000021 (1)
59/* Boot Code Fails to Enable Parity Fault Detection */
60#define ANOMALY_16000022 (1)
61/* USB DMA interrupt status do not show the DMA channel interrupt in the DMA ISR */
62#define ANOMALY_16000027 (1)
63/* Interrupted Core Reads of MMRs May Cause Data Loss */
64#define ANOMALY_16000030 (1)
62 65
63/* Anomalies that don't exist on this proc */ 66/* Anomalies that don't exist on this proc */
64#define ANOMALY_05000099 (0)
65#define ANOMALY_05000120 (0)
66#define ANOMALY_05000125 (0)
67#define ANOMALY_05000149 (0)
68#define ANOMALY_05000158 (0) 67#define ANOMALY_05000158 (0)
69#define ANOMALY_05000171 (0)
70#define ANOMALY_05000179 (0)
71#define ANOMALY_05000182 (0)
72#define ANOMALY_05000183 (0)
73#define ANOMALY_05000189 (0) 68#define ANOMALY_05000189 (0)
74#define ANOMALY_05000198 (0) 69#define ANOMALY_05000198 (0)
75#define ANOMALY_05000202 (0)
76#define ANOMALY_05000215 (0)
77#define ANOMALY_05000219 (0)
78#define ANOMALY_05000220 (0) 70#define ANOMALY_05000220 (0)
79#define ANOMALY_05000227 (0)
80#define ANOMALY_05000230 (0) 71#define ANOMALY_05000230 (0)
81#define ANOMALY_05000231 (0) 72#define ANOMALY_05000231 (0)
82#define ANOMALY_05000233 (0)
83#define ANOMALY_05000234 (0)
84#define ANOMALY_05000242 (0)
85#define ANOMALY_05000244 (0) 73#define ANOMALY_05000244 (0)
86#define ANOMALY_05000248 (0)
87#define ANOMALY_05000250 (0)
88#define ANOMALY_05000257 (0)
89#define ANOMALY_05000261 (0)
90#define ANOMALY_05000263 (0) 74#define ANOMALY_05000263 (0)
91#define ANOMALY_05000266 (0)
92#define ANOMALY_05000273 (0) 75#define ANOMALY_05000273 (0)
93#define ANOMALY_05000274 (0) 76#define ANOMALY_05000274 (0)
94#define ANOMALY_05000278 (0) 77#define ANOMALY_05000278 (0)
95#define ANOMALY_05000281 (0) 78#define ANOMALY_05000281 (0)
96#define ANOMALY_05000283 (0)
97#define ANOMALY_05000285 (0)
98#define ANOMALY_05000287 (0) 79#define ANOMALY_05000287 (0)
99#define ANOMALY_05000301 (0)
100#define ANOMALY_05000305 (0)
101#define ANOMALY_05000307 (0)
102#define ANOMALY_05000311 (0) 80#define ANOMALY_05000311 (0)
103#define ANOMALY_05000312 (0) 81#define ANOMALY_05000312 (0)
104#define ANOMALY_05000315 (0)
105#define ANOMALY_05000323 (0) 82#define ANOMALY_05000323 (0)
106#define ANOMALY_05000353 (1)
107#define ANOMALY_05000357 (0)
108#define ANOMALY_05000362 (1)
109#define ANOMALY_05000363 (0) 83#define ANOMALY_05000363 (0)
110#define ANOMALY_05000364 (0)
111#define ANOMALY_05000371 (0)
112#define ANOMALY_05000380 (0) 84#define ANOMALY_05000380 (0)
113#define ANOMALY_05000386 (0)
114#define ANOMALY_05000389 (0)
115#define ANOMALY_05000400 (0)
116#define ANOMALY_05000402 (0)
117#define ANOMALY_05000412 (0)
118#define ANOMALY_05000432 (0)
119#define ANOMALY_05000440 (0)
120#define ANOMALY_05000448 (0) 85#define ANOMALY_05000448 (0)
121#define ANOMALY_05000456 (0)
122#define ANOMALY_05000450 (0) 86#define ANOMALY_05000450 (0)
123#define ANOMALY_05000465 (0) 87#define ANOMALY_05000456 (0)
124#define ANOMALY_05000467 (0)
125#define ANOMALY_05000474 (0)
126#define ANOMALY_05000475 (0)
127#define ANOMALY_05000480 (0) 88#define ANOMALY_05000480 (0)
128#define ANOMALY_05000485 (0) 89#define ANOMALY_05000481 (1)
90
91/* Reuse BF5xx anomalies IDs for the same anomaly in BF60x */
92#define ANOMALY_05000491 ANOMALY_16000008
93#define ANOMALY_05000477 ANOMALY_16000009
94#define ANOMALY_05000443 ANOMALY_16000010
95#define ANOMALY_05000461 ANOMALY_16000011
96#define ANOMALY_05000426 ANOMALY_16000012
97#define ANOMALY_05000310 ANOMALY_16000013
98#define ANOMALY_05000245 ANOMALY_16000014
99#define ANOMALY_05000074 ANOMALY_16000015
100#define ANOMALY_05000416 ANOMALY_16000017
101
129 102
130#endif 103#endif
diff --git a/arch/blackfin/mach-bf609/include/mach/defBF60x_base.h b/arch/blackfin/mach-bf609/include/mach/defBF60x_base.h
index 6aac38544cc..f1a6afae1a7 100644
--- a/arch/blackfin/mach-bf609/include/mach/defBF60x_base.h
+++ b/arch/blackfin/mach-bf609/include/mach/defBF60x_base.h
@@ -2665,7 +2665,6 @@
2665#define DEVSZ_1G 0x400 /* DMC External Bank Size = 1Gbit */ 2665#define DEVSZ_1G 0x400 /* DMC External Bank Size = 1Gbit */
2666#define DEVSZ_2G 0x500 /* DMC External Bank Size = 2Gbit */ 2666#define DEVSZ_2G 0x500 /* DMC External Bank Size = 2Gbit */
2667 2667
2668
2669/* ========================= 2668/* =========================
2670 L2CTL Registers 2669 L2CTL Registers
2671 ========================= */ 2670 ========================= */
diff --git a/arch/blackfin/mach-bf609/include/mach/gpio.h b/arch/blackfin/mach-bf609/include/mach/gpio.h
index 127586b1e04..c32c8cc8db2 100644
--- a/arch/blackfin/mach-bf609/include/mach/gpio.h
+++ b/arch/blackfin/mach-bf609/include/mach/gpio.h
@@ -123,6 +123,8 @@
123 123
124 124
125#define BFIN_GPIO_PINT 1 125#define BFIN_GPIO_PINT 1
126#define NR_PINT_SYS_IRQS 6
127#define NR_PINTS 112
126 128
127 129
128#ifndef __ASSEMBLY__ 130#ifndef __ASSEMBLY__
diff --git a/arch/blackfin/mach-bf609/include/mach/irq.h b/arch/blackfin/mach-bf609/include/mach/irq.h
index 0004552433b..23e74cdeeee 100644
--- a/arch/blackfin/mach-bf609/include/mach/irq.h
+++ b/arch/blackfin/mach-bf609/include/mach/irq.h
@@ -293,9 +293,13 @@
293 293
294#define NR_MACH_IRQS (IRQ_PG15 + 1) 294#define NR_MACH_IRQS (IRQ_PG15 + 1)
295 295
296#define SEC_SCTL_PRIO_OFFSET 8
297
296#ifndef __ASSEMBLY__ 298#ifndef __ASSEMBLY__
297#include <linux/types.h> 299#include <linux/types.h>
298 300
301extern u8 sec_int_priority[];
302
299/* 303/*
300 * bfin pint registers layout 304 * bfin pint registers layout
301 */ 305 */
diff --git a/arch/blackfin/mach-bf609/include/mach/pm.h b/arch/blackfin/mach-bf609/include/mach/pm.h
index 036d9bdc889..3ca0fb96563 100644
--- a/arch/blackfin/mach-bf609/include/mach/pm.h
+++ b/arch/blackfin/mach-bf609/include/mach/pm.h
@@ -11,11 +11,14 @@
11 11
12#include <linux/suspend.h> 12#include <linux/suspend.h>
13 13
14int bfin609_pm_enter(suspend_state_t state); 14extern int bfin609_pm_enter(suspend_state_t state);
15int bf609_pm_prepare(void); 15extern int bf609_pm_prepare(void);
16void bf609_pm_finish(void); 16extern void bf609_pm_finish(void);
17 17
18void bf609_hibernate(void); 18void bf609_hibernate(void);
19void bfin_sec_raise_irq(unsigned int sid); 19void bfin_sec_raise_irq(unsigned int sid);
20void coreb_enable(void); 20void coreb_enable(void);
21
22int bf609_nor_flash_init(void);
23void bf609_nor_flash_exit(void);
21#endif 24#endif
diff --git a/arch/blackfin/mach-bf609/ints-priority.c b/arch/blackfin/mach-bf609/ints-priority.c
new file mode 100644
index 00000000000..f68abb9aa79
--- /dev/null
+++ b/arch/blackfin/mach-bf609/ints-priority.c
@@ -0,0 +1,156 @@
1/*
2 * Copyright 2007-2008 Analog Devices Inc.
3 *
4 * Licensed under the GPL-2 or later.
5 *
6 * Set up the interrupt priorities
7 */
8
9#include <linux/module.h>
10#include <linux/irq.h>
11#include <asm/blackfin.h>
12
13u8 sec_int_priority[] = {
14 255, /* IRQ_SEC_ERR */
15 255, /* IRQ_CGU_EVT */
16 254, /* IRQ_WATCH0 */
17 254, /* IRQ_WATCH1 */
18 253, /* IRQ_L2CTL0_ECC_ERR */
19 253, /* IRQ_L2CTL0_ECC_WARN */
20 253, /* IRQ_C0_DBL_FAULT */
21 253, /* IRQ_C1_DBL_FAULT */
22 252, /* IRQ_C0_HW_ERR */
23 252, /* IRQ_C1_HW_ERR */
24 255, /* IRQ_C0_NMI_L1_PARITY_ERR */
25 255, /* IRQ_C1_NMI_L1_PARITY_ERR */
26
27 50, /* IRQ_TIMER0 */
28 50, /* IRQ_TIMER1 */
29 50, /* IRQ_TIMER2 */
30 50, /* IRQ_TIMER3 */
31 50, /* IRQ_TIMER4 */
32 50, /* IRQ_TIMER5 */
33 50, /* IRQ_TIMER6 */
34 50, /* IRQ_TIMER7 */
35 50, /* IRQ_TIMER_STAT */
36 0, /* IRQ_PINT0 */
37 0, /* IRQ_PINT1 */
38 0, /* IRQ_PINT2 */
39 0, /* IRQ_PINT3 */
40 0, /* IRQ_PINT4 */
41 0, /* IRQ_PINT5 */
42 0, /* IRQ_CNT */
43 50, /* RQ_PWM0_TRIP */
44 50, /* IRQ_PWM0_SYNC */
45 50, /* IRQ_PWM1_TRIP */
46 50, /* IRQ_PWM1_SYNC */
47 0, /* IRQ_TWI0 */
48 0, /* IRQ_TWI1 */
49 10, /* IRQ_SOFT0 */
50 10, /* IRQ_SOFT1 */
51 10, /* IRQ_SOFT2 */
52 10, /* IRQ_SOFT3 */
53 0, /* IRQ_ACM_EVT_MISS */
54 0, /* IRQ_ACM_EVT_COMPLETE */
55 0, /* IRQ_CAN0_RX */
56 0, /* IRQ_CAN0_TX */
57 0, /* IRQ_CAN0_STAT */
58 100, /* IRQ_SPORT0_TX */
59 100, /* IRQ_SPORT0_TX_STAT */
60 100, /* IRQ_SPORT0_RX */
61 100, /* IRQ_SPORT0_RX_STAT */
62 100, /* IRQ_SPORT1_TX */
63 100, /* IRQ_SPORT1_TX_STAT */
64 100, /* IRQ_SPORT1_RX */
65 100, /* IRQ_SPORT1_RX_STAT */
66 100, /* IRQ_SPORT2_TX */
67 100, /* IRQ_SPORT2_TX_STAT */
68 100, /* IRQ_SPORT2_RX */
69 100, /* IRQ_SPORT2_RX_STAT */
70 0, /* IRQ_SPI0_TX */
71 0, /* IRQ_SPI0_RX */
72 0, /* IRQ_SPI0_STAT */
73 0, /* IRQ_SPI1_TX */
74 0, /* IRQ_SPI1_RX */
75 0, /* IRQ_SPI1_STAT */
76 0, /* IRQ_RSI */
77 0, /* IRQ_RSI_INT0 */
78 0, /* IRQ_RSI_INT1 */
79 0, /* DMA11 Data (SDU) */
80 0, /* DMA12 Data (Reserved) */
81 0, /* Reserved */
82 0, /* Reserved */
83 30, /* IRQ_EMAC0_STAT */
84 0, /* EMAC0 Power (Reserved) */
85 30, /* IRQ_EMAC1_STAT */
86 0, /* EMAC1 Power (Reserved) */
87 0, /* IRQ_LP0 */
88 0, /* IRQ_LP0_STAT */
89 0, /* IRQ_LP1 */
90 0, /* IRQ_LP1_STAT */
91 0, /* IRQ_LP2 */
92 0, /* IRQ_LP2_STAT */
93 0, /* IRQ_LP3 */
94 0, /* IRQ_LP3_STAT */
95 0, /* IRQ_UART0_TX */
96 0, /* IRQ_UART0_RX */
97 0, /* IRQ_UART0_STAT */
98 0, /* IRQ_UART1_TX */
99 0, /* IRQ_UART1_RX */
100 0, /* IRQ_UART1_STAT */
101 0, /* IRQ_MDMA0_SRC_CRC0 */
102 0, /* IRQ_MDMA0_DEST_CRC0 */
103 0, /* IRQ_CRC0_DCNTEXP */
104 0, /* IRQ_CRC0_ERR */
105 0, /* IRQ_MDMA1_SRC_CRC1 */
106 0, /* IRQ_MDMA1_DEST_CRC1 */
107 0, /* IRQ_CRC1_DCNTEXP */
108 0, /* IRQ_CRC1_ERR */
109 0, /* IRQ_MDMA2_SRC */
110 0, /* IRQ_MDMA2_DEST */
111 0, /* IRQ_MDMA3_SRC */
112 0, /* IRQ_MDMA3_DEST */
113 120, /* IRQ_EPPI0_CH0 */
114 120, /* IRQ_EPPI0_CH1 */
115 120, /* IRQ_EPPI0_STAT */
116 120, /* IRQ_EPPI2_CH0 */
117 120, /* IRQ_EPPI2_CH1 */
118 120, /* IRQ_EPPI2_STAT */
119 120, /* IRQ_EPPI1_CH0 */
120 120, /* IRQ_EPPI1_CH1 */
121 120, /* IRQ_EPPI1_STAT */
122 120, /* IRQ_PIXC_CH0 */
123 120, /* IRQ_PIXC_CH1 */
124 120, /* IRQ_PIXC_CH2 */
125 120, /* IRQ_PIXC_STAT */
126 120, /* IRQ_PVP_CPDOB */
127 120, /* IRQ_PVP_CPDOC */
128 120, /* IRQ_PVP_CPSTAT */
129 120, /* IRQ_PVP_CPCI */
130 120, /* IRQ_PVP_STAT0 */
131 120, /* IRQ_PVP_MPDO */
132 120, /* IRQ_PVP_MPDI */
133 120, /* IRQ_PVP_MPSTAT */
134 120, /* IRQ_PVP_MPCI */
135 120, /* IRQ_PVP_CPDOA */
136 120, /* IRQ_PVP_STAT1 */
137 0, /* IRQ_USB_STAT */
138 0, /* IRQ_USB_DMA */
139 0, /* IRQ_TRU_INT0 */
140 0, /* IRQ_TRU_INT1 */
141 0, /* IRQ_TRU_INT2 */
142 0, /* IRQ_TRU_INT3 */
143 0, /* IRQ_DMAC0_ERROR */
144 0, /* IRQ_CGU0_ERROR */
145 0, /* Reserved */
146 0, /* IRQ_DPM */
147 0, /* Reserved */
148 0, /* IRQ_SWU0 */
149 0, /* IRQ_SWU1 */
150 0, /* IRQ_SWU2 */
151 0, /* IRQ_SWU3 */
152 0, /* IRQ_SWU4 */
153 0, /* IRQ_SWU4 */
154 0, /* IRQ_SWU6 */
155};
156
diff --git a/arch/blackfin/mach-bf609/pm.c b/arch/blackfin/mach-bf609/pm.c
index b76966eb16a..dacafc163f7 100644
--- a/arch/blackfin/mach-bf609/pm.c
+++ b/arch/blackfin/mach-bf609/pm.c
@@ -11,13 +11,14 @@
11#include <linux/interrupt.h> 11#include <linux/interrupt.h>
12#include <linux/gpio.h> 12#include <linux/gpio.h>
13#include <linux/irq.h> 13#include <linux/irq.h>
14
15#include <linux/delay.h> 14#include <linux/delay.h>
15#include <linux/syscore_ops.h>
16 16
17#include <asm/dpmc.h> 17#include <asm/dpmc.h>
18#include <asm/pm.h> 18#include <asm/pm.h>
19#include <mach/pm.h> 19#include <mach/pm.h>
20#include <asm/blackfin.h> 20#include <asm/blackfin.h>
21#include <asm/mem_init.h>
21 22
22/***********************************************************/ 23/***********************************************************/
23/* */ 24/* */
@@ -132,60 +133,30 @@ void bfin_cpu_suspend(void)
132} 133}
133 134
134__attribute__((l1_text)) 135__attribute__((l1_text))
135void bfin_deepsleep(unsigned long mask) 136void bf609_ddr_sr(void)
136{ 137{
137 uint32_t dpm0_ctl; 138 dmc_enter_self_refresh();
138
139 bfin_write32(DPM0_WAKE_EN, 0x10);
140 bfin_write32(DPM0_WAKE_POL, 0x10);
141 dpm0_ctl = 0x00000008;
142 bfin_write32(DPM0_CTL, dpm0_ctl);
143 SSYNC();
144 __asm__ __volatile__( \
145 ".align 8;" \
146 "idle;" \
147 : : \
148 );
149#ifdef CONFIG_BFIN_PM_WAKEUP_TIME_BENCH
150 __asm__ __volatile__(
151 "R0 = 0;"
152 "CYCLES = R0;"
153 "CYCLES2 = R0;"
154 "R0 = SYSCFG;"
155 "BITSET(R0, 1);"
156 "SYSCFG = R0;"
157 : : : "R0"
158 );
159#endif
160
161} 139}
162 140
163__attribute__((l1_text)) 141__attribute__((l1_text))
164void bf609_ddr_sr(void) 142void bf609_ddr_sr_exit(void)
165{ 143{
166 uint32_t reg; 144 dmc_exit_self_refresh();
167
168 reg = bfin_read_DMC0_CTL();
169 reg |= 0x8;
170 bfin_write_DMC0_CTL(reg);
171 145
172 while (!(bfin_read_DMC0_STAT() & 0x8)) 146 /* After wake up from deep sleep and exit DDR from self refress mode,
147 * should wait till CGU PLL is locked.
148 */
149 while (bfin_read32(CGU0_STAT) & CLKSALGN)
173 continue; 150 continue;
174} 151}
175 152
176__attribute__((l1_text)) 153__attribute__((l1_text))
177void bf609_ddr_sr_exit(void) 154void bf609_resume_ccbuf(void)
178{ 155{
179 uint32_t reg; 156 bfin_write32(DPM0_CCBF_EN, 3);
180 while (!(bfin_read_DMC0_STAT() & 0x1)) 157 bfin_write32(DPM0_CTL, 2);
181 continue;
182 158
183 reg = bfin_read_DMC0_CTL(); 159 while ((bfin_read32(DPM0_STAT) & 0xf) != 1);
184 reg &= ~0x8;
185 bfin_write_DMC0_CTL(reg);
186
187 while ((bfin_read_DMC0_STAT() & 0x8))
188 continue;
189} 160}
190 161
191__attribute__((l1_text)) 162__attribute__((l1_text))
@@ -203,20 +174,25 @@ void bfin_hibernate_syscontrol(void)
203 bfin_write32(DPM0_RESTORE5, bfin_read32(DPM0_RESTORE5) | 4); 174 bfin_write32(DPM0_RESTORE5, bfin_read32(DPM0_RESTORE5) | 4);
204} 175}
205 176
206#ifndef CONFIG_BF60x 177#define IRQ_SID(irq) ((irq) - IVG15)
207# define SIC_SYSIRQ(irq) (irq - (IRQ_CORETMR + 1)) 178asmlinkage void enter_deepsleep(void);
208#else 179
209# define SIC_SYSIRQ(irq) ((irq) - IVG15) 180__attribute__((l1_text))
210#endif 181void bfin_deepsleep(unsigned long mask, unsigned long pol_mask)
211void bfin_hibernate(unsigned long mask)
212{ 182{
213 bfin_write32(DPM0_WAKE_EN, 0x10); 183 bfin_write32(DPM0_WAKE_EN, mask);
214 bfin_write32(DPM0_WAKE_POL, 0x10); 184 bfin_write32(DPM0_WAKE_POL, pol_mask);
185 SSYNC();
186 enter_deepsleep();
187}
188
189void bfin_hibernate(unsigned long mask, unsigned long pol_mask)
190{
191 bfin_write32(DPM0_WAKE_EN, mask);
192 bfin_write32(DPM0_WAKE_POL, pol_mask);
215 bfin_write32(DPM0_PGCNTR, 0x0000FFFF); 193 bfin_write32(DPM0_PGCNTR, 0x0000FFFF);
216 bfin_write32(DPM0_HIB_DIS, 0xFFFF); 194 bfin_write32(DPM0_HIB_DIS, 0xFFFF);
217 195
218 printk(KERN_DEBUG "hibernate: restore %x pgcnt %x\n", bfin_read32(DPM0_RESTORE0), bfin_read32(DPM0_PGCNTR));
219
220 bf609_hibernate(); 196 bf609_hibernate();
221} 197}
222 198
@@ -290,10 +266,11 @@ void bf609_cpu_pm_enter(suspend_state_t state)
290 printk(KERN_DEBUG "Unable to get irq wake\n"); 266 printk(KERN_DEBUG "Unable to get irq wake\n");
291 267
292 if (state == PM_SUSPEND_STANDBY) 268 if (state == PM_SUSPEND_STANDBY)
293 bfin_deepsleep(wakeup); 269 bfin_deepsleep(wakeup, wakeup_pol);
294 else { 270 else {
295 bfin_hibernate(wakeup); 271 bfin_hibernate(wakeup, wakeup_pol);
296 } 272 }
273
297} 274}
298 275
299int bf609_cpu_pm_prepare(void) 276int bf609_cpu_pm_prepare(void)
@@ -312,20 +289,36 @@ static struct bfin_cpu_pm_fns bf609_cpu_pm = {
312 .finish = bf609_cpu_pm_finish, 289 .finish = bf609_cpu_pm_finish,
313}; 290};
314 291
292#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
293static int smc_pm_syscore_suspend(void)
294{
295 bf609_nor_flash_exit();
296 return 0;
297}
298
299static void smc_pm_syscore_resume(void)
300{
301 bf609_nor_flash_init();
302}
303
304static struct syscore_ops smc_pm_syscore_ops = {
305 .suspend = smc_pm_syscore_suspend,
306 .resume = smc_pm_syscore_resume,
307};
308#endif
309
315static irqreturn_t test_isr(int irq, void *dev_id) 310static irqreturn_t test_isr(int irq, void *dev_id)
316{ 311{
317 printk(KERN_DEBUG "gpio irq %d\n", irq); 312 printk(KERN_DEBUG "gpio irq %d\n", irq);
313 if (irq == 231)
314 bfin_sec_raise_irq(IRQ_SID(IRQ_SOFT1));
318 return IRQ_HANDLED; 315 return IRQ_HANDLED;
319} 316}
320 317
321static irqreturn_t dpm0_isr(int irq, void *dev_id) 318static irqreturn_t dpm0_isr(int irq, void *dev_id)
322{ 319{
323 uint32_t wake_stat; 320 bfin_write32(DPM0_WAKE_STAT, bfin_read32(DPM0_WAKE_STAT));
324 321 bfin_write32(CGU0_STAT, bfin_read32(CGU0_STAT));
325 wake_stat = bfin_read32(DPM0_WAKE_STAT);
326 printk(KERN_DEBUG "enter %s wake stat %08x\n", __func__, wake_stat);
327
328 bfin_write32(DPM0_WAKE_STAT, wake_stat);
329 return IRQ_HANDLED; 322 return IRQ_HANDLED;
330} 323}
331 324
@@ -334,7 +327,11 @@ static int __init bf609_init_pm(void)
334 int irq; 327 int irq;
335 int error; 328 int error;
336 329
337#if CONFIG_PM_BFIN_WAKE_PE12 330#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
331 register_syscore_ops(&smc_pm_syscore_ops);
332#endif
333
334#ifdef CONFIG_PM_BFIN_WAKE_PE12
338 irq = gpio_to_irq(GPIO_PE12); 335 irq = gpio_to_irq(GPIO_PE12);
339 if (irq < 0) { 336 if (irq < 0) {
340 error = irq; 337 error = irq;
@@ -342,16 +339,19 @@ static int __init bf609_init_pm(void)
342 GPIO_PE12, error); 339 GPIO_PE12, error);
343 } 340 }
344 341
345 error = request_irq(irq, test_isr, IRQF_TRIGGER_RISING | IRQF_NO_SUSPEND, "gpiope12", NULL); 342 error = request_irq(irq, test_isr, IRQF_TRIGGER_RISING | IRQF_NO_SUSPEND
343 | IRQF_FORCE_RESUME, "gpiope12", NULL);
346 if(error < 0) 344 if(error < 0)
347 printk(KERN_DEBUG "Unable to get irq\n"); 345 printk(KERN_DEBUG "Unable to get irq\n");
348#endif 346#endif
349 347
350 error = request_irq(IRQ_CGU_EVT, dpm0_isr, IRQF_NO_SUSPEND, "cgu0 event", NULL); 348 error = request_irq(IRQ_CGU_EVT, dpm0_isr, IRQF_NO_SUSPEND |
349 IRQF_FORCE_RESUME, "cgu0 event", NULL);
351 if(error < 0) 350 if(error < 0)
352 printk(KERN_DEBUG "Unable to get irq\n"); 351 printk(KERN_DEBUG "Unable to get irq\n");
353 352
354 error = request_irq(IRQ_DPM, dpm0_isr, IRQF_NO_SUSPEND, "dpm0 event", NULL); 353 error = request_irq(IRQ_DPM, dpm0_isr, IRQF_NO_SUSPEND |
354 IRQF_FORCE_RESUME, "dpm0 event", NULL);
355 if (error < 0) 355 if (error < 0)
356 printk(KERN_DEBUG "Unable to get irq\n"); 356 printk(KERN_DEBUG "Unable to get irq\n");
357 357
diff --git a/arch/blackfin/mach-common/clocks-init.c b/arch/blackfin/mach-common/clocks-init.c
index 7ad2407d157..2308ce52f84 100644
--- a/arch/blackfin/mach-common/clocks-init.c
+++ b/arch/blackfin/mach-common/clocks-init.c
@@ -16,23 +16,14 @@
16#include <asm/dpmc.h> 16#include <asm/dpmc.h>
17 17
18#ifdef CONFIG_BF60x 18#ifdef CONFIG_BF60x
19#define CSEL_P 0
20#define S0SEL_P 5
21#define SYSSEL_P 8
22#define S1SEL_P 13
23#define DSEL_P 16
24#define OSEL_P 22
25#define ALGN_P 29
26#define UPDT_P 30
27#define LOCK_P 31
28 19
29#define CGU_CTL_VAL ((CONFIG_VCO_MULT << 8) | CLKIN_HALF) 20#define CGU_CTL_VAL ((CONFIG_VCO_MULT << 8) | CLKIN_HALF)
30#define CGU_DIV_VAL \ 21#define CGU_DIV_VAL \
31 ((CONFIG_CCLK_DIV << CSEL_P) | \ 22 ((CONFIG_CCLK_DIV << CSEL_OFFSET) | \
32 (CONFIG_SCLK_DIV << SYSSEL_P) | \ 23 (CONFIG_SCLK_DIV << SYSSEL_OFFSET) | \
33 (CONFIG_SCLK0_DIV << S0SEL_P) | \ 24 (CONFIG_SCLK0_DIV << S0SEL_OFFSET) | \
34 (CONFIG_SCLK1_DIV << S1SEL_P) | \ 25 (CONFIG_SCLK1_DIV << S1SEL_OFFSET) | \
35 (CONFIG_DCLK_DIV << DSEL_P)) 26 (CONFIG_DCLK_DIV << DSEL_OFFSET))
36 27
37#define CONFIG_BFIN_DCLK (((CONFIG_CLKIN_HZ * CONFIG_VCO_MULT) / CONFIG_DCLK_DIV) / 1000000) 28#define CONFIG_BFIN_DCLK (((CONFIG_CLKIN_HZ * CONFIG_VCO_MULT) / CONFIG_DCLK_DIV) / 1000000)
38#if ((CONFIG_BFIN_DCLK != 125) && \ 29#if ((CONFIG_BFIN_DCLK != 125) && \
@@ -41,89 +32,7 @@
41 (CONFIG_BFIN_DCLK != 225) && (CONFIG_BFIN_DCLK != 250)) 32 (CONFIG_BFIN_DCLK != 225) && (CONFIG_BFIN_DCLK != 250))
42#error "DCLK must be in (125, 133, 150, 166, 200, 225, 250)MHz" 33#error "DCLK must be in (125, 133, 150, 166, 200, 225, 250)MHz"
43#endif 34#endif
44struct ddr_config {
45 u32 ddr_clk;
46 u32 dmc_ddrctl;
47 u32 dmc_ddrcfg;
48 u32 dmc_ddrtr0;
49 u32 dmc_ddrtr1;
50 u32 dmc_ddrtr2;
51 u32 dmc_ddrmr;
52 u32 dmc_ddrmr1;
53};
54 35
55struct ddr_config ddr_config_table[] __attribute__((section(".data_l1"))) = {
56 [0] = {
57 .ddr_clk = 125,
58 .dmc_ddrctl = 0x00000904,
59 .dmc_ddrcfg = 0x00000422,
60 .dmc_ddrtr0 = 0x20705212,
61 .dmc_ddrtr1 = 0x201003CF,
62 .dmc_ddrtr2 = 0x00320107,
63 .dmc_ddrmr = 0x00000422,
64 .dmc_ddrmr1 = 0x4,
65 },
66 [1] = {
67 .ddr_clk = 133,
68 .dmc_ddrctl = 0x00000904,
69 .dmc_ddrcfg = 0x00000422,
70 .dmc_ddrtr0 = 0x20806313,
71 .dmc_ddrtr1 = 0x2013040D,
72 .dmc_ddrtr2 = 0x00320108,
73 .dmc_ddrmr = 0x00000632,
74 .dmc_ddrmr1 = 0x4,
75 },
76 [2] = {
77 .ddr_clk = 150,
78 .dmc_ddrctl = 0x00000904,
79 .dmc_ddrcfg = 0x00000422,
80 .dmc_ddrtr0 = 0x20A07323,
81 .dmc_ddrtr1 = 0x20160492,
82 .dmc_ddrtr2 = 0x00320209,
83 .dmc_ddrmr = 0x00000632,
84 .dmc_ddrmr1 = 0x4,
85 },
86 [3] = {
87 .ddr_clk = 166,
88 .dmc_ddrctl = 0x00000904,
89 .dmc_ddrcfg = 0x00000422,
90 .dmc_ddrtr0 = 0x20A07323,
91 .dmc_ddrtr1 = 0x2016050E,
92 .dmc_ddrtr2 = 0x00320209,
93 .dmc_ddrmr = 0x00000632,
94 .dmc_ddrmr1 = 0x4,
95 },
96 [4] = {
97 .ddr_clk = 200,
98 .dmc_ddrctl = 0x00000904,
99 .dmc_ddrcfg = 0x00000422,
100 .dmc_ddrtr0 = 0x20a07323,
101 .dmc_ddrtr1 = 0x2016050f,
102 .dmc_ddrtr2 = 0x00320509,
103 .dmc_ddrmr = 0x00000632,
104 .dmc_ddrmr1 = 0x4,
105 },
106 [5] = {
107 .ddr_clk = 225,
108 .dmc_ddrctl = 0x00000904,
109 .dmc_ddrcfg = 0x00000422,
110 .dmc_ddrtr0 = 0x20E0A424,
111 .dmc_ddrtr1 = 0x302006DB,
112 .dmc_ddrtr2 = 0x0032020D,
113 .dmc_ddrmr = 0x00000842,
114 .dmc_ddrmr1 = 0x4,
115 },
116 [6] = {
117 .ddr_clk = 250,
118 .dmc_ddrctl = 0x00000904,
119 .dmc_ddrcfg = 0x00000422,
120 .dmc_ddrtr0 = 0x20E0A424,
121 .dmc_ddrtr1 = 0x3020079E,
122 .dmc_ddrtr2 = 0x0032020D,
123 .dmc_ddrmr = 0x00000842,
124 .dmc_ddrmr1 = 0x4,
125 },
126};
127#else 36#else
128#define SDGCTL_WIDTH (1 << 31) /* SDRAM external data path width */ 37#define SDGCTL_WIDTH (1 << 31) /* SDRAM external data path width */
129#define PLL_CTL_VAL \ 38#define PLL_CTL_VAL \
@@ -144,43 +53,9 @@ void init_clocks(void)
144 * in the middle of reprogramming things, and that'll screw us up. 53 * in the middle of reprogramming things, and that'll screw us up.
145 * For example, any automatic DMAs left by U-Boot for splash screens. 54 * For example, any automatic DMAs left by U-Boot for splash screens.
146 */ 55 */
147
148#ifdef CONFIG_BF60x 56#ifdef CONFIG_BF60x
149 int i, dlldatacycle, dll_ctl; 57 init_cgu(CGU_DIV_VAL, CGU_CTL_VAL);
150 bfin_write32(CGU0_DIV, CGU_DIV_VAL); 58 init_dmc(CONFIG_BFIN_DCLK);
151 bfin_write32(CGU0_CTL, CGU_CTL_VAL);
152 while ((bfin_read32(CGU0_STAT) & 0x8) || !(bfin_read32(CGU0_STAT) & 0x4))
153 continue;
154
155 bfin_write32(CGU0_DIV, CGU_DIV_VAL | (1 << UPDT_P));
156 while (bfin_read32(CGU0_STAT) & (1 << 3))
157 continue;
158
159 for (i = 0; i < 7; i++) {
160 if (ddr_config_table[i].ddr_clk == CONFIG_BFIN_DCLK) {
161 bfin_write_DDR0_CFG(ddr_config_table[i].dmc_ddrcfg);
162 bfin_write_DDR0_TR0(ddr_config_table[i].dmc_ddrtr0);
163 bfin_write_DDR0_TR1(ddr_config_table[i].dmc_ddrtr1);
164 bfin_write_DDR0_TR2(ddr_config_table[i].dmc_ddrtr2);
165 bfin_write_DDR0_MR(ddr_config_table[i].dmc_ddrmr);
166 bfin_write_DDR0_EMR1(ddr_config_table[i].dmc_ddrmr1);
167 bfin_write_DDR0_CTL(ddr_config_table[i].dmc_ddrctl);
168 break;
169 }
170 }
171
172 do_sync();
173 while (!(bfin_read_DDR0_STAT() & 0x4))
174 continue;
175
176 dlldatacycle = (bfin_read_DDR0_STAT() & 0x00f00000) >> 20;
177 dll_ctl = bfin_read_DDR0_DLLCTL();
178 dll_ctl &= 0x0ff;
179 bfin_write_DDR0_DLLCTL(dll_ctl | (dlldatacycle << 8));
180
181 do_sync();
182 while (!(bfin_read_DDR0_STAT() & 0x2000))
183 continue;
184#else 59#else
185 size_t i; 60 size_t i;
186 for (i = 0; i < MAX_DMA_CHANNELS; ++i) { 61 for (i = 0; i < MAX_DMA_CHANNELS; ++i) {
diff --git a/arch/blackfin/mach-common/cpufreq.c b/arch/blackfin/mach-common/cpufreq.c
index 6e87dc13f6b..c854a27cbea 100644
--- a/arch/blackfin/mach-common/cpufreq.c
+++ b/arch/blackfin/mach-common/cpufreq.c
@@ -64,7 +64,8 @@ static void __init bfin_init_tables(unsigned long cclk, unsigned long sclk)
64 64
65 /* Anomaly 273 seems to still exist on non-BF54x w/dcache turned on */ 65 /* Anomaly 273 seems to still exist on non-BF54x w/dcache turned on */
66#if ANOMALY_05000273 || ANOMALY_05000274 || \ 66#if ANOMALY_05000273 || ANOMALY_05000274 || \
67 (!defined(CONFIG_BF54x) && defined(CONFIG_BFIN_EXTMEM_DCACHEABLE)) 67 (!(defined(CONFIG_BF54x) || defined(CONFIG_BF60x)) \
68 && defined(CONFIG_BFIN_EXTMEM_DCACHEABLE))
68 min_cclk = sclk * 2; 69 min_cclk = sclk * 2;
69#else 70#else
70 min_cclk = sclk; 71 min_cclk = sclk;
@@ -173,7 +174,7 @@ static int bfin_target(struct cpufreq_policy *poli,
173#else 174#else
174 ret = cpu_set_cclk(cpu, freqs.new * 1000); 175 ret = cpu_set_cclk(cpu, freqs.new * 1000);
175 if (ret != 0) { 176 if (ret != 0) {
176 pr_debug("cpufreq set freq failed %d\n", ret); 177 WARN_ONCE(ret, "cpufreq set freq failed %d\n", ret);
177 break; 178 break;
178 } 179 }
179#endif 180#endif
diff --git a/arch/blackfin/mach-common/entry.S b/arch/blackfin/mach-common/entry.S
index 04c2fbe41a7..1c3d2c5bb0b 100644
--- a/arch/blackfin/mach-common/entry.S
+++ b/arch/blackfin/mach-common/entry.S
@@ -25,13 +25,6 @@
25 25
26#include <asm/context.S> 26#include <asm/context.S>
27 27
28#if defined(CONFIG_BFIN_SCRATCH_REG_RETN)
29# define EX_SCRATCH_REG RETN
30#elif defined(CONFIG_BFIN_SCRATCH_REG_RETE)
31# define EX_SCRATCH_REG RETE
32#else
33# define EX_SCRATCH_REG CYCLES
34#endif
35 28
36#ifdef CONFIG_EXCPT_IRQ_SYSC_L1 29#ifdef CONFIG_EXCPT_IRQ_SYSC_L1
37.section .l1.text 30.section .l1.text
diff --git a/arch/blackfin/mach-common/ints-priority.c b/arch/blackfin/mach-common/ints-priority.c
index 2729cba715b..7ca09ec2ca5 100644
--- a/arch/blackfin/mach-common/ints-priority.c
+++ b/arch/blackfin/mach-common/ints-priority.c
@@ -26,8 +26,9 @@
26#include <asm/gpio.h> 26#include <asm/gpio.h>
27#include <asm/irq_handler.h> 27#include <asm/irq_handler.h>
28#include <asm/dpmc.h> 28#include <asm/dpmc.h>
29#include <asm/traps.h>
29 30
30#ifndef CONFIG_BF60x 31#ifndef SEC_GCTL
31# define SIC_SYSIRQ(irq) (irq - (IRQ_CORETMR + 1)) 32# define SIC_SYSIRQ(irq) (irq - (IRQ_CORETMR + 1))
32#else 33#else
33# define SIC_SYSIRQ(irq) ((irq) - IVG15) 34# define SIC_SYSIRQ(irq) ((irq) - IVG15)
@@ -56,7 +57,7 @@ unsigned long bfin_sic_iwr[3]; /* Up to 3 SIC_IWRx registers */
56unsigned vr_wakeup; 57unsigned vr_wakeup;
57#endif 58#endif
58 59
59#ifndef CONFIG_BF60x 60#ifndef SEC_GCTL
60static struct ivgx { 61static struct ivgx {
61 /* irq number for request_irq, available in mach-bf5xx/irq.h */ 62 /* irq number for request_irq, available in mach-bf5xx/irq.h */
62 unsigned int irqno; 63 unsigned int irqno;
@@ -143,7 +144,7 @@ static void bfin_core_unmask_irq(struct irq_data *d)
143void bfin_internal_mask_irq(unsigned int irq) 144void bfin_internal_mask_irq(unsigned int irq)
144{ 145{
145 unsigned long flags = hard_local_irq_save(); 146 unsigned long flags = hard_local_irq_save();
146#ifndef CONFIG_BF60x 147#ifndef SEC_GCTL
147#ifdef SIC_IMASK0 148#ifdef SIC_IMASK0
148 unsigned mask_bank = SIC_SYSIRQ(irq) / 32; 149 unsigned mask_bank = SIC_SYSIRQ(irq) / 32;
149 unsigned mask_bit = SIC_SYSIRQ(irq) % 32; 150 unsigned mask_bit = SIC_SYSIRQ(irq) % 32;
@@ -175,7 +176,7 @@ void bfin_internal_unmask_irq(unsigned int irq)
175{ 176{
176 unsigned long flags = hard_local_irq_save(); 177 unsigned long flags = hard_local_irq_save();
177 178
178#ifndef CONFIG_BF60x 179#ifndef SEC_GCTL
179#ifdef SIC_IMASK0 180#ifdef SIC_IMASK0
180 unsigned mask_bank = SIC_SYSIRQ(irq) / 32; 181 unsigned mask_bank = SIC_SYSIRQ(irq) / 32;
181 unsigned mask_bit = SIC_SYSIRQ(irq) % 32; 182 unsigned mask_bit = SIC_SYSIRQ(irq) % 32;
@@ -199,7 +200,7 @@ void bfin_internal_unmask_irq(unsigned int irq)
199 hard_local_irq_restore(flags); 200 hard_local_irq_restore(flags);
200} 201}
201 202
202#ifdef CONFIG_BF60x 203#ifdef SEC_GCTL
203static void bfin_sec_preflow_handler(struct irq_data *d) 204static void bfin_sec_preflow_handler(struct irq_data *d)
204{ 205{
205 unsigned long flags = hard_local_irq_save(); 206 unsigned long flags = hard_local_irq_save();
@@ -310,7 +311,24 @@ static void bfin_sec_disable(struct irq_data *d)
310 hard_local_irq_restore(flags); 311 hard_local_irq_restore(flags);
311} 312}
312 313
313static void bfin_sec_raise_irq(unsigned int sid) 314static void bfin_sec_set_priority(unsigned int sec_int_levels, u8 *sec_int_priority)
315{
316 unsigned long flags = hard_local_irq_save();
317 uint32_t reg_sctl;
318 int i;
319
320 bfin_write_SEC_SCI(0, SEC_CPLVL, sec_int_levels);
321
322 for (i = 0; i < SYS_IRQS - BFIN_IRQ(0); i++) {
323 reg_sctl = bfin_read_SEC_SCTL(i) & ~SEC_SCTL_PRIO;
324 reg_sctl |= sec_int_priority[i] << SEC_SCTL_PRIO_OFFSET;
325 bfin_write_SEC_SCTL(i, reg_sctl);
326 }
327
328 hard_local_irq_restore(flags);
329}
330
331void bfin_sec_raise_irq(unsigned int sid)
314{ 332{
315 unsigned long flags = hard_local_irq_save(); 333 unsigned long flags = hard_local_irq_save();
316 334
@@ -396,24 +414,34 @@ void handle_sec_fault(unsigned int irq, struct irq_desc *desc)
396 raw_spin_unlock(&desc->lock); 414 raw_spin_unlock(&desc->lock);
397} 415}
398 416
399static int sec_suspend(void) 417void handle_core_fault(unsigned int irq, struct irq_desc *desc)
400{ 418{
401 return 0; 419 struct pt_regs *fp = get_irq_regs();
402}
403 420
404static void sec_resume(void) 421 raw_spin_lock(&desc->lock);
405{
406 bfin_write_SEC_SCI(0, SEC_CCTL, SEC_CCTL_RESET);
407 udelay(100);
408 bfin_write_SEC_GCTL(SEC_GCTL_EN);
409 bfin_write_SEC_SCI(0, SEC_CCTL, SEC_CCTL_EN | SEC_CCTL_NMI_EN);
410}
411 422
412static struct syscore_ops sec_pm_syscore_ops = { 423 switch (irq) {
413 .suspend = sec_suspend, 424 case IRQ_C0_DBL_FAULT:
414 .resume = sec_resume, 425 double_fault_c(fp);
415}; 426 break;
427 case IRQ_C0_HW_ERR:
428 dump_bfin_process(fp);
429 dump_bfin_mem(fp);
430 show_regs(fp);
431 printk(KERN_NOTICE "Kernel Stack\n");
432 show_stack(current, NULL);
433 print_modules();
434 panic("Kernel core hardware error");
435 break;
436 case IRQ_C0_NMI_L1_PARITY_ERR:
437 panic("NMI occurs unexpectedly");
438 break;
439 default:
440 panic("Core 1 fault occurs unexpectedly");
441 }
416 442
443 raw_spin_unlock(&desc->lock);
444}
417#endif 445#endif
418 446
419#ifdef CONFIG_SMP 447#ifdef CONFIG_SMP
@@ -437,7 +465,7 @@ static void bfin_internal_unmask_irq_chip(struct irq_data *d)
437} 465}
438#endif 466#endif
439 467
440#if defined(CONFIG_PM) && !defined(CONFIG_BF60x) 468#if defined(CONFIG_PM) && !defined(SEC_GCTL)
441int bfin_internal_set_wake(unsigned int irq, unsigned int state) 469int bfin_internal_set_wake(unsigned int irq, unsigned int state)
442{ 470{
443 u32 bank, bit, wakeup = 0; 471 u32 bank, bit, wakeup = 0;
@@ -496,7 +524,10 @@ static int bfin_internal_set_wake_chip(struct irq_data *d, unsigned int state)
496 return bfin_internal_set_wake(d->irq, state); 524 return bfin_internal_set_wake(d->irq, state);
497} 525}
498#else 526#else
499# define bfin_internal_set_wake(irq, state) 527inline int bfin_internal_set_wake(unsigned int irq, unsigned int state)
528{
529 return 0;
530}
500# define bfin_internal_set_wake_chip NULL 531# define bfin_internal_set_wake_chip NULL
501#endif 532#endif
502 533
@@ -518,7 +549,7 @@ static struct irq_chip bfin_internal_irqchip = {
518 .irq_set_wake = bfin_internal_set_wake_chip, 549 .irq_set_wake = bfin_internal_set_wake_chip,
519}; 550};
520 551
521#ifdef CONFIG_BF60x 552#ifdef SEC_GCTL
522static struct irq_chip bfin_sec_irqchip = { 553static struct irq_chip bfin_sec_irqchip = {
523 .name = "SEC", 554 .name = "SEC",
524 .irq_mask_ack = bfin_sec_mask_ack_irq, 555 .irq_mask_ack = bfin_sec_mask_ack_irq,
@@ -868,14 +899,6 @@ void bfin_demux_gpio_irq(unsigned int inta_irq,
868 899
869#else 900#else
870 901
871# ifndef CONFIG_BF60x
872#define NR_PINT_SYS_IRQS 4
873#define NR_PINTS 160
874# else
875#define NR_PINT_SYS_IRQS 6
876#define NR_PINTS 112
877#endif
878
879#define NR_PINT_BITS 32 902#define NR_PINT_BITS 32
880#define IRQ_NOT_AVAIL 0xFF 903#define IRQ_NOT_AVAIL 0xFF
881 904
@@ -897,29 +920,21 @@ static struct bfin_pint_regs * const pint[NR_PINT_SYS_IRQS] = {
897#endif 920#endif
898}; 921};
899 922
900#ifndef CONFIG_BF60x
901inline unsigned int get_irq_base(u32 bank, u8 bmap) 923inline unsigned int get_irq_base(u32 bank, u8 bmap)
902{ 924{
903 unsigned int irq_base; 925 unsigned int irq_base;
904 926
927#ifndef CONFIG_BF60x
905 if (bank < 2) { /*PA-PB */ 928 if (bank < 2) { /*PA-PB */
906 irq_base = IRQ_PA0 + bmap * 16; 929 irq_base = IRQ_PA0 + bmap * 16;
907 } else { /*PC-PJ */ 930 } else { /*PC-PJ */
908 irq_base = IRQ_PC0 + bmap * 16; 931 irq_base = IRQ_PC0 + bmap * 16;
909 } 932 }
910
911 return irq_base;
912}
913#else 933#else
914inline unsigned int get_irq_base(u32 bank, u8 bmap)
915{
916 unsigned int irq_base;
917
918 irq_base = IRQ_PA0 + bank * 16 + bmap * 16; 934 irq_base = IRQ_PA0 + bank * 16 + bmap * 16;
919 935#endif
920 return irq_base; 936 return irq_base;
921} 937}
922#endif
923 938
924 /* Whenever PINTx_ASSIGN is altered init_pint_lut() must be executed! */ 939 /* Whenever PINTx_ASSIGN is altered init_pint_lut() must be executed! */
925void init_pint_lut(void) 940void init_pint_lut(void)
@@ -1089,6 +1104,9 @@ static int bfin_gpio_irq_type(struct irq_data *d, unsigned int type)
1089} 1104}
1090 1105
1091#ifdef CONFIG_PM 1106#ifdef CONFIG_PM
1107static struct bfin_pm_pint_save save_pint_reg[NR_PINT_SYS_IRQS];
1108static u32 save_pint_sec_ctl[NR_PINT_SYS_IRQS];
1109
1092static int bfin_gpio_set_wake(struct irq_data *d, unsigned int state) 1110static int bfin_gpio_set_wake(struct irq_data *d, unsigned int state)
1093{ 1111{
1094 u32 pint_irq; 1112 u32 pint_irq;
@@ -1124,6 +1142,59 @@ static int bfin_gpio_set_wake(struct irq_data *d, unsigned int state)
1124 1142
1125 return 0; 1143 return 0;
1126} 1144}
1145
1146void bfin_pint_suspend(void)
1147{
1148 u32 bank;
1149
1150 for (bank = 0; bank < NR_PINT_SYS_IRQS; bank++) {
1151 save_pint_reg[bank].mask_set = pint[bank]->mask_set;
1152 save_pint_reg[bank].assign = pint[bank]->assign;
1153 save_pint_reg[bank].edge_set = pint[bank]->edge_set;
1154 save_pint_reg[bank].invert_set = pint[bank]->invert_set;
1155 }
1156}
1157
1158void bfin_pint_resume(void)
1159{
1160 u32 bank;
1161
1162 for (bank = 0; bank < NR_PINT_SYS_IRQS; bank++) {
1163 pint[bank]->mask_set = save_pint_reg[bank].mask_set;
1164 pint[bank]->assign = save_pint_reg[bank].assign;
1165 pint[bank]->edge_set = save_pint_reg[bank].edge_set;
1166 pint[bank]->invert_set = save_pint_reg[bank].invert_set;
1167 }
1168}
1169
1170#ifdef SEC_GCTL
1171static int sec_suspend(void)
1172{
1173 u32 bank;
1174
1175 for (bank = 0; bank < NR_PINT_SYS_IRQS; bank++)
1176 save_pint_sec_ctl[bank] = bfin_read_SEC_SCTL(bank + SIC_SYSIRQ(IRQ_PINT0));
1177 return 0;
1178}
1179
1180static void sec_resume(void)
1181{
1182 u32 bank;
1183
1184 bfin_write_SEC_SCI(0, SEC_CCTL, SEC_CCTL_RESET);
1185 udelay(100);
1186 bfin_write_SEC_GCTL(SEC_GCTL_EN);
1187 bfin_write_SEC_SCI(0, SEC_CCTL, SEC_CCTL_EN | SEC_CCTL_NMI_EN);
1188
1189 for (bank = 0; bank < NR_PINT_SYS_IRQS; bank++)
1190 bfin_write_SEC_SCTL(bank + SIC_SYSIRQ(IRQ_PINT0), save_pint_sec_ctl[bank]);
1191}
1192
1193static struct syscore_ops sec_pm_syscore_ops = {
1194 .suspend = sec_suspend,
1195 .resume = sec_resume,
1196};
1197#endif
1127#else 1198#else
1128# define bfin_gpio_set_wake NULL 1199# define bfin_gpio_set_wake NULL
1129#endif 1200#endif
@@ -1230,6 +1301,7 @@ void __cpuinit init_exception_vectors(void)
1230 CSYNC(); 1301 CSYNC();
1231} 1302}
1232 1303
1304#ifndef SEC_GCTL
1233/* 1305/*
1234 * This function should be called during kernel startup to initialize 1306 * This function should be called during kernel startup to initialize
1235 * the BFin IRQ handling routines. 1307 * the BFin IRQ handling routines.
@@ -1240,7 +1312,6 @@ int __init init_arch_irq(void)
1240 int irq; 1312 int irq;
1241 unsigned long ilat = 0; 1313 unsigned long ilat = 0;
1242 1314
1243#ifndef CONFIG_BF60x
1244 /* Disable all the peripheral intrs - page 4-29 HW Ref manual */ 1315 /* Disable all the peripheral intrs - page 4-29 HW Ref manual */
1245#ifdef SIC_IMASK0 1316#ifdef SIC_IMASK0
1246 bfin_write_SIC_IMASK0(SIC_UNMASK_ALL); 1317 bfin_write_SIC_IMASK0(SIC_UNMASK_ALL);
@@ -1255,9 +1326,6 @@ int __init init_arch_irq(void)
1255#else 1326#else
1256 bfin_write_SIC_IMASK(SIC_UNMASK_ALL); 1327 bfin_write_SIC_IMASK(SIC_UNMASK_ALL);
1257#endif 1328#endif
1258#else /* CONFIG_BF60x */
1259 bfin_write_SEC_GCTL(SEC_GCTL_RESET);
1260#endif
1261 1329
1262 local_irq_disable(); 1330 local_irq_disable();
1263 1331
@@ -1267,10 +1335,6 @@ int __init init_arch_irq(void)
1267 pint[1]->assign = CONFIG_PINT1_ASSIGN; 1335 pint[1]->assign = CONFIG_PINT1_ASSIGN;
1268 pint[2]->assign = CONFIG_PINT2_ASSIGN; 1336 pint[2]->assign = CONFIG_PINT2_ASSIGN;
1269 pint[3]->assign = CONFIG_PINT3_ASSIGN; 1337 pint[3]->assign = CONFIG_PINT3_ASSIGN;
1270# ifdef CONFIG_BF60x
1271 pint[4]->assign = CONFIG_PINT4_ASSIGN;
1272 pint[5]->assign = CONFIG_PINT5_ASSIGN;
1273# endif
1274# endif 1338# endif
1275 /* Whenever PINTx_ASSIGN is altered init_pint_lut() must be executed! */ 1339 /* Whenever PINTx_ASSIGN is altered init_pint_lut() must be executed! */
1276 init_pint_lut(); 1340 init_pint_lut();
@@ -1283,7 +1347,6 @@ int __init init_arch_irq(void)
1283 irq_set_chip(irq, &bfin_internal_irqchip); 1347 irq_set_chip(irq, &bfin_internal_irqchip);
1284 1348
1285 switch (irq) { 1349 switch (irq) {
1286#ifndef CONFIG_BF60x
1287#if BFIN_GPIO_PINT 1350#if BFIN_GPIO_PINT
1288 case IRQ_PINT0: 1351 case IRQ_PINT0:
1289 case IRQ_PINT1: 1352 case IRQ_PINT1:
@@ -1319,7 +1382,6 @@ int __init init_arch_irq(void)
1319 irq_set_handler(irq, handle_percpu_irq); 1382 irq_set_handler(irq, handle_percpu_irq);
1320 break; 1383 break;
1321#endif 1384#endif
1322#endif
1323 1385
1324#ifdef CONFIG_TICKSOURCE_CORETMR 1386#ifdef CONFIG_TICKSOURCE_CORETMR
1325 case IRQ_CORETMR: 1387 case IRQ_CORETMR:
@@ -1349,8 +1411,7 @@ int __init init_arch_irq(void)
1349 1411
1350 init_mach_irq(); 1412 init_mach_irq();
1351 1413
1352#ifndef CONFIG_BF60x 1414#if (defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE))
1353#if (defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)) && !defined(CONFIG_BF60x)
1354 for (irq = IRQ_MAC_PHYINT; irq <= IRQ_MAC_STMDONE; irq++) 1415 for (irq = IRQ_MAC_PHYINT; irq <= IRQ_MAC_STMDONE; irq++)
1355 irq_set_chip_and_handler(irq, &bfin_mac_status_irqchip, 1416 irq_set_chip_and_handler(irq, &bfin_mac_status_irqchip,
1356 handle_level_irq); 1417 handle_level_irq);
@@ -1360,28 +1421,6 @@ int __init init_arch_irq(void)
1360 irq < (GPIO_IRQ_BASE + MAX_BLACKFIN_GPIOS); irq++) 1421 irq < (GPIO_IRQ_BASE + MAX_BLACKFIN_GPIOS); irq++)
1361 irq_set_chip_and_handler(irq, &bfin_gpio_irqchip, 1422 irq_set_chip_and_handler(irq, &bfin_gpio_irqchip,
1362 handle_level_irq); 1423 handle_level_irq);
1363#else
1364 for (irq = BFIN_IRQ(0); irq <= SYS_IRQS; irq++) {
1365 if (irq < CORE_IRQS) {
1366 irq_set_chip(irq, &bfin_sec_irqchip);
1367 __irq_set_handler(irq, handle_sec_fault, 0, NULL);
1368 } else if (irq >= BFIN_IRQ(21) && irq <= BFIN_IRQ(26)) {
1369 irq_set_chip(irq, &bfin_sec_irqchip);
1370 irq_set_chained_handler(irq, bfin_demux_gpio_irq);
1371 } else if (irq >= BFIN_IRQ(34) && irq <= BFIN_IRQ(37)) {
1372 irq_set_chip(irq, &bfin_sec_irqchip);
1373 irq_set_handler(irq, handle_percpu_irq);
1374 } else {
1375 irq_set_chip_and_handler(irq, &bfin_sec_irqchip,
1376 handle_fasteoi_irq);
1377 __irq_set_preflow_handler(irq, bfin_sec_preflow_handler);
1378 }
1379 }
1380 for (irq = GPIO_IRQ_BASE;
1381 irq < (GPIO_IRQ_BASE + MAX_BLACKFIN_GPIOS); irq++)
1382 irq_set_chip_and_handler(irq, &bfin_gpio_irqchip,
1383 handle_level_irq);
1384#endif
1385 bfin_write_IMASK(0); 1424 bfin_write_IMASK(0);
1386 CSYNC(); 1425 CSYNC();
1387 ilat = bfin_read_ILAT(); 1426 ilat = bfin_read_ILAT();
@@ -1393,7 +1432,6 @@ int __init init_arch_irq(void)
1393 /* IMASK=xxx is equivalent to STI xx or bfin_irq_flags=xx, 1432 /* IMASK=xxx is equivalent to STI xx or bfin_irq_flags=xx,
1394 * local_irq_enable() 1433 * local_irq_enable()
1395 */ 1434 */
1396#ifndef CONFIG_BF60x
1397 program_IAR(); 1435 program_IAR();
1398 /* Therefore it's better to setup IARs before interrupts enabled */ 1436 /* Therefore it's better to setup IARs before interrupts enabled */
1399 search_IAR(); 1437 search_IAR();
@@ -1427,23 +1465,6 @@ int __init init_arch_irq(void)
1427#else 1465#else
1428 bfin_write_SIC_IWR(IWR_DISABLE_ALL); 1466 bfin_write_SIC_IWR(IWR_DISABLE_ALL);
1429#endif 1467#endif
1430#else /* CONFIG_BF60x */
1431 /* Enable interrupts IVG7-15 */
1432 bfin_irq_flags |= IMASK_IVG15 |
1433 IMASK_IVG14 | IMASK_IVG13 | IMASK_IVG12 | IMASK_IVG11 |
1434 IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 | IMASK_IVGHW;
1435
1436
1437 bfin_write_SEC_FCTL(SEC_FCTL_EN | SEC_FCTL_SYSRST_EN | SEC_FCTL_FLTIN_EN);
1438 bfin_sec_enable_sci(SIC_SYSIRQ(IRQ_WATCH0));
1439 bfin_sec_enable_ssi(SIC_SYSIRQ(IRQ_WATCH0));
1440 bfin_write_SEC_SCI(0, SEC_CCTL, SEC_CCTL_RESET);
1441 udelay(100);
1442 bfin_write_SEC_GCTL(SEC_GCTL_EN);
1443 bfin_write_SEC_SCI(0, SEC_CCTL, SEC_CCTL_EN | SEC_CCTL_NMI_EN);
1444 init_software_driven_irq();
1445 register_syscore_ops(&sec_pm_syscore_ops);
1446#endif
1447 return 0; 1468 return 0;
1448} 1469}
1449 1470
@@ -1452,14 +1473,11 @@ __attribute__((l1_text))
1452#endif 1473#endif
1453static int vec_to_irq(int vec) 1474static int vec_to_irq(int vec)
1454{ 1475{
1455#ifndef CONFIG_BF60x
1456 struct ivgx *ivg = ivg7_13[vec - IVG7].ifirst; 1476 struct ivgx *ivg = ivg7_13[vec - IVG7].ifirst;
1457 struct ivgx *ivg_stop = ivg7_13[vec - IVG7].istop; 1477 struct ivgx *ivg_stop = ivg7_13[vec - IVG7].istop;
1458 unsigned long sic_status[3]; 1478 unsigned long sic_status[3];
1459#endif
1460 if (likely(vec == EVT_IVTMR_P)) 1479 if (likely(vec == EVT_IVTMR_P))
1461 return IRQ_CORETMR; 1480 return IRQ_CORETMR;
1462#ifndef CONFIG_BF60x
1463#ifdef SIC_ISR 1481#ifdef SIC_ISR
1464 sic_status[0] = bfin_read_SIC_IMASK() & bfin_read_SIC_ISR(); 1482 sic_status[0] = bfin_read_SIC_IMASK() & bfin_read_SIC_ISR();
1465#else 1483#else
@@ -1488,11 +1506,119 @@ static int vec_to_irq(int vec)
1488#endif 1506#endif
1489 return ivg->irqno; 1507 return ivg->irqno;
1490 } 1508 }
1491#else 1509}
1492 /* for bf60x read */ 1510
1511#else /* SEC_GCTL */
1512
1513/*
1514 * This function should be called during kernel startup to initialize
1515 * the BFin IRQ handling routines.
1516 */
1517
1518int __init init_arch_irq(void)
1519{
1520 int irq;
1521 unsigned long ilat = 0;
1522
1523 bfin_write_SEC_GCTL(SEC_GCTL_RESET);
1524
1525 local_irq_disable();
1526
1527#if BFIN_GPIO_PINT
1528# ifdef CONFIG_PINTx_REASSIGN
1529 pint[0]->assign = CONFIG_PINT0_ASSIGN;
1530 pint[1]->assign = CONFIG_PINT1_ASSIGN;
1531 pint[2]->assign = CONFIG_PINT2_ASSIGN;
1532 pint[3]->assign = CONFIG_PINT3_ASSIGN;
1533 pint[4]->assign = CONFIG_PINT4_ASSIGN;
1534 pint[5]->assign = CONFIG_PINT5_ASSIGN;
1535# endif
1536 /* Whenever PINTx_ASSIGN is altered init_pint_lut() must be executed! */
1537 init_pint_lut();
1538#endif
1539
1540 for (irq = 0; irq <= SYS_IRQS; irq++) {
1541 if (irq <= IRQ_CORETMR) {
1542 irq_set_chip(irq, &bfin_core_irqchip);
1543#ifdef CONFIG_TICKSOURCE_CORETMR
1544 if (irq == IRQ_CORETMR)
1545# ifdef CONFIG_SMP
1546 irq_set_handler(irq, handle_percpu_irq);
1547# else
1548 irq_set_handler(irq, handle_simple_irq);
1549# endif
1550#endif
1551 } else if (irq < BFIN_IRQ(0)) {
1552 irq_set_chip_and_handler(irq, &bfin_internal_irqchip,
1553 handle_simple_irq);
1554 } else if (irq == IRQ_SEC_ERR) {
1555 irq_set_chip_and_handler(irq, &bfin_sec_irqchip,
1556 handle_sec_fault);
1557 } else if (irq < CORE_IRQS && irq >= IRQ_C0_DBL_FAULT) {
1558 irq_set_chip_and_handler(irq, &bfin_sec_irqchip,
1559 handle_core_fault);
1560 } else if (irq >= BFIN_IRQ(21) && irq <= BFIN_IRQ(26)) {
1561 irq_set_chip(irq, &bfin_sec_irqchip);
1562 irq_set_chained_handler(irq, bfin_demux_gpio_irq);
1563 } else if (irq >= BFIN_IRQ(34) && irq <= BFIN_IRQ(37)) {
1564 irq_set_chip(irq, &bfin_sec_irqchip);
1565 irq_set_handler(irq, handle_percpu_irq);
1566 } else {
1567 irq_set_chip_and_handler(irq, &bfin_sec_irqchip,
1568 handle_fasteoi_irq);
1569 __irq_set_preflow_handler(irq, bfin_sec_preflow_handler);
1570 }
1571 }
1572 for (irq = GPIO_IRQ_BASE;
1573 irq < (GPIO_IRQ_BASE + MAX_BLACKFIN_GPIOS); irq++)
1574 irq_set_chip_and_handler(irq, &bfin_gpio_irqchip,
1575 handle_level_irq);
1576
1577 bfin_write_IMASK(0);
1578 CSYNC();
1579 ilat = bfin_read_ILAT();
1580 CSYNC();
1581 bfin_write_ILAT(ilat);
1582 CSYNC();
1583
1584 printk(KERN_INFO "Configuring Blackfin Priority Driven Interrupts\n");
1585
1586 bfin_sec_set_priority(CONFIG_SEC_IRQ_PRIORITY_LEVELS, sec_int_priority);
1587
1588 bfin_sec_set_priority(CONFIG_SEC_IRQ_PRIORITY_LEVELS, sec_int_priority);
1589
1590 /* Enable interrupts IVG7-15 */
1591 bfin_irq_flags |= IMASK_IVG15 |
1592 IMASK_IVG14 | IMASK_IVG13 | IMASK_IVG12 | IMASK_IVG11 |
1593 IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 | IMASK_IVGHW;
1594
1595
1596 bfin_write_SEC_FCTL(SEC_FCTL_EN | SEC_FCTL_SYSRST_EN | SEC_FCTL_FLTIN_EN);
1597 bfin_sec_enable_sci(SIC_SYSIRQ(IRQ_WATCH0));
1598 bfin_sec_enable_ssi(SIC_SYSIRQ(IRQ_WATCH0));
1599 bfin_write_SEC_SCI(0, SEC_CCTL, SEC_CCTL_RESET);
1600 udelay(100);
1601 bfin_write_SEC_GCTL(SEC_GCTL_EN);
1602 bfin_write_SEC_SCI(0, SEC_CCTL, SEC_CCTL_EN | SEC_CCTL_NMI_EN);
1603 bfin_write_SEC_SCI(1, SEC_CCTL, SEC_CCTL_EN | SEC_CCTL_NMI_EN);
1604
1605 init_software_driven_irq();
1606 register_syscore_ops(&sec_pm_syscore_ops);
1607
1608 return 0;
1609}
1610
1611#ifdef CONFIG_DO_IRQ_L1
1612__attribute__((l1_text))
1613#endif
1614static int vec_to_irq(int vec)
1615{
1616 if (likely(vec == EVT_IVTMR_P))
1617 return IRQ_CORETMR;
1618
1493 return BFIN_IRQ(bfin_read_SEC_SCI(0, SEC_CSID)); 1619 return BFIN_IRQ(bfin_read_SEC_SCI(0, SEC_CSID));
1494#endif /* end of CONFIG_BF60x */
1495} 1620}
1621#endif /* SEC_GCTL */
1496 1622
1497#ifdef CONFIG_DO_IRQ_L1 1623#ifdef CONFIG_DO_IRQ_L1
1498__attribute__((l1_text)) 1624__attribute__((l1_text))
@@ -1514,6 +1640,10 @@ int __ipipe_get_irq_priority(unsigned irq)
1514 if (irq <= IRQ_CORETMR) 1640 if (irq <= IRQ_CORETMR)
1515 return irq; 1641 return irq;
1516 1642
1643#ifdef SEC_GCTL
1644 if (irq >= BFIN_IRQ(0))
1645 return IVG11;
1646#else
1517 for (ient = 0; ient < NR_PERI_INTS; ient++) { 1647 for (ient = 0; ient < NR_PERI_INTS; ient++) {
1518 struct ivgx *ivg = ivg_table + ient; 1648 struct ivgx *ivg = ivg_table + ient;
1519 if (ivg->irqno == irq) { 1649 if (ivg->irqno == irq) {
@@ -1524,6 +1654,7 @@ int __ipipe_get_irq_priority(unsigned irq)
1524 } 1654 }
1525 } 1655 }
1526 } 1656 }
1657#endif
1527 1658
1528 return IVG15; 1659 return IVG15;
1529} 1660}
@@ -1536,8 +1667,6 @@ asmlinkage int __ipipe_grab_irq(int vec, struct pt_regs *regs)
1536{ 1667{
1537 struct ipipe_percpu_domain_data *p = ipipe_root_cpudom_ptr(); 1668 struct ipipe_percpu_domain_data *p = ipipe_root_cpudom_ptr();
1538 struct ipipe_domain *this_domain = __ipipe_current_domain; 1669 struct ipipe_domain *this_domain = __ipipe_current_domain;
1539 struct ivgx *ivg_stop = ivg7_13[vec-IVG7].istop;
1540 struct ivgx *ivg = ivg7_13[vec-IVG7].ifirst;
1541 int irq, s = 0; 1670 int irq, s = 0;
1542 1671
1543 irq = vec_to_irq(vec); 1672 irq = vec_to_irq(vec);
diff --git a/arch/blackfin/mach-common/pm.c b/arch/blackfin/mach-common/pm.c
index ca6655e0d65..87bfe549ad3 100644
--- a/arch/blackfin/mach-common/pm.c
+++ b/arch/blackfin/mach-common/pm.c
@@ -172,6 +172,10 @@ int bfin_pm_suspend_mem_enter(void)
172 172
173 bfin_gpio_pm_hibernate_suspend(); 173 bfin_gpio_pm_hibernate_suspend();
174 174
175#if BFIN_GPIO_PINT
176 bfin_pint_suspend();
177#endif
178
175#if defined(CONFIG_BFIN_EXTMEM_WRITEBACK) || defined(CONFIG_BFIN_L2_WRITEBACK) 179#if defined(CONFIG_BFIN_EXTMEM_WRITEBACK) || defined(CONFIG_BFIN_L2_WRITEBACK)
176 flushinv_all_dcache(); 180 flushinv_all_dcache();
177#endif 181#endif
@@ -190,6 +194,10 @@ int bfin_pm_suspend_mem_enter(void)
190 _enable_icplb(); 194 _enable_icplb();
191 _enable_dcplb(); 195 _enable_dcplb();
192 196
197#if BFIN_GPIO_PINT
198 bfin_pint_resume();
199#endif
200
193 bfin_gpio_pm_hibernate_restore(); 201 bfin_gpio_pm_hibernate_restore();
194 blackfin_dma_resume(); 202 blackfin_dma_resume();
195 203
diff --git a/arch/c6x/Kconfig b/arch/c6x/Kconfig
index 052f81a7623..983c859e40b 100644
--- a/arch/c6x/Kconfig
+++ b/arch/c6x/Kconfig
@@ -6,6 +6,7 @@
6config C6X 6config C6X
7 def_bool y 7 def_bool y
8 select CLKDEV_LOOKUP 8 select CLKDEV_LOOKUP
9 select GENERIC_ATOMIC64
9 select GENERIC_IRQ_SHOW 10 select GENERIC_IRQ_SHOW
10 select HAVE_ARCH_TRACEHOOK 11 select HAVE_ARCH_TRACEHOOK
11 select HAVE_DMA_API_DEBUG 12 select HAVE_DMA_API_DEBUG
diff --git a/arch/c6x/boot/dts/evmc6678.dts b/arch/c6x/boot/dts/evmc6678.dts
new file mode 100644
index 00000000000..ab686301d32
--- /dev/null
+++ b/arch/c6x/boot/dts/evmc6678.dts
@@ -0,0 +1,83 @@
1/*
2 * arch/c6x/boot/dts/evmc6678.dts
3 *
4 * EVMC6678 Evaluation Platform For TMS320C6678
5 *
6 * Copyright (C) 2012 Texas Instruments Incorporated
7 *
8 * Author: Ken Cox <jkc@redhat.com>
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 2
13 * of the License, or (at your option) any later version.
14 *
15 */
16
17/dts-v1/;
18
19/include/ "tms320c6678.dtsi"
20
21/ {
22 model = "Advantech EVMC6678";
23 compatible = "advantech,evmc6678";
24
25 chosen {
26 bootargs = "root=/dev/nfs ip=dhcp rw";
27 };
28
29 memory {
30 device_type = "memory";
31 reg = <0x80000000 0x20000000>;
32 };
33
34 soc {
35 megamod_pic: interrupt-controller@1800000 {
36 interrupts = < 12 13 14 15 >;
37 };
38
39 timer8: timer@2280000 {
40 interrupt-parent = <&megamod_pic>;
41 interrupts = < 66 >;
42 };
43
44 timer9: timer@2290000 {
45 interrupt-parent = <&megamod_pic>;
46 interrupts = < 68 >;
47 };
48
49 timer10: timer@22A0000 {
50 interrupt-parent = <&megamod_pic>;
51 interrupts = < 70 >;
52 };
53
54 timer11: timer@22B0000 {
55 interrupt-parent = <&megamod_pic>;
56 interrupts = < 72 >;
57 };
58
59 timer12: timer@22C0000 {
60 interrupt-parent = <&megamod_pic>;
61 interrupts = < 74 >;
62 };
63
64 timer13: timer@22D0000 {
65 interrupt-parent = <&megamod_pic>;
66 interrupts = < 76 >;
67 };
68
69 timer14: timer@22E0000 {
70 interrupt-parent = <&megamod_pic>;
71 interrupts = < 78 >;
72 };
73
74 timer15: timer@22F0000 {
75 interrupt-parent = <&megamod_pic>;
76 interrupts = < 80 >;
77 };
78
79 clock-controller@2310000 {
80 clock-frequency = <100000000>;
81 };
82 };
83};
diff --git a/arch/c6x/boot/dts/tms320c6678.dtsi b/arch/c6x/boot/dts/tms320c6678.dtsi
new file mode 100644
index 00000000000..386196e5eae
--- /dev/null
+++ b/arch/c6x/boot/dts/tms320c6678.dtsi
@@ -0,0 +1,146 @@
1
2/ {
3 #address-cells = <1>;
4 #size-cells = <1>;
5
6 cpus {
7 #address-cells = <1>;
8 #size-cells = <0>;
9
10 cpu@0 {
11 device_type = "cpu";
12 reg = <0>;
13 model = "ti,c66x";
14 };
15 cpu@1 {
16 device_type = "cpu";
17 reg = <1>;
18 model = "ti,c66x";
19 };
20 cpu@2 {
21 device_type = "cpu";
22 reg = <2>;
23 model = "ti,c66x";
24 };
25 cpu@3 {
26 device_type = "cpu";
27 reg = <3>;
28 model = "ti,c66x";
29 };
30 cpu@4 {
31 device_type = "cpu";
32 reg = <4>;
33 model = "ti,c66x";
34 };
35 cpu@5 {
36 device_type = "cpu";
37 reg = <5>;
38 model = "ti,c66x";
39 };
40 cpu@6 {
41 device_type = "cpu";
42 reg = <6>;
43 model = "ti,c66x";
44 };
45 cpu@7 {
46 device_type = "cpu";
47 reg = <7>;
48 model = "ti,c66x";
49 };
50 };
51
52 soc {
53 compatible = "simple-bus";
54 model = "tms320c6678";
55 #address-cells = <1>;
56 #size-cells = <1>;
57 ranges;
58
59 core_pic: interrupt-controller {
60 compatible = "ti,c64x+core-pic";
61 interrupt-controller;
62 #interrupt-cells = <1>;
63 };
64
65 megamod_pic: interrupt-controller@1800000 {
66 compatible = "ti,c64x+megamod-pic";
67 interrupt-controller;
68 #interrupt-cells = <1>;
69 reg = <0x1800000 0x1000>;
70 interrupt-parent = <&core_pic>;
71 };
72
73 cache-controller@1840000 {
74 compatible = "ti,c64x+cache";
75 reg = <0x01840000 0x8400>;
76 };
77
78 timer8: timer@2280000 {
79 compatible = "ti,c64x+timer64";
80 ti,core-mask = < 0x01 >;
81 reg = <0x2280000 0x40>;
82 };
83
84 timer9: timer@2290000 {
85 compatible = "ti,c64x+timer64";
86 ti,core-mask = < 0x02 >;
87 reg = <0x2290000 0x40>;
88 };
89
90 timer10: timer@22A0000 {
91 compatible = "ti,c64x+timer64";
92 ti,core-mask = < 0x04 >;
93 reg = <0x22A0000 0x40>;
94 };
95
96 timer11: timer@22B0000 {
97 compatible = "ti,c64x+timer64";
98 ti,core-mask = < 0x08 >;
99 reg = <0x22B0000 0x40>;
100 };
101
102 timer12: timer@22C0000 {
103 compatible = "ti,c64x+timer64";
104 ti,core-mask = < 0x10 >;
105 reg = <0x22C0000 0x40>;
106 };
107
108 timer13: timer@22D0000 {
109 compatible = "ti,c64x+timer64";
110 ti,core-mask = < 0x20 >;
111 reg = <0x22D0000 0x40>;
112 };
113
114 timer14: timer@22E0000 {
115 compatible = "ti,c64x+timer64";
116 ti,core-mask = < 0x40 >;
117 reg = <0x22E0000 0x40>;
118 };
119
120 timer15: timer@22F0000 {
121 compatible = "ti,c64x+timer64";
122 ti,core-mask = < 0x80 >;
123 reg = <0x22F0000 0x40>;
124 };
125
126 clock-controller@2310000 {
127 compatible = "ti,c6678-pll", "ti,c64x+pll";
128 reg = <0x02310000 0x200>;
129 ti,c64x+pll-bypass-delay = <200>;
130 ti,c64x+pll-reset-delay = <12000>;
131 ti,c64x+pll-lock-delay = <80000>;
132 };
133
134 device-state-controller@2620000 {
135 compatible = "ti,c64x+dscr";
136 reg = <0x02620000 0x1000>;
137
138 ti,dscr-devstat = <0x20>;
139 ti,dscr-silicon-rev = <0x18 28 0xf>;
140
141 ti,dscr-mac-fuse-regs = <0x110 1 2 3 4
142 0x114 5 6 0 0>;
143
144 };
145 };
146};
diff --git a/arch/c6x/configs/evmc6678_defconfig b/arch/c6x/configs/evmc6678_defconfig
new file mode 100644
index 00000000000..5f126d4905b
--- /dev/null
+++ b/arch/c6x/configs/evmc6678_defconfig
@@ -0,0 +1,42 @@
1CONFIG_SOC_TMS320C6678=y
2CONFIG_EXPERIMENTAL=y
3# CONFIG_LOCALVERSION_AUTO is not set
4CONFIG_SYSVIPC=y
5CONFIG_SPARSE_IRQ=y
6CONFIG_LOG_BUF_SHIFT=14
7CONFIG_NAMESPACES=y
8# CONFIG_UTS_NS is not set
9# CONFIG_USER_NS is not set
10# CONFIG_PID_NS is not set
11CONFIG_BLK_DEV_INITRD=y
12CONFIG_CC_OPTIMIZE_FOR_SIZE=y
13CONFIG_EXPERT=y
14# CONFIG_FUTEX is not set
15# CONFIG_SLUB_DEBUG is not set
16CONFIG_MODULES=y
17CONFIG_MODULE_FORCE_LOAD=y
18CONFIG_MODULE_UNLOAD=y
19CONFIG_MODULE_FORCE_UNLOAD=y
20CONFIG_CMDLINE_BOOL=y
21CONFIG_CMDLINE=""
22# CONFIG_CMDLINE_FORCE is not set
23CONFIG_BOARD_EVM6678=y
24CONFIG_NO_HZ=y
25CONFIG_HIGH_RES_TIMERS=y
26CONFIG_BLK_DEV_LOOP=y
27CONFIG_BLK_DEV_RAM=y
28CONFIG_BLK_DEV_RAM_COUNT=2
29CONFIG_BLK_DEV_RAM_SIZE=17000
30CONFIG_MISC_DEVICES=y
31# CONFIG_INPUT is not set
32# CONFIG_SERIO is not set
33# CONFIG_VT is not set
34# CONFIG_HW_RANDOM is not set
35# CONFIG_HWMON is not set
36# CONFIG_USB_SUPPORT is not set
37# CONFIG_IOMMU_SUPPORT is not set
38# CONFIG_MISC_FILESYSTEMS is not set
39CONFIG_CRC16=y
40# CONFIG_ENABLE_MUST_CHECK is not set
41# CONFIG_SCHED_DEBUG is not set
42# CONFIG_DEBUG_BUGVERBOSE is not set
diff --git a/arch/c6x/include/asm/cache.h b/arch/c6x/include/asm/cache.h
index 6d521d96d94..09c5a0f5f4d 100644
--- a/arch/c6x/include/asm/cache.h
+++ b/arch/c6x/include/asm/cache.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Port on Texas Instruments TMS320C6x architecture 2 * Port on Texas Instruments TMS320C6x architecture
3 * 3 *
4 * Copyright (C) 2005, 2006, 2009, 2010 Texas Instruments Incorporated 4 * Copyright (C) 2005, 2006, 2009, 2010, 2012 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com) 5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -16,9 +16,14 @@
16/* 16/*
17 * Cache line size 17 * Cache line size
18 */ 18 */
19#define L1D_CACHE_BYTES 64 19#define L1D_CACHE_SHIFT 6
20#define L1P_CACHE_BYTES 32 20#define L1D_CACHE_BYTES (1 << L1D_CACHE_SHIFT)
21#define L2_CACHE_BYTES 128 21
22#define L1P_CACHE_SHIFT 5
23#define L1P_CACHE_BYTES (1 << L1P_CACHE_SHIFT)
24
25#define L2_CACHE_SHIFT 7
26#define L2_CACHE_BYTES (1 << L2_CACHE_SHIFT)
22 27
23/* 28/*
24 * L2 used as cache 29 * L2 used as cache
@@ -29,7 +34,8 @@
29 * For practical reasons the L1_CACHE_BYTES defines should not be smaller than 34 * For practical reasons the L1_CACHE_BYTES defines should not be smaller than
30 * the L2 line size 35 * the L2 line size
31 */ 36 */
32#define L1_CACHE_BYTES L2_CACHE_BYTES 37#define L1_CACHE_SHIFT L2_CACHE_SHIFT
38#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
33 39
34#define L2_CACHE_ALIGN_LOW(x) \ 40#define L2_CACHE_ALIGN_LOW(x) \
35 (((x) & ~(L2_CACHE_BYTES - 1))) 41 (((x) & ~(L2_CACHE_BYTES - 1)))
diff --git a/arch/c6x/include/asm/irq.h b/arch/c6x/include/asm/irq.h
index ab4577f93d9..1324e62bd4e 100644
--- a/arch/c6x/include/asm/irq.h
+++ b/arch/c6x/include/asm/irq.h
@@ -34,8 +34,6 @@
34 */ 34 */
35#define NR_PRIORITY_IRQS 16 35#define NR_PRIORITY_IRQS 16
36 36
37#define NR_IRQS_LEGACY NR_PRIORITY_IRQS
38
39/* Total number of virq in the platform */ 37/* Total number of virq in the platform */
40#define NR_IRQS 256 38#define NR_IRQS 256
41 39
diff --git a/arch/c6x/kernel/irq.c b/arch/c6x/kernel/irq.c
index c90fb5e82ad..247e0eb5e46 100644
--- a/arch/c6x/kernel/irq.c
+++ b/arch/c6x/kernel/irq.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2011 Texas Instruments Incorporated 2 * Copyright (C) 2011-2012 Texas Instruments Incorporated
3 * 3 *
4 * This borrows heavily from powerpc version, which is: 4 * This borrows heavily from powerpc version, which is:
5 * 5 *
@@ -35,9 +35,7 @@ static DEFINE_RAW_SPINLOCK(core_irq_lock);
35 35
36static void mask_core_irq(struct irq_data *data) 36static void mask_core_irq(struct irq_data *data)
37{ 37{
38 unsigned int prio = data->irq; 38 unsigned int prio = data->hwirq;
39
40 BUG_ON(prio < 4 || prio >= NR_PRIORITY_IRQS);
41 39
42 raw_spin_lock(&core_irq_lock); 40 raw_spin_lock(&core_irq_lock);
43 and_creg(IER, ~(1 << prio)); 41 and_creg(IER, ~(1 << prio));
@@ -46,7 +44,7 @@ static void mask_core_irq(struct irq_data *data)
46 44
47static void unmask_core_irq(struct irq_data *data) 45static void unmask_core_irq(struct irq_data *data)
48{ 46{
49 unsigned int prio = data->irq; 47 unsigned int prio = data->hwirq;
50 48
51 raw_spin_lock(&core_irq_lock); 49 raw_spin_lock(&core_irq_lock);
52 or_creg(IER, 1 << prio); 50 or_creg(IER, 1 << prio);
@@ -59,15 +57,15 @@ static struct irq_chip core_chip = {
59 .irq_unmask = unmask_core_irq, 57 .irq_unmask = unmask_core_irq,
60}; 58};
61 59
60static int prio_to_virq[NR_PRIORITY_IRQS];
61
62asmlinkage void c6x_do_IRQ(unsigned int prio, struct pt_regs *regs) 62asmlinkage void c6x_do_IRQ(unsigned int prio, struct pt_regs *regs)
63{ 63{
64 struct pt_regs *old_regs = set_irq_regs(regs); 64 struct pt_regs *old_regs = set_irq_regs(regs);
65 65
66 irq_enter(); 66 irq_enter();
67 67
68 BUG_ON(prio < 4 || prio >= NR_PRIORITY_IRQS); 68 generic_handle_irq(prio_to_virq[prio]);
69
70 generic_handle_irq(prio);
71 69
72 irq_exit(); 70 irq_exit();
73 71
@@ -82,6 +80,8 @@ static int core_domain_map(struct irq_domain *h, unsigned int virq,
82 if (hw < 4 || hw >= NR_PRIORITY_IRQS) 80 if (hw < 4 || hw >= NR_PRIORITY_IRQS)
83 return -EINVAL; 81 return -EINVAL;
84 82
83 prio_to_virq[hw] = virq;
84
85 irq_set_status_flags(virq, IRQ_LEVEL); 85 irq_set_status_flags(virq, IRQ_LEVEL);
86 irq_set_chip_and_handler(virq, &core_chip, handle_level_irq); 86 irq_set_chip_and_handler(virq, &core_chip, handle_level_irq);
87 return 0; 87 return 0;
@@ -102,9 +102,8 @@ void __init init_IRQ(void)
102 np = of_find_compatible_node(NULL, NULL, "ti,c64x+core-pic"); 102 np = of_find_compatible_node(NULL, NULL, "ti,c64x+core-pic");
103 if (np != NULL) { 103 if (np != NULL) {
104 /* create the core host */ 104 /* create the core host */
105 core_domain = irq_domain_add_legacy(np, NR_PRIORITY_IRQS, 105 core_domain = irq_domain_add_linear(np, NR_PRIORITY_IRQS,
106 0, 0, &core_domain_ops, 106 &core_domain_ops, NULL);
107 NULL);
108 if (core_domain) 107 if (core_domain)
109 irq_set_default_host(core_domain); 108 irq_set_default_host(core_domain);
110 of_node_put(np); 109 of_node_put(np);
diff --git a/arch/c6x/kernel/setup.c b/arch/c6x/kernel/setup.c
index ce46186600c..f4e72bd8c10 100644
--- a/arch/c6x/kernel/setup.c
+++ b/arch/c6x/kernel/setup.c
@@ -143,6 +143,10 @@ static void __init get_cpuinfo(void)
143 p->cpu_name = "C64x+"; 143 p->cpu_name = "C64x+";
144 p->cpu_voltage = "1.2"; 144 p->cpu_voltage = "1.2";
145 break; 145 break;
146 case 21:
147 p->cpu_name = "C66X";
148 p->cpu_voltage = "1.2";
149 break;
146 default: 150 default:
147 p->cpu_name = "unknown"; 151 p->cpu_name = "unknown";
148 break; 152 break;
diff --git a/arch/c6x/kernel/signal.c b/arch/c6x/kernel/signal.c
index 3d8f3c22a94..3998b24e26f 100644
--- a/arch/c6x/kernel/signal.c
+++ b/arch/c6x/kernel/signal.c
@@ -249,8 +249,6 @@ static void handle_signal(int sig,
249 siginfo_t *info, struct k_sigaction *ka, 249 siginfo_t *info, struct k_sigaction *ka,
250 struct pt_regs *regs, int syscall) 250 struct pt_regs *regs, int syscall)
251{ 251{
252 int ret;
253
254 /* Are we from a system call? */ 252 /* Are we from a system call? */
255 if (syscall) { 253 if (syscall) {
256 /* If so, check system call restarting.. */ 254 /* If so, check system call restarting.. */
diff --git a/arch/c6x/kernel/soc.c b/arch/c6x/kernel/soc.c
index 0748c94ebef..3ac74080fde 100644
--- a/arch/c6x/kernel/soc.c
+++ b/arch/c6x/kernel/soc.c
@@ -80,7 +80,7 @@ int soc_mac_addr(unsigned int index, u8 *addr)
80 if (have_fuse_mac) 80 if (have_fuse_mac)
81 memcpy(addr, c6x_fuse_mac, 6); 81 memcpy(addr, c6x_fuse_mac, 6);
82 else 82 else
83 random_ether_addr(addr); 83 eth_random_addr(addr);
84 } 84 }
85 85
86 /* adjust for specific EMAC device */ 86 /* adjust for specific EMAC device */
diff --git a/arch/c6x/platforms/Kconfig b/arch/c6x/platforms/Kconfig
index 401ee678fd0..c4a0fad89aa 100644
--- a/arch/c6x/platforms/Kconfig
+++ b/arch/c6x/platforms/Kconfig
@@ -14,3 +14,7 @@ config SOC_TMS320C6472
14config SOC_TMS320C6474 14config SOC_TMS320C6474
15 bool "TMS320C6474" 15 bool "TMS320C6474"
16 default n 16 default n
17
18config SOC_TMS320C6678
19 bool "TMS320C6678"
20 default n
diff --git a/arch/c6x/platforms/megamod-pic.c b/arch/c6x/platforms/megamod-pic.c
index c1c4e2ae3f8..74e3371eb82 100644
--- a/arch/c6x/platforms/megamod-pic.c
+++ b/arch/c6x/platforms/megamod-pic.c
@@ -243,27 +243,37 @@ static struct megamod_pic * __init init_megamod_pic(struct device_node *np)
243 * as their interrupt parent. 243 * as their interrupt parent.
244 */ 244 */
245 for (i = 0; i < NR_COMBINERS; i++) { 245 for (i = 0; i < NR_COMBINERS; i++) {
246 struct irq_data *irq_data;
247 irq_hw_number_t hwirq;
246 248
247 irq = irq_of_parse_and_map(np, i); 249 irq = irq_of_parse_and_map(np, i);
248 if (irq == NO_IRQ) 250 if (irq == NO_IRQ)
249 continue; 251 continue;
250 252
253 irq_data = irq_get_irq_data(irq);
254 if (!irq_data) {
255 pr_err("%s: combiner-%d no irq_data for virq %d!\n",
256 np->full_name, i, irq);
257 continue;
258 }
259
260 hwirq = irq_data->hwirq;
261
251 /* 262 /*
252 * We count on the core priority interrupts (4 - 15) being 263 * Check that device tree provided something in the range
253 * direct mapped. Check that device tree provided something 264 * of the core priority interrupts (4 - 15).
254 * in that range.
255 */ 265 */
256 if (irq < 4 || irq >= NR_PRIORITY_IRQS) { 266 if (hwirq < 4 || hwirq >= NR_PRIORITY_IRQS) {
257 pr_err("%s: combiner-%d virq %d out of range!\n", 267 pr_err("%s: combiner-%d core irq %ld out of range!\n",
258 np->full_name, i, irq); 268 np->full_name, i, hwirq);
259 continue; 269 continue;
260 } 270 }
261 271
262 /* record the mapping */ 272 /* record the mapping */
263 mapping[irq - 4] = i; 273 mapping[hwirq - 4] = i;
264 274
265 pr_debug("%s: combiner-%d cascading to virq %d\n", 275 pr_debug("%s: combiner-%d cascading to hwirq %ld\n",
266 np->full_name, i, irq); 276 np->full_name, i, hwirq);
267 277
268 cascade_data[i].pic = pic; 278 cascade_data[i].pic = pic;
269 cascade_data[i].index = i; 279 cascade_data[i].index = i;
diff --git a/arch/c6x/platforms/plldata.c b/arch/c6x/platforms/plldata.c
index 2cfd6f42968..755359eb628 100644
--- a/arch/c6x/platforms/plldata.c
+++ b/arch/c6x/platforms/plldata.c
@@ -335,6 +335,68 @@ static void __init c6474_setup_clocks(struct device_node *node)
335} 335}
336#endif /* CONFIG_SOC_TMS320C6474 */ 336#endif /* CONFIG_SOC_TMS320C6474 */
337 337
338#ifdef CONFIG_SOC_TMS320C6678
339static struct clk_lookup c6678_clks[] = {
340 CLK(NULL, "pll1", &c6x_soc_pll1.sysclks[0]),
341 CLK(NULL, "pll1_refclk", &c6x_soc_pll1.sysclks[1]),
342 CLK(NULL, "pll1_sysclk2", &c6x_soc_pll1.sysclks[2]),
343 CLK(NULL, "pll1_sysclk3", &c6x_soc_pll1.sysclks[3]),
344 CLK(NULL, "pll1_sysclk4", &c6x_soc_pll1.sysclks[4]),
345 CLK(NULL, "pll1_sysclk5", &c6x_soc_pll1.sysclks[5]),
346 CLK(NULL, "pll1_sysclk6", &c6x_soc_pll1.sysclks[6]),
347 CLK(NULL, "pll1_sysclk7", &c6x_soc_pll1.sysclks[7]),
348 CLK(NULL, "pll1_sysclk8", &c6x_soc_pll1.sysclks[8]),
349 CLK(NULL, "pll1_sysclk9", &c6x_soc_pll1.sysclks[9]),
350 CLK(NULL, "pll1_sysclk10", &c6x_soc_pll1.sysclks[10]),
351 CLK(NULL, "pll1_sysclk11", &c6x_soc_pll1.sysclks[11]),
352 CLK(NULL, "core", &c6x_core_clk),
353 CLK("", NULL, NULL)
354};
355
356static void __init c6678_setup_clocks(struct device_node *node)
357{
358 struct pll_data *pll = &c6x_soc_pll1;
359 struct clk *sysclks = pll->sysclks;
360
361 pll->flags = PLL_HAS_MUL;
362
363 sysclks[1].flags |= FIXED_DIV_PLL;
364 sysclks[1].div = 1;
365
366 sysclks[2].div = PLLDIV2;
367
368 sysclks[3].flags |= FIXED_DIV_PLL;
369 sysclks[3].div = 2;
370
371 sysclks[4].flags |= FIXED_DIV_PLL;
372 sysclks[4].div = 3;
373
374 sysclks[5].div = PLLDIV5;
375
376 sysclks[6].flags |= FIXED_DIV_PLL;
377 sysclks[6].div = 64;
378
379 sysclks[7].flags |= FIXED_DIV_PLL;
380 sysclks[7].div = 6;
381
382 sysclks[8].div = PLLDIV8;
383
384 sysclks[9].flags |= FIXED_DIV_PLL;
385 sysclks[9].div = 12;
386
387 sysclks[10].flags |= FIXED_DIV_PLL;
388 sysclks[10].div = 3;
389
390 sysclks[11].flags |= FIXED_DIV_PLL;
391 sysclks[11].div = 6;
392
393 c6x_core_clk.parent = &sysclks[0];
394 c6x_i2c_clk.parent = &sysclks[7];
395
396 c6x_clks_init(c6678_clks);
397}
398#endif /* CONFIG_SOC_TMS320C6678 */
399
338static struct of_device_id c6x_clkc_match[] __initdata = { 400static struct of_device_id c6x_clkc_match[] __initdata = {
339#ifdef CONFIG_SOC_TMS320C6455 401#ifdef CONFIG_SOC_TMS320C6455
340 { .compatible = "ti,c6455-pll", .data = c6455_setup_clocks }, 402 { .compatible = "ti,c6455-pll", .data = c6455_setup_clocks },
@@ -348,6 +410,9 @@ static struct of_device_id c6x_clkc_match[] __initdata = {
348#ifdef CONFIG_SOC_TMS320C6474 410#ifdef CONFIG_SOC_TMS320C6474
349 { .compatible = "ti,c6474-pll", .data = c6474_setup_clocks }, 411 { .compatible = "ti,c6474-pll", .data = c6474_setup_clocks },
350#endif 412#endif
413#ifdef CONFIG_SOC_TMS320C6678
414 { .compatible = "ti,c6678-pll", .data = c6678_setup_clocks },
415#endif
351 { .compatible = "ti,c64x+pll" }, 416 { .compatible = "ti,c64x+pll" },
352 {} 417 {}
353}; 418};
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig
index bb344650a14..e92215428a3 100644
--- a/arch/cris/Kconfig
+++ b/arch/cris/Kconfig
@@ -42,6 +42,7 @@ config CRIS
42 select HAVE_IDE 42 select HAVE_IDE
43 select GENERIC_ATOMIC64 43 select GENERIC_ATOMIC64
44 select HAVE_GENERIC_HARDIRQS 44 select HAVE_GENERIC_HARDIRQS
45 select ARCH_WANT_IPC_PARSE_VERSION
45 select GENERIC_IRQ_SHOW 46 select GENERIC_IRQ_SHOW
46 select GENERIC_IOMAP 47 select GENERIC_IOMAP
47 select GENERIC_SMP_IDLE_THREAD if ETRAX_ARCH_V32 48 select GENERIC_SMP_IDLE_THREAD if ETRAX_ARCH_V32
diff --git a/arch/cris/arch-v32/drivers/pci/bios.c b/arch/cris/arch-v32/drivers/pci/bios.c
index bc0cfdad1cb..5b1ee82f63c 100644
--- a/arch/cris/arch-v32/drivers/pci/bios.c
+++ b/arch/cris/arch-v32/drivers/pci/bios.c
@@ -6,11 +6,6 @@ void __devinit pcibios_fixup_bus(struct pci_bus *b)
6{ 6{
7} 7}
8 8
9char * __devinit pcibios_setup(char *str)
10{
11 return NULL;
12}
13
14void pcibios_set_master(struct pci_dev *dev) 9void pcibios_set_master(struct pci_dev *dev)
15{ 10{
16 u8 lat; 11 u8 lat;
diff --git a/arch/cris/include/asm/unistd.h b/arch/cris/include/asm/unistd.h
index f921b8b0f97..51873a446f8 100644
--- a/arch/cris/include/asm/unistd.h
+++ b/arch/cris/include/asm/unistd.h
@@ -347,7 +347,6 @@
347 347
348#include <arch/unistd.h> 348#include <arch/unistd.h>
349 349
350#define __ARCH_WANT_IPC_PARSE_VERSION
351#define __ARCH_WANT_OLD_READDIR 350#define __ARCH_WANT_OLD_READDIR
352#define __ARCH_WANT_OLD_STAT 351#define __ARCH_WANT_OLD_STAT
353#define __ARCH_WANT_STAT64 352#define __ARCH_WANT_STAT64
diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig
index a685910d2d5..971c0a19fac 100644
--- a/arch/frv/Kconfig
+++ b/arch/frv/Kconfig
@@ -9,6 +9,7 @@ config FRV
9 select GENERIC_IRQ_SHOW 9 select GENERIC_IRQ_SHOW
10 select ARCH_HAVE_NMI_SAFE_CMPXCHG 10 select ARCH_HAVE_NMI_SAFE_CMPXCHG
11 select GENERIC_CPU_DEVICES 11 select GENERIC_CPU_DEVICES
12 select ARCH_WANT_IPC_PARSE_VERSION
12 13
13config ZONE_DMA 14config ZONE_DMA
14 bool 15 bool
diff --git a/arch/frv/include/asm/cpumask.h b/arch/frv/include/asm/cpumask.h
deleted file mode 100644
index d999c20c84d..00000000000
--- a/arch/frv/include/asm/cpumask.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_CPUMASK_H
2#define _ASM_CPUMASK_H
3
4#include <asm-generic/cpumask.h>
5
6#endif /* _ASM_CPUMASK_H */
diff --git a/arch/frv/include/asm/highmem.h b/arch/frv/include/asm/highmem.h
index 716956a5317..b3adc93611f 100644
--- a/arch/frv/include/asm/highmem.h
+++ b/arch/frv/include/asm/highmem.h
@@ -76,15 +76,16 @@ extern struct page *kmap_atomic_to_page(void *ptr);
76 76
77#ifndef __ASSEMBLY__ 77#ifndef __ASSEMBLY__
78 78
79#define __kmap_atomic_primary(type, paddr, ampr) \ 79#define __kmap_atomic_primary(cached, paddr, ampr) \
80({ \ 80({ \
81 unsigned long damlr, dampr; \ 81 unsigned long damlr, dampr; \
82 \ 82 \
83 dampr = paddr | xAMPRx_L | xAMPRx_M | xAMPRx_S | xAMPRx_SS_16Kb | xAMPRx_V; \ 83 dampr = paddr | xAMPRx_L | xAMPRx_M | xAMPRx_S | xAMPRx_SS_16Kb | xAMPRx_V; \
84 \ 84 \
85 if (type != __KM_CACHE) \ 85 if (!cached) \
86 asm volatile("movgs %0,dampr"#ampr :: "r"(dampr) : "memory"); \ 86 asm volatile("movgs %0,dampr"#ampr :: "r"(dampr) : "memory"); \
87 else \ 87 else \
88 /* cache flush page attachment point */ \
88 asm volatile("movgs %0,iampr"#ampr"\n" \ 89 asm volatile("movgs %0,iampr"#ampr"\n" \
89 "movgs %0,dampr"#ampr"\n" \ 90 "movgs %0,dampr"#ampr"\n" \
90 :: "r"(dampr) : "memory" \ 91 :: "r"(dampr) : "memory" \
@@ -112,29 +113,20 @@ extern struct page *kmap_atomic_to_page(void *ptr);
112 (void *) damlr; \ 113 (void *) damlr; \
113}) 114})
114 115
115static inline void *kmap_atomic_primary(struct page *page, enum km_type type) 116static inline void *kmap_atomic_primary(struct page *page)
116{ 117{
117 unsigned long paddr; 118 unsigned long paddr;
118 119
119 pagefault_disable(); 120 pagefault_disable();
120 paddr = page_to_phys(page); 121 paddr = page_to_phys(page);
121 122
122 switch (type) { 123 return __kmap_atomic_primary(1, paddr, 2);
123 case 0: return __kmap_atomic_primary(0, paddr, 2);
124 case 1: return __kmap_atomic_primary(1, paddr, 3);
125 case 2: return __kmap_atomic_primary(2, paddr, 4);
126 case 3: return __kmap_atomic_primary(3, paddr, 5);
127
128 default:
129 BUG();
130 return NULL;
131 }
132} 124}
133 125
134#define __kunmap_atomic_primary(type, ampr) \ 126#define __kunmap_atomic_primary(cached, ampr) \
135do { \ 127do { \
136 asm volatile("movgs gr0,dampr"#ampr"\n" ::: "memory"); \ 128 asm volatile("movgs gr0,dampr"#ampr"\n" ::: "memory"); \
137 if (type == __KM_CACHE) \ 129 if (cached) \
138 asm volatile("movgs gr0,iampr"#ampr"\n" ::: "memory"); \ 130 asm volatile("movgs gr0,iampr"#ampr"\n" ::: "memory"); \
139} while(0) 131} while(0)
140 132
@@ -143,17 +135,9 @@ do { \
143 asm volatile("tlbpr %0,gr0,#4,#1" : : "r"(vaddr) : "memory"); \ 135 asm volatile("tlbpr %0,gr0,#4,#1" : : "r"(vaddr) : "memory"); \
144} while(0) 136} while(0)
145 137
146static inline void kunmap_atomic_primary(void *kvaddr, enum km_type type) 138static inline void kunmap_atomic_primary(void *kvaddr)
147{ 139{
148 switch (type) { 140 __kunmap_atomic_primary(1, 2);
149 case 0: __kunmap_atomic_primary(0, 2); break;
150 case 1: __kunmap_atomic_primary(1, 3); break;
151 case 2: __kunmap_atomic_primary(2, 4); break;
152 case 3: __kunmap_atomic_primary(3, 5); break;
153
154 default:
155 BUG();
156 }
157 pagefault_enable(); 141 pagefault_enable();
158} 142}
159 143
diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
index f8e16b2a580..43901f22096 100644
--- a/arch/frv/include/asm/kmap_types.h
+++ b/arch/frv/include/asm/kmap_types.h
@@ -2,28 +2,6 @@
2#ifndef _ASM_KMAP_TYPES_H 2#ifndef _ASM_KMAP_TYPES_H
3#define _ASM_KMAP_TYPES_H 3#define _ASM_KMAP_TYPES_H
4 4
5enum km_type { 5#define KM_TYPE_NR 17
6 /* arch specific kmaps - change the numbers attached to these at your peril */
7 __KM_CACHE, /* cache flush page attachment point */
8 __KM_PGD, /* current page directory */
9 __KM_ITLB_PTD, /* current instruction TLB miss page table lookup */
10 __KM_DTLB_PTD, /* current data TLB miss page table lookup */
11
12 /* general kmaps */
13 KM_BOUNCE_READ,
14 KM_SKB_SUNRPC_DATA,
15 KM_SKB_DATA_SOFTIRQ,
16 KM_USER0,
17 KM_USER1,
18 KM_BIO_SRC_IRQ,
19 KM_BIO_DST_IRQ,
20 KM_PTE0,
21 KM_PTE1,
22 KM_IRQ0,
23 KM_IRQ1,
24 KM_SOFTIRQ0,
25 KM_SOFTIRQ1,
26 KM_TYPE_NR
27};
28 6
29#endif 7#endif
diff --git a/arch/frv/include/asm/unistd.h b/arch/frv/include/asm/unistd.h
index a569dff7cd5..67f23a311db 100644
--- a/arch/frv/include/asm/unistd.h
+++ b/arch/frv/include/asm/unistd.h
@@ -349,7 +349,6 @@
349 349
350#define NR_syscalls 338 350#define NR_syscalls 338
351 351
352#define __ARCH_WANT_IPC_PARSE_VERSION
353/* #define __ARCH_WANT_OLD_READDIR */ 352/* #define __ARCH_WANT_OLD_READDIR */
354#define __ARCH_WANT_OLD_STAT 353#define __ARCH_WANT_OLD_STAT
355#define __ARCH_WANT_STAT64 354#define __ARCH_WANT_STAT64
diff --git a/arch/frv/kernel/kernel_thread.S b/arch/frv/kernel/kernel_thread.S
index 4531c830d20..f0e52943f92 100644
--- a/arch/frv/kernel/kernel_thread.S
+++ b/arch/frv/kernel/kernel_thread.S
@@ -10,10 +10,10 @@
10 */ 10 */
11 11
12#include <linux/linkage.h> 12#include <linux/linkage.h>
13#include <linux/kern_levels.h>
13#include <asm/unistd.h> 14#include <asm/unistd.h>
14 15
15#define CLONE_VM 0x00000100 /* set if VM shared between processes */ 16#define CLONE_VM 0x00000100 /* set if VM shared between processes */
16#define KERN_ERR "<3>"
17 17
18 .section .rodata 18 .section .rodata
19kernel_thread_emsg: 19kernel_thread_emsg:
diff --git a/arch/frv/mb93090-mb00/pci-dma.c b/arch/frv/mb93090-mb00/pci-dma.c
index 4f8d8bcdc7d..82478979ac9 100644
--- a/arch/frv/mb93090-mb00/pci-dma.c
+++ b/arch/frv/mb93090-mb00/pci-dma.c
@@ -62,14 +62,14 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
62 dampr2 = __get_DAMPR(2); 62 dampr2 = __get_DAMPR(2);
63 63
64 for (i = 0; i < nents; i++) { 64 for (i = 0; i < nents; i++) {
65 vaddr = kmap_atomic_primary(sg_page(&sg[i]), __KM_CACHE); 65 vaddr = kmap_atomic_primary(sg_page(&sg[i]));
66 66
67 frv_dcache_writeback((unsigned long) vaddr, 67 frv_dcache_writeback((unsigned long) vaddr,
68 (unsigned long) vaddr + PAGE_SIZE); 68 (unsigned long) vaddr + PAGE_SIZE);
69 69
70 } 70 }
71 71
72 kunmap_atomic_primary(vaddr, __KM_CACHE); 72 kunmap_atomic_primary(vaddr);
73 if (dampr2) { 73 if (dampr2) {
74 __set_DAMPR(2, dampr2); 74 __set_DAMPR(2, dampr2);
75 __set_IAMPR(2, dampr2); 75 __set_IAMPR(2, dampr2);
diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c
index 6b0b82ff441..d04ed14bbf0 100644
--- a/arch/frv/mb93090-mb00/pci-vdk.c
+++ b/arch/frv/mb93090-mb00/pci-vdk.c
@@ -268,7 +268,7 @@ static void __init pci_fixup_umc_ide(struct pci_dev *d)
268 d->resource[i].flags |= PCI_BASE_ADDRESS_SPACE_IO; 268 d->resource[i].flags |= PCI_BASE_ADDRESS_SPACE_IO;
269} 269}
270 270
271static void __init pci_fixup_ide_bases(struct pci_dev *d) 271static void __devinit pci_fixup_ide_bases(struct pci_dev *d)
272{ 272{
273 int i; 273 int i;
274 274
@@ -287,7 +287,7 @@ static void __init pci_fixup_ide_bases(struct pci_dev *d)
287 } 287 }
288} 288}
289 289
290static void __init pci_fixup_ide_trash(struct pci_dev *d) 290static void __devinit pci_fixup_ide_trash(struct pci_dev *d)
291{ 291{
292 int i; 292 int i;
293 293
diff --git a/arch/frv/mm/cache-page.c b/arch/frv/mm/cache-page.c
index b24ade27a0f..8e09dae0ec3 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_primary(page, __KM_CACHE); 29 vaddr = kmap_atomic_primary(page);
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_primary(vaddr, __KM_CACHE); 33 kunmap_atomic_primary(vaddr);
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_primary(page, __KM_CACHE); 57 vaddr = kmap_atomic_primary(page);
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_primary(vaddr, __KM_CACHE); 62 kunmap_atomic_primary(vaddr);
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 31902c9d5be..bed9a9bd3c1 100644
--- a/arch/frv/mm/highmem.c
+++ b/arch/frv/mm/highmem.c
@@ -50,11 +50,11 @@ void *kmap_atomic(struct page *page)
50 /* 50 /*
51 * The first 4 primary maps are reserved for architecture code 51 * The first 4 primary maps are reserved for architecture code
52 */ 52 */
53 case 0: return __kmap_atomic_primary(4, paddr, 6); 53 case 0: return __kmap_atomic_primary(0, paddr, 6);
54 case 1: return __kmap_atomic_primary(5, paddr, 7); 54 case 1: return __kmap_atomic_primary(0, paddr, 7);
55 case 2: return __kmap_atomic_primary(6, paddr, 8); 55 case 2: return __kmap_atomic_primary(0, paddr, 8);
56 case 3: return __kmap_atomic_primary(7, paddr, 9); 56 case 3: return __kmap_atomic_primary(0, paddr, 9);
57 case 4: return __kmap_atomic_primary(8, paddr, 10); 57 case 4: return __kmap_atomic_primary(0, paddr, 10);
58 58
59 case 5 ... 5 + NR_TLB_LINES - 1: 59 case 5 ... 5 + NR_TLB_LINES - 1:
60 return __kmap_atomic_secondary(type - 5, paddr); 60 return __kmap_atomic_secondary(type - 5, paddr);
@@ -70,11 +70,11 @@ void __kunmap_atomic(void *kvaddr)
70{ 70{
71 int type = kmap_atomic_idx(); 71 int type = kmap_atomic_idx();
72 switch (type) { 72 switch (type) {
73 case 0: __kunmap_atomic_primary(4, 6); break; 73 case 0: __kunmap_atomic_primary(0, 6); break;
74 case 1: __kunmap_atomic_primary(5, 7); break; 74 case 1: __kunmap_atomic_primary(0, 7); break;
75 case 2: __kunmap_atomic_primary(6, 8); break; 75 case 2: __kunmap_atomic_primary(0, 8); break;
76 case 3: __kunmap_atomic_primary(7, 9); break; 76 case 3: __kunmap_atomic_primary(0, 9); break;
77 case 4: __kunmap_atomic_primary(8, 10); break; 77 case 4: __kunmap_atomic_primary(0, 10); break;
78 78
79 case 5 ... 5 + NR_TLB_LINES - 1: 79 case 5 ... 5 + NR_TLB_LINES - 1:
80 __kunmap_atomic_secondary(type - 5, kvaddr); 80 __kunmap_atomic_secondary(type - 5, kvaddr);
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 56e890df505..5e8a0d9a09c 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -3,6 +3,7 @@ config H8300
3 default y 3 default y
4 select HAVE_IDE 4 select HAVE_IDE
5 select HAVE_GENERIC_HARDIRQS 5 select HAVE_GENERIC_HARDIRQS
6 select ARCH_WANT_IPC_PARSE_VERSION
6 select GENERIC_IRQ_SHOW 7 select GENERIC_IRQ_SHOW
7 select GENERIC_CPU_DEVICES 8 select GENERIC_CPU_DEVICES
8 9
diff --git a/arch/h8300/include/asm/unistd.h b/arch/h8300/include/asm/unistd.h
index 718511303b4..5cd882801d7 100644
--- a/arch/h8300/include/asm/unistd.h
+++ b/arch/h8300/include/asm/unistd.h
@@ -331,7 +331,6 @@
331 331
332#define NR_syscalls 321 332#define NR_syscalls 321
333 333
334#define __ARCH_WANT_IPC_PARSE_VERSION
335#define __ARCH_WANT_OLD_READDIR 334#define __ARCH_WANT_OLD_READDIR
336#define __ARCH_WANT_OLD_STAT 335#define __ARCH_WANT_OLD_STAT
337#define __ARCH_WANT_STAT64 336#define __ARCH_WANT_STAT64
diff --git a/arch/hexagon/include/asm/Kbuild b/arch/hexagon/include/asm/Kbuild
index 9aa17f1917e..06906427c0a 100644
--- a/arch/hexagon/include/asm/Kbuild
+++ b/arch/hexagon/include/asm/Kbuild
@@ -7,7 +7,6 @@ header-y += user.h
7generic-y += auxvec.h 7generic-y += auxvec.h
8generic-y += bug.h 8generic-y += bug.h
9generic-y += bugs.h 9generic-y += bugs.h
10generic-y += cpumask.h
11generic-y += cputime.h 10generic-y += cputime.h
12generic-y += current.h 11generic-y += current.h
13generic-y += device.h 12generic-y += device.h
@@ -23,7 +22,6 @@ generic-y += ioctl.h
23generic-y += ioctls.h 22generic-y += ioctls.h
24generic-y += iomap.h 23generic-y += iomap.h
25generic-y += ipcbuf.h 24generic-y += ipcbuf.h
26generic-y += ipc.h
27generic-y += irq_regs.h 25generic-y += irq_regs.h
28generic-y += kdebug.h 26generic-y += kdebug.h
29generic-y += kmap_types.h 27generic-y += kmap_types.h
diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c
index f7264621e58..149fbefc1a4 100644
--- a/arch/hexagon/kernel/smp.c
+++ b/arch/hexagon/kernel/smp.c
@@ -180,9 +180,7 @@ void __cpuinit start_secondary(void)
180 180
181 notify_cpu_starting(cpu); 181 notify_cpu_starting(cpu);
182 182
183 ipi_call_lock();
184 set_cpu_online(cpu, true); 183 set_cpu_online(cpu, true);
185 ipi_call_unlock();
186 184
187 local_irq_enable(); 185 local_irq_enable();
188 186
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 8186ec5ea15..310cf5781fa 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -126,6 +126,7 @@ config AUDIT_ARCH
126 126
127menuconfig PARAVIRT_GUEST 127menuconfig PARAVIRT_GUEST
128 bool "Paravirtualized guest support" 128 bool "Paravirtualized guest support"
129 depends on BROKEN
129 help 130 help
130 Say Y here to get to see options related to running Linux under 131 Say Y here to get to see options related to running Linux under
131 various hypervisors. This option alone does not add any kernel code. 132 various hypervisors. This option alone does not add any kernel code.
@@ -138,8 +139,6 @@ config PARAVIRT
138 bool "Enable paravirtualization code" 139 bool "Enable paravirtualization code"
139 depends on PARAVIRT_GUEST 140 depends on PARAVIRT_GUEST
140 default y 141 default y
141 bool
142 default y
143 help 142 help
144 This changes the kernel so it can modify itself when it is run 143 This changes the kernel so it can modify itself when it is run
145 under a hypervisor, potentially improving performance significantly 144 under a hypervisor, potentially improving performance significantly
diff --git a/arch/ia64/configs/generic_defconfig b/arch/ia64/configs/generic_defconfig
index 954d81e2e83..7913695b2fc 100644
--- a/arch/ia64/configs/generic_defconfig
+++ b/arch/ia64/configs/generic_defconfig
@@ -234,5 +234,4 @@ CONFIG_CRYPTO_PCBC=m
234CONFIG_CRYPTO_MD5=y 234CONFIG_CRYPTO_MD5=y
235# CONFIG_CRYPTO_ANSI_CPRNG is not set 235# CONFIG_CRYPTO_ANSI_CPRNG is not set
236CONFIG_CRC_T10DIF=y 236CONFIG_CRC_T10DIF=y
237CONFIG_MISC_DEVICES=y
238CONFIG_INTEL_IOMMU=y 237CONFIG_INTEL_IOMMU=y
diff --git a/arch/ia64/configs/gensparse_defconfig b/arch/ia64/configs/gensparse_defconfig
index 91c41ecfa6d..f8e91336542 100644
--- a/arch/ia64/configs/gensparse_defconfig
+++ b/arch/ia64/configs/gensparse_defconfig
@@ -209,4 +209,3 @@ CONFIG_MAGIC_SYSRQ=y
209CONFIG_DEBUG_KERNEL=y 209CONFIG_DEBUG_KERNEL=y
210CONFIG_DEBUG_MUTEXES=y 210CONFIG_DEBUG_MUTEXES=y
211CONFIG_CRYPTO_MD5=y 211CONFIG_CRYPTO_MD5=y
212CONFIG_MISC_DEVICES=y
diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
index 7d9116600a3..6e6fe1839f5 100644
--- a/arch/ia64/include/asm/atomic.h
+++ b/arch/ia64/include/asm/atomic.h
@@ -17,8 +17,8 @@
17#include <asm/intrinsics.h> 17#include <asm/intrinsics.h>
18 18
19 19
20#define ATOMIC_INIT(i) ((atomic_t) { (i) }) 20#define ATOMIC_INIT(i) { (i) }
21#define ATOMIC64_INIT(i) ((atomic64_t) { (i) }) 21#define ATOMIC64_INIT(i) { (i) }
22 22
23#define atomic_read(v) (*(volatile int *)&(v)->counter) 23#define atomic_read(v) (*(volatile int *)&(v)->counter)
24#define atomic64_read(v) (*(volatile long *)&(v)->counter) 24#define atomic64_read(v) (*(volatile long *)&(v)->counter)
diff --git a/arch/ia64/include/asm/iommu.h b/arch/ia64/include/asm/iommu.h
index b6a809fa299..105c93b00b1 100644
--- a/arch/ia64/include/asm/iommu.h
+++ b/arch/ia64/include/asm/iommu.h
@@ -11,12 +11,10 @@ extern void no_iommu_init(void);
11extern int force_iommu, no_iommu; 11extern int force_iommu, no_iommu;
12extern int iommu_pass_through; 12extern int iommu_pass_through;
13extern int iommu_detected; 13extern int iommu_detected;
14extern int iommu_group_mf;
15#else 14#else
16#define iommu_pass_through (0) 15#define iommu_pass_through (0)
17#define no_iommu (1) 16#define no_iommu (1)
18#define iommu_detected (0) 17#define iommu_detected (0)
19#define iommu_group_mf (0)
20#endif 18#endif
21extern void iommu_dma_init(void); 19extern void iommu_dma_init(void);
22extern void machvec_init(const char *name); 20extern void machvec_init(const char *name);
diff --git a/arch/ia64/include/asm/kvm.h b/arch/ia64/include/asm/kvm.h
index b9f82c84f09..ec6c6b30123 100644
--- a/arch/ia64/include/asm/kvm.h
+++ b/arch/ia64/include/asm/kvm.h
@@ -26,6 +26,7 @@
26 26
27/* Select x86 specific features in <linux/kvm.h> */ 27/* Select x86 specific features in <linux/kvm.h> */
28#define __KVM_HAVE_IOAPIC 28#define __KVM_HAVE_IOAPIC
29#define __KVM_HAVE_IRQ_LINE
29#define __KVM_HAVE_DEVICE_ASSIGNMENT 30#define __KVM_HAVE_DEVICE_ASSIGNMENT
30 31
31/* Architectural interrupt line count. */ 32/* Architectural interrupt line count. */
diff --git a/arch/ia64/include/asm/machvec.h b/arch/ia64/include/asm/machvec.h
index 367d299d993..2d1ad4b11a8 100644
--- a/arch/ia64/include/asm/machvec.h
+++ b/arch/ia64/include/asm/machvec.h
@@ -120,7 +120,7 @@ extern void machvec_tlb_migrate_finish (struct mm_struct *);
120# ifdef MACHVEC_PLATFORM_HEADER 120# ifdef MACHVEC_PLATFORM_HEADER
121# include MACHVEC_PLATFORM_HEADER 121# include MACHVEC_PLATFORM_HEADER
122# else 122# else
123# define platform_name ia64_mv.name 123# define ia64_platform_name ia64_mv.name
124# define platform_setup ia64_mv.setup 124# define platform_setup ia64_mv.setup
125# define platform_cpu_init ia64_mv.cpu_init 125# define platform_cpu_init ia64_mv.cpu_init
126# define platform_irq_init ia64_mv.irq_init 126# define platform_irq_init ia64_mv.irq_init
diff --git a/arch/ia64/include/asm/machvec_dig.h b/arch/ia64/include/asm/machvec_dig.h
index 8a0752f4098..1f7403a2fbe 100644
--- a/arch/ia64/include/asm/machvec_dig.h
+++ b/arch/ia64/include/asm/machvec_dig.h
@@ -10,7 +10,7 @@ extern ia64_mv_setup_t dig_setup;
10 * platform's machvec structure. When compiling a non-generic kernel, 10 * platform's machvec structure. When compiling a non-generic kernel,
11 * the macros are used directly. 11 * the macros are used directly.
12 */ 12 */
13#define platform_name "dig" 13#define ia64_platform_name "dig"
14#define platform_setup dig_setup 14#define platform_setup dig_setup
15 15
16#endif /* _ASM_IA64_MACHVEC_DIG_h */ 16#endif /* _ASM_IA64_MACHVEC_DIG_h */
diff --git a/arch/ia64/include/asm/machvec_dig_vtd.h b/arch/ia64/include/asm/machvec_dig_vtd.h
index 6ab1de5c45e..44308b4c3f6 100644
--- a/arch/ia64/include/asm/machvec_dig_vtd.h
+++ b/arch/ia64/include/asm/machvec_dig_vtd.h
@@ -11,7 +11,7 @@ extern ia64_mv_dma_init pci_iommu_alloc;
11 * platform's machvec structure. When compiling a non-generic kernel, 11 * platform's machvec structure. When compiling a non-generic kernel,
12 * the macros are used directly. 12 * the macros are used directly.
13 */ 13 */
14#define platform_name "dig_vtd" 14#define ia64_platform_name "dig_vtd"
15#define platform_setup dig_setup 15#define platform_setup dig_setup
16#define platform_dma_init pci_iommu_alloc 16#define platform_dma_init pci_iommu_alloc
17 17
diff --git a/arch/ia64/include/asm/machvec_hpsim.h b/arch/ia64/include/asm/machvec_hpsim.h
index cf72fc87fdf..e7571127936 100644
--- a/arch/ia64/include/asm/machvec_hpsim.h
+++ b/arch/ia64/include/asm/machvec_hpsim.h
@@ -11,7 +11,7 @@ extern ia64_mv_irq_init_t hpsim_irq_init;
11 * platform's machvec structure. When compiling a non-generic kernel, 11 * platform's machvec structure. When compiling a non-generic kernel,
12 * the macros are used directly. 12 * the macros are used directly.
13 */ 13 */
14#define platform_name "hpsim" 14#define ia64_platform_name "hpsim"
15#define platform_setup hpsim_setup 15#define platform_setup hpsim_setup
16#define platform_irq_init hpsim_irq_init 16#define platform_irq_init hpsim_irq_init
17 17
diff --git a/arch/ia64/include/asm/machvec_hpzx1.h b/arch/ia64/include/asm/machvec_hpzx1.h
index 3bd83d78a41..c74d3159e9e 100644
--- a/arch/ia64/include/asm/machvec_hpzx1.h
+++ b/arch/ia64/include/asm/machvec_hpzx1.h
@@ -11,7 +11,7 @@ extern ia64_mv_dma_init sba_dma_init;
11 * platform's machvec structure. When compiling a non-generic kernel, 11 * platform's machvec structure. When compiling a non-generic kernel,
12 * the macros are used directly. 12 * the macros are used directly.
13 */ 13 */
14#define platform_name "hpzx1" 14#define ia64_platform_name "hpzx1"
15#define platform_setup dig_setup 15#define platform_setup dig_setup
16#define platform_dma_init sba_dma_init 16#define platform_dma_init sba_dma_init
17 17
diff --git a/arch/ia64/include/asm/machvec_hpzx1_swiotlb.h b/arch/ia64/include/asm/machvec_hpzx1_swiotlb.h
index 1091ac39740..906ef621077 100644
--- a/arch/ia64/include/asm/machvec_hpzx1_swiotlb.h
+++ b/arch/ia64/include/asm/machvec_hpzx1_swiotlb.h
@@ -11,7 +11,7 @@ extern ia64_mv_dma_get_ops hwsw_dma_get_ops;
11 * platform's machvec structure. When compiling a non-generic kernel, 11 * platform's machvec structure. When compiling a non-generic kernel,
12 * the macros are used directly. 12 * the macros are used directly.
13 */ 13 */
14#define platform_name "hpzx1_swiotlb" 14#define ia64_platform_name "hpzx1_swiotlb"
15#define platform_setup dig_setup 15#define platform_setup dig_setup
16#define platform_dma_init machvec_noop 16#define platform_dma_init machvec_noop
17#define platform_dma_get_ops hwsw_dma_get_ops 17#define platform_dma_get_ops hwsw_dma_get_ops
diff --git a/arch/ia64/include/asm/machvec_sn2.h b/arch/ia64/include/asm/machvec_sn2.h
index f061a30aac4..ece9fa85be8 100644
--- a/arch/ia64/include/asm/machvec_sn2.h
+++ b/arch/ia64/include/asm/machvec_sn2.h
@@ -71,7 +71,7 @@ extern ia64_mv_pci_fixup_bus_t sn_pci_fixup_bus;
71 * platform's machvec structure. When compiling a non-generic kernel, 71 * platform's machvec structure. When compiling a non-generic kernel,
72 * the macros are used directly. 72 * the macros are used directly.
73 */ 73 */
74#define platform_name "sn2" 74#define ia64_platform_name "sn2"
75#define platform_setup sn_setup 75#define platform_setup sn_setup
76#define platform_cpu_init sn_cpu_init 76#define platform_cpu_init sn_cpu_init
77#define platform_irq_init sn_irq_init 77#define platform_irq_init sn_irq_init
diff --git a/arch/ia64/include/asm/machvec_uv.h b/arch/ia64/include/asm/machvec_uv.h
index 2931447f381..2c50853f35a 100644
--- a/arch/ia64/include/asm/machvec_uv.h
+++ b/arch/ia64/include/asm/machvec_uv.h
@@ -20,7 +20,7 @@ extern ia64_mv_setup_t uv_setup;
20 * platform's machvec structure. When compiling a non-generic kernel, 20 * platform's machvec structure. When compiling a non-generic kernel,
21 * the macros are used directly. 21 * the macros are used directly.
22 */ 22 */
23#define platform_name "uv" 23#define ia64_platform_name "uv"
24#define platform_setup uv_setup 24#define platform_setup uv_setup
25 25
26#endif /* _ASM_IA64_MACHVEC_UV_H */ 26#endif /* _ASM_IA64_MACHVEC_UV_H */
diff --git a/arch/ia64/include/asm/machvec_xen.h b/arch/ia64/include/asm/machvec_xen.h
index 55f9228056c..8b8bd0eb392 100644
--- a/arch/ia64/include/asm/machvec_xen.h
+++ b/arch/ia64/include/asm/machvec_xen.h
@@ -13,7 +13,7 @@ extern ia64_mv_send_ipi_t xen_platform_send_ipi;
13 * platform's machvec structure. When compiling a non-generic kernel, 13 * platform's machvec structure. When compiling a non-generic kernel,
14 * the macros are used directly. 14 * the macros are used directly.
15 */ 15 */
16#define platform_name "xen" 16#define ia64_platform_name "xen"
17#define platform_setup dig_setup 17#define platform_setup dig_setup
18#define platform_cpu_init xen_cpu_init 18#define platform_cpu_init xen_cpu_init
19#define platform_irq_init xen_irq_init 19#define platform_irq_init xen_irq_init
diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h
index 832dd3789e9..944152a5091 100644
--- a/arch/ia64/include/asm/processor.h
+++ b/arch/ia64/include/asm/processor.h
@@ -719,7 +719,7 @@ enum idle_boot_override {IDLE_NO_OVERRIDE=0, IDLE_HALT, IDLE_FORCE_MWAIT,
719 719
720void default_idle(void); 720void default_idle(void);
721 721
722#define ia64_platform_is(x) (strcmp(x, platform_name) == 0) 722#define ia64_platform_is(x) (strcmp(x, ia64_platform_name) == 0)
723 723
724#endif /* !__ASSEMBLY__ */ 724#endif /* !__ASSEMBLY__ */
725 725
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 6f38b6120d9..440578850ae 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -497,7 +497,7 @@ acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
497 srat_num_cpus++; 497 srat_num_cpus++;
498} 498}
499 499
500void __init 500int __init
501acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) 501acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
502{ 502{
503 unsigned long paddr, size; 503 unsigned long paddr, size;
@@ -512,7 +512,7 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
512 512
513 /* Ignore disabled entries */ 513 /* Ignore disabled entries */
514 if (!(ma->flags & ACPI_SRAT_MEM_ENABLED)) 514 if (!(ma->flags & ACPI_SRAT_MEM_ENABLED))
515 return; 515 return -1;
516 516
517 /* record this node in proximity bitmap */ 517 /* record this node in proximity bitmap */
518 pxm_bit_set(pxm); 518 pxm_bit_set(pxm);
@@ -531,6 +531,7 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
531 p->size = size; 531 p->size = size;
532 p->nid = pxm; 532 p->nid = pxm;
533 num_node_memblks++; 533 num_node_memblks++;
534 return 0;
534} 535}
535 536
536void __init acpi_numa_arch_fixup(void) 537void __init acpi_numa_arch_fixup(void)
diff --git a/arch/ia64/kernel/ia64_ksyms.c b/arch/ia64/kernel/ia64_ksyms.c
index 7f4a0ed2415..5b7791dd396 100644
--- a/arch/ia64/kernel/ia64_ksyms.c
+++ b/arch/ia64/kernel/ia64_ksyms.c
@@ -12,7 +12,7 @@ EXPORT_SYMBOL(memset);
12EXPORT_SYMBOL(memcpy); 12EXPORT_SYMBOL(memcpy);
13EXPORT_SYMBOL(strlen); 13EXPORT_SYMBOL(strlen);
14 14
15#include<asm/pgtable.h> 15#include <asm/pgtable.h>
16EXPORT_SYMBOL_GPL(empty_zero_page); 16EXPORT_SYMBOL_GPL(empty_zero_page);
17 17
18#include <asm/checksum.h> 18#include <asm/checksum.h>
diff --git a/arch/ia64/kernel/irq_ia64.c b/arch/ia64/kernel/irq_ia64.c
index 5c3e0888265..1034884b77d 100644
--- a/arch/ia64/kernel/irq_ia64.c
+++ b/arch/ia64/kernel/irq_ia64.c
@@ -23,7 +23,6 @@
23#include <linux/ioport.h> 23#include <linux/ioport.h>
24#include <linux/kernel_stat.h> 24#include <linux/kernel_stat.h>
25#include <linux/ptrace.h> 25#include <linux/ptrace.h>
26#include <linux/random.h> /* for rand_initialize_irq() */
27#include <linux/signal.h> 26#include <linux/signal.h>
28#include <linux/smp.h> 27#include <linux/smp.h>
29#include <linux/threads.h> 28#include <linux/threads.h>
diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c
index 7cdc89b2483..1ddcfe5ef35 100644
--- a/arch/ia64/kernel/pci-dma.c
+++ b/arch/ia64/kernel/pci-dma.c
@@ -32,7 +32,6 @@ int force_iommu __read_mostly;
32#endif 32#endif
33 33
34int iommu_pass_through; 34int iommu_pass_through;
35int iommu_group_mf;
36 35
37/* Dummy device used for NULL arguments (normally ISA). Better would 36/* Dummy device used for NULL arguments (normally ISA). Better would
38 be probably a smaller DMA mask, but this is bug-to-bug compatible 37 be probably a smaller DMA mask, but this is bug-to-bug compatible
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index d7f558c1e71..3fa4bc53695 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -2353,7 +2353,6 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t
2353 */ 2353 */
2354 insert_vm_struct(mm, vma); 2354 insert_vm_struct(mm, vma);
2355 2355
2356 mm->total_vm += size >> PAGE_SHIFT;
2357 vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file, 2356 vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
2358 vma_pages(vma)); 2357 vma_pages(vma));
2359 up_write(&task->mm->mmap_sem); 2358 up_write(&task->mm->mmap_sem);
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
index 1113b8aba07..963d2db53bf 100644
--- a/arch/ia64/kernel/smpboot.c
+++ b/arch/ia64/kernel/smpboot.c
@@ -382,7 +382,6 @@ smp_callin (void)
382 set_numa_node(cpu_to_node_map[cpuid]); 382 set_numa_node(cpu_to_node_map[cpuid]);
383 set_numa_mem(local_memory_node(cpu_to_node_map[cpuid])); 383 set_numa_mem(local_memory_node(cpu_to_node_map[cpuid]));
384 384
385 ipi_call_lock_irq();
386 spin_lock(&vector_lock); 385 spin_lock(&vector_lock);
387 /* Setup the per cpu irq handling data structures */ 386 /* Setup the per cpu irq handling data structures */
388 __setup_vector_irq(cpuid); 387 __setup_vector_irq(cpuid);
@@ -390,7 +389,6 @@ smp_callin (void)
390 set_cpu_online(cpuid, true); 389 set_cpu_online(cpuid, true);
391 per_cpu(cpu_state, cpuid) = CPU_ONLINE; 390 per_cpu(cpu_state, cpuid) = CPU_ONLINE;
392 spin_unlock(&vector_lock); 391 spin_unlock(&vector_lock);
393 ipi_call_unlock_irq();
394 392
395 smp_setup_percpu_timer(); 393 smp_setup_percpu_timer();
396 394
diff --git a/arch/ia64/kvm/Kconfig b/arch/ia64/kvm/Kconfig
index 9806e55f91b..e7947528aee 100644
--- a/arch/ia64/kvm/Kconfig
+++ b/arch/ia64/kvm/Kconfig
@@ -19,9 +19,11 @@ if VIRTUALIZATION
19 19
20config KVM 20config KVM
21 tristate "Kernel-based Virtual Machine (KVM) support" 21 tristate "Kernel-based Virtual Machine (KVM) support"
22 depends on BROKEN
22 depends on HAVE_KVM && MODULES && EXPERIMENTAL 23 depends on HAVE_KVM && MODULES && EXPERIMENTAL
23 # for device assignment: 24 # for device assignment:
24 depends on PCI 25 depends on PCI
26 depends on BROKEN
25 select PREEMPT_NOTIFIERS 27 select PREEMPT_NOTIFIERS
26 select ANON_INODES 28 select ANON_INODES
27 select HAVE_KVM_IRQCHIP 29 select HAVE_KVM_IRQCHIP
diff --git a/arch/ia64/kvm/vmm.c b/arch/ia64/kvm/vmm.c
index f0b9cac8241..176a12cd56d 100644
--- a/arch/ia64/kvm/vmm.c
+++ b/arch/ia64/kvm/vmm.c
@@ -20,9 +20,9 @@
20 */ 20 */
21 21
22 22
23#include<linux/kernel.h> 23#include <linux/kernel.h>
24#include<linux/module.h> 24#include <linux/module.h>
25#include<asm/fpswa.h> 25#include <asm/fpswa.h>
26 26
27#include "vcpu.h" 27#include "vcpu.h"
28 28
diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
index 02d29c2a132..8443daf4f51 100644
--- a/arch/ia64/mm/fault.c
+++ b/arch/ia64/mm/fault.c
@@ -72,6 +72,10 @@ mapped_kernel_page_is_present (unsigned long address)
72 return pte_present(pte); 72 return pte_present(pte);
73} 73}
74 74
75# define VM_READ_BIT 0
76# define VM_WRITE_BIT 1
77# define VM_EXEC_BIT 2
78
75void __kprobes 79void __kprobes
76ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *regs) 80ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *regs)
77{ 81{
@@ -81,6 +85,12 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
81 struct siginfo si; 85 struct siginfo si;
82 unsigned long mask; 86 unsigned long mask;
83 int fault; 87 int fault;
88 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
89
90 mask = ((((isr >> IA64_ISR_X_BIT) & 1UL) << VM_EXEC_BIT)
91 | (((isr >> IA64_ISR_W_BIT) & 1UL) << VM_WRITE_BIT));
92
93 flags |= ((mask & VM_WRITE) ? FAULT_FLAG_WRITE : 0);
84 94
85 /* mmap_sem is performance critical.... */ 95 /* mmap_sem is performance critical.... */
86 prefetchw(&mm->mmap_sem); 96 prefetchw(&mm->mmap_sem);
@@ -109,6 +119,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
109 if (notify_page_fault(regs, TRAP_BRKPT)) 119 if (notify_page_fault(regs, TRAP_BRKPT))
110 return; 120 return;
111 121
122retry:
112 down_read(&mm->mmap_sem); 123 down_read(&mm->mmap_sem);
113 124
114 vma = find_vma_prev(mm, address, &prev_vma); 125 vma = find_vma_prev(mm, address, &prev_vma);
@@ -130,10 +141,6 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
130 141
131 /* OK, we've got a good vm_area for this memory area. Check the access permissions: */ 142 /* OK, we've got a good vm_area for this memory area. Check the access permissions: */
132 143
133# define VM_READ_BIT 0
134# define VM_WRITE_BIT 1
135# define VM_EXEC_BIT 2
136
137# if (((1 << VM_READ_BIT) != VM_READ || (1 << VM_WRITE_BIT) != VM_WRITE) \ 144# if (((1 << VM_READ_BIT) != VM_READ || (1 << VM_WRITE_BIT) != VM_WRITE) \
138 || (1 << VM_EXEC_BIT) != VM_EXEC) 145 || (1 << VM_EXEC_BIT) != VM_EXEC)
139# error File is out of sync with <linux/mm.h>. Please update. 146# error File is out of sync with <linux/mm.h>. Please update.
@@ -142,9 +149,6 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
142 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE)))) 149 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
143 goto bad_area; 150 goto bad_area;
144 151
145 mask = ( (((isr >> IA64_ISR_X_BIT) & 1UL) << VM_EXEC_BIT)
146 | (((isr >> IA64_ISR_W_BIT) & 1UL) << VM_WRITE_BIT));
147
148 if ((vma->vm_flags & mask) != mask) 152 if ((vma->vm_flags & mask) != mask)
149 goto bad_area; 153 goto bad_area;
150 154
@@ -153,7 +157,11 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
153 * sure we exit gracefully rather than endlessly redo the 157 * sure we exit gracefully rather than endlessly redo the
154 * fault. 158 * fault.
155 */ 159 */
156 fault = handle_mm_fault(mm, vma, address, (mask & VM_WRITE) ? FAULT_FLAG_WRITE : 0); 160 fault = handle_mm_fault(mm, vma, address, flags);
161
162 if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
163 return;
164
157 if (unlikely(fault & VM_FAULT_ERROR)) { 165 if (unlikely(fault & VM_FAULT_ERROR)) {
158 /* 166 /*
159 * We ran out of memory, or some other thing happened 167 * We ran out of memory, or some other thing happened
@@ -168,10 +176,24 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
168 } 176 }
169 BUG(); 177 BUG();
170 } 178 }
171 if (fault & VM_FAULT_MAJOR) 179
172 current->maj_flt++; 180 if (flags & FAULT_FLAG_ALLOW_RETRY) {
173 else 181 if (fault & VM_FAULT_MAJOR)
174 current->min_flt++; 182 current->maj_flt++;
183 else
184 current->min_flt++;
185 if (fault & VM_FAULT_RETRY) {
186 flags &= ~FAULT_FLAG_ALLOW_RETRY;
187
188 /* No need to up_read(&mm->mmap_sem) as we would
189 * have already released it in __lock_page_or_retry
190 * in mm/filemap.c.
191 */
192
193 goto retry;
194 }
195 }
196
175 up_read(&mm->mmap_sem); 197 up_read(&mm->mmap_sem);
176 return; 198 return;
177 199
diff --git a/arch/ia64/pci/fixup.c b/arch/ia64/pci/fixup.c
index f5959c0c181..eab28e31402 100644
--- a/arch/ia64/pci/fixup.c
+++ b/arch/ia64/pci/fixup.c
@@ -30,8 +30,8 @@ static void __devinit pci_fixup_video(struct pci_dev *pdev)
30 struct pci_bus *bus; 30 struct pci_bus *bus;
31 u16 config; 31 u16 config;
32 32
33 if ((strcmp(platform_name, "dig") != 0) 33 if ((strcmp(ia64_platform_name, "dig") != 0)
34 && (strcmp(platform_name, "hpzx1") != 0)) 34 && (strcmp(ia64_platform_name, "hpzx1") != 0))
35 return; 35 return;
36 /* Maybe, this machine supports legacy memory map. */ 36 /* Maybe, this machine supports legacy memory map. */
37 37
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 524df4295c9..81acc7a57f3 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -351,6 +351,8 @@ pci_acpi_scan_root(struct acpi_pci_root *root)
351#endif 351#endif
352 352
353 INIT_LIST_HEAD(&info.resources); 353 INIT_LIST_HEAD(&info.resources);
354 /* insert busn resource at first */
355 pci_add_resource(&info.resources, &root->secondary);
354 acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window, 356 acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window,
355 &windows); 357 &windows);
356 if (windows) { 358 if (windows) {
@@ -384,7 +386,7 @@ pci_acpi_scan_root(struct acpi_pci_root *root)
384 return NULL; 386 return NULL;
385 } 387 }
386 388
387 pbus->subordinate = pci_scan_child_bus(pbus); 389 pci_scan_child_bus(pbus);
388 return pbus; 390 return pbus;
389 391
390out3: 392out3:
@@ -496,15 +498,6 @@ pcibios_align_resource (void *data, const struct resource *res,
496 return res->start; 498 return res->start;
497} 499}
498 500
499/*
500 * PCI BIOS setup, always defaults to SAL interface
501 */
502char * __init
503pcibios_setup (char *str)
504{
505 return str;
506}
507
508int 501int
509pci_mmap_page_range (struct pci_dev *dev, struct vm_area_struct *vma, 502pci_mmap_page_range (struct pci_dev *dev, struct vm_area_struct *vma,
510 enum pci_mmap_state mmap_state, int write_combine) 503 enum pci_mmap_state mmap_state, int write_combine)
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
index b638d5bfa14..49498bbb961 100644
--- a/arch/m32r/Kconfig
+++ b/arch/m32r/Kconfig
@@ -7,6 +7,7 @@ config M32R
7 select HAVE_KERNEL_GZIP 7 select HAVE_KERNEL_GZIP
8 select HAVE_KERNEL_BZIP2 8 select HAVE_KERNEL_BZIP2
9 select HAVE_KERNEL_LZMA 9 select HAVE_KERNEL_LZMA
10 select ARCH_WANT_IPC_PARSE_VERSION
10 select HAVE_GENERIC_HARDIRQS 11 select HAVE_GENERIC_HARDIRQS
11 select GENERIC_IRQ_PROBE 12 select GENERIC_IRQ_PROBE
12 select GENERIC_IRQ_SHOW 13 select GENERIC_IRQ_SHOW
diff --git a/arch/m32r/include/asm/smp.h b/arch/m32r/include/asm/smp.h
index cf7829a6155..c689b828dfe 100644
--- a/arch/m32r/include/asm/smp.h
+++ b/arch/m32r/include/asm/smp.h
@@ -79,11 +79,6 @@ static __inline__ int cpu_number_map(int cpu)
79 return cpu; 79 return cpu;
80} 80}
81 81
82static __inline__ unsigned int num_booting_cpus(void)
83{
84 return cpumask_weight(&cpu_callout_map);
85}
86
87extern void smp_send_timer(void); 82extern void smp_send_timer(void);
88extern unsigned long send_IPI_mask_phys(const cpumask_t*, int, int); 83extern unsigned long send_IPI_mask_phys(const cpumask_t*, int, int);
89 84
diff --git a/arch/m32r/include/asm/unistd.h b/arch/m32r/include/asm/unistd.h
index 3e1db561aac..d5e66a48078 100644
--- a/arch/m32r/include/asm/unistd.h
+++ b/arch/m32r/include/asm/unistd.h
@@ -336,7 +336,6 @@
336 336
337#define NR_syscalls 326 337#define NR_syscalls 326
338 338
339#define __ARCH_WANT_IPC_PARSE_VERSION
340#define __ARCH_WANT_STAT64 339#define __ARCH_WANT_STAT64
341#define __ARCH_WANT_SYS_ALARM 340#define __ARCH_WANT_SYS_ALARM
342#define __ARCH_WANT_SYS_GETHOSTNAME 341#define __ARCH_WANT_SYS_GETHOSTNAME
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 14712012826..b22df9410dc 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -5,11 +5,13 @@ config M68K
5 select HAVE_AOUT if MMU 5 select HAVE_AOUT if MMU
6 select HAVE_GENERIC_HARDIRQS 6 select HAVE_GENERIC_HARDIRQS
7 select GENERIC_IRQ_SHOW 7 select GENERIC_IRQ_SHOW
8 select GENERIC_ATOMIC64
8 select ARCH_HAVE_NMI_SAFE_CMPXCHG if RMW_INSNS 9 select ARCH_HAVE_NMI_SAFE_CMPXCHG if RMW_INSNS
9 select GENERIC_CPU_DEVICES 10 select GENERIC_CPU_DEVICES
10 select GENERIC_STRNCPY_FROM_USER if MMU 11 select GENERIC_STRNCPY_FROM_USER if MMU
11 select GENERIC_STRNLEN_USER if MMU 12 select GENERIC_STRNLEN_USER if MMU
12 select FPU if MMU 13 select FPU if MMU
14 select ARCH_WANT_IPC_PARSE_VERSION
13 select ARCH_USES_GETTIMEOFFSET if MMU && !COLDFIRE 15 select ARCH_USES_GETTIMEOFFSET if MMU && !COLDFIRE
14 16
15config RWSEM_GENERIC_SPINLOCK 17config RWSEM_GENERIC_SPINLOCK
@@ -53,18 +55,6 @@ config ZONE_DMA
53 bool 55 bool
54 default y 56 default y
55 57
56config CPU_HAS_NO_BITFIELDS
57 bool
58
59config CPU_HAS_NO_MULDIV64
60 bool
61
62config CPU_HAS_ADDRESS_SPACES
63 bool
64
65config FPU
66 bool
67
68config HZ 58config HZ
69 int 59 int
70 default 1000 if CLEOPATRA 60 default 1000 if CLEOPATRA
diff --git a/arch/m68k/Kconfig.bus b/arch/m68k/Kconfig.bus
index 3adb499584f..ffc0601a2a1 100644
--- a/arch/m68k/Kconfig.bus
+++ b/arch/m68k/Kconfig.bus
@@ -48,6 +48,13 @@ config ISA
48config GENERIC_ISA_DMA 48config GENERIC_ISA_DMA
49 def_bool ISA 49 def_bool ISA
50 50
51config PCI
52 bool "PCI support"
53 depends on M54xx
54 help
55 Enable the PCI bus. Support for the PCI bus hardware built into the
56 ColdFire 547x and 548x processors.
57
51source "drivers/pci/Kconfig" 58source "drivers/pci/Kconfig"
52 59
53source "drivers/zorro/Kconfig" 60source "drivers/zorro/Kconfig"
diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
index 2b53254ad99..c4eb79edece 100644
--- a/arch/m68k/Kconfig.cpu
+++ b/arch/m68k/Kconfig.cpu
@@ -23,11 +23,12 @@ config M68KCLASSIC
23config COLDFIRE 23config COLDFIRE
24 bool "Coldfire CPU family support" 24 bool "Coldfire CPU family support"
25 select GENERIC_GPIO 25 select GENERIC_GPIO
26 select ARCH_REQUIRE_GPIOLIB 26 select ARCH_WANT_OPTIONAL_GPIOLIB
27 select ARCH_HAVE_CUSTOM_GPIO_H 27 select ARCH_HAVE_CUSTOM_GPIO_H
28 select CPU_HAS_NO_BITFIELDS 28 select CPU_HAS_NO_BITFIELDS
29 select CPU_HAS_NO_MULDIV64 29 select CPU_HAS_NO_MULDIV64
30 select GENERIC_CSUM 30 select GENERIC_CSUM
31 select HAVE_CLK
31 32
32endchoice 33endchoice
33 34
@@ -37,6 +38,7 @@ config M68000
37 bool 38 bool
38 select CPU_HAS_NO_BITFIELDS 39 select CPU_HAS_NO_BITFIELDS
39 select CPU_HAS_NO_MULDIV64 40 select CPU_HAS_NO_MULDIV64
41 select CPU_HAS_NO_UNALIGNED
40 select GENERIC_CSUM 42 select GENERIC_CSUM
41 help 43 help
42 The Freescale (was Motorola) 68000 CPU is the first generation of 44 The Freescale (was Motorola) 68000 CPU is the first generation of
@@ -48,6 +50,7 @@ config M68000
48config MCPU32 50config MCPU32
49 bool 51 bool
50 select CPU_HAS_NO_BITFIELDS 52 select CPU_HAS_NO_BITFIELDS
53 select CPU_HAS_NO_UNALIGNED
51 help 54 help
52 The Freescale (was then Motorola) CPU32 is a CPU core that is 55 The Freescale (was then Motorola) CPU32 is a CPU core that is
53 based on the 68020 processor. For the most part it is used in 56 based on the 68020 processor. For the most part it is used in
@@ -56,7 +59,6 @@ config MCPU32
56config M68020 59config M68020
57 bool "68020 support" 60 bool "68020 support"
58 depends on MMU 61 depends on MMU
59 select GENERIC_ATOMIC64
60 select CPU_HAS_ADDRESS_SPACES 62 select CPU_HAS_ADDRESS_SPACES
61 help 63 help
62 If you anticipate running this kernel on a computer with a MC68020 64 If you anticipate running this kernel on a computer with a MC68020
@@ -67,7 +69,6 @@ config M68020
67config M68030 69config M68030
68 bool "68030 support" 70 bool "68030 support"
69 depends on MMU && !MMU_SUN3 71 depends on MMU && !MMU_SUN3
70 select GENERIC_ATOMIC64
71 select CPU_HAS_ADDRESS_SPACES 72 select CPU_HAS_ADDRESS_SPACES
72 help 73 help
73 If you anticipate running this kernel on a computer with a MC68030 74 If you anticipate running this kernel on a computer with a MC68030
@@ -77,7 +78,6 @@ config M68030
77config M68040 78config M68040
78 bool "68040 support" 79 bool "68040 support"
79 depends on MMU && !MMU_SUN3 80 depends on MMU && !MMU_SUN3
80 select GENERIC_ATOMIC64
81 select CPU_HAS_ADDRESS_SPACES 81 select CPU_HAS_ADDRESS_SPACES
82 help 82 help
83 If you anticipate running this kernel on a computer with a MC68LC040 83 If you anticipate running this kernel on a computer with a MC68LC040
@@ -88,7 +88,6 @@ config M68040
88config M68060 88config M68060
89 bool "68060 support" 89 bool "68060 support"
90 depends on MMU && !MMU_SUN3 90 depends on MMU && !MMU_SUN3
91 select GENERIC_ATOMIC64
92 select CPU_HAS_ADDRESS_SPACES 91 select CPU_HAS_ADDRESS_SPACES
93 help 92 help
94 If you anticipate running this kernel on a computer with a MC68060 93 If you anticipate running this kernel on a computer with a MC68060
@@ -167,6 +166,14 @@ config M5249
167 help 166 help
168 Motorola ColdFire 5249 processor support. 167 Motorola ColdFire 5249 processor support.
169 168
169config M525x
170 bool "MCF525x"
171 depends on !MMU
172 select COLDFIRE_SW_A7
173 select HAVE_MBAR
174 help
175 Freescale (Motorola) Coldfire 5251/5253 processor support.
176
170config M527x 177config M527x
171 bool 178 bool
172 179
@@ -253,6 +260,14 @@ config M548x
253 help 260 help
254 Freescale ColdFire 5480/5481/5482/5483/5484/5485 processor support. 261 Freescale ColdFire 5480/5481/5482/5483/5484/5485 processor support.
255 262
263config M5441x
264 bool "MCF5441x"
265 depends on !MMU
266 select GENERIC_CLOCKEVENTS
267 select HAVE_CACHE_CB
268 help
269 Freescale Coldfire 54410/54415/54416/54417/54418 processor support.
270
256endif # COLDFIRE 271endif # COLDFIRE
257 272
258 273
@@ -360,6 +375,18 @@ config NODES_SHIFT
360 default "3" 375 default "3"
361 depends on !SINGLE_MEMORY_CHUNK 376 depends on !SINGLE_MEMORY_CHUNK
362 377
378config CPU_HAS_NO_BITFIELDS
379 bool
380
381config CPU_HAS_NO_MULDIV64
382 bool
383
384config CPU_HAS_NO_UNALIGNED
385 bool
386
387config CPU_HAS_ADDRESS_SPACES
388 bool
389
363config FPU 390config FPU
364 bool 391 bool
365 392
diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index b7f2e2d5cd2..7636751f2f8 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -41,6 +41,7 @@ cpuflags-$(CONFIG_M68030) :=
41cpuflags-$(CONFIG_M68020) := 41cpuflags-$(CONFIG_M68020) :=
42cpuflags-$(CONFIG_M68360) := -m68332 42cpuflags-$(CONFIG_M68360) := -m68332
43cpuflags-$(CONFIG_M68000) := -m68000 43cpuflags-$(CONFIG_M68000) := -m68000
44cpuflags-$(CONFIG_M5441x) := $(call cc-option,-mcpu=54455,-mcfv4e)
44cpuflags-$(CONFIG_M54xx) := $(call cc-option,-mcpu=5475,-m5200) 45cpuflags-$(CONFIG_M54xx) := $(call cc-option,-mcpu=5475,-m5200)
45cpuflags-$(CONFIG_M5407) := $(call cc-option,-mcpu=5407,-m5200) 46cpuflags-$(CONFIG_M5407) := $(call cc-option,-mcpu=5407,-m5200)
46cpuflags-$(CONFIG_M532x) := $(call cc-option,-mcpu=532x,-m5307) 47cpuflags-$(CONFIG_M532x) := $(call cc-option,-mcpu=532x,-m5307)
@@ -50,6 +51,7 @@ cpuflags-$(CONFIG_M5275) := $(call cc-option,-mcpu=5275,-m5307)
50cpuflags-$(CONFIG_M5272) := $(call cc-option,-mcpu=5272,-m5307) 51cpuflags-$(CONFIG_M5272) := $(call cc-option,-mcpu=5272,-m5307)
51cpuflags-$(CONFIG_M5271) := $(call cc-option,-mcpu=5271,-m5307) 52cpuflags-$(CONFIG_M5271) := $(call cc-option,-mcpu=5271,-m5307)
52cpuflags-$(CONFIG_M523x) := $(call cc-option,-mcpu=523x,-m5307) 53cpuflags-$(CONFIG_M523x) := $(call cc-option,-mcpu=523x,-m5307)
54cpuflags-$(CONFIG_M525x) := $(call cc-option,-mcpu=5253,-m5200)
53cpuflags-$(CONFIG_M5249) := $(call cc-option,-mcpu=5249,-m5200) 55cpuflags-$(CONFIG_M5249) := $(call cc-option,-mcpu=5249,-m5200)
54cpuflags-$(CONFIG_M520x) := $(call cc-option,-mcpu=5208,-m5200) 56cpuflags-$(CONFIG_M520x) := $(call cc-option,-mcpu=5208,-m5200)
55cpuflags-$(CONFIG_M5206e) := $(call cc-option,-mcpu=5206e,-m5200) 57cpuflags-$(CONFIG_M5206e) := $(call cc-option,-mcpu=5206e,-m5200)
diff --git a/arch/m68k/apollo/config.c b/arch/m68k/apollo/config.c
index 0a30406b944..f5565d6eeb8 100644
--- a/arch/m68k/apollo/config.c
+++ b/arch/m68k/apollo/config.c
@@ -177,8 +177,8 @@ irqreturn_t dn_timer_int(int irq, void *dev_id)
177 177
178 timer_handler(irq, dev_id); 178 timer_handler(irq, dev_id);
179 179
180 x=*(volatile unsigned char *)(timer+3); 180 x = *(volatile unsigned char *)(apollo_timer + 3);
181 x=*(volatile unsigned char *)(timer+5); 181 x = *(volatile unsigned char *)(apollo_timer + 5);
182 182
183 return IRQ_HANDLED; 183 return IRQ_HANDLED;
184} 184}
@@ -186,17 +186,17 @@ irqreturn_t dn_timer_int(int irq, void *dev_id)
186void dn_sched_init(irq_handler_t timer_routine) 186void dn_sched_init(irq_handler_t timer_routine)
187{ 187{
188 /* program timer 1 */ 188 /* program timer 1 */
189 *(volatile unsigned char *)(timer+3)=0x01; 189 *(volatile unsigned char *)(apollo_timer + 3) = 0x01;
190 *(volatile unsigned char *)(timer+1)=0x40; 190 *(volatile unsigned char *)(apollo_timer + 1) = 0x40;
191 *(volatile unsigned char *)(timer+5)=0x09; 191 *(volatile unsigned char *)(apollo_timer + 5) = 0x09;
192 *(volatile unsigned char *)(timer+7)=0xc4; 192 *(volatile unsigned char *)(apollo_timer + 7) = 0xc4;
193 193
194 /* enable IRQ of PIC B */ 194 /* enable IRQ of PIC B */
195 *(volatile unsigned char *)(pica+1)&=(~8); 195 *(volatile unsigned char *)(pica+1)&=(~8);
196 196
197#if 0 197#if 0
198 printk("*(0x10803) %02x\n",*(volatile unsigned char *)(timer+0x3)); 198 printk("*(0x10803) %02x\n",*(volatile unsigned char *)(apollo_timer + 0x3));
199 printk("*(0x10803) %02x\n",*(volatile unsigned char *)(timer+0x3)); 199 printk("*(0x10803) %02x\n",*(volatile unsigned char *)(apollo_timer + 0x3));
200#endif 200#endif
201 201
202 if (request_irq(IRQ_APOLLO, dn_timer_int, 0, "time", timer_routine)) 202 if (request_irq(IRQ_APOLLO, dn_timer_int, 0, "time", timer_routine))
diff --git a/arch/m68k/include/asm/Kbuild b/arch/m68k/include/asm/Kbuild
index eafa2539a8e..a74e5d95c38 100644
--- a/arch/m68k/include/asm/Kbuild
+++ b/arch/m68k/include/asm/Kbuild
@@ -1,4 +1,29 @@
1include include/asm-generic/Kbuild.asm 1include include/asm-generic/Kbuild.asm
2header-y += cachectl.h 2header-y += cachectl.h
3 3
4generic-y += bitsperlong.h
5generic-y += cputime.h
6generic-y += device.h
7generic-y += emergency-restart.h
8generic-y += errno.h
9generic-y += futex.h
10generic-y += ioctl.h
11generic-y += ipcbuf.h
12generic-y += irq_regs.h
13generic-y += kdebug.h
14generic-y += kmap_types.h
15generic-y += kvm_para.h
16generic-y += local64.h
17generic-y += local.h
18generic-y += mman.h
19generic-y += mutex.h
20generic-y += percpu.h
21generic-y += resource.h
22generic-y += scatterlist.h
23generic-y += sections.h
24generic-y += siginfo.h
25generic-y += statfs.h
26generic-y += topology.h
27generic-y += types.h
4generic-y += word-at-a-time.h 28generic-y += word-at-a-time.h
29generic-y += xor.h
diff --git a/arch/m68k/include/asm/MC68332.h b/arch/m68k/include/asm/MC68332.h
deleted file mode 100644
index 6bb8f02685a..00000000000
--- a/arch/m68k/include/asm/MC68332.h
+++ /dev/null
@@ -1,152 +0,0 @@
1
2/* include/asm-m68knommu/MC68332.h: '332 control registers
3 *
4 * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>,
5 *
6 */
7
8#ifndef _MC68332_H_
9#define _MC68332_H_
10
11#define BYTE_REF(addr) (*((volatile unsigned char*)addr))
12#define WORD_REF(addr) (*((volatile unsigned short*)addr))
13
14#define PORTE_ADDR 0xfffa11
15#define PORTE BYTE_REF(PORTE_ADDR)
16#define DDRE_ADDR 0xfffa15
17#define DDRE BYTE_REF(DDRE_ADDR)
18#define PEPAR_ADDR 0xfffa17
19#define PEPAR BYTE_REF(PEPAR_ADDR)
20
21#define PORTF_ADDR 0xfffa19
22#define PORTF BYTE_REF(PORTF_ADDR)
23#define DDRF_ADDR 0xfffa1d
24#define DDRF BYTE_REF(DDRF_ADDR)
25#define PFPAR_ADDR 0xfffa1f
26#define PFPAR BYTE_REF(PFPAR_ADDR)
27
28#define PORTQS_ADDR 0xfffc15
29#define PORTQS BYTE_REF(PORTQS_ADDR)
30#define DDRQS_ADDR 0xfffc17
31#define DDRQS BYTE_REF(DDRQS_ADDR)
32#define PQSPAR_ADDR 0xfffc16
33#define PQSPAR BYTE_REF(PQSPAR_ADDR)
34
35#define CSPAR0_ADDR 0xFFFA44
36#define CSPAR0 WORD_REF(CSPAR0_ADDR)
37#define CSPAR1_ADDR 0xFFFA46
38#define CSPAR1 WORD_REF(CSPAR1_ADDR)
39#define CSARBT_ADDR 0xFFFA48
40#define CSARBT WORD_REF(CSARBT_ADDR)
41#define CSOPBT_ADDR 0xFFFA4A
42#define CSOPBT WORD_REF(CSOPBT_ADDR)
43#define CSBAR0_ADDR 0xFFFA4C
44#define CSBAR0 WORD_REF(CSBAR0_ADDR)
45#define CSOR0_ADDR 0xFFFA4E
46#define CSOR0 WORD_REF(CSOR0_ADDR)
47#define CSBAR1_ADDR 0xFFFA50
48#define CSBAR1 WORD_REF(CSBAR1_ADDR)
49#define CSOR1_ADDR 0xFFFA52
50#define CSOR1 WORD_REF(CSOR1_ADDR)
51#define CSBAR2_ADDR 0xFFFA54
52#define CSBAR2 WORD_REF(CSBAR2_ADDR)
53#define CSOR2_ADDR 0xFFFA56
54#define CSOR2 WORD_REF(CSOR2_ADDR)
55#define CSBAR3_ADDR 0xFFFA58
56#define CSBAR3 WORD_REF(CSBAR3_ADDR)
57#define CSOR3_ADDR 0xFFFA5A
58#define CSOR3 WORD_REF(CSOR3_ADDR)
59#define CSBAR4_ADDR 0xFFFA5C
60#define CSBAR4 WORD_REF(CSBAR4_ADDR)
61#define CSOR4_ADDR 0xFFFA5E
62#define CSOR4 WORD_REF(CSOR4_ADDR)
63#define CSBAR5_ADDR 0xFFFA60
64#define CSBAR5 WORD_REF(CSBAR5_ADDR)
65#define CSOR5_ADDR 0xFFFA62
66#define CSOR5 WORD_REF(CSOR5_ADDR)
67#define CSBAR6_ADDR 0xFFFA64
68#define CSBAR6 WORD_REF(CSBAR6_ADDR)
69#define CSOR6_ADDR 0xFFFA66
70#define CSOR6 WORD_REF(CSOR6_ADDR)
71#define CSBAR7_ADDR 0xFFFA68
72#define CSBAR7 WORD_REF(CSBAR7_ADDR)
73#define CSOR7_ADDR 0xFFFA6A
74#define CSOR7 WORD_REF(CSOR7_ADDR)
75#define CSBAR8_ADDR 0xFFFA6C
76#define CSBAR8 WORD_REF(CSBAR8_ADDR)
77#define CSOR8_ADDR 0xFFFA6E
78#define CSOR8 WORD_REF(CSOR8_ADDR)
79#define CSBAR9_ADDR 0xFFFA70
80#define CSBAR9 WORD_REF(CSBAR9_ADDR)
81#define CSOR9_ADDR 0xFFFA72
82#define CSOR9 WORD_REF(CSOR9_ADDR)
83#define CSBAR10_ADDR 0xFFFA74
84#define CSBAR10 WORD_REF(CSBAR10_ADDR)
85#define CSOR10_ADDR 0xFFFA76
86#define CSOR10 WORD_REF(CSOR10_ADDR)
87
88#define CSOR_MODE_ASYNC 0x0000
89#define CSOR_MODE_SYNC 0x8000
90#define CSOR_MODE_MASK 0x8000
91#define CSOR_BYTE_DISABLE 0x0000
92#define CSOR_BYTE_UPPER 0x4000
93#define CSOR_BYTE_LOWER 0x2000
94#define CSOR_BYTE_BOTH 0x6000
95#define CSOR_BYTE_MASK 0x6000
96#define CSOR_RW_RSVD 0x0000
97#define CSOR_RW_READ 0x0800
98#define CSOR_RW_WRITE 0x1000
99#define CSOR_RW_BOTH 0x1800
100#define CSOR_RW_MASK 0x1800
101#define CSOR_STROBE_DS 0x0400
102#define CSOR_STROBE_AS 0x0000
103#define CSOR_STROBE_MASK 0x0400
104#define CSOR_DSACK_WAIT(x) (wait << 6)
105#define CSOR_DSACK_FTERM (14 << 6)
106#define CSOR_DSACK_EXTERNAL (15 << 6)
107#define CSOR_DSACK_MASK 0x03c0
108#define CSOR_SPACE_CPU 0x0000
109#define CSOR_SPACE_USER 0x0010
110#define CSOR_SPACE_SU 0x0020
111#define CSOR_SPACE_BOTH 0x0030
112#define CSOR_SPACE_MASK 0x0030
113#define CSOR_IPL_ALL 0x0000
114#define CSOR_IPL_PRIORITY(x) (x << 1)
115#define CSOR_IPL_MASK 0x000e
116#define CSOR_AVEC_ON 0x0001
117#define CSOR_AVEC_OFF 0x0000
118#define CSOR_AVEC_MASK 0x0001
119
120#define CSBAR_ADDR(x) ((addr >> 11) << 3)
121#define CSBAR_ADDR_MASK 0xfff8
122#define CSBAR_BLKSIZE_2K 0x0000
123#define CSBAR_BLKSIZE_8K 0x0001
124#define CSBAR_BLKSIZE_16K 0x0002
125#define CSBAR_BLKSIZE_64K 0x0003
126#define CSBAR_BLKSIZE_128K 0x0004
127#define CSBAR_BLKSIZE_256K 0x0005
128#define CSBAR_BLKSIZE_512K 0x0006
129#define CSBAR_BLKSIZE_1M 0x0007
130#define CSBAR_BLKSIZE_MASK 0x0007
131
132#define CSPAR_DISC 0
133#define CSPAR_ALT 1
134#define CSPAR_CS8 2
135#define CSPAR_CS16 3
136#define CSPAR_MASK 3
137
138#define CSPAR0_CSBOOT(x) (x << 0)
139#define CSPAR0_CS0(x) (x << 2)
140#define CSPAR0_CS1(x) (x << 4)
141#define CSPAR0_CS2(x) (x << 6)
142#define CSPAR0_CS3(x) (x << 8)
143#define CSPAR0_CS4(x) (x << 10)
144#define CSPAR0_CS5(x) (x << 12)
145
146#define CSPAR1_CS6(x) (x << 0)
147#define CSPAR1_CS7(x) (x << 2)
148#define CSPAR1_CS8(x) (x << 4)
149#define CSPAR1_CS9(x) (x << 6)
150#define CSPAR1_CS10(x) (x << 8)
151
152#endif
diff --git a/arch/m68k/include/asm/apollodma.h b/arch/m68k/include/asm/apollodma.h
deleted file mode 100644
index 954adc851ad..00000000000
--- a/arch/m68k/include/asm/apollodma.h
+++ /dev/null
@@ -1,248 +0,0 @@
1/*
2 * linux/include/asm/dma.h: Defines for using and allocating dma channels.
3 * Written by Hennus Bergman, 1992.
4 * High DMA channel support & info by Hannu Savolainen
5 * and John Boyd, Nov. 1992.
6 */
7
8#ifndef _ASM_APOLLO_DMA_H
9#define _ASM_APOLLO_DMA_H
10
11#include <asm/apollohw.h> /* need byte IO */
12#include <linux/spinlock.h> /* And spinlocks */
13#include <linux/delay.h>
14
15
16#define dma_outb(val,addr) (*((volatile unsigned char *)(addr+IO_BASE)) = (val))
17#define dma_inb(addr) (*((volatile unsigned char *)(addr+IO_BASE)))
18
19/*
20 * NOTES about DMA transfers:
21 *
22 * controller 1: channels 0-3, byte operations, ports 00-1F
23 * controller 2: channels 4-7, word operations, ports C0-DF
24 *
25 * - ALL registers are 8 bits only, regardless of transfer size
26 * - channel 4 is not used - cascades 1 into 2.
27 * - channels 0-3 are byte - addresses/counts are for physical bytes
28 * - channels 5-7 are word - addresses/counts are for physical words
29 * - transfers must not cross physical 64K (0-3) or 128K (5-7) boundaries
30 * - transfer count loaded to registers is 1 less than actual count
31 * - controller 2 offsets are all even (2x offsets for controller 1)
32 * - page registers for 5-7 don't use data bit 0, represent 128K pages
33 * - page registers for 0-3 use bit 0, represent 64K pages
34 *
35 * DMA transfers are limited to the lower 16MB of _physical_ memory.
36 * Note that addresses loaded into registers must be _physical_ addresses,
37 * not logical addresses (which may differ if paging is active).
38 *
39 * Address mapping for channels 0-3:
40 *
41 * A23 ... A16 A15 ... A8 A7 ... A0 (Physical addresses)
42 * | ... | | ... | | ... |
43 * | ... | | ... | | ... |
44 * | ... | | ... | | ... |
45 * P7 ... P0 A7 ... A0 A7 ... A0
46 * | Page | Addr MSB | Addr LSB | (DMA registers)
47 *
48 * Address mapping for channels 5-7:
49 *
50 * A23 ... A17 A16 A15 ... A9 A8 A7 ... A1 A0 (Physical addresses)
51 * | ... | \ \ ... \ \ \ ... \ \
52 * | ... | \ \ ... \ \ \ ... \ (not used)
53 * | ... | \ \ ... \ \ \ ... \
54 * P7 ... P1 (0) A7 A6 ... A0 A7 A6 ... A0
55 * | Page | Addr MSB | Addr LSB | (DMA registers)
56 *
57 * Again, channels 5-7 transfer _physical_ words (16 bits), so addresses
58 * and counts _must_ be word-aligned (the lowest address bit is _ignored_ at
59 * the hardware level, so odd-byte transfers aren't possible).
60 *
61 * Transfer count (_not # bytes_) is limited to 64K, represented as actual
62 * count - 1 : 64K => 0xFFFF, 1 => 0x0000. Thus, count is always 1 or more,
63 * and up to 128K bytes may be transferred on channels 5-7 in one operation.
64 *
65 */
66
67#define MAX_DMA_CHANNELS 8
68
69/* The maximum address that we can perform a DMA transfer to on this platform */#define MAX_DMA_ADDRESS (PAGE_OFFSET+0x1000000)
70
71/* 8237 DMA controllers */
72#define IO_DMA1_BASE 0x10C00 /* 8 bit slave DMA, channels 0..3 */
73#define IO_DMA2_BASE 0x10D00 /* 16 bit master DMA, ch 4(=slave input)..7 */
74
75/* DMA controller registers */
76#define DMA1_CMD_REG (IO_DMA1_BASE+0x08) /* command register (w) */
77#define DMA1_STAT_REG (IO_DMA1_BASE+0x08) /* status register (r) */
78#define DMA1_REQ_REG (IO_DMA1_BASE+0x09) /* request register (w) */
79#define DMA1_MASK_REG (IO_DMA1_BASE+0x0A) /* single-channel mask (w) */
80#define DMA1_MODE_REG (IO_DMA1_BASE+0x0B) /* mode register (w) */
81#define DMA1_CLEAR_FF_REG (IO_DMA1_BASE+0x0C) /* clear pointer flip-flop (w) */
82#define DMA1_TEMP_REG (IO_DMA1_BASE+0x0D) /* Temporary Register (r) */
83#define DMA1_RESET_REG (IO_DMA1_BASE+0x0D) /* Master Clear (w) */
84#define DMA1_CLR_MASK_REG (IO_DMA1_BASE+0x0E) /* Clear Mask */
85#define DMA1_MASK_ALL_REG (IO_DMA1_BASE+0x0F) /* all-channels mask (w) */
86
87#define DMA2_CMD_REG (IO_DMA2_BASE+0x10) /* command register (w) */
88#define DMA2_STAT_REG (IO_DMA2_BASE+0x10) /* status register (r) */
89#define DMA2_REQ_REG (IO_DMA2_BASE+0x12) /* request register (w) */
90#define DMA2_MASK_REG (IO_DMA2_BASE+0x14) /* single-channel mask (w) */
91#define DMA2_MODE_REG (IO_DMA2_BASE+0x16) /* mode register (w) */
92#define DMA2_CLEAR_FF_REG (IO_DMA2_BASE+0x18) /* clear pointer flip-flop (w) */
93#define DMA2_TEMP_REG (IO_DMA2_BASE+0x1A) /* Temporary Register (r) */
94#define DMA2_RESET_REG (IO_DMA2_BASE+0x1A) /* Master Clear (w) */
95#define DMA2_CLR_MASK_REG (IO_DMA2_BASE+0x1C) /* Clear Mask */
96#define DMA2_MASK_ALL_REG (IO_DMA2_BASE+0x1E) /* all-channels mask (w) */
97
98#define DMA_ADDR_0 (IO_DMA1_BASE+0x00) /* DMA address registers */
99#define DMA_ADDR_1 (IO_DMA1_BASE+0x02)
100#define DMA_ADDR_2 (IO_DMA1_BASE+0x04)
101#define DMA_ADDR_3 (IO_DMA1_BASE+0x06)
102#define DMA_ADDR_4 (IO_DMA2_BASE+0x00)
103#define DMA_ADDR_5 (IO_DMA2_BASE+0x04)
104#define DMA_ADDR_6 (IO_DMA2_BASE+0x08)
105#define DMA_ADDR_7 (IO_DMA2_BASE+0x0C)
106
107#define DMA_CNT_0 (IO_DMA1_BASE+0x01) /* DMA count registers */
108#define DMA_CNT_1 (IO_DMA1_BASE+0x03)
109#define DMA_CNT_2 (IO_DMA1_BASE+0x05)
110#define DMA_CNT_3 (IO_DMA1_BASE+0x07)
111#define DMA_CNT_4 (IO_DMA2_BASE+0x02)
112#define DMA_CNT_5 (IO_DMA2_BASE+0x06)
113#define DMA_CNT_6 (IO_DMA2_BASE+0x0A)
114#define DMA_CNT_7 (IO_DMA2_BASE+0x0E)
115
116#define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */
117#define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */
118#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */
119
120#define DMA_AUTOINIT 0x10
121
122#define DMA_8BIT 0
123#define DMA_16BIT 1
124#define DMA_BUSMASTER 2
125
126extern spinlock_t dma_spin_lock;
127
128static __inline__ unsigned long claim_dma_lock(void)
129{
130 unsigned long flags;
131 spin_lock_irqsave(&dma_spin_lock, flags);
132 return flags;
133}
134
135static __inline__ void release_dma_lock(unsigned long flags)
136{
137 spin_unlock_irqrestore(&dma_spin_lock, flags);
138}
139
140/* enable/disable a specific DMA channel */
141static __inline__ void enable_dma(unsigned int dmanr)
142{
143 if (dmanr<=3)
144 dma_outb(dmanr, DMA1_MASK_REG);
145 else
146 dma_outb(dmanr & 3, DMA2_MASK_REG);
147}
148
149static __inline__ void disable_dma(unsigned int dmanr)
150{
151 if (dmanr<=3)
152 dma_outb(dmanr | 4, DMA1_MASK_REG);
153 else
154 dma_outb((dmanr & 3) | 4, DMA2_MASK_REG);
155}
156
157/* Clear the 'DMA Pointer Flip Flop'.
158 * Write 0 for LSB/MSB, 1 for MSB/LSB access.
159 * Use this once to initialize the FF to a known state.
160 * After that, keep track of it. :-)
161 * --- In order to do that, the DMA routines below should ---
162 * --- only be used while holding the DMA lock ! ---
163 */
164static __inline__ void clear_dma_ff(unsigned int dmanr)
165{
166 if (dmanr<=3)
167 dma_outb(0, DMA1_CLEAR_FF_REG);
168 else
169 dma_outb(0, DMA2_CLEAR_FF_REG);
170}
171
172/* set mode (above) for a specific DMA channel */
173static __inline__ void set_dma_mode(unsigned int dmanr, char mode)
174{
175 if (dmanr<=3)
176 dma_outb(mode | dmanr, DMA1_MODE_REG);
177 else
178 dma_outb(mode | (dmanr&3), DMA2_MODE_REG);
179}
180
181/* Set transfer address & page bits for specific DMA channel.
182 * Assumes dma flipflop is clear.
183 */
184static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a)
185{
186 if (dmanr <= 3) {
187 dma_outb( a & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE );
188 dma_outb( (a>>8) & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE );
189 } else {
190 dma_outb( (a>>1) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE );
191 dma_outb( (a>>9) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE );
192 }
193}
194
195
196/* Set transfer size (max 64k for DMA1..3, 128k for DMA5..7) for
197 * a specific DMA channel.
198 * You must ensure the parameters are valid.
199 * NOTE: from a manual: "the number of transfers is one more
200 * than the initial word count"! This is taken into account.
201 * Assumes dma flip-flop is clear.
202 * NOTE 2: "count" represents _bytes_ and must be even for channels 5-7.
203 */
204static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count)
205{
206 count--;
207 if (dmanr <= 3) {
208 dma_outb( count & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE );
209 dma_outb( (count>>8) & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE );
210 } else {
211 dma_outb( (count>>1) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE );
212 dma_outb( (count>>9) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE );
213 }
214}
215
216
217/* Get DMA residue count. After a DMA transfer, this
218 * should return zero. Reading this while a DMA transfer is
219 * still in progress will return unpredictable results.
220 * If called before the channel has been used, it may return 1.
221 * Otherwise, it returns the number of _bytes_ left to transfer.
222 *
223 * Assumes DMA flip-flop is clear.
224 */
225static __inline__ int get_dma_residue(unsigned int dmanr)
226{
227 unsigned int io_port = (dmanr<=3)? ((dmanr&3)<<1) + 1 + IO_DMA1_BASE
228 : ((dmanr&3)<<2) + 2 + IO_DMA2_BASE;
229
230 /* using short to get 16-bit wrap around */
231 unsigned short count;
232
233 count = 1 + dma_inb(io_port);
234 count += dma_inb(io_port) << 8;
235
236 return (dmanr<=3)? count : (count<<1);
237}
238
239
240/* These are in kernel/dma.c: */
241extern int request_dma(unsigned int dmanr, const char * device_id); /* reserve a DMA channel */
242extern void free_dma(unsigned int dmanr); /* release it again */
243
244/* These are in arch/m68k/apollo/dma.c: */
245extern unsigned short dma_map_page(unsigned long phys_addr,int count,int type);
246extern void dma_unmap_page(unsigned short dma_addr);
247
248#endif /* _ASM_APOLLO_DMA_H */
diff --git a/arch/m68k/include/asm/apollohw.h b/arch/m68k/include/asm/apollohw.h
index a1373b9aa28..635ef4f8901 100644
--- a/arch/m68k/include/asm/apollohw.h
+++ b/arch/m68k/include/asm/apollohw.h
@@ -98,7 +98,7 @@ extern u_long timer_physaddr;
98#define cpuctrl (*(volatile unsigned int *)(IO_BASE + cpuctrl_physaddr)) 98#define cpuctrl (*(volatile unsigned int *)(IO_BASE + cpuctrl_physaddr))
99#define pica (IO_BASE + pica_physaddr) 99#define pica (IO_BASE + pica_physaddr)
100#define picb (IO_BASE + picb_physaddr) 100#define picb (IO_BASE + picb_physaddr)
101#define timer (IO_BASE + timer_physaddr) 101#define apollo_timer (IO_BASE + timer_physaddr)
102#define addr_xlat_map ((unsigned short *)(IO_BASE + 0x17000)) 102#define addr_xlat_map ((unsigned short *)(IO_BASE + 0x17000))
103 103
104#define isaIO2mem(x) (((((x) & 0x3f8) << 7) | (((x) & 0xfc00) >> 6) | ((x) & 0x7)) + 0x40000 + IO_BASE) 104#define isaIO2mem(x) (((((x) & 0x3f8) << 7) | (((x) & 0xfc00) >> 6) | ((x) & 0x7)) + 0x40000 + IO_BASE)
diff --git a/arch/m68k/include/asm/bitsperlong.h b/arch/m68k/include/asm/bitsperlong.h
deleted file mode 100644
index 6dc0bb0c13b..00000000000
--- a/arch/m68k/include/asm/bitsperlong.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/bitsperlong.h>
diff --git a/arch/m68k/include/asm/cacheflush_mm.h b/arch/m68k/include/asm/cacheflush_mm.h
index 8104bd87464..fa2c3d681d8 100644
--- a/arch/m68k/include/asm/cacheflush_mm.h
+++ b/arch/m68k/include/asm/cacheflush_mm.h
@@ -16,7 +16,48 @@
16#define DCACHE_MAX_ADDR 0 16#define DCACHE_MAX_ADDR 0
17#define DCACHE_SETMASK 0 17#define DCACHE_SETMASK 0
18#endif 18#endif
19#ifndef CACHE_MODE
20#define CACHE_MODE 0
21#define CACR_ICINVA 0
22#define CACR_DCINVA 0
23#define CACR_BCINVA 0
24#endif
25
26/*
27 * ColdFire architecture has no way to clear individual cache lines, so we
28 * are stuck invalidating all the cache entries when we want a clear operation.
29 */
30static inline void clear_cf_icache(unsigned long start, unsigned long end)
31{
32 __asm__ __volatile__ (
33 "movec %0,%%cacr\n\t"
34 "nop"
35 :
36 : "r" (CACHE_MODE | CACR_ICINVA | CACR_BCINVA));
37}
38
39static inline void clear_cf_dcache(unsigned long start, unsigned long end)
40{
41 __asm__ __volatile__ (
42 "movec %0,%%cacr\n\t"
43 "nop"
44 :
45 : "r" (CACHE_MODE | CACR_DCINVA));
46}
19 47
48static inline void clear_cf_bcache(unsigned long start, unsigned long end)
49{
50 __asm__ __volatile__ (
51 "movec %0,%%cacr\n\t"
52 "nop"
53 :
54 : "r" (CACHE_MODE | CACR_ICINVA | CACR_BCINVA | CACR_DCINVA));
55}
56
57/*
58 * Use the ColdFire cpushl instruction to push (and invalidate) cache lines.
59 * The start and end addresses are cache line numbers not memory addresses.
60 */
20static inline void flush_cf_icache(unsigned long start, unsigned long end) 61static inline void flush_cf_icache(unsigned long start, unsigned long end)
21{ 62{
22 unsigned long set; 63 unsigned long set;
diff --git a/arch/m68k/include/asm/cputime.h b/arch/m68k/include/asm/cputime.h
deleted file mode 100644
index c79c5e89230..00000000000
--- a/arch/m68k/include/asm/cputime.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __M68K_CPUTIME_H
2#define __M68K_CPUTIME_H
3
4#include <asm-generic/cputime.h>
5
6#endif /* __M68K_CPUTIME_H */
diff --git a/arch/m68k/include/asm/delay.h b/arch/m68k/include/asm/delay.h
index 9c09becfd4c..12d8fe4f1d3 100644
--- a/arch/m68k/include/asm/delay.h
+++ b/arch/m68k/include/asm/delay.h
@@ -43,7 +43,7 @@ static inline void __delay(unsigned long loops)
43extern void __bad_udelay(void); 43extern void __bad_udelay(void);
44 44
45 45
46#if defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE) 46#ifdef CONFIG_CPU_HAS_NO_MULDIV64
47/* 47/*
48 * The simpler m68k and ColdFire processors do not have a 32*32->64 48 * The simpler m68k and ColdFire processors do not have a 32*32->64
49 * multiply instruction. So we need to handle them a little differently. 49 * multiply instruction. So we need to handle them a little differently.
diff --git a/arch/m68k/include/asm/device.h b/arch/m68k/include/asm/device.h
deleted file mode 100644
index d8f9872b0e2..00000000000
--- a/arch/m68k/include/asm/device.h
+++ /dev/null
@@ -1,7 +0,0 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/arch/m68k/include/asm/dma.h b/arch/m68k/include/asm/dma.h
index 6fbdfe89510..0ff3fc6a6d9 100644
--- a/arch/m68k/include/asm/dma.h
+++ b/arch/m68k/include/asm/dma.h
@@ -33,7 +33,9 @@
33 * Set number of channels of DMA on ColdFire for different implementations. 33 * Set number of channels of DMA on ColdFire for different implementations.
34 */ 34 */
35#if defined(CONFIG_M5249) || defined(CONFIG_M5307) || defined(CONFIG_M5407) || \ 35#if defined(CONFIG_M5249) || defined(CONFIG_M5307) || defined(CONFIG_M5407) || \
36 defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) 36 defined(CONFIG_M523x) || defined(CONFIG_M527x) || \
37 defined(CONFIG_M528x) || defined(CONFIG_M525x)
38
37#define MAX_M68K_DMA_CHANNELS 4 39#define MAX_M68K_DMA_CHANNELS 4
38#elif defined(CONFIG_M5272) 40#elif defined(CONFIG_M5272)
39#define MAX_M68K_DMA_CHANNELS 1 41#define MAX_M68K_DMA_CHANNELS 1
@@ -486,6 +488,10 @@ static __inline__ int get_dma_residue(unsigned int dmanr)
486extern int request_dma(unsigned int dmanr, const char * device_id); /* reserve a DMA channel */ 488extern int request_dma(unsigned int dmanr, const char * device_id); /* reserve a DMA channel */
487extern void free_dma(unsigned int dmanr); /* release it again */ 489extern void free_dma(unsigned int dmanr); /* release it again */
488 490
491#ifdef CONFIG_PCI
492extern int isa_dma_bridge_buggy;
493#else
489#define isa_dma_bridge_buggy (0) 494#define isa_dma_bridge_buggy (0)
495#endif
490 496
491#endif /* _M68K_DMA_H */ 497#endif /* _M68K_DMA_H */
diff --git a/arch/m68k/include/asm/emergency-restart.h b/arch/m68k/include/asm/emergency-restart.h
deleted file mode 100644
index 108d8c48e42..00000000000
--- a/arch/m68k/include/asm/emergency-restart.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_EMERGENCY_RESTART_H
2#define _ASM_EMERGENCY_RESTART_H
3
4#include <asm-generic/emergency-restart.h>
5
6#endif /* _ASM_EMERGENCY_RESTART_H */
diff --git a/arch/m68k/include/asm/errno.h b/arch/m68k/include/asm/errno.h
deleted file mode 100644
index 0d4e188d6ef..00000000000
--- a/arch/m68k/include/asm/errno.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _M68K_ERRNO_H
2#define _M68K_ERRNO_H
3
4#include <asm-generic/errno.h>
5
6#endif /* _M68K_ERRNO_H */
diff --git a/arch/m68k/include/asm/futex.h b/arch/m68k/include/asm/futex.h
deleted file mode 100644
index 6a332a9f099..00000000000
--- a/arch/m68k/include/asm/futex.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_FUTEX_H
2#define _ASM_FUTEX_H
3
4#include <asm-generic/futex.h>
5
6#endif
diff --git a/arch/m68k/include/asm/gpio.h b/arch/m68k/include/asm/gpio.h
index 00d0071de4c..4395ffc51fd 100644
--- a/arch/m68k/include/asm/gpio.h
+++ b/arch/m68k/include/asm/gpio.h
@@ -17,170 +17,9 @@
17#define coldfire_gpio_h 17#define coldfire_gpio_h
18 18
19#include <linux/io.h> 19#include <linux/io.h>
20#include <asm-generic/gpio.h>
21#include <asm/coldfire.h> 20#include <asm/coldfire.h>
22#include <asm/mcfsim.h> 21#include <asm/mcfsim.h>
23 22#include <asm/mcfgpio.h>
24/*
25 * The Freescale Coldfire family is quite varied in how they implement GPIO.
26 * Some parts have 8 bit ports, some have 16bit and some have 32bit; some have
27 * only one port, others have multiple ports; some have a single data latch
28 * for both input and output, others have a separate pin data register to read
29 * input; some require a read-modify-write access to change an output, others
30 * have set and clear registers for some of the outputs; Some have all the
31 * GPIOs in a single control area, others have some GPIOs implemented in
32 * different modules.
33 *
34 * This implementation attempts accommodate the differences while presenting
35 * a generic interface that will optimize to as few instructions as possible.
36 */
37#if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || \
38 defined(CONFIG_M520x) || defined(CONFIG_M523x) || \
39 defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
40 defined(CONFIG_M532x) || defined(CONFIG_M54xx)
41
42/* These parts have GPIO organized by 8 bit ports */
43
44#define MCFGPIO_PORTTYPE u8
45#define MCFGPIO_PORTSIZE 8
46#define mcfgpio_read(port) __raw_readb(port)
47#define mcfgpio_write(data, port) __raw_writeb(data, port)
48
49#elif defined(CONFIG_M5307) || defined(CONFIG_M5407) || defined(CONFIG_M5272)
50
51/* These parts have GPIO organized by 16 bit ports */
52
53#define MCFGPIO_PORTTYPE u16
54#define MCFGPIO_PORTSIZE 16
55#define mcfgpio_read(port) __raw_readw(port)
56#define mcfgpio_write(data, port) __raw_writew(data, port)
57
58#elif defined(CONFIG_M5249)
59
60/* These parts have GPIO organized by 32 bit ports */
61
62#define MCFGPIO_PORTTYPE u32
63#define MCFGPIO_PORTSIZE 32
64#define mcfgpio_read(port) __raw_readl(port)
65#define mcfgpio_write(data, port) __raw_writel(data, port)
66
67#endif
68
69#define mcfgpio_bit(gpio) (1 << ((gpio) % MCFGPIO_PORTSIZE))
70#define mcfgpio_port(gpio) ((gpio) / MCFGPIO_PORTSIZE)
71
72#if defined(CONFIG_M520x) || defined(CONFIG_M523x) || \
73 defined(CONFIG_M527x) || defined(CONFIG_M528x) || defined(CONFIG_M532x)
74/*
75 * These parts have an 'Edge' Port module (external interrupt/GPIO) which uses
76 * read-modify-write to change an output and a GPIO module which has separate
77 * set/clr registers to directly change outputs with a single write access.
78 */
79#if defined(CONFIG_M528x)
80/*
81 * The 528x also has GPIOs in other modules (GPT, QADC) which use
82 * read-modify-write as well as those controlled by the EPORT and GPIO modules.
83 */
84#define MCFGPIO_SCR_START 40
85#else
86#define MCFGPIO_SCR_START 8
87#endif
88
89#define MCFGPIO_SETR_PORT(gpio) (MCFGPIO_SETR + \
90 mcfgpio_port(gpio - MCFGPIO_SCR_START))
91
92#define MCFGPIO_CLRR_PORT(gpio) (MCFGPIO_CLRR + \
93 mcfgpio_port(gpio - MCFGPIO_SCR_START))
94#else
95
96#define MCFGPIO_SCR_START MCFGPIO_PIN_MAX
97/* with MCFGPIO_SCR == MCFGPIO_PIN_MAX, these will be optimized away */
98#define MCFGPIO_SETR_PORT(gpio) 0
99#define MCFGPIO_CLRR_PORT(gpio) 0
100
101#endif
102/*
103 * Coldfire specific helper functions
104 */
105
106/* return the port pin data register for a gpio */
107static inline u32 __mcf_gpio_ppdr(unsigned gpio)
108{
109#if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || \
110 defined(CONFIG_M5307) || defined(CONFIG_M5407)
111 return MCFSIM_PADAT;
112#elif defined(CONFIG_M5272)
113 if (gpio < 16)
114 return MCFSIM_PADAT;
115 else if (gpio < 32)
116 return MCFSIM_PBDAT;
117 else
118 return MCFSIM_PCDAT;
119#elif defined(CONFIG_M5249)
120 if (gpio < 32)
121 return MCFSIM2_GPIOREAD;
122 else
123 return MCFSIM2_GPIO1READ;
124#elif defined(CONFIG_M520x) || defined(CONFIG_M523x) || \
125 defined(CONFIG_M527x) || defined(CONFIG_M528x) || defined(CONFIG_M532x)
126 if (gpio < 8)
127 return MCFEPORT_EPPDR;
128#if defined(CONFIG_M528x)
129 else if (gpio < 16)
130 return MCFGPTA_GPTPORT;
131 else if (gpio < 24)
132 return MCFGPTB_GPTPORT;
133 else if (gpio < 32)
134 return MCFQADC_PORTQA;
135 else if (gpio < 40)
136 return MCFQADC_PORTQB;
137#endif
138 else
139 return MCFGPIO_PPDR + mcfgpio_port(gpio - MCFGPIO_SCR_START);
140#else
141 return 0;
142#endif
143}
144
145/* return the port output data register for a gpio */
146static inline u32 __mcf_gpio_podr(unsigned gpio)
147{
148#if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || \
149 defined(CONFIG_M5307) || defined(CONFIG_M5407)
150 return MCFSIM_PADAT;
151#elif defined(CONFIG_M5272)
152 if (gpio < 16)
153 return MCFSIM_PADAT;
154 else if (gpio < 32)
155 return MCFSIM_PBDAT;
156 else
157 return MCFSIM_PCDAT;
158#elif defined(CONFIG_M5249)
159 if (gpio < 32)
160 return MCFSIM2_GPIOWRITE;
161 else
162 return MCFSIM2_GPIO1WRITE;
163#elif defined(CONFIG_M520x) || defined(CONFIG_M523x) || \
164 defined(CONFIG_M527x) || defined(CONFIG_M528x) || defined(CONFIG_M532x)
165 if (gpio < 8)
166 return MCFEPORT_EPDR;
167#if defined(CONFIG_M528x)
168 else if (gpio < 16)
169 return MCFGPTA_GPTPORT;
170 else if (gpio < 24)
171 return MCFGPTB_GPTPORT;
172 else if (gpio < 32)
173 return MCFQADC_PORTQA;
174 else if (gpio < 40)
175 return MCFQADC_PORTQB;
176#endif
177 else
178 return MCFGPIO_PODR + mcfgpio_port(gpio - MCFGPIO_SCR_START);
179#else
180 return 0;
181#endif
182}
183
184/* 23/*
185 * The Generic GPIO functions 24 * The Generic GPIO functions
186 * 25 *
@@ -191,7 +30,7 @@ static inline u32 __mcf_gpio_podr(unsigned gpio)
191static inline int gpio_get_value(unsigned gpio) 30static inline int gpio_get_value(unsigned gpio)
192{ 31{
193 if (__builtin_constant_p(gpio) && gpio < MCFGPIO_PIN_MAX) 32 if (__builtin_constant_p(gpio) && gpio < MCFGPIO_PIN_MAX)
194 return mcfgpio_read(__mcf_gpio_ppdr(gpio)) & mcfgpio_bit(gpio); 33 return mcfgpio_read(__mcfgpio_ppdr(gpio)) & mcfgpio_bit(gpio);
195 else 34 else
196 return __gpio_get_value(gpio); 35 return __gpio_get_value(gpio);
197} 36}
@@ -204,12 +43,12 @@ static inline void gpio_set_value(unsigned gpio, int value)
204 MCFGPIO_PORTTYPE data; 43 MCFGPIO_PORTTYPE data;
205 44
206 local_irq_save(flags); 45 local_irq_save(flags);
207 data = mcfgpio_read(__mcf_gpio_podr(gpio)); 46 data = mcfgpio_read(__mcfgpio_podr(gpio));
208 if (value) 47 if (value)
209 data |= mcfgpio_bit(gpio); 48 data |= mcfgpio_bit(gpio);
210 else 49 else
211 data &= ~mcfgpio_bit(gpio); 50 data &= ~mcfgpio_bit(gpio);
212 mcfgpio_write(data, __mcf_gpio_podr(gpio)); 51 mcfgpio_write(data, __mcfgpio_podr(gpio));
213 local_irq_restore(flags); 52 local_irq_restore(flags);
214 } else { 53 } else {
215 if (value) 54 if (value)
@@ -225,8 +64,14 @@ static inline void gpio_set_value(unsigned gpio, int value)
225 64
226static inline int gpio_to_irq(unsigned gpio) 65static inline int gpio_to_irq(unsigned gpio)
227{ 66{
228 return (gpio < MCFGPIO_IRQ_MAX) ? gpio + MCFGPIO_IRQ_VECBASE 67#if defined(MCFGPIO_IRQ_MIN)
229 : __gpio_to_irq(gpio); 68 if ((gpio >= MCFGPIO_IRQ_MIN) && (gpio < MCFGPIO_IRQ_MAX))
69#else
70 if (gpio < MCFGPIO_IRQ_MAX)
71#endif
72 return gpio + MCFGPIO_IRQ_VECBASE;
73 else
74 return __gpio_to_irq(gpio);
230} 75}
231 76
232static inline int irq_to_gpio(unsigned irq) 77static inline int irq_to_gpio(unsigned irq)
diff --git a/arch/m68k/include/asm/io_mm.h b/arch/m68k/include/asm/io_mm.h
index fa4324bcf56..a6686d26fe1 100644
--- a/arch/m68k/include/asm/io_mm.h
+++ b/arch/m68k/include/asm/io_mm.h
@@ -65,7 +65,53 @@
65 65
66 66
67 67
68#ifdef CONFIG_ISA 68#if defined(CONFIG_PCI) && defined(CONFIG_COLDFIRE)
69
70#define HAVE_ARCH_PIO_SIZE
71#define PIO_OFFSET 0
72#define PIO_MASK 0xffff
73#define PIO_RESERVED 0x10000
74
75u8 mcf_pci_inb(u32 addr);
76u16 mcf_pci_inw(u32 addr);
77u32 mcf_pci_inl(u32 addr);
78void mcf_pci_insb(u32 addr, u8 *buf, u32 len);
79void mcf_pci_insw(u32 addr, u16 *buf, u32 len);
80void mcf_pci_insl(u32 addr, u32 *buf, u32 len);
81
82void mcf_pci_outb(u8 v, u32 addr);
83void mcf_pci_outw(u16 v, u32 addr);
84void mcf_pci_outl(u32 v, u32 addr);
85void mcf_pci_outsb(u32 addr, const u8 *buf, u32 len);
86void mcf_pci_outsw(u32 addr, const u16 *buf, u32 len);
87void mcf_pci_outsl(u32 addr, const u32 *buf, u32 len);
88
89#define inb mcf_pci_inb
90#define inb_p mcf_pci_inb
91#define inw mcf_pci_inw
92#define inw_p mcf_pci_inw
93#define inl mcf_pci_inl
94#define inl_p mcf_pci_inl
95#define insb mcf_pci_insb
96#define insw mcf_pci_insw
97#define insl mcf_pci_insl
98
99#define outb mcf_pci_outb
100#define outb_p mcf_pci_outb
101#define outw mcf_pci_outw
102#define outw_p mcf_pci_outw
103#define outl mcf_pci_outl
104#define outl_p mcf_pci_outl
105#define outsb mcf_pci_outsb
106#define outsw mcf_pci_outsw
107#define outsl mcf_pci_outsl
108
109#define readb(addr) in_8(addr)
110#define writeb(v, addr) out_8((addr), (v))
111#define readw(addr) in_le16(addr)
112#define writew(v, addr) out_le16((addr), (v))
113
114#elif defined(CONFIG_ISA)
69 115
70#if MULTI_ISA == 0 116#if MULTI_ISA == 0
71#undef MULTI_ISA 117#undef MULTI_ISA
@@ -340,4 +386,6 @@ static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int
340 */ 386 */
341#define xlate_dev_kmem_ptr(p) p 387#define xlate_dev_kmem_ptr(p) p
342 388
389#define ioport_map(port, nr) ((void __iomem *)(port))
390
343#endif /* _IO_H */ 391#endif /* _IO_H */
diff --git a/arch/m68k/include/asm/ioctl.h b/arch/m68k/include/asm/ioctl.h
deleted file mode 100644
index b279fe06dfe..00000000000
--- a/arch/m68k/include/asm/ioctl.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/ioctl.h>
diff --git a/arch/m68k/include/asm/ipcbuf.h b/arch/m68k/include/asm/ipcbuf.h
deleted file mode 100644
index 84c7e51cb6d..00000000000
--- a/arch/m68k/include/asm/ipcbuf.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/ipcbuf.h>
diff --git a/arch/m68k/include/asm/irq_regs.h b/arch/m68k/include/asm/irq_regs.h
deleted file mode 100644
index 3dd9c0b7027..00000000000
--- a/arch/m68k/include/asm/irq_regs.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/irq_regs.h>
diff --git a/arch/m68k/include/asm/kdebug.h b/arch/m68k/include/asm/kdebug.h
deleted file mode 100644
index 6ece1b03766..00000000000
--- a/arch/m68k/include/asm/kdebug.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/kdebug.h>
diff --git a/arch/m68k/include/asm/kmap_types.h b/arch/m68k/include/asm/kmap_types.h
deleted file mode 100644
index 3413cc1390e..00000000000
--- a/arch/m68k/include/asm/kmap_types.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_M68K_KMAP_TYPES_H
2#define __ASM_M68K_KMAP_TYPES_H
3
4#include <asm-generic/kmap_types.h>
5
6#endif /* __ASM_M68K_KMAP_TYPES_H */
diff --git a/arch/m68k/include/asm/kvm_para.h b/arch/m68k/include/asm/kvm_para.h
deleted file mode 100644
index 14fab8f0b95..00000000000
--- a/arch/m68k/include/asm/kvm_para.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/kvm_para.h>
diff --git a/arch/m68k/include/asm/local.h b/arch/m68k/include/asm/local.h
deleted file mode 100644
index 6c259263e1f..00000000000
--- a/arch/m68k/include/asm/local.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_M68K_LOCAL_H
2#define _ASM_M68K_LOCAL_H
3
4#include <asm-generic/local.h>
5
6#endif /* _ASM_M68K_LOCAL_H */
diff --git a/arch/m68k/include/asm/local64.h b/arch/m68k/include/asm/local64.h
deleted file mode 100644
index 36c93b5cc23..00000000000
--- a/arch/m68k/include/asm/local64.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/local64.h>
diff --git a/arch/m68k/include/asm/m520xsim.h b/arch/m68k/include/asm/m520xsim.h
index 17f2aab9cf9..db3f8ee4a6c 100644
--- a/arch/m68k/include/asm/m520xsim.h
+++ b/arch/m68k/include/asm/m520xsim.h
@@ -42,6 +42,9 @@
42#define MCFINTC1_SIMR (0) 42#define MCFINTC1_SIMR (0)
43#define MCFINTC1_CIMR (0) 43#define MCFINTC1_CIMR (0)
44#define MCFINTC1_ICR0 (0) 44#define MCFINTC1_ICR0 (0)
45#define MCFINTC2_SIMR (0)
46#define MCFINTC2_CIMR (0)
47#define MCFINTC2_ICR0 (0)
45 48
46#define MCFINT_VECBASE 64 49#define MCFINT_VECBASE 64
47#define MCFINT_UART0 26 /* Interrupt number for UART0 */ 50#define MCFINT_UART0 26 /* Interrupt number for UART0 */
@@ -62,6 +65,7 @@
62#define MCF_IRQ_FECENTC0 (MCFINT_VECBASE + MCFINT_FECENTC0) 65#define MCF_IRQ_FECENTC0 (MCFINT_VECBASE + MCFINT_FECENTC0)
63 66
64#define MCF_IRQ_QSPI (MCFINT_VECBASE + MCFINT_QSPI) 67#define MCF_IRQ_QSPI (MCFINT_VECBASE + MCFINT_QSPI)
68#define MCF_IRQ_PIT1 (MCFINT_VECBASE + MCFINT_PIT1)
65 69
66/* 70/*
67 * SDRAM configuration registers. 71 * SDRAM configuration registers.
@@ -186,5 +190,15 @@
186#define MCF_RCR_SWRESET 0x80 /* Software reset bit */ 190#define MCF_RCR_SWRESET 0x80 /* Software reset bit */
187#define MCF_RCR_FRCSTOUT 0x40 /* Force external reset */ 191#define MCF_RCR_FRCSTOUT 0x40 /* Force external reset */
188 192
193/*
194 * Power Management.
195 */
196#define MCFPM_WCR 0xfc040013
197#define MCFPM_PPMSR0 0xfc04002c
198#define MCFPM_PPMCR0 0xfc04002d
199#define MCFPM_PPMHR0 0xfc040030
200#define MCFPM_PPMLR0 0xfc040034
201#define MCFPM_LPCR 0xfc0a0007
202
189/****************************************************************************/ 203/****************************************************************************/
190#endif /* m520xsim_h */ 204#endif /* m520xsim_h */
diff --git a/arch/m68k/include/asm/m523xsim.h b/arch/m68k/include/asm/m523xsim.h
index 075062d4eec..91d3abc3f2a 100644
--- a/arch/m68k/include/asm/m523xsim.h
+++ b/arch/m68k/include/asm/m523xsim.h
@@ -52,6 +52,7 @@
52#define MCF_IRQ_FECENTC0 (MCFINT_VECBASE + MCFINT_FECENTC0) 52#define MCF_IRQ_FECENTC0 (MCFINT_VECBASE + MCFINT_FECENTC0)
53 53
54#define MCF_IRQ_QSPI (MCFINT_VECBASE + MCFINT_QSPI) 54#define MCF_IRQ_QSPI (MCFINT_VECBASE + MCFINT_QSPI)
55#define MCF_IRQ_PIT1 (MCFINT_VECBASE + MCFINT_PIT1)
55 56
56/* 57/*
57 * SDRAM configuration registers. 58 * SDRAM configuration registers.
diff --git a/arch/m68k/include/asm/m525xsim.h b/arch/m68k/include/asm/m525xsim.h
new file mode 100644
index 00000000000..6da24f65390
--- /dev/null
+++ b/arch/m68k/include/asm/m525xsim.h
@@ -0,0 +1,194 @@
1/****************************************************************************/
2
3/*
4 * m525xsim.h -- ColdFire 525x System Integration Module support.
5 *
6 * (C) Copyright 2012, Steven king <sfking@fdwdc.com>
7 * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
8 */
9
10/****************************************************************************/
11#ifndef m525xsim_h
12#define m525xsim_h
13/****************************************************************************/
14
15#define CPU_NAME "COLDFIRE(m525x)"
16#define CPU_INSTR_PER_JIFFY 3
17#define MCF_BUSCLK (MCF_CLK / 2)
18
19#include <asm/m52xxacr.h>
20
21/*
22 * The 525x has a second MBAR region, define its address.
23 */
24#define MCF_MBAR2 0x80000000
25
26/*
27 * Define the 525x SIM register set addresses.
28 */
29#define MCFSIM_RSR 0x00 /* Reset Status reg (r/w) */
30#define MCFSIM_SYPCR 0x01 /* System Protection reg (r/w)*/
31#define MCFSIM_SWIVR 0x02 /* SW Watchdog intr reg (r/w) */
32#define MCFSIM_SWSR 0x03 /* SW Watchdog service (r/w) */
33#define MCFSIM_MPARK 0x0C /* BUS Master Control Reg*/
34#define MCFSIM_IPR 0x40 /* Interrupt Pend reg (r/w) */
35#define MCFSIM_IMR 0x44 /* Interrupt Mask reg (r/w) */
36#define MCFSIM_ICR0 0x4c /* Intr Ctrl reg 0 (r/w) */
37#define MCFSIM_ICR1 0x4d /* Intr Ctrl reg 1 (r/w) */
38#define MCFSIM_ICR2 0x4e /* Intr Ctrl reg 2 (r/w) */
39#define MCFSIM_ICR3 0x4f /* Intr Ctrl reg 3 (r/w) */
40#define MCFSIM_ICR4 0x50 /* Intr Ctrl reg 4 (r/w) */
41#define MCFSIM_ICR5 0x51 /* Intr Ctrl reg 5 (r/w) */
42#define MCFSIM_ICR6 0x52 /* Intr Ctrl reg 6 (r/w) */
43#define MCFSIM_ICR7 0x53 /* Intr Ctrl reg 7 (r/w) */
44#define MCFSIM_ICR8 0x54 /* Intr Ctrl reg 8 (r/w) */
45#define MCFSIM_ICR9 0x55 /* Intr Ctrl reg 9 (r/w) */
46#define MCFSIM_ICR10 0x56 /* Intr Ctrl reg 10 (r/w) */
47#define MCFSIM_ICR11 0x57 /* Intr Ctrl reg 11 (r/w) */
48
49#define MCFSIM_CSAR0 0x80 /* CS 0 Address 0 reg (r/w) */
50#define MCFSIM_CSMR0 0x84 /* CS 0 Mask 0 reg (r/w) */
51#define MCFSIM_CSCR0 0x8a /* CS 0 Control reg (r/w) */
52#define MCFSIM_CSAR1 0x8c /* CS 1 Address reg (r/w) */
53#define MCFSIM_CSMR1 0x90 /* CS 1 Mask reg (r/w) */
54#define MCFSIM_CSCR1 0x96 /* CS 1 Control reg (r/w) */
55#define MCFSIM_CSAR2 0x98 /* CS 2 Address reg (r/w) */
56#define MCFSIM_CSMR2 0x9c /* CS 2 Mask reg (r/w) */
57#define MCFSIM_CSCR2 0xa2 /* CS 2 Control reg (r/w) */
58#define MCFSIM_CSAR3 0xa4 /* CS 3 Address reg (r/w) */
59#define MCFSIM_CSMR3 0xa8 /* CS 3 Mask reg (r/w) */
60#define MCFSIM_CSCR3 0xae /* CS 3 Control reg (r/w) */
61#define MCFSIM_CSAR4 0xb0 /* CS 4 Address reg (r/w) */
62#define MCFSIM_CSMR4 0xb4 /* CS 4 Mask reg (r/w) */
63#define MCFSIM_CSCR4 0xba /* CS 4 Control reg (r/w) */
64
65#define MCFSIM_DCR (MCF_MBAR + 0x100) /* DRAM Control */
66#define MCFSIM_DACR0 (MCF_MBAR + 0x108) /* DRAM 0 Addr/Ctrl */
67#define MCFSIM_DMR0 (MCF_MBAR + 0x10c) /* DRAM 0 Mask */
68
69/*
70 * Secondary Interrupt Controller (in MBAR2)
71*/
72#define MCFINTC2_INTBASE (MCF_MBAR2 + 0x168) /* Base Vector Reg */
73#define MCFINTC2_INTPRI1 (MCF_MBAR2 + 0x140) /* 0-7 priority */
74#define MCFINTC2_INTPRI2 (MCF_MBAR2 + 0x144) /* 8-15 priority */
75#define MCFINTC2_INTPRI3 (MCF_MBAR2 + 0x148) /* 16-23 priority */
76#define MCFINTC2_INTPRI4 (MCF_MBAR2 + 0x14c) /* 24-31 priority */
77#define MCFINTC2_INTPRI5 (MCF_MBAR2 + 0x150) /* 32-39 priority */
78#define MCFINTC2_INTPRI6 (MCF_MBAR2 + 0x154) /* 40-47 priority */
79#define MCFINTC2_INTPRI7 (MCF_MBAR2 + 0x158) /* 48-55 priority */
80#define MCFINTC2_INTPRI8 (MCF_MBAR2 + 0x15c) /* 56-63 priority */
81
82#define MCFINTC2_INTPRI_REG(i) (MCFINTC2_INTPRI1 + \
83 ((((i) - MCFINTC2_VECBASE) / 8) * 4))
84#define MCFINTC2_INTPRI_BITS(b, i) ((b) << (((i) % 8) * 4))
85
86/*
87 * Timer module.
88 */
89#define MCFTIMER_BASE1 (MCF_MBAR + 0x140) /* Base of TIMER1 */
90#define MCFTIMER_BASE2 (MCF_MBAR + 0x180) /* Base of TIMER2 */
91
92/*
93 * UART module.
94 */
95#define MCFUART_BASE0 (MCF_MBAR + 0x1c0) /* Base address UART0 */
96#define MCFUART_BASE1 (MCF_MBAR + 0x200) /* Base address UART1 */
97
98/*
99 * QSPI module.
100 */
101#define MCFQSPI_BASE (MCF_MBAR + 0x300) /* Base address QSPI */
102#define MCFQSPI_SIZE 0x40 /* Register set size */
103
104
105#define MCFQSPI_CS0 15
106#define MCFQSPI_CS1 16
107#define MCFQSPI_CS2 24
108#define MCFQSPI_CS3 28
109
110/*
111 * I2C module.
112 */
113#define MCFI2C_BASE0 (MCF_MBAR + 0x280) /* Base addreess I2C0 */
114#define MCFI2C_SIZE0 0x20 /* Register set size */
115
116#define MCFI2C_BASE1 (MCF_MBAR2 + 0x440) /* Base addreess I2C1 */
117#define MCFI2C_SIZE1 0x20 /* Register set size */
118/*
119 * DMA unit base addresses.
120 */
121#define MCFDMA_BASE0 (MCF_MBAR + 0x300) /* Base address DMA 0 */
122#define MCFDMA_BASE1 (MCF_MBAR + 0x340) /* Base address DMA 1 */
123#define MCFDMA_BASE2 (MCF_MBAR + 0x380) /* Base address DMA 2 */
124#define MCFDMA_BASE3 (MCF_MBAR + 0x3C0) /* Base address DMA 3 */
125
126/*
127 * Some symbol defines for the above...
128 */
129#define MCFSIM_SWDICR MCFSIM_ICR0 /* Watchdog timer ICR */
130#define MCFSIM_TIMER1ICR MCFSIM_ICR1 /* Timer 1 ICR */
131#define MCFSIM_TIMER2ICR MCFSIM_ICR2 /* Timer 2 ICR */
132#define MCFSIM_I2CICR MCFSIM_ICR3 /* I2C ICR */
133#define MCFSIM_UART1ICR MCFSIM_ICR4 /* UART 1 ICR */
134#define MCFSIM_UART2ICR MCFSIM_ICR5 /* UART 2 ICR */
135#define MCFSIM_DMA0ICR MCFSIM_ICR6 /* DMA 0 ICR */
136#define MCFSIM_DMA1ICR MCFSIM_ICR7 /* DMA 1 ICR */
137#define MCFSIM_DMA2ICR MCFSIM_ICR8 /* DMA 2 ICR */
138#define MCFSIM_DMA3ICR MCFSIM_ICR9 /* DMA 3 ICR */
139#define MCFSIM_QSPIICR MCFSIM_ICR10 /* QSPI ICR */
140
141/*
142 * Define system peripheral IRQ usage.
143 */
144#define MCF_IRQ_QSPI 28 /* QSPI, Level 4 */
145#define MCF_IRQ_I2C0 29
146#define MCF_IRQ_TIMER 30 /* Timer0, Level 6 */
147#define MCF_IRQ_PROFILER 31 /* Timer1, Level 7 */
148
149#define MCF_IRQ_UART0 73 /* UART0 */
150#define MCF_IRQ_UART1 74 /* UART1 */
151
152/*
153 * Define the base interrupt for the second interrupt controller.
154 * We set it to 128, out of the way of the base interrupts, and plenty
155 * of room for its 64 interrupts.
156 */
157#define MCFINTC2_VECBASE 128
158
159#define MCF_IRQ_GPIO0 (MCFINTC2_VECBASE + 32)
160#define MCF_IRQ_GPIO1 (MCFINTC2_VECBASE + 33)
161#define MCF_IRQ_GPIO2 (MCFINTC2_VECBASE + 34)
162#define MCF_IRQ_GPIO3 (MCFINTC2_VECBASE + 35)
163#define MCF_IRQ_GPIO4 (MCFINTC2_VECBASE + 36)
164#define MCF_IRQ_GPIO5 (MCFINTC2_VECBASE + 37)
165#define MCF_IRQ_GPIO6 (MCFINTC2_VECBASE + 38)
166
167#define MCF_IRQ_USBWUP (MCFINTC2_VECBASE + 40)
168#define MCF_IRQ_I2C1 (MCFINTC2_VECBASE + 62)
169
170/*
171 * General purpose IO registers (in MBAR2).
172 */
173#define MCFSIM2_GPIOREAD (MCF_MBAR2 + 0x000) /* GPIO read values */
174#define MCFSIM2_GPIOWRITE (MCF_MBAR2 + 0x004) /* GPIO write values */
175#define MCFSIM2_GPIOENABLE (MCF_MBAR2 + 0x008) /* GPIO enabled */
176#define MCFSIM2_GPIOFUNC (MCF_MBAR2 + 0x00C) /* GPIO function */
177#define MCFSIM2_GPIO1READ (MCF_MBAR2 + 0x0B0) /* GPIO1 read values */
178#define MCFSIM2_GPIO1WRITE (MCF_MBAR2 + 0x0B4) /* GPIO1 write values */
179#define MCFSIM2_GPIO1ENABLE (MCF_MBAR2 + 0x0B8) /* GPIO1 enabled */
180#define MCFSIM2_GPIO1FUNC (MCF_MBAR2 + 0x0BC) /* GPIO1 function */
181
182#define MCFSIM2_GPIOINTSTAT (MCF_MBAR2 + 0xc0) /* GPIO intr status */
183#define MCFSIM2_GPIOINTCLEAR (MCF_MBAR2 + 0xc0) /* GPIO intr clear */
184#define MCFSIM2_GPIOINTENABLE (MCF_MBAR2 + 0xc4) /* GPIO intr enable */
185
186/*
187 * Generic GPIO support
188 */
189#define MCFGPIO_PIN_MAX 64
190#define MCFGPIO_IRQ_MAX 7
191#define MCFGPIO_IRQ_VECBASE MCF_IRQ_GPIO0
192
193/****************************************************************************/
194#endif /* m525xsim_h */
diff --git a/arch/m68k/include/asm/m527xsim.h b/arch/m68k/include/asm/m527xsim.h
index 83db8106f50..71aa5104d3d 100644
--- a/arch/m68k/include/asm/m527xsim.h
+++ b/arch/m68k/include/asm/m527xsim.h
@@ -60,6 +60,7 @@
60#define MCF_IRQ_FECENTC1 (MCFINT2_VECBASE + MCFINT2_FECENTC1) 60#define MCF_IRQ_FECENTC1 (MCFINT2_VECBASE + MCFINT2_FECENTC1)
61 61
62#define MCF_IRQ_QSPI (MCFINT_VECBASE + MCFINT_QSPI) 62#define MCF_IRQ_QSPI (MCFINT_VECBASE + MCFINT_QSPI)
63#define MCF_IRQ_PIT1 (MCFINT_VECBASE + MCFINT_PIT1)
63 64
64/* 65/*
65 * SDRAM configuration registers. 66 * SDRAM configuration registers.
diff --git a/arch/m68k/include/asm/m528xsim.h b/arch/m68k/include/asm/m528xsim.h
index 497c31c803f..4acb3c0a642 100644
--- a/arch/m68k/include/asm/m528xsim.h
+++ b/arch/m68k/include/asm/m528xsim.h
@@ -52,7 +52,7 @@
52#define MCF_IRQ_FECENTC0 (MCFINT_VECBASE + MCFINT_FECENTC0) 52#define MCF_IRQ_FECENTC0 (MCFINT_VECBASE + MCFINT_FECENTC0)
53 53
54#define MCF_IRQ_QSPI (MCFINT_VECBASE + MCFINT_QSPI) 54#define MCF_IRQ_QSPI (MCFINT_VECBASE + MCFINT_QSPI)
55 55#define MCF_IRQ_PIT1 (MCFINT_VECBASE + MCFINT_PIT1)
56/* 56/*
57 * SDRAM configuration registers. 57 * SDRAM configuration registers.
58 */ 58 */
diff --git a/arch/m68k/include/asm/m532xsim.h b/arch/m68k/include/asm/m532xsim.h
index 29b66e21413..5ca7b298c6e 100644
--- a/arch/m68k/include/asm/m532xsim.h
+++ b/arch/m68k/include/asm/m532xsim.h
@@ -82,6 +82,9 @@
82#define MCFINTC1_SIMR 0xFC04C01C 82#define MCFINTC1_SIMR 0xFC04C01C
83#define MCFINTC1_CIMR 0xFC04C01D 83#define MCFINTC1_CIMR 0xFC04C01D
84#define MCFINTC1_ICR0 0xFC04C040 84#define MCFINTC1_ICR0 0xFC04C040
85#define MCFINTC2_SIMR (0)
86#define MCFINTC2_CIMR (0)
87#define MCFINTC2_ICR0 (0)
85 88
86#define MCFSIM_ICR_TIMER1 (0xFC048040+32) 89#define MCFSIM_ICR_TIMER1 (0xFC048040+32)
87#define MCFSIM_ICR_TIMER2 (0xFC048040+33) 90#define MCFSIM_ICR_TIMER2 (0xFC048040+33)
@@ -135,6 +138,20 @@
135#define MCF_RCR_SWRESET 0x80 /* Software reset bit */ 138#define MCF_RCR_SWRESET 0x80 /* Software reset bit */
136#define MCF_RCR_FRCSTOUT 0x40 /* Force external reset */ 139#define MCF_RCR_FRCSTOUT 0x40 /* Force external reset */
137 140
141
142/*
143 * Power Management
144 */
145#define MCFPM_WCR 0xfc040013
146#define MCFPM_PPMSR0 0xfc04002c
147#define MCFPM_PPMCR0 0xfc04002d
148#define MCFPM_PPMSR1 0xfc04002e
149#define MCFPM_PPMCR1 0xfc04002f
150#define MCFPM_PPMHR0 0xfc040030
151#define MCFPM_PPMLR0 0xfc040034
152#define MCFPM_PPMHR1 0xfc040038
153#define MCFPM_LPCR 0xec090007
154
138/********************************************************************* 155/*********************************************************************
139 * 156 *
140 * Inter-IC (I2C) Module 157 * Inter-IC (I2C) Module
diff --git a/arch/m68k/include/asm/m5441xsim.h b/arch/m68k/include/asm/m5441xsim.h
new file mode 100644
index 00000000000..cc798ab9524
--- /dev/null
+++ b/arch/m68k/include/asm/m5441xsim.h
@@ -0,0 +1,276 @@
1/*
2 * m5441xsim.h -- Coldfire 5441x register definitions
3 *
4 * (C) Copyright 2012, Steven King <sfking@fdwdc.com>
5*/
6
7#ifndef m5441xsim_h
8#define m5441xsim_h
9
10#define CPU_NAME "COLDFIRE(m5441x)"
11#define CPU_INSTR_PER_JIFFY 2
12#define MCF_BUSCLK (MCF_CLK / 2)
13
14#include <asm/m54xxacr.h>
15
16/*
17 * Reset Controller Module.
18 */
19
20#define MCF_RCR 0xec090000
21#define MCF_RSR 0xec090001
22
23#define MCF_RCR_SWRESET 0x80 /* Software reset bit */
24#define MCF_RCR_FRCSTOUT 0x40 /* Force external reset */
25
26/*
27 * Interrupt Controller Modules.
28 */
29/* the 5441x have 3 interrupt controllers, each control 64 interrupts */
30#define MCFINT_VECBASE 64
31#define MCFINT0_VECBASE MCFINT_VECBASE
32#define MCFINT1_VECBASE (MCFINT0_VECBASE + 64)
33#define MCFINT2_VECBASE (MCFINT1_VECBASE + 64)
34
35/* interrupt controller 0 */
36#define MCFINTC0_SIMR 0xfc04801c
37#define MCFINTC0_CIMR 0xfc04801d
38#define MCFINTC0_ICR0 0xfc048040
39/* interrupt controller 1 */
40#define MCFINTC1_SIMR 0xfc04c01c
41#define MCFINTC1_CIMR 0xfc04c01d
42#define MCFINTC1_ICR0 0xfc04c040
43/* interrupt controller 2 */
44#define MCFINTC2_SIMR 0xfc05001c
45#define MCFINTC2_CIMR 0xfc05001d
46#define MCFINTC2_ICR0 0xfc050040
47
48/* on interrupt controller 0 */
49#define MCFINT0_EPORT0 1
50#define MCFINT0_UART0 26
51#define MCFINT0_UART1 27
52#define MCFINT0_UART2 28
53#define MCFINT0_UART3 29
54#define MCFINT0_I2C0 30
55#define MCFINT0_DSPI0 31
56
57#define MCFINT0_TIMER0 32
58#define MCFINT0_TIMER1 33
59#define MCFINT0_TIMER2 34
60#define MCFINT0_TIMER3 35
61
62#define MCFINT0_FECRX0 36
63#define MCFINT0_FECTX0 40
64#define MCFINT0_FECENTC0 42
65
66#define MCFINT0_FECRX1 49
67#define MCFINT0_FECTX1 53
68#define MCFINT0_FECENTC1 55
69
70/* on interrupt controller 1 */
71#define MCFINT1_UART4 48
72#define MCFINT1_UART5 49
73#define MCFINT1_UART6 50
74#define MCFINT1_UART7 51
75#define MCFINT1_UART8 52
76#define MCFINT1_UART9 53
77#define MCFINT1_DSPI1 54
78#define MCFINT1_DSPI2 55
79#define MCFINT1_DSPI3 56
80#define MCFINT1_I2C1 57
81#define MCFINT1_I2C2 58
82#define MCFINT1_I2C3 59
83#define MCFINT1_I2C4 60
84#define MCFINT1_I2C5 61
85
86/* on interrupt controller 2 */
87#define MCFINT2_PIT0 13
88#define MCFINT2_PIT1 14
89#define MCFINT2_PIT2 15
90#define MCFINT2_PIT3 16
91#define MCFINT2_RTC 26
92
93/*
94 * PIT timer module.
95 */
96#define MCFPIT_BASE0 0xFC080000 /* Base address of TIMER0 */
97#define MCFPIT_BASE1 0xFC084000 /* Base address of TIMER1 */
98#define MCFPIT_BASE2 0xFC088000 /* Base address of TIMER2 */
99#define MCFPIT_BASE3 0xFC08C000 /* Base address of TIMER3 */
100
101
102#define MCF_IRQ_PIT1 (MCFINT2_VECBASE + MCFINT2_PIT1)
103
104/*
105 * Power Management
106 */
107#define MCFPM_WCR 0xfc040013
108#define MCFPM_PPMSR0 0xfc04002c
109#define MCFPM_PPMCR0 0xfc04002d
110#define MCFPM_PPMSR1 0xfc04002e
111#define MCFPM_PPMCR1 0xfc04002f
112#define MCFPM_PPMHR0 0xfc040030
113#define MCFPM_PPMLR0 0xfc040034
114#define MCFPM_PPMHR1 0xfc040038
115#define MCFPM_PPMLR1 0xfc04003c
116#define MCFPM_LPCR 0xec090007
117/*
118 * UART module.
119 */
120#define MCFUART_BASE0 0xfc060000 /* Base address of UART0 */
121#define MCFUART_BASE1 0xfc064000 /* Base address of UART1 */
122#define MCFUART_BASE2 0xfc068000 /* Base address of UART2 */
123#define MCFUART_BASE3 0xfc06c000 /* Base address of UART3 */
124#define MCFUART_BASE4 0xec060000 /* Base address of UART4 */
125#define MCFUART_BASE5 0xec064000 /* Base address of UART5 */
126#define MCFUART_BASE6 0xec068000 /* Base address of UART6 */
127#define MCFUART_BASE7 0xec06c000 /* Base address of UART7 */
128#define MCFUART_BASE8 0xec070000 /* Base address of UART8 */
129#define MCFUART_BASE9 0xec074000 /* Base address of UART9 */
130
131#define MCF_IRQ_UART0 (MCFINT0_VECBASE + MCFINT0_UART0)
132#define MCF_IRQ_UART1 (MCFINT0_VECBASE + MCFINT0_UART1)
133#define MCF_IRQ_UART2 (MCFINT0_VECBASE + MCFINT0_UART2)
134#define MCF_IRQ_UART3 (MCFINT0_VECBASE + MCFINT0_UART3)
135#define MCF_IRQ_UART4 (MCFINT1_VECBASE + MCFINT1_UART4)
136#define MCF_IRQ_UART5 (MCFINT1_VECBASE + MCFINT1_UART5)
137#define MCF_IRQ_UART6 (MCFINT1_VECBASE + MCFINT1_UART6)
138#define MCF_IRQ_UART7 (MCFINT1_VECBASE + MCFINT1_UART7)
139#define MCF_IRQ_UART8 (MCFINT1_VECBASE + MCFINT1_UART8)
140#define MCF_IRQ_UART9 (MCFINT1_VECBASE + MCFINT1_UART9)
141/*
142 * FEC modules.
143 */
144#define MCFFEC_BASE0 0xfc0d4000
145#define MCFFEC_SIZE0 0x800
146#define MCF_IRQ_FECRX0 (MCFINT0_VECBASE + MCFINT0_FECRX0)
147#define MCF_IRQ_FECTX0 (MCFINT0_VECBASE + MCFINT0_FECTX0)
148#define MCF_IRQ_FECENTC0 (MCFINT0_VECBASE + MCFINT0_FECENTC0)
149
150#define MCFFEC_BASE1 0xfc0d8000
151#define MCFFEC_SIZE1 0x800
152#define MCF_IRQ_FECRX1 (MCFINT0_VECBASE + MCFINT0_FECRX1)
153#define MCF_IRQ_FECTX1 (MCFINT0_VECBASE + MCFINT0_FECTX1)
154#define MCF_IRQ_FECENTC1 (MCFINT0_VECBASE + MCFINT0_FECENTC1)
155/*
156 * I2C modules.
157 */
158#define MCFI2C_BASE0 0xfc058000
159#define MCFI2C_SIZE0 0x20
160#define MCFI2C_BASE1 0xfc038000
161#define MCFI2C_SIZE1 0x20
162#define MCFI2C_BASE2 0xec010000
163#define MCFI2C_SIZE2 0x20
164#define MCFI2C_BASE3 0xec014000
165#define MCFI2C_SIZE3 0x20
166#define MCFI2C_BASE4 0xec018000
167#define MCFI2C_SIZE4 0x20
168#define MCFI2C_BASE5 0xec01c000
169#define MCFI2C_SIZE5 0x20
170
171#define MCF_IRQ_I2C0 (MCFINT0_VECBASE + MCFINT0_I2C0)
172#define MCF_IRQ_I2C1 (MCFINT1_VECBASE + MCFINT1_I2C1)
173#define MCF_IRQ_I2C2 (MCFINT1_VECBASE + MCFINT1_I2C2)
174#define MCF_IRQ_I2C3 (MCFINT1_VECBASE + MCFINT1_I2C3)
175#define MCF_IRQ_I2C4 (MCFINT1_VECBASE + MCFINT1_I2C4)
176#define MCF_IRQ_I2C5 (MCFINT1_VECBASE + MCFINT1_I2C5)
177/*
178 * EPORT Module.
179 */
180#define MCFEPORT_EPPAR 0xfc090000
181#define MCFEPORT_EPIER 0xfc090003
182#define MCFEPORT_EPFR 0xfc090006
183/*
184 * RTC Module.
185 */
186#define MCFRTC_BASE 0xfc0a8000
187#define MCFRTC_SIZE (0xfc0a8840 - 0xfc0a8000)
188#define MCF_IRQ_RTC (MCFINT2_VECBASE + MCFINT2_RTC)
189
190/*
191 * GPIO Module.
192 */
193#define MCFGPIO_PODR_A 0xec094000
194#define MCFGPIO_PODR_B 0xec094001
195#define MCFGPIO_PODR_C 0xec094002
196#define MCFGPIO_PODR_D 0xec094003
197#define MCFGPIO_PODR_E 0xec094004
198#define MCFGPIO_PODR_F 0xec094005
199#define MCFGPIO_PODR_G 0xec094006
200#define MCFGPIO_PODR_H 0xec094007
201#define MCFGPIO_PODR_I 0xec094008
202#define MCFGPIO_PODR_J 0xec094009
203#define MCFGPIO_PODR_K 0xec09400a
204
205#define MCFGPIO_PDDR_A 0xec09400c
206#define MCFGPIO_PDDR_B 0xec09400d
207#define MCFGPIO_PDDR_C 0xec09400e
208#define MCFGPIO_PDDR_D 0xec09400f
209#define MCFGPIO_PDDR_E 0xec094010
210#define MCFGPIO_PDDR_F 0xec094011
211#define MCFGPIO_PDDR_G 0xec094012
212#define MCFGPIO_PDDR_H 0xec094013
213#define MCFGPIO_PDDR_I 0xec094014
214#define MCFGPIO_PDDR_J 0xec094015
215#define MCFGPIO_PDDR_K 0xec094016
216
217#define MCFGPIO_PPDSDR_A 0xec094018
218#define MCFGPIO_PPDSDR_B 0xec094019
219#define MCFGPIO_PPDSDR_C 0xec09401a
220#define MCFGPIO_PPDSDR_D 0xec09401b
221#define MCFGPIO_PPDSDR_E 0xec09401c
222#define MCFGPIO_PPDSDR_F 0xec09401d
223#define MCFGPIO_PPDSDR_G 0xec09401e
224#define MCFGPIO_PPDSDR_H 0xec09401f
225#define MCFGPIO_PPDSDR_I 0xec094020
226#define MCFGPIO_PPDSDR_J 0xec094021
227#define MCFGPIO_PPDSDR_K 0xec094022
228
229#define MCFGPIO_PCLRR_A 0xec094024
230#define MCFGPIO_PCLRR_B 0xec094025
231#define MCFGPIO_PCLRR_C 0xec094026
232#define MCFGPIO_PCLRR_D 0xec094027
233#define MCFGPIO_PCLRR_E 0xec094028
234#define MCFGPIO_PCLRR_F 0xec094029
235#define MCFGPIO_PCLRR_G 0xec09402a
236#define MCFGPIO_PCLRR_H 0xec09402b
237#define MCFGPIO_PCLRR_I 0xec09402c
238#define MCFGPIO_PCLRR_J 0xec09402d
239#define MCFGPIO_PCLRR_K 0xec09402e
240
241#define MCFGPIO_PAR_FBCTL 0xec094048
242#define MCFGPIO_PAR_BE 0xec094049
243#define MCFGPIO_PAR_CS 0xec09404a
244#define MCFGPIO_PAR_CANI2C 0xec09404b
245#define MCFGPIO_PAR_IRQ0H 0xec09404c
246#define MCFGPIO_PAR_IRQ0L 0xec09404d
247#define MCFGPIO_PAR_DSPIOWH 0xec09404e
248#define MCFGPIO_PAR_DSPIOWL 0xec09404f
249#define MCFGPIO_PAR_TIMER 0xec094050
250#define MCFGPIO_PAR_UART2 0xec094051
251#define MCFGPIO_PAR_UART1 0xec094052
252#define MCFGPIO_PAR_UART0 0xec094053
253#define MCFGPIO_PAR_SDHCH 0xec094054
254#define MCFGPIO_PAR_SDHCL 0xec094055
255#define MCFGPIO_PAR_SIMP0H 0xec094056
256#define MCFGPIO_PAR_SIMP0L 0xec094057
257#define MCFGPIO_PAR_SSI0H 0xec094058
258#define MCFGPIO_PAR_SSI0L 0xec094059
259#define MCFGPIO_PAR_DEBUGH1 0xec09405a
260#define MCFGPIO_PAR_DEBUGH0 0xec09405b
261#define MCFGPIO_PAR_DEBUGl 0xec09405c
262#define MCFGPIO_PAR_FEC 0xec09405e
263
264/* generalization for generic gpio support */
265#define MCFGPIO_PODR MCFGPIO_PODR_A
266#define MCFGPIO_PDDR MCFGPIO_PDDR_A
267#define MCFGPIO_PPDR MCFGPIO_PPDSDR_A
268#define MCFGPIO_SETR MCFGPIO_PPDSDR_A
269#define MCFGPIO_CLRR MCFGPIO_PCLRR_A
270
271#define MCFGPIO_IRQ_MIN 17
272#define MCFGPIO_IRQ_MAX 24
273#define MCFGPIO_IRQ_VECBASE (MCFINT_VECBASE - MCFGPIO_IRQ_MIN)
274#define MCFGPIO_PIN_MAX 87
275
276#endif /* m5441xsim_h */
diff --git a/arch/m68k/include/asm/m54xxacr.h b/arch/m68k/include/asm/m54xxacr.h
index 47906aafbf6..192bbfeabf7 100644
--- a/arch/m68k/include/asm/m54xxacr.h
+++ b/arch/m68k/include/asm/m54xxacr.h
@@ -55,6 +55,10 @@
55#define ICACHE_SIZE 0x8000 /* instruction - 32k */ 55#define ICACHE_SIZE 0x8000 /* instruction - 32k */
56#define DCACHE_SIZE 0x8000 /* data - 32k */ 56#define DCACHE_SIZE 0x8000 /* data - 32k */
57 57
58#elif defined(CONFIG_M5441x)
59
60#define ICACHE_SIZE 0x2000 /* instruction - 8k */
61#define DCACHE_SIZE 0x2000 /* data - 8k */
58#endif 62#endif
59 63
60#define CACHE_LINE_SIZE 0x0010 /* 16 bytes */ 64#define CACHE_LINE_SIZE 0x0010 /* 16 bytes */
diff --git a/arch/m68k/include/asm/m54xxpci.h b/arch/m68k/include/asm/m54xxpci.h
new file mode 100644
index 00000000000..6fbf54f72f2
--- /dev/null
+++ b/arch/m68k/include/asm/m54xxpci.h
@@ -0,0 +1,138 @@
1/****************************************************************************/
2
3/*
4 * m54xxpci.h -- ColdFire 547x and 548x PCI bus support
5 *
6 * (C) Copyright 2011, Greg Ungerer <gerg@uclinux.org>
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
13/****************************************************************************/
14#ifndef M54XXPCI_H
15#define M54XXPCI_H
16/****************************************************************************/
17
18/*
19 * The core set of PCI support registers are mapped into the MBAR region.
20 */
21#define PCIIDR (CONFIG_MBAR + 0xb00) /* PCI device/vendor ID */
22#define PCISCR (CONFIG_MBAR + 0xb04) /* PCI status/command */
23#define PCICCRIR (CONFIG_MBAR + 0xb08) /* PCI class/revision */
24#define PCICR1 (CONFIG_MBAR + 0xb0c) /* PCI configuration 1 */
25#define PCIBAR0 (CONFIG_MBAR + 0xb10) /* PCI base address 0 */
26#define PCIBAR1 (CONFIG_MBAR + 0xb14) /* PCI base address 1 */
27#define PCICCPR (CONFIG_MBAR + 0xb28) /* PCI cardbus CIS pointer */
28#define PCISID (CONFIG_MBAR + 0xb2c) /* PCI subsystem IDs */
29#define PCIERBAR (CONFIG_MBAR + 0xb30) /* PCI expansion ROM */
30#define PCICPR (CONFIG_MBAR + 0xb34) /* PCI capabilities pointer */
31#define PCICR2 (CONFIG_MBAR + 0xb3c) /* PCI configuration 2 */
32
33#define PCIGSCR (CONFIG_MBAR + 0xb60) /* Global status/control */
34#define PCITBATR0 (CONFIG_MBAR + 0xb64) /* Target base translation 0 */
35#define PCITBATR1 (CONFIG_MBAR + 0xb68) /* Target base translation 1 */
36#define PCITCR (CONFIG_MBAR + 0xb6c) /* Target control */
37#define PCIIW0BTAR (CONFIG_MBAR + 0xb70) /* Initiator window 0 */
38#define PCIIW1BTAR (CONFIG_MBAR + 0xb74) /* Initiator window 1 */
39#define PCIIW2BTAR (CONFIG_MBAR + 0xb78) /* Initiator window 2 */
40#define PCIIWCR (CONFIG_MBAR + 0xb80) /* Initiator window config */
41#define PCIICR (CONFIG_MBAR + 0xb84) /* Initiator control */
42#define PCIISR (CONFIG_MBAR + 0xb88) /* Initiator status */
43#define PCICAR (CONFIG_MBAR + 0xbf8) /* Configuration address */
44
45#define PCITPSR (CONFIG_MBAR + 0x8400) /* TX packet size */
46#define PCITSAR (CONFIG_MBAR + 0x8404) /* TX start address */
47#define PCITTCR (CONFIG_MBAR + 0x8408) /* TX transaction control */
48#define PCITER (CONFIG_MBAR + 0x840c) /* TX enables */
49#define PCITNAR (CONFIG_MBAR + 0x8410) /* TX next address */
50#define PCITLWR (CONFIG_MBAR + 0x8414) /* TX last word */
51#define PCITDCR (CONFIG_MBAR + 0x8418) /* TX done counts */
52#define PCITSR (CONFIG_MBAR + 0x841c) /* TX status */
53#define PCITFDR (CONFIG_MBAR + 0x8440) /* TX FIFO data */
54#define PCITFSR (CONFIG_MBAR + 0x8444) /* TX FIFO status */
55#define PCITFCR (CONFIG_MBAR + 0x8448) /* TX FIFO control */
56#define PCITFAR (CONFIG_MBAR + 0x844c) /* TX FIFO alarm */
57#define PCITFRPR (CONFIG_MBAR + 0x8450) /* TX FIFO read pointer */
58#define PCITFWPR (CONFIG_MBAR + 0x8454) /* TX FIFO write pointer */
59
60#define PCIRPSR (CONFIG_MBAR + 0x8480) /* RX packet size */
61#define PCIRSAR (CONFIG_MBAR + 0x8484) /* RX start address */
62#define PCIRTCR (CONFIG_MBAR + 0x8488) /* RX transaction control */
63#define PCIRER (CONFIG_MBAR + 0x848c) /* RX enables */
64#define PCIRNAR (CONFIG_MBAR + 0x8490) /* RX next address */
65#define PCIRDCR (CONFIG_MBAR + 0x8498) /* RX done counts */
66#define PCIRSR (CONFIG_MBAR + 0x849c) /* RX status */
67#define PCIRFDR (CONFIG_MBAR + 0x84c0) /* RX FIFO data */
68#define PCIRFSR (CONFIG_MBAR + 0x84c4) /* RX FIFO status */
69#define PCIRFCR (CONFIG_MBAR + 0x84c8) /* RX FIFO control */
70#define PCIRFAR (CONFIG_MBAR + 0x84cc) /* RX FIFO alarm */
71#define PCIRFRPR (CONFIG_MBAR + 0x84d0) /* RX FIFO read pointer */
72#define PCIRFWPR (CONFIG_MBAR + 0x84d4) /* RX FIFO write pointer */
73
74#define PACR (CONFIG_MBAR + 0xc00) /* PCI arbiter control */
75#define PASR (COFNIG_MBAR + 0xc04) /* PCI arbiter status */
76
77/*
78 * Definitions for the Global status and control register.
79 */
80#define PCIGSCR_PE 0x20000000 /* Parity error detected */
81#define PCIGSCR_SE 0x10000000 /* System error detected */
82#define PCIGSCR_XCLKBIN 0x07000000 /* XLB2CLKIN mask */
83#define PCIGSCR_PEE 0x00002000 /* Parity error intr enable */
84#define PCIGSCR_SEE 0x00001000 /* System error intr enable */
85#define PCIGSCR_RESET 0x00000001 /* Reset bit */
86
87/*
88 * Bit definitions for the PCICAR configuration address register.
89 */
90#define PCICAR_E 0x80000000 /* Enable config space */
91#define PCICAR_BUSN 16 /* Move bus bits */
92#define PCICAR_DEVFNN 8 /* Move devfn bits */
93#define PCICAR_DWORDN 0 /* Move dword bits */
94
95/*
96 * The initiator windows hold the memory and IO mapping information.
97 * This macro creates the register values from the desired addresses.
98 */
99#define WXBTAR(hostaddr, pciaddr, size) \
100 (((hostaddr) & 0xff000000) | \
101 ((((size) - 1) & 0xff000000) >> 8) | \
102 (((pciaddr) & 0xff000000) >> 16))
103
104#define PCIIWCR_W0_MEM 0x00000000 /* Window 0 is memory */
105#define PCIIWCR_W0_IO 0x08000000 /* Window 0 is IO */
106#define PCIIWCR_W0_MRD 0x00000000 /* Window 0 memory read */
107#define PCIIWCR_W0_MRDL 0x02000000 /* Window 0 memory read line */
108#define PCIIWCR_W0_MRDM 0x04000000 /* Window 0 memory read mult */
109#define PCIIWCR_W0_E 0x01000000 /* Window 0 enable */
110
111#define PCIIWCR_W1_MEM 0x00000000 /* Window 0 is memory */
112#define PCIIWCR_W1_IO 0x00080000 /* Window 0 is IO */
113#define PCIIWCR_W1_MRD 0x00000000 /* Window 0 memory read */
114#define PCIIWCR_W1_MRDL 0x00020000 /* Window 0 memory read line */
115#define PCIIWCR_W1_MRDM 0x00040000 /* Window 0 memory read mult */
116#define PCIIWCR_W1_E 0x00010000 /* Window 0 enable */
117
118/*
119 * Bit definitions for the PCIBATR registers.
120 */
121#define PCITBATR0_E 0x00000001 /* Enable window 0 */
122#define PCITBATR1_E 0x00000001 /* Enable window 1 */
123
124/*
125 * PCI arbiter support definitions and macros.
126 */
127#define PACR_INTMPRI 0x00000001
128#define PACR_EXTMPRI(x) (((x) & 0x1f) << 1)
129#define PACR_INTMINTE 0x00010000
130#define PACR_EXTMINTE(x) (((x) & 0x1f) << 17)
131#define PACR_PKMD 0x40000000
132#define PACR_DS 0x80000000
133
134#define PCICR1_CL(x) ((x) & 0xf) /* Cacheline size field */
135#define PCICR1_LT(x) (((x) & 0xff) << 8) /* Latency timer field */
136
137/****************************************************************************/
138#endif /* M54XXPCI_H */
diff --git a/arch/m68k/include/asm/m54xxsim.h b/arch/m68k/include/asm/m54xxsim.h
index ae56b8848a9..d3c5e0dbdad 100644
--- a/arch/m68k/include/asm/m54xxsim.h
+++ b/arch/m68k/include/asm/m54xxsim.h
@@ -81,4 +81,7 @@
81#define MCF_PAR_PSC_RTS_RTS (0x30) 81#define MCF_PAR_PSC_RTS_RTS (0x30)
82#define MCF_PAR_PSC_CANRX (0x40) 82#define MCF_PAR_PSC_CANRX (0x40)
83 83
84#define MCF_PAR_PCIBG (CONFIG_MBAR + 0xa48) /* PCI bus grant */
85#define MCF_PAR_PCIBR (CONFIG_MBAR + 0xa4a) /* PCI */
86
84#endif /* m54xxsim_h */ 87#endif /* m54xxsim_h */
diff --git a/arch/m68k/include/asm/mac_mouse.h b/arch/m68k/include/asm/mac_mouse.h
deleted file mode 100644
index 39a5c292eae..00000000000
--- a/arch/m68k/include/asm/mac_mouse.h
+++ /dev/null
@@ -1,23 +0,0 @@
1#ifndef _ASM_MAC_MOUSE_H
2#define _ASM_MAC_MOUSE_H
3
4/*
5 * linux/include/asm-m68k/mac_mouse.h
6 * header file for Macintosh ADB mouse driver
7 * 27-10-97 Michael Schmitz
8 * copied from:
9 * header file for Atari Mouse driver
10 * by Robert de Vries (robert@and.nl) on 19Jul93
11 */
12
13struct mouse_status {
14 char buttons;
15 short dx;
16 short dy;
17 int ready;
18 int active;
19 wait_queue_head_t wait;
20 struct fasync_struct *fasyncptr;
21};
22
23#endif
diff --git a/arch/m68k/include/asm/mcfne.h b/arch/m68k/include/asm/mcf8390.h
index bf638be0958..a72a20819a5 100644
--- a/arch/m68k/include/asm/mcfne.h
+++ b/arch/m68k/include/asm/mcf8390.h
@@ -1,7 +1,7 @@
1/****************************************************************************/ 1/****************************************************************************/
2 2
3/* 3/*
4 * mcfne.h -- NE2000 in ColdFire eval boards. 4 * mcf8390.h -- NS8390 support for ColdFire eval boards.
5 * 5 *
6 * (C) Copyright 1999-2000, Greg Ungerer (gerg@snapgear.com) 6 * (C) Copyright 1999-2000, Greg Ungerer (gerg@snapgear.com)
7 * (C) Copyright 2000, Lineo (www.lineo.com) 7 * (C) Copyright 2000, Lineo (www.lineo.com)
@@ -14,8 +14,8 @@
14 */ 14 */
15 15
16/****************************************************************************/ 16/****************************************************************************/
17#ifndef mcfne_h 17#ifndef mcf8390_h
18#define mcfne_h 18#define mcf8390_h
19/****************************************************************************/ 19/****************************************************************************/
20 20
21 21
@@ -37,6 +37,7 @@
37#if defined(CONFIG_ARN5206) 37#if defined(CONFIG_ARN5206)
38#define NE2000_ADDR 0x40000300 38#define NE2000_ADDR 0x40000300
39#define NE2000_ODDOFFSET 0x00010000 39#define NE2000_ODDOFFSET 0x00010000
40#define NE2000_ADDRSIZE 0x00020000
40#define NE2000_IRQ_VECTOR 0xf0 41#define NE2000_IRQ_VECTOR 0xf0
41#define NE2000_IRQ_PRIORITY 2 42#define NE2000_IRQ_PRIORITY 2
42#define NE2000_IRQ_LEVEL 4 43#define NE2000_IRQ_LEVEL 4
@@ -46,6 +47,7 @@
46#if defined(CONFIG_M5206eC3) 47#if defined(CONFIG_M5206eC3)
47#define NE2000_ADDR 0x40000300 48#define NE2000_ADDR 0x40000300
48#define NE2000_ODDOFFSET 0x00010000 49#define NE2000_ODDOFFSET 0x00010000
50#define NE2000_ADDRSIZE 0x00020000
49#define NE2000_IRQ_VECTOR 0x1c 51#define NE2000_IRQ_VECTOR 0x1c
50#define NE2000_IRQ_PRIORITY 2 52#define NE2000_IRQ_PRIORITY 2
51#define NE2000_IRQ_LEVEL 4 53#define NE2000_IRQ_LEVEL 4
@@ -54,6 +56,7 @@
54 56
55#if defined(CONFIG_M5206e) && defined(CONFIG_NETtel) 57#if defined(CONFIG_M5206e) && defined(CONFIG_NETtel)
56#define NE2000_ADDR 0x30000300 58#define NE2000_ADDR 0x30000300
59#define NE2000_ADDRSIZE 0x00001000
57#define NE2000_IRQ_VECTOR 25 60#define NE2000_IRQ_VECTOR 25
58#define NE2000_IRQ_PRIORITY 1 61#define NE2000_IRQ_PRIORITY 1
59#define NE2000_IRQ_LEVEL 3 62#define NE2000_IRQ_LEVEL 3
@@ -63,6 +66,7 @@
63#if defined(CONFIG_M5307C3) 66#if defined(CONFIG_M5307C3)
64#define NE2000_ADDR 0x40000300 67#define NE2000_ADDR 0x40000300
65#define NE2000_ODDOFFSET 0x00010000 68#define NE2000_ODDOFFSET 0x00010000
69#define NE2000_ADDRSIZE 0x00020000
66#define NE2000_IRQ_VECTOR 0x1b 70#define NE2000_IRQ_VECTOR 0x1b
67#define NE2000_BYTE volatile unsigned short 71#define NE2000_BYTE volatile unsigned short
68#endif 72#endif
@@ -70,6 +74,7 @@
70#if defined(CONFIG_M5272) && defined(CONFIG_NETtel) 74#if defined(CONFIG_M5272) && defined(CONFIG_NETtel)
71#define NE2000_ADDR 0x30600300 75#define NE2000_ADDR 0x30600300
72#define NE2000_ODDOFFSET 0x00008000 76#define NE2000_ODDOFFSET 0x00008000
77#define NE2000_ADDRSIZE 0x00010000
73#define NE2000_IRQ_VECTOR 67 78#define NE2000_IRQ_VECTOR 67
74#undef BSWAP 79#undef BSWAP
75#define BSWAP(w) (w) 80#define BSWAP(w) (w)
@@ -82,6 +87,7 @@
82#define NE2000_ADDR0 0x30600300 87#define NE2000_ADDR0 0x30600300
83#define NE2000_ADDR1 0x30800300 88#define NE2000_ADDR1 0x30800300
84#define NE2000_ODDOFFSET 0x00008000 89#define NE2000_ODDOFFSET 0x00008000
90#define NE2000_ADDRSIZE 0x00010000
85#define NE2000_IRQ_VECTOR0 27 91#define NE2000_IRQ_VECTOR0 27
86#define NE2000_IRQ_VECTOR1 29 92#define NE2000_IRQ_VECTOR1 29
87#undef BSWAP 93#undef BSWAP
@@ -94,6 +100,7 @@
94#if defined(CONFIG_M5307) && defined(CONFIG_SECUREEDGEMP3) 100#if defined(CONFIG_M5307) && defined(CONFIG_SECUREEDGEMP3)
95#define NE2000_ADDR 0x30600300 101#define NE2000_ADDR 0x30600300
96#define NE2000_ODDOFFSET 0x00008000 102#define NE2000_ODDOFFSET 0x00008000
103#define NE2000_ADDRSIZE 0x00010000
97#define NE2000_IRQ_VECTOR 27 104#define NE2000_IRQ_VECTOR 27
98#undef BSWAP 105#undef BSWAP
99#define BSWAP(w) (w) 106#define BSWAP(w) (w)
@@ -105,6 +112,7 @@
105#if defined(CONFIG_ARN5307) 112#if defined(CONFIG_ARN5307)
106#define NE2000_ADDR 0xfe600300 113#define NE2000_ADDR 0xfe600300
107#define NE2000_ODDOFFSET 0x00010000 114#define NE2000_ODDOFFSET 0x00010000
115#define NE2000_ADDRSIZE 0x00020000
108#define NE2000_IRQ_VECTOR 0x1b 116#define NE2000_IRQ_VECTOR 0x1b
109#define NE2000_IRQ_PRIORITY 2 117#define NE2000_IRQ_PRIORITY 2
110#define NE2000_IRQ_LEVEL 3 118#define NE2000_IRQ_LEVEL 3
@@ -114,129 +122,10 @@
114#if defined(CONFIG_M5407C3) 122#if defined(CONFIG_M5407C3)
115#define NE2000_ADDR 0x40000300 123#define NE2000_ADDR 0x40000300
116#define NE2000_ODDOFFSET 0x00010000 124#define NE2000_ODDOFFSET 0x00010000
125#define NE2000_ADDRSIZE 0x00020000
117#define NE2000_IRQ_VECTOR 0x1b 126#define NE2000_IRQ_VECTOR 0x1b
118#define NE2000_BYTE volatile unsigned short 127#define NE2000_BYTE volatile unsigned short
119#endif 128#endif
120 129
121/****************************************************************************/ 130/****************************************************************************/
122 131#endif /* mcf8390_h */
123/*
124 * Side-band address space for odd address requires re-mapping
125 * many of the standard ISA access functions.
126 */
127#ifdef NE2000_ODDOFFSET
128
129#undef outb
130#undef outb_p
131#undef inb
132#undef inb_p
133#undef outsb
134#undef outsw
135#undef insb
136#undef insw
137
138#define outb ne2000_outb
139#define inb ne2000_inb
140#define outb_p ne2000_outb
141#define inb_p ne2000_inb
142#define outsb ne2000_outsb
143#define outsw ne2000_outsw
144#define insb ne2000_insb
145#define insw ne2000_insw
146
147
148#ifndef COLDFIRE_NE2000_FUNCS
149
150void ne2000_outb(unsigned int val, unsigned int addr);
151int ne2000_inb(unsigned int addr);
152void ne2000_insb(unsigned int addr, void *vbuf, int unsigned long len);
153void ne2000_insw(unsigned int addr, void *vbuf, unsigned long len);
154void ne2000_outsb(unsigned int addr, void *vbuf, unsigned long len);
155void ne2000_outsw(unsigned int addr, void *vbuf, unsigned long len);
156
157#else
158
159/*
160 * This macro converts a conventional register address into the
161 * real memory pointer of the mapped NE2000 device.
162 * On most NE2000 implementations on ColdFire boards the chip is
163 * mapped in kinda funny, due to its ISA heritage.
164 */
165#define NE2000_PTR(addr) ((addr&0x1)?(NE2000_ODDOFFSET+addr-1):(addr))
166#define NE2000_DATA_PTR(addr) (addr)
167
168
169void ne2000_outb(unsigned int val, unsigned int addr)
170{
171 NE2000_BYTE *rp;
172
173 rp = (NE2000_BYTE *) NE2000_PTR(addr);
174 *rp = RSWAP(val);
175}
176
177int ne2000_inb(unsigned int addr)
178{
179 NE2000_BYTE *rp, val;
180
181 rp = (NE2000_BYTE *) NE2000_PTR(addr);
182 val = *rp;
183 return((int) ((NE2000_BYTE) RSWAP(val)));
184}
185
186void ne2000_insb(unsigned int addr, void *vbuf, int unsigned long len)
187{
188 NE2000_BYTE *rp, val;
189 unsigned char *buf;
190
191 buf = (unsigned char *) vbuf;
192 rp = (NE2000_BYTE *) NE2000_DATA_PTR(addr);
193 for (; (len > 0); len--) {
194 val = *rp;
195 *buf++ = RSWAP(val);
196 }
197}
198
199void ne2000_insw(unsigned int addr, void *vbuf, unsigned long len)
200{
201 volatile unsigned short *rp;
202 unsigned short w, *buf;
203
204 buf = (unsigned short *) vbuf;
205 rp = (volatile unsigned short *) NE2000_DATA_PTR(addr);
206 for (; (len > 0); len--) {
207 w = *rp;
208 *buf++ = BSWAP(w);
209 }
210}
211
212void ne2000_outsb(unsigned int addr, const void *vbuf, unsigned long len)
213{
214 NE2000_BYTE *rp, val;
215 unsigned char *buf;
216
217 buf = (unsigned char *) vbuf;
218 rp = (NE2000_BYTE *) NE2000_DATA_PTR(addr);
219 for (; (len > 0); len--) {
220 val = *buf++;
221 *rp = RSWAP(val);
222 }
223}
224
225void ne2000_outsw(unsigned int addr, const void *vbuf, unsigned long len)
226{
227 volatile unsigned short *rp;
228 unsigned short w, *buf;
229
230 buf = (unsigned short *) vbuf;
231 rp = (volatile unsigned short *) NE2000_DATA_PTR(addr);
232 for (; (len > 0); len--) {
233 w = *buf++;
234 *rp = BSWAP(w);
235 }
236}
237
238#endif /* COLDFIRE_NE2000_FUNCS */
239#endif /* NE2000_OFFOFFSET */
240
241/****************************************************************************/
242#endif /* mcfne_h */
diff --git a/arch/m68k/include/asm/mcfclk.h b/arch/m68k/include/asm/mcfclk.h
new file mode 100644
index 00000000000..b676a02bb39
--- /dev/null
+++ b/arch/m68k/include/asm/mcfclk.h
@@ -0,0 +1,43 @@
1/*
2 * mcfclk.h -- coldfire specific clock structure
3 */
4
5
6#ifndef mcfclk_h
7#define mcfclk_h
8
9struct clk;
10
11#ifdef MCFPM_PPMCR0
12struct clk_ops {
13 void (*enable)(struct clk *);
14 void (*disable)(struct clk *);
15};
16
17struct clk {
18 const char *name;
19 struct clk_ops *clk_ops;
20 unsigned long rate;
21 unsigned long enabled;
22 u8 slot;
23};
24
25extern struct clk *mcf_clks[];
26extern struct clk_ops clk_ops0;
27#ifdef MCFPM_PPMCR1
28extern struct clk_ops clk_ops1;
29#endif /* MCFPM_PPMCR1 */
30
31#define DEFINE_CLK(clk_bank, clk_name, clk_slot, clk_rate) \
32static struct clk __clk_##clk_bank##_##clk_slot = { \
33 .name = clk_name, \
34 .clk_ops = &clk_ops##clk_bank, \
35 .rate = clk_rate, \
36 .slot = clk_slot, \
37}
38
39void __clk_init_enabled(struct clk *);
40void __clk_init_disabled(struct clk *);
41#endif /* MCFPM_PPMCR0 */
42
43#endif /* mcfclk_h */
diff --git a/arch/m68k/include/asm/mcfgpio.h b/arch/m68k/include/asm/mcfgpio.h
index fe468eaa51e..fa1059f50df 100644
--- a/arch/m68k/include/asm/mcfgpio.h
+++ b/arch/m68k/include/asm/mcfgpio.h
@@ -16,82 +16,289 @@
16#ifndef mcfgpio_h 16#ifndef mcfgpio_h
17#define mcfgpio_h 17#define mcfgpio_h
18 18
19#include <linux/io.h> 19#ifdef CONFIG_GPIOLIB
20#include <asm-generic/gpio.h> 20#include <asm-generic/gpio.h>
21#else
22
23int __mcfgpio_get_value(unsigned gpio);
24void __mcfgpio_set_value(unsigned gpio, int value);
25int __mcfgpio_direction_input(unsigned gpio);
26int __mcfgpio_direction_output(unsigned gpio, int value);
27int __mcfgpio_request(unsigned gpio);
28void __mcfgpio_free(unsigned gpio);
29
30/* our alternate 'gpiolib' functions */
31static inline int __gpio_get_value(unsigned gpio)
32{
33 if (gpio < MCFGPIO_PIN_MAX)
34 return __mcfgpio_get_value(gpio);
35 else
36 return -EINVAL;
37}
38
39static inline void __gpio_set_value(unsigned gpio, int value)
40{
41 if (gpio < MCFGPIO_PIN_MAX)
42 __mcfgpio_set_value(gpio, value);
43}
44
45static inline int __gpio_cansleep(unsigned gpio)
46{
47 if (gpio < MCFGPIO_PIN_MAX)
48 return 0;
49 else
50 return -EINVAL;
51}
52
53static inline int __gpio_to_irq(unsigned gpio)
54{
55 return -EINVAL;
56}
57
58static inline int gpio_direction_input(unsigned gpio)
59{
60 if (gpio < MCFGPIO_PIN_MAX)
61 return __mcfgpio_direction_input(gpio);
62 else
63 return -EINVAL;
64}
65
66static inline int gpio_direction_output(unsigned gpio, int value)
67{
68 if (gpio < MCFGPIO_PIN_MAX)
69 return __mcfgpio_direction_output(gpio, value);
70 else
71 return -EINVAL;
72}
73
74static inline int gpio_request(unsigned gpio, const char *label)
75{
76 if (gpio < MCFGPIO_PIN_MAX)
77 return __mcfgpio_request(gpio);
78 else
79 return -EINVAL;
80}
81
82static inline void gpio_free(unsigned gpio)
83{
84 if (gpio < MCFGPIO_PIN_MAX)
85 __mcfgpio_free(gpio);
86}
87
88#endif /* CONFIG_GPIOLIB */
21 89
22struct mcf_gpio_chip {
23 struct gpio_chip gpio_chip;
24 void __iomem *pddr;
25 void __iomem *podr;
26 void __iomem *ppdr;
27 void __iomem *setr;
28 void __iomem *clrr;
29 const u8 *gpio_to_pinmux;
30};
31
32extern struct mcf_gpio_chip mcf_gpio_chips[];
33extern unsigned int mcf_gpio_chips_size;
34
35int mcf_gpio_direction_input(struct gpio_chip *, unsigned);
36int mcf_gpio_get_value(struct gpio_chip *, unsigned);
37int mcf_gpio_direction_output(struct gpio_chip *, unsigned, int);
38void mcf_gpio_set_value(struct gpio_chip *, unsigned, int);
39void mcf_gpio_set_value_fast(struct gpio_chip *, unsigned, int);
40int mcf_gpio_request(struct gpio_chip *, unsigned);
41void mcf_gpio_free(struct gpio_chip *, unsigned);
42 90
43/* 91/*
44 * Define macros to ease the pain of setting up the GPIO tables. There 92 * The Freescale Coldfire family is quite varied in how they implement GPIO.
45 * are two cases we need to deal with here, they cover all currently 93 * Some parts have 8 bit ports, some have 16bit and some have 32bit; some have
46 * available ColdFire GPIO hardware. There are of course minor differences 94 * only one port, others have multiple ports; some have a single data latch
47 * in the layout and number of bits in each ColdFire part, but the macros 95 * for both input and output, others have a separate pin data register to read
48 * take all that in. 96 * input; some require a read-modify-write access to change an output, others
97 * have set and clear registers for some of the outputs; Some have all the
98 * GPIOs in a single control area, others have some GPIOs implemented in
99 * different modules.
49 * 100 *
50 * Firstly is the conventional GPIO registers where we toggle individual 101 * This implementation attempts accommodate the differences while presenting
51 * bits in a register, preserving the other bits in the register. For 102 * a generic interface that will optimize to as few instructions as possible.
52 * lack of a better term I have called this the slow method. 103 */
104#if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || \
105 defined(CONFIG_M520x) || defined(CONFIG_M523x) || \
106 defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
107 defined(CONFIG_M532x) || defined(CONFIG_M54xx) || \
108 defined(CONFIG_M5441x)
109
110/* These parts have GPIO organized by 8 bit ports */
111
112#define MCFGPIO_PORTTYPE u8
113#define MCFGPIO_PORTSIZE 8
114#define mcfgpio_read(port) __raw_readb(port)
115#define mcfgpio_write(data, port) __raw_writeb(data, port)
116
117#elif defined(CONFIG_M5307) || defined(CONFIG_M5407) || defined(CONFIG_M5272)
118
119/* These parts have GPIO organized by 16 bit ports */
120
121#define MCFGPIO_PORTTYPE u16
122#define MCFGPIO_PORTSIZE 16
123#define mcfgpio_read(port) __raw_readw(port)
124#define mcfgpio_write(data, port) __raw_writew(data, port)
125
126#elif defined(CONFIG_M5249) || defined(CONFIG_M525x)
127
128/* These parts have GPIO organized by 32 bit ports */
129
130#define MCFGPIO_PORTTYPE u32
131#define MCFGPIO_PORTSIZE 32
132#define mcfgpio_read(port) __raw_readl(port)
133#define mcfgpio_write(data, port) __raw_writel(data, port)
134
135#endif
136
137#define mcfgpio_bit(gpio) (1 << ((gpio) % MCFGPIO_PORTSIZE))
138#define mcfgpio_port(gpio) ((gpio) / MCFGPIO_PORTSIZE)
139
140#if defined(CONFIG_M520x) || defined(CONFIG_M523x) || \
141 defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
142 defined(CONFIG_M532x) || defined(CONFIG_M5441x)
143/*
144 * These parts have an 'Edge' Port module (external interrupt/GPIO) which uses
145 * read-modify-write to change an output and a GPIO module which has separate
146 * set/clr registers to directly change outputs with a single write access.
147 */
148#if defined(CONFIG_M528x)
149/*
150 * The 528x also has GPIOs in other modules (GPT, QADC) which use
151 * read-modify-write as well as those controlled by the EPORT and GPIO modules.
53 */ 152 */
54#define MCFGPS(mlabel, mbase, mngpio, mpddr, mpodr, mppdr) \ 153#define MCFGPIO_SCR_START 40
55 { \ 154#elif defined(CONFIGM5441x)
56 .gpio_chip = { \ 155/* The m5441x EPORT doesn't have its own GPIO port, uses PORT C */
57 .label = #mlabel, \ 156#define MCFGPIO_SCR_START 0
58 .request = mcf_gpio_request, \ 157#else
59 .free = mcf_gpio_free, \ 158#define MCFGPIO_SCR_START 8
60 .direction_input = mcf_gpio_direction_input, \ 159#endif
61 .direction_output = mcf_gpio_direction_output,\
62 .get = mcf_gpio_get_value, \
63 .set = mcf_gpio_set_value, \
64 .base = mbase, \
65 .ngpio = mngpio, \
66 }, \
67 .pddr = (void __iomem *) mpddr, \
68 .podr = (void __iomem *) mpodr, \
69 .ppdr = (void __iomem *) mppdr, \
70 }
71 160
161#define MCFGPIO_SETR_PORT(gpio) (MCFGPIO_SETR + \
162 mcfgpio_port(gpio - MCFGPIO_SCR_START))
163
164#define MCFGPIO_CLRR_PORT(gpio) (MCFGPIO_CLRR + \
165 mcfgpio_port(gpio - MCFGPIO_SCR_START))
166#else
167
168#define MCFGPIO_SCR_START MCFGPIO_PIN_MAX
169/* with MCFGPIO_SCR == MCFGPIO_PIN_MAX, these will be optimized away */
170#define MCFGPIO_SETR_PORT(gpio) 0
171#define MCFGPIO_CLRR_PORT(gpio) 0
172
173#endif
72/* 174/*
73 * Secondly is the faster case, where we have set and clear registers 175 * Coldfire specific helper functions
74 * that allow us to set or clear a bit with a single write, not having
75 * to worry about preserving other bits.
76 */ 176 */
77#define MCFGPF(mlabel, mbase, mngpio) \
78 { \
79 .gpio_chip = { \
80 .label = #mlabel, \
81 .request = mcf_gpio_request, \
82 .free = mcf_gpio_free, \
83 .direction_input = mcf_gpio_direction_input, \
84 .direction_output = mcf_gpio_direction_output,\
85 .get = mcf_gpio_get_value, \
86 .set = mcf_gpio_set_value_fast, \
87 .base = mbase, \
88 .ngpio = mngpio, \
89 }, \
90 .pddr = (void __iomem *) MCFGPIO_PDDR_##mlabel, \
91 .podr = (void __iomem *) MCFGPIO_PODR_##mlabel, \
92 .ppdr = (void __iomem *) MCFGPIO_PPDSDR_##mlabel, \
93 .setr = (void __iomem *) MCFGPIO_PPDSDR_##mlabel, \
94 .clrr = (void __iomem *) MCFGPIO_PCLRR_##mlabel, \
95 }
96 177
178/* return the port pin data register for a gpio */
179static inline u32 __mcfgpio_ppdr(unsigned gpio)
180{
181#if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || \
182 defined(CONFIG_M5307) || defined(CONFIG_M5407)
183 return MCFSIM_PADAT;
184#elif defined(CONFIG_M5272)
185 if (gpio < 16)
186 return MCFSIM_PADAT;
187 else if (gpio < 32)
188 return MCFSIM_PBDAT;
189 else
190 return MCFSIM_PCDAT;
191#elif defined(CONFIG_M5249) || defined(CONFIG_M525x)
192 if (gpio < 32)
193 return MCFSIM2_GPIOREAD;
194 else
195 return MCFSIM2_GPIO1READ;
196#elif defined(CONFIG_M520x) || defined(CONFIG_M523x) || \
197 defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
198 defined(CONFIG_M532x) || defined(CONFIG_M5441x)
199#if !defined(CONFIG_M5441x)
200 if (gpio < 8)
201 return MCFEPORT_EPPDR;
202#if defined(CONFIG_M528x)
203 else if (gpio < 16)
204 return MCFGPTA_GPTPORT;
205 else if (gpio < 24)
206 return MCFGPTB_GPTPORT;
207 else if (gpio < 32)
208 return MCFQADC_PORTQA;
209 else if (gpio < 40)
210 return MCFQADC_PORTQB;
211#endif /* defined(CONFIG_M528x) */
212 else
213#endif /* !defined(CONFIG_M5441x) */
214 return MCFGPIO_PPDR + mcfgpio_port(gpio - MCFGPIO_SCR_START);
215#else
216 return 0;
97#endif 217#endif
218}
219
220/* return the port output data register for a gpio */
221static inline u32 __mcfgpio_podr(unsigned gpio)
222{
223#if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || \
224 defined(CONFIG_M5307) || defined(CONFIG_M5407)
225 return MCFSIM_PADAT;
226#elif defined(CONFIG_M5272)
227 if (gpio < 16)
228 return MCFSIM_PADAT;
229 else if (gpio < 32)
230 return MCFSIM_PBDAT;
231 else
232 return MCFSIM_PCDAT;
233#elif defined(CONFIG_M5249) || defined(CONFIG_M525x)
234 if (gpio < 32)
235 return MCFSIM2_GPIOWRITE;
236 else
237 return MCFSIM2_GPIO1WRITE;
238#elif defined(CONFIG_M520x) || defined(CONFIG_M523x) || \
239 defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
240 defined(CONFIG_M532x) || defined(CONFIG_M5441x)
241#if !defined(CONFIG_M5441x)
242 if (gpio < 8)
243 return MCFEPORT_EPDR;
244#if defined(CONFIG_M528x)
245 else if (gpio < 16)
246 return MCFGPTA_GPTPORT;
247 else if (gpio < 24)
248 return MCFGPTB_GPTPORT;
249 else if (gpio < 32)
250 return MCFQADC_PORTQA;
251 else if (gpio < 40)
252 return MCFQADC_PORTQB;
253#endif /* defined(CONFIG_M528x) */
254 else
255#endif /* !defined(CONFIG_M5441x) */
256 return MCFGPIO_PODR + mcfgpio_port(gpio - MCFGPIO_SCR_START);
257#else
258 return 0;
259#endif
260}
261
262/* return the port direction data register for a gpio */
263static inline u32 __mcfgpio_pddr(unsigned gpio)
264{
265#if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || \
266 defined(CONFIG_M5307) || defined(CONFIG_M5407)
267 return MCFSIM_PADDR;
268#elif defined(CONFIG_M5272)
269 if (gpio < 16)
270 return MCFSIM_PADDR;
271 else if (gpio < 32)
272 return MCFSIM_PBDDR;
273 else
274 return MCFSIM_PCDDR;
275#elif defined(CONFIG_M5249) || defined(CONFIG_M525x)
276 if (gpio < 32)
277 return MCFSIM2_GPIOENABLE;
278 else
279 return MCFSIM2_GPIO1ENABLE;
280#elif defined(CONFIG_M520x) || defined(CONFIG_M523x) || \
281 defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
282 defined(CONFIG_M532x) || defined(CONFIG_M5441x)
283#if !defined(CONFIG_M5441x)
284 if (gpio < 8)
285 return MCFEPORT_EPDDR;
286#if defined(CONFIG_M528x)
287 else if (gpio < 16)
288 return MCFGPTA_GPTDDR;
289 else if (gpio < 24)
290 return MCFGPTB_GPTDDR;
291 else if (gpio < 32)
292 return MCFQADC_DDRQA;
293 else if (gpio < 40)
294 return MCFQADC_DDRQB;
295#endif /* defined(CONFIG_M528x) */
296 else
297#endif /* !defined(CONFIG_M5441x) */
298 return MCFGPIO_PDDR + mcfgpio_port(gpio - MCFGPIO_SCR_START);
299#else
300 return 0;
301#endif
302}
303
304#endif /* mcfgpio_h */
diff --git a/arch/m68k/include/asm/mcfmbus.h b/arch/m68k/include/asm/mcfmbus.h
deleted file mode 100644
index 319899c47a2..00000000000
--- a/arch/m68k/include/asm/mcfmbus.h
+++ /dev/null
@@ -1,77 +0,0 @@
1/****************************************************************************/
2
3/*
4 * mcfmbus.h -- Coldfire MBUS support defines.
5 *
6 * (C) Copyright 1999, Martin Floeer (mfloeer@axcent.de)
7 */
8
9/****************************************************************************/
10
11
12#ifndef mcfmbus_h
13#define mcfmbus_h
14
15
16#define MCFMBUS_BASE 0x280
17#define MCFMBUS_IRQ_VECTOR 0x19
18#define MCFMBUS_IRQ 0x1
19#define MCFMBUS_CLK 0x3f
20#define MCFMBUS_IRQ_LEVEL 0x07 /*IRQ Level 1*/
21#define MCFMBUS_ADDRESS 0x01
22
23
24/*
25* Define the 5307 MBUS register set addresses
26*/
27
28#define MCFMBUS_MADR 0x00
29#define MCFMBUS_MFDR 0x04
30#define MCFMBUS_MBCR 0x08
31#define MCFMBUS_MBSR 0x0C
32#define MCFMBUS_MBDR 0x10
33
34
35#define MCFMBUS_MADR_ADDR(a) (((a)&0x7F)<<0x01) /*Slave Address*/
36
37#define MCFMBUS_MFDR_MBC(a) ((a)&0x3F) /*M-Bus Clock*/
38
39/*
40* Define bit flags in Control Register
41*/
42
43#define MCFMBUS_MBCR_MEN (0x80) /* M-Bus Enable */
44#define MCFMBUS_MBCR_MIEN (0x40) /* M-Bus Interrupt Enable */
45#define MCFMBUS_MBCR_MSTA (0x20) /* Master/Slave Mode Select Bit */
46#define MCFMBUS_MBCR_MTX (0x10) /* Transmit/Rcv Mode Select Bit */
47#define MCFMBUS_MBCR_TXAK (0x08) /* Transmit Acknowledge Enable */
48#define MCFMBUS_MBCR_RSTA (0x04) /* Repeat Start */
49
50/*
51* Define bit flags in Status Register
52*/
53
54#define MCFMBUS_MBSR_MCF (0x80) /* Data Transfer Complete */
55#define MCFMBUS_MBSR_MAAS (0x40) /* Addressed as a Slave */
56#define MCFMBUS_MBSR_MBB (0x20) /* Bus Busy */
57#define MCFMBUS_MBSR_MAL (0x10) /* Arbitration Lost */
58#define MCFMBUS_MBSR_SRW (0x04) /* Slave Transmit */
59#define MCFMBUS_MBSR_MIF (0x02) /* M-Bus Interrupt */
60#define MCFMBUS_MBSR_RXAK (0x01) /* No Acknowledge Received */
61
62/*
63* Define bit flags in DATA I/O Register
64*/
65
66#define MCFMBUS_MBDR_READ (0x01) /* 1=read 0=write MBUS */
67
68#define MBUSIOCSCLOCK 1
69#define MBUSIOCGCLOCK 2
70#define MBUSIOCSADDR 3
71#define MBUSIOCGADDR 4
72#define MBUSIOCSSLADDR 5
73#define MBUSIOCGSLADDR 6
74#define MBUSIOCSSUBADDR 7
75#define MBUSIOCGSUBADDR 8
76
77#endif
diff --git a/arch/m68k/include/asm/mcfsim.h b/arch/m68k/include/asm/mcfsim.h
index ebd0304054a..7a83e619e73 100644
--- a/arch/m68k/include/asm/mcfsim.h
+++ b/arch/m68k/include/asm/mcfsim.h
@@ -27,6 +27,9 @@
27#elif defined(CONFIG_M5249) 27#elif defined(CONFIG_M5249)
28#include <asm/m5249sim.h> 28#include <asm/m5249sim.h>
29#include <asm/mcfintc.h> 29#include <asm/mcfintc.h>
30#elif defined(CONFIG_M525x)
31#include <asm/m525xsim.h>
32#include <asm/mcfintc.h>
30#elif defined(CONFIG_M527x) 33#elif defined(CONFIG_M527x)
31#include <asm/m527xsim.h> 34#include <asm/m527xsim.h>
32#elif defined(CONFIG_M5272) 35#elif defined(CONFIG_M5272)
@@ -43,6 +46,8 @@
43#include <asm/mcfintc.h> 46#include <asm/mcfintc.h>
44#elif defined(CONFIG_M54xx) 47#elif defined(CONFIG_M54xx)
45#include <asm/m54xxsim.h> 48#include <asm/m54xxsim.h>
49#elif defined(CONFIG_M5441x)
50#include <asm/m5441xsim.h>
46#endif 51#endif
47 52
48/****************************************************************************/ 53/****************************************************************************/
diff --git a/arch/m68k/include/asm/mcftimer.h b/arch/m68k/include/asm/mcftimer.h
index 351c2723787..da2fa43c2e4 100644
--- a/arch/m68k/include/asm/mcftimer.h
+++ b/arch/m68k/include/asm/mcftimer.h
@@ -19,7 +19,7 @@
19#define MCFTIMER_TRR 0x04 /* Timer Reference (r/w) */ 19#define MCFTIMER_TRR 0x04 /* Timer Reference (r/w) */
20#define MCFTIMER_TCR 0x08 /* Timer Capture reg (r/w) */ 20#define MCFTIMER_TCR 0x08 /* Timer Capture reg (r/w) */
21#define MCFTIMER_TCN 0x0C /* Timer Counter reg (r/w) */ 21#define MCFTIMER_TCN 0x0C /* Timer Counter reg (r/w) */
22#if defined(CONFIG_M532x) 22#if defined(CONFIG_M532x) || defined(CONFIG_M5441x)
23#define MCFTIMER_TER 0x03 /* Timer Event reg (r/w) */ 23#define MCFTIMER_TER 0x03 /* Timer Event reg (r/w) */
24#else 24#else
25#define MCFTIMER_TER 0x11 /* Timer Event reg (r/w) */ 25#define MCFTIMER_TER 0x11 /* Timer Event reg (r/w) */
diff --git a/arch/m68k/include/asm/mcfuart.h b/arch/m68k/include/asm/mcfuart.h
index 2d3bc774b3c..b40c20f6664 100644
--- a/arch/m68k/include/asm/mcfuart.h
+++ b/arch/m68k/include/asm/mcfuart.h
@@ -43,8 +43,8 @@ struct mcf_platform_uart {
43#define MCFUART_UFPD 0x30 /* Frac Prec. Divider (r/w) */ 43#define MCFUART_UFPD 0x30 /* Frac Prec. Divider (r/w) */
44#endif 44#endif
45#if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || \ 45#if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || \
46 defined(CONFIG_M5249) || defined(CONFIG_M5307) || \ 46 defined(CONFIG_M5249) || defined(CONFIG_M525x) || \
47 defined(CONFIG_M5407) 47 defined(CONFIG_M5307) || defined(CONFIG_M5407)
48#define MCFUART_UIVR 0x30 /* Interrupt Vector (r/w) */ 48#define MCFUART_UIVR 0x30 /* Interrupt Vector (r/w) */
49#endif 49#endif
50#define MCFUART_UIPR 0x34 /* Input Port (r) */ 50#define MCFUART_UIPR 0x34 /* Input Port (r) */
diff --git a/arch/m68k/include/asm/mman.h b/arch/m68k/include/asm/mman.h
deleted file mode 100644
index 8eebf89f5ab..00000000000
--- a/arch/m68k/include/asm/mman.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/mman.h>
diff --git a/arch/m68k/include/asm/mutex.h b/arch/m68k/include/asm/mutex.h
deleted file mode 100644
index 458c1f7fbc1..00000000000
--- a/arch/m68k/include/asm/mutex.h
+++ /dev/null
@@ -1,9 +0,0 @@
1/*
2 * Pull in the generic implementation for the mutex fastpath.
3 *
4 * TODO: implement optimized primitives instead, or leave the generic
5 * implementation in place, or pick the atomic_xchg() based generic
6 * implementation. (see asm-generic/mutex-xchg.h for details)
7 */
8
9#include <asm-generic/mutex-dec.h>
diff --git a/arch/m68k/include/asm/pci.h b/arch/m68k/include/asm/pci.h
index 4ad0aea48ab..848c3dfaad5 100644
--- a/arch/m68k/include/asm/pci.h
+++ b/arch/m68k/include/asm/pci.h
@@ -2,6 +2,7 @@
2#define _ASM_M68K_PCI_H 2#define _ASM_M68K_PCI_H
3 3
4#include <asm-generic/pci-dma-compat.h> 4#include <asm-generic/pci-dma-compat.h>
5#include <asm-generic/pci.h>
5 6
6/* The PCI address space does equal the physical memory 7/* The PCI address space does equal the physical memory
7 * address space. The networking and block device layers use 8 * address space. The networking and block device layers use
@@ -9,4 +10,9 @@
9 */ 10 */
10#define PCI_DMA_BUS_IS_PHYS (1) 11#define PCI_DMA_BUS_IS_PHYS (1)
11 12
13#define pcibios_assign_all_busses() 1
14
15#define PCIBIOS_MIN_IO 0x00000100
16#define PCIBIOS_MIN_MEM 0x02000000
17
12#endif /* _ASM_M68K_PCI_H */ 18#endif /* _ASM_M68K_PCI_H */
diff --git a/arch/m68k/include/asm/percpu.h b/arch/m68k/include/asm/percpu.h
deleted file mode 100644
index 0859d048faf..00000000000
--- a/arch/m68k/include/asm/percpu.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_M68K_PERCPU_H
2#define __ASM_M68K_PERCPU_H
3
4#include <asm-generic/percpu.h>
5
6#endif /* __ASM_M68K_PERCPU_H */
diff --git a/arch/m68k/include/asm/pinmux.h b/arch/m68k/include/asm/pinmux.h
deleted file mode 100644
index 119ee686dbd..00000000000
--- a/arch/m68k/include/asm/pinmux.h
+++ /dev/null
@@ -1,30 +0,0 @@
1/*
2 * Coldfire generic GPIO pinmux support.
3 *
4 * (C) Copyright 2009, Steven King <sfking@fdwdc.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 as published by
8 * the Free Software Foundation; version 2 of the License.
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 pinmux_h
17#define pinmux_h
18
19#define MCFPINMUX_NONE -1
20
21extern int mcf_pinmux_request(unsigned, unsigned);
22extern void mcf_pinmux_release(unsigned, unsigned);
23
24static inline int mcf_pinmux_is_valid(unsigned pinmux)
25{
26 return pinmux != MCFPINMUX_NONE;
27}
28
29#endif
30
diff --git a/arch/m68k/include/asm/resource.h b/arch/m68k/include/asm/resource.h
deleted file mode 100644
index e7d35019f33..00000000000
--- a/arch/m68k/include/asm/resource.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _M68K_RESOURCE_H
2#define _M68K_RESOURCE_H
3
4#include <asm-generic/resource.h>
5
6#endif /* _M68K_RESOURCE_H */
diff --git a/arch/m68k/include/asm/sbus.h b/arch/m68k/include/asm/sbus.h
deleted file mode 100644
index bfe3ba147f2..00000000000
--- a/arch/m68k/include/asm/sbus.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/*
2 * some sbus structures and macros to make usage of sbus drivers possible
3 */
4
5#ifndef __M68K_SBUS_H
6#define __M68K_SBUS_H
7
8struct sbus_dev {
9 struct {
10 unsigned int which_io;
11 unsigned int phys_addr;
12 } reg_addrs[1];
13};
14
15/* sbus IO functions stolen from include/asm-sparc/io.h for the serial driver */
16/* No SBUS on the Sun3, kludge -- sam */
17
18static inline void _sbus_writeb(unsigned char val, unsigned long addr)
19{
20 *(volatile unsigned char *)addr = val;
21}
22
23static inline unsigned char _sbus_readb(unsigned long addr)
24{
25 return *(volatile unsigned char *)addr;
26}
27
28static inline void _sbus_writel(unsigned long val, unsigned long addr)
29{
30 *(volatile unsigned long *)addr = val;
31
32}
33
34extern inline unsigned long _sbus_readl(unsigned long addr)
35{
36 return *(volatile unsigned long *)addr;
37}
38
39
40#define sbus_readb(a) _sbus_readb((unsigned long)a)
41#define sbus_writeb(v, a) _sbus_writeb(v, (unsigned long)a)
42#define sbus_readl(a) _sbus_readl((unsigned long)a)
43#define sbus_writel(v, a) _sbus_writel(v, (unsigned long)a)
44
45#endif
diff --git a/arch/m68k/include/asm/scatterlist.h b/arch/m68k/include/asm/scatterlist.h
deleted file mode 100644
index 312505452a1..00000000000
--- a/arch/m68k/include/asm/scatterlist.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _M68K_SCATTERLIST_H
2#define _M68K_SCATTERLIST_H
3
4#include <asm-generic/scatterlist.h>
5
6#endif /* !(_M68K_SCATTERLIST_H) */
diff --git a/arch/m68k/include/asm/sections.h b/arch/m68k/include/asm/sections.h
deleted file mode 100644
index 5277e52715e..00000000000
--- a/arch/m68k/include/asm/sections.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef _ASM_M68K_SECTIONS_H
2#define _ASM_M68K_SECTIONS_H
3
4#include <asm-generic/sections.h>
5
6extern char _sbss[], _ebss[];
7
8#endif /* _ASM_M68K_SECTIONS_H */
diff --git a/arch/m68k/include/asm/shm.h b/arch/m68k/include/asm/shm.h
deleted file mode 100644
index fa56ec84a12..00000000000
--- a/arch/m68k/include/asm/shm.h
+++ /dev/null
@@ -1,31 +0,0 @@
1#ifndef _M68K_SHM_H
2#define _M68K_SHM_H
3
4
5/* format of page table entries that correspond to shared memory pages
6 currently out in swap space (see also mm/swap.c):
7 bits 0-1 (PAGE_PRESENT) is = 0
8 bits 8..2 (SWP_TYPE) are = SHM_SWP_TYPE
9 bits 31..9 are used like this:
10 bits 15..9 (SHM_ID) the id of the shared memory segment
11 bits 30..16 (SHM_IDX) the index of the page within the shared memory segment
12 (actually only bits 25..16 get used since SHMMAX is so low)
13 bit 31 (SHM_READ_ONLY) flag whether the page belongs to a read-only attach
14*/
15/* on the m68k both bits 0 and 1 must be zero */
16/* format on the sun3 is similar, but bits 30, 31 are set to zero and all
17 others are reduced by 2. --m */
18
19#ifndef CONFIG_SUN3
20#define SHM_ID_SHIFT 9
21#else
22#define SHM_ID_SHIFT 7
23#endif
24#define _SHM_ID_BITS 7
25#define SHM_ID_MASK ((1<<_SHM_ID_BITS)-1)
26
27#define SHM_IDX_SHIFT (SHM_ID_SHIFT+_SHM_ID_BITS)
28#define _SHM_IDX_BITS 15
29#define SHM_IDX_MASK ((1<<_SHM_IDX_BITS)-1)
30
31#endif /* _M68K_SHM_H */
diff --git a/arch/m68k/include/asm/siginfo.h b/arch/m68k/include/asm/siginfo.h
deleted file mode 100644
index 851d3d784b5..00000000000
--- a/arch/m68k/include/asm/siginfo.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _M68K_SIGINFO_H
2#define _M68K_SIGINFO_H
3
4#include <asm-generic/siginfo.h>
5
6#endif
diff --git a/arch/m68k/include/asm/statfs.h b/arch/m68k/include/asm/statfs.h
deleted file mode 100644
index 08d93f14e06..00000000000
--- a/arch/m68k/include/asm/statfs.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _M68K_STATFS_H
2#define _M68K_STATFS_H
3
4#include <asm-generic/statfs.h>
5
6#endif /* _M68K_STATFS_H */
diff --git a/arch/m68k/include/asm/topology.h b/arch/m68k/include/asm/topology.h
deleted file mode 100644
index ca173e9f26f..00000000000
--- a/arch/m68k/include/asm/topology.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_M68K_TOPOLOGY_H
2#define _ASM_M68K_TOPOLOGY_H
3
4#include <asm-generic/topology.h>
5
6#endif /* _ASM_M68K_TOPOLOGY_H */
diff --git a/arch/m68k/include/asm/types.h b/arch/m68k/include/asm/types.h
deleted file mode 100644
index 89705adcbd5..00000000000
--- a/arch/m68k/include/asm/types.h
+++ /dev/null
@@ -1,22 +0,0 @@
1#ifndef _M68K_TYPES_H
2#define _M68K_TYPES_H
3
4/*
5 * This file is never included by application software unless
6 * explicitly requested (e.g., via linux/types.h) in which case the
7 * application is Linux specific so (user-) name space pollution is
8 * not a major issue. However, for interoperability, libraries still
9 * need to be careful to avoid a name clashes.
10 */
11#include <asm-generic/int-ll64.h>
12
13/*
14 * These aren't exported outside the kernel to avoid name space clashes
15 */
16#ifdef __KERNEL__
17
18#define BITS_PER_LONG 32
19
20#endif /* __KERNEL__ */
21
22#endif /* _M68K_TYPES_H */
diff --git a/arch/m68k/include/asm/unaligned.h b/arch/m68k/include/asm/unaligned.h
index f4043ae63db..2b3ca0bf7a0 100644
--- a/arch/m68k/include/asm/unaligned.h
+++ b/arch/m68k/include/asm/unaligned.h
@@ -2,7 +2,7 @@
2#define _ASM_M68K_UNALIGNED_H 2#define _ASM_M68K_UNALIGNED_H
3 3
4 4
5#if defined(CONFIG_COLDFIRE) || defined(CONFIG_M68000) 5#ifdef CONFIG_CPU_HAS_NO_UNALIGNED
6#include <linux/unaligned/be_struct.h> 6#include <linux/unaligned/be_struct.h>
7#include <linux/unaligned/le_byteshift.h> 7#include <linux/unaligned/le_byteshift.h>
8#include <linux/unaligned/generic.h> 8#include <linux/unaligned/generic.h>
@@ -12,7 +12,7 @@
12 12
13#else 13#else
14/* 14/*
15 * The m68k can do unaligned accesses itself. 15 * The m68k can do unaligned accesses itself.
16 */ 16 */
17#include <linux/unaligned/access_ok.h> 17#include <linux/unaligned/access_ok.h>
18#include <linux/unaligned/generic.h> 18#include <linux/unaligned/generic.h>
diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h
index ea0b502f845..045cfd6a9e3 100644
--- a/arch/m68k/include/asm/unistd.h
+++ b/arch/m68k/include/asm/unistd.h
@@ -357,7 +357,6 @@
357 357
358#define NR_syscalls 347 358#define NR_syscalls 347
359 359
360#define __ARCH_WANT_IPC_PARSE_VERSION
361#define __ARCH_WANT_OLD_READDIR 360#define __ARCH_WANT_OLD_READDIR
362#define __ARCH_WANT_OLD_STAT 361#define __ARCH_WANT_OLD_STAT
363#define __ARCH_WANT_STAT64 362#define __ARCH_WANT_STAT64
diff --git a/arch/m68k/include/asm/xor.h b/arch/m68k/include/asm/xor.h
deleted file mode 100644
index c82eb12a5b1..00000000000
--- a/arch/m68k/include/asm/xor.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/xor.h>
diff --git a/arch/m68k/kernel/Makefile b/arch/m68k/kernel/Makefile
index 5c7070e21eb..068ad49210d 100644
--- a/arch/m68k/kernel/Makefile
+++ b/arch/m68k/kernel/Makefile
@@ -18,6 +18,7 @@ obj-y += setup.o signal.o sys_m68k.o syscalltable.o time.o traps.o
18 18
19obj-$(CONFIG_MMU_MOTOROLA) += ints.o vectors.o 19obj-$(CONFIG_MMU_MOTOROLA) += ints.o vectors.o
20obj-$(CONFIG_MMU_SUN3) += ints.o vectors.o 20obj-$(CONFIG_MMU_SUN3) += ints.o vectors.o
21obj-$(CONFIG_PCI) += pcibios.o
21 22
22ifndef CONFIG_MMU_SUN3 23ifndef CONFIG_MMU_SUN3
23obj-y += dma.o 24obj-y += dma.o
diff --git a/arch/m68k/kernel/dma.c b/arch/m68k/kernel/dma.c
index f6daf6e15d2..e546a5534dd 100644
--- a/arch/m68k/kernel/dma.c
+++ b/arch/m68k/kernel/dma.c
@@ -16,7 +16,7 @@
16 16
17#include <asm/pgalloc.h> 17#include <asm/pgalloc.h>
18 18
19#ifdef CONFIG_MMU 19#if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE)
20 20
21void *dma_alloc_coherent(struct device *dev, size_t size, 21void *dma_alloc_coherent(struct device *dev, size_t size,
22 dma_addr_t *handle, gfp_t flag) 22 dma_addr_t *handle, gfp_t flag)
@@ -96,7 +96,7 @@ void dma_free_coherent(struct device *dev, size_t size,
96 free_pages((unsigned long)vaddr, get_order(size)); 96 free_pages((unsigned long)vaddr, get_order(size));
97} 97}
98 98
99#endif /* CONFIG_MMU */ 99#endif /* CONFIG_MMU && !CONFIG_COLDFIRE */
100 100
101EXPORT_SYMBOL(dma_alloc_coherent); 101EXPORT_SYMBOL(dma_alloc_coherent);
102EXPORT_SYMBOL(dma_free_coherent); 102EXPORT_SYMBOL(dma_free_coherent);
@@ -105,6 +105,7 @@ void dma_sync_single_for_device(struct device *dev, dma_addr_t handle,
105 size_t size, enum dma_data_direction dir) 105 size_t size, enum dma_data_direction dir)
106{ 106{
107 switch (dir) { 107 switch (dir) {
108 case DMA_BIDIRECTIONAL:
108 case DMA_TO_DEVICE: 109 case DMA_TO_DEVICE:
109 cache_push(handle, size); 110 cache_push(handle, size);
110 break; 111 break;
diff --git a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S
index b8daf64e347..165ee9f9d5c 100644
--- a/arch/m68k/kernel/entry.S
+++ b/arch/m68k/kernel/entry.S
@@ -1,5 +1,451 @@
1#if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE) 1/* -*- mode: asm -*-
2#include "entry_mm.S" 2 *
3 * linux/arch/m68k/kernel/entry.S
4 *
5 * Copyright (C) 1991, 1992 Linus Torvalds
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file README.legal in the main directory of this archive
9 * for more details.
10 *
11 * Linux/m68k support by Hamish Macdonald
12 *
13 * 68060 fixes by Jesper Skov
14 *
15 */
16
17/*
18 * entry.S contains the system-call and fault low-level handling routines.
19 * This also contains the timer-interrupt handler, as well as all interrupts
20 * and faults that can result in a task-switch.
21 *
22 * NOTE: This code handles signal-recognition, which happens every time
23 * after a timer-interrupt and after each system call.
24 *
25 */
26
27/*
28 * 12/03/96 Jes: Currently we only support m68k single-cpu systems, so
29 * all pointers that used to be 'current' are now entry
30 * number 0 in the 'current_set' list.
31 *
32 * 6/05/00 RZ: addedd writeback completion after return from sighandler
33 * for 68040
34 */
35
36#include <linux/linkage.h>
37#include <asm/errno.h>
38#include <asm/setup.h>
39#include <asm/segment.h>
40#include <asm/traps.h>
41#include <asm/unistd.h>
42#include <asm/asm-offsets.h>
43#include <asm/entry.h>
44
45.globl system_call, buserr, trap, resume
46.globl sys_call_table
47.globl sys_fork, sys_clone, sys_vfork
48.globl ret_from_interrupt, bad_interrupt
49.globl auto_irqhandler_fixup
50.globl user_irqvec_fixup
51
52.text
53ENTRY(sys_fork)
54 SAVE_SWITCH_STACK
55 pea %sp@(SWITCH_STACK_SIZE)
56 jbsr m68k_fork
57 addql #4,%sp
58 RESTORE_SWITCH_STACK
59 rts
60
61ENTRY(sys_clone)
62 SAVE_SWITCH_STACK
63 pea %sp@(SWITCH_STACK_SIZE)
64 jbsr m68k_clone
65 addql #4,%sp
66 RESTORE_SWITCH_STACK
67 rts
68
69ENTRY(sys_vfork)
70 SAVE_SWITCH_STACK
71 pea %sp@(SWITCH_STACK_SIZE)
72 jbsr m68k_vfork
73 addql #4,%sp
74 RESTORE_SWITCH_STACK
75 rts
76
77ENTRY(sys_sigreturn)
78 SAVE_SWITCH_STACK
79 jbsr do_sigreturn
80 RESTORE_SWITCH_STACK
81 rts
82
83ENTRY(sys_rt_sigreturn)
84 SAVE_SWITCH_STACK
85 jbsr do_rt_sigreturn
86 RESTORE_SWITCH_STACK
87 rts
88
89ENTRY(buserr)
90 SAVE_ALL_INT
91 GET_CURRENT(%d0)
92 movel %sp,%sp@- | stack frame pointer argument
93 jbsr buserr_c
94 addql #4,%sp
95 jra ret_from_exception
96
97ENTRY(trap)
98 SAVE_ALL_INT
99 GET_CURRENT(%d0)
100 movel %sp,%sp@- | stack frame pointer argument
101 jbsr trap_c
102 addql #4,%sp
103 jra ret_from_exception
104
105 | After a fork we jump here directly from resume,
106 | so that %d1 contains the previous task
107 | schedule_tail now used regardless of CONFIG_SMP
108ENTRY(ret_from_fork)
109 movel %d1,%sp@-
110 jsr schedule_tail
111 addql #4,%sp
112 jra ret_from_exception
113
114#if defined(CONFIG_COLDFIRE) || !defined(CONFIG_MMU)
115
116#ifdef TRAP_DBG_INTERRUPT
117
118.globl dbginterrupt
119ENTRY(dbginterrupt)
120 SAVE_ALL_INT
121 GET_CURRENT(%d0)
122 movel %sp,%sp@- /* stack frame pointer argument */
123 jsr dbginterrupt_c
124 addql #4,%sp
125 jra ret_from_exception
126#endif
127
128ENTRY(reschedule)
129 /* save top of frame */
130 pea %sp@
131 jbsr set_esp0
132 addql #4,%sp
133 pea ret_from_exception
134 jmp schedule
135
136ENTRY(ret_from_user_signal)
137 moveq #__NR_sigreturn,%d0
138 trap #0
139
140ENTRY(ret_from_user_rt_signal)
141 movel #__NR_rt_sigreturn,%d0
142 trap #0
143
3#else 144#else
4#include "entry_no.S" 145
146do_trace_entry:
147 movel #-ENOSYS,%sp@(PT_OFF_D0)| needed for strace
148 subql #4,%sp
149 SAVE_SWITCH_STACK
150 jbsr syscall_trace
151 RESTORE_SWITCH_STACK
152 addql #4,%sp
153 movel %sp@(PT_OFF_ORIG_D0),%d0
154 cmpl #NR_syscalls,%d0
155 jcs syscall
156badsys:
157 movel #-ENOSYS,%sp@(PT_OFF_D0)
158 jra ret_from_syscall
159
160do_trace_exit:
161 subql #4,%sp
162 SAVE_SWITCH_STACK
163 jbsr syscall_trace
164 RESTORE_SWITCH_STACK
165 addql #4,%sp
166 jra .Lret_from_exception
167
168ENTRY(ret_from_signal)
169 movel %curptr@(TASK_STACK),%a1
170 tstb %a1@(TINFO_FLAGS+2)
171 jge 1f
172 jbsr syscall_trace
1731: RESTORE_SWITCH_STACK
174 addql #4,%sp
175/* on 68040 complete pending writebacks if any */
176#ifdef CONFIG_M68040
177 bfextu %sp@(PT_OFF_FORMATVEC){#0,#4},%d0
178 subql #7,%d0 | bus error frame ?
179 jbne 1f
180 movel %sp,%sp@-
181 jbsr berr_040cleanup
182 addql #4,%sp
1831:
184#endif
185 jra .Lret_from_exception
186
187ENTRY(system_call)
188 SAVE_ALL_SYS
189
190 GET_CURRENT(%d1)
191 movel %d1,%a1
192
193 | save top of frame
194 movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0)
195
196 | syscall trace?
197 tstb %a1@(TINFO_FLAGS+2)
198 jmi do_trace_entry
199 cmpl #NR_syscalls,%d0
200 jcc badsys
201syscall:
202 jbsr @(sys_call_table,%d0:l:4)@(0)
203 movel %d0,%sp@(PT_OFF_D0) | save the return value
204ret_from_syscall:
205 |oriw #0x0700,%sr
206 movel %curptr@(TASK_STACK),%a1
207 movew %a1@(TINFO_FLAGS+2),%d0
208 jne syscall_exit_work
2091: RESTORE_ALL
210
211syscall_exit_work:
212 btst #5,%sp@(PT_OFF_SR) | check if returning to kernel
213 bnes 1b | if so, skip resched, signals
214 lslw #1,%d0
215 jcs do_trace_exit
216 jmi do_delayed_trace
217 lslw #8,%d0
218 jne do_signal_return
219 pea resume_userspace
220 jra schedule
221
222
223ENTRY(ret_from_exception)
224.Lret_from_exception:
225 btst #5,%sp@(PT_OFF_SR) | check if returning to kernel
226 bnes 1f | if so, skip resched, signals
227 | only allow interrupts when we are really the last one on the
228 | kernel stack, otherwise stack overflow can occur during
229 | heavy interrupt load
230 andw #ALLOWINT,%sr
231
232resume_userspace:
233 movel %curptr@(TASK_STACK),%a1
234 moveb %a1@(TINFO_FLAGS+3),%d0
235 jne exit_work
2361: RESTORE_ALL
237
238exit_work:
239 | save top of frame
240 movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0)
241 lslb #1,%d0
242 jne do_signal_return
243 pea resume_userspace
244 jra schedule
245
246
247do_signal_return:
248 |andw #ALLOWINT,%sr
249 subql #4,%sp | dummy return address
250 SAVE_SWITCH_STACK
251 pea %sp@(SWITCH_STACK_SIZE)
252 bsrl do_notify_resume
253 addql #4,%sp
254 RESTORE_SWITCH_STACK
255 addql #4,%sp
256 jbra resume_userspace
257
258do_delayed_trace:
259 bclr #7,%sp@(PT_OFF_SR) | clear trace bit in SR
260 pea 1 | send SIGTRAP
261 movel %curptr,%sp@-
262 pea LSIGTRAP
263 jbsr send_sig
264 addql #8,%sp
265 addql #4,%sp
266 jbra resume_userspace
267
268
269/* This is the main interrupt handler for autovector interrupts */
270
271ENTRY(auto_inthandler)
272 SAVE_ALL_INT
273 GET_CURRENT(%d0)
274 movel %d0,%a1
275 addqb #1,%a1@(TINFO_PREEMPT+1)
276 | put exception # in d0
277 bfextu %sp@(PT_OFF_FORMATVEC){#4,#10},%d0
278 subw #VEC_SPUR,%d0
279
280 movel %sp,%sp@-
281 movel %d0,%sp@- | put vector # on stack
282auto_irqhandler_fixup = . + 2
283 jsr do_IRQ | process the IRQ
284 addql #8,%sp | pop parameters off stack
285
286ret_from_interrupt:
287 movel %curptr@(TASK_STACK),%a1
288 subqb #1,%a1@(TINFO_PREEMPT+1)
289 jeq ret_from_last_interrupt
2902: RESTORE_ALL
291
292 ALIGN
293ret_from_last_interrupt:
294 moveq #(~ALLOWINT>>8)&0xff,%d0
295 andb %sp@(PT_OFF_SR),%d0
296 jne 2b
297
298 /* check if we need to do software interrupts */
299 tstl irq_stat+CPUSTAT_SOFTIRQ_PENDING
300 jeq .Lret_from_exception
301 pea ret_from_exception
302 jra do_softirq
303
304/* Handler for user defined interrupt vectors */
305
306ENTRY(user_inthandler)
307 SAVE_ALL_INT
308 GET_CURRENT(%d0)
309 movel %d0,%a1
310 addqb #1,%a1@(TINFO_PREEMPT+1)
311 | put exception # in d0
312 bfextu %sp@(PT_OFF_FORMATVEC){#4,#10},%d0
313user_irqvec_fixup = . + 2
314 subw #VEC_USER,%d0
315
316 movel %sp,%sp@-
317 movel %d0,%sp@- | put vector # on stack
318 jsr do_IRQ | process the IRQ
319 addql #8,%sp | pop parameters off stack
320
321 movel %curptr@(TASK_STACK),%a1
322 subqb #1,%a1@(TINFO_PREEMPT+1)
323 jeq ret_from_last_interrupt
324 RESTORE_ALL
325
326/* Handler for uninitialized and spurious interrupts */
327
328ENTRY(bad_inthandler)
329 SAVE_ALL_INT
330 GET_CURRENT(%d0)
331 movel %d0,%a1
332 addqb #1,%a1@(TINFO_PREEMPT+1)
333
334 movel %sp,%sp@-
335 jsr handle_badint
336 addql #4,%sp
337
338 movel %curptr@(TASK_STACK),%a1
339 subqb #1,%a1@(TINFO_PREEMPT+1)
340 jeq ret_from_last_interrupt
341 RESTORE_ALL
342
343
344resume:
345 /*
346 * Beware - when entering resume, prev (the current task) is
347 * in a0, next (the new task) is in a1,so don't change these
348 * registers until their contents are no longer needed.
349 */
350
351 /* save sr */
352 movew %sr,%a0@(TASK_THREAD+THREAD_SR)
353
354 /* save fs (sfc,%dfc) (may be pointing to kernel memory) */
355 movec %sfc,%d0
356 movew %d0,%a0@(TASK_THREAD+THREAD_FS)
357
358 /* save usp */
359 /* it is better to use a movel here instead of a movew 8*) */
360 movec %usp,%d0
361 movel %d0,%a0@(TASK_THREAD+THREAD_USP)
362
363 /* save non-scratch registers on stack */
364 SAVE_SWITCH_STACK
365
366 /* save current kernel stack pointer */
367 movel %sp,%a0@(TASK_THREAD+THREAD_KSP)
368
369 /* save floating point context */
370#ifndef CONFIG_M68KFPU_EMU_ONLY
371#ifdef CONFIG_M68KFPU_EMU
372 tstl m68k_fputype
373 jeq 3f
374#endif
375 fsave %a0@(TASK_THREAD+THREAD_FPSTATE)
376
377#if defined(CONFIG_M68060)
378#if !defined(CPU_M68060_ONLY)
379 btst #3,m68k_cputype+3
380 beqs 1f
381#endif
382 /* The 060 FPU keeps status in bits 15-8 of the first longword */
383 tstb %a0@(TASK_THREAD+THREAD_FPSTATE+2)
384 jeq 3f
385#if !defined(CPU_M68060_ONLY)
386 jra 2f
387#endif
388#endif /* CONFIG_M68060 */
389#if !defined(CPU_M68060_ONLY)
3901: tstb %a0@(TASK_THREAD+THREAD_FPSTATE)
391 jeq 3f
392#endif
3932: fmovemx %fp0-%fp7,%a0@(TASK_THREAD+THREAD_FPREG)
394 fmoveml %fpcr/%fpsr/%fpiar,%a0@(TASK_THREAD+THREAD_FPCNTL)
3953:
396#endif /* CONFIG_M68KFPU_EMU_ONLY */
397 /* Return previous task in %d1 */
398 movel %curptr,%d1
399
400 /* switch to new task (a1 contains new task) */
401 movel %a1,%curptr
402
403 /* restore floating point context */
404#ifndef CONFIG_M68KFPU_EMU_ONLY
405#ifdef CONFIG_M68KFPU_EMU
406 tstl m68k_fputype
407 jeq 4f
408#endif
409#if defined(CONFIG_M68060)
410#if !defined(CPU_M68060_ONLY)
411 btst #3,m68k_cputype+3
412 beqs 1f
413#endif
414 /* The 060 FPU keeps status in bits 15-8 of the first longword */
415 tstb %a1@(TASK_THREAD+THREAD_FPSTATE+2)
416 jeq 3f
417#if !defined(CPU_M68060_ONLY)
418 jra 2f
419#endif
420#endif /* CONFIG_M68060 */
421#if !defined(CPU_M68060_ONLY)
4221: tstb %a1@(TASK_THREAD+THREAD_FPSTATE)
423 jeq 3f
5#endif 424#endif
4252: fmovemx %a1@(TASK_THREAD+THREAD_FPREG),%fp0-%fp7
426 fmoveml %a1@(TASK_THREAD+THREAD_FPCNTL),%fpcr/%fpsr/%fpiar
4273: frestore %a1@(TASK_THREAD+THREAD_FPSTATE)
4284:
429#endif /* CONFIG_M68KFPU_EMU_ONLY */
430
431 /* restore the kernel stack pointer */
432 movel %a1@(TASK_THREAD+THREAD_KSP),%sp
433
434 /* restore non-scratch registers */
435 RESTORE_SWITCH_STACK
436
437 /* restore user stack pointer */
438 movel %a1@(TASK_THREAD+THREAD_USP),%a0
439 movel %a0,%usp
440
441 /* restore fs (sfc,%dfc) */
442 movew %a1@(TASK_THREAD+THREAD_FS),%a0
443 movec %a0,%sfc
444 movec %a0,%dfc
445
446 /* restore status register */
447 movew %a1@(TASK_THREAD+THREAD_SR),%sr
448
449 rts
450
451#endif /* CONFIG_MMU && !CONFIG_COLDFIRE */
diff --git a/arch/m68k/kernel/entry_mm.S b/arch/m68k/kernel/entry_mm.S
deleted file mode 100644
index f29e73ca9db..00000000000
--- a/arch/m68k/kernel/entry_mm.S
+++ /dev/null
@@ -1,419 +0,0 @@
1/* -*- mode: asm -*-
2 *
3 * linux/arch/m68k/kernel/entry.S
4 *
5 * Copyright (C) 1991, 1992 Linus Torvalds
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file README.legal in the main directory of this archive
9 * for more details.
10 *
11 * Linux/m68k support by Hamish Macdonald
12 *
13 * 68060 fixes by Jesper Skov
14 *
15 */
16
17/*
18 * entry.S contains the system-call and fault low-level handling routines.
19 * This also contains the timer-interrupt handler, as well as all interrupts
20 * and faults that can result in a task-switch.
21 *
22 * NOTE: This code handles signal-recognition, which happens every time
23 * after a timer-interrupt and after each system call.
24 *
25 */
26
27/*
28 * 12/03/96 Jes: Currently we only support m68k single-cpu systems, so
29 * all pointers that used to be 'current' are now entry
30 * number 0 in the 'current_set' list.
31 *
32 * 6/05/00 RZ: addedd writeback completion after return from sighandler
33 * for 68040
34 */
35
36#include <linux/linkage.h>
37#include <asm/entry.h>
38#include <asm/errno.h>
39#include <asm/setup.h>
40#include <asm/segment.h>
41#include <asm/traps.h>
42#include <asm/unistd.h>
43
44#include <asm/asm-offsets.h>
45
46.globl system_call, buserr, trap, resume
47.globl sys_call_table
48.globl sys_fork, sys_clone, sys_vfork
49.globl ret_from_interrupt, bad_interrupt
50.globl auto_irqhandler_fixup
51.globl user_irqvec_fixup
52
53.text
54ENTRY(buserr)
55 SAVE_ALL_INT
56 GET_CURRENT(%d0)
57 movel %sp,%sp@- | stack frame pointer argument
58 bsrl buserr_c
59 addql #4,%sp
60 jra .Lret_from_exception
61
62ENTRY(trap)
63 SAVE_ALL_INT
64 GET_CURRENT(%d0)
65 movel %sp,%sp@- | stack frame pointer argument
66 bsrl trap_c
67 addql #4,%sp
68 jra .Lret_from_exception
69
70 | After a fork we jump here directly from resume,
71 | so that %d1 contains the previous task
72 | schedule_tail now used regardless of CONFIG_SMP
73ENTRY(ret_from_fork)
74 movel %d1,%sp@-
75 jsr schedule_tail
76 addql #4,%sp
77 jra .Lret_from_exception
78
79do_trace_entry:
80 movel #-ENOSYS,%sp@(PT_OFF_D0)| needed for strace
81 subql #4,%sp
82 SAVE_SWITCH_STACK
83 jbsr syscall_trace
84 RESTORE_SWITCH_STACK
85 addql #4,%sp
86 movel %sp@(PT_OFF_ORIG_D0),%d0
87 cmpl #NR_syscalls,%d0
88 jcs syscall
89badsys:
90 movel #-ENOSYS,%sp@(PT_OFF_D0)
91 jra ret_from_syscall
92
93do_trace_exit:
94 subql #4,%sp
95 SAVE_SWITCH_STACK
96 jbsr syscall_trace
97 RESTORE_SWITCH_STACK
98 addql #4,%sp
99 jra .Lret_from_exception
100
101ENTRY(ret_from_signal)
102 movel %curptr@(TASK_STACK),%a1
103 tstb %a1@(TINFO_FLAGS+2)
104 jge 1f
105 jbsr syscall_trace
1061: RESTORE_SWITCH_STACK
107 addql #4,%sp
108/* on 68040 complete pending writebacks if any */
109#ifdef CONFIG_M68040
110 bfextu %sp@(PT_OFF_FORMATVEC){#0,#4},%d0
111 subql #7,%d0 | bus error frame ?
112 jbne 1f
113 movel %sp,%sp@-
114 jbsr berr_040cleanup
115 addql #4,%sp
1161:
117#endif
118 jra .Lret_from_exception
119
120ENTRY(system_call)
121 SAVE_ALL_SYS
122
123 GET_CURRENT(%d1)
124 movel %d1,%a1
125
126 | save top of frame
127 movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0)
128
129 | syscall trace?
130 tstb %a1@(TINFO_FLAGS+2)
131 jmi do_trace_entry
132 cmpl #NR_syscalls,%d0
133 jcc badsys
134syscall:
135 jbsr @(sys_call_table,%d0:l:4)@(0)
136 movel %d0,%sp@(PT_OFF_D0) | save the return value
137ret_from_syscall:
138 |oriw #0x0700,%sr
139 movel %curptr@(TASK_STACK),%a1
140 movew %a1@(TINFO_FLAGS+2),%d0
141 jne syscall_exit_work
1421: RESTORE_ALL
143
144syscall_exit_work:
145 btst #5,%sp@(PT_OFF_SR) | check if returning to kernel
146 bnes 1b | if so, skip resched, signals
147 lslw #1,%d0
148 jcs do_trace_exit
149 jmi do_delayed_trace
150 lslw #8,%d0
151 jne do_signal_return
152 pea resume_userspace
153 jra schedule
154
155
156ENTRY(ret_from_exception)
157.Lret_from_exception:
158 btst #5,%sp@(PT_OFF_SR) | check if returning to kernel
159 bnes 1f | if so, skip resched, signals
160 | only allow interrupts when we are really the last one on the
161 | kernel stack, otherwise stack overflow can occur during
162 | heavy interrupt load
163 andw #ALLOWINT,%sr
164
165resume_userspace:
166 movel %curptr@(TASK_STACK),%a1
167 moveb %a1@(TINFO_FLAGS+3),%d0
168 jne exit_work
1691: RESTORE_ALL
170
171exit_work:
172 | save top of frame
173 movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0)
174 lslb #1,%d0
175 jne do_signal_return
176 pea resume_userspace
177 jra schedule
178
179
180do_signal_return:
181 |andw #ALLOWINT,%sr
182 subql #4,%sp | dummy return address
183 SAVE_SWITCH_STACK
184 pea %sp@(SWITCH_STACK_SIZE)
185 bsrl do_notify_resume
186 addql #4,%sp
187 RESTORE_SWITCH_STACK
188 addql #4,%sp
189 jbra resume_userspace
190
191do_delayed_trace:
192 bclr #7,%sp@(PT_OFF_SR) | clear trace bit in SR
193 pea 1 | send SIGTRAP
194 movel %curptr,%sp@-
195 pea LSIGTRAP
196 jbsr send_sig
197 addql #8,%sp
198 addql #4,%sp
199 jbra resume_userspace
200
201
202/* This is the main interrupt handler for autovector interrupts */
203
204ENTRY(auto_inthandler)
205 SAVE_ALL_INT
206 GET_CURRENT(%d0)
207 movel %d0,%a1
208 addqb #1,%a1@(TINFO_PREEMPT+1)
209 | put exception # in d0
210 bfextu %sp@(PT_OFF_FORMATVEC){#4,#10},%d0
211 subw #VEC_SPUR,%d0
212
213 movel %sp,%sp@-
214 movel %d0,%sp@- | put vector # on stack
215auto_irqhandler_fixup = . + 2
216 jsr do_IRQ | process the IRQ
217 addql #8,%sp | pop parameters off stack
218
219ret_from_interrupt:
220 movel %curptr@(TASK_STACK),%a1
221 subqb #1,%a1@(TINFO_PREEMPT+1)
222 jeq ret_from_last_interrupt
2232: RESTORE_ALL
224
225 ALIGN
226ret_from_last_interrupt:
227 moveq #(~ALLOWINT>>8)&0xff,%d0
228 andb %sp@(PT_OFF_SR),%d0
229 jne 2b
230
231 /* check if we need to do software interrupts */
232 tstl irq_stat+CPUSTAT_SOFTIRQ_PENDING
233 jeq .Lret_from_exception
234 pea ret_from_exception
235 jra do_softirq
236
237/* Handler for user defined interrupt vectors */
238
239ENTRY(user_inthandler)
240 SAVE_ALL_INT
241 GET_CURRENT(%d0)
242 movel %d0,%a1
243 addqb #1,%a1@(TINFO_PREEMPT+1)
244 | put exception # in d0
245 bfextu %sp@(PT_OFF_FORMATVEC){#4,#10},%d0
246user_irqvec_fixup = . + 2
247 subw #VEC_USER,%d0
248
249 movel %sp,%sp@-
250 movel %d0,%sp@- | put vector # on stack
251 jsr do_IRQ | process the IRQ
252 addql #8,%sp | pop parameters off stack
253
254 movel %curptr@(TASK_STACK),%a1
255 subqb #1,%a1@(TINFO_PREEMPT+1)
256 jeq ret_from_last_interrupt
257 RESTORE_ALL
258
259/* Handler for uninitialized and spurious interrupts */
260
261ENTRY(bad_inthandler)
262 SAVE_ALL_INT
263 GET_CURRENT(%d0)
264 movel %d0,%a1
265 addqb #1,%a1@(TINFO_PREEMPT+1)
266
267 movel %sp,%sp@-
268 jsr handle_badint
269 addql #4,%sp
270
271 movel %curptr@(TASK_STACK),%a1
272 subqb #1,%a1@(TINFO_PREEMPT+1)
273 jeq ret_from_last_interrupt
274 RESTORE_ALL
275
276
277ENTRY(sys_fork)
278 SAVE_SWITCH_STACK
279 pea %sp@(SWITCH_STACK_SIZE)
280 jbsr m68k_fork
281 addql #4,%sp
282 RESTORE_SWITCH_STACK
283 rts
284
285ENTRY(sys_clone)
286 SAVE_SWITCH_STACK
287 pea %sp@(SWITCH_STACK_SIZE)
288 jbsr m68k_clone
289 addql #4,%sp
290 RESTORE_SWITCH_STACK
291 rts
292
293ENTRY(sys_vfork)
294 SAVE_SWITCH_STACK
295 pea %sp@(SWITCH_STACK_SIZE)
296 jbsr m68k_vfork
297 addql #4,%sp
298 RESTORE_SWITCH_STACK
299 rts
300
301ENTRY(sys_sigreturn)
302 SAVE_SWITCH_STACK
303 jbsr do_sigreturn
304 RESTORE_SWITCH_STACK
305 rts
306
307ENTRY(sys_rt_sigreturn)
308 SAVE_SWITCH_STACK
309 jbsr do_rt_sigreturn
310 RESTORE_SWITCH_STACK
311 rts
312
313resume:
314 /*
315 * Beware - when entering resume, prev (the current task) is
316 * in a0, next (the new task) is in a1,so don't change these
317 * registers until their contents are no longer needed.
318 */
319
320 /* save sr */
321 movew %sr,%a0@(TASK_THREAD+THREAD_SR)
322
323 /* save fs (sfc,%dfc) (may be pointing to kernel memory) */
324 movec %sfc,%d0
325 movew %d0,%a0@(TASK_THREAD+THREAD_FS)
326
327 /* save usp */
328 /* it is better to use a movel here instead of a movew 8*) */
329 movec %usp,%d0
330 movel %d0,%a0@(TASK_THREAD+THREAD_USP)
331
332 /* save non-scratch registers on stack */
333 SAVE_SWITCH_STACK
334
335 /* save current kernel stack pointer */
336 movel %sp,%a0@(TASK_THREAD+THREAD_KSP)
337
338 /* save floating point context */
339#ifndef CONFIG_M68KFPU_EMU_ONLY
340#ifdef CONFIG_M68KFPU_EMU
341 tstl m68k_fputype
342 jeq 3f
343#endif
344 fsave %a0@(TASK_THREAD+THREAD_FPSTATE)
345
346#if defined(CONFIG_M68060)
347#if !defined(CPU_M68060_ONLY)
348 btst #3,m68k_cputype+3
349 beqs 1f
350#endif
351 /* The 060 FPU keeps status in bits 15-8 of the first longword */
352 tstb %a0@(TASK_THREAD+THREAD_FPSTATE+2)
353 jeq 3f
354#if !defined(CPU_M68060_ONLY)
355 jra 2f
356#endif
357#endif /* CONFIG_M68060 */
358#if !defined(CPU_M68060_ONLY)
3591: tstb %a0@(TASK_THREAD+THREAD_FPSTATE)
360 jeq 3f
361#endif
3622: fmovemx %fp0-%fp7,%a0@(TASK_THREAD+THREAD_FPREG)
363 fmoveml %fpcr/%fpsr/%fpiar,%a0@(TASK_THREAD+THREAD_FPCNTL)
3643:
365#endif /* CONFIG_M68KFPU_EMU_ONLY */
366 /* Return previous task in %d1 */
367 movel %curptr,%d1
368
369 /* switch to new task (a1 contains new task) */
370 movel %a1,%curptr
371
372 /* restore floating point context */
373#ifndef CONFIG_M68KFPU_EMU_ONLY
374#ifdef CONFIG_M68KFPU_EMU
375 tstl m68k_fputype
376 jeq 4f
377#endif
378#if defined(CONFIG_M68060)
379#if !defined(CPU_M68060_ONLY)
380 btst #3,m68k_cputype+3
381 beqs 1f
382#endif
383 /* The 060 FPU keeps status in bits 15-8 of the first longword */
384 tstb %a1@(TASK_THREAD+THREAD_FPSTATE+2)
385 jeq 3f
386#if !defined(CPU_M68060_ONLY)
387 jra 2f
388#endif
389#endif /* CONFIG_M68060 */
390#if !defined(CPU_M68060_ONLY)
3911: tstb %a1@(TASK_THREAD+THREAD_FPSTATE)
392 jeq 3f
393#endif
3942: fmovemx %a1@(TASK_THREAD+THREAD_FPREG),%fp0-%fp7
395 fmoveml %a1@(TASK_THREAD+THREAD_FPCNTL),%fpcr/%fpsr/%fpiar
3963: frestore %a1@(TASK_THREAD+THREAD_FPSTATE)
3974:
398#endif /* CONFIG_M68KFPU_EMU_ONLY */
399
400 /* restore the kernel stack pointer */
401 movel %a1@(TASK_THREAD+THREAD_KSP),%sp
402
403 /* restore non-scratch registers */
404 RESTORE_SWITCH_STACK
405
406 /* restore user stack pointer */
407 movel %a1@(TASK_THREAD+THREAD_USP),%a0
408 movel %a0,%usp
409
410 /* restore fs (sfc,%dfc) */
411 movew %a1@(TASK_THREAD+THREAD_FS),%a0
412 movec %a0,%sfc
413 movec %a0,%dfc
414
415 /* restore status register */
416 movew %a1@(TASK_THREAD+THREAD_SR),%sr
417
418 rts
419
diff --git a/arch/m68k/kernel/entry_no.S b/arch/m68k/kernel/entry_no.S
deleted file mode 100644
index d80cba45589..00000000000
--- a/arch/m68k/kernel/entry_no.S
+++ /dev/null
@@ -1,130 +0,0 @@
1/*
2 * linux/arch/m68knommu/kernel/entry.S
3 *
4 * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
5 * Copyright (C) 1998 D. Jeff Dionne <jeff@lineo.ca>,
6 * Kenneth Albanowski <kjahds@kjahds.com>,
7 * Copyright (C) 2000 Lineo Inc. (www.lineo.com)
8 *
9 * Based on:
10 *
11 * linux/arch/m68k/kernel/entry.S
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 *
15 * This file is subject to the terms and conditions of the GNU General Public
16 * License. See the file README.legal in the main directory of this archive
17 * for more details.
18 *
19 * Linux/m68k support by Hamish Macdonald
20 *
21 * 68060 fixes by Jesper Skov
22 * ColdFire support by Greg Ungerer (gerg@snapgear.com)
23 * 5307 fixes by David W. Miller
24 * linux 2.4 support David McCullough <davidm@snapgear.com>
25 */
26
27#include <linux/linkage.h>
28#include <asm/errno.h>
29#include <asm/setup.h>
30#include <asm/segment.h>
31#include <asm/asm-offsets.h>
32#include <asm/entry.h>
33#include <asm/unistd.h>
34
35.text
36
37.globl buserr
38.globl trap
39.globl ret_from_exception
40.globl ret_from_signal
41.globl sys_fork
42.globl sys_clone
43.globl sys_vfork
44
45ENTRY(buserr)
46 SAVE_ALL_INT
47 GET_CURRENT(%d0)
48 movel %sp,%sp@- /* stack frame pointer argument */
49 jsr buserr_c
50 addql #4,%sp
51 jra ret_from_exception
52
53ENTRY(trap)
54 SAVE_ALL_INT
55 GET_CURRENT(%d0)
56 movel %sp,%sp@- /* stack frame pointer argument */
57 jsr trap_c
58 addql #4,%sp
59 jra ret_from_exception
60
61#ifdef TRAP_DBG_INTERRUPT
62
63.globl dbginterrupt
64ENTRY(dbginterrupt)
65 SAVE_ALL_INT
66 GET_CURRENT(%d0)
67 movel %sp,%sp@- /* stack frame pointer argument */
68 jsr dbginterrupt_c
69 addql #4,%sp
70 jra ret_from_exception
71#endif
72
73ENTRY(reschedule)
74 /* save top of frame */
75 pea %sp@
76 jbsr set_esp0
77 addql #4,%sp
78 pea ret_from_exception
79 jmp schedule
80
81ENTRY(ret_from_fork)
82 movel %d1,%sp@-
83 jsr schedule_tail
84 addql #4,%sp
85 jra ret_from_exception
86
87ENTRY(sys_fork)
88 SAVE_SWITCH_STACK
89 pea %sp@(SWITCH_STACK_SIZE)
90 jbsr m68k_fork
91 addql #4,%sp
92 RESTORE_SWITCH_STACK
93 rts
94
95ENTRY(sys_vfork)
96 SAVE_SWITCH_STACK
97 pea %sp@(SWITCH_STACK_SIZE)
98 jbsr m68k_vfork
99 addql #4,%sp
100 RESTORE_SWITCH_STACK
101 rts
102
103ENTRY(sys_clone)
104 SAVE_SWITCH_STACK
105 pea %sp@(SWITCH_STACK_SIZE)
106 jbsr m68k_clone
107 addql #4,%sp
108 RESTORE_SWITCH_STACK
109 rts
110
111ENTRY(sys_sigreturn)
112 SAVE_SWITCH_STACK
113 jbsr do_sigreturn
114 RESTORE_SWITCH_STACK
115 rts
116
117ENTRY(sys_rt_sigreturn)
118 SAVE_SWITCH_STACK
119 jbsr do_rt_sigreturn
120 RESTORE_SWITCH_STACK
121 rts
122
123ENTRY(ret_from_user_signal)
124 moveq #__NR_sigreturn,%d0
125 trap #0
126
127ENTRY(ret_from_user_rt_signal)
128 movel #__NR_rt_sigreturn,%d0
129 trap #0
130
diff --git a/arch/m68k/kernel/module.c b/arch/m68k/kernel/module.c
index 34849c4c6e3..eb46fd6038c 100644
--- a/arch/m68k/kernel/module.c
+++ b/arch/m68k/kernel/module.c
@@ -47,7 +47,7 @@ int apply_relocate(Elf32_Shdr *sechdrs,
47 *location += sym->st_value; 47 *location += sym->st_value;
48 break; 48 break;
49 case R_68K_PC32: 49 case R_68K_PC32:
50 /* Add the value, subtract its postition */ 50 /* Add the value, subtract its position */
51 *location += sym->st_value - (uint32_t)location; 51 *location += sym->st_value - (uint32_t)location;
52 break; 52 break;
53 default: 53 default:
@@ -87,7 +87,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
87 *location = rel[i].r_addend + sym->st_value; 87 *location = rel[i].r_addend + sym->st_value;
88 break; 88 break;
89 case R_68K_PC32: 89 case R_68K_PC32:
90 /* Add the value, subtract its postition */ 90 /* Add the value, subtract its position */
91 *location = rel[i].r_addend + sym->st_value - (uint32_t)location; 91 *location = rel[i].r_addend + sym->st_value - (uint32_t)location;
92 break; 92 break;
93 default: 93 default:
diff --git a/arch/m68k/kernel/pcibios.c b/arch/m68k/kernel/pcibios.c
new file mode 100644
index 00000000000..b2988aa1840
--- /dev/null
+++ b/arch/m68k/kernel/pcibios.c
@@ -0,0 +1,109 @@
1/*
2 * pci.c -- basic PCI support code
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * (C) Copyright 2011, Greg Ungerer <gerg@uclinux.org>
10 */
11
12#include <linux/kernel.h>
13#include <linux/types.h>
14#include <linux/mm.h>
15#include <linux/init.h>
16#include <linux/pci.h>
17
18/*
19 * From arch/i386/kernel/pci-i386.c:
20 *
21 * We need to avoid collisions with `mirrored' VGA ports
22 * and other strange ISA hardware, so we always want the
23 * addresses to be allocated in the 0x000-0x0ff region
24 * modulo 0x400.
25 *
26 * Why? Because some silly external IO cards only decode
27 * the low 10 bits of the IO address. The 0x00-0xff region
28 * is reserved for motherboard devices that decode all 16
29 * bits, so it's ok to allocate at, say, 0x2800-0x28ff,
30 * but we want to try to avoid allocating at 0x2900-0x2bff
31 * which might be mirrored at 0x0100-0x03ff..
32 */
33resource_size_t pcibios_align_resource(void *data, const struct resource *res,
34 resource_size_t size, resource_size_t align)
35{
36 resource_size_t start = res->start;
37
38 if ((res->flags & IORESOURCE_IO) && (start & 0x300))
39 start = (start + 0x3ff) & ~0x3ff;
40
41 start = (start + align - 1) & ~(align - 1);
42
43 return start;
44}
45
46/*
47 * This is taken from the ARM code for this.
48 */
49int pcibios_enable_device(struct pci_dev *dev, int mask)
50{
51 struct resource *r;
52 u16 cmd, newcmd;
53 int idx;
54
55 pci_read_config_word(dev, PCI_COMMAND, &cmd);
56 newcmd = cmd;
57
58 for (idx = 0; idx < 6; idx++) {
59 /* Only set up the requested stuff */
60 if (!(mask & (1 << idx)))
61 continue;
62
63 r = dev->resource + idx;
64 if (!r->start && r->end) {
65 pr_err(KERN_ERR "PCI: Device %s not available because of resource collisions\n",
66 pci_name(dev));
67 return -EINVAL;
68 }
69 if (r->flags & IORESOURCE_IO)
70 newcmd |= PCI_COMMAND_IO;
71 if (r->flags & IORESOURCE_MEM)
72 newcmd |= PCI_COMMAND_MEMORY;
73 }
74
75 /*
76 * Bridges (eg, cardbus bridges) need to be fully enabled
77 */
78 if ((dev->class >> 16) == PCI_BASE_CLASS_BRIDGE)
79 newcmd |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
80
81
82 if (newcmd != cmd) {
83 pr_info("PCI: enabling device %s (0x%04x -> 0x%04x)\n",
84 pci_name(dev), cmd, newcmd);
85 pci_write_config_word(dev, PCI_COMMAND, newcmd);
86 }
87 return 0;
88}
89
90void pcibios_update_irq(struct pci_dev *dev, int irq)
91{
92 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
93}
94
95void __devinit pcibios_fixup_bus(struct pci_bus *bus)
96{
97 struct pci_dev *dev;
98
99 list_for_each_entry(dev, &bus->devices, bus_list) {
100 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 8);
101 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 32);
102 }
103}
104
105char __devinit *pcibios_setup(char *str)
106{
107 return str;
108}
109
diff --git a/arch/m68k/kernel/setup_no.c b/arch/m68k/kernel/setup_no.c
index 7dc186b7a85..71fb29938db 100644
--- a/arch/m68k/kernel/setup_no.c
+++ b/arch/m68k/kernel/setup_no.c
@@ -218,13 +218,10 @@ void __init setup_arch(char **cmdline_p)
218 printk(KERN_INFO "Motorola M5235EVB support (C)2005 Syn-tech Systems, Inc. (Jate Sujjavanich)\n"); 218 printk(KERN_INFO "Motorola M5235EVB support (C)2005 Syn-tech Systems, Inc. (Jate Sujjavanich)\n");
219#endif 219#endif
220 220
221 pr_debug("KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x " 221 pr_debug("KERNEL -> TEXT=0x%p-0x%p DATA=0x%p-0x%p BSS=0x%p-0x%p\n",
222 "BSS=0x%06x-0x%06x\n", (int) &_stext, (int) &_etext, 222 _stext, _etext, _sdata, _edata, __bss_start, __bss_stop);
223 (int) &_sdata, (int) &_edata, 223 pr_debug("MEMORY -> ROMFS=0x%p-0x%06lx MEM=0x%06lx-0x%06lx\n ",
224 (int) &_sbss, (int) &_ebss); 224 __bss_stop, memory_start, memory_start, memory_end);
225 pr_debug("MEMORY -> ROMFS=0x%06x-0x%06x MEM=0x%06x-0x%06x\n ",
226 (int) &_ebss, (int) memory_start,
227 (int) memory_start, (int) memory_end);
228 225
229 /* Keep a copy of command line */ 226 /* Keep a copy of command line */
230 *cmdline_p = &command_line[0]; 227 *cmdline_p = &command_line[0];
diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c
index 8623f8dc16f..9a5932ec368 100644
--- a/arch/m68k/kernel/sys_m68k.c
+++ b/arch/m68k/kernel/sys_m68k.c
@@ -479,9 +479,13 @@ sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5,
479 goto bad_access; 479 goto bad_access;
480 } 480 }
481 481
482 mem_value = *mem; 482 /*
483 * No need to check for EFAULT; we know that the page is
484 * present and writable.
485 */
486 __get_user(mem_value, mem);
483 if (mem_value == oldval) 487 if (mem_value == oldval)
484 *mem = newval; 488 __put_user(newval, mem);
485 489
486 pte_unmap_unlock(pte, ptl); 490 pte_unmap_unlock(pte, ptl);
487 up_read(&mm->mmap_sem); 491 up_read(&mm->mmap_sem);
diff --git a/arch/m68k/kernel/vmlinux-nommu.lds b/arch/m68k/kernel/vmlinux-nommu.lds
index 40e02d9c38b..06a763f49fd 100644
--- a/arch/m68k/kernel/vmlinux-nommu.lds
+++ b/arch/m68k/kernel/vmlinux-nommu.lds
@@ -78,9 +78,7 @@ SECTIONS {
78 __init_end = .; 78 __init_end = .;
79 } 79 }
80 80
81 _sbss = .;
82 BSS_SECTION(0, 0, 0) 81 BSS_SECTION(0, 0, 0)
83 _ebss = .;
84 82
85 _end = .; 83 _end = .;
86 84
diff --git a/arch/m68k/kernel/vmlinux-std.lds b/arch/m68k/kernel/vmlinux-std.lds
index 63407c83682..d0993594f55 100644
--- a/arch/m68k/kernel/vmlinux-std.lds
+++ b/arch/m68k/kernel/vmlinux-std.lds
@@ -31,9 +31,7 @@ SECTIONS
31 31
32 RW_DATA_SECTION(16, PAGE_SIZE, THREAD_SIZE) 32 RW_DATA_SECTION(16, PAGE_SIZE, THREAD_SIZE)
33 33
34 _sbss = .;
35 BSS_SECTION(0, 0, 0) 34 BSS_SECTION(0, 0, 0)
36 _ebss = .;
37 35
38 _edata = .; /* End of data section */ 36 _edata = .; /* End of data section */
39 37
diff --git a/arch/m68k/kernel/vmlinux-sun3.lds b/arch/m68k/kernel/vmlinux-sun3.lds
index ad0f46d64c0..8080469ee6c 100644
--- a/arch/m68k/kernel/vmlinux-sun3.lds
+++ b/arch/m68k/kernel/vmlinux-sun3.lds
@@ -44,9 +44,7 @@ __init_begin = .;
44 . = ALIGN(PAGE_SIZE); 44 . = ALIGN(PAGE_SIZE);
45 __init_end = .; 45 __init_end = .;
46 46
47 _sbss = .;
48 BSS_SECTION(0, 0, 0) 47 BSS_SECTION(0, 0, 0)
49 _ebss = .;
50 48
51 _end = . ; 49 _end = . ;
52 50
diff --git a/arch/m68k/lib/muldi3.c b/arch/m68k/lib/muldi3.c
index 79e928a525d..ee5f0b1b5c5 100644
--- a/arch/m68k/lib/muldi3.c
+++ b/arch/m68k/lib/muldi3.c
@@ -19,7 +19,7 @@ along with GNU CC; see the file COPYING. If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330, 19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA. */ 20Boston, MA 02111-1307, USA. */
21 21
22#if defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE) 22#ifdef CONFIG_CPU_HAS_NO_MULDIV64
23 23
24#define SI_TYPE_SIZE 32 24#define SI_TYPE_SIZE 32
25#define __BITS4 (SI_TYPE_SIZE / 4) 25#define __BITS4 (SI_TYPE_SIZE / 4)
diff --git a/arch/m68k/mm/init_mm.c b/arch/m68k/mm/init_mm.c
index f77f258dce3..282f9de6896 100644
--- a/arch/m68k/mm/init_mm.c
+++ b/arch/m68k/mm/init_mm.c
@@ -104,7 +104,7 @@ void __init print_memmap(void)
104 MLK_ROUNDUP(__init_begin, __init_end), 104 MLK_ROUNDUP(__init_begin, __init_end),
105 MLK_ROUNDUP(_stext, _etext), 105 MLK_ROUNDUP(_stext, _etext),
106 MLK_ROUNDUP(_sdata, _edata), 106 MLK_ROUNDUP(_sdata, _edata),
107 MLK_ROUNDUP(_sbss, _ebss)); 107 MLK_ROUNDUP(__bss_start, __bss_stop));
108} 108}
109 109
110void __init mem_init(void) 110void __init mem_init(void)
diff --git a/arch/m68k/mm/init_no.c b/arch/m68k/mm/init_no.c
index 345ec0d83e3..688e3664aea 100644
--- a/arch/m68k/mm/init_no.c
+++ b/arch/m68k/mm/init_no.c
@@ -91,7 +91,7 @@ void __init mem_init(void)
91 totalram_pages = free_all_bootmem(); 91 totalram_pages = free_all_bootmem();
92 92
93 codek = (_etext - _stext) >> 10; 93 codek = (_etext - _stext) >> 10;
94 datak = (_ebss - _sdata) >> 10; 94 datak = (__bss_stop - _sdata) >> 10;
95 initk = (__init_begin - __init_end) >> 10; 95 initk = (__init_begin - __init_end) >> 10;
96 96
97 tmp = nr_free_pages() << PAGE_SHIFT; 97 tmp = nr_free_pages() << PAGE_SHIFT;
diff --git a/arch/m68k/mm/memory.c b/arch/m68k/mm/memory.c
index 250b8b786f4..51bc9d258ed 100644
--- a/arch/m68k/mm/memory.c
+++ b/arch/m68k/mm/memory.c
@@ -203,7 +203,7 @@ static inline void pushcl040(unsigned long paddr)
203void cache_clear (unsigned long paddr, int len) 203void cache_clear (unsigned long paddr, int len)
204{ 204{
205 if (CPU_IS_COLDFIRE) { 205 if (CPU_IS_COLDFIRE) {
206 flush_cf_bcache(0, DCACHE_MAX_ADDR); 206 clear_cf_bcache(0, DCACHE_MAX_ADDR);
207 } else if (CPU_IS_040_OR_060) { 207 } else if (CPU_IS_040_OR_060) {
208 int tmp; 208 int tmp;
209 209
diff --git a/arch/m68k/platform/68328/head-de2.S b/arch/m68k/platform/68328/head-de2.S
index f632fdcb93e..537d3245b53 100644
--- a/arch/m68k/platform/68328/head-de2.S
+++ b/arch/m68k/platform/68328/head-de2.S
@@ -60,8 +60,8 @@ _start:
60 * Move ROM filesystem above bss :-) 60 * Move ROM filesystem above bss :-)
61 */ 61 */
62 62
63 moveal #_sbss, %a0 /* romfs at the start of bss */ 63 moveal #__bss_start, %a0 /* romfs at the start of bss */
64 moveal #_ebss, %a1 /* Set up destination */ 64 moveal #__bss_stop, %a1 /* Set up destination */
65 movel %a0, %a2 /* Copy of bss start */ 65 movel %a0, %a2 /* Copy of bss start */
66 66
67 movel 8(%a0), %d1 /* Get size of ROMFS */ 67 movel 8(%a0), %d1 /* Get size of ROMFS */
@@ -84,8 +84,8 @@ _start:
84 * Initialize BSS segment to 0 84 * Initialize BSS segment to 0
85 */ 85 */
86 86
87 lea _sbss, %a0 87 lea __bss_start, %a0
88 lea _ebss, %a1 88 lea __bss_stop, %a1
89 89
90 /* Copy 0 to %a0 until %a0 == %a1 */ 90 /* Copy 0 to %a0 until %a0 == %a1 */
912: cmpal %a0, %a1 912: cmpal %a0, %a1
diff --git a/arch/m68k/platform/68328/head-pilot.S b/arch/m68k/platform/68328/head-pilot.S
index 2ebfd642081..45a9dad29e3 100644
--- a/arch/m68k/platform/68328/head-pilot.S
+++ b/arch/m68k/platform/68328/head-pilot.S
@@ -110,7 +110,7 @@ L0:
110 movel #CONFIG_VECTORBASE, %d7 110 movel #CONFIG_VECTORBASE, %d7
111 addl #16, %d7 111 addl #16, %d7
112 moveal %d7, %a0 112 moveal %d7, %a0
113 moveal #_ebss, %a1 113 moveal #__bss_stop, %a1
114 lea %a1@(512), %a2 114 lea %a1@(512), %a2
115 115
116 DBG_PUTC('C') 116 DBG_PUTC('C')
@@ -138,8 +138,8 @@ LD1:
138 138
139 DBG_PUTC('E') 139 DBG_PUTC('E')
140 140
141 moveal #_sbss, %a0 141 moveal #__bss_start, %a0
142 moveal #_ebss, %a1 142 moveal #__bss_stop, %a1
143 143
144 /* Copy 0 to %a0 until %a0 == %a1 */ 144 /* Copy 0 to %a0 until %a0 == %a1 */
145L1: 145L1:
@@ -150,7 +150,7 @@ L1:
150 DBG_PUTC('F') 150 DBG_PUTC('F')
151 151
152 /* Copy command line from end of bss to command line */ 152 /* Copy command line from end of bss to command line */
153 moveal #_ebss, %a0 153 moveal #__bss_stop, %a0
154 moveal #command_line, %a1 154 moveal #command_line, %a1
155 lea %a1@(512), %a2 155 lea %a1@(512), %a2
156 156
@@ -165,7 +165,7 @@ L3:
165 165
166 movel #_sdata, %d0 166 movel #_sdata, %d0
167 movel %d0, _rambase 167 movel %d0, _rambase
168 movel #_ebss, %d0 168 movel #__bss_stop, %d0
169 movel %d0, _ramstart 169 movel %d0, _ramstart
170 170
171 movel %a4, %d0 171 movel %a4, %d0
diff --git a/arch/m68k/platform/68328/head-ram.S b/arch/m68k/platform/68328/head-ram.S
index 7f1aeeacb21..5189ef92609 100644
--- a/arch/m68k/platform/68328/head-ram.S
+++ b/arch/m68k/platform/68328/head-ram.S
@@ -76,8 +76,8 @@ pclp3:
76 beq pclp3 76 beq pclp3
77#endif /* DEBUG */ 77#endif /* DEBUG */
78 moveal #0x007ffff0, %ssp 78 moveal #0x007ffff0, %ssp
79 moveal #_sbss, %a0 79 moveal #__bss_start, %a0
80 moveal #_ebss, %a1 80 moveal #__bss_stop, %a1
81 81
82 /* Copy 0 to %a0 until %a0 >= %a1 */ 82 /* Copy 0 to %a0 until %a0 >= %a1 */
83L1: 83L1:
diff --git a/arch/m68k/platform/68328/head-rom.S b/arch/m68k/platform/68328/head-rom.S
index a5ff96d0295..3dff98ba2e9 100644
--- a/arch/m68k/platform/68328/head-rom.S
+++ b/arch/m68k/platform/68328/head-rom.S
@@ -59,8 +59,8 @@ _stext: movew #0x2700,%sr
59 cmpal %a1, %a2 59 cmpal %a1, %a2
60 bhi 1b 60 bhi 1b
61 61
62 moveal #_sbss, %a0 62 moveal #__bss_start, %a0
63 moveal #_ebss, %a1 63 moveal #__bss_stop, %a1
64 /* Copy 0 to %a0 until %a0 == %a1 */ 64 /* Copy 0 to %a0 until %a0 == %a1 */
65 65
661: 661:
@@ -70,7 +70,7 @@ _stext: movew #0x2700,%sr
70 70
71 movel #_sdata, %d0 71 movel #_sdata, %d0
72 movel %d0, _rambase 72 movel %d0, _rambase
73 movel #_ebss, %d0 73 movel #__bss_stop, %d0
74 movel %d0, _ramstart 74 movel %d0, _ramstart
75 movel #RAMEND-CONFIG_MEMORY_RESERVE*0x100000, %d0 75 movel #RAMEND-CONFIG_MEMORY_RESERVE*0x100000, %d0
76 movel %d0, _ramend 76 movel %d0, _ramend
diff --git a/arch/m68k/platform/68360/head-ram.S b/arch/m68k/platform/68360/head-ram.S
index 8eb94fb6b97..acd213170d8 100644
--- a/arch/m68k/platform/68360/head-ram.S
+++ b/arch/m68k/platform/68360/head-ram.S
@@ -219,8 +219,8 @@ LD1:
219 cmp.l #_edata, %a1 219 cmp.l #_edata, %a1
220 blt LD1 220 blt LD1
221 221
222 moveal #_sbss, %a0 222 moveal #__bss_start, %a0
223 moveal #_ebss, %a1 223 moveal #__bss_stop, %a1
224 224
225 /* Copy 0 to %a0 until %a0 == %a1 */ 225 /* Copy 0 to %a0 until %a0 == %a1 */
226L1: 226L1:
@@ -234,7 +234,7 @@ load_quicc:
234store_ram_size: 234store_ram_size:
235 /* Set ram size information */ 235 /* Set ram size information */
236 move.l #_sdata, _rambase 236 move.l #_sdata, _rambase
237 move.l #_ebss, _ramstart 237 move.l #__bss_stop, _ramstart
238 move.l #RAMEND, %d0 238 move.l #RAMEND, %d0
239 sub.l #0x1000, %d0 /* Reserve 4K for stack space.*/ 239 sub.l #0x1000, %d0 /* Reserve 4K for stack space.*/
240 move.l %d0, _ramend /* Different from RAMEND.*/ 240 move.l %d0, _ramend /* Different from RAMEND.*/
diff --git a/arch/m68k/platform/68360/head-rom.S b/arch/m68k/platform/68360/head-rom.S
index 97510e55b80..dfc756d9988 100644
--- a/arch/m68k/platform/68360/head-rom.S
+++ b/arch/m68k/platform/68360/head-rom.S
@@ -13,7 +13,7 @@
13 */ 13 */
14 14
15.global _stext 15.global _stext
16.global _sbss 16.global __bss_start
17.global _start 17.global _start
18 18
19.global _rambase 19.global _rambase
@@ -229,8 +229,8 @@ LD1:
229 cmp.l #_edata, %a1 229 cmp.l #_edata, %a1
230 blt LD1 230 blt LD1
231 231
232 moveal #_sbss, %a0 232 moveal #__bss_start, %a0
233 moveal #_ebss, %a1 233 moveal #__bss_stop, %a1
234 234
235 /* Copy 0 to %a0 until %a0 == %a1 */ 235 /* Copy 0 to %a0 until %a0 == %a1 */
236L1: 236L1:
@@ -244,7 +244,7 @@ load_quicc:
244store_ram_size: 244store_ram_size:
245 /* Set ram size information */ 245 /* Set ram size information */
246 move.l #_sdata, _rambase 246 move.l #_sdata, _rambase
247 move.l #_ebss, _ramstart 247 move.l #__bss_stop, _ramstart
248 move.l #RAMEND, %d0 248 move.l #RAMEND, %d0
249 sub.l #0x1000, %d0 /* Reserve 4K for stack space.*/ 249 sub.l #0x1000, %d0 /* Reserve 4K for stack space.*/
250 move.l %d0, _ramend /* Different from RAMEND.*/ 250 move.l %d0, _ramend /* Different from RAMEND.*/
diff --git a/arch/m68k/platform/coldfire/Makefile b/arch/m68k/platform/coldfire/Makefile
index 76d389d9a84..02591a109f8 100644
--- a/arch/m68k/platform/coldfire/Makefile
+++ b/arch/m68k/platform/coldfire/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_M5206e) += m5206.o timers.o intc.o reset.o
20obj-$(CONFIG_M520x) += m520x.o pit.o intc-simr.o reset.o 20obj-$(CONFIG_M520x) += m520x.o pit.o intc-simr.o reset.o
21obj-$(CONFIG_M523x) += m523x.o pit.o dma_timer.o intc-2.o reset.o 21obj-$(CONFIG_M523x) += m523x.o pit.o dma_timer.o intc-2.o reset.o
22obj-$(CONFIG_M5249) += m5249.o timers.o intc.o intc-5249.o reset.o 22obj-$(CONFIG_M5249) += m5249.o timers.o intc.o intc-5249.o reset.o
23obj-$(CONFIG_M525x) += m525x.o timers.o intc.o intc-525x.o reset.o
23obj-$(CONFIG_M527x) += m527x.o pit.o intc-2.o reset.o 24obj-$(CONFIG_M527x) += m527x.o pit.o intc-2.o reset.o
24obj-$(CONFIG_M5272) += m5272.o intc-5272.o timers.o 25obj-$(CONFIG_M5272) += m5272.o intc-5272.o timers.o
25obj-$(CONFIG_M528x) += m528x.o pit.o intc-2.o reset.o 26obj-$(CONFIG_M528x) += m528x.o pit.o intc-2.o reset.o
@@ -27,10 +28,14 @@ obj-$(CONFIG_M5307) += m5307.o timers.o intc.o reset.o
27obj-$(CONFIG_M532x) += m532x.o timers.o intc-simr.o reset.o 28obj-$(CONFIG_M532x) += m532x.o timers.o intc-simr.o reset.o
28obj-$(CONFIG_M5407) += m5407.o timers.o intc.o reset.o 29obj-$(CONFIG_M5407) += m5407.o timers.o intc.o reset.o
29obj-$(CONFIG_M54xx) += m54xx.o sltimers.o intc-2.o 30obj-$(CONFIG_M54xx) += m54xx.o sltimers.o intc-2.o
31obj-$(CONFIG_M5441x) += m5441x.o pit.o intc-simr.o reset.o
30 32
31obj-$(CONFIG_NETtel) += nettel.o 33obj-$(CONFIG_NETtel) += nettel.o
32obj-$(CONFIG_CLEOPATRA) += nettel.o 34obj-$(CONFIG_CLEOPATRA) += nettel.o
33obj-$(CONFIG_FIREBEE) += firebee.o 35obj-$(CONFIG_FIREBEE) += firebee.o
36obj-$(CONFIG_MCF8390) += mcf8390.o
34 37
35obj-y += pinmux.o gpio.o 38obj-$(CONFIG_PCI) += pci.o
39
40obj-y += gpio.o
36extra-y := head.o 41extra-y := head.o
diff --git a/arch/m68k/platform/coldfire/clk.c b/arch/m68k/platform/coldfire/clk.c
index 44da406897e..75f9ee967ea 100644
--- a/arch/m68k/platform/coldfire/clk.c
+++ b/arch/m68k/platform/coldfire/clk.c
@@ -10,11 +10,17 @@
10 10
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/platform_device.h>
14#include <linux/mutex.h>
13#include <linux/clk.h> 15#include <linux/clk.h>
16#include <linux/io.h>
17#include <linux/err.h>
14#include <asm/coldfire.h> 18#include <asm/coldfire.h>
19#include <asm/mcfsim.h>
20#include <asm/mcfclk.h>
15 21
16/***************************************************************************/ 22/***************************************************************************/
17 23#ifndef MCFPM_PPMCR0
18struct clk *clk_get(struct device *dev, const char *id) 24struct clk *clk_get(struct device *dev, const char *id)
19{ 25{
20 return NULL; 26 return NULL;
@@ -42,11 +48,107 @@ unsigned long clk_get_rate(struct clk *clk)
42 return MCF_CLK; 48 return MCF_CLK;
43} 49}
44EXPORT_SYMBOL(clk_get_rate); 50EXPORT_SYMBOL(clk_get_rate);
51#else
52static DEFINE_SPINLOCK(clk_lock);
53
54struct clk *clk_get(struct device *dev, const char *id)
55{
56 const char *clk_name = dev ? dev_name(dev) : id ? id : NULL;
57 struct clk *clk;
58 unsigned i;
59
60 for (i = 0; (clk = mcf_clks[i]) != NULL; ++i)
61 if (!strcmp(clk->name, clk_name))
62 return clk;
63 pr_warn("clk_get: didn't find clock %s\n", clk_name);
64 return ERR_PTR(-ENOENT);
65}
66EXPORT_SYMBOL(clk_get);
67
68int clk_enable(struct clk *clk)
69{
70 unsigned long flags;
71 spin_lock_irqsave(&clk_lock, flags);
72 if ((clk->enabled++ == 0) && clk->clk_ops)
73 clk->clk_ops->enable(clk);
74 spin_unlock_irqrestore(&clk_lock, flags);
75
76 return 0;
77}
78EXPORT_SYMBOL(clk_enable);
79
80void clk_disable(struct clk *clk)
81{
82 unsigned long flags;
83 spin_lock_irqsave(&clk_lock, flags);
84 if ((--clk->enabled == 0) && clk->clk_ops)
85 clk->clk_ops->disable(clk);
86 spin_unlock_irqrestore(&clk_lock, flags);
87}
88EXPORT_SYMBOL(clk_disable);
89
90void clk_put(struct clk *clk)
91{
92 if (clk->enabled != 0)
93 pr_warn("clk_put %s still enabled\n", clk->name);
94}
95EXPORT_SYMBOL(clk_put);
96
97unsigned long clk_get_rate(struct clk *clk)
98{
99 return clk->rate;
100}
101EXPORT_SYMBOL(clk_get_rate);
102
103/***************************************************************************/
104
105void __clk_init_enabled(struct clk *clk)
106{
107 clk->enabled = 1;
108 clk->clk_ops->enable(clk);
109}
110
111void __clk_init_disabled(struct clk *clk)
112{
113 clk->enabled = 0;
114 clk->clk_ops->disable(clk);
115}
116
117static void __clk_enable0(struct clk *clk)
118{
119 __raw_writeb(clk->slot, MCFPM_PPMCR0);
120}
121
122static void __clk_disable0(struct clk *clk)
123{
124 __raw_writeb(clk->slot, MCFPM_PPMSR0);
125}
126
127struct clk_ops clk_ops0 = {
128 .enable = __clk_enable0,
129 .disable = __clk_disable0,
130};
131
132#ifdef MCFPM_PPMCR1
133static void __clk_enable1(struct clk *clk)
134{
135 __raw_writeb(clk->slot, MCFPM_PPMCR1);
136}
137
138static void __clk_disable1(struct clk *clk)
139{
140 __raw_writeb(clk->slot, MCFPM_PPMSR1);
141}
142
143struct clk_ops clk_ops1 = {
144 .enable = __clk_enable1,
145 .disable = __clk_disable1,
146};
147#endif /* MCFPM_PPMCR1 */
148#endif /* MCFPM_PPMCR0 */
45 149
46struct clk *devm_clk_get(struct device *dev, const char *id) 150struct clk *devm_clk_get(struct device *dev, const char *id)
47{ 151{
48 return NULL; 152 return NULL;
49} 153}
50EXPORT_SYMBOL(devm_clk_get); 154EXPORT_SYMBOL(devm_clk_get);
51
52/***************************************************************************/
diff --git a/arch/m68k/platform/coldfire/device.c b/arch/m68k/platform/coldfire/device.c
index 3aa77ddea89..81f0fb5e51c 100644
--- a/arch/m68k/platform/coldfire/device.c
+++ b/arch/m68k/platform/coldfire/device.c
@@ -13,6 +13,7 @@
13#include <linux/io.h> 13#include <linux/io.h>
14#include <linux/spi/spi.h> 14#include <linux/spi/spi.h>
15#include <linux/gpio.h> 15#include <linux/gpio.h>
16#include <linux/fec.h>
16#include <asm/traps.h> 17#include <asm/traps.h>
17#include <asm/coldfire.h> 18#include <asm/coldfire.h>
18#include <asm/mcfsim.h> 19#include <asm/mcfsim.h>
@@ -20,7 +21,7 @@
20#include <asm/mcfqspi.h> 21#include <asm/mcfqspi.h>
21 22
22/* 23/*
23 * All current ColdFire parts contain from 2, 3 or 4 UARTS. 24 * All current ColdFire parts contain from 2, 3, 4 or 10 UARTS.
24 */ 25 */
25static struct mcf_platform_uart mcf_uart_platform_data[] = { 26static struct mcf_platform_uart mcf_uart_platform_data[] = {
26 { 27 {
@@ -43,6 +44,42 @@ static struct mcf_platform_uart mcf_uart_platform_data[] = {
43 .irq = MCF_IRQ_UART3, 44 .irq = MCF_IRQ_UART3,
44 }, 45 },
45#endif 46#endif
47#ifdef MCFUART_BASE4
48 {
49 .mapbase = MCFUART_BASE4,
50 .irq = MCF_IRQ_UART4,
51 },
52#endif
53#ifdef MCFUART_BASE5
54 {
55 .mapbase = MCFUART_BASE5,
56 .irq = MCF_IRQ_UART5,
57 },
58#endif
59#ifdef MCFUART_BASE6
60 {
61 .mapbase = MCFUART_BASE6,
62 .irq = MCF_IRQ_UART6,
63 },
64#endif
65#ifdef MCFUART_BASE7
66 {
67 .mapbase = MCFUART_BASE7,
68 .irq = MCF_IRQ_UART7,
69 },
70#endif
71#ifdef MCFUART_BASE8
72 {
73 .mapbase = MCFUART_BASE8,
74 .irq = MCF_IRQ_UART8,
75 },
76#endif
77#ifdef MCFUART_BASE9
78 {
79 .mapbase = MCFUART_BASE9,
80 .irq = MCF_IRQ_UART9,
81 },
82#endif
46 { }, 83 { },
47}; 84};
48 85
@@ -53,6 +90,18 @@ static struct platform_device mcf_uart = {
53}; 90};
54 91
55#ifdef CONFIG_FEC 92#ifdef CONFIG_FEC
93
94#ifdef CONFIG_M5441x
95#define FEC_NAME "enet-fec"
96static struct fec_platform_data fec_pdata = {
97 .phy = PHY_INTERFACE_MODE_RMII,
98};
99#define FEC_PDATA (&fec_pdata)
100#else
101#define FEC_NAME "fec"
102#define FEC_PDATA NULL
103#endif
104
56/* 105/*
57 * Some ColdFire cores contain the Fast Ethernet Controller (FEC) 106 * Some ColdFire cores contain the Fast Ethernet Controller (FEC)
58 * block. It is Freescale's own hardware block. Some ColdFires 107 * block. It is Freescale's own hardware block. Some ColdFires
@@ -82,10 +131,11 @@ static struct resource mcf_fec0_resources[] = {
82}; 131};
83 132
84static struct platform_device mcf_fec0 = { 133static struct platform_device mcf_fec0 = {
85 .name = "fec", 134 .name = FEC_NAME,
86 .id = 0, 135 .id = 0,
87 .num_resources = ARRAY_SIZE(mcf_fec0_resources), 136 .num_resources = ARRAY_SIZE(mcf_fec0_resources),
88 .resource = mcf_fec0_resources, 137 .resource = mcf_fec0_resources,
138 .dev.platform_data = FEC_PDATA,
89}; 139};
90 140
91#ifdef MCFFEC_BASE1 141#ifdef MCFFEC_BASE1
@@ -113,10 +163,11 @@ static struct resource mcf_fec1_resources[] = {
113}; 163};
114 164
115static struct platform_device mcf_fec1 = { 165static struct platform_device mcf_fec1 = {
116 .name = "fec", 166 .name = FEC_NAME,
117 .id = 1, 167 .id = 1,
118 .num_resources = ARRAY_SIZE(mcf_fec1_resources), 168 .num_resources = ARRAY_SIZE(mcf_fec1_resources),
119 .resource = mcf_fec1_resources, 169 .resource = mcf_fec1_resources,
170 .dev.platform_data = FEC_PDATA,
120}; 171};
121#endif /* MCFFEC_BASE1 */ 172#endif /* MCFFEC_BASE1 */
122#endif /* CONFIG_FEC */ 173#endif /* CONFIG_FEC */
diff --git a/arch/m68k/platform/coldfire/gpio.c b/arch/m68k/platform/coldfire/gpio.c
index 4c8c42450a4..9cd2b5c7051 100644
--- a/arch/m68k/platform/coldfire/gpio.c
+++ b/arch/m68k/platform/coldfire/gpio.c
@@ -14,119 +14,161 @@
14 */ 14 */
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/module.h>
17#include <linux/init.h> 18#include <linux/init.h>
18#include <linux/device.h> 19#include <linux/device.h>
19 20
20#include <asm/gpio.h> 21#include <linux/io.h>
21#include <asm/pinmux.h> 22#include <asm/coldfire.h>
23#include <asm/mcfsim.h>
22#include <asm/mcfgpio.h> 24#include <asm/mcfgpio.h>
23 25
24#define MCF_CHIP(chip) container_of(chip, struct mcf_gpio_chip, gpio_chip) 26int __mcfgpio_get_value(unsigned gpio)
27{
28 return mcfgpio_read(__mcfgpio_ppdr(gpio)) & mcfgpio_bit(gpio);
29}
30EXPORT_SYMBOL(__mcfgpio_get_value);
31
32void __mcfgpio_set_value(unsigned gpio, int value)
33{
34 if (gpio < MCFGPIO_SCR_START) {
35 unsigned long flags;
36 MCFGPIO_PORTTYPE data;
37
38 local_irq_save(flags);
39 data = mcfgpio_read(__mcfgpio_podr(gpio));
40 if (value)
41 data |= mcfgpio_bit(gpio);
42 else
43 data &= ~mcfgpio_bit(gpio);
44 mcfgpio_write(data, __mcfgpio_podr(gpio));
45 local_irq_restore(flags);
46 } else {
47 if (value)
48 mcfgpio_write(mcfgpio_bit(gpio),
49 MCFGPIO_SETR_PORT(gpio));
50 else
51 mcfgpio_write(~mcfgpio_bit(gpio),
52 MCFGPIO_CLRR_PORT(gpio));
53 }
54}
55EXPORT_SYMBOL(__mcfgpio_set_value);
25 56
26int mcf_gpio_direction_input(struct gpio_chip *chip, unsigned offset) 57int __mcfgpio_direction_input(unsigned gpio)
27{ 58{
28 unsigned long flags; 59 unsigned long flags;
29 MCFGPIO_PORTTYPE dir; 60 MCFGPIO_PORTTYPE dir;
30 struct mcf_gpio_chip *mcf_chip = MCF_CHIP(chip);
31 61
32 local_irq_save(flags); 62 local_irq_save(flags);
33 dir = mcfgpio_read(mcf_chip->pddr); 63 dir = mcfgpio_read(__mcfgpio_pddr(gpio));
34 dir &= ~mcfgpio_bit(chip->base + offset); 64 dir &= ~mcfgpio_bit(gpio);
35 mcfgpio_write(dir, mcf_chip->pddr); 65 mcfgpio_write(dir, __mcfgpio_pddr(gpio));
36 local_irq_restore(flags); 66 local_irq_restore(flags);
37 67
38 return 0; 68 return 0;
39} 69}
70EXPORT_SYMBOL(__mcfgpio_direction_input);
40 71
41int mcf_gpio_get_value(struct gpio_chip *chip, unsigned offset) 72int __mcfgpio_direction_output(unsigned gpio, int value)
42{
43 struct mcf_gpio_chip *mcf_chip = MCF_CHIP(chip);
44
45 return mcfgpio_read(mcf_chip->ppdr) & mcfgpio_bit(chip->base + offset);
46}
47
48int mcf_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
49 int value)
50{ 73{
51 unsigned long flags; 74 unsigned long flags;
52 MCFGPIO_PORTTYPE data; 75 MCFGPIO_PORTTYPE data;
53 struct mcf_gpio_chip *mcf_chip = MCF_CHIP(chip);
54 76
55 local_irq_save(flags); 77 local_irq_save(flags);
56 /* write the value to the output latch */ 78 data = mcfgpio_read(__mcfgpio_pddr(gpio));
57 data = mcfgpio_read(mcf_chip->podr);
58 if (value) 79 if (value)
59 data |= mcfgpio_bit(chip->base + offset); 80 data |= mcfgpio_bit(gpio);
60 else 81 else
61 data &= ~mcfgpio_bit(chip->base + offset); 82 data &= mcfgpio_bit(gpio);
62 mcfgpio_write(data, mcf_chip->podr); 83 mcfgpio_write(data, __mcfgpio_pddr(gpio));
63 84
64 /* now set the direction to output */ 85 /* now set the data to output */
65 data = mcfgpio_read(mcf_chip->pddr); 86 if (gpio < MCFGPIO_SCR_START) {
66 data |= mcfgpio_bit(chip->base + offset); 87 data = mcfgpio_read(__mcfgpio_podr(gpio));
67 mcfgpio_write(data, mcf_chip->pddr); 88 if (value)
89 data |= mcfgpio_bit(gpio);
90 else
91 data &= ~mcfgpio_bit(gpio);
92 mcfgpio_write(data, __mcfgpio_podr(gpio));
93 } else {
94 if (value)
95 mcfgpio_write(mcfgpio_bit(gpio),
96 MCFGPIO_SETR_PORT(gpio));
97 else
98 mcfgpio_write(~mcfgpio_bit(gpio),
99 MCFGPIO_CLRR_PORT(gpio));
100 }
68 local_irq_restore(flags); 101 local_irq_restore(flags);
102 return 0;
103}
104EXPORT_SYMBOL(__mcfgpio_direction_output);
69 105
106int __mcfgpio_request(unsigned gpio)
107{
70 return 0; 108 return 0;
71} 109}
110EXPORT_SYMBOL(__mcfgpio_request);
72 111
73void mcf_gpio_set_value(struct gpio_chip *chip, unsigned offset, int value) 112void __mcfgpio_free(unsigned gpio)
74{ 113{
75 struct mcf_gpio_chip *mcf_chip = MCF_CHIP(chip); 114 __mcfgpio_direction_input(gpio);
115}
116EXPORT_SYMBOL(__mcfgpio_free);
76 117
77 unsigned long flags; 118#ifdef CONFIG_GPIOLIB
78 MCFGPIO_PORTTYPE data;
79 119
80 local_irq_save(flags); 120int mcfgpio_direction_input(struct gpio_chip *chip, unsigned offset)
81 data = mcfgpio_read(mcf_chip->podr); 121{
82 if (value) 122 return __mcfgpio_direction_input(offset);
83 data |= mcfgpio_bit(chip->base + offset);
84 else
85 data &= ~mcfgpio_bit(chip->base + offset);
86 mcfgpio_write(data, mcf_chip->podr);
87 local_irq_restore(flags);
88} 123}
89 124
90void mcf_gpio_set_value_fast(struct gpio_chip *chip, unsigned offset, int value) 125int mcfgpio_get_value(struct gpio_chip *chip, unsigned offset)
91{ 126{
92 struct mcf_gpio_chip *mcf_chip = MCF_CHIP(chip); 127 return __mcfgpio_get_value(offset);
93
94 if (value)
95 mcfgpio_write(mcfgpio_bit(chip->base + offset), mcf_chip->setr);
96 else
97 mcfgpio_write(~mcfgpio_bit(chip->base + offset), mcf_chip->clrr);
98} 128}
99 129
100int mcf_gpio_request(struct gpio_chip *chip, unsigned offset) 130int mcfgpio_direction_output(struct gpio_chip *chip, unsigned offset, int value)
101{ 131{
102 struct mcf_gpio_chip *mcf_chip = MCF_CHIP(chip); 132 return __mcfgpio_direction_output(offset, value);
103
104 return mcf_chip->gpio_to_pinmux ?
105 mcf_pinmux_request(mcf_chip->gpio_to_pinmux[offset], 0) : 0;
106} 133}
107 134
108void mcf_gpio_free(struct gpio_chip *chip, unsigned offset) 135void mcfgpio_set_value(struct gpio_chip *chip, unsigned offset, int value)
109{ 136{
110 struct mcf_gpio_chip *mcf_chip = MCF_CHIP(chip); 137 __mcfgpio_set_value(offset, value);
138}
111 139
112 mcf_gpio_direction_input(chip, offset); 140int mcfgpio_request(struct gpio_chip *chip, unsigned offset)
141{
142 return __mcfgpio_request(offset);
143}
113 144
114 if (mcf_chip->gpio_to_pinmux) 145void mcfgpio_free(struct gpio_chip *chip, unsigned offset)
115 mcf_pinmux_release(mcf_chip->gpio_to_pinmux[offset], 0); 146{
147 __mcfgpio_free(offset);
116} 148}
117 149
118struct bus_type mcf_gpio_subsys = { 150struct bus_type mcfgpio_subsys = {
119 .name = "gpio", 151 .name = "gpio",
120 .dev_name = "gpio", 152 .dev_name = "gpio",
121}; 153};
122 154
123static int __init mcf_gpio_sysinit(void) 155static struct gpio_chip mcfgpio_chip = {
124{ 156 .label = "mcfgpio",
125 unsigned int i = 0; 157 .request = mcfgpio_request,
158 .free = mcfgpio_free,
159 .direction_input = mcfgpio_direction_input,
160 .direction_output = mcfgpio_direction_output,
161 .get = mcfgpio_get_value,
162 .set = mcfgpio_set_value,
163 .base = 0,
164 .ngpio = MCFGPIO_PIN_MAX,
165};
126 166
127 while (i < mcf_gpio_chips_size) 167static int __init mcfgpio_sysinit(void)
128 gpiochip_add((struct gpio_chip *)&mcf_gpio_chips[i++]); 168{
129 return subsys_system_register(&mcf_gpio_subsys, NULL); 169 gpiochip_add(&mcfgpio_chip);
170 return subsys_system_register(&mcfgpio_subsys, NULL);
130} 171}
131 172
132core_initcall(mcf_gpio_sysinit); 173core_initcall(mcfgpio_sysinit);
174#endif
diff --git a/arch/m68k/platform/coldfire/head.S b/arch/m68k/platform/coldfire/head.S
index c3db70ed33b..b88f5716f35 100644
--- a/arch/m68k/platform/coldfire/head.S
+++ b/arch/m68k/platform/coldfire/head.S
@@ -31,9 +31,9 @@
31.endm 31.endm
32 32
33#elif defined(CONFIG_M5206) || defined(CONFIG_M5206e) || \ 33#elif defined(CONFIG_M5206) || defined(CONFIG_M5206e) || \
34 defined(CONFIG_M5249) || defined(CONFIG_M527x) || \ 34 defined(CONFIG_M5249) || defined(CONFIG_M525x) || \
35 defined(CONFIG_M528x) || defined(CONFIG_M5307) || \ 35 defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
36 defined(CONFIG_M5407) 36 defined(CONFIG_M5307) || defined(CONFIG_M5407)
37/* 37/*
38 * Not all these devices have exactly the same DRAM controller, 38 * Not all these devices have exactly the same DRAM controller,
39 * but the DCMR register is virtually identical - give or take 39 * but the DCMR register is virtually identical - give or take
@@ -230,8 +230,8 @@ _vstart:
230 /* 230 /*
231 * Move ROM filesystem above bss :-) 231 * Move ROM filesystem above bss :-)
232 */ 232 */
233 lea _sbss,%a0 /* get start of bss */ 233 lea __bss_start,%a0 /* get start of bss */
234 lea _ebss,%a1 /* set up destination */ 234 lea __bss_stop,%a1 /* set up destination */
235 movel %a0,%a2 /* copy of bss start */ 235 movel %a0,%a2 /* copy of bss start */
236 236
237 movel 8(%a0),%d0 /* get size of ROMFS */ 237 movel 8(%a0),%d0 /* get size of ROMFS */
@@ -249,7 +249,7 @@ _copy_romfs:
249 bne _copy_romfs 249 bne _copy_romfs
250 250
251#else /* CONFIG_ROMFS_FS */ 251#else /* CONFIG_ROMFS_FS */
252 lea _ebss,%a1 252 lea __bss_stop,%a1
253 movel %a1,_ramstart 253 movel %a1,_ramstart
254#endif /* CONFIG_ROMFS_FS */ 254#endif /* CONFIG_ROMFS_FS */
255 255
@@ -257,8 +257,8 @@ _copy_romfs:
257 /* 257 /*
258 * Zero out the bss region. 258 * Zero out the bss region.
259 */ 259 */
260 lea _sbss,%a0 /* get start of bss */ 260 lea __bss_start,%a0 /* get start of bss */
261 lea _ebss,%a1 /* get end of bss */ 261 lea __bss_stop,%a1 /* get end of bss */
262 clrl %d0 /* set value */ 262 clrl %d0 /* set value */
263_clear_bss: 263_clear_bss:
264 movel %d0,(%a0)+ /* clear each word */ 264 movel %d0,(%a0)+ /* clear each word */
diff --git a/arch/m68k/platform/coldfire/intc-525x.c b/arch/m68k/platform/coldfire/intc-525x.c
new file mode 100644
index 00000000000..b23204d059a
--- /dev/null
+++ b/arch/m68k/platform/coldfire/intc-525x.c
@@ -0,0 +1,91 @@
1/*
2 * intc2.c -- support for the 2nd INTC controller of the 525x
3 *
4 * (C) Copyright 2012, Steven King <sfking@fdwdc.com>
5 * (C) Copyright 2009, Greg Ungerer <gerg@snapgear.com>
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file COPYING in the main directory of this archive
9 * for more details.
10 */
11
12#include <linux/types.h>
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/interrupt.h>
16#include <linux/irq.h>
17#include <linux/io.h>
18#include <asm/coldfire.h>
19#include <asm/mcfsim.h>
20
21static void intc2_irq_gpio_mask(struct irq_data *d)
22{
23 u32 imr = readl(MCFSIM2_GPIOINTENABLE);
24 u32 type = irqd_get_trigger_type(d);
25 int irq = d->irq - MCF_IRQ_GPIO0;
26
27 if (type & IRQ_TYPE_EDGE_RISING)
28 imr &= ~(0x001 << irq);
29 if (type & IRQ_TYPE_EDGE_FALLING)
30 imr &= ~(0x100 << irq);
31 writel(imr, MCFSIM2_GPIOINTENABLE);
32}
33
34static void intc2_irq_gpio_unmask(struct irq_data *d)
35{
36 u32 imr = readl(MCFSIM2_GPIOINTENABLE);
37 u32 type = irqd_get_trigger_type(d);
38 int irq = d->irq - MCF_IRQ_GPIO0;
39
40 if (type & IRQ_TYPE_EDGE_RISING)
41 imr |= (0x001 << irq);
42 if (type & IRQ_TYPE_EDGE_FALLING)
43 imr |= (0x100 << irq);
44 writel(imr, MCFSIM2_GPIOINTENABLE);
45}
46
47static void intc2_irq_gpio_ack(struct irq_data *d)
48{
49 u32 imr = 0;
50 u32 type = irqd_get_trigger_type(d);
51 int irq = d->irq - MCF_IRQ_GPIO0;
52
53 if (type & IRQ_TYPE_EDGE_RISING)
54 imr |= (0x001 << irq);
55 if (type & IRQ_TYPE_EDGE_FALLING)
56 imr |= (0x100 << irq);
57 writel(imr, MCFSIM2_GPIOINTCLEAR);
58}
59
60static int intc2_irq_gpio_set_type(struct irq_data *d, unsigned int f)
61{
62 if (f & ~IRQ_TYPE_EDGE_BOTH)
63 return -EINVAL;
64 return 0;
65}
66
67static struct irq_chip intc2_irq_gpio_chip = {
68 .name = "CF-INTC2",
69 .irq_mask = intc2_irq_gpio_mask,
70 .irq_unmask = intc2_irq_gpio_unmask,
71 .irq_ack = intc2_irq_gpio_ack,
72 .irq_set_type = intc2_irq_gpio_set_type,
73};
74
75static int __init mcf_intc2_init(void)
76{
77 int irq;
78
79 /* set the interrupt base for the second interrupt controller */
80 writel(MCFINTC2_VECBASE, MCFINTC2_INTBASE);
81
82 /* GPIO interrupt sources */
83 for (irq = MCF_IRQ_GPIO0; (irq <= MCF_IRQ_GPIO6); irq++) {
84 irq_set_chip(irq, &intc2_irq_gpio_chip);
85 irq_set_handler(irq, handle_edge_irq);
86 }
87
88 return 0;
89}
90
91arch_initcall(mcf_intc2_init);
diff --git a/arch/m68k/platform/coldfire/intc-simr.c b/arch/m68k/platform/coldfire/intc-simr.c
index 650d52e2927..7cf2c156f72 100644
--- a/arch/m68k/platform/coldfire/intc-simr.c
+++ b/arch/m68k/platform/coldfire/intc-simr.c
@@ -59,16 +59,18 @@ static unsigned int inline irq2ebit(unsigned int irq)
59#endif 59#endif
60 60
61/* 61/*
62 * There maybe one or two interrupt control units, each has 64 62 * There maybe one, two or three interrupt control units, each has 64
63 * interrupts. If there is no second unit then MCFINTC1_* defines 63 * interrupts. If there is no second or third unit then MCFINTC1_* or
64 * will be 0 (and code for them optimized away). 64 * MCFINTC2_* defines will be 0 (and code for them optimized away).
65 */ 65 */
66 66
67static void intc_irq_mask(struct irq_data *d) 67static void intc_irq_mask(struct irq_data *d)
68{ 68{
69 unsigned int irq = d->irq - MCFINT_VECBASE; 69 unsigned int irq = d->irq - MCFINT_VECBASE;
70 70
71 if (MCFINTC1_SIMR && (irq > 64)) 71 if (MCFINTC2_SIMR && (irq > 128))
72 __raw_writeb(irq - 128, MCFINTC2_SIMR);
73 else if (MCFINTC1_SIMR && (irq > 64))
72 __raw_writeb(irq - 64, MCFINTC1_SIMR); 74 __raw_writeb(irq - 64, MCFINTC1_SIMR);
73 else 75 else
74 __raw_writeb(irq, MCFINTC0_SIMR); 76 __raw_writeb(irq, MCFINTC0_SIMR);
@@ -78,7 +80,9 @@ static void intc_irq_unmask(struct irq_data *d)
78{ 80{
79 unsigned int irq = d->irq - MCFINT_VECBASE; 81 unsigned int irq = d->irq - MCFINT_VECBASE;
80 82
81 if (MCFINTC1_CIMR && (irq > 64)) 83 if (MCFINTC2_CIMR && (irq > 128))
84 __raw_writeb(irq - 128, MCFINTC2_CIMR);
85 else if (MCFINTC1_CIMR && (irq > 64))
82 __raw_writeb(irq - 64, MCFINTC1_CIMR); 86 __raw_writeb(irq - 64, MCFINTC1_CIMR);
83 else 87 else
84 __raw_writeb(irq, MCFINTC0_CIMR); 88 __raw_writeb(irq, MCFINTC0_CIMR);
@@ -99,9 +103,11 @@ static unsigned int intc_irq_startup(struct irq_data *d)
99 unsigned int ebit = irq2ebit(irq); 103 unsigned int ebit = irq2ebit(irq);
100 u8 v; 104 u8 v;
101 105
106#if defined(MCFEPORT_EPDDR)
102 /* Set EPORT line as input */ 107 /* Set EPORT line as input */
103 v = __raw_readb(MCFEPORT_EPDDR); 108 v = __raw_readb(MCFEPORT_EPDDR);
104 __raw_writeb(v & ~(0x1 << ebit), MCFEPORT_EPDDR); 109 __raw_writeb(v & ~(0x1 << ebit), MCFEPORT_EPDDR);
110#endif
105 111
106 /* Set EPORT line as interrupt source */ 112 /* Set EPORT line as interrupt source */
107 v = __raw_readb(MCFEPORT_EPIER); 113 v = __raw_readb(MCFEPORT_EPIER);
@@ -109,12 +115,13 @@ static unsigned int intc_irq_startup(struct irq_data *d)
109 } 115 }
110 116
111 irq -= MCFINT_VECBASE; 117 irq -= MCFINT_VECBASE;
112 if (MCFINTC1_ICR0 && (irq > 64)) 118 if (MCFINTC2_ICR0 && (irq > 128))
119 __raw_writeb(5, MCFINTC2_ICR0 + irq - 128);
120 else if (MCFINTC1_ICR0 && (irq > 64))
113 __raw_writeb(5, MCFINTC1_ICR0 + irq - 64); 121 __raw_writeb(5, MCFINTC1_ICR0 + irq - 64);
114 else 122 else
115 __raw_writeb(5, MCFINTC0_ICR0 + irq); 123 __raw_writeb(5, MCFINTC0_ICR0 + irq);
116 124
117
118 intc_irq_unmask(d); 125 intc_irq_unmask(d);
119 return 0; 126 return 0;
120} 127}
@@ -175,8 +182,11 @@ void __init init_IRQ(void)
175 __raw_writeb(0xff, MCFINTC0_SIMR); 182 __raw_writeb(0xff, MCFINTC0_SIMR);
176 if (MCFINTC1_SIMR) 183 if (MCFINTC1_SIMR)
177 __raw_writeb(0xff, MCFINTC1_SIMR); 184 __raw_writeb(0xff, MCFINTC1_SIMR);
185 if (MCFINTC2_SIMR)
186 __raw_writeb(0xff, MCFINTC2_SIMR);
178 187
179 eirq = MCFINT_VECBASE + 64 + (MCFINTC1_ICR0 ? 64 : 0); 188 eirq = MCFINT_VECBASE + 64 + (MCFINTC1_ICR0 ? 64 : 0) +
189 (MCFINTC2_ICR0 ? 64 : 0);
180 for (irq = MCFINT_VECBASE; (irq < eirq); irq++) { 190 for (irq = MCFINT_VECBASE; (irq < eirq); irq++) {
181 if ((irq >= EINT1) && (irq <= EINT7)) 191 if ((irq >= EINT1) && (irq <= EINT7))
182 irq_set_chip(irq, &intc_irq_chip_edge_port); 192 irq_set_chip(irq, &intc_irq_chip_edge_port);
diff --git a/arch/m68k/platform/coldfire/m5206.c b/arch/m68k/platform/coldfire/m5206.c
index a8b81df653f..6bfbeebd231 100644
--- a/arch/m68k/platform/coldfire/m5206.c
+++ b/arch/m68k/platform/coldfire/m5206.c
@@ -16,15 +16,6 @@
16#include <asm/machdep.h> 16#include <asm/machdep.h>
17#include <asm/coldfire.h> 17#include <asm/coldfire.h>
18#include <asm/mcfsim.h> 18#include <asm/mcfsim.h>
19#include <asm/mcfgpio.h>
20
21/***************************************************************************/
22
23struct mcf_gpio_chip mcf_gpio_chips[] = {
24 MCFGPS(PP, 0, 8, MCFSIM_PADDR, MCFSIM_PADAT, MCFSIM_PADAT),
25};
26
27unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips);
28 19
29/***************************************************************************/ 20/***************************************************************************/
30 21
diff --git a/arch/m68k/platform/coldfire/m520x.c b/arch/m68k/platform/coldfire/m520x.c
index 3264b8883d5..ea1be0e98ad 100644
--- a/arch/m68k/platform/coldfire/m520x.c
+++ b/arch/m68k/platform/coldfire/m520x.c
@@ -19,22 +19,102 @@
19#include <asm/coldfire.h> 19#include <asm/coldfire.h>
20#include <asm/mcfsim.h> 20#include <asm/mcfsim.h>
21#include <asm/mcfuart.h> 21#include <asm/mcfuart.h>
22#include <asm/mcfgpio.h> 22#include <asm/mcfclk.h>
23 23
24/***************************************************************************/ 24/***************************************************************************/
25 25
26struct mcf_gpio_chip mcf_gpio_chips[] = { 26DEFINE_CLK(0, "flexbus", 2, MCF_CLK);
27 MCFGPS(PIRQ, 0, 8, MCFEPORT_EPDDR, MCFEPORT_EPDR, MCFEPORT_EPPDR), 27DEFINE_CLK(0, "fec.0", 12, MCF_CLK);
28 MCFGPF(CS, 9, 3), 28DEFINE_CLK(0, "edma", 17, MCF_CLK);
29 MCFGPF(FECI2C, 16, 4), 29DEFINE_CLK(0, "intc.0", 18, MCF_CLK);
30 MCFGPF(QSPI, 24, 4), 30DEFINE_CLK(0, "iack.0", 21, MCF_CLK);
31 MCFGPF(TIMER, 32, 4), 31DEFINE_CLK(0, "mcfi2c.0", 22, MCF_CLK);
32 MCFGPF(UART, 40, 8), 32DEFINE_CLK(0, "mcfqspi.0", 23, MCF_CLK);
33 MCFGPF(FECH, 48, 8), 33DEFINE_CLK(0, "mcfuart.0", 24, MCF_BUSCLK);
34 MCFGPF(FECL, 56, 8), 34DEFINE_CLK(0, "mcfuart.1", 25, MCF_BUSCLK);
35DEFINE_CLK(0, "mcfuart.2", 26, MCF_BUSCLK);
36DEFINE_CLK(0, "mcftmr.0", 28, MCF_CLK);
37DEFINE_CLK(0, "mcftmr.1", 29, MCF_CLK);
38DEFINE_CLK(0, "mcftmr.2", 30, MCF_CLK);
39DEFINE_CLK(0, "mcftmr.3", 31, MCF_CLK);
40
41DEFINE_CLK(0, "mcfpit.0", 32, MCF_CLK);
42DEFINE_CLK(0, "mcfpit.1", 33, MCF_CLK);
43DEFINE_CLK(0, "mcfeport.0", 34, MCF_CLK);
44DEFINE_CLK(0, "mcfwdt.0", 35, MCF_CLK);
45DEFINE_CLK(0, "pll.0", 36, MCF_CLK);
46DEFINE_CLK(0, "sys.0", 40, MCF_BUSCLK);
47DEFINE_CLK(0, "gpio.0", 41, MCF_BUSCLK);
48DEFINE_CLK(0, "sdram.0", 42, MCF_CLK);
49
50struct clk *mcf_clks[] = {
51 &__clk_0_2, /* flexbus */
52 &__clk_0_12, /* fec.0 */
53 &__clk_0_17, /* edma */
54 &__clk_0_18, /* intc.0 */
55 &__clk_0_21, /* iack.0 */
56 &__clk_0_22, /* mcfi2c.0 */
57 &__clk_0_23, /* mcfqspi.0 */
58 &__clk_0_24, /* mcfuart.0 */
59 &__clk_0_25, /* mcfuart.1 */
60 &__clk_0_26, /* mcfuart.2 */
61 &__clk_0_28, /* mcftmr.0 */
62 &__clk_0_29, /* mcftmr.1 */
63 &__clk_0_30, /* mcftmr.2 */
64 &__clk_0_31, /* mcftmr.3 */
65
66 &__clk_0_32, /* mcfpit.0 */
67 &__clk_0_33, /* mcfpit.1 */
68 &__clk_0_34, /* mcfeport.0 */
69 &__clk_0_35, /* mcfwdt.0 */
70 &__clk_0_36, /* pll.0 */
71 &__clk_0_40, /* sys.0 */
72 &__clk_0_41, /* gpio.0 */
73 &__clk_0_42, /* sdram.0 */
74NULL,
35}; 75};
36 76
37unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips); 77static struct clk * const enable_clks[] __initconst = {
78 &__clk_0_2, /* flexbus */
79 &__clk_0_18, /* intc.0 */
80 &__clk_0_21, /* iack.0 */
81 &__clk_0_24, /* mcfuart.0 */
82 &__clk_0_25, /* mcfuart.1 */
83 &__clk_0_26, /* mcfuart.2 */
84
85 &__clk_0_32, /* mcfpit.0 */
86 &__clk_0_33, /* mcfpit.1 */
87 &__clk_0_34, /* mcfeport.0 */
88 &__clk_0_36, /* pll.0 */
89 &__clk_0_40, /* sys.0 */
90 &__clk_0_41, /* gpio.0 */
91 &__clk_0_42, /* sdram.0 */
92};
93
94static struct clk * const disable_clks[] __initconst = {
95 &__clk_0_12, /* fec.0 */
96 &__clk_0_17, /* edma */
97 &__clk_0_22, /* mcfi2c.0 */
98 &__clk_0_23, /* mcfqspi.0 */
99 &__clk_0_28, /* mcftmr.0 */
100 &__clk_0_29, /* mcftmr.1 */
101 &__clk_0_30, /* mcftmr.2 */
102 &__clk_0_31, /* mcftmr.3 */
103 &__clk_0_35, /* mcfwdt.0 */
104};
105
106
107static void __init m520x_clk_init(void)
108{
109 unsigned i;
110
111 /* make sure these clocks are enabled */
112 for (i = 0; i < ARRAY_SIZE(enable_clks); ++i)
113 __clk_init_enabled(enable_clks[i]);
114 /* make sure these clocks are disabled */
115 for (i = 0; i < ARRAY_SIZE(disable_clks); ++i)
116 __clk_init_disabled(disable_clks[i]);
117}
38 118
39/***************************************************************************/ 119/***************************************************************************/
40 120
@@ -93,6 +173,7 @@ static void __init m520x_fec_init(void)
93void __init config_BSP(char *commandp, int size) 173void __init config_BSP(char *commandp, int size)
94{ 174{
95 mach_sched_init = hw_timer_init; 175 mach_sched_init = hw_timer_init;
176 m520x_clk_init();
96 m520x_uarts_init(); 177 m520x_uarts_init();
97 m520x_fec_init(); 178 m520x_fec_init();
98#if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) 179#if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
diff --git a/arch/m68k/platform/coldfire/m523x.c b/arch/m68k/platform/coldfire/m523x.c
index 5d57a424941..d47dfd8f50a 100644
--- a/arch/m68k/platform/coldfire/m523x.c
+++ b/arch/m68k/platform/coldfire/m523x.c
@@ -19,28 +19,6 @@
19#include <asm/machdep.h> 19#include <asm/machdep.h>
20#include <asm/coldfire.h> 20#include <asm/coldfire.h>
21#include <asm/mcfsim.h> 21#include <asm/mcfsim.h>
22#include <asm/mcfgpio.h>
23
24/***************************************************************************/
25
26struct mcf_gpio_chip mcf_gpio_chips[] = {
27 MCFGPS(PIRQ, 1, 7, MCFEPORT_EPDDR, MCFEPORT_EPDR, MCFEPORT_EPPDR),
28 MCFGPF(ADDR, 13, 3),
29 MCFGPF(DATAH, 16, 8),
30 MCFGPF(DATAL, 24, 8),
31 MCFGPF(BUSCTL, 32, 8),
32 MCFGPF(BS, 40, 4),
33 MCFGPF(CS, 49, 7),
34 MCFGPF(SDRAM, 56, 6),
35 MCFGPF(FECI2C, 64, 4),
36 MCFGPF(UARTH, 72, 2),
37 MCFGPF(UARTL, 80, 8),
38 MCFGPF(QSPI, 88, 5),
39 MCFGPF(TIMER, 96, 8),
40 MCFGPF(ETPU, 104, 3),
41};
42
43unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips);
44 22
45/***************************************************************************/ 23/***************************************************************************/
46 24
diff --git a/arch/m68k/platform/coldfire/m5249.c b/arch/m68k/platform/coldfire/m5249.c
index fdfa1edfd1a..300e729a58d 100644
--- a/arch/m68k/platform/coldfire/m5249.c
+++ b/arch/m68k/platform/coldfire/m5249.c
@@ -16,16 +16,6 @@
16#include <asm/machdep.h> 16#include <asm/machdep.h>
17#include <asm/coldfire.h> 17#include <asm/coldfire.h>
18#include <asm/mcfsim.h> 18#include <asm/mcfsim.h>
19#include <asm/mcfgpio.h>
20
21/***************************************************************************/
22
23struct mcf_gpio_chip mcf_gpio_chips[] = {
24 MCFGPS(GPIO0, 0, 32, MCFSIM2_GPIOENABLE, MCFSIM2_GPIOWRITE, MCFSIM2_GPIOREAD),
25 MCFGPS(GPIO1, 32, 32, MCFSIM2_GPIO1ENABLE, MCFSIM2_GPIO1WRITE, MCFSIM2_GPIO1READ),
26};
27
28unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips);
29 19
30/***************************************************************************/ 20/***************************************************************************/
31 21
diff --git a/arch/m68k/platform/coldfire/m525x.c b/arch/m68k/platform/coldfire/m525x.c
new file mode 100644
index 00000000000..8ce905f9b84
--- /dev/null
+++ b/arch/m68k/platform/coldfire/m525x.c
@@ -0,0 +1,66 @@
1/***************************************************************************/
2
3/*
4 * 525x.c
5 *
6 * Copyright (C) 2012, Steven King <sfking@fdwdc.com>
7 */
8
9/***************************************************************************/
10
11#include <linux/kernel.h>
12#include <linux/param.h>
13#include <linux/init.h>
14#include <linux/io.h>
15#include <linux/platform_device.h>
16#include <asm/machdep.h>
17#include <asm/coldfire.h>
18#include <asm/mcfsim.h>
19
20/***************************************************************************/
21
22static void __init m525x_qspi_init(void)
23{
24#if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
25 /* set the GPIO function for the qspi cs gpios */
26 /* FIXME: replace with pinmux/pinctl support */
27 u32 f = readl(MCFSIM2_GPIOFUNC);
28 f |= (1 << MCFQSPI_CS2) | (1 << MCFQSPI_CS1) | (1 << MCFQSPI_CS0);
29 writel(f, MCFSIM2_GPIOFUNC);
30
31 /* QSPI irq setup */
32 writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL4 | MCFSIM_ICR_PRI0,
33 MCF_MBAR + MCFSIM_QSPIICR);
34 mcf_mapirq2imr(MCF_IRQ_QSPI, MCFINTC_QSPI);
35#endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
36}
37
38static void __init m525x_i2c_init(void)
39{
40#if IS_ENABLED(CONFIG_I2C_COLDFIRE)
41 u32 r;
42
43 /* first I2C controller uses regular irq setup */
44 writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL5 | MCFSIM_ICR_PRI0,
45 MCF_MBAR + MCFSIM_I2CICR);
46 mcf_mapirq2imr(MCF_IRQ_I2C0, MCFINTC_I2C);
47
48 /* second I2C controller is completely different */
49 r = readl(MCFINTC2_INTPRI_REG(MCF_IRQ_I2C1));
50 r &= ~MCFINTC2_INTPRI_BITS(0xf, MCF_IRQ_I2C1);
51 r |= MCFINTC2_INTPRI_BITS(0x5, MCF_IRQ_I2C1);
52 writel(r, MCFINTC2_INTPRI_REG(MCF_IRQ_I2C1));
53#endif /* IS_ENABLED(CONFIG_I2C_COLDFIRE) */
54}
55
56/***************************************************************************/
57
58void __init config_BSP(char *commandp, int size)
59{
60 mach_sched_init = hw_timer_init;
61
62 m525x_qspi_init();
63 m525x_i2c_init();
64}
65
66/***************************************************************************/
diff --git a/arch/m68k/platform/coldfire/m5272.c b/arch/m68k/platform/coldfire/m5272.c
index 43e36060da1..e68bc7a148e 100644
--- a/arch/m68k/platform/coldfire/m5272.c
+++ b/arch/m68k/platform/coldfire/m5272.c
@@ -19,7 +19,6 @@
19#include <asm/coldfire.h> 19#include <asm/coldfire.h>
20#include <asm/mcfsim.h> 20#include <asm/mcfsim.h>
21#include <asm/mcfuart.h> 21#include <asm/mcfuart.h>
22#include <asm/mcfgpio.h>
23 22
24/***************************************************************************/ 23/***************************************************************************/
25 24
@@ -31,16 +30,6 @@ unsigned char ledbank = 0xff;
31 30
32/***************************************************************************/ 31/***************************************************************************/
33 32
34struct mcf_gpio_chip mcf_gpio_chips[] = {
35 MCFGPS(PA, 0, 16, MCFSIM_PADDR, MCFSIM_PADAT, MCFSIM_PADAT),
36 MCFGPS(PB, 16, 16, MCFSIM_PBDDR, MCFSIM_PBDAT, MCFSIM_PBDAT),
37 MCFGPS(Pc, 32, 16, MCFSIM_PCDDR, MCFSIM_PCDAT, MCFSIM_PCDAT),
38};
39
40unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips);
41
42/***************************************************************************/
43
44static void __init m5272_uarts_init(void) 33static void __init m5272_uarts_init(void)
45{ 34{
46 u32 v; 35 u32 v;
diff --git a/arch/m68k/platform/coldfire/m527x.c b/arch/m68k/platform/coldfire/m527x.c
index 9b0b66aabd1..b3cb378c5e9 100644
--- a/arch/m68k/platform/coldfire/m527x.c
+++ b/arch/m68k/platform/coldfire/m527x.c
@@ -20,49 +20,6 @@
20#include <asm/coldfire.h> 20#include <asm/coldfire.h>
21#include <asm/mcfsim.h> 21#include <asm/mcfsim.h>
22#include <asm/mcfuart.h> 22#include <asm/mcfuart.h>
23#include <asm/mcfgpio.h>
24
25/***************************************************************************/
26
27struct mcf_gpio_chip mcf_gpio_chips[] = {
28#if defined(CONFIG_M5271)
29 MCFGPS(PIRQ, 1, 7, MCFEPORT_EPDDR, MCFEPORT_EPDR, MCFEPORT_EPPDR),
30 MCFGPF(ADDR, 13, 3),
31 MCFGPF(DATAH, 16, 8),
32 MCFGPF(DATAL, 24, 8),
33 MCFGPF(BUSCTL, 32, 8),
34 MCFGPF(BS, 40, 4),
35 MCFGPF(CS, 49, 7),
36 MCFGPF(SDRAM, 56, 6),
37 MCFGPF(FECI2C, 64, 4),
38 MCFGPF(UARTH, 72, 2),
39 MCFGPF(UARTL, 80, 8),
40 MCFGPF(QSPI, 88, 5),
41 MCFGPF(TIMER, 96, 8),
42#elif defined(CONFIG_M5275)
43 MCFGPS(PIRQ, 1, 7, MCFEPORT_EPDDR, MCFEPORT_EPDR, MCFEPORT_EPPDR),
44 MCFGPF(BUSCTL, 8, 8),
45 MCFGPF(ADDR, 21, 3),
46 MCFGPF(CS, 25, 7),
47 MCFGPF(FEC0H, 32, 8),
48 MCFGPF(FEC0L, 40, 8),
49 MCFGPF(FECI2C, 48, 6),
50 MCFGPF(QSPI, 56, 7),
51 MCFGPF(SDRAM, 64, 8),
52 MCFGPF(TIMERH, 72, 4),
53 MCFGPF(TIMERL, 80, 4),
54 MCFGPF(UARTL, 88, 8),
55 MCFGPF(FEC1H, 96, 8),
56 MCFGPF(FEC1L, 104, 8),
57 MCFGPF(BS, 114, 2),
58 MCFGPF(IRQ, 121, 7),
59 MCFGPF(USBH, 128, 1),
60 MCFGPF(USBL, 136, 8),
61 MCFGPF(UARTH, 144, 4),
62#endif
63};
64
65unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips);
66 23
67/***************************************************************************/ 24/***************************************************************************/
68 25
diff --git a/arch/m68k/platform/coldfire/m528x.c b/arch/m68k/platform/coldfire/m528x.c
index 7ed1276b29d..f1319e5d254 100644
--- a/arch/m68k/platform/coldfire/m528x.c
+++ b/arch/m68k/platform/coldfire/m528x.c
@@ -21,37 +21,6 @@
21#include <asm/coldfire.h> 21#include <asm/coldfire.h>
22#include <asm/mcfsim.h> 22#include <asm/mcfsim.h>
23#include <asm/mcfuart.h> 23#include <asm/mcfuart.h>
24#include <asm/mcfgpio.h>
25
26/***************************************************************************/
27
28struct mcf_gpio_chip mcf_gpio_chips[] = {
29 MCFGPS(NQ, 1, 7, MCFEPORT_EPDDR, MCFEPORT_EPDR, MCFEPORT_EPPDR),
30 MCFGPS(TA, 8, 4, MCFGPTA_GPTDDR, MCFGPTA_GPTPORT, MCFGPTB_GPTPORT),
31 MCFGPS(TB, 16, 4, MCFGPTB_GPTDDR, MCFGPTB_GPTPORT, MCFGPTB_GPTPORT),
32 MCFGPS(QA, 24, 4, MCFQADC_DDRQA, MCFQADC_PORTQA, MCFQADC_PORTQA),
33 MCFGPS(QB, 32, 4, MCFQADC_DDRQB, MCFQADC_PORTQB, MCFQADC_PORTQB),
34 MCFGPF(A, 40, 8),
35 MCFGPF(B, 48, 8),
36 MCFGPF(C, 56, 8),
37 MCFGPF(D, 64, 8),
38 MCFGPF(E, 72, 8),
39 MCFGPF(F, 80, 8),
40 MCFGPF(G, 88, 8),
41 MCFGPF(H, 96, 8),
42 MCFGPF(J, 104, 8),
43 MCFGPF(DD, 112, 8),
44 MCFGPF(EH, 120, 8),
45 MCFGPF(EL, 128, 8),
46 MCFGPF(AS, 136, 6),
47 MCFGPF(QS, 144, 7),
48 MCFGPF(SD, 152, 6),
49 MCFGPF(TC, 160, 4),
50 MCFGPF(TD, 168, 4),
51 MCFGPF(UA, 176, 4),
52};
53
54unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips);
55 24
56/***************************************************************************/ 25/***************************************************************************/
57 26
@@ -74,7 +43,7 @@ static void __init m528x_uarts_init(void)
74 /* make sure PUAPAR is set for UART0 and UART1 */ 43 /* make sure PUAPAR is set for UART0 and UART1 */
75 port = readb(MCF5282_GPIO_PUAPAR); 44 port = readb(MCF5282_GPIO_PUAPAR);
76 port |= 0x03 | (0x03 << 2); 45 port |= 0x03 | (0x03 << 2);
77 writeb(port, MCF5282_GPIO_PUAPAR); 46 writeb(port, MCFGPIO_PUAPAR);
78} 47}
79 48
80/***************************************************************************/ 49/***************************************************************************/
diff --git a/arch/m68k/platform/coldfire/m5307.c b/arch/m68k/platform/coldfire/m5307.c
index 93b484976ab..a568d2870d1 100644
--- a/arch/m68k/platform/coldfire/m5307.c
+++ b/arch/m68k/platform/coldfire/m5307.c
@@ -16,7 +16,6 @@
16#include <asm/machdep.h> 16#include <asm/machdep.h>
17#include <asm/coldfire.h> 17#include <asm/coldfire.h>
18#include <asm/mcfsim.h> 18#include <asm/mcfsim.h>
19#include <asm/mcfgpio.h>
20#include <asm/mcfwdebug.h> 19#include <asm/mcfwdebug.h>
21 20
22/***************************************************************************/ 21/***************************************************************************/
@@ -29,14 +28,6 @@ unsigned char ledbank = 0xff;
29 28
30/***************************************************************************/ 29/***************************************************************************/
31 30
32struct mcf_gpio_chip mcf_gpio_chips[] = {
33 MCFGPS(PP, 0, 16, MCFSIM_PADDR, MCFSIM_PADAT, MCFSIM_PADAT),
34};
35
36unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips);
37
38/***************************************************************************/
39
40void __init config_BSP(char *commandp, int size) 31void __init config_BSP(char *commandp, int size)
41{ 32{
42#if defined(CONFIG_NETtel) || \ 33#if defined(CONFIG_NETtel) || \
diff --git a/arch/m68k/platform/coldfire/m532x.c b/arch/m68k/platform/coldfire/m532x.c
index 5394223639f..4819a44991e 100644
--- a/arch/m68k/platform/coldfire/m532x.c
+++ b/arch/m68k/platform/coldfire/m532x.c
@@ -26,32 +26,144 @@
26#include <asm/mcfsim.h> 26#include <asm/mcfsim.h>
27#include <asm/mcfuart.h> 27#include <asm/mcfuart.h>
28#include <asm/mcfdma.h> 28#include <asm/mcfdma.h>
29#include <asm/mcfgpio.h>
30#include <asm/mcfwdebug.h> 29#include <asm/mcfwdebug.h>
30#include <asm/mcfclk.h>
31 31
32/***************************************************************************/ 32/***************************************************************************/
33 33
34struct mcf_gpio_chip mcf_gpio_chips[] = { 34DEFINE_CLK(0, "flexbus", 2, MCF_CLK);
35 MCFGPS(PIRQ, 0, 8, MCFEPORT_EPDDR, MCFEPORT_EPDR, MCFEPORT_EPPDR), 35DEFINE_CLK(0, "mcfcan.0", 8, MCF_CLK);
36 MCFGPF(FECH, 8, 8), 36DEFINE_CLK(0, "fec.0", 12, MCF_CLK);
37 MCFGPF(FECL, 16, 8), 37DEFINE_CLK(0, "edma", 17, MCF_CLK);
38 MCFGPF(SSI, 24, 5), 38DEFINE_CLK(0, "intc.0", 18, MCF_CLK);
39 MCFGPF(BUSCTL, 32, 4), 39DEFINE_CLK(0, "intc.1", 19, MCF_CLK);
40 MCFGPF(BE, 40, 4), 40DEFINE_CLK(0, "iack.0", 21, MCF_CLK);
41 MCFGPF(CS, 49, 5), 41DEFINE_CLK(0, "mcfi2c.0", 22, MCF_CLK);
42 MCFGPF(PWM, 58, 4), 42DEFINE_CLK(0, "mcfqspi.0", 23, MCF_CLK);
43 MCFGPF(FECI2C, 64, 4), 43DEFINE_CLK(0, "mcfuart.0", 24, MCF_BUSCLK);
44 MCFGPF(UART, 72, 8), 44DEFINE_CLK(0, "mcfuart.1", 25, MCF_BUSCLK);
45 MCFGPF(QSPI, 80, 6), 45DEFINE_CLK(0, "mcfuart.2", 26, MCF_BUSCLK);
46 MCFGPF(TIMER, 88, 4), 46DEFINE_CLK(0, "mcftmr.0", 28, MCF_CLK);
47 MCFGPF(LCDDATAH, 96, 2), 47DEFINE_CLK(0, "mcftmr.1", 29, MCF_CLK);
48 MCFGPF(LCDDATAM, 104, 8), 48DEFINE_CLK(0, "mcftmr.2", 30, MCF_CLK);
49 MCFGPF(LCDDATAL, 112, 8), 49DEFINE_CLK(0, "mcftmr.3", 31, MCF_CLK);
50 MCFGPF(LCDCTLH, 120, 1), 50
51 MCFGPF(LCDCTLL, 128, 8), 51DEFINE_CLK(0, "mcfpit.0", 32, MCF_CLK);
52DEFINE_CLK(0, "mcfpit.1", 33, MCF_CLK);
53DEFINE_CLK(0, "mcfpit.2", 34, MCF_CLK);
54DEFINE_CLK(0, "mcfpit.3", 35, MCF_CLK);
55DEFINE_CLK(0, "mcfpwm.0", 36, MCF_CLK);
56DEFINE_CLK(0, "mcfeport.0", 37, MCF_CLK);
57DEFINE_CLK(0, "mcfwdt.0", 38, MCF_CLK);
58DEFINE_CLK(0, "sys.0", 40, MCF_BUSCLK);
59DEFINE_CLK(0, "gpio.0", 41, MCF_BUSCLK);
60DEFINE_CLK(0, "mcfrtc.0", 42, MCF_CLK);
61DEFINE_CLK(0, "mcflcd.0", 43, MCF_CLK);
62DEFINE_CLK(0, "mcfusb-otg.0", 44, MCF_CLK);
63DEFINE_CLK(0, "mcfusb-host.0", 45, MCF_CLK);
64DEFINE_CLK(0, "sdram.0", 46, MCF_CLK);
65DEFINE_CLK(0, "ssi.0", 47, MCF_CLK);
66DEFINE_CLK(0, "pll.0", 48, MCF_CLK);
67
68DEFINE_CLK(1, "mdha.0", 32, MCF_CLK);
69DEFINE_CLK(1, "skha.0", 33, MCF_CLK);
70DEFINE_CLK(1, "rng.0", 34, MCF_CLK);
71
72struct clk *mcf_clks[] = {
73 &__clk_0_2, /* flexbus */
74 &__clk_0_8, /* mcfcan.0 */
75 &__clk_0_12, /* fec.0 */
76 &__clk_0_17, /* edma */
77 &__clk_0_18, /* intc.0 */
78 &__clk_0_19, /* intc.1 */
79 &__clk_0_21, /* iack.0 */
80 &__clk_0_22, /* mcfi2c.0 */
81 &__clk_0_23, /* mcfqspi.0 */
82 &__clk_0_24, /* mcfuart.0 */
83 &__clk_0_25, /* mcfuart.1 */
84 &__clk_0_26, /* mcfuart.2 */
85 &__clk_0_28, /* mcftmr.0 */
86 &__clk_0_29, /* mcftmr.1 */
87 &__clk_0_30, /* mcftmr.2 */
88 &__clk_0_31, /* mcftmr.3 */
89
90 &__clk_0_32, /* mcfpit.0 */
91 &__clk_0_33, /* mcfpit.1 */
92 &__clk_0_34, /* mcfpit.2 */
93 &__clk_0_35, /* mcfpit.3 */
94 &__clk_0_36, /* mcfpwm.0 */
95 &__clk_0_37, /* mcfeport.0 */
96 &__clk_0_38, /* mcfwdt.0 */
97 &__clk_0_40, /* sys.0 */
98 &__clk_0_41, /* gpio.0 */
99 &__clk_0_42, /* mcfrtc.0 */
100 &__clk_0_43, /* mcflcd.0 */
101 &__clk_0_44, /* mcfusb-otg.0 */
102 &__clk_0_45, /* mcfusb-host.0 */
103 &__clk_0_46, /* sdram.0 */
104 &__clk_0_47, /* ssi.0 */
105 &__clk_0_48, /* pll.0 */
106
107 &__clk_1_32, /* mdha.0 */
108 &__clk_1_33, /* skha.0 */
109 &__clk_1_34, /* rng.0 */
110 NULL,
111};
112
113static struct clk * const enable_clks[] __initconst = {
114 &__clk_0_2, /* flexbus */
115 &__clk_0_18, /* intc.0 */
116 &__clk_0_19, /* intc.1 */
117 &__clk_0_21, /* iack.0 */
118 &__clk_0_24, /* mcfuart.0 */
119 &__clk_0_25, /* mcfuart.1 */
120 &__clk_0_26, /* mcfuart.2 */
121
122 &__clk_0_32, /* mcfpit.0 */
123 &__clk_0_33, /* mcfpit.1 */
124 &__clk_0_37, /* mcfeport.0 */
125 &__clk_0_40, /* sys.0 */
126 &__clk_0_41, /* gpio.0 */
127 &__clk_0_46, /* sdram.0 */
128 &__clk_0_48, /* pll.0 */
129};
130
131static struct clk * const disable_clks[] __initconst = {
132 &__clk_0_8, /* mcfcan.0 */
133 &__clk_0_12, /* fec.0 */
134 &__clk_0_17, /* edma */
135 &__clk_0_22, /* mcfi2c.0 */
136 &__clk_0_23, /* mcfqspi.0 */
137 &__clk_0_28, /* mcftmr.0 */
138 &__clk_0_29, /* mcftmr.1 */
139 &__clk_0_30, /* mcftmr.2 */
140 &__clk_0_31, /* mcftmr.3 */
141 &__clk_0_34, /* mcfpit.2 */
142 &__clk_0_35, /* mcfpit.3 */
143 &__clk_0_36, /* mcfpwm.0 */
144 &__clk_0_38, /* mcfwdt.0 */
145 &__clk_0_42, /* mcfrtc.0 */
146 &__clk_0_43, /* mcflcd.0 */
147 &__clk_0_44, /* mcfusb-otg.0 */
148 &__clk_0_45, /* mcfusb-host.0 */
149 &__clk_0_47, /* ssi.0 */
150 &__clk_1_32, /* mdha.0 */
151 &__clk_1_33, /* skha.0 */
152 &__clk_1_34, /* rng.0 */
52}; 153};
53 154
54unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips); 155
156static void __init m532x_clk_init(void)
157{
158 unsigned i;
159
160 /* make sure these clocks are enabled */
161 for (i = 0; i < ARRAY_SIZE(enable_clks); ++i)
162 __clk_init_enabled(enable_clks[i]);
163 /* make sure these clocks are disabled */
164 for (i = 0; i < ARRAY_SIZE(disable_clks); ++i)
165 __clk_init_disabled(disable_clks[i]);
166}
55 167
56/***************************************************************************/ 168/***************************************************************************/
57 169
@@ -98,8 +210,8 @@ void __init config_BSP(char *commandp, int size)
98 memset(commandp, 0, size); 210 memset(commandp, 0, size);
99 } 211 }
100#endif 212#endif
101
102 mach_sched_init = hw_timer_init; 213 mach_sched_init = hw_timer_init;
214 m532x_clk_init();
103 m532x_uarts_init(); 215 m532x_uarts_init();
104 m532x_fec_init(); 216 m532x_fec_init();
105#if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) 217#if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
diff --git a/arch/m68k/platform/coldfire/m5407.c b/arch/m68k/platform/coldfire/m5407.c
index faa6680b340..bb6c746ae81 100644
--- a/arch/m68k/platform/coldfire/m5407.c
+++ b/arch/m68k/platform/coldfire/m5407.c
@@ -16,15 +16,6 @@
16#include <asm/machdep.h> 16#include <asm/machdep.h>
17#include <asm/coldfire.h> 17#include <asm/coldfire.h>
18#include <asm/mcfsim.h> 18#include <asm/mcfsim.h>
19#include <asm/mcfgpio.h>
20
21/***************************************************************************/
22
23struct mcf_gpio_chip mcf_gpio_chips[] = {
24 MCFGPS(PP, 0, 16, MCFSIM_PADDR, MCFSIM_PADAT, MCFSIM_PADAT),
25};
26
27unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips);
28 19
29/***************************************************************************/ 20/***************************************************************************/
30 21
diff --git a/arch/m68k/platform/coldfire/m5441x.c b/arch/m68k/platform/coldfire/m5441x.c
new file mode 100644
index 00000000000..98a13cce93d
--- /dev/null
+++ b/arch/m68k/platform/coldfire/m5441x.c
@@ -0,0 +1,261 @@
1/*
2 * m5441x.c -- support for Coldfire m5441x processors
3 *
4 * (C) Copyright Steven King <sfking@fdwdc.com>
5 */
6
7#include <linux/kernel.h>
8#include <linux/param.h>
9#include <linux/init.h>
10#include <linux/io.h>
11#include <linux/clk.h>
12#include <asm/machdep.h>
13#include <asm/coldfire.h>
14#include <asm/mcfsim.h>
15#include <asm/mcfuart.h>
16#include <asm/mcfdma.h>
17#include <asm/mcfclk.h>
18
19DEFINE_CLK(0, "flexbus", 2, MCF_CLK);
20DEFINE_CLK(0, "mcfcan.0", 8, MCF_CLK);
21DEFINE_CLK(0, "mcfcan.1", 9, MCF_CLK);
22DEFINE_CLK(0, "mcfi2c.1", 14, MCF_CLK);
23DEFINE_CLK(0, "mcfdspi.1", 15, MCF_CLK);
24DEFINE_CLK(0, "edma", 17, MCF_CLK);
25DEFINE_CLK(0, "intc.0", 18, MCF_CLK);
26DEFINE_CLK(0, "intc.1", 19, MCF_CLK);
27DEFINE_CLK(0, "intc.2", 20, MCF_CLK);
28DEFINE_CLK(0, "mcfi2c.0", 22, MCF_CLK);
29DEFINE_CLK(0, "mcfdspi.0", 23, MCF_CLK);
30DEFINE_CLK(0, "mcfuart.0", 24, MCF_BUSCLK);
31DEFINE_CLK(0, "mcfuart.1", 25, MCF_BUSCLK);
32DEFINE_CLK(0, "mcfuart.2", 26, MCF_BUSCLK);
33DEFINE_CLK(0, "mcfuart.3", 27, MCF_BUSCLK);
34DEFINE_CLK(0, "mcftmr.0", 28, MCF_CLK);
35DEFINE_CLK(0, "mcftmr.1", 29, MCF_CLK);
36DEFINE_CLK(0, "mcftmr.2", 30, MCF_CLK);
37DEFINE_CLK(0, "mcftmr.3", 31, MCF_CLK);
38DEFINE_CLK(0, "mcfpit.0", 32, MCF_CLK);
39DEFINE_CLK(0, "mcfpit.1", 33, MCF_CLK);
40DEFINE_CLK(0, "mcfpit.2", 34, MCF_CLK);
41DEFINE_CLK(0, "mcfpit.3", 35, MCF_CLK);
42DEFINE_CLK(0, "mcfeport.0", 37, MCF_CLK);
43DEFINE_CLK(0, "mcfadc.0", 38, MCF_CLK);
44DEFINE_CLK(0, "mcfdac.0", 39, MCF_CLK);
45DEFINE_CLK(0, "mcfrtc.0", 42, MCF_CLK);
46DEFINE_CLK(0, "mcfsim.0", 43, MCF_CLK);
47DEFINE_CLK(0, "mcfusb-otg.0", 44, MCF_CLK);
48DEFINE_CLK(0, "mcfusb-host.0", 45, MCF_CLK);
49DEFINE_CLK(0, "mcfddr-sram.0", 46, MCF_CLK);
50DEFINE_CLK(0, "mcfssi.0", 47, MCF_CLK);
51DEFINE_CLK(0, "pll.0", 48, MCF_CLK);
52DEFINE_CLK(0, "mcfrng.0", 49, MCF_CLK);
53DEFINE_CLK(0, "mcfssi.1", 50, MCF_CLK);
54DEFINE_CLK(0, "mcfsdhc.0", 51, MCF_CLK);
55DEFINE_CLK(0, "enet-fec.0", 53, MCF_CLK);
56DEFINE_CLK(0, "enet-fec.1", 54, MCF_CLK);
57DEFINE_CLK(0, "switch.0", 55, MCF_CLK);
58DEFINE_CLK(0, "switch.1", 56, MCF_CLK);
59DEFINE_CLK(0, "nand.0", 63, MCF_CLK);
60
61DEFINE_CLK(1, "mcfow.0", 2, MCF_CLK);
62DEFINE_CLK(1, "mcfi2c.2", 4, MCF_CLK);
63DEFINE_CLK(1, "mcfi2c.3", 5, MCF_CLK);
64DEFINE_CLK(1, "mcfi2c.4", 6, MCF_CLK);
65DEFINE_CLK(1, "mcfi2c.5", 7, MCF_CLK);
66DEFINE_CLK(1, "mcfuart.4", 24, MCF_BUSCLK);
67DEFINE_CLK(1, "mcfuart.5", 25, MCF_BUSCLK);
68DEFINE_CLK(1, "mcfuart.6", 26, MCF_BUSCLK);
69DEFINE_CLK(1, "mcfuart.7", 27, MCF_BUSCLK);
70DEFINE_CLK(1, "mcfuart.8", 28, MCF_BUSCLK);
71DEFINE_CLK(1, "mcfuart.9", 29, MCF_BUSCLK);
72DEFINE_CLK(1, "mcfpwm.0", 34, MCF_BUSCLK);
73DEFINE_CLK(1, "sys.0", 36, MCF_BUSCLK);
74DEFINE_CLK(1, "gpio.0", 37, MCF_BUSCLK);
75
76struct clk *mcf_clks[] = {
77 &__clk_0_2,
78 &__clk_0_8,
79 &__clk_0_9,
80 &__clk_0_14,
81 &__clk_0_15,
82 &__clk_0_17,
83 &__clk_0_18,
84 &__clk_0_19,
85 &__clk_0_20,
86 &__clk_0_22,
87 &__clk_0_23,
88 &__clk_0_24,
89 &__clk_0_25,
90 &__clk_0_26,
91 &__clk_0_27,
92 &__clk_0_28,
93 &__clk_0_29,
94 &__clk_0_30,
95 &__clk_0_31,
96 &__clk_0_32,
97 &__clk_0_33,
98 &__clk_0_34,
99 &__clk_0_35,
100 &__clk_0_37,
101 &__clk_0_38,
102 &__clk_0_39,
103 &__clk_0_42,
104 &__clk_0_43,
105 &__clk_0_44,
106 &__clk_0_45,
107 &__clk_0_46,
108 &__clk_0_47,
109 &__clk_0_48,
110 &__clk_0_49,
111 &__clk_0_50,
112 &__clk_0_51,
113 &__clk_0_53,
114 &__clk_0_54,
115 &__clk_0_55,
116 &__clk_0_56,
117 &__clk_0_63,
118
119 &__clk_1_2,
120 &__clk_1_4,
121 &__clk_1_5,
122 &__clk_1_6,
123 &__clk_1_7,
124 &__clk_1_24,
125 &__clk_1_25,
126 &__clk_1_26,
127 &__clk_1_27,
128 &__clk_1_28,
129 &__clk_1_29,
130 &__clk_1_34,
131 &__clk_1_36,
132 &__clk_1_37,
133 NULL,
134};
135
136
137static struct clk * const enable_clks[] __initconst = {
138 /* make sure these clocks are enabled */
139 &__clk_0_18, /* intc0 */
140 &__clk_0_19, /* intc0 */
141 &__clk_0_20, /* intc0 */
142 &__clk_0_24, /* uart0 */
143 &__clk_0_25, /* uart1 */
144 &__clk_0_26, /* uart2 */
145 &__clk_0_27, /* uart3 */
146
147 &__clk_0_33, /* pit.1 */
148 &__clk_0_37, /* eport */
149 &__clk_0_48, /* pll */
150
151 &__clk_1_36, /* CCM/reset module/Power management */
152 &__clk_1_37, /* gpio */
153};
154static struct clk * const disable_clks[] __initconst = {
155 &__clk_0_8, /* can.0 */
156 &__clk_0_9, /* can.1 */
157 &__clk_0_14, /* i2c.1 */
158 &__clk_0_15, /* dspi.1 */
159 &__clk_0_17, /* eDMA */
160 &__clk_0_22, /* i2c.0 */
161 &__clk_0_23, /* dspi.0 */
162 &__clk_0_28, /* tmr.1 */
163 &__clk_0_29, /* tmr.2 */
164 &__clk_0_30, /* tmr.2 */
165 &__clk_0_31, /* tmr.3 */
166 &__clk_0_32, /* pit.0 */
167 &__clk_0_34, /* pit.2 */
168 &__clk_0_35, /* pit.3 */
169 &__clk_0_38, /* adc */
170 &__clk_0_39, /* dac */
171 &__clk_0_44, /* usb otg */
172 &__clk_0_45, /* usb host */
173 &__clk_0_47, /* ssi.0 */
174 &__clk_0_49, /* rng */
175 &__clk_0_50, /* ssi.1 */
176 &__clk_0_51, /* eSDHC */
177 &__clk_0_53, /* enet-fec */
178 &__clk_0_54, /* enet-fec */
179 &__clk_0_55, /* switch.0 */
180 &__clk_0_56, /* switch.1 */
181
182 &__clk_1_2, /* 1-wire */
183 &__clk_1_4, /* i2c.2 */
184 &__clk_1_5, /* i2c.3 */
185 &__clk_1_6, /* i2c.4 */
186 &__clk_1_7, /* i2c.5 */
187 &__clk_1_24, /* uart 4 */
188 &__clk_1_25, /* uart 5 */
189 &__clk_1_26, /* uart 6 */
190 &__clk_1_27, /* uart 7 */
191 &__clk_1_28, /* uart 8 */
192 &__clk_1_29, /* uart 9 */
193};
194
195static void __init m5441x_clk_init(void)
196{
197 unsigned i;
198
199 for (i = 0; i < ARRAY_SIZE(enable_clks); ++i)
200 __clk_init_enabled(enable_clks[i]);
201 /* make sure these clocks are disabled */
202 for (i = 0; i < ARRAY_SIZE(disable_clks); ++i)
203 __clk_init_disabled(disable_clks[i]);
204}
205
206static void __init m5441x_uarts_init(void)
207{
208 __raw_writeb(0x0f, MCFGPIO_PAR_UART0);
209 __raw_writeb(0x00, MCFGPIO_PAR_UART1);
210 __raw_writeb(0x00, MCFGPIO_PAR_UART2);
211}
212
213static void __init m5441x_fec_init(void)
214{
215 __raw_writeb(0x03, MCFGPIO_PAR_FEC);
216}
217
218void __init config_BSP(char *commandp, int size)
219{
220 m5441x_clk_init();
221 mach_sched_init = hw_timer_init;
222 m5441x_uarts_init();
223 m5441x_fec_init();
224}
225
226
227#if IS_ENABLED(CONFIG_RTC_DRV_M5441x)
228static struct resource m5441x_rtc_resources[] = {
229 {
230 .start = MCFRTC_BASE,
231 .end = MCFRTC_BASE + MCFRTC_SIZE - 1,
232 .flags = IORESOURCE_MEM,
233 },
234 {
235 .start = MCF_IRQ_RTC,
236 .end = MCF_IRQ_RTC,
237 .flags = IORESOURCE_IRQ,
238 },
239};
240
241static struct platform_device m5441x_rtc = {
242 .name = "mcfrtc",
243 .id = 0,
244 .resource = m5441x_rtc_resources,
245 .num_resources = ARRAY_SIZE(m5441x_rtc_resources),
246};
247#endif
248
249static struct platform_device *m5441x_devices[] __initdata = {
250#if IS_ENABLED(CONFIG_RTC_DRV_M5441x)
251 &m5441x_rtc,
252#endif
253};
254
255static int __init init_BSP(void)
256{
257 platform_add_devices(m5441x_devices, ARRAY_SIZE(m5441x_devices));
258 return 0;
259}
260
261arch_initcall(init_BSP);
diff --git a/arch/m68k/platform/coldfire/m54xx.c b/arch/m68k/platform/coldfire/m54xx.c
index 20672dadb25..2081c6cbb3d 100644
--- a/arch/m68k/platform/coldfire/m54xx.c
+++ b/arch/m68k/platform/coldfire/m54xx.c
@@ -21,19 +21,12 @@
21#include <asm/m54xxsim.h> 21#include <asm/m54xxsim.h>
22#include <asm/mcfuart.h> 22#include <asm/mcfuart.h>
23#include <asm/m54xxgpt.h> 23#include <asm/m54xxgpt.h>
24#include <asm/mcfgpio.h>
25#ifdef CONFIG_MMU 24#ifdef CONFIG_MMU
26#include <asm/mmu_context.h> 25#include <asm/mmu_context.h>
27#endif 26#endif
28 27
29/***************************************************************************/ 28/***************************************************************************/
30 29
31struct mcf_gpio_chip mcf_gpio_chips[] = { };
32
33unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips);
34
35/***************************************************************************/
36
37static void __init m54xx_uarts_init(void) 30static void __init m54xx_uarts_init(void)
38{ 31{
39 /* enable io pins */ 32 /* enable io pins */
diff --git a/arch/m68k/platform/coldfire/mcf8390.c b/arch/m68k/platform/coldfire/mcf8390.c
new file mode 100644
index 00000000000..23a6874a324
--- /dev/null
+++ b/arch/m68k/platform/coldfire/mcf8390.c
@@ -0,0 +1,38 @@
1/*
2 * mcf8390.c -- platform support for 8390 ethernet on many boards
3 *
4 * (C) Copyright 2012, Greg Ungerer <gerg@uclinux.org>
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/kernel.h>
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/resource.h>
15#include <linux/platform_device.h>
16#include <asm/mcf8390.h>
17
18static struct resource mcf8390_resources[] = {
19 {
20 .start = NE2000_ADDR,
21 .end = NE2000_ADDR + NE2000_ADDRSIZE - 1,
22 .flags = IORESOURCE_MEM,
23 },
24 {
25 .start = NE2000_IRQ_VECTOR,
26 .end = NE2000_IRQ_VECTOR,
27 .flags = IORESOURCE_IRQ,
28 },
29};
30
31static int __init mcf8390_platform_init(void)
32{
33 platform_device_register_simple("mcf8390", -1, mcf8390_resources,
34 ARRAY_SIZE(mcf8390_resources));
35 return 0;
36}
37
38arch_initcall(mcf8390_platform_init);
diff --git a/arch/m68k/platform/coldfire/pci.c b/arch/m68k/platform/coldfire/pci.c
new file mode 100644
index 00000000000..553210d3d4c
--- /dev/null
+++ b/arch/m68k/platform/coldfire/pci.c
@@ -0,0 +1,327 @@
1/*
2 * pci.c -- PCI bus support for ColdFire processors
3 *
4 * (C) Copyright 2012, Greg Ungerer <gerg@uclinux.com>
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/types.h>
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/interrupt.h>
16#include <linux/irq.h>
17#include <linux/io.h>
18#include <linux/pci.h>
19#include <linux/delay.h>
20#include <asm/coldfire.h>
21#include <asm/mcfsim.h>
22#include <asm/m54xxpci.h>
23
24/*
25 * Memory and IO mappings. We use a 1:1 mapping for local host memory to
26 * PCI bus memory (no reason not to really). IO space doesn't matter, we
27 * always use access functions for that. The device configuration space is
28 * mapped over the IO map space when we enable it in the PCICAR register.
29 */
30#define PCI_MEM_PA 0xf0000000 /* Host physical address */
31#define PCI_MEM_BA 0xf0000000 /* Bus physical address */
32#define PCI_MEM_SIZE 0x08000000 /* 128 MB */
33#define PCI_MEM_MASK (PCI_MEM_SIZE - 1)
34
35#define PCI_IO_PA 0xf8000000 /* Host physical address */
36#define PCI_IO_BA 0x00000000 /* Bus physical address */
37#define PCI_IO_SIZE 0x00010000 /* 64k */
38#define PCI_IO_MASK (PCI_IO_SIZE - 1)
39
40static struct pci_bus *rootbus;
41static unsigned long iospace;
42
43/*
44 * We need to be carefull probing on bus 0 (directly connected to host
45 * bridge). We should only acccess the well defined possible devices in
46 * use, ignore aliases and the like.
47 */
48static unsigned char mcf_host_slot2sid[32] = {
49 0, 0, 0, 0, 0, 0, 0, 0,
50 0, 0, 0, 0, 0, 0, 0, 0,
51 0, 1, 2, 0, 3, 4, 0, 0,
52 0, 0, 0, 0, 0, 0, 0, 0,
53};
54
55static unsigned char mcf_host_irq[] = {
56 0, 69, 69, 71, 71,
57};
58
59
60static inline void syncio(void)
61{
62 /* The ColdFire "nop" instruction waits for all bus IO to complete */
63 __asm__ __volatile__ ("nop");
64}
65
66/*
67 * Configuration space access functions. Configuration space access is
68 * through the IO mapping window, enabling it via the PCICAR register.
69 */
70static unsigned long mcf_mk_pcicar(int bus, unsigned int devfn, int where)
71{
72 return (bus << PCICAR_BUSN) | (devfn << PCICAR_DEVFNN) | (where & 0xfc);
73}
74
75static int mcf_pci_readconfig(struct pci_bus *bus, unsigned int devfn,
76 int where, int size, u32 *value)
77{
78 unsigned long addr;
79
80 *value = 0xffffffff;
81
82 if (bus->number == 0) {
83 if (mcf_host_slot2sid[PCI_SLOT(devfn)] == 0)
84 return PCIBIOS_SUCCESSFUL;
85 }
86
87 syncio();
88 addr = mcf_mk_pcicar(bus->number, devfn, where);
89 __raw_writel(PCICAR_E | addr, PCICAR);
90 addr = iospace + (where & 0x3);
91
92 switch (size) {
93 case 1:
94 *value = __raw_readb(addr);
95 break;
96 case 2:
97 *value = le16_to_cpu(__raw_readw(addr));
98 break;
99 default:
100 *value = le32_to_cpu(__raw_readl(addr));
101 break;
102 }
103
104 syncio();
105 __raw_writel(0, PCICAR);
106 return PCIBIOS_SUCCESSFUL;
107}
108
109static int mcf_pci_writeconfig(struct pci_bus *bus, unsigned int devfn,
110 int where, int size, u32 value)
111{
112 unsigned long addr;
113
114 if (bus->number == 0) {
115 if (mcf_host_slot2sid[PCI_SLOT(devfn)] == 0)
116 return PCIBIOS_SUCCESSFUL;
117 }
118
119 syncio();
120 addr = mcf_mk_pcicar(bus->number, devfn, where);
121 __raw_writel(PCICAR_E | addr, PCICAR);
122 addr = iospace + (where & 0x3);
123
124 switch (size) {
125 case 1:
126 __raw_writeb(value, addr);
127 break;
128 case 2:
129 __raw_writew(cpu_to_le16(value), addr);
130 break;
131 default:
132 __raw_writel(cpu_to_le32(value), addr);
133 break;
134 }
135
136 syncio();
137 __raw_writel(0, PCICAR);
138 return PCIBIOS_SUCCESSFUL;
139}
140
141static struct pci_ops mcf_pci_ops = {
142 .read = mcf_pci_readconfig,
143 .write = mcf_pci_writeconfig,
144};
145
146/*
147 * IO address space access functions. Pretty strait forward, these are
148 * directly mapped in to the IO mapping window. And that is mapped into
149 * virtual address space.
150 */
151u8 mcf_pci_inb(u32 addr)
152{
153 return __raw_readb(iospace + (addr & PCI_IO_MASK));
154}
155EXPORT_SYMBOL(mcf_pci_inb);
156
157u16 mcf_pci_inw(u32 addr)
158{
159 return le16_to_cpu(__raw_readw(iospace + (addr & PCI_IO_MASK)));
160}
161EXPORT_SYMBOL(mcf_pci_inw);
162
163u32 mcf_pci_inl(u32 addr)
164{
165 return le32_to_cpu(__raw_readl(iospace + (addr & PCI_IO_MASK)));
166}
167EXPORT_SYMBOL(mcf_pci_inl);
168
169void mcf_pci_insb(u32 addr, u8 *buf, u32 len)
170{
171 for (; len; len--)
172 *buf++ = mcf_pci_inb(addr);
173}
174EXPORT_SYMBOL(mcf_pci_insb);
175
176void mcf_pci_insw(u32 addr, u16 *buf, u32 len)
177{
178 for (; len; len--)
179 *buf++ = mcf_pci_inw(addr);
180}
181EXPORT_SYMBOL(mcf_pci_insw);
182
183void mcf_pci_insl(u32 addr, u32 *buf, u32 len)
184{
185 for (; len; len--)
186 *buf++ = mcf_pci_inl(addr);
187}
188EXPORT_SYMBOL(mcf_pci_insl);
189
190void mcf_pci_outb(u8 v, u32 addr)
191{
192 __raw_writeb(v, iospace + (addr & PCI_IO_MASK));
193}
194EXPORT_SYMBOL(mcf_pci_outb);
195
196void mcf_pci_outw(u16 v, u32 addr)
197{
198 __raw_writew(cpu_to_le16(v), iospace + (addr & PCI_IO_MASK));
199}
200EXPORT_SYMBOL(mcf_pci_outw);
201
202void mcf_pci_outl(u32 v, u32 addr)
203{
204 __raw_writel(cpu_to_le32(v), iospace + (addr & PCI_IO_MASK));
205}
206EXPORT_SYMBOL(mcf_pci_outl);
207
208void mcf_pci_outsb(u32 addr, const u8 *buf, u32 len)
209{
210 for (; len; len--)
211 mcf_pci_outb(*buf++, addr);
212}
213EXPORT_SYMBOL(mcf_pci_outsb);
214
215void mcf_pci_outsw(u32 addr, const u16 *buf, u32 len)
216{
217 for (; len; len--)
218 mcf_pci_outw(*buf++, addr);
219}
220EXPORT_SYMBOL(mcf_pci_outsw);
221
222void mcf_pci_outsl(u32 addr, const u32 *buf, u32 len)
223{
224 for (; len; len--)
225 mcf_pci_outl(*buf++, addr);
226}
227EXPORT_SYMBOL(mcf_pci_outsl);
228
229/*
230 * Initialize the PCI bus registers, and scan the bus.
231 */
232static struct resource mcf_pci_mem = {
233 .name = "PCI Memory space",
234 .start = PCI_MEM_PA,
235 .end = PCI_MEM_PA + PCI_MEM_SIZE - 1,
236 .flags = IORESOURCE_MEM,
237};
238
239static struct resource mcf_pci_io = {
240 .name = "PCI IO space",
241 .start = 0x400,
242 .end = 0x10000 - 1,
243 .flags = IORESOURCE_IO,
244};
245
246/*
247 * Interrupt mapping and setting.
248 */
249static int mcf_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
250{
251 int sid;
252
253 sid = mcf_host_slot2sid[slot];
254 if (sid)
255 return mcf_host_irq[sid];
256 return 0;
257}
258
259static int __init mcf_pci_init(void)
260{
261 pr_info("ColdFire: PCI bus initialization...\n");
262
263 /* Reset the external PCI bus */
264 __raw_writel(PCIGSCR_RESET, PCIGSCR);
265 __raw_writel(0, PCITCR);
266
267 request_resource(&iomem_resource, &mcf_pci_mem);
268 request_resource(&iomem_resource, &mcf_pci_io);
269
270 /* Configure PCI arbiter */
271 __raw_writel(PACR_INTMPRI | PACR_INTMINTE | PACR_EXTMPRI(0x1f) |
272 PACR_EXTMINTE(0x1f), PACR);
273
274 /* Set required multi-function pins for PCI bus use */
275 __raw_writew(0x3ff, MCF_PAR_PCIBG);
276 __raw_writew(0x3ff, MCF_PAR_PCIBR);
277
278 /* Set up config space for local host bus controller */
279 __raw_writel(PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
280 PCI_COMMAND_INVALIDATE, PCISCR);
281 __raw_writel(PCICR1_LT(32) | PCICR1_CL(8), PCICR1);
282 __raw_writel(0, PCICR2);
283
284 /*
285 * Set up the initiator windows for memory and IO mapping.
286 * These give the CPU bus access onto the PCI bus. One for each of
287 * PCI memory and IO address spaces.
288 */
289 __raw_writel(WXBTAR(PCI_MEM_PA, PCI_MEM_BA, PCI_MEM_SIZE),
290 PCIIW0BTAR);
291 __raw_writel(WXBTAR(PCI_IO_PA, PCI_IO_BA, PCI_IO_SIZE),
292 PCIIW1BTAR);
293 __raw_writel(PCIIWCR_W0_MEM /*| PCIIWCR_W0_MRDL*/ | PCIIWCR_W0_E |
294 PCIIWCR_W1_IO | PCIIWCR_W1_E, PCIIWCR);
295
296 /*
297 * Set up the target windows for access from the PCI bus back to the
298 * CPU bus. All we need is access to system RAM (for mastering).
299 */
300 __raw_writel(CONFIG_RAMBASE, PCIBAR1);
301 __raw_writel(CONFIG_RAMBASE | PCITBATR1_E, PCITBATR1);
302
303 /* Keep a virtual mapping to IO/config space active */
304 iospace = (unsigned long) ioremap(PCI_IO_PA, PCI_IO_SIZE);
305 if (iospace == 0)
306 return -ENODEV;
307 pr_info("Coldfire: PCI IO/config window mapped to 0x%x\n",
308 (u32) iospace);
309
310 /* Turn of PCI reset, and wait for devices to settle */
311 __raw_writel(0, PCIGSCR);
312 set_current_state(TASK_UNINTERRUPTIBLE);
313 schedule_timeout(msecs_to_jiffies(200));
314
315 rootbus = pci_scan_bus(0, &mcf_pci_ops, NULL);
316 rootbus->resource[0] = &mcf_pci_io;
317 rootbus->resource[1] = &mcf_pci_mem;
318
319 pci_fixup_irqs(pci_common_swizzle, mcf_pci_map_irq);
320 pci_bus_size_bridges(rootbus);
321 pci_bus_assign_resources(rootbus);
322 pci_enable_bridges(rootbus);
323 pci_bus_add_devices(rootbus);
324 return 0;
325}
326
327subsys_initcall(mcf_pci_init);
diff --git a/arch/m68k/platform/coldfire/pinmux.c b/arch/m68k/platform/coldfire/pinmux.c
deleted file mode 100644
index 8c62b825939..00000000000
--- a/arch/m68k/platform/coldfire/pinmux.c
+++ /dev/null
@@ -1,28 +0,0 @@
1/*
2 * Coldfire generic GPIO pinmux support.
3 *
4 * (C) Copyright 2009, Steven King <sfking@fdwdc.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 as published by
8 * the Free Software Foundation; version 2 of the License.
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#include <linux/kernel.h>
18
19#include <asm/pinmux.h>
20
21int mcf_pinmux_request(unsigned pinmux, unsigned func)
22{
23 return 0;
24}
25
26void mcf_pinmux_release(unsigned pinmux, unsigned func)
27{
28}
diff --git a/arch/m68k/platform/coldfire/pit.c b/arch/m68k/platform/coldfire/pit.c
index e62dbbcb10f..e8f3b97b0f7 100644
--- a/arch/m68k/platform/coldfire/pit.c
+++ b/arch/m68k/platform/coldfire/pit.c
@@ -93,7 +93,7 @@ struct clock_event_device cf_pit_clockevent = {
93 .set_mode = init_cf_pit_timer, 93 .set_mode = init_cf_pit_timer,
94 .set_next_event = cf_pit_next_event, 94 .set_next_event = cf_pit_next_event,
95 .shift = 32, 95 .shift = 32,
96 .irq = MCFINT_VECBASE + MCFINT_PIT1, 96 .irq = MCF_IRQ_PIT1,
97}; 97};
98 98
99 99
@@ -159,7 +159,7 @@ void hw_timer_init(irq_handler_t handler)
159 clockevent_delta2ns(0x3f, &cf_pit_clockevent); 159 clockevent_delta2ns(0x3f, &cf_pit_clockevent);
160 clockevents_register_device(&cf_pit_clockevent); 160 clockevents_register_device(&cf_pit_clockevent);
161 161
162 setup_irq(MCFINT_VECBASE + MCFINT_PIT1, &pit_irq); 162 setup_irq(MCF_IRQ_PIT1, &pit_irq);
163 163
164 clocksource_register_hz(&pit_clk, FREQ); 164 clocksource_register_hz(&pit_clk, FREQ);
165} 165}
diff --git a/arch/m68k/platform/coldfire/timers.c b/arch/m68k/platform/coldfire/timers.c
index ed96ce50d79..0a273e75408 100644
--- a/arch/m68k/platform/coldfire/timers.c
+++ b/arch/m68k/platform/coldfire/timers.c
@@ -36,7 +36,7 @@
36 */ 36 */
37void coldfire_profile_init(void); 37void coldfire_profile_init(void);
38 38
39#if defined(CONFIG_M532x) 39#if defined(CONFIG_M532x) || defined(CONFIG_M5441x)
40#define __raw_readtrr __raw_readl 40#define __raw_readtrr __raw_readl
41#define __raw_writetrr __raw_writel 41#define __raw_writetrr __raw_writel
42#else 42#else
diff --git a/arch/m68k/sun3/prom/init.c b/arch/m68k/sun3/prom/init.c
index d8e6349336b..eeba067d565 100644
--- a/arch/m68k/sun3/prom/init.c
+++ b/arch/m68k/sun3/prom/init.c
@@ -22,57 +22,13 @@ int prom_root_node;
22struct linux_nodeops *prom_nodeops; 22struct linux_nodeops *prom_nodeops;
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.
26 * failure. It gets passed the pointer to the PROM vector. 26 * It gets passed the pointer to the PROM vector.
27 */ 27 */
28 28
29extern void prom_meminit(void);
30extern void prom_ranges_init(void);
31
32void __init prom_init(struct linux_romvec *rp) 29void __init prom_init(struct linux_romvec *rp)
33{ 30{
34 romvec = rp; 31 romvec = rp;
35#ifndef CONFIG_SUN3
36 switch(romvec->pv_romvers) {
37 case 0:
38 prom_vers = PROM_V0;
39 break;
40 case 2:
41 prom_vers = PROM_V2;
42 break;
43 case 3:
44 prom_vers = PROM_V3;
45 break;
46 case 4:
47 prom_vers = PROM_P1275;
48 prom_printf("PROMLIB: Sun IEEE Prom not supported yet\n");
49 prom_halt();
50 break;
51 default:
52 prom_printf("PROMLIB: Bad PROM version %d\n",
53 romvec->pv_romvers);
54 prom_halt();
55 break;
56 };
57
58 prom_rev = romvec->pv_plugin_revision;
59 prom_prev = romvec->pv_printrev;
60 prom_nodeops = romvec->pv_nodeops;
61
62 prom_root_node = prom_getsibling(0);
63 if((prom_root_node == 0) || (prom_root_node == -1))
64 prom_halt();
65
66 if((((unsigned long) prom_nodeops) == 0) ||
67 (((unsigned long) prom_nodeops) == -1))
68 prom_halt();
69
70 prom_meminit();
71
72 prom_ranges_init();
73#endif
74// printk("PROMLIB: Sun Boot Prom Version %d Revision %d\n",
75// romvec->pv_romvers, prom_rev);
76 32
77 /* Initialization successful. */ 33 /* Initialization successful. */
78 return; 34 return;
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 0bf44231aaf..ab9afcaa7f6 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -15,6 +15,7 @@ config MICROBLAZE
15 select TRACING_SUPPORT 15 select TRACING_SUPPORT
16 select OF 16 select OF
17 select OF_EARLY_FLATTREE 17 select OF_EARLY_FLATTREE
18 select ARCH_WANT_IPC_PARSE_VERSION
18 select IRQ_DOMAIN 19 select IRQ_DOMAIN
19 select HAVE_GENERIC_HARDIRQS 20 select HAVE_GENERIC_HARDIRQS
20 select GENERIC_IRQ_PROBE 21 select GENERIC_IRQ_PROBE
diff --git a/arch/microblaze/include/asm/sections.h b/arch/microblaze/include/asm/sections.h
index 4487e150b45..c07ed5d2a82 100644
--- a/arch/microblaze/include/asm/sections.h
+++ b/arch/microblaze/include/asm/sections.h
@@ -18,10 +18,6 @@ extern char _ssbss[], _esbss[];
18extern unsigned long __ivt_start[], __ivt_end[]; 18extern unsigned long __ivt_start[], __ivt_end[];
19extern char _etext[], _stext[]; 19extern char _etext[], _stext[];
20 20
21# ifdef CONFIG_MTD_UCLINUX
22extern char *_ebss;
23# endif
24
25extern u32 _fdt_start[], _fdt_end[]; 21extern u32 _fdt_start[], _fdt_end[];
26 22
27# endif /* !__ASSEMBLY__ */ 23# endif /* !__ASSEMBLY__ */
diff --git a/arch/microblaze/include/asm/unistd.h b/arch/microblaze/include/asm/unistd.h
index d20ffbc86be..6985e6e9d82 100644
--- a/arch/microblaze/include/asm/unistd.h
+++ b/arch/microblaze/include/asm/unistd.h
@@ -400,7 +400,6 @@
400#ifdef __KERNEL__ 400#ifdef __KERNEL__
401#ifndef __ASSEMBLY__ 401#ifndef __ASSEMBLY__
402 402
403#define __ARCH_WANT_IPC_PARSE_VERSION
404/* #define __ARCH_WANT_OLD_READDIR */ 403/* #define __ARCH_WANT_OLD_READDIR */
405/* #define __ARCH_WANT_OLD_STAT */ 404/* #define __ARCH_WANT_OLD_STAT */
406#define __ARCH_WANT_STAT64 405#define __ARCH_WANT_STAT64
diff --git a/arch/microblaze/kernel/microblaze_ksyms.c b/arch/microblaze/kernel/microblaze_ksyms.c
index bb4907c828d..2b25bcf05c0 100644
--- a/arch/microblaze/kernel/microblaze_ksyms.c
+++ b/arch/microblaze/kernel/microblaze_ksyms.c
@@ -21,9 +21,6 @@
21#include <linux/ftrace.h> 21#include <linux/ftrace.h>
22#include <linux/uaccess.h> 22#include <linux/uaccess.h>
23 23
24extern char *_ebss;
25EXPORT_SYMBOL_GPL(_ebss);
26
27#ifdef CONFIG_FUNCTION_TRACER 24#ifdef CONFIG_FUNCTION_TRACER
28extern void _mcount(void); 25extern void _mcount(void);
29EXPORT_SYMBOL(_mcount); 26EXPORT_SYMBOL(_mcount);
diff --git a/arch/microblaze/kernel/setup.c b/arch/microblaze/kernel/setup.c
index 16d8dfd9094..4da971d4392 100644
--- a/arch/microblaze/kernel/setup.c
+++ b/arch/microblaze/kernel/setup.c
@@ -121,7 +121,7 @@ void __init machine_early_init(const char *cmdline, unsigned int ram,
121 121
122 /* Move ROMFS out of BSS before clearing it */ 122 /* Move ROMFS out of BSS before clearing it */
123 if (romfs_size > 0) { 123 if (romfs_size > 0) {
124 memmove(&_ebss, (int *)romfs_base, romfs_size); 124 memmove(&__bss_stop, (int *)romfs_base, romfs_size);
125 klimit += romfs_size; 125 klimit += romfs_size;
126 } 126 }
127#endif 127#endif
@@ -165,7 +165,7 @@ void __init machine_early_init(const char *cmdline, unsigned int ram,
165 BUG_ON(romfs_size < 0); /* What else can we do? */ 165 BUG_ON(romfs_size < 0); /* What else can we do? */
166 166
167 printk("Moved 0x%08x bytes from 0x%08x to 0x%08x\n", 167 printk("Moved 0x%08x bytes from 0x%08x to 0x%08x\n",
168 romfs_size, romfs_base, (unsigned)&_ebss); 168 romfs_size, romfs_base, (unsigned)&__bss_stop);
169 169
170 printk("New klimit: 0x%08x\n", (unsigned)klimit); 170 printk("New klimit: 0x%08x\n", (unsigned)klimit);
171#endif 171#endif
diff --git a/arch/microblaze/kernel/vmlinux.lds.S b/arch/microblaze/kernel/vmlinux.lds.S
index 109e9d86ade..936d01a689d 100644
--- a/arch/microblaze/kernel/vmlinux.lds.S
+++ b/arch/microblaze/kernel/vmlinux.lds.S
@@ -131,7 +131,6 @@ SECTIONS {
131 *(COMMON) 131 *(COMMON)
132 . = ALIGN (4) ; 132 . = ALIGN (4) ;
133 __bss_stop = . ; 133 __bss_stop = . ;
134 _ebss = . ;
135 } 134 }
136 . = ALIGN(PAGE_SIZE); 135 . = ALIGN(PAGE_SIZE);
137 _end = .; 136 _end = .;
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index ed22bfc5db1..4dbb5055d04 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -192,11 +192,6 @@ void pcibios_set_master(struct pci_dev *dev)
192 /* No special bus mastering setup handling */ 192 /* No special bus mastering setup handling */
193} 193}
194 194
195char __devinit *pcibios_setup(char *str)
196{
197 return str;
198}
199
200/* 195/*
201 * Reads the interrupt pin to determine if interrupt is use by card. 196 * Reads the interrupt pin to determine if interrupt is use by card.
202 * If the interrupt is used, then gets the interrupt line from the 197 * If the interrupt is used, then gets the interrupt line from the
@@ -249,8 +244,7 @@ int pci_read_irq_line(struct pci_dev *pci_dev)
249 } else { 244 } else {
250 pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n", 245 pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n",
251 oirq.size, oirq.specifier[0], oirq.specifier[1], 246 oirq.size, oirq.specifier[0], oirq.specifier[1],
252 oirq.controller ? oirq.controller->full_name : 247 of_node_full_name(oirq.controller));
253 "<default>");
254 248
255 virq = irq_create_of_mapping(oirq.controller, oirq.specifier, 249 virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
256 oirq.size); 250 oirq.size);
@@ -1493,8 +1487,7 @@ static void __devinit pcibios_scan_phb(struct pci_controller *hose)
1493 struct pci_bus *bus; 1487 struct pci_bus *bus;
1494 struct device_node *node = hose->dn; 1488 struct device_node *node = hose->dn;
1495 1489
1496 pr_debug("PCI: Scanning PHB %s\n", 1490 pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node));
1497 node ? node->full_name : "<NO NAME>");
1498 1491
1499 pcibios_setup_phb_resources(hose, &resources); 1492 pcibios_setup_phb_resources(hose, &resources);
1500 1493
@@ -1506,10 +1499,10 @@ static void __devinit pcibios_scan_phb(struct pci_controller *hose)
1506 pci_free_resource_list(&resources); 1499 pci_free_resource_list(&resources);
1507 return; 1500 return;
1508 } 1501 }
1509 bus->secondary = hose->first_busno; 1502 bus->busn_res.start = hose->first_busno;
1510 hose->bus = bus; 1503 hose->bus = bus;
1511 1504
1512 hose->last_busno = bus->subordinate; 1505 hose->last_busno = bus->busn_res.end;
1513} 1506}
1514 1507
1515static int __init pcibios_init(void) 1508static int __init pcibios_init(void)
diff --git a/arch/mips/Kbuild.platforms b/arch/mips/Kbuild.platforms
index 5ce8029f558..d64786d5e2f 100644
--- a/arch/mips/Kbuild.platforms
+++ b/arch/mips/Kbuild.platforms
@@ -14,6 +14,7 @@ platforms += jz4740
14platforms += lantiq 14platforms += lantiq
15platforms += lasat 15platforms += lasat
16platforms += loongson 16platforms += loongson
17platforms += loongson1
17platforms += mipssim 18platforms += mipssim
18platforms += mti-malta 19platforms += mti-malta
19platforms += netlogic 20platforms += netlogic
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index b3e10fdd389..faf65286574 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -20,12 +20,14 @@ config MIPS
20 select ARCH_BINFMT_ELF_RANDOMIZE_PIE 20 select ARCH_BINFMT_ELF_RANDOMIZE_PIE
21 select RTC_LIB if !MACH_LOONGSON 21 select RTC_LIB if !MACH_LOONGSON
22 select GENERIC_ATOMIC64 if !64BIT 22 select GENERIC_ATOMIC64 if !64BIT
23 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
23 select HAVE_DMA_ATTRS 24 select HAVE_DMA_ATTRS
24 select HAVE_DMA_API_DEBUG 25 select HAVE_DMA_API_DEBUG
25 select HAVE_GENERIC_HARDIRQS 26 select HAVE_GENERIC_HARDIRQS
26 select GENERIC_IRQ_PROBE 27 select GENERIC_IRQ_PROBE
27 select GENERIC_IRQ_SHOW 28 select GENERIC_IRQ_SHOW
28 select HAVE_ARCH_JUMP_LABEL 29 select HAVE_ARCH_JUMP_LABEL
30 select ARCH_WANT_IPC_PARSE_VERSION
29 select IRQ_FORCED_THREADING 31 select IRQ_FORCED_THREADING
30 select HAVE_MEMBLOCK 32 select HAVE_MEMBLOCK
31 select HAVE_MEMBLOCK_NODE_MAP 33 select HAVE_MEMBLOCK_NODE_MAP
@@ -75,6 +77,7 @@ config AR7
75 select SYS_SUPPORTS_ZBOOT_UART16550 77 select SYS_SUPPORTS_ZBOOT_UART16550
76 select ARCH_REQUIRE_GPIOLIB 78 select ARCH_REQUIRE_GPIOLIB
77 select VLYNQ 79 select VLYNQ
80 select HAVE_CLK
78 help 81 help
79 Support for the Texas Instruments AR7 System-on-a-Chip 82 Support for the Texas Instruments AR7 System-on-a-Chip
80 family: TNETD7100, 7200 and 7300. 83 family: TNETD7100, 7200 and 7300.
@@ -86,6 +89,7 @@ config ATH79
86 select CEVT_R4K 89 select CEVT_R4K
87 select CSRC_R4K 90 select CSRC_R4K
88 select DMA_NONCOHERENT 91 select DMA_NONCOHERENT
92 select HAVE_CLK
89 select IRQ_CPU 93 select IRQ_CPU
90 select MIPS_MACHINE 94 select MIPS_MACHINE
91 select SYS_HAS_CPU_MIPS32_R2 95 select SYS_HAS_CPU_MIPS32_R2
@@ -122,6 +126,7 @@ config BCM63XX
122 select SYS_HAS_EARLY_PRINTK 126 select SYS_HAS_EARLY_PRINTK
123 select SWAP_IO_SPACE 127 select SWAP_IO_SPACE
124 select ARCH_REQUIRE_GPIOLIB 128 select ARCH_REQUIRE_GPIOLIB
129 select HAVE_CLK
125 help 130 help
126 Support for BCM63XX based boards 131 Support for BCM63XX based boards
127 132
@@ -209,6 +214,7 @@ config MACH_JZ4740
209 select SYS_HAS_CPU_MIPS32_R1 214 select SYS_HAS_CPU_MIPS32_R1
210 select SYS_SUPPORTS_32BIT_KERNEL 215 select SYS_SUPPORTS_32BIT_KERNEL
211 select SYS_SUPPORTS_LITTLE_ENDIAN 216 select SYS_SUPPORTS_LITTLE_ENDIAN
217 select SYS_SUPPORTS_ZBOOT_UART16550
212 select DMA_NONCOHERENT 218 select DMA_NONCOHERENT
213 select IRQ_CPU 219 select IRQ_CPU
214 select GENERIC_GPIO 220 select GENERIC_GPIO
@@ -264,6 +270,16 @@ config MACH_LOONGSON
264 Chinese Academy of Sciences (CAS) in the People's Republic 270 Chinese Academy of Sciences (CAS) in the People's Republic
265 of China. The chief architect is Professor Weiwu Hu. 271 of China. The chief architect is Professor Weiwu Hu.
266 272
273config MACH_LOONGSON1
274 bool "Loongson 1 family of machines"
275 select SYS_SUPPORTS_ZBOOT
276 help
277 This enables support for the Loongson 1 based machines.
278
279 Loongson 1 is a family of 32-bit MIPS-compatible SoCs developed by
280 the ICT (Institute of Computing Technology) and the Chinese Academy
281 of Sciences.
282
267config MIPS_MALTA 283config MIPS_MALTA
268 bool "MIPS Malta board" 284 bool "MIPS Malta board"
269 select ARCH_MAY_HAVE_PC_FDC 285 select ARCH_MAY_HAVE_PC_FDC
@@ -787,6 +803,8 @@ config NLM_XLR_BOARD
787 select ZONE_DMA if 64BIT 803 select ZONE_DMA if 64BIT
788 select SYNC_R4K 804 select SYNC_R4K
789 select SYS_HAS_EARLY_PRINTK 805 select SYS_HAS_EARLY_PRINTK
806 select USB_ARCH_HAS_OHCI if USB_SUPPORT
807 select USB_ARCH_HAS_EHCI if USB_SUPPORT
790 help 808 help
791 Support for systems based on Netlogic XLR and XLS processors. 809 Support for systems based on Netlogic XLR and XLS processors.
792 Say Y here if you have a XLR or XLS based board. 810 Say Y here if you have a XLR or XLS based board.
@@ -799,7 +817,6 @@ config NLM_XLP_BOARD
799 select SYS_HAS_CPU_XLP 817 select SYS_HAS_CPU_XLP
800 select SYS_SUPPORTS_SMP 818 select SYS_SUPPORTS_SMP
801 select HW_HAS_PCI 819 select HW_HAS_PCI
802 select SWAP_IO_SPACE
803 select SYS_SUPPORTS_32BIT_KERNEL 820 select SYS_SUPPORTS_32BIT_KERNEL
804 select SYS_SUPPORTS_64BIT_KERNEL 821 select SYS_SUPPORTS_64BIT_KERNEL
805 select 64BIT_PHYS_ADDR 822 select 64BIT_PHYS_ADDR
@@ -836,6 +853,7 @@ source "arch/mips/txx9/Kconfig"
836source "arch/mips/vr41xx/Kconfig" 853source "arch/mips/vr41xx/Kconfig"
837source "arch/mips/cavium-octeon/Kconfig" 854source "arch/mips/cavium-octeon/Kconfig"
838source "arch/mips/loongson/Kconfig" 855source "arch/mips/loongson/Kconfig"
856source "arch/mips/loongson1/Kconfig"
839source "arch/mips/netlogic/Kconfig" 857source "arch/mips/netlogic/Kconfig"
840 858
841endmenu 859endmenu
@@ -1217,6 +1235,14 @@ config CPU_LOONGSON2F
1217 have a similar programming interface with FPGA northbridge used in 1235 have a similar programming interface with FPGA northbridge used in
1218 Loongson2E. 1236 Loongson2E.
1219 1237
1238config CPU_LOONGSON1B
1239 bool "Loongson 1B"
1240 depends on SYS_HAS_CPU_LOONGSON1B
1241 select CPU_LOONGSON1
1242 help
1243 The Loongson 1B is a 32-bit SoC, which implements the MIPS32
1244 release 2 instruction set.
1245
1220config CPU_MIPS32_R1 1246config CPU_MIPS32_R1
1221 bool "MIPS32 Release 1" 1247 bool "MIPS32 Release 1"
1222 depends on SYS_HAS_CPU_MIPS32_R1 1248 depends on SYS_HAS_CPU_MIPS32_R1
@@ -1432,6 +1458,8 @@ config CPU_CAVIUM_OCTEON
1432 select WEAK_ORDERING 1458 select WEAK_ORDERING
1433 select CPU_SUPPORTS_HIGHMEM 1459 select CPU_SUPPORTS_HIGHMEM
1434 select CPU_SUPPORTS_HUGEPAGES 1460 select CPU_SUPPORTS_HUGEPAGES
1461 select LIBFDT
1462 select USE_OF
1435 help 1463 help
1436 The Cavium Octeon processor is a highly integrated chip containing 1464 The Cavium Octeon processor is a highly integrated chip containing
1437 many ethernet hardware widgets for networking tasks. The processor 1465 many ethernet hardware widgets for networking tasks. The processor
@@ -1544,6 +1572,14 @@ config CPU_LOONGSON2
1544 select CPU_SUPPORTS_64BIT_KERNEL 1572 select CPU_SUPPORTS_64BIT_KERNEL
1545 select CPU_SUPPORTS_HIGHMEM 1573 select CPU_SUPPORTS_HIGHMEM
1546 1574
1575config CPU_LOONGSON1
1576 bool
1577 select CPU_MIPS32
1578 select CPU_MIPSR2
1579 select CPU_HAS_PREFETCH
1580 select CPU_SUPPORTS_32BIT_KERNEL
1581 select CPU_SUPPORTS_HIGHMEM
1582
1547config CPU_BMIPS 1583config CPU_BMIPS
1548 bool 1584 bool
1549 select CPU_MIPS32 1585 select CPU_MIPS32
@@ -1562,6 +1598,9 @@ config SYS_HAS_CPU_LOONGSON2F
1562 select CPU_SUPPORTS_ADDRWINCFG if 64BIT 1598 select CPU_SUPPORTS_ADDRWINCFG if 64BIT
1563 select CPU_SUPPORTS_UNCACHED_ACCELERATED 1599 select CPU_SUPPORTS_UNCACHED_ACCELERATED
1564 1600
1601config SYS_HAS_CPU_LOONGSON1B
1602 bool
1603
1565config SYS_HAS_CPU_MIPS32_R1 1604config SYS_HAS_CPU_MIPS32_R1
1566 bool 1605 bool
1567 1606
@@ -2366,6 +2405,8 @@ config PCI_DOMAINS
2366 2405
2367source "drivers/pci/Kconfig" 2406source "drivers/pci/Kconfig"
2368 2407
2408source "drivers/pci/pcie/Kconfig"
2409
2369# 2410#
2370# ISA support is now enabled via select. Too many systems still have the one 2411# ISA support is now enabled via select. Too many systems still have the one
2371# or other ISA chip on the board that users don't know about so don't expect 2412# or other ISA chip on the board that users don't know about so don't expect
diff --git a/arch/mips/alchemy/board-mtx1.c b/arch/mips/alchemy/board-mtx1.c
index 295f1a95f74..a124c251c0c 100644
--- a/arch/mips/alchemy/board-mtx1.c
+++ b/arch/mips/alchemy/board-mtx1.c
@@ -81,10 +81,10 @@ static void mtx1_power_off(void)
81 81
82void __init board_setup(void) 82void __init board_setup(void)
83{ 83{
84#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 84#if IS_ENABLED(CONFIG_USB_OHCI_HCD)
85 /* Enable USB power switch */ 85 /* Enable USB power switch */
86 alchemy_gpio_direction_output(204, 0); 86 alchemy_gpio_direction_output(204, 0);
87#endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */ 87#endif /* IS_ENABLED(CONFIG_USB_OHCI_HCD) */
88 88
89 /* Initialize sys_pinfunc */ 89 /* Initialize sys_pinfunc */
90 au_writel(SYS_PF_NI2, SYS_PINFUNC); 90 au_writel(SYS_PF_NI2, SYS_PINFUNC);
@@ -228,6 +228,8 @@ static int mtx1_pci_idsel(unsigned int devsel, int assert)
228 * adapter on the mtx-1 "singleboard" variant. It triggers a custom 228 * adapter on the mtx-1 "singleboard" variant. It triggers a custom
229 * logic chip connected to EXT_IO3 (GPIO1) to suppress IDSEL signals. 229 * logic chip connected to EXT_IO3 (GPIO1) to suppress IDSEL signals.
230 */ 230 */
231 udelay(1);
232
231 if (assert && devsel != 0) 233 if (assert && devsel != 0)
232 /* Suppress signal to Cardbus */ 234 /* Suppress signal to Cardbus */
233 alchemy_gpio_set_value(1, 0); /* set EXT_IO3 OFF */ 235 alchemy_gpio_set_value(1, 0); /* set EXT_IO3 OFF */
diff --git a/arch/mips/alchemy/common/platform.c b/arch/mips/alchemy/common/platform.c
index 95cb9113b12..c0f3ce6dcb5 100644
--- a/arch/mips/alchemy/common/platform.c
+++ b/arch/mips/alchemy/common/platform.c
@@ -334,13 +334,12 @@ static void __init alchemy_setup_macs(int ctype)
334 if (alchemy_get_macs(ctype) < 1) 334 if (alchemy_get_macs(ctype) < 1)
335 return; 335 return;
336 336
337 macres = kmalloc(sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL); 337 macres = kmemdup(au1xxx_eth0_resources[ctype],
338 sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL);
338 if (!macres) { 339 if (!macres) {
339 printk(KERN_INFO "Alchemy: no memory for MAC0 resources\n"); 340 printk(KERN_INFO "Alchemy: no memory for MAC0 resources\n");
340 return; 341 return;
341 } 342 }
342 memcpy(macres, au1xxx_eth0_resources[ctype],
343 sizeof(struct resource) * MAC_RES_COUNT);
344 au1xxx_eth0_device.resource = macres; 343 au1xxx_eth0_device.resource = macres;
345 344
346 i = prom_get_ethernet_addr(ethaddr); 345 i = prom_get_ethernet_addr(ethaddr);
@@ -356,13 +355,12 @@ static void __init alchemy_setup_macs(int ctype)
356 if (alchemy_get_macs(ctype) < 2) 355 if (alchemy_get_macs(ctype) < 2)
357 return; 356 return;
358 357
359 macres = kmalloc(sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL); 358 macres = kmemdup(au1xxx_eth1_resources[ctype],
359 sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL);
360 if (!macres) { 360 if (!macres) {
361 printk(KERN_INFO "Alchemy: no memory for MAC1 resources\n"); 361 printk(KERN_INFO "Alchemy: no memory for MAC1 resources\n");
362 return; 362 return;
363 } 363 }
364 memcpy(macres, au1xxx_eth1_resources[ctype],
365 sizeof(struct resource) * MAC_RES_COUNT);
366 au1xxx_eth1_device.resource = macres; 364 au1xxx_eth1_device.resource = macres;
367 365
368 ethaddr[5] += 1; /* next addr for 2nd MAC */ 366 ethaddr[5] += 1; /* next addr for 2nd MAC */
diff --git a/arch/mips/alchemy/devboards/Makefile b/arch/mips/alchemy/devboards/Makefile
index 3c37fb30336..c9e747dd9fc 100644
--- a/arch/mips/alchemy/devboards/Makefile
+++ b/arch/mips/alchemy/devboards/Makefile
@@ -2,7 +2,7 @@
2# Alchemy Develboards 2# Alchemy Develboards
3# 3#
4 4
5obj-y += prom.o bcsr.o platform.o 5obj-y += bcsr.o platform.o
6obj-$(CONFIG_PM) += pm.o 6obj-$(CONFIG_PM) += pm.o
7obj-$(CONFIG_MIPS_PB1100) += pb1100.o 7obj-$(CONFIG_MIPS_PB1100) += pb1100.o
8obj-$(CONFIG_MIPS_PB1500) += pb1500.o 8obj-$(CONFIG_MIPS_PB1500) += pb1500.o
diff --git a/arch/mips/alchemy/devboards/bcsr.c b/arch/mips/alchemy/devboards/bcsr.c
index 1e83ce2e114..f2039ef2c29 100644
--- a/arch/mips/alchemy/devboards/bcsr.c
+++ b/arch/mips/alchemy/devboards/bcsr.c
@@ -90,10 +90,7 @@ static void bcsr_csc_handler(unsigned int irq, struct irq_desc *d)
90 unsigned short bisr = __raw_readw(bcsr_virt + BCSR_REG_INTSTAT); 90 unsigned short bisr = __raw_readw(bcsr_virt + BCSR_REG_INTSTAT);
91 91
92 disable_irq_nosync(irq); 92 disable_irq_nosync(irq);
93 93 generic_handle_irq(bcsr_csc_base + __ffs(bisr));
94 for ( ; bisr; bisr &= bisr - 1)
95 generic_handle_irq(bcsr_csc_base + __ffs(bisr));
96
97 enable_irq(irq); 94 enable_irq(irq);
98} 95}
99 96
diff --git a/arch/mips/alchemy/devboards/pb1100.c b/arch/mips/alchemy/devboards/pb1100.c
index cff50d05ddd..78c77a44a31 100644
--- a/arch/mips/alchemy/devboards/pb1100.c
+++ b/arch/mips/alchemy/devboards/pb1100.c
@@ -46,7 +46,7 @@ void __init board_setup(void)
46 alchemy_gpio1_input_enable(); 46 alchemy_gpio1_input_enable();
47 udelay(100); 47 udelay(100);
48 48
49#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 49#if IS_ENABLED(CONFIG_USB_OHCI_HCD)
50 { 50 {
51 u32 pin_func, sys_freqctrl, sys_clksrc; 51 u32 pin_func, sys_freqctrl, sys_clksrc;
52 52
@@ -93,7 +93,7 @@ void __init board_setup(void)
93 pin_func |= SYS_PF_USB; 93 pin_func |= SYS_PF_USB;
94 au_writel(pin_func, SYS_PINFUNC); 94 au_writel(pin_func, SYS_PINFUNC);
95 } 95 }
96#endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */ 96#endif /* IS_ENABLED(CONFIG_USB_OHCI_HCD) */
97 97
98 /* Enable sys bus clock divider when IDLE state or no bus activity. */ 98 /* Enable sys bus clock divider when IDLE state or no bus activity. */
99 au_writel(au_readl(SYS_POWERCTRL) | (0x3 << 5), SYS_POWERCTRL); 99 au_writel(au_readl(SYS_POWERCTRL) | (0x3 << 5), SYS_POWERCTRL);
diff --git a/arch/mips/alchemy/devboards/pb1500.c b/arch/mips/alchemy/devboards/pb1500.c
index e7b807b3ec5..232fee94200 100644
--- a/arch/mips/alchemy/devboards/pb1500.c
+++ b/arch/mips/alchemy/devboards/pb1500.c
@@ -53,7 +53,7 @@ void __init board_setup(void)
53 alchemy_gpio_direction_input(201); 53 alchemy_gpio_direction_input(201);
54 alchemy_gpio_direction_input(203); 54 alchemy_gpio_direction_input(203);
55 55
56#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 56#if IS_ENABLED(CONFIG_USB_OHCI_HCD)
57 57
58 /* Zero and disable FREQ2 */ 58 /* Zero and disable FREQ2 */
59 sys_freqctrl = au_readl(SYS_FREQCTRL0); 59 sys_freqctrl = au_readl(SYS_FREQCTRL0);
@@ -87,7 +87,7 @@ void __init board_setup(void)
87 /* 2nd USB port is USB host */ 87 /* 2nd USB port is USB host */
88 pin_func |= SYS_PF_USB; 88 pin_func |= SYS_PF_USB;
89 au_writel(pin_func, SYS_PINFUNC); 89 au_writel(pin_func, SYS_PINFUNC);
90#endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */ 90#endif /* IS_ENABLED(CONFIG_USB_OHCI_HCD) */
91 91
92#ifdef CONFIG_PCI 92#ifdef CONFIG_PCI
93 { 93 {
diff --git a/arch/mips/alchemy/devboards/platform.c b/arch/mips/alchemy/devboards/platform.c
index 621f70afb63..f39042e99d0 100644
--- a/arch/mips/alchemy/devboards/platform.c
+++ b/arch/mips/alchemy/devboards/platform.c
@@ -10,9 +10,39 @@
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/pm.h> 11#include <linux/pm.h>
12 12
13#include <asm/bootinfo.h>
13#include <asm/reboot.h> 14#include <asm/reboot.h>
15#include <asm/mach-au1x00/au1000.h>
14#include <asm/mach-db1x00/bcsr.h> 16#include <asm/mach-db1x00/bcsr.h>
15 17
18#include <prom.h>
19
20void __init prom_init(void)
21{
22 unsigned char *memsize_str;
23 unsigned long memsize;
24
25 prom_argc = (int)fw_arg0;
26 prom_argv = (char **)fw_arg1;
27 prom_envp = (char **)fw_arg2;
28
29 prom_init_cmdline();
30 memsize_str = prom_getenv("memsize");
31 if (!memsize_str || kstrtoul(memsize_str, 0, &memsize))
32 memsize = 64 << 20; /* all devboards have at least 64MB RAM */
33
34 add_memory_region(0, memsize, BOOT_MEM_RAM);
35}
36
37void prom_putchar(unsigned char c)
38{
39#ifdef CONFIG_MIPS_DB1300
40 alchemy_uart_putchar(AU1300_UART2_PHYS_ADDR, c);
41#else
42 alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
43#endif
44}
45
16 46
17static struct platform_device db1x00_rtc_dev = { 47static struct platform_device db1x00_rtc_dev = {
18 .name = "rtc-au1xxx", 48 .name = "rtc-au1xxx",
diff --git a/arch/mips/alchemy/devboards/prom.c b/arch/mips/alchemy/devboards/prom.c
deleted file mode 100644
index 93a22107cc4..00000000000
--- a/arch/mips/alchemy/devboards/prom.c
+++ /dev/null
@@ -1,69 +0,0 @@
1/*
2 * Common code used by all Alchemy develboards.
3 *
4 * Extracted from files which had this to say:
5 *
6 * Copyright 2000, 2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
20 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 675 Mass Ave, Cambridge, MA 02139, USA.
28 */
29
30#include <linux/init.h>
31#include <linux/kernel.h>
32#include <asm/bootinfo.h>
33#include <asm/mach-au1x00/au1000.h>
34#include <prom.h>
35
36#if defined(CONFIG_MIPS_DB1000) || \
37 defined(CONFIG_MIPS_PB1100) || \
38 defined(CONFIG_MIPS_PB1500)
39#define ALCHEMY_BOARD_DEFAULT_MEMSIZE 0x04000000
40
41#else /* Au1550/Au1200-based develboards */
42#define ALCHEMY_BOARD_DEFAULT_MEMSIZE 0x08000000
43#endif
44
45void __init prom_init(void)
46{
47 unsigned char *memsize_str;
48 unsigned long memsize;
49
50 prom_argc = (int)fw_arg0;
51 prom_argv = (char **)fw_arg1;
52 prom_envp = (char **)fw_arg2;
53
54 prom_init_cmdline();
55 memsize_str = prom_getenv("memsize");
56 if (!memsize_str || strict_strtoul(memsize_str, 0, &memsize))
57 memsize = ALCHEMY_BOARD_DEFAULT_MEMSIZE;
58
59 add_memory_region(0, memsize, BOOT_MEM_RAM);
60}
61
62void prom_putchar(unsigned char c)
63{
64#ifdef CONFIG_MIPS_DB1300
65 alchemy_uart_putchar(AU1300_UART2_PHYS_ADDR, c);
66#else
67 alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
68#endif
69}
diff --git a/arch/mips/ar7/platform.c b/arch/mips/ar7/platform.c
index 1a24d317e7a..1bbc24b0868 100644
--- a/arch/mips/ar7/platform.c
+++ b/arch/mips/ar7/platform.c
@@ -310,10 +310,10 @@ static void __init cpmac_get_mac(int instance, unsigned char *dev_addr)
310 &dev_addr[4], &dev_addr[5]) != 6) { 310 &dev_addr[4], &dev_addr[5]) != 6) {
311 pr_warning("cannot parse mac address, " 311 pr_warning("cannot parse mac address, "
312 "using random address\n"); 312 "using random address\n");
313 random_ether_addr(dev_addr); 313 eth_random_addr(dev_addr);
314 } 314 }
315 } else 315 } else
316 random_ether_addr(dev_addr); 316 eth_random_addr(dev_addr);
317} 317}
318 318
319/***************************************************************************** 319/*****************************************************************************
diff --git a/arch/mips/ath79/dev-usb.c b/arch/mips/ath79/dev-usb.c
index 36e9570e7bc..b2a2311ec85 100644
--- a/arch/mips/ath79/dev-usb.c
+++ b/arch/mips/ath79/dev-usb.c
@@ -145,6 +145,8 @@ static void __init ar7240_usb_setup(void)
145 145
146 ath79_ohci_resources[0].start = AR7240_OHCI_BASE; 146 ath79_ohci_resources[0].start = AR7240_OHCI_BASE;
147 ath79_ohci_resources[0].end = AR7240_OHCI_BASE + AR7240_OHCI_SIZE - 1; 147 ath79_ohci_resources[0].end = AR7240_OHCI_BASE + AR7240_OHCI_SIZE - 1;
148 ath79_ohci_resources[1].start = ATH79_CPU_IRQ_USB;
149 ath79_ohci_resources[1].end = ATH79_CPU_IRQ_USB;
148 platform_device_register(&ath79_ohci_device); 150 platform_device_register(&ath79_ohci_device);
149} 151}
150 152
diff --git a/arch/mips/ath79/gpio.c b/arch/mips/ath79/gpio.c
index 29054f21183..48fe762d252 100644
--- a/arch/mips/ath79/gpio.c
+++ b/arch/mips/ath79/gpio.c
@@ -188,8 +188,10 @@ void __init ath79_gpio_init(void)
188 188
189 if (soc_is_ar71xx()) 189 if (soc_is_ar71xx())
190 ath79_gpio_count = AR71XX_GPIO_COUNT; 190 ath79_gpio_count = AR71XX_GPIO_COUNT;
191 else if (soc_is_ar724x()) 191 else if (soc_is_ar7240())
192 ath79_gpio_count = AR724X_GPIO_COUNT; 192 ath79_gpio_count = AR7240_GPIO_COUNT;
193 else if (soc_is_ar7241() || soc_is_ar7242())
194 ath79_gpio_count = AR7241_GPIO_COUNT;
193 else if (soc_is_ar913x()) 195 else if (soc_is_ar913x())
194 ath79_gpio_count = AR913X_GPIO_COUNT; 196 ath79_gpio_count = AR913X_GPIO_COUNT;
195 else if (soc_is_ar933x()) 197 else if (soc_is_ar933x())
diff --git a/arch/mips/bcm63xx/Kconfig b/arch/mips/bcm63xx/Kconfig
index 6b1b9ad8d85..d03e8799d1c 100644
--- a/arch/mips/bcm63xx/Kconfig
+++ b/arch/mips/bcm63xx/Kconfig
@@ -1,6 +1,10 @@
1menu "CPU support" 1menu "CPU support"
2 depends on BCM63XX 2 depends on BCM63XX
3 3
4config BCM63XX_CPU_6328
5 bool "support 6328 CPU"
6 select HW_HAS_PCI
7
4config BCM63XX_CPU_6338 8config BCM63XX_CPU_6338
5 bool "support 6338 CPU" 9 bool "support 6338 CPU"
6 select HW_HAS_PCI 10 select HW_HAS_PCI
diff --git a/arch/mips/bcm63xx/Makefile b/arch/mips/bcm63xx/Makefile
index 6dfdc69928a..833af72c852 100644
--- a/arch/mips/bcm63xx/Makefile
+++ b/arch/mips/bcm63xx/Makefile
@@ -1,5 +1,6 @@
1obj-y += clk.o cpu.o cs.o gpio.o irq.o prom.o setup.o timer.o \ 1obj-y += clk.o cpu.o cs.o gpio.o irq.o prom.o setup.o timer.o \
2 dev-dsp.o dev-enet.o dev-pcmcia.o dev-uart.o dev-wdt.o 2 dev-dsp.o dev-enet.o dev-flash.o dev-pcmcia.o dev-rng.o \
3 dev-spi.o dev-uart.o dev-wdt.o
3obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 4obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
4 5
5obj-y += boards/ 6obj-y += boards/
diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c
index 2f1773f3fb7..feb05258a4d 100644
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
@@ -11,9 +11,6 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/string.h> 12#include <linux/string.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/mtd/mtd.h>
15#include <linux/mtd/partitions.h>
16#include <linux/mtd/physmap.h>
17#include <linux/ssb/ssb.h> 14#include <linux/ssb/ssb.h>
18#include <asm/addrspace.h> 15#include <asm/addrspace.h>
19#include <bcm63xx_board.h> 16#include <bcm63xx_board.h>
@@ -24,7 +21,9 @@
24#include <bcm63xx_dev_pci.h> 21#include <bcm63xx_dev_pci.h>
25#include <bcm63xx_dev_enet.h> 22#include <bcm63xx_dev_enet.h>
26#include <bcm63xx_dev_dsp.h> 23#include <bcm63xx_dev_dsp.h>
24#include <bcm63xx_dev_flash.h>
27#include <bcm63xx_dev_pcmcia.h> 25#include <bcm63xx_dev_pcmcia.h>
26#include <bcm63xx_dev_spi.h>
28#include <board_bcm963xx.h> 27#include <board_bcm963xx.h>
29 28
30#define PFX "board_bcm963xx: " 29#define PFX "board_bcm963xx: "
@@ -34,6 +33,48 @@ static unsigned int mac_addr_used;
34static struct board_info board; 33static struct board_info board;
35 34
36/* 35/*
36 * known 6328 boards
37 */
38#ifdef CONFIG_BCM63XX_CPU_6328
39static struct board_info __initdata board_96328avng = {
40 .name = "96328avng",
41 .expected_cpu_id = 0x6328,
42
43 .has_uart0 = 1,
44 .has_pci = 1,
45
46 .leds = {
47 {
48 .name = "96328avng::ppp-fail",
49 .gpio = 2,
50 .active_low = 1,
51 },
52 {
53 .name = "96328avng::power",
54 .gpio = 4,
55 .active_low = 1,
56 .default_trigger = "default-on",
57 },
58 {
59 .name = "96328avng::power-fail",
60 .gpio = 8,
61 .active_low = 1,
62 },
63 {
64 .name = "96328avng::wps",
65 .gpio = 9,
66 .active_low = 1,
67 },
68 {
69 .name = "96328avng::ppp",
70 .gpio = 11,
71 .active_low = 1,
72 },
73 },
74};
75#endif
76
77/*
37 * known 6338 boards 78 * known 6338 boards
38 */ 79 */
39#ifdef CONFIG_BCM63XX_CPU_6338 80#ifdef CONFIG_BCM63XX_CPU_6338
@@ -592,6 +633,9 @@ static struct board_info __initdata board_DWVS0 = {
592 * all boards 633 * all boards
593 */ 634 */
594static const struct board_info __initdata *bcm963xx_boards[] = { 635static const struct board_info __initdata *bcm963xx_boards[] = {
636#ifdef CONFIG_BCM63XX_CPU_6328
637 &board_96328avng,
638#endif
595#ifdef CONFIG_BCM63XX_CPU_6338 639#ifdef CONFIG_BCM63XX_CPU_6338
596 &board_96338gw, 640 &board_96338gw,
597 &board_96338w, 641 &board_96338w,
@@ -709,9 +753,15 @@ void __init board_prom_init(void)
709 char cfe_version[32]; 753 char cfe_version[32];
710 u32 val; 754 u32 val;
711 755
712 /* read base address of boot chip select (0) */ 756 /* read base address of boot chip select (0)
713 val = bcm_mpi_readl(MPI_CSBASE_REG(0)); 757 * 6328 does not have MPI but boots from a fixed address
714 val &= MPI_CSBASE_BASE_MASK; 758 */
759 if (BCMCPU_IS_6328())
760 val = 0x18000000;
761 else {
762 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
763 val &= MPI_CSBASE_BASE_MASK;
764 }
715 boot_addr = (u8 *)KSEG1ADDR(val); 765 boot_addr = (u8 *)KSEG1ADDR(val);
716 766
717 /* dump cfe version */ 767 /* dump cfe version */
@@ -808,40 +858,6 @@ void __init board_setup(void)
808 panic("unexpected CPU for bcm963xx board"); 858 panic("unexpected CPU for bcm963xx board");
809} 859}
810 860
811static struct mtd_partition mtd_partitions[] = {
812 {
813 .name = "cfe",
814 .offset = 0x0,
815 .size = 0x40000,
816 }
817};
818
819static const char *bcm63xx_part_types[] = { "bcm63xxpart", NULL };
820
821static struct physmap_flash_data flash_data = {
822 .width = 2,
823 .nr_parts = ARRAY_SIZE(mtd_partitions),
824 .parts = mtd_partitions,
825 .part_probe_types = bcm63xx_part_types,
826};
827
828static struct resource mtd_resources[] = {
829 {
830 .start = 0, /* filled at runtime */
831 .end = 0, /* filled at runtime */
832 .flags = IORESOURCE_MEM,
833 }
834};
835
836static struct platform_device mtd_dev = {
837 .name = "physmap-flash",
838 .resource = mtd_resources,
839 .num_resources = ARRAY_SIZE(mtd_resources),
840 .dev = {
841 .platform_data = &flash_data,
842 },
843};
844
845static struct gpio_led_platform_data bcm63xx_led_data; 861static struct gpio_led_platform_data bcm63xx_led_data;
846 862
847static struct platform_device bcm63xx_gpio_leds = { 863static struct platform_device bcm63xx_gpio_leds = {
@@ -855,8 +871,6 @@ static struct platform_device bcm63xx_gpio_leds = {
855 */ 871 */
856int __init board_register_devices(void) 872int __init board_register_devices(void)
857{ 873{
858 u32 val;
859
860 if (board.has_uart0) 874 if (board.has_uart0)
861 bcm63xx_uart_register(0); 875 bcm63xx_uart_register(0);
862 876
@@ -890,14 +904,9 @@ int __init board_register_devices(void)
890 } 904 }
891#endif 905#endif
892 906
893 /* read base address of boot chip select (0) */ 907 bcm63xx_spi_register();
894 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
895 val &= MPI_CSBASE_BASE_MASK;
896
897 mtd_resources[0].start = val;
898 mtd_resources[0].end = 0x1FFFFFFF;
899 908
900 platform_device_register(&mtd_dev); 909 bcm63xx_flash_register();
901 910
902 bcm63xx_led_data.num_leds = ARRAY_SIZE(board.leds); 911 bcm63xx_led_data.num_leds = ARRAY_SIZE(board.leds);
903 bcm63xx_led_data.leds = board.leds; 912 bcm63xx_led_data.leds = board.leds;
diff --git a/arch/mips/bcm63xx/clk.c b/arch/mips/bcm63xx/clk.c
index 9d57c71b7b5..1db48adb543 100644
--- a/arch/mips/bcm63xx/clk.c
+++ b/arch/mips/bcm63xx/clk.c
@@ -120,7 +120,7 @@ static void enetsw_set(struct clk *clk, int enable)
120{ 120{
121 if (!BCMCPU_IS_6368()) 121 if (!BCMCPU_IS_6368())
122 return; 122 return;
123 bcm_hwclock_set(CKCTL_6368_ROBOSW_CLK_EN | 123 bcm_hwclock_set(CKCTL_6368_ROBOSW_EN |
124 CKCTL_6368_SWPKT_USB_EN | 124 CKCTL_6368_SWPKT_USB_EN |
125 CKCTL_6368_SWPKT_SAR_EN, enable); 125 CKCTL_6368_SWPKT_SAR_EN, enable);
126 if (enable) { 126 if (enable) {
@@ -163,7 +163,7 @@ static void usbh_set(struct clk *clk, int enable)
163 if (BCMCPU_IS_6348()) 163 if (BCMCPU_IS_6348())
164 bcm_hwclock_set(CKCTL_6348_USBH_EN, enable); 164 bcm_hwclock_set(CKCTL_6348_USBH_EN, enable);
165 else if (BCMCPU_IS_6368()) 165 else if (BCMCPU_IS_6368())
166 bcm_hwclock_set(CKCTL_6368_USBH_CLK_EN, enable); 166 bcm_hwclock_set(CKCTL_6368_USBH_EN, enable);
167} 167}
168 168
169static struct clk clk_usbh = { 169static struct clk clk_usbh = {
@@ -181,9 +181,11 @@ static void spi_set(struct clk *clk, int enable)
181 mask = CKCTL_6338_SPI_EN; 181 mask = CKCTL_6338_SPI_EN;
182 else if (BCMCPU_IS_6348()) 182 else if (BCMCPU_IS_6348())
183 mask = CKCTL_6348_SPI_EN; 183 mask = CKCTL_6348_SPI_EN;
184 else 184 else if (BCMCPU_IS_6358())
185 /* BCMCPU_IS_6358 */
186 mask = CKCTL_6358_SPI_EN; 185 mask = CKCTL_6358_SPI_EN;
186 else
187 /* BCMCPU_IS_6368 */
188 mask = CKCTL_6368_SPI_EN;
187 bcm_hwclock_set(mask, enable); 189 bcm_hwclock_set(mask, enable);
188} 190}
189 191
@@ -199,7 +201,7 @@ static void xtm_set(struct clk *clk, int enable)
199 if (!BCMCPU_IS_6368()) 201 if (!BCMCPU_IS_6368())
200 return; 202 return;
201 203
202 bcm_hwclock_set(CKCTL_6368_SAR_CLK_EN | 204 bcm_hwclock_set(CKCTL_6368_SAR_EN |
203 CKCTL_6368_SWPKT_SAR_EN, enable); 205 CKCTL_6368_SWPKT_SAR_EN, enable);
204 206
205 if (enable) { 207 if (enable) {
@@ -222,6 +224,18 @@ static struct clk clk_xtm = {
222}; 224};
223 225
224/* 226/*
227 * IPsec clock
228 */
229static void ipsec_set(struct clk *clk, int enable)
230{
231 bcm_hwclock_set(CKCTL_6368_IPSEC_EN, enable);
232}
233
234static struct clk clk_ipsec = {
235 .set = ipsec_set,
236};
237
238/*
225 * Internal peripheral clock 239 * Internal peripheral clock
226 */ 240 */
227static struct clk clk_periph = { 241static struct clk clk_periph = {
@@ -278,6 +292,8 @@ struct clk *clk_get(struct device *dev, const char *id)
278 return &clk_periph; 292 return &clk_periph;
279 if (BCMCPU_IS_6358() && !strcmp(id, "pcm")) 293 if (BCMCPU_IS_6358() && !strcmp(id, "pcm"))
280 return &clk_pcm; 294 return &clk_pcm;
295 if (BCMCPU_IS_6368() && !strcmp(id, "ipsec"))
296 return &clk_ipsec;
281 return ERR_PTR(-ENOENT); 297 return ERR_PTR(-ENOENT);
282} 298}
283 299
diff --git a/arch/mips/bcm63xx/cpu.c b/arch/mips/bcm63xx/cpu.c
index 8f0d6c7725e..a7afb289b15 100644
--- a/arch/mips/bcm63xx/cpu.c
+++ b/arch/mips/bcm63xx/cpu.c
@@ -29,6 +29,14 @@ static u16 bcm63xx_cpu_rev;
29static unsigned int bcm63xx_cpu_freq; 29static unsigned int bcm63xx_cpu_freq;
30static unsigned int bcm63xx_memory_size; 30static unsigned int bcm63xx_memory_size;
31 31
32static const unsigned long bcm6328_regs_base[] = {
33 __GEN_CPU_REGS_TABLE(6328)
34};
35
36static const int bcm6328_irqs[] = {
37 __GEN_CPU_IRQ_TABLE(6328)
38};
39
32static const unsigned long bcm6338_regs_base[] = { 40static const unsigned long bcm6338_regs_base[] = {
33 __GEN_CPU_REGS_TABLE(6338) 41 __GEN_CPU_REGS_TABLE(6338)
34}; 42};
@@ -99,6 +107,33 @@ unsigned int bcm63xx_get_memory_size(void)
99static unsigned int detect_cpu_clock(void) 107static unsigned int detect_cpu_clock(void)
100{ 108{
101 switch (bcm63xx_get_cpu_id()) { 109 switch (bcm63xx_get_cpu_id()) {
110 case BCM6328_CPU_ID:
111 {
112 unsigned int tmp, mips_pll_fcvo;
113
114 tmp = bcm_misc_readl(MISC_STRAPBUS_6328_REG);
115 mips_pll_fcvo = (tmp & STRAPBUS_6328_FCVO_MASK)
116 >> STRAPBUS_6328_FCVO_SHIFT;
117
118 switch (mips_pll_fcvo) {
119 case 0x12:
120 case 0x14:
121 case 0x19:
122 return 160000000;
123 case 0x1c:
124 return 192000000;
125 case 0x13:
126 case 0x15:
127 return 200000000;
128 case 0x1a:
129 return 384000000;
130 case 0x16:
131 return 400000000;
132 default:
133 return 320000000;
134 }
135
136 }
102 case BCM6338_CPU_ID: 137 case BCM6338_CPU_ID:
103 /* BCM6338 has a fixed 240 Mhz frequency */ 138 /* BCM6338 has a fixed 240 Mhz frequency */
104 return 240000000; 139 return 240000000;
@@ -170,6 +205,9 @@ static unsigned int detect_memory_size(void)
170 unsigned int cols = 0, rows = 0, is_32bits = 0, banks = 0; 205 unsigned int cols = 0, rows = 0, is_32bits = 0, banks = 0;
171 u32 val; 206 u32 val;
172 207
208 if (BCMCPU_IS_6328())
209 return bcm_ddr_readl(DDR_CSEND_REG) << 24;
210
173 if (BCMCPU_IS_6345()) { 211 if (BCMCPU_IS_6345()) {
174 val = bcm_sdram_readl(SDRAM_MBASE_REG); 212 val = bcm_sdram_readl(SDRAM_MBASE_REG);
175 return (val * 8 * 1024 * 1024); 213 return (val * 8 * 1024 * 1024);
@@ -228,17 +266,26 @@ void __init bcm63xx_cpu_init(void)
228 bcm63xx_irqs = bcm6345_irqs; 266 bcm63xx_irqs = bcm6345_irqs;
229 break; 267 break;
230 case CPU_BMIPS4350: 268 case CPU_BMIPS4350:
231 switch (read_c0_prid() & 0xf0) { 269 if ((read_c0_prid() & 0xf0) == 0x10) {
232 case 0x10:
233 expected_cpu_id = BCM6358_CPU_ID; 270 expected_cpu_id = BCM6358_CPU_ID;
234 bcm63xx_regs_base = bcm6358_regs_base; 271 bcm63xx_regs_base = bcm6358_regs_base;
235 bcm63xx_irqs = bcm6358_irqs; 272 bcm63xx_irqs = bcm6358_irqs;
236 break; 273 } else {
237 case 0x30: 274 /* all newer chips have the same chip id location */
238 expected_cpu_id = BCM6368_CPU_ID; 275 u16 chip_id = bcm_readw(BCM_6368_PERF_BASE);
239 bcm63xx_regs_base = bcm6368_regs_base; 276
240 bcm63xx_irqs = bcm6368_irqs; 277 switch (chip_id) {
241 break; 278 case BCM6328_CPU_ID:
279 expected_cpu_id = BCM6328_CPU_ID;
280 bcm63xx_regs_base = bcm6328_regs_base;
281 bcm63xx_irqs = bcm6328_irqs;
282 break;
283 case BCM6368_CPU_ID:
284 expected_cpu_id = BCM6368_CPU_ID;
285 bcm63xx_regs_base = bcm6368_regs_base;
286 bcm63xx_irqs = bcm6368_irqs;
287 break;
288 }
242 } 289 }
243 break; 290 break;
244 } 291 }
diff --git a/arch/mips/bcm63xx/dev-dsp.c b/arch/mips/bcm63xx/dev-dsp.c
index da46d1d3c77..5bb5b154c9b 100644
--- a/arch/mips/bcm63xx/dev-dsp.c
+++ b/arch/mips/bcm63xx/dev-dsp.c
@@ -31,7 +31,7 @@ static struct resource voip_dsp_resources[] = {
31 31
32static struct platform_device bcm63xx_voip_dsp_device = { 32static struct platform_device bcm63xx_voip_dsp_device = {
33 .name = "bcm63xx-voip-dsp", 33 .name = "bcm63xx-voip-dsp",
34 .id = 0, 34 .id = -1,
35 .num_resources = ARRAY_SIZE(voip_dsp_resources), 35 .num_resources = ARRAY_SIZE(voip_dsp_resources),
36 .resource = voip_dsp_resources, 36 .resource = voip_dsp_resources,
37}; 37};
diff --git a/arch/mips/bcm63xx/dev-flash.c b/arch/mips/bcm63xx/dev-flash.c
new file mode 100644
index 00000000000..58371c7deac
--- /dev/null
+++ b/arch/mips/bcm63xx/dev-flash.c
@@ -0,0 +1,123 @@
1/*
2 * Broadcom BCM63xx flash registration
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
9 * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
10 * Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com>
11 */
12
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/platform_device.h>
16#include <linux/mtd/mtd.h>
17#include <linux/mtd/partitions.h>
18#include <linux/mtd/physmap.h>
19
20#include <bcm63xx_cpu.h>
21#include <bcm63xx_dev_flash.h>
22#include <bcm63xx_regs.h>
23#include <bcm63xx_io.h>
24
25static struct mtd_partition mtd_partitions[] = {
26 {
27 .name = "cfe",
28 .offset = 0x0,
29 .size = 0x40000,
30 }
31};
32
33static const char *bcm63xx_part_types[] = { "bcm63xxpart", NULL };
34
35static struct physmap_flash_data flash_data = {
36 .width = 2,
37 .parts = mtd_partitions,
38 .part_probe_types = bcm63xx_part_types,
39};
40
41static struct resource mtd_resources[] = {
42 {
43 .start = 0, /* filled at runtime */
44 .end = 0, /* filled at runtime */
45 .flags = IORESOURCE_MEM,
46 }
47};
48
49static struct platform_device mtd_dev = {
50 .name = "physmap-flash",
51 .resource = mtd_resources,
52 .num_resources = ARRAY_SIZE(mtd_resources),
53 .dev = {
54 .platform_data = &flash_data,
55 },
56};
57
58static int __init bcm63xx_detect_flash_type(void)
59{
60 u32 val;
61
62 switch (bcm63xx_get_cpu_id()) {
63 case BCM6328_CPU_ID:
64 val = bcm_misc_readl(MISC_STRAPBUS_6328_REG);
65 if (val & STRAPBUS_6328_BOOT_SEL_SERIAL)
66 return BCM63XX_FLASH_TYPE_SERIAL;
67 else
68 return BCM63XX_FLASH_TYPE_NAND;
69 case BCM6338_CPU_ID:
70 case BCM6345_CPU_ID:
71 case BCM6348_CPU_ID:
72 /* no way to auto detect so assume parallel */
73 return BCM63XX_FLASH_TYPE_PARALLEL;
74 case BCM6358_CPU_ID:
75 val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
76 if (val & STRAPBUS_6358_BOOT_SEL_PARALLEL)
77 return BCM63XX_FLASH_TYPE_PARALLEL;
78 else
79 return BCM63XX_FLASH_TYPE_SERIAL;
80 case BCM6368_CPU_ID:
81 val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
82 switch (val & STRAPBUS_6368_BOOT_SEL_MASK) {
83 case STRAPBUS_6368_BOOT_SEL_NAND:
84 return BCM63XX_FLASH_TYPE_NAND;
85 case STRAPBUS_6368_BOOT_SEL_SERIAL:
86 return BCM63XX_FLASH_TYPE_SERIAL;
87 case STRAPBUS_6368_BOOT_SEL_PARALLEL:
88 return BCM63XX_FLASH_TYPE_PARALLEL;
89 }
90 default:
91 return -EINVAL;
92 }
93}
94
95int __init bcm63xx_flash_register(void)
96{
97 int flash_type;
98 u32 val;
99
100 flash_type = bcm63xx_detect_flash_type();
101
102 switch (flash_type) {
103 case BCM63XX_FLASH_TYPE_PARALLEL:
104 /* read base address of boot chip select (0) */
105 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
106 val &= MPI_CSBASE_BASE_MASK;
107
108 mtd_resources[0].start = val;
109 mtd_resources[0].end = 0x1FFFFFFF;
110
111 return platform_device_register(&mtd_dev);
112 case BCM63XX_FLASH_TYPE_SERIAL:
113 pr_warn("unsupported serial flash detected\n");
114 return -ENODEV;
115 case BCM63XX_FLASH_TYPE_NAND:
116 pr_warn("unsupported NAND flash detected\n");
117 return -ENODEV;
118 default:
119 pr_err("flash detection failed for BCM%x: %d\n",
120 bcm63xx_get_cpu_id(), flash_type);
121 return -ENODEV;
122 }
123}
diff --git a/arch/mips/bcm63xx/dev-rng.c b/arch/mips/bcm63xx/dev-rng.c
new file mode 100644
index 00000000000..d277b4dc6c6
--- /dev/null
+++ b/arch/mips/bcm63xx/dev-rng.c
@@ -0,0 +1,40 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2011 Florian Fainelli <florian@openwrt.org>
7 */
8
9#include <linux/init.h>
10#include <linux/kernel.h>
11#include <linux/platform_device.h>
12#include <bcm63xx_cpu.h>
13
14static struct resource rng_resources[] = {
15 {
16 .start = -1, /* filled at runtime */
17 .end = -1, /* filled at runtime */
18 .flags = IORESOURCE_MEM,
19 },
20};
21
22static struct platform_device bcm63xx_rng_device = {
23 .name = "bcm63xx-rng",
24 .id = -1,
25 .num_resources = ARRAY_SIZE(rng_resources),
26 .resource = rng_resources,
27};
28
29int __init bcm63xx_rng_register(void)
30{
31 if (!BCMCPU_IS_6368())
32 return -ENODEV;
33
34 rng_resources[0].start = bcm63xx_regset_address(RSET_RNG);
35 rng_resources[0].end = rng_resources[0].start;
36 rng_resources[0].end += RSET_RNG_SIZE - 1;
37
38 return platform_device_register(&bcm63xx_rng_device);
39}
40arch_initcall(bcm63xx_rng_register);
diff --git a/arch/mips/bcm63xx/dev-spi.c b/arch/mips/bcm63xx/dev-spi.c
new file mode 100644
index 00000000000..f1c9c3e2f67
--- /dev/null
+++ b/arch/mips/bcm63xx/dev-spi.c
@@ -0,0 +1,123 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2009-2011 Florian Fainelli <florian@openwrt.org>
7 * Copyright (C) 2010 Tanguy Bouzeloc <tanguy.bouzeloc@efixo.com>
8 */
9
10#include <linux/init.h>
11#include <linux/kernel.h>
12#include <linux/export.h>
13#include <linux/platform_device.h>
14#include <linux/err.h>
15#include <linux/clk.h>
16
17#include <bcm63xx_cpu.h>
18#include <bcm63xx_dev_spi.h>
19#include <bcm63xx_regs.h>
20
21#ifdef BCMCPU_RUNTIME_DETECT
22/*
23 * register offsets
24 */
25static const unsigned long bcm6338_regs_spi[] = {
26 __GEN_SPI_REGS_TABLE(6338)
27};
28
29static const unsigned long bcm6348_regs_spi[] = {
30 __GEN_SPI_REGS_TABLE(6348)
31};
32
33static const unsigned long bcm6358_regs_spi[] = {
34 __GEN_SPI_REGS_TABLE(6358)
35};
36
37static const unsigned long bcm6368_regs_spi[] = {
38 __GEN_SPI_REGS_TABLE(6368)
39};
40
41const unsigned long *bcm63xx_regs_spi;
42EXPORT_SYMBOL(bcm63xx_regs_spi);
43
44static __init void bcm63xx_spi_regs_init(void)
45{
46 if (BCMCPU_IS_6338())
47 bcm63xx_regs_spi = bcm6338_regs_spi;
48 if (BCMCPU_IS_6348())
49 bcm63xx_regs_spi = bcm6348_regs_spi;
50 if (BCMCPU_IS_6358())
51 bcm63xx_regs_spi = bcm6358_regs_spi;
52 if (BCMCPU_IS_6368())
53 bcm63xx_regs_spi = bcm6368_regs_spi;
54}
55#else
56static __init void bcm63xx_spi_regs_init(void) { }
57#endif
58
59static struct resource spi_resources[] = {
60 {
61 .start = -1, /* filled at runtime */
62 .end = -1, /* filled at runtime */
63 .flags = IORESOURCE_MEM,
64 },
65 {
66 .start = -1, /* filled at runtime */
67 .flags = IORESOURCE_IRQ,
68 },
69};
70
71static struct bcm63xx_spi_pdata spi_pdata = {
72 .bus_num = 0,
73 .num_chipselect = 8,
74};
75
76static struct platform_device bcm63xx_spi_device = {
77 .name = "bcm63xx-spi",
78 .id = -1,
79 .num_resources = ARRAY_SIZE(spi_resources),
80 .resource = spi_resources,
81 .dev = {
82 .platform_data = &spi_pdata,
83 },
84};
85
86int __init bcm63xx_spi_register(void)
87{
88 struct clk *periph_clk;
89
90 if (BCMCPU_IS_6328() || BCMCPU_IS_6345())
91 return -ENODEV;
92
93 periph_clk = clk_get(NULL, "periph");
94 if (IS_ERR(periph_clk)) {
95 pr_err("unable to get periph clock\n");
96 return -ENODEV;
97 }
98
99 /* Set bus frequency */
100 spi_pdata.speed_hz = clk_get_rate(periph_clk);
101
102 spi_resources[0].start = bcm63xx_regset_address(RSET_SPI);
103 spi_resources[0].end = spi_resources[0].start;
104 spi_resources[1].start = bcm63xx_get_irq_number(IRQ_SPI);
105
106 if (BCMCPU_IS_6338() || BCMCPU_IS_6348()) {
107 spi_resources[0].end += BCM_6338_RSET_SPI_SIZE - 1;
108 spi_pdata.fifo_size = SPI_6338_MSG_DATA_SIZE;
109 spi_pdata.msg_type_shift = SPI_6338_MSG_TYPE_SHIFT;
110 spi_pdata.msg_ctl_width = SPI_6338_MSG_CTL_WIDTH;
111 }
112
113 if (BCMCPU_IS_6358() || BCMCPU_IS_6368()) {
114 spi_resources[0].end += BCM_6358_RSET_SPI_SIZE - 1;
115 spi_pdata.fifo_size = SPI_6358_MSG_DATA_SIZE;
116 spi_pdata.msg_type_shift = SPI_6358_MSG_TYPE_SHIFT;
117 spi_pdata.msg_ctl_width = SPI_6358_MSG_CTL_WIDTH;
118 }
119
120 bcm63xx_spi_regs_init();
121
122 return platform_device_register(&bcm63xx_spi_device);
123}
diff --git a/arch/mips/bcm63xx/dev-wdt.c b/arch/mips/bcm63xx/dev-wdt.c
index 3e6c716a4c1..2a2346a99bc 100644
--- a/arch/mips/bcm63xx/dev-wdt.c
+++ b/arch/mips/bcm63xx/dev-wdt.c
@@ -21,7 +21,7 @@ static struct resource wdt_resources[] = {
21 21
22static struct platform_device bcm63xx_wdt_device = { 22static struct platform_device bcm63xx_wdt_device = {
23 .name = "bcm63xx-wdt", 23 .name = "bcm63xx-wdt",
24 .id = 0, 24 .id = -1,
25 .num_resources = ARRAY_SIZE(wdt_resources), 25 .num_resources = ARRAY_SIZE(wdt_resources),
26 .resource = wdt_resources, 26 .resource = wdt_resources,
27}; 27};
diff --git a/arch/mips/bcm63xx/irq.c b/arch/mips/bcm63xx/irq.c
index 9a216a451d9..18e051ad18a 100644
--- a/arch/mips/bcm63xx/irq.c
+++ b/arch/mips/bcm63xx/irq.c
@@ -27,6 +27,17 @@ static void __internal_irq_unmask_32(unsigned int irq) __maybe_unused;
27static void __internal_irq_unmask_64(unsigned int irq) __maybe_unused; 27static void __internal_irq_unmask_64(unsigned int irq) __maybe_unused;
28 28
29#ifndef BCMCPU_RUNTIME_DETECT 29#ifndef BCMCPU_RUNTIME_DETECT
30#ifdef CONFIG_BCM63XX_CPU_6328
31#define irq_stat_reg PERF_IRQSTAT_6328_REG
32#define irq_mask_reg PERF_IRQMASK_6328_REG
33#define irq_bits 64
34#define is_ext_irq_cascaded 1
35#define ext_irq_start (BCM_6328_EXT_IRQ0 - IRQ_INTERNAL_BASE)
36#define ext_irq_end (BCM_6328_EXT_IRQ3 - IRQ_INTERNAL_BASE)
37#define ext_irq_count 4
38#define ext_irq_cfg_reg1 PERF_EXTIRQ_CFG_REG_6328
39#define ext_irq_cfg_reg2 0
40#endif
30#ifdef CONFIG_BCM63XX_CPU_6338 41#ifdef CONFIG_BCM63XX_CPU_6338
31#define irq_stat_reg PERF_IRQSTAT_6338_REG 42#define irq_stat_reg PERF_IRQSTAT_6338_REG
32#define irq_mask_reg PERF_IRQMASK_6338_REG 43#define irq_mask_reg PERF_IRQMASK_6338_REG
@@ -118,6 +129,16 @@ static void bcm63xx_init_irq(void)
118 irq_mask_addr = bcm63xx_regset_address(RSET_PERF); 129 irq_mask_addr = bcm63xx_regset_address(RSET_PERF);
119 130
120 switch (bcm63xx_get_cpu_id()) { 131 switch (bcm63xx_get_cpu_id()) {
132 case BCM6328_CPU_ID:
133 irq_stat_addr += PERF_IRQSTAT_6328_REG;
134 irq_mask_addr += PERF_IRQMASK_6328_REG;
135 irq_bits = 64;
136 ext_irq_count = 4;
137 is_ext_irq_cascaded = 1;
138 ext_irq_start = BCM_6328_EXT_IRQ0 - IRQ_INTERNAL_BASE;
139 ext_irq_end = BCM_6328_EXT_IRQ3 - IRQ_INTERNAL_BASE;
140 ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_6328;
141 break;
121 case BCM6338_CPU_ID: 142 case BCM6338_CPU_ID:
122 irq_stat_addr += PERF_IRQSTAT_6338_REG; 143 irq_stat_addr += PERF_IRQSTAT_6338_REG;
123 irq_mask_addr += PERF_IRQMASK_6338_REG; 144 irq_mask_addr += PERF_IRQMASK_6338_REG;
diff --git a/arch/mips/bcm63xx/prom.c b/arch/mips/bcm63xx/prom.c
index 99d7f405cbe..10eaff45807 100644
--- a/arch/mips/bcm63xx/prom.c
+++ b/arch/mips/bcm63xx/prom.c
@@ -26,7 +26,9 @@ void __init prom_init(void)
26 bcm_wdt_writel(WDT_STOP_2, WDT_CTL_REG); 26 bcm_wdt_writel(WDT_STOP_2, WDT_CTL_REG);
27 27
28 /* disable all hardware blocks clock for now */ 28 /* disable all hardware blocks clock for now */
29 if (BCMCPU_IS_6338()) 29 if (BCMCPU_IS_6328())
30 mask = CKCTL_6328_ALL_SAFE_EN;
31 else if (BCMCPU_IS_6338())
30 mask = CKCTL_6338_ALL_SAFE_EN; 32 mask = CKCTL_6338_ALL_SAFE_EN;
31 else if (BCMCPU_IS_6345()) 33 else if (BCMCPU_IS_6345())
32 mask = CKCTL_6345_ALL_SAFE_EN; 34 mask = CKCTL_6345_ALL_SAFE_EN;
diff --git a/arch/mips/bcm63xx/setup.c b/arch/mips/bcm63xx/setup.c
index 356b05583e1..0e74a13639c 100644
--- a/arch/mips/bcm63xx/setup.c
+++ b/arch/mips/bcm63xx/setup.c
@@ -68,6 +68,9 @@ void bcm63xx_machine_reboot(void)
68 68
69 /* mask and clear all external irq */ 69 /* mask and clear all external irq */
70 switch (bcm63xx_get_cpu_id()) { 70 switch (bcm63xx_get_cpu_id()) {
71 case BCM6328_CPU_ID:
72 perf_regs[0] = PERF_EXTIRQ_CFG_REG_6328;
73 break;
71 case BCM6338_CPU_ID: 74 case BCM6338_CPU_ID:
72 perf_regs[0] = PERF_EXTIRQ_CFG_REG_6338; 75 perf_regs[0] = PERF_EXTIRQ_CFG_REG_6338;
73 break; 76 break;
@@ -95,9 +98,13 @@ void bcm63xx_machine_reboot(void)
95 bcm6348_a1_reboot(); 98 bcm6348_a1_reboot();
96 99
97 printk(KERN_INFO "triggering watchdog soft-reset...\n"); 100 printk(KERN_INFO "triggering watchdog soft-reset...\n");
98 reg = bcm_perf_readl(PERF_SYS_PLL_CTL_REG); 101 if (BCMCPU_IS_6328()) {
99 reg |= SYS_PLL_SOFT_RESET; 102 bcm_wdt_writel(1, WDT_SOFTRESET_REG);
100 bcm_perf_writel(reg, PERF_SYS_PLL_CTL_REG); 103 } else {
104 reg = bcm_perf_readl(PERF_SYS_PLL_CTL_REG);
105 reg |= SYS_PLL_SOFT_RESET;
106 bcm_perf_writel(reg, PERF_SYS_PLL_CTL_REG);
107 }
101 while (1) 108 while (1)
102 ; 109 ;
103} 110}
diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile
index 5042d51b051..c2a3fb0ffc8 100644
--- a/arch/mips/boot/compressed/Makefile
+++ b/arch/mips/boot/compressed/Makefile
@@ -58,8 +58,12 @@ $(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
58# Calculate the load address of the compressed kernel image 58# Calculate the load address of the compressed kernel image
59hostprogs-y := calc_vmlinuz_load_addr 59hostprogs-y := calc_vmlinuz_load_addr
60 60
61ifeq ($(CONFIG_MACH_JZ4740),y)
62VMLINUZ_LOAD_ADDRESS := 0x80600000
63else
61VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \ 64VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
62 $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS)) 65 $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS))
66endif
63 67
64vmlinuzobjs-y += $(obj)/piggy.o 68vmlinuzobjs-y += $(obj)/piggy.o
65 69
diff --git a/arch/mips/boot/compressed/uart-16550.c b/arch/mips/boot/compressed/uart-16550.c
index c9caaf4fbf6..1c7b739b6a1 100644
--- a/arch/mips/boot/compressed/uart-16550.c
+++ b/arch/mips/boot/compressed/uart-16550.c
@@ -18,6 +18,11 @@
18#define PORT(offset) (CKSEG1ADDR(AR7_REGS_UART0) + (4 * offset)) 18#define PORT(offset) (CKSEG1ADDR(AR7_REGS_UART0) + (4 * offset))
19#endif 19#endif
20 20
21#ifdef CONFIG_MACH_JZ4740
22#define UART0_BASE 0xB0030000
23#define PORT(offset) (UART0_BASE + (4 * offset))
24#endif
25
21#ifndef PORT 26#ifndef PORT
22#error please define the serial port address for your own machine 27#error please define the serial port address for your own machine
23#endif 28#endif
diff --git a/arch/mips/cavium-octeon/.gitignore b/arch/mips/cavium-octeon/.gitignore
new file mode 100644
index 00000000000..39c968605ff
--- /dev/null
+++ b/arch/mips/cavium-octeon/.gitignore
@@ -0,0 +1,2 @@
1*.dtb.S
2*.dtb
diff --git a/arch/mips/cavium-octeon/Makefile b/arch/mips/cavium-octeon/Makefile
index 19eb0434269..bc96e2908f1 100644
--- a/arch/mips/cavium-octeon/Makefile
+++ b/arch/mips/cavium-octeon/Makefile
@@ -9,9 +9,25 @@
9# Copyright (C) 2005-2009 Cavium Networks 9# Copyright (C) 2005-2009 Cavium Networks
10# 10#
11 11
12CFLAGS_octeon-platform.o = -I$(src)/../../../scripts/dtc/libfdt
13CFLAGS_setup.o = -I$(src)/../../../scripts/dtc/libfdt
14
12obj-y := cpu.o setup.o serial.o octeon-platform.o octeon-irq.o csrc-octeon.o 15obj-y := cpu.o setup.o serial.o octeon-platform.o octeon-irq.o csrc-octeon.o
13obj-y += dma-octeon.o flash_setup.o 16obj-y += dma-octeon.o flash_setup.o
14obj-y += octeon-memcpy.o 17obj-y += octeon-memcpy.o
15obj-y += executive/ 18obj-y += executive/
16 19
17obj-$(CONFIG_SMP) += smp.o 20obj-$(CONFIG_SMP) += smp.o
21
22DTS_FILES = octeon_3xxx.dts octeon_68xx.dts
23DTB_FILES = $(patsubst %.dts, %.dtb, $(DTS_FILES))
24
25obj-y += $(patsubst %.dts, %.dtb.o, $(DTS_FILES))
26
27$(obj)/%.dtb: $(src)/%.dts FORCE
28 $(call if_changed_dep,dtc)
29
30# Let's keep the .dtb files around in case we want to look at them.
31.SECONDARY: $(addprefix $(obj)/, $(DTB_FILES))
32
33clean-files += $(DTB_FILES) $(patsubst %.dtb, %.dtb.S, $(DTB_FILES))
diff --git a/arch/mips/cavium-octeon/executive/cvmx-fpa.c b/arch/mips/cavium-octeon/executive/cvmx-fpa.c
deleted file mode 100644
index ad44b8bd805..00000000000
--- a/arch/mips/cavium-octeon/executive/cvmx-fpa.c
+++ /dev/null
@@ -1,183 +0,0 @@
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-2008 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/**
29 * @file
30 *
31 * Support library for the hardware Free Pool Allocator.
32 *
33 *
34 */
35
36#include "cvmx-config.h"
37#include "cvmx.h"
38#include "cvmx-fpa.h"
39#include "cvmx-ipd.h"
40
41/**
42 * Current state of all the pools. Use access functions
43 * instead of using it directly.
44 */
45CVMX_SHARED cvmx_fpa_pool_info_t cvmx_fpa_pool_info[CVMX_FPA_NUM_POOLS];
46
47/**
48 * Setup a FPA pool to control a new block of memory. The
49 * buffer pointer must be a physical address.
50 *
51 * @pool: Pool to initialize
52 * 0 <= pool < 8
53 * @name: Constant character string to name this pool.
54 * String is not copied.
55 * @buffer: Pointer to the block of memory to use. This must be
56 * accessible by all processors and external hardware.
57 * @block_size: Size for each block controlled by the FPA
58 * @num_blocks: Number of blocks
59 *
60 * Returns 0 on Success,
61 * -1 on failure
62 */
63int cvmx_fpa_setup_pool(uint64_t pool, const char *name, void *buffer,
64 uint64_t block_size, uint64_t num_blocks)
65{
66 char *ptr;
67 if (!buffer) {
68 cvmx_dprintf
69 ("ERROR: cvmx_fpa_setup_pool: NULL buffer pointer!\n");
70 return -1;
71 }
72 if (pool >= CVMX_FPA_NUM_POOLS) {
73 cvmx_dprintf("ERROR: cvmx_fpa_setup_pool: Illegal pool!\n");
74 return -1;
75 }
76
77 if (block_size < CVMX_FPA_MIN_BLOCK_SIZE) {
78 cvmx_dprintf
79 ("ERROR: cvmx_fpa_setup_pool: Block size too small.\n");
80 return -1;
81 }
82
83 if (((unsigned long)buffer & (CVMX_FPA_ALIGNMENT - 1)) != 0) {
84 cvmx_dprintf
85 ("ERROR: cvmx_fpa_setup_pool: Buffer not aligned properly.\n");
86 return -1;
87 }
88
89 cvmx_fpa_pool_info[pool].name = name;
90 cvmx_fpa_pool_info[pool].size = block_size;
91 cvmx_fpa_pool_info[pool].starting_element_count = num_blocks;
92 cvmx_fpa_pool_info[pool].base = buffer;
93
94 ptr = (char *)buffer;
95 while (num_blocks--) {
96 cvmx_fpa_free(ptr, pool, 0);
97 ptr += block_size;
98 }
99 return 0;
100}
101
102/**
103 * Shutdown a Memory pool and validate that it had all of
104 * the buffers originally placed in it.
105 *
106 * @pool: Pool to shutdown
107 * Returns Zero on success
108 * - Positive is count of missing buffers
109 * - Negative is too many buffers or corrupted pointers
110 */
111uint64_t cvmx_fpa_shutdown_pool(uint64_t pool)
112{
113 uint64_t errors = 0;
114 uint64_t count = 0;
115 uint64_t base = cvmx_ptr_to_phys(cvmx_fpa_pool_info[pool].base);
116 uint64_t finish =
117 base +
118 cvmx_fpa_pool_info[pool].size *
119 cvmx_fpa_pool_info[pool].starting_element_count;
120 void *ptr;
121 uint64_t address;
122
123 count = 0;
124 do {
125 ptr = cvmx_fpa_alloc(pool);
126 if (ptr)
127 address = cvmx_ptr_to_phys(ptr);
128 else
129 address = 0;
130 if (address) {
131 if ((address >= base) && (address < finish) &&
132 (((address -
133 base) % cvmx_fpa_pool_info[pool].size) == 0)) {
134 count++;
135 } else {
136 cvmx_dprintf
137 ("ERROR: cvmx_fpa_shutdown_pool: Illegal address 0x%llx in pool %s(%d)\n",
138 (unsigned long long)address,
139 cvmx_fpa_pool_info[pool].name, (int)pool);
140 errors++;
141 }
142 }
143 } while (address);
144
145#ifdef CVMX_ENABLE_PKO_FUNCTIONS
146 if (pool == 0)
147 cvmx_ipd_free_ptr();
148#endif
149
150 if (errors) {
151 cvmx_dprintf
152 ("ERROR: cvmx_fpa_shutdown_pool: Pool %s(%d) started at 0x%llx, ended at 0x%llx, with a step of 0x%llx\n",
153 cvmx_fpa_pool_info[pool].name, (int)pool,
154 (unsigned long long)base, (unsigned long long)finish,
155 (unsigned long long)cvmx_fpa_pool_info[pool].size);
156 return -errors;
157 } else
158 return 0;
159}
160
161uint64_t cvmx_fpa_get_block_size(uint64_t pool)
162{
163 switch (pool) {
164 case 0:
165 return CVMX_FPA_POOL_0_SIZE;
166 case 1:
167 return CVMX_FPA_POOL_1_SIZE;
168 case 2:
169 return CVMX_FPA_POOL_2_SIZE;
170 case 3:
171 return CVMX_FPA_POOL_3_SIZE;
172 case 4:
173 return CVMX_FPA_POOL_4_SIZE;
174 case 5:
175 return CVMX_FPA_POOL_5_SIZE;
176 case 6:
177 return CVMX_FPA_POOL_6_SIZE;
178 case 7:
179 return CVMX_FPA_POOL_7_SIZE;
180 default:
181 return 0;
182 }
183}
diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper-fpa.c b/arch/mips/cavium-octeon/executive/cvmx-helper-fpa.c
deleted file mode 100644
index c239e5f4ab9..00000000000
--- a/arch/mips/cavium-octeon/executive/cvmx-helper-fpa.c
+++ /dev/null
@@ -1,243 +0,0 @@
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-2008 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/**
29 * @file
30 *
31 * Helper functions for FPA setup.
32 *
33 */
34#include "executive-config.h"
35#include "cvmx-config.h"
36#include "cvmx.h"
37#include "cvmx-bootmem.h"
38#include "cvmx-fpa.h"
39#include "cvmx-helper-fpa.h"
40
41/**
42 * Allocate memory for and initialize a single FPA pool.
43 *
44 * @pool: Pool to initialize
45 * @buffer_size: Size of buffers to allocate in bytes
46 * @buffers: Number of buffers to put in the pool. Zero is allowed
47 * @name: String name of the pool for debugging purposes
48 * Returns Zero on success, non-zero on failure
49 */
50static int __cvmx_helper_initialize_fpa_pool(int pool, uint64_t buffer_size,
51 uint64_t buffers, const char *name)
52{
53 uint64_t current_num;
54 void *memory;
55 uint64_t align = CVMX_CACHE_LINE_SIZE;
56
57 /*
58 * Align the allocation so that power of 2 size buffers are
59 * naturally aligned.
60 */
61 while (align < buffer_size)
62 align = align << 1;
63
64 if (buffers == 0)
65 return 0;
66
67 current_num = cvmx_read_csr(CVMX_FPA_QUEX_AVAILABLE(pool));
68 if (current_num) {
69 cvmx_dprintf("Fpa pool %d(%s) already has %llu buffers. "
70 "Skipping setup.\n",
71 pool, name, (unsigned long long)current_num);
72 return 0;
73 }
74
75 memory = cvmx_bootmem_alloc(buffer_size * buffers, align);
76 if (memory == NULL) {
77 cvmx_dprintf("Out of memory initializing fpa pool %d(%s).\n",
78 pool, name);
79 return -1;
80 }
81 cvmx_fpa_setup_pool(pool, name, memory, buffer_size, buffers);
82 return 0;
83}
84
85/**
86 * Allocate memory and initialize the FPA pools using memory
87 * from cvmx-bootmem. Specifying zero for the number of
88 * buffers will cause that FPA pool to not be setup. This is
89 * useful if you aren't using some of the hardware and want
90 * to save memory. Use cvmx_helper_initialize_fpa instead of
91 * this function directly.
92 *
93 * @pip_pool: Should always be CVMX_FPA_PACKET_POOL
94 * @pip_size: Should always be CVMX_FPA_PACKET_POOL_SIZE
95 * @pip_buffers:
96 * Number of packet buffers.
97 * @wqe_pool: Should always be CVMX_FPA_WQE_POOL
98 * @wqe_size: Should always be CVMX_FPA_WQE_POOL_SIZE
99 * @wqe_entries:
100 * Number of work queue entries
101 * @pko_pool: Should always be CVMX_FPA_OUTPUT_BUFFER_POOL
102 * @pko_size: Should always be CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE
103 * @pko_buffers:
104 * PKO Command buffers. You should at minimum have two per
105 * each PKO queue.
106 * @tim_pool: Should always be CVMX_FPA_TIMER_POOL
107 * @tim_size: Should always be CVMX_FPA_TIMER_POOL_SIZE
108 * @tim_buffers:
109 * TIM ring buffer command queues. At least two per timer bucket
110 * is recommened.
111 * @dfa_pool: Should always be CVMX_FPA_DFA_POOL
112 * @dfa_size: Should always be CVMX_FPA_DFA_POOL_SIZE
113 * @dfa_buffers:
114 * DFA command buffer. A relatively small (32 for example)
115 * number should work.
116 * Returns Zero on success, non-zero if out of memory
117 */
118static int __cvmx_helper_initialize_fpa(int pip_pool, int pip_size,
119 int pip_buffers, int wqe_pool,
120 int wqe_size, int wqe_entries,
121 int pko_pool, int pko_size,
122 int pko_buffers, int tim_pool,
123 int tim_size, int tim_buffers,
124 int dfa_pool, int dfa_size,
125 int dfa_buffers)
126{
127 int status;
128
129 cvmx_fpa_enable();
130
131 if ((pip_buffers > 0) && (pip_buffers <= 64))
132 cvmx_dprintf
133 ("Warning: %d packet buffers may not be enough for hardware"
134 " prefetch. 65 or more is recommended.\n", pip_buffers);
135
136 if (pip_pool >= 0) {
137 status =
138 __cvmx_helper_initialize_fpa_pool(pip_pool, pip_size,
139 pip_buffers,
140 "Packet Buffers");
141 if (status)
142 return status;
143 }
144
145 if (wqe_pool >= 0) {
146 status =
147 __cvmx_helper_initialize_fpa_pool(wqe_pool, wqe_size,
148 wqe_entries,
149 "Work Queue Entries");
150 if (status)
151 return status;
152 }
153
154 if (pko_pool >= 0) {
155 status =
156 __cvmx_helper_initialize_fpa_pool(pko_pool, pko_size,
157 pko_buffers,
158 "PKO Command Buffers");
159 if (status)
160 return status;
161 }
162
163 if (tim_pool >= 0) {
164 status =
165 __cvmx_helper_initialize_fpa_pool(tim_pool, tim_size,
166 tim_buffers,
167 "TIM Command Buffers");
168 if (status)
169 return status;
170 }
171
172 if (dfa_pool >= 0) {
173 status =
174 __cvmx_helper_initialize_fpa_pool(dfa_pool, dfa_size,
175 dfa_buffers,
176 "DFA Command Buffers");
177 if (status)
178 return status;
179 }
180
181 return 0;
182}
183
184/**
185 * Allocate memory and initialize the FPA pools using memory
186 * from cvmx-bootmem. Sizes of each element in the pools is
187 * controlled by the cvmx-config.h header file. Specifying
188 * zero for any parameter will cause that FPA pool to not be
189 * setup. This is useful if you aren't using some of the
190 * hardware and want to save memory.
191 *
192 * @packet_buffers:
193 * Number of packet buffers to allocate
194 * @work_queue_entries:
195 * Number of work queue entries
196 * @pko_buffers:
197 * PKO Command buffers. You should at minimum have two per
198 * each PKO queue.
199 * @tim_buffers:
200 * TIM ring buffer command queues. At least two per timer bucket
201 * is recommened.
202 * @dfa_buffers:
203 * DFA command buffer. A relatively small (32 for example)
204 * number should work.
205 * Returns Zero on success, non-zero if out of memory
206 */
207int cvmx_helper_initialize_fpa(int packet_buffers, int work_queue_entries,
208 int pko_buffers, int tim_buffers,
209 int dfa_buffers)
210{
211#ifndef CVMX_FPA_PACKET_POOL
212#define CVMX_FPA_PACKET_POOL -1
213#define CVMX_FPA_PACKET_POOL_SIZE 0
214#endif
215#ifndef CVMX_FPA_WQE_POOL
216#define CVMX_FPA_WQE_POOL -1
217#define CVMX_FPA_WQE_POOL_SIZE 0
218#endif
219#ifndef CVMX_FPA_OUTPUT_BUFFER_POOL
220#define CVMX_FPA_OUTPUT_BUFFER_POOL -1
221#define CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE 0
222#endif
223#ifndef CVMX_FPA_TIMER_POOL
224#define CVMX_FPA_TIMER_POOL -1
225#define CVMX_FPA_TIMER_POOL_SIZE 0
226#endif
227#ifndef CVMX_FPA_DFA_POOL
228#define CVMX_FPA_DFA_POOL -1
229#define CVMX_FPA_DFA_POOL_SIZE 0
230#endif
231 return __cvmx_helper_initialize_fpa(CVMX_FPA_PACKET_POOL,
232 CVMX_FPA_PACKET_POOL_SIZE,
233 packet_buffers, CVMX_FPA_WQE_POOL,
234 CVMX_FPA_WQE_POOL_SIZE,
235 work_queue_entries,
236 CVMX_FPA_OUTPUT_BUFFER_POOL,
237 CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE,
238 pko_buffers, CVMX_FPA_TIMER_POOL,
239 CVMX_FPA_TIMER_POOL_SIZE,
240 tim_buffers, CVMX_FPA_DFA_POOL,
241 CVMX_FPA_DFA_POOL_SIZE,
242 dfa_buffers);
243}
diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octeon-irq.c
index ffd4ae660f7..274cd4fad30 100644
--- a/arch/mips/cavium-octeon/octeon-irq.c
+++ b/arch/mips/cavium-octeon/octeon-irq.c
@@ -3,14 +3,17 @@
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-2008, 2009, 2010, 2011 Cavium Networks 6 * Copyright (C) 2004-2012 Cavium, Inc.
7 */ 7 */
8 8
9#include <linux/interrupt.h> 9#include <linux/interrupt.h>
10#include <linux/irqdomain.h>
10#include <linux/bitops.h> 11#include <linux/bitops.h>
11#include <linux/percpu.h> 12#include <linux/percpu.h>
13#include <linux/slab.h>
12#include <linux/irq.h> 14#include <linux/irq.h>
13#include <linux/smp.h> 15#include <linux/smp.h>
16#include <linux/of.h>
14 17
15#include <asm/octeon/octeon.h> 18#include <asm/octeon/octeon.h>
16 19
@@ -42,9 +45,9 @@ struct octeon_core_chip_data {
42 45
43static struct octeon_core_chip_data octeon_irq_core_chip_data[MIPS_CORE_IRQ_LINES]; 46static struct octeon_core_chip_data octeon_irq_core_chip_data[MIPS_CORE_IRQ_LINES];
44 47
45static void __init octeon_irq_set_ciu_mapping(int irq, int line, int bit, 48static void octeon_irq_set_ciu_mapping(int irq, int line, int bit,
46 struct irq_chip *chip, 49 struct irq_chip *chip,
47 irq_flow_handler_t handler) 50 irq_flow_handler_t handler)
48{ 51{
49 union octeon_ciu_chip_data cd; 52 union octeon_ciu_chip_data cd;
50 53
@@ -58,6 +61,12 @@ static void __init octeon_irq_set_ciu_mapping(int irq, int line, int bit,
58 octeon_irq_ciu_to_irq[line][bit] = irq; 61 octeon_irq_ciu_to_irq[line][bit] = irq;
59} 62}
60 63
64static void octeon_irq_force_ciu_mapping(struct irq_domain *domain,
65 int irq, int line, int bit)
66{
67 irq_domain_associate(domain, irq, line << 6 | bit);
68}
69
61static int octeon_coreid_for_cpu(int cpu) 70static int octeon_coreid_for_cpu(int cpu)
62{ 71{
63#ifdef CONFIG_SMP 72#ifdef CONFIG_SMP
@@ -180,19 +189,9 @@ static void __init octeon_irq_init_core(void)
180 mutex_init(&cd->core_irq_mutex); 189 mutex_init(&cd->core_irq_mutex);
181 190
182 irq = OCTEON_IRQ_SW0 + i; 191 irq = OCTEON_IRQ_SW0 + i;
183 switch (irq) { 192 irq_set_chip_data(irq, cd);
184 case OCTEON_IRQ_TIMER: 193 irq_set_chip_and_handler(irq, &octeon_irq_chip_core,
185 case OCTEON_IRQ_SW0: 194 handle_percpu_irq);
186 case OCTEON_IRQ_SW1:
187 case OCTEON_IRQ_5:
188 case OCTEON_IRQ_PERF:
189 irq_set_chip_data(irq, cd);
190 irq_set_chip_and_handler(irq, &octeon_irq_chip_core,
191 handle_percpu_irq);
192 break;
193 default:
194 break;
195 }
196 } 195 }
197} 196}
198 197
@@ -505,6 +504,85 @@ static void octeon_irq_ciu_enable_all_v2(struct irq_data *data)
505 } 504 }
506} 505}
507 506
507static void octeon_irq_gpio_setup(struct irq_data *data)
508{
509 union cvmx_gpio_bit_cfgx cfg;
510 union octeon_ciu_chip_data cd;
511 u32 t = irqd_get_trigger_type(data);
512
513 cd.p = irq_data_get_irq_chip_data(data);
514
515 cfg.u64 = 0;
516 cfg.s.int_en = 1;
517 cfg.s.int_type = (t & IRQ_TYPE_EDGE_BOTH) != 0;
518 cfg.s.rx_xor = (t & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_EDGE_FALLING)) != 0;
519
520 /* 140 nS glitch filter*/
521 cfg.s.fil_cnt = 7;
522 cfg.s.fil_sel = 3;
523
524 cvmx_write_csr(CVMX_GPIO_BIT_CFGX(cd.s.bit - 16), cfg.u64);
525}
526
527static void octeon_irq_ciu_enable_gpio_v2(struct irq_data *data)
528{
529 octeon_irq_gpio_setup(data);
530 octeon_irq_ciu_enable_v2(data);
531}
532
533static void octeon_irq_ciu_enable_gpio(struct irq_data *data)
534{
535 octeon_irq_gpio_setup(data);
536 octeon_irq_ciu_enable(data);
537}
538
539static int octeon_irq_ciu_gpio_set_type(struct irq_data *data, unsigned int t)
540{
541 irqd_set_trigger_type(data, t);
542 octeon_irq_gpio_setup(data);
543
544 return IRQ_SET_MASK_OK;
545}
546
547static void octeon_irq_ciu_disable_gpio_v2(struct irq_data *data)
548{
549 union octeon_ciu_chip_data cd;
550
551 cd.p = irq_data_get_irq_chip_data(data);
552 cvmx_write_csr(CVMX_GPIO_BIT_CFGX(cd.s.bit - 16), 0);
553
554 octeon_irq_ciu_disable_all_v2(data);
555}
556
557static void octeon_irq_ciu_disable_gpio(struct irq_data *data)
558{
559 union octeon_ciu_chip_data cd;
560
561 cd.p = irq_data_get_irq_chip_data(data);
562 cvmx_write_csr(CVMX_GPIO_BIT_CFGX(cd.s.bit - 16), 0);
563
564 octeon_irq_ciu_disable_all(data);
565}
566
567static void octeon_irq_ciu_gpio_ack(struct irq_data *data)
568{
569 union octeon_ciu_chip_data cd;
570 u64 mask;
571
572 cd.p = irq_data_get_irq_chip_data(data);
573 mask = 1ull << (cd.s.bit - 16);
574
575 cvmx_write_csr(CVMX_GPIO_INT_CLR, mask);
576}
577
578static void octeon_irq_handle_gpio(unsigned int irq, struct irq_desc *desc)
579{
580 if (irqd_get_trigger_type(irq_desc_get_irq_data(desc)) & IRQ_TYPE_EDGE_BOTH)
581 handle_edge_irq(irq, desc);
582 else
583 handle_level_irq(irq, desc);
584}
585
508#ifdef CONFIG_SMP 586#ifdef CONFIG_SMP
509 587
510static void octeon_irq_cpu_offline_ciu(struct irq_data *data) 588static void octeon_irq_cpu_offline_ciu(struct irq_data *data)
@@ -650,18 +728,6 @@ static struct irq_chip octeon_irq_chip_ciu_v2 = {
650 .name = "CIU", 728 .name = "CIU",
651 .irq_enable = octeon_irq_ciu_enable_v2, 729 .irq_enable = octeon_irq_ciu_enable_v2,
652 .irq_disable = octeon_irq_ciu_disable_all_v2, 730 .irq_disable = octeon_irq_ciu_disable_all_v2,
653 .irq_mask = octeon_irq_ciu_disable_local_v2,
654 .irq_unmask = octeon_irq_ciu_enable_v2,
655#ifdef CONFIG_SMP
656 .irq_set_affinity = octeon_irq_ciu_set_affinity_v2,
657 .irq_cpu_offline = octeon_irq_cpu_offline_ciu,
658#endif
659};
660
661static struct irq_chip octeon_irq_chip_ciu_edge_v2 = {
662 .name = "CIU-E",
663 .irq_enable = octeon_irq_ciu_enable_v2,
664 .irq_disable = octeon_irq_ciu_disable_all_v2,
665 .irq_ack = octeon_irq_ciu_ack, 731 .irq_ack = octeon_irq_ciu_ack,
666 .irq_mask = octeon_irq_ciu_disable_local_v2, 732 .irq_mask = octeon_irq_ciu_disable_local_v2,
667 .irq_unmask = octeon_irq_ciu_enable_v2, 733 .irq_unmask = octeon_irq_ciu_enable_v2,
@@ -675,19 +741,8 @@ static struct irq_chip octeon_irq_chip_ciu = {
675 .name = "CIU", 741 .name = "CIU",
676 .irq_enable = octeon_irq_ciu_enable, 742 .irq_enable = octeon_irq_ciu_enable,
677 .irq_disable = octeon_irq_ciu_disable_all, 743 .irq_disable = octeon_irq_ciu_disable_all,
678 .irq_mask = octeon_irq_dummy_mask,
679#ifdef CONFIG_SMP
680 .irq_set_affinity = octeon_irq_ciu_set_affinity,
681 .irq_cpu_offline = octeon_irq_cpu_offline_ciu,
682#endif
683};
684
685static struct irq_chip octeon_irq_chip_ciu_edge = {
686 .name = "CIU-E",
687 .irq_enable = octeon_irq_ciu_enable,
688 .irq_disable = octeon_irq_ciu_disable_all,
689 .irq_mask = octeon_irq_dummy_mask,
690 .irq_ack = octeon_irq_ciu_ack, 744 .irq_ack = octeon_irq_ciu_ack,
745 .irq_mask = octeon_irq_dummy_mask,
691#ifdef CONFIG_SMP 746#ifdef CONFIG_SMP
692 .irq_set_affinity = octeon_irq_ciu_set_affinity, 747 .irq_set_affinity = octeon_irq_ciu_set_affinity,
693 .irq_cpu_offline = octeon_irq_cpu_offline_ciu, 748 .irq_cpu_offline = octeon_irq_cpu_offline_ciu,
@@ -717,6 +772,33 @@ static struct irq_chip octeon_irq_chip_ciu_mbox = {
717 .flags = IRQCHIP_ONOFFLINE_ENABLED, 772 .flags = IRQCHIP_ONOFFLINE_ENABLED,
718}; 773};
719 774
775static struct irq_chip octeon_irq_chip_ciu_gpio_v2 = {
776 .name = "CIU-GPIO",
777 .irq_enable = octeon_irq_ciu_enable_gpio_v2,
778 .irq_disable = octeon_irq_ciu_disable_gpio_v2,
779 .irq_ack = octeon_irq_ciu_gpio_ack,
780 .irq_mask = octeon_irq_ciu_disable_local_v2,
781 .irq_unmask = octeon_irq_ciu_enable_v2,
782 .irq_set_type = octeon_irq_ciu_gpio_set_type,
783#ifdef CONFIG_SMP
784 .irq_set_affinity = octeon_irq_ciu_set_affinity_v2,
785#endif
786 .flags = IRQCHIP_SET_TYPE_MASKED,
787};
788
789static struct irq_chip octeon_irq_chip_ciu_gpio = {
790 .name = "CIU-GPIO",
791 .irq_enable = octeon_irq_ciu_enable_gpio,
792 .irq_disable = octeon_irq_ciu_disable_gpio,
793 .irq_mask = octeon_irq_dummy_mask,
794 .irq_ack = octeon_irq_ciu_gpio_ack,
795 .irq_set_type = octeon_irq_ciu_gpio_set_type,
796#ifdef CONFIG_SMP
797 .irq_set_affinity = octeon_irq_ciu_set_affinity,
798#endif
799 .flags = IRQCHIP_SET_TYPE_MASKED,
800};
801
720/* 802/*
721 * Watchdog interrupts are special. They are associated with a single 803 * Watchdog interrupts are special. They are associated with a single
722 * core, so we hardwire the affinity to that core. 804 * core, so we hardwire the affinity to that core.
@@ -764,6 +846,178 @@ static struct irq_chip octeon_irq_chip_ciu_wd = {
764 .irq_mask = octeon_irq_dummy_mask, 846 .irq_mask = octeon_irq_dummy_mask,
765}; 847};
766 848
849static bool octeon_irq_ciu_is_edge(unsigned int line, unsigned int bit)
850{
851 bool edge = false;
852
853 if (line == 0)
854 switch (bit) {
855 case 48 ... 49: /* GMX DRP */
856 case 50: /* IPD_DRP */
857 case 52 ... 55: /* Timers */
858 case 58: /* MPI */
859 edge = true;
860 break;
861 default:
862 break;
863 }
864 else /* line == 1 */
865 switch (bit) {
866 case 47: /* PTP */
867 edge = true;
868 break;
869 default:
870 break;
871 }
872 return edge;
873}
874
875struct octeon_irq_gpio_domain_data {
876 unsigned int base_hwirq;
877};
878
879static int octeon_irq_gpio_xlat(struct irq_domain *d,
880 struct device_node *node,
881 const u32 *intspec,
882 unsigned int intsize,
883 unsigned long *out_hwirq,
884 unsigned int *out_type)
885{
886 unsigned int type;
887 unsigned int pin;
888 unsigned int trigger;
889
890 if (d->of_node != node)
891 return -EINVAL;
892
893 if (intsize < 2)
894 return -EINVAL;
895
896 pin = intspec[0];
897 if (pin >= 16)
898 return -EINVAL;
899
900 trigger = intspec[1];
901
902 switch (trigger) {
903 case 1:
904 type = IRQ_TYPE_EDGE_RISING;
905 break;
906 case 2:
907 type = IRQ_TYPE_EDGE_FALLING;
908 break;
909 case 4:
910 type = IRQ_TYPE_LEVEL_HIGH;
911 break;
912 case 8:
913 type = IRQ_TYPE_LEVEL_LOW;
914 break;
915 default:
916 pr_err("Error: (%s) Invalid irq trigger specification: %x\n",
917 node->name,
918 trigger);
919 type = IRQ_TYPE_LEVEL_LOW;
920 break;
921 }
922 *out_type = type;
923 *out_hwirq = pin;
924
925 return 0;
926}
927
928static int octeon_irq_ciu_xlat(struct irq_domain *d,
929 struct device_node *node,
930 const u32 *intspec,
931 unsigned int intsize,
932 unsigned long *out_hwirq,
933 unsigned int *out_type)
934{
935 unsigned int ciu, bit;
936
937 ciu = intspec[0];
938 bit = intspec[1];
939
940 if (ciu > 1 || bit > 63)
941 return -EINVAL;
942
943 /* These are the GPIO lines */
944 if (ciu == 0 && bit >= 16 && bit < 32)
945 return -EINVAL;
946
947 *out_hwirq = (ciu << 6) | bit;
948 *out_type = 0;
949
950 return 0;
951}
952
953static struct irq_chip *octeon_irq_ciu_chip;
954static struct irq_chip *octeon_irq_gpio_chip;
955
956static bool octeon_irq_virq_in_range(unsigned int virq)
957{
958 /* We cannot let it overflow the mapping array. */
959 if (virq < (1ul << 8 * sizeof(octeon_irq_ciu_to_irq[0][0])))
960 return true;
961
962 WARN_ONCE(true, "virq out of range %u.\n", virq);
963 return false;
964}
965
966static int octeon_irq_ciu_map(struct irq_domain *d,
967 unsigned int virq, irq_hw_number_t hw)
968{
969 unsigned int line = hw >> 6;
970 unsigned int bit = hw & 63;
971
972 if (!octeon_irq_virq_in_range(virq))
973 return -EINVAL;
974
975 if (line > 1 || octeon_irq_ciu_to_irq[line][bit] != 0)
976 return -EINVAL;
977
978 if (octeon_irq_ciu_is_edge(line, bit))
979 octeon_irq_set_ciu_mapping(virq, line, bit,
980 octeon_irq_ciu_chip,
981 handle_edge_irq);
982 else
983 octeon_irq_set_ciu_mapping(virq, line, bit,
984 octeon_irq_ciu_chip,
985 handle_level_irq);
986
987 return 0;
988}
989
990static int octeon_irq_gpio_map(struct irq_domain *d,
991 unsigned int virq, irq_hw_number_t hw)
992{
993 struct octeon_irq_gpio_domain_data *gpiod = d->host_data;
994 unsigned int line, bit;
995
996 if (!octeon_irq_virq_in_range(virq))
997 return -EINVAL;
998
999 hw += gpiod->base_hwirq;
1000 line = hw >> 6;
1001 bit = hw & 63;
1002 if (line > 1 || octeon_irq_ciu_to_irq[line][bit] != 0)
1003 return -EINVAL;
1004
1005 octeon_irq_set_ciu_mapping(virq, line, bit,
1006 octeon_irq_gpio_chip,
1007 octeon_irq_handle_gpio);
1008 return 0;
1009}
1010
1011static struct irq_domain_ops octeon_irq_domain_ciu_ops = {
1012 .map = octeon_irq_ciu_map,
1013 .xlate = octeon_irq_ciu_xlat,
1014};
1015
1016static struct irq_domain_ops octeon_irq_domain_gpio_ops = {
1017 .map = octeon_irq_gpio_map,
1018 .xlate = octeon_irq_gpio_xlat,
1019};
1020
767static void octeon_irq_ip2_v1(void) 1021static void octeon_irq_ip2_v1(void)
768{ 1022{
769 const unsigned long core_id = cvmx_get_core_num(); 1023 const unsigned long core_id = cvmx_get_core_num();
@@ -887,9 +1141,11 @@ static void __init octeon_irq_init_ciu(void)
887{ 1141{
888 unsigned int i; 1142 unsigned int i;
889 struct irq_chip *chip; 1143 struct irq_chip *chip;
890 struct irq_chip *chip_edge;
891 struct irq_chip *chip_mbox; 1144 struct irq_chip *chip_mbox;
892 struct irq_chip *chip_wd; 1145 struct irq_chip *chip_wd;
1146 struct device_node *gpio_node;
1147 struct device_node *ciu_node;
1148 struct irq_domain *ciu_domain = NULL;
893 1149
894 octeon_irq_init_ciu_percpu(); 1150 octeon_irq_init_ciu_percpu();
895 octeon_irq_setup_secondary = octeon_irq_setup_secondary_ciu; 1151 octeon_irq_setup_secondary = octeon_irq_setup_secondary_ciu;
@@ -901,99 +1157,69 @@ static void __init octeon_irq_init_ciu(void)
901 octeon_irq_ip2 = octeon_irq_ip2_v2; 1157 octeon_irq_ip2 = octeon_irq_ip2_v2;
902 octeon_irq_ip3 = octeon_irq_ip3_v2; 1158 octeon_irq_ip3 = octeon_irq_ip3_v2;
903 chip = &octeon_irq_chip_ciu_v2; 1159 chip = &octeon_irq_chip_ciu_v2;
904 chip_edge = &octeon_irq_chip_ciu_edge_v2;
905 chip_mbox = &octeon_irq_chip_ciu_mbox_v2; 1160 chip_mbox = &octeon_irq_chip_ciu_mbox_v2;
906 chip_wd = &octeon_irq_chip_ciu_wd_v2; 1161 chip_wd = &octeon_irq_chip_ciu_wd_v2;
1162 octeon_irq_gpio_chip = &octeon_irq_chip_ciu_gpio_v2;
907 } else { 1163 } else {
908 octeon_irq_ip2 = octeon_irq_ip2_v1; 1164 octeon_irq_ip2 = octeon_irq_ip2_v1;
909 octeon_irq_ip3 = octeon_irq_ip3_v1; 1165 octeon_irq_ip3 = octeon_irq_ip3_v1;
910 chip = &octeon_irq_chip_ciu; 1166 chip = &octeon_irq_chip_ciu;
911 chip_edge = &octeon_irq_chip_ciu_edge;
912 chip_mbox = &octeon_irq_chip_ciu_mbox; 1167 chip_mbox = &octeon_irq_chip_ciu_mbox;
913 chip_wd = &octeon_irq_chip_ciu_wd; 1168 chip_wd = &octeon_irq_chip_ciu_wd;
1169 octeon_irq_gpio_chip = &octeon_irq_chip_ciu_gpio;
914 } 1170 }
1171 octeon_irq_ciu_chip = chip;
915 octeon_irq_ip4 = octeon_irq_ip4_mask; 1172 octeon_irq_ip4 = octeon_irq_ip4_mask;
916 1173
917 /* Mips internal */ 1174 /* Mips internal */
918 octeon_irq_init_core(); 1175 octeon_irq_init_core();
919 1176
1177 gpio_node = of_find_compatible_node(NULL, NULL, "cavium,octeon-3860-gpio");
1178 if (gpio_node) {
1179 struct octeon_irq_gpio_domain_data *gpiod;
1180
1181 gpiod = kzalloc(sizeof(*gpiod), GFP_KERNEL);
1182 if (gpiod) {
1183 /* gpio domain host_data is the base hwirq number. */
1184 gpiod->base_hwirq = 16;
1185 irq_domain_add_linear(gpio_node, 16, &octeon_irq_domain_gpio_ops, gpiod);
1186 of_node_put(gpio_node);
1187 } else
1188 pr_warn("Cannot allocate memory for GPIO irq_domain.\n");
1189 } else
1190 pr_warn("Cannot find device node for cavium,octeon-3860-gpio.\n");
1191
1192 ciu_node = of_find_compatible_node(NULL, NULL, "cavium,octeon-3860-ciu");
1193 if (ciu_node) {
1194 ciu_domain = irq_domain_add_tree(ciu_node, &octeon_irq_domain_ciu_ops, NULL);
1195 of_node_put(ciu_node);
1196 } else
1197 panic("Cannot find device node for cavium,octeon-3860-ciu.");
1198
920 /* CIU_0 */ 1199 /* CIU_0 */
921 for (i = 0; i < 16; i++) 1200 for (i = 0; i < 16; i++)
922 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_WORKQ0, 0, i + 0, chip, handle_level_irq); 1201 octeon_irq_force_ciu_mapping(ciu_domain, i + OCTEON_IRQ_WORKQ0, 0, i + 0);
923 for (i = 0; i < 16; i++)
924 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_GPIO0, 0, i + 16, chip, handle_level_irq);
925 1202
926 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MBOX0, 0, 32, chip_mbox, handle_percpu_irq); 1203 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MBOX0, 0, 32, chip_mbox, handle_percpu_irq);
927 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MBOX1, 0, 33, chip_mbox, handle_percpu_irq); 1204 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MBOX1, 0, 33, chip_mbox, handle_percpu_irq);
928 1205
929 octeon_irq_set_ciu_mapping(OCTEON_IRQ_UART0, 0, 34, chip, handle_level_irq);
930 octeon_irq_set_ciu_mapping(OCTEON_IRQ_UART1, 0, 35, chip, handle_level_irq);
931
932 for (i = 0; i < 4; i++) 1206 for (i = 0; i < 4; i++)
933 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_PCI_INT0, 0, i + 36, chip, handle_level_irq); 1207 octeon_irq_force_ciu_mapping(ciu_domain, i + OCTEON_IRQ_PCI_INT0, 0, i + 36);
934 for (i = 0; i < 4; i++) 1208 for (i = 0; i < 4; i++)
935 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_PCI_MSI0, 0, i + 40, chip, handle_level_irq); 1209 octeon_irq_force_ciu_mapping(ciu_domain, i + OCTEON_IRQ_PCI_MSI0, 0, i + 40);
936
937 octeon_irq_set_ciu_mapping(OCTEON_IRQ_TWSI, 0, 45, chip, handle_level_irq);
938 octeon_irq_set_ciu_mapping(OCTEON_IRQ_RML, 0, 46, chip, handle_level_irq);
939 octeon_irq_set_ciu_mapping(OCTEON_IRQ_TRACE0, 0, 47, chip, handle_level_irq);
940
941 for (i = 0; i < 2; i++)
942 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_GMX_DRP0, 0, i + 48, chip_edge, handle_edge_irq);
943
944 octeon_irq_set_ciu_mapping(OCTEON_IRQ_IPD_DRP, 0, 50, chip_edge, handle_edge_irq);
945 octeon_irq_set_ciu_mapping(OCTEON_IRQ_KEY_ZERO, 0, 51, chip_edge, handle_edge_irq);
946 1210
1211 octeon_irq_force_ciu_mapping(ciu_domain, OCTEON_IRQ_RML, 0, 46);
947 for (i = 0; i < 4; i++) 1212 for (i = 0; i < 4; i++)
948 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_TIMER0, 0, i + 52, chip_edge, handle_edge_irq); 1213 octeon_irq_force_ciu_mapping(ciu_domain, i + OCTEON_IRQ_TIMER0, 0, i + 52);
949 1214
950 octeon_irq_set_ciu_mapping(OCTEON_IRQ_USB0, 0, 56, chip, handle_level_irq); 1215 octeon_irq_force_ciu_mapping(ciu_domain, OCTEON_IRQ_USB0, 0, 56);
951 octeon_irq_set_ciu_mapping(OCTEON_IRQ_PCM, 0, 57, chip, handle_level_irq); 1216 octeon_irq_force_ciu_mapping(ciu_domain, OCTEON_IRQ_BOOTDMA, 0, 63);
952 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MPI, 0, 58, chip, handle_level_irq);
953 octeon_irq_set_ciu_mapping(OCTEON_IRQ_TWSI2, 0, 59, chip, handle_level_irq);
954 octeon_irq_set_ciu_mapping(OCTEON_IRQ_POWIQ, 0, 60, chip, handle_level_irq);
955 octeon_irq_set_ciu_mapping(OCTEON_IRQ_IPDPPTHR, 0, 61, chip, handle_level_irq);
956 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MII0, 0, 62, chip, handle_level_irq);
957 octeon_irq_set_ciu_mapping(OCTEON_IRQ_BOOTDMA, 0, 63, chip, handle_level_irq);
958 1217
959 /* CIU_1 */ 1218 /* CIU_1 */
960 for (i = 0; i < 16; i++) 1219 for (i = 0; i < 16; i++)
961 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_WDOG0, 1, i + 0, chip_wd, handle_level_irq); 1220 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_WDOG0, 1, i + 0, chip_wd, handle_level_irq);
962 1221
963 octeon_irq_set_ciu_mapping(OCTEON_IRQ_UART2, 1, 16, chip, handle_level_irq); 1222 octeon_irq_force_ciu_mapping(ciu_domain, OCTEON_IRQ_USB1, 1, 17);
964 octeon_irq_set_ciu_mapping(OCTEON_IRQ_USB1, 1, 17, chip, handle_level_irq);
965 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MII1, 1, 18, chip, handle_level_irq);
966 octeon_irq_set_ciu_mapping(OCTEON_IRQ_NAND, 1, 19, chip, handle_level_irq);
967 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MIO, 1, 20, chip, handle_level_irq);
968 octeon_irq_set_ciu_mapping(OCTEON_IRQ_IOB, 1, 21, chip, handle_level_irq);
969 octeon_irq_set_ciu_mapping(OCTEON_IRQ_FPA, 1, 22, chip, handle_level_irq);
970 octeon_irq_set_ciu_mapping(OCTEON_IRQ_POW, 1, 23, chip, handle_level_irq);
971 octeon_irq_set_ciu_mapping(OCTEON_IRQ_L2C, 1, 24, chip, handle_level_irq);
972 octeon_irq_set_ciu_mapping(OCTEON_IRQ_IPD, 1, 25, chip, handle_level_irq);
973 octeon_irq_set_ciu_mapping(OCTEON_IRQ_PIP, 1, 26, chip, handle_level_irq);
974 octeon_irq_set_ciu_mapping(OCTEON_IRQ_PKO, 1, 27, chip, handle_level_irq);
975 octeon_irq_set_ciu_mapping(OCTEON_IRQ_ZIP, 1, 28, chip, handle_level_irq);
976 octeon_irq_set_ciu_mapping(OCTEON_IRQ_TIM, 1, 29, chip, handle_level_irq);
977 octeon_irq_set_ciu_mapping(OCTEON_IRQ_RAD, 1, 30, chip, handle_level_irq);
978 octeon_irq_set_ciu_mapping(OCTEON_IRQ_KEY, 1, 31, chip, handle_level_irq);
979 octeon_irq_set_ciu_mapping(OCTEON_IRQ_DFA, 1, 32, chip, handle_level_irq);
980 octeon_irq_set_ciu_mapping(OCTEON_IRQ_USBCTL, 1, 33, chip, handle_level_irq);
981 octeon_irq_set_ciu_mapping(OCTEON_IRQ_SLI, 1, 34, chip, handle_level_irq);
982 octeon_irq_set_ciu_mapping(OCTEON_IRQ_DPI, 1, 35, chip, handle_level_irq);
983
984 octeon_irq_set_ciu_mapping(OCTEON_IRQ_AGX0, 1, 36, chip, handle_level_irq);
985
986 octeon_irq_set_ciu_mapping(OCTEON_IRQ_AGL, 1, 46, chip, handle_level_irq);
987
988 octeon_irq_set_ciu_mapping(OCTEON_IRQ_PTP, 1, 47, chip_edge, handle_edge_irq);
989
990 octeon_irq_set_ciu_mapping(OCTEON_IRQ_PEM0, 1, 48, chip, handle_level_irq);
991 octeon_irq_set_ciu_mapping(OCTEON_IRQ_PEM1, 1, 49, chip, handle_level_irq);
992 octeon_irq_set_ciu_mapping(OCTEON_IRQ_SRIO0, 1, 50, chip, handle_level_irq);
993 octeon_irq_set_ciu_mapping(OCTEON_IRQ_SRIO1, 1, 51, chip, handle_level_irq);
994 octeon_irq_set_ciu_mapping(OCTEON_IRQ_LMC0, 1, 52, chip, handle_level_irq);
995 octeon_irq_set_ciu_mapping(OCTEON_IRQ_DFM, 1, 56, chip, handle_level_irq);
996 octeon_irq_set_ciu_mapping(OCTEON_IRQ_RST, 1, 63, chip, handle_level_irq);
997 1223
998 /* Enable the CIU lines */ 1224 /* Enable the CIU lines */
999 set_c0_status(STATUSF_IP3 | STATUSF_IP2); 1225 set_c0_status(STATUSF_IP3 | STATUSF_IP2);
diff --git a/arch/mips/cavium-octeon/octeon-memcpy.S b/arch/mips/cavium-octeon/octeon-memcpy.S
index 88e0cddca20..db478dbb9c7 100644
--- a/arch/mips/cavium-octeon/octeon-memcpy.S
+++ b/arch/mips/cavium-octeon/octeon-memcpy.S
@@ -164,6 +164,14 @@
164 .set noat 164 .set noat
165 165
166/* 166/*
167 * t7 is used as a flag to note inatomic mode.
168 */
169LEAF(__copy_user_inatomic)
170 b __copy_user_common
171 li t7, 1
172 END(__copy_user_inatomic)
173
174/*
167 * A combined memcpy/__copy_user 175 * A combined memcpy/__copy_user
168 * __copy_user sets len to 0 for success; else to an upper bound of 176 * __copy_user sets len to 0 for success; else to an upper bound of
169 * the number of uncopied bytes. 177 * the number of uncopied bytes.
@@ -174,6 +182,8 @@ LEAF(memcpy) /* a0=dst a1=src a2=len */
174 move v0, dst /* return value */ 182 move v0, dst /* return value */
175__memcpy: 183__memcpy:
176FEXPORT(__copy_user) 184FEXPORT(__copy_user)
185 li t7, 0 /* not inatomic */
186__copy_user_common:
177 /* 187 /*
178 * Note: dst & src may be unaligned, len may be 0 188 * Note: dst & src may be unaligned, len may be 0
179 * Temps 189 * Temps
@@ -412,7 +422,6 @@ l_exc_copy:
412 * Assumes src < THREAD_BUADDR($28) 422 * Assumes src < THREAD_BUADDR($28)
413 */ 423 */
414 LOAD t0, TI_TASK($28) 424 LOAD t0, TI_TASK($28)
415 nop
416 LOAD t0, THREAD_BUADDR(t0) 425 LOAD t0, THREAD_BUADDR(t0)
4171: 4261:
418EXC( lb t1, 0(src), l_exc) 427EXC( lb t1, 0(src), l_exc)
@@ -422,10 +431,9 @@ EXC( lb t1, 0(src), l_exc)
422 ADD dst, dst, 1 431 ADD dst, dst, 1
423l_exc: 432l_exc:
424 LOAD t0, TI_TASK($28) 433 LOAD t0, TI_TASK($28)
425 nop
426 LOAD t0, THREAD_BUADDR(t0) # t0 is just past last good address 434 LOAD t0, THREAD_BUADDR(t0) # t0 is just past last good address
427 nop
428 SUB len, AT, t0 # len number of uncopied bytes 435 SUB len, AT, t0 # len number of uncopied bytes
436 bnez t7, 2f /* Skip the zeroing out part if inatomic */
429 /* 437 /*
430 * Here's where we rely on src and dst being incremented in tandem, 438 * Here's where we rely on src and dst being incremented in tandem,
431 * See (3) above. 439 * See (3) above.
@@ -443,7 +451,7 @@ l_exc:
443 ADD dst, dst, 1 451 ADD dst, dst, 1
444 bnez src, 1b 452 bnez src, 1b
445 SUB src, src, 1 453 SUB src, src, 1
446 jr ra 4542: jr ra
447 nop 455 nop
448 456
449 457
diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
index cd61d7281d9..0938df10a71 100644
--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -3,7 +3,7 @@
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-2010 Cavium Networks 6 * Copyright (C) 2004-2011 Cavium Networks
7 * Copyright (C) 2008 Wind River Systems 7 * Copyright (C) 2008 Wind River Systems
8 */ 8 */
9 9
@@ -13,10 +13,16 @@
13#include <linux/usb.h> 13#include <linux/usb.h>
14#include <linux/dma-mapping.h> 14#include <linux/dma-mapping.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/slab.h>
16#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/of_platform.h>
19#include <linux/of_fdt.h>
20#include <linux/libfdt.h>
17 21
18#include <asm/octeon/octeon.h> 22#include <asm/octeon/octeon.h>
19#include <asm/octeon/cvmx-rnm-defs.h> 23#include <asm/octeon/cvmx-rnm-defs.h>
24#include <asm/octeon/cvmx-helper.h>
25#include <asm/octeon/cvmx-helper-board.h>
20 26
21static struct octeon_cf_data octeon_cf_data; 27static struct octeon_cf_data octeon_cf_data;
22 28
@@ -162,182 +168,6 @@ out:
162} 168}
163device_initcall(octeon_rng_device_init); 169device_initcall(octeon_rng_device_init);
164 170
165static struct i2c_board_info __initdata octeon_i2c_devices[] = {
166 {
167 I2C_BOARD_INFO("ds1337", 0x68),
168 },
169};
170
171static int __init octeon_i2c_devices_init(void)
172{
173 return i2c_register_board_info(0, octeon_i2c_devices,
174 ARRAY_SIZE(octeon_i2c_devices));
175}
176arch_initcall(octeon_i2c_devices_init);
177
178#define OCTEON_I2C_IO_BASE 0x1180000001000ull
179#define OCTEON_I2C_IO_UNIT_OFFSET 0x200
180
181static struct octeon_i2c_data octeon_i2c_data[2];
182
183static int __init octeon_i2c_device_init(void)
184{
185 struct platform_device *pd;
186 int ret = 0;
187 int port, num_ports;
188
189 struct resource i2c_resources[] = {
190 {
191 .flags = IORESOURCE_MEM,
192 }, {
193 .flags = IORESOURCE_IRQ,
194 }
195 };
196
197 if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX))
198 num_ports = 2;
199 else
200 num_ports = 1;
201
202 for (port = 0; port < num_ports; port++) {
203 octeon_i2c_data[port].sys_freq = octeon_get_io_clock_rate();
204 /*FIXME: should be examined. At the moment is set for 100Khz */
205 octeon_i2c_data[port].i2c_freq = 100000;
206
207 pd = platform_device_alloc("i2c-octeon", port);
208 if (!pd) {
209 ret = -ENOMEM;
210 goto out;
211 }
212
213 pd->dev.platform_data = octeon_i2c_data + port;
214
215 i2c_resources[0].start =
216 OCTEON_I2C_IO_BASE + (port * OCTEON_I2C_IO_UNIT_OFFSET);
217 i2c_resources[0].end = i2c_resources[0].start + 0x1f;
218 switch (port) {
219 case 0:
220 i2c_resources[1].start = OCTEON_IRQ_TWSI;
221 i2c_resources[1].end = OCTEON_IRQ_TWSI;
222 break;
223 case 1:
224 i2c_resources[1].start = OCTEON_IRQ_TWSI2;
225 i2c_resources[1].end = OCTEON_IRQ_TWSI2;
226 break;
227 default:
228 BUG();
229 }
230
231 ret = platform_device_add_resources(pd,
232 i2c_resources,
233 ARRAY_SIZE(i2c_resources));
234 if (ret)
235 goto fail;
236
237 ret = platform_device_add(pd);
238 if (ret)
239 goto fail;
240 }
241 return ret;
242fail:
243 platform_device_put(pd);
244out:
245 return ret;
246}
247device_initcall(octeon_i2c_device_init);
248
249/* Octeon SMI/MDIO interface. */
250static int __init octeon_mdiobus_device_init(void)
251{
252 struct platform_device *pd;
253 int ret = 0;
254
255 if (octeon_is_simulation())
256 return 0; /* No mdio in the simulator. */
257
258 /* The bus number is the platform_device id. */
259 pd = platform_device_alloc("mdio-octeon", 0);
260 if (!pd) {
261 ret = -ENOMEM;
262 goto out;
263 }
264
265 ret = platform_device_add(pd);
266 if (ret)
267 goto fail;
268
269 return ret;
270fail:
271 platform_device_put(pd);
272
273out:
274 return ret;
275
276}
277device_initcall(octeon_mdiobus_device_init);
278
279/* Octeon mgmt port Ethernet interface. */
280static int __init octeon_mgmt_device_init(void)
281{
282 struct platform_device *pd;
283 int ret = 0;
284 int port, num_ports;
285
286 struct resource mgmt_port_resource = {
287 .flags = IORESOURCE_IRQ,
288 .start = -1,
289 .end = -1
290 };
291
292 if (!OCTEON_IS_MODEL(OCTEON_CN56XX) && !OCTEON_IS_MODEL(OCTEON_CN52XX))
293 return 0;
294
295 if (OCTEON_IS_MODEL(OCTEON_CN56XX))
296 num_ports = 1;
297 else
298 num_ports = 2;
299
300 for (port = 0; port < num_ports; port++) {
301 pd = platform_device_alloc("octeon_mgmt", port);
302 if (!pd) {
303 ret = -ENOMEM;
304 goto out;
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
310 switch (port) {
311 case 0:
312 mgmt_port_resource.start = OCTEON_IRQ_MII0;
313 break;
314 case 1:
315 mgmt_port_resource.start = OCTEON_IRQ_MII1;
316 break;
317 default:
318 BUG();
319 }
320 mgmt_port_resource.end = mgmt_port_resource.start;
321
322 ret = platform_device_add_resources(pd, &mgmt_port_resource, 1);
323
324 if (ret)
325 goto fail;
326
327 ret = platform_device_add(pd);
328 if (ret)
329 goto fail;
330 }
331 return ret;
332fail:
333 platform_device_put(pd);
334
335out:
336 return ret;
337
338}
339device_initcall(octeon_mgmt_device_init);
340
341#ifdef CONFIG_USB 171#ifdef CONFIG_USB
342 172
343static int __init octeon_ehci_device_init(void) 173static int __init octeon_ehci_device_init(void)
@@ -440,6 +270,521 @@ device_initcall(octeon_ohci_device_init);
440 270
441#endif /* CONFIG_USB */ 271#endif /* CONFIG_USB */
442 272
273static struct of_device_id __initdata octeon_ids[] = {
274 { .compatible = "simple-bus", },
275 { .compatible = "cavium,octeon-6335-uctl", },
276 { .compatible = "cavium,octeon-3860-bootbus", },
277 { .compatible = "cavium,mdio-mux", },
278 { .compatible = "gpio-leds", },
279 {},
280};
281
282static bool __init octeon_has_88e1145(void)
283{
284 return !OCTEON_IS_MODEL(OCTEON_CN52XX) &&
285 !OCTEON_IS_MODEL(OCTEON_CN6XXX) &&
286 !OCTEON_IS_MODEL(OCTEON_CN56XX);
287}
288
289static void __init octeon_fdt_set_phy(int eth, int phy_addr)
290{
291 const __be32 *phy_handle;
292 const __be32 *alt_phy_handle;
293 const __be32 *reg;
294 u32 phandle;
295 int phy;
296 int alt_phy;
297 const char *p;
298 int current_len;
299 char new_name[20];
300
301 phy_handle = fdt_getprop(initial_boot_params, eth, "phy-handle", NULL);
302 if (!phy_handle)
303 return;
304
305 phandle = be32_to_cpup(phy_handle);
306 phy = fdt_node_offset_by_phandle(initial_boot_params, phandle);
307
308 alt_phy_handle = fdt_getprop(initial_boot_params, eth, "cavium,alt-phy-handle", NULL);
309 if (alt_phy_handle) {
310 u32 alt_phandle = be32_to_cpup(alt_phy_handle);
311 alt_phy = fdt_node_offset_by_phandle(initial_boot_params, alt_phandle);
312 } else {
313 alt_phy = -1;
314 }
315
316 if (phy_addr < 0 || phy < 0) {
317 /* Delete the PHY things */
318 fdt_nop_property(initial_boot_params, eth, "phy-handle");
319 /* This one may fail */
320 fdt_nop_property(initial_boot_params, eth, "cavium,alt-phy-handle");
321 if (phy >= 0)
322 fdt_nop_node(initial_boot_params, phy);
323 if (alt_phy >= 0)
324 fdt_nop_node(initial_boot_params, alt_phy);
325 return;
326 }
327
328 if (phy_addr >= 256 && alt_phy > 0) {
329 const struct fdt_property *phy_prop;
330 struct fdt_property *alt_prop;
331 u32 phy_handle_name;
332
333 /* Use the alt phy node instead.*/
334 phy_prop = fdt_get_property(initial_boot_params, eth, "phy-handle", NULL);
335 phy_handle_name = phy_prop->nameoff;
336 fdt_nop_node(initial_boot_params, phy);
337 fdt_nop_property(initial_boot_params, eth, "phy-handle");
338 alt_prop = fdt_get_property_w(initial_boot_params, eth, "cavium,alt-phy-handle", NULL);
339 alt_prop->nameoff = phy_handle_name;
340 phy = alt_phy;
341 }
342
343 phy_addr &= 0xff;
344
345 if (octeon_has_88e1145()) {
346 fdt_nop_property(initial_boot_params, phy, "marvell,reg-init");
347 memset(new_name, 0, sizeof(new_name));
348 strcpy(new_name, "marvell,88e1145");
349 p = fdt_getprop(initial_boot_params, phy, "compatible",
350 &current_len);
351 if (p && current_len >= strlen(new_name))
352 fdt_setprop_inplace(initial_boot_params, phy,
353 "compatible", new_name, current_len);
354 }
355
356 reg = fdt_getprop(initial_boot_params, phy, "reg", NULL);
357 if (phy_addr == be32_to_cpup(reg))
358 return;
359
360 fdt_setprop_inplace_cell(initial_boot_params, phy, "reg", phy_addr);
361
362 snprintf(new_name, sizeof(new_name), "ethernet-phy@%x", phy_addr);
363
364 p = fdt_get_name(initial_boot_params, phy, &current_len);
365 if (p && current_len == strlen(new_name))
366 fdt_set_name(initial_boot_params, phy, new_name);
367 else
368 pr_err("Error: could not rename ethernet phy: <%s>", p);
369}
370
371static void __init octeon_fdt_set_mac_addr(int n, u64 *pmac)
372{
373 u8 new_mac[6];
374 u64 mac = *pmac;
375 int r;
376
377 new_mac[0] = (mac >> 40) & 0xff;
378 new_mac[1] = (mac >> 32) & 0xff;
379 new_mac[2] = (mac >> 24) & 0xff;
380 new_mac[3] = (mac >> 16) & 0xff;
381 new_mac[4] = (mac >> 8) & 0xff;
382 new_mac[5] = mac & 0xff;
383
384 r = fdt_setprop_inplace(initial_boot_params, n, "local-mac-address",
385 new_mac, sizeof(new_mac));
386
387 if (r) {
388 pr_err("Setting \"local-mac-address\" failed %d", r);
389 return;
390 }
391 *pmac = mac + 1;
392}
393
394static void __init octeon_fdt_rm_ethernet(int node)
395{
396 const __be32 *phy_handle;
397
398 phy_handle = fdt_getprop(initial_boot_params, node, "phy-handle", NULL);
399 if (phy_handle) {
400 u32 ph = be32_to_cpup(phy_handle);
401 int p = fdt_node_offset_by_phandle(initial_boot_params, ph);
402 if (p >= 0)
403 fdt_nop_node(initial_boot_params, p);
404 }
405 fdt_nop_node(initial_boot_params, node);
406}
407
408static void __init octeon_fdt_pip_port(int iface, int i, int p, int max, u64 *pmac)
409{
410 char name_buffer[20];
411 int eth;
412 int phy_addr;
413 int ipd_port;
414
415 snprintf(name_buffer, sizeof(name_buffer), "ethernet@%x", p);
416 eth = fdt_subnode_offset(initial_boot_params, iface, name_buffer);
417 if (eth < 0)
418 return;
419 if (p > max) {
420 pr_debug("Deleting port %x:%x\n", i, p);
421 octeon_fdt_rm_ethernet(eth);
422 return;
423 }
424 if (OCTEON_IS_MODEL(OCTEON_CN68XX))
425 ipd_port = (0x100 * i) + (0x10 * p) + 0x800;
426 else
427 ipd_port = 16 * i + p;
428
429 phy_addr = cvmx_helper_board_get_mii_address(ipd_port);
430 octeon_fdt_set_phy(eth, phy_addr);
431 octeon_fdt_set_mac_addr(eth, pmac);
432}
433
434static void __init octeon_fdt_pip_iface(int pip, int idx, u64 *pmac)
435{
436 char name_buffer[20];
437 int iface;
438 int p;
439 int count;
440
441 count = cvmx_helper_interface_enumerate(idx);
442
443 snprintf(name_buffer, sizeof(name_buffer), "interface@%d", idx);
444 iface = fdt_subnode_offset(initial_boot_params, pip, name_buffer);
445 if (iface < 0)
446 return;
447
448 for (p = 0; p < 16; p++)
449 octeon_fdt_pip_port(iface, idx, p, count - 1, pmac);
450}
451
452int __init octeon_prune_device_tree(void)
453{
454 int i, max_port, uart_mask;
455 const char *pip_path;
456 const char *alias_prop;
457 char name_buffer[20];
458 int aliases;
459 u64 mac_addr_base;
460
461 if (fdt_check_header(initial_boot_params))
462 panic("Corrupt Device Tree.");
463
464 aliases = fdt_path_offset(initial_boot_params, "/aliases");
465 if (aliases < 0) {
466 pr_err("Error: No /aliases node in device tree.");
467 return -EINVAL;
468 }
469
470
471 mac_addr_base =
472 ((octeon_bootinfo->mac_addr_base[0] & 0xffull)) << 40 |
473 ((octeon_bootinfo->mac_addr_base[1] & 0xffull)) << 32 |
474 ((octeon_bootinfo->mac_addr_base[2] & 0xffull)) << 24 |
475 ((octeon_bootinfo->mac_addr_base[3] & 0xffull)) << 16 |
476 ((octeon_bootinfo->mac_addr_base[4] & 0xffull)) << 8 |
477 (octeon_bootinfo->mac_addr_base[5] & 0xffull);
478
479 if (OCTEON_IS_MODEL(OCTEON_CN52XX) || OCTEON_IS_MODEL(OCTEON_CN63XX))
480 max_port = 2;
481 else if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN68XX))
482 max_port = 1;
483 else
484 max_port = 0;
485
486 if (octeon_bootinfo->board_type == CVMX_BOARD_TYPE_NIC10E)
487 max_port = 0;
488
489 for (i = 0; i < 2; i++) {
490 int mgmt;
491 snprintf(name_buffer, sizeof(name_buffer),
492 "mix%d", i);
493 alias_prop = fdt_getprop(initial_boot_params, aliases,
494 name_buffer, NULL);
495 if (alias_prop) {
496 mgmt = fdt_path_offset(initial_boot_params, alias_prop);
497 if (mgmt < 0)
498 continue;
499 if (i >= max_port) {
500 pr_debug("Deleting mix%d\n", i);
501 octeon_fdt_rm_ethernet(mgmt);
502 fdt_nop_property(initial_boot_params, aliases,
503 name_buffer);
504 } else {
505 int phy_addr = cvmx_helper_board_get_mii_address(CVMX_HELPER_BOARD_MGMT_IPD_PORT + i);
506 octeon_fdt_set_phy(mgmt, phy_addr);
507 octeon_fdt_set_mac_addr(mgmt, &mac_addr_base);
508 }
509 }
510 }
511
512 pip_path = fdt_getprop(initial_boot_params, aliases, "pip", NULL);
513 if (pip_path) {
514 int pip = fdt_path_offset(initial_boot_params, pip_path);
515 if (pip >= 0)
516 for (i = 0; i <= 4; i++)
517 octeon_fdt_pip_iface(pip, i, &mac_addr_base);
518 }
519
520 /* I2C */
521 if (OCTEON_IS_MODEL(OCTEON_CN52XX) ||
522 OCTEON_IS_MODEL(OCTEON_CN63XX) ||
523 OCTEON_IS_MODEL(OCTEON_CN68XX) ||
524 OCTEON_IS_MODEL(OCTEON_CN56XX))
525 max_port = 2;
526 else
527 max_port = 1;
528
529 for (i = 0; i < 2; i++) {
530 int i2c;
531 snprintf(name_buffer, sizeof(name_buffer),
532 "twsi%d", i);
533 alias_prop = fdt_getprop(initial_boot_params, aliases,
534 name_buffer, NULL);
535
536 if (alias_prop) {
537 i2c = fdt_path_offset(initial_boot_params, alias_prop);
538 if (i2c < 0)
539 continue;
540 if (i >= max_port) {
541 pr_debug("Deleting twsi%d\n", i);
542 fdt_nop_node(initial_boot_params, i2c);
543 fdt_nop_property(initial_boot_params, aliases,
544 name_buffer);
545 }
546 }
547 }
548
549 /* SMI/MDIO */
550 if (OCTEON_IS_MODEL(OCTEON_CN68XX))
551 max_port = 4;
552 else if (OCTEON_IS_MODEL(OCTEON_CN52XX) ||
553 OCTEON_IS_MODEL(OCTEON_CN63XX) ||
554 OCTEON_IS_MODEL(OCTEON_CN56XX))
555 max_port = 2;
556 else
557 max_port = 1;
558
559 for (i = 0; i < 2; i++) {
560 int i2c;
561 snprintf(name_buffer, sizeof(name_buffer),
562 "smi%d", i);
563 alias_prop = fdt_getprop(initial_boot_params, aliases,
564 name_buffer, NULL);
565
566 if (alias_prop) {
567 i2c = fdt_path_offset(initial_boot_params, alias_prop);
568 if (i2c < 0)
569 continue;
570 if (i >= max_port) {
571 pr_debug("Deleting smi%d\n", i);
572 fdt_nop_node(initial_boot_params, i2c);
573 fdt_nop_property(initial_boot_params, aliases,
574 name_buffer);
575 }
576 }
577 }
578
579 /* Serial */
580 uart_mask = 3;
581
582 /* Right now CN52XX is the only chip with a third uart */
583 if (OCTEON_IS_MODEL(OCTEON_CN52XX))
584 uart_mask |= 4; /* uart2 */
585
586 for (i = 0; i < 3; i++) {
587 int uart;
588 snprintf(name_buffer, sizeof(name_buffer),
589 "uart%d", i);
590 alias_prop = fdt_getprop(initial_boot_params, aliases,
591 name_buffer, NULL);
592
593 if (alias_prop) {
594 uart = fdt_path_offset(initial_boot_params, alias_prop);
595 if (uart_mask & (1 << i))
596 continue;
597 pr_debug("Deleting uart%d\n", i);
598 fdt_nop_node(initial_boot_params, uart);
599 fdt_nop_property(initial_boot_params, aliases,
600 name_buffer);
601 }
602 }
603
604 /* Compact Flash */
605 alias_prop = fdt_getprop(initial_boot_params, aliases,
606 "cf0", NULL);
607 if (alias_prop) {
608 union cvmx_mio_boot_reg_cfgx mio_boot_reg_cfg;
609 unsigned long base_ptr, region_base, region_size;
610 unsigned long region1_base = 0;
611 unsigned long region1_size = 0;
612 int cs, bootbus;
613 bool is_16bit = false;
614 bool is_true_ide = false;
615 __be32 new_reg[6];
616 __be32 *ranges;
617 int len;
618
619 int cf = fdt_path_offset(initial_boot_params, alias_prop);
620 base_ptr = 0;
621 if (octeon_bootinfo->major_version == 1
622 && octeon_bootinfo->minor_version >= 1) {
623 if (octeon_bootinfo->compact_flash_common_base_addr)
624 base_ptr = octeon_bootinfo->compact_flash_common_base_addr;
625 } else {
626 base_ptr = 0x1d000800;
627 }
628
629 if (!base_ptr)
630 goto no_cf;
631
632 /* Find CS0 region. */
633 for (cs = 0; cs < 8; cs++) {
634 mio_boot_reg_cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(cs));
635 region_base = mio_boot_reg_cfg.s.base << 16;
636 region_size = (mio_boot_reg_cfg.s.size + 1) << 16;
637 if (mio_boot_reg_cfg.s.en && base_ptr >= region_base
638 && base_ptr < region_base + region_size) {
639 is_16bit = mio_boot_reg_cfg.s.width;
640 break;
641 }
642 }
643 if (cs >= 7) {
644 /* cs and cs + 1 are CS0 and CS1, both must be less than 8. */
645 goto no_cf;
646 }
647
648 if (!(base_ptr & 0xfffful)) {
649 /*
650 * Boot loader signals availability of DMA (true_ide
651 * mode) by setting low order bits of base_ptr to
652 * zero.
653 */
654
655 /* Asume that CS1 immediately follows. */
656 mio_boot_reg_cfg.u64 =
657 cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(cs + 1));
658 region1_base = mio_boot_reg_cfg.s.base << 16;
659 region1_size = (mio_boot_reg_cfg.s.size + 1) << 16;
660 if (!mio_boot_reg_cfg.s.en)
661 goto no_cf;
662 is_true_ide = true;
663
664 } else {
665 fdt_nop_property(initial_boot_params, cf, "cavium,true-ide");
666 fdt_nop_property(initial_boot_params, cf, "cavium,dma-engine-handle");
667 if (!is_16bit) {
668 __be32 width = cpu_to_be32(8);
669 fdt_setprop_inplace(initial_boot_params, cf,
670 "cavium,bus-width", &width, sizeof(width));
671 }
672 }
673 new_reg[0] = cpu_to_be32(cs);
674 new_reg[1] = cpu_to_be32(0);
675 new_reg[2] = cpu_to_be32(0x10000);
676 new_reg[3] = cpu_to_be32(cs + 1);
677 new_reg[4] = cpu_to_be32(0);
678 new_reg[5] = cpu_to_be32(0x10000);
679 fdt_setprop_inplace(initial_boot_params, cf,
680 "reg", new_reg, sizeof(new_reg));
681
682 bootbus = fdt_parent_offset(initial_boot_params, cf);
683 if (bootbus < 0)
684 goto no_cf;
685 ranges = fdt_getprop_w(initial_boot_params, bootbus, "ranges", &len);
686 if (!ranges || len < (5 * 8 * sizeof(__be32)))
687 goto no_cf;
688
689 ranges[(cs * 5) + 2] = cpu_to_be32(region_base >> 32);
690 ranges[(cs * 5) + 3] = cpu_to_be32(region_base & 0xffffffff);
691 ranges[(cs * 5) + 4] = cpu_to_be32(region_size);
692 if (is_true_ide) {
693 cs++;
694 ranges[(cs * 5) + 2] = cpu_to_be32(region1_base >> 32);
695 ranges[(cs * 5) + 3] = cpu_to_be32(region1_base & 0xffffffff);
696 ranges[(cs * 5) + 4] = cpu_to_be32(region1_size);
697 }
698 goto end_cf;
699no_cf:
700 fdt_nop_node(initial_boot_params, cf);
701
702end_cf:
703 ;
704 }
705
706 /* 8 char LED */
707 alias_prop = fdt_getprop(initial_boot_params, aliases,
708 "led0", NULL);
709 if (alias_prop) {
710 union cvmx_mio_boot_reg_cfgx mio_boot_reg_cfg;
711 unsigned long base_ptr, region_base, region_size;
712 int cs, bootbus;
713 __be32 new_reg[6];
714 __be32 *ranges;
715 int len;
716 int led = fdt_path_offset(initial_boot_params, alias_prop);
717
718 base_ptr = octeon_bootinfo->led_display_base_addr;
719 if (base_ptr == 0)
720 goto no_led;
721 /* Find CS0 region. */
722 for (cs = 0; cs < 8; cs++) {
723 mio_boot_reg_cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(cs));
724 region_base = mio_boot_reg_cfg.s.base << 16;
725 region_size = (mio_boot_reg_cfg.s.size + 1) << 16;
726 if (mio_boot_reg_cfg.s.en && base_ptr >= region_base
727 && base_ptr < region_base + region_size)
728 break;
729 }
730
731 if (cs > 7)
732 goto no_led;
733
734 new_reg[0] = cpu_to_be32(cs);
735 new_reg[1] = cpu_to_be32(0x20);
736 new_reg[2] = cpu_to_be32(0x20);
737 new_reg[3] = cpu_to_be32(cs);
738 new_reg[4] = cpu_to_be32(0);
739 new_reg[5] = cpu_to_be32(0x20);
740 fdt_setprop_inplace(initial_boot_params, led,
741 "reg", new_reg, sizeof(new_reg));
742
743 bootbus = fdt_parent_offset(initial_boot_params, led);
744 if (bootbus < 0)
745 goto no_led;
746 ranges = fdt_getprop_w(initial_boot_params, bootbus, "ranges", &len);
747 if (!ranges || len < (5 * 8 * sizeof(__be32)))
748 goto no_led;
749
750 ranges[(cs * 5) + 2] = cpu_to_be32(region_base >> 32);
751 ranges[(cs * 5) + 3] = cpu_to_be32(region_base & 0xffffffff);
752 ranges[(cs * 5) + 4] = cpu_to_be32(region_size);
753 goto end_led;
754
755no_led:
756 fdt_nop_node(initial_boot_params, led);
757end_led:
758 ;
759 }
760
761 /* OHCI/UHCI USB */
762 alias_prop = fdt_getprop(initial_boot_params, aliases,
763 "uctl", NULL);
764 if (alias_prop) {
765 int uctl = fdt_path_offset(initial_boot_params, alias_prop);
766
767 if (uctl >= 0 && (!OCTEON_IS_MODEL(OCTEON_CN6XXX) ||
768 octeon_bootinfo->board_type == CVMX_BOARD_TYPE_NIC2E)) {
769 pr_debug("Deleting uctl\n");
770 fdt_nop_node(initial_boot_params, uctl);
771 fdt_nop_property(initial_boot_params, aliases, "uctl");
772 } else if (octeon_bootinfo->board_type == CVMX_BOARD_TYPE_NIC10E ||
773 octeon_bootinfo->board_type == CVMX_BOARD_TYPE_NIC4E) {
774 /* Missing "refclk-type" defaults to crystal. */
775 fdt_nop_property(initial_boot_params, uctl, "refclk-type");
776 }
777 }
778
779 return 0;
780}
781
782static int __init octeon_publish_devices(void)
783{
784 return of_platform_bus_probe(NULL, octeon_ids, NULL);
785}
786device_initcall(octeon_publish_devices);
787
443MODULE_AUTHOR("David Daney <ddaney@caviumnetworks.com>"); 788MODULE_AUTHOR("David Daney <ddaney@caviumnetworks.com>");
444MODULE_LICENSE("GPL"); 789MODULE_LICENSE("GPL");
445MODULE_DESCRIPTION("Platform driver for Octeon SOC"); 790MODULE_DESCRIPTION("Platform driver for Octeon SOC");
diff --git a/arch/mips/cavium-octeon/octeon_3xxx.dts b/arch/mips/cavium-octeon/octeon_3xxx.dts
new file mode 100644
index 00000000000..f28b2d0fde2
--- /dev/null
+++ b/arch/mips/cavium-octeon/octeon_3xxx.dts
@@ -0,0 +1,571 @@
1/dts-v1/;
2/*
3 * OCTEON 3XXX, 5XXX, 63XX device tree skeleton.
4 *
5 * This device tree is pruned and patched by early boot code before
6 * use. Because of this, it contains a super-set of the available
7 * devices and properties.
8 */
9/ {
10 compatible = "cavium,octeon-3860";
11 #address-cells = <2>;
12 #size-cells = <2>;
13 interrupt-parent = <&ciu>;
14
15 soc@0 {
16 compatible = "simple-bus";
17 #address-cells = <2>;
18 #size-cells = <2>;
19 ranges; /* Direct mapping */
20
21 ciu: interrupt-controller@1070000000000 {
22 compatible = "cavium,octeon-3860-ciu";
23 interrupt-controller;
24 /* Interrupts are specified by two parts:
25 * 1) Controller register (0 or 1)
26 * 2) Bit within the register (0..63)
27 */
28 #interrupt-cells = <2>;
29 reg = <0x10700 0x00000000 0x0 0x7000>;
30 };
31
32 gpio: gpio-controller@1070000000800 {
33 #gpio-cells = <2>;
34 compatible = "cavium,octeon-3860-gpio";
35 reg = <0x10700 0x00000800 0x0 0x100>;
36 gpio-controller;
37 /* Interrupts are specified by two parts:
38 * 1) GPIO pin number (0..15)
39 * 2) Triggering (1 - edge rising
40 * 2 - edge falling
41 * 4 - level active high
42 * 8 - level active low)
43 */
44 interrupt-controller;
45 #interrupt-cells = <2>;
46 /* The GPIO pin connect to 16 consecutive CUI bits */
47 interrupts = <0 16>, <0 17>, <0 18>, <0 19>,
48 <0 20>, <0 21>, <0 22>, <0 23>,
49 <0 24>, <0 25>, <0 26>, <0 27>,
50 <0 28>, <0 29>, <0 30>, <0 31>;
51 };
52
53 smi0: mdio@1180000001800 {
54 compatible = "cavium,octeon-3860-mdio";
55 #address-cells = <1>;
56 #size-cells = <0>;
57 reg = <0x11800 0x00001800 0x0 0x40>;
58
59 phy0: ethernet-phy@0 {
60 compatible = "marvell,88e1118";
61 marvell,reg-init =
62 /* Fix rx and tx clock transition timing */
63 <2 0x15 0xffcf 0>, /* Reg 2,21 Clear bits 4, 5 */
64 /* Adjust LED drive. */
65 <3 0x11 0 0x442a>, /* Reg 3,17 <- 0442a */
66 /* irq, blink-activity, blink-link */
67 <3 0x10 0 0x0242>; /* Reg 3,16 <- 0x0242 */
68 reg = <0>;
69 };
70
71 phy1: ethernet-phy@1 {
72 compatible = "marvell,88e1118";
73 marvell,reg-init =
74 /* Fix rx and tx clock transition timing */
75 <2 0x15 0xffcf 0>, /* Reg 2,21 Clear bits 4, 5 */
76 /* Adjust LED drive. */
77 <3 0x11 0 0x442a>, /* Reg 3,17 <- 0442a */
78 /* irq, blink-activity, blink-link */
79 <3 0x10 0 0x0242>; /* Reg 3,16 <- 0x0242 */
80 reg = <1>;
81 };
82
83 phy2: ethernet-phy@2 {
84 reg = <2>;
85 compatible = "marvell,88e1149r";
86 marvell,reg-init = <3 0x10 0 0x5777>,
87 <3 0x11 0 0x00aa>,
88 <3 0x12 0 0x4105>,
89 <3 0x13 0 0x0a60>;
90 };
91 phy3: ethernet-phy@3 {
92 reg = <3>;
93 compatible = "marvell,88e1149r";
94 marvell,reg-init = <3 0x10 0 0x5777>,
95 <3 0x11 0 0x00aa>,
96 <3 0x12 0 0x4105>,
97 <3 0x13 0 0x0a60>;
98 };
99 phy4: ethernet-phy@4 {
100 reg = <4>;
101 compatible = "marvell,88e1149r";
102 marvell,reg-init = <3 0x10 0 0x5777>,
103 <3 0x11 0 0x00aa>,
104 <3 0x12 0 0x4105>,
105 <3 0x13 0 0x0a60>;
106 };
107 phy5: ethernet-phy@5 {
108 reg = <5>;
109 compatible = "marvell,88e1149r";
110 marvell,reg-init = <3 0x10 0 0x5777>,
111 <3 0x11 0 0x00aa>,
112 <3 0x12 0 0x4105>,
113 <3 0x13 0 0x0a60>;
114 };
115
116 phy6: ethernet-phy@6 {
117 reg = <6>;
118 compatible = "marvell,88e1149r";
119 marvell,reg-init = <3 0x10 0 0x5777>,
120 <3 0x11 0 0x00aa>,
121 <3 0x12 0 0x4105>,
122 <3 0x13 0 0x0a60>;
123 };
124 phy7: ethernet-phy@7 {
125 reg = <7>;
126 compatible = "marvell,88e1149r";
127 marvell,reg-init = <3 0x10 0 0x5777>,
128 <3 0x11 0 0x00aa>,
129 <3 0x12 0 0x4105>,
130 <3 0x13 0 0x0a60>;
131 };
132 phy8: ethernet-phy@8 {
133 reg = <8>;
134 compatible = "marvell,88e1149r";
135 marvell,reg-init = <3 0x10 0 0x5777>,
136 <3 0x11 0 0x00aa>,
137 <3 0x12 0 0x4105>,
138 <3 0x13 0 0x0a60>;
139 };
140 phy9: ethernet-phy@9 {
141 reg = <9>;
142 compatible = "marvell,88e1149r";
143 marvell,reg-init = <3 0x10 0 0x5777>,
144 <3 0x11 0 0x00aa>,
145 <3 0x12 0 0x4105>,
146 <3 0x13 0 0x0a60>;
147 };
148 };
149
150 smi1: mdio@1180000001900 {
151 compatible = "cavium,octeon-3860-mdio";
152 #address-cells = <1>;
153 #size-cells = <0>;
154 reg = <0x11800 0x00001900 0x0 0x40>;
155
156 phy100: ethernet-phy@1 {
157 reg = <1>;
158 compatible = "marvell,88e1149r";
159 marvell,reg-init = <3 0x10 0 0x5777>,
160 <3 0x11 0 0x00aa>,
161 <3 0x12 0 0x4105>,
162 <3 0x13 0 0x0a60>;
163 interrupt-parent = <&gpio>;
164 interrupts = <12 8>; /* Pin 12, active low */
165 };
166 phy101: ethernet-phy@2 {
167 reg = <2>;
168 compatible = "marvell,88e1149r";
169 marvell,reg-init = <3 0x10 0 0x5777>,
170 <3 0x11 0 0x00aa>,
171 <3 0x12 0 0x4105>,
172 <3 0x13 0 0x0a60>;
173 interrupt-parent = <&gpio>;
174 interrupts = <12 8>; /* Pin 12, active low */
175 };
176 phy102: ethernet-phy@3 {
177 reg = <3>;
178 compatible = "marvell,88e1149r";
179 marvell,reg-init = <3 0x10 0 0x5777>,
180 <3 0x11 0 0x00aa>,
181 <3 0x12 0 0x4105>,
182 <3 0x13 0 0x0a60>;
183 interrupt-parent = <&gpio>;
184 interrupts = <12 8>; /* Pin 12, active low */
185 };
186 phy103: ethernet-phy@4 {
187 reg = <4>;
188 compatible = "marvell,88e1149r";
189 marvell,reg-init = <3 0x10 0 0x5777>,
190 <3 0x11 0 0x00aa>,
191 <3 0x12 0 0x4105>,
192 <3 0x13 0 0x0a60>;
193 interrupt-parent = <&gpio>;
194 interrupts = <12 8>; /* Pin 12, active low */
195 };
196 };
197
198 mix0: ethernet@1070000100000 {
199 compatible = "cavium,octeon-5750-mix";
200 reg = <0x10700 0x00100000 0x0 0x100>, /* MIX */
201 <0x11800 0xE0000000 0x0 0x300>, /* AGL */
202 <0x11800 0xE0000400 0x0 0x400>, /* AGL_SHARED */
203 <0x11800 0xE0002000 0x0 0x8>; /* AGL_PRT_CTL */
204 cell-index = <0>;
205 interrupts = <0 62>, <1 46>;
206 local-mac-address = [ 00 00 00 00 00 00 ];
207 phy-handle = <&phy0>;
208 };
209
210 mix1: ethernet@1070000100800 {
211 compatible = "cavium,octeon-5750-mix";
212 reg = <0x10700 0x00100800 0x0 0x100>, /* MIX */
213 <0x11800 0xE0000800 0x0 0x300>, /* AGL */
214 <0x11800 0xE0000400 0x0 0x400>, /* AGL_SHARED */
215 <0x11800 0xE0002008 0x0 0x8>; /* AGL_PRT_CTL */
216 cell-index = <1>;
217 interrupts = <1 18>, < 1 46>;
218 local-mac-address = [ 00 00 00 00 00 00 ];
219 phy-handle = <&phy1>;
220 };
221
222 pip: pip@11800a0000000 {
223 compatible = "cavium,octeon-3860-pip";
224 #address-cells = <1>;
225 #size-cells = <0>;
226 reg = <0x11800 0xa0000000 0x0 0x2000>;
227
228 interface@0 {
229 compatible = "cavium,octeon-3860-pip-interface";
230 #address-cells = <1>;
231 #size-cells = <0>;
232 reg = <0>; /* interface */
233
234 ethernet@0 {
235 compatible = "cavium,octeon-3860-pip-port";
236 reg = <0x0>; /* Port */
237 local-mac-address = [ 00 00 00 00 00 00 ];
238 phy-handle = <&phy2>;
239 cavium,alt-phy-handle = <&phy100>;
240 };
241 ethernet@1 {
242 compatible = "cavium,octeon-3860-pip-port";
243 reg = <0x1>; /* Port */
244 local-mac-address = [ 00 00 00 00 00 00 ];
245 phy-handle = <&phy3>;
246 cavium,alt-phy-handle = <&phy101>;
247 };
248 ethernet@2 {
249 compatible = "cavium,octeon-3860-pip-port";
250 reg = <0x2>; /* Port */
251 local-mac-address = [ 00 00 00 00 00 00 ];
252 phy-handle = <&phy4>;
253 cavium,alt-phy-handle = <&phy102>;
254 };
255 ethernet@3 {
256 compatible = "cavium,octeon-3860-pip-port";
257 reg = <0x3>; /* Port */
258 local-mac-address = [ 00 00 00 00 00 00 ];
259 phy-handle = <&phy5>;
260 cavium,alt-phy-handle = <&phy103>;
261 };
262 ethernet@4 {
263 compatible = "cavium,octeon-3860-pip-port";
264 reg = <0x4>; /* Port */
265 local-mac-address = [ 00 00 00 00 00 00 ];
266 };
267 ethernet@5 {
268 compatible = "cavium,octeon-3860-pip-port";
269 reg = <0x5>; /* Port */
270 local-mac-address = [ 00 00 00 00 00 00 ];
271 };
272 ethernet@6 {
273 compatible = "cavium,octeon-3860-pip-port";
274 reg = <0x6>; /* Port */
275 local-mac-address = [ 00 00 00 00 00 00 ];
276 };
277 ethernet@7 {
278 compatible = "cavium,octeon-3860-pip-port";
279 reg = <0x7>; /* Port */
280 local-mac-address = [ 00 00 00 00 00 00 ];
281 };
282 ethernet@8 {
283 compatible = "cavium,octeon-3860-pip-port";
284 reg = <0x8>; /* Port */
285 local-mac-address = [ 00 00 00 00 00 00 ];
286 };
287 ethernet@9 {
288 compatible = "cavium,octeon-3860-pip-port";
289 reg = <0x9>; /* Port */
290 local-mac-address = [ 00 00 00 00 00 00 ];
291 };
292 ethernet@a {
293 compatible = "cavium,octeon-3860-pip-port";
294 reg = <0xa>; /* Port */
295 local-mac-address = [ 00 00 00 00 00 00 ];
296 };
297 ethernet@b {
298 compatible = "cavium,octeon-3860-pip-port";
299 reg = <0xb>; /* Port */
300 local-mac-address = [ 00 00 00 00 00 00 ];
301 };
302 ethernet@c {
303 compatible = "cavium,octeon-3860-pip-port";
304 reg = <0xc>; /* Port */
305 local-mac-address = [ 00 00 00 00 00 00 ];
306 };
307 ethernet@d {
308 compatible = "cavium,octeon-3860-pip-port";
309 reg = <0xd>; /* Port */
310 local-mac-address = [ 00 00 00 00 00 00 ];
311 };
312 ethernet@e {
313 compatible = "cavium,octeon-3860-pip-port";
314 reg = <0xe>; /* Port */
315 local-mac-address = [ 00 00 00 00 00 00 ];
316 };
317 ethernet@f {
318 compatible = "cavium,octeon-3860-pip-port";
319 reg = <0xf>; /* Port */
320 local-mac-address = [ 00 00 00 00 00 00 ];
321 };
322 };
323
324 interface@1 {
325 compatible = "cavium,octeon-3860-pip-interface";
326 #address-cells = <1>;
327 #size-cells = <0>;
328 reg = <1>; /* interface */
329
330 ethernet@0 {
331 compatible = "cavium,octeon-3860-pip-port";
332 reg = <0x0>; /* Port */
333 local-mac-address = [ 00 00 00 00 00 00 ];
334 phy-handle = <&phy6>;
335 };
336 ethernet@1 {
337 compatible = "cavium,octeon-3860-pip-port";
338 reg = <0x1>; /* Port */
339 local-mac-address = [ 00 00 00 00 00 00 ];
340 phy-handle = <&phy7>;
341 };
342 ethernet@2 {
343 compatible = "cavium,octeon-3860-pip-port";
344 reg = <0x2>; /* Port */
345 local-mac-address = [ 00 00 00 00 00 00 ];
346 phy-handle = <&phy8>;
347 };
348 ethernet@3 {
349 compatible = "cavium,octeon-3860-pip-port";
350 reg = <0x3>; /* Port */
351 local-mac-address = [ 00 00 00 00 00 00 ];
352 phy-handle = <&phy9>;
353 };
354 };
355 };
356
357 twsi0: i2c@1180000001000 {
358 #address-cells = <1>;
359 #size-cells = <0>;
360 compatible = "cavium,octeon-3860-twsi";
361 reg = <0x11800 0x00001000 0x0 0x200>;
362 interrupts = <0 45>;
363 clock-frequency = <100000>;
364
365 rtc@68 {
366 compatible = "dallas,ds1337";
367 reg = <0x68>;
368 };
369 tmp@4c {
370 compatible = "ti,tmp421";
371 reg = <0x4c>;
372 };
373 };
374
375 twsi1: i2c@1180000001200 {
376 #address-cells = <1>;
377 #size-cells = <0>;
378 compatible = "cavium,octeon-3860-twsi";
379 reg = <0x11800 0x00001200 0x0 0x200>;
380 interrupts = <0 59>;
381 clock-frequency = <100000>;
382 };
383
384 uart0: serial@1180000000800 {
385 compatible = "cavium,octeon-3860-uart","ns16550";
386 reg = <0x11800 0x00000800 0x0 0x400>;
387 clock-frequency = <0>;
388 current-speed = <115200>;
389 reg-shift = <3>;
390 interrupts = <0 34>;
391 };
392
393 uart1: serial@1180000000c00 {
394 compatible = "cavium,octeon-3860-uart","ns16550";
395 reg = <0x11800 0x00000c00 0x0 0x400>;
396 clock-frequency = <0>;
397 current-speed = <115200>;
398 reg-shift = <3>;
399 interrupts = <0 35>;
400 };
401
402 uart2: serial@1180000000400 {
403 compatible = "cavium,octeon-3860-uart","ns16550";
404 reg = <0x11800 0x00000400 0x0 0x400>;
405 clock-frequency = <0>;
406 current-speed = <115200>;
407 reg-shift = <3>;
408 interrupts = <1 16>;
409 };
410
411 bootbus: bootbus@1180000000000 {
412 compatible = "cavium,octeon-3860-bootbus";
413 reg = <0x11800 0x00000000 0x0 0x200>;
414 /* The chip select number and offset */
415 #address-cells = <2>;
416 /* The size of the chip select region */
417 #size-cells = <1>;
418 ranges = <0 0 0x0 0x1f400000 0xc00000>,
419 <1 0 0x10000 0x30000000 0>,
420 <2 0 0x10000 0x40000000 0>,
421 <3 0 0x10000 0x50000000 0>,
422 <4 0 0x0 0x1d020000 0x10000>,
423 <5 0 0x0 0x1d040000 0x10000>,
424 <6 0 0x0 0x1d050000 0x10000>,
425 <7 0 0x10000 0x90000000 0>;
426
427 cavium,cs-config@0 {
428 compatible = "cavium,octeon-3860-bootbus-config";
429 cavium,cs-index = <0>;
430 cavium,t-adr = <20>;
431 cavium,t-ce = <60>;
432 cavium,t-oe = <60>;
433 cavium,t-we = <45>;
434 cavium,t-rd-hld = <35>;
435 cavium,t-wr-hld = <45>;
436 cavium,t-pause = <0>;
437 cavium,t-wait = <0>;
438 cavium,t-page = <35>;
439 cavium,t-rd-dly = <0>;
440
441 cavium,pages = <0>;
442 cavium,bus-width = <8>;
443 };
444 cavium,cs-config@4 {
445 compatible = "cavium,octeon-3860-bootbus-config";
446 cavium,cs-index = <4>;
447 cavium,t-adr = <320>;
448 cavium,t-ce = <320>;
449 cavium,t-oe = <320>;
450 cavium,t-we = <320>;
451 cavium,t-rd-hld = <320>;
452 cavium,t-wr-hld = <320>;
453 cavium,t-pause = <320>;
454 cavium,t-wait = <320>;
455 cavium,t-page = <320>;
456 cavium,t-rd-dly = <0>;
457
458 cavium,pages = <0>;
459 cavium,bus-width = <8>;
460 };
461 cavium,cs-config@5 {
462 compatible = "cavium,octeon-3860-bootbus-config";
463 cavium,cs-index = <5>;
464 cavium,t-adr = <5>;
465 cavium,t-ce = <300>;
466 cavium,t-oe = <125>;
467 cavium,t-we = <150>;
468 cavium,t-rd-hld = <100>;
469 cavium,t-wr-hld = <30>;
470 cavium,t-pause = <0>;
471 cavium,t-wait = <30>;
472 cavium,t-page = <320>;
473 cavium,t-rd-dly = <0>;
474
475 cavium,pages = <0>;
476 cavium,bus-width = <16>;
477 };
478 cavium,cs-config@6 {
479 compatible = "cavium,octeon-3860-bootbus-config";
480 cavium,cs-index = <6>;
481 cavium,t-adr = <5>;
482 cavium,t-ce = <300>;
483 cavium,t-oe = <270>;
484 cavium,t-we = <150>;
485 cavium,t-rd-hld = <100>;
486 cavium,t-wr-hld = <70>;
487 cavium,t-pause = <0>;
488 cavium,t-wait = <0>;
489 cavium,t-page = <320>;
490 cavium,t-rd-dly = <0>;
491
492 cavium,pages = <0>;
493 cavium,wait-mode;
494 cavium,bus-width = <16>;
495 };
496
497 flash0: nor@0,0 {
498 compatible = "cfi-flash";
499 reg = <0 0 0x800000>;
500 #address-cells = <1>;
501 #size-cells = <1>;
502 };
503
504 led0: led-display@4,0 {
505 compatible = "avago,hdsp-253x";
506 reg = <4 0x20 0x20>, <4 0 0x20>;
507 };
508
509 cf0: compact-flash@5,0 {
510 compatible = "cavium,ebt3000-compact-flash";
511 reg = <5 0 0x10000>, <6 0 0x10000>;
512 cavium,bus-width = <16>;
513 cavium,true-ide;
514 cavium,dma-engine-handle = <&dma0>;
515 };
516 };
517
518 dma0: dma-engine@1180000000100 {
519 compatible = "cavium,octeon-5750-bootbus-dma";
520 reg = <0x11800 0x00000100 0x0 0x8>;
521 interrupts = <0 63>;
522 };
523 dma1: dma-engine@1180000000108 {
524 compatible = "cavium,octeon-5750-bootbus-dma";
525 reg = <0x11800 0x00000108 0x0 0x8>;
526 interrupts = <0 63>;
527 };
528
529 uctl: uctl@118006f000000 {
530 compatible = "cavium,octeon-6335-uctl";
531 reg = <0x11800 0x6f000000 0x0 0x100>;
532 ranges; /* Direct mapping */
533 #address-cells = <2>;
534 #size-cells = <2>;
535 /* 12MHz, 24MHz and 48MHz allowed */
536 refclk-frequency = <12000000>;
537 /* Either "crystal" or "external" */
538 refclk-type = "crystal";
539
540 ehci@16f0000000000 {
541 compatible = "cavium,octeon-6335-ehci","usb-ehci";
542 reg = <0x16f00 0x00000000 0x0 0x100>;
543 interrupts = <0 56>;
544 big-endian-regs;
545 };
546 ohci@16f0000000400 {
547 compatible = "cavium,octeon-6335-ohci","usb-ohci";
548 reg = <0x16f00 0x00000400 0x0 0x100>;
549 interrupts = <0 56>;
550 big-endian-regs;
551 };
552 };
553 };
554
555 aliases {
556 mix0 = &mix0;
557 mix1 = &mix1;
558 pip = &pip;
559 smi0 = &smi0;
560 smi1 = &smi1;
561 twsi0 = &twsi0;
562 twsi1 = &twsi1;
563 uart0 = &uart0;
564 uart1 = &uart1;
565 uart2 = &uart2;
566 flash0 = &flash0;
567 cf0 = &cf0;
568 uctl = &uctl;
569 led0 = &led0;
570 };
571 };
diff --git a/arch/mips/cavium-octeon/octeon_68xx.dts b/arch/mips/cavium-octeon/octeon_68xx.dts
new file mode 100644
index 00000000000..1839468932b
--- /dev/null
+++ b/arch/mips/cavium-octeon/octeon_68xx.dts
@@ -0,0 +1,625 @@
1/dts-v1/;
2/*
3 * OCTEON 68XX device tree skeleton.
4 *
5 * This device tree is pruned and patched by early boot code before
6 * use. Because of this, it contains a super-set of the available
7 * devices and properties.
8 */
9/ {
10 compatible = "cavium,octeon-6880";
11 #address-cells = <2>;
12 #size-cells = <2>;
13 interrupt-parent = <&ciu2>;
14
15 soc@0 {
16 compatible = "simple-bus";
17 #address-cells = <2>;
18 #size-cells = <2>;
19 ranges; /* Direct mapping */
20
21 ciu2: interrupt-controller@1070100000000 {
22 compatible = "cavium,octeon-6880-ciu2";
23 interrupt-controller;
24 /* Interrupts are specified by two parts:
25 * 1) Controller register (0 or 7)
26 * 2) Bit within the register (0..63)
27 */
28 #address-cells = <0>;
29 #interrupt-cells = <2>;
30 reg = <0x10701 0x00000000 0x0 0x4000000>;
31 };
32
33 gpio: gpio-controller@1070000000800 {
34 #gpio-cells = <2>;
35 compatible = "cavium,octeon-3860-gpio";
36 reg = <0x10700 0x00000800 0x0 0x100>;
37 gpio-controller;
38 /* Interrupts are specified by two parts:
39 * 1) GPIO pin number (0..15)
40 * 2) Triggering (1 - edge rising
41 * 2 - edge falling
42 * 4 - level active high
43 * 8 - level active low)
44 */
45 interrupt-controller;
46 #interrupt-cells = <2>;
47 /* The GPIO pins connect to 16 consecutive CUI bits */
48 interrupts = <7 0>, <7 1>, <7 2>, <7 3>,
49 <7 4>, <7 5>, <7 6>, <7 7>,
50 <7 8>, <7 9>, <7 10>, <7 11>,
51 <7 12>, <7 13>, <7 14>, <7 15>;
52 };
53
54 smi0: mdio@1180000003800 {
55 compatible = "cavium,octeon-3860-mdio";
56 #address-cells = <1>;
57 #size-cells = <0>;
58 reg = <0x11800 0x00003800 0x0 0x40>;
59
60 phy0: ethernet-phy@6 {
61 compatible = "marvell,88e1118";
62 marvell,reg-init =
63 /* Fix rx and tx clock transition timing */
64 <2 0x15 0xffcf 0>, /* Reg 2,21 Clear bits 4, 5 */
65 /* Adjust LED drive. */
66 <3 0x11 0 0x442a>, /* Reg 3,17 <- 0442a */
67 /* irq, blink-activity, blink-link */
68 <3 0x10 0 0x0242>; /* Reg 3,16 <- 0x0242 */
69 reg = <6>;
70 };
71
72 phy1: ethernet-phy@1 {
73 cavium,qlm-trim = "4,sgmii";
74 reg = <1>;
75 compatible = "marvell,88e1149r";
76 marvell,reg-init = <3 0x10 0 0x5777>,
77 <3 0x11 0 0x00aa>,
78 <3 0x12 0 0x4105>,
79 <3 0x13 0 0x0a60>;
80 };
81 phy2: ethernet-phy@2 {
82 cavium,qlm-trim = "4,sgmii";
83 reg = <2>;
84 compatible = "marvell,88e1149r";
85 marvell,reg-init = <3 0x10 0 0x5777>,
86 <3 0x11 0 0x00aa>,
87 <3 0x12 0 0x4105>,
88 <3 0x13 0 0x0a60>;
89 };
90 phy3: ethernet-phy@3 {
91 cavium,qlm-trim = "4,sgmii";
92 reg = <3>;
93 compatible = "marvell,88e1149r";
94 marvell,reg-init = <3 0x10 0 0x5777>,
95 <3 0x11 0 0x00aa>,
96 <3 0x12 0 0x4105>,
97 <3 0x13 0 0x0a60>;
98 };
99 phy4: ethernet-phy@4 {
100 cavium,qlm-trim = "4,sgmii";
101 reg = <4>;
102 compatible = "marvell,88e1149r";
103 marvell,reg-init = <3 0x10 0 0x5777>,
104 <3 0x11 0 0x00aa>,
105 <3 0x12 0 0x4105>,
106 <3 0x13 0 0x0a60>;
107 };
108 };
109
110 smi1: mdio@1180000003880 {
111 compatible = "cavium,octeon-3860-mdio";
112 #address-cells = <1>;
113 #size-cells = <0>;
114 reg = <0x11800 0x00003880 0x0 0x40>;
115
116 phy41: ethernet-phy@1 {
117 cavium,qlm-trim = "0,sgmii";
118 reg = <1>;
119 compatible = "marvell,88e1149r";
120 marvell,reg-init = <3 0x10 0 0x5777>,
121 <3 0x11 0 0x00aa>,
122 <3 0x12 0 0x4105>,
123 <3 0x13 0 0x0a60>;
124 };
125 phy42: ethernet-phy@2 {
126 cavium,qlm-trim = "0,sgmii";
127 reg = <2>;
128 compatible = "marvell,88e1149r";
129 marvell,reg-init = <3 0x10 0 0x5777>,
130 <3 0x11 0 0x00aa>,
131 <3 0x12 0 0x4105>,
132 <3 0x13 0 0x0a60>;
133 };
134 phy43: ethernet-phy@3 {
135 cavium,qlm-trim = "0,sgmii";
136 reg = <3>;
137 compatible = "marvell,88e1149r";
138 marvell,reg-init = <3 0x10 0 0x5777>,
139 <3 0x11 0 0x00aa>,
140 <3 0x12 0 0x4105>,
141 <3 0x13 0 0x0a60>;
142 };
143 phy44: ethernet-phy@4 {
144 cavium,qlm-trim = "0,sgmii";
145 reg = <4>;
146 compatible = "marvell,88e1149r";
147 marvell,reg-init = <3 0x10 0 0x5777>,
148 <3 0x11 0 0x00aa>,
149 <3 0x12 0 0x4105>,
150 <3 0x13 0 0x0a60>;
151 };
152 };
153
154 smi2: mdio@1180000003900 {
155 compatible = "cavium,octeon-3860-mdio";
156 #address-cells = <1>;
157 #size-cells = <0>;
158 reg = <0x11800 0x00003900 0x0 0x40>;
159
160 phy21: ethernet-phy@1 {
161 cavium,qlm-trim = "2,sgmii";
162 reg = <1>;
163 compatible = "marvell,88e1149r";
164 marvell,reg-init = <3 0x10 0 0x5777>,
165 <3 0x11 0 0x00aa>,
166 <3 0x12 0 0x4105>,
167 <3 0x13 0 0x0a60>;
168 };
169 phy22: ethernet-phy@2 {
170 cavium,qlm-trim = "2,sgmii";
171 reg = <2>;
172 compatible = "marvell,88e1149r";
173 marvell,reg-init = <3 0x10 0 0x5777>,
174 <3 0x11 0 0x00aa>,
175 <3 0x12 0 0x4105>,
176 <3 0x13 0 0x0a60>;
177 };
178 phy23: ethernet-phy@3 {
179 cavium,qlm-trim = "2,sgmii";
180 reg = <3>;
181 compatible = "marvell,88e1149r";
182 marvell,reg-init = <3 0x10 0 0x5777>,
183 <3 0x11 0 0x00aa>,
184 <3 0x12 0 0x4105>,
185 <3 0x13 0 0x0a60>;
186 };
187 phy24: ethernet-phy@4 {
188 cavium,qlm-trim = "2,sgmii";
189 reg = <4>;
190 compatible = "marvell,88e1149r";
191 marvell,reg-init = <3 0x10 0 0x5777>,
192 <3 0x11 0 0x00aa>,
193 <3 0x12 0 0x4105>,
194 <3 0x13 0 0x0a60>;
195 };
196 };
197
198 smi3: mdio@1180000003980 {
199 compatible = "cavium,octeon-3860-mdio";
200 #address-cells = <1>;
201 #size-cells = <0>;
202 reg = <0x11800 0x00003980 0x0 0x40>;
203
204 phy11: ethernet-phy@1 {
205 cavium,qlm-trim = "3,sgmii";
206 reg = <1>;
207 compatible = "marvell,88e1149r";
208 marvell,reg-init = <3 0x10 0 0x5777>,
209 <3 0x11 0 0x00aa>,
210 <3 0x12 0 0x4105>,
211 <3 0x13 0 0x0a60>;
212 };
213 phy12: ethernet-phy@2 {
214 cavium,qlm-trim = "3,sgmii";
215 reg = <2>;
216 compatible = "marvell,88e1149r";
217 marvell,reg-init = <3 0x10 0 0x5777>,
218 <3 0x11 0 0x00aa>,
219 <3 0x12 0 0x4105>,
220 <3 0x13 0 0x0a60>;
221 };
222 phy13: ethernet-phy@3 {
223 cavium,qlm-trim = "3,sgmii";
224 reg = <3>;
225 compatible = "marvell,88e1149r";
226 marvell,reg-init = <3 0x10 0 0x5777>,
227 <3 0x11 0 0x00aa>,
228 <3 0x12 0 0x4105>,
229 <3 0x13 0 0x0a60>;
230 };
231 phy14: ethernet-phy@4 {
232 cavium,qlm-trim = "3,sgmii";
233 reg = <4>;
234 compatible = "marvell,88e1149r";
235 marvell,reg-init = <3 0x10 0 0x5777>,
236 <3 0x11 0 0x00aa>,
237 <3 0x12 0 0x4105>,
238 <3 0x13 0 0x0a60>;
239 };
240 };
241
242 mix0: ethernet@1070000100000 {
243 compatible = "cavium,octeon-5750-mix";
244 reg = <0x10700 0x00100000 0x0 0x100>, /* MIX */
245 <0x11800 0xE0000000 0x0 0x300>, /* AGL */
246 <0x11800 0xE0000400 0x0 0x400>, /* AGL_SHARED */
247 <0x11800 0xE0002000 0x0 0x8>; /* AGL_PRT_CTL */
248 cell-index = <0>;
249 interrupts = <6 40>, <6 32>;
250 local-mac-address = [ 00 00 00 00 00 00 ];
251 phy-handle = <&phy0>;
252 };
253
254 pip: pip@11800a0000000 {
255 compatible = "cavium,octeon-3860-pip";
256 #address-cells = <1>;
257 #size-cells = <0>;
258 reg = <0x11800 0xa0000000 0x0 0x2000>;
259
260 interface@4 {
261 compatible = "cavium,octeon-3860-pip-interface";
262 #address-cells = <1>;
263 #size-cells = <0>;
264 reg = <0x4>; /* interface */
265
266 ethernet@0 {
267 compatible = "cavium,octeon-3860-pip-port";
268 reg = <0x0>; /* Port */
269 local-mac-address = [ 00 00 00 00 00 00 ];
270 phy-handle = <&phy1>;
271 };
272 ethernet@1 {
273 compatible = "cavium,octeon-3860-pip-port";
274 reg = <0x1>; /* Port */
275 local-mac-address = [ 00 00 00 00 00 00 ];
276 phy-handle = <&phy2>;
277 };
278 ethernet@2 {
279 compatible = "cavium,octeon-3860-pip-port";
280 reg = <0x2>; /* Port */
281 local-mac-address = [ 00 00 00 00 00 00 ];
282 phy-handle = <&phy3>;
283 };
284 ethernet@3 {
285 compatible = "cavium,octeon-3860-pip-port";
286 reg = <0x3>; /* Port */
287 local-mac-address = [ 00 00 00 00 00 00 ];
288 phy-handle = <&phy4>;
289 };
290 };
291
292 interface@3 {
293 compatible = "cavium,octeon-3860-pip-interface";
294 #address-cells = <1>;
295 #size-cells = <0>;
296 reg = <0x3>; /* interface */
297
298 ethernet@0 {
299 compatible = "cavium,octeon-3860-pip-port";
300 reg = <0x0>; /* Port */
301 local-mac-address = [ 00 00 00 00 00 00 ];
302 phy-handle = <&phy11>;
303 };
304 ethernet@1 {
305 compatible = "cavium,octeon-3860-pip-port";
306 reg = <0x1>; /* Port */
307 local-mac-address = [ 00 00 00 00 00 00 ];
308 phy-handle = <&phy12>;
309 };
310 ethernet@2 {
311 compatible = "cavium,octeon-3860-pip-port";
312 reg = <0x2>; /* Port */
313 local-mac-address = [ 00 00 00 00 00 00 ];
314 phy-handle = <&phy13>;
315 };
316 ethernet@3 {
317 compatible = "cavium,octeon-3860-pip-port";
318 reg = <0x3>; /* Port */
319 local-mac-address = [ 00 00 00 00 00 00 ];
320 phy-handle = <&phy14>;
321 };
322 };
323
324 interface@2 {
325 compatible = "cavium,octeon-3860-pip-interface";
326 #address-cells = <1>;
327 #size-cells = <0>;
328 reg = <0x2>; /* interface */
329
330 ethernet@0 {
331 compatible = "cavium,octeon-3860-pip-port";
332 reg = <0x0>; /* Port */
333 local-mac-address = [ 00 00 00 00 00 00 ];
334 phy-handle = <&phy21>;
335 };
336 ethernet@1 {
337 compatible = "cavium,octeon-3860-pip-port";
338 reg = <0x1>; /* Port */
339 local-mac-address = [ 00 00 00 00 00 00 ];
340 phy-handle = <&phy22>;
341 };
342 ethernet@2 {
343 compatible = "cavium,octeon-3860-pip-port";
344 reg = <0x2>; /* Port */
345 local-mac-address = [ 00 00 00 00 00 00 ];
346 phy-handle = <&phy23>;
347 };
348 ethernet@3 {
349 compatible = "cavium,octeon-3860-pip-port";
350 reg = <0x3>; /* Port */
351 local-mac-address = [ 00 00 00 00 00 00 ];
352 phy-handle = <&phy24>;
353 };
354 };
355
356 interface@1 {
357 compatible = "cavium,octeon-3860-pip-interface";
358 #address-cells = <1>;
359 #size-cells = <0>;
360 reg = <0x1>; /* interface */
361
362 ethernet@0 {
363 compatible = "cavium,octeon-3860-pip-port";
364 reg = <0x0>; /* Port */
365 local-mac-address = [ 00 00 00 00 00 00 ];
366 };
367 };
368
369 interface@0 {
370 compatible = "cavium,octeon-3860-pip-interface";
371 #address-cells = <1>;
372 #size-cells = <0>;
373 reg = <0x0>; /* interface */
374
375 ethernet@0 {
376 compatible = "cavium,octeon-3860-pip-port";
377 reg = <0x0>; /* Port */
378 local-mac-address = [ 00 00 00 00 00 00 ];
379 phy-handle = <&phy41>;
380 };
381 ethernet@1 {
382 compatible = "cavium,octeon-3860-pip-port";
383 reg = <0x1>; /* Port */
384 local-mac-address = [ 00 00 00 00 00 00 ];
385 phy-handle = <&phy42>;
386 };
387 ethernet@2 {
388 compatible = "cavium,octeon-3860-pip-port";
389 reg = <0x2>; /* Port */
390 local-mac-address = [ 00 00 00 00 00 00 ];
391 phy-handle = <&phy43>;
392 };
393 ethernet@3 {
394 compatible = "cavium,octeon-3860-pip-port";
395 reg = <0x3>; /* Port */
396 local-mac-address = [ 00 00 00 00 00 00 ];
397 phy-handle = <&phy44>;
398 };
399 };
400 };
401
402 twsi0: i2c@1180000001000 {
403 #address-cells = <1>;
404 #size-cells = <0>;
405 compatible = "cavium,octeon-3860-twsi";
406 reg = <0x11800 0x00001000 0x0 0x200>;
407 interrupts = <3 32>;
408 clock-frequency = <100000>;
409
410 rtc@68 {
411 compatible = "dallas,ds1337";
412 reg = <0x68>;
413 };
414 tmp@4c {
415 compatible = "ti,tmp421";
416 reg = <0x4c>;
417 };
418 };
419
420 twsi1: i2c@1180000001200 {
421 #address-cells = <1>;
422 #size-cells = <0>;
423 compatible = "cavium,octeon-3860-twsi";
424 reg = <0x11800 0x00001200 0x0 0x200>;
425 interrupts = <3 33>;
426 clock-frequency = <100000>;
427 };
428
429 uart0: serial@1180000000800 {
430 compatible = "cavium,octeon-3860-uart","ns16550";
431 reg = <0x11800 0x00000800 0x0 0x400>;
432 clock-frequency = <0>;
433 current-speed = <115200>;
434 reg-shift = <3>;
435 interrupts = <3 36>;
436 };
437
438 uart1: serial@1180000000c00 {
439 compatible = "cavium,octeon-3860-uart","ns16550";
440 reg = <0x11800 0x00000c00 0x0 0x400>;
441 clock-frequency = <0>;
442 current-speed = <115200>;
443 reg-shift = <3>;
444 interrupts = <3 37>;
445 };
446
447 bootbus: bootbus@1180000000000 {
448 compatible = "cavium,octeon-3860-bootbus";
449 reg = <0x11800 0x00000000 0x0 0x200>;
450 /* The chip select number and offset */
451 #address-cells = <2>;
452 /* The size of the chip select region */
453 #size-cells = <1>;
454 ranges = <0 0 0 0x1f400000 0xc00000>,
455 <1 0 0x10000 0x30000000 0>,
456 <2 0 0x10000 0x40000000 0>,
457 <3 0 0x10000 0x50000000 0>,
458 <4 0 0 0x1d020000 0x10000>,
459 <5 0 0 0x1d040000 0x10000>,
460 <6 0 0 0x1d050000 0x10000>,
461 <7 0 0x10000 0x90000000 0>;
462
463 cavium,cs-config@0 {
464 compatible = "cavium,octeon-3860-bootbus-config";
465 cavium,cs-index = <0>;
466 cavium,t-adr = <10>;
467 cavium,t-ce = <50>;
468 cavium,t-oe = <50>;
469 cavium,t-we = <35>;
470 cavium,t-rd-hld = <25>;
471 cavium,t-wr-hld = <35>;
472 cavium,t-pause = <0>;
473 cavium,t-wait = <300>;
474 cavium,t-page = <25>;
475 cavium,t-rd-dly = <0>;
476
477 cavium,pages = <0>;
478 cavium,bus-width = <8>;
479 };
480 cavium,cs-config@4 {
481 compatible = "cavium,octeon-3860-bootbus-config";
482 cavium,cs-index = <4>;
483 cavium,t-adr = <320>;
484 cavium,t-ce = <320>;
485 cavium,t-oe = <320>;
486 cavium,t-we = <320>;
487 cavium,t-rd-hld = <320>;
488 cavium,t-wr-hld = <320>;
489 cavium,t-pause = <320>;
490 cavium,t-wait = <320>;
491 cavium,t-page = <320>;
492 cavium,t-rd-dly = <0>;
493
494 cavium,pages = <0>;
495 cavium,bus-width = <8>;
496 };
497 cavium,cs-config@5 {
498 compatible = "cavium,octeon-3860-bootbus-config";
499 cavium,cs-index = <5>;
500 cavium,t-adr = <0>;
501 cavium,t-ce = <300>;
502 cavium,t-oe = <125>;
503 cavium,t-we = <150>;
504 cavium,t-rd-hld = <100>;
505 cavium,t-wr-hld = <300>;
506 cavium,t-pause = <0>;
507 cavium,t-wait = <300>;
508 cavium,t-page = <310>;
509 cavium,t-rd-dly = <0>;
510
511 cavium,pages = <0>;
512 cavium,bus-width = <16>;
513 };
514 cavium,cs-config@6 {
515 compatible = "cavium,octeon-3860-bootbus-config";
516 cavium,cs-index = <6>;
517 cavium,t-adr = <0>;
518 cavium,t-ce = <30>;
519 cavium,t-oe = <125>;
520 cavium,t-we = <150>;
521 cavium,t-rd-hld = <100>;
522 cavium,t-wr-hld = <30>;
523 cavium,t-pause = <0>;
524 cavium,t-wait = <30>;
525 cavium,t-page = <310>;
526 cavium,t-rd-dly = <0>;
527
528 cavium,pages = <0>;
529 cavium,wait-mode;
530 cavium,bus-width = <16>;
531 };
532
533 flash0: nor@0,0 {
534 compatible = "cfi-flash";
535 reg = <0 0 0x800000>;
536 #address-cells = <1>;
537 #size-cells = <1>;
538
539 partition@0 {
540 label = "bootloader";
541 reg = <0 0x200000>;
542 read-only;
543 };
544 partition@200000 {
545 label = "kernel";
546 reg = <0x200000 0x200000>;
547 };
548 partition@400000 {
549 label = "cramfs";
550 reg = <0x400000 0x3fe000>;
551 };
552 partition@7fe000 {
553 label = "environment";
554 reg = <0x7fe000 0x2000>;
555 read-only;
556 };
557 };
558
559 led0: led-display@4,0 {
560 compatible = "avago,hdsp-253x";
561 reg = <4 0x20 0x20>, <4 0 0x20>;
562 };
563
564 compact-flash@5,0 {
565 compatible = "cavium,ebt3000-compact-flash";
566 reg = <5 0 0x10000>, <6 0 0x10000>;
567 cavium,bus-width = <16>;
568 cavium,true-ide;
569 cavium,dma-engine-handle = <&dma0>;
570 };
571 };
572
573 dma0: dma-engine@1180000000100 {
574 compatible = "cavium,octeon-5750-bootbus-dma";
575 reg = <0x11800 0x00000100 0x0 0x8>;
576 interrupts = <0 63>;
577 };
578 dma1: dma-engine@1180000000108 {
579 compatible = "cavium,octeon-5750-bootbus-dma";
580 reg = <0x11800 0x00000108 0x0 0x8>;
581 interrupts = <0 63>;
582 };
583
584 uctl: uctl@118006f000000 {
585 compatible = "cavium,octeon-6335-uctl";
586 reg = <0x11800 0x6f000000 0x0 0x100>;
587 ranges; /* Direct mapping */
588 #address-cells = <2>;
589 #size-cells = <2>;
590 /* 12MHz, 24MHz and 48MHz allowed */
591 refclk-frequency = <12000000>;
592 /* Either "crystal" or "external" */
593 refclk-type = "crystal";
594
595 ehci@16f0000000000 {
596 compatible = "cavium,octeon-6335-ehci","usb-ehci";
597 reg = <0x16f00 0x00000000 0x0 0x100>;
598 interrupts = <3 44>;
599 big-endian-regs;
600 };
601 ohci@16f0000000400 {
602 compatible = "cavium,octeon-6335-ohci","usb-ohci";
603 reg = <0x16f00 0x00000400 0x0 0x100>;
604 interrupts = <3 44>;
605 big-endian-regs;
606 };
607 };
608 };
609
610 aliases {
611 mix0 = &mix0;
612 pip = &pip;
613 smi0 = &smi0;
614 smi1 = &smi1;
615 smi2 = &smi2;
616 smi3 = &smi3;
617 twsi0 = &twsi0;
618 twsi1 = &twsi1;
619 uart0 = &uart0;
620 uart1 = &uart1;
621 uctl = &uctl;
622 led0 = &led0;
623 flash0 = &flash0;
624 };
625 };
diff --git a/arch/mips/cavium-octeon/serial.c b/arch/mips/cavium-octeon/serial.c
index 057f0ae88c9..138b2216b4f 100644
--- a/arch/mips/cavium-octeon/serial.c
+++ b/arch/mips/cavium-octeon/serial.c
@@ -43,95 +43,67 @@ void octeon_serial_out(struct uart_port *up, int offset, int value)
43 cvmx_write_csr((uint64_t)(up->membase + (offset << 3)), (u8)value); 43 cvmx_write_csr((uint64_t)(up->membase + (offset << 3)), (u8)value);
44} 44}
45 45
46/* 46static int __devinit octeon_serial_probe(struct platform_device *pdev)
47 * Allocated in .bss, so it is all zeroed.
48 */
49#define OCTEON_MAX_UARTS 3
50static struct plat_serial8250_port octeon_uart8250_data[OCTEON_MAX_UARTS + 1];
51static struct platform_device octeon_uart8250_device = {
52 .name = "serial8250",
53 .id = PLAT8250_DEV_PLATFORM,
54 .dev = {
55 .platform_data = octeon_uart8250_data,
56 },
57};
58
59static void __init octeon_uart_set_common(struct plat_serial8250_port *p)
60{ 47{
61 p->flags = ASYNC_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE; 48 int irq, res;
62 p->type = PORT_OCTEON; 49 struct resource *res_mem;
63 p->iotype = UPIO_MEM; 50 struct uart_port port;
64 p->regshift = 3; /* I/O addresses are every 8 bytes */ 51
52 /* All adaptors have an irq. */
53 irq = platform_get_irq(pdev, 0);
54 if (irq < 0)
55 return irq;
56
57 memset(&port, 0, sizeof(port));
58
59 port.flags = ASYNC_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
60 port.type = PORT_OCTEON;
61 port.iotype = UPIO_MEM;
62 port.regshift = 3;
63 port.dev = &pdev->dev;
64
65 if (octeon_is_simulation()) 65 if (octeon_is_simulation())
66 /* Make simulator output fast*/ 66 /* Make simulator output fast*/
67 p->uartclk = 115200 * 16; 67 port.uartclk = 115200 * 16;
68 else 68 else
69 p->uartclk = octeon_get_io_clock_rate(); 69 port.uartclk = octeon_get_io_clock_rate();
70 p->serial_in = octeon_serial_in;
71 p->serial_out = octeon_serial_out;
72}
73 70
74static int __init octeon_serial_init(void) 71 port.serial_in = octeon_serial_in;
75{ 72 port.serial_out = octeon_serial_out;
76 int enable_uart0; 73 port.irq = irq;
77 int enable_uart1;
78 int enable_uart2;
79 struct plat_serial8250_port *p;
80
81#ifdef CONFIG_CAVIUM_OCTEON_2ND_KERNEL
82 /*
83 * If we are configured to run as the second of two kernels,
84 * disable uart0 and enable uart1. Uart0 is owned by the first
85 * kernel
86 */
87 enable_uart0 = 0;
88 enable_uart1 = 1;
89#else
90 /*
91 * We are configured for the first kernel. We'll enable uart0
92 * if the bootloader told us to use 0, otherwise will enable
93 * uart 1.
94 */
95 enable_uart0 = (octeon_get_boot_uart() == 0);
96 enable_uart1 = (octeon_get_boot_uart() == 1);
97#ifdef CONFIG_KGDB
98 enable_uart1 = 1;
99#endif
100#endif
101
102 /* Right now CN52XX is the only chip with a third uart */
103 enable_uart2 = OCTEON_IS_MODEL(OCTEON_CN52XX);
104
105 p = octeon_uart8250_data;
106 if (enable_uart0) {
107 /* Add a ttyS device for hardware uart 0 */
108 octeon_uart_set_common(p);
109 p->membase = (void *) CVMX_MIO_UARTX_RBR(0);
110 p->mapbase = CVMX_MIO_UARTX_RBR(0) & ((1ull << 49) - 1);
111 p->irq = OCTEON_IRQ_UART0;
112 p++;
113 }
114 74
115 if (enable_uart1) { 75 res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
116 /* Add a ttyS device for hardware uart 1 */ 76 if (res_mem == NULL) {
117 octeon_uart_set_common(p); 77 dev_err(&pdev->dev, "found no memory resource\n");
118 p->membase = (void *) CVMX_MIO_UARTX_RBR(1); 78 return -ENXIO;
119 p->mapbase = CVMX_MIO_UARTX_RBR(1) & ((1ull << 49) - 1);
120 p->irq = OCTEON_IRQ_UART1;
121 p++;
122 }
123 if (enable_uart2) {
124 /* Add a ttyS device for hardware uart 2 */
125 octeon_uart_set_common(p);
126 p->membase = (void *) CVMX_MIO_UART2_RBR;
127 p->mapbase = CVMX_MIO_UART2_RBR & ((1ull << 49) - 1);
128 p->irq = OCTEON_IRQ_UART2;
129 p++;
130 } 79 }
80 port.mapbase = res_mem->start;
81 port.membase = ioremap(res_mem->start, resource_size(res_mem));
131 82
132 BUG_ON(p > &octeon_uart8250_data[OCTEON_MAX_UARTS]); 83 res = serial8250_register_port(&port);
133 84
134 return platform_device_register(&octeon_uart8250_device); 85 return res >= 0 ? 0 : res;
135} 86}
136 87
137device_initcall(octeon_serial_init); 88static struct of_device_id octeon_serial_match[] = {
89 {
90 .compatible = "cavium,octeon-3860-uart",
91 },
92 {},
93};
94MODULE_DEVICE_TABLE(of, octeon_serial_match);
95
96static struct platform_driver octeon_serial_driver = {
97 .probe = octeon_serial_probe,
98 .driver = {
99 .owner = THIS_MODULE,
100 .name = "octeon_serial",
101 .of_match_table = octeon_serial_match,
102 },
103};
104
105static int __init octeon_serial_init(void)
106{
107 return platform_driver_register(&octeon_serial_driver);
108}
109late_initcall(octeon_serial_init);
diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c
index 260dc247c05..919b0fb7bb1 100644
--- a/arch/mips/cavium-octeon/setup.c
+++ b/arch/mips/cavium-octeon/setup.c
@@ -21,6 +21,8 @@
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/serial_core.h> 22#include <linux/serial_core.h>
23#include <linux/serial_8250.h> 23#include <linux/serial_8250.h>
24#include <linux/of_fdt.h>
25#include <linux/libfdt.h>
24 26
25#include <asm/processor.h> 27#include <asm/processor.h>
26#include <asm/reboot.h> 28#include <asm/reboot.h>
@@ -775,3 +777,46 @@ void prom_free_prom_memory(void)
775 } 777 }
776#endif 778#endif
777} 779}
780
781int octeon_prune_device_tree(void);
782
783extern const char __dtb_octeon_3xxx_begin;
784extern const char __dtb_octeon_3xxx_end;
785extern const char __dtb_octeon_68xx_begin;
786extern const char __dtb_octeon_68xx_end;
787void __init device_tree_init(void)
788{
789 int dt_size;
790 struct boot_param_header *fdt;
791 bool do_prune;
792
793 if (octeon_bootinfo->minor_version >= 3 && octeon_bootinfo->fdt_addr) {
794 fdt = phys_to_virt(octeon_bootinfo->fdt_addr);
795 if (fdt_check_header(fdt))
796 panic("Corrupt Device Tree passed to kernel.");
797 dt_size = be32_to_cpu(fdt->totalsize);
798 do_prune = false;
799 } else if (OCTEON_IS_MODEL(OCTEON_CN68XX)) {
800 fdt = (struct boot_param_header *)&__dtb_octeon_68xx_begin;
801 dt_size = &__dtb_octeon_68xx_end - &__dtb_octeon_68xx_begin;
802 do_prune = true;
803 } else {
804 fdt = (struct boot_param_header *)&__dtb_octeon_3xxx_begin;
805 dt_size = &__dtb_octeon_3xxx_end - &__dtb_octeon_3xxx_begin;
806 do_prune = true;
807 }
808
809 /* Copy the default tree from init memory. */
810 initial_boot_params = early_init_dt_alloc_memory_arch(dt_size, 8);
811 if (initial_boot_params == NULL)
812 panic("Could not allocate initial_boot_params\n");
813 memcpy(initial_boot_params, fdt, dt_size);
814
815 if (do_prune) {
816 octeon_prune_device_tree();
817 pr_info("Using internal Device Tree.\n");
818 } else {
819 pr_info("Using passed Device Tree.\n");
820 }
821 unflatten_device_tree();
822}
diff --git a/arch/mips/configs/ls1b_defconfig b/arch/mips/configs/ls1b_defconfig
new file mode 100644
index 00000000000..80cff8bea8e
--- /dev/null
+++ b/arch/mips/configs/ls1b_defconfig
@@ -0,0 +1,109 @@
1CONFIG_MACH_LOONGSON1=y
2CONFIG_PREEMPT=y
3# CONFIG_SECCOMP is not set
4CONFIG_EXPERIMENTAL=y
5# CONFIG_LOCALVERSION_AUTO is not set
6CONFIG_SYSVIPC=y
7CONFIG_BSD_PROCESS_ACCT=y
8CONFIG_BSD_PROCESS_ACCT_V3=y
9CONFIG_HIGH_RES_TIMERS=y
10CONFIG_IKCONFIG=y
11CONFIG_IKCONFIG_PROC=y
12CONFIG_LOG_BUF_SHIFT=16
13CONFIG_NAMESPACES=y
14CONFIG_BLK_DEV_INITRD=y
15CONFIG_RD_BZIP2=y
16CONFIG_RD_LZMA=y
17CONFIG_EXPERT=y
18CONFIG_PERF_EVENTS=y
19# CONFIG_COMPAT_BRK is not set
20CONFIG_MODULES=y
21CONFIG_MODULE_UNLOAD=y
22CONFIG_MODVERSIONS=y
23# CONFIG_LBDAF is not set
24# CONFIG_BLK_DEV_BSG is not set
25# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
26# CONFIG_SUSPEND is not set
27CONFIG_NET=y
28CONFIG_PACKET=y
29CONFIG_UNIX=y
30CONFIG_INET=y
31CONFIG_IP_PNP=y
32CONFIG_IP_PNP_DHCP=y
33CONFIG_SYN_COOKIES=y
34# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
35# CONFIG_INET_XFRM_MODE_TUNNEL is not set
36# CONFIG_INET_XFRM_MODE_BEET is not set
37# CONFIG_INET_DIAG is not set
38# CONFIG_IPV6 is not set
39# CONFIG_WIRELESS is not set
40CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
41CONFIG_DEVTMPFS=y
42CONFIG_DEVTMPFS_MOUNT=y
43# CONFIG_STANDALONE is not set
44CONFIG_BLK_DEV_LOOP=y
45CONFIG_SCSI=m
46# CONFIG_SCSI_PROC_FS is not set
47CONFIG_BLK_DEV_SD=m
48# CONFIG_SCSI_LOWLEVEL is not set
49CONFIG_NETDEVICES=y
50# CONFIG_NET_VENDOR_BROADCOM is not set
51# CONFIG_NET_VENDOR_CHELSIO is not set
52# CONFIG_NET_VENDOR_INTEL is not set
53# CONFIG_NET_VENDOR_MARVELL is not set
54# CONFIG_NET_VENDOR_MICREL is not set
55# CONFIG_NET_VENDOR_NATSEMI is not set
56# CONFIG_NET_VENDOR_SEEQ is not set
57# CONFIG_NET_VENDOR_SMSC is not set
58CONFIG_STMMAC_ETH=y
59CONFIG_STMMAC_DA=y
60# CONFIG_NET_VENDOR_WIZNET is not set
61# CONFIG_WLAN is not set
62CONFIG_INPUT_EVDEV=y
63# CONFIG_INPUT_KEYBOARD is not set
64# CONFIG_INPUT_MOUSE is not set
65# CONFIG_SERIO is not set
66CONFIG_VT_HW_CONSOLE_BINDING=y
67CONFIG_LEGACY_PTY_COUNT=8
68# CONFIG_DEVKMEM is not set
69CONFIG_SERIAL_8250=y
70CONFIG_SERIAL_8250_CONSOLE=y
71# CONFIG_HW_RANDOM is not set
72# CONFIG_HWMON is not set
73# CONFIG_VGA_CONSOLE is not set
74CONFIG_USB_HID=m
75CONFIG_HID_GENERIC=m
76CONFIG_USB=y
77CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
78CONFIG_USB_EHCI_HCD=y
79# CONFIG_USB_EHCI_TT_NEWSCHED is not set
80CONFIG_USB_STORAGE=m
81CONFIG_USB_SERIAL=m
82CONFIG_USB_SERIAL_PL2303=m
83CONFIG_RTC_CLASS=y
84CONFIG_RTC_DRV_LOONGSON1=y
85# CONFIG_IOMMU_SUPPORT is not set
86CONFIG_EXT2_FS=y
87CONFIG_EXT2_FS_XATTR=y
88CONFIG_EXT2_FS_POSIX_ACL=y
89CONFIG_EXT2_FS_SECURITY=y
90CONFIG_EXT3_FS=y
91CONFIG_EXT3_FS_POSIX_ACL=y
92CONFIG_EXT3_FS_SECURITY=y
93# CONFIG_DNOTIFY is not set
94CONFIG_VFAT_FS=y
95CONFIG_PROC_KCORE=y
96CONFIG_TMPFS=y
97CONFIG_TMPFS_POSIX_ACL=y
98# CONFIG_MISC_FILESYSTEMS is not set
99CONFIG_NFS_FS=y
100CONFIG_ROOT_NFS=y
101CONFIG_NLS_CODEPAGE_437=m
102CONFIG_NLS_ISO8859_1=m
103# CONFIG_ENABLE_WARN_DEPRECATED is not set
104# CONFIG_ENABLE_MUST_CHECK is not set
105CONFIG_MAGIC_SYSRQ=y
106# CONFIG_SCHED_DEBUG is not set
107# CONFIG_DEBUG_PREEMPT is not set
108# CONFIG_FTRACE is not set
109# CONFIG_EARLY_PRINTK is not set
diff --git a/arch/mips/configs/nlm_xlr_defconfig b/arch/mips/configs/nlm_xlr_defconfig
index d0b857d98c9..138f698d7c0 100644
--- a/arch/mips/configs/nlm_xlr_defconfig
+++ b/arch/mips/configs/nlm_xlr_defconfig
@@ -367,6 +367,10 @@ CONFIG_SERIAL_8250_RSA=y
367CONFIG_HW_RANDOM=y 367CONFIG_HW_RANDOM=y
368CONFIG_HW_RANDOM_TIMERIOMEM=m 368CONFIG_HW_RANDOM_TIMERIOMEM=m
369CONFIG_RAW_DRIVER=m 369CONFIG_RAW_DRIVER=m
370CONFIG_I2C=y
371CONFIG_I2C_XLR=y
372CONFIG_RTC_CLASS=y
373CONFIG_RTC_DRV_DS1374=y
370# CONFIG_HWMON is not set 374# CONFIG_HWMON is not set
371# CONFIG_VGA_CONSOLE is not set 375# CONFIG_VGA_CONSOLE is not set
372# CONFIG_HID_SUPPORT is not set 376# CONFIG_HID_SUPPORT is not set
diff --git a/arch/mips/dec/prom/memory.c b/arch/mips/dec/prom/memory.c
index e95ff3054ff..8c62316f22f 100644
--- a/arch/mips/dec/prom/memory.c
+++ b/arch/mips/dec/prom/memory.c
@@ -101,7 +101,7 @@ void __init prom_free_prom_memory(void)
101 * the first page reserved for the exception handlers. 101 * the first page reserved for the exception handlers.
102 */ 102 */
103 103
104#if defined(CONFIG_DECLANCE) || defined(CONFIG_DECLANCE_MODULE) 104#if IS_ENABLED(CONFIG_DECLANCE)
105 /* 105 /*
106 * Leave 128 KB reserved for Lance memory for 106 * Leave 128 KB reserved for Lance memory for
107 * IOASIC DECstations. 107 * IOASIC DECstations.
diff --git a/arch/mips/include/asm/clock.h b/arch/mips/include/asm/clock.h
index 83894aa7932..c9456e7a728 100644
--- a/arch/mips/include/asm/clock.h
+++ b/arch/mips/include/asm/clock.h
@@ -50,15 +50,4 @@ void clk_recalc_rate(struct clk *);
50int clk_register(struct clk *); 50int clk_register(struct clk *);
51void clk_unregister(struct clk *); 51void clk_unregister(struct clk *);
52 52
53/* the exported API, in addition to clk_set_rate */
54/**
55 * clk_set_rate_ex - set the clock rate for a clock source, with additional parameter
56 * @clk: clock source
57 * @rate: desired clock rate in Hz
58 * @algo_id: algorithm id to be passed down to ops->set_rate
59 *
60 * Returns success (0) or negative errno.
61 */
62int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id);
63
64#endif /* __ASM_MIPS_CLOCK_H */ 53#endif /* __ASM_MIPS_CLOCK_H */
diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h
index 95e40c1e8ed..f21b7c04e95 100644
--- a/arch/mips/include/asm/cpu.h
+++ b/arch/mips/include/asm/cpu.h
@@ -197,6 +197,7 @@
197#define PRID_REV_VR4181A 0x0070 /* Same as VR4122 */ 197#define PRID_REV_VR4181A 0x0070 /* Same as VR4122 */
198#define PRID_REV_VR4130 0x0080 198#define PRID_REV_VR4130 0x0080
199#define PRID_REV_34K_V1_0_2 0x0022 199#define PRID_REV_34K_V1_0_2 0x0022
200#define PRID_REV_LOONGSON1B 0x0020
200#define PRID_REV_LOONGSON2E 0x0002 201#define PRID_REV_LOONGSON2E 0x0002
201#define PRID_REV_LOONGSON2F 0x0003 202#define PRID_REV_LOONGSON2F 0x0003
202 203
@@ -261,7 +262,7 @@ enum cpu_type_enum {
261 */ 262 */
262 CPU_4KC, CPU_4KEC, CPU_4KSC, CPU_24K, CPU_34K, CPU_1004K, CPU_74K, 263 CPU_4KC, CPU_4KEC, CPU_4KSC, CPU_24K, CPU_34K, CPU_1004K, CPU_74K,
263 CPU_ALCHEMY, CPU_PR4450, CPU_BMIPS32, CPU_BMIPS3300, CPU_BMIPS4350, 264 CPU_ALCHEMY, CPU_PR4450, CPU_BMIPS32, CPU_BMIPS3300, CPU_BMIPS4350,
264 CPU_BMIPS4380, CPU_BMIPS5000, CPU_JZRISC, CPU_M14KC, 265 CPU_BMIPS4380, CPU_BMIPS5000, CPU_JZRISC, CPU_LOONGSON1, CPU_M14KC,
265 266
266 /* 267 /*
267 * MIPS64 class processors 268 * MIPS64 class processors
diff --git a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
index 1caa78ad06d..dde504477fa 100644
--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
+++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
@@ -393,7 +393,8 @@
393#define AR71XX_GPIO_REG_FUNC 0x28 393#define AR71XX_GPIO_REG_FUNC 0x28
394 394
395#define AR71XX_GPIO_COUNT 16 395#define AR71XX_GPIO_COUNT 16
396#define AR724X_GPIO_COUNT 18 396#define AR7240_GPIO_COUNT 18
397#define AR7241_GPIO_COUNT 20
397#define AR913X_GPIO_COUNT 22 398#define AR913X_GPIO_COUNT 22
398#define AR933X_GPIO_COUNT 30 399#define AR933X_GPIO_COUNT 30
399#define AR934X_GPIO_COUNT 23 400#define AR934X_GPIO_COUNT 23
diff --git a/arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h b/arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h
index 4476fa03bf3..6ddae926bf7 100644
--- a/arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h
+++ b/arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h
@@ -42,7 +42,6 @@
42#define cpu_has_mips64r1 0 42#define cpu_has_mips64r1 0
43#define cpu_has_mips64r2 0 43#define cpu_has_mips64r2 0
44 44
45#define cpu_has_dsp 0
46#define cpu_has_mipsmt 0 45#define cpu_has_mipsmt 0
47 46
48#define cpu_has_64bits 0 47#define cpu_has_64bits 0
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h
index 5b8d15bb5fe..e104ddb694a 100644
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h
@@ -9,6 +9,7 @@
9 * compile time if only one CPU support is enabled (idea stolen from 9 * compile time if only one CPU support is enabled (idea stolen from
10 * arm mach-types) 10 * arm mach-types)
11 */ 11 */
12#define BCM6328_CPU_ID 0x6328
12#define BCM6338_CPU_ID 0x6338 13#define BCM6338_CPU_ID 0x6338
13#define BCM6345_CPU_ID 0x6345 14#define BCM6345_CPU_ID 0x6345
14#define BCM6348_CPU_ID 0x6348 15#define BCM6348_CPU_ID 0x6348
@@ -20,6 +21,19 @@ u16 __bcm63xx_get_cpu_id(void);
20u16 bcm63xx_get_cpu_rev(void); 21u16 bcm63xx_get_cpu_rev(void);
21unsigned int bcm63xx_get_cpu_freq(void); 22unsigned int bcm63xx_get_cpu_freq(void);
22 23
24#ifdef CONFIG_BCM63XX_CPU_6328
25# ifdef bcm63xx_get_cpu_id
26# undef bcm63xx_get_cpu_id
27# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
28# define BCMCPU_RUNTIME_DETECT
29# else
30# define bcm63xx_get_cpu_id() BCM6328_CPU_ID
31# endif
32# define BCMCPU_IS_6328() (bcm63xx_get_cpu_id() == BCM6328_CPU_ID)
33#else
34# define BCMCPU_IS_6328() (0)
35#endif
36
23#ifdef CONFIG_BCM63XX_CPU_6338 37#ifdef CONFIG_BCM63XX_CPU_6338
24# ifdef bcm63xx_get_cpu_id 38# ifdef bcm63xx_get_cpu_id
25# undef bcm63xx_get_cpu_id 39# undef bcm63xx_get_cpu_id
@@ -102,13 +116,13 @@ enum bcm63xx_regs_set {
102 RSET_UART1, 116 RSET_UART1,
103 RSET_GPIO, 117 RSET_GPIO,
104 RSET_SPI, 118 RSET_SPI,
105 RSET_SPI2,
106 RSET_UDC0, 119 RSET_UDC0,
107 RSET_OHCI0, 120 RSET_OHCI0,
108 RSET_OHCI_PRIV, 121 RSET_OHCI_PRIV,
109 RSET_USBH_PRIV, 122 RSET_USBH_PRIV,
110 RSET_MPI, 123 RSET_MPI,
111 RSET_PCMCIA, 124 RSET_PCMCIA,
125 RSET_PCIE,
112 RSET_DSL, 126 RSET_DSL,
113 RSET_ENET0, 127 RSET_ENET0,
114 RSET_ENET1, 128 RSET_ENET1,
@@ -130,11 +144,17 @@ enum bcm63xx_regs_set {
130 RSET_PCMDMA, 144 RSET_PCMDMA,
131 RSET_PCMDMAC, 145 RSET_PCMDMAC,
132 RSET_PCMDMAS, 146 RSET_PCMDMAS,
147 RSET_RNG,
148 RSET_MISC
133}; 149};
134 150
135#define RSET_DSL_LMEM_SIZE (64 * 1024 * 4) 151#define RSET_DSL_LMEM_SIZE (64 * 1024 * 4)
136#define RSET_DSL_SIZE 4096 152#define RSET_DSL_SIZE 4096
137#define RSET_WDT_SIZE 12 153#define RSET_WDT_SIZE 12
154#define BCM_6338_RSET_SPI_SIZE 64
155#define BCM_6348_RSET_SPI_SIZE 64
156#define BCM_6358_RSET_SPI_SIZE 1804
157#define BCM_6368_RSET_SPI_SIZE 1804
138#define RSET_ENET_SIZE 2048 158#define RSET_ENET_SIZE 2048
139#define RSET_ENETDMA_SIZE 2048 159#define RSET_ENETDMA_SIZE 2048
140#define RSET_ENETSW_SIZE 65536 160#define RSET_ENETSW_SIZE 65536
@@ -149,8 +169,53 @@ enum bcm63xx_regs_set {
149#define RSET_XTMDMA_SIZE 256 169#define RSET_XTMDMA_SIZE 256
150#define RSET_XTMDMAC_SIZE(chans) (16 * (chans)) 170#define RSET_XTMDMAC_SIZE(chans) (16 * (chans))
151#define RSET_XTMDMAS_SIZE(chans) (16 * (chans)) 171#define RSET_XTMDMAS_SIZE(chans) (16 * (chans))
172#define RSET_RNG_SIZE 20
152 173
153/* 174/*
175 * 6328 register sets base address
176 */
177#define BCM_6328_DSL_LMEM_BASE (0xdeadbeef)
178#define BCM_6328_PERF_BASE (0xb0000000)
179#define BCM_6328_TIMER_BASE (0xb0000040)
180#define BCM_6328_WDT_BASE (0xb000005c)
181#define BCM_6328_UART0_BASE (0xb0000100)
182#define BCM_6328_UART1_BASE (0xb0000120)
183#define BCM_6328_GPIO_BASE (0xb0000080)
184#define BCM_6328_SPI_BASE (0xdeadbeef)
185#define BCM_6328_UDC0_BASE (0xdeadbeef)
186#define BCM_6328_USBDMA_BASE (0xdeadbeef)
187#define BCM_6328_OHCI0_BASE (0xdeadbeef)
188#define BCM_6328_OHCI_PRIV_BASE (0xdeadbeef)
189#define BCM_6328_USBH_PRIV_BASE (0xdeadbeef)
190#define BCM_6328_MPI_BASE (0xdeadbeef)
191#define BCM_6328_PCMCIA_BASE (0xdeadbeef)
192#define BCM_6328_PCIE_BASE (0xb0e40000)
193#define BCM_6328_SDRAM_REGS_BASE (0xdeadbeef)
194#define BCM_6328_DSL_BASE (0xb0001900)
195#define BCM_6328_UBUS_BASE (0xdeadbeef)
196#define BCM_6328_ENET0_BASE (0xdeadbeef)
197#define BCM_6328_ENET1_BASE (0xdeadbeef)
198#define BCM_6328_ENETDMA_BASE (0xb000d800)
199#define BCM_6328_ENETDMAC_BASE (0xb000da00)
200#define BCM_6328_ENETDMAS_BASE (0xb000dc00)
201#define BCM_6328_ENETSW_BASE (0xb0e00000)
202#define BCM_6328_EHCI0_BASE (0x10002500)
203#define BCM_6328_SDRAM_BASE (0xdeadbeef)
204#define BCM_6328_MEMC_BASE (0xdeadbeef)
205#define BCM_6328_DDR_BASE (0xb0003000)
206#define BCM_6328_M2M_BASE (0xdeadbeef)
207#define BCM_6328_ATM_BASE (0xdeadbeef)
208#define BCM_6328_XTM_BASE (0xdeadbeef)
209#define BCM_6328_XTMDMA_BASE (0xb000b800)
210#define BCM_6328_XTMDMAC_BASE (0xdeadbeef)
211#define BCM_6328_XTMDMAS_BASE (0xdeadbeef)
212#define BCM_6328_PCM_BASE (0xb000a800)
213#define BCM_6328_PCMDMA_BASE (0xdeadbeef)
214#define BCM_6328_PCMDMAC_BASE (0xdeadbeef)
215#define BCM_6328_PCMDMAS_BASE (0xdeadbeef)
216#define BCM_6328_RNG_BASE (0xdeadbeef)
217#define BCM_6328_MISC_BASE (0xb0001800)
218/*
154 * 6338 register sets base address 219 * 6338 register sets base address
155 */ 220 */
156#define BCM_6338_DSL_LMEM_BASE (0xfff00000) 221#define BCM_6338_DSL_LMEM_BASE (0xfff00000)
@@ -162,7 +227,6 @@ enum bcm63xx_regs_set {
162#define BCM_6338_UART1_BASE (0xdeadbeef) 227#define BCM_6338_UART1_BASE (0xdeadbeef)
163#define BCM_6338_GPIO_BASE (0xfffe0400) 228#define BCM_6338_GPIO_BASE (0xfffe0400)
164#define BCM_6338_SPI_BASE (0xfffe0c00) 229#define BCM_6338_SPI_BASE (0xfffe0c00)
165#define BCM_6338_SPI2_BASE (0xdeadbeef)
166#define BCM_6338_UDC0_BASE (0xdeadbeef) 230#define BCM_6338_UDC0_BASE (0xdeadbeef)
167#define BCM_6338_USBDMA_BASE (0xfffe2400) 231#define BCM_6338_USBDMA_BASE (0xfffe2400)
168#define BCM_6338_OHCI0_BASE (0xdeadbeef) 232#define BCM_6338_OHCI0_BASE (0xdeadbeef)
@@ -170,6 +234,7 @@ enum bcm63xx_regs_set {
170#define BCM_6338_USBH_PRIV_BASE (0xdeadbeef) 234#define BCM_6338_USBH_PRIV_BASE (0xdeadbeef)
171#define BCM_6338_MPI_BASE (0xfffe3160) 235#define BCM_6338_MPI_BASE (0xfffe3160)
172#define BCM_6338_PCMCIA_BASE (0xdeadbeef) 236#define BCM_6338_PCMCIA_BASE (0xdeadbeef)
237#define BCM_6338_PCIE_BASE (0xdeadbeef)
173#define BCM_6338_SDRAM_REGS_BASE (0xfffe3100) 238#define BCM_6338_SDRAM_REGS_BASE (0xfffe3100)
174#define BCM_6338_DSL_BASE (0xfffe1000) 239#define BCM_6338_DSL_BASE (0xfffe1000)
175#define BCM_6338_UBUS_BASE (0xdeadbeef) 240#define BCM_6338_UBUS_BASE (0xdeadbeef)
@@ -193,6 +258,8 @@ enum bcm63xx_regs_set {
193#define BCM_6338_PCMDMA_BASE (0xdeadbeef) 258#define BCM_6338_PCMDMA_BASE (0xdeadbeef)
194#define BCM_6338_PCMDMAC_BASE (0xdeadbeef) 259#define BCM_6338_PCMDMAC_BASE (0xdeadbeef)
195#define BCM_6338_PCMDMAS_BASE (0xdeadbeef) 260#define BCM_6338_PCMDMAS_BASE (0xdeadbeef)
261#define BCM_6338_RNG_BASE (0xdeadbeef)
262#define BCM_6338_MISC_BASE (0xdeadbeef)
196 263
197/* 264/*
198 * 6345 register sets base address 265 * 6345 register sets base address
@@ -206,7 +273,6 @@ enum bcm63xx_regs_set {
206#define BCM_6345_UART1_BASE (0xdeadbeef) 273#define BCM_6345_UART1_BASE (0xdeadbeef)
207#define BCM_6345_GPIO_BASE (0xfffe0400) 274#define BCM_6345_GPIO_BASE (0xfffe0400)
208#define BCM_6345_SPI_BASE (0xdeadbeef) 275#define BCM_6345_SPI_BASE (0xdeadbeef)
209#define BCM_6345_SPI2_BASE (0xdeadbeef)
210#define BCM_6345_UDC0_BASE (0xdeadbeef) 276#define BCM_6345_UDC0_BASE (0xdeadbeef)
211#define BCM_6345_USBDMA_BASE (0xfffe2800) 277#define BCM_6345_USBDMA_BASE (0xfffe2800)
212#define BCM_6345_ENET0_BASE (0xfffe1800) 278#define BCM_6345_ENET0_BASE (0xfffe1800)
@@ -216,6 +282,7 @@ enum bcm63xx_regs_set {
216#define BCM_6345_ENETSW_BASE (0xdeadbeef) 282#define BCM_6345_ENETSW_BASE (0xdeadbeef)
217#define BCM_6345_PCMCIA_BASE (0xfffe2028) 283#define BCM_6345_PCMCIA_BASE (0xfffe2028)
218#define BCM_6345_MPI_BASE (0xfffe2000) 284#define BCM_6345_MPI_BASE (0xfffe2000)
285#define BCM_6345_PCIE_BASE (0xdeadbeef)
219#define BCM_6345_OHCI0_BASE (0xfffe2100) 286#define BCM_6345_OHCI0_BASE (0xfffe2100)
220#define BCM_6345_OHCI_PRIV_BASE (0xfffe2200) 287#define BCM_6345_OHCI_PRIV_BASE (0xfffe2200)
221#define BCM_6345_USBH_PRIV_BASE (0xdeadbeef) 288#define BCM_6345_USBH_PRIV_BASE (0xdeadbeef)
@@ -237,6 +304,8 @@ enum bcm63xx_regs_set {
237#define BCM_6345_PCMDMA_BASE (0xdeadbeef) 304#define BCM_6345_PCMDMA_BASE (0xdeadbeef)
238#define BCM_6345_PCMDMAC_BASE (0xdeadbeef) 305#define BCM_6345_PCMDMAC_BASE (0xdeadbeef)
239#define BCM_6345_PCMDMAS_BASE (0xdeadbeef) 306#define BCM_6345_PCMDMAS_BASE (0xdeadbeef)
307#define BCM_6345_RNG_BASE (0xdeadbeef)
308#define BCM_6345_MISC_BASE (0xdeadbeef)
240 309
241/* 310/*
242 * 6348 register sets base address 311 * 6348 register sets base address
@@ -249,13 +318,13 @@ enum bcm63xx_regs_set {
249#define BCM_6348_UART1_BASE (0xdeadbeef) 318#define BCM_6348_UART1_BASE (0xdeadbeef)
250#define BCM_6348_GPIO_BASE (0xfffe0400) 319#define BCM_6348_GPIO_BASE (0xfffe0400)
251#define BCM_6348_SPI_BASE (0xfffe0c00) 320#define BCM_6348_SPI_BASE (0xfffe0c00)
252#define BCM_6348_SPI2_BASE (0xdeadbeef)
253#define BCM_6348_UDC0_BASE (0xfffe1000) 321#define BCM_6348_UDC0_BASE (0xfffe1000)
254#define BCM_6348_OHCI0_BASE (0xfffe1b00) 322#define BCM_6348_OHCI0_BASE (0xfffe1b00)
255#define BCM_6348_OHCI_PRIV_BASE (0xfffe1c00) 323#define BCM_6348_OHCI_PRIV_BASE (0xfffe1c00)
256#define BCM_6348_USBH_PRIV_BASE (0xdeadbeef) 324#define BCM_6348_USBH_PRIV_BASE (0xdeadbeef)
257#define BCM_6348_MPI_BASE (0xfffe2000) 325#define BCM_6348_MPI_BASE (0xfffe2000)
258#define BCM_6348_PCMCIA_BASE (0xfffe2054) 326#define BCM_6348_PCMCIA_BASE (0xfffe2054)
327#define BCM_6348_PCIE_BASE (0xdeadbeef)
259#define BCM_6348_SDRAM_REGS_BASE (0xfffe2300) 328#define BCM_6348_SDRAM_REGS_BASE (0xfffe2300)
260#define BCM_6348_M2M_BASE (0xfffe2800) 329#define BCM_6348_M2M_BASE (0xfffe2800)
261#define BCM_6348_DSL_BASE (0xfffe3000) 330#define BCM_6348_DSL_BASE (0xfffe3000)
@@ -278,6 +347,8 @@ enum bcm63xx_regs_set {
278#define BCM_6348_PCMDMA_BASE (0xdeadbeef) 347#define BCM_6348_PCMDMA_BASE (0xdeadbeef)
279#define BCM_6348_PCMDMAC_BASE (0xdeadbeef) 348#define BCM_6348_PCMDMAC_BASE (0xdeadbeef)
280#define BCM_6348_PCMDMAS_BASE (0xdeadbeef) 349#define BCM_6348_PCMDMAS_BASE (0xdeadbeef)
350#define BCM_6348_RNG_BASE (0xdeadbeef)
351#define BCM_6348_MISC_BASE (0xdeadbeef)
281 352
282/* 353/*
283 * 6358 register sets base address 354 * 6358 register sets base address
@@ -289,14 +360,14 @@ enum bcm63xx_regs_set {
289#define BCM_6358_UART0_BASE (0xfffe0100) 360#define BCM_6358_UART0_BASE (0xfffe0100)
290#define BCM_6358_UART1_BASE (0xfffe0120) 361#define BCM_6358_UART1_BASE (0xfffe0120)
291#define BCM_6358_GPIO_BASE (0xfffe0080) 362#define BCM_6358_GPIO_BASE (0xfffe0080)
292#define BCM_6358_SPI_BASE (0xdeadbeef) 363#define BCM_6358_SPI_BASE (0xfffe0800)
293#define BCM_6358_SPI2_BASE (0xfffe0800)
294#define BCM_6358_UDC0_BASE (0xfffe0800) 364#define BCM_6358_UDC0_BASE (0xfffe0800)
295#define BCM_6358_OHCI0_BASE (0xfffe1400) 365#define BCM_6358_OHCI0_BASE (0xfffe1400)
296#define BCM_6358_OHCI_PRIV_BASE (0xdeadbeef) 366#define BCM_6358_OHCI_PRIV_BASE (0xdeadbeef)
297#define BCM_6358_USBH_PRIV_BASE (0xfffe1500) 367#define BCM_6358_USBH_PRIV_BASE (0xfffe1500)
298#define BCM_6358_MPI_BASE (0xfffe1000) 368#define BCM_6358_MPI_BASE (0xfffe1000)
299#define BCM_6358_PCMCIA_BASE (0xfffe1054) 369#define BCM_6358_PCMCIA_BASE (0xfffe1054)
370#define BCM_6358_PCIE_BASE (0xdeadbeef)
300#define BCM_6358_SDRAM_REGS_BASE (0xfffe2300) 371#define BCM_6358_SDRAM_REGS_BASE (0xfffe2300)
301#define BCM_6358_M2M_BASE (0xdeadbeef) 372#define BCM_6358_M2M_BASE (0xdeadbeef)
302#define BCM_6358_DSL_BASE (0xfffe3000) 373#define BCM_6358_DSL_BASE (0xfffe3000)
@@ -319,6 +390,8 @@ enum bcm63xx_regs_set {
319#define BCM_6358_PCMDMA_BASE (0xfffe1800) 390#define BCM_6358_PCMDMA_BASE (0xfffe1800)
320#define BCM_6358_PCMDMAC_BASE (0xfffe1900) 391#define BCM_6358_PCMDMAC_BASE (0xfffe1900)
321#define BCM_6358_PCMDMAS_BASE (0xfffe1a00) 392#define BCM_6358_PCMDMAS_BASE (0xfffe1a00)
393#define BCM_6358_RNG_BASE (0xdeadbeef)
394#define BCM_6358_MISC_BASE (0xdeadbeef)
322 395
323 396
324/* 397/*
@@ -331,14 +404,14 @@ enum bcm63xx_regs_set {
331#define BCM_6368_UART0_BASE (0xb0000100) 404#define BCM_6368_UART0_BASE (0xb0000100)
332#define BCM_6368_UART1_BASE (0xb0000120) 405#define BCM_6368_UART1_BASE (0xb0000120)
333#define BCM_6368_GPIO_BASE (0xb0000080) 406#define BCM_6368_GPIO_BASE (0xb0000080)
334#define BCM_6368_SPI_BASE (0xdeadbeef) 407#define BCM_6368_SPI_BASE (0xb0000800)
335#define BCM_6368_SPI2_BASE (0xb0000800)
336#define BCM_6368_UDC0_BASE (0xdeadbeef) 408#define BCM_6368_UDC0_BASE (0xdeadbeef)
337#define BCM_6368_OHCI0_BASE (0xb0001600) 409#define BCM_6368_OHCI0_BASE (0xb0001600)
338#define BCM_6368_OHCI_PRIV_BASE (0xdeadbeef) 410#define BCM_6368_OHCI_PRIV_BASE (0xdeadbeef)
339#define BCM_6368_USBH_PRIV_BASE (0xb0001700) 411#define BCM_6368_USBH_PRIV_BASE (0xb0001700)
340#define BCM_6368_MPI_BASE (0xb0001000) 412#define BCM_6368_MPI_BASE (0xb0001000)
341#define BCM_6368_PCMCIA_BASE (0xb0001054) 413#define BCM_6368_PCMCIA_BASE (0xb0001054)
414#define BCM_6368_PCIE_BASE (0xdeadbeef)
342#define BCM_6368_SDRAM_REGS_BASE (0xdeadbeef) 415#define BCM_6368_SDRAM_REGS_BASE (0xdeadbeef)
343#define BCM_6368_M2M_BASE (0xdeadbeef) 416#define BCM_6368_M2M_BASE (0xdeadbeef)
344#define BCM_6368_DSL_BASE (0xdeadbeef) 417#define BCM_6368_DSL_BASE (0xdeadbeef)
@@ -361,6 +434,8 @@ enum bcm63xx_regs_set {
361#define BCM_6368_PCMDMA_BASE (0xb0005800) 434#define BCM_6368_PCMDMA_BASE (0xb0005800)
362#define BCM_6368_PCMDMAC_BASE (0xb0005a00) 435#define BCM_6368_PCMDMAC_BASE (0xb0005a00)
363#define BCM_6368_PCMDMAS_BASE (0xb0005c00) 436#define BCM_6368_PCMDMAS_BASE (0xb0005c00)
437#define BCM_6368_RNG_BASE (0xb0004180)
438#define BCM_6368_MISC_BASE (0xdeadbeef)
364 439
365 440
366extern const unsigned long *bcm63xx_regs_base; 441extern const unsigned long *bcm63xx_regs_base;
@@ -379,13 +454,13 @@ extern const unsigned long *bcm63xx_regs_base;
379 __GEN_RSET_BASE(__cpu, UART1) \ 454 __GEN_RSET_BASE(__cpu, UART1) \
380 __GEN_RSET_BASE(__cpu, GPIO) \ 455 __GEN_RSET_BASE(__cpu, GPIO) \
381 __GEN_RSET_BASE(__cpu, SPI) \ 456 __GEN_RSET_BASE(__cpu, SPI) \
382 __GEN_RSET_BASE(__cpu, SPI2) \
383 __GEN_RSET_BASE(__cpu, UDC0) \ 457 __GEN_RSET_BASE(__cpu, UDC0) \
384 __GEN_RSET_BASE(__cpu, OHCI0) \ 458 __GEN_RSET_BASE(__cpu, OHCI0) \
385 __GEN_RSET_BASE(__cpu, OHCI_PRIV) \ 459 __GEN_RSET_BASE(__cpu, OHCI_PRIV) \
386 __GEN_RSET_BASE(__cpu, USBH_PRIV) \ 460 __GEN_RSET_BASE(__cpu, USBH_PRIV) \
387 __GEN_RSET_BASE(__cpu, MPI) \ 461 __GEN_RSET_BASE(__cpu, MPI) \
388 __GEN_RSET_BASE(__cpu, PCMCIA) \ 462 __GEN_RSET_BASE(__cpu, PCMCIA) \
463 __GEN_RSET_BASE(__cpu, PCIE) \
389 __GEN_RSET_BASE(__cpu, DSL) \ 464 __GEN_RSET_BASE(__cpu, DSL) \
390 __GEN_RSET_BASE(__cpu, ENET0) \ 465 __GEN_RSET_BASE(__cpu, ENET0) \
391 __GEN_RSET_BASE(__cpu, ENET1) \ 466 __GEN_RSET_BASE(__cpu, ENET1) \
@@ -407,6 +482,8 @@ extern const unsigned long *bcm63xx_regs_base;
407 __GEN_RSET_BASE(__cpu, PCMDMA) \ 482 __GEN_RSET_BASE(__cpu, PCMDMA) \
408 __GEN_RSET_BASE(__cpu, PCMDMAC) \ 483 __GEN_RSET_BASE(__cpu, PCMDMAC) \
409 __GEN_RSET_BASE(__cpu, PCMDMAS) \ 484 __GEN_RSET_BASE(__cpu, PCMDMAS) \
485 __GEN_RSET_BASE(__cpu, RNG) \
486 __GEN_RSET_BASE(__cpu, MISC) \
410 } 487 }
411 488
412#define __GEN_CPU_REGS_TABLE(__cpu) \ 489#define __GEN_CPU_REGS_TABLE(__cpu) \
@@ -418,13 +495,13 @@ extern const unsigned long *bcm63xx_regs_base;
418 [RSET_UART1] = BCM_## __cpu ##_UART1_BASE, \ 495 [RSET_UART1] = BCM_## __cpu ##_UART1_BASE, \
419 [RSET_GPIO] = BCM_## __cpu ##_GPIO_BASE, \ 496 [RSET_GPIO] = BCM_## __cpu ##_GPIO_BASE, \
420 [RSET_SPI] = BCM_## __cpu ##_SPI_BASE, \ 497 [RSET_SPI] = BCM_## __cpu ##_SPI_BASE, \
421 [RSET_SPI2] = BCM_## __cpu ##_SPI2_BASE, \
422 [RSET_UDC0] = BCM_## __cpu ##_UDC0_BASE, \ 498 [RSET_UDC0] = BCM_## __cpu ##_UDC0_BASE, \
423 [RSET_OHCI0] = BCM_## __cpu ##_OHCI0_BASE, \ 499 [RSET_OHCI0] = BCM_## __cpu ##_OHCI0_BASE, \
424 [RSET_OHCI_PRIV] = BCM_## __cpu ##_OHCI_PRIV_BASE, \ 500 [RSET_OHCI_PRIV] = BCM_## __cpu ##_OHCI_PRIV_BASE, \
425 [RSET_USBH_PRIV] = BCM_## __cpu ##_USBH_PRIV_BASE, \ 501 [RSET_USBH_PRIV] = BCM_## __cpu ##_USBH_PRIV_BASE, \
426 [RSET_MPI] = BCM_## __cpu ##_MPI_BASE, \ 502 [RSET_MPI] = BCM_## __cpu ##_MPI_BASE, \
427 [RSET_PCMCIA] = BCM_## __cpu ##_PCMCIA_BASE, \ 503 [RSET_PCMCIA] = BCM_## __cpu ##_PCMCIA_BASE, \
504 [RSET_PCIE] = BCM_## __cpu ##_PCIE_BASE, \
428 [RSET_DSL] = BCM_## __cpu ##_DSL_BASE, \ 505 [RSET_DSL] = BCM_## __cpu ##_DSL_BASE, \
429 [RSET_ENET0] = BCM_## __cpu ##_ENET0_BASE, \ 506 [RSET_ENET0] = BCM_## __cpu ##_ENET0_BASE, \
430 [RSET_ENET1] = BCM_## __cpu ##_ENET1_BASE, \ 507 [RSET_ENET1] = BCM_## __cpu ##_ENET1_BASE, \
@@ -446,6 +523,8 @@ extern const unsigned long *bcm63xx_regs_base;
446 [RSET_PCMDMA] = BCM_## __cpu ##_PCMDMA_BASE, \ 523 [RSET_PCMDMA] = BCM_## __cpu ##_PCMDMA_BASE, \
447 [RSET_PCMDMAC] = BCM_## __cpu ##_PCMDMAC_BASE, \ 524 [RSET_PCMDMAC] = BCM_## __cpu ##_PCMDMAC_BASE, \
448 [RSET_PCMDMAS] = BCM_## __cpu ##_PCMDMAS_BASE, \ 525 [RSET_PCMDMAS] = BCM_## __cpu ##_PCMDMAS_BASE, \
526 [RSET_RNG] = BCM_## __cpu ##_RNG_BASE, \
527 [RSET_MISC] = BCM_## __cpu ##_MISC_BASE, \
449 528
450 529
451static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set) 530static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set)
@@ -453,6 +532,9 @@ static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set)
453#ifdef BCMCPU_RUNTIME_DETECT 532#ifdef BCMCPU_RUNTIME_DETECT
454 return bcm63xx_regs_base[set]; 533 return bcm63xx_regs_base[set];
455#else 534#else
535#ifdef CONFIG_BCM63XX_CPU_6328
536 __GEN_RSET(6328)
537#endif
456#ifdef CONFIG_BCM63XX_CPU_6338 538#ifdef CONFIG_BCM63XX_CPU_6338
457 __GEN_RSET(6338) 539 __GEN_RSET(6338)
458#endif 540#endif
@@ -478,6 +560,7 @@ static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set)
478 */ 560 */
479enum bcm63xx_irq { 561enum bcm63xx_irq {
480 IRQ_TIMER = 0, 562 IRQ_TIMER = 0,
563 IRQ_SPI,
481 IRQ_UART0, 564 IRQ_UART0,
482 IRQ_UART1, 565 IRQ_UART1,
483 IRQ_DSL, 566 IRQ_DSL,
@@ -506,9 +589,51 @@ enum bcm63xx_irq {
506}; 589};
507 590
508/* 591/*
592 * 6328 irqs
593 */
594#define BCM_6328_HIGH_IRQ_BASE (IRQ_INTERNAL_BASE + 32)
595
596#define BCM_6328_TIMER_IRQ (IRQ_INTERNAL_BASE + 31)
597#define BCM_6328_SPI_IRQ 0
598#define BCM_6328_UART0_IRQ (IRQ_INTERNAL_BASE + 28)
599#define BCM_6328_UART1_IRQ (BCM_6328_HIGH_IRQ_BASE + 7)
600#define BCM_6328_DSL_IRQ (IRQ_INTERNAL_BASE + 4)
601#define BCM_6328_UDC0_IRQ 0
602#define BCM_6328_ENET0_IRQ 0
603#define BCM_6328_ENET1_IRQ 0
604#define BCM_6328_ENET_PHY_IRQ (IRQ_INTERNAL_BASE + 12)
605#define BCM_6328_OHCI0_IRQ (IRQ_INTERNAL_BASE + 9)
606#define BCM_6328_EHCI0_IRQ (IRQ_INTERNAL_BASE + 10)
607#define BCM_6328_PCMCIA_IRQ 0
608#define BCM_6328_ENET0_RXDMA_IRQ 0
609#define BCM_6328_ENET0_TXDMA_IRQ 0
610#define BCM_6328_ENET1_RXDMA_IRQ 0
611#define BCM_6328_ENET1_TXDMA_IRQ 0
612#define BCM_6328_PCI_IRQ (IRQ_INTERNAL_BASE + 23)
613#define BCM_6328_ATM_IRQ 0
614#define BCM_6328_ENETSW_RXDMA0_IRQ (BCM_6328_HIGH_IRQ_BASE + 0)
615#define BCM_6328_ENETSW_RXDMA1_IRQ (BCM_6328_HIGH_IRQ_BASE + 1)
616#define BCM_6328_ENETSW_RXDMA2_IRQ (BCM_6328_HIGH_IRQ_BASE + 2)
617#define BCM_6328_ENETSW_RXDMA3_IRQ (BCM_6328_HIGH_IRQ_BASE + 3)
618#define BCM_6328_ENETSW_TXDMA0_IRQ (BCM_6328_HIGH_IRQ_BASE + 4)
619#define BCM_6328_ENETSW_TXDMA1_IRQ (BCM_6328_HIGH_IRQ_BASE + 5)
620#define BCM_6328_ENETSW_TXDMA2_IRQ (BCM_6328_HIGH_IRQ_BASE + 6)
621#define BCM_6328_ENETSW_TXDMA3_IRQ (BCM_6328_HIGH_IRQ_BASE + 7)
622#define BCM_6328_XTM_IRQ (BCM_6328_HIGH_IRQ_BASE + 31)
623#define BCM_6328_XTM_DMA0_IRQ (BCM_6328_HIGH_IRQ_BASE + 11)
624
625#define BCM_6328_PCM_DMA0_IRQ (IRQ_INTERNAL_BASE + 2)
626#define BCM_6328_PCM_DMA1_IRQ (IRQ_INTERNAL_BASE + 3)
627#define BCM_6328_EXT_IRQ0 (IRQ_INTERNAL_BASE + 24)
628#define BCM_6328_EXT_IRQ1 (IRQ_INTERNAL_BASE + 25)
629#define BCM_6328_EXT_IRQ2 (IRQ_INTERNAL_BASE + 26)
630#define BCM_6328_EXT_IRQ3 (IRQ_INTERNAL_BASE + 27)
631
632/*
509 * 6338 irqs 633 * 6338 irqs
510 */ 634 */
511#define BCM_6338_TIMER_IRQ (IRQ_INTERNAL_BASE + 0) 635#define BCM_6338_TIMER_IRQ (IRQ_INTERNAL_BASE + 0)
636#define BCM_6338_SPI_IRQ (IRQ_INTERNAL_BASE + 1)
512#define BCM_6338_UART0_IRQ (IRQ_INTERNAL_BASE + 2) 637#define BCM_6338_UART0_IRQ (IRQ_INTERNAL_BASE + 2)
513#define BCM_6338_UART1_IRQ 0 638#define BCM_6338_UART1_IRQ 0
514#define BCM_6338_DSL_IRQ (IRQ_INTERNAL_BASE + 5) 639#define BCM_6338_DSL_IRQ (IRQ_INTERNAL_BASE + 5)
@@ -539,6 +664,7 @@ enum bcm63xx_irq {
539 * 6345 irqs 664 * 6345 irqs
540 */ 665 */
541#define BCM_6345_TIMER_IRQ (IRQ_INTERNAL_BASE + 0) 666#define BCM_6345_TIMER_IRQ (IRQ_INTERNAL_BASE + 0)
667#define BCM_6345_SPI_IRQ 0
542#define BCM_6345_UART0_IRQ (IRQ_INTERNAL_BASE + 2) 668#define BCM_6345_UART0_IRQ (IRQ_INTERNAL_BASE + 2)
543#define BCM_6345_UART1_IRQ 0 669#define BCM_6345_UART1_IRQ 0
544#define BCM_6345_DSL_IRQ (IRQ_INTERNAL_BASE + 3) 670#define BCM_6345_DSL_IRQ (IRQ_INTERNAL_BASE + 3)
@@ -569,6 +695,7 @@ enum bcm63xx_irq {
569 * 6348 irqs 695 * 6348 irqs
570 */ 696 */
571#define BCM_6348_TIMER_IRQ (IRQ_INTERNAL_BASE + 0) 697#define BCM_6348_TIMER_IRQ (IRQ_INTERNAL_BASE + 0)
698#define BCM_6348_SPI_IRQ (IRQ_INTERNAL_BASE + 1)
572#define BCM_6348_UART0_IRQ (IRQ_INTERNAL_BASE + 2) 699#define BCM_6348_UART0_IRQ (IRQ_INTERNAL_BASE + 2)
573#define BCM_6348_UART1_IRQ 0 700#define BCM_6348_UART1_IRQ 0
574#define BCM_6348_DSL_IRQ (IRQ_INTERNAL_BASE + 4) 701#define BCM_6348_DSL_IRQ (IRQ_INTERNAL_BASE + 4)
@@ -599,6 +726,7 @@ enum bcm63xx_irq {
599 * 6358 irqs 726 * 6358 irqs
600 */ 727 */
601#define BCM_6358_TIMER_IRQ (IRQ_INTERNAL_BASE + 0) 728#define BCM_6358_TIMER_IRQ (IRQ_INTERNAL_BASE + 0)
729#define BCM_6358_SPI_IRQ (IRQ_INTERNAL_BASE + 1)
602#define BCM_6358_UART0_IRQ (IRQ_INTERNAL_BASE + 2) 730#define BCM_6358_UART0_IRQ (IRQ_INTERNAL_BASE + 2)
603#define BCM_6358_UART1_IRQ (IRQ_INTERNAL_BASE + 3) 731#define BCM_6358_UART1_IRQ (IRQ_INTERNAL_BASE + 3)
604#define BCM_6358_DSL_IRQ (IRQ_INTERNAL_BASE + 29) 732#define BCM_6358_DSL_IRQ (IRQ_INTERNAL_BASE + 29)
@@ -638,6 +766,7 @@ enum bcm63xx_irq {
638#define BCM_6368_HIGH_IRQ_BASE (IRQ_INTERNAL_BASE + 32) 766#define BCM_6368_HIGH_IRQ_BASE (IRQ_INTERNAL_BASE + 32)
639 767
640#define BCM_6368_TIMER_IRQ (IRQ_INTERNAL_BASE + 0) 768#define BCM_6368_TIMER_IRQ (IRQ_INTERNAL_BASE + 0)
769#define BCM_6368_SPI_IRQ (IRQ_INTERNAL_BASE + 1)
641#define BCM_6368_UART0_IRQ (IRQ_INTERNAL_BASE + 2) 770#define BCM_6368_UART0_IRQ (IRQ_INTERNAL_BASE + 2)
642#define BCM_6368_UART1_IRQ (IRQ_INTERNAL_BASE + 3) 771#define BCM_6368_UART1_IRQ (IRQ_INTERNAL_BASE + 3)
643#define BCM_6368_DSL_IRQ (IRQ_INTERNAL_BASE + 4) 772#define BCM_6368_DSL_IRQ (IRQ_INTERNAL_BASE + 4)
@@ -677,6 +806,7 @@ extern const int *bcm63xx_irqs;
677 806
678#define __GEN_CPU_IRQ_TABLE(__cpu) \ 807#define __GEN_CPU_IRQ_TABLE(__cpu) \
679 [IRQ_TIMER] = BCM_## __cpu ##_TIMER_IRQ, \ 808 [IRQ_TIMER] = BCM_## __cpu ##_TIMER_IRQ, \
809 [IRQ_SPI] = BCM_## __cpu ##_SPI_IRQ, \
680 [IRQ_UART0] = BCM_## __cpu ##_UART0_IRQ, \ 810 [IRQ_UART0] = BCM_## __cpu ##_UART0_IRQ, \
681 [IRQ_UART1] = BCM_## __cpu ##_UART1_IRQ, \ 811 [IRQ_UART1] = BCM_## __cpu ##_UART1_IRQ, \
682 [IRQ_DSL] = BCM_## __cpu ##_DSL_IRQ, \ 812 [IRQ_DSL] = BCM_## __cpu ##_DSL_IRQ, \
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
new file mode 100644
index 00000000000..354b8481ec4
--- /dev/null
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
@@ -0,0 +1,12 @@
1#ifndef __BCM63XX_FLASH_H
2#define __BCM63XX_FLASH_H
3
4enum {
5 BCM63XX_FLASH_TYPE_PARALLEL,
6 BCM63XX_FLASH_TYPE_SERIAL,
7 BCM63XX_FLASH_TYPE_NAND,
8};
9
10int __init bcm63xx_flash_register(void);
11
12#endif /* __BCM63XX_FLASH_H */
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h
new file mode 100644
index 00000000000..c9bae136260
--- /dev/null
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h
@@ -0,0 +1,91 @@
1#ifndef BCM63XX_DEV_SPI_H
2#define BCM63XX_DEV_SPI_H
3
4#include <linux/types.h>
5#include <bcm63xx_io.h>
6#include <bcm63xx_regs.h>
7
8int __init bcm63xx_spi_register(void);
9
10struct bcm63xx_spi_pdata {
11 unsigned int fifo_size;
12 unsigned int msg_type_shift;
13 unsigned int msg_ctl_width;
14 int bus_num;
15 int num_chipselect;
16 u32 speed_hz;
17};
18
19enum bcm63xx_regs_spi {
20 SPI_CMD,
21 SPI_INT_STATUS,
22 SPI_INT_MASK_ST,
23 SPI_INT_MASK,
24 SPI_ST,
25 SPI_CLK_CFG,
26 SPI_FILL_BYTE,
27 SPI_MSG_TAIL,
28 SPI_RX_TAIL,
29 SPI_MSG_CTL,
30 SPI_MSG_DATA,
31 SPI_RX_DATA,
32};
33
34#define __GEN_SPI_RSET_BASE(__cpu, __rset) \
35 case SPI_## __rset: \
36 return SPI_## __cpu ##_## __rset;
37
38#define __GEN_SPI_RSET(__cpu) \
39 switch (reg) { \
40 __GEN_SPI_RSET_BASE(__cpu, CMD) \
41 __GEN_SPI_RSET_BASE(__cpu, INT_STATUS) \
42 __GEN_SPI_RSET_BASE(__cpu, INT_MASK_ST) \
43 __GEN_SPI_RSET_BASE(__cpu, INT_MASK) \
44 __GEN_SPI_RSET_BASE(__cpu, ST) \
45 __GEN_SPI_RSET_BASE(__cpu, CLK_CFG) \
46 __GEN_SPI_RSET_BASE(__cpu, FILL_BYTE) \
47 __GEN_SPI_RSET_BASE(__cpu, MSG_TAIL) \
48 __GEN_SPI_RSET_BASE(__cpu, RX_TAIL) \
49 __GEN_SPI_RSET_BASE(__cpu, MSG_CTL) \
50 __GEN_SPI_RSET_BASE(__cpu, MSG_DATA) \
51 __GEN_SPI_RSET_BASE(__cpu, RX_DATA) \
52 }
53
54#define __GEN_SPI_REGS_TABLE(__cpu) \
55 [SPI_CMD] = SPI_## __cpu ##_CMD, \
56 [SPI_INT_STATUS] = SPI_## __cpu ##_INT_STATUS, \
57 [SPI_INT_MASK_ST] = SPI_## __cpu ##_INT_MASK_ST, \
58 [SPI_INT_MASK] = SPI_## __cpu ##_INT_MASK, \
59 [SPI_ST] = SPI_## __cpu ##_ST, \
60 [SPI_CLK_CFG] = SPI_## __cpu ##_CLK_CFG, \
61 [SPI_FILL_BYTE] = SPI_## __cpu ##_FILL_BYTE, \
62 [SPI_MSG_TAIL] = SPI_## __cpu ##_MSG_TAIL, \
63 [SPI_RX_TAIL] = SPI_## __cpu ##_RX_TAIL, \
64 [SPI_MSG_CTL] = SPI_## __cpu ##_MSG_CTL, \
65 [SPI_MSG_DATA] = SPI_## __cpu ##_MSG_DATA, \
66 [SPI_RX_DATA] = SPI_## __cpu ##_RX_DATA,
67
68static inline unsigned long bcm63xx_spireg(enum bcm63xx_regs_spi reg)
69{
70#ifdef BCMCPU_RUNTIME_DETECT
71 extern const unsigned long *bcm63xx_regs_spi;
72
73 return bcm63xx_regs_spi[reg];
74#else
75#ifdef CONFIG_BCM63XX_CPU_6338
76 __GEN_SPI_RSET(6338)
77#endif
78#ifdef CONFIG_BCM63XX_CPU_6348
79 __GEN_SPI_RSET(6348)
80#endif
81#ifdef CONFIG_BCM63XX_CPU_6358
82 __GEN_SPI_RSET(6358)
83#endif
84#ifdef CONFIG_BCM63XX_CPU_6368
85 __GEN_SPI_RSET(6368)
86#endif
87#endif
88 return 0;
89}
90
91#endif /* BCM63XX_DEV_SPI_H */
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
index 1d7dd96aa46..0a9891f7580 100644
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
@@ -9,6 +9,8 @@ int __init bcm63xx_gpio_init(void);
9static inline unsigned long bcm63xx_gpio_count(void) 9static inline unsigned long bcm63xx_gpio_count(void)
10{ 10{
11 switch (bcm63xx_get_cpu_id()) { 11 switch (bcm63xx_get_cpu_id()) {
12 case BCM6328_CPU_ID:
13 return 32;
12 case BCM6358_CPU_ID: 14 case BCM6358_CPU_ID:
13 return 40; 15 return 40;
14 case BCM6338_CPU_ID: 16 case BCM6338_CPU_ID:
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h
index 72477a6441d..9203d90e610 100644
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h
@@ -40,6 +40,10 @@
40#define BCM_CB_MEM_END_PA (BCM_CB_MEM_BASE_PA + \ 40#define BCM_CB_MEM_END_PA (BCM_CB_MEM_BASE_PA + \
41 BCM_CB_MEM_SIZE - 1) 41 BCM_CB_MEM_SIZE - 1)
42 42
43#define BCM_PCIE_MEM_BASE_PA 0x10f00000
44#define BCM_PCIE_MEM_SIZE (16 * 1024 * 1024)
45#define BCM_PCIE_MEM_END_PA (BCM_PCIE_MEM_BASE_PA + \
46 BCM_PCIE_MEM_SIZE - 1)
43 47
44/* 48/*
45 * Internal registers are accessed through KSEG3 49 * Internal registers are accessed through KSEG3
@@ -85,11 +89,15 @@
85#define bcm_mpi_writel(v, o) bcm_rset_writel(RSET_MPI, (v), (o)) 89#define bcm_mpi_writel(v, o) bcm_rset_writel(RSET_MPI, (v), (o))
86#define bcm_pcmcia_readl(o) bcm_rset_readl(RSET_PCMCIA, (o)) 90#define bcm_pcmcia_readl(o) bcm_rset_readl(RSET_PCMCIA, (o))
87#define bcm_pcmcia_writel(v, o) bcm_rset_writel(RSET_PCMCIA, (v), (o)) 91#define bcm_pcmcia_writel(v, o) bcm_rset_writel(RSET_PCMCIA, (v), (o))
92#define bcm_pcie_readl(o) bcm_rset_readl(RSET_PCIE, (o))
93#define bcm_pcie_writel(v, o) bcm_rset_writel(RSET_PCIE, (v), (o))
88#define bcm_sdram_readl(o) bcm_rset_readl(RSET_SDRAM, (o)) 94#define bcm_sdram_readl(o) bcm_rset_readl(RSET_SDRAM, (o))
89#define bcm_sdram_writel(v, o) bcm_rset_writel(RSET_SDRAM, (v), (o)) 95#define bcm_sdram_writel(v, o) bcm_rset_writel(RSET_SDRAM, (v), (o))
90#define bcm_memc_readl(o) bcm_rset_readl(RSET_MEMC, (o)) 96#define bcm_memc_readl(o) bcm_rset_readl(RSET_MEMC, (o))
91#define bcm_memc_writel(v, o) bcm_rset_writel(RSET_MEMC, (v), (o)) 97#define bcm_memc_writel(v, o) bcm_rset_writel(RSET_MEMC, (v), (o))
92#define bcm_ddr_readl(o) bcm_rset_readl(RSET_DDR, (o)) 98#define bcm_ddr_readl(o) bcm_rset_readl(RSET_DDR, (o))
93#define bcm_ddr_writel(v, o) bcm_rset_writel(RSET_DDR, (v), (o)) 99#define bcm_ddr_writel(v, o) bcm_rset_writel(RSET_DDR, (v), (o))
100#define bcm_misc_readl(o) bcm_rset_readl(RSET_MISC, (o))
101#define bcm_misc_writel(v, o) bcm_rset_writel(RSET_MISC, (v), (o))
94 102
95#endif /* ! BCM63XX_IO_H_ */ 103#endif /* ! BCM63XX_IO_H_ */
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
index fdcd78ca1b0..61f2a2a5099 100644
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
@@ -15,6 +15,30 @@
15/* Clock Control register */ 15/* Clock Control register */
16#define PERF_CKCTL_REG 0x4 16#define PERF_CKCTL_REG 0x4
17 17
18#define CKCTL_6328_PHYMIPS_EN (1 << 0)
19#define CKCTL_6328_ADSL_QPROC_EN (1 << 1)
20#define CKCTL_6328_ADSL_AFE_EN (1 << 2)
21#define CKCTL_6328_ADSL_EN (1 << 3)
22#define CKCTL_6328_MIPS_EN (1 << 4)
23#define CKCTL_6328_SAR_EN (1 << 5)
24#define CKCTL_6328_PCM_EN (1 << 6)
25#define CKCTL_6328_USBD_EN (1 << 7)
26#define CKCTL_6328_USBH_EN (1 << 8)
27#define CKCTL_6328_HSSPI_EN (1 << 9)
28#define CKCTL_6328_PCIE_EN (1 << 10)
29#define CKCTL_6328_ROBOSW_EN (1 << 11)
30
31#define CKCTL_6328_ALL_SAFE_EN (CKCTL_6328_PHYMIPS_EN | \
32 CKCTL_6328_ADSL_QPROC_EN | \
33 CKCTL_6328_ADSL_AFE_EN | \
34 CKCTL_6328_ADSL_EN | \
35 CKCTL_6328_SAR_EN | \
36 CKCTL_6328_PCM_EN | \
37 CKCTL_6328_USBD_EN | \
38 CKCTL_6328_USBH_EN | \
39 CKCTL_6328_ROBOSW_EN | \
40 CKCTL_6328_PCIE_EN)
41
18#define CKCTL_6338_ADSLPHY_EN (1 << 0) 42#define CKCTL_6338_ADSLPHY_EN (1 << 0)
19#define CKCTL_6338_MPI_EN (1 << 1) 43#define CKCTL_6338_MPI_EN (1 << 1)
20#define CKCTL_6338_DRAM_EN (1 << 2) 44#define CKCTL_6338_DRAM_EN (1 << 2)
@@ -90,35 +114,36 @@
90#define CKCTL_6368_PHYMIPS_EN (1 << 6) 114#define CKCTL_6368_PHYMIPS_EN (1 << 6)
91#define CKCTL_6368_SWPKT_USB_EN (1 << 7) 115#define CKCTL_6368_SWPKT_USB_EN (1 << 7)
92#define CKCTL_6368_SWPKT_SAR_EN (1 << 8) 116#define CKCTL_6368_SWPKT_SAR_EN (1 << 8)
93#define CKCTL_6368_SPI_CLK_EN (1 << 9) 117#define CKCTL_6368_SPI_EN (1 << 9)
94#define CKCTL_6368_USBD_CLK_EN (1 << 10) 118#define CKCTL_6368_USBD_EN (1 << 10)
95#define CKCTL_6368_SAR_CLK_EN (1 << 11) 119#define CKCTL_6368_SAR_EN (1 << 11)
96#define CKCTL_6368_ROBOSW_CLK_EN (1 << 12) 120#define CKCTL_6368_ROBOSW_EN (1 << 12)
97#define CKCTL_6368_UTOPIA_CLK_EN (1 << 13) 121#define CKCTL_6368_UTOPIA_EN (1 << 13)
98#define CKCTL_6368_PCM_CLK_EN (1 << 14) 122#define CKCTL_6368_PCM_EN (1 << 14)
99#define CKCTL_6368_USBH_CLK_EN (1 << 15) 123#define CKCTL_6368_USBH_EN (1 << 15)
100#define CKCTL_6368_DISABLE_GLESS_EN (1 << 16) 124#define CKCTL_6368_DISABLE_GLESS_EN (1 << 16)
101#define CKCTL_6368_NAND_CLK_EN (1 << 17) 125#define CKCTL_6368_NAND_EN (1 << 17)
102#define CKCTL_6368_IPSEC_CLK_EN (1 << 18) 126#define CKCTL_6368_IPSEC_EN (1 << 18)
103 127
104#define CKCTL_6368_ALL_SAFE_EN (CKCTL_6368_SWPKT_USB_EN | \ 128#define CKCTL_6368_ALL_SAFE_EN (CKCTL_6368_SWPKT_USB_EN | \
105 CKCTL_6368_SWPKT_SAR_EN | \ 129 CKCTL_6368_SWPKT_SAR_EN | \
106 CKCTL_6368_SPI_CLK_EN | \ 130 CKCTL_6368_SPI_EN | \
107 CKCTL_6368_USBD_CLK_EN | \ 131 CKCTL_6368_USBD_EN | \
108 CKCTL_6368_SAR_CLK_EN | \ 132 CKCTL_6368_SAR_EN | \
109 CKCTL_6368_ROBOSW_CLK_EN | \ 133 CKCTL_6368_ROBOSW_EN | \
110 CKCTL_6368_UTOPIA_CLK_EN | \ 134 CKCTL_6368_UTOPIA_EN | \
111 CKCTL_6368_PCM_CLK_EN | \ 135 CKCTL_6368_PCM_EN | \
112 CKCTL_6368_USBH_CLK_EN | \ 136 CKCTL_6368_USBH_EN | \
113 CKCTL_6368_DISABLE_GLESS_EN | \ 137 CKCTL_6368_DISABLE_GLESS_EN | \
114 CKCTL_6368_NAND_CLK_EN | \ 138 CKCTL_6368_NAND_EN | \
115 CKCTL_6368_IPSEC_CLK_EN) 139 CKCTL_6368_IPSEC_EN)
116 140
117/* System PLL Control register */ 141/* System PLL Control register */
118#define PERF_SYS_PLL_CTL_REG 0x8 142#define PERF_SYS_PLL_CTL_REG 0x8
119#define SYS_PLL_SOFT_RESET 0x1 143#define SYS_PLL_SOFT_RESET 0x1
120 144
121/* Interrupt Mask register */ 145/* Interrupt Mask register */
146#define PERF_IRQMASK_6328_REG 0x20
122#define PERF_IRQMASK_6338_REG 0xc 147#define PERF_IRQMASK_6338_REG 0xc
123#define PERF_IRQMASK_6345_REG 0xc 148#define PERF_IRQMASK_6345_REG 0xc
124#define PERF_IRQMASK_6348_REG 0xc 149#define PERF_IRQMASK_6348_REG 0xc
@@ -126,6 +151,7 @@
126#define PERF_IRQMASK_6368_REG 0x20 151#define PERF_IRQMASK_6368_REG 0x20
127 152
128/* Interrupt Status register */ 153/* Interrupt Status register */
154#define PERF_IRQSTAT_6328_REG 0x28
129#define PERF_IRQSTAT_6338_REG 0x10 155#define PERF_IRQSTAT_6338_REG 0x10
130#define PERF_IRQSTAT_6345_REG 0x10 156#define PERF_IRQSTAT_6345_REG 0x10
131#define PERF_IRQSTAT_6348_REG 0x10 157#define PERF_IRQSTAT_6348_REG 0x10
@@ -133,6 +159,7 @@
133#define PERF_IRQSTAT_6368_REG 0x28 159#define PERF_IRQSTAT_6368_REG 0x28
134 160
135/* External Interrupt Configuration register */ 161/* External Interrupt Configuration register */
162#define PERF_EXTIRQ_CFG_REG_6328 0x18
136#define PERF_EXTIRQ_CFG_REG_6338 0x14 163#define PERF_EXTIRQ_CFG_REG_6338 0x14
137#define PERF_EXTIRQ_CFG_REG_6348 0x14 164#define PERF_EXTIRQ_CFG_REG_6348 0x14
138#define PERF_EXTIRQ_CFG_REG_6358 0x14 165#define PERF_EXTIRQ_CFG_REG_6358 0x14
@@ -162,8 +189,21 @@
162 189
163/* Soft Reset register */ 190/* Soft Reset register */
164#define PERF_SOFTRESET_REG 0x28 191#define PERF_SOFTRESET_REG 0x28
192#define PERF_SOFTRESET_6328_REG 0x10
165#define PERF_SOFTRESET_6368_REG 0x10 193#define PERF_SOFTRESET_6368_REG 0x10
166 194
195#define SOFTRESET_6328_SPI_MASK (1 << 0)
196#define SOFTRESET_6328_EPHY_MASK (1 << 1)
197#define SOFTRESET_6328_SAR_MASK (1 << 2)
198#define SOFTRESET_6328_ENETSW_MASK (1 << 3)
199#define SOFTRESET_6328_USBS_MASK (1 << 4)
200#define SOFTRESET_6328_USBH_MASK (1 << 5)
201#define SOFTRESET_6328_PCM_MASK (1 << 6)
202#define SOFTRESET_6328_PCIE_CORE_MASK (1 << 7)
203#define SOFTRESET_6328_PCIE_MASK (1 << 8)
204#define SOFTRESET_6328_PCIE_EXT_MASK (1 << 9)
205#define SOFTRESET_6328_PCIE_HARD_MASK (1 << 10)
206
167#define SOFTRESET_6338_SPI_MASK (1 << 0) 207#define SOFTRESET_6338_SPI_MASK (1 << 0)
168#define SOFTRESET_6338_ENET_MASK (1 << 2) 208#define SOFTRESET_6338_ENET_MASK (1 << 2)
169#define SOFTRESET_6338_USBH_MASK (1 << 3) 209#define SOFTRESET_6338_USBH_MASK (1 << 3)
@@ -307,6 +347,8 @@
307/* Watchdog reset length register */ 347/* Watchdog reset length register */
308#define WDT_RSTLEN_REG 0x8 348#define WDT_RSTLEN_REG 0x8
309 349
350/* Watchdog soft reset register (BCM6328 only) */
351#define WDT_SOFTRESET_REG 0xc
310 352
311/************************************************************************* 353/*************************************************************************
312 * _REG relative to RSET_UARTx 354 * _REG relative to RSET_UARTx
@@ -507,6 +549,15 @@
507#define GPIO_BASEMODE_6368_MASK 0x7 549#define GPIO_BASEMODE_6368_MASK 0x7
508/* those bits must be kept as read in gpio basemode register*/ 550/* those bits must be kept as read in gpio basemode register*/
509 551
552#define GPIO_STRAPBUS_REG 0x40
553#define STRAPBUS_6358_BOOT_SEL_PARALLEL (1 << 1)
554#define STRAPBUS_6358_BOOT_SEL_SERIAL (0 << 1)
555#define STRAPBUS_6368_BOOT_SEL_MASK 0x3
556#define STRAPBUS_6368_BOOT_SEL_NAND 0
557#define STRAPBUS_6368_BOOT_SEL_SERIAL 1
558#define STRAPBUS_6368_BOOT_SEL_PARALLEL 3
559
560
510/************************************************************************* 561/*************************************************************************
511 * _REG relative to RSET_ENET 562 * _REG relative to RSET_ENET
512 *************************************************************************/ 563 *************************************************************************/
@@ -924,6 +975,8 @@
924 * _REG relative to RSET_DDR 975 * _REG relative to RSET_DDR
925 *************************************************************************/ 976 *************************************************************************/
926 977
978#define DDR_CSEND_REG 0x8
979
927#define DDR_DMIPSPLLCFG_REG 0x18 980#define DDR_DMIPSPLLCFG_REG 0x18
928#define DMIPSPLLCFG_M1_SHIFT 0 981#define DMIPSPLLCFG_M1_SHIFT 0
929#define DMIPSPLLCFG_M1_MASK (0xff << DMIPSPLLCFG_M1_SHIFT) 982#define DMIPSPLLCFG_M1_MASK (0xff << DMIPSPLLCFG_M1_SHIFT)
@@ -973,4 +1026,208 @@
973#define M2M_SRCID_REG(x) ((x) * 0x40 + 0x14) 1026#define M2M_SRCID_REG(x) ((x) * 0x40 + 0x14)
974#define M2M_DSTID_REG(x) ((x) * 0x40 + 0x18) 1027#define M2M_DSTID_REG(x) ((x) * 0x40 + 0x18)
975 1028
1029/*************************************************************************
1030 * _REG relative to RSET_RNG
1031 *************************************************************************/
1032
1033#define RNG_CTRL 0x00
1034#define RNG_EN (1 << 0)
1035
1036#define RNG_STAT 0x04
1037#define RNG_AVAIL_MASK (0xff000000)
1038
1039#define RNG_DATA 0x08
1040#define RNG_THRES 0x0c
1041#define RNG_MASK 0x10
1042
1043/*************************************************************************
1044 * _REG relative to RSET_SPI
1045 *************************************************************************/
1046
1047/* BCM 6338 SPI core */
1048#define SPI_6338_CMD 0x00 /* 16-bits register */
1049#define SPI_6338_INT_STATUS 0x02
1050#define SPI_6338_INT_MASK_ST 0x03
1051#define SPI_6338_INT_MASK 0x04
1052#define SPI_6338_ST 0x05
1053#define SPI_6338_CLK_CFG 0x06
1054#define SPI_6338_FILL_BYTE 0x07
1055#define SPI_6338_MSG_TAIL 0x09
1056#define SPI_6338_RX_TAIL 0x0b
1057#define SPI_6338_MSG_CTL 0x40 /* 8-bits register */
1058#define SPI_6338_MSG_CTL_WIDTH 8
1059#define SPI_6338_MSG_DATA 0x41
1060#define SPI_6338_MSG_DATA_SIZE 0x3f
1061#define SPI_6338_RX_DATA 0x80
1062#define SPI_6338_RX_DATA_SIZE 0x3f
1063
1064/* BCM 6348 SPI core */
1065#define SPI_6348_CMD 0x00 /* 16-bits register */
1066#define SPI_6348_INT_STATUS 0x02
1067#define SPI_6348_INT_MASK_ST 0x03
1068#define SPI_6348_INT_MASK 0x04
1069#define SPI_6348_ST 0x05
1070#define SPI_6348_CLK_CFG 0x06
1071#define SPI_6348_FILL_BYTE 0x07
1072#define SPI_6348_MSG_TAIL 0x09
1073#define SPI_6348_RX_TAIL 0x0b
1074#define SPI_6348_MSG_CTL 0x40 /* 8-bits register */
1075#define SPI_6348_MSG_CTL_WIDTH 8
1076#define SPI_6348_MSG_DATA 0x41
1077#define SPI_6348_MSG_DATA_SIZE 0x3f
1078#define SPI_6348_RX_DATA 0x80
1079#define SPI_6348_RX_DATA_SIZE 0x3f
1080
1081/* BCM 6358 SPI core */
1082#define SPI_6358_MSG_CTL 0x00 /* 16-bits register */
1083#define SPI_6358_MSG_CTL_WIDTH 16
1084#define SPI_6358_MSG_DATA 0x02
1085#define SPI_6358_MSG_DATA_SIZE 0x21e
1086#define SPI_6358_RX_DATA 0x400
1087#define SPI_6358_RX_DATA_SIZE 0x220
1088#define SPI_6358_CMD 0x700 /* 16-bits register */
1089#define SPI_6358_INT_STATUS 0x702
1090#define SPI_6358_INT_MASK_ST 0x703
1091#define SPI_6358_INT_MASK 0x704
1092#define SPI_6358_ST 0x705
1093#define SPI_6358_CLK_CFG 0x706
1094#define SPI_6358_FILL_BYTE 0x707
1095#define SPI_6358_MSG_TAIL 0x709
1096#define SPI_6358_RX_TAIL 0x70B
1097
1098/* BCM 6358 SPI core */
1099#define SPI_6368_MSG_CTL 0x00 /* 16-bits register */
1100#define SPI_6368_MSG_CTL_WIDTH 16
1101#define SPI_6368_MSG_DATA 0x02
1102#define SPI_6368_MSG_DATA_SIZE 0x21e
1103#define SPI_6368_RX_DATA 0x400
1104#define SPI_6368_RX_DATA_SIZE 0x220
1105#define SPI_6368_CMD 0x700 /* 16-bits register */
1106#define SPI_6368_INT_STATUS 0x702
1107#define SPI_6368_INT_MASK_ST 0x703
1108#define SPI_6368_INT_MASK 0x704
1109#define SPI_6368_ST 0x705
1110#define SPI_6368_CLK_CFG 0x706
1111#define SPI_6368_FILL_BYTE 0x707
1112#define SPI_6368_MSG_TAIL 0x709
1113#define SPI_6368_RX_TAIL 0x70B
1114
1115/* Shared SPI definitions */
1116
1117/* Message configuration */
1118#define SPI_FD_RW 0x00
1119#define SPI_HD_W 0x01
1120#define SPI_HD_R 0x02
1121#define SPI_BYTE_CNT_SHIFT 0
1122#define SPI_6338_MSG_TYPE_SHIFT 6
1123#define SPI_6348_MSG_TYPE_SHIFT 6
1124#define SPI_6358_MSG_TYPE_SHIFT 14
1125#define SPI_6368_MSG_TYPE_SHIFT 14
1126
1127/* Command */
1128#define SPI_CMD_NOOP 0x00
1129#define SPI_CMD_SOFT_RESET 0x01
1130#define SPI_CMD_HARD_RESET 0x02
1131#define SPI_CMD_START_IMMEDIATE 0x03
1132#define SPI_CMD_COMMAND_SHIFT 0
1133#define SPI_CMD_COMMAND_MASK 0x000f
1134#define SPI_CMD_DEVICE_ID_SHIFT 4
1135#define SPI_CMD_PREPEND_BYTE_CNT_SHIFT 8
1136#define SPI_CMD_ONE_BYTE_SHIFT 11
1137#define SPI_CMD_ONE_WIRE_SHIFT 12
1138#define SPI_DEV_ID_0 0
1139#define SPI_DEV_ID_1 1
1140#define SPI_DEV_ID_2 2
1141#define SPI_DEV_ID_3 3
1142
1143/* Interrupt mask */
1144#define SPI_INTR_CMD_DONE 0x01
1145#define SPI_INTR_RX_OVERFLOW 0x02
1146#define SPI_INTR_TX_UNDERFLOW 0x04
1147#define SPI_INTR_TX_OVERFLOW 0x08
1148#define SPI_INTR_RX_UNDERFLOW 0x10
1149#define SPI_INTR_CLEAR_ALL 0x1f
1150
1151/* Status */
1152#define SPI_RX_EMPTY 0x02
1153#define SPI_CMD_BUSY 0x04
1154#define SPI_SERIAL_BUSY 0x08
1155
1156/* Clock configuration */
1157#define SPI_CLK_20MHZ 0x00
1158#define SPI_CLK_0_391MHZ 0x01
1159#define SPI_CLK_0_781MHZ 0x02 /* default */
1160#define SPI_CLK_1_563MHZ 0x03
1161#define SPI_CLK_3_125MHZ 0x04
1162#define SPI_CLK_6_250MHZ 0x05
1163#define SPI_CLK_12_50MHZ 0x06
1164#define SPI_CLK_MASK 0x07
1165#define SPI_SSOFFTIME_MASK 0x38
1166#define SPI_SSOFFTIME_SHIFT 3
1167#define SPI_BYTE_SWAP 0x80
1168
1169/*************************************************************************
1170 * _REG relative to RSET_MISC
1171 *************************************************************************/
1172#define MISC_SERDES_CTRL_REG 0x0
1173#define SERDES_PCIE_EN (1 << 0)
1174#define SERDES_PCIE_EXD_EN (1 << 15)
1175
1176#define MISC_STRAPBUS_6328_REG 0x240
1177#define STRAPBUS_6328_FCVO_SHIFT 7
1178#define STRAPBUS_6328_FCVO_MASK (0x1f << STRAPBUS_6328_FCVO_SHIFT)
1179#define STRAPBUS_6328_BOOT_SEL_SERIAL (1 << 28)
1180#define STRAPBUS_6328_BOOT_SEL_NAND (0 << 28)
1181
1182/*************************************************************************
1183 * _REG relative to RSET_PCIE
1184 *************************************************************************/
1185
1186#define PCIE_CONFIG2_REG 0x408
1187#define CONFIG2_BAR1_SIZE_EN 1
1188#define CONFIG2_BAR1_SIZE_MASK 0xf
1189
1190#define PCIE_IDVAL3_REG 0x43c
1191#define IDVAL3_CLASS_CODE_MASK 0xffffff
1192#define IDVAL3_SUBCLASS_SHIFT 8
1193#define IDVAL3_CLASS_SHIFT 16
1194
1195#define PCIE_DLSTATUS_REG 0x1048
1196#define DLSTATUS_PHYLINKUP (1 << 13)
1197
1198#define PCIE_BRIDGE_OPT1_REG 0x2820
1199#define OPT1_RD_BE_OPT_EN (1 << 7)
1200#define OPT1_RD_REPLY_BE_FIX_EN (1 << 9)
1201#define OPT1_PCIE_BRIDGE_HOLE_DET_EN (1 << 11)
1202#define OPT1_L1_INT_STATUS_MASK_POL (1 << 12)
1203
1204#define PCIE_BRIDGE_OPT2_REG 0x2824
1205#define OPT2_UBUS_UR_DECODE_DIS (1 << 2)
1206#define OPT2_TX_CREDIT_CHK_EN (1 << 4)
1207#define OPT2_CFG_TYPE1_BD_SEL (1 << 7)
1208#define OPT2_CFG_TYPE1_BUS_NO_SHIFT 16
1209#define OPT2_CFG_TYPE1_BUS_NO_MASK (0xff << OPT2_CFG_TYPE1_BUS_NO_SHIFT)
1210
1211#define PCIE_BRIDGE_BAR0_BASEMASK_REG 0x2828
1212#define PCIE_BRIDGE_BAR1_BASEMASK_REG 0x2830
1213#define BASEMASK_REMAP_EN (1 << 0)
1214#define BASEMASK_SWAP_EN (1 << 1)
1215#define BASEMASK_MASK_SHIFT 4
1216#define BASEMASK_MASK_MASK (0xfff << BASEMASK_MASK_SHIFT)
1217#define BASEMASK_BASE_SHIFT 20
1218#define BASEMASK_BASE_MASK (0xfff << BASEMASK_BASE_SHIFT)
1219
1220#define PCIE_BRIDGE_BAR0_REBASE_ADDR_REG 0x282c
1221#define PCIE_BRIDGE_BAR1_REBASE_ADDR_REG 0x2834
1222#define REBASE_ADDR_BASE_SHIFT 20
1223#define REBASE_ADDR_BASE_MASK (0xfff << REBASE_ADDR_BASE_SHIFT)
1224
1225#define PCIE_BRIDGE_RC_INT_MASK_REG 0x2854
1226#define PCIE_RC_INT_A (1 << 0)
1227#define PCIE_RC_INT_B (1 << 1)
1228#define PCIE_RC_INT_C (1 << 2)
1229#define PCIE_RC_INT_D (1 << 3)
1230
1231#define PCIE_DEVICE_OFFSET 0x8000
1232
976#endif /* BCM63XX_REGS_H_ */ 1233#endif /* BCM63XX_REGS_H_ */
diff --git a/arch/mips/include/asm/mach-bcm63xx/ioremap.h b/arch/mips/include/asm/mach-bcm63xx/ioremap.h
index ef94ba73646..30931c42379 100644
--- a/arch/mips/include/asm/mach-bcm63xx/ioremap.h
+++ b/arch/mips/include/asm/mach-bcm63xx/ioremap.h
@@ -18,6 +18,7 @@ static inline int is_bcm63xx_internal_registers(phys_t offset)
18 if (offset >= 0xfff00000) 18 if (offset >= 0xfff00000)
19 return 1; 19 return 1;
20 break; 20 break;
21 case BCM6328_CPU_ID:
21 case BCM6368_CPU_ID: 22 case BCM6368_CPU_ID:
22 if (offset >= 0xb0000000 && offset < 0xb1000000) 23 if (offset >= 0xb0000000 && offset < 0xb1000000)
23 return 1; 24 return 1;
diff --git a/arch/mips/include/asm/mach-cavium-octeon/irq.h b/arch/mips/include/asm/mach-cavium-octeon/irq.h
index 5b05f186e39..c22a3078bf1 100644
--- a/arch/mips/include/asm/mach-cavium-octeon/irq.h
+++ b/arch/mips/include/asm/mach-cavium-octeon/irq.h
@@ -21,14 +21,10 @@ enum octeon_irq {
21 OCTEON_IRQ_TIMER, 21 OCTEON_IRQ_TIMER,
22/* sources in CIU_INTX_EN0 */ 22/* sources in CIU_INTX_EN0 */
23 OCTEON_IRQ_WORKQ0, 23 OCTEON_IRQ_WORKQ0,
24 OCTEON_IRQ_GPIO0 = OCTEON_IRQ_WORKQ0 + 16, 24 OCTEON_IRQ_WDOG0 = OCTEON_IRQ_WORKQ0 + 16,
25 OCTEON_IRQ_WDOG0 = OCTEON_IRQ_GPIO0 + 16,
26 OCTEON_IRQ_WDOG15 = OCTEON_IRQ_WDOG0 + 15, 25 OCTEON_IRQ_WDOG15 = OCTEON_IRQ_WDOG0 + 15,
27 OCTEON_IRQ_MBOX0 = OCTEON_IRQ_WDOG0 + 16, 26 OCTEON_IRQ_MBOX0 = OCTEON_IRQ_WDOG0 + 16,
28 OCTEON_IRQ_MBOX1, 27 OCTEON_IRQ_MBOX1,
29 OCTEON_IRQ_UART0,
30 OCTEON_IRQ_UART1,
31 OCTEON_IRQ_UART2,
32 OCTEON_IRQ_PCI_INT0, 28 OCTEON_IRQ_PCI_INT0,
33 OCTEON_IRQ_PCI_INT1, 29 OCTEON_IRQ_PCI_INT1,
34 OCTEON_IRQ_PCI_INT2, 30 OCTEON_IRQ_PCI_INT2,
@@ -38,64 +34,25 @@ enum octeon_irq {
38 OCTEON_IRQ_PCI_MSI2, 34 OCTEON_IRQ_PCI_MSI2,
39 OCTEON_IRQ_PCI_MSI3, 35 OCTEON_IRQ_PCI_MSI3,
40 36
41 OCTEON_IRQ_TWSI,
42 OCTEON_IRQ_TWSI2,
43 OCTEON_IRQ_RML, 37 OCTEON_IRQ_RML,
44 OCTEON_IRQ_TRACE0,
45 OCTEON_IRQ_GMX_DRP0 = OCTEON_IRQ_TRACE0 + 4,
46 OCTEON_IRQ_IPD_DRP = OCTEON_IRQ_GMX_DRP0 + 5,
47 OCTEON_IRQ_KEY_ZERO,
48 OCTEON_IRQ_TIMER0, 38 OCTEON_IRQ_TIMER0,
49 OCTEON_IRQ_TIMER1, 39 OCTEON_IRQ_TIMER1,
50 OCTEON_IRQ_TIMER2, 40 OCTEON_IRQ_TIMER2,
51 OCTEON_IRQ_TIMER3, 41 OCTEON_IRQ_TIMER3,
52 OCTEON_IRQ_USB0, 42 OCTEON_IRQ_USB0,
53 OCTEON_IRQ_USB1, 43 OCTEON_IRQ_USB1,
54 OCTEON_IRQ_PCM,
55 OCTEON_IRQ_MPI,
56 OCTEON_IRQ_POWIQ,
57 OCTEON_IRQ_IPDPPTHR,
58 OCTEON_IRQ_MII0,
59 OCTEON_IRQ_MII1,
60 OCTEON_IRQ_BOOTDMA, 44 OCTEON_IRQ_BOOTDMA,
61 45#ifndef CONFIG_PCI_MSI
62 OCTEON_IRQ_NAND, 46 OCTEON_IRQ_LAST = 127
63 OCTEON_IRQ_MIO, /* Summary of MIO_BOOT_ERR */ 47#endif
64 OCTEON_IRQ_IOB, /* Summary of IOB_INT_SUM */
65 OCTEON_IRQ_FPA, /* Summary of FPA_INT_SUM */
66 OCTEON_IRQ_POW, /* Summary of POW_ECC_ERR */
67 OCTEON_IRQ_L2C, /* Summary of L2C_INT_STAT */
68 OCTEON_IRQ_IPD, /* Summary of IPD_INT_SUM */
69 OCTEON_IRQ_PIP, /* Summary of PIP_INT_REG */
70 OCTEON_IRQ_PKO, /* Summary of PKO_REG_ERROR */
71 OCTEON_IRQ_ZIP, /* Summary of ZIP_ERROR */
72 OCTEON_IRQ_TIM, /* Summary of TIM_REG_ERROR */
73 OCTEON_IRQ_RAD, /* Summary of RAD_REG_ERROR */
74 OCTEON_IRQ_KEY, /* Summary of KEY_INT_SUM */
75 OCTEON_IRQ_DFA, /* Summary of DFA */
76 OCTEON_IRQ_USBCTL, /* Summary of USBN0_INT_SUM */
77 OCTEON_IRQ_SLI, /* Summary of SLI_INT_SUM */
78 OCTEON_IRQ_DPI, /* Summary of DPI_INT_SUM */
79 OCTEON_IRQ_AGX0, /* Summary of GMX0*+PCS0_INT*_REG */
80 OCTEON_IRQ_AGL = OCTEON_IRQ_AGX0 + 5,
81 OCTEON_IRQ_PTP,
82 OCTEON_IRQ_PEM0,
83 OCTEON_IRQ_PEM1,
84 OCTEON_IRQ_SRIO0,
85 OCTEON_IRQ_SRIO1,
86 OCTEON_IRQ_LMC0,
87 OCTEON_IRQ_DFM = OCTEON_IRQ_LMC0 + 4, /* Summary of DFM */
88 OCTEON_IRQ_RST,
89}; 48};
90 49
91#ifdef CONFIG_PCI_MSI 50#ifdef CONFIG_PCI_MSI
92/* 152 - 407 represent the MSI interrupts 0-255 */ 51/* 256 - 511 represent the MSI interrupts 0-255 */
93#define OCTEON_IRQ_MSI_BIT0 (OCTEON_IRQ_RST + 1) 52#define OCTEON_IRQ_MSI_BIT0 (256)
94 53
95#define OCTEON_IRQ_MSI_LAST (OCTEON_IRQ_MSI_BIT0 + 255) 54#define OCTEON_IRQ_MSI_LAST (OCTEON_IRQ_MSI_BIT0 + 255)
96#define OCTEON_IRQ_LAST (OCTEON_IRQ_MSI_LAST + 1) 55#define OCTEON_IRQ_LAST (OCTEON_IRQ_MSI_LAST + 1)
97#else
98#define OCTEON_IRQ_LAST (OCTEON_IRQ_RST + 1)
99#endif 56#endif
100 57
101#endif 58#endif
diff --git a/arch/mips/include/asm/mach-jz4740/jz4740_nand.h b/arch/mips/include/asm/mach-jz4740/jz4740_nand.h
index bb5b9a4e29c..986982db7c3 100644
--- a/arch/mips/include/asm/mach-jz4740/jz4740_nand.h
+++ b/arch/mips/include/asm/mach-jz4740/jz4740_nand.h
@@ -19,6 +19,8 @@
19#include <linux/mtd/nand.h> 19#include <linux/mtd/nand.h>
20#include <linux/mtd/partitions.h> 20#include <linux/mtd/partitions.h>
21 21
22#define JZ_NAND_NUM_BANKS 4
23
22struct jz_nand_platform_data { 24struct jz_nand_platform_data {
23 int num_partitions; 25 int num_partitions;
24 struct mtd_partition *partitions; 26 struct mtd_partition *partitions;
@@ -27,6 +29,8 @@ struct jz_nand_platform_data {
27 29
28 unsigned int busy_gpio; 30 unsigned int busy_gpio;
29 31
32 unsigned char banks[JZ_NAND_NUM_BANKS];
33
30 void (*ident_callback)(struct platform_device *, struct nand_chip *, 34 void (*ident_callback)(struct platform_device *, struct nand_chip *,
31 struct mtd_partition **, int *num_partitions); 35 struct mtd_partition **, int *num_partitions);
32}; 36};
diff --git a/arch/mips/include/asm/mach-loongson/loongson.h b/arch/mips/include/asm/mach-loongson/loongson.h
index 1e29b9dd1d7..5222a007bc2 100644
--- a/arch/mips/include/asm/mach-loongson/loongson.h
+++ b/arch/mips/include/asm/mach-loongson/loongson.h
@@ -14,6 +14,7 @@
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/irq.h> 16#include <linux/irq.h>
17#include <linux/kconfig.h>
17 18
18/* loongson internal northbridge initialization */ 19/* loongson internal northbridge initialization */
19extern void bonito_irq_init(void); 20extern void bonito_irq_init(void);
@@ -66,7 +67,7 @@ extern int mach_i8259_irq(void);
66#include <linux/interrupt.h> 67#include <linux/interrupt.h>
67static inline void do_perfcnt_IRQ(void) 68static inline void do_perfcnt_IRQ(void)
68{ 69{
69#if defined(CONFIG_OPROFILE) || defined(CONFIG_OPROFILE_MODULE) 70#if IS_ENABLED(CONFIG_OPROFILE)
70 do_IRQ(LOONGSON2_PERFCNT_IRQ); 71 do_IRQ(LOONGSON2_PERFCNT_IRQ);
71#endif 72#endif
72} 73}
@@ -244,7 +245,6 @@ static inline void do_perfcnt_IRQ(void)
244 245
245#ifdef CONFIG_CPU_SUPPORTS_CPUFREQ 246#ifdef CONFIG_CPU_SUPPORTS_CPUFREQ
246#include <linux/cpufreq.h> 247#include <linux/cpufreq.h>
247extern void loongson2_cpu_wait(void);
248extern struct cpufreq_frequency_table loongson2_clockmod_table[]; 248extern struct cpufreq_frequency_table loongson2_clockmod_table[];
249 249
250/* Chip Config */ 250/* Chip Config */
diff --git a/arch/mips/include/asm/mach-loongson1/irq.h b/arch/mips/include/asm/mach-loongson1/irq.h
new file mode 100644
index 00000000000..da96ed42f73
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson1/irq.h
@@ -0,0 +1,73 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * IRQ mappings for Loongson 1
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12
13#ifndef __ASM_MACH_LOONGSON1_IRQ_H
14#define __ASM_MACH_LOONGSON1_IRQ_H
15
16/*
17 * CPU core Interrupt Numbers
18 */
19#define MIPS_CPU_IRQ_BASE 0
20#define MIPS_CPU_IRQ(x) (MIPS_CPU_IRQ_BASE + (x))
21
22#define SOFTINT0_IRQ MIPS_CPU_IRQ(0)
23#define SOFTINT1_IRQ MIPS_CPU_IRQ(1)
24#define INT0_IRQ MIPS_CPU_IRQ(2)
25#define INT1_IRQ MIPS_CPU_IRQ(3)
26#define INT2_IRQ MIPS_CPU_IRQ(4)
27#define INT3_IRQ MIPS_CPU_IRQ(5)
28#define INT4_IRQ MIPS_CPU_IRQ(6)
29#define TIMER_IRQ MIPS_CPU_IRQ(7) /* cpu timer */
30
31#define MIPS_CPU_IRQS (MIPS_CPU_IRQ(7) + 1 - MIPS_CPU_IRQ_BASE)
32
33/*
34 * INT0~3 Interrupt Numbers
35 */
36#define LS1X_IRQ_BASE MIPS_CPU_IRQS
37#define LS1X_IRQ(n, x) (LS1X_IRQ_BASE + (n << 5) + (x))
38
39#define LS1X_UART0_IRQ LS1X_IRQ(0, 2)
40#define LS1X_UART1_IRQ LS1X_IRQ(0, 3)
41#define LS1X_UART2_IRQ LS1X_IRQ(0, 4)
42#define LS1X_UART3_IRQ LS1X_IRQ(0, 5)
43#define LS1X_CAN0_IRQ LS1X_IRQ(0, 6)
44#define LS1X_CAN1_IRQ LS1X_IRQ(0, 7)
45#define LS1X_SPI0_IRQ LS1X_IRQ(0, 8)
46#define LS1X_SPI1_IRQ LS1X_IRQ(0, 9)
47#define LS1X_AC97_IRQ LS1X_IRQ(0, 10)
48#define LS1X_DMA0_IRQ LS1X_IRQ(0, 13)
49#define LS1X_DMA1_IRQ LS1X_IRQ(0, 14)
50#define LS1X_DMA2_IRQ LS1X_IRQ(0, 15)
51#define LS1X_PWM0_IRQ LS1X_IRQ(0, 17)
52#define LS1X_PWM1_IRQ LS1X_IRQ(0, 18)
53#define LS1X_PWM2_IRQ LS1X_IRQ(0, 19)
54#define LS1X_PWM3_IRQ LS1X_IRQ(0, 20)
55#define LS1X_RTC_INT0_IRQ LS1X_IRQ(0, 21)
56#define LS1X_RTC_INT1_IRQ LS1X_IRQ(0, 22)
57#define LS1X_RTC_INT2_IRQ LS1X_IRQ(0, 23)
58#define LS1X_TOY_INT0_IRQ LS1X_IRQ(0, 24)
59#define LS1X_TOY_INT1_IRQ LS1X_IRQ(0, 25)
60#define LS1X_TOY_INT2_IRQ LS1X_IRQ(0, 26)
61#define LS1X_RTC_TICK_IRQ LS1X_IRQ(0, 27)
62#define LS1X_TOY_TICK_IRQ LS1X_IRQ(0, 28)
63
64#define LS1X_EHCI_IRQ LS1X_IRQ(1, 0)
65#define LS1X_OHCI_IRQ LS1X_IRQ(1, 1)
66#define LS1X_GMAC0_IRQ LS1X_IRQ(1, 2)
67#define LS1X_GMAC1_IRQ LS1X_IRQ(1, 3)
68
69#define LS1X_IRQS (LS1X_IRQ(4, 31) + 1 - LS1X_IRQ_BASE)
70
71#define NR_IRQS (MIPS_CPU_IRQS + LS1X_IRQS)
72
73#endif /* __ASM_MACH_LOONGSON1_IRQ_H */
diff --git a/arch/mips/include/asm/mach-loongson1/loongson1.h b/arch/mips/include/asm/mach-loongson1/loongson1.h
new file mode 100644
index 00000000000..4e18e88cebb
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson1/loongson1.h
@@ -0,0 +1,44 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * Register mappings for Loongson 1
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12
13#ifndef __ASM_MACH_LOONGSON1_LOONGSON1_H
14#define __ASM_MACH_LOONGSON1_LOONGSON1_H
15
16#define DEFAULT_MEMSIZE 256 /* If no memsize provided */
17
18/* Loongson 1 Register Bases */
19#define LS1X_INTC_BASE 0x1fd01040
20#define LS1X_EHCI_BASE 0x1fe00000
21#define LS1X_OHCI_BASE 0x1fe08000
22#define LS1X_GMAC0_BASE 0x1fe10000
23#define LS1X_GMAC1_BASE 0x1fe20000
24
25#define LS1X_UART0_BASE 0x1fe40000
26#define LS1X_UART1_BASE 0x1fe44000
27#define LS1X_UART2_BASE 0x1fe48000
28#define LS1X_UART3_BASE 0x1fe4c000
29#define LS1X_CAN0_BASE 0x1fe50000
30#define LS1X_CAN1_BASE 0x1fe54000
31#define LS1X_I2C0_BASE 0x1fe58000
32#define LS1X_I2C1_BASE 0x1fe68000
33#define LS1X_I2C2_BASE 0x1fe70000
34#define LS1X_PWM_BASE 0x1fe5c000
35#define LS1X_WDT_BASE 0x1fe5c060
36#define LS1X_RTC_BASE 0x1fe64000
37#define LS1X_AC97_BASE 0x1fe74000
38#define LS1X_NAND_BASE 0x1fe78000
39#define LS1X_CLK_BASE 0x1fe78030
40
41#include <regs-clk.h>
42#include <regs-wdt.h>
43
44#endif /* __ASM_MACH_LOONGSON1_LOONGSON1_H */
diff --git a/arch/mips/include/asm/mach-loongson1/platform.h b/arch/mips/include/asm/mach-loongson1/platform.h
new file mode 100644
index 00000000000..2f171617bad
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson1/platform.h
@@ -0,0 +1,23 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10
11#ifndef __ASM_MACH_LOONGSON1_PLATFORM_H
12#define __ASM_MACH_LOONGSON1_PLATFORM_H
13
14#include <linux/platform_device.h>
15
16extern struct platform_device ls1x_uart_device;
17extern struct platform_device ls1x_eth0_device;
18extern struct platform_device ls1x_ehci_device;
19extern struct platform_device ls1x_rtc_device;
20
21void ls1x_serial_setup(void);
22
23#endif /* __ASM_MACH_LOONGSON1_PLATFORM_H */
diff --git a/arch/mips/include/asm/mach-loongson1/prom.h b/arch/mips/include/asm/mach-loongson1/prom.h
new file mode 100644
index 00000000000..b871dc41b8d
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson1/prom.h
@@ -0,0 +1,24 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#ifndef __ASM_MACH_LOONGSON1_PROM_H
11#define __ASM_MACH_LOONGSON1_PROM_H
12
13#include <linux/io.h>
14#include <linux/init.h>
15#include <linux/irq.h>
16
17/* environment arguments from bootloader */
18extern unsigned long memsize, highmemsize;
19
20/* loongson-specific command line, env and memory initialization */
21extern char *prom_getenv(char *name);
22extern void __init prom_init_cmdline(void);
23
24#endif /* __ASM_MACH_LOONGSON1_PROM_H */
diff --git a/arch/mips/include/asm/mach-loongson1/regs-clk.h b/arch/mips/include/asm/mach-loongson1/regs-clk.h
new file mode 100644
index 00000000000..8efa7fb9f73
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson1/regs-clk.h
@@ -0,0 +1,33 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * Loongson 1 Clock Register Definitions.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#ifndef __ASM_MACH_LOONGSON1_REGS_CLK_H
13#define __ASM_MACH_LOONGSON1_REGS_CLK_H
14
15#define LS1X_CLK_REG(x) \
16 ((void __iomem *)KSEG1ADDR(LS1X_CLK_BASE + (x)))
17
18#define LS1X_CLK_PLL_FREQ LS1X_CLK_REG(0x0)
19#define LS1X_CLK_PLL_DIV LS1X_CLK_REG(0x4)
20
21/* Clock PLL Divisor Register Bits */
22#define DIV_DC_EN (0x1 << 31)
23#define DIV_DC (0x1f << 26)
24#define DIV_CPU_EN (0x1 << 25)
25#define DIV_CPU (0x1f << 20)
26#define DIV_DDR_EN (0x1 << 19)
27#define DIV_DDR (0x1f << 14)
28
29#define DIV_DC_SHIFT 26
30#define DIV_CPU_SHIFT 20
31#define DIV_DDR_SHIFT 14
32
33#endif /* __ASM_MACH_LOONGSON1_REGS_CLK_H */
diff --git a/arch/mips/include/asm/mach-loongson1/regs-wdt.h b/arch/mips/include/asm/mach-loongson1/regs-wdt.h
new file mode 100644
index 00000000000..f897de68c52
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson1/regs-wdt.h
@@ -0,0 +1,22 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * Loongson 1 watchdog register definitions.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#ifndef __ASM_MACH_LOONGSON1_REGS_WDT_H
13#define __ASM_MACH_LOONGSON1_REGS_WDT_H
14
15#define LS1X_WDT_REG(x) \
16 ((void __iomem *)KSEG1ADDR(LS1X_WDT_BASE + (x)))
17
18#define LS1X_WDT_EN LS1X_WDT_REG(0x0)
19#define LS1X_WDT_SET LS1X_WDT_REG(0x4)
20#define LS1X_WDT_TIMER LS1X_WDT_REG(0x8)
21
22#endif /* __ASM_MACH_LOONGSON1_REGS_WDT_H */
diff --git a/arch/mips/include/asm/mach-loongson1/war.h b/arch/mips/include/asm/mach-loongson1/war.h
new file mode 100644
index 00000000000..e3680a8fb34
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson1/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MACH_LOONGSON1_WAR_H
9#define __ASM_MACH_LOONGSON1_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MACH_LOONGSON1_WAR_H */
diff --git a/arch/mips/include/asm/mach-netlogic/cpu-feature-overrides.h b/arch/mips/include/asm/mach-netlogic/cpu-feature-overrides.h
index d193fb68cf2..966db4be377 100644
--- a/arch/mips/include/asm/mach-netlogic/cpu-feature-overrides.h
+++ b/arch/mips/include/asm/mach-netlogic/cpu-feature-overrides.h
@@ -48,7 +48,6 @@
48#define cpu_has_userlocal 1 48#define cpu_has_userlocal 1
49#define cpu_has_mips32r2 1 49#define cpu_has_mips32r2 1
50#define cpu_has_mips64r2 1 50#define cpu_has_mips64r2 1
51#define cpu_has_dc_aliases 1
52#else 51#else
53#error "Unknown Netlogic CPU" 52#error "Unknown Netlogic CPU"
54#endif 53#endif
diff --git a/arch/mips/include/asm/mach-tx49xx/mangle-port.h b/arch/mips/include/asm/mach-tx49xx/mangle-port.h
index 5e6912fdd0e..490867b03c8 100644
--- a/arch/mips/include/asm/mach-tx49xx/mangle-port.h
+++ b/arch/mips/include/asm/mach-tx49xx/mangle-port.h
@@ -9,7 +9,7 @@
9#define ioswabb(a, x) (x) 9#define ioswabb(a, x) (x)
10#define __mem_ioswabb(a, x) (x) 10#define __mem_ioswabb(a, x) (x)
11#if defined(CONFIG_TOSHIBA_RBTX4939) && \ 11#if defined(CONFIG_TOSHIBA_RBTX4939) && \
12 (defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)) && \ 12 IS_ENABLED(CONFIG_SMC91X) && \
13 defined(__BIG_ENDIAN) 13 defined(__BIG_ENDIAN)
14#define NEEDS_TXX9_IOSWABW 14#define NEEDS_TXX9_IOSWABW
15extern u16 (*ioswabw)(volatile u16 *a, u16 x); 15extern u16 (*ioswabw)(volatile u16 *a, u16 x);
diff --git a/arch/mips/include/asm/mipsmtregs.h b/arch/mips/include/asm/mipsmtregs.h
index e71ff4c317f..5b3cb8553e9 100644
--- a/arch/mips/include/asm/mipsmtregs.h
+++ b/arch/mips/include/asm/mipsmtregs.h
@@ -28,6 +28,9 @@
28#define read_c0_vpeconf0() __read_32bit_c0_register($1, 2) 28#define read_c0_vpeconf0() __read_32bit_c0_register($1, 2)
29#define write_c0_vpeconf0(val) __write_32bit_c0_register($1, 2, val) 29#define write_c0_vpeconf0(val) __write_32bit_c0_register($1, 2, val)
30 30
31#define read_c0_vpeconf1() __read_32bit_c0_register($1, 3)
32#define write_c0_vpeconf1(val) __write_32bit_c0_register($1, 3, val)
33
31#define read_c0_tcstatus() __read_32bit_c0_register($2, 1) 34#define read_c0_tcstatus() __read_32bit_c0_register($2, 1)
32#define write_c0_tcstatus(val) __write_32bit_c0_register($2, 1, val) 35#define write_c0_tcstatus(val) __write_32bit_c0_register($2, 1, val)
33 36
@@ -124,6 +127,14 @@
124#define VPECONF0_XTC_SHIFT 21 127#define VPECONF0_XTC_SHIFT 21
125#define VPECONF0_XTC (_ULCAST_(0xff) << VPECONF0_XTC_SHIFT) 128#define VPECONF0_XTC (_ULCAST_(0xff) << VPECONF0_XTC_SHIFT)
126 129
130/* VPEConf1 fields (per VPE) */
131#define VPECONF1_NCP1_SHIFT 0
132#define VPECONF1_NCP1 (_ULCAST_(0xff) << VPECONF1_NCP1_SHIFT)
133#define VPECONF1_NCP2_SHIFT 10
134#define VPECONF1_NCP2 (_ULCAST_(0xff) << VPECONF1_NCP2_SHIFT)
135#define VPECONF1_NCX_SHIFT 20
136#define VPECONF1_NCX (_ULCAST_(0xff) << VPECONF1_NCX_SHIFT)
137
127/* TCStatus fields (per TC) */ 138/* TCStatus fields (per TC) */
128#define TCSTATUS_TASID (_ULCAST_(0xff)) 139#define TCSTATUS_TASID (_ULCAST_(0xff))
129#define TCSTATUS_IXMT_SHIFT 10 140#define TCSTATUS_IXMT_SHIFT 10
@@ -350,6 +361,8 @@ do { \
350#define write_vpe_c0_vpecontrol(val) mttc0(1, 1, val) 361#define write_vpe_c0_vpecontrol(val) mttc0(1, 1, val)
351#define read_vpe_c0_vpeconf0() mftc0(1, 2) 362#define read_vpe_c0_vpeconf0() mftc0(1, 2)
352#define write_vpe_c0_vpeconf0(val) mttc0(1, 2, val) 363#define write_vpe_c0_vpeconf0(val) mttc0(1, 2, val)
364#define read_vpe_c0_vpeconf1() mftc0(1, 3)
365#define write_vpe_c0_vpeconf1(val) mttc0(1, 3, val)
353#define read_vpe_c0_count() mftc0(9, 0) 366#define read_vpe_c0_count() mftc0(9, 0)
354#define write_vpe_c0_count(val) mttc0(9, 0, val) 367#define write_vpe_c0_count(val) mttc0(9, 0, val)
355#define read_vpe_c0_status() mftc0(12, 0) 368#define read_vpe_c0_status() mftc0(12, 0)
diff --git a/arch/mips/include/asm/module.h b/arch/mips/include/asm/module.h
index 530008048c6..dca8bce8c7a 100644
--- a/arch/mips/include/asm/module.h
+++ b/arch/mips/include/asm/module.h
@@ -10,6 +10,7 @@ struct mod_arch_specific {
10 struct list_head dbe_list; 10 struct list_head dbe_list;
11 const struct exception_table_entry *dbe_start; 11 const struct exception_table_entry *dbe_start;
12 const struct exception_table_entry *dbe_end; 12 const struct exception_table_entry *dbe_end;
13 struct mips_hi16 *r_mips_hi16_list;
13}; 14};
14 15
15typedef uint8_t Elf64_Byte; /* Type for a 8-bit quantity. */ 16typedef uint8_t Elf64_Byte; /* Type for a 8-bit quantity. */
@@ -117,6 +118,8 @@ search_module_dbetables(unsigned long addr)
117#define MODULE_PROC_FAMILY "RM9000 " 118#define MODULE_PROC_FAMILY "RM9000 "
118#elif defined CONFIG_CPU_SB1 119#elif defined CONFIG_CPU_SB1
119#define MODULE_PROC_FAMILY "SB1 " 120#define MODULE_PROC_FAMILY "SB1 "
121#elif defined CONFIG_CPU_LOONGSON1
122#define MODULE_PROC_FAMILY "LOONGSON1 "
120#elif defined CONFIG_CPU_LOONGSON2 123#elif defined CONFIG_CPU_LOONGSON2
121#define MODULE_PROC_FAMILY "LOONGSON2 " 124#define MODULE_PROC_FAMILY "LOONGSON2 "
122#elif defined CONFIG_CPU_CAVIUM_OCTEON 125#elif defined CONFIG_CPU_CAVIUM_OCTEON
diff --git a/arch/mips/include/asm/netlogic/xlp-hal/cpucontrol.h b/arch/mips/include/asm/netlogic/xlp-hal/cpucontrol.h
index bf7d41deb9b..7b63a6b722a 100644
--- a/arch/mips/include/asm/netlogic/xlp-hal/cpucontrol.h
+++ b/arch/mips/include/asm/netlogic/xlp-hal/cpucontrol.h
@@ -47,7 +47,9 @@
47#define CPU_BLOCKID_MAP 10 47#define CPU_BLOCKID_MAP 10
48 48
49#define LSU_DEFEATURE 0x304 49#define LSU_DEFEATURE 0x304
50#define LSU_CERRLOG_REGID 0x09 50#define LSU_DEBUG_ADDR 0x305
51#define LSU_DEBUG_DATA0 0x306
52#define LSU_CERRLOG_REGID 0x309
51#define SCHED_DEFEATURE 0x700 53#define SCHED_DEFEATURE 0x700
52 54
53/* Offsets of interest from the 'MAP' Block */ 55/* Offsets of interest from the 'MAP' Block */
diff --git a/arch/mips/include/asm/netlogic/xlp-hal/iomap.h b/arch/mips/include/asm/netlogic/xlp-hal/iomap.h
index 86cc3391e50..2c63f975464 100644
--- a/arch/mips/include/asm/netlogic/xlp-hal/iomap.h
+++ b/arch/mips/include/asm/netlogic/xlp-hal/iomap.h
@@ -36,6 +36,9 @@
36#define __NLM_HAL_IOMAP_H__ 36#define __NLM_HAL_IOMAP_H__
37 37
38#define XLP_DEFAULT_IO_BASE 0x18000000 38#define XLP_DEFAULT_IO_BASE 0x18000000
39#define XLP_DEFAULT_PCI_ECFG_BASE XLP_DEFAULT_IO_BASE
40#define XLP_DEFAULT_PCI_CFG_BASE 0x1c000000
41
39#define NMI_BASE 0xbfc00000 42#define NMI_BASE 0xbfc00000
40#define XLP_IO_CLK 133333333 43#define XLP_IO_CLK 133333333
41 44
@@ -129,7 +132,7 @@
129#define PCI_DEVICE_ID_NLM_PIC 0x1003 132#define PCI_DEVICE_ID_NLM_PIC 0x1003
130#define PCI_DEVICE_ID_NLM_PCIE 0x1004 133#define PCI_DEVICE_ID_NLM_PCIE 0x1004
131#define PCI_DEVICE_ID_NLM_EHCI 0x1007 134#define PCI_DEVICE_ID_NLM_EHCI 0x1007
132#define PCI_DEVICE_ID_NLM_ILK 0x1008 135#define PCI_DEVICE_ID_NLM_OHCI 0x1008
133#define PCI_DEVICE_ID_NLM_NAE 0x1009 136#define PCI_DEVICE_ID_NLM_NAE 0x1009
134#define PCI_DEVICE_ID_NLM_POE 0x100A 137#define PCI_DEVICE_ID_NLM_POE 0x100A
135#define PCI_DEVICE_ID_NLM_FMN 0x100B 138#define PCI_DEVICE_ID_NLM_FMN 0x100B
diff --git a/arch/mips/include/asm/netlogic/xlp-hal/pcibus.h b/arch/mips/include/asm/netlogic/xlp-hal/pcibus.h
new file mode 100644
index 00000000000..66c323d1bd7
--- /dev/null
+++ b/arch/mips/include/asm/netlogic/xlp-hal/pcibus.h
@@ -0,0 +1,76 @@
1/*
2 * Copyright (c) 2003-2012 Broadcom Corporation
3 * All Rights Reserved
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the Broadcom
9 * license below:
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
20 * distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#ifndef __NLM_HAL_PCIBUS_H__
36#define __NLM_HAL_PCIBUS_H__
37
38/* PCIE Memory and IO regions */
39#define PCIE_MEM_BASE 0xd0000000ULL
40#define PCIE_MEM_LIMIT 0xdfffffffULL
41#define PCIE_IO_BASE 0x14000000ULL
42#define PCIE_IO_LIMIT 0x15ffffffULL
43
44#define PCIE_BRIDGE_CMD 0x1
45#define PCIE_BRIDGE_MSI_CAP 0x14
46#define PCIE_BRIDGE_MSI_ADDRL 0x15
47#define PCIE_BRIDGE_MSI_ADDRH 0x16
48#define PCIE_BRIDGE_MSI_DATA 0x17
49
50/* XLP Global PCIE configuration space registers */
51#define PCIE_BYTE_SWAP_MEM_BASE 0x247
52#define PCIE_BYTE_SWAP_MEM_LIM 0x248
53#define PCIE_BYTE_SWAP_IO_BASE 0x249
54#define PCIE_BYTE_SWAP_IO_LIM 0x24A
55#define PCIE_MSI_STATUS 0x25A
56#define PCIE_MSI_EN 0x25B
57#define PCIE_INT_EN0 0x261
58
59/* PCIE_MSI_EN */
60#define PCIE_MSI_VECTOR_INT_EN 0xFFFFFFFF
61
62/* PCIE_INT_EN0 */
63#define PCIE_MSI_INT_EN (1 << 9)
64
65#ifndef __ASSEMBLY__
66
67#define nlm_read_pcie_reg(b, r) nlm_read_reg(b, r)
68#define nlm_write_pcie_reg(b, r, v) nlm_write_reg(b, r, v)
69#define nlm_get_pcie_base(node, inst) \
70 nlm_pcicfg_base(XLP_IO_PCIE_OFFSET(node, inst))
71#define nlm_get_pcie_regbase(node, inst) \
72 (nlm_get_pcie_base(node, inst) + XLP_IO_PCI_HDRSZ)
73
74int xlp_pcie_link_irt(int link);
75#endif
76#endif /* __NLM_HAL_PCIBUS_H__ */
diff --git a/arch/mips/include/asm/netlogic/xlp-hal/pic.h b/arch/mips/include/asm/netlogic/xlp-hal/pic.h
index b6628f7ccf7..ad8b80233a6 100644
--- a/arch/mips/include/asm/netlogic/xlp-hal/pic.h
+++ b/arch/mips/include/asm/netlogic/xlp-hal/pic.h
@@ -201,7 +201,11 @@
201#define PIC_NUM_USB_IRTS 6 201#define PIC_NUM_USB_IRTS 6
202#define PIC_IRT_USB_0_INDEX 115 202#define PIC_IRT_USB_0_INDEX 115
203#define PIC_IRT_EHCI_0_INDEX 115 203#define PIC_IRT_EHCI_0_INDEX 115
204#define PIC_IRT_OHCI_0_INDEX 116
205#define PIC_IRT_OHCI_1_INDEX 117
204#define PIC_IRT_EHCI_1_INDEX 118 206#define PIC_IRT_EHCI_1_INDEX 118
207#define PIC_IRT_OHCI_2_INDEX 119
208#define PIC_IRT_OHCI_3_INDEX 120
205#define PIC_IRT_USB_INDEX(num) ((num) + PIC_IRT_USB_0_INDEX) 209#define PIC_IRT_USB_INDEX(num) ((num) + PIC_IRT_USB_0_INDEX)
206/* 115 to 120 */ 210/* 115 to 120 */
207#define PIC_IRT_GDX_INDEX 121 211#define PIC_IRT_GDX_INDEX 121
diff --git a/arch/mips/include/asm/netlogic/xlp-hal/usb.h b/arch/mips/include/asm/netlogic/xlp-hal/usb.h
new file mode 100644
index 00000000000..a9cd350dfb6
--- /dev/null
+++ b/arch/mips/include/asm/netlogic/xlp-hal/usb.h
@@ -0,0 +1,64 @@
1/*
2 * Copyright (c) 2003-2012 Broadcom Corporation
3 * All Rights Reserved
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the Broadcom
9 * license below:
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
20 * distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#ifndef __NLM_HAL_USB_H__
36#define __NLM_HAL_USB_H__
37
38#define USB_CTL_0 0x01
39#define USB_PHY_0 0x0A
40#define USB_PHY_RESET 0x01
41#define USB_PHY_PORT_RESET_0 0x10
42#define USB_PHY_PORT_RESET_1 0x20
43#define USB_CONTROLLER_RESET 0x01
44#define USB_INT_STATUS 0x0E
45#define USB_INT_EN 0x0F
46#define USB_PHY_INTERRUPT_EN 0x01
47#define USB_OHCI_INTERRUPT_EN 0x02
48#define USB_OHCI_INTERRUPT1_EN 0x04
49#define USB_OHCI_INTERRUPT2_EN 0x08
50#define USB_CTRL_INTERRUPT_EN 0x10
51
52#ifndef __ASSEMBLY__
53
54#define nlm_read_usb_reg(b, r) nlm_read_reg(b, r)
55#define nlm_write_usb_reg(b, r, v) nlm_write_reg(b, r, v)
56#define nlm_get_usb_pcibase(node, inst) \
57 nlm_pcicfg_base(XLP_IO_USB_OFFSET(node, inst))
58#define nlm_get_usb_hcd_base(node, inst) \
59 nlm_xkphys_map_pcibar0(nlm_get_usb_pcibase(node, inst))
60#define nlm_get_usb_regbase(node, inst) \
61 (nlm_get_usb_pcibase(node, inst) + XLP_IO_PCI_HDRSZ)
62
63#endif
64#endif /* __NLM_HAL_USB_H__ */
diff --git a/arch/mips/include/asm/netlogic/xlp-hal/xlp.h b/arch/mips/include/asm/netlogic/xlp-hal/xlp.h
index 1540588e396..7e47209327a 100644
--- a/arch/mips/include/asm/netlogic/xlp-hal/xlp.h
+++ b/arch/mips/include/asm/netlogic/xlp-hal/xlp.h
@@ -35,8 +35,21 @@
35#ifndef _NLM_HAL_XLP_H 35#ifndef _NLM_HAL_XLP_H
36#define _NLM_HAL_XLP_H 36#define _NLM_HAL_XLP_H
37 37
38#define PIC_UART_0_IRQ 17 38#define PIC_UART_0_IRQ 17
39#define PIC_UART_1_IRQ 18 39#define PIC_UART_1_IRQ 18
40#define PIC_PCIE_LINK_0_IRQ 19
41#define PIC_PCIE_LINK_1_IRQ 20
42#define PIC_PCIE_LINK_2_IRQ 21
43#define PIC_PCIE_LINK_3_IRQ 22
44#define PIC_EHCI_0_IRQ 23
45#define PIC_EHCI_1_IRQ 24
46#define PIC_OHCI_0_IRQ 25
47#define PIC_OHCI_1_IRQ 26
48#define PIC_OHCI_2_IRQ 27
49#define PIC_OHCI_3_IRQ 28
50#define PIC_MMC_IRQ 29
51#define PIC_I2C_0_IRQ 30
52#define PIC_I2C_1_IRQ 31
40 53
41#ifndef __ASSEMBLY__ 54#ifndef __ASSEMBLY__
42 55
diff --git a/arch/mips/include/asm/netlogic/xlr/bridge.h b/arch/mips/include/asm/netlogic/xlr/bridge.h
new file mode 100644
index 00000000000..2d02428c4f1
--- /dev/null
+++ b/arch/mips/include/asm/netlogic/xlr/bridge.h
@@ -0,0 +1,104 @@
1/*
2 * Copyright (c) 2003-2012 Broadcom Corporation
3 * All Rights Reserved
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the Broadcom
9 * license below:
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
20 * distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34#ifndef _ASM_NLM_BRIDGE_H_
35#define _ASM_NLM_BRIDGE_H_
36
37#define BRIDGE_DRAM_0_BAR 0
38#define BRIDGE_DRAM_1_BAR 1
39#define BRIDGE_DRAM_2_BAR 2
40#define BRIDGE_DRAM_3_BAR 3
41#define BRIDGE_DRAM_4_BAR 4
42#define BRIDGE_DRAM_5_BAR 5
43#define BRIDGE_DRAM_6_BAR 6
44#define BRIDGE_DRAM_7_BAR 7
45#define BRIDGE_DRAM_CHN_0_MTR_0_BAR 8
46#define BRIDGE_DRAM_CHN_0_MTR_1_BAR 9
47#define BRIDGE_DRAM_CHN_0_MTR_2_BAR 10
48#define BRIDGE_DRAM_CHN_0_MTR_3_BAR 11
49#define BRIDGE_DRAM_CHN_0_MTR_4_BAR 12
50#define BRIDGE_DRAM_CHN_0_MTR_5_BAR 13
51#define BRIDGE_DRAM_CHN_0_MTR_6_BAR 14
52#define BRIDGE_DRAM_CHN_0_MTR_7_BAR 15
53#define BRIDGE_DRAM_CHN_1_MTR_0_BAR 16
54#define BRIDGE_DRAM_CHN_1_MTR_1_BAR 17
55#define BRIDGE_DRAM_CHN_1_MTR_2_BAR 18
56#define BRIDGE_DRAM_CHN_1_MTR_3_BAR 19
57#define BRIDGE_DRAM_CHN_1_MTR_4_BAR 20
58#define BRIDGE_DRAM_CHN_1_MTR_5_BAR 21
59#define BRIDGE_DRAM_CHN_1_MTR_6_BAR 22
60#define BRIDGE_DRAM_CHN_1_MTR_7_BAR 23
61#define BRIDGE_CFG_BAR 24
62#define BRIDGE_PHNX_IO_BAR 25
63#define BRIDGE_FLASH_BAR 26
64#define BRIDGE_SRAM_BAR 27
65#define BRIDGE_HTMEM_BAR 28
66#define BRIDGE_HTINT_BAR 29
67#define BRIDGE_HTPIC_BAR 30
68#define BRIDGE_HTSM_BAR 31
69#define BRIDGE_HTIO_BAR 32
70#define BRIDGE_HTCFG_BAR 33
71#define BRIDGE_PCIXCFG_BAR 34
72#define BRIDGE_PCIXMEM_BAR 35
73#define BRIDGE_PCIXIO_BAR 36
74#define BRIDGE_DEVICE_MASK 37
75#define BRIDGE_AERR_INTR_LOG1 38
76#define BRIDGE_AERR_INTR_LOG2 39
77#define BRIDGE_AERR_INTR_LOG3 40
78#define BRIDGE_AERR_DEV_STAT 41
79#define BRIDGE_AERR1_LOG1 42
80#define BRIDGE_AERR1_LOG2 43
81#define BRIDGE_AERR1_LOG3 44
82#define BRIDGE_AERR1_DEV_STAT 45
83#define BRIDGE_AERR_INTR_EN 46
84#define BRIDGE_AERR_UPG 47
85#define BRIDGE_AERR_CLEAR 48
86#define BRIDGE_AERR1_CLEAR 49
87#define BRIDGE_SBE_COUNTS 50
88#define BRIDGE_DBE_COUNTS 51
89#define BRIDGE_BITERR_INT_EN 52
90
91#define BRIDGE_SYS2IO_CREDITS 53
92#define BRIDGE_EVNT_CNT_CTRL1 54
93#define BRIDGE_EVNT_COUNTER1 55
94#define BRIDGE_EVNT_CNT_CTRL2 56
95#define BRIDGE_EVNT_COUNTER2 57
96#define BRIDGE_RESERVED1 58
97
98#define BRIDGE_DEFEATURE 59
99#define BRIDGE_SCRATCH0 60
100#define BRIDGE_SCRATCH1 61
101#define BRIDGE_SCRATCH2 62
102#define BRIDGE_SCRATCH3 63
103
104#endif
diff --git a/arch/mips/include/asm/netlogic/xlr/flash.h b/arch/mips/include/asm/netlogic/xlr/flash.h
new file mode 100644
index 00000000000..f8aca5472b6
--- /dev/null
+++ b/arch/mips/include/asm/netlogic/xlr/flash.h
@@ -0,0 +1,55 @@
1/*
2 * Copyright (c) 2003-2012 Broadcom Corporation
3 * All Rights Reserved
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the Broadcom
9 * license below:
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
20 * distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34#ifndef _ASM_NLM_FLASH_H_
35#define _ASM_NLM_FLASH_H_
36
37#define FLASH_CSBASE_ADDR(cs) (cs)
38#define FLASH_CSADDR_MASK(cs) (0x10 + (cs))
39#define FLASH_CSDEV_PARM(cs) (0x20 + (cs))
40#define FLASH_CSTIME_PARMA(cs) (0x30 + (cs))
41#define FLASH_CSTIME_PARMB(cs) (0x40 + (cs))
42
43#define FLASH_INT_MASK 0x50
44#define FLASH_INT_STATUS 0x60
45#define FLASH_ERROR_STATUS 0x70
46#define FLASH_ERROR_ADDR 0x80
47
48#define FLASH_NAND_CLE(cs) (0x90 + (cs))
49#define FLASH_NAND_ALE(cs) (0xa0 + (cs))
50
51#define FLASH_NAND_CSDEV_PARAM 0x000041e6
52#define FLASH_NAND_CSTIME_PARAMA 0x4f400e22
53#define FLASH_NAND_CSTIME_PARAMB 0x000083cf
54
55#endif
diff --git a/arch/mips/include/asm/netlogic/xlr/gpio.h b/arch/mips/include/asm/netlogic/xlr/gpio.h
index 51f6ad4aeb1..8492e835b11 100644
--- a/arch/mips/include/asm/netlogic/xlr/gpio.h
+++ b/arch/mips/include/asm/netlogic/xlr/gpio.h
@@ -35,39 +35,40 @@
35#ifndef _ASM_NLM_GPIO_H 35#ifndef _ASM_NLM_GPIO_H
36#define _ASM_NLM_GPIO_H 36#define _ASM_NLM_GPIO_H
37 37
38#define NETLOGIC_GPIO_INT_EN_REG 0 38#define GPIO_INT_EN_REG 0
39#define NETLOGIC_GPIO_INPUT_INVERSION_REG 1 39#define GPIO_INPUT_INVERSION_REG 1
40#define NETLOGIC_GPIO_IO_DIR_REG 2 40#define GPIO_IO_DIR_REG 2
41#define NETLOGIC_GPIO_IO_DATA_WR_REG 3 41#define GPIO_IO_DATA_WR_REG 3
42#define NETLOGIC_GPIO_IO_DATA_RD_REG 4 42#define GPIO_IO_DATA_RD_REG 4
43 43
44#define NETLOGIC_GPIO_SWRESET_REG 8 44#define GPIO_SWRESET_REG 8
45#define NETLOGIC_GPIO_DRAM1_CNTRL_REG 9 45#define GPIO_DRAM1_CNTRL_REG 9
46#define NETLOGIC_GPIO_DRAM1_RATIO_REG 10 46#define GPIO_DRAM1_RATIO_REG 10
47#define NETLOGIC_GPIO_DRAM1_RESET_REG 11 47#define GPIO_DRAM1_RESET_REG 11
48#define NETLOGIC_GPIO_DRAM1_STATUS_REG 12 48#define GPIO_DRAM1_STATUS_REG 12
49#define NETLOGIC_GPIO_DRAM2_CNTRL_REG 13 49#define GPIO_DRAM2_CNTRL_REG 13
50#define NETLOGIC_GPIO_DRAM2_RATIO_REG 14 50#define GPIO_DRAM2_RATIO_REG 14
51#define NETLOGIC_GPIO_DRAM2_RESET_REG 15 51#define GPIO_DRAM2_RESET_REG 15
52#define NETLOGIC_GPIO_DRAM2_STATUS_REG 16 52#define GPIO_DRAM2_STATUS_REG 16
53 53
54#define NETLOGIC_GPIO_PWRON_RESET_CFG_REG 21 54#define GPIO_PWRON_RESET_CFG_REG 21
55#define NETLOGIC_GPIO_BIST_ALL_GO_STATUS_REG 24 55#define GPIO_BIST_ALL_GO_STATUS_REG 24
56#define NETLOGIC_GPIO_BIST_CPU_GO_STATUS_REG 25 56#define GPIO_BIST_CPU_GO_STATUS_REG 25
57#define NETLOGIC_GPIO_BIST_DEV_GO_STATUS_REG 26 57#define GPIO_BIST_DEV_GO_STATUS_REG 26
58 58
59#define NETLOGIC_GPIO_FUSE_BANK_REG 35 59#define GPIO_FUSE_BANK_REG 35
60#define NETLOGIC_GPIO_CPU_RESET_REG 40 60#define GPIO_CPU_RESET_REG 40
61#define NETLOGIC_GPIO_RNG_REG 43 61#define GPIO_RNG_REG 43
62 62
63#define NETLOGIC_PWRON_RESET_PCMCIA_BOOT 17 63#define PWRON_RESET_PCMCIA_BOOT 17
64#define NETLOGIC_GPIO_LED_BITMAP 0x1700000
65#define NETLOGIC_GPIO_LED_0_SHIFT 20
66#define NETLOGIC_GPIO_LED_1_SHIFT 24
67 64
68#define NETLOGIC_GPIO_LED_OUTPUT_CODE_RESET 0x01 65#define GPIO_LED_BITMAP 0x1700000
69#define NETLOGIC_GPIO_LED_OUTPUT_CODE_HARD_RESET 0x02 66#define GPIO_LED_0_SHIFT 20
70#define NETLOGIC_GPIO_LED_OUTPUT_CODE_SOFT_RESET 0x03 67#define GPIO_LED_1_SHIFT 24
71#define NETLOGIC_GPIO_LED_OUTPUT_CODE_MAIN 0x04 68
69#define GPIO_LED_OUTPUT_CODE_RESET 0x01
70#define GPIO_LED_OUTPUT_CODE_HARD_RESET 0x02
71#define GPIO_LED_OUTPUT_CODE_SOFT_RESET 0x03
72#define GPIO_LED_OUTPUT_CODE_MAIN 0x04
72 73
73#endif 74#endif
diff --git a/arch/mips/include/asm/octeon/cvmx-helper-fpa.h b/arch/mips/include/asm/octeon/cvmx-helper-fpa.h
deleted file mode 100644
index 5ff8c93198d..00000000000
--- a/arch/mips/include/asm/octeon/cvmx-helper-fpa.h
+++ /dev/null
@@ -1,64 +0,0 @@
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-2008 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/**
29 * @file
30 *
31 * Helper functions for FPA setup.
32 *
33 */
34#ifndef __CVMX_HELPER_H_FPA__
35#define __CVMX_HELPER_H_FPA__
36
37/**
38 * Allocate memory and initialize the FPA pools using memory
39 * from cvmx-bootmem. Sizes of each element in the pools is
40 * controlled by the cvmx-config.h header file. Specifying
41 * zero for any parameter will cause that FPA pool to not be
42 * setup. This is useful if you aren't using some of the
43 * hardware and want to save memory.
44 *
45 * @packet_buffers:
46 * Number of packet buffers to allocate
47 * @work_queue_entries:
48 * Number of work queue entries
49 * @pko_buffers:
50 * PKO Command buffers. You should at minimum have two per
51 * each PKO queue.
52 * @tim_buffers:
53 * TIM ring buffer command queues. At least two per timer bucket
54 * is recommened.
55 * @dfa_buffers:
56 * DFA command buffer. A relatively small (32 for example)
57 * number should work.
58 * Returns Zero on success, non-zero if out of memory
59 */
60extern int cvmx_helper_initialize_fpa(int packet_buffers,
61 int work_queue_entries, int pko_buffers,
62 int tim_buffers, int dfa_buffers);
63
64#endif /* __CVMX_HELPER_H__ */
diff --git a/arch/mips/include/asm/octeon/cvmx-helper.h b/arch/mips/include/asm/octeon/cvmx-helper.h
index 3169cd79f2a..0ac6b9f412b 100644
--- a/arch/mips/include/asm/octeon/cvmx-helper.h
+++ b/arch/mips/include/asm/octeon/cvmx-helper.h
@@ -61,8 +61,6 @@ typedef union {
61 } s; 61 } s;
62} cvmx_helper_link_info_t; 62} cvmx_helper_link_info_t;
63 63
64#include "cvmx-helper-fpa.h"
65
66#include <asm/octeon/cvmx-helper-errata.h> 64#include <asm/octeon/cvmx-helper-errata.h>
67#include "cvmx-helper-loop.h" 65#include "cvmx-helper-loop.h"
68#include "cvmx-helper-npi.h" 66#include "cvmx-helper-npi.h"
diff --git a/arch/mips/include/asm/octeon/octeon.h b/arch/mips/include/asm/octeon/octeon.h
index f72f768cd3a..1e2486e2357 100644
--- a/arch/mips/include/asm/octeon/octeon.h
+++ b/arch/mips/include/asm/octeon/octeon.h
@@ -215,11 +215,6 @@ struct octeon_cf_data {
215 int dma_engine; /* -1 for no DMA */ 215 int dma_engine; /* -1 for no DMA */
216}; 216};
217 217
218struct octeon_i2c_data {
219 unsigned int sys_freq;
220 unsigned int i2c_freq;
221};
222
223extern void octeon_write_lcd(const char *s); 218extern void octeon_write_lcd(const char *s);
224extern void octeon_check_cpu_bist(void); 219extern void octeon_check_cpu_bist(void);
225extern int octeon_get_boot_debug_flag(void); 220extern int octeon_get_boot_debug_flag(void);
diff --git a/arch/mips/include/asm/prom.h b/arch/mips/include/asm/prom.h
index 7206d445bab..8808bf548b9 100644
--- a/arch/mips/include/asm/prom.h
+++ b/arch/mips/include/asm/prom.h
@@ -20,9 +20,6 @@
20extern int early_init_dt_scan_memory_arch(unsigned long node, 20extern int early_init_dt_scan_memory_arch(unsigned long node,
21 const char *uname, int depth, void *data); 21 const char *uname, int depth, void *data);
22 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); 23extern void device_tree_init(void);
27 24
28static inline unsigned long pci_address_to_pio(phys_addr_t address) 25static inline unsigned long pci_address_to_pio(phys_addr_t address)
diff --git a/arch/mips/include/asm/r4k-timer.h b/arch/mips/include/asm/r4k-timer.h
index a37d12b3b61..afe9e0e03fe 100644
--- a/arch/mips/include/asm/r4k-timer.h
+++ b/arch/mips/include/asm/r4k-timer.h
@@ -12,16 +12,16 @@
12 12
13#ifdef CONFIG_SYNC_R4K 13#ifdef CONFIG_SYNC_R4K
14 14
15extern void synchronise_count_master(void); 15extern void synchronise_count_master(int cpu);
16extern void synchronise_count_slave(void); 16extern void synchronise_count_slave(int cpu);
17 17
18#else 18#else
19 19
20static inline void synchronise_count_master(void) 20static inline void synchronise_count_master(int cpu)
21{ 21{
22} 22}
23 23
24static inline void synchronise_count_slave(void) 24static inline void synchronise_count_slave(int cpu)
25{ 25{
26} 26}
27 27
diff --git a/arch/mips/include/asm/smtc.h b/arch/mips/include/asm/smtc.h
index c9736fc0632..8935426a56a 100644
--- a/arch/mips/include/asm/smtc.h
+++ b/arch/mips/include/asm/smtc.h
@@ -33,6 +33,12 @@ typedef long asiduse;
33#endif 33#endif
34#endif 34#endif
35 35
36/*
37 * VPE Management information
38 */
39
40#define MAX_SMTC_VPES MAX_SMTC_TLBS /* FIXME: May not always be true. */
41
36extern asiduse smtc_live_asid[MAX_SMTC_TLBS][MAX_SMTC_ASIDS]; 42extern asiduse smtc_live_asid[MAX_SMTC_TLBS][MAX_SMTC_ASIDS];
37 43
38struct mm_struct; 44struct mm_struct;
diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h
index 653a412c036..3b92efef56d 100644
--- a/arch/mips/include/asm/uaccess.h
+++ b/arch/mips/include/asm/uaccess.h
@@ -687,7 +687,7 @@ extern size_t __copy_user(void *__to, const void *__from, size_t __n);
687 __MODULE_JAL(__copy_user) \ 687 __MODULE_JAL(__copy_user) \
688 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \ 688 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \
689 : \ 689 : \
690 : "$8", "$9", "$10", "$11", "$12", "$15", "$24", "$31", \ 690 : "$8", "$9", "$10", "$11", "$12", "$14", "$15", "$24", "$31", \
691 DADDI_SCRATCH, "memory"); \ 691 DADDI_SCRATCH, "memory"); \
692 __cu_len_r; \ 692 __cu_len_r; \
693}) 693})
@@ -797,7 +797,7 @@ extern size_t __copy_user_inatomic(void *__to, const void *__from, size_t __n);
797 ".set\treorder" \ 797 ".set\treorder" \
798 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \ 798 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \
799 : \ 799 : \
800 : "$8", "$9", "$10", "$11", "$12", "$15", "$24", "$31", \ 800 : "$8", "$9", "$10", "$11", "$12", "$14", "$15", "$24", "$31", \
801 DADDI_SCRATCH, "memory"); \ 801 DADDI_SCRATCH, "memory"); \
802 __cu_len_r; \ 802 __cu_len_r; \
803}) 803})
@@ -820,7 +820,7 @@ extern size_t __copy_user_inatomic(void *__to, const void *__from, size_t __n);
820 ".set\treorder" \ 820 ".set\treorder" \
821 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \ 821 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \
822 : \ 822 : \
823 : "$8", "$9", "$10", "$11", "$12", "$15", "$24", "$31", \ 823 : "$8", "$9", "$10", "$11", "$12", "$14", "$15", "$24", "$31", \
824 DADDI_SCRATCH, "memory"); \ 824 DADDI_SCRATCH, "memory"); \
825 __cu_len_r; \ 825 __cu_len_r; \
826}) 826})
diff --git a/arch/mips/include/asm/uasm.h b/arch/mips/include/asm/uasm.h
index 440a21dab57..3d9f75f7ffc 100644
--- a/arch/mips/include/asm/uasm.h
+++ b/arch/mips/include/asm/uasm.h
@@ -6,6 +6,7 @@
6 * Copyright (C) 2004, 2005, 2006, 2008 Thiemo Seufer 6 * Copyright (C) 2004, 2005, 2006, 2008 Thiemo Seufer
7 * Copyright (C) 2005 Maciej W. Rozycki 7 * Copyright (C) 2005 Maciej W. Rozycki
8 * Copyright (C) 2006 Ralf Baechle (ralf@linux-mips.org) 8 * Copyright (C) 2006 Ralf Baechle (ralf@linux-mips.org)
9 * Copyright (C) 2012 MIPS Technologies, Inc.
9 */ 10 */
10 11
11#include <linux/types.h> 12#include <linux/types.h>
@@ -62,8 +63,10 @@ void __uasminit uasm_i##op(u32 **buf, unsigned int a, signed int b)
62 63
63Ip_u2u1s3(_addiu); 64Ip_u2u1s3(_addiu);
64Ip_u3u1u2(_addu); 65Ip_u3u1u2(_addu);
65Ip_u2u1u3(_andi);
66Ip_u3u1u2(_and); 66Ip_u3u1u2(_and);
67Ip_u2u1u3(_andi);
68Ip_u1u2s3(_bbit0);
69Ip_u1u2s3(_bbit1);
67Ip_u1u2s3(_beq); 70Ip_u1u2s3(_beq);
68Ip_u1u2s3(_beql); 71Ip_u1u2s3(_beql);
69Ip_u1s2(_bgez); 72Ip_u1s2(_bgez);
@@ -72,55 +75,54 @@ Ip_u1s2(_bltz);
72Ip_u1s2(_bltzl); 75Ip_u1s2(_bltzl);
73Ip_u1u2s3(_bne); 76Ip_u1u2s3(_bne);
74Ip_u2s3u1(_cache); 77Ip_u2s3u1(_cache);
75Ip_u1u2u3(_dmfc0);
76Ip_u1u2u3(_dmtc0);
77Ip_u2u1s3(_daddiu); 78Ip_u2u1s3(_daddiu);
78Ip_u3u1u2(_daddu); 79Ip_u3u1u2(_daddu);
80Ip_u2u1msbu3(_dins);
81Ip_u2u1msbu3(_dinsm);
82Ip_u1u2u3(_dmfc0);
83Ip_u1u2u3(_dmtc0);
84Ip_u2u1u3(_drotr);
85Ip_u2u1u3(_drotr32);
79Ip_u2u1u3(_dsll); 86Ip_u2u1u3(_dsll);
80Ip_u2u1u3(_dsll32); 87Ip_u2u1u3(_dsll32);
81Ip_u2u1u3(_dsra); 88Ip_u2u1u3(_dsra);
82Ip_u2u1u3(_dsrl); 89Ip_u2u1u3(_dsrl);
83Ip_u2u1u3(_dsrl32); 90Ip_u2u1u3(_dsrl32);
84Ip_u2u1u3(_drotr);
85Ip_u2u1u3(_drotr32);
86Ip_u3u1u2(_dsubu); 91Ip_u3u1u2(_dsubu);
87Ip_0(_eret); 92Ip_0(_eret);
88Ip_u1(_j); 93Ip_u1(_j);
89Ip_u1(_jal); 94Ip_u1(_jal);
90Ip_u1(_jr); 95Ip_u1(_jr);
91Ip_u2s3u1(_ld); 96Ip_u2s3u1(_ld);
97Ip_u3u1u2(_ldx);
92Ip_u2s3u1(_ll); 98Ip_u2s3u1(_ll);
93Ip_u2s3u1(_lld); 99Ip_u2s3u1(_lld);
94Ip_u1s2(_lui); 100Ip_u1s2(_lui);
95Ip_u2s3u1(_lw); 101Ip_u2s3u1(_lw);
102Ip_u3u1u2(_lwx);
96Ip_u1u2u3(_mfc0); 103Ip_u1u2u3(_mfc0);
97Ip_u1u2u3(_mtc0); 104Ip_u1u2u3(_mtc0);
98Ip_u2u1u3(_ori);
99Ip_u3u1u2(_or); 105Ip_u3u1u2(_or);
106Ip_u2u1u3(_ori);
100Ip_u2s3u1(_pref); 107Ip_u2s3u1(_pref);
101Ip_0(_rfe); 108Ip_0(_rfe);
109Ip_u2u1u3(_rotr);
102Ip_u2s3u1(_sc); 110Ip_u2s3u1(_sc);
103Ip_u2s3u1(_scd); 111Ip_u2s3u1(_scd);
104Ip_u2s3u1(_sd); 112Ip_u2s3u1(_sd);
105Ip_u2u1u3(_sll); 113Ip_u2u1u3(_sll);
106Ip_u2u1u3(_sra); 114Ip_u2u1u3(_sra);
107Ip_u2u1u3(_srl); 115Ip_u2u1u3(_srl);
108Ip_u2u1u3(_rotr);
109Ip_u3u1u2(_subu); 116Ip_u3u1u2(_subu);
110Ip_u2s3u1(_sw); 117Ip_u2s3u1(_sw);
118Ip_u1(_syscall);
111Ip_0(_tlbp); 119Ip_0(_tlbp);
112Ip_0(_tlbr); 120Ip_0(_tlbr);
113Ip_0(_tlbwi); 121Ip_0(_tlbwi);
114Ip_0(_tlbwr); 122Ip_0(_tlbwr);
115Ip_u3u1u2(_xor); 123Ip_u3u1u2(_xor);
116Ip_u2u1u3(_xori); 124Ip_u2u1u3(_xori);
117Ip_u2u1msbu3(_dins); 125
118Ip_u2u1msbu3(_dinsm);
119Ip_u1(_syscall);
120Ip_u1u2s3(_bbit0);
121Ip_u1u2s3(_bbit1);
122Ip_u3u1u2(_lwx);
123Ip_u3u1u2(_ldx);
124 126
125/* Handle labels. */ 127/* Handle labels. */
126struct uasm_label { 128struct uasm_label {
@@ -145,37 +147,37 @@ static inline void __uasminit uasm_l##lb(struct uasm_label **lab, u32 *addr) \
145 147
146/* convenience macros for instructions */ 148/* convenience macros for instructions */
147#ifdef CONFIG_64BIT 149#ifdef CONFIG_64BIT
150# define UASM_i_ADDIU(buf, rs, rt, val) uasm_i_daddiu(buf, rs, rt, val)
151# define UASM_i_ADDU(buf, rs, rt, rd) uasm_i_daddu(buf, rs, rt, rd)
152# define UASM_i_LL(buf, rs, rt, off) uasm_i_lld(buf, rs, rt, off)
148# define UASM_i_LW(buf, rs, rt, off) uasm_i_ld(buf, rs, rt, off) 153# define UASM_i_LW(buf, rs, rt, off) uasm_i_ld(buf, rs, rt, off)
149# define UASM_i_SW(buf, rs, rt, off) uasm_i_sd(buf, rs, rt, off) 154# define UASM_i_LWX(buf, rs, rt, rd) uasm_i_ldx(buf, rs, rt, rd)
155# define UASM_i_MFC0(buf, rt, rd...) uasm_i_dmfc0(buf, rt, rd)
156# define UASM_i_MTC0(buf, rt, rd...) uasm_i_dmtc0(buf, rt, rd)
157# define UASM_i_ROTR(buf, rs, rt, sh) uasm_i_drotr(buf, rs, rt, sh)
158# define UASM_i_SC(buf, rs, rt, off) uasm_i_scd(buf, rs, rt, off)
150# define UASM_i_SLL(buf, rs, rt, sh) uasm_i_dsll(buf, rs, rt, sh) 159# define UASM_i_SLL(buf, rs, rt, sh) uasm_i_dsll(buf, rs, rt, sh)
151# define UASM_i_SRA(buf, rs, rt, sh) uasm_i_dsra(buf, rs, rt, sh) 160# define UASM_i_SRA(buf, rs, rt, sh) uasm_i_dsra(buf, rs, rt, sh)
152# define UASM_i_SRL(buf, rs, rt, sh) uasm_i_dsrl(buf, rs, rt, sh) 161# define UASM_i_SRL(buf, rs, rt, sh) uasm_i_dsrl(buf, rs, rt, sh)
153# define UASM_i_SRL_SAFE(buf, rs, rt, sh) uasm_i_dsrl_safe(buf, rs, rt, sh) 162# define UASM_i_SRL_SAFE(buf, rs, rt, sh) uasm_i_dsrl_safe(buf, rs, rt, sh)
154# define UASM_i_ROTR(buf, rs, rt, sh) uasm_i_drotr(buf, rs, rt, sh)
155# define UASM_i_MFC0(buf, rt, rd...) uasm_i_dmfc0(buf, rt, rd)
156# define UASM_i_MTC0(buf, rt, rd...) uasm_i_dmtc0(buf, rt, rd)
157# define UASM_i_ADDIU(buf, rs, rt, val) uasm_i_daddiu(buf, rs, rt, val)
158# define UASM_i_ADDU(buf, rs, rt, rd) uasm_i_daddu(buf, rs, rt, rd)
159# define UASM_i_SUBU(buf, rs, rt, rd) uasm_i_dsubu(buf, rs, rt, rd) 163# define UASM_i_SUBU(buf, rs, rt, rd) uasm_i_dsubu(buf, rs, rt, rd)
160# define UASM_i_LL(buf, rs, rt, off) uasm_i_lld(buf, rs, rt, off) 164# define UASM_i_SW(buf, rs, rt, off) uasm_i_sd(buf, rs, rt, off)
161# define UASM_i_SC(buf, rs, rt, off) uasm_i_scd(buf, rs, rt, off)
162# define UASM_i_LWX(buf, rs, rt, rd) uasm_i_ldx(buf, rs, rt, rd)
163#else 165#else
166# define UASM_i_ADDIU(buf, rs, rt, val) uasm_i_addiu(buf, rs, rt, val)
167# define UASM_i_ADDU(buf, rs, rt, rd) uasm_i_addu(buf, rs, rt, rd)
168# define UASM_i_LL(buf, rs, rt, off) uasm_i_ll(buf, rs, rt, off)
164# define UASM_i_LW(buf, rs, rt, off) uasm_i_lw(buf, rs, rt, off) 169# define UASM_i_LW(buf, rs, rt, off) uasm_i_lw(buf, rs, rt, off)
165# define UASM_i_SW(buf, rs, rt, off) uasm_i_sw(buf, rs, rt, off) 170# define UASM_i_LWX(buf, rs, rt, rd) uasm_i_lwx(buf, rs, rt, rd)
171# define UASM_i_MFC0(buf, rt, rd...) uasm_i_mfc0(buf, rt, rd)
172# define UASM_i_MTC0(buf, rt, rd...) uasm_i_mtc0(buf, rt, rd)
173# define UASM_i_ROTR(buf, rs, rt, sh) uasm_i_rotr(buf, rs, rt, sh)
174# define UASM_i_SC(buf, rs, rt, off) uasm_i_sc(buf, rs, rt, off)
166# define UASM_i_SLL(buf, rs, rt, sh) uasm_i_sll(buf, rs, rt, sh) 175# define UASM_i_SLL(buf, rs, rt, sh) uasm_i_sll(buf, rs, rt, sh)
167# define UASM_i_SRA(buf, rs, rt, sh) uasm_i_sra(buf, rs, rt, sh) 176# define UASM_i_SRA(buf, rs, rt, sh) uasm_i_sra(buf, rs, rt, sh)
168# define UASM_i_SRL(buf, rs, rt, sh) uasm_i_srl(buf, rs, rt, sh) 177# define UASM_i_SRL(buf, rs, rt, sh) uasm_i_srl(buf, rs, rt, sh)
169# define UASM_i_SRL_SAFE(buf, rs, rt, sh) uasm_i_srl(buf, rs, rt, sh) 178# define UASM_i_SRL_SAFE(buf, rs, rt, sh) uasm_i_srl(buf, rs, rt, sh)
170# define UASM_i_ROTR(buf, rs, rt, sh) uasm_i_rotr(buf, rs, rt, sh)
171# define UASM_i_MFC0(buf, rt, rd...) uasm_i_mfc0(buf, rt, rd)
172# define UASM_i_MTC0(buf, rt, rd...) uasm_i_mtc0(buf, rt, rd)
173# define UASM_i_ADDIU(buf, rs, rt, val) uasm_i_addiu(buf, rs, rt, val)
174# define UASM_i_ADDU(buf, rs, rt, rd) uasm_i_addu(buf, rs, rt, rd)
175# define UASM_i_SUBU(buf, rs, rt, rd) uasm_i_subu(buf, rs, rt, rd) 179# define UASM_i_SUBU(buf, rs, rt, rd) uasm_i_subu(buf, rs, rt, rd)
176# define UASM_i_LL(buf, rs, rt, off) uasm_i_ll(buf, rs, rt, off) 180# define UASM_i_SW(buf, rs, rt, off) uasm_i_sw(buf, rs, rt, off)
177# define UASM_i_SC(buf, rs, rt, off) uasm_i_sc(buf, rs, rt, off)
178# define UASM_i_LWX(buf, rs, rt, rd) uasm_i_lwx(buf, rs, rt, rd)
179#endif 181#endif
180 182
181#define uasm_i_b(buf, off) uasm_i_beq(buf, 0, 0, off) 183#define uasm_i_b(buf, off) uasm_i_beq(buf, 0, 0, off)
@@ -183,19 +185,10 @@ static inline void __uasminit uasm_l##lb(struct uasm_label **lab, u32 *addr) \
183#define uasm_i_beqzl(buf, rs, off) uasm_i_beql(buf, rs, 0, off) 185#define uasm_i_beqzl(buf, rs, off) uasm_i_beql(buf, rs, 0, off)
184#define uasm_i_bnez(buf, rs, off) uasm_i_bne(buf, rs, 0, off) 186#define uasm_i_bnez(buf, rs, off) uasm_i_bne(buf, rs, 0, off)
185#define uasm_i_bnezl(buf, rs, off) uasm_i_bnel(buf, rs, 0, off) 187#define uasm_i_bnezl(buf, rs, off) uasm_i_bnel(buf, rs, 0, off)
188#define uasm_i_ehb(buf) uasm_i_sll(buf, 0, 0, 3)
186#define uasm_i_move(buf, a, b) UASM_i_ADDU(buf, a, 0, b) 189#define uasm_i_move(buf, a, b) UASM_i_ADDU(buf, a, 0, b)
187#define uasm_i_nop(buf) uasm_i_sll(buf, 0, 0, 0) 190#define uasm_i_nop(buf) uasm_i_sll(buf, 0, 0, 0)
188#define uasm_i_ssnop(buf) uasm_i_sll(buf, 0, 0, 1) 191#define uasm_i_ssnop(buf) uasm_i_sll(buf, 0, 0, 1)
189#define uasm_i_ehb(buf) uasm_i_sll(buf, 0, 0, 3)
190
191static inline void uasm_i_dsrl_safe(u32 **p, unsigned int a1,
192 unsigned int a2, unsigned int a3)
193{
194 if (a3 < 32)
195 uasm_i_dsrl(p, a1, a2, a3);
196 else
197 uasm_i_dsrl32(p, a1, a2, a3 - 32);
198}
199 192
200static inline void uasm_i_drotr_safe(u32 **p, unsigned int a1, 193static inline void uasm_i_drotr_safe(u32 **p, unsigned int a1,
201 unsigned int a2, unsigned int a3) 194 unsigned int a2, unsigned int a3)
@@ -215,6 +208,15 @@ static inline void uasm_i_dsll_safe(u32 **p, unsigned int a1,
215 uasm_i_dsll32(p, a1, a2, a3 - 32); 208 uasm_i_dsll32(p, a1, a2, a3 - 32);
216} 209}
217 210
211static inline void uasm_i_dsrl_safe(u32 **p, unsigned int a1,
212 unsigned int a2, unsigned int a3)
213{
214 if (a3 < 32)
215 uasm_i_dsrl(p, a1, a2, a3);
216 else
217 uasm_i_dsrl32(p, a1, a2, a3 - 32);
218}
219
218/* Handle relocations. */ 220/* Handle relocations. */
219struct uasm_reloc { 221struct uasm_reloc {
220 u32 *addr; 222 u32 *addr;
@@ -234,16 +236,16 @@ void uasm_copy_handler(struct uasm_reloc *rel, struct uasm_label *lab,
234int uasm_insn_has_bdelay(struct uasm_reloc *rel, u32 *addr); 236int uasm_insn_has_bdelay(struct uasm_reloc *rel, u32 *addr);
235 237
236/* Convenience functions for labeled branches. */ 238/* Convenience functions for labeled branches. */
237void uasm_il_bltz(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
238void uasm_il_b(u32 **p, struct uasm_reloc **r, int lid); 239void uasm_il_b(u32 **p, struct uasm_reloc **r, int lid);
240void uasm_il_bbit0(u32 **p, struct uasm_reloc **r, unsigned int reg,
241 unsigned int bit, int lid);
242void uasm_il_bbit1(u32 **p, struct uasm_reloc **r, unsigned int reg,
243 unsigned int bit, int lid);
239void uasm_il_beqz(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid); 244void uasm_il_beqz(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
240void uasm_il_beqzl(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid); 245void uasm_il_beqzl(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
246void uasm_il_bgezl(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
247void uasm_il_bgez(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
248void uasm_il_bltz(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
241void uasm_il_bne(u32 **p, struct uasm_reloc **r, unsigned int reg1, 249void uasm_il_bne(u32 **p, struct uasm_reloc **r, unsigned int reg1,
242 unsigned int reg2, int lid); 250 unsigned int reg2, int lid);
243void uasm_il_bnez(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid); 251void uasm_il_bnez(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
244void uasm_il_bgezl(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
245void uasm_il_bgez(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
246void uasm_il_bbit0(u32 **p, struct uasm_reloc **r, unsigned int reg,
247 unsigned int bit, int lid);
248void uasm_il_bbit1(u32 **p, struct uasm_reloc **r, unsigned int reg,
249 unsigned int bit, int lid);
diff --git a/arch/mips/include/asm/unistd.h b/arch/mips/include/asm/unistd.h
index d8dad5340ea..bebbde01be9 100644
--- a/arch/mips/include/asm/unistd.h
+++ b/arch/mips/include/asm/unistd.h
@@ -1034,7 +1034,6 @@
1034#ifndef __ASSEMBLY__ 1034#ifndef __ASSEMBLY__
1035 1035
1036#define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 1036#define __ARCH_OMIT_COMPAT_SYS_GETDENTS64
1037#define __ARCH_WANT_IPC_PARSE_VERSION
1038#define __ARCH_WANT_OLD_READDIR 1037#define __ARCH_WANT_OLD_READDIR
1039#define __ARCH_WANT_SYS_ALARM 1038#define __ARCH_WANT_SYS_ALARM
1040#define __ARCH_WANT_SYS_GETHOSTNAME 1039#define __ARCH_WANT_SYS_GETHOSTNAME
diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c
index 9a91fe9de69..9a3d9de4d04 100644
--- a/arch/mips/jz4740/board-qi_lb60.c
+++ b/arch/mips/jz4740/board-qi_lb60.c
@@ -140,6 +140,7 @@ static void qi_lb60_nand_ident(struct platform_device *pdev,
140static struct jz_nand_platform_data qi_lb60_nand_pdata = { 140static struct jz_nand_platform_data qi_lb60_nand_pdata = {
141 .ident_callback = qi_lb60_nand_ident, 141 .ident_callback = qi_lb60_nand_ident,
142 .busy_gpio = 94, 142 .busy_gpio = 94,
143 .banks = { 1 },
143}; 144};
144 145
145/* Keyboard*/ 146/* Keyboard*/
diff --git a/arch/mips/jz4740/platform.c b/arch/mips/jz4740/platform.c
index 10929e2bc6d..e342ed4cbd4 100644
--- a/arch/mips/jz4740/platform.c
+++ b/arch/mips/jz4740/platform.c
@@ -157,11 +157,29 @@ static struct resource jz4740_nand_resources[] = {
157 .flags = IORESOURCE_MEM, 157 .flags = IORESOURCE_MEM,
158 }, 158 },
159 { 159 {
160 .name = "bank", 160 .name = "bank1",
161 .start = 0x18000000, 161 .start = 0x18000000,
162 .end = 0x180C0000 - 1, 162 .end = 0x180C0000 - 1,
163 .flags = IORESOURCE_MEM, 163 .flags = IORESOURCE_MEM,
164 }, 164 },
165 {
166 .name = "bank2",
167 .start = 0x14000000,
168 .end = 0x140C0000 - 1,
169 .flags = IORESOURCE_MEM,
170 },
171 {
172 .name = "bank3",
173 .start = 0x0C000000,
174 .end = 0x0C0C0000 - 1,
175 .flags = IORESOURCE_MEM,
176 },
177 {
178 .name = "bank4",
179 .start = 0x08000000,
180 .end = 0x080C0000 - 1,
181 .flags = IORESOURCE_MEM,
182 },
165}; 183};
166 184
167struct platform_device jz4740_nand_device = { 185struct platform_device jz4740_nand_device = {
diff --git a/arch/mips/jz4740/reset.c b/arch/mips/jz4740/reset.c
index 5f1fb95c0d0..6c0da5afcf1 100644
--- a/arch/mips/jz4740/reset.c
+++ b/arch/mips/jz4740/reset.c
@@ -21,6 +21,9 @@
21#include <asm/mach-jz4740/base.h> 21#include <asm/mach-jz4740/base.h>
22#include <asm/mach-jz4740/timer.h> 22#include <asm/mach-jz4740/timer.h>
23 23
24#include "reset.h"
25#include "clock.h"
26
24static void jz4740_halt(void) 27static void jz4740_halt(void)
25{ 28{
26 while (1) { 29 while (1) {
@@ -53,21 +56,57 @@ static void jz4740_restart(char *command)
53 jz4740_halt(); 56 jz4740_halt();
54} 57}
55 58
56#define JZ_REG_RTC_CTRL 0x00 59#define JZ_REG_RTC_CTRL 0x00
57#define JZ_REG_RTC_HIBERNATE 0x20 60#define JZ_REG_RTC_HIBERNATE 0x20
61#define JZ_REG_RTC_WAKEUP_FILTER 0x24
62#define JZ_REG_RTC_RESET_COUNTER 0x28
58 63
59#define JZ_RTC_CTRL_WRDY BIT(7) 64#define JZ_RTC_CTRL_WRDY BIT(7)
65#define JZ_RTC_WAKEUP_FILTER_MASK 0x0000FFE0
66#define JZ_RTC_RESET_COUNTER_MASK 0x00000FE0
60 67
61static void jz4740_power_off(void) 68static inline void jz4740_rtc_wait_ready(void __iomem *rtc_base)
62{ 69{
63 void __iomem *rtc_base = ioremap(JZ4740_RTC_BASE_ADDR, 0x24);
64 uint32_t ctrl; 70 uint32_t ctrl;
65 71
66 do { 72 do {
67 ctrl = readl(rtc_base + JZ_REG_RTC_CTRL); 73 ctrl = readl(rtc_base + JZ_REG_RTC_CTRL);
68 } while (!(ctrl & JZ_RTC_CTRL_WRDY)); 74 } while (!(ctrl & JZ_RTC_CTRL_WRDY));
75}
69 76
77static void jz4740_power_off(void)
78{
79 void __iomem *rtc_base = ioremap(JZ4740_RTC_BASE_ADDR, 0x38);
80 unsigned long wakeup_filter_ticks;
81 unsigned long reset_counter_ticks;
82
83 /*
84 * Set minimum wakeup pin assertion time: 100 ms.
85 * Range is 0 to 2 sec if RTC is clocked at 32 kHz.
86 */
87 wakeup_filter_ticks = (100 * jz4740_clock_bdata.rtc_rate) / 1000;
88 if (wakeup_filter_ticks < JZ_RTC_WAKEUP_FILTER_MASK)
89 wakeup_filter_ticks &= JZ_RTC_WAKEUP_FILTER_MASK;
90 else
91 wakeup_filter_ticks = JZ_RTC_WAKEUP_FILTER_MASK;
92 jz4740_rtc_wait_ready(rtc_base);
93 writel(wakeup_filter_ticks, rtc_base + JZ_REG_RTC_WAKEUP_FILTER);
94
95 /*
96 * Set reset pin low-level assertion time after wakeup: 60 ms.
97 * Range is 0 to 125 ms if RTC is clocked at 32 kHz.
98 */
99 reset_counter_ticks = (60 * jz4740_clock_bdata.rtc_rate) / 1000;
100 if (reset_counter_ticks < JZ_RTC_RESET_COUNTER_MASK)
101 reset_counter_ticks &= JZ_RTC_RESET_COUNTER_MASK;
102 else
103 reset_counter_ticks = JZ_RTC_RESET_COUNTER_MASK;
104 jz4740_rtc_wait_ready(rtc_base);
105 writel(reset_counter_ticks, rtc_base + JZ_REG_RTC_RESET_COUNTER);
106
107 jz4740_rtc_wait_ready(rtc_base);
70 writel(1, rtc_base + JZ_REG_RTC_HIBERNATE); 108 writel(1, rtc_base + JZ_REG_RTC_HIBERNATE);
109
71 jz4740_halt(); 110 jz4740_halt();
72} 111}
73 112
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index f4630e1082a..1b51046191e 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -190,6 +190,7 @@ void __init check_wait(void)
190 case CPU_CAVIUM_OCTEON_PLUS: 190 case CPU_CAVIUM_OCTEON_PLUS:
191 case CPU_CAVIUM_OCTEON2: 191 case CPU_CAVIUM_OCTEON2:
192 case CPU_JZRISC: 192 case CPU_JZRISC:
193 case CPU_LOONGSON1:
193 case CPU_XLR: 194 case CPU_XLR:
194 case CPU_XLP: 195 case CPU_XLP:
195 cpu_wait = r4k_wait; 196 cpu_wait = r4k_wait;
@@ -330,6 +331,154 @@ static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
330#endif 331#endif
331} 332}
332 333
334static char unknown_isa[] __cpuinitdata = KERN_ERR \
335 "Unsupported ISA type, c0.config0: %d.";
336
337static inline unsigned int decode_config0(struct cpuinfo_mips *c)
338{
339 unsigned int config0;
340 int isa;
341
342 config0 = read_c0_config();
343
344 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
345 c->options |= MIPS_CPU_TLB;
346 isa = (config0 & MIPS_CONF_AT) >> 13;
347 switch (isa) {
348 case 0:
349 switch ((config0 & MIPS_CONF_AR) >> 10) {
350 case 0:
351 c->isa_level = MIPS_CPU_ISA_M32R1;
352 break;
353 case 1:
354 c->isa_level = MIPS_CPU_ISA_M32R2;
355 break;
356 default:
357 goto unknown;
358 }
359 break;
360 case 2:
361 switch ((config0 & MIPS_CONF_AR) >> 10) {
362 case 0:
363 c->isa_level = MIPS_CPU_ISA_M64R1;
364 break;
365 case 1:
366 c->isa_level = MIPS_CPU_ISA_M64R2;
367 break;
368 default:
369 goto unknown;
370 }
371 break;
372 default:
373 goto unknown;
374 }
375
376 return config0 & MIPS_CONF_M;
377
378unknown:
379 panic(unknown_isa, config0);
380}
381
382static inline unsigned int decode_config1(struct cpuinfo_mips *c)
383{
384 unsigned int config1;
385
386 config1 = read_c0_config1();
387
388 if (config1 & MIPS_CONF1_MD)
389 c->ases |= MIPS_ASE_MDMX;
390 if (config1 & MIPS_CONF1_WR)
391 c->options |= MIPS_CPU_WATCH;
392 if (config1 & MIPS_CONF1_CA)
393 c->ases |= MIPS_ASE_MIPS16;
394 if (config1 & MIPS_CONF1_EP)
395 c->options |= MIPS_CPU_EJTAG;
396 if (config1 & MIPS_CONF1_FP) {
397 c->options |= MIPS_CPU_FPU;
398 c->options |= MIPS_CPU_32FPR;
399 }
400 if (cpu_has_tlb)
401 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
402
403 return config1 & MIPS_CONF_M;
404}
405
406static inline unsigned int decode_config2(struct cpuinfo_mips *c)
407{
408 unsigned int config2;
409
410 config2 = read_c0_config2();
411
412 if (config2 & MIPS_CONF2_SL)
413 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
414
415 return config2 & MIPS_CONF_M;
416}
417
418static inline unsigned int decode_config3(struct cpuinfo_mips *c)
419{
420 unsigned int config3;
421
422 config3 = read_c0_config3();
423
424 if (config3 & MIPS_CONF3_SM)
425 c->ases |= MIPS_ASE_SMARTMIPS;
426 if (config3 & MIPS_CONF3_DSP)
427 c->ases |= MIPS_ASE_DSP;
428 if (config3 & MIPS_CONF3_VINT)
429 c->options |= MIPS_CPU_VINT;
430 if (config3 & MIPS_CONF3_VEIC)
431 c->options |= MIPS_CPU_VEIC;
432 if (config3 & MIPS_CONF3_MT)
433 c->ases |= MIPS_ASE_MIPSMT;
434 if (config3 & MIPS_CONF3_ULRI)
435 c->options |= MIPS_CPU_ULRI;
436
437 return config3 & MIPS_CONF_M;
438}
439
440static inline unsigned int decode_config4(struct cpuinfo_mips *c)
441{
442 unsigned int config4;
443
444 config4 = read_c0_config4();
445
446 if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
447 && cpu_has_tlb)
448 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
449
450 c->kscratch_mask = (config4 >> 16) & 0xff;
451
452 return config4 & MIPS_CONF_M;
453}
454
455static void __cpuinit decode_configs(struct cpuinfo_mips *c)
456{
457 int ok;
458
459 /* MIPS32 or MIPS64 compliant CPU. */
460 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
461 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
462
463 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
464
465 ok = decode_config0(c); /* Read Config registers. */
466 BUG_ON(!ok); /* Arch spec violation! */
467 if (ok)
468 ok = decode_config1(c);
469 if (ok)
470 ok = decode_config2(c);
471 if (ok)
472 ok = decode_config3(c);
473 if (ok)
474 ok = decode_config4(c);
475
476 mips_probe_watch_registers(c);
477
478 if (cpu_has_mips_r2)
479 c->core = read_c0_ebase() & 0x3ff;
480}
481
333#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \ 482#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
334 | MIPS_CPU_COUNTER) 483 | MIPS_CPU_COUNTER)
335 484
@@ -638,155 +787,19 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
638 MIPS_CPU_32FPR; 787 MIPS_CPU_32FPR;
639 c->tlbsize = 64; 788 c->tlbsize = 64;
640 break; 789 break;
641 } 790 case PRID_IMP_LOONGSON1:
642} 791 decode_configs(c);
643
644static char unknown_isa[] __cpuinitdata = KERN_ERR \
645 "Unsupported ISA type, c0.config0: %d.";
646 792
647static inline unsigned int decode_config0(struct cpuinfo_mips *c) 793 c->cputype = CPU_LOONGSON1;
648{
649 unsigned int config0;
650 int isa;
651 794
652 config0 = read_c0_config(); 795 switch (c->processor_id & PRID_REV_MASK) {
653 796 case PRID_REV_LOONGSON1B:
654 if (((config0 & MIPS_CONF_MT) >> 7) == 1) 797 __cpu_name[cpu] = "Loongson 1B";
655 c->options |= MIPS_CPU_TLB;
656 isa = (config0 & MIPS_CONF_AT) >> 13;
657 switch (isa) {
658 case 0:
659 switch ((config0 & MIPS_CONF_AR) >> 10) {
660 case 0:
661 c->isa_level = MIPS_CPU_ISA_M32R1;
662 break;
663 case 1:
664 c->isa_level = MIPS_CPU_ISA_M32R2;
665 break; 798 break;
666 default:
667 goto unknown;
668 } 799 }
669 break;
670 case 2:
671 switch ((config0 & MIPS_CONF_AR) >> 10) {
672 case 0:
673 c->isa_level = MIPS_CPU_ISA_M64R1;
674 break;
675 case 1:
676 c->isa_level = MIPS_CPU_ISA_M64R2;
677 break;
678 default:
679 goto unknown;
680 }
681 break;
682 default:
683 goto unknown;
684 }
685
686 return config0 & MIPS_CONF_M;
687
688unknown:
689 panic(unknown_isa, config0);
690}
691 800
692static inline unsigned int decode_config1(struct cpuinfo_mips *c) 801 break;
693{
694 unsigned int config1;
695
696 config1 = read_c0_config1();
697
698 if (config1 & MIPS_CONF1_MD)
699 c->ases |= MIPS_ASE_MDMX;
700 if (config1 & MIPS_CONF1_WR)
701 c->options |= MIPS_CPU_WATCH;
702 if (config1 & MIPS_CONF1_CA)
703 c->ases |= MIPS_ASE_MIPS16;
704 if (config1 & MIPS_CONF1_EP)
705 c->options |= MIPS_CPU_EJTAG;
706 if (config1 & MIPS_CONF1_FP) {
707 c->options |= MIPS_CPU_FPU;
708 c->options |= MIPS_CPU_32FPR;
709 } 802 }
710 if (cpu_has_tlb)
711 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
712
713 return config1 & MIPS_CONF_M;
714}
715
716static inline unsigned int decode_config2(struct cpuinfo_mips *c)
717{
718 unsigned int config2;
719
720 config2 = read_c0_config2();
721
722 if (config2 & MIPS_CONF2_SL)
723 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
724
725 return config2 & MIPS_CONF_M;
726}
727
728static inline unsigned int decode_config3(struct cpuinfo_mips *c)
729{
730 unsigned int config3;
731
732 config3 = read_c0_config3();
733
734 if (config3 & MIPS_CONF3_SM)
735 c->ases |= MIPS_ASE_SMARTMIPS;
736 if (config3 & MIPS_CONF3_DSP)
737 c->ases |= MIPS_ASE_DSP;
738 if (config3 & MIPS_CONF3_VINT)
739 c->options |= MIPS_CPU_VINT;
740 if (config3 & MIPS_CONF3_VEIC)
741 c->options |= MIPS_CPU_VEIC;
742 if (config3 & MIPS_CONF3_MT)
743 c->ases |= MIPS_ASE_MIPSMT;
744 if (config3 & MIPS_CONF3_ULRI)
745 c->options |= MIPS_CPU_ULRI;
746
747 return config3 & MIPS_CONF_M;
748}
749
750static inline unsigned int decode_config4(struct cpuinfo_mips *c)
751{
752 unsigned int config4;
753
754 config4 = read_c0_config4();
755
756 if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
757 && cpu_has_tlb)
758 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
759
760 c->kscratch_mask = (config4 >> 16) & 0xff;
761
762 return config4 & MIPS_CONF_M;
763}
764
765static void __cpuinit decode_configs(struct cpuinfo_mips *c)
766{
767 int ok;
768
769 /* MIPS32 or MIPS64 compliant CPU. */
770 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
771 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
772
773 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
774
775 ok = decode_config0(c); /* Read Config registers. */
776 BUG_ON(!ok); /* Arch spec violation! */
777 if (ok)
778 ok = decode_config1(c);
779 if (ok)
780 ok = decode_config2(c);
781 if (ok)
782 ok = decode_config3(c);
783 if (ok)
784 ok = decode_config4(c);
785
786 mips_probe_watch_registers(c);
787
788 if (cpu_has_mips_r2)
789 c->core = read_c0_ebase() & 0x3ff;
790} 803}
791 804
792static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu) 805static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
diff --git a/arch/mips/kernel/cpufreq/Makefile b/arch/mips/kernel/cpufreq/Makefile
index c3479a432ef..05a5715ee38 100644
--- a/arch/mips/kernel/cpufreq/Makefile
+++ b/arch/mips/kernel/cpufreq/Makefile
@@ -2,4 +2,4 @@
2# Makefile for the Linux/MIPS cpufreq. 2# Makefile for the Linux/MIPS cpufreq.
3# 3#
4 4
5obj-$(CONFIG_LOONGSON2_CPUFREQ) += loongson2_cpufreq.o loongson2_clock.o 5obj-$(CONFIG_LOONGSON2_CPUFREQ) += loongson2_cpufreq.o
diff --git a/arch/mips/kernel/cpufreq/loongson2_cpufreq.c b/arch/mips/kernel/cpufreq/loongson2_cpufreq.c
index ae5db206347..e7c98e2b78b 100644
--- a/arch/mips/kernel/cpufreq/loongson2_cpufreq.c
+++ b/arch/mips/kernel/cpufreq/loongson2_cpufreq.c
@@ -19,7 +19,7 @@
19 19
20#include <asm/clock.h> 20#include <asm/clock.h>
21 21
22#include <loongson.h> 22#include <asm/mach-loongson/loongson.h>
23 23
24static uint nowait; 24static uint nowait;
25 25
@@ -181,6 +181,25 @@ static struct platform_driver platform_driver = {
181 .id_table = platform_device_ids, 181 .id_table = platform_device_ids,
182}; 182};
183 183
184/*
185 * This is the simple version of Loongson-2 wait, Maybe we need do this in
186 * interrupt disabled context.
187 */
188
189static DEFINE_SPINLOCK(loongson2_wait_lock);
190
191static void loongson2_cpu_wait(void)
192{
193 unsigned long flags;
194 u32 cpu_freq;
195
196 spin_lock_irqsave(&loongson2_wait_lock, flags);
197 cpu_freq = LOONGSON_CHIPCFG0;
198 LOONGSON_CHIPCFG0 &= ~0x7; /* Put CPU into wait mode */
199 LOONGSON_CHIPCFG0 = cpu_freq; /* Restore CPU state */
200 spin_unlock_irqrestore(&loongson2_wait_lock, flags);
201}
202
184static int __init cpufreq_init(void) 203static int __init cpufreq_init(void)
185{ 204{
186 int ret; 205 int ret;
diff --git a/arch/mips/kernel/kspd.c b/arch/mips/kernel/kspd.c
index 84d0639e458..b77f56bbb47 100644
--- a/arch/mips/kernel/kspd.c
+++ b/arch/mips/kernel/kspd.c
@@ -323,7 +323,7 @@ static void sp_cleanup(void)
323 fdt = files_fdtable(files); 323 fdt = files_fdtable(files);
324 for (;;) { 324 for (;;) {
325 unsigned long set; 325 unsigned long set;
326 i = j * __NFDBITS; 326 i = j * BITS_PER_LONG;
327 if (i >= fdt->max_fds) 327 if (i >= fdt->max_fds)
328 break; 328 break;
329 set = fdt->open_fds[j++]; 329 set = fdt->open_fds[j++];
diff --git a/arch/mips/kernel/module.c b/arch/mips/kernel/module.c
index a5066b1c3de..4f8c3cba8c0 100644
--- a/arch/mips/kernel/module.c
+++ b/arch/mips/kernel/module.c
@@ -39,8 +39,6 @@ struct mips_hi16 {
39 Elf_Addr value; 39 Elf_Addr value;
40}; 40};
41 41
42static struct mips_hi16 *mips_hi16_list;
43
44static LIST_HEAD(dbe_list); 42static LIST_HEAD(dbe_list);
45static DEFINE_SPINLOCK(dbe_lock); 43static DEFINE_SPINLOCK(dbe_lock);
46 44
@@ -128,8 +126,8 @@ static int apply_r_mips_hi16_rel(struct module *me, u32 *location, Elf_Addr v)
128 126
129 n->addr = (Elf_Addr *)location; 127 n->addr = (Elf_Addr *)location;
130 n->value = v; 128 n->value = v;
131 n->next = mips_hi16_list; 129 n->next = me->arch.r_mips_hi16_list;
132 mips_hi16_list = n; 130 me->arch.r_mips_hi16_list = n;
133 131
134 return 0; 132 return 0;
135} 133}
@@ -142,18 +140,28 @@ static int apply_r_mips_hi16_rela(struct module *me, u32 *location, Elf_Addr v)
142 return 0; 140 return 0;
143} 141}
144 142
143static void free_relocation_chain(struct mips_hi16 *l)
144{
145 struct mips_hi16 *next;
146
147 while (l) {
148 next = l->next;
149 kfree(l);
150 l = next;
151 }
152}
153
145static int apply_r_mips_lo16_rel(struct module *me, u32 *location, Elf_Addr v) 154static int apply_r_mips_lo16_rel(struct module *me, u32 *location, Elf_Addr v)
146{ 155{
147 unsigned long insnlo = *location; 156 unsigned long insnlo = *location;
157 struct mips_hi16 *l;
148 Elf_Addr val, vallo; 158 Elf_Addr val, vallo;
149 159
150 /* Sign extend the addend we extract from the lo insn. */ 160 /* Sign extend the addend we extract from the lo insn. */
151 vallo = ((insnlo & 0xffff) ^ 0x8000) - 0x8000; 161 vallo = ((insnlo & 0xffff) ^ 0x8000) - 0x8000;
152 162
153 if (mips_hi16_list != NULL) { 163 if (me->arch.r_mips_hi16_list != NULL) {
154 struct mips_hi16 *l; 164 l = me->arch.r_mips_hi16_list;
155
156 l = mips_hi16_list;
157 while (l != NULL) { 165 while (l != NULL) {
158 struct mips_hi16 *next; 166 struct mips_hi16 *next;
159 unsigned long insn; 167 unsigned long insn;
@@ -188,7 +196,7 @@ static int apply_r_mips_lo16_rel(struct module *me, u32 *location, Elf_Addr v)
188 l = next; 196 l = next;
189 } 197 }
190 198
191 mips_hi16_list = NULL; 199 me->arch.r_mips_hi16_list = NULL;
192 } 200 }
193 201
194 /* 202 /*
@@ -201,6 +209,9 @@ static int apply_r_mips_lo16_rel(struct module *me, u32 *location, Elf_Addr v)
201 return 0; 209 return 0;
202 210
203out_danger: 211out_danger:
212 free_relocation_chain(l);
213 me->arch.r_mips_hi16_list = NULL;
214
204 pr_err("module %s: dangerous R_MIPS_LO16 REL relocation\n", me->name); 215 pr_err("module %s: dangerous R_MIPS_LO16 REL relocation\n", me->name);
205 216
206 return -ENOEXEC; 217 return -ENOEXEC;
@@ -273,6 +284,7 @@ int apply_relocate(Elf_Shdr *sechdrs, const char *strtab,
273 pr_debug("Applying relocate section %u to %u\n", relsec, 284 pr_debug("Applying relocate section %u to %u\n", relsec,
274 sechdrs[relsec].sh_info); 285 sechdrs[relsec].sh_info);
275 286
287 me->arch.r_mips_hi16_list = NULL;
276 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { 288 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
277 /* This is where to make the change */ 289 /* This is where to make the change */
278 location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr 290 location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
@@ -296,6 +308,19 @@ int apply_relocate(Elf_Shdr *sechdrs, const char *strtab,
296 return res; 308 return res;
297 } 309 }
298 310
311 /*
312 * Normally the hi16 list should be deallocated at this point. A
313 * malformed binary however could contain a series of R_MIPS_HI16
314 * relocations not followed by a R_MIPS_LO16 relocation. In that
315 * case, free up the list and return an error.
316 */
317 if (me->arch.r_mips_hi16_list) {
318 free_relocation_chain(me->arch.r_mips_hi16_list);
319 me->arch.r_mips_hi16_list = NULL;
320
321 return -ENOEXEC;
322 }
323
299 return 0; 324 return 0;
300} 325}
301 326
diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c
index eb5e394a465..2f28d3b5568 100644
--- a/arch/mips/kernel/perf_event_mipsxx.c
+++ b/arch/mips/kernel/perf_event_mipsxx.c
@@ -1559,6 +1559,11 @@ init_hw_perf_events(void)
1559 mipspmu.general_event_map = &mipsxxcore_event_map; 1559 mipspmu.general_event_map = &mipsxxcore_event_map;
1560 mipspmu.cache_event_map = &mipsxxcore_cache_map; 1560 mipspmu.cache_event_map = &mipsxxcore_cache_map;
1561 break; 1561 break;
1562 case CPU_LOONGSON1:
1563 mipspmu.name = "mips/loongson1";
1564 mipspmu.general_event_map = &mipsxxcore_event_map;
1565 mipspmu.cache_event_map = &mipsxxcore_cache_map;
1566 break;
1562 case CPU_CAVIUM_OCTEON: 1567 case CPU_CAVIUM_OCTEON:
1563 case CPU_CAVIUM_OCTEON_PLUS: 1568 case CPU_CAVIUM_OCTEON_PLUS:
1564 case CPU_CAVIUM_OCTEON2: 1569 case CPU_CAVIUM_OCTEON2:
diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c
index f11b2bbb826..028f6f837ef 100644
--- a/arch/mips/kernel/prom.c
+++ b/arch/mips/kernel/prom.c
@@ -35,16 +35,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
35 return add_memory_region(base, size, BOOT_MEM_RAM); 35 return add_memory_region(base, size, BOOT_MEM_RAM);
36} 36}
37 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
48void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) 38void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
49{ 39{
50 return __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS)); 40 return __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS));
@@ -77,25 +67,6 @@ void __init early_init_devtree(void *params)
77 of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL); 67 of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL);
78} 68}
79 69
80void __init device_tree_init(void)
81{
82 unsigned long base, size;
83
84 if (!initial_boot_params)
85 return;
86
87 base = virt_to_phys((void *)initial_boot_params);
88 size = be32_to_cpu(initial_boot_params->totalsize);
89
90 /* Before we do anything, lets reserve the dt blob */
91 reserve_mem_mach(base, size);
92
93 unflatten_device_tree();
94
95 /* free the space reserved for the dt blob */
96 free_mem_mach(base, size);
97}
98
99void __init __dt_setup_arch(struct boot_param_header *bph) 70void __init __dt_setup_arch(struct boot_param_header *bph)
100{ 71{
101 if (be32_to_cpu(bph->magic) != OF_DT_HEADER) { 72 if (be32_to_cpu(bph->magic) != OF_DT_HEADER) {
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 1268392f1d2..9005bf9fb85 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -102,7 +102,9 @@ asmlinkage __cpuinit void start_secondary(void)
102 102
103#ifdef CONFIG_MIPS_MT_SMTC 103#ifdef CONFIG_MIPS_MT_SMTC
104 /* Only do cpu_probe for first TC of CPU */ 104 /* Only do cpu_probe for first TC of CPU */
105 if ((read_c0_tcbind() & TCBIND_CURTC) == 0) 105 if ((read_c0_tcbind() & TCBIND_CURTC) != 0)
106 __cpu_name[smp_processor_id()] = __cpu_name[0];
107 else
106#endif /* CONFIG_MIPS_MT_SMTC */ 108#endif /* CONFIG_MIPS_MT_SMTC */
107 cpu_probe(); 109 cpu_probe();
108 cpu_report(); 110 cpu_report();
@@ -128,7 +130,7 @@ asmlinkage __cpuinit void start_secondary(void)
128 130
129 cpu_set(cpu, cpu_callin_map); 131 cpu_set(cpu, cpu_callin_map);
130 132
131 synchronise_count_slave(); 133 synchronise_count_slave(cpu);
132 134
133 /* 135 /*
134 * irq will be enabled in ->smp_finish(), enabling it too early 136 * irq will be enabled in ->smp_finish(), enabling it too early
@@ -171,7 +173,6 @@ void smp_send_stop(void)
171void __init smp_cpus_done(unsigned int max_cpus) 173void __init smp_cpus_done(unsigned int max_cpus)
172{ 174{
173 mp_ops->cpus_done(); 175 mp_ops->cpus_done();
174 synchronise_count_master();
175} 176}
176 177
177/* called from main before smp_init() */ 178/* called from main before smp_init() */
@@ -204,6 +205,7 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
204 while (!cpu_isset(cpu, cpu_callin_map)) 205 while (!cpu_isset(cpu, cpu_callin_map))
205 udelay(100); 206 udelay(100);
206 207
208 synchronise_count_master(cpu);
207 return 0; 209 return 0;
208} 210}
209 211
diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
index 15b5f3cfd20..1d47843d3cc 100644
--- a/arch/mips/kernel/smtc.c
+++ b/arch/mips/kernel/smtc.c
@@ -86,6 +86,13 @@ struct smtc_ipi_q IPIQ[NR_CPUS];
86static struct smtc_ipi_q freeIPIq; 86static struct smtc_ipi_q freeIPIq;
87 87
88 88
89/*
90 * Number of FPU contexts for each VPE
91 */
92
93static int smtc_nconf1[MAX_SMTC_VPES];
94
95
89/* Forward declarations */ 96/* Forward declarations */
90 97
91void ipi_decode(struct smtc_ipi *); 98void ipi_decode(struct smtc_ipi *);
@@ -174,9 +181,9 @@ static int __init tintq(char *str)
174 181
175__setup("tintq=", tintq); 182__setup("tintq=", tintq);
176 183
177static int imstuckcount[2][8]; 184static int imstuckcount[MAX_SMTC_VPES][8];
178/* vpemask represents IM/IE bits of per-VPE Status registers, low-to-high */ 185/* vpemask represents IM/IE bits of per-VPE Status registers, low-to-high */
179static int vpemask[2][8] = { 186static int vpemask[MAX_SMTC_VPES][8] = {
180 {0, 0, 1, 0, 0, 0, 0, 1}, 187 {0, 0, 1, 0, 0, 0, 0, 1},
181 {0, 0, 0, 0, 0, 0, 0, 1} 188 {0, 0, 0, 0, 0, 0, 0, 1}
182}; 189};
@@ -331,6 +338,22 @@ int __init smtc_build_cpu_map(int start_cpu_slot)
331 338
332static void smtc_tc_setup(int vpe, int tc, int cpu) 339static void smtc_tc_setup(int vpe, int tc, int cpu)
333{ 340{
341 static int cp1contexts[MAX_SMTC_VPES];
342
343 /*
344 * Make a local copy of the available FPU contexts in order
345 * to keep track of TCs that can have one.
346 */
347 if (tc == 1)
348 {
349 /*
350 * FIXME: Multi-core SMTC hasn't been tested and the
351 * maximum number of VPEs may change.
352 */
353 cp1contexts[0] = smtc_nconf1[0] - 1;
354 cp1contexts[1] = smtc_nconf1[1];
355 }
356
334 settc(tc); 357 settc(tc);
335 write_tc_c0_tchalt(TCHALT_H); 358 write_tc_c0_tchalt(TCHALT_H);
336 mips_ihb(); 359 mips_ihb();
@@ -343,22 +366,29 @@ static void smtc_tc_setup(int vpe, int tc, int cpu)
343 * an active IPI queue. 366 * an active IPI queue.
344 */ 367 */
345 write_tc_c0_tccontext((sizeof(struct smtc_ipi_q) * cpu) << 16); 368 write_tc_c0_tccontext((sizeof(struct smtc_ipi_q) * cpu) << 16);
346 /* Bind tc to vpe */ 369
370 /* Bind TC to VPE. */
347 write_tc_c0_tcbind(vpe); 371 write_tc_c0_tcbind(vpe);
372
348 /* In general, all TCs should have the same cpu_data indications. */ 373 /* In general, all TCs should have the same cpu_data indications. */
349 memcpy(&cpu_data[cpu], &cpu_data[0], sizeof(struct cpuinfo_mips)); 374 memcpy(&cpu_data[cpu], &cpu_data[0], sizeof(struct cpuinfo_mips));
350 /* For 34Kf, start with TC/CPU 0 as sole owner of single FPU context */ 375
351 if (cpu_data[0].cputype == CPU_34K || 376 /* Check to see if there is a FPU context available for this TC. */
352 cpu_data[0].cputype == CPU_1004K) 377 if (!cp1contexts[vpe])
353 cpu_data[cpu].options &= ~MIPS_CPU_FPU; 378 cpu_data[cpu].options &= ~MIPS_CPU_FPU;
379 else
380 cp1contexts[vpe]--;
381
382 /* Store the TC and VPE into the cpu_data structure. */
354 cpu_data[cpu].vpe_id = vpe; 383 cpu_data[cpu].vpe_id = vpe;
355 cpu_data[cpu].tc_id = tc; 384 cpu_data[cpu].tc_id = tc;
356 /* Multi-core SMTC hasn't been tested, but be prepared */ 385
386 /* FIXME: Multi-core SMTC hasn't been tested, but be prepared. */
357 cpu_data[cpu].core = (read_vpe_c0_ebase() >> 1) & 0xff; 387 cpu_data[cpu].core = (read_vpe_c0_ebase() >> 1) & 0xff;
358} 388}
359 389
360/* 390/*
361 * Tweak to get Count registes in as close a sync as possible. The 391 * Tweak to get Count registers synced as closely as possible. The
362 * value seems good for 34K-class cores. 392 * value seems good for 34K-class cores.
363 */ 393 */
364 394
@@ -466,6 +496,24 @@ void smtc_prepare_cpus(int cpus)
466 smtc_configure_tlb(); 496 smtc_configure_tlb();
467 497
468 for (tc = 0, vpe = 0 ; (vpe < nvpe) && (tc < ntc) ; vpe++) { 498 for (tc = 0, vpe = 0 ; (vpe < nvpe) && (tc < ntc) ; vpe++) {
499 /* Get number of CP1 contexts for each VPE. */
500 if (tc == 0)
501 {
502 /*
503 * Do not call settc() for TC0 or the FPU context
504 * value will be incorrect. Besides, we know that
505 * we are TC0 anyway.
506 */
507 smtc_nconf1[0] = ((read_vpe_c0_vpeconf1() &
508 VPECONF1_NCP1) >> VPECONF1_NCP1_SHIFT);
509 if (nvpe == 2)
510 {
511 settc(1);
512 smtc_nconf1[1] = ((read_vpe_c0_vpeconf1() &
513 VPECONF1_NCP1) >> VPECONF1_NCP1_SHIFT);
514 settc(0);
515 }
516 }
469 if (tcpervpe[vpe] == 0) 517 if (tcpervpe[vpe] == 0)
470 continue; 518 continue;
471 if (vpe != 0) 519 if (vpe != 0)
@@ -479,6 +527,18 @@ void smtc_prepare_cpus(int cpus)
479 */ 527 */
480 if (tc != 0) { 528 if (tc != 0) {
481 smtc_tc_setup(vpe, tc, cpu); 529 smtc_tc_setup(vpe, tc, cpu);
530 if (vpe != 0) {
531 /*
532 * Set MVP bit (possibly again). Do it
533 * here to catch CPUs that have no TCs
534 * bound to the VPE at reset. In that
535 * case, a TC must be bound to the VPE
536 * before we can set VPEControl[MVP]
537 */
538 write_vpe_c0_vpeconf0(
539 read_vpe_c0_vpeconf0() |
540 VPECONF0_MVP);
541 }
482 cpu++; 542 cpu++;
483 } 543 }
484 printk(" %d", tc); 544 printk(" %d", tc);
diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
index 842d55e411f..7f1eca3858d 100644
--- a/arch/mips/kernel/sync-r4k.c
+++ b/arch/mips/kernel/sync-r4k.c
@@ -28,12 +28,11 @@ static atomic_t __cpuinitdata count_reference = ATOMIC_INIT(0);
28#define COUNTON 100 28#define COUNTON 100
29#define NR_LOOPS 5 29#define NR_LOOPS 5
30 30
31void __cpuinit synchronise_count_master(void) 31void __cpuinit synchronise_count_master(int cpu)
32{ 32{
33 int i; 33 int i;
34 unsigned long flags; 34 unsigned long flags;
35 unsigned int initcount; 35 unsigned int initcount;
36 int nslaves;
37 36
38#ifdef CONFIG_MIPS_MT_SMTC 37#ifdef CONFIG_MIPS_MT_SMTC
39 /* 38 /*
@@ -43,8 +42,7 @@ void __cpuinit synchronise_count_master(void)
43 return; 42 return;
44#endif 43#endif
45 44
46 printk(KERN_INFO "Synchronize counters across %u CPUs: ", 45 printk(KERN_INFO "Synchronize counters for CPU %u: ", cpu);
47 num_online_cpus());
48 46
49 local_irq_save(flags); 47 local_irq_save(flags);
50 48
@@ -52,7 +50,7 @@ void __cpuinit synchronise_count_master(void)
52 * Notify the slaves that it's time to start 50 * Notify the slaves that it's time to start
53 */ 51 */
54 atomic_set(&count_reference, read_c0_count()); 52 atomic_set(&count_reference, read_c0_count());
55 atomic_set(&count_start_flag, 1); 53 atomic_set(&count_start_flag, cpu);
56 smp_wmb(); 54 smp_wmb();
57 55
58 /* Count will be initialised to current timer for all CPU's */ 56 /* Count will be initialised to current timer for all CPU's */
@@ -69,10 +67,9 @@ void __cpuinit synchronise_count_master(void)
69 * two CPUs. 67 * two CPUs.
70 */ 68 */
71 69
72 nslaves = num_online_cpus()-1;
73 for (i = 0; i < NR_LOOPS; i++) { 70 for (i = 0; i < NR_LOOPS; i++) {
74 /* slaves loop on '!= ncpus' */ 71 /* slaves loop on '!= 2' */
75 while (atomic_read(&count_count_start) != nslaves) 72 while (atomic_read(&count_count_start) != 1)
76 mb(); 73 mb();
77 atomic_set(&count_count_stop, 0); 74 atomic_set(&count_count_stop, 0);
78 smp_wmb(); 75 smp_wmb();
@@ -89,7 +86,7 @@ void __cpuinit synchronise_count_master(void)
89 /* 86 /*
90 * Wait for all slaves to leave the synchronization point: 87 * Wait for all slaves to leave the synchronization point:
91 */ 88 */
92 while (atomic_read(&count_count_stop) != nslaves) 89 while (atomic_read(&count_count_stop) != 1)
93 mb(); 90 mb();
94 atomic_set(&count_count_start, 0); 91 atomic_set(&count_count_start, 0);
95 smp_wmb(); 92 smp_wmb();
@@ -97,6 +94,7 @@ void __cpuinit synchronise_count_master(void)
97 } 94 }
98 /* Arrange for an interrupt in a short while */ 95 /* Arrange for an interrupt in a short while */
99 write_c0_compare(read_c0_count() + COUNTON); 96 write_c0_compare(read_c0_count() + COUNTON);
97 atomic_set(&count_start_flag, 0);
100 98
101 local_irq_restore(flags); 99 local_irq_restore(flags);
102 100
@@ -108,11 +106,10 @@ void __cpuinit synchronise_count_master(void)
108 printk("done.\n"); 106 printk("done.\n");
109} 107}
110 108
111void __cpuinit synchronise_count_slave(void) 109void __cpuinit synchronise_count_slave(int cpu)
112{ 110{
113 int i; 111 int i;
114 unsigned int initcount; 112 unsigned int initcount;
115 int ncpus;
116 113
117#ifdef CONFIG_MIPS_MT_SMTC 114#ifdef CONFIG_MIPS_MT_SMTC
118 /* 115 /*
@@ -127,16 +124,15 @@ void __cpuinit synchronise_count_slave(void)
127 * so we first wait for the master to say everyone is ready 124 * so we first wait for the master to say everyone is ready
128 */ 125 */
129 126
130 while (!atomic_read(&count_start_flag)) 127 while (atomic_read(&count_start_flag) != cpu)
131 mb(); 128 mb();
132 129
133 /* Count will be initialised to next expire for all CPU's */ 130 /* Count will be initialised to next expire for all CPU's */
134 initcount = atomic_read(&count_reference); 131 initcount = atomic_read(&count_reference);
135 132
136 ncpus = num_online_cpus();
137 for (i = 0; i < NR_LOOPS; i++) { 133 for (i = 0; i < NR_LOOPS; i++) {
138 atomic_inc(&count_count_start); 134 atomic_inc(&count_count_start);
139 while (atomic_read(&count_count_start) != ncpus) 135 while (atomic_read(&count_count_start) != 2)
140 mb(); 136 mb();
141 137
142 /* 138 /*
@@ -146,7 +142,7 @@ void __cpuinit synchronise_count_slave(void)
146 write_c0_count(initcount); 142 write_c0_count(initcount);
147 143
148 atomic_inc(&count_count_stop); 144 atomic_inc(&count_count_stop);
149 while (atomic_read(&count_count_stop) != ncpus) 145 while (atomic_read(&count_count_stop) != 2)
150 mb(); 146 mb();
151 } 147 }
152 /* Arrange for an interrupt in a short while */ 148 /* Arrange for an interrupt in a short while */
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index c3c29354370..9be3df1fa8a 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -1253,6 +1253,7 @@ static inline void parity_protection_init(void)
1253 1253
1254 case CPU_5KC: 1254 case CPU_5KC:
1255 case CPU_5KE: 1255 case CPU_5KE:
1256 case CPU_LOONGSON1:
1256 write_c0_ecc(0x80000000); 1257 write_c0_ecc(0x80000000);
1257 back_to_back_c0_hazard(); 1258 back_to_back_c0_hazard();
1258 /* Set the PE bit (bit 31) in the c0_errctl register. */ 1259 /* Set the PE bit (bit 31) in the c0_errctl register. */
diff --git a/arch/mips/lantiq/clk.c b/arch/mips/lantiq/clk.c
index d3bcc33f469..ce2f129b081 100644
--- a/arch/mips/lantiq/clk.c
+++ b/arch/mips/lantiq/clk.c
@@ -135,6 +135,11 @@ void clk_deactivate(struct clk *clk)
135} 135}
136EXPORT_SYMBOL(clk_deactivate); 136EXPORT_SYMBOL(clk_deactivate);
137 137
138struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec)
139{
140 return NULL;
141}
142
138static inline u32 get_counter_resolution(void) 143static inline u32 get_counter_resolution(void)
139{ 144{
140 u32 res; 145 u32 res;
diff --git a/arch/mips/lantiq/prom.c b/arch/mips/lantiq/prom.c
index d185e8477fd..6cfd6117fbf 100644
--- a/arch/mips/lantiq/prom.c
+++ b/arch/mips/lantiq/prom.c
@@ -8,7 +8,10 @@
8 8
9#include <linux/export.h> 9#include <linux/export.h>
10#include <linux/clk.h> 10#include <linux/clk.h>
11#include <linux/bootmem.h>
11#include <linux/of_platform.h> 12#include <linux/of_platform.h>
13#include <linux/of_fdt.h>
14
12#include <asm/bootinfo.h> 15#include <asm/bootinfo.h>
13#include <asm/time.h> 16#include <asm/time.h>
14 17
@@ -70,6 +73,25 @@ void __init plat_mem_setup(void)
70 __dt_setup_arch(&__dtb_start); 73 __dt_setup_arch(&__dtb_start);
71} 74}
72 75
76void __init device_tree_init(void)
77{
78 unsigned long base, size;
79
80 if (!initial_boot_params)
81 return;
82
83 base = virt_to_phys((void *)initial_boot_params);
84 size = be32_to_cpu(initial_boot_params->totalsize);
85
86 /* Before we do anything, lets reserve the dt blob */
87 reserve_bootmem(base, size, BOOTMEM_DEFAULT);
88
89 unflatten_device_tree();
90
91 /* free the space reserved for the dt blob */
92 free_bootmem(base, size);
93}
94
73void __init prom_init(void) 95void __init prom_init(void)
74{ 96{
75 /* call the soc specific detetcion code and get it to fill soc_info */ 97 /* call the soc specific detetcion code and get it to fill soc_info */
diff --git a/arch/mips/lantiq/xway/sysctrl.c b/arch/mips/lantiq/xway/sysctrl.c
index 83780f7c842..befbb760ab7 100644
--- a/arch/mips/lantiq/xway/sysctrl.c
+++ b/arch/mips/lantiq/xway/sysctrl.c
@@ -20,10 +20,12 @@
20 20
21/* clock control register */ 21/* clock control register */
22#define CGU_IFCCR 0x0018 22#define CGU_IFCCR 0x0018
23#define CGU_IFCCR_VR9 0x0024
23/* system clock register */ 24/* system clock register */
24#define CGU_SYS 0x0010 25#define CGU_SYS 0x0010
25/* pci control register */ 26/* pci control register */
26#define CGU_PCICR 0x0034 27#define CGU_PCICR 0x0034
28#define CGU_PCICR_VR9 0x0038
27/* ephy configuration register */ 29/* ephy configuration register */
28#define CGU_EPHY 0x10 30#define CGU_EPHY 0x10
29/* power control register */ 31/* power control register */
@@ -80,6 +82,9 @@ static void __iomem *pmu_membase;
80void __iomem *ltq_cgu_membase; 82void __iomem *ltq_cgu_membase;
81void __iomem *ltq_ebu_membase; 83void __iomem *ltq_ebu_membase;
82 84
85static u32 ifccr = CGU_IFCCR;
86static u32 pcicr = CGU_PCICR;
87
83/* legacy function kept alive to ease clkdev transition */ 88/* legacy function kept alive to ease clkdev transition */
84void ltq_pmu_enable(unsigned int module) 89void ltq_pmu_enable(unsigned int module)
85{ 90{
@@ -103,14 +108,14 @@ EXPORT_SYMBOL(ltq_pmu_disable);
103/* enable a hw clock */ 108/* enable a hw clock */
104static int cgu_enable(struct clk *clk) 109static int cgu_enable(struct clk *clk)
105{ 110{
106 ltq_cgu_w32(ltq_cgu_r32(CGU_IFCCR) | clk->bits, CGU_IFCCR); 111 ltq_cgu_w32(ltq_cgu_r32(ifccr) | clk->bits, ifccr);
107 return 0; 112 return 0;
108} 113}
109 114
110/* disable a hw clock */ 115/* disable a hw clock */
111static void cgu_disable(struct clk *clk) 116static void cgu_disable(struct clk *clk)
112{ 117{
113 ltq_cgu_w32(ltq_cgu_r32(CGU_IFCCR) & ~clk->bits, CGU_IFCCR); 118 ltq_cgu_w32(ltq_cgu_r32(ifccr) & ~clk->bits, ifccr);
114} 119}
115 120
116/* enable a clock gate */ 121/* enable a clock gate */
@@ -138,22 +143,22 @@ static void pmu_disable(struct clk *clk)
138/* the pci enable helper */ 143/* the pci enable helper */
139static int pci_enable(struct clk *clk) 144static int pci_enable(struct clk *clk)
140{ 145{
141 unsigned int ifccr = ltq_cgu_r32(CGU_IFCCR); 146 unsigned int val = ltq_cgu_r32(ifccr);
142 /* set bus clock speed */ 147 /* set bus clock speed */
143 if (of_machine_is_compatible("lantiq,ar9")) { 148 if (of_machine_is_compatible("lantiq,ar9")) {
144 ifccr &= ~0x1f00000; 149 val &= ~0x1f00000;
145 if (clk->rate == CLOCK_33M) 150 if (clk->rate == CLOCK_33M)
146 ifccr |= 0xe00000; 151 val |= 0xe00000;
147 else 152 else
148 ifccr |= 0x700000; /* 62.5M */ 153 val |= 0x700000; /* 62.5M */
149 } else { 154 } else {
150 ifccr &= ~0xf00000; 155 val &= ~0xf00000;
151 if (clk->rate == CLOCK_33M) 156 if (clk->rate == CLOCK_33M)
152 ifccr |= 0x800000; 157 val |= 0x800000;
153 else 158 else
154 ifccr |= 0x400000; /* 62.5M */ 159 val |= 0x400000; /* 62.5M */
155 } 160 }
156 ltq_cgu_w32(ifccr, CGU_IFCCR); 161 ltq_cgu_w32(val, ifccr);
157 pmu_enable(clk); 162 pmu_enable(clk);
158 return 0; 163 return 0;
159} 164}
@@ -161,18 +166,16 @@ static int pci_enable(struct clk *clk)
161/* enable the external clock as a source */ 166/* enable the external clock as a source */
162static int pci_ext_enable(struct clk *clk) 167static int pci_ext_enable(struct clk *clk)
163{ 168{
164 ltq_cgu_w32(ltq_cgu_r32(CGU_IFCCR) & ~(1 << 16), 169 ltq_cgu_w32(ltq_cgu_r32(ifccr) & ~(1 << 16), ifccr);
165 CGU_IFCCR); 170 ltq_cgu_w32((1 << 30), pcicr);
166 ltq_cgu_w32((1 << 30), CGU_PCICR);
167 return 0; 171 return 0;
168} 172}
169 173
170/* disable the external clock as a source */ 174/* disable the external clock as a source */
171static void pci_ext_disable(struct clk *clk) 175static void pci_ext_disable(struct clk *clk)
172{ 176{
173 ltq_cgu_w32(ltq_cgu_r32(CGU_IFCCR) | (1 << 16), 177 ltq_cgu_w32(ltq_cgu_r32(ifccr) | (1 << 16), ifccr);
174 CGU_IFCCR); 178 ltq_cgu_w32((1 << 31) | (1 << 30), pcicr);
175 ltq_cgu_w32((1 << 31) | (1 << 30), CGU_PCICR);
176} 179}
177 180
178/* enable a clockout source */ 181/* enable a clockout source */
@@ -184,11 +187,11 @@ static int clkout_enable(struct clk *clk)
184 for (i = 0; i < 4; i++) { 187 for (i = 0; i < 4; i++) {
185 if (clk->rates[i] == clk->rate) { 188 if (clk->rates[i] == clk->rate) {
186 int shift = 14 - (2 * clk->module); 189 int shift = 14 - (2 * clk->module);
187 unsigned int ifccr = ltq_cgu_r32(CGU_IFCCR); 190 unsigned int val = ltq_cgu_r32(ifccr);
188 191
189 ifccr &= ~(3 << shift); 192 val &= ~(3 << shift);
190 ifccr |= i << shift; 193 val |= i << shift;
191 ltq_cgu_w32(ifccr, CGU_IFCCR); 194 ltq_cgu_w32(val, ifccr);
192 return 0; 195 return 0;
193 } 196 }
194 } 197 }
@@ -336,8 +339,12 @@ void __init ltq_soc_init(void)
336 clkdev_add_clkout(); 339 clkdev_add_clkout();
337 340
338 /* add the soc dependent clocks */ 341 /* add the soc dependent clocks */
339 if (!of_machine_is_compatible("lantiq,vr9")) 342 if (of_machine_is_compatible("lantiq,vr9")) {
343 ifccr = CGU_IFCCR_VR9;
344 pcicr = CGU_PCICR_VR9;
345 } else {
340 clkdev_add_pmu("1e180000.etop", NULL, 0, PMU_PPE); 346 clkdev_add_pmu("1e180000.etop", NULL, 0, PMU_PPE);
347 }
341 348
342 if (!of_machine_is_compatible("lantiq,ase")) { 349 if (!of_machine_is_compatible("lantiq,ase")) {
343 clkdev_add_pmu("1e100c00.serial", NULL, 0, PMU_ASC1); 350 clkdev_add_pmu("1e100c00.serial", NULL, 0, PMU_ASC1);
diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile
index 2a7c74fc15f..399a50a541d 100644
--- a/arch/mips/lib/Makefile
+++ b/arch/mips/lib/Makefile
@@ -2,7 +2,7 @@
2# Makefile for MIPS-specific library files.. 2# Makefile for MIPS-specific library files..
3# 3#
4 4
5lib-y += csum_partial.o delay.o memcpy.o memcpy-inatomic.o memset.o \ 5lib-y += csum_partial.o delay.o memcpy.o memset.o \
6 strlen_user.o strncpy_user.o strnlen_user.o uncached.o 6 strlen_user.o strncpy_user.o strnlen_user.o uncached.o
7 7
8obj-y += iomap.o 8obj-y += iomap.o
diff --git a/arch/mips/lib/memcpy-inatomic.S b/arch/mips/lib/memcpy-inatomic.S
deleted file mode 100644
index 68853a038d3..00000000000
--- a/arch/mips/lib/memcpy-inatomic.S
+++ /dev/null
@@ -1,451 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Unified implementation of memcpy, memmove and the __copy_user backend.
7 *
8 * Copyright (C) 1998, 99, 2000, 01, 2002 Ralf Baechle (ralf@gnu.org)
9 * Copyright (C) 1999, 2000, 01, 2002 Silicon Graphics, Inc.
10 * Copyright (C) 2002 Broadcom, Inc.
11 * memcpy/copy_user author: Mark Vandevoorde
12 * Copyright (C) 2007 Maciej W. Rozycki
13 *
14 * Mnemonic names for arguments to memcpy/__copy_user
15 */
16
17/*
18 * Hack to resolve longstanding prefetch issue
19 *
20 * Prefetching may be fatal on some systems if we're prefetching beyond the
21 * end of memory on some systems. It's also a seriously bad idea on non
22 * dma-coherent systems.
23 */
24#ifdef CONFIG_DMA_NONCOHERENT
25#undef CONFIG_CPU_HAS_PREFETCH
26#endif
27#ifdef CONFIG_MIPS_MALTA
28#undef CONFIG_CPU_HAS_PREFETCH
29#endif
30
31#include <asm/asm.h>
32#include <asm/asm-offsets.h>
33#include <asm/regdef.h>
34
35#define dst a0
36#define src a1
37#define len a2
38
39/*
40 * Spec
41 *
42 * memcpy copies len bytes from src to dst and sets v0 to dst.
43 * It assumes that
44 * - src and dst don't overlap
45 * - src is readable
46 * - dst is writable
47 * memcpy uses the standard calling convention
48 *
49 * __copy_user copies up to len bytes from src to dst and sets a2 (len) to
50 * the number of uncopied bytes due to an exception caused by a read or write.
51 * __copy_user assumes that src and dst don't overlap, and that the call is
52 * implementing one of the following:
53 * copy_to_user
54 * - src is readable (no exceptions when reading src)
55 * copy_from_user
56 * - dst is writable (no exceptions when writing dst)
57 * __copy_user uses a non-standard calling convention; see
58 * include/asm-mips/uaccess.h
59 *
60 * When an exception happens on a load, the handler must
61 # ensure that all of the destination buffer is overwritten to prevent
62 * leaking information to user mode programs.
63 */
64
65/*
66 * Implementation
67 */
68
69/*
70 * The exception handler for loads requires that:
71 * 1- AT contain the address of the byte just past the end of the source
72 * of the copy,
73 * 2- src_entry <= src < AT, and
74 * 3- (dst - src) == (dst_entry - src_entry),
75 * The _entry suffix denotes values when __copy_user was called.
76 *
77 * (1) is set up up by uaccess.h and maintained by not writing AT in copy_user
78 * (2) is met by incrementing src by the number of bytes copied
79 * (3) is met by not doing loads between a pair of increments of dst and src
80 *
81 * The exception handlers for stores adjust len (if necessary) and return.
82 * These handlers do not need to overwrite any data.
83 *
84 * For __rmemcpy and memmove an exception is always a kernel bug, therefore
85 * they're not protected.
86 */
87
88#define EXC(inst_reg,addr,handler) \
899: inst_reg, addr; \
90 .section __ex_table,"a"; \
91 PTR 9b, handler; \
92 .previous
93
94/*
95 * Only on the 64-bit kernel we can made use of 64-bit registers.
96 */
97#ifdef CONFIG_64BIT
98#define USE_DOUBLE
99#endif
100
101#ifdef USE_DOUBLE
102
103#define LOAD ld
104#define LOADL ldl
105#define LOADR ldr
106#define STOREL sdl
107#define STORER sdr
108#define STORE sd
109#define ADD daddu
110#define SUB dsubu
111#define SRL dsrl
112#define SRA dsra
113#define SLL dsll
114#define SLLV dsllv
115#define SRLV dsrlv
116#define NBYTES 8
117#define LOG_NBYTES 3
118
119/*
120 * As we are sharing code base with the mips32 tree (which use the o32 ABI
121 * register definitions). We need to redefine the register definitions from
122 * the n64 ABI register naming to the o32 ABI register naming.
123 */
124#undef t0
125#undef t1
126#undef t2
127#undef t3
128#define t0 $8
129#define t1 $9
130#define t2 $10
131#define t3 $11
132#define t4 $12
133#define t5 $13
134#define t6 $14
135#define t7 $15
136
137#else
138
139#define LOAD lw
140#define LOADL lwl
141#define LOADR lwr
142#define STOREL swl
143#define STORER swr
144#define STORE sw
145#define ADD addu
146#define SUB subu
147#define SRL srl
148#define SLL sll
149#define SRA sra
150#define SLLV sllv
151#define SRLV srlv
152#define NBYTES 4
153#define LOG_NBYTES 2
154
155#endif /* USE_DOUBLE */
156
157#ifdef CONFIG_CPU_LITTLE_ENDIAN
158#define LDFIRST LOADR
159#define LDREST LOADL
160#define STFIRST STORER
161#define STREST STOREL
162#define SHIFT_DISCARD SLLV
163#else
164#define LDFIRST LOADL
165#define LDREST LOADR
166#define STFIRST STOREL
167#define STREST STORER
168#define SHIFT_DISCARD SRLV
169#endif
170
171#define FIRST(unit) ((unit)*NBYTES)
172#define REST(unit) (FIRST(unit)+NBYTES-1)
173#define UNIT(unit) FIRST(unit)
174
175#define ADDRMASK (NBYTES-1)
176
177 .text
178 .set noreorder
179#ifndef CONFIG_CPU_DADDI_WORKAROUNDS
180 .set noat
181#else
182 .set at=v1
183#endif
184
185/*
186 * A combined memcpy/__copy_user
187 * __copy_user sets len to 0 for success; else to an upper bound of
188 * the number of uncopied bytes.
189 * memcpy sets v0 to dst.
190 */
191 .align 5
192LEAF(__copy_user_inatomic)
193 /*
194 * Note: dst & src may be unaligned, len may be 0
195 * Temps
196 */
197#define rem t8
198
199 /*
200 * The "issue break"s below are very approximate.
201 * Issue delays for dcache fills will perturb the schedule, as will
202 * load queue full replay traps, etc.
203 *
204 * If len < NBYTES use byte operations.
205 */
206 PREF( 0, 0(src) )
207 PREF( 1, 0(dst) )
208 sltu t2, len, NBYTES
209 and t1, dst, ADDRMASK
210 PREF( 0, 1*32(src) )
211 PREF( 1, 1*32(dst) )
212 bnez t2, .Lcopy_bytes_checklen
213 and t0, src, ADDRMASK
214 PREF( 0, 2*32(src) )
215 PREF( 1, 2*32(dst) )
216 bnez t1, .Ldst_unaligned
217 nop
218 bnez t0, .Lsrc_unaligned_dst_aligned
219 /*
220 * use delay slot for fall-through
221 * src and dst are aligned; need to compute rem
222 */
223.Lboth_aligned:
224 SRL t0, len, LOG_NBYTES+3 # +3 for 8 units/iter
225 beqz t0, .Lcleanup_both_aligned # len < 8*NBYTES
226 and rem, len, (8*NBYTES-1) # rem = len % (8*NBYTES)
227 PREF( 0, 3*32(src) )
228 PREF( 1, 3*32(dst) )
229 .align 4
2301:
231EXC( LOAD t0, UNIT(0)(src), .Ll_exc)
232EXC( LOAD t1, UNIT(1)(src), .Ll_exc_copy)
233EXC( LOAD t2, UNIT(2)(src), .Ll_exc_copy)
234EXC( LOAD t3, UNIT(3)(src), .Ll_exc_copy)
235 SUB len, len, 8*NBYTES
236EXC( LOAD t4, UNIT(4)(src), .Ll_exc_copy)
237EXC( LOAD t7, UNIT(5)(src), .Ll_exc_copy)
238 STORE t0, UNIT(0)(dst)
239 STORE t1, UNIT(1)(dst)
240EXC( LOAD t0, UNIT(6)(src), .Ll_exc_copy)
241EXC( LOAD t1, UNIT(7)(src), .Ll_exc_copy)
242 ADD src, src, 8*NBYTES
243 ADD dst, dst, 8*NBYTES
244 STORE t2, UNIT(-6)(dst)
245 STORE t3, UNIT(-5)(dst)
246 STORE t4, UNIT(-4)(dst)
247 STORE t7, UNIT(-3)(dst)
248 STORE t0, UNIT(-2)(dst)
249 STORE t1, UNIT(-1)(dst)
250 PREF( 0, 8*32(src) )
251 PREF( 1, 8*32(dst) )
252 bne len, rem, 1b
253 nop
254
255 /*
256 * len == rem == the number of bytes left to copy < 8*NBYTES
257 */
258.Lcleanup_both_aligned:
259 beqz len, .Ldone
260 sltu t0, len, 4*NBYTES
261 bnez t0, .Lless_than_4units
262 and rem, len, (NBYTES-1) # rem = len % NBYTES
263 /*
264 * len >= 4*NBYTES
265 */
266EXC( LOAD t0, UNIT(0)(src), .Ll_exc)
267EXC( LOAD t1, UNIT(1)(src), .Ll_exc_copy)
268EXC( LOAD t2, UNIT(2)(src), .Ll_exc_copy)
269EXC( LOAD t3, UNIT(3)(src), .Ll_exc_copy)
270 SUB len, len, 4*NBYTES
271 ADD src, src, 4*NBYTES
272 STORE t0, UNIT(0)(dst)
273 STORE t1, UNIT(1)(dst)
274 STORE t2, UNIT(2)(dst)
275 STORE t3, UNIT(3)(dst)
276 .set reorder /* DADDI_WAR */
277 ADD dst, dst, 4*NBYTES
278 beqz len, .Ldone
279 .set noreorder
280.Lless_than_4units:
281 /*
282 * rem = len % NBYTES
283 */
284 beq rem, len, .Lcopy_bytes
285 nop
2861:
287EXC( LOAD t0, 0(src), .Ll_exc)
288 ADD src, src, NBYTES
289 SUB len, len, NBYTES
290 STORE t0, 0(dst)
291 .set reorder /* DADDI_WAR */
292 ADD dst, dst, NBYTES
293 bne rem, len, 1b
294 .set noreorder
295
296 /*
297 * src and dst are aligned, need to copy rem bytes (rem < NBYTES)
298 * A loop would do only a byte at a time with possible branch
299 * mispredicts. Can't do an explicit LOAD dst,mask,or,STORE
300 * because can't assume read-access to dst. Instead, use
301 * STREST dst, which doesn't require read access to dst.
302 *
303 * This code should perform better than a simple loop on modern,
304 * wide-issue mips processors because the code has fewer branches and
305 * more instruction-level parallelism.
306 */
307#define bits t2
308 beqz len, .Ldone
309 ADD t1, dst, len # t1 is just past last byte of dst
310 li bits, 8*NBYTES
311 SLL rem, len, 3 # rem = number of bits to keep
312EXC( LOAD t0, 0(src), .Ll_exc)
313 SUB bits, bits, rem # bits = number of bits to discard
314 SHIFT_DISCARD t0, t0, bits
315 STREST t0, -1(t1)
316 jr ra
317 move len, zero
318.Ldst_unaligned:
319 /*
320 * dst is unaligned
321 * t0 = src & ADDRMASK
322 * t1 = dst & ADDRMASK; T1 > 0
323 * len >= NBYTES
324 *
325 * Copy enough bytes to align dst
326 * Set match = (src and dst have same alignment)
327 */
328#define match rem
329EXC( LDFIRST t3, FIRST(0)(src), .Ll_exc)
330 ADD t2, zero, NBYTES
331EXC( LDREST t3, REST(0)(src), .Ll_exc_copy)
332 SUB t2, t2, t1 # t2 = number of bytes copied
333 xor match, t0, t1
334 STFIRST t3, FIRST(0)(dst)
335 beq len, t2, .Ldone
336 SUB len, len, t2
337 ADD dst, dst, t2
338 beqz match, .Lboth_aligned
339 ADD src, src, t2
340
341.Lsrc_unaligned_dst_aligned:
342 SRL t0, len, LOG_NBYTES+2 # +2 for 4 units/iter
343 PREF( 0, 3*32(src) )
344 beqz t0, .Lcleanup_src_unaligned
345 and rem, len, (4*NBYTES-1) # rem = len % 4*NBYTES
346 PREF( 1, 3*32(dst) )
3471:
348/*
349 * Avoid consecutive LD*'s to the same register since some mips
350 * implementations can't issue them in the same cycle.
351 * It's OK to load FIRST(N+1) before REST(N) because the two addresses
352 * are to the same unit (unless src is aligned, but it's not).
353 */
354EXC( LDFIRST t0, FIRST(0)(src), .Ll_exc)
355EXC( LDFIRST t1, FIRST(1)(src), .Ll_exc_copy)
356 SUB len, len, 4*NBYTES
357EXC( LDREST t0, REST(0)(src), .Ll_exc_copy)
358EXC( LDREST t1, REST(1)(src), .Ll_exc_copy)
359EXC( LDFIRST t2, FIRST(2)(src), .Ll_exc_copy)
360EXC( LDFIRST t3, FIRST(3)(src), .Ll_exc_copy)
361EXC( LDREST t2, REST(2)(src), .Ll_exc_copy)
362EXC( LDREST t3, REST(3)(src), .Ll_exc_copy)
363 PREF( 0, 9*32(src) ) # 0 is PREF_LOAD (not streamed)
364 ADD src, src, 4*NBYTES
365#ifdef CONFIG_CPU_SB1
366 nop # improves slotting
367#endif
368 STORE t0, UNIT(0)(dst)
369 STORE t1, UNIT(1)(dst)
370 STORE t2, UNIT(2)(dst)
371 STORE t3, UNIT(3)(dst)
372 PREF( 1, 9*32(dst) ) # 1 is PREF_STORE (not streamed)
373 .set reorder /* DADDI_WAR */
374 ADD dst, dst, 4*NBYTES
375 bne len, rem, 1b
376 .set noreorder
377
378.Lcleanup_src_unaligned:
379 beqz len, .Ldone
380 and rem, len, NBYTES-1 # rem = len % NBYTES
381 beq rem, len, .Lcopy_bytes
382 nop
3831:
384EXC( LDFIRST t0, FIRST(0)(src), .Ll_exc)
385EXC( LDREST t0, REST(0)(src), .Ll_exc_copy)
386 ADD src, src, NBYTES
387 SUB len, len, NBYTES
388 STORE t0, 0(dst)
389 .set reorder /* DADDI_WAR */
390 ADD dst, dst, NBYTES
391 bne len, rem, 1b
392 .set noreorder
393
394.Lcopy_bytes_checklen:
395 beqz len, .Ldone
396 nop
397.Lcopy_bytes:
398 /* 0 < len < NBYTES */
399#define COPY_BYTE(N) \
400EXC( lb t0, N(src), .Ll_exc); \
401 SUB len, len, 1; \
402 beqz len, .Ldone; \
403 sb t0, N(dst)
404
405 COPY_BYTE(0)
406 COPY_BYTE(1)
407#ifdef USE_DOUBLE
408 COPY_BYTE(2)
409 COPY_BYTE(3)
410 COPY_BYTE(4)
411 COPY_BYTE(5)
412#endif
413EXC( lb t0, NBYTES-2(src), .Ll_exc)
414 SUB len, len, 1
415 jr ra
416 sb t0, NBYTES-2(dst)
417.Ldone:
418 jr ra
419 nop
420 END(__copy_user_inatomic)
421
422.Ll_exc_copy:
423 /*
424 * Copy bytes from src until faulting load address (or until a
425 * lb faults)
426 *
427 * When reached by a faulting LDFIRST/LDREST, THREAD_BUADDR($28)
428 * may be more than a byte beyond the last address.
429 * Hence, the lb below may get an exception.
430 *
431 * Assumes src < THREAD_BUADDR($28)
432 */
433 LOAD t0, TI_TASK($28)
434 nop
435 LOAD t0, THREAD_BUADDR(t0)
4361:
437EXC( lb t1, 0(src), .Ll_exc)
438 ADD src, src, 1
439 sb t1, 0(dst) # can't fault -- we're copy_from_user
440 .set reorder /* DADDI_WAR */
441 ADD dst, dst, 1
442 bne src, t0, 1b
443 .set noreorder
444.Ll_exc:
445 LOAD t0, TI_TASK($28)
446 nop
447 LOAD t0, THREAD_BUADDR(t0) # t0 is just past last good address
448 nop
449 SUB len, AT, t0 # len number of uncopied bytes
450 jr ra
451 nop
diff --git a/arch/mips/lib/memcpy.S b/arch/mips/lib/memcpy.S
index 56a1f85a1ce..65192c06781 100644
--- a/arch/mips/lib/memcpy.S
+++ b/arch/mips/lib/memcpy.S
@@ -183,6 +183,14 @@
183#endif 183#endif
184 184
185/* 185/*
186 * t6 is used as a flag to note inatomic mode.
187 */
188LEAF(__copy_user_inatomic)
189 b __copy_user_common
190 li t6, 1
191 END(__copy_user_inatomic)
192
193/*
186 * A combined memcpy/__copy_user 194 * A combined memcpy/__copy_user
187 * __copy_user sets len to 0 for success; else to an upper bound of 195 * __copy_user sets len to 0 for success; else to an upper bound of
188 * the number of uncopied bytes. 196 * the number of uncopied bytes.
@@ -193,6 +201,8 @@ LEAF(memcpy) /* a0=dst a1=src a2=len */
193 move v0, dst /* return value */ 201 move v0, dst /* return value */
194.L__memcpy: 202.L__memcpy:
195FEXPORT(__copy_user) 203FEXPORT(__copy_user)
204 li t6, 0 /* not inatomic */
205__copy_user_common:
196 /* 206 /*
197 * Note: dst & src may be unaligned, len may be 0 207 * Note: dst & src may be unaligned, len may be 0
198 * Temps 208 * Temps
@@ -458,6 +468,7 @@ EXC( lb t1, 0(src), .Ll_exc)
458 LOAD t0, THREAD_BUADDR(t0) # t0 is just past last good address 468 LOAD t0, THREAD_BUADDR(t0) # t0 is just past last good address
459 nop 469 nop
460 SUB len, AT, t0 # len number of uncopied bytes 470 SUB len, AT, t0 # len number of uncopied bytes
471 bnez t6, .Ldone /* Skip the zeroing part if inatomic */
461 /* 472 /*
462 * Here's where we rely on src and dst being incremented in tandem, 473 * Here's where we rely on src and dst being incremented in tandem,
463 * See (3) above. 474 * See (3) above.
diff --git a/arch/mips/loongson/Kconfig b/arch/mips/loongson/Kconfig
index aca93eed877..263beb9322a 100644
--- a/arch/mips/loongson/Kconfig
+++ b/arch/mips/loongson/Kconfig
@@ -41,6 +41,7 @@ config LEMOTE_MACH2F
41 select CSRC_R4K if ! MIPS_EXTERNAL_TIMER 41 select CSRC_R4K if ! MIPS_EXTERNAL_TIMER
42 select DMA_NONCOHERENT 42 select DMA_NONCOHERENT
43 select GENERIC_ISA_DMA_SUPPORT_BROKEN 43 select GENERIC_ISA_DMA_SUPPORT_BROKEN
44 select HAVE_CLK
44 select HW_HAS_PCI 45 select HW_HAS_PCI
45 select I8259 46 select I8259
46 select IRQ_CPU 47 select IRQ_CPU
diff --git a/arch/mips/loongson/lemote-2f/Makefile b/arch/mips/loongson/lemote-2f/Makefile
index 8699a53f047..4f9eaa328a1 100644
--- a/arch/mips/loongson/lemote-2f/Makefile
+++ b/arch/mips/loongson/lemote-2f/Makefile
@@ -2,7 +2,7 @@
2# Makefile for lemote loongson2f family machines 2# Makefile for lemote loongson2f family machines
3# 3#
4 4
5obj-y += machtype.o irq.o reset.o ec_kb3310b.o 5obj-y += clock.o machtype.o irq.o reset.o ec_kb3310b.o
6 6
7# 7#
8# Suspend Support 8# Suspend Support
diff --git a/arch/mips/kernel/cpufreq/loongson2_clock.c b/arch/mips/loongson/lemote-2f/clock.c
index 5426779d9fd..bc739d4bab2 100644
--- a/arch/mips/kernel/cpufreq/loongson2_clock.c
+++ b/arch/mips/loongson/lemote-2f/clock.c
@@ -6,14 +6,17 @@
6 * License. See the file "COPYING" in the main directory of this archive 6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details. 7 * for more details.
8 */ 8 */
9 9#include <linux/clk.h>
10#include <linux/module.h>
11#include <linux/cpufreq.h> 10#include <linux/cpufreq.h>
12#include <linux/platform_device.h> 11#include <linux/errno.h>
12#include <linux/export.h>
13#include <linux/init.h>
14#include <linux/list.h>
15#include <linux/mutex.h>
16#include <linux/spinlock.h>
13 17
14#include <asm/clock.h> 18#include <asm/clock.h>
15 19#include <asm/mach-loongson/loongson.h>
16#include <loongson.h>
17 20
18static LIST_HEAD(clock_list); 21static LIST_HEAD(clock_list);
19static DEFINE_SPINLOCK(clock_lock); 22static DEFINE_SPINLOCK(clock_lock);
@@ -89,12 +92,6 @@ EXPORT_SYMBOL(clk_put);
89 92
90int clk_set_rate(struct clk *clk, unsigned long rate) 93int clk_set_rate(struct clk *clk, unsigned long rate)
91{ 94{
92 return clk_set_rate_ex(clk, rate, 0);
93}
94EXPORT_SYMBOL_GPL(clk_set_rate);
95
96int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id)
97{
98 int ret = 0; 95 int ret = 0;
99 int regval; 96 int regval;
100 int i; 97 int i;
@@ -103,7 +100,7 @@ int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id)
103 unsigned long flags; 100 unsigned long flags;
104 101
105 spin_lock_irqsave(&clock_lock, flags); 102 spin_lock_irqsave(&clock_lock, flags);
106 ret = clk->ops->set_rate(clk, rate, algo_id); 103 ret = clk->ops->set_rate(clk, rate, 0);
107 spin_unlock_irqrestore(&clock_lock, flags); 104 spin_unlock_irqrestore(&clock_lock, flags);
108 } 105 }
109 106
@@ -129,7 +126,7 @@ int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id)
129 126
130 return ret; 127 return ret;
131} 128}
132EXPORT_SYMBOL_GPL(clk_set_rate_ex); 129EXPORT_SYMBOL_GPL(clk_set_rate);
133 130
134long clk_round_rate(struct clk *clk, unsigned long rate) 131long clk_round_rate(struct clk *clk, unsigned long rate)
135{ 132{
@@ -146,26 +143,3 @@ long clk_round_rate(struct clk *clk, unsigned long rate)
146 return rate; 143 return rate;
147} 144}
148EXPORT_SYMBOL_GPL(clk_round_rate); 145EXPORT_SYMBOL_GPL(clk_round_rate);
149
150/*
151 * This is the simple version of Loongson-2 wait, Maybe we need do this in
152 * interrupt disabled content
153 */
154
155DEFINE_SPINLOCK(loongson2_wait_lock);
156void loongson2_cpu_wait(void)
157{
158 u32 cpu_freq;
159 unsigned long flags;
160
161 spin_lock_irqsave(&loongson2_wait_lock, flags);
162 cpu_freq = LOONGSON_CHIPCFG0;
163 LOONGSON_CHIPCFG0 &= ~0x7; /* Put CPU into wait mode */
164 LOONGSON_CHIPCFG0 = cpu_freq; /* Restore CPU state */
165 spin_unlock_irqrestore(&loongson2_wait_lock, flags);
166}
167EXPORT_SYMBOL_GPL(loongson2_cpu_wait);
168
169MODULE_AUTHOR("Yanhua <yanh@lemote.com>");
170MODULE_DESCRIPTION("cpufreq driver for Loongson 2F");
171MODULE_LICENSE("GPL");
diff --git a/arch/mips/loongson1/Kconfig b/arch/mips/loongson1/Kconfig
new file mode 100644
index 00000000000..a9a14d6e81a
--- /dev/null
+++ b/arch/mips/loongson1/Kconfig
@@ -0,0 +1,22 @@
1if MACH_LOONGSON1
2
3choice
4 prompt "Machine Type"
5
6config LOONGSON1_LS1B
7 bool "Loongson LS1B board"
8 select CEVT_R4K
9 select CSRC_R4K
10 select SYS_HAS_CPU_LOONGSON1B
11 select DMA_NONCOHERENT
12 select BOOT_ELF32
13 select IRQ_CPU
14 select SYS_SUPPORTS_32BIT_KERNEL
15 select SYS_SUPPORTS_LITTLE_ENDIAN
16 select SYS_SUPPORTS_HIGHMEM
17 select SYS_HAS_EARLY_PRINTK
18 select HAVE_CLK
19
20endchoice
21
22endif # MACH_LOONGSON1
diff --git a/arch/mips/loongson1/Makefile b/arch/mips/loongson1/Makefile
new file mode 100644
index 00000000000..9719c75886f
--- /dev/null
+++ b/arch/mips/loongson1/Makefile
@@ -0,0 +1,11 @@
1#
2# Common code for all Loongson 1 based systems
3#
4
5obj-$(CONFIG_MACH_LOONGSON1) += common/
6
7#
8# Loongson LS1B board
9#
10
11obj-$(CONFIG_LOONGSON1_LS1B) += ls1b/
diff --git a/arch/mips/loongson1/Platform b/arch/mips/loongson1/Platform
new file mode 100644
index 00000000000..99bdefe627a
--- /dev/null
+++ b/arch/mips/loongson1/Platform
@@ -0,0 +1,7 @@
1cflags-$(CONFIG_CPU_LOONGSON1) += \
2 $(call cc-option,-march=mips32r2,-mips32r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32) \
3 -Wa,-mips32r2 -Wa,--trap
4
5platform-$(CONFIG_MACH_LOONGSON1) += loongson1/
6cflags-$(CONFIG_MACH_LOONGSON1) += -I$(srctree)/arch/mips/include/asm/mach-loongson1
7load-$(CONFIG_LOONGSON1_LS1B) += 0xffffffff80100000
diff --git a/arch/mips/loongson1/common/Makefile b/arch/mips/loongson1/common/Makefile
new file mode 100644
index 00000000000..b2797709ef5
--- /dev/null
+++ b/arch/mips/loongson1/common/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for common code of loongson1 based machines.
3#
4
5obj-y += clock.o irq.o platform.o prom.o reset.o setup.o
diff --git a/arch/mips/loongson1/common/clock.c b/arch/mips/loongson1/common/clock.c
new file mode 100644
index 00000000000..1bbbbec1208
--- /dev/null
+++ b/arch/mips/loongson1/common/clock.c
@@ -0,0 +1,181 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#include <linux/module.h>
11#include <linux/list.h>
12#include <linux/mutex.h>
13#include <linux/clk.h>
14#include <linux/err.h>
15#include <asm/clock.h>
16#include <asm/time.h>
17
18#include <loongson1.h>
19
20static LIST_HEAD(clocks);
21static DEFINE_MUTEX(clocks_mutex);
22
23struct clk *clk_get(struct device *dev, const char *name)
24{
25 struct clk *c;
26 struct clk *ret = NULL;
27
28 mutex_lock(&clocks_mutex);
29 list_for_each_entry(c, &clocks, node) {
30 if (!strcmp(c->name, name)) {
31 ret = c;
32 break;
33 }
34 }
35 mutex_unlock(&clocks_mutex);
36
37 return ret;
38}
39EXPORT_SYMBOL(clk_get);
40
41int clk_enable(struct clk *clk)
42{
43 return 0;
44}
45EXPORT_SYMBOL(clk_enable);
46
47void clk_disable(struct clk *clk)
48{
49}
50EXPORT_SYMBOL(clk_disable);
51
52unsigned long clk_get_rate(struct clk *clk)
53{
54 return clk->rate;
55}
56EXPORT_SYMBOL(clk_get_rate);
57
58void clk_put(struct clk *clk)
59{
60}
61EXPORT_SYMBOL(clk_put);
62
63static void pll_clk_init(struct clk *clk)
64{
65 u32 pll;
66
67 pll = __raw_readl(LS1X_CLK_PLL_FREQ);
68 clk->rate = (12 + (pll & 0x3f)) * 33 / 2
69 + ((pll >> 8) & 0x3ff) * 33 / 1024 / 2;
70 clk->rate *= 1000000;
71}
72
73static void cpu_clk_init(struct clk *clk)
74{
75 u32 pll, ctrl;
76
77 pll = clk_get_rate(clk->parent);
78 ctrl = __raw_readl(LS1X_CLK_PLL_DIV) & DIV_CPU;
79 clk->rate = pll / (ctrl >> DIV_CPU_SHIFT);
80}
81
82static void ddr_clk_init(struct clk *clk)
83{
84 u32 pll, ctrl;
85
86 pll = clk_get_rate(clk->parent);
87 ctrl = __raw_readl(LS1X_CLK_PLL_DIV) & DIV_DDR;
88 clk->rate = pll / (ctrl >> DIV_DDR_SHIFT);
89}
90
91static void dc_clk_init(struct clk *clk)
92{
93 u32 pll, ctrl;
94
95 pll = clk_get_rate(clk->parent);
96 ctrl = __raw_readl(LS1X_CLK_PLL_DIV) & DIV_DC;
97 clk->rate = pll / (ctrl >> DIV_DC_SHIFT);
98}
99
100static struct clk_ops pll_clk_ops = {
101 .init = pll_clk_init,
102};
103
104static struct clk_ops cpu_clk_ops = {
105 .init = cpu_clk_init,
106};
107
108static struct clk_ops ddr_clk_ops = {
109 .init = ddr_clk_init,
110};
111
112static struct clk_ops dc_clk_ops = {
113 .init = dc_clk_init,
114};
115
116static struct clk pll_clk = {
117 .name = "pll",
118 .ops = &pll_clk_ops,
119};
120
121static struct clk cpu_clk = {
122 .name = "cpu",
123 .parent = &pll_clk,
124 .ops = &cpu_clk_ops,
125};
126
127static struct clk ddr_clk = {
128 .name = "ddr",
129 .parent = &pll_clk,
130 .ops = &ddr_clk_ops,
131};
132
133static struct clk dc_clk = {
134 .name = "dc",
135 .parent = &pll_clk,
136 .ops = &dc_clk_ops,
137};
138
139int clk_register(struct clk *clk)
140{
141 mutex_lock(&clocks_mutex);
142 list_add(&clk->node, &clocks);
143 if (clk->ops->init)
144 clk->ops->init(clk);
145 mutex_unlock(&clocks_mutex);
146
147 return 0;
148}
149EXPORT_SYMBOL(clk_register);
150
151static struct clk *ls1x_clks[] = {
152 &pll_clk,
153 &cpu_clk,
154 &ddr_clk,
155 &dc_clk,
156};
157
158int __init ls1x_clock_init(void)
159{
160 int i;
161
162 for (i = 0; i < ARRAY_SIZE(ls1x_clks); i++)
163 clk_register(ls1x_clks[i]);
164
165 return 0;
166}
167
168void __init plat_time_init(void)
169{
170 struct clk *clk;
171
172 /* Initialize LS1X clocks */
173 ls1x_clock_init();
174
175 /* setup mips r4k timer */
176 clk = clk_get(NULL, "cpu");
177 if (IS_ERR(clk))
178 panic("unable to get dc clock, err=%ld", PTR_ERR(clk));
179
180 mips_hpt_frequency = clk_get_rate(clk) / 2;
181}
diff --git a/arch/mips/loongson1/common/irq.c b/arch/mips/loongson1/common/irq.c
new file mode 100644
index 00000000000..41bc8ffe7bb
--- /dev/null
+++ b/arch/mips/loongson1/common/irq.c
@@ -0,0 +1,147 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#include <linux/interrupt.h>
11#include <linux/irq.h>
12#include <asm/irq_cpu.h>
13
14#include <loongson1.h>
15#include <irq.h>
16
17#define LS1X_INTC_REG(n, x) \
18 ((void __iomem *)KSEG1ADDR(LS1X_INTC_BASE + (n * 0x18) + (x)))
19
20#define LS1X_INTC_INTISR(n) LS1X_INTC_REG(n, 0x0)
21#define LS1X_INTC_INTIEN(n) LS1X_INTC_REG(n, 0x4)
22#define LS1X_INTC_INTSET(n) LS1X_INTC_REG(n, 0x8)
23#define LS1X_INTC_INTCLR(n) LS1X_INTC_REG(n, 0xc)
24#define LS1X_INTC_INTPOL(n) LS1X_INTC_REG(n, 0x10)
25#define LS1X_INTC_INTEDGE(n) LS1X_INTC_REG(n, 0x14)
26
27static void ls1x_irq_ack(struct irq_data *d)
28{
29 unsigned int bit = (d->irq - LS1X_IRQ_BASE) & 0x1f;
30 unsigned int n = (d->irq - LS1X_IRQ_BASE) >> 5;
31
32 __raw_writel(__raw_readl(LS1X_INTC_INTCLR(n))
33 | (1 << bit), LS1X_INTC_INTCLR(n));
34}
35
36static void ls1x_irq_mask(struct irq_data *d)
37{
38 unsigned int bit = (d->irq - LS1X_IRQ_BASE) & 0x1f;
39 unsigned int n = (d->irq - LS1X_IRQ_BASE) >> 5;
40
41 __raw_writel(__raw_readl(LS1X_INTC_INTIEN(n))
42 & ~(1 << bit), LS1X_INTC_INTIEN(n));
43}
44
45static void ls1x_irq_mask_ack(struct irq_data *d)
46{
47 unsigned int bit = (d->irq - LS1X_IRQ_BASE) & 0x1f;
48 unsigned int n = (d->irq - LS1X_IRQ_BASE) >> 5;
49
50 __raw_writel(__raw_readl(LS1X_INTC_INTIEN(n))
51 & ~(1 << bit), LS1X_INTC_INTIEN(n));
52 __raw_writel(__raw_readl(LS1X_INTC_INTCLR(n))
53 | (1 << bit), LS1X_INTC_INTCLR(n));
54}
55
56static void ls1x_irq_unmask(struct irq_data *d)
57{
58 unsigned int bit = (d->irq - LS1X_IRQ_BASE) & 0x1f;
59 unsigned int n = (d->irq - LS1X_IRQ_BASE) >> 5;
60
61 __raw_writel(__raw_readl(LS1X_INTC_INTIEN(n))
62 | (1 << bit), LS1X_INTC_INTIEN(n));
63}
64
65static struct irq_chip ls1x_irq_chip = {
66 .name = "LS1X-INTC",
67 .irq_ack = ls1x_irq_ack,
68 .irq_mask = ls1x_irq_mask,
69 .irq_mask_ack = ls1x_irq_mask_ack,
70 .irq_unmask = ls1x_irq_unmask,
71};
72
73static void ls1x_irq_dispatch(int n)
74{
75 u32 int_status, irq;
76
77 /* Get pending sources, masked by current enables */
78 int_status = __raw_readl(LS1X_INTC_INTISR(n)) &
79 __raw_readl(LS1X_INTC_INTIEN(n));
80
81 if (int_status) {
82 irq = LS1X_IRQ(n, __ffs(int_status));
83 do_IRQ(irq);
84 }
85}
86
87asmlinkage void plat_irq_dispatch(void)
88{
89 unsigned int pending;
90
91 pending = read_c0_cause() & read_c0_status() & ST0_IM;
92
93 if (pending & CAUSEF_IP7)
94 do_IRQ(TIMER_IRQ);
95 else if (pending & CAUSEF_IP2)
96 ls1x_irq_dispatch(0); /* INT0 */
97 else if (pending & CAUSEF_IP3)
98 ls1x_irq_dispatch(1); /* INT1 */
99 else if (pending & CAUSEF_IP4)
100 ls1x_irq_dispatch(2); /* INT2 */
101 else if (pending & CAUSEF_IP5)
102 ls1x_irq_dispatch(3); /* INT3 */
103 else if (pending & CAUSEF_IP6)
104 ls1x_irq_dispatch(4); /* INT4 */
105 else
106 spurious_interrupt();
107
108}
109
110struct irqaction cascade_irqaction = {
111 .handler = no_action,
112 .name = "cascade",
113 .flags = IRQF_NO_THREAD,
114};
115
116static void __init ls1x_irq_init(int base)
117{
118 int n;
119
120 /* Disable interrupts and clear pending,
121 * setup all IRQs as high level triggered
122 */
123 for (n = 0; n < 4; n++) {
124 __raw_writel(0x0, LS1X_INTC_INTIEN(n));
125 __raw_writel(0xffffffff, LS1X_INTC_INTCLR(n));
126 __raw_writel(0xffffffff, LS1X_INTC_INTPOL(n));
127 /* set DMA0, DMA1 and DMA2 to edge trigger */
128 __raw_writel(n ? 0x0 : 0xe000, LS1X_INTC_INTEDGE(n));
129 }
130
131
132 for (n = base; n < LS1X_IRQS; n++) {
133 irq_set_chip_and_handler(n, &ls1x_irq_chip,
134 handle_level_irq);
135 }
136
137 setup_irq(INT0_IRQ, &cascade_irqaction);
138 setup_irq(INT1_IRQ, &cascade_irqaction);
139 setup_irq(INT2_IRQ, &cascade_irqaction);
140 setup_irq(INT3_IRQ, &cascade_irqaction);
141}
142
143void __init arch_init_irq(void)
144{
145 mips_cpu_irq_init();
146 ls1x_irq_init(LS1X_IRQ_BASE);
147}
diff --git a/arch/mips/loongson1/common/platform.c b/arch/mips/loongson1/common/platform.c
new file mode 100644
index 00000000000..e92d59c4bd7
--- /dev/null
+++ b/arch/mips/loongson1/common/platform.c
@@ -0,0 +1,124 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#include <linux/clk.h>
11#include <linux/dma-mapping.h>
12#include <linux/err.h>
13#include <linux/phy.h>
14#include <linux/serial_8250.h>
15#include <linux/stmmac.h>
16#include <asm-generic/sizes.h>
17
18#include <loongson1.h>
19
20#define LS1X_UART(_id) \
21 { \
22 .mapbase = LS1X_UART ## _id ## _BASE, \
23 .irq = LS1X_UART ## _id ## _IRQ, \
24 .iotype = UPIO_MEM, \
25 .flags = UPF_IOREMAP | UPF_FIXED_TYPE, \
26 .type = PORT_16550A, \
27 }
28
29static struct plat_serial8250_port ls1x_serial8250_port[] = {
30 LS1X_UART(0),
31 LS1X_UART(1),
32 LS1X_UART(2),
33 LS1X_UART(3),
34 {},
35};
36
37struct platform_device ls1x_uart_device = {
38 .name = "serial8250",
39 .id = PLAT8250_DEV_PLATFORM,
40 .dev = {
41 .platform_data = ls1x_serial8250_port,
42 },
43};
44
45void __init ls1x_serial_setup(void)
46{
47 struct clk *clk;
48 struct plat_serial8250_port *p;
49
50 clk = clk_get(NULL, "dc");
51 if (IS_ERR(clk))
52 panic("unable to get dc clock, err=%ld", PTR_ERR(clk));
53
54 for (p = ls1x_serial8250_port; p->flags != 0; ++p)
55 p->uartclk = clk_get_rate(clk);
56}
57
58/* Synopsys Ethernet GMAC */
59static struct resource ls1x_eth0_resources[] = {
60 [0] = {
61 .start = LS1X_GMAC0_BASE,
62 .end = LS1X_GMAC0_BASE + SZ_64K - 1,
63 .flags = IORESOURCE_MEM,
64 },
65 [1] = {
66 .name = "macirq",
67 .start = LS1X_GMAC0_IRQ,
68 .flags = IORESOURCE_IRQ,
69 },
70};
71
72static struct stmmac_mdio_bus_data ls1x_mdio_bus_data = {
73 .bus_id = 0,
74 .phy_mask = 0,
75};
76
77static struct plat_stmmacenet_data ls1x_eth_data = {
78 .bus_id = 0,
79 .phy_addr = -1,
80 .mdio_bus_data = &ls1x_mdio_bus_data,
81 .has_gmac = 1,
82 .tx_coe = 1,
83};
84
85struct platform_device ls1x_eth0_device = {
86 .name = "stmmaceth",
87 .id = 0,
88 .num_resources = ARRAY_SIZE(ls1x_eth0_resources),
89 .resource = ls1x_eth0_resources,
90 .dev = {
91 .platform_data = &ls1x_eth_data,
92 },
93};
94
95/* USB EHCI */
96static u64 ls1x_ehci_dmamask = DMA_BIT_MASK(32);
97
98static struct resource ls1x_ehci_resources[] = {
99 [0] = {
100 .start = LS1X_EHCI_BASE,
101 .end = LS1X_EHCI_BASE + SZ_32K - 1,
102 .flags = IORESOURCE_MEM,
103 },
104 [1] = {
105 .start = LS1X_EHCI_IRQ,
106 .flags = IORESOURCE_IRQ,
107 },
108};
109
110struct platform_device ls1x_ehci_device = {
111 .name = "ls1x-ehci",
112 .id = -1,
113 .num_resources = ARRAY_SIZE(ls1x_ehci_resources),
114 .resource = ls1x_ehci_resources,
115 .dev = {
116 .dma_mask = &ls1x_ehci_dmamask,
117 },
118};
119
120/* Real Time Clock */
121struct platform_device ls1x_rtc_device = {
122 .name = "ls1x-rtc",
123 .id = -1,
124};
diff --git a/arch/mips/loongson1/common/prom.c b/arch/mips/loongson1/common/prom.c
new file mode 100644
index 00000000000..1f8e49f9886
--- /dev/null
+++ b/arch/mips/loongson1/common/prom.c
@@ -0,0 +1,87 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * Modified from arch/mips/pnx833x/common/prom.c.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/serial_reg.h>
13#include <asm/bootinfo.h>
14
15#include <loongson1.h>
16#include <prom.h>
17
18int prom_argc;
19char **prom_argv, **prom_envp;
20unsigned long memsize, highmemsize;
21
22char *prom_getenv(char *envname)
23{
24 char **env = prom_envp;
25 int i;
26
27 i = strlen(envname);
28
29 while (*env) {
30 if (strncmp(envname, *env, i) == 0 && *(*env+i) == '=')
31 return *env + i + 1;
32 env++;
33 }
34
35 return 0;
36}
37
38static inline unsigned long env_or_default(char *env, unsigned long dfl)
39{
40 char *str = prom_getenv(env);
41 return str ? simple_strtol(str, 0, 0) : dfl;
42}
43
44void __init prom_init_cmdline(void)
45{
46 char *c = &(arcs_cmdline[0]);
47 int i;
48
49 for (i = 1; i < prom_argc; i++) {
50 strcpy(c, prom_argv[i]);
51 c += strlen(prom_argv[i]);
52 if (i < prom_argc-1)
53 *c++ = ' ';
54 }
55 *c = 0;
56}
57
58void __init prom_init(void)
59{
60 prom_argc = fw_arg0;
61 prom_argv = (char **)fw_arg1;
62 prom_envp = (char **)fw_arg2;
63
64 prom_init_cmdline();
65
66 memsize = env_or_default("memsize", DEFAULT_MEMSIZE);
67 highmemsize = env_or_default("highmemsize", 0x0);
68}
69
70void __init prom_free_prom_memory(void)
71{
72}
73
74#define PORT(offset) (u8 *)(KSEG1ADDR(LS1X_UART0_BASE + offset))
75
76void __init prom_putchar(char c)
77{
78 int timeout;
79
80 timeout = 1024;
81
82 while (((readb(PORT(UART_LSR)) & UART_LSR_THRE) == 0)
83 && (timeout-- > 0))
84 ;
85
86 writeb(c, PORT(UART_TX));
87}
diff --git a/arch/mips/loongson1/common/reset.c b/arch/mips/loongson1/common/reset.c
new file mode 100644
index 00000000000..fb979a784ec
--- /dev/null
+++ b/arch/mips/loongson1/common/reset.c
@@ -0,0 +1,45 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#include <linux/io.h>
11#include <linux/pm.h>
12#include <asm/reboot.h>
13
14#include <loongson1.h>
15
16static void ls1x_restart(char *command)
17{
18 __raw_writel(0x1, LS1X_WDT_EN);
19 __raw_writel(0x5000000, LS1X_WDT_TIMER);
20 __raw_writel(0x1, LS1X_WDT_SET);
21}
22
23static void ls1x_halt(void)
24{
25 while (1) {
26 if (cpu_wait)
27 cpu_wait();
28 }
29}
30
31static void ls1x_power_off(void)
32{
33 ls1x_halt();
34}
35
36static int __init ls1x_reboot_setup(void)
37{
38 _machine_restart = ls1x_restart;
39 _machine_halt = ls1x_halt;
40 pm_power_off = ls1x_power_off;
41
42 return 0;
43}
44
45arch_initcall(ls1x_reboot_setup);
diff --git a/arch/mips/loongson1/common/setup.c b/arch/mips/loongson1/common/setup.c
new file mode 100644
index 00000000000..62128cc27e6
--- /dev/null
+++ b/arch/mips/loongson1/common/setup.c
@@ -0,0 +1,29 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#include <asm/bootinfo.h>
11
12#include <prom.h>
13
14void __init plat_mem_setup(void)
15{
16 add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM);
17}
18
19const char *get_system_type(void)
20{
21 unsigned int processor_id = (&current_cpu_data)->processor_id;
22
23 switch (processor_id & PRID_REV_MASK) {
24 case PRID_REV_LOONGSON1B:
25 return "LOONGSON LS1B";
26 default:
27 return "LOONGSON (unknown)";
28 }
29}
diff --git a/arch/mips/loongson1/ls1b/Makefile b/arch/mips/loongson1/ls1b/Makefile
new file mode 100644
index 00000000000..891eac482b8
--- /dev/null
+++ b/arch/mips/loongson1/ls1b/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for loongson1B based machines.
3#
4
5obj-y += board.o
diff --git a/arch/mips/loongson1/ls1b/board.c b/arch/mips/loongson1/ls1b/board.c
new file mode 100644
index 00000000000..295b1be893e
--- /dev/null
+++ b/arch/mips/loongson1/ls1b/board.c
@@ -0,0 +1,33 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#include <platform.h>
11
12#include <linux/serial_8250.h>
13#include <loongson1.h>
14
15static struct platform_device *ls1b_platform_devices[] __initdata = {
16 &ls1x_uart_device,
17 &ls1x_eth0_device,
18 &ls1x_ehci_device,
19 &ls1x_rtc_device,
20};
21
22static int __init ls1b_platform_init(void)
23{
24 int err;
25
26 ls1x_serial_setup();
27
28 err = platform_add_devices(ls1b_platform_devices,
29 ARRAY_SIZE(ls1b_platform_devices));
30 return err;
31}
32
33arch_initcall(ls1b_platform_init);
diff --git a/arch/mips/mm/uasm.c b/arch/mips/mm/uasm.c
index 5fa185151fc..64a28e81906 100644
--- a/arch/mips/mm/uasm.c
+++ b/arch/mips/mm/uasm.c
@@ -58,18 +58,16 @@ enum fields {
58 58
59enum opcode { 59enum opcode {
60 insn_invalid, 60 insn_invalid,
61 insn_addu, insn_addiu, insn_and, insn_andi, insn_beq, 61 insn_addiu, insn_addu, insn_and, insn_andi, insn_bbit0, insn_bbit1,
62 insn_beql, insn_bgez, insn_bgezl, insn_bltz, insn_bltzl, 62 insn_beq, insn_beql, insn_bgez, insn_bgezl, insn_bltz, insn_bltzl,
63 insn_bne, insn_cache, insn_daddu, insn_daddiu, insn_dmfc0, 63 insn_bne, insn_cache, insn_daddiu, insn_daddu, insn_dins, insn_dinsm,
64 insn_dmtc0, insn_dsll, insn_dsll32, insn_dsra, insn_dsrl, 64 insn_dmfc0, insn_dmtc0, insn_drotr, insn_drotr32, insn_dsll,
65 insn_dsrl32, insn_drotr, insn_drotr32, insn_dsubu, insn_eret, 65 insn_dsll32, insn_dsra, insn_dsrl, insn_dsrl32, insn_dsubu, insn_eret,
66 insn_j, insn_jal, insn_jr, insn_ld, insn_ll, insn_lld, 66 insn_j, insn_jal, insn_jr, insn_ld, insn_ldx, insn_ll, insn_lld,
67 insn_lui, insn_lw, insn_mfc0, insn_mtc0, insn_or, insn_ori, 67 insn_lui, insn_lw, insn_lwx, insn_mfc0, insn_mtc0, insn_or, insn_ori,
68 insn_pref, insn_rfe, insn_sc, insn_scd, insn_sd, insn_sll, 68 insn_pref, insn_rfe, insn_rotr, insn_sc, insn_scd, insn_sd, insn_sll,
69 insn_sra, insn_srl, insn_rotr, insn_subu, insn_sw, insn_tlbp, 69 insn_sra, insn_srl, insn_subu, insn_sw, insn_syscall, insn_tlbp,
70 insn_tlbr, insn_tlbwi, insn_tlbwr, insn_xor, insn_xori, 70 insn_tlbr, insn_tlbwi, insn_tlbwr, insn_xor, insn_xori,
71 insn_dins, insn_dinsm, insn_syscall, insn_bbit0, insn_bbit1,
72 insn_lwx, insn_ldx
73}; 71};
74 72
75struct insn { 73struct insn {
@@ -90,65 +88,65 @@ struct insn {
90static struct insn insn_table[] __uasminitdata = { 88static struct insn insn_table[] __uasminitdata = {
91 { insn_addiu, M(addiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 89 { insn_addiu, M(addiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
92 { insn_addu, M(spec_op, 0, 0, 0, 0, addu_op), RS | RT | RD }, 90 { insn_addu, M(spec_op, 0, 0, 0, 0, addu_op), RS | RT | RD },
93 { insn_and, M(spec_op, 0, 0, 0, 0, and_op), RS | RT | RD },
94 { insn_andi, M(andi_op, 0, 0, 0, 0, 0), RS | RT | UIMM }, 91 { insn_andi, M(andi_op, 0, 0, 0, 0, 0), RS | RT | UIMM },
95 { insn_beq, M(beq_op, 0, 0, 0, 0, 0), RS | RT | BIMM }, 92 { insn_and, M(spec_op, 0, 0, 0, 0, and_op), RS | RT | RD },
93 { insn_bbit0, M(lwc2_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
94 { insn_bbit1, M(swc2_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
96 { insn_beql, M(beql_op, 0, 0, 0, 0, 0), RS | RT | BIMM }, 95 { insn_beql, M(beql_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
97 { insn_bgez, M(bcond_op, 0, bgez_op, 0, 0, 0), RS | BIMM }, 96 { insn_beq, M(beq_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
98 { insn_bgezl, M(bcond_op, 0, bgezl_op, 0, 0, 0), RS | BIMM }, 97 { insn_bgezl, M(bcond_op, 0, bgezl_op, 0, 0, 0), RS | BIMM },
99 { insn_bltz, M(bcond_op, 0, bltz_op, 0, 0, 0), RS | BIMM }, 98 { insn_bgez, M(bcond_op, 0, bgez_op, 0, 0, 0), RS | BIMM },
100 { insn_bltzl, M(bcond_op, 0, bltzl_op, 0, 0, 0), RS | BIMM }, 99 { insn_bltzl, M(bcond_op, 0, bltzl_op, 0, 0, 0), RS | BIMM },
100 { insn_bltz, M(bcond_op, 0, bltz_op, 0, 0, 0), RS | BIMM },
101 { insn_bne, M(bne_op, 0, 0, 0, 0, 0), RS | RT | BIMM }, 101 { insn_bne, M(bne_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
102 { insn_cache, M(cache_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 102 { insn_cache, M(cache_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
103 { insn_daddiu, M(daddiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 103 { insn_daddiu, M(daddiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
104 { insn_daddu, M(spec_op, 0, 0, 0, 0, daddu_op), RS | RT | RD }, 104 { insn_daddu, M(spec_op, 0, 0, 0, 0, daddu_op), RS | RT | RD },
105 { insn_dinsm, M(spec3_op, 0, 0, 0, 0, dinsm_op), RS | RT | RD | RE },
106 { insn_dins, M(spec3_op, 0, 0, 0, 0, dins_op), RS | RT | RD | RE },
105 { insn_dmfc0, M(cop0_op, dmfc_op, 0, 0, 0, 0), RT | RD | SET}, 107 { insn_dmfc0, M(cop0_op, dmfc_op, 0, 0, 0, 0), RT | RD | SET},
106 { insn_dmtc0, M(cop0_op, dmtc_op, 0, 0, 0, 0), RT | RD | SET}, 108 { insn_dmtc0, M(cop0_op, dmtc_op, 0, 0, 0, 0), RT | RD | SET},
107 { insn_dsll, M(spec_op, 0, 0, 0, 0, dsll_op), RT | RD | RE }, 109 { insn_drotr32, M(spec_op, 1, 0, 0, 0, dsrl32_op), RT | RD | RE },
110 { insn_drotr, M(spec_op, 1, 0, 0, 0, dsrl_op), RT | RD | RE },
108 { insn_dsll32, M(spec_op, 0, 0, 0, 0, dsll32_op), RT | RD | RE }, 111 { insn_dsll32, M(spec_op, 0, 0, 0, 0, dsll32_op), RT | RD | RE },
112 { insn_dsll, M(spec_op, 0, 0, 0, 0, dsll_op), RT | RD | RE },
109 { insn_dsra, M(spec_op, 0, 0, 0, 0, dsra_op), RT | RD | RE }, 113 { insn_dsra, M(spec_op, 0, 0, 0, 0, dsra_op), RT | RD | RE },
110 { insn_dsrl, M(spec_op, 0, 0, 0, 0, dsrl_op), RT | RD | RE },
111 { insn_dsrl32, M(spec_op, 0, 0, 0, 0, dsrl32_op), RT | RD | RE }, 114 { insn_dsrl32, M(spec_op, 0, 0, 0, 0, dsrl32_op), RT | RD | RE },
112 { insn_drotr, M(spec_op, 1, 0, 0, 0, dsrl_op), RT | RD | RE }, 115 { insn_dsrl, M(spec_op, 0, 0, 0, 0, dsrl_op), RT | RD | RE },
113 { insn_drotr32, M(spec_op, 1, 0, 0, 0, dsrl32_op), RT | RD | RE },
114 { insn_dsubu, M(spec_op, 0, 0, 0, 0, dsubu_op), RS | RT | RD }, 116 { insn_dsubu, M(spec_op, 0, 0, 0, 0, dsubu_op), RS | RT | RD },
115 { insn_eret, M(cop0_op, cop_op, 0, 0, 0, eret_op), 0 }, 117 { insn_eret, M(cop0_op, cop_op, 0, 0, 0, eret_op), 0 },
116 { insn_j, M(j_op, 0, 0, 0, 0, 0), JIMM },
117 { insn_jal, M(jal_op, 0, 0, 0, 0, 0), JIMM }, 118 { insn_jal, M(jal_op, 0, 0, 0, 0, 0), JIMM },
119 { insn_j, M(j_op, 0, 0, 0, 0, 0), JIMM },
118 { insn_jr, M(spec_op, 0, 0, 0, 0, jr_op), RS }, 120 { insn_jr, M(spec_op, 0, 0, 0, 0, jr_op), RS },
119 { insn_ld, M(ld_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 121 { insn_ld, M(ld_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
120 { insn_ll, M(ll_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 122 { insn_ldx, M(spec3_op, 0, 0, 0, ldx_op, lx_op), RS | RT | RD },
121 { insn_lld, M(lld_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 123 { insn_lld, M(lld_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
124 { insn_ll, M(ll_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
122 { insn_lui, M(lui_op, 0, 0, 0, 0, 0), RT | SIMM }, 125 { insn_lui, M(lui_op, 0, 0, 0, 0, 0), RT | SIMM },
123 { insn_lw, M(lw_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 126 { insn_lw, M(lw_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
127 { insn_lwx, M(spec3_op, 0, 0, 0, lwx_op, lx_op), RS | RT | RD },
124 { insn_mfc0, M(cop0_op, mfc_op, 0, 0, 0, 0), RT | RD | SET}, 128 { insn_mfc0, M(cop0_op, mfc_op, 0, 0, 0, 0), RT | RD | SET},
125 { insn_mtc0, M(cop0_op, mtc_op, 0, 0, 0, 0), RT | RD | SET}, 129 { insn_mtc0, M(cop0_op, mtc_op, 0, 0, 0, 0), RT | RD | SET},
126 { insn_or, M(spec_op, 0, 0, 0, 0, or_op), RS | RT | RD },
127 { insn_ori, M(ori_op, 0, 0, 0, 0, 0), RS | RT | UIMM }, 130 { insn_ori, M(ori_op, 0, 0, 0, 0, 0), RS | RT | UIMM },
131 { insn_or, M(spec_op, 0, 0, 0, 0, or_op), RS | RT | RD },
128 { insn_pref, M(pref_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 132 { insn_pref, M(pref_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
129 { insn_rfe, M(cop0_op, cop_op, 0, 0, 0, rfe_op), 0 }, 133 { insn_rfe, M(cop0_op, cop_op, 0, 0, 0, rfe_op), 0 },
130 { insn_sc, M(sc_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 134 { insn_rotr, M(spec_op, 1, 0, 0, 0, srl_op), RT | RD | RE },
131 { insn_scd, M(scd_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 135 { insn_scd, M(scd_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
136 { insn_sc, M(sc_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
132 { insn_sd, M(sd_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 137 { insn_sd, M(sd_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
133 { insn_sll, M(spec_op, 0, 0, 0, 0, sll_op), RT | RD | RE }, 138 { insn_sll, M(spec_op, 0, 0, 0, 0, sll_op), RT | RD | RE },
134 { insn_sra, M(spec_op, 0, 0, 0, 0, sra_op), RT | RD | RE }, 139 { insn_sra, M(spec_op, 0, 0, 0, 0, sra_op), RT | RD | RE },
135 { insn_srl, M(spec_op, 0, 0, 0, 0, srl_op), RT | RD | RE }, 140 { insn_srl, M(spec_op, 0, 0, 0, 0, srl_op), RT | RD | RE },
136 { insn_rotr, M(spec_op, 1, 0, 0, 0, srl_op), RT | RD | RE },
137 { insn_subu, M(spec_op, 0, 0, 0, 0, subu_op), RS | RT | RD }, 141 { insn_subu, M(spec_op, 0, 0, 0, 0, subu_op), RS | RT | RD },
138 { insn_sw, M(sw_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 142 { insn_sw, M(sw_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
143 { insn_syscall, M(spec_op, 0, 0, 0, 0, syscall_op), SCIMM},
139 { insn_tlbp, M(cop0_op, cop_op, 0, 0, 0, tlbp_op), 0 }, 144 { insn_tlbp, M(cop0_op, cop_op, 0, 0, 0, tlbp_op), 0 },
140 { insn_tlbr, M(cop0_op, cop_op, 0, 0, 0, tlbr_op), 0 }, 145 { insn_tlbr, M(cop0_op, cop_op, 0, 0, 0, tlbr_op), 0 },
141 { insn_tlbwi, M(cop0_op, cop_op, 0, 0, 0, tlbwi_op), 0 }, 146 { insn_tlbwi, M(cop0_op, cop_op, 0, 0, 0, tlbwi_op), 0 },
142 { insn_tlbwr, M(cop0_op, cop_op, 0, 0, 0, tlbwr_op), 0 }, 147 { insn_tlbwr, M(cop0_op, cop_op, 0, 0, 0, tlbwr_op), 0 },
143 { insn_xor, M(spec_op, 0, 0, 0, 0, xor_op), RS | RT | RD },
144 { insn_xori, M(xori_op, 0, 0, 0, 0, 0), RS | RT | UIMM }, 148 { insn_xori, M(xori_op, 0, 0, 0, 0, 0), RS | RT | UIMM },
145 { insn_dins, M(spec3_op, 0, 0, 0, 0, dins_op), RS | RT | RD | RE }, 149 { insn_xor, M(spec_op, 0, 0, 0, 0, xor_op), RS | RT | RD },
146 { insn_dinsm, M(spec3_op, 0, 0, 0, 0, dinsm_op), RS | RT | RD | RE },
147 { insn_syscall, M(spec_op, 0, 0, 0, 0, syscall_op), SCIMM},
148 { insn_bbit0, M(lwc2_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
149 { insn_bbit1, M(swc2_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
150 { insn_lwx, M(spec3_op, 0, 0, 0, lwx_op, lx_op), RS | RT | RD },
151 { insn_ldx, M(spec3_op, 0, 0, 0, ldx_op, lx_op), RS | RT | RD },
152 { insn_invalid, 0, 0 } 150 { insn_invalid, 0, 0 }
153}; 151};
154 152
diff --git a/arch/mips/mti-malta/malta-pci.c b/arch/mips/mti-malta/malta-pci.c
index 284dea54faf..2147cb34e70 100644
--- a/arch/mips/mti-malta/malta-pci.c
+++ b/arch/mips/mti-malta/malta-pci.c
@@ -252,16 +252,3 @@ void __init mips_pcibios_init(void)
252 252
253 register_pci_controller(controller); 253 register_pci_controller(controller);
254} 254}
255
256/* Enable PCI 2.1 compatibility in PIIX4 */
257static void __devinit quirk_dlcsetup(struct pci_dev *dev)
258{
259 u8 odlc, ndlc;
260 (void) pci_read_config_byte(dev, 0x82, &odlc);
261 /* Enable passive releases and delayed transaction */
262 ndlc = odlc | 7;
263 (void) pci_write_config_byte(dev, 0x82, ndlc);
264}
265
266DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_0,
267 quirk_dlcsetup);
diff --git a/arch/mips/netlogic/common/earlycons.c b/arch/mips/netlogic/common/earlycons.c
index f193f7b3bd8..1902fa22d27 100644
--- a/arch/mips/netlogic/common/earlycons.c
+++ b/arch/mips/netlogic/common/earlycons.c
@@ -54,7 +54,7 @@ void prom_putchar(char c)
54#elif defined(CONFIG_CPU_XLR) 54#elif defined(CONFIG_CPU_XLR)
55 uartbase = nlm_mmio_base(NETLOGIC_IO_UART_0_OFFSET); 55 uartbase = nlm_mmio_base(NETLOGIC_IO_UART_0_OFFSET);
56#endif 56#endif
57 while (nlm_read_reg(uartbase, UART_LSR) == 0) 57 while ((nlm_read_reg(uartbase, UART_LSR) & UART_LSR_THRE) == 0)
58 ; 58 ;
59 nlm_write_reg(uartbase, UART_TX, c); 59 nlm_write_reg(uartbase, UART_TX, c);
60} 60}
diff --git a/arch/mips/netlogic/common/smpboot.S b/arch/mips/netlogic/common/smpboot.S
index c138b1a6dec..a13355cc97e 100644
--- a/arch/mips/netlogic/common/smpboot.S
+++ b/arch/mips/netlogic/common/smpboot.S
@@ -54,28 +54,68 @@
54 XLP_IO_SYS_OFFSET(node) + XLP_IO_PCI_HDRSZ + \ 54 XLP_IO_SYS_OFFSET(node) + XLP_IO_PCI_HDRSZ + \
55 SYS_CPU_NONCOHERENT_MODE * 4 55 SYS_CPU_NONCOHERENT_MODE * 4
56 56
57.macro __config_lsu 57#define XLP_AX_WORKAROUND /* enable Ax silicon workarounds */
58 li t0, LSU_DEFEATURE
59 mfcr t1, t0
60 58
61 lui t2, 0x4080 /* Enable Unaligned Access, L2HPE */ 59/* Enable XLP features and workarounds in the LSU */
62 or t1, t1, t2 60.macro xlp_config_lsu
63 li t2, ~0xe /* S1RCM */ 61 li t0, LSU_DEFEATURE
62 mfcr t1, t0
63
64 lui t2, 0x4080 /* Enable Unaligned Access, L2HPE */
65 or t1, t1, t2
66#ifdef XLP_AX_WORKAROUND
67 li t2, ~0xe /* S1RCM */
64 and t1, t1, t2 68 and t1, t1, t2
65 mtcr t1, t0 69#endif
70 mtcr t1, t0
66 71
67 li t0, SCHED_DEFEATURE 72#ifdef XLP_AX_WORKAROUND
68 lui t1, 0x0100 /* Experimental: Disable BRU accepting ALU ops */ 73 li t0, SCHED_DEFEATURE
69 mtcr t1, t0 74 lui t1, 0x0100 /* Disable BRU accepting ALU ops */
75 mtcr t1, t0
76#endif
77.endm
78
79/*
80 * This is the code that will be copied to the reset entry point for
81 * XLR and XLP. The XLP cores start here when they are woken up. This
82 * is also the NMI entry point.
83 */
84.macro xlp_flush_l1_dcache
85 li t0, LSU_DEBUG_DATA0
86 li t1, LSU_DEBUG_ADDR
87 li t2, 0 /* index */
88 li t3, 0x1000 /* loop count */
891:
90 sll v0, t2, 5
91 mtcr zero, t0
92 ori v1, v0, 0x3 /* way0 | write_enable | write_active */
93 mtcr v1, t1
942:
95 mfcr v1, t1
96 andi v1, 0x1 /* wait for write_active == 0 */
97 bnez v1, 2b
98 nop
99 mtcr zero, t0
100 ori v1, v0, 0x7 /* way1 | write_enable | write_active */
101 mtcr v1, t1
1023:
103 mfcr v1, t1
104 andi v1, 0x1 /* wait for write_active == 0 */
105 bnez v1, 3b
106 nop
107 addi t2, 1
108 bne t3, t2, 1b
109 nop
70.endm 110.endm
71 111
72/* 112/*
73 * The cores can come start when they are woken up. This is also the NMI 113 * The cores can come start when they are woken up. This is also the NMI
74 * entry, so check that first. 114 * entry, so check that first.
75 * 115 *
76 * The data corresponding to reset is stored at RESET_DATA_PHYS location, 116 * The data corresponding to reset/NMI is stored at RESET_DATA_PHYS
77 * this will have the thread mask (used when core is woken up) and the 117 * location, this will have the thread mask (used when core is woken up)
78 * current NMI handler in case we reached here for an NMI. 118 * and the current NMI handler in case we reached here for an NMI.
79 * 119 *
80 * When a core or thread is newly woken up, it loops in a 'wait'. When 120 * When a core or thread is newly woken up, it loops in a 'wait'. When
81 * the CPU really needs waking up, we send an NMI to it, with the NMI 121 * the CPU really needs waking up, we send an NMI to it, with the NMI
@@ -89,12 +129,12 @@
89FEXPORT(nlm_reset_entry) 129FEXPORT(nlm_reset_entry)
90 dmtc0 k0, $22, 6 130 dmtc0 k0, $22, 6
91 dmtc0 k1, $22, 7 131 dmtc0 k1, $22, 7
92 mfc0 k0, CP0_STATUS 132 mfc0 k0, CP0_STATUS
93 li k1, 0x80000 133 li k1, 0x80000
94 and k1, k0, k1 134 and k1, k0, k1
95 beqz k1, 1f /* go to real reset entry */ 135 beqz k1, 1f /* go to real reset entry */
96 nop 136 nop
97 li k1, CKSEG1ADDR(RESET_DATA_PHYS) /* NMI */ 137 li k1, CKSEG1ADDR(RESET_DATA_PHYS) /* NMI */
98 ld k0, BOOT_NMI_HANDLER(k1) 138 ld k0, BOOT_NMI_HANDLER(k1)
99 jr k0 139 jr k0
100 nop 140 nop
@@ -114,21 +154,25 @@ FEXPORT(nlm_reset_entry)
114 li t2, SYS_CPU_COHERENT_BASE(0) 154 li t2, SYS_CPU_COHERENT_BASE(0)
115 add t2, t2, t3 /* t2 <- SYS offset for node */ 155 add t2, t2, t3 /* t2 <- SYS offset for node */
116 lw t1, 0(t2) 156 lw t1, 0(t2)
117 and t1, t1, t0 157 and t1, t1, t0
118 sw t1, 0(t2) 158 sw t1, 0(t2)
119 159
120 /* read back to ensure complete */ 160 /* read back to ensure complete */
121 lw t1, 0(t2) 161 lw t1, 0(t2)
122 sync 162 sync
123 163
124 /* Configure LSU on Non-0 Cores. */ 164 /* Configure LSU on Non-0 Cores. */
125 __config_lsu 165 xlp_config_lsu
166 /* FALL THROUGH */
126 167
127/* 168/*
128 * Wake up sibling threads from the initial thread in 169 * Wake up sibling threads from the initial thread in
129 * a core. 170 * a core.
130 */ 171 */
131EXPORT(nlm_boot_siblings) 172EXPORT(nlm_boot_siblings)
173 /* core L1D flush before enable threads */
174 xlp_flush_l1_dcache
175 /* Enable hw threads by writing to MAP_THREADMODE of the core */
132 li t0, CKSEG1ADDR(RESET_DATA_PHYS) 176 li t0, CKSEG1ADDR(RESET_DATA_PHYS)
133 lw t1, BOOT_THREAD_MODE(t0) /* t1 <- thread mode */ 177 lw t1, BOOT_THREAD_MODE(t0) /* t1 <- thread mode */
134 li t0, ((CPU_BLOCKID_MAP << 8) | MAP_THREADMODE) 178 li t0, ((CPU_BLOCKID_MAP << 8) | MAP_THREADMODE)
@@ -139,31 +183,28 @@ EXPORT(nlm_boot_siblings)
139 /* 183 /*
140 * The new hardware thread starts at the next instruction 184 * The new hardware thread starts at the next instruction
141 * For all the cases other than core 0 thread 0, we will 185 * For all the cases other than core 0 thread 0, we will
142 * jump to the secondary wait function. 186 * jump to the secondary wait function.
143 */ 187 */
144 mfc0 v0, CP0_EBASE, 1 188 mfc0 v0, CP0_EBASE, 1
145 andi v0, 0x7f /* v0 <- node/core */ 189 andi v0, 0x7f /* v0 <- node/core */
146 190
147#if 1 191 /* Init MMU in the first thread after changing THREAD_MODE
148 /* A0 errata - Write MMU_SETUP after changing thread mode register. */ 192 * register (Ax Errata?)
193 */
149 andi v1, v0, 0x3 /* v1 <- thread id */ 194 andi v1, v0, 0x3 /* v1 <- thread id */
150 bnez v1, 2f 195 bnez v1, 2f
151 nop 196 nop
152 197
153 li t0, MMU_SETUP 198 li t0, MMU_SETUP
154 li t1, 0 199 li t1, 0
155 mtcr t1, t0 200 mtcr t1, t0
156 ehb 201 _ehb
157#endif
158 202
1592: beqz v0, 4f 2032: beqz v0, 4f /* boot cpu (cpuid == 0)? */
160 nop 204 nop
161 205
162 /* setup status reg */ 206 /* setup status reg */
163 mfc0 t1, CP0_STATUS 207 move t1, zero
164 li t0, ST0_BEV
165 or t1, t0
166 xor t1, t0
167#ifdef CONFIG_64BIT 208#ifdef CONFIG_64BIT
168 ori t1, ST0_KX 209 ori t1, ST0_KX
169#endif 210#endif
@@ -183,9 +224,9 @@ EXPORT(nlm_boot_siblings)
183 * For the boot CPU, we have to restore registers and 224 * For the boot CPU, we have to restore registers and
184 * return 225 * return
185 */ 226 */
1864: dmfc0 t0, $4, 2 /* restore SP from UserLocal */ 2274: dmfc0 t0, $4, 2 /* restore SP from UserLocal */
187 li t1, 0xfadebeef 228 li t1, 0xfadebeef
188 dmtc0 t1, $4, 2 /* restore SP from UserLocal */ 229 dmtc0 t1, $4, 2 /* restore SP from UserLocal */
189 PTR_SUBU sp, t0, PT_SIZE 230 PTR_SUBU sp, t0, PT_SIZE
190 RESTORE_ALL 231 RESTORE_ALL
191 jr ra 232 jr ra
@@ -193,7 +234,7 @@ EXPORT(nlm_boot_siblings)
193EXPORT(nlm_reset_entry_end) 234EXPORT(nlm_reset_entry_end)
194 235
195FEXPORT(xlp_boot_core0_siblings) /* "Master" cpu starts from here */ 236FEXPORT(xlp_boot_core0_siblings) /* "Master" cpu starts from here */
196 __config_lsu 237 xlp_config_lsu
197 dmtc0 sp, $4, 2 /* SP saved in UserLocal */ 238 dmtc0 sp, $4, 2 /* SP saved in UserLocal */
198 SAVE_ALL 239 SAVE_ALL
199 sync 240 sync
@@ -210,6 +251,12 @@ FEXPORT(xlp_boot_core0_siblings) /* "Master" cpu starts from here */
210 251
211 __CPUINIT 252 __CPUINIT
212NESTED(nlm_boot_secondary_cpus, 16, sp) 253NESTED(nlm_boot_secondary_cpus, 16, sp)
254 /* Initialize CP0 Status */
255 move t1, zero
256#ifdef CONFIG_64BIT
257 ori t1, ST0_KX
258#endif
259 mtc0 t1, CP0_STATUS
213 PTR_LA t1, nlm_next_sp 260 PTR_LA t1, nlm_next_sp
214 PTR_L sp, 0(t1) 261 PTR_L sp, 0(t1)
215 PTR_LA t1, nlm_next_gp 262 PTR_LA t1, nlm_next_gp
@@ -234,36 +281,36 @@ END(nlm_boot_secondary_cpus)
234 */ 281 */
235 __CPUINIT 282 __CPUINIT
236NESTED(nlm_rmiboot_preboot, 16, sp) 283NESTED(nlm_rmiboot_preboot, 16, sp)
237 mfc0 t0, $15, 1 # read ebase 284 mfc0 t0, $15, 1 /* read ebase */
238 andi t0, 0x1f # t0 has the processor_id() 285 andi t0, 0x1f /* t0 has the processor_id() */
239 andi t2, t0, 0x3 # thread no 286 andi t2, t0, 0x3 /* thread num */
240 sll t0, 2 # offset in cpu array 287 sll t0, 2 /* offset in cpu array */
241 288
242 PTR_LA t1, nlm_cpu_ready # mark CPU ready 289 PTR_LA t1, nlm_cpu_ready /* mark CPU ready */
243 PTR_ADDU t1, t0 290 PTR_ADDU t1, t0
244 li t3, 1 291 li t3, 1
245 sw t3, 0(t1) 292 sw t3, 0(t1)
246 293
247 bnez t2, 1f # skip thread programming 294 bnez t2, 1f /* skip thread programming */
248 nop # for non zero hw threads 295 nop /* for thread id != 0 */
249 296
250 /* 297 /*
251 * MMU setup only for first thread in core 298 * XLR MMU setup only for first thread in core
252 */ 299 */
253 li t0, 0x400 300 li t0, 0x400
254 mfcr t1, t0 301 mfcr t1, t0
255 li t2, 6 # XLR thread mode mask 302 li t2, 6 /* XLR thread mode mask */
256 nor t3, t2, zero 303 nor t3, t2, zero
257 and t2, t1, t2 # t2 - current thread mode 304 and t2, t1, t2 /* t2 - current thread mode */
258 li v0, CKSEG1ADDR(RESET_DATA_PHYS) 305 li v0, CKSEG1ADDR(RESET_DATA_PHYS)
259 lw v1, BOOT_THREAD_MODE(v0) # v1 - new thread mode 306 lw v1, BOOT_THREAD_MODE(v0) /* v1 - new thread mode */
260 sll v1, 1 307 sll v1, 1
261 beq v1, t2, 1f # same as request value 308 beq v1, t2, 1f /* same as request value */
262 nop # nothing to do */ 309 nop /* nothing to do */
263 310
264 and t2, t1, t3 # mask out old thread mode 311 and t2, t1, t3 /* mask out old thread mode */
265 or t1, t2, v1 # put in new value 312 or t1, t2, v1 /* put in new value */
266 mtcr t1, t0 # update core control 313 mtcr t1, t0 /* update core control */
267 314
2681: wait 3151: wait
269 j 1b 316 j 1b
diff --git a/arch/mips/netlogic/xlp/Makefile b/arch/mips/netlogic/xlp/Makefile
index b93ed83474e..6b4b972218f 100644
--- a/arch/mips/netlogic/xlp/Makefile
+++ b/arch/mips/netlogic/xlp/Makefile
@@ -1,2 +1,4 @@
1obj-y += setup.o platform.o nlm_hal.o 1obj-y += setup.o platform.o nlm_hal.o
2obj-$(CONFIG_OF) += of.o
2obj-$(CONFIG_SMP) += wakeup.o 3obj-$(CONFIG_SMP) += wakeup.o
4obj-$(CONFIG_USB) += usb-init.o
diff --git a/arch/mips/netlogic/xlp/nlm_hal.c b/arch/mips/netlogic/xlp/nlm_hal.c
index 9428e7125fe..6c65ac70191 100644
--- a/arch/mips/netlogic/xlp/nlm_hal.c
+++ b/arch/mips/netlogic/xlp/nlm_hal.c
@@ -69,6 +69,32 @@ int nlm_irq_to_irt(int irq)
69 return PIC_IRT_UART_0_INDEX; 69 return PIC_IRT_UART_0_INDEX;
70 case PIC_UART_1_IRQ: 70 case PIC_UART_1_IRQ:
71 return PIC_IRT_UART_1_INDEX; 71 return PIC_IRT_UART_1_INDEX;
72 case PIC_PCIE_LINK_0_IRQ:
73 return PIC_IRT_PCIE_LINK_0_INDEX;
74 case PIC_PCIE_LINK_1_IRQ:
75 return PIC_IRT_PCIE_LINK_1_INDEX;
76 case PIC_PCIE_LINK_2_IRQ:
77 return PIC_IRT_PCIE_LINK_2_INDEX;
78 case PIC_PCIE_LINK_3_IRQ:
79 return PIC_IRT_PCIE_LINK_3_INDEX;
80 case PIC_EHCI_0_IRQ:
81 return PIC_IRT_EHCI_0_INDEX;
82 case PIC_EHCI_1_IRQ:
83 return PIC_IRT_EHCI_1_INDEX;
84 case PIC_OHCI_0_IRQ:
85 return PIC_IRT_OHCI_0_INDEX;
86 case PIC_OHCI_1_IRQ:
87 return PIC_IRT_OHCI_1_INDEX;
88 case PIC_OHCI_2_IRQ:
89 return PIC_IRT_OHCI_2_INDEX;
90 case PIC_OHCI_3_IRQ:
91 return PIC_IRT_OHCI_3_INDEX;
92 case PIC_MMC_IRQ:
93 return PIC_IRT_MMC_INDEX;
94 case PIC_I2C_0_IRQ:
95 return PIC_IRT_I2C_0_INDEX;
96 case PIC_I2C_1_IRQ:
97 return PIC_IRT_I2C_1_INDEX;
72 default: 98 default:
73 return -1; 99 return -1;
74 } 100 }
@@ -81,6 +107,32 @@ int nlm_irt_to_irq(int irt)
81 return PIC_UART_0_IRQ; 107 return PIC_UART_0_IRQ;
82 case PIC_IRT_UART_1_INDEX: 108 case PIC_IRT_UART_1_INDEX:
83 return PIC_UART_1_IRQ; 109 return PIC_UART_1_IRQ;
110 case PIC_IRT_PCIE_LINK_0_INDEX:
111 return PIC_PCIE_LINK_0_IRQ;
112 case PIC_IRT_PCIE_LINK_1_INDEX:
113 return PIC_PCIE_LINK_1_IRQ;
114 case PIC_IRT_PCIE_LINK_2_INDEX:
115 return PIC_PCIE_LINK_2_IRQ;
116 case PIC_IRT_PCIE_LINK_3_INDEX:
117 return PIC_PCIE_LINK_3_IRQ;
118 case PIC_IRT_EHCI_0_INDEX:
119 return PIC_EHCI_0_IRQ;
120 case PIC_IRT_EHCI_1_INDEX:
121 return PIC_EHCI_1_IRQ;
122 case PIC_IRT_OHCI_0_INDEX:
123 return PIC_OHCI_0_IRQ;
124 case PIC_IRT_OHCI_1_INDEX:
125 return PIC_OHCI_1_IRQ;
126 case PIC_IRT_OHCI_2_INDEX:
127 return PIC_OHCI_2_IRQ;
128 case PIC_IRT_OHCI_3_INDEX:
129 return PIC_OHCI_3_IRQ;
130 case PIC_IRT_MMC_INDEX:
131 return PIC_MMC_IRQ;
132 case PIC_IRT_I2C_0_INDEX:
133 return PIC_I2C_0_IRQ;
134 case PIC_IRT_I2C_1_INDEX:
135 return PIC_I2C_1_IRQ;
84 default: 136 default:
85 return -1; 137 return -1;
86 } 138 }
diff --git a/arch/mips/netlogic/xlp/of.c b/arch/mips/netlogic/xlp/of.c
new file mode 100644
index 00000000000..8e3921c0c20
--- /dev/null
+++ b/arch/mips/netlogic/xlp/of.c
@@ -0,0 +1,34 @@
1#include <linux/bootmem.h>
2#include <linux/init.h>
3#include <linux/io.h>
4#include <linux/of_fdt.h>
5#include <asm/byteorder.h>
6
7static int __init reserve_mem_mach(unsigned long addr, unsigned long size)
8{
9 return reserve_bootmem(addr, size, BOOTMEM_DEFAULT);
10}
11
12void __init free_mem_mach(unsigned long addr, unsigned long size)
13{
14 return free_bootmem(addr, size);
15}
16
17void __init device_tree_init(void)
18{
19 unsigned long base, size;
20
21 if (!initial_boot_params)
22 return;
23
24 base = virt_to_phys((void *)initial_boot_params);
25 size = be32_to_cpu(initial_boot_params->totalsize);
26
27 /* Before we do anything, lets reserve the dt blob */
28 reserve_mem_mach(base, size);
29
30 unflatten_device_tree();
31
32 /* free the space reserved for the dt blob */
33 free_mem_mach(base, size);
34}
diff --git a/arch/mips/netlogic/xlp/platform.c b/arch/mips/netlogic/xlp/platform.c
index 1f5e4cba891..2c510d58544 100644
--- a/arch/mips/netlogic/xlp/platform.c
+++ b/arch/mips/netlogic/xlp/platform.c
@@ -53,7 +53,7 @@
53 53
54static unsigned int nlm_xlp_uart_in(struct uart_port *p, int offset) 54static unsigned int nlm_xlp_uart_in(struct uart_port *p, int offset)
55{ 55{
56 return nlm_read_reg(p->iobase, offset); 56 return nlm_read_reg(p->iobase, offset);
57} 57}
58 58
59static void nlm_xlp_uart_out(struct uart_port *p, int offset, int value) 59static void nlm_xlp_uart_out(struct uart_port *p, int offset, int value)
diff --git a/arch/mips/netlogic/xlp/setup.c b/arch/mips/netlogic/xlp/setup.c
index b3df7c2aad1..3dec9f28b65 100644
--- a/arch/mips/netlogic/xlp/setup.c
+++ b/arch/mips/netlogic/xlp/setup.c
@@ -41,6 +41,8 @@
41#include <asm/bootinfo.h> 41#include <asm/bootinfo.h>
42 42
43#include <linux/of_fdt.h> 43#include <linux/of_fdt.h>
44#include <linux/of_platform.h>
45#include <linux/of_device.h>
44 46
45#include <asm/netlogic/haldefs.h> 47#include <asm/netlogic/haldefs.h>
46#include <asm/netlogic/common.h> 48#include <asm/netlogic/common.h>
@@ -109,3 +111,17 @@ void __init prom_init(void)
109 register_smp_ops(&nlm_smp_ops); 111 register_smp_ops(&nlm_smp_ops);
110#endif 112#endif
111} 113}
114
115static struct of_device_id __initdata xlp_ids[] = {
116 { .compatible = "simple-bus", },
117 {},
118};
119
120int __init xlp8xx_ds_publish_devices(void)
121{
122 if (!of_have_populated_dt())
123 return 0;
124 return of_platform_bus_probe(NULL, xlp_ids, NULL);
125}
126
127device_initcall(xlp8xx_ds_publish_devices);
diff --git a/arch/mips/netlogic/xlp/usb-init.c b/arch/mips/netlogic/xlp/usb-init.c
new file mode 100644
index 00000000000..dbe083a9353
--- /dev/null
+++ b/arch/mips/netlogic/xlp/usb-init.c
@@ -0,0 +1,124 @@
1/*
2 * Copyright (c) 2003-2012 Broadcom Corporation
3 * All Rights Reserved
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the Broadcom
9 * license below:
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
20 * distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#include <linux/dma-mapping.h>
36#include <linux/kernel.h>
37#include <linux/delay.h>
38#include <linux/init.h>
39#include <linux/pci.h>
40#include <linux/platform_device.h>
41
42#include <asm/netlogic/haldefs.h>
43#include <asm/netlogic/xlp-hal/iomap.h>
44#include <asm/netlogic/xlp-hal/xlp.h>
45#include <asm/netlogic/xlp-hal/usb.h>
46
47static void nlm_usb_intr_en(int node, int port)
48{
49 uint32_t val;
50 uint64_t port_addr;
51
52 port_addr = nlm_get_usb_regbase(node, port);
53 val = nlm_read_usb_reg(port_addr, USB_INT_EN);
54 val = USB_CTRL_INTERRUPT_EN | USB_OHCI_INTERRUPT_EN |
55 USB_OHCI_INTERRUPT1_EN | USB_CTRL_INTERRUPT_EN |
56 USB_OHCI_INTERRUPT_EN | USB_OHCI_INTERRUPT2_EN;
57 nlm_write_usb_reg(port_addr, USB_INT_EN, val);
58}
59
60static void nlm_usb_hw_reset(int node, int port)
61{
62 uint64_t port_addr;
63 uint32_t val;
64
65 /* reset USB phy */
66 port_addr = nlm_get_usb_regbase(node, port);
67 val = nlm_read_usb_reg(port_addr, USB_PHY_0);
68 val &= ~(USB_PHY_RESET | USB_PHY_PORT_RESET_0 | USB_PHY_PORT_RESET_1);
69 nlm_write_usb_reg(port_addr, USB_PHY_0, val);
70
71 mdelay(100);
72 val = nlm_read_usb_reg(port_addr, USB_CTL_0);
73 val &= ~(USB_CONTROLLER_RESET);
74 val |= 0x4;
75 nlm_write_usb_reg(port_addr, USB_CTL_0, val);
76}
77
78static int __init nlm_platform_usb_init(void)
79{
80 pr_info("Initializing USB Interface\n");
81 nlm_usb_hw_reset(0, 0);
82 nlm_usb_hw_reset(0, 3);
83
84 /* Enable PHY interrupts */
85 nlm_usb_intr_en(0, 0);
86 nlm_usb_intr_en(0, 3);
87
88 return 0;
89}
90
91arch_initcall(nlm_platform_usb_init);
92
93static u64 xlp_usb_dmamask = ~(u32)0;
94
95/* Fixup the IRQ for USB devices which is exist on XLP SOC PCIE bus */
96static void nlm_usb_fixup_final(struct pci_dev *dev)
97{
98 dev->dev.dma_mask = &xlp_usb_dmamask;
99 dev->dev.coherent_dma_mask = DMA_BIT_MASK(64);
100 switch (dev->devfn) {
101 case 0x10:
102 dev->irq = PIC_EHCI_0_IRQ;
103 break;
104 case 0x11:
105 dev->irq = PIC_OHCI_0_IRQ;
106 break;
107 case 0x12:
108 dev->irq = PIC_OHCI_1_IRQ;
109 break;
110 case 0x13:
111 dev->irq = PIC_EHCI_1_IRQ;
112 break;
113 case 0x14:
114 dev->irq = PIC_OHCI_2_IRQ;
115 break;
116 case 0x15:
117 dev->irq = PIC_OHCI_3_IRQ;
118 break;
119 }
120}
121DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_NETLOGIC, PCI_DEVICE_ID_NLM_EHCI,
122 nlm_usb_fixup_final);
123DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_NETLOGIC, PCI_DEVICE_ID_NLM_OHCI,
124 nlm_usb_fixup_final);
diff --git a/arch/mips/netlogic/xlr/Makefile b/arch/mips/netlogic/xlr/Makefile
index f01e4d7a060..c287dea8757 100644
--- a/arch/mips/netlogic/xlr/Makefile
+++ b/arch/mips/netlogic/xlr/Makefile
@@ -1,2 +1,2 @@
1obj-y += setup.o platform.o 1obj-y += setup.o platform.o platform-flash.o
2obj-$(CONFIG_SMP) += wakeup.o 2obj-$(CONFIG_SMP) += wakeup.o
diff --git a/arch/mips/netlogic/xlr/platform-flash.c b/arch/mips/netlogic/xlr/platform-flash.c
new file mode 100644
index 00000000000..340ab1601c4
--- /dev/null
+++ b/arch/mips/netlogic/xlr/platform-flash.c
@@ -0,0 +1,220 @@
1/*
2 * Copyright 2011, Netlogic Microsystems.
3 * Copyright 2004, Matt Porter <mporter@kernel.crashing.org>
4 *
5 * This file is licensed under the terms of the GNU General Public
6 * License version 2. This program is licensed "as is" without any
7 * warranty of any kind, whether express or implied.
8 */
9
10#include <linux/device.h>
11#include <linux/platform_device.h>
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/io.h>
15#include <linux/delay.h>
16#include <linux/ioport.h>
17#include <linux/resource.h>
18#include <linux/spi/flash.h>
19
20#include <linux/mtd/mtd.h>
21#include <linux/mtd/physmap.h>
22#include <linux/mtd/nand.h>
23#include <linux/mtd/partitions.h>
24
25#include <asm/netlogic/haldefs.h>
26#include <asm/netlogic/xlr/iomap.h>
27#include <asm/netlogic/xlr/flash.h>
28#include <asm/netlogic/xlr/bridge.h>
29#include <asm/netlogic/xlr/gpio.h>
30#include <asm/netlogic/xlr/xlr.h>
31
32/*
33 * Default NOR partition layout
34 */
35static struct mtd_partition xlr_nor_parts[] = {
36 {
37 .name = "User FS",
38 .offset = 0x800000,
39 .size = MTDPART_SIZ_FULL,
40 }
41};
42
43/*
44 * Default NAND partition layout
45 */
46static struct mtd_partition xlr_nand_parts[] = {
47 {
48 .name = "Root Filesystem",
49 .offset = 64 * 64 * 2048,
50 .size = 432 * 64 * 2048,
51 },
52 {
53 .name = "Home Filesystem",
54 .offset = MTDPART_OFS_APPEND,
55 .size = MTDPART_SIZ_FULL,
56 },
57};
58
59/* Use PHYSMAP flash for NOR */
60struct physmap_flash_data xlr_nor_data = {
61 .width = 2,
62 .parts = xlr_nor_parts,
63 .nr_parts = ARRAY_SIZE(xlr_nor_parts),
64};
65
66static struct resource xlr_nor_res[] = {
67 {
68 .flags = IORESOURCE_MEM,
69 },
70};
71
72static struct platform_device xlr_nor_dev = {
73 .name = "physmap-flash",
74 .dev = {
75 .platform_data = &xlr_nor_data,
76 },
77 .num_resources = ARRAY_SIZE(xlr_nor_res),
78 .resource = xlr_nor_res,
79};
80
81const char *xlr_part_probes[] = { "cmdlinepart", NULL };
82
83/*
84 * Use "gen_nand" driver for NAND flash
85 *
86 * There seems to be no way to store a private pointer containing
87 * platform specific info in gen_nand drivier. We will use a global
88 * struct for now, since we currently have only one NAND chip per board.
89 */
90struct xlr_nand_flash_priv {
91 int cs;
92 uint64_t flash_mmio;
93};
94
95static struct xlr_nand_flash_priv nand_priv;
96
97static void xlr_nand_ctrl(struct mtd_info *mtd, int cmd,
98 unsigned int ctrl)
99{
100 if (ctrl & NAND_CLE)
101 nlm_write_reg(nand_priv.flash_mmio,
102 FLASH_NAND_CLE(nand_priv.cs), cmd);
103 else if (ctrl & NAND_ALE)
104 nlm_write_reg(nand_priv.flash_mmio,
105 FLASH_NAND_ALE(nand_priv.cs), cmd);
106}
107
108struct platform_nand_data xlr_nand_data = {
109 .chip = {
110 .nr_chips = 1,
111 .nr_partitions = ARRAY_SIZE(xlr_nand_parts),
112 .chip_delay = 50,
113 .partitions = xlr_nand_parts,
114 .part_probe_types = xlr_part_probes,
115 },
116 .ctrl = {
117 .cmd_ctrl = xlr_nand_ctrl,
118 },
119};
120
121static struct resource xlr_nand_res[] = {
122 {
123 .flags = IORESOURCE_MEM,
124 },
125};
126
127static struct platform_device xlr_nand_dev = {
128 .name = "gen_nand",
129 .id = -1,
130 .num_resources = ARRAY_SIZE(xlr_nand_res),
131 .resource = xlr_nand_res,
132 .dev = {
133 .platform_data = &xlr_nand_data,
134 }
135};
136
137/*
138 * XLR/XLS supports upto 8 devices on its FLASH interface. The value in
139 * FLASH_BAR (on the MEM/IO bridge) gives the base for mapping all the
140 * flash devices.
141 * Under this, each flash device has an offset and size given by the
142 * CSBASE_ADDR and CSBASE_MASK registers for the device.
143 *
144 * The CSBASE_ registers are expected to be setup by the bootloader.
145 */
146static void setup_flash_resource(uint64_t flash_mmio,
147 uint64_t flash_map_base, int cs, struct resource *res)
148{
149 u32 base, mask;
150
151 base = nlm_read_reg(flash_mmio, FLASH_CSBASE_ADDR(cs));
152 mask = nlm_read_reg(flash_mmio, FLASH_CSADDR_MASK(cs));
153
154 res->start = flash_map_base + ((unsigned long)base << 16);
155 res->end = res->start + (mask + 1) * 64 * 1024;
156}
157
158static int __init xlr_flash_init(void)
159{
160 uint64_t gpio_mmio, flash_mmio, flash_map_base;
161 u32 gpio_resetcfg, flash_bar;
162 int cs, boot_nand, boot_nor;
163
164 /* Flash address bits 39:24 is in bridge flash BAR */
165 flash_bar = nlm_read_reg(nlm_io_base, BRIDGE_FLASH_BAR);
166 flash_map_base = (flash_bar & 0xffff0000) << 8;
167
168 gpio_mmio = nlm_mmio_base(NETLOGIC_IO_GPIO_OFFSET);
169 flash_mmio = nlm_mmio_base(NETLOGIC_IO_FLASH_OFFSET);
170
171 /* Get the chip reset config */
172 gpio_resetcfg = nlm_read_reg(gpio_mmio, GPIO_PWRON_RESET_CFG_REG);
173
174 /* Check for boot flash type */
175 boot_nor = boot_nand = 0;
176 if (nlm_chip_is_xls()) {
177 /* On XLS, check boot from NAND bit (GPIO reset reg bit 16) */
178 if (gpio_resetcfg & (1 << 16))
179 boot_nand = 1;
180
181 /* check boot from PCMCIA, (GPIO reset reg bit 15 */
182 if ((gpio_resetcfg & (1 << 15)) == 0)
183 boot_nor = 1; /* not set, booted from NOR */
184 } else { /* XLR */
185 /* check boot from PCMCIA (bit 16 in GPIO reset on XLR) */
186 if ((gpio_resetcfg & (1 << 16)) == 0)
187 boot_nor = 1; /* not set, booted from NOR */
188 }
189
190 /* boot flash at chip select 0 */
191 cs = 0;
192
193 if (boot_nand) {
194 nand_priv.cs = cs;
195 nand_priv.flash_mmio = flash_mmio;
196 setup_flash_resource(flash_mmio, flash_map_base, cs,
197 xlr_nand_res);
198
199 /* Initialize NAND flash at CS 0 */
200 nlm_write_reg(flash_mmio, FLASH_CSDEV_PARM(cs),
201 FLASH_NAND_CSDEV_PARAM);
202 nlm_write_reg(flash_mmio, FLASH_CSTIME_PARMA(cs),
203 FLASH_NAND_CSTIME_PARAMA);
204 nlm_write_reg(flash_mmio, FLASH_CSTIME_PARMB(cs),
205 FLASH_NAND_CSTIME_PARAMB);
206
207 pr_info("ChipSelect %d: NAND Flash %pR\n", cs, xlr_nand_res);
208 return platform_device_register(&xlr_nand_dev);
209 }
210
211 if (boot_nor) {
212 setup_flash_resource(flash_mmio, flash_map_base, cs,
213 xlr_nor_res);
214 pr_info("ChipSelect %d: NOR Flash %pR\n", cs, xlr_nor_res);
215 return platform_device_register(&xlr_nor_dev);
216 }
217 return 0;
218}
219
220arch_initcall(xlr_flash_init);
diff --git a/arch/mips/netlogic/xlr/platform.c b/arch/mips/netlogic/xlr/platform.c
index eab64b45dff..71b44d82621 100644
--- a/arch/mips/netlogic/xlr/platform.c
+++ b/arch/mips/netlogic/xlr/platform.c
@@ -14,6 +14,7 @@
14#include <linux/resource.h> 14#include <linux/resource.h>
15#include <linux/serial_8250.h> 15#include <linux/serial_8250.h>
16#include <linux/serial_reg.h> 16#include <linux/serial_reg.h>
17#include <linux/i2c.h>
17 18
18#include <asm/netlogic/haldefs.h> 19#include <asm/netlogic/haldefs.h>
19#include <asm/netlogic/xlr/iomap.h> 20#include <asm/netlogic/xlr/iomap.h>
@@ -97,3 +98,142 @@ static int __init nlm_uart_init(void)
97} 98}
98 99
99arch_initcall(nlm_uart_init); 100arch_initcall(nlm_uart_init);
101
102#ifdef CONFIG_USB
103/* Platform USB devices, only on XLS chips */
104static u64 xls_usb_dmamask = ~(u32)0;
105#define USB_PLATFORM_DEV(n, i, irq) \
106 { \
107 .name = n, \
108 .id = i, \
109 .num_resources = 2, \
110 .dev = { \
111 .dma_mask = &xls_usb_dmamask, \
112 .coherent_dma_mask = 0xffffffff, \
113 }, \
114 .resource = (struct resource[]) { \
115 { \
116 .flags = IORESOURCE_MEM, \
117 }, \
118 { \
119 .start = irq, \
120 .end = irq, \
121 .flags = IORESOURCE_IRQ, \
122 }, \
123 }, \
124 }
125
126static struct platform_device xls_usb_ehci_device =
127 USB_PLATFORM_DEV("ehci-xls", 0, PIC_USB_IRQ);
128static struct platform_device xls_usb_ohci_device_0 =
129 USB_PLATFORM_DEV("ohci-xls-0", 1, PIC_USB_IRQ);
130static struct platform_device xls_usb_ohci_device_1 =
131 USB_PLATFORM_DEV("ohci-xls-1", 2, PIC_USB_IRQ);
132
133static struct platform_device *xls_platform_devices[] = {
134 &xls_usb_ehci_device,
135 &xls_usb_ohci_device_0,
136 &xls_usb_ohci_device_1,
137};
138
139int xls_platform_usb_init(void)
140{
141 uint64_t usb_mmio, gpio_mmio;
142 unsigned long memres;
143 uint32_t val;
144
145 if (!nlm_chip_is_xls())
146 return 0;
147
148 gpio_mmio = nlm_mmio_base(NETLOGIC_IO_GPIO_OFFSET);
149 usb_mmio = nlm_mmio_base(NETLOGIC_IO_USB_1_OFFSET);
150
151 /* Clear Rogue Phy INTs */
152 nlm_write_reg(usb_mmio, 49, 0x10000000);
153 /* Enable all interrupts */
154 nlm_write_reg(usb_mmio, 50, 0x1f000000);
155
156 /* Enable ports */
157 nlm_write_reg(usb_mmio, 1, 0x07000500);
158
159 val = nlm_read_reg(gpio_mmio, 21);
160 if (((val >> 22) & 0x01) == 0) {
161 pr_info("Detected USB Device mode - Not supported!\n");
162 nlm_write_reg(usb_mmio, 0, 0x01000000);
163 return 0;
164 }
165
166 pr_info("Detected USB Host mode - Adding XLS USB devices.\n");
167 /* Clear reset, host mode */
168 nlm_write_reg(usb_mmio, 0, 0x02000000);
169
170 /* Memory resource for various XLS usb ports */
171 usb_mmio = nlm_mmio_base(NETLOGIC_IO_USB_0_OFFSET);
172 memres = CPHYSADDR((unsigned long)usb_mmio);
173 xls_usb_ehci_device.resource[0].start = memres;
174 xls_usb_ehci_device.resource[0].end = memres + 0x400 - 1;
175
176 memres += 0x400;
177 xls_usb_ohci_device_0.resource[0].start = memres;
178 xls_usb_ohci_device_0.resource[0].end = memres + 0x400 - 1;
179
180 memres += 0x400;
181 xls_usb_ohci_device_1.resource[0].start = memres;
182 xls_usb_ohci_device_1.resource[0].end = memres + 0x400 - 1;
183
184 return platform_add_devices(xls_platform_devices,
185 ARRAY_SIZE(xls_platform_devices));
186}
187
188arch_initcall(xls_platform_usb_init);
189#endif
190
191#ifdef CONFIG_I2C
192static struct i2c_board_info nlm_i2c_board_info1[] __initdata = {
193 /* All XLR boards have this RTC and Max6657 Temp Chip */
194 [0] = {
195 .type = "ds1374",
196 .addr = 0x68
197 },
198 [1] = {
199 .type = "lm90",
200 .addr = 0x4c
201 },
202};
203
204static struct resource i2c_resources[] = {
205 [0] = {
206 .start = 0, /* filled at init */
207 .end = 0,
208 .flags = IORESOURCE_MEM,
209 },
210};
211
212static struct platform_device nlm_xlr_i2c_1 = {
213 .name = "xlr-i2cbus",
214 .id = 1,
215 .num_resources = 1,
216 .resource = i2c_resources,
217};
218
219static int __init nlm_i2c_init(void)
220{
221 int err = 0;
222 unsigned int offset;
223
224 /* I2C bus 0 does not have any useful devices, configure only bus 1 */
225 offset = NETLOGIC_IO_I2C_1_OFFSET;
226 nlm_xlr_i2c_1.resource[0].start = CPHYSADDR(nlm_mmio_base(offset));
227 nlm_xlr_i2c_1.resource[0].end = nlm_xlr_i2c_1.resource[0].start + 0xfff;
228
229 platform_device_register(&nlm_xlr_i2c_1);
230
231 err = i2c_register_board_info(1, nlm_i2c_board_info1,
232 ARRAY_SIZE(nlm_i2c_board_info1));
233 if (err < 0)
234 pr_err("nlm-i2c: cannot register board I2C devices\n");
235 return err;
236}
237
238arch_initcall(nlm_i2c_init);
239#endif
diff --git a/arch/mips/netlogic/xlr/setup.c b/arch/mips/netlogic/xlr/setup.c
index c9d066dedc4..81b1d311834 100644
--- a/arch/mips/netlogic/xlr/setup.c
+++ b/arch/mips/netlogic/xlr/setup.c
@@ -85,7 +85,7 @@ static void nlm_linux_exit(void)
85 85
86 gpiobase = nlm_mmio_base(NETLOGIC_IO_GPIO_OFFSET); 86 gpiobase = nlm_mmio_base(NETLOGIC_IO_GPIO_OFFSET);
87 /* trigger a chip reset by writing 1 to GPIO_SWRESET_REG */ 87 /* trigger a chip reset by writing 1 to GPIO_SWRESET_REG */
88 nlm_write_reg(gpiobase, NETLOGIC_GPIO_SWRESET_REG, 1); 88 nlm_write_reg(gpiobase, GPIO_SWRESET_REG, 1);
89 for ( ; ; ) 89 for ( ; ; )
90 cpu_wait(); 90 cpu_wait();
91} 91}
diff --git a/arch/mips/oprofile/common.c b/arch/mips/oprofile/common.c
index b6e378211a2..f80480a5a03 100644
--- a/arch/mips/oprofile/common.c
+++ b/arch/mips/oprofile/common.c
@@ -85,6 +85,7 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
85 case CPU_34K: 85 case CPU_34K:
86 case CPU_1004K: 86 case CPU_1004K:
87 case CPU_74K: 87 case CPU_74K:
88 case CPU_LOONGSON1:
88 case CPU_SB1: 89 case CPU_SB1:
89 case CPU_SB1A: 90 case CPU_SB1A:
90 case CPU_R10000: 91 case CPU_R10000:
diff --git a/arch/mips/oprofile/op_model_mipsxx.c b/arch/mips/oprofile/op_model_mipsxx.c
index 4d80a856048..28ea1a4cc57 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -339,12 +339,6 @@ static int __init mipsxx_init(void)
339 break; 339 break;
340 340
341 case CPU_1004K: 341 case CPU_1004K:
342#if 0
343 /* FIXME: report as 34K for now */
344 op_model_mipsxx_ops.cpu_type = "mips/1004K";
345 break;
346#endif
347
348 case CPU_34K: 342 case CPU_34K:
349 op_model_mipsxx_ops.cpu_type = "mips/34K"; 343 op_model_mipsxx_ops.cpu_type = "mips/34K";
350 break; 344 break;
@@ -374,6 +368,10 @@ static int __init mipsxx_init(void)
374 op_model_mipsxx_ops.cpu_type = "mips/sb1"; 368 op_model_mipsxx_ops.cpu_type = "mips/sb1";
375 break; 369 break;
376 370
371 case CPU_LOONGSON1:
372 op_model_mipsxx_ops.cpu_type = "mips/loongson1";
373 break;
374
377 default: 375 default:
378 printk(KERN_ERR "Profiling unsupported for this CPU\n"); 376 printk(KERN_ERR "Profiling unsupported for this CPU\n");
379 377
diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile
index c703f43a991..e13a71cbc3c 100644
--- a/arch/mips/pci/Makefile
+++ b/arch/mips/pci/Makefile
@@ -59,6 +59,7 @@ obj-$(CONFIG_WR_PPMC) += fixup-wrppmc.o
59obj-$(CONFIG_MIKROTIK_RB532) += pci-rc32434.o ops-rc32434.o fixup-rc32434.o 59obj-$(CONFIG_MIKROTIK_RB532) += pci-rc32434.o ops-rc32434.o fixup-rc32434.o
60obj-$(CONFIG_CPU_CAVIUM_OCTEON) += pci-octeon.o pcie-octeon.o 60obj-$(CONFIG_CPU_CAVIUM_OCTEON) += pci-octeon.o pcie-octeon.o
61obj-$(CONFIG_CPU_XLR) += pci-xlr.o 61obj-$(CONFIG_CPU_XLR) += pci-xlr.o
62obj-$(CONFIG_CPU_XLP) += pci-xlp.o
62 63
63ifdef CONFIG_PCI_MSI 64ifdef CONFIG_PCI_MSI
64obj-$(CONFIG_CPU_CAVIUM_OCTEON) += msi-octeon.o 65obj-$(CONFIG_CPU_CAVIUM_OCTEON) += msi-octeon.o
diff --git a/arch/mips/pci/fixup-cobalt.c b/arch/mips/pci/fixup-cobalt.c
index 9553b14002d..3e7ce65d776 100644
--- a/arch/mips/pci/fixup-cobalt.c
+++ b/arch/mips/pci/fixup-cobalt.c
@@ -37,7 +37,7 @@
37#define VIA_COBALT_BRD_ID_REG 0x94 37#define VIA_COBALT_BRD_ID_REG 0x94
38#define VIA_COBALT_BRD_REG_to_ID(reg) ((unsigned char)(reg) >> 4) 38#define VIA_COBALT_BRD_REG_to_ID(reg) ((unsigned char)(reg) >> 4)
39 39
40static void qube_raq_galileo_early_fixup(struct pci_dev *dev) 40static void __devinit qube_raq_galileo_early_fixup(struct pci_dev *dev)
41{ 41{
42 if (dev->devfn == PCI_DEVFN(0, 0) && 42 if (dev->devfn == PCI_DEVFN(0, 0) &&
43 (dev->class >> 8) == PCI_CLASS_MEMORY_OTHER) { 43 (dev->class >> 8) == PCI_CLASS_MEMORY_OTHER) {
@@ -51,7 +51,7 @@ static void qube_raq_galileo_early_fixup(struct pci_dev *dev)
51DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_GT64111, 51DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_GT64111,
52 qube_raq_galileo_early_fixup); 52 qube_raq_galileo_early_fixup);
53 53
54static void qube_raq_via_bmIDE_fixup(struct pci_dev *dev) 54static void __devinit qube_raq_via_bmIDE_fixup(struct pci_dev *dev)
55{ 55{
56 unsigned short cfgword; 56 unsigned short cfgword;
57 unsigned char lt; 57 unsigned char lt;
@@ -74,7 +74,7 @@ static void qube_raq_via_bmIDE_fixup(struct pci_dev *dev)
74DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, 74DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1,
75 qube_raq_via_bmIDE_fixup); 75 qube_raq_via_bmIDE_fixup);
76 76
77static void qube_raq_galileo_fixup(struct pci_dev *dev) 77static void __devinit qube_raq_galileo_fixup(struct pci_dev *dev)
78{ 78{
79 if (dev->devfn != PCI_DEVFN(0, 0)) 79 if (dev->devfn != PCI_DEVFN(0, 0))
80 return; 80 return;
@@ -129,7 +129,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_GT64111,
129 129
130int cobalt_board_id; 130int cobalt_board_id;
131 131
132static void qube_raq_via_board_id_fixup(struct pci_dev *dev) 132static void __devinit qube_raq_via_board_id_fixup(struct pci_dev *dev)
133{ 133{
134 u8 id; 134 u8 id;
135 int retval; 135 int retval;
diff --git a/arch/mips/pci/fixup-malta.c b/arch/mips/pci/fixup-malta.c
index 70073c98ed3..819622f93e9 100644
--- a/arch/mips/pci/fixup-malta.c
+++ b/arch/mips/pci/fixup-malta.c
@@ -101,3 +101,17 @@ static void __devinit malta_piix_func1_fixup(struct pci_dev *pdev)
101 101
102DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB, 102DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB,
103 malta_piix_func1_fixup); 103 malta_piix_func1_fixup);
104
105/* Enable PCI 2.1 compatibility in PIIX4 */
106static void __devinit quirk_dlcsetup(struct pci_dev *dev)
107{
108 u8 odlc, ndlc;
109
110 (void) pci_read_config_byte(dev, 0x82, &odlc);
111 /* Enable passive releases and delayed transaction */
112 ndlc = odlc | 7;
113 (void) pci_write_config_byte(dev, 0x82, ndlc);
114}
115
116DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_0,
117 quirk_dlcsetup);
diff --git a/arch/mips/pci/fixup-rc32434.c b/arch/mips/pci/fixup-rc32434.c
index 3d86823d03a..76bb1be99d4 100644
--- a/arch/mips/pci/fixup-rc32434.c
+++ b/arch/mips/pci/fixup-rc32434.c
@@ -47,7 +47,7 @@ int __devinit pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
47 return irq + GROUP4_IRQ_BASE + 4; 47 return irq + GROUP4_IRQ_BASE + 4;
48} 48}
49 49
50static void rc32434_pci_early_fixup(struct pci_dev *dev) 50static void __devinit rc32434_pci_early_fixup(struct pci_dev *dev)
51{ 51{
52 if (PCI_SLOT(dev->devfn) == 6 && dev->bus->number == 0) { 52 if (PCI_SLOT(dev->devfn) == 6 && dev->bus->number == 0) {
53 /* disable prefetched memory range */ 53 /* disable prefetched memory range */
diff --git a/arch/mips/pci/ops-bcm63xx.c b/arch/mips/pci/ops-bcm63xx.c
index 822ae179bc5..65c7bd10048 100644
--- a/arch/mips/pci/ops-bcm63xx.c
+++ b/arch/mips/pci/ops-bcm63xx.c
@@ -411,7 +411,7 @@ struct pci_ops bcm63xx_cb_ops = {
411 * only one IO window, so it cannot be shared by PCI and cardbus, use 411 * only one IO window, so it cannot be shared by PCI and cardbus, use
412 * fixup to choose and detect unhandled configuration 412 * fixup to choose and detect unhandled configuration
413 */ 413 */
414static void bcm63xx_fixup(struct pci_dev *dev) 414static void __devinit bcm63xx_fixup(struct pci_dev *dev)
415{ 415{
416 static int io_window = -1; 416 static int io_window = -1;
417 int i, found, new_io_window; 417 int i, found, new_io_window;
@@ -465,3 +465,64 @@ static void bcm63xx_fixup(struct pci_dev *dev)
465 465
466DECLARE_PCI_FIXUP_ENABLE(PCI_ANY_ID, PCI_ANY_ID, bcm63xx_fixup); 466DECLARE_PCI_FIXUP_ENABLE(PCI_ANY_ID, PCI_ANY_ID, bcm63xx_fixup);
467#endif 467#endif
468
469static int bcm63xx_pcie_can_access(struct pci_bus *bus, int devfn)
470{
471 switch (bus->number) {
472 case PCIE_BUS_BRIDGE:
473 return (PCI_SLOT(devfn) == 0);
474 case PCIE_BUS_DEVICE:
475 if (PCI_SLOT(devfn) == 0)
476 return bcm_pcie_readl(PCIE_DLSTATUS_REG)
477 & DLSTATUS_PHYLINKUP;
478 default:
479 return false;
480 }
481}
482
483static int bcm63xx_pcie_read(struct pci_bus *bus, unsigned int devfn,
484 int where, int size, u32 *val)
485{
486 u32 data;
487 u32 reg = where & ~3;
488
489 if (!bcm63xx_pcie_can_access(bus, devfn))
490 return PCIBIOS_DEVICE_NOT_FOUND;
491
492 if (bus->number == PCIE_BUS_DEVICE)
493 reg += PCIE_DEVICE_OFFSET;
494
495 data = bcm_pcie_readl(reg);
496
497 *val = postprocess_read(data, where, size);
498
499 return PCIBIOS_SUCCESSFUL;
500
501}
502
503static int bcm63xx_pcie_write(struct pci_bus *bus, unsigned int devfn,
504 int where, int size, u32 val)
505{
506 u32 data;
507 u32 reg = where & ~3;
508
509 if (!bcm63xx_pcie_can_access(bus, devfn))
510 return PCIBIOS_DEVICE_NOT_FOUND;
511
512 if (bus->number == PCIE_BUS_DEVICE)
513 reg += PCIE_DEVICE_OFFSET;
514
515
516 data = bcm_pcie_readl(reg);
517
518 data = preprocess_write(data, val, where, size);
519 bcm_pcie_writel(data, reg);
520
521 return PCIBIOS_SUCCESSFUL;
522}
523
524
525struct pci_ops bcm63xx_pcie_ops = {
526 .read = bcm63xx_pcie_read,
527 .write = bcm63xx_pcie_write
528};
diff --git a/arch/mips/pci/pci-ar724x.c b/arch/mips/pci/pci-ar724x.c
index 414a7459858..86d77a66645 100644
--- a/arch/mips/pci/pci-ar724x.c
+++ b/arch/mips/pci/pci-ar724x.c
@@ -23,9 +23,12 @@
23#define AR724X_PCI_MEM_BASE 0x10000000 23#define AR724X_PCI_MEM_BASE 0x10000000
24#define AR724X_PCI_MEM_SIZE 0x08000000 24#define AR724X_PCI_MEM_SIZE 0x08000000
25 25
26#define AR724X_PCI_REG_RESET 0x18
26#define AR724X_PCI_REG_INT_STATUS 0x4c 27#define AR724X_PCI_REG_INT_STATUS 0x4c
27#define AR724X_PCI_REG_INT_MASK 0x50 28#define AR724X_PCI_REG_INT_MASK 0x50
28 29
30#define AR724X_PCI_RESET_LINK_UP BIT(0)
31
29#define AR724X_PCI_INT_DEV0 BIT(14) 32#define AR724X_PCI_INT_DEV0 BIT(14)
30 33
31#define AR724X_PCI_IRQ_COUNT 1 34#define AR724X_PCI_IRQ_COUNT 1
@@ -38,6 +41,15 @@ static void __iomem *ar724x_pci_ctrl_base;
38 41
39static u32 ar724x_pci_bar0_value; 42static u32 ar724x_pci_bar0_value;
40static bool ar724x_pci_bar0_is_cached; 43static bool ar724x_pci_bar0_is_cached;
44static bool ar724x_pci_link_up;
45
46static inline bool ar724x_pci_check_link(void)
47{
48 u32 reset;
49
50 reset = __raw_readl(ar724x_pci_ctrl_base + AR724X_PCI_REG_RESET);
51 return reset & AR724X_PCI_RESET_LINK_UP;
52}
41 53
42static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where, 54static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where,
43 int size, uint32_t *value) 55 int size, uint32_t *value)
@@ -46,6 +58,9 @@ static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where,
46 void __iomem *base; 58 void __iomem *base;
47 u32 data; 59 u32 data;
48 60
61 if (!ar724x_pci_link_up)
62 return PCIBIOS_DEVICE_NOT_FOUND;
63
49 if (devfn) 64 if (devfn)
50 return PCIBIOS_DEVICE_NOT_FOUND; 65 return PCIBIOS_DEVICE_NOT_FOUND;
51 66
@@ -96,6 +111,9 @@ static int ar724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where,
96 u32 data; 111 u32 data;
97 int s; 112 int s;
98 113
114 if (!ar724x_pci_link_up)
115 return PCIBIOS_DEVICE_NOT_FOUND;
116
99 if (devfn) 117 if (devfn)
100 return PCIBIOS_DEVICE_NOT_FOUND; 118 return PCIBIOS_DEVICE_NOT_FOUND;
101 119
@@ -280,6 +298,10 @@ int __init ar724x_pcibios_init(int irq)
280 if (ar724x_pci_ctrl_base == NULL) 298 if (ar724x_pci_ctrl_base == NULL)
281 goto err_unmap_devcfg; 299 goto err_unmap_devcfg;
282 300
301 ar724x_pci_link_up = ar724x_pci_check_link();
302 if (!ar724x_pci_link_up)
303 pr_warn("ar724x: PCIe link is down\n");
304
283 ar724x_pci_irq_init(irq); 305 ar724x_pci_irq_init(irq);
284 register_pci_controller(&ar724x_pci_controller); 306 register_pci_controller(&ar724x_pci_controller);
285 307
diff --git a/arch/mips/pci/pci-bcm63xx.c b/arch/mips/pci/pci-bcm63xx.c
index 39eb7c417e2..8a48139d219 100644
--- a/arch/mips/pci/pci-bcm63xx.c
+++ b/arch/mips/pci/pci-bcm63xx.c
@@ -10,6 +10,7 @@
10#include <linux/pci.h> 10#include <linux/pci.h>
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/delay.h>
13#include <asm/bootinfo.h> 14#include <asm/bootinfo.h>
14 15
15#include "pci-bcm63xx.h" 16#include "pci-bcm63xx.h"
@@ -71,6 +72,26 @@ struct pci_controller bcm63xx_cb_controller = {
71}; 72};
72#endif 73#endif
73 74
75static struct resource bcm_pcie_mem_resource = {
76 .name = "bcm63xx PCIe memory space",
77 .start = BCM_PCIE_MEM_BASE_PA,
78 .end = BCM_PCIE_MEM_END_PA,
79 .flags = IORESOURCE_MEM,
80};
81
82static struct resource bcm_pcie_io_resource = {
83 .name = "bcm63xx PCIe IO space",
84 .start = 0,
85 .end = 0,
86 .flags = 0,
87};
88
89struct pci_controller bcm63xx_pcie_controller = {
90 .pci_ops = &bcm63xx_pcie_ops,
91 .io_resource = &bcm_pcie_io_resource,
92 .mem_resource = &bcm_pcie_mem_resource,
93};
94
74static u32 bcm63xx_int_cfg_readl(u32 reg) 95static u32 bcm63xx_int_cfg_readl(u32 reg)
75{ 96{
76 u32 tmp; 97 u32 tmp;
@@ -94,17 +115,99 @@ static void bcm63xx_int_cfg_writel(u32 val, u32 reg)
94 115
95void __iomem *pci_iospace_start; 116void __iomem *pci_iospace_start;
96 117
97static int __init bcm63xx_pci_init(void) 118static void __init bcm63xx_reset_pcie(void)
98{ 119{
99 unsigned int mem_size;
100 u32 val; 120 u32 val;
101 121
102 if (!BCMCPU_IS_6348() && !BCMCPU_IS_6358() && !BCMCPU_IS_6368()) 122 /* enable clock */
103 return -ENODEV; 123 val = bcm_perf_readl(PERF_CKCTL_REG);
124 val |= CKCTL_6328_PCIE_EN;
125 bcm_perf_writel(val, PERF_CKCTL_REG);
126
127 /* enable SERDES */
128 val = bcm_misc_readl(MISC_SERDES_CTRL_REG);
129 val |= SERDES_PCIE_EN | SERDES_PCIE_EXD_EN;
130 bcm_misc_writel(val, MISC_SERDES_CTRL_REG);
131
132 /* reset the PCIe core */
133 val = bcm_perf_readl(PERF_SOFTRESET_6328_REG);
134
135 val &= ~SOFTRESET_6328_PCIE_MASK;
136 val &= ~SOFTRESET_6328_PCIE_CORE_MASK;
137 val &= ~SOFTRESET_6328_PCIE_HARD_MASK;
138 val &= ~SOFTRESET_6328_PCIE_EXT_MASK;
139 bcm_perf_writel(val, PERF_SOFTRESET_6328_REG);
140 mdelay(10);
141
142 val |= SOFTRESET_6328_PCIE_MASK;
143 val |= SOFTRESET_6328_PCIE_CORE_MASK;
144 val |= SOFTRESET_6328_PCIE_HARD_MASK;
145 bcm_perf_writel(val, PERF_SOFTRESET_6328_REG);
146 mdelay(10);
147
148 val |= SOFTRESET_6328_PCIE_EXT_MASK;
149 bcm_perf_writel(val, PERF_SOFTRESET_6328_REG);
150 mdelay(200);
151}
104 152
105 if (!bcm63xx_pci_enabled) 153static int __init bcm63xx_register_pcie(void)
106 return -ENODEV; 154{
155 u32 val;
107 156
157 bcm63xx_reset_pcie();
158
159 /* configure the PCIe bridge */
160 val = bcm_pcie_readl(PCIE_BRIDGE_OPT1_REG);
161 val |= OPT1_RD_BE_OPT_EN;
162 val |= OPT1_RD_REPLY_BE_FIX_EN;
163 val |= OPT1_PCIE_BRIDGE_HOLE_DET_EN;
164 val |= OPT1_L1_INT_STATUS_MASK_POL;
165 bcm_pcie_writel(val, PCIE_BRIDGE_OPT1_REG);
166
167 /* setup the interrupts */
168 val = bcm_pcie_readl(PCIE_BRIDGE_RC_INT_MASK_REG);
169 val |= PCIE_RC_INT_A | PCIE_RC_INT_B | PCIE_RC_INT_C | PCIE_RC_INT_D;
170 bcm_pcie_writel(val, PCIE_BRIDGE_RC_INT_MASK_REG);
171
172 val = bcm_pcie_readl(PCIE_BRIDGE_OPT2_REG);
173 /* enable credit checking and error checking */
174 val |= OPT2_TX_CREDIT_CHK_EN;
175 val |= OPT2_UBUS_UR_DECODE_DIS;
176
177 /* set device bus/func for the pcie device */
178 val |= (PCIE_BUS_DEVICE << OPT2_CFG_TYPE1_BUS_NO_SHIFT);
179 val |= OPT2_CFG_TYPE1_BD_SEL;
180 bcm_pcie_writel(val, PCIE_BRIDGE_OPT2_REG);
181
182 /* setup class code as bridge */
183 val = bcm_pcie_readl(PCIE_IDVAL3_REG);
184 val &= ~IDVAL3_CLASS_CODE_MASK;
185 val |= (PCI_CLASS_BRIDGE_PCI << IDVAL3_SUBCLASS_SHIFT);
186 bcm_pcie_writel(val, PCIE_IDVAL3_REG);
187
188 /* disable bar1 size */
189 val = bcm_pcie_readl(PCIE_CONFIG2_REG);
190 val &= ~CONFIG2_BAR1_SIZE_MASK;
191 bcm_pcie_writel(val, PCIE_CONFIG2_REG);
192
193 /* set bar0 to little endian */
194 val = (BCM_PCIE_MEM_BASE_PA >> 20) << BASEMASK_BASE_SHIFT;
195 val |= (BCM_PCIE_MEM_BASE_PA >> 20) << BASEMASK_MASK_SHIFT;
196 val |= BASEMASK_REMAP_EN;
197 bcm_pcie_writel(val, PCIE_BRIDGE_BAR0_BASEMASK_REG);
198
199 val = (BCM_PCIE_MEM_BASE_PA >> 20) << REBASE_ADDR_BASE_SHIFT;
200 bcm_pcie_writel(val, PCIE_BRIDGE_BAR0_REBASE_ADDR_REG);
201
202 register_pci_controller(&bcm63xx_pcie_controller);
203
204 return 0;
205}
206
207static int __init bcm63xx_register_pci(void)
208{
209 unsigned int mem_size;
210 u32 val;
108 /* 211 /*
109 * configuration access are done through IO space, remap 4 212 * configuration access are done through IO space, remap 4
110 * first bytes to access it from CPU. 213 * first bytes to access it from CPU.
@@ -221,4 +324,22 @@ static int __init bcm63xx_pci_init(void)
221 return 0; 324 return 0;
222} 325}
223 326
327
328static int __init bcm63xx_pci_init(void)
329{
330 if (!bcm63xx_pci_enabled)
331 return -ENODEV;
332
333 switch (bcm63xx_get_cpu_id()) {
334 case BCM6328_CPU_ID:
335 return bcm63xx_register_pcie();
336 case BCM6348_CPU_ID:
337 case BCM6358_CPU_ID:
338 case BCM6368_CPU_ID:
339 return bcm63xx_register_pci();
340 default:
341 return -ENODEV;
342 }
343}
344
224arch_initcall(bcm63xx_pci_init); 345arch_initcall(bcm63xx_pci_init);
diff --git a/arch/mips/pci/pci-bcm63xx.h b/arch/mips/pci/pci-bcm63xx.h
index a6e594ef3d6..e6736d558ac 100644
--- a/arch/mips/pci/pci-bcm63xx.h
+++ b/arch/mips/pci/pci-bcm63xx.h
@@ -13,11 +13,16 @@
13 */ 13 */
14#define CARDBUS_PCI_IDSEL 0x8 14#define CARDBUS_PCI_IDSEL 0x8
15 15
16
17#define PCIE_BUS_BRIDGE 0
18#define PCIE_BUS_DEVICE 1
19
16/* 20/*
17 * defined in ops-bcm63xx.c 21 * defined in ops-bcm63xx.c
18 */ 22 */
19extern struct pci_ops bcm63xx_pci_ops; 23extern struct pci_ops bcm63xx_pci_ops;
20extern struct pci_ops bcm63xx_cb_ops; 24extern struct pci_ops bcm63xx_cb_ops;
25extern struct pci_ops bcm63xx_pcie_ops;
21 26
22/* 27/*
23 * defined in pci-bcm63xx.c 28 * defined in pci-bcm63xx.c
diff --git a/arch/mips/pci/pci-xlp.c b/arch/mips/pci/pci-xlp.c
new file mode 100644
index 00000000000..140557a2048
--- /dev/null
+++ b/arch/mips/pci/pci-xlp.c
@@ -0,0 +1,248 @@
1/*
2 * Copyright (c) 2003-2012 Broadcom Corporation
3 * All Rights Reserved
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the Broadcom
9 * license below:
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
20 * distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#include <linux/types.h>
36#include <linux/pci.h>
37#include <linux/kernel.h>
38#include <linux/init.h>
39#include <linux/msi.h>
40#include <linux/mm.h>
41#include <linux/irq.h>
42#include <linux/irqdesc.h>
43#include <linux/console.h>
44
45#include <asm/io.h>
46
47#include <asm/netlogic/interrupt.h>
48#include <asm/netlogic/haldefs.h>
49
50#include <asm/netlogic/xlp-hal/iomap.h>
51#include <asm/netlogic/xlp-hal/pic.h>
52#include <asm/netlogic/xlp-hal/xlp.h>
53#include <asm/netlogic/xlp-hal/pcibus.h>
54#include <asm/netlogic/xlp-hal/bridge.h>
55
56static void *pci_config_base;
57
58#define pci_cfg_addr(bus, devfn, off) (((bus) << 20) | ((devfn) << 12) | (off))
59
60/* PCI ops */
61static inline u32 pci_cfg_read_32bit(struct pci_bus *bus, unsigned int devfn,
62 int where)
63{
64 u32 data;
65 u32 *cfgaddr;
66
67 cfgaddr = (u32 *)(pci_config_base +
68 pci_cfg_addr(bus->number, devfn, where & ~3));
69 data = *cfgaddr;
70 return data;
71}
72
73static inline void pci_cfg_write_32bit(struct pci_bus *bus, unsigned int devfn,
74 int where, u32 data)
75{
76 u32 *cfgaddr;
77
78 cfgaddr = (u32 *)(pci_config_base +
79 pci_cfg_addr(bus->number, devfn, where & ~3));
80 *cfgaddr = data;
81}
82
83static int nlm_pcibios_read(struct pci_bus *bus, unsigned int devfn,
84 int where, int size, u32 *val)
85{
86 u32 data;
87
88 if ((size == 2) && (where & 1))
89 return PCIBIOS_BAD_REGISTER_NUMBER;
90 else if ((size == 4) && (where & 3))
91 return PCIBIOS_BAD_REGISTER_NUMBER;
92
93 data = pci_cfg_read_32bit(bus, devfn, where);
94
95 if (size == 1)
96 *val = (data >> ((where & 3) << 3)) & 0xff;
97 else if (size == 2)
98 *val = (data >> ((where & 3) << 3)) & 0xffff;
99 else
100 *val = data;
101
102 return PCIBIOS_SUCCESSFUL;
103}
104
105
106static int nlm_pcibios_write(struct pci_bus *bus, unsigned int devfn,
107 int where, int size, u32 val)
108{
109 u32 data;
110
111 if ((size == 2) && (where & 1))
112 return PCIBIOS_BAD_REGISTER_NUMBER;
113 else if ((size == 4) && (where & 3))
114 return PCIBIOS_BAD_REGISTER_NUMBER;
115
116 data = pci_cfg_read_32bit(bus, devfn, where);
117
118 if (size == 1)
119 data = (data & ~(0xff << ((where & 3) << 3))) |
120 (val << ((where & 3) << 3));
121 else if (size == 2)
122 data = (data & ~(0xffff << ((where & 3) << 3))) |
123 (val << ((where & 3) << 3));
124 else
125 data = val;
126
127 pci_cfg_write_32bit(bus, devfn, where, data);
128
129 return PCIBIOS_SUCCESSFUL;
130}
131
132struct pci_ops nlm_pci_ops = {
133 .read = nlm_pcibios_read,
134 .write = nlm_pcibios_write
135};
136
137static struct resource nlm_pci_mem_resource = {
138 .name = "XLP PCI MEM",
139 .start = 0xd0000000UL, /* 256MB PCI mem @ 0xd000_0000 */
140 .end = 0xdfffffffUL,
141 .flags = IORESOURCE_MEM,
142};
143
144static struct resource nlm_pci_io_resource = {
145 .name = "XLP IO MEM",
146 .start = 0x14000000UL, /* 64MB PCI IO @ 0x1000_0000 */
147 .end = 0x17ffffffUL,
148 .flags = IORESOURCE_IO,
149};
150
151struct pci_controller nlm_pci_controller = {
152 .index = 0,
153 .pci_ops = &nlm_pci_ops,
154 .mem_resource = &nlm_pci_mem_resource,
155 .mem_offset = 0x00000000UL,
156 .io_resource = &nlm_pci_io_resource,
157 .io_offset = 0x00000000UL,
158};
159
160static int get_irq_vector(const struct pci_dev *dev)
161{
162 /*
163 * For XLP PCIe, there is an IRQ per Link, find out which
164 * link the device is on to assign interrupts
165 */
166 if (dev->bus->self == NULL)
167 return 0;
168
169 switch (dev->bus->self->devfn) {
170 case 0x8:
171 return PIC_PCIE_LINK_0_IRQ;
172 case 0x9:
173 return PIC_PCIE_LINK_1_IRQ;
174 case 0xa:
175 return PIC_PCIE_LINK_2_IRQ;
176 case 0xb:
177 return PIC_PCIE_LINK_3_IRQ;
178 }
179 WARN(1, "Unexpected devfn %d\n", dev->bus->self->devfn);
180 return 0;
181}
182
183int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
184{
185 return get_irq_vector(dev);
186}
187
188/* Do platform specific device initialization at pci_enable_device() time */
189int pcibios_plat_dev_init(struct pci_dev *dev)
190{
191 return 0;
192}
193
194static int xlp_enable_pci_bswap(void)
195{
196 uint64_t pciebase, sysbase;
197 int node, i;
198 u32 reg;
199
200 /* Chip-0 so node set to 0 */
201 node = 0;
202 sysbase = nlm_get_bridge_regbase(node);
203 /*
204 * Enable byte swap in hardware. Program each link's PCIe SWAP regions
205 * from the link's address ranges.
206 */
207 for (i = 0; i < 4; i++) {
208 pciebase = nlm_pcicfg_base(XLP_IO_PCIE_OFFSET(node, i));
209 if (nlm_read_pci_reg(pciebase, 0) == 0xffffffff)
210 continue;
211
212 reg = nlm_read_bridge_reg(sysbase, BRIDGE_PCIEMEM_BASE0 + i);
213 nlm_write_pci_reg(pciebase, PCIE_BYTE_SWAP_MEM_BASE, reg);
214
215 reg = nlm_read_bridge_reg(sysbase, BRIDGE_PCIEMEM_LIMIT0 + i);
216 nlm_write_pci_reg(pciebase, PCIE_BYTE_SWAP_MEM_LIM,
217 reg | 0xfff);
218
219 reg = nlm_read_bridge_reg(sysbase, BRIDGE_PCIEIO_BASE0 + i);
220 nlm_write_pci_reg(pciebase, PCIE_BYTE_SWAP_IO_BASE, reg);
221
222 reg = nlm_read_bridge_reg(sysbase, BRIDGE_PCIEIO_LIMIT0 + i);
223 nlm_write_pci_reg(pciebase, PCIE_BYTE_SWAP_IO_LIM, reg | 0xfff);
224 }
225 return 0;
226}
227
228static int __init pcibios_init(void)
229{
230 /* Firmware assigns PCI resources */
231 pci_set_flags(PCI_PROBE_ONLY);
232 pci_config_base = ioremap(XLP_DEFAULT_PCI_ECFG_BASE, 64 << 20);
233
234 /* Extend IO port for memory mapped io */
235 ioport_resource.start = 0;
236 ioport_resource.end = ~0;
237
238 xlp_enable_pci_bswap();
239 set_io_port_base(CKSEG1);
240 nlm_pci_controller.io_map_base = CKSEG1;
241
242 register_pci_controller(&nlm_pci_controller);
243 pr_info("XLP PCIe Controller %pR%pR.\n", &nlm_pci_io_resource,
244 &nlm_pci_mem_resource);
245
246 return 0;
247}
248arch_initcall(pcibios_init);
diff --git a/arch/mips/pci/pci-xlr.c b/arch/mips/pci/pci-xlr.c
index 172af1cd586..18af021d289 100644
--- a/arch/mips/pci/pci-xlr.c
+++ b/arch/mips/pci/pci-xlr.c
@@ -375,7 +375,3 @@ static int __init pcibios_init(void)
375} 375}
376 376
377arch_initcall(pcibios_init); 377arch_initcall(pcibios_init);
378
379struct pci_fixup pcibios_fixups[] = {
380 {0}
381};
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 271e8c4a54c..690356808f8 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -102,7 +102,7 @@ static void __devinit pcibios_scanbus(struct pci_controller *hose)
102 need_domain_info = need_domain_info || hose->index; 102 need_domain_info = need_domain_info || hose->index;
103 hose->need_domain_info = need_domain_info; 103 hose->need_domain_info = need_domain_info;
104 if (bus) { 104 if (bus) {
105 next_busno = bus->subordinate + 1; 105 next_busno = bus->busn_res.end + 1;
106 /* Don't allow 8-bit bus number overflow inside the hose - 106 /* Don't allow 8-bit bus number overflow inside the hose -
107 reserve some space for bridges. */ 107 reserve some space for bridges. */
108 if (next_busno > 224) { 108 if (next_busno > 224) {
@@ -348,9 +348,9 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
348 vma->vm_end - vma->vm_start, vma->vm_page_prot); 348 vma->vm_end - vma->vm_start, vma->vm_page_prot);
349} 349}
350 350
351char * (*pcibios_plat_setup)(char *str) __devinitdata; 351char * (*pcibios_plat_setup)(char *str) __initdata;
352 352
353char *__devinit pcibios_setup(char *str) 353char *__init pcibios_setup(char *str)
354{ 354{
355 if (pcibios_plat_setup) 355 if (pcibios_plat_setup)
356 return pcibios_plat_setup(str); 356 return pcibios_plat_setup(str);
diff --git a/arch/mips/pmc-sierra/yosemite/ht.c b/arch/mips/pmc-sierra/yosemite/ht.c
index 63be40e470d..14dc9c8fff0 100644
--- a/arch/mips/pmc-sierra/yosemite/ht.c
+++ b/arch/mips/pmc-sierra/yosemite/ht.c
@@ -395,17 +395,6 @@ void __init pcibios_init(void)
395 pci_scan_bus(3, &titan_pci_ops, NULL); 395 pci_scan_bus(3, &titan_pci_ops, NULL);
396} 396}
397 397
398/*
399 * for parsing "pci=" kernel boot arguments.
400 */
401char *pcibios_setup(char *str)
402{
403 printk(KERN_INFO "rr: pcibios_setup\n");
404 /* Nothing to do for now. */
405
406 return str;
407}
408
409unsigned __init int pcibios_assign_all_busses(void) 398unsigned __init int pcibios_assign_all_busses(void)
410{ 399{
411 /* We want to use the PCI bus detection done by PMON */ 400 /* We want to use the PCI bus detection done by PMON */
diff --git a/arch/mips/pnx833x/stb22x/board.c b/arch/mips/pnx833x/stb22x/board.c
index 644eb7c3210..4b328ac4305 100644
--- a/arch/mips/pnx833x/stb22x/board.c
+++ b/arch/mips/pnx833x/stb22x/board.c
@@ -91,7 +91,7 @@ void __init pnx833x_board_setup(void)
91 pnx833x_gpio_select_function_alt(32); 91 pnx833x_gpio_select_function_alt(32);
92 pnx833x_gpio_select_function_alt(33); 92 pnx833x_gpio_select_function_alt(33);
93 93
94#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE) 94#if IS_ENABLED(CONFIG_MTD_NAND_PLATFORM)
95 /* Setup MIU for NAND access on CS0... 95 /* Setup MIU for NAND access on CS0...
96 * 96 *
97 * (it seems that we must also configure CS1 for reliable operation, 97 * (it seems that we must also configure CS1 for reliable operation,
@@ -117,7 +117,7 @@ void __init pnx833x_board_setup(void)
117 pnx833x_gpio_select_output(5); 117 pnx833x_gpio_select_output(5);
118 pnx833x_gpio_write(1, 5); 118 pnx833x_gpio_write(1, 5);
119 119
120#elif defined(CONFIG_MTD_CFI) || defined(CONFIG_MTD_CFI_MODULE) 120#elif IS_ENABLED(CONFIG_MTD_CFI)
121 121
122 /* Set up MIU for 16-bit NOR access on CS0 and CS1... */ 122 /* Set up MIU for 16-bit NOR access on CS0 and CS1... */
123 123
diff --git a/arch/mips/powertv/powertv_setup.c b/arch/mips/powertv/powertv_setup.c
index 3933c373a43..820b8480f22 100644
--- a/arch/mips/powertv/powertv_setup.c
+++ b/arch/mips/powertv/powertv_setup.c
@@ -254,7 +254,7 @@ early_param("rfmac", rfmac_param);
254 * Generates an Ethernet MAC address that is highly likely to be unique for 254 * Generates an Ethernet MAC address that is highly likely to be unique for
255 * this particular system on a network with other systems of the same type. 255 * this particular system on a network with other systems of the same type.
256 * 256 *
257 * The problem we are solving is that, when random_ether_addr() is used to 257 * The problem we are solving is that, when eth_random_addr() is used to
258 * generate MAC addresses at startup, there isn't much entropy for the random 258 * generate MAC addresses at startup, there isn't much entropy for the random
259 * number generator to use and the addresses it produces are fairly likely to 259 * number generator to use and the addresses it produces are fairly likely to
260 * be the same as those of other identical systems on the same local network. 260 * be the same as those of other identical systems on the same local network.
@@ -269,7 +269,7 @@ early_param("rfmac", rfmac_param);
269 * Still, this does give us something to work with. 269 * Still, this does give us something to work with.
270 * 270 *
271 * The approach we take is: 271 * The approach we take is:
272 * 1. If we can't get the RF MAC Address, just call random_ether_addr. 272 * 1. If we can't get the RF MAC Address, just call eth_random_addr.
273 * 2. Use the 24-bit NIC-specific bits of the RF MAC address as the last 24 273 * 2. Use the 24-bit NIC-specific bits of the RF MAC address as the last 24
274 * bits of the new address. This is very likely to be unique, except for 274 * bits of the new address. This is very likely to be unique, except for
275 * the current box. 275 * the current box.
@@ -299,7 +299,7 @@ void platform_random_ether_addr(u8 addr[ETH_ALEN])
299 if (!have_rfmac) { 299 if (!have_rfmac) {
300 pr_warning("rfmac not available on command line; " 300 pr_warning("rfmac not available on command line; "
301 "generating random MAC address\n"); 301 "generating random MAC address\n");
302 random_ether_addr(addr); 302 eth_random_addr(addr);
303 } 303 }
304 304
305 else { 305 else {
diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c
index b105eca3c02..cd8fcab6b05 100644
--- a/arch/mips/sgi-ip27/ip27-memory.c
+++ b/arch/mips/sgi-ip27/ip27-memory.c
@@ -401,6 +401,7 @@ static void __init node_mem_init(cnodeid_t node)
401 * Allocate the node data structures on the node first. 401 * Allocate the node data structures on the node first.
402 */ 402 */
403 __node_data[node] = __va(slot_freepfn << PAGE_SHIFT); 403 __node_data[node] = __va(slot_freepfn << PAGE_SHIFT);
404 memset(__node_data[node], 0, PAGE_SIZE);
404 405
405 NODE_DATA(node)->bdata = &bootmem_node_data[node]; 406 NODE_DATA(node)->bdata = &bootmem_node_data[node];
406 NODE_DATA(node)->node_start_pfn = start_pfn; 407 NODE_DATA(node)->node_start_pfn = start_pfn;
diff --git a/arch/mips/txx9/Kconfig b/arch/mips/txx9/Kconfig
index 852ae4bb7a8..6d40bc78345 100644
--- a/arch/mips/txx9/Kconfig
+++ b/arch/mips/txx9/Kconfig
@@ -20,6 +20,7 @@ config MACH_TXX9
20 select SYS_SUPPORTS_32BIT_KERNEL 20 select SYS_SUPPORTS_32BIT_KERNEL
21 select SYS_SUPPORTS_LITTLE_ENDIAN 21 select SYS_SUPPORTS_LITTLE_ENDIAN
22 select SYS_SUPPORTS_BIG_ENDIAN 22 select SYS_SUPPORTS_BIG_ENDIAN
23 select HAVE_CLK
23 24
24config TOSHIBA_JMR3927 25config TOSHIBA_JMR3927
25 bool "Toshiba JMR-TX3927 board" 26 bool "Toshiba JMR-TX3927 board"
diff --git a/arch/mips/txx9/generic/pci.c b/arch/mips/txx9/generic/pci.c
index 64eb71b1528..4efd9185f29 100644
--- a/arch/mips/txx9/generic/pci.c
+++ b/arch/mips/txx9/generic/pci.c
@@ -256,7 +256,7 @@ static irqreturn_t i8259_interrupt(int irq, void *dev_id)
256 return IRQ_HANDLED; 256 return IRQ_HANDLED;
257} 257}
258 258
259static int __init 259static int __devinit
260txx9_i8259_irq_setup(int irq) 260txx9_i8259_irq_setup(int irq)
261{ 261{
262 int err; 262 int err;
@@ -304,7 +304,7 @@ static void __devinit quirk_slc90e66_bridge(struct pci_dev *dev)
304 smsc_fdc37m81x_config_end(); 304 smsc_fdc37m81x_config_end();
305} 305}
306 306
307static void quirk_slc90e66_ide(struct pci_dev *dev) 307static void __devinit quirk_slc90e66_ide(struct pci_dev *dev)
308{ 308{
309 unsigned char dat; 309 unsigned char dat;
310 int regs[2] = {0x41, 0x43}; 310 int regs[2] = {0x41, 0x43};
@@ -339,7 +339,7 @@ static void quirk_slc90e66_ide(struct pci_dev *dev)
339} 339}
340#endif /* CONFIG_TOSHIBA_FPCIB0 */ 340#endif /* CONFIG_TOSHIBA_FPCIB0 */
341 341
342static void tc35815_fixup(struct pci_dev *dev) 342static void __devinit tc35815_fixup(struct pci_dev *dev)
343{ 343{
344 /* This device may have PM registers but not they are not suported. */ 344 /* This device may have PM registers but not they are not suported. */
345 if (dev->pm_cap) { 345 if (dev->pm_cap) {
@@ -348,7 +348,7 @@ static void tc35815_fixup(struct pci_dev *dev)
348 } 348 }
349} 349}
350 350
351static void final_fixup(struct pci_dev *dev) 351static void __devinit final_fixup(struct pci_dev *dev)
352{ 352{
353 unsigned char bist; 353 unsigned char bist;
354 354
@@ -398,9 +398,9 @@ int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
398 return txx9_board_vec->pci_map_irq(dev, slot, pin); 398 return txx9_board_vec->pci_map_irq(dev, slot, pin);
399} 399}
400 400
401char * (*txx9_board_pcibios_setup)(char *str) __devinitdata; 401char * (*txx9_board_pcibios_setup)(char *str) __initdata;
402 402
403char *__devinit txx9_pcibios_setup(char *str) 403char *__init txx9_pcibios_setup(char *str)
404{ 404{
405 if (txx9_board_pcibios_setup && !txx9_board_pcibios_setup(str)) 405 if (txx9_board_pcibios_setup && !txx9_board_pcibios_setup(str))
406 return NULL; 406 return NULL;
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index ae77a7916c0..560fe899175 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -632,7 +632,7 @@ void __init txx9_physmap_flash_init(int no, unsigned long addr,
632 unsigned long size, 632 unsigned long size,
633 const struct physmap_flash_data *pdata) 633 const struct physmap_flash_data *pdata)
634{ 634{
635#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 635#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
636 struct resource res = { 636 struct resource res = {
637 .start = addr, 637 .start = addr,
638 .end = addr + size - 1, 638 .end = addr + size - 1,
@@ -670,8 +670,7 @@ void __init txx9_physmap_flash_init(int no, unsigned long addr,
670void __init txx9_ndfmc_init(unsigned long baseaddr, 670void __init txx9_ndfmc_init(unsigned long baseaddr,
671 const struct txx9ndfmc_platform_data *pdata) 671 const struct txx9ndfmc_platform_data *pdata)
672{ 672{
673#if defined(CONFIG_MTD_NAND_TXX9NDFMC) || \ 673#if IS_ENABLED(CONFIG_MTD_NAND_TXX9NDFMC)
674 defined(CONFIG_MTD_NAND_TXX9NDFMC_MODULE)
675 struct resource res = { 674 struct resource res = {
676 .start = baseaddr, 675 .start = baseaddr,
677 .end = baseaddr + 0x1000 - 1, 676 .end = baseaddr + 0x1000 - 1,
@@ -687,7 +686,7 @@ void __init txx9_ndfmc_init(unsigned long baseaddr,
687#endif 686#endif
688} 687}
689 688
690#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) 689#if IS_ENABLED(CONFIG_LEDS_GPIO)
691static DEFINE_SPINLOCK(txx9_iocled_lock); 690static DEFINE_SPINLOCK(txx9_iocled_lock);
692 691
693#define TXX9_IOCLED_MAXLEDS 8 692#define TXX9_IOCLED_MAXLEDS 8
@@ -810,7 +809,7 @@ void __init txx9_iocled_init(unsigned long baseaddr,
810void __init txx9_dmac_init(int id, unsigned long baseaddr, int irq, 809void __init txx9_dmac_init(int id, unsigned long baseaddr, int irq,
811 const struct txx9dmac_platform_data *pdata) 810 const struct txx9dmac_platform_data *pdata)
812{ 811{
813#if defined(CONFIG_TXX9_DMAC) || defined(CONFIG_TXX9_DMAC_MODULE) 812#if IS_ENABLED(CONFIG_TXX9_DMAC)
814 struct resource res[] = { 813 struct resource res[] = {
815 { 814 {
816 .start = baseaddr, 815 .start = baseaddr,
@@ -866,8 +865,7 @@ void __init txx9_aclc_init(unsigned long baseaddr, int irq,
866 unsigned int dma_chan_out, 865 unsigned int dma_chan_out,
867 unsigned int dma_chan_in) 866 unsigned int dma_chan_in)
868{ 867{
869#if defined(CONFIG_SND_SOC_TXX9ACLC) || \ 868#if IS_ENABLED(CONFIG_SND_SOC_TXX9ACLC)
870 defined(CONFIG_SND_SOC_TXX9ACLC_MODULE)
871 unsigned int dma_base = dmac_id * TXX9_DMA_MAX_NR_CHANNELS; 869 unsigned int dma_base = dmac_id * TXX9_DMA_MAX_NR_CHANNELS;
872 struct resource res[] = { 870 struct resource res[] = {
873 { 871 {
diff --git a/arch/mips/txx9/generic/setup_tx4939.c b/arch/mips/txx9/generic/setup_tx4939.c
index 6567895d1f5..5ff7a9584da 100644
--- a/arch/mips/txx9/generic/setup_tx4939.c
+++ b/arch/mips/txx9/generic/setup_tx4939.c
@@ -317,7 +317,7 @@ void __init tx4939_sio_init(unsigned int sclk, unsigned int cts_mask)
317 } 317 }
318} 318}
319 319
320#if defined(CONFIG_TC35815) || defined(CONFIG_TC35815_MODULE) 320#if IS_ENABLED(CONFIG_TC35815)
321static u32 tx4939_get_eth_speed(struct net_device *dev) 321static u32 tx4939_get_eth_speed(struct net_device *dev)
322{ 322{
323 struct ethtool_cmd cmd; 323 struct ethtool_cmd cmd;
diff --git a/arch/mips/txx9/rbtx4939/setup.c b/arch/mips/txx9/rbtx4939/setup.c
index 2ad8973ba13..e15641d9309 100644
--- a/arch/mips/txx9/rbtx4939/setup.c
+++ b/arch/mips/txx9/rbtx4939/setup.c
@@ -40,8 +40,7 @@ static void __init rbtx4939_time_init(void)
40 tx4939_time_init(0); 40 tx4939_time_init(0);
41} 41}
42 42
43#if defined(__BIG_ENDIAN) && \ 43#if defined(__BIG_ENDIAN) && IS_ENABLED(CONFIG_SMC91X)
44 (defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE))
45#define HAVE_RBTX4939_IOSWAB 44#define HAVE_RBTX4939_IOSWAB
46#define IS_CE1_ADDR(addr) \ 45#define IS_CE1_ADDR(addr) \
47 ((((unsigned long)(addr) - IO_BASE) & 0xfff00000) == TXX9_CE(1)) 46 ((((unsigned long)(addr) - IO_BASE) & 0xfff00000) == TXX9_CE(1))
@@ -187,7 +186,7 @@ static void __init rbtx4939_update_ioc_pen(void)
187 186
188#define RBTX4939_MAX_7SEGLEDS 8 187#define RBTX4939_MAX_7SEGLEDS 8
189 188
190#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) 189#if IS_ENABLED(CONFIG_LEDS_CLASS)
191static u8 led_val[RBTX4939_MAX_7SEGLEDS]; 190static u8 led_val[RBTX4939_MAX_7SEGLEDS];
192struct rbtx4939_led_data { 191struct rbtx4939_led_data {
193 struct led_classdev cdev; 192 struct led_classdev cdev;
@@ -263,7 +262,7 @@ static inline void rbtx4939_led_setup(void)
263 262
264static void __rbtx4939_7segled_putc(unsigned int pos, unsigned char val) 263static void __rbtx4939_7segled_putc(unsigned int pos, unsigned char val)
265{ 264{
266#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) 265#if IS_ENABLED(CONFIG_LEDS_CLASS)
267 unsigned long flags; 266 unsigned long flags;
268 local_irq_save(flags); 267 local_irq_save(flags);
269 /* bit7: reserved for LED class */ 268 /* bit7: reserved for LED class */
@@ -287,7 +286,7 @@ static void rbtx4939_7segled_putc(unsigned int pos, unsigned char val)
287 __rbtx4939_7segled_putc(pos, val); 286 __rbtx4939_7segled_putc(pos, val);
288} 287}
289 288
290#if defined(CONFIG_MTD_RBTX4939) || defined(CONFIG_MTD_RBTX4939_MODULE) 289#if IS_ENABLED(CONFIG_MTD_RBTX4939)
291/* special mapping for boot rom */ 290/* special mapping for boot rom */
292static unsigned long rbtx4939_flash_fixup_ofs(unsigned long ofs) 291static unsigned long rbtx4939_flash_fixup_ofs(unsigned long ofs)
293{ 292{
@@ -463,7 +462,7 @@ static void __init rbtx4939_device_init(void)
463 .flags = SMC91X_USE_16BIT, 462 .flags = SMC91X_USE_16BIT,
464 }; 463 };
465 struct platform_device *pdev; 464 struct platform_device *pdev;
466#if defined(CONFIG_TC35815) || defined(CONFIG_TC35815_MODULE) 465#if IS_ENABLED(CONFIG_TC35815)
467 int i, j; 466 int i, j;
468 unsigned char ethaddr[2][6]; 467 unsigned char ethaddr[2][6];
469 u8 bdipsw = readb(rbtx4939_bdipsw_addr) & 0x0f; 468 u8 bdipsw = readb(rbtx4939_bdipsw_addr) & 0x0f;
diff --git a/arch/mn10300/Kconfig b/arch/mn10300/Kconfig
index 687f9b4a2ed..5cfb086b390 100644
--- a/arch/mn10300/Kconfig
+++ b/arch/mn10300/Kconfig
@@ -3,6 +3,7 @@ config MN10300
3 select HAVE_OPROFILE 3 select HAVE_OPROFILE
4 select HAVE_GENERIC_HARDIRQS 4 select HAVE_GENERIC_HARDIRQS
5 select GENERIC_IRQ_SHOW 5 select GENERIC_IRQ_SHOW
6 select ARCH_WANT_IPC_PARSE_VERSION
6 select HAVE_ARCH_TRACEHOOK 7 select HAVE_ARCH_TRACEHOOK
7 select HAVE_ARCH_KGDB 8 select HAVE_ARCH_KGDB
8 select HAVE_NMI_WATCHDOG if MN10300_WD_TIMER 9 select HAVE_NMI_WATCHDOG if MN10300_WD_TIMER
diff --git a/arch/mn10300/include/asm/ipc.h b/arch/mn10300/include/asm/ipc.h
deleted file mode 100644
index a46e3d9c2a3..00000000000
--- a/arch/mn10300/include/asm/ipc.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/ipc.h>
diff --git a/arch/mn10300/include/asm/unistd.h b/arch/mn10300/include/asm/unistd.h
index 9051f921cbc..866eb14749d 100644
--- a/arch/mn10300/include/asm/unistd.h
+++ b/arch/mn10300/include/asm/unistd.h
@@ -358,7 +358,6 @@
358/* 358/*
359 * specify the deprecated syscalls we want to support on this arch 359 * specify the deprecated syscalls we want to support on this arch
360 */ 360 */
361#define __ARCH_WANT_IPC_PARSE_VERSION
362#define __ARCH_WANT_OLD_READDIR 361#define __ARCH_WANT_OLD_READDIR
363#define __ARCH_WANT_OLD_STAT 362#define __ARCH_WANT_OLD_STAT
364#define __ARCH_WANT_STAT64 363#define __ARCH_WANT_STAT64
diff --git a/arch/mn10300/kernel/smp.c b/arch/mn10300/kernel/smp.c
index 090d35d3697..e62c223e4c4 100644
--- a/arch/mn10300/kernel/smp.c
+++ b/arch/mn10300/kernel/smp.c
@@ -876,9 +876,7 @@ static void __init smp_online(void)
876 876
877 notify_cpu_starting(cpu); 877 notify_cpu_starting(cpu);
878 878
879 ipi_call_lock();
880 set_cpu_online(cpu, true); 879 set_cpu_online(cpu, true);
881 ipi_call_unlock();
882 880
883 local_irq_enable(); 881 local_irq_enable();
884} 882}
diff --git a/arch/openrisc/include/asm/Kbuild b/arch/openrisc/include/asm/Kbuild
index 3f35c38d7b6..0922959663a 100644
--- a/arch/openrisc/include/asm/Kbuild
+++ b/arch/openrisc/include/asm/Kbuild
@@ -13,7 +13,6 @@ generic-y += cacheflush.h
13generic-y += checksum.h 13generic-y += checksum.h
14generic-y += cmpxchg.h 14generic-y += cmpxchg.h
15generic-y += cmpxchg-local.h 15generic-y += cmpxchg-local.h
16generic-y += cpumask.h
17generic-y += cputime.h 16generic-y += cputime.h
18generic-y += current.h 17generic-y += current.h
19generic-y += device.h 18generic-y += device.h
@@ -43,7 +42,6 @@ generic-y += percpu.h
43generic-y += poll.h 42generic-y += poll.h
44generic-y += posix_types.h 43generic-y += posix_types.h
45generic-y += resource.h 44generic-y += resource.h
46generic-y += rmap.h
47generic-y += scatterlist.h 45generic-y += scatterlist.h
48generic-y += sections.h 46generic-y += sections.h
49generic-y += segment.h 47generic-y += segment.h
diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
index 6c6defc2461..af9cf30ed47 100644
--- a/arch/parisc/include/asm/atomic.h
+++ b/arch/parisc/include/asm/atomic.h
@@ -141,7 +141,7 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
141 141
142#define atomic_sub_and_test(i,v) (atomic_sub_return((i),(v)) == 0) 142#define atomic_sub_and_test(i,v) (atomic_sub_return((i),(v)) == 0)
143 143
144#define ATOMIC_INIT(i) ((atomic_t) { (i) }) 144#define ATOMIC_INIT(i) { (i) }
145 145
146#define smp_mb__before_atomic_dec() smp_mb() 146#define smp_mb__before_atomic_dec() smp_mb()
147#define smp_mb__after_atomic_dec() smp_mb() 147#define smp_mb__after_atomic_dec() smp_mb()
@@ -150,7 +150,7 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
150 150
151#ifdef CONFIG_64BIT 151#ifdef CONFIG_64BIT
152 152
153#define ATOMIC64_INIT(i) ((atomic64_t) { (i) }) 153#define ATOMIC64_INIT(i) { (i) }
154 154
155static __inline__ s64 155static __inline__ s64
156__atomic64_add_return(s64 i, atomic64_t *v) 156__atomic64_add_return(s64 i, atomic64_t *v)
diff --git a/arch/parisc/include/asm/compat_rt_sigframe.h b/arch/parisc/include/asm/compat_rt_sigframe.h
index 81bec28bdc4..b3f95a7f18b 100644
--- a/arch/parisc/include/asm/compat_rt_sigframe.h
+++ b/arch/parisc/include/asm/compat_rt_sigframe.h
@@ -1,6 +1,6 @@
1#include<linux/compat.h> 1#include <linux/compat.h>
2#include<linux/compat_siginfo.h> 2#include <linux/compat_siginfo.h>
3#include<asm/compat_ucontext.h> 3#include <asm/compat_ucontext.h>
4 4
5#ifndef _ASM_PARISC_COMPAT_RT_SIGFRAME_H 5#ifndef _ASM_PARISC_COMPAT_RT_SIGFRAME_H
6#define _ASM_PARISC_COMPAT_RT_SIGFRAME_H 6#define _ASM_PARISC_COMPAT_RT_SIGFRAME_H
diff --git a/arch/parisc/kernel/pci.c b/arch/parisc/kernel/pci.c
index 24644aca10c..60309051875 100644
--- a/arch/parisc/kernel/pci.c
+++ b/arch/parisc/kernel/pci.c
@@ -139,11 +139,6 @@ void pcibios_fixup_bus(struct pci_bus *bus)
139} 139}
140 140
141 141
142char *pcibios_setup(char *str)
143{
144 return str;
145}
146
147/* 142/*
148 * Called by pci_set_master() - a driver interface. 143 * Called by pci_set_master() - a driver interface.
149 * 144 *
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
index d4b94b395c1..2c05a9292a8 100644
--- a/arch/parisc/kernel/process.c
+++ b/arch/parisc/kernel/process.c
@@ -309,7 +309,7 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
309 cregs->ksp = (unsigned long)stack 309 cregs->ksp = (unsigned long)stack
310 + (pregs->gr[21] & (THREAD_SIZE - 1)); 310 + (pregs->gr[21] & (THREAD_SIZE - 1));
311 cregs->gr[30] = usp; 311 cregs->gr[30] = usp;
312 if (p->personality == PER_HPUX) { 312 if (personality(p->personality) == PER_HPUX) {
313#ifdef CONFIG_HPUX 313#ifdef CONFIG_HPUX
314 cregs->kpc = (unsigned long) &hpux_child_return; 314 cregs->kpc = (unsigned long) &hpux_child_return;
315#else 315#else
diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
index a47828d31fe..6266730efd6 100644
--- a/arch/parisc/kernel/smp.c
+++ b/arch/parisc/kernel/smp.c
@@ -300,9 +300,7 @@ smp_cpu_init(int cpunum)
300 300
301 notify_cpu_starting(cpunum); 301 notify_cpu_starting(cpunum);
302 302
303 ipi_call_lock();
304 set_cpu_online(cpunum, true); 303 set_cpu_online(cpunum, true);
305 ipi_call_unlock();
306 304
307 /* Initialise the idle task for this CPU */ 305 /* Initialise the idle task for this CPU */
308 atomic_inc(&init_mm.mm_count); 306 atomic_inc(&init_mm.mm_count);
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index c9b932260f4..7426e40699b 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -225,12 +225,12 @@ long parisc_personality(unsigned long personality)
225 long err; 225 long err;
226 226
227 if (personality(current->personality) == PER_LINUX32 227 if (personality(current->personality) == PER_LINUX32
228 && personality == PER_LINUX) 228 && personality(personality) == PER_LINUX)
229 personality = PER_LINUX32; 229 personality = (personality & ~PER_MASK) | PER_LINUX32;
230 230
231 err = sys_personality(personality); 231 err = sys_personality(personality);
232 if (err == PER_LINUX32) 232 if (personality(err) == PER_LINUX32)
233 err = PER_LINUX; 233 err = (err & ~PER_MASK) | PER_LINUX;
234 234
235 return err; 235 return err;
236} 236}
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 050cb371a69..352f416269c 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -115,11 +115,13 @@ config PPC
115 select HAVE_OPROFILE 115 select HAVE_OPROFILE
116 select HAVE_SYSCALL_WRAPPERS if PPC64 116 select HAVE_SYSCALL_WRAPPERS if PPC64
117 select GENERIC_ATOMIC64 if PPC32 117 select GENERIC_ATOMIC64 if PPC32
118 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
118 select HAVE_IRQ_WORK 119 select HAVE_IRQ_WORK
119 select HAVE_PERF_EVENTS 120 select HAVE_PERF_EVENTS
120 select HAVE_REGS_AND_STACK_ACCESS_API 121 select HAVE_REGS_AND_STACK_ACCESS_API
121 select HAVE_HW_BREAKPOINT if PERF_EVENTS && PPC_BOOK3S_64 122 select HAVE_HW_BREAKPOINT if PERF_EVENTS && PPC_BOOK3S_64
122 select HAVE_GENERIC_HARDIRQS 123 select HAVE_GENERIC_HARDIRQS
124 select ARCH_WANT_IPC_PARSE_VERSION
123 select SPARSE_IRQ 125 select SPARSE_IRQ
124 select IRQ_PER_CPU 126 select IRQ_PER_CPU
125 select IRQ_DOMAIN 127 select IRQ_DOMAIN
@@ -653,7 +655,7 @@ config SBUS
653config FSL_SOC 655config FSL_SOC
654 bool 656 bool
655 select HAVE_CAN_FLEXCAN if NET && CAN 657 select HAVE_CAN_FLEXCAN if NET && CAN
656 select PPC_CLOCK if CAN_FLEXCAN 658 select PPC_CLOCK
657 659
658config FSL_PCI 660config FSL_PCI
659 bool 661 bool
diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
index e5f26890a69..5416e28a753 100644
--- a/arch/powerpc/Kconfig.debug
+++ b/arch/powerpc/Kconfig.debug
@@ -331,4 +331,13 @@ config STRICT_DEVMEM
331 331
332 If you are unsure, say Y. 332 If you are unsure, say Y.
333 333
334config FAIL_IOMMU
335 bool "Fault-injection capability for IOMMU"
336 depends on FAULT_INJECTION
337 help
338 Provide fault-injection capability for IOMMU. Each device can
339 be selectively enabled via the fail_iommu property.
340
341 If you are unsure, say N.
342
334endmenu 343endmenu
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 950d1f7a5a3..159e94f4b22 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -149,7 +149,6 @@ core-$(CONFIG_KVM) += arch/powerpc/kvm/
149core-$(CONFIG_PERF_EVENTS) += arch/powerpc/perf/ 149core-$(CONFIG_PERF_EVENTS) += arch/powerpc/perf/
150 150
151drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/ 151drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/
152drivers-$(CONFIG_CRYPTO_DEV_NX) += drivers/crypto/nx/
153 152
154# Default to zImage, override when needed 153# Default to zImage, override when needed
155all: zImage 154all: zImage
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index e8461cb18d0..b7d833382be 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -62,26 +62,45 @@ libfdtheader := fdt.h libfdt.h libfdt_internal.h
62$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o): \ 62$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o): \
63 $(addprefix $(obj)/,$(libfdtheader)) 63 $(addprefix $(obj)/,$(libfdtheader))
64 64
65src-wlib := string.S crt0.S crtsavres.S stdio.c main.c \ 65src-wlib-y := string.S crt0.S crtsavres.S stdio.c main.c \
66 $(libfdt) libfdt-wrapper.c \ 66 $(libfdt) libfdt-wrapper.c \
67 ns16550.c serial.c simple_alloc.c div64.S util.S \ 67 ns16550.c serial.c simple_alloc.c div64.S util.S \
68 gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \ 68 gunzip_util.c elf_util.c $(zlib) devtree.c stdlib.c \
69 4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \ 69 oflib.c ofconsole.c cuboot.c mpsc.c cpm-serial.c \
70 cpm-serial.c stdlib.c mpc52xx-psc.c planetcore.c uartlite.c \ 70 uartlite.c mpc52xx-psc.c
71 fsl-soc.c mpc8xx.c pq2.c ugecon.c 71src-wlib-$(CONFIG_40x) += 4xx.c planetcore.c
72src-plat := of.c cuboot-52xx.c cuboot-824x.c cuboot-83xx.c cuboot-85xx.c holly.c \ 72src-wlib-$(CONFIG_44x) += 4xx.c ebony.c bamboo.c
73 cuboot-ebony.c cuboot-hotfoot.c epapr.c treeboot-ebony.c \ 73src-wlib-$(CONFIG_8xx) += mpc8xx.c planetcore.c
74 prpmc2800.c \ 74src-wlib-$(CONFIG_PPC_82xx) += pq2.c fsl-soc.c planetcore.c
75 ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c \ 75src-wlib-$(CONFIG_EMBEDDED6xx) += mv64x60.c mv64x60_i2c.c ugecon.c
76 cuboot-pq2.c cuboot-sequoia.c treeboot-walnut.c \ 76
77 cuboot-bamboo.c cuboot-mpc7448hpc2.c cuboot-taishan.c \ 77src-plat-y := of.c
78 fixed-head.S ep88xc.c ep405.c cuboot-c2k.c \ 78src-plat-$(CONFIG_40x) += fixed-head.S ep405.c cuboot-hotfoot.c \
79 cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c \ 79 treeboot-walnut.c cuboot-acadia.c \
80 cuboot-warp.c cuboot-85xx-cpm2.c cuboot-yosemite.c simpleboot.c \ 80 cuboot-kilauea.c simpleboot.c \
81 virtex405-head.S virtex.c redboot-83xx.c cuboot-sam440ep.c \ 81 virtex405-head.S virtex.c
82 cuboot-acadia.c cuboot-amigaone.c cuboot-kilauea.c \ 82src-plat-$(CONFIG_44x) += treeboot-ebony.c cuboot-ebony.c treeboot-bamboo.c \
83 gamecube-head.S gamecube.c wii-head.S wii.c treeboot-iss4xx.c \ 83 cuboot-bamboo.c cuboot-sam440ep.c \
84 treeboot-currituck.c 84 cuboot-sequoia.c cuboot-rainier.c \
85 cuboot-taishan.c cuboot-katmai.c \
86 cuboot-warp.c cuboot-yosemite.c \
87 treeboot-iss4xx.c treeboot-currituck.c \
88 simpleboot.c fixed-head.S virtex.c
89src-plat-$(CONFIG_8xx) += cuboot-8xx.c fixed-head.S ep88xc.c redboot-8xx.c
90src-plat-$(CONFIG_PPC_MPC52xx) += cuboot-52xx.c
91src-plat-$(CONFIG_PPC_82xx) += cuboot-pq2.c fixed-head.S ep8248e.c cuboot-824x.c
92src-plat-$(CONFIG_PPC_83xx) += cuboot-83xx.c fixed-head.S redboot-83xx.c
93src-plat-$(CONFIG_FSL_SOC_BOOKE) += cuboot-85xx.c cuboot-85xx-cpm2.c
94src-plat-$(CONFIG_EMBEDDED6xx) += cuboot-pq2.c cuboot-mpc7448hpc2.c \
95 cuboot-c2k.c gamecube-head.S \
96 gamecube.c wii-head.S wii.c holly.c \
97 prpmc2800.c
98src-plat-$(CONFIG_AMIGAONE) += cuboot-amigaone.c
99src-plat-$(CONFIG_PPC_PS3) += ps3-head.S ps3-hvcall.S ps3.c
100src-plat-$(CONFIG_EPAPR_BOOT) += epapr.c
101
102src-wlib := $(sort $(src-wlib-y))
103src-plat := $(sort $(src-plat-y))
85src-boot := $(src-wlib) $(src-plat) empty.c 104src-boot := $(src-wlib) $(src-plat) empty.c
86 105
87src-boot := $(addprefix $(obj)/, $(src-boot)) 106src-boot := $(addprefix $(obj)/, $(src-boot))
@@ -257,7 +276,6 @@ image-$(CONFIG_TQM8548) += cuImage.tqm8548
257image-$(CONFIG_TQM8555) += cuImage.tqm8555 276image-$(CONFIG_TQM8555) += cuImage.tqm8555
258image-$(CONFIG_TQM8560) += cuImage.tqm8560 277image-$(CONFIG_TQM8560) += cuImage.tqm8560
259image-$(CONFIG_SBC8548) += cuImage.sbc8548 278image-$(CONFIG_SBC8548) += cuImage.sbc8548
260image-$(CONFIG_SBC8560) += cuImage.sbc8560
261image-$(CONFIG_KSI8560) += cuImage.ksi8560 279image-$(CONFIG_KSI8560) += cuImage.ksi8560
262 280
263# Board ports in arch/powerpc/platform/embedded6xx/Kconfig 281# Board ports in arch/powerpc/platform/embedded6xx/Kconfig
@@ -412,4 +430,3 @@ $(wrapper-installed): $(DESTDIR)$(WRAPPER_BINDIR) $(srctree)/$(obj)/wrapper | $(
412 $(call cmd,install_wrapper) 430 $(call cmd,install_wrapper)
413 431
414$(obj)/bootwrapper_install: $(all-installed) 432$(obj)/bootwrapper_install: $(all-installed)
415
diff --git a/arch/powerpc/boot/dts/bsc9131rdb.dts b/arch/powerpc/boot/dts/bsc9131rdb.dts
new file mode 100644
index 00000000000..e13d2d4877b
--- /dev/null
+++ b/arch/powerpc/boot/dts/bsc9131rdb.dts
@@ -0,0 +1,34 @@
1/*
2 * BSC9131 RDB Device Tree Source
3 *
4 * Copyright 2011-2012 Freescale Semiconductor Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12/include/ "fsl/bsc9131si-pre.dtsi"
13
14/ {
15 model = "fsl,bsc9131rdb";
16 compatible = "fsl,bsc9131rdb";
17
18 memory {
19 device_type = "memory";
20 };
21
22 board_ifc: ifc: ifc@ff71e000 {
23 /* NAND Flash on board */
24 ranges = <0x0 0x0 0x0 0xff800000 0x00004000>;
25 reg = <0x0 0xff71e000 0x0 0x2000>;
26 };
27
28 board_soc: soc: soc@ff700000 {
29 ranges = <0x0 0x0 0xff700000 0x100000>;
30 };
31};
32
33/include/ "bsc9131rdb.dtsi"
34/include/ "fsl/bsc9131si-post.dtsi"
diff --git a/arch/powerpc/boot/dts/bsc9131rdb.dtsi b/arch/powerpc/boot/dts/bsc9131rdb.dtsi
new file mode 100644
index 00000000000..638adda2c21
--- /dev/null
+++ b/arch/powerpc/boot/dts/bsc9131rdb.dtsi
@@ -0,0 +1,142 @@
1/*
2 * BSC9131 RDB Device Tree Source stub (no addresses or top-level ranges)
3 *
4 * Copyright 2011-2012 Freescale Semiconductor Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Freescale Semiconductor nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 *
18 * ALTERNATIVELY, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") as published by the Free Software
20 * Foundation, either version 2 of that License or (at your option) any
21 * later version.
22 *
23 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35&board_ifc {
36
37 nand@0,0 {
38 #address-cells = <1>;
39 #size-cells = <1>;
40 compatible = "fsl,ifc-nand";
41 reg = <0x0 0x0 0x4000>;
42
43 partition@0 {
44 /* This location must not be altered */
45 /* 3MB for u-boot Bootloader Image */
46 reg = <0x0 0x00300000>;
47 label = "NAND U-Boot Image";
48 read-only;
49 };
50
51 partition@300000 {
52 /* 1MB for DTB Image */
53 reg = <0x00300000 0x00100000>;
54 label = "NAND DTB Image";
55 };
56
57 partition@400000 {
58 /* 8MB for Linux Kernel Image */
59 reg = <0x00400000 0x00800000>;
60 label = "NAND Linux Kernel Image";
61 };
62
63 partition@c00000 {
64 /* Rest space for Root file System Image */
65 reg = <0x00c00000 0x07400000>;
66 label = "NAND RFS Image";
67 };
68 };
69};
70
71&board_soc {
72 /* BSC9131RDB does not have any device on i2c@3100 */
73 i2c@3100 {
74 status = "disabled";
75 };
76
77 spi@7000 {
78 flash@0 {
79 #address-cells = <1>;
80 #size-cells = <1>;
81 compatible = "spansion,s25sl12801";
82 reg = <0>;
83 spi-max-frequency = <50000000>;
84
85 /* 512KB for u-boot Bootloader Image */
86 partition@0 {
87 reg = <0x0 0x00080000>;
88 label = "SPI Flash U-Boot Image";
89 read-only;
90 };
91
92 /* 512KB for DTB Image */
93 partition@80000 {
94 reg = <0x00080000 0x00080000>;
95 label = "SPI Flash DTB Image";
96 };
97
98 /* 4MB for Linux Kernel Image */
99 partition@100000 {
100 reg = <0x00100000 0x00400000>;
101 label = "SPI Flash Kernel Image";
102 };
103
104 /*11MB for RFS Image */
105 partition@500000 {
106 reg = <0x00500000 0x00B00000>;
107 label = "SPI Flash RFS Image";
108 };
109
110 };
111 };
112
113 usb@22000 {
114 phy_type = "ulpi";
115 };
116
117 mdio@24000 {
118 phy0: ethernet-phy@0 {
119 interrupts = <3 1 0 0>;
120 reg = <0x0>;
121 };
122
123 phy1: ethernet-phy@1 {
124 interrupts = <2 1 0 0>;
125 reg = <0x3>;
126 };
127 };
128
129 sdhci@2e000 {
130 status = "disabled";
131 };
132
133 enet0: ethernet@b0000 {
134 phy-handle = <&phy0>;
135 phy-connection-type = "rgmii-id";
136 };
137
138 enet1: ethernet@b1000 {
139 phy-handle = <&phy1>;
140 phy-connection-type = "rgmii-id";
141 };
142};
diff --git a/arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi b/arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi
new file mode 100644
index 00000000000..5180d9d3798
--- /dev/null
+++ b/arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi
@@ -0,0 +1,193 @@
1/*
2 * BSC9131 Silicon/SoC Device Tree Source (post include)
3 *
4 * Copyright 2011-2012 Freescale Semiconductor Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Freescale Semiconductor nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 *
18 * ALTERNATIVELY, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") as published by the Free Software
20 * Foundation, either version 2 of that License or (at your option) any
21 * later version.
22 *
23 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35&ifc {
36 #address-cells = <2>;
37 #size-cells = <1>;
38 compatible = "fsl,ifc", "simple-bus";
39 interrupts = <16 2 0 0 20 2 0 0>;
40};
41
42&soc {
43 #address-cells = <1>;
44 #size-cells = <1>;
45 device_type = "soc";
46 compatible = "fsl,bsc9131-immr", "simple-bus";
47 bus-frequency = <0>; // Filled out by uboot.
48
49 ecm-law@0 {
50 compatible = "fsl,ecm-law";
51 reg = <0x0 0x1000>;
52 fsl,num-laws = <12>;
53 };
54
55 ecm@1000 {
56 compatible = "fsl,bsc9131-ecm", "fsl,ecm";
57 reg = <0x1000 0x1000>;
58 interrupts = <16 2 0 0>;
59 };
60
61 memory-controller@2000 {
62 compatible = "fsl,bsc9131-memory-controller";
63 reg = <0x2000 0x1000>;
64 interrupts = <16 2 0 0>;
65 };
66
67/include/ "pq3-i2c-0.dtsi"
68 i2c@3000 {
69 interrupts = <17 2 0 0>;
70 };
71
72/include/ "pq3-i2c-1.dtsi"
73 i2c@3100 {
74 interrupts = <17 2 0 0>;
75 };
76
77/include/ "pq3-duart-0.dtsi"
78 serial0: serial@4500 {
79 interrupts = <18 2 0 0>;
80 };
81
82 serial1: serial@4600 {
83 interrupts = <18 2 0 0 >;
84 };
85/include/ "pq3-espi-0.dtsi"
86 spi0: spi@7000 {
87 fsl,espi-num-chipselects = <1>;
88 interrupts = <22 0x2 0 0>;
89 };
90
91/include/ "pq3-gpio-0.dtsi"
92 gpio-controller@f000 {
93 interrupts = <19 0x2 0 0>;
94 };
95
96 L2: l2-cache-controller@20000 {
97 compatible = "fsl,bsc9131-l2-cache-controller";
98 reg = <0x20000 0x1000>;
99 cache-line-size = <32>; // 32 bytes
100 cache-size = <0x40000>; // L2,256K
101 interrupts = <16 2 0 0>;
102 };
103
104/include/ "pq3-dma-0.dtsi"
105
106dma@21300 {
107
108 dma-channel@0 {
109 interrupts = <62 2 0 0>;
110 };
111
112 dma-channel@80 {
113 interrupts = <63 2 0 0>;
114 };
115
116 dma-channel@100 {
117 interrupts = <64 2 0 0>;
118 };
119
120 dma-channel@180 {
121 interrupts = <65 2 0 0>;
122 };
123};
124
125/include/ "pq3-usb2-dr-0.dtsi"
126usb@22000 {
127 compatible = "fsl-usb2-dr","fsl-usb2-dr-v2.2";
128 interrupts = <40 0x2 0 0>;
129};
130
131/include/ "pq3-esdhc-0.dtsi"
132 sdhc@2e000 {
133 fsl,sdhci-auto-cmd12;
134 interrupts = <41 0x2 0 0>;
135 };
136
137/include/ "pq3-sec4.4-0.dtsi"
138crypto@30000 {
139 interrupts = <57 2 0 0>;
140
141 sec_jr0: jr@1000 {
142 interrupts = <58 2 0 0>;
143 };
144
145 sec_jr1: jr@2000 {
146 interrupts = <59 2 0 0>;
147 };
148
149 sec_jr2: jr@3000 {
150 interrupts = <60 2 0 0>;
151 };
152
153 sec_jr3: jr@4000 {
154 interrupts = <61 2 0 0>;
155 };
156};
157
158/include/ "pq3-mpic.dtsi"
159
160timer@41100 {
161 compatible = "fsl,mpic-v1.2-msgr", "fsl,mpic-msg";
162 reg = <0x41400 0x200>;
163 interrupts = <
164 0xb0 2
165 0xb1 2
166 0xb2 2
167 0xb3 2>;
168};
169
170/include/ "pq3-etsec2-0.dtsi"
171enet0: ethernet@b0000 {
172 queue-group@b0000 {
173 fsl,rx-bit-map = <0xff>;
174 fsl,tx-bit-map = <0xff>;
175 interrupts = <26 2 0 0 27 2 0 0 28 2 0 0>;
176 };
177};
178
179/include/ "pq3-etsec2-1.dtsi"
180enet1: ethernet@b1000 {
181 queue-group@b1000 {
182 fsl,rx-bit-map = <0xff>;
183 fsl,tx-bit-map = <0xff>;
184 interrupts = <33 2 0 0 34 2 0 0 35 2 0 0>;
185 };
186};
187
188global-utilities@e0000 {
189 compatible = "fsl,bsc9131-guts";
190 reg = <0xe0000 0x1000>;
191 fsl,has-rstcr;
192 };
193};
diff --git a/arch/powerpc/boot/dts/fsl/p3060si-pre.dtsi b/arch/powerpc/boot/dts/fsl/bsc9131si-pre.dtsi
index 00c8e70e7b9..743e4aeda34 100644
--- a/arch/powerpc/boot/dts/fsl/p3060si-pre.dtsi
+++ b/arch/powerpc/boot/dts/fsl/bsc9131si-pre.dtsi
@@ -1,7 +1,7 @@
1/* 1/*
2 * P3060 Silicon/SoC Device Tree Source (pre include) 2 * BSC9131 Silicon/SoC Device Tree Source (pre include)
3 * 3 *
4 * Copyright 2011 Freescale Semiconductor Inc. 4 * Copyright 2011-2012 Freescale Semiconductor Inc.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met: 7 * modification, are permitted provided that the following conditions are met:
@@ -34,92 +34,26 @@
34 34
35/dts-v1/; 35/dts-v1/;
36/ { 36/ {
37 compatible = "fsl,P3060"; 37 compatible = "fsl,BSC9131";
38 #address-cells = <2>; 38 #address-cells = <2>;
39 #size-cells = <2>; 39 #size-cells = <2>;
40 interrupt-parent = <&mpic>; 40 interrupt-parent = <&mpic>;
41 41
42 aliases { 42 aliases {
43 ccsr = &soc;
44 dcsr = &dcsr;
45
46 serial0 = &serial0; 43 serial0 = &serial0;
47 serial1 = &serial1; 44 ethernet0 = &enet0;
48 serial2 = &serial2; 45 ethernet1 = &enet1;
49 serial3 = &serial3;
50 pci0 = &pci0;
51 pci1 = &pci1;
52 usb0 = &usb0;
53 usb1 = &usb1;
54 dma0 = &dma0;
55 dma1 = &dma1;
56 msi0 = &msi0;
57 msi1 = &msi1;
58 msi2 = &msi2;
59
60 crypto = &crypto;
61 sec_jr0 = &sec_jr0;
62 sec_jr1 = &sec_jr1;
63 sec_jr2 = &sec_jr2;
64 sec_jr3 = &sec_jr3;
65 rtic_a = &rtic_a;
66 rtic_b = &rtic_b;
67 rtic_c = &rtic_c;
68 rtic_d = &rtic_d;
69 sec_mon = &sec_mon;
70 }; 46 };
71 47
72 cpus { 48 cpus {
73 #address-cells = <1>; 49 #address-cells = <1>;
74 #size-cells = <0>; 50 #size-cells = <0>;
75 51
76 cpu0: PowerPC,e500mc@0 { 52 PowerPC,BSC9131@0 {
77 device_type = "cpu";
78 reg = <0>;
79 next-level-cache = <&L2_0>;
80 L2_0: l2-cache {
81 next-level-cache = <&cpc>;
82 };
83 };
84 cpu1: PowerPC,e500mc@1 {
85 device_type = "cpu";
86 reg = <1>;
87 next-level-cache = <&L2_1>;
88 L2_1: l2-cache {
89 next-level-cache = <&cpc>;
90 };
91 };
92 cpu4: PowerPC,e500mc@4 {
93 device_type = "cpu";
94 reg = <4>;
95 next-level-cache = <&L2_4>;
96 L2_4: l2-cache {
97 next-level-cache = <&cpc>;
98 };
99 };
100 cpu5: PowerPC,e500mc@5 {
101 device_type = "cpu";
102 reg = <5>;
103 next-level-cache = <&L2_5>;
104 L2_5: l2-cache {
105 next-level-cache = <&cpc>;
106 };
107 };
108 cpu6: PowerPC,e500mc@6 {
109 device_type = "cpu";
110 reg = <6>;
111 next-level-cache = <&L2_6>;
112 L2_6: l2-cache {
113 next-level-cache = <&cpc>;
114 };
115 };
116 cpu7: PowerPC,e500mc@7 {
117 device_type = "cpu"; 53 device_type = "cpu";
118 reg = <7>; 54 compatible = "fsl,e500v2";
119 next-level-cache = <&L2_7>; 55 reg = <0x0>;
120 L2_7: l2-cache { 56 next-level-cache = <&L2>;
121 next-level-cache = <&cpc>;
122 };
123 }; 57 };
124 }; 58 };
125}; 59};
diff --git a/arch/powerpc/boot/dts/fsl/p1021si-post.dtsi b/arch/powerpc/boot/dts/fsl/p1021si-post.dtsi
index 4252ef85fb7..adb82fd9057 100644
--- a/arch/powerpc/boot/dts/fsl/p1021si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p1021si-post.dtsi
@@ -1,7 +1,7 @@
1/* 1/*
2 * P1021/P1012 Silicon/SoC Device Tree Source (post include) 2 * P1021/P1012 Silicon/SoC Device Tree Source (post include)
3 * 3 *
4 * Copyright 2011 Freescale Semiconductor Inc. 4 * Copyright 2011-2012 Freescale Semiconductor Inc.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met: 7 * modification, are permitted provided that the following conditions are met:
@@ -213,6 +213,20 @@
213 interrupt-parent = <&qeic>; 213 interrupt-parent = <&qeic>;
214 }; 214 };
215 215
216 ucc@2600 {
217 cell-index = <7>;
218 reg = <0x2600 0x200>;
219 interrupts = <42>;
220 interrupt-parent = <&qeic>;
221 };
222
223 ucc@2200 {
224 cell-index = <3>;
225 reg = <0x2200 0x200>;
226 interrupts = <34>;
227 interrupt-parent = <&qeic>;
228 };
229
216 muram@10000 { 230 muram@10000 {
217 #address-cells = <1>; 231 #address-cells = <1>;
218 #size-cells = <1>; 232 #size-cells = <1>;
diff --git a/arch/powerpc/boot/dts/fsl/p3060si-post.dtsi b/arch/powerpc/boot/dts/fsl/p3060si-post.dtsi
deleted file mode 100644
index b3e56929eee..00000000000
--- a/arch/powerpc/boot/dts/fsl/p3060si-post.dtsi
+++ /dev/null
@@ -1,302 +0,0 @@
1/*
2 * P3060 Silicon/SoC Device Tree Source (post include)
3 *
4 * Copyright 2011 Freescale Semiconductor Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Freescale Semiconductor nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 *
18 * ALTERNATIVELY, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") as published by the Free Software
20 * Foundation, either version 2 of that License or (at your option) any
21 * later version.
22 *
23 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35&lbc {
36 compatible = "fsl,p3060-elbc", "fsl,elbc", "simple-bus";
37 interrupts = <25 2 0 0>;
38 #address-cells = <2>;
39 #size-cells = <1>;
40};
41
42/* controller at 0x200000 */
43&pci0 {
44 compatible = "fsl,p3060-pcie", "fsl,qoriq-pcie-v2.2";
45 device_type = "pci";
46 #size-cells = <2>;
47 #address-cells = <3>;
48 bus-range = <0x0 0xff>;
49 clock-frequency = <33333333>;
50 interrupts = <16 2 1 15>;
51 pcie@0 {
52 reg = <0 0 0 0 0>;
53 #interrupt-cells = <1>;
54 #size-cells = <2>;
55 #address-cells = <3>;
56 device_type = "pci";
57 interrupts = <16 2 1 15>;
58 interrupt-map-mask = <0xf800 0 0 7>;
59 interrupt-map = <
60 /* IDSEL 0x0 */
61 0000 0 0 1 &mpic 40 1 0 0
62 0000 0 0 2 &mpic 1 1 0 0
63 0000 0 0 3 &mpic 2 1 0 0
64 0000 0 0 4 &mpic 3 1 0 0
65 >;
66 };
67};
68
69/* controller at 0x201000 */
70&pci1 {
71 compatible = "fsl,p3060-pcie", "fsl,qoriq-pcie-v2.2";
72 device_type = "pci";
73 #size-cells = <2>;
74 #address-cells = <3>;
75 bus-range = <0 0xff>;
76 clock-frequency = <33333333>;
77 interrupts = <16 2 1 14>;
78 pcie@0 {
79 reg = <0 0 0 0 0>;
80 #interrupt-cells = <1>;
81 #size-cells = <2>;
82 #address-cells = <3>;
83 device_type = "pci";
84 interrupts = <16 2 1 14>;
85 interrupt-map-mask = <0xf800 0 0 7>;
86 interrupt-map = <
87 /* IDSEL 0x0 */
88 0000 0 0 1 &mpic 41 1 0 0
89 0000 0 0 2 &mpic 5 1 0 0
90 0000 0 0 3 &mpic 6 1 0 0
91 0000 0 0 4 &mpic 7 1 0 0
92 >;
93 };
94};
95
96&rio {
97 compatible = "fsl,srio";
98 interrupts = <16 2 1 11>;
99 #address-cells = <2>;
100 #size-cells = <2>;
101 fsl,srio-rmu-handle = <&rmu>;
102 ranges;
103
104 port1 {
105 #address-cells = <2>;
106 #size-cells = <2>;
107 cell-index = <1>;
108 };
109
110 port2 {
111 #address-cells = <2>;
112 #size-cells = <2>;
113 cell-index = <2>;
114 };
115};
116
117&dcsr {
118 #address-cells = <1>;
119 #size-cells = <1>;
120 compatible = "fsl,dcsr", "simple-bus";
121
122 dcsr-epu@0 {
123 compatible = "fsl,dcsr-epu";
124 interrupts = <52 2 0 0
125 84 2 0 0
126 85 2 0 0>;
127 reg = <0x0 0x1000>;
128 };
129 dcsr-npc {
130 compatible = "fsl,dcsr-npc";
131 reg = <0x1000 0x1000 0x1000000 0x8000>;
132 };
133 dcsr-nxc@2000 {
134 compatible = "fsl,dcsr-nxc";
135 reg = <0x2000 0x1000>;
136 };
137 dcsr-corenet {
138 compatible = "fsl,dcsr-corenet";
139 reg = <0x8000 0x1000 0xB0000 0x1000>;
140 };
141 dcsr-dpaa@9000 {
142 compatible = "fsl,p3060-dcsr-dpaa", "fsl,dcsr-dpaa";
143 reg = <0x9000 0x1000>;
144 };
145 dcsr-ocn@11000 {
146 compatible = "fsl,p3060-dcsr-ocn", "fsl,dcsr-ocn";
147 reg = <0x11000 0x1000>;
148 };
149 dcsr-ddr@12000 {
150 compatible = "fsl,dcsr-ddr";
151 dev-handle = <&ddr1>;
152 reg = <0x12000 0x1000>;
153 };
154 dcsr-nal@18000 {
155 compatible = "fsl,p3060-dcsr-nal", "fsl,dcsr-nal";
156 reg = <0x18000 0x1000>;
157 };
158 dcsr-rcpm@22000 {
159 compatible = "fsl,p3060-dcsr-rcpm", "fsl,dcsr-rcpm";
160 reg = <0x22000 0x1000>;
161 };
162 dcsr-cpu-sb-proxy@40000 {
163 compatible = "fsl,dcsr-e500mc-sb-proxy", "fsl,dcsr-cpu-sb-proxy";
164 cpu-handle = <&cpu0>;
165 reg = <0x40000 0x1000>;
166 };
167 dcsr-cpu-sb-proxy@41000 {
168 compatible = "fsl,dcsr-e500mc-sb-proxy", "fsl,dcsr-cpu-sb-proxy";
169 cpu-handle = <&cpu1>;
170 reg = <0x41000 0x1000>;
171 };
172 dcsr-cpu-sb-proxy@44000 {
173 compatible = "fsl,dcsr-e500mc-sb-proxy", "fsl,dcsr-cpu-sb-proxy";
174 cpu-handle = <&cpu4>;
175 reg = <0x44000 0x1000>;
176 };
177 dcsr-cpu-sb-proxy@45000 {
178 compatible = "fsl,dcsr-e500mc-sb-proxy", "fsl,dcsr-cpu-sb-proxy";
179 cpu-handle = <&cpu5>;
180 reg = <0x45000 0x1000>;
181 };
182 dcsr-cpu-sb-proxy@46000 {
183 compatible = "fsl,dcsr-e500mc-sb-proxy", "fsl,dcsr-cpu-sb-proxy";
184 cpu-handle = <&cpu6>;
185 reg = <0x46000 0x1000>;
186 };
187 dcsr-cpu-sb-proxy@47000 {
188 compatible = "fsl,dcsr-e500mc-sb-proxy", "fsl,dcsr-cpu-sb-proxy";
189 cpu-handle = <&cpu7>;
190 reg = <0x47000 0x1000>;
191 };
192
193};
194
195&soc {
196 #address-cells = <1>;
197 #size-cells = <1>;
198 device_type = "soc";
199 compatible = "simple-bus";
200
201 soc-sram-error {
202 compatible = "fsl,soc-sram-error";
203 interrupts = <16 2 1 29>;
204 };
205
206 corenet-law@0 {
207 compatible = "fsl,corenet-law";
208 reg = <0x0 0x1000>;
209 fsl,num-laws = <32>;
210 };
211
212 ddr1: memory-controller@8000 {
213 compatible = "fsl,qoriq-memory-controller-v4.4", "fsl,qoriq-memory-controller";
214 reg = <0x8000 0x1000>;
215 interrupts = <16 2 1 23>;
216 };
217
218 cpc: l3-cache-controller@10000 {
219 compatible = "fsl,p3060-l3-cache-controller", "cache";
220 reg = <0x10000 0x1000
221 0x11000 0x1000>;
222 interrupts = <16 2 1 27
223 16 2 1 26>;
224 };
225
226 corenet-cf@18000 {
227 compatible = "fsl,corenet-cf";
228 reg = <0x18000 0x1000>;
229 interrupts = <16 2 1 31>;
230 fsl,ccf-num-csdids = <32>;
231 fsl,ccf-num-snoopids = <32>;
232 };
233
234 iommu@20000 {
235 compatible = "fsl,pamu-v1.0", "fsl,pamu";
236 reg = <0x20000 0x5000>;
237 interrupts = <
238 24 2 0 0
239 16 2 1 30>;
240 };
241
242/include/ "qoriq-rmu-0.dtsi"
243/include/ "qoriq-mpic.dtsi"
244
245 guts: global-utilities@e0000 {
246 compatible = "fsl,qoriq-device-config-1.0";
247 reg = <0xe0000 0xe00>;
248 fsl,has-rstcr;
249 #sleep-cells = <1>;
250 fsl,liodn-bits = <12>;
251 };
252
253 pins: global-utilities@e0e00 {
254 compatible = "fsl,qoriq-pin-control-1.0";
255 reg = <0xe0e00 0x200>;
256 #sleep-cells = <2>;
257 };
258
259 clockgen: global-utilities@e1000 {
260 compatible = "fsl,p3060-clockgen", "fsl,qoriq-clockgen-1.0";
261 reg = <0xe1000 0x1000>;
262 clock-frequency = <0>;
263 };
264
265 rcpm: global-utilities@e2000 {
266 compatible = "fsl,qoriq-rcpm-1.0";
267 reg = <0xe2000 0x1000>;
268 #sleep-cells = <1>;
269 };
270
271 sfp: sfp@e8000 {
272 compatible = "fsl,p3060-sfp", "fsl,qoriq-sfp-1.0";
273 reg = <0xe8000 0x1000>;
274 };
275
276 serdes: serdes@ea000 {
277 compatible = "fsl,p3060-serdes";
278 reg = <0xea000 0x1000>;
279 };
280
281/include/ "qoriq-dma-0.dtsi"
282/include/ "qoriq-dma-1.dtsi"
283/include/ "qoriq-espi-0.dtsi"
284 spi@110000 {
285 fsl,espi-num-chipselects = <4>;
286 };
287
288/include/ "qoriq-i2c-0.dtsi"
289/include/ "qoriq-i2c-1.dtsi"
290/include/ "qoriq-duart-0.dtsi"
291/include/ "qoriq-duart-1.dtsi"
292/include/ "qoriq-gpio-0.dtsi"
293/include/ "qoriq-usb2-mph-0.dtsi"
294 usb@210000 {
295 compatible = "fsl-usb2-mph-v2.2", "fsl,mpc85xx-usb2-mph", "fsl-usb2-mph";
296 };
297/include/ "qoriq-usb2-dr-0.dtsi"
298 usb@211000 {
299 compatible = "fsl-usb2-dr-v2.2", "fsl,mpc85xx-usb2-dr", "fsl-usb2-dr";
300 };
301/include/ "qoriq-sec4.1-0.dtsi"
302};
diff --git a/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi b/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi
index 8d35d2c1f69..4f9c9f682ec 100644
--- a/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi
@@ -345,6 +345,13 @@
345/include/ "qoriq-duart-1.dtsi" 345/include/ "qoriq-duart-1.dtsi"
346/include/ "qoriq-gpio-0.dtsi" 346/include/ "qoriq-gpio-0.dtsi"
347/include/ "qoriq-usb2-mph-0.dtsi" 347/include/ "qoriq-usb2-mph-0.dtsi"
348 usb@210000 {
349 compatible = "fsl-usb2-mph-v1.6", "fsl,mpc85xx-usb2-mph", "fsl-usb2-mph";
350 port0;
351 };
348/include/ "qoriq-usb2-dr-0.dtsi" 352/include/ "qoriq-usb2-dr-0.dtsi"
353 usb@211000 {
354 compatible = "fsl-usb2-dr-v1.6", "fsl,mpc85xx-usb2-dr", "fsl-usb2-dr";
355 };
349/include/ "qoriq-sec4.0-0.dtsi" 356/include/ "qoriq-sec4.0-0.dtsi"
350}; 357};
diff --git a/arch/powerpc/boot/dts/mgcoge.dts b/arch/powerpc/boot/dts/mgcoge.dts
index ededaf5ac01..d72fb5e219d 100644
--- a/arch/powerpc/boot/dts/mgcoge.dts
+++ b/arch/powerpc/boot/dts/mgcoge.dts
@@ -222,6 +222,29 @@
222 interrupt-parent = <&PIC>; 222 interrupt-parent = <&PIC>;
223 usb-clock = <5>; 223 usb-clock = <5>;
224 }; 224 };
225 spi@11aa0 {
226 cell-index = <0>;
227 compatible = "fsl,spi", "fsl,cpm2-spi";
228 reg = <0x11a80 0x40 0x89fc 0x2>;
229 interrupts = <2 8>;
230 interrupt-parent = <&PIC>;
231 gpios = < &cpm2_pio_d 19 0>;
232 #address-cells = <1>;
233 #size-cells = <0>;
234 ds3106@1 {
235 compatible = "gen,spidev";
236 reg = <0>;
237 spi-max-frequency = <8000000>;
238 };
239 };
240
241 };
242
243 cpm2_pio_d: gpio-controller@10d60 {
244 #gpio-cells = <2>;
245 compatible = "fsl,cpm2-pario-bank";
246 reg = <0x10d60 0x14>;
247 gpio-controller;
225 }; 248 };
226 249
227 cpm2_pio_c: gpio-controller@10d40 { 250 cpm2_pio_c: gpio-controller@10d40 {
diff --git a/arch/powerpc/boot/dts/mpc8536ds.dtsi b/arch/powerpc/boot/dts/mpc8536ds.dtsi
index cc46dbd9746..d304a2d68c6 100644
--- a/arch/powerpc/boot/dts/mpc8536ds.dtsi
+++ b/arch/powerpc/boot/dts/mpc8536ds.dtsi
@@ -203,6 +203,14 @@
203 reg = <1>; 203 reg = <1>;
204 device_type = "ethernet-phy"; 204 device_type = "ethernet-phy";
205 }; 205 };
206 sgmii_phy0: sgmii-phy@0 {
207 interrupts = <6 1 0 0>;
208 reg = <0x1d>;
209 };
210 sgmii_phy1: sgmii-phy@1 {
211 interrupts = <6 1 0 0>;
212 reg = <0x1c>;
213 };
206 tbi0: tbi-phy@11 { 214 tbi0: tbi-phy@11 {
207 reg = <0x11>; 215 reg = <0x11>;
208 device_type = "tbi-phy"; 216 device_type = "tbi-phy";
diff --git a/arch/powerpc/boot/dts/mpc8544ds.dtsi b/arch/powerpc/boot/dts/mpc8544ds.dtsi
index 270f64b90f4..77ebc9f1d37 100644
--- a/arch/powerpc/boot/dts/mpc8544ds.dtsi
+++ b/arch/powerpc/boot/dts/mpc8544ds.dtsi
@@ -51,6 +51,15 @@
51 device_type = "ethernet-phy"; 51 device_type = "ethernet-phy";
52 }; 52 };
53 53
54 sgmii_phy0: sgmii-phy@0 {
55 interrupts = <6 1 0 0>;
56 reg = <0x1c>;
57 };
58 sgmii_phy1: sgmii-phy@1 {
59 interrupts = <6 1 0 0>;
60 reg = <0x1d>;
61 };
62
54 tbi0: tbi-phy@11 { 63 tbi0: tbi-phy@11 {
55 reg = <0x11>; 64 reg = <0x11>;
56 device_type = "tbi-phy"; 65 device_type = "tbi-phy";
diff --git a/arch/powerpc/boot/dts/mpc8572ds.dtsi b/arch/powerpc/boot/dts/mpc8572ds.dtsi
index 14178944e22..357490bb84d 100644
--- a/arch/powerpc/boot/dts/mpc8572ds.dtsi
+++ b/arch/powerpc/boot/dts/mpc8572ds.dtsi
@@ -169,6 +169,23 @@
169 reg = <0x3>; 169 reg = <0x3>;
170 }; 170 };
171 171
172 sgmii_phy0: sgmii-phy@0 {
173 interrupts = <6 1 0 0>;
174 reg = <0x1c>;
175 };
176 sgmii_phy1: sgmii-phy@1 {
177 interrupts = <6 1 0 0>;
178 reg = <0x1d>;
179 };
180 sgmii_phy2: sgmii-phy@2 {
181 interrupts = <7 1 0 0>;
182 reg = <0x1e>;
183 };
184 sgmii_phy3: sgmii-phy@3 {
185 interrupts = <7 1 0 0>;
186 reg = <0x1f>;
187 };
188
172 tbi0: tbi-phy@11 { 189 tbi0: tbi-phy@11 {
173 reg = <0x11>; 190 reg = <0x11>;
174 device_type = "tbi-phy"; 191 device_type = "tbi-phy";
diff --git a/arch/powerpc/boot/dts/mpc8572ds_camp_core0.dts b/arch/powerpc/boot/dts/mpc8572ds_camp_core0.dts
index d34d1271212..ef9ef56b3ee 100644
--- a/arch/powerpc/boot/dts/mpc8572ds_camp_core0.dts
+++ b/arch/powerpc/boot/dts/mpc8572ds_camp_core0.dts
@@ -67,10 +67,10 @@
67 msi@41600 { 67 msi@41600 {
68 msi-available-ranges = <0 0x80>; 68 msi-available-ranges = <0 0x80>;
69 interrupts = < 69 interrupts = <
70 0xe0 0 70 0xe0 0 0 0
71 0xe1 0 71 0xe1 0 0 0
72 0xe2 0 72 0xe2 0 0 0
73 0xe3 0>; 73 0xe3 0 0 0>;
74 }; 74 };
75 timer@42100 { 75 timer@42100 {
76 status = "disabled"; 76 status = "disabled";
diff --git a/arch/powerpc/boot/dts/mpc8572ds_camp_core1.dts b/arch/powerpc/boot/dts/mpc8572ds_camp_core1.dts
index d6a8fafc0d0..24564ee108e 100644
--- a/arch/powerpc/boot/dts/mpc8572ds_camp_core1.dts
+++ b/arch/powerpc/boot/dts/mpc8572ds_camp_core1.dts
@@ -67,9 +67,6 @@
67 ethernet@24000 { 67 ethernet@24000 {
68 status = "disabled"; 68 status = "disabled";
69 }; 69 };
70 mdio@24520 {
71 status = "disabled";
72 };
73 ptp_clock@24e00 { 70 ptp_clock@24e00 {
74 status = "disabled"; 71 status = "disabled";
75 }; 72 };
@@ -100,10 +97,10 @@
100 msi@41600 { 97 msi@41600 {
101 msi-available-ranges = <0x80 0x80>; 98 msi-available-ranges = <0x80 0x80>;
102 interrupts = < 99 interrupts = <
103 0xe4 0 100 0xe4 0 0 0
104 0xe5 0 101 0xe5 0 0 0
105 0xe6 0 102 0xe6 0 0 0
106 0xe7 0>; 103 0xe7 0 0 0>;
107 }; 104 };
108 global-utilities@e0000 { 105 global-utilities@e0000 {
109 status = "disabled"; 106 status = "disabled";
diff --git a/arch/powerpc/boot/dts/p1010rdb.dtsi b/arch/powerpc/boot/dts/p1010rdb.dtsi
index 49776143a1b..ec7c27a6467 100644
--- a/arch/powerpc/boot/dts/p1010rdb.dtsi
+++ b/arch/powerpc/boot/dts/p1010rdb.dtsi
@@ -126,12 +126,24 @@
126 126
127&board_soc { 127&board_soc {
128 i2c@3000 { 128 i2c@3000 {
129 eeprom@50 {
130 compatible = "st,24c256";
131 reg = <0x50>;
132 };
133
129 rtc@68 { 134 rtc@68 {
130 compatible = "pericom,pt7c4338"; 135 compatible = "pericom,pt7c4338";
131 reg = <0x68>; 136 reg = <0x68>;
132 }; 137 };
133 }; 138 };
134 139
140 i2c@3100 {
141 eeprom@52 {
142 compatible = "atmel,24c01";
143 reg = <0x52>;
144 };
145 };
146
135 spi@7000 { 147 spi@7000 {
136 flash@0 { 148 flash@0 {
137 #address-cells = <1>; 149 #address-cells = <1>;
diff --git a/arch/powerpc/boot/dts/p1021rdb.dtsi b/arch/powerpc/boot/dts/p1021rdb-pc.dtsi
index b973461ab75..c13abfbbe2e 100644
--- a/arch/powerpc/boot/dts/p1021rdb.dtsi
+++ b/arch/powerpc/boot/dts/p1021rdb-pc.dtsi
@@ -1,7 +1,7 @@
1/* 1/*
2 * P1021 RDB Device Tree Source stub (no addresses or top-level ranges) 2 * P1021 RDB Device Tree Source stub (no addresses or top-level ranges)
3 * 3 *
4 * Copyright 2011 Freescale Semiconductor Inc. 4 * Copyright 2012 Freescale Semiconductor Inc.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met: 7 * modification, are permitted provided that the following conditions are met:
diff --git a/arch/powerpc/boot/dts/p1021rdb.dts b/arch/powerpc/boot/dts/p1021rdb-pc_32b.dts
index 90b6b4caa27..7cefa12b629 100644
--- a/arch/powerpc/boot/dts/p1021rdb.dts
+++ b/arch/powerpc/boot/dts/p1021rdb-pc_32b.dts
@@ -1,7 +1,7 @@
1/* 1/*
2 * P1021 RDB Device Tree Source 2 * P1021 RDB Device Tree Source
3 * 3 *
4 * Copyright 2011 Freescale Semiconductor Inc. 4 * Copyright 2012 Freescale Semiconductor Inc.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met: 7 * modification, are permitted provided that the following conditions are met:
@@ -92,5 +92,5 @@
92 }; 92 };
93}; 93};
94 94
95/include/ "p1021rdb.dtsi" 95/include/ "p1021rdb-pc.dtsi"
96/include/ "fsl/p1021si-post.dtsi" 96/include/ "fsl/p1021si-post.dtsi"
diff --git a/arch/powerpc/boot/dts/p1021rdb_36b.dts b/arch/powerpc/boot/dts/p1021rdb-pc_36b.dts
index ea6d8b5fa10..53d0c889039 100644
--- a/arch/powerpc/boot/dts/p1021rdb_36b.dts
+++ b/arch/powerpc/boot/dts/p1021rdb-pc_36b.dts
@@ -1,7 +1,7 @@
1/* 1/*
2 * P1021 RDB Device Tree Source (36-bit address map) 2 * P1021 RDB Device Tree Source (36-bit address map)
3 * 3 *
4 * Copyright 2011 Freescale Semiconductor Inc. 4 * Copyright 2012 Freescale Semiconductor Inc.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met: 7 * modification, are permitted provided that the following conditions are met:
@@ -92,5 +92,5 @@
92 }; 92 };
93}; 93};
94 94
95/include/ "p1021rdb.dtsi" 95/include/ "p1021rdb-pc.dtsi"
96/include/ "fsl/p1021si-post.dtsi" 96/include/ "fsl/p1021si-post.dtsi"
diff --git a/arch/powerpc/boot/dts/p1022ds.dtsi b/arch/powerpc/boot/dts/p1022ds.dtsi
index 7cdb505036b..c3344b04d8f 100644
--- a/arch/powerpc/boot/dts/p1022ds.dtsi
+++ b/arch/powerpc/boot/dts/p1022ds.dtsi
@@ -33,22 +33,6 @@
33 */ 33 */
34 34
35&board_lbc { 35&board_lbc {
36 /*
37 * This node is used to access the pixis via "indirect" mode,
38 * which is done by writing the pixis register index to chip
39 * select 0 and the value to/from chip select 1. Indirect
40 * mode is the only way to access the pixis when DIU video
41 * is enabled. Note that this assumes that the first column
42 * of the 'ranges' property above is the chip select number.
43 */
44 board-control@0,0 {
45 compatible = "fsl,p1022ds-indirect-pixis";
46 reg = <0x0 0x0 1 /* CS0 */
47 0x1 0x0 1>; /* CS1 */
48 interrupt-parent = <&mpic>;
49 interrupts = <8 0 0 0>;
50 };
51
52 nor@0,0 { 36 nor@0,0 {
53 #address-cells = <1>; 37 #address-cells = <1>;
54 #size-cells = <1>; 38 #size-cells = <1>;
@@ -161,6 +145,10 @@
161 * the clock is enabled. 145 * the clock is enabled.
162 */ 146 */
163 }; 147 };
148 rtc@68 {
149 compatible = "dallas,ds1339";
150 reg = <0x68>;
151 };
164 }; 152 };
165 153
166 spi@7000 { 154 spi@7000 {
diff --git a/arch/powerpc/boot/dts/p1024rdb.dtsi b/arch/powerpc/boot/dts/p1024rdb.dtsi
new file mode 100644
index 00000000000..b05dcb40f80
--- /dev/null
+++ b/arch/powerpc/boot/dts/p1024rdb.dtsi
@@ -0,0 +1,228 @@
1/*
2 * P1024 RDB Device Tree Source stub (no addresses or top-level ranges)
3 *
4 * Copyright 2012 Freescale Semiconductor Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Freescale Semiconductor nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 *
18 * ALTERNATIVELY, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") as published by the Free Software
20 * Foundation, either version 2 of that License or (at your option) any
21 * later version.
22 *
23 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35&lbc {
36 nor@0,0 {
37 #address-cells = <1>;
38 #size-cells = <1>;
39 compatible = "cfi-flash";
40 reg = <0x0 0x0 0x1000000>;
41 bank-width = <2>;
42 device-width = <1>;
43
44 partition@0 {
45 /* This location must not be altered */
46 /* 256KB for Vitesse 7385 Switch firmware */
47 reg = <0x0 0x00040000>;
48 label = "NOR Vitesse-7385 Firmware";
49 read-only;
50 };
51
52 partition@40000 {
53 /* 256KB for DTB Image */
54 reg = <0x00040000 0x00040000>;
55 label = "NOR DTB Image";
56 };
57
58 partition@80000 {
59 /* 3.5 MB for Linux Kernel Image */
60 reg = <0x00080000 0x00380000>;
61 label = "NOR Linux Kernel Image";
62 };
63
64 partition@400000 {
65 /* 11MB for JFFS2 based Root file System */
66 reg = <0x00400000 0x00b00000>;
67 label = "NOR JFFS2 Root File System";
68 };
69
70 partition@f00000 {
71 /* This location must not be altered */
72 /* 512KB for u-boot Bootloader Image */
73 /* 512KB for u-boot Environment Variables */
74 reg = <0x00f00000 0x00100000>;
75 label = "NOR U-Boot Image";
76 read-only;
77 };
78 };
79
80 nand@1,0 {
81 #address-cells = <1>;
82 #size-cells = <1>;
83 compatible = "fsl,p1020-fcm-nand",
84 "fsl,elbc-fcm-nand";
85 reg = <0x1 0x0 0x40000>;
86
87 partition@0 {
88 /* This location must not be altered */
89 /* 1MB for u-boot Bootloader Image */
90 reg = <0x0 0x00100000>;
91 label = "NAND U-Boot Image";
92 read-only;
93 };
94
95 partition@100000 {
96 /* 1MB for DTB Image */
97 reg = <0x00100000 0x00100000>;
98 label = "NAND DTB Image";
99 };
100
101 partition@200000 {
102 /* 4MB for Linux Kernel Image */
103 reg = <0x00200000 0x00400000>;
104 label = "NAND Linux Kernel Image";
105 };
106
107 partition@600000 {
108 /* 4MB for Compressed Root file System Image */
109 reg = <0x00600000 0x00400000>;
110 label = "NAND Compressed RFS Image";
111 };
112
113 partition@a00000 {
114 /* 15MB for JFFS2 based Root file System */
115 reg = <0x00a00000 0x00f00000>;
116 label = "NAND JFFS2 Root File System";
117 };
118
119 partition@1900000 {
120 /* 7MB for User Writable Area */
121 reg = <0x01900000 0x00700000>;
122 label = "NAND Writable User area";
123 };
124 };
125};
126
127&soc {
128 spi@7000 {
129 flash@0 {
130 #address-cells = <1>;
131 #size-cells = <1>;
132 compatible = "spansion,m25p80";
133 reg = <0>;
134 spi-max-frequency = <40000000>;
135
136 partition@0 {
137 /* 512KB for u-boot Bootloader Image */
138 reg = <0x0 0x00080000>;
139 label = "SPI U-Boot Image";
140 read-only;
141 };
142
143 partition@80000 {
144 /* 512KB for DTB Image */
145 reg = <0x00080000 0x00080000>;
146 label = "SPI DTB Image";
147 };
148
149 partition@100000 {
150 /* 4MB for Linux Kernel Image */
151 reg = <0x00100000 0x00400000>;
152 label = "SPI Linux Kernel Image";
153 };
154
155 partition@500000 {
156 /* 4MB for Compressed RFS Image */
157 reg = <0x00500000 0x00400000>;
158 label = "SPI Compressed RFS Image";
159 };
160
161 partition@900000 {
162 /* 7MB for JFFS2 based RFS */
163 reg = <0x00900000 0x00700000>;
164 label = "SPI JFFS2 RFS";
165 };
166 };
167 };
168
169 i2c@3000 {
170 rtc@68 {
171 compatible = "dallas,ds1339";
172 reg = <0x68>;
173 };
174 };
175
176 usb@22000 {
177 phy_type = "ulpi";
178 };
179
180 usb@23000 {
181 status = "disabled";
182 };
183
184 mdio@24000 {
185 phy0: ethernet-phy@0 {
186 interrupts = <3 1 0 0>;
187 reg = <0x0>;
188 };
189 phy1: ethernet-phy@1 {
190 interrupts = <2 1 0 0>;
191 reg = <0x1>;
192 };
193 phy2: ethernet-phy@2 {
194 interrupts = <1 1 0 0>;
195 reg = <0x2>;
196 };
197 };
198
199 mdio@25000 {
200 tbi0: tbi-phy@11 {
201 reg = <0x11>;
202 device_type = "tbi-phy";
203 };
204 };
205
206 mdio@26000 {
207 tbi1: tbi-phy@11 {
208 reg = <0x11>;
209 device_type = "tbi-phy";
210 };
211 };
212
213 ethernet@b0000 {
214 phy-handle = <&phy2>;
215 phy-connection-type = "rgmii-id";
216 };
217
218 ethernet@b1000 {
219 phy-handle = <&phy0>;
220 tbi-handle = <&tbi0>;
221 phy-connection-type = "sgmii";
222 };
223
224 ethernet@b2000 {
225 phy-handle = <&phy1>;
226 phy-connection-type = "rgmii-id";
227 };
228};
diff --git a/arch/powerpc/boot/dts/p1024rdb_32b.dts b/arch/powerpc/boot/dts/p1024rdb_32b.dts
new file mode 100644
index 00000000000..90e803e9ba5
--- /dev/null
+++ b/arch/powerpc/boot/dts/p1024rdb_32b.dts
@@ -0,0 +1,87 @@
1/*
2 * P1024 RDB 32Bit Physical Address Map Device Tree Source
3 *
4 * Copyright 2012 Freescale Semiconductor Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Freescale Semiconductor nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 *
18 * ALTERNATIVELY, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") as published by the Free Software
20 * Foundation, either version 2 of that License or (at your option) any
21 * later version.
22 *
23 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35/include/ "fsl/p1020si-pre.dtsi"
36/ {
37 model = "fsl,P1024RDB";
38 compatible = "fsl,P1024RDB";
39
40 memory {
41 device_type = "memory";
42 };
43
44 lbc: localbus@ffe05000 {
45 reg = <0x0 0xffe05000 0 0x1000>;
46 ranges = <0x0 0x0 0x0 0xef000000 0x01000000
47 0x1 0x0 0x0 0xff800000 0x00040000>;
48 };
49
50 soc: soc@ffe00000 {
51 ranges = <0x0 0x0 0xffe00000 0x100000>;
52 };
53
54 pci0: pcie@ffe09000 {
55 reg = <0x0 0xffe09000 0 0x1000>;
56 ranges = <0x2000000 0x0 0xe0000000 0x0 0xa0000000 0x0 0x20000000
57 0x1000000 0x0 0x00000000 0x0 0xffc10000 0x0 0x10000>;
58 pcie@0 {
59 ranges = <0x2000000 0x0 0xe0000000
60 0x2000000 0x0 0xe0000000
61 0x0 0x20000000
62
63 0x1000000 0x0 0x0
64 0x1000000 0x0 0x0
65 0x0 0x100000>;
66 };
67 };
68
69 pci1: pcie@ffe0a000 {
70 reg = <0x0 0xffe0a000 0 0x1000>;
71 ranges = <0x2000000 0x0 0xe0000000 0x0 0x80000000 0x0 0x20000000
72 0x1000000 0x0 0x00000000 0x0 0xffc00000 0x0 0x10000>;
73 pcie@0 {
74 reg = <0x0 0x0 0x0 0x0 0x0>;
75 ranges = <0x2000000 0x0 0xe0000000
76 0x2000000 0x0 0xe0000000
77 0x0 0x20000000
78
79 0x1000000 0x0 0x0
80 0x1000000 0x0 0x0
81 0x0 0x100000>;
82 };
83 };
84};
85
86/include/ "p1024rdb.dtsi"
87/include/ "fsl/p1020si-post.dtsi"
diff --git a/arch/powerpc/boot/dts/p1024rdb_36b.dts b/arch/powerpc/boot/dts/p1024rdb_36b.dts
new file mode 100644
index 00000000000..3656825b65a
--- /dev/null
+++ b/arch/powerpc/boot/dts/p1024rdb_36b.dts
@@ -0,0 +1,87 @@
1/*
2 * P1024 RDB 36Bit Physical Address Map Device Tree Source
3 *
4 * Copyright 2012 Freescale Semiconductor Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Freescale Semiconductor nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 *
18 * ALTERNATIVELY, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") as published by the Free Software
20 * Foundation, either version 2 of that License or (at your option) any
21 * later version.
22 *
23 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35/include/ "fsl/p1020si-pre.dtsi"
36/ {
37 model = "fsl,P1024RDB";
38 compatible = "fsl,P1024RDB";
39
40 memory {
41 device_type = "memory";
42 };
43
44 lbc: localbus@fffe05000 {
45 reg = <0xf 0xffe05000 0 0x1000>;
46 ranges = <0x0 0x0 0xf 0xef000000 0x01000000
47 0x1 0x0 0xf 0xff800000 0x00040000>;
48 };
49
50 soc: soc@fffe00000 {
51 ranges = <0x0 0xf 0xffe00000 0x100000>;
52 };
53
54 pci0: pcie@fffe09000 {
55 reg = <0xf 0xffe09000 0 0x1000>;
56 ranges = <0x2000000 0x0 0xe0000000 0xc 0x20000000 0x0 0x20000000
57 0x1000000 0x0 0x00000000 0xf 0xffc10000 0x0 0x10000>;
58 pcie@0 {
59 ranges = <0x2000000 0x0 0xe0000000
60 0x2000000 0x0 0xe0000000
61 0x0 0x20000000
62
63 0x1000000 0x0 0x0
64 0x1000000 0x0 0x0
65 0x0 0x100000>;
66 };
67 };
68
69 pci1: pcie@fffe0a000 {
70 reg = <0xf 0xffe0a000 0 0x1000>;
71 ranges = <0x2000000 0x0 0xe0000000 0xc 0x00000000 0x0 0x20000000
72 0x1000000 0x0 0x00000000 0xf 0xffc00000 0x0 0x10000>;
73 pcie@0 {
74 reg = <0x0 0x0 0x0 0x0 0x0>;
75 ranges = <0x2000000 0x0 0xe0000000
76 0x2000000 0x0 0xe0000000
77 0x0 0x20000000
78
79 0x1000000 0x0 0x0
80 0x1000000 0x0 0x0
81 0x0 0x100000>;
82 };
83 };
84};
85
86/include/ "p1024rdb.dtsi"
87/include/ "fsl/p1020si-post.dtsi"
diff --git a/arch/powerpc/boot/dts/p1025rdb.dtsi b/arch/powerpc/boot/dts/p1025rdb.dtsi
index cf3676fc714..f5025648229 100644
--- a/arch/powerpc/boot/dts/p1025rdb.dtsi
+++ b/arch/powerpc/boot/dts/p1025rdb.dtsi
@@ -282,5 +282,45 @@
282 0x1 0x4 0x2 0x0 0x2 0x0 /* ENET5_RX_DV_SER5_CTS_B */ 282 0x1 0x4 0x2 0x0 0x2 0x0 /* ENET5_RX_DV_SER5_CTS_B */
283 0x1 0x8 0x2 0x0 0x2 0x0>; /* ENET5_RX_ER_SER5_CD_B */ 283 0x1 0x8 0x2 0x0 0x2 0x0>; /* ENET5_RX_ER_SER5_CD_B */
284 }; 284 };
285
286 pio3: ucc_pin@03 {
287 pio-map = <
288 /* port pin dir open_drain assignment has_irq */
289 0x0 0x16 0x2 0x0 0x2 0x0 /* SER7_CD_B*/
290 0x0 0x12 0x2 0x0 0x2 0x0 /* SER7_CTS_B*/
291 0x0 0x13 0x1 0x0 0x2 0x0 /* SER7_RTS_B*/
292 0x0 0x14 0x2 0x0 0x2 0x0 /* SER7_RXD0*/
293 0x0 0x15 0x1 0x0 0x2 0x0>; /* SER7_TXD0*/
294 };
295
296 pio4: ucc_pin@04 {
297 pio-map = <
298 /* port pin dir open_drain assignment has_irq */
299 0x1 0x0 0x2 0x0 0x2 0x0 /* SER3_CD_B*/
300 0x0 0x1c 0x2 0x0 0x2 0x0 /* SER3_CTS_B*/
301 0x0 0x1d 0x1 0x0 0x2 0x0 /* SER3_RTS_B*/
302 0x0 0x1e 0x2 0x0 0x2 0x0 /* SER3_RXD0*/
303 0x0 0x1f 0x1 0x0 0x2 0x0>; /* SER3_TXD0*/
304 };
305 };
306};
307
308&qe {
309 serial2: ucc@2600 {
310 device_type = "serial";
311 compatible = "ucc_uart";
312 port-number = <0>;
313 rx-clock-name = "brg6";
314 tx-clock-name = "brg6";
315 pio-handle = <&pio3>;
316 };
317
318 serial3: ucc@2200 {
319 device_type = "serial";
320 compatible = "ucc_uart";
321 port-number = <1>;
322 rx-clock-name = "brg2";
323 tx-clock-name = "brg2";
324 pio-handle = <&pio4>;
285 }; 325 };
286}; 326};
diff --git a/arch/powerpc/boot/dts/p2020ds.dtsi b/arch/powerpc/boot/dts/p2020ds.dtsi
index d3b939c573b..e699cf95b06 100644
--- a/arch/powerpc/boot/dts/p2020ds.dtsi
+++ b/arch/powerpc/boot/dts/p2020ds.dtsi
@@ -150,6 +150,16 @@
150 interrupts = <3 1 0 0>; 150 interrupts = <3 1 0 0>;
151 reg = <0x2>; 151 reg = <0x2>;
152 }; 152 };
153
154 sgmii_phy1: sgmii-phy@1 {
155 interrupts = <5 1 0 0>;
156 reg = <0x1c>;
157 };
158 sgmii_phy2: sgmii-phy@2 {
159 interrupts = <5 1 0 0>;
160 reg = <0x1d>;
161 };
162
153 tbi0: tbi-phy@11 { 163 tbi0: tbi-phy@11 {
154 reg = <0x11>; 164 reg = <0x11>;
155 device_type = "tbi-phy"; 165 device_type = "tbi-phy";
diff --git a/arch/powerpc/boot/dts/p2020rdb-pc_32b.dts b/arch/powerpc/boot/dts/p2020rdb-pc_32b.dts
index 852e5b27485..57573bd52ca 100644
--- a/arch/powerpc/boot/dts/p2020rdb-pc_32b.dts
+++ b/arch/powerpc/boot/dts/p2020rdb-pc_32b.dts
@@ -56,7 +56,7 @@
56 ranges = <0x0 0x0 0xffe00000 0x100000>; 56 ranges = <0x0 0x0 0xffe00000 0x100000>;
57 }; 57 };
58 58
59 pci0: pcie@ffe08000 { 59 pci2: pcie@ffe08000 {
60 reg = <0 0xffe08000 0 0x1000>; 60 reg = <0 0xffe08000 0 0x1000>;
61 status = "disabled"; 61 status = "disabled";
62 }; 62 };
@@ -76,7 +76,7 @@
76 }; 76 };
77 }; 77 };
78 78
79 pci2: pcie@ffe0a000 { 79 pci0: pcie@ffe0a000 {
80 reg = <0 0xffe0a000 0 0x1000>; 80 reg = <0 0xffe0a000 0 0x1000>;
81 ranges = <0x2000000 0x0 0xe0000000 0 0x80000000 0x0 0x20000000 81 ranges = <0x2000000 0x0 0xe0000000 0 0x80000000 0x0 0x20000000
82 0x1000000 0x0 0x00000000 0 0xffc00000 0x0 0x10000>; 82 0x1000000 0x0 0x00000000 0 0xffc00000 0x0 0x10000>;
diff --git a/arch/powerpc/boot/dts/p2020rdb-pc_36b.dts b/arch/powerpc/boot/dts/p2020rdb-pc_36b.dts
index b5a56ca51cf..470247ea68b 100644
--- a/arch/powerpc/boot/dts/p2020rdb-pc_36b.dts
+++ b/arch/powerpc/boot/dts/p2020rdb-pc_36b.dts
@@ -56,7 +56,7 @@
56 ranges = <0x0 0xf 0xffe00000 0x100000>; 56 ranges = <0x0 0xf 0xffe00000 0x100000>;
57 }; 57 };
58 58
59 pci0: pcie@fffe08000 { 59 pci2: pcie@fffe08000 {
60 reg = <0xf 0xffe08000 0 0x1000>; 60 reg = <0xf 0xffe08000 0 0x1000>;
61 status = "disabled"; 61 status = "disabled";
62 }; 62 };
@@ -76,7 +76,7 @@
76 }; 76 };
77 }; 77 };
78 78
79 pci2: pcie@fffe0a000 { 79 pci0: pcie@fffe0a000 {
80 reg = <0xf 0xffe0a000 0 0x1000>; 80 reg = <0xf 0xffe0a000 0 0x1000>;
81 ranges = <0x2000000 0x0 0xe0000000 0xc 0x00000000 0x0 0x20000000 81 ranges = <0x2000000 0x0 0xe0000000 0xc 0x00000000 0x0 0x20000000
82 0x1000000 0x0 0x00000000 0xf 0xffc00000 0x0 0x10000>; 82 0x1000000 0x0 0x00000000 0xf 0xffc00000 0x0 0x10000>;
diff --git a/arch/powerpc/boot/dts/p2020rdb.dts b/arch/powerpc/boot/dts/p2020rdb.dts
index 153bc76bb48..4d52bce1d5b 100644
--- a/arch/powerpc/boot/dts/p2020rdb.dts
+++ b/arch/powerpc/boot/dts/p2020rdb.dts
@@ -34,7 +34,7 @@
34 34
35 /* NOR and NAND Flashes */ 35 /* NOR and NAND Flashes */
36 ranges = <0x0 0x0 0x0 0xef000000 0x01000000 36 ranges = <0x0 0x0 0x0 0xef000000 0x01000000
37 0x1 0x0 0x0 0xff800000 0x00040000 37 0x1 0x0 0x0 0xffa00000 0x00040000
38 0x2 0x0 0x0 0xffb00000 0x00020000>; 38 0x2 0x0 0x0 0xffb00000 0x00020000>;
39 39
40 nor@0,0 { 40 nor@0,0 {
diff --git a/arch/powerpc/boot/dts/p2041rdb.dts b/arch/powerpc/boot/dts/p2041rdb.dts
index 285213976a7..baab0347dab 100644
--- a/arch/powerpc/boot/dts/p2041rdb.dts
+++ b/arch/powerpc/boot/dts/p2041rdb.dts
@@ -121,7 +121,8 @@
121 121
122 lbc: localbus@ffe124000 { 122 lbc: localbus@ffe124000 {
123 reg = <0xf 0xfe124000 0 0x1000>; 123 reg = <0xf 0xfe124000 0 0x1000>;
124 ranges = <0 0 0xf 0xe8000000 0x08000000>; 124 ranges = <0 0 0xf 0xe8000000 0x08000000
125 1 0 0xf 0xffa00000 0x00040000>;
125 126
126 flash@0,0 { 127 flash@0,0 {
127 compatible = "cfi-flash"; 128 compatible = "cfi-flash";
@@ -129,6 +130,44 @@
129 bank-width = <2>; 130 bank-width = <2>;
130 device-width = <2>; 131 device-width = <2>;
131 }; 132 };
133
134 nand@1,0 {
135 #address-cells = <1>;
136 #size-cells = <1>;
137 compatible = "fsl,elbc-fcm-nand";
138 reg = <0x1 0x0 0x40000>;
139
140 partition@0 {
141 label = "NAND U-Boot Image";
142 reg = <0x0 0x02000000>;
143 read-only;
144 };
145
146 partition@2000000 {
147 label = "NAND Root File System";
148 reg = <0x02000000 0x10000000>;
149 };
150
151 partition@12000000 {
152 label = "NAND Compressed RFS Image";
153 reg = <0x12000000 0x08000000>;
154 };
155
156 partition@1a000000 {
157 label = "NAND Linux Kernel Image";
158 reg = <0x1a000000 0x04000000>;
159 };
160
161 partition@1e000000 {
162 label = "NAND DTB Image";
163 reg = <0x1e000000 0x01000000>;
164 };
165
166 partition@1f000000 {
167 label = "NAND Writable User area";
168 reg = <0x1f000000 0x01000000>;
169 };
170 };
132 }; 171 };
133 172
134 pci0: pcie@ffe200000 { 173 pci0: pcie@ffe200000 {
diff --git a/arch/powerpc/boot/dts/p3041ds.dts b/arch/powerpc/boot/dts/p3041ds.dts
index 22a215e9416..6cdcadc80c3 100644
--- a/arch/powerpc/boot/dts/p3041ds.dts
+++ b/arch/powerpc/boot/dts/p3041ds.dts
@@ -58,7 +58,7 @@
58 #size-cells = <1>; 58 #size-cells = <1>;
59 compatible = "spansion,s25sl12801"; 59 compatible = "spansion,s25sl12801";
60 reg = <0>; 60 reg = <0>;
61 spi-max-frequency = <40000000>; /* input clock */ 61 spi-max-frequency = <35000000>; /* input clock */
62 partition@u-boot { 62 partition@u-boot {
63 label = "u-boot"; 63 label = "u-boot";
64 reg = <0x00000000 0x00100000>; 64 reg = <0x00000000 0x00100000>;
diff --git a/arch/powerpc/boot/dts/p3060qds.dts b/arch/powerpc/boot/dts/p3060qds.dts
deleted file mode 100644
index 9ae875c8a21..00000000000
--- a/arch/powerpc/boot/dts/p3060qds.dts
+++ /dev/null
@@ -1,242 +0,0 @@
1/*
2 * P3060QDS Device Tree Source
3 *
4 * Copyright 2011 Freescale Semiconductor Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Freescale Semiconductor nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 *
18 * ALTERNATIVELY, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") as published by the Free Software
20 * Foundation, either version 2 of that License or (at your option) any
21 * later version.
22 *
23 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35/include/ "fsl/p3060si-pre.dtsi"
36
37/ {
38 model = "fsl,P3060QDS";
39 compatible = "fsl,P3060QDS";
40 #address-cells = <2>;
41 #size-cells = <2>;
42 interrupt-parent = <&mpic>;
43
44 memory {
45 device_type = "memory";
46 };
47
48 dcsr: dcsr@f00000000 {
49 ranges = <0x00000000 0xf 0x00000000 0x01008000>;
50 };
51
52 soc: soc@ffe000000 {
53 ranges = <0x00000000 0xf 0xfe000000 0x1000000>;
54 reg = <0xf 0xfe000000 0 0x00001000>;
55 spi@110000 {
56 flash@0 {
57 #address-cells = <1>;
58 #size-cells = <1>;
59 compatible = "spansion,s25sl12801";
60 reg = <0>;
61 spi-max-frequency = <40000000>; /* input clock */
62 partition@u-boot {
63 label = "u-boot";
64 reg = <0x00000000 0x00100000>;
65 read-only;
66 };
67 partition@kernel {
68 label = "kernel";
69 reg = <0x00100000 0x00500000>;
70 read-only;
71 };
72 partition@dtb {
73 label = "dtb";
74 reg = <0x00600000 0x00100000>;
75 read-only;
76 };
77 partition@fs {
78 label = "file system";
79 reg = <0x00700000 0x00900000>;
80 };
81 };
82 flash@1 {
83 #address-cells = <1>;
84 #size-cells = <1>;
85 compatible = "spansion,en25q32b";
86 reg = <1>;
87 spi-max-frequency = <40000000>; /* input clock */
88 partition@spi1 {
89 label = "spi1";
90 reg = <0x00000000 0x00400000>;
91 };
92 };
93 flash@2 {
94 #address-cells = <1>;
95 #size-cells = <1>;
96 compatible = "atmel,at45db081d";
97 reg = <2>;
98 spi-max-frequency = <40000000>; /* input clock */
99 partition@spi1 {
100 label = "spi2";
101 reg = <0x00000000 0x00100000>;
102 };
103 };
104 flash@3 {
105 #address-cells = <1>;
106 #size-cells = <1>;
107 compatible = "spansion,sst25wf040";
108 reg = <3>;
109 spi-max-frequency = <40000000>; /* input clock */
110 partition@spi3 {
111 label = "spi3";
112 reg = <0x00000000 0x00080000>;
113 };
114 };
115 };
116
117 i2c@118000 {
118 eeprom@51 {
119 compatible = "at24,24c256";
120 reg = <0x51>;
121 };
122 eeprom@53 {
123 compatible = "at24,24c256";
124 reg = <0x53>;
125 };
126 rtc@68 {
127 compatible = "dallas,ds3232";
128 reg = <0x68>;
129 interrupts = <0x1 0x1 0 0>;
130 };
131 };
132
133 usb0: usb@210000 {
134 phy_type = "ulpi";
135 };
136
137 usb1: usb@211000 {
138 dr_mode = "host";
139 phy_type = "ulpi";
140 };
141 };
142
143 rio: rapidio@ffe0c0000 {
144 reg = <0xf 0xfe0c0000 0 0x11000>;
145
146 port1 {
147 ranges = <0 0 0xc 0x20000000 0 0x10000000>;
148 };
149 port2 {
150 ranges = <0 0 0xc 0x30000000 0 0x10000000>;
151 };
152 };
153
154 lbc: localbus@ffe124000 {
155 reg = <0xf 0xfe124000 0 0x1000>;
156 ranges = <0 0 0xf 0xe8000000 0x08000000
157 2 0 0xf 0xffa00000 0x00040000
158 3 0 0xf 0xffdf0000 0x00008000>;
159
160 flash@0,0 {
161 compatible = "cfi-flash";
162 reg = <0 0 0x08000000>;
163 bank-width = <2>;
164 device-width = <2>;
165 };
166
167 nand@2,0 {
168 #address-cells = <1>;
169 #size-cells = <1>;
170 compatible = "fsl,elbc-fcm-nand";
171 reg = <0x2 0x0 0x40000>;
172
173 partition@0 {
174 label = "NAND U-Boot Image";
175 reg = <0x0 0x02000000>;
176 read-only;
177 };
178
179 partition@2000000 {
180 label = "NAND Root File System";
181 reg = <0x02000000 0x10000000>;
182 };
183
184 partition@12000000 {
185 label = "NAND Compressed RFS Image";
186 reg = <0x12000000 0x08000000>;
187 };
188
189 partition@1a000000 {
190 label = "NAND Linux Kernel Image";
191 reg = <0x1a000000 0x04000000>;
192 };
193
194 partition@1e000000 {
195 label = "NAND DTB Image";
196 reg = <0x1e000000 0x01000000>;
197 };
198
199 partition@1f000000 {
200 label = "NAND Writable User area";
201 reg = <0x1f000000 0x21000000>;
202 };
203 };
204
205 board-control@3,0 {
206 compatible = "fsl,p3060qds-fpga", "fsl,fpga-qixis";
207 reg = <3 0 0x100>;
208 };
209 };
210
211 pci0: pcie@ffe200000 {
212 reg = <0xf 0xfe200000 0 0x1000>;
213 ranges = <0x02000000 0 0xe0000000 0xc 0x00000000 0x0 0x20000000
214 0x01000000 0 0x00000000 0xf 0xf8000000 0x0 0x00010000>;
215 pcie@0 {
216 ranges = <0x02000000 0 0xe0000000
217 0x02000000 0 0xe0000000
218 0 0x20000000
219
220 0x01000000 0 0x00000000
221 0x01000000 0 0x00000000
222 0 0x00010000>;
223 };
224 };
225
226 pci1: pcie@ffe201000 {
227 reg = <0xf 0xfe201000 0 0x1000>;
228 ranges = <0x02000000 0x0 0xe0000000 0xc 0x20000000 0x0 0x20000000
229 0x01000000 0x0 0x00000000 0xf 0xf8010000 0x0 0x00010000>;
230 pcie@0 {
231 ranges = <0x02000000 0 0xe0000000
232 0x02000000 0 0xe0000000
233 0 0x20000000
234
235 0x01000000 0 0x00000000
236 0x01000000 0 0x00000000
237 0 0x00010000>;
238 };
239 };
240};
241
242/include/ "fsl/p3060si-post.dtsi"
diff --git a/arch/powerpc/boot/dts/sbc8560.dts b/arch/powerpc/boot/dts/sbc8560.dts
deleted file mode 100644
index 72078eb1561..00000000000
--- a/arch/powerpc/boot/dts/sbc8560.dts
+++ /dev/null
@@ -1,406 +0,0 @@
1/*
2 * SBC8560 Device Tree Source
3 *
4 * Copyright 2007 Wind River Systems Inc.
5 *
6 * Paul Gortmaker (see MAINTAINERS for contact information)
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/dts-v1/;
15
16/ {
17 model = "SBC8560";
18 compatible = "SBC8560";
19 #address-cells = <1>;
20 #size-cells = <1>;
21
22 aliases {
23 ethernet0 = &enet0;
24 ethernet1 = &enet1;
25 ethernet2 = &enet2;
26 ethernet3 = &enet3;
27 serial0 = &serial0;
28 serial1 = &serial1;
29 pci0 = &pci0;
30 };
31
32 cpus {
33 #address-cells = <1>;
34 #size-cells = <0>;
35
36 PowerPC,8560@0 {
37 device_type = "cpu";
38 reg = <0>;
39 d-cache-line-size = <0x20>; // 32 bytes
40 i-cache-line-size = <0x20>; // 32 bytes
41 d-cache-size = <0x8000>; // L1, 32K
42 i-cache-size = <0x8000>; // L1, 32K
43 timebase-frequency = <0>; // From uboot
44 bus-frequency = <0>;
45 clock-frequency = <0>;
46 next-level-cache = <&L2>;
47 };
48 };
49
50 memory {
51 device_type = "memory";
52 reg = <0x00000000 0x20000000>;
53 };
54
55 soc@ff700000 {
56 #address-cells = <1>;
57 #size-cells = <1>;
58 device_type = "soc";
59 ranges = <0x0 0xff700000 0x00100000>;
60 clock-frequency = <0>;
61
62 ecm-law@0 {
63 compatible = "fsl,ecm-law";
64 reg = <0x0 0x1000>;
65 fsl,num-laws = <8>;
66 };
67
68 ecm@1000 {
69 compatible = "fsl,mpc8560-ecm", "fsl,ecm";
70 reg = <0x1000 0x1000>;
71 interrupts = <17 2>;
72 interrupt-parent = <&mpic>;
73 };
74
75 memory-controller@2000 {
76 compatible = "fsl,mpc8560-memory-controller";
77 reg = <0x2000 0x1000>;
78 interrupt-parent = <&mpic>;
79 interrupts = <0x12 0x2>;
80 };
81
82 L2: l2-cache-controller@20000 {
83 compatible = "fsl,mpc8560-l2-cache-controller";
84 reg = <0x20000 0x1000>;
85 cache-line-size = <0x20>; // 32 bytes
86 cache-size = <0x40000>; // L2, 256K
87 interrupt-parent = <&mpic>;
88 interrupts = <0x10 0x2>;
89 };
90
91 i2c@3000 {
92 #address-cells = <1>;
93 #size-cells = <0>;
94 cell-index = <0>;
95 compatible = "fsl-i2c";
96 reg = <0x3000 0x100>;
97 interrupts = <0x2b 0x2>;
98 interrupt-parent = <&mpic>;
99 dfsrr;
100 };
101
102 i2c@3100 {
103 #address-cells = <1>;
104 #size-cells = <0>;
105 cell-index = <1>;
106 compatible = "fsl-i2c";
107 reg = <0x3100 0x100>;
108 interrupts = <0x2b 0x2>;
109 interrupt-parent = <&mpic>;
110 dfsrr;
111 };
112
113 dma@21300 {
114 #address-cells = <1>;
115 #size-cells = <1>;
116 compatible = "fsl,mpc8560-dma", "fsl,eloplus-dma";
117 reg = <0x21300 0x4>;
118 ranges = <0x0 0x21100 0x200>;
119 cell-index = <0>;
120 dma-channel@0 {
121 compatible = "fsl,mpc8560-dma-channel",
122 "fsl,eloplus-dma-channel";
123 reg = <0x0 0x80>;
124 cell-index = <0>;
125 interrupt-parent = <&mpic>;
126 interrupts = <20 2>;
127 };
128 dma-channel@80 {
129 compatible = "fsl,mpc8560-dma-channel",
130 "fsl,eloplus-dma-channel";
131 reg = <0x80 0x80>;
132 cell-index = <1>;
133 interrupt-parent = <&mpic>;
134 interrupts = <21 2>;
135 };
136 dma-channel@100 {
137 compatible = "fsl,mpc8560-dma-channel",
138 "fsl,eloplus-dma-channel";
139 reg = <0x100 0x80>;
140 cell-index = <2>;
141 interrupt-parent = <&mpic>;
142 interrupts = <22 2>;
143 };
144 dma-channel@180 {
145 compatible = "fsl,mpc8560-dma-channel",
146 "fsl,eloplus-dma-channel";
147 reg = <0x180 0x80>;
148 cell-index = <3>;
149 interrupt-parent = <&mpic>;
150 interrupts = <23 2>;
151 };
152 };
153
154 enet0: ethernet@24000 {
155 #address-cells = <1>;
156 #size-cells = <1>;
157 cell-index = <0>;
158 device_type = "network";
159 model = "TSEC";
160 compatible = "gianfar";
161 reg = <0x24000 0x1000>;
162 ranges = <0x0 0x24000 0x1000>;
163 local-mac-address = [ 00 00 00 00 00 00 ];
164 interrupts = <0x1d 0x2 0x1e 0x2 0x22 0x2>;
165 interrupt-parent = <&mpic>;
166 tbi-handle = <&tbi0>;
167 phy-handle = <&phy0>;
168
169 mdio@520 {
170 #address-cells = <1>;
171 #size-cells = <0>;
172 compatible = "fsl,gianfar-mdio";
173 reg = <0x520 0x20>;
174 phy0: ethernet-phy@19 {
175 interrupt-parent = <&mpic>;
176 interrupts = <0x6 0x1>;
177 reg = <0x19>;
178 device_type = "ethernet-phy";
179 };
180 phy1: ethernet-phy@1a {
181 interrupt-parent = <&mpic>;
182 interrupts = <0x7 0x1>;
183 reg = <0x1a>;
184 device_type = "ethernet-phy";
185 };
186 phy2: ethernet-phy@1b {
187 interrupt-parent = <&mpic>;
188 interrupts = <0x8 0x1>;
189 reg = <0x1b>;
190 device_type = "ethernet-phy";
191 };
192 phy3: ethernet-phy@1c {
193 interrupt-parent = <&mpic>;
194 interrupts = <0x8 0x1>;
195 reg = <0x1c>;
196 device_type = "ethernet-phy";
197 };
198 tbi0: tbi-phy@11 {
199 reg = <0x11>;
200 device_type = "tbi-phy";
201 };
202 };
203 };
204
205 enet1: ethernet@25000 {
206 #address-cells = <1>;
207 #size-cells = <1>;
208 cell-index = <1>;
209 device_type = "network";
210 model = "TSEC";
211 compatible = "gianfar";
212 reg = <0x25000 0x1000>;
213 ranges = <0x0 0x25000 0x1000>;
214 local-mac-address = [ 00 00 00 00 00 00 ];
215 interrupts = <0x23 0x2 0x24 0x2 0x28 0x2>;
216 interrupt-parent = <&mpic>;
217 tbi-handle = <&tbi1>;
218 phy-handle = <&phy1>;
219
220 mdio@520 {
221 #address-cells = <1>;
222 #size-cells = <0>;
223 compatible = "fsl,gianfar-tbi";
224 reg = <0x520 0x20>;
225
226 tbi1: tbi-phy@11 {
227 reg = <0x11>;
228 device_type = "tbi-phy";
229 };
230 };
231 };
232
233 mpic: pic@40000 {
234 interrupt-controller;
235 #address-cells = <0>;
236 #interrupt-cells = <2>;
237 compatible = "chrp,open-pic";
238 reg = <0x40000 0x40000>;
239 device_type = "open-pic";
240 };
241
242 cpm@919c0 {
243 #address-cells = <1>;
244 #size-cells = <1>;
245 compatible = "fsl,mpc8560-cpm", "fsl,cpm2";
246 reg = <0x919c0 0x30>;
247 ranges;
248
249 muram@80000 {
250 #address-cells = <1>;
251 #size-cells = <1>;
252 ranges = <0x0 0x80000 0x10000>;
253
254 data@0 {
255 compatible = "fsl,cpm-muram-data";
256 reg = <0x0 0x4000 0x9000 0x2000>;
257 };
258 };
259
260 brg@919f0 {
261 compatible = "fsl,mpc8560-brg",
262 "fsl,cpm2-brg",
263 "fsl,cpm-brg";
264 reg = <0x919f0 0x10 0x915f0 0x10>;
265 clock-frequency = <165000000>;
266 };
267
268 cpmpic: pic@90c00 {
269 interrupt-controller;
270 #address-cells = <0>;
271 #interrupt-cells = <2>;
272 interrupts = <0x2e 0x2>;
273 interrupt-parent = <&mpic>;
274 reg = <0x90c00 0x80>;
275 compatible = "fsl,mpc8560-cpm-pic", "fsl,cpm2-pic";
276 };
277
278 enet2: ethernet@91320 {
279 device_type = "network";
280 compatible = "fsl,mpc8560-fcc-enet",
281 "fsl,cpm2-fcc-enet";
282 reg = <0x91320 0x20 0x88500 0x100 0x913b0 0x1>;
283 local-mac-address = [ 00 00 00 00 00 00 ];
284 fsl,cpm-command = <0x16200300>;
285 interrupts = <0x21 0x8>;
286 interrupt-parent = <&cpmpic>;
287 phy-handle = <&phy2>;
288 };
289
290 enet3: ethernet@91340 {
291 device_type = "network";
292 compatible = "fsl,mpc8560-fcc-enet",
293 "fsl,cpm2-fcc-enet";
294 reg = <0x91340 0x20 0x88600 0x100 0x913d0 0x1>;
295 local-mac-address = [ 00 00 00 00 00 00 ];
296 fsl,cpm-command = <0x1a400300>;
297 interrupts = <0x22 0x8>;
298 interrupt-parent = <&cpmpic>;
299 phy-handle = <&phy3>;
300 };
301 };
302
303 global-utilities@e0000 {
304 compatible = "fsl,mpc8560-guts";
305 reg = <0xe0000 0x1000>;
306 };
307 };
308
309 pci0: pci@ff708000 {
310 #interrupt-cells = <1>;
311 #size-cells = <2>;
312 #address-cells = <3>;
313 compatible = "fsl,mpc8540-pcix", "fsl,mpc8540-pci";
314 device_type = "pci";
315 reg = <0xff708000 0x1000>;
316 clock-frequency = <66666666>;
317 interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
318 interrupt-map = <
319
320 /* IDSEL 0x02 */
321 0x1000 0x0 0x0 0x1 &mpic 0x2 0x1
322 0x1000 0x0 0x0 0x2 &mpic 0x3 0x1
323 0x1000 0x0 0x0 0x3 &mpic 0x4 0x1
324 0x1000 0x0 0x0 0x4 &mpic 0x5 0x1>;
325
326 interrupt-parent = <&mpic>;
327 interrupts = <0x18 0x2>;
328 bus-range = <0x0 0x0>;
329 ranges = <0x02000000 0x0 0x80000000 0x80000000 0x0 0x20000000
330 0x01000000 0x0 0x00000000 0xe2000000 0x0 0x00100000>;
331 };
332
333 localbus@ff705000 {
334 compatible = "fsl,mpc8560-localbus", "simple-bus";
335 #address-cells = <2>;
336 #size-cells = <1>;
337 reg = <0xff705000 0x100>; // BRx, ORx, etc.
338
339 ranges = <
340 0x0 0x0 0xff800000 0x0800000 // 8MB boot flash
341 0x1 0x0 0xe4000000 0x4000000 // 64MB flash
342 0x3 0x0 0x20000000 0x4000000 // 64MB SDRAM
343 0x4 0x0 0x24000000 0x4000000 // 64MB SDRAM
344 0x5 0x0 0xfc000000 0x0c00000 // EPLD
345 0x6 0x0 0xe0000000 0x4000000 // 64MB flash
346 0x7 0x0 0x80000000 0x0200000 // ATM1,2
347 >;
348
349 epld@5,0 {
350 compatible = "wrs,epld-localbus";
351 #address-cells = <2>;
352 #size-cells = <1>;
353 reg = <0x5 0x0 0xc00000>;
354 ranges = <
355 0x0 0x0 0x5 0x000000 0x1fff // LED disp.
356 0x1 0x0 0x5 0x100000 0x1fff // switches
357 0x2 0x0 0x5 0x200000 0x1fff // ID reg.
358 0x3 0x0 0x5 0x300000 0x1fff // status reg.
359 0x4 0x0 0x5 0x400000 0x1fff // reset reg.
360 0x5 0x0 0x5 0x500000 0x1fff // Wind port
361 0x7 0x0 0x5 0x700000 0x1fff // UART #1
362 0x8 0x0 0x5 0x800000 0x1fff // UART #2
363 0x9 0x0 0x5 0x900000 0x1fff // RTC
364 0xb 0x0 0x5 0xb00000 0x1fff // EEPROM
365 >;
366
367 bidr@2,0 {
368 compatible = "wrs,sbc8560-bidr";
369 reg = <0x2 0x0 0x10>;
370 };
371
372 bcsr@3,0 {
373 compatible = "wrs,sbc8560-bcsr";
374 reg = <0x3 0x0 0x10>;
375 };
376
377 brstcr@4,0 {
378 compatible = "wrs,sbc8560-brstcr";
379 reg = <0x4 0x0 0x10>;
380 };
381
382 serial0: serial@7,0 {
383 device_type = "serial";
384 compatible = "ns16550";
385 reg = <0x7 0x0 0x100>;
386 clock-frequency = <1843200>;
387 interrupts = <0x9 0x2>;
388 interrupt-parent = <&mpic>;
389 };
390
391 serial1: serial@8,0 {
392 device_type = "serial";
393 compatible = "ns16550";
394 reg = <0x8 0x0 0x100>;
395 clock-frequency = <1843200>;
396 interrupts = <0xa 0x2>;
397 interrupt-parent = <&mpic>;
398 };
399
400 rtc@9,0 {
401 compatible = "m48t59";
402 reg = <0x9 0x0 0x1fff>;
403 };
404 };
405 };
406};
diff --git a/arch/powerpc/boot/flatdevtree_env.h b/arch/powerpc/boot/flatdevtree_env.h
deleted file mode 100644
index 66e0ebb1a36..00000000000
--- a/arch/powerpc/boot/flatdevtree_env.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/*
2 * This file adds the header file glue so that the shared files
3 * flatdevicetree.[ch] can compile and work in the powerpc bootwrapper.
4 *
5 * strncmp & strchr copied from <file:lib/string.c>
6 * Copyright (C) 1991, 1992 Linus Torvalds
7 *
8 * Maintained by: Mark A. Greer <mgreer@mvista.com>
9 */
10#ifndef _PPC_BOOT_FLATDEVTREE_ENV_H_
11#define _PPC_BOOT_FLATDEVTREE_ENV_H_
12
13#include <stdarg.h>
14#include <stddef.h>
15#include "types.h"
16#include "string.h"
17#include "stdio.h"
18#include "ops.h"
19
20#define be16_to_cpu(x) (x)
21#define cpu_to_be16(x) (x)
22#define be32_to_cpu(x) (x)
23#define cpu_to_be32(x) (x)
24#define be64_to_cpu(x) (x)
25#define cpu_to_be64(x) (x)
26
27#endif /* _PPC_BOOT_FLATDEVTREE_ENV_H_ */
diff --git a/arch/powerpc/configs/83xx/kmeter1_defconfig b/arch/powerpc/configs/83xx/kmeter1_defconfig
index 07e1bbadebf..a0dfef1fcdb 100644
--- a/arch/powerpc/configs/83xx/kmeter1_defconfig
+++ b/arch/powerpc/configs/83xx/kmeter1_defconfig
@@ -2,14 +2,14 @@ CONFIG_EXPERIMENTAL=y
2# CONFIG_SWAP is not set 2# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y 3CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 4CONFIG_POSIX_MQUEUE=y
5CONFIG_SPARSE_IRQ=y
6CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
7CONFIG_EXPERT=y 6CONFIG_EXPERT=y
8# CONFIG_HOTPLUG is not set
9CONFIG_SLAB=y 7CONFIG_SLAB=y
10CONFIG_MODULES=y 8CONFIG_MODULES=y
11CONFIG_MODULE_UNLOAD=y 9CONFIG_MODULE_UNLOAD=y
12# CONFIG_BLK_DEV_BSG is not set 10# CONFIG_BLK_DEV_BSG is not set
11CONFIG_PARTITION_ADVANCED=y
12# CONFIG_MSDOS_PARTITION is not set
13# CONFIG_IOSCHED_DEADLINE is not set 13# CONFIG_IOSCHED_DEADLINE is not set
14# CONFIG_IOSCHED_CFQ is not set 14# CONFIG_IOSCHED_CFQ is not set
15# CONFIG_PPC_CHRP is not set 15# CONFIG_PPC_CHRP is not set
@@ -31,11 +31,10 @@ CONFIG_IP_PNP=y
31# CONFIG_INET_XFRM_MODE_BEET is not set 31# CONFIG_INET_XFRM_MODE_BEET is not set
32# CONFIG_INET_LRO is not set 32# CONFIG_INET_LRO is not set
33# CONFIG_IPV6 is not set 33# CONFIG_IPV6 is not set
34CONFIG_TIPC=y
34CONFIG_BRIDGE=m 35CONFIG_BRIDGE=m
35CONFIG_VLAN_8021Q=y 36CONFIG_VLAN_8021Q=y
36CONFIG_MTD=y 37CONFIG_MTD=y
37CONFIG_MTD_CONCAT=y
38CONFIG_MTD_PARTITIONS=y
39CONFIG_MTD_CMDLINE_PARTS=y 38CONFIG_MTD_CMDLINE_PARTS=y
40CONFIG_MTD_CHAR=y 39CONFIG_MTD_CHAR=y
41CONFIG_MTD_BLOCK=y 40CONFIG_MTD_BLOCK=y
@@ -50,17 +49,15 @@ CONFIG_MTD_UBI_DEBUG=y
50CONFIG_PROC_DEVICETREE=y 49CONFIG_PROC_DEVICETREE=y
51CONFIG_NETDEVICES=y 50CONFIG_NETDEVICES=y
52CONFIG_DUMMY=y 51CONFIG_DUMMY=y
53CONFIG_TUN=y
54CONFIG_MII=y 52CONFIG_MII=y
55CONFIG_MARVELL_PHY=y 53CONFIG_TUN=y
56CONFIG_NET_ETHERNET=y
57CONFIG_UCC_GETH=y 54CONFIG_UCC_GETH=y
58# CONFIG_NETDEV_10000 is not set 55CONFIG_MARVELL_PHY=y
59CONFIG_WAN=y
60CONFIG_HDLC=y
61CONFIG_PPP=y 56CONFIG_PPP=y
62CONFIG_PPP_MULTILINK=y 57CONFIG_PPP_MULTILINK=y
63CONFIG_PPPOE=y 58CONFIG_PPPOE=y
59CONFIG_WAN=y
60CONFIG_HDLC=y
64# CONFIG_INPUT is not set 61# CONFIG_INPUT is not set
65# CONFIG_SERIO is not set 62# CONFIG_SERIO is not set
66# CONFIG_VT is not set 63# CONFIG_VT is not set
@@ -77,10 +74,7 @@ CONFIG_UIO=y
77# CONFIG_DNOTIFY is not set 74# CONFIG_DNOTIFY is not set
78CONFIG_TMPFS=y 75CONFIG_TMPFS=y
79CONFIG_JFFS2_FS=y 76CONFIG_JFFS2_FS=y
77CONFIG_UBIFS_FS=y
80CONFIG_NFS_FS=y 78CONFIG_NFS_FS=y
81CONFIG_NFS_V3=y 79CONFIG_NFS_V3=y
82CONFIG_ROOT_NFS=y 80CONFIG_ROOT_NFS=y
83CONFIG_PARTITION_ADVANCED=y
84# CONFIG_MSDOS_PARTITION is not set
85# CONFIG_RCU_CPU_STALL_DETECTOR is not set
86CONFIG_SYSCTL_SYSCALL_CHECK=y
diff --git a/arch/powerpc/configs/85xx/p1023rds_defconfig b/arch/powerpc/configs/85xx/p1023rds_defconfig
index f4337bacd0e..26e541c4662 100644
--- a/arch/powerpc/configs/85xx/p1023rds_defconfig
+++ b/arch/powerpc/configs/85xx/p1023rds_defconfig
@@ -6,28 +6,27 @@ CONFIG_SYSVIPC=y
6CONFIG_POSIX_MQUEUE=y 6CONFIG_POSIX_MQUEUE=y
7CONFIG_BSD_PROCESS_ACCT=y 7CONFIG_BSD_PROCESS_ACCT=y
8CONFIG_AUDIT=y 8CONFIG_AUDIT=y
9CONFIG_SPARSE_IRQ=y 9CONFIG_IRQ_DOMAIN_DEBUG=y
10CONFIG_NO_HZ=y
11CONFIG_HIGH_RES_TIMERS=y
10CONFIG_IKCONFIG=y 12CONFIG_IKCONFIG=y
11CONFIG_IKCONFIG_PROC=y 13CONFIG_IKCONFIG_PROC=y
12CONFIG_LOG_BUF_SHIFT=14 14CONFIG_LOG_BUF_SHIFT=14
13CONFIG_BLK_DEV_INITRD=y 15CONFIG_BLK_DEV_INITRD=y
14# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
15CONFIG_KALLSYMS_ALL=y 16CONFIG_KALLSYMS_ALL=y
16CONFIG_KALLSYMS_EXTRA_PASS=y
17CONFIG_EMBEDDED=y 17CONFIG_EMBEDDED=y
18CONFIG_MODULES=y 18CONFIG_MODULES=y
19CONFIG_MODULE_UNLOAD=y 19CONFIG_MODULE_UNLOAD=y
20CONFIG_MODULE_FORCE_UNLOAD=y 20CONFIG_MODULE_FORCE_UNLOAD=y
21CONFIG_MODVERSIONS=y 21CONFIG_MODVERSIONS=y
22# CONFIG_BLK_DEV_BSG is not set 22# CONFIG_BLK_DEV_BSG is not set
23CONFIG_PARTITION_ADVANCED=y
24CONFIG_MAC_PARTITION=y
23CONFIG_P1023_RDS=y 25CONFIG_P1023_RDS=y
24CONFIG_QUICC_ENGINE=y 26CONFIG_QUICC_ENGINE=y
25CONFIG_QE_GPIO=y 27CONFIG_QE_GPIO=y
26CONFIG_CPM2=y 28CONFIG_CPM2=y
27CONFIG_GPIO_MPC8XXX=y
28CONFIG_HIGHMEM=y 29CONFIG_HIGHMEM=y
29CONFIG_NO_HZ=y
30CONFIG_HIGH_RES_TIMERS=y
31# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set 30# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
32CONFIG_BINFMT_MISC=m 31CONFIG_BINFMT_MISC=m
33CONFIG_MATH_EMULATION=y 32CONFIG_MATH_EMULATION=y
@@ -63,11 +62,11 @@ CONFIG_INET_ESP=y
63CONFIG_IPV6=y 62CONFIG_IPV6=y
64CONFIG_IP_SCTP=m 63CONFIG_IP_SCTP=m
65CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 64CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
65CONFIG_DEVTMPFS=y
66CONFIG_PROC_DEVICETREE=y 66CONFIG_PROC_DEVICETREE=y
67CONFIG_BLK_DEV_LOOP=y 67CONFIG_BLK_DEV_LOOP=y
68CONFIG_BLK_DEV_RAM=y 68CONFIG_BLK_DEV_RAM=y
69CONFIG_BLK_DEV_RAM_SIZE=131072 69CONFIG_BLK_DEV_RAM_SIZE=131072
70CONFIG_MISC_DEVICES=y
71CONFIG_EEPROM_LEGACY=y 70CONFIG_EEPROM_LEGACY=y
72CONFIG_BLK_DEV_SD=y 71CONFIG_BLK_DEV_SD=y
73CONFIG_CHR_DEV_ST=y 72CONFIG_CHR_DEV_ST=y
@@ -80,15 +79,14 @@ CONFIG_SATA_FSL=y
80CONFIG_SATA_SIL24=y 79CONFIG_SATA_SIL24=y
81CONFIG_NETDEVICES=y 80CONFIG_NETDEVICES=y
82CONFIG_DUMMY=y 81CONFIG_DUMMY=y
82CONFIG_FS_ENET=y
83CONFIG_FSL_PQ_MDIO=y
84CONFIG_E1000E=y
83CONFIG_MARVELL_PHY=y 85CONFIG_MARVELL_PHY=y
84CONFIG_DAVICOM_PHY=y 86CONFIG_DAVICOM_PHY=y
85CONFIG_CICADA_PHY=y 87CONFIG_CICADA_PHY=y
86CONFIG_VITESSE_PHY=y 88CONFIG_VITESSE_PHY=y
87CONFIG_FIXED_PHY=y 89CONFIG_FIXED_PHY=y
88CONFIG_NET_ETHERNET=y
89CONFIG_FS_ENET=y
90CONFIG_E1000E=y
91CONFIG_FSL_PQ_MDIO=y
92CONFIG_INPUT_FF_MEMLESS=m 90CONFIG_INPUT_FF_MEMLESS=m
93# CONFIG_INPUT_MOUSEDEV is not set 91# CONFIG_INPUT_MOUSEDEV is not set
94# CONFIG_INPUT_KEYBOARD is not set 92# CONFIG_INPUT_KEYBOARD is not set
@@ -98,16 +96,15 @@ CONFIG_SERIAL_8250=y
98CONFIG_SERIAL_8250_CONSOLE=y 96CONFIG_SERIAL_8250_CONSOLE=y
99CONFIG_SERIAL_8250_NR_UARTS=2 97CONFIG_SERIAL_8250_NR_UARTS=2
100CONFIG_SERIAL_8250_RUNTIME_UARTS=2 98CONFIG_SERIAL_8250_RUNTIME_UARTS=2
101CONFIG_SERIAL_8250_EXTENDED=y
102CONFIG_SERIAL_8250_MANY_PORTS=y 99CONFIG_SERIAL_8250_MANY_PORTS=y
103CONFIG_SERIAL_8250_DETECT_IRQ=y 100CONFIG_SERIAL_8250_DETECT_IRQ=y
104CONFIG_SERIAL_8250_RSA=y 101CONFIG_SERIAL_8250_RSA=y
105CONFIG_SERIAL_QE=m 102CONFIG_SERIAL_QE=m
106CONFIG_HW_RANDOM=y
107CONFIG_NVRAM=y 103CONFIG_NVRAM=y
108CONFIG_I2C=y 104CONFIG_I2C=y
109CONFIG_I2C_CPM=m 105CONFIG_I2C_CPM=m
110CONFIG_I2C_MPC=y 106CONFIG_I2C_MPC=y
107CONFIG_GPIO_MPC8XXX=y
111# CONFIG_HWMON is not set 108# CONFIG_HWMON is not set
112CONFIG_VIDEO_OUTPUT_CONTROL=y 109CONFIG_VIDEO_OUTPUT_CONTROL=y
113CONFIG_SOUND=y 110CONFIG_SOUND=y
@@ -123,7 +120,6 @@ CONFIG_DMADEVICES=y
123CONFIG_FSL_DMA=y 120CONFIG_FSL_DMA=y
124# CONFIG_NET_DMA is not set 121# CONFIG_NET_DMA is not set
125CONFIG_STAGING=y 122CONFIG_STAGING=y
126# CONFIG_STAGING_EXCLUDE_BUILD is not set
127CONFIG_EXT2_FS=y 123CONFIG_EXT2_FS=y
128CONFIG_EXT3_FS=y 124CONFIG_EXT3_FS=y
129# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 125# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
@@ -150,22 +146,15 @@ CONFIG_QNX4FS_FS=m
150CONFIG_SYSV_FS=m 146CONFIG_SYSV_FS=m
151CONFIG_UFS_FS=m 147CONFIG_UFS_FS=m
152CONFIG_NFS_FS=y 148CONFIG_NFS_FS=y
153CONFIG_NFS_V3=y
154CONFIG_NFS_V4=y 149CONFIG_NFS_V4=y
155CONFIG_ROOT_NFS=y 150CONFIG_ROOT_NFS=y
156CONFIG_NFSD=y 151CONFIG_NFSD=y
157CONFIG_PARTITION_ADVANCED=y
158CONFIG_MAC_PARTITION=y
159CONFIG_CRC_T10DIF=y 152CONFIG_CRC_T10DIF=y
160CONFIG_FRAME_WARN=8092 153CONFIG_FRAME_WARN=8092
161CONFIG_DEBUG_FS=y 154CONFIG_DEBUG_FS=y
162CONFIG_DEBUG_KERNEL=y
163CONFIG_DETECT_HUNG_TASK=y 155CONFIG_DETECT_HUNG_TASK=y
164# CONFIG_DEBUG_BUGVERBOSE is not set 156# CONFIG_DEBUG_BUGVERBOSE is not set
165CONFIG_DEBUG_INFO=y 157CONFIG_DEBUG_INFO=y
166# CONFIG_RCU_CPU_STALL_DETECTOR is not set
167CONFIG_SYSCTL_SYSCALL_CHECK=y
168CONFIG_IRQ_DOMAIN_DEBUG=y
169CONFIG_CRYPTO_PCBC=m 158CONFIG_CRYPTO_PCBC=m
170CONFIG_CRYPTO_SHA256=y 159CONFIG_CRYPTO_SHA256=y
171CONFIG_CRYPTO_SHA512=y 160CONFIG_CRYPTO_SHA512=y
diff --git a/arch/powerpc/configs/85xx/sbc8560_defconfig b/arch/powerpc/configs/85xx/sbc8560_defconfig
deleted file mode 100644
index f7fdb0318e4..00000000000
--- a/arch/powerpc/configs/85xx/sbc8560_defconfig
+++ /dev/null
@@ -1,65 +0,0 @@
1CONFIG_PPC_85xx=y
2CONFIG_EXPERIMENTAL=y
3CONFIG_SYSVIPC=y
4CONFIG_LOG_BUF_SHIFT=14
5CONFIG_BLK_DEV_INITRD=y
6# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
7CONFIG_EXPERT=y
8CONFIG_SLAB=y
9# CONFIG_BLK_DEV_BSG is not set
10CONFIG_SBC8560=y
11CONFIG_BINFMT_MISC=y
12CONFIG_SPARSE_IRQ=y
13# CONFIG_SECCOMP is not set
14CONFIG_NET=y
15CONFIG_PACKET=y
16CONFIG_UNIX=y
17CONFIG_XFRM_USER=y
18CONFIG_INET=y
19CONFIG_IP_MULTICAST=y
20CONFIG_IP_PNP=y
21CONFIG_IP_PNP_DHCP=y
22CONFIG_IP_PNP_BOOTP=y
23CONFIG_SYN_COOKIES=y
24# CONFIG_INET_LRO is not set
25# CONFIG_IPV6 is not set
26CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
27# CONFIG_FW_LOADER is not set
28CONFIG_PROC_DEVICETREE=y
29CONFIG_BLK_DEV_LOOP=y
30CONFIG_BLK_DEV_RAM=y
31CONFIG_BLK_DEV_RAM_SIZE=32768
32CONFIG_NETDEVICES=y
33CONFIG_BROADCOM_PHY=y
34CONFIG_NET_ETHERNET=y
35CONFIG_MII=y
36CONFIG_GIANFAR=y
37# CONFIG_INPUT_MOUSEDEV is not set
38# CONFIG_INPUT_KEYBOARD is not set
39# CONFIG_INPUT_MOUSE is not set
40# CONFIG_SERIO is not set
41# CONFIG_VT is not set
42CONFIG_SERIAL_8250=y
43CONFIG_SERIAL_8250_CONSOLE=y
44CONFIG_SERIAL_8250_NR_UARTS=2
45CONFIG_SERIAL_8250_RUNTIME_UARTS=2
46# CONFIG_HW_RANDOM is not set
47CONFIG_VIDEO_OUTPUT_CONTROL=y
48CONFIG_RTC_CLASS=y
49CONFIG_RTC_DRV_M48T59=y
50CONFIG_INOTIFY=y
51CONFIG_PROC_KCORE=y
52CONFIG_TMPFS=y
53CONFIG_NFS_FS=y
54CONFIG_ROOT_NFS=y
55CONFIG_PARTITION_ADVANCED=y
56# CONFIG_MSDOS_PARTITION is not set
57CONFIG_MAGIC_SYSRQ=y
58CONFIG_DEBUG_KERNEL=y
59CONFIG_DETECT_HUNG_TASK=y
60CONFIG_DEBUG_MUTEXES=y
61# CONFIG_DEBUG_BUGVERBOSE is not set
62# CONFIG_RCU_CPU_STALL_DETECTOR is not set
63CONFIG_SYSCTL_SYSCALL_CHECK=y
64CONFIG_PPC_EARLY_DEBUG=y
65# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/powerpc/configs/chroma_defconfig b/arch/powerpc/configs/chroma_defconfig
index b1f9597fe31..29bb11ec6c6 100644
--- a/arch/powerpc/configs/chroma_defconfig
+++ b/arch/powerpc/configs/chroma_defconfig
@@ -21,8 +21,8 @@ CONFIG_CGROUP_DEVICE=y
21CONFIG_CPUSETS=y 21CONFIG_CPUSETS=y
22CONFIG_CGROUP_CPUACCT=y 22CONFIG_CGROUP_CPUACCT=y
23CONFIG_RESOURCE_COUNTERS=y 23CONFIG_RESOURCE_COUNTERS=y
24CONFIG_CGROUP_MEM_RES_CTLR=y 24CONFIG_CGROUP_MEMCG=y
25CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y 25CONFIG_CGROUP_MEMCG_SWAP=y
26CONFIG_NAMESPACES=y 26CONFIG_NAMESPACES=y
27CONFIG_RELAY=y 27CONFIG_RELAY=y
28CONFIG_BLK_DEV_INITRD=y 28CONFIG_BLK_DEV_INITRD=y
diff --git a/arch/powerpc/configs/corenet32_smp_defconfig b/arch/powerpc/configs/corenet32_smp_defconfig
index 91db656294e..8b3d57c1ebe 100644
--- a/arch/powerpc/configs/corenet32_smp_defconfig
+++ b/arch/powerpc/configs/corenet32_smp_defconfig
@@ -6,8 +6,8 @@ CONFIG_SYSVIPC=y
6CONFIG_POSIX_MQUEUE=y 6CONFIG_POSIX_MQUEUE=y
7CONFIG_BSD_PROCESS_ACCT=y 7CONFIG_BSD_PROCESS_ACCT=y
8CONFIG_AUDIT=y 8CONFIG_AUDIT=y
9CONFIG_SPARSE_IRQ=y 9CONFIG_NO_HZ=y
10CONFIG_RCU_TRACE=y 10CONFIG_HIGH_RES_TIMERS=y
11CONFIG_IKCONFIG=y 11CONFIG_IKCONFIG=y
12CONFIG_IKCONFIG_PROC=y 12CONFIG_IKCONFIG_PROC=y
13CONFIG_LOG_BUF_SHIFT=14 13CONFIG_LOG_BUF_SHIFT=14
@@ -21,22 +21,22 @@ CONFIG_MODULE_UNLOAD=y
21CONFIG_MODULE_FORCE_UNLOAD=y 21CONFIG_MODULE_FORCE_UNLOAD=y
22CONFIG_MODVERSIONS=y 22CONFIG_MODVERSIONS=y
23# CONFIG_BLK_DEV_BSG is not set 23# CONFIG_BLK_DEV_BSG is not set
24CONFIG_PARTITION_ADVANCED=y
25CONFIG_MAC_PARTITION=y
24CONFIG_P2041_RDB=y 26CONFIG_P2041_RDB=y
25CONFIG_P3041_DS=y 27CONFIG_P3041_DS=y
26CONFIG_P3060_QDS=y
27CONFIG_P4080_DS=y 28CONFIG_P4080_DS=y
28CONFIG_P5020_DS=y 29CONFIG_P5020_DS=y
29CONFIG_HIGHMEM=y 30CONFIG_HIGHMEM=y
30CONFIG_NO_HZ=y
31CONFIG_HIGH_RES_TIMERS=y
32# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set 31# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
33CONFIG_BINFMT_MISC=m 32CONFIG_BINFMT_MISC=m
34CONFIG_KEXEC=y 33CONFIG_KEXEC=y
34CONFIG_IRQ_ALL_CPUS=y
35CONFIG_FORCE_MAX_ZONEORDER=13 35CONFIG_FORCE_MAX_ZONEORDER=13
36CONFIG_FSL_LBC=y
37CONFIG_PCI=y 36CONFIG_PCI=y
38CONFIG_PCIEPORTBUS=y 37CONFIG_PCIEPORTBUS=y
39# CONFIG_PCIEASPM is not set 38# CONFIG_PCIEASPM is not set
39CONFIG_PCI_MSI=y
40CONFIG_RAPIDIO=y 40CONFIG_RAPIDIO=y
41CONFIG_FSL_RIO=y 41CONFIG_FSL_RIO=y
42CONFIG_NET=y 42CONFIG_NET=y
@@ -69,6 +69,7 @@ CONFIG_INET_IPCOMP=y
69CONFIG_IPV6=y 69CONFIG_IPV6=y
70CONFIG_IP_SCTP=m 70CONFIG_IP_SCTP=m
71CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 71CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
72CONFIG_DEVTMPFS=y
72CONFIG_MTD=y 73CONFIG_MTD=y
73CONFIG_MTD_CMDLINE_PARTS=y 74CONFIG_MTD_CMDLINE_PARTS=y
74CONFIG_MTD_CHAR=y 75CONFIG_MTD_CHAR=y
@@ -77,11 +78,13 @@ CONFIG_MTD_CFI=y
77CONFIG_MTD_CFI_AMDSTD=y 78CONFIG_MTD_CFI_AMDSTD=y
78CONFIG_MTD_PHYSMAP_OF=y 79CONFIG_MTD_PHYSMAP_OF=y
79CONFIG_MTD_M25P80=y 80CONFIG_MTD_M25P80=y
81CONFIG_MTD_NAND=y
82CONFIG_MTD_NAND_FSL_ELBC=y
83CONFIG_MTD_NAND_FSL_IFC=y
80CONFIG_PROC_DEVICETREE=y 84CONFIG_PROC_DEVICETREE=y
81CONFIG_BLK_DEV_LOOP=y 85CONFIG_BLK_DEV_LOOP=y
82CONFIG_BLK_DEV_RAM=y 86CONFIG_BLK_DEV_RAM=y
83CONFIG_BLK_DEV_RAM_SIZE=131072 87CONFIG_BLK_DEV_RAM_SIZE=131072
84CONFIG_MISC_DEVICES=y
85CONFIG_BLK_DEV_SD=y 88CONFIG_BLK_DEV_SD=y
86CONFIG_CHR_DEV_ST=y 89CONFIG_CHR_DEV_ST=y
87CONFIG_BLK_DEV_SR=y 90CONFIG_BLK_DEV_SR=y
@@ -109,11 +112,9 @@ CONFIG_SERIO_LIBPS2=y
109CONFIG_PPC_EPAPR_HV_BYTECHAN=y 112CONFIG_PPC_EPAPR_HV_BYTECHAN=y
110CONFIG_SERIAL_8250=y 113CONFIG_SERIAL_8250=y
111CONFIG_SERIAL_8250_CONSOLE=y 114CONFIG_SERIAL_8250_CONSOLE=y
112CONFIG_SERIAL_8250_EXTENDED=y
113CONFIG_SERIAL_8250_MANY_PORTS=y 115CONFIG_SERIAL_8250_MANY_PORTS=y
114CONFIG_SERIAL_8250_DETECT_IRQ=y 116CONFIG_SERIAL_8250_DETECT_IRQ=y
115CONFIG_SERIAL_8250_RSA=y 117CONFIG_SERIAL_8250_RSA=y
116CONFIG_HW_RANDOM=y
117CONFIG_NVRAM=y 118CONFIG_NVRAM=y
118CONFIG_I2C=y 119CONFIG_I2C=y
119CONFIG_I2C_CHARDEV=y 120CONFIG_I2C_CHARDEV=y
@@ -126,7 +127,6 @@ CONFIG_SPI_FSL_ESPI=y
126CONFIG_VIDEO_OUTPUT_CONTROL=y 127CONFIG_VIDEO_OUTPUT_CONTROL=y
127CONFIG_USB_HID=m 128CONFIG_USB_HID=m
128CONFIG_USB=y 129CONFIG_USB=y
129CONFIG_USB_DEVICEFS=y
130CONFIG_USB_MON=y 130CONFIG_USB_MON=y
131CONFIG_USB_EHCI_HCD=y 131CONFIG_USB_EHCI_HCD=y
132CONFIG_USB_EHCI_FSL=y 132CONFIG_USB_EHCI_FSL=y
@@ -162,19 +162,16 @@ CONFIG_HUGETLBFS=y
162CONFIG_JFFS2_FS=y 162CONFIG_JFFS2_FS=y
163CONFIG_CRAMFS=y 163CONFIG_CRAMFS=y
164CONFIG_NFS_FS=y 164CONFIG_NFS_FS=y
165CONFIG_NFS_V3=y
166CONFIG_NFS_V4=y 165CONFIG_NFS_V4=y
167CONFIG_ROOT_NFS=y 166CONFIG_ROOT_NFS=y
168CONFIG_NFSD=m 167CONFIG_NFSD=m
169CONFIG_PARTITION_ADVANCED=y
170CONFIG_MAC_PARTITION=y
171CONFIG_NLS_ISO8859_1=y 168CONFIG_NLS_ISO8859_1=y
172CONFIG_NLS_UTF8=m 169CONFIG_NLS_UTF8=m
173CONFIG_MAGIC_SYSRQ=y 170CONFIG_MAGIC_SYSRQ=y
174CONFIG_DEBUG_SHIRQ=y 171CONFIG_DEBUG_SHIRQ=y
175CONFIG_DETECT_HUNG_TASK=y 172CONFIG_DETECT_HUNG_TASK=y
176CONFIG_DEBUG_INFO=y 173CONFIG_DEBUG_INFO=y
177CONFIG_SYSCTL_SYSCALL_CHECK=y 174CONFIG_RCU_TRACE=y
178CONFIG_CRYPTO_NULL=y 175CONFIG_CRYPTO_NULL=y
179CONFIG_CRYPTO_PCBC=m 176CONFIG_CRYPTO_PCBC=m
180CONFIG_CRYPTO_MD4=y 177CONFIG_CRYPTO_MD4=y
diff --git a/arch/powerpc/configs/corenet64_smp_defconfig b/arch/powerpc/configs/corenet64_smp_defconfig
index 6798343580f..0516e22ca3d 100644
--- a/arch/powerpc/configs/corenet64_smp_defconfig
+++ b/arch/powerpc/configs/corenet64_smp_defconfig
@@ -6,7 +6,9 @@ CONFIG_NR_CPUS=2
6CONFIG_EXPERIMENTAL=y 6CONFIG_EXPERIMENTAL=y
7CONFIG_SYSVIPC=y 7CONFIG_SYSVIPC=y
8CONFIG_BSD_PROCESS_ACCT=y 8CONFIG_BSD_PROCESS_ACCT=y
9CONFIG_SPARSE_IRQ=y 9CONFIG_IRQ_DOMAIN_DEBUG=y
10CONFIG_NO_HZ=y
11CONFIG_HIGH_RES_TIMERS=y
10CONFIG_IKCONFIG=y 12CONFIG_IKCONFIG=y
11CONFIG_IKCONFIG_PROC=y 13CONFIG_IKCONFIG_PROC=y
12CONFIG_LOG_BUF_SHIFT=14 14CONFIG_LOG_BUF_SHIFT=14
@@ -18,11 +20,14 @@ CONFIG_MODULE_UNLOAD=y
18CONFIG_MODULE_FORCE_UNLOAD=y 20CONFIG_MODULE_FORCE_UNLOAD=y
19CONFIG_MODVERSIONS=y 21CONFIG_MODVERSIONS=y
20# CONFIG_BLK_DEV_BSG is not set 22# CONFIG_BLK_DEV_BSG is not set
23CONFIG_PARTITION_ADVANCED=y
24CONFIG_MAC_PARTITION=y
21CONFIG_P5020_DS=y 25CONFIG_P5020_DS=y
22# CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set 26# CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set
23CONFIG_NO_HZ=y
24CONFIG_HIGH_RES_TIMERS=y
25CONFIG_BINFMT_MISC=m 27CONFIG_BINFMT_MISC=m
28CONFIG_IRQ_ALL_CPUS=y
29CONFIG_PCIEPORTBUS=y
30CONFIG_PCI_MSI=y
26CONFIG_RAPIDIO=y 31CONFIG_RAPIDIO=y
27CONFIG_FSL_RIO=y 32CONFIG_FSL_RIO=y
28CONFIG_NET=y 33CONFIG_NET=y
@@ -51,12 +56,26 @@ CONFIG_INET_ESP=y
51CONFIG_IPV6=y 56CONFIG_IPV6=y
52CONFIG_IP_SCTP=m 57CONFIG_IP_SCTP=m
53CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 58CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
59CONFIG_DEVTMPFS=y
60CONFIG_MTD=y
61CONFIG_MTD_CMDLINE_PARTS=y
62CONFIG_MTD_CHAR=y
63CONFIG_MTD_BLOCK=y
64CONFIG_MTD_CFI=y
65CONFIG_MTD_CFI_AMDSTD=y
66CONFIG_MTD_PHYSMAP_OF=y
67CONFIG_MTD_M25P80=y
68CONFIG_MTD_NAND=y
69CONFIG_MTD_NAND_FSL_ELBC=y
70CONFIG_MTD_NAND_FSL_IFC=y
54CONFIG_PROC_DEVICETREE=y 71CONFIG_PROC_DEVICETREE=y
55CONFIG_BLK_DEV_LOOP=y 72CONFIG_BLK_DEV_LOOP=y
56CONFIG_BLK_DEV_RAM=y 73CONFIG_BLK_DEV_RAM=y
57CONFIG_BLK_DEV_RAM_SIZE=131072 74CONFIG_BLK_DEV_RAM_SIZE=131072
58CONFIG_MISC_DEVICES=y
59CONFIG_EEPROM_LEGACY=y 75CONFIG_EEPROM_LEGACY=y
76CONFIG_ATA=y
77CONFIG_SATA_FSL=y
78CONFIG_SATA_SIL24=y
60CONFIG_NETDEVICES=y 79CONFIG_NETDEVICES=y
61CONFIG_DUMMY=y 80CONFIG_DUMMY=y
62CONFIG_INPUT_FF_MEMLESS=m 81CONFIG_INPUT_FF_MEMLESS=m
@@ -66,39 +85,59 @@ CONFIG_INPUT_FF_MEMLESS=m
66CONFIG_SERIO_LIBPS2=y 85CONFIG_SERIO_LIBPS2=y
67CONFIG_SERIAL_8250=y 86CONFIG_SERIAL_8250=y
68CONFIG_SERIAL_8250_CONSOLE=y 87CONFIG_SERIAL_8250_CONSOLE=y
69CONFIG_SERIAL_8250_EXTENDED=y
70CONFIG_SERIAL_8250_MANY_PORTS=y 88CONFIG_SERIAL_8250_MANY_PORTS=y
71CONFIG_SERIAL_8250_DETECT_IRQ=y 89CONFIG_SERIAL_8250_DETECT_IRQ=y
72CONFIG_SERIAL_8250_RSA=y 90CONFIG_SERIAL_8250_RSA=y
73CONFIG_I2C=y 91CONFIG_I2C=y
74CONFIG_I2C_CHARDEV=y 92CONFIG_I2C_CHARDEV=y
75CONFIG_I2C_MPC=y 93CONFIG_I2C_MPC=y
94CONFIG_SPI=y
95CONFIG_SPI_GPIO=y
96CONFIG_SPI_FSL_SPI=y
97CONFIG_SPI_FSL_ESPI=y
76# CONFIG_HWMON is not set 98# CONFIG_HWMON is not set
77CONFIG_VIDEO_OUTPUT_CONTROL=y 99CONFIG_VIDEO_OUTPUT_CONTROL=y
78# CONFIG_HID_SUPPORT is not set 100CONFIG_USB_HID=m
79# CONFIG_USB_SUPPORT is not set 101CONFIG_USB=y
102CONFIG_USB_MON=y
103CONFIG_USB_EHCI_HCD=y
104CONFIG_USB_EHCI_FSL=y
105CONFIG_USB_STORAGE=y
106CONFIG_MMC=y
107CONFIG_MMC_SDHCI=y
108CONFIG_EDAC=y
109CONFIG_EDAC_MM_EDAC=y
80CONFIG_DMADEVICES=y 110CONFIG_DMADEVICES=y
81CONFIG_FSL_DMA=y 111CONFIG_FSL_DMA=y
82CONFIG_EXT2_FS=y 112CONFIG_EXT2_FS=y
83CONFIG_EXT3_FS=y 113CONFIG_EXT3_FS=y
84# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 114CONFIG_ISO9660_FS=m
115CONFIG_JOLIET=y
116CONFIG_ZISOFS=y
117CONFIG_UDF_FS=m
118CONFIG_MSDOS_FS=m
119CONFIG_VFAT_FS=y
120CONFIG_NTFS_FS=y
85CONFIG_PROC_KCORE=y 121CONFIG_PROC_KCORE=y
86CONFIG_TMPFS=y 122CONFIG_TMPFS=y
87CONFIG_HUGETLBFS=y 123CONFIG_HUGETLBFS=y
88# CONFIG_MISC_FILESYSTEMS is not set 124# CONFIG_MISC_FILESYSTEMS is not set
89CONFIG_PARTITION_ADVANCED=y 125CONFIG_NFS_FS=y
90CONFIG_MAC_PARTITION=y 126CONFIG_NFS_V4=y
91CONFIG_NLS=y 127CONFIG_ROOT_NFS=y
128CONFIG_NFSD=m
129CONFIG_NLS_ISO8859_1=y
92CONFIG_NLS_UTF8=m 130CONFIG_NLS_UTF8=m
93CONFIG_CRC_T10DIF=y 131CONFIG_CRC_T10DIF=y
94CONFIG_CRC_ITU_T=m
95CONFIG_FRAME_WARN=1024 132CONFIG_FRAME_WARN=1024
133CONFIG_MAGIC_SYSRQ=y
96CONFIG_DEBUG_FS=y 134CONFIG_DEBUG_FS=y
135CONFIG_DEBUG_SHIRQ=y
97CONFIG_DETECT_HUNG_TASK=y 136CONFIG_DETECT_HUNG_TASK=y
98CONFIG_DEBUG_INFO=y 137CONFIG_DEBUG_INFO=y
99CONFIG_SYSCTL_SYSCALL_CHECK=y 138CONFIG_CRYPTO_NULL=y
100CONFIG_IRQ_DOMAIN_DEBUG=y
101CONFIG_CRYPTO_PCBC=m 139CONFIG_CRYPTO_PCBC=m
140CONFIG_CRYPTO_MD4=y
102CONFIG_CRYPTO_SHA256=y 141CONFIG_CRYPTO_SHA256=y
103CONFIG_CRYPTO_SHA512=y 142CONFIG_CRYPTO_SHA512=y
104CONFIG_CRYPTO_AES=y 143CONFIG_CRYPTO_AES=y
diff --git a/arch/powerpc/configs/mgcoge_defconfig b/arch/powerpc/configs/mgcoge_defconfig
index 0d36b0e1e26..8fa84f156ef 100644
--- a/arch/powerpc/configs/mgcoge_defconfig
+++ b/arch/powerpc/configs/mgcoge_defconfig
@@ -2,7 +2,6 @@ CONFIG_EXPERIMENTAL=y
2# CONFIG_SWAP is not set 2# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y 3CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 4CONFIG_POSIX_MQUEUE=y
5CONFIG_SPARSE_IRQ=y
6CONFIG_IKCONFIG=y 5CONFIG_IKCONFIG=y
7CONFIG_IKCONFIG_PROC=y 6CONFIG_IKCONFIG_PROC=y
8CONFIG_LOG_BUF_SHIFT=14 7CONFIG_LOG_BUF_SHIFT=14
@@ -12,6 +11,7 @@ CONFIG_KALLSYMS_ALL=y
12# CONFIG_PCSPKR_PLATFORM is not set 11# CONFIG_PCSPKR_PLATFORM is not set
13CONFIG_EMBEDDED=y 12CONFIG_EMBEDDED=y
14CONFIG_SLAB=y 13CONFIG_SLAB=y
14CONFIG_PARTITION_ADVANCED=y
15# CONFIG_IOSCHED_CFQ is not set 15# CONFIG_IOSCHED_CFQ is not set
16# CONFIG_PPC_PMAC is not set 16# CONFIG_PPC_PMAC is not set
17CONFIG_PPC_82xx=y 17CONFIG_PPC_82xx=y
@@ -49,12 +49,9 @@ CONFIG_PROC_DEVICETREE=y
49CONFIG_BLK_DEV_LOOP=y 49CONFIG_BLK_DEV_LOOP=y
50CONFIG_BLK_DEV_RAM=y 50CONFIG_BLK_DEV_RAM=y
51CONFIG_NETDEVICES=y 51CONFIG_NETDEVICES=y
52CONFIG_FIXED_PHY=y
53CONFIG_NET_ETHERNET=y
54CONFIG_FS_ENET=y 52CONFIG_FS_ENET=y
55CONFIG_FS_ENET_MDIO_FCC=y 53CONFIG_FS_ENET_MDIO_FCC=y
56# CONFIG_NETDEV_1000 is not set 54CONFIG_FIXED_PHY=y
57# CONFIG_NETDEV_10000 is not set
58# CONFIG_WLAN is not set 55# CONFIG_WLAN is not set
59# CONFIG_INPUT is not set 56# CONFIG_INPUT is not set
60# CONFIG_SERIO is not set 57# CONFIG_SERIO is not set
@@ -64,6 +61,8 @@ CONFIG_SERIAL_CPM_CONSOLE=y
64CONFIG_I2C=y 61CONFIG_I2C=y
65CONFIG_I2C_CHARDEV=y 62CONFIG_I2C_CHARDEV=y
66CONFIG_I2C_CPM=y 63CONFIG_I2C_CPM=y
64CONFIG_SPI=y
65CONFIG_SPI_FSL_SPI=y
67# CONFIG_HWMON is not set 66# CONFIG_HWMON is not set
68CONFIG_USB_GADGET=y 67CONFIG_USB_GADGET=y
69CONFIG_USB_FSL_USB2=y 68CONFIG_USB_FSL_USB2=y
@@ -80,8 +79,6 @@ CONFIG_SQUASHFS=y
80CONFIG_NFS_FS=y 79CONFIG_NFS_FS=y
81CONFIG_NFS_V3=y 80CONFIG_NFS_V3=y
82CONFIG_ROOT_NFS=y 81CONFIG_ROOT_NFS=y
83CONFIG_PARTITION_ADVANCED=y
84CONFIG_NLS=y
85CONFIG_NLS_CODEPAGE_437=y 82CONFIG_NLS_CODEPAGE_437=y
86CONFIG_NLS_ASCII=y 83CONFIG_NLS_ASCII=y
87CONFIG_NLS_ISO8859_1=y 84CONFIG_NLS_ISO8859_1=y
@@ -90,7 +87,6 @@ CONFIG_MAGIC_SYSRQ=y
90CONFIG_DEBUG_FS=y 87CONFIG_DEBUG_FS=y
91# CONFIG_SCHED_DEBUG is not set 88# CONFIG_SCHED_DEBUG is not set
92CONFIG_DEBUG_INFO=y 89CONFIG_DEBUG_INFO=y
93CONFIG_SYSCTL_SYSCALL_CHECK=y
94CONFIG_BDI_SWITCH=y 90CONFIG_BDI_SWITCH=y
95CONFIG_CRYPTO_ECB=y 91CONFIG_CRYPTO_ECB=y
96CONFIG_CRYPTO_PCBC=y 92CONFIG_CRYPTO_PCBC=y
diff --git a/arch/powerpc/configs/mpc83xx_defconfig b/arch/powerpc/configs/mpc83xx_defconfig
index 5aac9a8bc53..9352e4430c3 100644
--- a/arch/powerpc/configs/mpc83xx_defconfig
+++ b/arch/powerpc/configs/mpc83xx_defconfig
@@ -2,12 +2,12 @@ CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
3CONFIG_LOG_BUF_SHIFT=14 3CONFIG_LOG_BUF_SHIFT=14
4CONFIG_BLK_DEV_INITRD=y 4CONFIG_BLK_DEV_INITRD=y
5# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
6CONFIG_EXPERT=y 5CONFIG_EXPERT=y
7CONFIG_SLAB=y 6CONFIG_SLAB=y
8CONFIG_MODULES=y 7CONFIG_MODULES=y
9CONFIG_MODULE_UNLOAD=y 8CONFIG_MODULE_UNLOAD=y
10# CONFIG_BLK_DEV_BSG is not set 9# CONFIG_BLK_DEV_BSG is not set
10CONFIG_PARTITION_ADVANCED=y
11# CONFIG_PPC_CHRP is not set 11# CONFIG_PPC_CHRP is not set
12# CONFIG_PPC_PMAC is not set 12# CONFIG_PPC_PMAC is not set
13CONFIG_PPC_83xx=y 13CONFIG_PPC_83xx=y
@@ -25,7 +25,6 @@ CONFIG_ASP834x=y
25CONFIG_QUICC_ENGINE=y 25CONFIG_QUICC_ENGINE=y
26CONFIG_QE_GPIO=y 26CONFIG_QE_GPIO=y
27CONFIG_MATH_EMULATION=y 27CONFIG_MATH_EMULATION=y
28CONFIG_SPARSE_IRQ=y
29CONFIG_PCI=y 28CONFIG_PCI=y
30CONFIG_NET=y 29CONFIG_NET=y
31CONFIG_PACKET=y 30CONFIG_PACKET=y
@@ -42,10 +41,9 @@ CONFIG_INET_ESP=y
42# CONFIG_INET_LRO is not set 41# CONFIG_INET_LRO is not set
43# CONFIG_IPV6 is not set 42# CONFIG_IPV6 is not set
44CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 43CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
44CONFIG_DEVTMPFS=y
45# CONFIG_FW_LOADER is not set 45# CONFIG_FW_LOADER is not set
46CONFIG_MTD=y 46CONFIG_MTD=y
47CONFIG_MTD_PARTITIONS=y
48CONFIG_MTD_OF_PARTS=y
49CONFIG_MTD_CHAR=y 47CONFIG_MTD_CHAR=y
50CONFIG_MTD_BLOCK=y 48CONFIG_MTD_BLOCK=y
51CONFIG_MTD_CFI=y 49CONFIG_MTD_CFI=y
@@ -64,15 +62,14 @@ CONFIG_ATA=y
64CONFIG_SATA_FSL=y 62CONFIG_SATA_FSL=y
65CONFIG_SATA_SIL=y 63CONFIG_SATA_SIL=y
66CONFIG_NETDEVICES=y 64CONFIG_NETDEVICES=y
65CONFIG_MII=y
66CONFIG_UCC_GETH=y
67CONFIG_GIANFAR=y
67CONFIG_MARVELL_PHY=y 68CONFIG_MARVELL_PHY=y
68CONFIG_DAVICOM_PHY=y 69CONFIG_DAVICOM_PHY=y
69CONFIG_VITESSE_PHY=y 70CONFIG_VITESSE_PHY=y
70CONFIG_ICPLUS_PHY=y 71CONFIG_ICPLUS_PHY=y
71CONFIG_FIXED_PHY=y 72CONFIG_FIXED_PHY=y
72CONFIG_NET_ETHERNET=y
73CONFIG_MII=y
74CONFIG_GIANFAR=y
75CONFIG_UCC_GETH=y
76CONFIG_INPUT_FF_MEMLESS=m 73CONFIG_INPUT_FF_MEMLESS=m
77# CONFIG_INPUT_MOUSEDEV is not set 74# CONFIG_INPUT_MOUSEDEV is not set
78# CONFIG_INPUT_KEYBOARD is not set 75# CONFIG_INPUT_KEYBOARD is not set
@@ -112,17 +109,12 @@ CONFIG_RTC_DRV_DS1374=y
112CONFIG_EXT2_FS=y 109CONFIG_EXT2_FS=y
113CONFIG_EXT3_FS=y 110CONFIG_EXT3_FS=y
114# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 111# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
115CONFIG_INOTIFY=y
116CONFIG_PROC_KCORE=y 112CONFIG_PROC_KCORE=y
117CONFIG_TMPFS=y 113CONFIG_TMPFS=y
118CONFIG_NFS_FS=y 114CONFIG_NFS_FS=y
119CONFIG_NFS_V3=y
120CONFIG_NFS_V4=y 115CONFIG_NFS_V4=y
121CONFIG_ROOT_NFS=y 116CONFIG_ROOT_NFS=y
122CONFIG_PARTITION_ADVANCED=y
123CONFIG_CRC_T10DIF=y 117CONFIG_CRC_T10DIF=y
124# CONFIG_RCU_CPU_STALL_DETECTOR is not set
125CONFIG_SYSCTL_SYSCALL_CHECK=y
126CONFIG_CRYPTO_ECB=m 118CONFIG_CRYPTO_ECB=m
127CONFIG_CRYPTO_PCBC=m 119CONFIG_CRYPTO_PCBC=m
128CONFIG_CRYPTO_SHA256=y 120CONFIG_CRYPTO_SHA256=y
diff --git a/arch/powerpc/configs/mpc85xx_defconfig b/arch/powerpc/configs/mpc85xx_defconfig
index 62bb723c5b5..8b5bda27d24 100644
--- a/arch/powerpc/configs/mpc85xx_defconfig
+++ b/arch/powerpc/configs/mpc85xx_defconfig
@@ -5,7 +5,9 @@ CONFIG_SYSVIPC=y
5CONFIG_POSIX_MQUEUE=y 5CONFIG_POSIX_MQUEUE=y
6CONFIG_BSD_PROCESS_ACCT=y 6CONFIG_BSD_PROCESS_ACCT=y
7CONFIG_AUDIT=y 7CONFIG_AUDIT=y
8CONFIG_SPARSE_IRQ=y 8CONFIG_IRQ_DOMAIN_DEBUG=y
9CONFIG_NO_HZ=y
10CONFIG_HIGH_RES_TIMERS=y
9CONFIG_IKCONFIG=y 11CONFIG_IKCONFIG=y
10CONFIG_IKCONFIG_PROC=y 12CONFIG_IKCONFIG_PROC=y
11CONFIG_LOG_BUF_SHIFT=14 13CONFIG_LOG_BUF_SHIFT=14
@@ -17,6 +19,8 @@ CONFIG_MODULE_UNLOAD=y
17CONFIG_MODULE_FORCE_UNLOAD=y 19CONFIG_MODULE_FORCE_UNLOAD=y
18CONFIG_MODVERSIONS=y 20CONFIG_MODVERSIONS=y
19# CONFIG_BLK_DEV_BSG is not set 21# CONFIG_BLK_DEV_BSG is not set
22CONFIG_PARTITION_ADVANCED=y
23CONFIG_MAC_PARTITION=y
20CONFIG_MPC8540_ADS=y 24CONFIG_MPC8540_ADS=y
21CONFIG_MPC8560_ADS=y 25CONFIG_MPC8560_ADS=y
22CONFIG_MPC85xx_CDS=y 26CONFIG_MPC85xx_CDS=y
@@ -40,8 +44,6 @@ CONFIG_SBC8548=y
40CONFIG_QUICC_ENGINE=y 44CONFIG_QUICC_ENGINE=y
41CONFIG_QE_GPIO=y 45CONFIG_QE_GPIO=y
42CONFIG_HIGHMEM=y 46CONFIG_HIGHMEM=y
43CONFIG_NO_HZ=y
44CONFIG_HIGH_RES_TIMERS=y
45CONFIG_BINFMT_MISC=m 47CONFIG_BINFMT_MISC=m
46CONFIG_MATH_EMULATION=y 48CONFIG_MATH_EMULATION=y
47CONFIG_FORCE_MAX_ZONEORDER=12 49CONFIG_FORCE_MAX_ZONEORDER=12
@@ -74,12 +76,25 @@ CONFIG_INET_ESP=y
74CONFIG_IPV6=y 76CONFIG_IPV6=y
75CONFIG_IP_SCTP=m 77CONFIG_IP_SCTP=m
76CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 78CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
79CONFIG_DEVTMPFS=y
80CONFIG_MTD=y
81CONFIG_MTD_CMDLINE_PARTS=y
82CONFIG_MTD_CHAR=y
83CONFIG_MTD_BLOCK=y
84CONFIG_FTL=y
85CONFIG_MTD_CFI=y
86CONFIG_MTD_CFI_INTELEXT=y
87CONFIG_MTD_CFI_AMDSTD=y
88CONFIG_MTD_PHYSMAP_OF=y
89CONFIG_MTD_M25P80=y
90CONFIG_MTD_NAND=y
91CONFIG_MTD_NAND_FSL_ELBC=y
92CONFIG_MTD_NAND_FSL_IFC=y
77CONFIG_PROC_DEVICETREE=y 93CONFIG_PROC_DEVICETREE=y
78CONFIG_BLK_DEV_LOOP=y 94CONFIG_BLK_DEV_LOOP=y
79CONFIG_BLK_DEV_NBD=y 95CONFIG_BLK_DEV_NBD=y
80CONFIG_BLK_DEV_RAM=y 96CONFIG_BLK_DEV_RAM=y
81CONFIG_BLK_DEV_RAM_SIZE=131072 97CONFIG_BLK_DEV_RAM_SIZE=131072
82CONFIG_MISC_DEVICES=y
83CONFIG_EEPROM_LEGACY=y 98CONFIG_EEPROM_LEGACY=y
84CONFIG_BLK_DEV_SD=y 99CONFIG_BLK_DEV_SD=y
85CONFIG_CHR_DEV_ST=y 100CONFIG_CHR_DEV_ST=y
@@ -91,6 +106,7 @@ CONFIG_ATA=y
91CONFIG_SATA_AHCI=y 106CONFIG_SATA_AHCI=y
92CONFIG_SATA_FSL=y 107CONFIG_SATA_FSL=y
93CONFIG_PATA_ALI=y 108CONFIG_PATA_ALI=y
109CONFIG_PATA_VIA=y
94CONFIG_NETDEVICES=y 110CONFIG_NETDEVICES=y
95CONFIG_DUMMY=y 111CONFIG_DUMMY=y
96CONFIG_FS_ENET=y 112CONFIG_FS_ENET=y
@@ -110,7 +126,6 @@ CONFIG_SERIAL_8250=y
110CONFIG_SERIAL_8250_CONSOLE=y 126CONFIG_SERIAL_8250_CONSOLE=y
111CONFIG_SERIAL_8250_NR_UARTS=2 127CONFIG_SERIAL_8250_NR_UARTS=2
112CONFIG_SERIAL_8250_RUNTIME_UARTS=2 128CONFIG_SERIAL_8250_RUNTIME_UARTS=2
113CONFIG_SERIAL_8250_EXTENDED=y
114CONFIG_SERIAL_8250_MANY_PORTS=y 129CONFIG_SERIAL_8250_MANY_PORTS=y
115CONFIG_SERIAL_8250_DETECT_IRQ=y 130CONFIG_SERIAL_8250_DETECT_IRQ=y
116CONFIG_SERIAL_8250_RSA=y 131CONFIG_SERIAL_8250_RSA=y
@@ -159,7 +174,6 @@ CONFIG_HID_SAMSUNG=y
159CONFIG_HID_SONY=y 174CONFIG_HID_SONY=y
160CONFIG_HID_SUNPLUS=y 175CONFIG_HID_SUNPLUS=y
161CONFIG_USB=y 176CONFIG_USB=y
162CONFIG_USB_DEVICEFS=y
163CONFIG_USB_MON=y 177CONFIG_USB_MON=y
164CONFIG_USB_EHCI_HCD=y 178CONFIG_USB_EHCI_HCD=y
165CONFIG_USB_EHCI_FSL=y 179CONFIG_USB_EHCI_FSL=y
@@ -205,18 +219,13 @@ CONFIG_QNX4FS_FS=m
205CONFIG_SYSV_FS=m 219CONFIG_SYSV_FS=m
206CONFIG_UFS_FS=m 220CONFIG_UFS_FS=m
207CONFIG_NFS_FS=y 221CONFIG_NFS_FS=y
208CONFIG_NFS_V3=y
209CONFIG_NFS_V4=y 222CONFIG_NFS_V4=y
210CONFIG_ROOT_NFS=y 223CONFIG_ROOT_NFS=y
211CONFIG_NFSD=y 224CONFIG_NFSD=y
212CONFIG_PARTITION_ADVANCED=y
213CONFIG_MAC_PARTITION=y
214CONFIG_CRC_T10DIF=y 225CONFIG_CRC_T10DIF=y
215CONFIG_DEBUG_FS=y 226CONFIG_DEBUG_FS=y
216CONFIG_DETECT_HUNG_TASK=y 227CONFIG_DETECT_HUNG_TASK=y
217CONFIG_DEBUG_INFO=y 228CONFIG_DEBUG_INFO=y
218CONFIG_SYSCTL_SYSCALL_CHECK=y
219CONFIG_IRQ_DOMAIN_DEBUG=y
220CONFIG_CRYPTO_PCBC=m 229CONFIG_CRYPTO_PCBC=m
221CONFIG_CRYPTO_SHA256=y 230CONFIG_CRYPTO_SHA256=y
222CONFIG_CRYPTO_SHA512=y 231CONFIG_CRYPTO_SHA512=y
diff --git a/arch/powerpc/configs/mpc85xx_smp_defconfig b/arch/powerpc/configs/mpc85xx_smp_defconfig
index d1828427ae5..b0974e7e98a 100644
--- a/arch/powerpc/configs/mpc85xx_smp_defconfig
+++ b/arch/powerpc/configs/mpc85xx_smp_defconfig
@@ -7,7 +7,9 @@ CONFIG_SYSVIPC=y
7CONFIG_POSIX_MQUEUE=y 7CONFIG_POSIX_MQUEUE=y
8CONFIG_BSD_PROCESS_ACCT=y 8CONFIG_BSD_PROCESS_ACCT=y
9CONFIG_AUDIT=y 9CONFIG_AUDIT=y
10CONFIG_SPARSE_IRQ=y 10CONFIG_IRQ_DOMAIN_DEBUG=y
11CONFIG_NO_HZ=y
12CONFIG_HIGH_RES_TIMERS=y
11CONFIG_IKCONFIG=y 13CONFIG_IKCONFIG=y
12CONFIG_IKCONFIG_PROC=y 14CONFIG_IKCONFIG_PROC=y
13CONFIG_LOG_BUF_SHIFT=14 15CONFIG_LOG_BUF_SHIFT=14
@@ -19,6 +21,8 @@ CONFIG_MODULE_UNLOAD=y
19CONFIG_MODULE_FORCE_UNLOAD=y 21CONFIG_MODULE_FORCE_UNLOAD=y
20CONFIG_MODVERSIONS=y 22CONFIG_MODVERSIONS=y
21# CONFIG_BLK_DEV_BSG is not set 23# CONFIG_BLK_DEV_BSG is not set
24CONFIG_PARTITION_ADVANCED=y
25CONFIG_MAC_PARTITION=y
22CONFIG_MPC8540_ADS=y 26CONFIG_MPC8540_ADS=y
23CONFIG_MPC8560_ADS=y 27CONFIG_MPC8560_ADS=y
24CONFIG_MPC85xx_CDS=y 28CONFIG_MPC85xx_CDS=y
@@ -42,10 +46,9 @@ CONFIG_SBC8548=y
42CONFIG_QUICC_ENGINE=y 46CONFIG_QUICC_ENGINE=y
43CONFIG_QE_GPIO=y 47CONFIG_QE_GPIO=y
44CONFIG_HIGHMEM=y 48CONFIG_HIGHMEM=y
45CONFIG_NO_HZ=y
46CONFIG_HIGH_RES_TIMERS=y
47CONFIG_BINFMT_MISC=m 49CONFIG_BINFMT_MISC=m
48CONFIG_MATH_EMULATION=y 50CONFIG_MATH_EMULATION=y
51CONFIG_IRQ_ALL_CPUS=y
49CONFIG_FORCE_MAX_ZONEORDER=12 52CONFIG_FORCE_MAX_ZONEORDER=12
50CONFIG_PCI=y 53CONFIG_PCI=y
51CONFIG_PCI_MSI=y 54CONFIG_PCI_MSI=y
@@ -76,12 +79,25 @@ CONFIG_INET_ESP=y
76CONFIG_IPV6=y 79CONFIG_IPV6=y
77CONFIG_IP_SCTP=m 80CONFIG_IP_SCTP=m
78CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 81CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
82CONFIG_DEVTMPFS=y
83CONFIG_MTD=y
84CONFIG_MTD_CMDLINE_PARTS=y
85CONFIG_MTD_CHAR=y
86CONFIG_MTD_BLOCK=y
87CONFIG_FTL=y
88CONFIG_MTD_CFI=y
89CONFIG_MTD_CFI_INTELEXT=y
90CONFIG_MTD_CFI_AMDSTD=y
91CONFIG_MTD_PHYSMAP_OF=y
92CONFIG_MTD_M25P80=y
93CONFIG_MTD_NAND=y
94CONFIG_MTD_NAND_FSL_ELBC=y
95CONFIG_MTD_NAND_FSL_IFC=y
79CONFIG_PROC_DEVICETREE=y 96CONFIG_PROC_DEVICETREE=y
80CONFIG_BLK_DEV_LOOP=y 97CONFIG_BLK_DEV_LOOP=y
81CONFIG_BLK_DEV_NBD=y 98CONFIG_BLK_DEV_NBD=y
82CONFIG_BLK_DEV_RAM=y 99CONFIG_BLK_DEV_RAM=y
83CONFIG_BLK_DEV_RAM_SIZE=131072 100CONFIG_BLK_DEV_RAM_SIZE=131072
84CONFIG_MISC_DEVICES=y
85CONFIG_EEPROM_LEGACY=y 101CONFIG_EEPROM_LEGACY=y
86CONFIG_BLK_DEV_SD=y 102CONFIG_BLK_DEV_SD=y
87CONFIG_CHR_DEV_ST=y 103CONFIG_CHR_DEV_ST=y
@@ -112,7 +128,6 @@ CONFIG_SERIAL_8250=y
112CONFIG_SERIAL_8250_CONSOLE=y 128CONFIG_SERIAL_8250_CONSOLE=y
113CONFIG_SERIAL_8250_NR_UARTS=2 129CONFIG_SERIAL_8250_NR_UARTS=2
114CONFIG_SERIAL_8250_RUNTIME_UARTS=2 130CONFIG_SERIAL_8250_RUNTIME_UARTS=2
115CONFIG_SERIAL_8250_EXTENDED=y
116CONFIG_SERIAL_8250_MANY_PORTS=y 131CONFIG_SERIAL_8250_MANY_PORTS=y
117CONFIG_SERIAL_8250_DETECT_IRQ=y 132CONFIG_SERIAL_8250_DETECT_IRQ=y
118CONFIG_SERIAL_8250_RSA=y 133CONFIG_SERIAL_8250_RSA=y
@@ -161,7 +176,6 @@ CONFIG_HID_SAMSUNG=y
161CONFIG_HID_SONY=y 176CONFIG_HID_SONY=y
162CONFIG_HID_SUNPLUS=y 177CONFIG_HID_SUNPLUS=y
163CONFIG_USB=y 178CONFIG_USB=y
164CONFIG_USB_DEVICEFS=y
165CONFIG_USB_MON=y 179CONFIG_USB_MON=y
166CONFIG_USB_EHCI_HCD=y 180CONFIG_USB_EHCI_HCD=y
167CONFIG_USB_EHCI_FSL=y 181CONFIG_USB_EHCI_FSL=y
@@ -207,18 +221,13 @@ CONFIG_QNX4FS_FS=m
207CONFIG_SYSV_FS=m 221CONFIG_SYSV_FS=m
208CONFIG_UFS_FS=m 222CONFIG_UFS_FS=m
209CONFIG_NFS_FS=y 223CONFIG_NFS_FS=y
210CONFIG_NFS_V3=y
211CONFIG_NFS_V4=y 224CONFIG_NFS_V4=y
212CONFIG_ROOT_NFS=y 225CONFIG_ROOT_NFS=y
213CONFIG_NFSD=y 226CONFIG_NFSD=y
214CONFIG_PARTITION_ADVANCED=y
215CONFIG_MAC_PARTITION=y
216CONFIG_CRC_T10DIF=y 227CONFIG_CRC_T10DIF=y
217CONFIG_DEBUG_FS=y 228CONFIG_DEBUG_FS=y
218CONFIG_DETECT_HUNG_TASK=y 229CONFIG_DETECT_HUNG_TASK=y
219CONFIG_DEBUG_INFO=y 230CONFIG_DEBUG_INFO=y
220CONFIG_SYSCTL_SYSCALL_CHECK=y
221CONFIG_IRQ_DOMAIN_DEBUG=y
222CONFIG_CRYPTO_PCBC=m 231CONFIG_CRYPTO_PCBC=m
223CONFIG_CRYPTO_SHA256=y 232CONFIG_CRYPTO_SHA256=y
224CONFIG_CRYPTO_SHA512=y 233CONFIG_CRYPTO_SHA512=y
diff --git a/arch/powerpc/configs/ppc64_defconfig b/arch/powerpc/configs/ppc64_defconfig
index c1442a3758a..db27c82e054 100644
--- a/arch/powerpc/configs/ppc64_defconfig
+++ b/arch/powerpc/configs/ppc64_defconfig
@@ -16,6 +16,7 @@ CONFIG_BLK_DEV_INITRD=y
16CONFIG_PROFILING=y 16CONFIG_PROFILING=y
17CONFIG_OPROFILE=y 17CONFIG_OPROFILE=y
18CONFIG_KPROBES=y 18CONFIG_KPROBES=y
19CONFIG_JUMP_LABEL=y
19CONFIG_MODULES=y 20CONFIG_MODULES=y
20CONFIG_MODULE_UNLOAD=y 21CONFIG_MODULE_UNLOAD=y
21CONFIG_MODVERSIONS=y 22CONFIG_MODVERSIONS=y
@@ -278,7 +279,8 @@ CONFIG_HVC_RTAS=y
278CONFIG_HVC_BEAT=y 279CONFIG_HVC_BEAT=y
279CONFIG_HVCS=m 280CONFIG_HVCS=m
280CONFIG_IBM_BSR=m 281CONFIG_IBM_BSR=m
281# CONFIG_HW_RANDOM is not set 282CONFIG_HW_RANDOM=m
283CONFIG_HW_RANDOM_PSERIES=m
282CONFIG_RAW_DRIVER=y 284CONFIG_RAW_DRIVER=y
283CONFIG_I2C_CHARDEV=y 285CONFIG_I2C_CHARDEV=y
284CONFIG_I2C_AMD8111=y 286CONFIG_I2C_AMD8111=y
@@ -484,8 +486,10 @@ CONFIG_CRYPTO_TEA=m
484CONFIG_CRYPTO_TWOFISH=m 486CONFIG_CRYPTO_TWOFISH=m
485CONFIG_CRYPTO_LZO=m 487CONFIG_CRYPTO_LZO=m
486# CONFIG_CRYPTO_ANSI_CPRNG is not set 488# CONFIG_CRYPTO_ANSI_CPRNG is not set
487# CONFIG_CRYPTO_HW is not set 489CONFIG_CRYPTO_HW=y
490CONFIG_CRYPTO_DEV_NX=m
488CONFIG_VIRTUALIZATION=y 491CONFIG_VIRTUALIZATION=y
489CONFIG_KVM_BOOK3S_64=m 492CONFIG_KVM_BOOK3S_64=m
490CONFIG_KVM_BOOK3S_64_HV=y 493CONFIG_KVM_BOOK3S_64_HV=y
491CONFIG_VHOST_NET=m 494CONFIG_VHOST_NET=m
495CONFIG_BPF_JIT=y
diff --git a/arch/powerpc/configs/pseries_defconfig b/arch/powerpc/configs/pseries_defconfig
index 6608232663c..1f65b3c9b59 100644
--- a/arch/powerpc/configs/pseries_defconfig
+++ b/arch/powerpc/configs/pseries_defconfig
@@ -24,6 +24,7 @@ CONFIG_BLK_DEV_INITRD=y
24CONFIG_PROFILING=y 24CONFIG_PROFILING=y
25CONFIG_OPROFILE=y 25CONFIG_OPROFILE=y
26CONFIG_KPROBES=y 26CONFIG_KPROBES=y
27CONFIG_JUMP_LABEL=y
27CONFIG_MODULES=y 28CONFIG_MODULES=y
28CONFIG_MODULE_UNLOAD=y 29CONFIG_MODULE_UNLOAD=y
29CONFIG_MODVERSIONS=y 30CONFIG_MODVERSIONS=y
@@ -225,7 +226,8 @@ CONFIG_HVC_CONSOLE=y
225CONFIG_HVC_RTAS=y 226CONFIG_HVC_RTAS=y
226CONFIG_HVCS=m 227CONFIG_HVCS=m
227CONFIG_IBM_BSR=m 228CONFIG_IBM_BSR=m
228# CONFIG_HW_RANDOM is not set 229CONFIG_HW_RANDOM=m
230CONFIG_HW_RANDOM_PSERIES=m
229CONFIG_GEN_RTC=y 231CONFIG_GEN_RTC=y
230CONFIG_RAW_DRIVER=y 232CONFIG_RAW_DRIVER=y
231CONFIG_MAX_RAW_DEVS=1024 233CONFIG_MAX_RAW_DEVS=1024
@@ -366,7 +368,8 @@ CONFIG_CRYPTO_TEA=m
366CONFIG_CRYPTO_TWOFISH=m 368CONFIG_CRYPTO_TWOFISH=m
367CONFIG_CRYPTO_LZO=m 369CONFIG_CRYPTO_LZO=m
368# CONFIG_CRYPTO_ANSI_CPRNG is not set 370# CONFIG_CRYPTO_ANSI_CPRNG is not set
369# CONFIG_CRYPTO_HW is not set 371CONFIG_CRYPTO_HW=y
372CONFIG_CRYPTO_DEV_NX=m
370CONFIG_VIRTUALIZATION=y 373CONFIG_VIRTUALIZATION=y
371CONFIG_KVM_BOOK3S_64=m 374CONFIG_KVM_BOOK3S_64=m
372CONFIG_KVM_BOOK3S_64_HV=y 375CONFIG_KVM_BOOK3S_64_HV=y
diff --git a/arch/powerpc/include/asm/asm-compat.h b/arch/powerpc/include/asm/asm-compat.h
index 5d7fbe1950f..6e82f5f9a6f 100644
--- a/arch/powerpc/include/asm/asm-compat.h
+++ b/arch/powerpc/include/asm/asm-compat.h
@@ -29,7 +29,7 @@
29#define PPC_LLARX(t, a, b, eh) PPC_LDARX(t, a, b, eh) 29#define PPC_LLARX(t, a, b, eh) PPC_LDARX(t, a, b, eh)
30#define PPC_STLCX stringify_in_c(stdcx.) 30#define PPC_STLCX stringify_in_c(stdcx.)
31#define PPC_CNTLZL stringify_in_c(cntlzd) 31#define PPC_CNTLZL stringify_in_c(cntlzd)
32#define PPC_MTOCRF(FXM, RS) MTOCRF((FXM), (RS)) 32#define PPC_MTOCRF(FXM, RS) MTOCRF((FXM), RS)
33#define PPC_LR_STKOFF 16 33#define PPC_LR_STKOFF 16
34#define PPC_MIN_STKFRM 112 34#define PPC_MIN_STKFRM 112
35#else /* 32-bit */ 35#else /* 32-bit */
diff --git a/arch/powerpc/include/asm/code-patching.h b/arch/powerpc/include/asm/code-patching.h
index 37c32aba79b..a6f8c7a5cbb 100644
--- a/arch/powerpc/include/asm/code-patching.h
+++ b/arch/powerpc/include/asm/code-patching.h
@@ -26,8 +26,8 @@ unsigned int create_branch(const unsigned int *addr,
26 unsigned long target, int flags); 26 unsigned long target, int flags);
27unsigned int create_cond_branch(const unsigned int *addr, 27unsigned int create_cond_branch(const unsigned int *addr,
28 unsigned long target, int flags); 28 unsigned long target, int flags);
29void patch_branch(unsigned int *addr, unsigned long target, int flags); 29int patch_branch(unsigned int *addr, unsigned long target, int flags);
30void patch_instruction(unsigned int *addr, unsigned int instr); 30int patch_instruction(unsigned int *addr, unsigned int instr);
31 31
32int instr_is_relative_branch(unsigned int instr); 32int instr_is_relative_branch(unsigned int instr);
33int instr_is_branch_to_addr(const unsigned int *instr, unsigned long addr); 33int instr_is_branch_to_addr(const unsigned int *instr, unsigned long addr);
diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h
index 50d82c8a037..b3c083de17a 100644
--- a/arch/powerpc/include/asm/cputable.h
+++ b/arch/powerpc/include/asm/cputable.h
@@ -553,9 +553,7 @@ static inline int cpu_has_feature(unsigned long feature)
553 & feature); 553 & feature);
554} 554}
555 555
556#ifdef CONFIG_HAVE_HW_BREAKPOINT
557#define HBP_NUM 1 556#define HBP_NUM 1
558#endif /* CONFIG_HAVE_HW_BREAKPOINT */
559 557
560#endif /* !__ASSEMBLY__ */ 558#endif /* !__ASSEMBLY__ */
561 559
diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/include/asm/device.h
index 63d5ca49cec..77e97dd0c15 100644
--- a/arch/powerpc/include/asm/device.h
+++ b/arch/powerpc/include/asm/device.h
@@ -34,6 +34,9 @@ struct dev_archdata {
34#ifdef CONFIG_EEH 34#ifdef CONFIG_EEH
35 struct eeh_dev *edev; 35 struct eeh_dev *edev;
36#endif 36#endif
37#ifdef CONFIG_FAIL_IOMMU
38 int fail_iommu;
39#endif
37}; 40};
38 41
39struct pdev_archdata { 42struct pdev_archdata {
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index 62678e365ca..78160874809 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -27,7 +27,10 @@ extern void *dma_direct_alloc_coherent(struct device *dev, size_t size,
27extern void dma_direct_free_coherent(struct device *dev, size_t size, 27extern void dma_direct_free_coherent(struct device *dev, size_t size,
28 void *vaddr, dma_addr_t dma_handle, 28 void *vaddr, dma_addr_t dma_handle,
29 struct dma_attrs *attrs); 29 struct dma_attrs *attrs);
30 30extern int dma_direct_mmap_coherent(struct device *dev,
31 struct vm_area_struct *vma,
32 void *cpu_addr, dma_addr_t handle,
33 size_t size, struct dma_attrs *attrs);
31 34
32#ifdef CONFIG_NOT_COHERENT_CACHE 35#ifdef CONFIG_NOT_COHERENT_CACHE
33/* 36/*
@@ -207,11 +210,8 @@ static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
207#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 210#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
208#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 211#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
209 212
210extern int dma_mmap_coherent(struct device *, struct vm_area_struct *,
211 void *, dma_addr_t, size_t);
212#define ARCH_HAS_DMA_MMAP_COHERENT 213#define ARCH_HAS_DMA_MMAP_COHERENT
213 214
214
215static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size, 215static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
216 enum dma_data_direction direction) 216 enum dma_data_direction direction)
217{ 217{
diff --git a/arch/powerpc/include/asm/epapr_hcalls.h b/arch/powerpc/include/asm/epapr_hcalls.h
index 976835d8f22..bf2c06c3387 100644
--- a/arch/powerpc/include/asm/epapr_hcalls.h
+++ b/arch/powerpc/include/asm/epapr_hcalls.h
@@ -153,6 +153,8 @@
153#define EV_HCALL_CLOBBERS2 EV_HCALL_CLOBBERS3, "r5" 153#define EV_HCALL_CLOBBERS2 EV_HCALL_CLOBBERS3, "r5"
154#define EV_HCALL_CLOBBERS1 EV_HCALL_CLOBBERS2, "r4" 154#define EV_HCALL_CLOBBERS1 EV_HCALL_CLOBBERS2, "r4"
155 155
156extern bool epapr_paravirt_enabled;
157extern u32 epapr_hypercall_start[];
156 158
157/* 159/*
158 * We use "uintptr_t" to define a register because it's guaranteed to be a 160 * We use "uintptr_t" to define a register because it's guaranteed to be a
diff --git a/arch/powerpc/include/asm/exception-64s.h b/arch/powerpc/include/asm/exception-64s.h
index d58fc4e4149..a43c1473915 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -293,7 +293,7 @@ label##_hv: \
293 293
294#define RUNLATCH_ON \ 294#define RUNLATCH_ON \
295BEGIN_FTR_SECTION \ 295BEGIN_FTR_SECTION \
296 clrrdi r3,r1,THREAD_SHIFT; \ 296 CURRENT_THREAD_INFO(r3, r1); \
297 ld r4,TI_LOCAL_FLAGS(r3); \ 297 ld r4,TI_LOCAL_FLAGS(r3); \
298 andi. r0,r4,_TLF_RUNLATCH; \ 298 andi. r0,r4,_TLF_RUNLATCH; \
299 beql ppc64_runlatch_on_trampoline; \ 299 beql ppc64_runlatch_on_trampoline; \
@@ -332,7 +332,7 @@ label##_common: \
332#ifdef CONFIG_PPC_970_NAP 332#ifdef CONFIG_PPC_970_NAP
333#define FINISH_NAP \ 333#define FINISH_NAP \
334BEGIN_FTR_SECTION \ 334BEGIN_FTR_SECTION \
335 clrrdi r11,r1,THREAD_SHIFT; \ 335 CURRENT_THREAD_INFO(r11, r1); \
336 ld r9,TI_LOCAL_FLAGS(r11); \ 336 ld r9,TI_LOCAL_FLAGS(r11); \
337 andi. r10,r9,_TLF_NAPPING; \ 337 andi. r10,r9,_TLF_NAPPING; \
338 bnel power4_fixup_nap; \ 338 bnel power4_fixup_nap; \
diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
index 0554ab062bd..e45c4947a77 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -34,6 +34,8 @@ extern void __replay_interrupt(unsigned int vector);
34 34
35extern void timer_interrupt(struct pt_regs *); 35extern void timer_interrupt(struct pt_regs *);
36extern void performance_monitor_exception(struct pt_regs *regs); 36extern void performance_monitor_exception(struct pt_regs *regs);
37extern void WatchdogException(struct pt_regs *regs);
38extern void unknown_exception(struct pt_regs *regs);
37 39
38#ifdef CONFIG_PPC64 40#ifdef CONFIG_PPC64
39#include <asm/paca.h> 41#include <asm/paca.h>
diff --git a/arch/powerpc/include/asm/immap_qe.h b/arch/powerpc/include/asm/immap_qe.h
index 0edb6842b13..61e8490786b 100644
--- a/arch/powerpc/include/asm/immap_qe.h
+++ b/arch/powerpc/include/asm/immap_qe.h
@@ -26,7 +26,9 @@
26struct qe_iram { 26struct qe_iram {
27 __be32 iadd; /* I-RAM Address Register */ 27 __be32 iadd; /* I-RAM Address Register */
28 __be32 idata; /* I-RAM Data Register */ 28 __be32 idata; /* I-RAM Data Register */
29 u8 res0[0x78]; 29 u8 res0[0x04];
30 __be32 iready; /* I-RAM Ready Register */
31 u8 res1[0x70];
30} __attribute__ ((packed)); 32} __attribute__ ((packed));
31 33
32/* QE Interrupt Controller */ 34/* QE Interrupt Controller */
diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index a3855b81ead..f94ef4213e9 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -20,6 +20,14 @@ extern int check_legacy_ioport(unsigned long base_port);
20#define _PNPWRP 0xa79 20#define _PNPWRP 0xa79
21#define PNPBIOS_BASE 0xf000 21#define PNPBIOS_BASE 0xf000
22 22
23#if defined(CONFIG_PPC64) && defined(CONFIG_PCI)
24extern struct pci_dev *isa_bridge_pcidev;
25/*
26 * has legacy ISA devices ?
27 */
28#define arch_has_dev_port() (isa_bridge_pcidev != NULL)
29#endif
30
23#include <linux/device.h> 31#include <linux/device.h>
24#include <linux/io.h> 32#include <linux/io.h>
25 33
diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h
index 957a83f4364..cbfe678e3db 100644
--- a/arch/powerpc/include/asm/iommu.h
+++ b/arch/powerpc/include/asm/iommu.h
@@ -53,6 +53,16 @@ static __inline__ __attribute_const__ int get_iommu_order(unsigned long size)
53 */ 53 */
54#define IOMAP_MAX_ORDER 13 54#define IOMAP_MAX_ORDER 13
55 55
56#define IOMMU_POOL_HASHBITS 2
57#define IOMMU_NR_POOLS (1 << IOMMU_POOL_HASHBITS)
58
59struct iommu_pool {
60 unsigned long start;
61 unsigned long end;
62 unsigned long hint;
63 spinlock_t lock;
64} ____cacheline_aligned_in_smp;
65
56struct iommu_table { 66struct iommu_table {
57 unsigned long it_busno; /* Bus number this table belongs to */ 67 unsigned long it_busno; /* Bus number this table belongs to */
58 unsigned long it_size; /* Size of iommu table in entries */ 68 unsigned long it_size; /* Size of iommu table in entries */
@@ -61,10 +71,10 @@ struct iommu_table {
61 unsigned long it_index; /* which iommu table this is */ 71 unsigned long it_index; /* which iommu table this is */
62 unsigned long it_type; /* type: PCI or Virtual Bus */ 72 unsigned long it_type; /* type: PCI or Virtual Bus */
63 unsigned long it_blocksize; /* Entries in each block (cacheline) */ 73 unsigned long it_blocksize; /* Entries in each block (cacheline) */
64 unsigned long it_hint; /* Hint for next alloc */ 74 unsigned long poolsize;
65 unsigned long it_largehint; /* Hint for large allocs */ 75 unsigned long nr_pools;
66 unsigned long it_halfpoint; /* Breaking point for small/large allocs */ 76 struct iommu_pool large_pool;
67 spinlock_t it_lock; /* Protects it_map */ 77 struct iommu_pool pools[IOMMU_NR_POOLS];
68 unsigned long *it_map; /* A simple allocation bitmap for now */ 78 unsigned long *it_map; /* A simple allocation bitmap for now */
69}; 79};
70 80
diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
index bca8fdcd254..5acabbd7ac6 100644
--- a/arch/powerpc/include/asm/kmap_types.h
+++ b/arch/powerpc/include/asm/kmap_types.h
@@ -10,36 +10,7 @@
10 * 2 of the License, or (at your option) any later version. 10 * 2 of the License, or (at your option) any later version.
11 */ 11 */
12 12
13enum km_type { 13#define KM_TYPE_NR 16
14 KM_BOUNCE_READ,
15 KM_SKB_SUNRPC_DATA,
16 KM_SKB_DATA_SOFTIRQ,
17 KM_USER0,
18 KM_USER1,
19 KM_BIO_SRC_IRQ,
20 KM_BIO_DST_IRQ,
21 KM_PTE0,
22 KM_PTE1,
23 KM_IRQ0,
24 KM_IRQ1,
25 KM_SOFTIRQ0,
26 KM_SOFTIRQ1,
27 KM_PPC_SYNC_PAGE,
28 KM_PPC_SYNC_ICACHE,
29 KM_KDB,
30 KM_TYPE_NR
31};
32
33/*
34 * This is a temporary build fix that (so they say on lkml....) should no longer
35 * be required after 2.6.33, because of changes planned to the kmap code.
36 * Let's try to remove this cruft then.
37 */
38#ifdef CONFIG_DEBUG_HIGHMEM
39#define KM_NMI (-1)
40#define KM_NMI_PTE (-1)
41#define KM_IRQ_PTE (-1)
42#endif
43 14
44#endif /* __KERNEL__ */ 15#endif /* __KERNEL__ */
45#endif /* _ASM_POWERPC_KMAP_TYPES_H */ 16#endif /* _ASM_POWERPC_KMAP_TYPES_H */
diff --git a/arch/powerpc/include/asm/kvm_book3s_64.h b/arch/powerpc/include/asm/kvm_book3s_64.h
index b0c08b14277..0dd1d86d3e3 100644
--- a/arch/powerpc/include/asm/kvm_book3s_64.h
+++ b/arch/powerpc/include/asm/kvm_book3s_64.h
@@ -36,11 +36,8 @@ static inline void svcpu_put(struct kvmppc_book3s_shadow_vcpu *svcpu)
36#define SPAPR_TCE_SHIFT 12 36#define SPAPR_TCE_SHIFT 12
37 37
38#ifdef CONFIG_KVM_BOOK3S_64_HV 38#ifdef CONFIG_KVM_BOOK3S_64_HV
39/* For now use fixed-size 16MB page table */ 39#define KVM_DEFAULT_HPT_ORDER 24 /* 16MB HPT by default */
40#define HPT_ORDER 24 40extern int kvm_hpt_order; /* order of preallocated HPTs */
41#define HPT_NPTEG (1ul << (HPT_ORDER - 7)) /* 128B per pteg */
42#define HPT_NPTE (HPT_NPTEG << 3) /* 8 PTEs per PTEG */
43#define HPT_HASH_MASK (HPT_NPTEG - 1)
44#endif 41#endif
45 42
46#define VRMA_VSID 0x1ffffffUL /* 1TB VSID reserved for VRMA */ 43#define VRMA_VSID 0x1ffffffUL /* 1TB VSID reserved for VRMA */
diff --git a/arch/powerpc/include/asm/kvm_book3s_asm.h b/arch/powerpc/include/asm/kvm_book3s_asm.h
index 88609b23b77..bfcd00c1485 100644
--- a/arch/powerpc/include/asm/kvm_book3s_asm.h
+++ b/arch/powerpc/include/asm/kvm_book3s_asm.h
@@ -74,6 +74,7 @@ struct kvmppc_host_state {
74 ulong vmhandler; 74 ulong vmhandler;
75 ulong scratch0; 75 ulong scratch0;
76 ulong scratch1; 76 ulong scratch1;
77 ulong sprg3;
77 u8 in_guest; 78 u8 in_guest;
78 u8 restore_hid5; 79 u8 restore_hid5;
79 u8 napping; 80 u8 napping;
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index d848cdc4971..a8bf5c673a3 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -33,6 +33,7 @@
33#include <asm/kvm_asm.h> 33#include <asm/kvm_asm.h>
34#include <asm/processor.h> 34#include <asm/processor.h>
35#include <asm/page.h> 35#include <asm/page.h>
36#include <asm/cacheflush.h>
36 37
37#define KVM_MAX_VCPUS NR_CPUS 38#define KVM_MAX_VCPUS NR_CPUS
38#define KVM_MAX_VCORES NR_CPUS 39#define KVM_MAX_VCORES NR_CPUS
@@ -237,6 +238,10 @@ struct kvm_arch {
237 unsigned long vrma_slb_v; 238 unsigned long vrma_slb_v;
238 int rma_setup_done; 239 int rma_setup_done;
239 int using_mmu_notifiers; 240 int using_mmu_notifiers;
241 u32 hpt_order;
242 atomic_t vcpus_running;
243 unsigned long hpt_npte;
244 unsigned long hpt_mask;
240 spinlock_t slot_phys_lock; 245 spinlock_t slot_phys_lock;
241 unsigned long *slot_phys[KVM_MEM_SLOTS_NUM]; 246 unsigned long *slot_phys[KVM_MEM_SLOTS_NUM];
242 int slot_npages[KVM_MEM_SLOTS_NUM]; 247 int slot_npages[KVM_MEM_SLOTS_NUM];
@@ -414,7 +419,9 @@ struct kvm_vcpu_arch {
414 ulong mcsrr1; 419 ulong mcsrr1;
415 ulong mcsr; 420 ulong mcsr;
416 u32 dec; 421 u32 dec;
422#ifdef CONFIG_BOOKE
417 u32 decar; 423 u32 decar;
424#endif
418 u32 tbl; 425 u32 tbl;
419 u32 tbu; 426 u32 tbu;
420 u32 tcr; 427 u32 tcr;
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
index f68c22fa2fc..e006f0bdea9 100644
--- a/arch/powerpc/include/asm/kvm_ppc.h
+++ b/arch/powerpc/include/asm/kvm_ppc.h
@@ -119,7 +119,8 @@ extern void kvmppc_core_destroy_mmu(struct kvm_vcpu *vcpu);
119extern int kvmppc_kvm_pv(struct kvm_vcpu *vcpu); 119extern int kvmppc_kvm_pv(struct kvm_vcpu *vcpu);
120extern void kvmppc_map_magic(struct kvm_vcpu *vcpu); 120extern void kvmppc_map_magic(struct kvm_vcpu *vcpu);
121 121
122extern long kvmppc_alloc_hpt(struct kvm *kvm); 122extern long kvmppc_alloc_hpt(struct kvm *kvm, u32 *htab_orderp);
123extern long kvmppc_alloc_reset_hpt(struct kvm *kvm, u32 *htab_orderp);
123extern void kvmppc_free_hpt(struct kvm *kvm); 124extern void kvmppc_free_hpt(struct kvm *kvm);
124extern long kvmppc_prepare_vrma(struct kvm *kvm, 125extern long kvmppc_prepare_vrma(struct kvm *kvm,
125 struct kvm_userspace_memory_region *mem); 126 struct kvm_userspace_memory_region *mem);
@@ -218,4 +219,16 @@ void kvmppc_claim_lpid(long lpid);
218void kvmppc_free_lpid(long lpid); 219void kvmppc_free_lpid(long lpid);
219void kvmppc_init_lpid(unsigned long nr_lpids); 220void kvmppc_init_lpid(unsigned long nr_lpids);
220 221
222static inline void kvmppc_mmu_flush_icache(pfn_t pfn)
223{
224 /* Clear i-cache for new pages */
225 struct page *page;
226 page = pfn_to_page(pfn);
227 if (!test_bit(PG_arch_1, &page->flags)) {
228 flush_dcache_icache_page(page);
229 set_bit(PG_arch_1, &page->flags);
230 }
231}
232
233
221#endif /* __POWERPC_KVM_PPC_H__ */ 234#endif /* __POWERPC_KVM_PPC_H__ */
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index f0145522cfb..e8a26db2e8f 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -163,12 +163,7 @@ extern u64 ppc64_rma_size;
163 * to think about, feedback welcome. --BenH. 163 * to think about, feedback welcome. --BenH.
164 */ 164 */
165 165
166/* There are #define as they have to be used in assembly 166/* These are #defines as they have to be used in assembly */
167 *
168 * WARNING: If you change this list, make sure to update the array of
169 * names currently in arch/powerpc/mm/hugetlbpage.c or bad things will
170 * happen
171 */
172#define MMU_PAGE_4K 0 167#define MMU_PAGE_4K 0
173#define MMU_PAGE_16K 1 168#define MMU_PAGE_16K 1
174#define MMU_PAGE_64K 2 169#define MMU_PAGE_64K 2
diff --git a/arch/powerpc/include/asm/mpic_msgr.h b/arch/powerpc/include/asm/mpic_msgr.h
index 326d33ca55c..d4f471fb103 100644
--- a/arch/powerpc/include/asm/mpic_msgr.h
+++ b/arch/powerpc/include/asm/mpic_msgr.h
@@ -14,6 +14,7 @@
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/spinlock.h> 15#include <linux/spinlock.h>
16#include <asm/smp.h> 16#include <asm/smp.h>
17#include <asm/io.h>
17 18
18struct mpic_msgr { 19struct mpic_msgr {
19 u32 __iomem *base; 20 u32 __iomem *base;
diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
index ac39e6a3b25..8cccbee6151 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -30,6 +30,7 @@ struct pci_controller {
30 int first_busno; 30 int first_busno;
31 int last_busno; 31 int last_busno;
32 int self_busno; 32 int self_busno;
33 struct resource busn;
33 34
34 void __iomem *io_base_virt; 35 void __iomem *io_base_virt;
35#ifdef CONFIG_PPC64 36#ifdef CONFIG_PPC64
diff --git a/arch/powerpc/include/asm/perf_event.h b/arch/powerpc/include/asm/perf_event.h
index 5c16b891d50..0bb23725b1e 100644
--- a/arch/powerpc/include/asm/perf_event.h
+++ b/arch/powerpc/include/asm/perf_event.h
@@ -26,8 +26,13 @@
26#include <asm/ptrace.h> 26#include <asm/ptrace.h>
27#include <asm/reg.h> 27#include <asm/reg.h>
28 28
29/*
30 * Overload regs->result to specify whether we should use the MSR (result
31 * is zero) or the SIAR (result is non zero).
32 */
29#define perf_arch_fetch_caller_regs(regs, __ip) \ 33#define perf_arch_fetch_caller_regs(regs, __ip) \
30 do { \ 34 do { \
35 (regs)->result = 0; \
31 (regs)->nip = __ip; \ 36 (regs)->nip = __ip; \
32 (regs)->gpr[1] = *(unsigned long *)__get_SP(); \ 37 (regs)->gpr[1] = *(unsigned long *)__get_SP(); \
33 asm volatile("mfmsr %0" : "=r" ((regs)->msr)); \ 38 asm volatile("mfmsr %0" : "=r" ((regs)->msr)); \
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index d81f99430fe..4c25319f2fb 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -15,6 +15,72 @@
15#include <linux/stringify.h> 15#include <linux/stringify.h>
16#include <asm/asm-compat.h> 16#include <asm/asm-compat.h>
17 17
18#define __REG_R0 0
19#define __REG_R1 1
20#define __REG_R2 2
21#define __REG_R3 3
22#define __REG_R4 4
23#define __REG_R5 5
24#define __REG_R6 6
25#define __REG_R7 7
26#define __REG_R8 8
27#define __REG_R9 9
28#define __REG_R10 10
29#define __REG_R11 11
30#define __REG_R12 12
31#define __REG_R13 13
32#define __REG_R14 14
33#define __REG_R15 15
34#define __REG_R16 16
35#define __REG_R17 17
36#define __REG_R18 18
37#define __REG_R19 19
38#define __REG_R20 20
39#define __REG_R21 21
40#define __REG_R22 22
41#define __REG_R23 23
42#define __REG_R24 24
43#define __REG_R25 25
44#define __REG_R26 26
45#define __REG_R27 27
46#define __REG_R28 28
47#define __REG_R29 29
48#define __REG_R30 30
49#define __REG_R31 31
50
51#define __REGA0_0 0
52#define __REGA0_R1 1
53#define __REGA0_R2 2
54#define __REGA0_R3 3
55#define __REGA0_R4 4
56#define __REGA0_R5 5
57#define __REGA0_R6 6
58#define __REGA0_R7 7
59#define __REGA0_R8 8
60#define __REGA0_R9 9
61#define __REGA0_R10 10
62#define __REGA0_R11 11
63#define __REGA0_R12 12
64#define __REGA0_R13 13
65#define __REGA0_R14 14
66#define __REGA0_R15 15
67#define __REGA0_R16 16
68#define __REGA0_R17 17
69#define __REGA0_R18 18
70#define __REGA0_R19 19
71#define __REGA0_R20 20
72#define __REGA0_R21 21
73#define __REGA0_R22 22
74#define __REGA0_R23 23
75#define __REGA0_R24 24
76#define __REGA0_R25 25
77#define __REGA0_R26 26
78#define __REGA0_R27 27
79#define __REGA0_R28 28
80#define __REGA0_R29 29
81#define __REGA0_R30 30
82#define __REGA0_R31 31
83
18/* sorted alphabetically */ 84/* sorted alphabetically */
19#define PPC_INST_DCBA 0x7c0005ec 85#define PPC_INST_DCBA 0x7c0005ec
20#define PPC_INST_DCBA_MASK 0xfc0007fe 86#define PPC_INST_DCBA_MASK 0xfc0007fe
@@ -107,12 +173,19 @@
107#define PPC_INST_NEG 0x7c0000d0 173#define PPC_INST_NEG 0x7c0000d0
108#define PPC_INST_BRANCH 0x48000000 174#define PPC_INST_BRANCH 0x48000000
109#define PPC_INST_BRANCH_COND 0x40800000 175#define PPC_INST_BRANCH_COND 0x40800000
176#define PPC_INST_LBZCIX 0x7c0006aa
177#define PPC_INST_STBCIX 0x7c0007aa
110 178
111/* macros to insert fields into opcodes */ 179/* macros to insert fields into opcodes */
112#define __PPC_RA(a) (((a) & 0x1f) << 16) 180#define ___PPC_RA(a) (((a) & 0x1f) << 16)
113#define __PPC_RB(b) (((b) & 0x1f) << 11) 181#define ___PPC_RB(b) (((b) & 0x1f) << 11)
114#define __PPC_RS(s) (((s) & 0x1f) << 21) 182#define ___PPC_RS(s) (((s) & 0x1f) << 21)
115#define __PPC_RT(s) __PPC_RS(s) 183#define ___PPC_RT(t) ___PPC_RS(t)
184#define __PPC_RA(a) ___PPC_RA(__REG_##a)
185#define __PPC_RA0(a) ___PPC_RA(__REGA0_##a)
186#define __PPC_RB(b) ___PPC_RB(__REG_##b)
187#define __PPC_RS(s) ___PPC_RS(__REG_##s)
188#define __PPC_RT(t) ___PPC_RT(__REG_##t)
116#define __PPC_XA(a) ((((a) & 0x1f) << 16) | (((a) & 0x20) >> 3)) 189#define __PPC_XA(a) ((((a) & 0x1f) << 16) | (((a) & 0x20) >> 3))
117#define __PPC_XB(b) ((((b) & 0x1f) << 11) | (((b) & 0x20) >> 4)) 190#define __PPC_XB(b) ((((b) & 0x1f) << 11) | (((b) & 0x20) >> 4))
118#define __PPC_XS(s) ((((s) & 0x1f) << 21) | (((s) & 0x20) >> 5)) 191#define __PPC_XS(s) ((((s) & 0x1f) << 21) | (((s) & 0x20) >> 5))
@@ -141,13 +214,13 @@
141#define PPC_DCBZL(a, b) stringify_in_c(.long PPC_INST_DCBZL | \ 214#define PPC_DCBZL(a, b) stringify_in_c(.long PPC_INST_DCBZL | \
142 __PPC_RA(a) | __PPC_RB(b)) 215 __PPC_RA(a) | __PPC_RB(b))
143#define PPC_LDARX(t, a, b, eh) stringify_in_c(.long PPC_INST_LDARX | \ 216#define PPC_LDARX(t, a, b, eh) stringify_in_c(.long PPC_INST_LDARX | \
144 __PPC_RT(t) | __PPC_RA(a) | \ 217 ___PPC_RT(t) | ___PPC_RA(a) | \
145 __PPC_RB(b) | __PPC_EH(eh)) 218 ___PPC_RB(b) | __PPC_EH(eh))
146#define PPC_LWARX(t, a, b, eh) stringify_in_c(.long PPC_INST_LWARX | \ 219#define PPC_LWARX(t, a, b, eh) stringify_in_c(.long PPC_INST_LWARX | \
147 __PPC_RT(t) | __PPC_RA(a) | \ 220 ___PPC_RT(t) | ___PPC_RA(a) | \
148 __PPC_RB(b) | __PPC_EH(eh)) 221 ___PPC_RB(b) | __PPC_EH(eh))
149#define PPC_MSGSND(b) stringify_in_c(.long PPC_INST_MSGSND | \ 222#define PPC_MSGSND(b) stringify_in_c(.long PPC_INST_MSGSND | \
150 __PPC_RB(b)) 223 ___PPC_RB(b))
151#define PPC_POPCNTB(a, s) stringify_in_c(.long PPC_INST_POPCNTB | \ 224#define PPC_POPCNTB(a, s) stringify_in_c(.long PPC_INST_POPCNTB | \
152 __PPC_RA(a) | __PPC_RS(s)) 225 __PPC_RA(a) | __PPC_RS(s))
153#define PPC_POPCNTD(a, s) stringify_in_c(.long PPC_INST_POPCNTD | \ 226#define PPC_POPCNTD(a, s) stringify_in_c(.long PPC_INST_POPCNTD | \
@@ -158,34 +231,39 @@
158#define PPC_RFDI stringify_in_c(.long PPC_INST_RFDI) 231#define PPC_RFDI stringify_in_c(.long PPC_INST_RFDI)
159#define PPC_RFMCI stringify_in_c(.long PPC_INST_RFMCI) 232#define PPC_RFMCI stringify_in_c(.long PPC_INST_RFMCI)
160#define PPC_TLBILX(t, a, b) stringify_in_c(.long PPC_INST_TLBILX | \ 233#define PPC_TLBILX(t, a, b) stringify_in_c(.long PPC_INST_TLBILX | \
161 __PPC_T_TLB(t) | __PPC_RA(a) | __PPC_RB(b)) 234 __PPC_T_TLB(t) | __PPC_RA0(a) | __PPC_RB(b))
162#define PPC_TLBILX_ALL(a, b) PPC_TLBILX(0, a, b) 235#define PPC_TLBILX_ALL(a, b) PPC_TLBILX(0, a, b)
163#define PPC_TLBILX_PID(a, b) PPC_TLBILX(1, a, b) 236#define PPC_TLBILX_PID(a, b) PPC_TLBILX(1, a, b)
164#define PPC_TLBILX_VA(a, b) PPC_TLBILX(3, a, b) 237#define PPC_TLBILX_VA(a, b) PPC_TLBILX(3, a, b)
165#define PPC_WAIT(w) stringify_in_c(.long PPC_INST_WAIT | \ 238#define PPC_WAIT(w) stringify_in_c(.long PPC_INST_WAIT | \
166 __PPC_WC(w)) 239 __PPC_WC(w))
167#define PPC_TLBIE(lp,a) stringify_in_c(.long PPC_INST_TLBIE | \ 240#define PPC_TLBIE(lp,a) stringify_in_c(.long PPC_INST_TLBIE | \
168 __PPC_RB(a) | __PPC_RS(lp)) 241 ___PPC_RB(a) | ___PPC_RS(lp))
169#define PPC_TLBSRX_DOT(a,b) stringify_in_c(.long PPC_INST_TLBSRX_DOT | \ 242#define PPC_TLBSRX_DOT(a,b) stringify_in_c(.long PPC_INST_TLBSRX_DOT | \
170 __PPC_RA(a) | __PPC_RB(b)) 243 __PPC_RA0(a) | __PPC_RB(b))
171#define PPC_TLBIVAX(a,b) stringify_in_c(.long PPC_INST_TLBIVAX | \ 244#define PPC_TLBIVAX(a,b) stringify_in_c(.long PPC_INST_TLBIVAX | \
172 __PPC_RA(a) | __PPC_RB(b)) 245 __PPC_RA0(a) | __PPC_RB(b))
173 246
174#define PPC_ERATWE(s, a, w) stringify_in_c(.long PPC_INST_ERATWE | \ 247#define PPC_ERATWE(s, a, w) stringify_in_c(.long PPC_INST_ERATWE | \
175 __PPC_RS(s) | __PPC_RA(a) | __PPC_WS(w)) 248 __PPC_RS(s) | __PPC_RA(a) | __PPC_WS(w))
176#define PPC_ERATRE(s, a, w) stringify_in_c(.long PPC_INST_ERATRE | \ 249#define PPC_ERATRE(s, a, w) stringify_in_c(.long PPC_INST_ERATRE | \
177 __PPC_RS(s) | __PPC_RA(a) | __PPC_WS(w)) 250 __PPC_RS(s) | __PPC_RA(a) | __PPC_WS(w))
178#define PPC_ERATILX(t, a, b) stringify_in_c(.long PPC_INST_ERATILX | \ 251#define PPC_ERATILX(t, a, b) stringify_in_c(.long PPC_INST_ERATILX | \
179 __PPC_T_TLB(t) | __PPC_RA(a) | \ 252 __PPC_T_TLB(t) | __PPC_RA0(a) | \
180 __PPC_RB(b)) 253 __PPC_RB(b))
181#define PPC_ERATIVAX(s, a, b) stringify_in_c(.long PPC_INST_ERATIVAX | \ 254#define PPC_ERATIVAX(s, a, b) stringify_in_c(.long PPC_INST_ERATIVAX | \
182 __PPC_RS(s) | __PPC_RA(a) | __PPC_RB(b)) 255 __PPC_RS(s) | __PPC_RA0(a) | __PPC_RB(b))
183#define PPC_ERATSX(t, a, w) stringify_in_c(.long PPC_INST_ERATSX | \ 256#define PPC_ERATSX(t, a, w) stringify_in_c(.long PPC_INST_ERATSX | \
184 __PPC_RS(t) | __PPC_RA(a) | __PPC_RB(b)) 257 __PPC_RS(t) | __PPC_RA0(a) | __PPC_RB(b))
185#define PPC_ERATSX_DOT(t, a, w) stringify_in_c(.long PPC_INST_ERATSX_DOT | \ 258#define PPC_ERATSX_DOT(t, a, w) stringify_in_c(.long PPC_INST_ERATSX_DOT | \
186 __PPC_RS(t) | __PPC_RA(a) | __PPC_RB(b)) 259 __PPC_RS(t) | __PPC_RA0(a) | __PPC_RB(b))
187#define PPC_SLBFEE_DOT(t, b) stringify_in_c(.long PPC_INST_SLBFEE | \ 260#define PPC_SLBFEE_DOT(t, b) stringify_in_c(.long PPC_INST_SLBFEE | \
188 __PPC_RT(t) | __PPC_RB(b)) 261 __PPC_RT(t) | __PPC_RB(b))
262/* PASemi instructions */
263#define LBZCIX(t,a,b) stringify_in_c(.long PPC_INST_LBZCIX | \
264 __PPC_RT(t) | __PPC_RA(a) | __PPC_RB(b))
265#define STBCIX(s,a,b) stringify_in_c(.long PPC_INST_STBCIX | \
266 __PPC_RS(s) | __PPC_RA(a) | __PPC_RB(b))
189 267
190/* 268/*
191 * Define what the VSX XX1 form instructions will look like, then add 269 * Define what the VSX XX1 form instructions will look like, then add
@@ -194,11 +272,11 @@
194#define VSX_XX1(s, a, b) (__PPC_XS(s) | __PPC_RA(a) | __PPC_RB(b)) 272#define VSX_XX1(s, a, b) (__PPC_XS(s) | __PPC_RA(a) | __PPC_RB(b))
195#define VSX_XX3(t, a, b) (__PPC_XT(t) | __PPC_XA(a) | __PPC_XB(b)) 273#define VSX_XX3(t, a, b) (__PPC_XT(t) | __PPC_XA(a) | __PPC_XB(b))
196#define STXVD2X(s, a, b) stringify_in_c(.long PPC_INST_STXVD2X | \ 274#define STXVD2X(s, a, b) stringify_in_c(.long PPC_INST_STXVD2X | \
197 VSX_XX1((s), (a), (b))) 275 VSX_XX1((s), a, b))
198#define LXVD2X(s, a, b) stringify_in_c(.long PPC_INST_LXVD2X | \ 276#define LXVD2X(s, a, b) stringify_in_c(.long PPC_INST_LXVD2X | \
199 VSX_XX1((s), (a), (b))) 277 VSX_XX1((s), a, b))
200#define XXLOR(t, a, b) stringify_in_c(.long PPC_INST_XXLOR | \ 278#define XXLOR(t, a, b) stringify_in_c(.long PPC_INST_XXLOR | \
201 VSX_XX3((t), (a), (b))) 279 VSX_XX3((t), a, b))
202 280
203#define PPC_NAP stringify_in_c(.long PPC_INST_NAP) 281#define PPC_NAP stringify_in_c(.long PPC_INST_NAP)
204#define PPC_SLEEP stringify_in_c(.long PPC_INST_SLEEP) 282#define PPC_SLEEP stringify_in_c(.long PPC_INST_SLEEP)
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index 15444204a3a..ea2a86e8ff9 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -126,26 +126,26 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
126#define REST_32VRS(n,b,base) REST_16VRS(n,b,base); REST_16VRS(n+16,b,base) 126#define REST_32VRS(n,b,base) REST_16VRS(n,b,base); REST_16VRS(n+16,b,base)
127 127
128/* Save the lower 32 VSRs in the thread VSR region */ 128/* Save the lower 32 VSRs in the thread VSR region */
129#define SAVE_VSR(n,b,base) li b,THREAD_VSR0+(16*(n)); STXVD2X(n,base,b) 129#define SAVE_VSR(n,b,base) li b,THREAD_VSR0+(16*(n)); STXVD2X(n,R##base,R##b)
130#define SAVE_2VSRS(n,b,base) SAVE_VSR(n,b,base); SAVE_VSR(n+1,b,base) 130#define SAVE_2VSRS(n,b,base) SAVE_VSR(n,b,base); SAVE_VSR(n+1,b,base)
131#define SAVE_4VSRS(n,b,base) SAVE_2VSRS(n,b,base); SAVE_2VSRS(n+2,b,base) 131#define SAVE_4VSRS(n,b,base) SAVE_2VSRS(n,b,base); SAVE_2VSRS(n+2,b,base)
132#define SAVE_8VSRS(n,b,base) SAVE_4VSRS(n,b,base); SAVE_4VSRS(n+4,b,base) 132#define SAVE_8VSRS(n,b,base) SAVE_4VSRS(n,b,base); SAVE_4VSRS(n+4,b,base)
133#define SAVE_16VSRS(n,b,base) SAVE_8VSRS(n,b,base); SAVE_8VSRS(n+8,b,base) 133#define SAVE_16VSRS(n,b,base) SAVE_8VSRS(n,b,base); SAVE_8VSRS(n+8,b,base)
134#define SAVE_32VSRS(n,b,base) SAVE_16VSRS(n,b,base); SAVE_16VSRS(n+16,b,base) 134#define SAVE_32VSRS(n,b,base) SAVE_16VSRS(n,b,base); SAVE_16VSRS(n+16,b,base)
135#define REST_VSR(n,b,base) li b,THREAD_VSR0+(16*(n)); LXVD2X(n,base,b) 135#define REST_VSR(n,b,base) li b,THREAD_VSR0+(16*(n)); LXVD2X(n,R##base,R##b)
136#define REST_2VSRS(n,b,base) REST_VSR(n,b,base); REST_VSR(n+1,b,base) 136#define REST_2VSRS(n,b,base) REST_VSR(n,b,base); REST_VSR(n+1,b,base)
137#define REST_4VSRS(n,b,base) REST_2VSRS(n,b,base); REST_2VSRS(n+2,b,base) 137#define REST_4VSRS(n,b,base) REST_2VSRS(n,b,base); REST_2VSRS(n+2,b,base)
138#define REST_8VSRS(n,b,base) REST_4VSRS(n,b,base); REST_4VSRS(n+4,b,base) 138#define REST_8VSRS(n,b,base) REST_4VSRS(n,b,base); REST_4VSRS(n+4,b,base)
139#define REST_16VSRS(n,b,base) REST_8VSRS(n,b,base); REST_8VSRS(n+8,b,base) 139#define REST_16VSRS(n,b,base) REST_8VSRS(n,b,base); REST_8VSRS(n+8,b,base)
140#define REST_32VSRS(n,b,base) REST_16VSRS(n,b,base); REST_16VSRS(n+16,b,base) 140#define REST_32VSRS(n,b,base) REST_16VSRS(n,b,base); REST_16VSRS(n+16,b,base)
141/* Save the upper 32 VSRs (32-63) in the thread VSX region (0-31) */ 141/* Save the upper 32 VSRs (32-63) in the thread VSX region (0-31) */
142#define SAVE_VSRU(n,b,base) li b,THREAD_VR0+(16*(n)); STXVD2X(n+32,base,b) 142#define SAVE_VSRU(n,b,base) li b,THREAD_VR0+(16*(n)); STXVD2X(n+32,R##base,R##b)
143#define SAVE_2VSRSU(n,b,base) SAVE_VSRU(n,b,base); SAVE_VSRU(n+1,b,base) 143#define SAVE_2VSRSU(n,b,base) SAVE_VSRU(n,b,base); SAVE_VSRU(n+1,b,base)
144#define SAVE_4VSRSU(n,b,base) SAVE_2VSRSU(n,b,base); SAVE_2VSRSU(n+2,b,base) 144#define SAVE_4VSRSU(n,b,base) SAVE_2VSRSU(n,b,base); SAVE_2VSRSU(n+2,b,base)
145#define SAVE_8VSRSU(n,b,base) SAVE_4VSRSU(n,b,base); SAVE_4VSRSU(n+4,b,base) 145#define SAVE_8VSRSU(n,b,base) SAVE_4VSRSU(n,b,base); SAVE_4VSRSU(n+4,b,base)
146#define SAVE_16VSRSU(n,b,base) SAVE_8VSRSU(n,b,base); SAVE_8VSRSU(n+8,b,base) 146#define SAVE_16VSRSU(n,b,base) SAVE_8VSRSU(n,b,base); SAVE_8VSRSU(n+8,b,base)
147#define SAVE_32VSRSU(n,b,base) SAVE_16VSRSU(n,b,base); SAVE_16VSRSU(n+16,b,base) 147#define SAVE_32VSRSU(n,b,base) SAVE_16VSRSU(n,b,base); SAVE_16VSRSU(n+16,b,base)
148#define REST_VSRU(n,b,base) li b,THREAD_VR0+(16*(n)); LXVD2X(n+32,base,b) 148#define REST_VSRU(n,b,base) li b,THREAD_VR0+(16*(n)); LXVD2X(n+32,R##base,R##b)
149#define REST_2VSRSU(n,b,base) REST_VSRU(n,b,base); REST_VSRU(n+1,b,base) 149#define REST_2VSRSU(n,b,base) REST_VSRU(n,b,base); REST_VSRU(n+1,b,base)
150#define REST_4VSRSU(n,b,base) REST_2VSRSU(n,b,base); REST_2VSRSU(n+2,b,base) 150#define REST_4VSRSU(n,b,base) REST_2VSRSU(n,b,base); REST_2VSRSU(n+2,b,base)
151#define REST_8VSRSU(n,b,base) REST_4VSRSU(n,b,base); REST_4VSRSU(n+4,b,base) 151#define REST_8VSRSU(n,b,base) REST_4VSRSU(n,b,base); REST_4VSRSU(n+4,b,base)
@@ -178,9 +178,24 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
178#define HMT_HIGH or 3,3,3 178#define HMT_HIGH or 3,3,3
179#define HMT_EXTRA_HIGH or 7,7,7 # power7 only 179#define HMT_EXTRA_HIGH or 7,7,7 # power7 only
180 180
181#ifdef CONFIG_PPC64
182#define ULONG_SIZE 8
183#else
184#define ULONG_SIZE 4
185#endif
186#define __VCPU_GPR(n) (VCPU_GPRS + (n * ULONG_SIZE))
187#define VCPU_GPR(n) __VCPU_GPR(__REG_##n)
188
181#ifdef __KERNEL__ 189#ifdef __KERNEL__
182#ifdef CONFIG_PPC64 190#ifdef CONFIG_PPC64
183 191
192#define STACKFRAMESIZE 256
193#define __STK_REG(i) (112 + ((i)-14)*8)
194#define STK_REG(i) __STK_REG(__REG_##i)
195
196#define __STK_PARAM(i) (48 + ((i)-3)*8)
197#define STK_PARAM(i) __STK_PARAM(__REG_##i)
198
184#define XGLUE(a,b) a##b 199#define XGLUE(a,b) a##b
185#define GLUE(a,b) XGLUE(a,b) 200#define GLUE(a,b) XGLUE(a,b)
186 201
@@ -295,14 +310,14 @@ n:
295 */ 310 */
296#ifdef __powerpc64__ 311#ifdef __powerpc64__
297#define LOAD_REG_IMMEDIATE(reg,expr) \ 312#define LOAD_REG_IMMEDIATE(reg,expr) \
298 lis (reg),(expr)@highest; \ 313 lis reg,(expr)@highest; \
299 ori (reg),(reg),(expr)@higher; \ 314 ori reg,reg,(expr)@higher; \
300 rldicr (reg),(reg),32,31; \ 315 rldicr reg,reg,32,31; \
301 oris (reg),(reg),(expr)@h; \ 316 oris reg,reg,(expr)@h; \
302 ori (reg),(reg),(expr)@l; 317 ori reg,reg,(expr)@l;
303 318
304#define LOAD_REG_ADDR(reg,name) \ 319#define LOAD_REG_ADDR(reg,name) \
305 ld (reg),name@got(r2) 320 ld reg,name@got(r2)
306 321
307#define LOAD_REG_ADDRBASE(reg,name) LOAD_REG_ADDR(reg,name) 322#define LOAD_REG_ADDRBASE(reg,name) LOAD_REG_ADDR(reg,name)
308#define ADDROFF(name) 0 323#define ADDROFF(name) 0
@@ -313,12 +328,12 @@ n:
313#else /* 32-bit */ 328#else /* 32-bit */
314 329
315#define LOAD_REG_IMMEDIATE(reg,expr) \ 330#define LOAD_REG_IMMEDIATE(reg,expr) \
316 lis (reg),(expr)@ha; \ 331 lis reg,(expr)@ha; \
317 addi (reg),(reg),(expr)@l; 332 addi reg,reg,(expr)@l;
318 333
319#define LOAD_REG_ADDR(reg,name) LOAD_REG_IMMEDIATE(reg, name) 334#define LOAD_REG_ADDR(reg,name) LOAD_REG_IMMEDIATE(reg, name)
320 335
321#define LOAD_REG_ADDRBASE(reg, name) lis (reg),name@ha 336#define LOAD_REG_ADDRBASE(reg, name) lis reg,name@ha
322#define ADDROFF(name) name@l 337#define ADDROFF(name) name@l
323 338
324/* offsets for stack frame layout */ 339/* offsets for stack frame layout */
@@ -372,9 +387,9 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)
372#ifdef CONFIG_PPC64 387#ifdef CONFIG_PPC64
373#define MTOCRF(FXM, RS) \ 388#define MTOCRF(FXM, RS) \
374 BEGIN_FTR_SECTION_NESTED(848); \ 389 BEGIN_FTR_SECTION_NESTED(848); \
375 mtcrf (FXM), (RS); \ 390 mtcrf (FXM), RS; \
376 FTR_SECTION_ELSE_NESTED(848); \ 391 FTR_SECTION_ELSE_NESTED(848); \
377 mtocrf (FXM), (RS); \ 392 mtocrf (FXM), RS; \
378 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_NOEXECUTE, 848) 393 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_NOEXECUTE, 848)
379#endif 394#endif
380 395
@@ -463,6 +478,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)
463#ifdef CONFIG_PPC_BOOK3S_64 478#ifdef CONFIG_PPC_BOOK3S_64
464#define RFI rfid 479#define RFI rfid
465#define MTMSRD(r) mtmsrd r 480#define MTMSRD(r) mtmsrd r
481#define MTMSR_EERI(reg) mtmsrd reg,1
466#else 482#else
467#define FIX_SRR1(ra, rb) 483#define FIX_SRR1(ra, rb)
468#ifndef CONFIG_40x 484#ifndef CONFIG_40x
@@ -471,6 +487,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)
471#define RFI rfi; b . /* Prevent prefetch past rfi */ 487#define RFI rfi; b . /* Prevent prefetch past rfi */
472#endif 488#endif
473#define MTMSRD(r) mtmsr r 489#define MTMSRD(r) mtmsr r
490#define MTMSR_EERI(reg) mtmsr reg
474#define CLR_TOP32(r) 491#define CLR_TOP32(r)
475#endif 492#endif
476 493
@@ -490,40 +507,46 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)
490#define cr7 7 507#define cr7 7
491 508
492 509
493/* General Purpose Registers (GPRs) */ 510/*
494 511 * General Purpose Registers (GPRs)
495#define r0 0 512 *
496#define r1 1 513 * The lower case r0-r31 should be used in preference to the upper
497#define r2 2 514 * case R0-R31 as they provide more error checking in the assembler.
498#define r3 3 515 * Use R0-31 only when really nessesary.
499#define r4 4 516 */
500#define r5 5 517
501#define r6 6 518#define r0 %r0
502#define r7 7 519#define r1 %r1
503#define r8 8 520#define r2 %r2
504#define r9 9 521#define r3 %r3
505#define r10 10 522#define r4 %r4
506#define r11 11 523#define r5 %r5
507#define r12 12 524#define r6 %r6
508#define r13 13 525#define r7 %r7
509#define r14 14 526#define r8 %r8
510#define r15 15 527#define r9 %r9
511#define r16 16 528#define r10 %r10
512#define r17 17 529#define r11 %r11
513#define r18 18 530#define r12 %r12
514#define r19 19 531#define r13 %r13
515#define r20 20 532#define r14 %r14
516#define r21 21 533#define r15 %r15
517#define r22 22 534#define r16 %r16
518#define r23 23 535#define r17 %r17
519#define r24 24 536#define r18 %r18
520#define r25 25 537#define r19 %r19
521#define r26 26 538#define r20 %r20
522#define r27 27 539#define r21 %r21
523#define r28 28 540#define r22 %r22
524#define r29 29 541#define r23 %r23
525#define r30 30 542#define r24 %r24
526#define r31 31 543#define r25 %r25
544#define r26 %r26
545#define r27 %r27
546#define r28 %r28
547#define r29 %r29
548#define r30 %r30
549#define r31 %r31
527 550
528 551
529/* Floating Point Registers (FPRs) */ 552/* Floating Point Registers (FPRs) */
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index 413a5eaef56..54b73a28c20 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -386,13 +386,12 @@ extern unsigned long cpuidle_disable;
386enum idle_boot_override {IDLE_NO_OVERRIDE = 0, IDLE_POWERSAVE_OFF}; 386enum idle_boot_override {IDLE_NO_OVERRIDE = 0, IDLE_POWERSAVE_OFF};
387 387
388extern int powersave_nap; /* set if nap mode can be used in idle loop */ 388extern int powersave_nap; /* set if nap mode can be used in idle loop */
389extern void power7_nap(void);
389 390
390#ifdef CONFIG_PSERIES_IDLE 391#ifdef CONFIG_PSERIES_IDLE
391extern void update_smt_snooze_delay(int snooze); 392extern void update_smt_snooze_delay(int snooze);
392extern int pseries_notify_cpuidle_add_cpu(int cpu);
393#else 393#else
394static inline void update_smt_snooze_delay(int snooze) {} 394static inline void update_smt_snooze_delay(int snooze) {}
395static inline int pseries_notify_cpuidle_add_cpu(int cpu) { return 0; }
396#endif 395#endif
397 396
398extern void flush_instruction_cache(void); 397extern void flush_instruction_cache(void);
diff --git a/arch/powerpc/include/asm/qe.h b/arch/powerpc/include/asm/qe.h
index 5e0b6d511e1..229571a4939 100644
--- a/arch/powerpc/include/asm/qe.h
+++ b/arch/powerpc/include/asm/qe.h
@@ -499,6 +499,7 @@ enum comm_dir {
499/* I-RAM */ 499/* I-RAM */
500#define QE_IRAM_IADD_AIE 0x80000000 /* Auto Increment Enable */ 500#define QE_IRAM_IADD_AIE 0x80000000 /* Auto Increment Enable */
501#define QE_IRAM_IADD_BADDR 0x00080000 /* Base Address */ 501#define QE_IRAM_IADD_BADDR 0x00080000 /* Base Address */
502#define QE_IRAM_READY 0x80000000 /* Ready */
502 503
503/* UPC */ 504/* UPC */
504#define UPGCR_PROTOCOL 0x80000000 /* protocol ul2 or pl2 */ 505#define UPGCR_PROTOCOL 0x80000000 /* protocol ul2 or pl2 */
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index f0cb7f461b9..638608677e2 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -491,6 +491,7 @@
491#define SPRN_SPRG1 0x111 /* Special Purpose Register General 1 */ 491#define SPRN_SPRG1 0x111 /* Special Purpose Register General 1 */
492#define SPRN_SPRG2 0x112 /* Special Purpose Register General 2 */ 492#define SPRN_SPRG2 0x112 /* Special Purpose Register General 2 */
493#define SPRN_SPRG3 0x113 /* Special Purpose Register General 3 */ 493#define SPRN_SPRG3 0x113 /* Special Purpose Register General 3 */
494#define SPRN_USPRG3 0x103 /* SPRG3 userspace read */
494#define SPRN_SPRG4 0x114 /* Special Purpose Register General 4 */ 495#define SPRN_SPRG4 0x114 /* Special Purpose Register General 4 */
495#define SPRN_SPRG5 0x115 /* Special Purpose Register General 5 */ 496#define SPRN_SPRG5 0x115 /* Special Purpose Register General 5 */
496#define SPRN_SPRG6 0x116 /* Special Purpose Register General 6 */ 497#define SPRN_SPRG6 0x116 /* Special Purpose Register General 6 */
@@ -753,14 +754,14 @@
753 * 64-bit server: 754 * 64-bit server:
754 * - SPRG0 unused (reserved for HV on Power4) 755 * - SPRG0 unused (reserved for HV on Power4)
755 * - SPRG2 scratch for exception vectors 756 * - SPRG2 scratch for exception vectors
756 * - SPRG3 unused (user visible) 757 * - SPRG3 CPU and NUMA node for VDSO getcpu (user visible)
757 * - HSPRG0 stores PACA in HV mode 758 * - HSPRG0 stores PACA in HV mode
758 * - HSPRG1 scratch for "HV" exceptions 759 * - HSPRG1 scratch for "HV" exceptions
759 * 760 *
760 * 64-bit embedded 761 * 64-bit embedded
761 * - SPRG0 generic exception scratch 762 * - SPRG0 generic exception scratch
762 * - SPRG2 TLB exception stack 763 * - SPRG2 TLB exception stack
763 * - SPRG3 unused (user visible) 764 * - SPRG3 CPU and NUMA node for VDSO getcpu (user visible)
764 * - SPRG4 unused (user visible) 765 * - SPRG4 unused (user visible)
765 * - SPRG6 TLB miss scratch (user visible, sorry !) 766 * - SPRG6 TLB miss scratch (user visible, sorry !)
766 * - SPRG7 critical exception scratch 767 * - SPRG7 critical exception scratch
@@ -1024,7 +1025,8 @@
1024/* Macros for setting and retrieving special purpose registers */ 1025/* Macros for setting and retrieving special purpose registers */
1025#ifndef __ASSEMBLY__ 1026#ifndef __ASSEMBLY__
1026#define mfmsr() ({unsigned long rval; \ 1027#define mfmsr() ({unsigned long rval; \
1027 asm volatile("mfmsr %0" : "=r" (rval)); rval;}) 1028 asm volatile("mfmsr %0" : "=r" (rval) : \
1029 : "memory"); rval;})
1028#ifdef CONFIG_PPC_BOOK3S_64 1030#ifdef CONFIG_PPC_BOOK3S_64
1029#define __mtmsrd(v, l) asm volatile("mtmsrd %0," __stringify(l) \ 1031#define __mtmsrd(v, l) asm volatile("mtmsrd %0," __stringify(l) \
1030 : : "r" (v) : "memory") 1032 : : "r" (v) : "memory")
diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
index 68831e9cf82..faf93529cbf 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -22,6 +22,12 @@
22 22
23#define THREAD_SIZE (1 << THREAD_SHIFT) 23#define THREAD_SIZE (1 << THREAD_SHIFT)
24 24
25#ifdef CONFIG_PPC64
26#define CURRENT_THREAD_INFO(dest, sp) clrrdi dest, sp, THREAD_SHIFT
27#else
28#define CURRENT_THREAD_INFO(dest, sp) rlwinm dest, sp, 0, 0, 31-THREAD_SHIFT
29#endif
30
25#ifndef __ASSEMBLY__ 31#ifndef __ASSEMBLY__
26#include <linux/cache.h> 32#include <linux/cache.h>
27#include <asm/processor.h> 33#include <asm/processor.h>
diff --git a/arch/powerpc/include/asm/trace.h b/arch/powerpc/include/asm/trace.h
index cbe2297d68b..5712f06905a 100644
--- a/arch/powerpc/include/asm/trace.h
+++ b/arch/powerpc/include/asm/trace.h
@@ -8,7 +8,7 @@
8 8
9struct pt_regs; 9struct pt_regs;
10 10
11TRACE_EVENT(irq_entry, 11DECLARE_EVENT_CLASS(ppc64_interrupt_class,
12 12
13 TP_PROTO(struct pt_regs *regs), 13 TP_PROTO(struct pt_regs *regs),
14 14
@@ -25,55 +25,32 @@ TRACE_EVENT(irq_entry,
25 TP_printk("pt_regs=%p", __entry->regs) 25 TP_printk("pt_regs=%p", __entry->regs)
26); 26);
27 27
28TRACE_EVENT(irq_exit, 28DEFINE_EVENT(ppc64_interrupt_class, irq_entry,
29 29
30 TP_PROTO(struct pt_regs *regs), 30 TP_PROTO(struct pt_regs *regs),
31 31
32 TP_ARGS(regs), 32 TP_ARGS(regs)
33
34 TP_STRUCT__entry(
35 __field(struct pt_regs *, regs)
36 ),
37
38 TP_fast_assign(
39 __entry->regs = regs;
40 ),
41
42 TP_printk("pt_regs=%p", __entry->regs)
43); 33);
44 34
45TRACE_EVENT(timer_interrupt_entry, 35DEFINE_EVENT(ppc64_interrupt_class, irq_exit,
46 36
47 TP_PROTO(struct pt_regs *regs), 37 TP_PROTO(struct pt_regs *regs),
48 38
49 TP_ARGS(regs), 39 TP_ARGS(regs)
50
51 TP_STRUCT__entry(
52 __field(struct pt_regs *, regs)
53 ),
54
55 TP_fast_assign(
56 __entry->regs = regs;
57 ),
58
59 TP_printk("pt_regs=%p", __entry->regs)
60); 40);
61 41
62TRACE_EVENT(timer_interrupt_exit, 42DEFINE_EVENT(ppc64_interrupt_class, timer_interrupt_entry,
63 43
64 TP_PROTO(struct pt_regs *regs), 44 TP_PROTO(struct pt_regs *regs),
65 45
66 TP_ARGS(regs), 46 TP_ARGS(regs)
47);
67 48
68 TP_STRUCT__entry( 49DEFINE_EVENT(ppc64_interrupt_class, timer_interrupt_exit,
69 __field(struct pt_regs *, regs)
70 ),
71 50
72 TP_fast_assign( 51 TP_PROTO(struct pt_regs *regs),
73 __entry->regs = regs;
74 ),
75 52
76 TP_printk("pt_regs=%p", __entry->regs) 53 TP_ARGS(regs)
77); 54);
78 55
79#ifdef CONFIG_PPC_PSERIES 56#ifdef CONFIG_PPC_PSERIES
diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h
index d3d1b5efd7e..bd377a36861 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -389,7 +389,6 @@
389#include <linux/compiler.h> 389#include <linux/compiler.h>
390#include <linux/linkage.h> 390#include <linux/linkage.h>
391 391
392#define __ARCH_WANT_IPC_PARSE_VERSION
393#define __ARCH_WANT_OLD_READDIR 392#define __ARCH_WANT_OLD_READDIR
394#define __ARCH_WANT_STAT64 393#define __ARCH_WANT_STAT64
395#define __ARCH_WANT_SYS_ALARM 394#define __ARCH_WANT_SYS_ALARM
diff --git a/arch/powerpc/include/asm/vdso.h b/arch/powerpc/include/asm/vdso.h
index dc0419b66f1..50f261bc3e9 100644
--- a/arch/powerpc/include/asm/vdso.h
+++ b/arch/powerpc/include/asm/vdso.h
@@ -22,6 +22,8 @@ extern unsigned long vdso64_rt_sigtramp;
22extern unsigned long vdso32_sigtramp; 22extern unsigned long vdso32_sigtramp;
23extern unsigned long vdso32_rt_sigtramp; 23extern unsigned long vdso32_rt_sigtramp;
24 24
25int __cpuinit vdso_getcpu_init(void);
26
25#else /* __ASSEMBLY__ */ 27#else /* __ASSEMBLY__ */
26 28
27#ifdef __VDSO64__ 29#ifdef __VDSO64__
diff --git a/arch/powerpc/include/asm/vio.h b/arch/powerpc/include/asm/vio.h
index b19adf751dd..df81cb72d1e 100644
--- a/arch/powerpc/include/asm/vio.h
+++ b/arch/powerpc/include/asm/vio.h
@@ -44,6 +44,8 @@
44 */ 44 */
45#define VIO_CMO_MIN_ENT 1562624 45#define VIO_CMO_MIN_ENT 1562624
46 46
47extern struct bus_type vio_bus_type;
48
47struct iommu_table; 49struct iommu_table;
48 50
49/* 51/*
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 83afacd3ba7..bb282dd8161 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -128,6 +128,7 @@ ifneq ($(CONFIG_XMON)$(CONFIG_KEXEC),)
128obj-y += ppc_save_regs.o 128obj-y += ppc_save_regs.o
129endif 129endif
130 130
131obj-$(CONFIG_EPAPR_PARAVIRT) += epapr_paravirt.o epapr_hcalls.o
131obj-$(CONFIG_KVM_GUEST) += kvm.o kvm_emul.o 132obj-$(CONFIG_KVM_GUEST) += kvm.o kvm_emul.o
132 133
133# Disable GCOV in odd or sensitive code 134# Disable GCOV in odd or sensitive code
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 52c7ad78242..e8995727b1c 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -76,6 +76,7 @@ int main(void)
76 DEFINE(SIGSEGV, SIGSEGV); 76 DEFINE(SIGSEGV, SIGSEGV);
77 DEFINE(NMI_MASK, NMI_MASK); 77 DEFINE(NMI_MASK, NMI_MASK);
78 DEFINE(THREAD_DSCR, offsetof(struct thread_struct, dscr)); 78 DEFINE(THREAD_DSCR, offsetof(struct thread_struct, dscr));
79 DEFINE(THREAD_DSCR_INHERIT, offsetof(struct thread_struct, dscr_inherit));
79#else 80#else
80 DEFINE(THREAD_INFO, offsetof(struct task_struct, stack)); 81 DEFINE(THREAD_INFO, offsetof(struct task_struct, stack));
81#endif /* CONFIG_PPC64 */ 82#endif /* CONFIG_PPC64 */
@@ -533,6 +534,7 @@ int main(void)
533 HSTATE_FIELD(HSTATE_VMHANDLER, vmhandler); 534 HSTATE_FIELD(HSTATE_VMHANDLER, vmhandler);
534 HSTATE_FIELD(HSTATE_SCRATCH0, scratch0); 535 HSTATE_FIELD(HSTATE_SCRATCH0, scratch0);
535 HSTATE_FIELD(HSTATE_SCRATCH1, scratch1); 536 HSTATE_FIELD(HSTATE_SCRATCH1, scratch1);
537 HSTATE_FIELD(HSTATE_SPRG3, sprg3);
536 HSTATE_FIELD(HSTATE_IN_GUEST, in_guest); 538 HSTATE_FIELD(HSTATE_IN_GUEST, in_guest);
537 HSTATE_FIELD(HSTATE_RESTORE_HID5, restore_hid5); 539 HSTATE_FIELD(HSTATE_RESTORE_HID5, restore_hid5);
538 HSTATE_FIELD(HSTATE_NAPPING, napping); 540 HSTATE_FIELD(HSTATE_NAPPING, napping);
diff --git a/arch/powerpc/kernel/cpu_setup_a2.S b/arch/powerpc/kernel/cpu_setup_a2.S
index ebc62f42a23..61f079e05b6 100644
--- a/arch/powerpc/kernel/cpu_setup_a2.S
+++ b/arch/powerpc/kernel/cpu_setup_a2.S
@@ -100,19 +100,19 @@ _icswx_skip_guest:
100 lis r4,(MMUCR0_TLBSEL_I|MMUCR0_ECL)@h 100 lis r4,(MMUCR0_TLBSEL_I|MMUCR0_ECL)@h
101 mtspr SPRN_MMUCR0, r4 101 mtspr SPRN_MMUCR0, r4
102 li r4,A2_IERAT_SIZE-1 102 li r4,A2_IERAT_SIZE-1
103 PPC_ERATWE(r4,r4,3) 103 PPC_ERATWE(R4,R4,3)
104 104
105 /* Now set the D-ERAT watermark to 31 */ 105 /* Now set the D-ERAT watermark to 31 */
106 lis r4,(MMUCR0_TLBSEL_D|MMUCR0_ECL)@h 106 lis r4,(MMUCR0_TLBSEL_D|MMUCR0_ECL)@h
107 mtspr SPRN_MMUCR0, r4 107 mtspr SPRN_MMUCR0, r4
108 li r4,A2_DERAT_SIZE-1 108 li r4,A2_DERAT_SIZE-1
109 PPC_ERATWE(r4,r4,3) 109 PPC_ERATWE(R4,R4,3)
110 110
111 /* And invalidate the beast just in case. That won't get rid of 111 /* And invalidate the beast just in case. That won't get rid of
112 * a bolted entry though it will be in LRU and so will go away eventually 112 * a bolted entry though it will be in LRU and so will go away eventually
113 * but let's not bother for now 113 * but let's not bother for now
114 */ 114 */
115 PPC_ERATILX(0,0,0) 115 PPC_ERATILX(0,0,R0)
1161: 1161:
117 blr 117 blr
118 118
diff --git a/arch/powerpc/kernel/dbell.c b/arch/powerpc/kernel/dbell.c
index 5b25c8060fd..a892680668d 100644
--- a/arch/powerpc/kernel/dbell.c
+++ b/arch/powerpc/kernel/dbell.c
@@ -28,6 +28,8 @@ void doorbell_setup_this_cpu(void)
28 28
29void doorbell_cause_ipi(int cpu, unsigned long data) 29void doorbell_cause_ipi(int cpu, unsigned long data)
30{ 30{
31 /* Order previous accesses vs. msgsnd, which is treated as a store */
32 mb();
31 ppc_msgsnd(PPC_DBELL, 0, data); 33 ppc_msgsnd(PPC_DBELL, 0, data);
32} 34}
33 35
diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c
index bcfdcd22c76..e4897523de4 100644
--- a/arch/powerpc/kernel/dma-iommu.c
+++ b/arch/powerpc/kernel/dma-iommu.c
@@ -83,11 +83,10 @@ static int dma_iommu_dma_supported(struct device *dev, u64 mask)
83 return 0; 83 return 0;
84 } 84 }
85 85
86 if ((tbl->it_offset + tbl->it_size) > (mask >> IOMMU_PAGE_SHIFT)) { 86 if (tbl->it_offset > (mask >> IOMMU_PAGE_SHIFT)) {
87 dev_info(dev, "Warning: IOMMU window too big for device mask\n"); 87 dev_info(dev, "Warning: IOMMU offset too big for device mask\n");
88 dev_info(dev, "mask: 0x%08llx, table end: 0x%08lx\n", 88 dev_info(dev, "mask: 0x%08llx, table offset: 0x%08lx\n",
89 mask, (tbl->it_offset + tbl->it_size) << 89 mask, tbl->it_offset << IOMMU_PAGE_SHIFT);
90 IOMMU_PAGE_SHIFT);
91 return 0; 90 return 0;
92 } else 91 } else
93 return 1; 92 return 1;
@@ -109,6 +108,7 @@ static u64 dma_iommu_get_required_mask(struct device *dev)
109struct dma_map_ops dma_iommu_ops = { 108struct dma_map_ops dma_iommu_ops = {
110 .alloc = dma_iommu_alloc_coherent, 109 .alloc = dma_iommu_alloc_coherent,
111 .free = dma_iommu_free_coherent, 110 .free = dma_iommu_free_coherent,
111 .mmap = dma_direct_mmap_coherent,
112 .map_sg = dma_iommu_map_sg, 112 .map_sg = dma_iommu_map_sg,
113 .unmap_sg = dma_iommu_unmap_sg, 113 .unmap_sg = dma_iommu_unmap_sg,
114 .dma_supported = dma_iommu_dma_supported, 114 .dma_supported = dma_iommu_dma_supported,
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index 4ab88dafb23..46943651da2 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -49,6 +49,7 @@ static u64 swiotlb_powerpc_get_required(struct device *dev)
49struct dma_map_ops swiotlb_dma_ops = { 49struct dma_map_ops swiotlb_dma_ops = {
50 .alloc = dma_direct_alloc_coherent, 50 .alloc = dma_direct_alloc_coherent,
51 .free = dma_direct_free_coherent, 51 .free = dma_direct_free_coherent,
52 .mmap = dma_direct_mmap_coherent,
52 .map_sg = swiotlb_map_sg_attrs, 53 .map_sg = swiotlb_map_sg_attrs,
53 .unmap_sg = swiotlb_unmap_sg_attrs, 54 .unmap_sg = swiotlb_unmap_sg_attrs,
54 .dma_supported = swiotlb_dma_supported, 55 .dma_supported = swiotlb_dma_supported,
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index b1ec983dcec..355b9d84b0f 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -11,6 +11,8 @@
11#include <linux/gfp.h> 11#include <linux/gfp.h>
12#include <linux/memblock.h> 12#include <linux/memblock.h>
13#include <linux/export.h> 13#include <linux/export.h>
14#include <linux/pci.h>
15#include <asm/vio.h>
14#include <asm/bug.h> 16#include <asm/bug.h>
15#include <asm/abs_addr.h> 17#include <asm/abs_addr.h>
16#include <asm/machdep.h> 18#include <asm/machdep.h>
@@ -65,6 +67,24 @@ void dma_direct_free_coherent(struct device *dev, size_t size,
65#endif 67#endif
66} 68}
67 69
70int dma_direct_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
71 void *cpu_addr, dma_addr_t handle, size_t size,
72 struct dma_attrs *attrs)
73{
74 unsigned long pfn;
75
76#ifdef CONFIG_NOT_COHERENT_CACHE
77 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
78 pfn = __dma_get_coherent_pfn((unsigned long)cpu_addr);
79#else
80 pfn = page_to_pfn(virt_to_page(cpu_addr));
81#endif
82 return remap_pfn_range(vma, vma->vm_start,
83 pfn + vma->vm_pgoff,
84 vma->vm_end - vma->vm_start,
85 vma->vm_page_prot);
86}
87
68static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, 88static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl,
69 int nents, enum dma_data_direction direction, 89 int nents, enum dma_data_direction direction,
70 struct dma_attrs *attrs) 90 struct dma_attrs *attrs)
@@ -154,6 +174,7 @@ static inline void dma_direct_sync_single(struct device *dev,
154struct dma_map_ops dma_direct_ops = { 174struct dma_map_ops dma_direct_ops = {
155 .alloc = dma_direct_alloc_coherent, 175 .alloc = dma_direct_alloc_coherent,
156 .free = dma_direct_free_coherent, 176 .free = dma_direct_free_coherent,
177 .mmap = dma_direct_mmap_coherent,
157 .map_sg = dma_direct_map_sg, 178 .map_sg = dma_direct_map_sg,
158 .unmap_sg = dma_direct_unmap_sg, 179 .unmap_sg = dma_direct_unmap_sg,
159 .dma_supported = dma_direct_dma_supported, 180 .dma_supported = dma_direct_dma_supported,
@@ -205,26 +226,15 @@ EXPORT_SYMBOL_GPL(dma_get_required_mask);
205 226
206static int __init dma_init(void) 227static int __init dma_init(void)
207{ 228{
208 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES); 229 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
230#ifdef CONFIG_PCI
231 dma_debug_add_bus(&pci_bus_type);
232#endif
233#ifdef CONFIG_IBMVIO
234 dma_debug_add_bus(&vio_bus_type);
235#endif
209 236
210 return 0; 237 return 0;
211} 238}
212fs_initcall(dma_init); 239fs_initcall(dma_init);
213 240
214int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
215 void *cpu_addr, dma_addr_t handle, size_t size)
216{
217 unsigned long pfn;
218
219#ifdef CONFIG_NOT_COHERENT_CACHE
220 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
221 pfn = __dma_get_coherent_pfn((unsigned long)cpu_addr);
222#else
223 pfn = page_to_pfn(virt_to_page(cpu_addr));
224#endif
225 return remap_pfn_range(vma, vma->vm_start,
226 pfn + vma->vm_pgoff,
227 vma->vm_end - vma->vm_start,
228 vma->vm_page_prot);
229}
230EXPORT_SYMBOL_GPL(dma_mmap_coherent);
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index ba3aeb4bc06..ead5016b02d 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -89,6 +89,10 @@ crit_transfer_to_handler:
89 mfspr r0,SPRN_SRR1 89 mfspr r0,SPRN_SRR1
90 stw r0,_SRR1(r11) 90 stw r0,_SRR1(r11)
91 91
92 /* set the stack limit to the current stack
93 * and set the limit to protect the thread_info
94 * struct
95 */
92 mfspr r8,SPRN_SPRG_THREAD 96 mfspr r8,SPRN_SPRG_THREAD
93 lwz r0,KSP_LIMIT(r8) 97 lwz r0,KSP_LIMIT(r8)
94 stw r0,SAVED_KSP_LIMIT(r11) 98 stw r0,SAVED_KSP_LIMIT(r11)
@@ -109,6 +113,10 @@ crit_transfer_to_handler:
109 mfspr r0,SPRN_SRR1 113 mfspr r0,SPRN_SRR1
110 stw r0,crit_srr1@l(0) 114 stw r0,crit_srr1@l(0)
111 115
116 /* set the stack limit to the current stack
117 * and set the limit to protect the thread_info
118 * struct
119 */
112 mfspr r8,SPRN_SPRG_THREAD 120 mfspr r8,SPRN_SPRG_THREAD
113 lwz r0,KSP_LIMIT(r8) 121 lwz r0,KSP_LIMIT(r8)
114 stw r0,saved_ksp_limit@l(0) 122 stw r0,saved_ksp_limit@l(0)
@@ -158,7 +166,7 @@ transfer_to_handler:
158 tophys(r11,r11) 166 tophys(r11,r11)
159 addi r11,r11,global_dbcr0@l 167 addi r11,r11,global_dbcr0@l
160#ifdef CONFIG_SMP 168#ifdef CONFIG_SMP
161 rlwinm r9,r1,0,0,(31-THREAD_SHIFT) 169 CURRENT_THREAD_INFO(r9, r1)
162 lwz r9,TI_CPU(r9) 170 lwz r9,TI_CPU(r9)
163 slwi r9,r9,3 171 slwi r9,r9,3
164 add r11,r11,r9 172 add r11,r11,r9
@@ -179,7 +187,7 @@ transfer_to_handler:
179 ble- stack_ovf /* then the kernel stack overflowed */ 187 ble- stack_ovf /* then the kernel stack overflowed */
1805: 1885:
181#if defined(CONFIG_6xx) || defined(CONFIG_E500) 189#if defined(CONFIG_6xx) || defined(CONFIG_E500)
182 rlwinm r9,r1,0,0,31-THREAD_SHIFT 190 CURRENT_THREAD_INFO(r9, r1)
183 tophys(r9,r9) /* check local flags */ 191 tophys(r9,r9) /* check local flags */
184 lwz r12,TI_LOCAL_FLAGS(r9) 192 lwz r12,TI_LOCAL_FLAGS(r9)
185 mtcrf 0x01,r12 193 mtcrf 0x01,r12
@@ -226,13 +234,7 @@ reenable_mmu: /* re-enable mmu so we can */
226 stw r3,16(r1) 234 stw r3,16(r1)
227 stw r4,20(r1) 235 stw r4,20(r1)
228 stw r5,24(r1) 236 stw r5,24(r1)
229 andi. r12,r12,MSR_PR
230 b 11f
231 bl trace_hardirqs_off
232 b 12f
23311:
234 bl trace_hardirqs_off 237 bl trace_hardirqs_off
23512:
236 lwz r5,24(r1) 238 lwz r5,24(r1)
237 lwz r4,20(r1) 239 lwz r4,20(r1)
238 lwz r3,16(r1) 240 lwz r3,16(r1)
@@ -333,7 +335,7 @@ _GLOBAL(DoSyscall)
333 mtmsr r11 335 mtmsr r11
3341: 3361:
335#endif /* CONFIG_TRACE_IRQFLAGS */ 337#endif /* CONFIG_TRACE_IRQFLAGS */
336 rlwinm r10,r1,0,0,(31-THREAD_SHIFT) /* current_thread_info() */ 338 CURRENT_THREAD_INFO(r10, r1)
337 lwz r11,TI_FLAGS(r10) 339 lwz r11,TI_FLAGS(r10)
338 andi. r11,r11,_TIF_SYSCALL_T_OR_A 340 andi. r11,r11,_TIF_SYSCALL_T_OR_A
339 bne- syscall_dotrace 341 bne- syscall_dotrace
@@ -354,7 +356,7 @@ ret_from_syscall:
354 bl do_show_syscall_exit 356 bl do_show_syscall_exit
355#endif 357#endif
356 mr r6,r3 358 mr r6,r3
357 rlwinm r12,r1,0,0,(31-THREAD_SHIFT) /* current_thread_info() */ 359 CURRENT_THREAD_INFO(r12, r1)
358 /* disable interrupts so current_thread_info()->flags can't change */ 360 /* disable interrupts so current_thread_info()->flags can't change */
359 LOAD_MSR_KERNEL(r10,MSR_KERNEL) /* doesn't include MSR_EE */ 361 LOAD_MSR_KERNEL(r10,MSR_KERNEL) /* doesn't include MSR_EE */
360 /* Note: We don't bother telling lockdep about it */ 362 /* Note: We don't bother telling lockdep about it */
@@ -815,7 +817,7 @@ ret_from_except:
815 817
816user_exc_return: /* r10 contains MSR_KERNEL here */ 818user_exc_return: /* r10 contains MSR_KERNEL here */
817 /* Check current_thread_info()->flags */ 819 /* Check current_thread_info()->flags */
818 rlwinm r9,r1,0,0,(31-THREAD_SHIFT) 820 CURRENT_THREAD_INFO(r9, r1)
819 lwz r9,TI_FLAGS(r9) 821 lwz r9,TI_FLAGS(r9)
820 andi. r0,r9,_TIF_USER_WORK_MASK 822 andi. r0,r9,_TIF_USER_WORK_MASK
821 bne do_work 823 bne do_work
@@ -835,7 +837,7 @@ restore_user:
835/* N.B. the only way to get here is from the beq following ret_from_except. */ 837/* N.B. the only way to get here is from the beq following ret_from_except. */
836resume_kernel: 838resume_kernel:
837 /* check current_thread_info->preempt_count */ 839 /* check current_thread_info->preempt_count */
838 rlwinm r9,r1,0,0,(31-THREAD_SHIFT) 840 CURRENT_THREAD_INFO(r9, r1)
839 lwz r0,TI_PREEMPT(r9) 841 lwz r0,TI_PREEMPT(r9)
840 cmpwi 0,r0,0 /* if non-zero, just restore regs and return */ 842 cmpwi 0,r0,0 /* if non-zero, just restore regs and return */
841 bne restore 843 bne restore
@@ -852,7 +854,7 @@ resume_kernel:
852 bl trace_hardirqs_off 854 bl trace_hardirqs_off
853#endif 855#endif
8541: bl preempt_schedule_irq 8561: bl preempt_schedule_irq
855 rlwinm r9,r1,0,0,(31-THREAD_SHIFT) 857 CURRENT_THREAD_INFO(r9, r1)
856 lwz r3,TI_FLAGS(r9) 858 lwz r3,TI_FLAGS(r9)
857 andi. r0,r3,_TIF_NEED_RESCHED 859 andi. r0,r3,_TIF_NEED_RESCHED
858 bne- 1b 860 bne- 1b
@@ -1122,7 +1124,7 @@ ret_from_debug_exc:
1122 lwz r10,SAVED_KSP_LIMIT(r1) 1124 lwz r10,SAVED_KSP_LIMIT(r1)
1123 stw r10,KSP_LIMIT(r9) 1125 stw r10,KSP_LIMIT(r9)
1124 lwz r9,THREAD_INFO-THREAD(r9) 1126 lwz r9,THREAD_INFO-THREAD(r9)
1125 rlwinm r10,r1,0,0,(31-THREAD_SHIFT) 1127 CURRENT_THREAD_INFO(r10, r1)
1126 lwz r10,TI_PREEMPT(r10) 1128 lwz r10,TI_PREEMPT(r10)
1127 stw r10,TI_PREEMPT(r9) 1129 stw r10,TI_PREEMPT(r9)
1128 RESTORE_xSRR(SRR0,SRR1); 1130 RESTORE_xSRR(SRR0,SRR1);
@@ -1156,7 +1158,7 @@ load_dbcr0:
1156 lis r11,global_dbcr0@ha 1158 lis r11,global_dbcr0@ha
1157 addi r11,r11,global_dbcr0@l 1159 addi r11,r11,global_dbcr0@l
1158#ifdef CONFIG_SMP 1160#ifdef CONFIG_SMP
1159 rlwinm r9,r1,0,0,(31-THREAD_SHIFT) 1161 CURRENT_THREAD_INFO(r9, r1)
1160 lwz r9,TI_CPU(r9) 1162 lwz r9,TI_CPU(r9)
1161 slwi r9,r9,3 1163 slwi r9,r9,3
1162 add r11,r11,r9 1164 add r11,r11,r9
@@ -1197,7 +1199,7 @@ recheck:
1197 LOAD_MSR_KERNEL(r10,MSR_KERNEL) 1199 LOAD_MSR_KERNEL(r10,MSR_KERNEL)
1198 SYNC 1200 SYNC
1199 MTMSRD(r10) /* disable interrupts */ 1201 MTMSRD(r10) /* disable interrupts */
1200 rlwinm r9,r1,0,0,(31-THREAD_SHIFT) 1202 CURRENT_THREAD_INFO(r9, r1)
1201 lwz r9,TI_FLAGS(r9) 1203 lwz r9,TI_FLAGS(r9)
1202 andi. r0,r9,_TIF_NEED_RESCHED 1204 andi. r0,r9,_TIF_NEED_RESCHED
1203 bne- do_resched 1205 bne- do_resched
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 5971c85df13..b40e0b4815b 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -146,7 +146,7 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
146 REST_2GPRS(7,r1) 146 REST_2GPRS(7,r1)
147 addi r9,r1,STACK_FRAME_OVERHEAD 147 addi r9,r1,STACK_FRAME_OVERHEAD
148#endif 148#endif
149 clrrdi r11,r1,THREAD_SHIFT 149 CURRENT_THREAD_INFO(r11, r1)
150 ld r10,TI_FLAGS(r11) 150 ld r10,TI_FLAGS(r11)
151 andi. r11,r10,_TIF_SYSCALL_T_OR_A 151 andi. r11,r10,_TIF_SYSCALL_T_OR_A
152 bne- syscall_dotrace 152 bne- syscall_dotrace
@@ -181,7 +181,7 @@ syscall_exit:
181 bl .do_show_syscall_exit 181 bl .do_show_syscall_exit
182 ld r3,RESULT(r1) 182 ld r3,RESULT(r1)
183#endif 183#endif
184 clrrdi r12,r1,THREAD_SHIFT 184 CURRENT_THREAD_INFO(r12, r1)
185 185
186 ld r8,_MSR(r1) 186 ld r8,_MSR(r1)
187#ifdef CONFIG_PPC_BOOK3S 187#ifdef CONFIG_PPC_BOOK3S
@@ -197,7 +197,16 @@ syscall_exit:
197 wrteei 0 197 wrteei 0
198#else 198#else
199 ld r10,PACAKMSR(r13) 199 ld r10,PACAKMSR(r13)
200 mtmsrd r10,1 200 /*
201 * For performance reasons we clear RI the same time that we
202 * clear EE. We only need to clear RI just before we restore r13
203 * below, but batching it with EE saves us one expensive mtmsrd call.
204 * We have to be careful to restore RI if we branch anywhere from
205 * here (eg syscall_exit_work).
206 */
207 li r9,MSR_RI
208 andc r11,r10,r9
209 mtmsrd r11,1
201#endif /* CONFIG_PPC_BOOK3E */ 210#endif /* CONFIG_PPC_BOOK3E */
202 211
203 ld r9,TI_FLAGS(r12) 212 ld r9,TI_FLAGS(r12)
@@ -214,17 +223,6 @@ BEGIN_FTR_SECTION
214END_FTR_SECTION_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS) 223END_FTR_SECTION_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS)
215 andi. r6,r8,MSR_PR 224 andi. r6,r8,MSR_PR
216 ld r4,_LINK(r1) 225 ld r4,_LINK(r1)
217 /*
218 * Clear RI before restoring r13. If we are returning to
219 * userspace and we take an exception after restoring r13,
220 * we end up corrupting the userspace r13 value.
221 */
222#ifdef CONFIG_PPC_BOOK3S
223 /* No MSR:RI on BookE */
224 li r12,MSR_RI
225 andc r11,r10,r12
226 mtmsrd r11,1 /* clear MSR.RI */
227#endif /* CONFIG_PPC_BOOK3S */
228 226
229 beq- 1f 227 beq- 1f
230 ACCOUNT_CPU_USER_EXIT(r11, r12) 228 ACCOUNT_CPU_USER_EXIT(r11, r12)
@@ -262,7 +260,7 @@ syscall_dotrace:
262 ld r7,GPR7(r1) 260 ld r7,GPR7(r1)
263 ld r8,GPR8(r1) 261 ld r8,GPR8(r1)
264 addi r9,r1,STACK_FRAME_OVERHEAD 262 addi r9,r1,STACK_FRAME_OVERHEAD
265 clrrdi r10,r1,THREAD_SHIFT 263 CURRENT_THREAD_INFO(r10, r1)
266 ld r10,TI_FLAGS(r10) 264 ld r10,TI_FLAGS(r10)
267 b .Lsyscall_dotrace_cont 265 b .Lsyscall_dotrace_cont
268 266
@@ -271,6 +269,9 @@ syscall_enosys:
271 b syscall_exit 269 b syscall_exit
272 270
273syscall_exit_work: 271syscall_exit_work:
272#ifdef CONFIG_PPC_BOOK3S
273 mtmsrd r10,1 /* Restore RI */
274#endif
274 /* If TIF_RESTOREALL is set, don't scribble on either r3 or ccr. 275 /* If TIF_RESTOREALL is set, don't scribble on either r3 or ccr.
275 If TIF_NOERROR is set, just save r3 as it is. */ 276 If TIF_NOERROR is set, just save r3 as it is. */
276 277
@@ -369,6 +370,12 @@ _GLOBAL(ret_from_fork)
369 li r3,0 370 li r3,0
370 b syscall_exit 371 b syscall_exit
371 372
373 .section ".toc","aw"
374DSCR_DEFAULT:
375 .tc dscr_default[TC],dscr_default
376
377 .section ".text"
378
372/* 379/*
373 * This routine switches between two different tasks. The process 380 * This routine switches between two different tasks. The process
374 * state of one is saved on its kernel stack. Then the state 381 * state of one is saved on its kernel stack. Then the state
@@ -499,7 +506,7 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
4992: 5062:
500#endif /* !CONFIG_PPC_BOOK3S */ 507#endif /* !CONFIG_PPC_BOOK3S */
501 508
502 clrrdi r7,r8,THREAD_SHIFT /* base of new stack */ 509 CURRENT_THREAD_INFO(r7, r8) /* base of new stack */
503 /* Note: this uses SWITCH_FRAME_SIZE rather than INT_FRAME_SIZE 510 /* Note: this uses SWITCH_FRAME_SIZE rather than INT_FRAME_SIZE
504 because we don't need to leave the 288-byte ABI gap at the 511 because we don't need to leave the 288-byte ABI gap at the
505 top of the kernel stack. */ 512 top of the kernel stack. */
@@ -508,9 +515,6 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
508 mr r1,r8 /* start using new stack pointer */ 515 mr r1,r8 /* start using new stack pointer */
509 std r7,PACAKSAVE(r13) 516 std r7,PACAKSAVE(r13)
510 517
511 ld r6,_CCR(r1)
512 mtcrf 0xFF,r6
513
514#ifdef CONFIG_ALTIVEC 518#ifdef CONFIG_ALTIVEC
515BEGIN_FTR_SECTION 519BEGIN_FTR_SECTION
516 ld r0,THREAD_VRSAVE(r4) 520 ld r0,THREAD_VRSAVE(r4)
@@ -519,14 +523,22 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
519#endif /* CONFIG_ALTIVEC */ 523#endif /* CONFIG_ALTIVEC */
520#ifdef CONFIG_PPC64 524#ifdef CONFIG_PPC64
521BEGIN_FTR_SECTION 525BEGIN_FTR_SECTION
526 lwz r6,THREAD_DSCR_INHERIT(r4)
527 ld r7,DSCR_DEFAULT@toc(2)
522 ld r0,THREAD_DSCR(r4) 528 ld r0,THREAD_DSCR(r4)
523 cmpd r0,r25 529 cmpwi r6,0
524 beq 1f 530 bne 1f
531 ld r0,0(r7)
5321: cmpd r0,r25
533 beq 2f
525 mtspr SPRN_DSCR,r0 534 mtspr SPRN_DSCR,r0
5261: 5352:
527END_FTR_SECTION_IFSET(CPU_FTR_DSCR) 536END_FTR_SECTION_IFSET(CPU_FTR_DSCR)
528#endif 537#endif
529 538
539 ld r6,_CCR(r1)
540 mtcrf 0xFF,r6
541
530 /* r3-r13 are destroyed -- Cort */ 542 /* r3-r13 are destroyed -- Cort */
531 REST_8GPRS(14, r1) 543 REST_8GPRS(14, r1)
532 REST_10GPRS(22, r1) 544 REST_10GPRS(22, r1)
@@ -558,7 +570,7 @@ _GLOBAL(ret_from_except_lite)
558 mtmsrd r10,1 /* Update machine state */ 570 mtmsrd r10,1 /* Update machine state */
559#endif /* CONFIG_PPC_BOOK3E */ 571#endif /* CONFIG_PPC_BOOK3E */
560 572
561 clrrdi r9,r1,THREAD_SHIFT /* current_thread_info() */ 573 CURRENT_THREAD_INFO(r9, r1)
562 ld r3,_MSR(r1) 574 ld r3,_MSR(r1)
563 ld r4,TI_FLAGS(r9) 575 ld r4,TI_FLAGS(r9)
564 andi. r3,r3,MSR_PR 576 andi. r3,r3,MSR_PR
@@ -601,7 +613,7 @@ resume_kernel:
6011: bl .preempt_schedule_irq 6131: bl .preempt_schedule_irq
602 614
603 /* Re-test flags and eventually loop */ 615 /* Re-test flags and eventually loop */
604 clrrdi r9,r1,THREAD_SHIFT 616 CURRENT_THREAD_INFO(r9, r1)
605 ld r4,TI_FLAGS(r9) 617 ld r4,TI_FLAGS(r9)
606 andi. r0,r4,_TIF_NEED_RESCHED 618 andi. r0,r4,_TIF_NEED_RESCHED
607 bne 1b 619 bne 1b
diff --git a/arch/powerpc/kernel/epapr_hcalls.S b/arch/powerpc/kernel/epapr_hcalls.S
new file mode 100644
index 00000000000..697b390ebfd
--- /dev/null
+++ b/arch/powerpc/kernel/epapr_hcalls.S
@@ -0,0 +1,25 @@
1/*
2 * Copyright (C) 2012 Freescale Semiconductor, Inc.
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
7 * 2 of the License, or (at your option) any later version.
8 */
9
10#include <linux/threads.h>
11#include <asm/reg.h>
12#include <asm/page.h>
13#include <asm/cputable.h>
14#include <asm/thread_info.h>
15#include <asm/ppc_asm.h>
16#include <asm/asm-offsets.h>
17
18/* Hypercall entry point. Will be patched with device tree instructions. */
19.global epapr_hypercall_start
20epapr_hypercall_start:
21 li r3, -1
22 nop
23 nop
24 nop
25 blr
diff --git a/arch/powerpc/kernel/epapr_paravirt.c b/arch/powerpc/kernel/epapr_paravirt.c
new file mode 100644
index 00000000000..028aeae370b
--- /dev/null
+++ b/arch/powerpc/kernel/epapr_paravirt.c
@@ -0,0 +1,52 @@
1/*
2 * ePAPR para-virtualization support.
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 * 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 *
17 * Copyright (C) 2012 Freescale Semiconductor, Inc.
18 */
19
20#include <linux/of.h>
21#include <asm/epapr_hcalls.h>
22#include <asm/cacheflush.h>
23#include <asm/code-patching.h>
24
25bool epapr_paravirt_enabled;
26
27static int __init epapr_paravirt_init(void)
28{
29 struct device_node *hyper_node;
30 const u32 *insts;
31 int len, i;
32
33 hyper_node = of_find_node_by_path("/hypervisor");
34 if (!hyper_node)
35 return -ENODEV;
36
37 insts = of_get_property(hyper_node, "hcall-instructions", &len);
38 if (!insts)
39 return -ENODEV;
40
41 if (len % 4 || len > (4 * 4))
42 return -ENODEV;
43
44 for (i = 0; i < (len / 4); i++)
45 patch_instruction(epapr_hypercall_start + i, insts[i]);
46
47 epapr_paravirt_enabled = true;
48
49 return 0;
50}
51
52early_initcall(epapr_paravirt_init);
diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
index 7215cc2495d..98be7f0cd22 100644
--- a/arch/powerpc/kernel/exceptions-64e.S
+++ b/arch/powerpc/kernel/exceptions-64e.S
@@ -222,7 +222,7 @@ exc_##n##_bad_stack: \
222 * interrupts happen before the wait instruction. 222 * interrupts happen before the wait instruction.
223 */ 223 */
224#define CHECK_NAPPING() \ 224#define CHECK_NAPPING() \
225 clrrdi r11,r1,THREAD_SHIFT; \ 225 CURRENT_THREAD_INFO(r11, r1); \
226 ld r10,TI_LOCAL_FLAGS(r11); \ 226 ld r10,TI_LOCAL_FLAGS(r11); \
227 andi. r9,r10,_TLF_NAPPING; \ 227 andi. r9,r10,_TLF_NAPPING; \
228 beq+ 1f; \ 228 beq+ 1f; \
@@ -903,7 +903,7 @@ skpinv: addi r6,r6,1 /* Increment */
903 bne 1b /* If not, repeat */ 903 bne 1b /* If not, repeat */
904 904
905 /* Invalidate all TLBs */ 905 /* Invalidate all TLBs */
906 PPC_TLBILX_ALL(0,0) 906 PPC_TLBILX_ALL(0,R0)
907 sync 907 sync
908 isync 908 isync
909 909
@@ -961,7 +961,7 @@ skpinv: addi r6,r6,1 /* Increment */
961 tlbwe 961 tlbwe
962 962
963 /* Invalidate TLB1 */ 963 /* Invalidate TLB1 */
964 PPC_TLBILX_ALL(0,0) 964 PPC_TLBILX_ALL(0,R0)
965 sync 965 sync
966 isync 966 isync
967 967
@@ -1020,7 +1020,7 @@ skpinv: addi r6,r6,1 /* Increment */
1020 tlbwe 1020 tlbwe
1021 1021
1022 /* Invalidate TLB1 */ 1022 /* Invalidate TLB1 */
1023 PPC_TLBILX_ALL(0,0) 1023 PPC_TLBILX_ALL(0,R0)
1024 sync 1024 sync
1025 isync 1025 isync
1026 1026
@@ -1138,7 +1138,7 @@ a2_tlbinit_after_iprot_flush:
1138 tlbwe 1138 tlbwe
1139#endif /* CONFIG_PPC_EARLY_DEBUG_WSP */ 1139#endif /* CONFIG_PPC_EARLY_DEBUG_WSP */
1140 1140
1141 PPC_TLBILX(0,0,0) 1141 PPC_TLBILX(0,0,R0)
1142 sync 1142 sync
1143 isync 1143 isync
1144 1144
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 1c06d297154..39aa97d3ff8 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -186,7 +186,7 @@ hardware_interrupt_hv:
186 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x800) 186 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x800)
187 187
188 MASKABLE_EXCEPTION_PSERIES(0x900, 0x900, decrementer) 188 MASKABLE_EXCEPTION_PSERIES(0x900, 0x900, decrementer)
189 MASKABLE_EXCEPTION_HV(0x980, 0x982, decrementer) 189 STD_EXCEPTION_HV(0x980, 0x982, hdecrementer)
190 190
191 STD_EXCEPTION_PSERIES(0xa00, 0xa00, trap_0a) 191 STD_EXCEPTION_PSERIES(0xa00, 0xa00, trap_0a)
192 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xa00) 192 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xa00)
@@ -239,6 +239,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)
239 * out of line to handle them 239 * out of line to handle them
240 */ 240 */
241 . = 0xe00 241 . = 0xe00
242hv_exception_trampoline:
242 b h_data_storage_hv 243 b h_data_storage_hv
243 . = 0xe20 244 . = 0xe20
244 b h_instr_storage_hv 245 b h_instr_storage_hv
@@ -485,6 +486,7 @@ machine_check_common:
485 486
486 STD_EXCEPTION_COMMON_ASYNC(0x500, hardware_interrupt, do_IRQ) 487 STD_EXCEPTION_COMMON_ASYNC(0x500, hardware_interrupt, do_IRQ)
487 STD_EXCEPTION_COMMON_ASYNC(0x900, decrementer, .timer_interrupt) 488 STD_EXCEPTION_COMMON_ASYNC(0x900, decrementer, .timer_interrupt)
489 STD_EXCEPTION_COMMON(0x980, hdecrementer, .hdec_interrupt)
488 STD_EXCEPTION_COMMON(0xa00, trap_0a, .unknown_exception) 490 STD_EXCEPTION_COMMON(0xa00, trap_0a, .unknown_exception)
489 STD_EXCEPTION_COMMON(0xb00, trap_0b, .unknown_exception) 491 STD_EXCEPTION_COMMON(0xb00, trap_0b, .unknown_exception)
490 STD_EXCEPTION_COMMON(0xd00, single_step, .single_step_exception) 492 STD_EXCEPTION_COMMON(0xd00, single_step, .single_step_exception)
@@ -851,7 +853,7 @@ BEGIN_FTR_SECTION
851 bne- do_ste_alloc /* If so handle it */ 853 bne- do_ste_alloc /* If so handle it */
852END_MMU_FTR_SECTION_IFCLR(MMU_FTR_SLB) 854END_MMU_FTR_SECTION_IFCLR(MMU_FTR_SLB)
853 855
854 clrrdi r11,r1,THREAD_SHIFT 856 CURRENT_THREAD_INFO(r11, r1)
855 lwz r0,TI_PREEMPT(r11) /* If we're in an "NMI" */ 857 lwz r0,TI_PREEMPT(r11) /* If we're in an "NMI" */
856 andis. r0,r0,NMI_MASK@h /* (i.e. an irq when soft-disabled) */ 858 andis. r0,r0,NMI_MASK@h /* (i.e. an irq when soft-disabled) */
857 bne 77f /* then don't call hash_page now */ 859 bne 77f /* then don't call hash_page now */
diff --git a/arch/powerpc/kernel/fpu.S b/arch/powerpc/kernel/fpu.S
index de369558bf0..e0ada05f2df 100644
--- a/arch/powerpc/kernel/fpu.S
+++ b/arch/powerpc/kernel/fpu.S
@@ -26,7 +26,7 @@
26#include <asm/ptrace.h> 26#include <asm/ptrace.h>
27 27
28#ifdef CONFIG_VSX 28#ifdef CONFIG_VSX
29#define REST_32FPVSRS(n,c,base) \ 29#define __REST_32FPVSRS(n,c,base) \
30BEGIN_FTR_SECTION \ 30BEGIN_FTR_SECTION \
31 b 2f; \ 31 b 2f; \
32END_FTR_SECTION_IFSET(CPU_FTR_VSX); \ 32END_FTR_SECTION_IFSET(CPU_FTR_VSX); \
@@ -35,7 +35,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX); \
352: REST_32VSRS(n,c,base); \ 352: REST_32VSRS(n,c,base); \
363: 363:
37 37
38#define SAVE_32FPVSRS(n,c,base) \ 38#define __SAVE_32FPVSRS(n,c,base) \
39BEGIN_FTR_SECTION \ 39BEGIN_FTR_SECTION \
40 b 2f; \ 40 b 2f; \
41END_FTR_SECTION_IFSET(CPU_FTR_VSX); \ 41END_FTR_SECTION_IFSET(CPU_FTR_VSX); \
@@ -44,9 +44,11 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX); \
442: SAVE_32VSRS(n,c,base); \ 442: SAVE_32VSRS(n,c,base); \
453: 453:
46#else 46#else
47#define REST_32FPVSRS(n,b,base) REST_32FPRS(n, base) 47#define __REST_32FPVSRS(n,b,base) REST_32FPRS(n, base)
48#define SAVE_32FPVSRS(n,b,base) SAVE_32FPRS(n, base) 48#define __SAVE_32FPVSRS(n,b,base) SAVE_32FPRS(n, base)
49#endif 49#endif
50#define REST_32FPVSRS(n,c,base) __REST_32FPVSRS(n,__REG_##c,__REG_##base)
51#define SAVE_32FPVSRS(n,c,base) __SAVE_32FPVSRS(n,__REG_##c,__REG_##base)
50 52
51/* 53/*
52 * This task wants to use the FPU now. 54 * This task wants to use the FPU now.
@@ -79,7 +81,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
79 beq 1f 81 beq 1f
80 toreal(r4) 82 toreal(r4)
81 addi r4,r4,THREAD /* want last_task_used_math->thread */ 83 addi r4,r4,THREAD /* want last_task_used_math->thread */
82 SAVE_32FPVSRS(0, r5, r4) 84 SAVE_32FPVSRS(0, R5, R4)
83 mffs fr0 85 mffs fr0
84 stfd fr0,THREAD_FPSCR(r4) 86 stfd fr0,THREAD_FPSCR(r4)
85 PPC_LL r5,PT_REGS(r4) 87 PPC_LL r5,PT_REGS(r4)
@@ -106,7 +108,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
106#endif 108#endif
107 lfd fr0,THREAD_FPSCR(r5) 109 lfd fr0,THREAD_FPSCR(r5)
108 MTFSF_L(fr0) 110 MTFSF_L(fr0)
109 REST_32FPVSRS(0, r4, r5) 111 REST_32FPVSRS(0, R4, R5)
110#ifndef CONFIG_SMP 112#ifndef CONFIG_SMP
111 subi r4,r5,THREAD 113 subi r4,r5,THREAD
112 fromreal(r4) 114 fromreal(r4)
@@ -140,7 +142,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
140 addi r3,r3,THREAD /* want THREAD of task */ 142 addi r3,r3,THREAD /* want THREAD of task */
141 PPC_LL r5,PT_REGS(r3) 143 PPC_LL r5,PT_REGS(r3)
142 PPC_LCMPI 0,r5,0 144 PPC_LCMPI 0,r5,0
143 SAVE_32FPVSRS(0, r4 ,r3) 145 SAVE_32FPVSRS(0, R4 ,R3)
144 mffs fr0 146 mffs fr0
145 stfd fr0,THREAD_FPSCR(r3) 147 stfd fr0,THREAD_FPSCR(r3)
146 beq 1f 148 beq 1f
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index bf99cfa6bbf..1fb78561096 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -63,11 +63,9 @@ ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new)
63 return -EINVAL; 63 return -EINVAL;
64 64
65 /* replace the text with the new text */ 65 /* replace the text with the new text */
66 if (probe_kernel_write((void *)ip, &new, MCOUNT_INSN_SIZE)) 66 if (patch_instruction((unsigned int *)ip, new))
67 return -EPERM; 67 return -EPERM;
68 68
69 flush_icache_range(ip, ip + 8);
70
71 return 0; 69 return 0;
72} 70}
73 71
@@ -212,12 +210,9 @@ __ftrace_make_nop(struct module *mod,
212 */ 210 */
213 op = 0x48000008; /* b +8 */ 211 op = 0x48000008; /* b +8 */
214 212
215 if (probe_kernel_write((void *)ip, &op, MCOUNT_INSN_SIZE)) 213 if (patch_instruction((unsigned int *)ip, op))
216 return -EPERM; 214 return -EPERM;
217 215
218
219 flush_icache_range(ip, ip + 8);
220
221 return 0; 216 return 0;
222} 217}
223 218
@@ -245,9 +240,9 @@ __ftrace_make_nop(struct module *mod,
245 240
246 /* 241 /*
247 * On PPC32 the trampoline looks like: 242 * On PPC32 the trampoline looks like:
248 * 0x3d, 0x60, 0x00, 0x00 lis r11,sym@ha 243 * 0x3d, 0x80, 0x00, 0x00 lis r12,sym@ha
249 * 0x39, 0x6b, 0x00, 0x00 addi r11,r11,sym@l 244 * 0x39, 0x8c, 0x00, 0x00 addi r12,r12,sym@l
250 * 0x7d, 0x69, 0x03, 0xa6 mtctr r11 245 * 0x7d, 0x89, 0x03, 0xa6 mtctr r12
251 * 0x4e, 0x80, 0x04, 0x20 bctr 246 * 0x4e, 0x80, 0x04, 0x20 bctr
252 */ 247 */
253 248
@@ -262,9 +257,9 @@ __ftrace_make_nop(struct module *mod,
262 pr_devel(" %08x %08x ", jmp[0], jmp[1]); 257 pr_devel(" %08x %08x ", jmp[0], jmp[1]);
263 258
264 /* verify that this is what we expect it to be */ 259 /* verify that this is what we expect it to be */
265 if (((jmp[0] & 0xffff0000) != 0x3d600000) || 260 if (((jmp[0] & 0xffff0000) != 0x3d800000) ||
266 ((jmp[1] & 0xffff0000) != 0x396b0000) || 261 ((jmp[1] & 0xffff0000) != 0x398c0000) ||
267 (jmp[2] != 0x7d6903a6) || 262 (jmp[2] != 0x7d8903a6) ||
268 (jmp[3] != 0x4e800420)) { 263 (jmp[3] != 0x4e800420)) {
269 printk(KERN_ERR "Not a trampoline\n"); 264 printk(KERN_ERR "Not a trampoline\n");
270 return -EINVAL; 265 return -EINVAL;
@@ -286,11 +281,9 @@ __ftrace_make_nop(struct module *mod,
286 281
287 op = PPC_INST_NOP; 282 op = PPC_INST_NOP;
288 283
289 if (probe_kernel_write((void *)ip, &op, MCOUNT_INSN_SIZE)) 284 if (patch_instruction((unsigned int *)ip, op))
290 return -EPERM; 285 return -EPERM;
291 286
292 flush_icache_range(ip, ip + 8);
293
294 return 0; 287 return 0;
295} 288}
296#endif /* PPC64 */ 289#endif /* PPC64 */
@@ -426,11 +419,9 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
426 419
427 pr_devel("write to %lx\n", rec->ip); 420 pr_devel("write to %lx\n", rec->ip);
428 421
429 if (probe_kernel_write((void *)ip, &op, MCOUNT_INSN_SIZE)) 422 if (patch_instruction((unsigned int *)ip, op))
430 return -EPERM; 423 return -EPERM;
431 424
432 flush_icache_range(ip, ip + 8);
433
434 return 0; 425 return 0;
435} 426}
436#endif /* CONFIG_PPC64 */ 427#endif /* CONFIG_PPC64 */
@@ -484,6 +475,58 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
484 return ret; 475 return ret;
485} 476}
486 477
478static int __ftrace_replace_code(struct dyn_ftrace *rec, int enable)
479{
480 unsigned long ftrace_addr = (unsigned long)FTRACE_ADDR;
481 int ret;
482
483 ret = ftrace_update_record(rec, enable);
484
485 switch (ret) {
486 case FTRACE_UPDATE_IGNORE:
487 return 0;
488 case FTRACE_UPDATE_MAKE_CALL:
489 return ftrace_make_call(rec, ftrace_addr);
490 case FTRACE_UPDATE_MAKE_NOP:
491 return ftrace_make_nop(NULL, rec, ftrace_addr);
492 }
493
494 return 0;
495}
496
497void ftrace_replace_code(int enable)
498{
499 struct ftrace_rec_iter *iter;
500 struct dyn_ftrace *rec;
501 int ret;
502
503 for (iter = ftrace_rec_iter_start(); iter;
504 iter = ftrace_rec_iter_next(iter)) {
505 rec = ftrace_rec_iter_record(iter);
506 ret = __ftrace_replace_code(rec, enable);
507 if (ret) {
508 ftrace_bug(ret, rec->ip);
509 return;
510 }
511 }
512}
513
514void arch_ftrace_update_code(int command)
515{
516 if (command & FTRACE_UPDATE_CALLS)
517 ftrace_replace_code(1);
518 else if (command & FTRACE_DISABLE_CALLS)
519 ftrace_replace_code(0);
520
521 if (command & FTRACE_UPDATE_TRACE_FUNC)
522 ftrace_update_ftrace_func(ftrace_trace_function);
523
524 if (command & FTRACE_START_FUNC_RET)
525 ftrace_enable_ftrace_graph_caller();
526 else if (command & FTRACE_STOP_FUNC_RET)
527 ftrace_disable_ftrace_graph_caller();
528}
529
487int __init ftrace_dyn_arch_init(void *data) 530int __init ftrace_dyn_arch_init(void *data)
488{ 531{
489 /* caller expects data to be zero */ 532 /* caller expects data to be zero */
@@ -587,18 +630,17 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
587 return; 630 return;
588 } 631 }
589 632
590 if (ftrace_push_return_trace(old, self_addr, &trace.depth, 0) == -EBUSY) {
591 *parent = old;
592 return;
593 }
594
595 trace.func = self_addr; 633 trace.func = self_addr;
634 trace.depth = current->curr_ret_stack + 1;
596 635
597 /* Only trace if the calling function expects to */ 636 /* Only trace if the calling function expects to */
598 if (!ftrace_graph_entry(&trace)) { 637 if (!ftrace_graph_entry(&trace)) {
599 current->curr_ret_stack--;
600 *parent = old; 638 *parent = old;
639 return;
601 } 640 }
641
642 if (ftrace_push_return_trace(old, self_addr, &trace.depth, 0) == -EBUSY)
643 *parent = old;
602} 644}
603#endif /* CONFIG_FUNCTION_GRAPH_TRACER */ 645#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
604 646
diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S
index 1f4434a3860..0f59863c3ad 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -192,7 +192,7 @@ _ENTRY(__early_start)
192 li r0,0 192 li r0,0
193 stwu r0,THREAD_SIZE-STACK_FRAME_OVERHEAD(r1) 193 stwu r0,THREAD_SIZE-STACK_FRAME_OVERHEAD(r1)
194 194
195 rlwinm r22,r1,0,0,31-THREAD_SHIFT /* current thread_info */ 195 CURRENT_THREAD_INFO(r22, r1)
196 stw r24, TI_CPU(r22) 196 stw r24, TI_CPU(r22)
197 197
198 bl early_init 198 bl early_init
@@ -556,8 +556,10 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV)
556 /* SPE Unavailable */ 556 /* SPE Unavailable */
557 START_EXCEPTION(SPEUnavailable) 557 START_EXCEPTION(SPEUnavailable)
558 NORMAL_EXCEPTION_PROLOG(SPE_UNAVAIL) 558 NORMAL_EXCEPTION_PROLOG(SPE_UNAVAIL)
559 bne load_up_spe 559 beq 1f
560 addi r3,r1,STACK_FRAME_OVERHEAD 560 bl load_up_spe
561 b fast_exception_return
5621: addi r3,r1,STACK_FRAME_OVERHEAD
561 EXC_XFER_EE_LITE(0x2010, KernelSPE) 563 EXC_XFER_EE_LITE(0x2010, KernelSPE)
562#else 564#else
563 EXCEPTION(0x2020, SPE_UNAVAIL, SPEUnavailable, \ 565 EXCEPTION(0x2020, SPE_UNAVAIL, SPEUnavailable, \
@@ -778,7 +780,7 @@ tlb_write_entry:
778/* Note that the SPE support is closely modeled after the AltiVec 780/* Note that the SPE support is closely modeled after the AltiVec
779 * support. Changes to one are likely to be applicable to the 781 * support. Changes to one are likely to be applicable to the
780 * other! */ 782 * other! */
781load_up_spe: 783_GLOBAL(load_up_spe)
782/* 784/*
783 * Disable SPE for the task which had SPE previously, 785 * Disable SPE for the task which had SPE previously,
784 * and save its SPE registers in its thread_struct. 786 * and save its SPE registers in its thread_struct.
@@ -826,20 +828,7 @@ load_up_spe:
826 subi r4,r5,THREAD 828 subi r4,r5,THREAD
827 stw r4,last_task_used_spe@l(r3) 829 stw r4,last_task_used_spe@l(r3)
828#endif /* !CONFIG_SMP */ 830#endif /* !CONFIG_SMP */
829 /* restore registers and return */ 831 blr
8302: REST_4GPRS(3, r11)
831 lwz r10,_CCR(r11)
832 REST_GPR(1, r11)
833 mtcr r10
834 lwz r10,_LINK(r11)
835 mtlr r10
836 REST_GPR(10, r11)
837 mtspr SPRN_SRR1,r9
838 mtspr SPRN_SRR0,r12
839 REST_GPR(9, r11)
840 REST_GPR(12, r11)
841 lwz r11,GPR11(r11)
842 rfi
843 832
844/* 833/*
845 * SPE unavailable trap from kernel - print a message, but let 834 * SPE unavailable trap from kernel - print a message, but let
diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c
index 2bc0584be81..956a4c496de 100644
--- a/arch/powerpc/kernel/hw_breakpoint.c
+++ b/arch/powerpc/kernel/hw_breakpoint.c
@@ -111,7 +111,7 @@ void arch_unregister_hw_breakpoint(struct perf_event *bp)
111 * and the single_step_dabr_instruction(), then cleanup the breakpoint 111 * and the single_step_dabr_instruction(), then cleanup the breakpoint
112 * restoration variables to prevent dangling pointers. 112 * restoration variables to prevent dangling pointers.
113 */ 113 */
114 if (bp->ctx->task) 114 if (bp->ctx && bp->ctx->task)
115 bp->ctx->task->thread.last_hit_ubp = NULL; 115 bp->ctx->task->thread.last_hit_ubp = NULL;
116} 116}
117 117
@@ -253,7 +253,7 @@ int __kprobes hw_breakpoint_handler(struct die_args *args)
253 253
254 /* Do not emulate user-space instructions, instead single-step them */ 254 /* Do not emulate user-space instructions, instead single-step them */
255 if (user_mode(regs)) { 255 if (user_mode(regs)) {
256 bp->ctx->task->thread.last_hit_ubp = bp; 256 current->thread.last_hit_ubp = bp;
257 regs->msr |= MSR_SE; 257 regs->msr |= MSR_SE;
258 goto out; 258 goto out;
259 } 259 }
diff --git a/arch/powerpc/kernel/idle_6xx.S b/arch/powerpc/kernel/idle_6xx.S
index 15c611de1ee..1686916cc7f 100644
--- a/arch/powerpc/kernel/idle_6xx.S
+++ b/arch/powerpc/kernel/idle_6xx.S
@@ -135,7 +135,7 @@ BEGIN_FTR_SECTION
135 DSSALL 135 DSSALL
136 sync 136 sync
137END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) 137END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
138 rlwinm r9,r1,0,0,31-THREAD_SHIFT /* current thread_info */ 138 CURRENT_THREAD_INFO(r9, r1)
139 lwz r8,TI_LOCAL_FLAGS(r9) /* set napping bit */ 139 lwz r8,TI_LOCAL_FLAGS(r9) /* set napping bit */
140 ori r8,r8,_TLF_NAPPING /* so when we take an exception */ 140 ori r8,r8,_TLF_NAPPING /* so when we take an exception */
141 stw r8,TI_LOCAL_FLAGS(r9) /* it will return to our caller */ 141 stw r8,TI_LOCAL_FLAGS(r9) /* it will return to our caller */
@@ -158,7 +158,7 @@ _GLOBAL(power_save_ppc32_restore)
158 stw r9,_NIP(r11) /* make it do a blr */ 158 stw r9,_NIP(r11) /* make it do a blr */
159 159
160#ifdef CONFIG_SMP 160#ifdef CONFIG_SMP
161 rlwinm r12,r11,0,0,31-THREAD_SHIFT 161 CURRENT_THREAD_INFO(r12, r11)
162 lwz r11,TI_CPU(r12) /* get cpu number * 4 */ 162 lwz r11,TI_CPU(r12) /* get cpu number * 4 */
163 slwi r11,r11,2 163 slwi r11,r11,2
164#else 164#else
diff --git a/arch/powerpc/kernel/idle_book3e.S b/arch/powerpc/kernel/idle_book3e.S
index ff007b59448..4c7cb400858 100644
--- a/arch/powerpc/kernel/idle_book3e.S
+++ b/arch/powerpc/kernel/idle_book3e.S
@@ -60,7 +60,7 @@ _GLOBAL(book3e_idle)
601: /* Let's set the _TLF_NAPPING flag so interrupts make us return 601: /* Let's set the _TLF_NAPPING flag so interrupts make us return
61 * to the right spot 61 * to the right spot
62 */ 62 */
63 clrrdi r11,r1,THREAD_SHIFT 63 CURRENT_THREAD_INFO(r11, r1)
64 ld r10,TI_LOCAL_FLAGS(r11) 64 ld r10,TI_LOCAL_FLAGS(r11)
65 ori r10,r10,_TLF_NAPPING 65 ori r10,r10,_TLF_NAPPING
66 std r10,TI_LOCAL_FLAGS(r11) 66 std r10,TI_LOCAL_FLAGS(r11)
diff --git a/arch/powerpc/kernel/idle_e500.S b/arch/powerpc/kernel/idle_e500.S
index 4f0ab85f378..15448668988 100644
--- a/arch/powerpc/kernel/idle_e500.S
+++ b/arch/powerpc/kernel/idle_e500.S
@@ -21,7 +21,7 @@
21 .text 21 .text
22 22
23_GLOBAL(e500_idle) 23_GLOBAL(e500_idle)
24 rlwinm r3,r1,0,0,31-THREAD_SHIFT /* current thread_info */ 24 CURRENT_THREAD_INFO(r3, r1)
25 lwz r4,TI_LOCAL_FLAGS(r3) /* set napping bit */ 25 lwz r4,TI_LOCAL_FLAGS(r3) /* set napping bit */
26 ori r4,r4,_TLF_NAPPING /* so when we take an exception */ 26 ori r4,r4,_TLF_NAPPING /* so when we take an exception */
27 stw r4,TI_LOCAL_FLAGS(r3) /* it will return to our caller */ 27 stw r4,TI_LOCAL_FLAGS(r3) /* it will return to our caller */
@@ -96,7 +96,7 @@ _GLOBAL(power_save_ppc32_restore)
96 stw r9,_NIP(r11) /* make it do a blr */ 96 stw r9,_NIP(r11) /* make it do a blr */
97 97
98#ifdef CONFIG_SMP 98#ifdef CONFIG_SMP
99 rlwinm r12,r1,0,0,31-THREAD_SHIFT 99 CURRENT_THREAD_INFO(r12, r1)
100 lwz r11,TI_CPU(r12) /* get cpu number * 4 */ 100 lwz r11,TI_CPU(r12) /* get cpu number * 4 */
101 slwi r11,r11,2 101 slwi r11,r11,2
102#else 102#else
diff --git a/arch/powerpc/kernel/idle_power4.S b/arch/powerpc/kernel/idle_power4.S
index 2c71b0fc9f9..e3edaa18991 100644
--- a/arch/powerpc/kernel/idle_power4.S
+++ b/arch/powerpc/kernel/idle_power4.S
@@ -59,7 +59,7 @@ BEGIN_FTR_SECTION
59 DSSALL 59 DSSALL
60 sync 60 sync
61END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) 61END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
62 clrrdi r9,r1,THREAD_SHIFT /* current thread_info */ 62 CURRENT_THREAD_INFO(r9, r1)
63 ld r8,TI_LOCAL_FLAGS(r9) /* set napping bit */ 63 ld r8,TI_LOCAL_FLAGS(r9) /* set napping bit */
64 ori r8,r8,_TLF_NAPPING /* so when we take an exception */ 64 ori r8,r8,_TLF_NAPPING /* so when we take an exception */
65 std r8,TI_LOCAL_FLAGS(r9) /* it will return to our caller */ 65 std r8,TI_LOCAL_FLAGS(r9) /* it will return to our caller */
diff --git a/arch/powerpc/kernel/idle_power7.S b/arch/powerpc/kernel/idle_power7.S
index 7140d838339..e11863f4e59 100644
--- a/arch/powerpc/kernel/idle_power7.S
+++ b/arch/powerpc/kernel/idle_power7.S
@@ -28,7 +28,9 @@ _GLOBAL(power7_idle)
28 lwz r4,ADDROFF(powersave_nap)(r3) 28 lwz r4,ADDROFF(powersave_nap)(r3)
29 cmpwi 0,r4,0 29 cmpwi 0,r4,0
30 beqlr 30 beqlr
31 /* fall through */
31 32
33_GLOBAL(power7_nap)
32 /* NAP is a state loss, we create a regs frame on the 34 /* NAP is a state loss, we create a regs frame on the
33 * stack, fill it up with the state we care about and 35 * stack, fill it up with the state we care about and
34 * stick a pointer to it in PACAR1. We really only 36 * stick a pointer to it in PACAR1. We really only
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index 359f078571c..ff5a6ce027b 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -33,6 +33,9 @@
33#include <linux/bitmap.h> 33#include <linux/bitmap.h>
34#include <linux/iommu-helper.h> 34#include <linux/iommu-helper.h>
35#include <linux/crash_dump.h> 35#include <linux/crash_dump.h>
36#include <linux/hash.h>
37#include <linux/fault-inject.h>
38#include <linux/pci.h>
36#include <asm/io.h> 39#include <asm/io.h>
37#include <asm/prom.h> 40#include <asm/prom.h>
38#include <asm/iommu.h> 41#include <asm/iommu.h>
@@ -40,6 +43,7 @@
40#include <asm/machdep.h> 43#include <asm/machdep.h>
41#include <asm/kdump.h> 44#include <asm/kdump.h>
42#include <asm/fadump.h> 45#include <asm/fadump.h>
46#include <asm/vio.h>
43 47
44#define DBG(...) 48#define DBG(...)
45 49
@@ -58,6 +62,114 @@ static int __init setup_iommu(char *str)
58 62
59__setup("iommu=", setup_iommu); 63__setup("iommu=", setup_iommu);
60 64
65static DEFINE_PER_CPU(unsigned int, iommu_pool_hash);
66
67/*
68 * We precalculate the hash to avoid doing it on every allocation.
69 *
70 * The hash is important to spread CPUs across all the pools. For example,
71 * on a POWER7 with 4 way SMT we want interrupts on the primary threads and
72 * with 4 pools all primary threads would map to the same pool.
73 */
74static int __init setup_iommu_pool_hash(void)
75{
76 unsigned int i;
77
78 for_each_possible_cpu(i)
79 per_cpu(iommu_pool_hash, i) = hash_32(i, IOMMU_POOL_HASHBITS);
80
81 return 0;
82}
83subsys_initcall(setup_iommu_pool_hash);
84
85#ifdef CONFIG_FAIL_IOMMU
86
87static DECLARE_FAULT_ATTR(fail_iommu);
88
89static int __init setup_fail_iommu(char *str)
90{
91 return setup_fault_attr(&fail_iommu, str);
92}
93__setup("fail_iommu=", setup_fail_iommu);
94
95static bool should_fail_iommu(struct device *dev)
96{
97 return dev->archdata.fail_iommu && should_fail(&fail_iommu, 1);
98}
99
100static int __init fail_iommu_debugfs(void)
101{
102 struct dentry *dir = fault_create_debugfs_attr("fail_iommu",
103 NULL, &fail_iommu);
104
105 return IS_ERR(dir) ? PTR_ERR(dir) : 0;
106}
107late_initcall(fail_iommu_debugfs);
108
109static ssize_t fail_iommu_show(struct device *dev,
110 struct device_attribute *attr, char *buf)
111{
112 return sprintf(buf, "%d\n", dev->archdata.fail_iommu);
113}
114
115static ssize_t fail_iommu_store(struct device *dev,
116 struct device_attribute *attr, const char *buf,
117 size_t count)
118{
119 int i;
120
121 if (count > 0 && sscanf(buf, "%d", &i) > 0)
122 dev->archdata.fail_iommu = (i == 0) ? 0 : 1;
123
124 return count;
125}
126
127static DEVICE_ATTR(fail_iommu, S_IRUGO|S_IWUSR, fail_iommu_show,
128 fail_iommu_store);
129
130static int fail_iommu_bus_notify(struct notifier_block *nb,
131 unsigned long action, void *data)
132{
133 struct device *dev = data;
134
135 if (action == BUS_NOTIFY_ADD_DEVICE) {
136 if (device_create_file(dev, &dev_attr_fail_iommu))
137 pr_warn("Unable to create IOMMU fault injection sysfs "
138 "entries\n");
139 } else if (action == BUS_NOTIFY_DEL_DEVICE) {
140 device_remove_file(dev, &dev_attr_fail_iommu);
141 }
142
143 return 0;
144}
145
146static struct notifier_block fail_iommu_bus_notifier = {
147 .notifier_call = fail_iommu_bus_notify
148};
149
150static int __init fail_iommu_setup(void)
151{
152#ifdef CONFIG_PCI
153 bus_register_notifier(&pci_bus_type, &fail_iommu_bus_notifier);
154#endif
155#ifdef CONFIG_IBMVIO
156 bus_register_notifier(&vio_bus_type, &fail_iommu_bus_notifier);
157#endif
158
159 return 0;
160}
161/*
162 * Must execute after PCI and VIO subsystem have initialised but before
163 * devices are probed.
164 */
165arch_initcall(fail_iommu_setup);
166#else
167static inline bool should_fail_iommu(struct device *dev)
168{
169 return false;
170}
171#endif
172
61static unsigned long iommu_range_alloc(struct device *dev, 173static unsigned long iommu_range_alloc(struct device *dev,
62 struct iommu_table *tbl, 174 struct iommu_table *tbl,
63 unsigned long npages, 175 unsigned long npages,
@@ -71,6 +183,9 @@ static unsigned long iommu_range_alloc(struct device *dev,
71 int pass = 0; 183 int pass = 0;
72 unsigned long align_mask; 184 unsigned long align_mask;
73 unsigned long boundary_size; 185 unsigned long boundary_size;
186 unsigned long flags;
187 unsigned int pool_nr;
188 struct iommu_pool *pool;
74 189
75 align_mask = 0xffffffffffffffffl >> (64 - align_order); 190 align_mask = 0xffffffffffffffffl >> (64 - align_order);
76 191
@@ -83,36 +198,49 @@ static unsigned long iommu_range_alloc(struct device *dev,
83 return DMA_ERROR_CODE; 198 return DMA_ERROR_CODE;
84 } 199 }
85 200
86 if (handle && *handle) 201 if (should_fail_iommu(dev))
87 start = *handle; 202 return DMA_ERROR_CODE;
203
204 /*
205 * We don't need to disable preemption here because any CPU can
206 * safely use any IOMMU pool.
207 */
208 pool_nr = __raw_get_cpu_var(iommu_pool_hash) & (tbl->nr_pools - 1);
209
210 if (largealloc)
211 pool = &(tbl->large_pool);
88 else 212 else
89 start = largealloc ? tbl->it_largehint : tbl->it_hint; 213 pool = &(tbl->pools[pool_nr]);
90 214
91 /* Use only half of the table for small allocs (15 pages or less) */ 215 spin_lock_irqsave(&(pool->lock), flags);
92 limit = largealloc ? tbl->it_size : tbl->it_halfpoint;
93 216
94 if (largealloc && start < tbl->it_halfpoint) 217again:
95 start = tbl->it_halfpoint; 218 if ((pass == 0) && handle && *handle)
219 start = *handle;
220 else
221 start = pool->hint;
222
223 limit = pool->end;
96 224
97 /* The case below can happen if we have a small segment appended 225 /* The case below can happen if we have a small segment appended
98 * to a large, or when the previous alloc was at the very end of 226 * to a large, or when the previous alloc was at the very end of
99 * the available space. If so, go back to the initial start. 227 * the available space. If so, go back to the initial start.
100 */ 228 */
101 if (start >= limit) 229 if (start >= limit)
102 start = largealloc ? tbl->it_largehint : tbl->it_hint; 230 start = pool->start;
103
104 again:
105 231
106 if (limit + tbl->it_offset > mask) { 232 if (limit + tbl->it_offset > mask) {
107 limit = mask - tbl->it_offset + 1; 233 limit = mask - tbl->it_offset + 1;
108 /* If we're constrained on address range, first try 234 /* If we're constrained on address range, first try
109 * at the masked hint to avoid O(n) search complexity, 235 * at the masked hint to avoid O(n) search complexity,
110 * but on second pass, start at 0. 236 * but on second pass, start at 0 in pool 0.
111 */ 237 */
112 if ((start & mask) >= limit || pass > 0) 238 if ((start & mask) >= limit || pass > 0) {
113 start = 0; 239 pool = &(tbl->pools[0]);
114 else 240 start = pool->start;
241 } else {
115 start &= mask; 242 start &= mask;
243 }
116 } 244 }
117 245
118 if (dev) 246 if (dev)
@@ -126,16 +254,25 @@ static unsigned long iommu_range_alloc(struct device *dev,
126 tbl->it_offset, boundary_size >> IOMMU_PAGE_SHIFT, 254 tbl->it_offset, boundary_size >> IOMMU_PAGE_SHIFT,
127 align_mask); 255 align_mask);
128 if (n == -1) { 256 if (n == -1) {
129 if (likely(pass < 2)) { 257 if (likely(pass == 0)) {
130 /* First failure, just rescan the half of the table. 258 /* First try the pool from the start */
131 * Second failure, rescan the other half of the table. 259 pool->hint = pool->start;
132 */
133 start = (largealloc ^ pass) ? tbl->it_halfpoint : 0;
134 limit = pass ? tbl->it_size : limit;
135 pass++; 260 pass++;
136 goto again; 261 goto again;
262
263 } else if (pass <= tbl->nr_pools) {
264 /* Now try scanning all the other pools */
265 spin_unlock(&(pool->lock));
266 pool_nr = (pool_nr + 1) & (tbl->nr_pools - 1);
267 pool = &tbl->pools[pool_nr];
268 spin_lock(&(pool->lock));
269 pool->hint = pool->start;
270 pass++;
271 goto again;
272
137 } else { 273 } else {
138 /* Third failure, give up */ 274 /* Give up */
275 spin_unlock_irqrestore(&(pool->lock), flags);
139 return DMA_ERROR_CODE; 276 return DMA_ERROR_CODE;
140 } 277 }
141 } 278 }
@@ -145,10 +282,10 @@ static unsigned long iommu_range_alloc(struct device *dev,
145 /* Bump the hint to a new block for small allocs. */ 282 /* Bump the hint to a new block for small allocs. */
146 if (largealloc) { 283 if (largealloc) {
147 /* Don't bump to new block to avoid fragmentation */ 284 /* Don't bump to new block to avoid fragmentation */
148 tbl->it_largehint = end; 285 pool->hint = end;
149 } else { 286 } else {
150 /* Overflow will be taken care of at the next allocation */ 287 /* Overflow will be taken care of at the next allocation */
151 tbl->it_hint = (end + tbl->it_blocksize - 1) & 288 pool->hint = (end + tbl->it_blocksize - 1) &
152 ~(tbl->it_blocksize - 1); 289 ~(tbl->it_blocksize - 1);
153 } 290 }
154 291
@@ -156,6 +293,8 @@ static unsigned long iommu_range_alloc(struct device *dev,
156 if (handle) 293 if (handle)
157 *handle = end; 294 *handle = end;
158 295
296 spin_unlock_irqrestore(&(pool->lock), flags);
297
159 return n; 298 return n;
160} 299}
161 300
@@ -165,18 +304,14 @@ static dma_addr_t iommu_alloc(struct device *dev, struct iommu_table *tbl,
165 unsigned long mask, unsigned int align_order, 304 unsigned long mask, unsigned int align_order,
166 struct dma_attrs *attrs) 305 struct dma_attrs *attrs)
167{ 306{
168 unsigned long entry, flags; 307 unsigned long entry;
169 dma_addr_t ret = DMA_ERROR_CODE; 308 dma_addr_t ret = DMA_ERROR_CODE;
170 int build_fail; 309 int build_fail;
171 310
172 spin_lock_irqsave(&(tbl->it_lock), flags);
173
174 entry = iommu_range_alloc(dev, tbl, npages, NULL, mask, align_order); 311 entry = iommu_range_alloc(dev, tbl, npages, NULL, mask, align_order);
175 312
176 if (unlikely(entry == DMA_ERROR_CODE)) { 313 if (unlikely(entry == DMA_ERROR_CODE))
177 spin_unlock_irqrestore(&(tbl->it_lock), flags);
178 return DMA_ERROR_CODE; 314 return DMA_ERROR_CODE;
179 }
180 315
181 entry += tbl->it_offset; /* Offset into real TCE table */ 316 entry += tbl->it_offset; /* Offset into real TCE table */
182 ret = entry << IOMMU_PAGE_SHIFT; /* Set the return dma address */ 317 ret = entry << IOMMU_PAGE_SHIFT; /* Set the return dma address */
@@ -193,8 +328,6 @@ static dma_addr_t iommu_alloc(struct device *dev, struct iommu_table *tbl,
193 */ 328 */
194 if (unlikely(build_fail)) { 329 if (unlikely(build_fail)) {
195 __iommu_free(tbl, ret, npages); 330 __iommu_free(tbl, ret, npages);
196
197 spin_unlock_irqrestore(&(tbl->it_lock), flags);
198 return DMA_ERROR_CODE; 331 return DMA_ERROR_CODE;
199 } 332 }
200 333
@@ -202,16 +335,14 @@ static dma_addr_t iommu_alloc(struct device *dev, struct iommu_table *tbl,
202 if (ppc_md.tce_flush) 335 if (ppc_md.tce_flush)
203 ppc_md.tce_flush(tbl); 336 ppc_md.tce_flush(tbl);
204 337
205 spin_unlock_irqrestore(&(tbl->it_lock), flags);
206
207 /* Make sure updates are seen by hardware */ 338 /* Make sure updates are seen by hardware */
208 mb(); 339 mb();
209 340
210 return ret; 341 return ret;
211} 342}
212 343
213static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr, 344static bool iommu_free_check(struct iommu_table *tbl, dma_addr_t dma_addr,
214 unsigned int npages) 345 unsigned int npages)
215{ 346{
216 unsigned long entry, free_entry; 347 unsigned long entry, free_entry;
217 348
@@ -231,20 +362,57 @@ static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
231 printk(KERN_INFO "\tindex = 0x%llx\n", (u64)tbl->it_index); 362 printk(KERN_INFO "\tindex = 0x%llx\n", (u64)tbl->it_index);
232 WARN_ON(1); 363 WARN_ON(1);
233 } 364 }
234 return; 365
366 return false;
367 }
368
369 return true;
370}
371
372static struct iommu_pool *get_pool(struct iommu_table *tbl,
373 unsigned long entry)
374{
375 struct iommu_pool *p;
376 unsigned long largepool_start = tbl->large_pool.start;
377
378 /* The large pool is the last pool at the top of the table */
379 if (entry >= largepool_start) {
380 p = &tbl->large_pool;
381 } else {
382 unsigned int pool_nr = entry / tbl->poolsize;
383
384 BUG_ON(pool_nr > tbl->nr_pools);
385 p = &tbl->pools[pool_nr];
235 } 386 }
236 387
388 return p;
389}
390
391static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
392 unsigned int npages)
393{
394 unsigned long entry, free_entry;
395 unsigned long flags;
396 struct iommu_pool *pool;
397
398 entry = dma_addr >> IOMMU_PAGE_SHIFT;
399 free_entry = entry - tbl->it_offset;
400
401 pool = get_pool(tbl, free_entry);
402
403 if (!iommu_free_check(tbl, dma_addr, npages))
404 return;
405
237 ppc_md.tce_free(tbl, entry, npages); 406 ppc_md.tce_free(tbl, entry, npages);
407
408 spin_lock_irqsave(&(pool->lock), flags);
238 bitmap_clear(tbl->it_map, free_entry, npages); 409 bitmap_clear(tbl->it_map, free_entry, npages);
410 spin_unlock_irqrestore(&(pool->lock), flags);
239} 411}
240 412
241static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr, 413static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
242 unsigned int npages) 414 unsigned int npages)
243{ 415{
244 unsigned long flags;
245
246 spin_lock_irqsave(&(tbl->it_lock), flags);
247
248 __iommu_free(tbl, dma_addr, npages); 416 __iommu_free(tbl, dma_addr, npages);
249 417
250 /* Make sure TLB cache is flushed if the HW needs it. We do 418 /* Make sure TLB cache is flushed if the HW needs it. We do
@@ -253,8 +421,6 @@ static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
253 */ 421 */
254 if (ppc_md.tce_flush) 422 if (ppc_md.tce_flush)
255 ppc_md.tce_flush(tbl); 423 ppc_md.tce_flush(tbl);
256
257 spin_unlock_irqrestore(&(tbl->it_lock), flags);
258} 424}
259 425
260int iommu_map_sg(struct device *dev, struct iommu_table *tbl, 426int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
@@ -263,7 +429,6 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
263 struct dma_attrs *attrs) 429 struct dma_attrs *attrs)
264{ 430{
265 dma_addr_t dma_next = 0, dma_addr; 431 dma_addr_t dma_next = 0, dma_addr;
266 unsigned long flags;
267 struct scatterlist *s, *outs, *segstart; 432 struct scatterlist *s, *outs, *segstart;
268 int outcount, incount, i, build_fail = 0; 433 int outcount, incount, i, build_fail = 0;
269 unsigned int align; 434 unsigned int align;
@@ -285,8 +450,6 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
285 450
286 DBG("sg mapping %d elements:\n", nelems); 451 DBG("sg mapping %d elements:\n", nelems);
287 452
288 spin_lock_irqsave(&(tbl->it_lock), flags);
289
290 max_seg_size = dma_get_max_seg_size(dev); 453 max_seg_size = dma_get_max_seg_size(dev);
291 for_each_sg(sglist, s, nelems, i) { 454 for_each_sg(sglist, s, nelems, i) {
292 unsigned long vaddr, npages, entry, slen; 455 unsigned long vaddr, npages, entry, slen;
@@ -369,8 +532,6 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
369 if (ppc_md.tce_flush) 532 if (ppc_md.tce_flush)
370 ppc_md.tce_flush(tbl); 533 ppc_md.tce_flush(tbl);
371 534
372 spin_unlock_irqrestore(&(tbl->it_lock), flags);
373
374 DBG("mapped %d elements:\n", outcount); 535 DBG("mapped %d elements:\n", outcount);
375 536
376 /* For the sake of iommu_unmap_sg, we clear out the length in the 537 /* For the sake of iommu_unmap_sg, we clear out the length in the
@@ -402,7 +563,6 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
402 if (s == outs) 563 if (s == outs)
403 break; 564 break;
404 } 565 }
405 spin_unlock_irqrestore(&(tbl->it_lock), flags);
406 return 0; 566 return 0;
407} 567}
408 568
@@ -412,15 +572,12 @@ void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
412 struct dma_attrs *attrs) 572 struct dma_attrs *attrs)
413{ 573{
414 struct scatterlist *sg; 574 struct scatterlist *sg;
415 unsigned long flags;
416 575
417 BUG_ON(direction == DMA_NONE); 576 BUG_ON(direction == DMA_NONE);
418 577
419 if (!tbl) 578 if (!tbl)
420 return; 579 return;
421 580
422 spin_lock_irqsave(&(tbl->it_lock), flags);
423
424 sg = sglist; 581 sg = sglist;
425 while (nelems--) { 582 while (nelems--) {
426 unsigned int npages; 583 unsigned int npages;
@@ -440,8 +597,6 @@ void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
440 */ 597 */
441 if (ppc_md.tce_flush) 598 if (ppc_md.tce_flush)
442 ppc_md.tce_flush(tbl); 599 ppc_md.tce_flush(tbl);
443
444 spin_unlock_irqrestore(&(tbl->it_lock), flags);
445} 600}
446 601
447static void iommu_table_clear(struct iommu_table *tbl) 602static void iommu_table_clear(struct iommu_table *tbl)
@@ -494,9 +649,8 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
494 unsigned long sz; 649 unsigned long sz;
495 static int welcomed = 0; 650 static int welcomed = 0;
496 struct page *page; 651 struct page *page;
497 652 unsigned int i;
498 /* Set aside 1/4 of the table for large allocations. */ 653 struct iommu_pool *p;
499 tbl->it_halfpoint = tbl->it_size * 3 / 4;
500 654
501 /* number of bytes needed for the bitmap */ 655 /* number of bytes needed for the bitmap */
502 sz = (tbl->it_size + 7) >> 3; 656 sz = (tbl->it_size + 7) >> 3;
@@ -515,9 +669,28 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
515 if (tbl->it_offset == 0) 669 if (tbl->it_offset == 0)
516 set_bit(0, tbl->it_map); 670 set_bit(0, tbl->it_map);
517 671
518 tbl->it_hint = 0; 672 /* We only split the IOMMU table if we have 1GB or more of space */
519 tbl->it_largehint = tbl->it_halfpoint; 673 if ((tbl->it_size << IOMMU_PAGE_SHIFT) >= (1UL * 1024 * 1024 * 1024))
520 spin_lock_init(&tbl->it_lock); 674 tbl->nr_pools = IOMMU_NR_POOLS;
675 else
676 tbl->nr_pools = 1;
677
678 /* We reserve the top 1/4 of the table for large allocations */
679 tbl->poolsize = (tbl->it_size * 3 / 4) / tbl->nr_pools;
680
681 for (i = 0; i < tbl->nr_pools; i++) {
682 p = &tbl->pools[i];
683 spin_lock_init(&(p->lock));
684 p->start = tbl->poolsize * i;
685 p->hint = p->start;
686 p->end = p->start + tbl->poolsize;
687 }
688
689 p = &tbl->large_pool;
690 spin_lock_init(&(p->lock));
691 p->start = tbl->poolsize * i;
692 p->hint = p->start;
693 p->end = tbl->it_size;
521 694
522 iommu_table_clear(tbl); 695 iommu_table_clear(tbl);
523 696
diff --git a/arch/powerpc/kernel/kgdb.c b/arch/powerpc/kernel/kgdb.c
index 782bd0a3c2f..c470a40b29f 100644
--- a/arch/powerpc/kernel/kgdb.c
+++ b/arch/powerpc/kernel/kgdb.c
@@ -25,6 +25,7 @@
25#include <asm/processor.h> 25#include <asm/processor.h>
26#include <asm/machdep.h> 26#include <asm/machdep.h>
27#include <asm/debug.h> 27#include <asm/debug.h>
28#include <linux/slab.h>
28 29
29/* 30/*
30 * This table contains the mapping between PowerPC hardware trap types, and 31 * This table contains the mapping between PowerPC hardware trap types, and
@@ -101,6 +102,21 @@ static int computeSignal(unsigned int tt)
101 return SIGHUP; /* default for things we don't know about */ 102 return SIGHUP; /* default for things we don't know about */
102} 103}
103 104
105/**
106 *
107 * kgdb_skipexception - Bail out of KGDB when we've been triggered.
108 * @exception: Exception vector number
109 * @regs: Current &struct pt_regs.
110 *
111 * On some architectures we need to skip a breakpoint exception when
112 * it occurs after a breakpoint has been removed.
113 *
114 */
115int kgdb_skipexception(int exception, struct pt_regs *regs)
116{
117 return kgdb_isremovedbreak(regs->nip);
118}
119
104static int kgdb_call_nmi_hook(struct pt_regs *regs) 120static int kgdb_call_nmi_hook(struct pt_regs *regs)
105{ 121{
106 kgdb_nmicallback(raw_smp_processor_id(), regs); 122 kgdb_nmicallback(raw_smp_processor_id(), regs);
@@ -138,6 +154,8 @@ static int kgdb_handle_breakpoint(struct pt_regs *regs)
138static int kgdb_singlestep(struct pt_regs *regs) 154static int kgdb_singlestep(struct pt_regs *regs)
139{ 155{
140 struct thread_info *thread_info, *exception_thread_info; 156 struct thread_info *thread_info, *exception_thread_info;
157 struct thread_info *backup_current_thread_info = \
158 (struct thread_info *)kmalloc(sizeof(struct thread_info), GFP_KERNEL);
141 159
142 if (user_mode(regs)) 160 if (user_mode(regs))
143 return 0; 161 return 0;
@@ -155,13 +173,17 @@ static int kgdb_singlestep(struct pt_regs *regs)
155 thread_info = (struct thread_info *)(regs->gpr[1] & ~(THREAD_SIZE-1)); 173 thread_info = (struct thread_info *)(regs->gpr[1] & ~(THREAD_SIZE-1));
156 exception_thread_info = current_thread_info(); 174 exception_thread_info = current_thread_info();
157 175
158 if (thread_info != exception_thread_info) 176 if (thread_info != exception_thread_info) {
177 /* Save the original current_thread_info. */
178 memcpy(backup_current_thread_info, exception_thread_info, sizeof *thread_info);
159 memcpy(exception_thread_info, thread_info, sizeof *thread_info); 179 memcpy(exception_thread_info, thread_info, sizeof *thread_info);
180 }
160 181
161 kgdb_handle_exception(0, SIGTRAP, 0, regs); 182 kgdb_handle_exception(0, SIGTRAP, 0, regs);
162 183
163 if (thread_info != exception_thread_info) 184 if (thread_info != exception_thread_info)
164 memcpy(thread_info, exception_thread_info, sizeof *thread_info); 185 /* Restore current_thread_info lastly. */
186 memcpy(exception_thread_info, backup_current_thread_info, sizeof *thread_info);
165 187
166 return 1; 188 return 1;
167} 189}
@@ -410,7 +432,6 @@ int kgdb_arch_handle_exception(int vector, int signo, int err_code,
410#else 432#else
411 linux_regs->msr |= MSR_SE; 433 linux_regs->msr |= MSR_SE;
412#endif 434#endif
413 kgdb_single_step = 1;
414 atomic_set(&kgdb_cpu_doing_single_step, 435 atomic_set(&kgdb_cpu_doing_single_step,
415 raw_smp_processor_id()); 436 raw_smp_processor_id());
416 } 437 }
diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c
index 62bdf238966..867db1de894 100644
--- a/arch/powerpc/kernel/kvm.c
+++ b/arch/powerpc/kernel/kvm.c
@@ -31,6 +31,7 @@
31#include <asm/cacheflush.h> 31#include <asm/cacheflush.h>
32#include <asm/disassemble.h> 32#include <asm/disassemble.h>
33#include <asm/ppc-opcode.h> 33#include <asm/ppc-opcode.h>
34#include <asm/epapr_hcalls.h>
34 35
35#define KVM_MAGIC_PAGE (-4096L) 36#define KVM_MAGIC_PAGE (-4096L)
36#define magic_var(x) KVM_MAGIC_PAGE + offsetof(struct kvm_vcpu_arch_shared, x) 37#define magic_var(x) KVM_MAGIC_PAGE + offsetof(struct kvm_vcpu_arch_shared, x)
@@ -302,7 +303,7 @@ static void kvm_patch_ins_wrtee(u32 *inst, u32 rt, int imm_one)
302 303
303 if (imm_one) { 304 if (imm_one) {
304 p[kvm_emulate_wrtee_reg_offs] = 305 p[kvm_emulate_wrtee_reg_offs] =
305 KVM_INST_LI | __PPC_RT(30) | MSR_EE; 306 KVM_INST_LI | __PPC_RT(R30) | MSR_EE;
306 } else { 307 } else {
307 /* Make clobbered registers work too */ 308 /* Make clobbered registers work too */
308 switch (get_rt(rt)) { 309 switch (get_rt(rt)) {
@@ -726,7 +727,7 @@ unsigned long kvm_hypercall(unsigned long *in,
726 unsigned long register r11 asm("r11") = nr; 727 unsigned long register r11 asm("r11") = nr;
727 unsigned long register r12 asm("r12"); 728 unsigned long register r12 asm("r12");
728 729
729 asm volatile("bl kvm_hypercall_start" 730 asm volatile("bl epapr_hypercall_start"
730 : "=r"(r0), "=r"(r3), "=r"(r4), "=r"(r5), "=r"(r6), 731 : "=r"(r0), "=r"(r3), "=r"(r4), "=r"(r5), "=r"(r6),
731 "=r"(r7), "=r"(r8), "=r"(r9), "=r"(r10), "=r"(r11), 732 "=r"(r7), "=r"(r8), "=r"(r9), "=r"(r10), "=r"(r11),
732 "=r"(r12) 733 "=r"(r12)
@@ -747,29 +748,6 @@ unsigned long kvm_hypercall(unsigned long *in,
747} 748}
748EXPORT_SYMBOL_GPL(kvm_hypercall); 749EXPORT_SYMBOL_GPL(kvm_hypercall);
749 750
750static int kvm_para_setup(void)
751{
752 extern u32 kvm_hypercall_start;
753 struct device_node *hyper_node;
754 u32 *insts;
755 int len, i;
756
757 hyper_node = of_find_node_by_path("/hypervisor");
758 if (!hyper_node)
759 return -1;
760
761 insts = (u32*)of_get_property(hyper_node, "hcall-instructions", &len);
762 if (len % 4)
763 return -1;
764 if (len > (4 * 4))
765 return -1;
766
767 for (i = 0; i < (len / 4); i++)
768 kvm_patch_ins(&(&kvm_hypercall_start)[i], insts[i]);
769
770 return 0;
771}
772
773static __init void kvm_free_tmp(void) 751static __init void kvm_free_tmp(void)
774{ 752{
775 unsigned long start, end; 753 unsigned long start, end;
@@ -791,7 +769,7 @@ static int __init kvm_guest_init(void)
791 if (!kvm_para_available()) 769 if (!kvm_para_available())
792 goto free_tmp; 770 goto free_tmp;
793 771
794 if (kvm_para_setup()) 772 if (!epapr_paravirt_enabled)
795 goto free_tmp; 773 goto free_tmp;
796 774
797 if (kvm_para_has_feature(KVM_FEATURE_MAGIC_PAGE)) 775 if (kvm_para_has_feature(KVM_FEATURE_MAGIC_PAGE))
diff --git a/arch/powerpc/kernel/kvm_emul.S b/arch/powerpc/kernel/kvm_emul.S
index e291cf3cf95..e100ff324a8 100644
--- a/arch/powerpc/kernel/kvm_emul.S
+++ b/arch/powerpc/kernel/kvm_emul.S
@@ -24,16 +24,6 @@
24#include <asm/page.h> 24#include <asm/page.h>
25#include <asm/asm-offsets.h> 25#include <asm/asm-offsets.h>
26 26
27/* Hypercall entry point. Will be patched with device tree instructions. */
28
29.global kvm_hypercall_start
30kvm_hypercall_start:
31 li r3, -1
32 nop
33 nop
34 nop
35 blr
36
37#define KVM_MAGIC_PAGE (-4096) 27#define KVM_MAGIC_PAGE (-4096)
38 28
39#ifdef CONFIG_64BIT 29#ifdef CONFIG_64BIT
@@ -132,7 +122,7 @@ kvm_emulate_mtmsrd_len:
132 .long (kvm_emulate_mtmsrd_end - kvm_emulate_mtmsrd) / 4 122 .long (kvm_emulate_mtmsrd_end - kvm_emulate_mtmsrd) / 4
133 123
134 124
135#define MSR_SAFE_BITS (MSR_EE | MSR_CE | MSR_ME | MSR_RI) 125#define MSR_SAFE_BITS (MSR_EE | MSR_RI)
136#define MSR_CRITICAL_BITS ~MSR_SAFE_BITS 126#define MSR_CRITICAL_BITS ~MSR_SAFE_BITS
137 127
138.global kvm_emulate_mtmsr 128.global kvm_emulate_mtmsr
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index 386d57f66f2..407e293aad2 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -179,7 +179,7 @@ _GLOBAL(low_choose_750fx_pll)
179 mtspr SPRN_HID1,r4 179 mtspr SPRN_HID1,r4
180 180
181 /* Store new HID1 image */ 181 /* Store new HID1 image */
182 rlwinm r6,r1,0,0,(31-THREAD_SHIFT) 182 CURRENT_THREAD_INFO(r6, r1)
183 lwz r6,TI_CPU(r6) 183 lwz r6,TI_CPU(r6)
184 slwi r6,r6,2 184 slwi r6,r6,2
185 addis r6,r6,nap_save_hid1@ha 185 addis r6,r6,nap_save_hid1@ha
@@ -699,7 +699,7 @@ _GLOBAL(kernel_thread)
699#ifdef CONFIG_SMP 699#ifdef CONFIG_SMP
700_GLOBAL(start_secondary_resume) 700_GLOBAL(start_secondary_resume)
701 /* Reset stack */ 701 /* Reset stack */
702 rlwinm r1,r1,0,0,(31-THREAD_SHIFT) /* current_thread_info() */ 702 CURRENT_THREAD_INFO(r1, r1)
703 addi r1,r1,THREAD_SIZE-STACK_FRAME_OVERHEAD 703 addi r1,r1,THREAD_SIZE-STACK_FRAME_OVERHEAD
704 li r3,0 704 li r3,0
705 stw r3,0(r1) /* Zero the stack frame pointer */ 705 stw r3,0(r1) /* Zero the stack frame pointer */
diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
index 616921ef143..565b78625a3 100644
--- a/arch/powerpc/kernel/misc_64.S
+++ b/arch/powerpc/kernel/misc_64.S
@@ -301,11 +301,6 @@ _GLOBAL(real_writeb)
301 301
302#ifdef CONFIG_PPC_PASEMI 302#ifdef CONFIG_PPC_PASEMI
303 303
304/* No support in all binutils for these yet, so use defines */
305#define LBZCIX(RT,RA,RB) .long (0x7c0006aa|(RT<<21)|(RA<<16)|(RB << 11))
306#define STBCIX(RS,RA,RB) .long (0x7c0007aa|(RS<<21)|(RA<<16)|(RB << 11))
307
308
309_GLOBAL(real_205_readb) 304_GLOBAL(real_205_readb)
310 mfmsr r7 305 mfmsr r7
311 ori r0,r7,MSR_DR 306 ori r0,r7,MSR_DR
@@ -314,7 +309,7 @@ _GLOBAL(real_205_readb)
314 mtmsrd r0 309 mtmsrd r0
315 sync 310 sync
316 isync 311 isync
317 LBZCIX(r3,0,r3) 312 LBZCIX(R3,R0,R3)
318 isync 313 isync
319 mtmsrd r7 314 mtmsrd r7
320 sync 315 sync
@@ -329,7 +324,7 @@ _GLOBAL(real_205_writeb)
329 mtmsrd r0 324 mtmsrd r0
330 sync 325 sync
331 isync 326 isync
332 STBCIX(r3,0,r4) 327 STBCIX(R3,R0,R4)
333 isync 328 isync
334 mtmsrd r7 329 mtmsrd r7
335 sync 330 sync
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 8e78e93c818..2aa04f29e1d 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -200,11 +200,6 @@ int pcibios_add_platform_entries(struct pci_dev *pdev)
200 return device_create_file(&pdev->dev, &dev_attr_devspec); 200 return device_create_file(&pdev->dev, &dev_attr_devspec);
201} 201}
202 202
203char __devinit *pcibios_setup(char *str)
204{
205 return str;
206}
207
208/* 203/*
209 * Reads the interrupt pin to determine if interrupt is use by card. 204 * Reads the interrupt pin to determine if interrupt is use by card.
210 * If the interrupt is used, then gets the interrupt line from the 205 * If the interrupt is used, then gets the interrupt line from the
@@ -248,8 +243,7 @@ static int pci_read_irq_line(struct pci_dev *pci_dev)
248 } else { 243 } else {
249 pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n", 244 pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n",
250 oirq.size, oirq.specifier[0], oirq.specifier[1], 245 oirq.size, oirq.specifier[0], oirq.specifier[1],
251 oirq.controller ? oirq.controller->full_name : 246 of_node_full_name(oirq.controller));
252 "<default>");
253 247
254 virq = irq_create_of_mapping(oirq.controller, oirq.specifier, 248 virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
255 oirq.size); 249 oirq.size);
@@ -1628,8 +1622,7 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose)
1628 struct device_node *node = hose->dn; 1622 struct device_node *node = hose->dn;
1629 int mode; 1623 int mode;
1630 1624
1631 pr_debug("PCI: Scanning PHB %s\n", 1625 pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node));
1632 node ? node->full_name : "<NO NAME>");
1633 1626
1634 /* Get some IO space for the new PHB */ 1627 /* Get some IO space for the new PHB */
1635 pcibios_setup_phb_io_space(hose); 1628 pcibios_setup_phb_io_space(hose);
@@ -1637,6 +1630,11 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose)
1637 /* Wire up PHB bus resources */ 1630 /* Wire up PHB bus resources */
1638 pcibios_setup_phb_resources(hose, &resources); 1631 pcibios_setup_phb_resources(hose, &resources);
1639 1632
1633 hose->busn.start = hose->first_busno;
1634 hose->busn.end = hose->last_busno;
1635 hose->busn.flags = IORESOURCE_BUS;
1636 pci_add_resource(&resources, &hose->busn);
1637
1640 /* Create an empty bus for the toplevel */ 1638 /* Create an empty bus for the toplevel */
1641 bus = pci_create_root_bus(hose->parent, hose->first_busno, 1639 bus = pci_create_root_bus(hose->parent, hose->first_busno,
1642 hose->ops, hose, &resources); 1640 hose->ops, hose, &resources);
@@ -1646,7 +1644,6 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose)
1646 pci_free_resource_list(&resources); 1644 pci_free_resource_list(&resources);
1647 return; 1645 return;
1648 } 1646 }
1649 bus->secondary = hose->first_busno;
1650 hose->bus = bus; 1647 hose->bus = bus;
1651 1648
1652 /* Get probe mode and perform scan */ 1649 /* Get probe mode and perform scan */
@@ -1654,13 +1651,14 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose)
1654 if (node && ppc_md.pci_probe_mode) 1651 if (node && ppc_md.pci_probe_mode)
1655 mode = ppc_md.pci_probe_mode(bus); 1652 mode = ppc_md.pci_probe_mode(bus);
1656 pr_debug(" probe mode: %d\n", mode); 1653 pr_debug(" probe mode: %d\n", mode);
1657 if (mode == PCI_PROBE_DEVTREE) { 1654 if (mode == PCI_PROBE_DEVTREE)
1658 bus->subordinate = hose->last_busno;
1659 of_scan_bus(node, bus); 1655 of_scan_bus(node, bus);
1660 }
1661 1656
1662 if (mode == PCI_PROBE_NORMAL) 1657 if (mode == PCI_PROBE_NORMAL) {
1663 hose->last_busno = bus->subordinate = pci_scan_child_bus(bus); 1658 pci_bus_update_busn_res_end(bus, 255);
1659 hose->last_busno = pci_scan_child_bus(bus);
1660 pci_bus_update_busn_res_end(bus, hose->last_busno);
1661 }
1664 1662
1665 /* Platform gets a chance to do some global fixups before 1663 /* Platform gets a chance to do some global fixups before
1666 * we proceed to resource allocation 1664 * we proceed to resource allocation
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 94a54f61d34..4ff190ff24a 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -236,7 +236,7 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
236 236
237 for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) { 237 for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
238 bus = pci_bus_b(ln); 238 bus = pci_bus_b(ln);
239 if (in_bus >= bus->number && in_bus <= bus->subordinate) 239 if (in_bus >= bus->number && in_bus <= bus->busn_res.end)
240 break; 240 break;
241 bus = NULL; 241 bus = NULL;
242 } 242 }
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
index 89dde171a6f..30378a19f65 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -198,7 +198,6 @@ EXPORT_SYMBOL(of_create_pci_dev);
198 198
199/** 199/**
200 * of_scan_pci_bridge - Set up a PCI bridge and scan for child nodes 200 * of_scan_pci_bridge - Set up a PCI bridge and scan for child nodes
201 * @node: device tree node of bridge
202 * @dev: pci_dev structure for the bridge 201 * @dev: pci_dev structure for the bridge
203 * 202 *
204 * of_scan_bus() calls this routine for each PCI bridge that it finds, and 203 * of_scan_bus() calls this routine for each PCI bridge that it finds, and
@@ -240,7 +239,7 @@ void __devinit of_scan_pci_bridge(struct pci_dev *dev)
240 } 239 }
241 240
242 bus->primary = dev->bus->number; 241 bus->primary = dev->bus->number;
243 bus->subordinate = busrange[1]; 242 pci_bus_insert_busn_res(bus, busrange[0], busrange[1]);
244 bus->bridge_ctl = 0; 243 bus->bridge_ctl = 0;
245 244
246 /* parse ranges property */ 245 /* parse ranges property */
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 710f400476d..1a1f2ddfb58 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -802,16 +802,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
802#endif /* CONFIG_PPC_STD_MMU_64 */ 802#endif /* CONFIG_PPC_STD_MMU_64 */
803#ifdef CONFIG_PPC64 803#ifdef CONFIG_PPC64
804 if (cpu_has_feature(CPU_FTR_DSCR)) { 804 if (cpu_has_feature(CPU_FTR_DSCR)) {
805 if (current->thread.dscr_inherit) { 805 p->thread.dscr_inherit = current->thread.dscr_inherit;
806 p->thread.dscr_inherit = 1; 806 p->thread.dscr = current->thread.dscr;
807 p->thread.dscr = current->thread.dscr;
808 } else if (0 != dscr_default) {
809 p->thread.dscr_inherit = 1;
810 p->thread.dscr = dscr_default;
811 } else {
812 p->thread.dscr_inherit = 0;
813 p->thread.dscr = 0;
814 }
815 } 807 }
816#endif 808#endif
817 809
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c
index 4174b4b2324..2c0ee640563 100644
--- a/arch/powerpc/kernel/rtas_flash.c
+++ b/arch/powerpc/kernel/rtas_flash.c
@@ -709,7 +709,7 @@ static int __init rtas_flash_init(void)
709 709
710 if (rtas_token("ibm,update-flash-64-and-reboot") == 710 if (rtas_token("ibm,update-flash-64-and-reboot") ==
711 RTAS_UNKNOWN_SERVICE) { 711 RTAS_UNKNOWN_SERVICE) {
712 printk(KERN_ERR "rtas_flash: no firmware flash support\n"); 712 pr_info("rtas_flash: no firmware flash support\n");
713 return 1; 713 return 1;
714 } 714 }
715 715
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index afd4f051f3f..bdc499c1787 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -720,6 +720,33 @@ static int powerpc_debugfs_init(void)
720arch_initcall(powerpc_debugfs_init); 720arch_initcall(powerpc_debugfs_init);
721#endif 721#endif
722 722
723#ifdef CONFIG_BOOKE_WDT
724extern u32 booke_wdt_enabled;
725extern u32 booke_wdt_period;
726
727/* Checks wdt=x and wdt_period=xx command-line option */
728notrace int __init early_parse_wdt(char *p)
729{
730 if (p && strncmp(p, "0", 1) != 0)
731 booke_wdt_enabled = 1;
732
733 return 0;
734}
735early_param("wdt", early_parse_wdt);
736
737int __init early_parse_wdt_period(char *p)
738{
739 unsigned long ret;
740 if (p) {
741 if (!kstrtol(p, 0, &ret))
742 booke_wdt_period = ret;
743 }
744
745 return 0;
746}
747early_param("wdt_period", early_parse_wdt_period);
748#endif /* CONFIG_BOOKE_WDT */
749
723void ppc_printk_progress(char *s, unsigned short hex) 750void ppc_printk_progress(char *s, unsigned short hex)
724{ 751{
725 pr_info("%s\n", s); 752 pr_info("%s\n", s);
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index ec8a53fa9e8..a8f54ecb091 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -149,30 +149,6 @@ notrace void __init machine_init(u64 dt_ptr)
149 ppc_md.progress("id mach(): done", 0x200); 149 ppc_md.progress("id mach(): done", 0x200);
150} 150}
151 151
152#ifdef CONFIG_BOOKE_WDT
153extern u32 booke_wdt_enabled;
154extern u32 booke_wdt_period;
155
156/* Checks wdt=x and wdt_period=xx command-line option */
157notrace int __init early_parse_wdt(char *p)
158{
159 if (p && strncmp(p, "0", 1) != 0)
160 booke_wdt_enabled = 1;
161
162 return 0;
163}
164early_param("wdt", early_parse_wdt);
165
166int __init early_parse_wdt_period (char *p)
167{
168 if (p)
169 booke_wdt_period = simple_strtoul(p, NULL, 0);
170
171 return 0;
172}
173early_param("wdt_period", early_parse_wdt_period);
174#endif /* CONFIG_BOOKE_WDT */
175
176/* Checks "l2cr=xxxx" command-line option */ 152/* Checks "l2cr=xxxx" command-line option */
177int __init ppc_setup_l2cr(char *str) 153int __init ppc_setup_l2cr(char *str)
178{ 154{
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index e4cb34322de..8d4214afc21 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -48,6 +48,7 @@
48#ifdef CONFIG_PPC64 48#ifdef CONFIG_PPC64
49#include <asm/paca.h> 49#include <asm/paca.h>
50#endif 50#endif
51#include <asm/vdso.h>
51#include <asm/debug.h> 52#include <asm/debug.h>
52 53
53#ifdef DEBUG 54#ifdef DEBUG
@@ -197,8 +198,15 @@ void smp_muxed_ipi_message_pass(int cpu, int msg)
197 struct cpu_messages *info = &per_cpu(ipi_message, cpu); 198 struct cpu_messages *info = &per_cpu(ipi_message, cpu);
198 char *message = (char *)&info->messages; 199 char *message = (char *)&info->messages;
199 200
201 /*
202 * Order previous accesses before accesses in the IPI handler.
203 */
204 smp_mb();
200 message[msg] = 1; 205 message[msg] = 1;
201 mb(); 206 /*
207 * cause_ipi functions are required to include a full barrier
208 * before doing whatever causes the IPI.
209 */
202 smp_ops->cause_ipi(cpu, info->data); 210 smp_ops->cause_ipi(cpu, info->data);
203} 211}
204 212
@@ -210,7 +218,7 @@ irqreturn_t smp_ipi_demux(void)
210 mb(); /* order any irq clear */ 218 mb(); /* order any irq clear */
211 219
212 do { 220 do {
213 all = xchg_local(&info->messages, 0); 221 all = xchg(&info->messages, 0);
214 222
215#ifdef __BIG_ENDIAN 223#ifdef __BIG_ENDIAN
216 if (all & (1 << (24 - 8 * PPC_MSG_CALL_FUNCTION))) 224 if (all & (1 << (24 - 8 * PPC_MSG_CALL_FUNCTION)))
@@ -570,8 +578,9 @@ void __devinit start_secondary(void *unused)
570#ifdef CONFIG_PPC64 578#ifdef CONFIG_PPC64
571 if (system_state == SYSTEM_RUNNING) 579 if (system_state == SYSTEM_RUNNING)
572 vdso_data->processorCount++; 580 vdso_data->processorCount++;
581
582 vdso_getcpu_init();
573#endif 583#endif
574 ipi_call_lock();
575 notify_cpu_starting(cpu); 584 notify_cpu_starting(cpu);
576 set_cpu_online(cpu, true); 585 set_cpu_online(cpu, true);
577 /* Update sibling maps */ 586 /* Update sibling maps */
@@ -601,7 +610,6 @@ void __devinit start_secondary(void *unused)
601 of_node_put(np); 610 of_node_put(np);
602 } 611 }
603 of_node_put(l2_cache); 612 of_node_put(l2_cache);
604 ipi_call_unlock();
605 613
606 local_irq_enable(); 614 local_irq_enable();
607 615
diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
index f2496f2faec..4e3cc47f26b 100644
--- a/arch/powerpc/kernel/syscalls.c
+++ b/arch/powerpc/kernel/syscalls.c
@@ -107,11 +107,11 @@ long ppc64_personality(unsigned long personality)
107 long ret; 107 long ret;
108 108
109 if (personality(current->personality) == PER_LINUX32 109 if (personality(current->personality) == PER_LINUX32
110 && personality == PER_LINUX) 110 && personality(personality) == PER_LINUX)
111 personality = PER_LINUX32; 111 personality = (personality & ~PER_MASK) | PER_LINUX32;
112 ret = sys_personality(personality); 112 ret = sys_personality(personality);
113 if (ret == PER_LINUX32) 113 if (personality(ret) == PER_LINUX32)
114 ret = PER_LINUX; 114 ret = (ret & ~PER_MASK) | PER_LINUX;
115 return ret; 115 return ret;
116} 116}
117#endif 117#endif
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 3529446c2ab..8302af64921 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -194,6 +194,14 @@ static ssize_t show_dscr_default(struct device *dev,
194 return sprintf(buf, "%lx\n", dscr_default); 194 return sprintf(buf, "%lx\n", dscr_default);
195} 195}
196 196
197static void update_dscr(void *dummy)
198{
199 if (!current->thread.dscr_inherit) {
200 current->thread.dscr = dscr_default;
201 mtspr(SPRN_DSCR, dscr_default);
202 }
203}
204
197static ssize_t __used store_dscr_default(struct device *dev, 205static ssize_t __used store_dscr_default(struct device *dev,
198 struct device_attribute *attr, const char *buf, 206 struct device_attribute *attr, const char *buf,
199 size_t count) 207 size_t count)
@@ -206,6 +214,8 @@ static ssize_t __used store_dscr_default(struct device *dev,
206 return -EINVAL; 214 return -EINVAL;
207 dscr_default = val; 215 dscr_default = val;
208 216
217 on_each_cpu(update_dscr, NULL, 1);
218
209 return count; 219 return count;
210} 220}
211 221
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index be171ee73bf..e49e93191b6 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -535,6 +535,15 @@ void timer_interrupt(struct pt_regs * regs)
535 trace_timer_interrupt_exit(regs); 535 trace_timer_interrupt_exit(regs);
536} 536}
537 537
538/*
539 * Hypervisor decrementer interrupts shouldn't occur but are sometimes
540 * left pending on exit from a KVM guest. We don't need to do anything
541 * to clear them, as they are edge-triggered.
542 */
543void hdec_interrupt(struct pt_regs *regs)
544{
545}
546
538#ifdef CONFIG_SUSPEND 547#ifdef CONFIG_SUSPEND
539static void generic_suspend_disable_irqs(void) 548static void generic_suspend_disable_irqs(void)
540{ 549{
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 158972341a2..ae0843fa7a6 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -972,8 +972,9 @@ static int emulate_instruction(struct pt_regs *regs)
972 cpu_has_feature(CPU_FTR_DSCR)) { 972 cpu_has_feature(CPU_FTR_DSCR)) {
973 PPC_WARN_EMULATED(mtdscr, regs); 973 PPC_WARN_EMULATED(mtdscr, regs);
974 rd = (instword >> 21) & 0x1f; 974 rd = (instword >> 21) & 0x1f;
975 mtspr(SPRN_DSCR, regs->gpr[rd]); 975 current->thread.dscr = regs->gpr[rd];
976 current->thread.dscr_inherit = 1; 976 current->thread.dscr_inherit = 1;
977 mtspr(SPRN_DSCR, current->thread.dscr);
977 return 0; 978 return 0;
978 } 979 }
979#endif 980#endif
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index 9eb5b9b536a..b67db22e102 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -706,6 +706,34 @@ static void __init vdso_setup_syscall_map(void)
706 } 706 }
707} 707}
708 708
709#ifdef CONFIG_PPC64
710int __cpuinit vdso_getcpu_init(void)
711{
712 unsigned long cpu, node, val;
713
714 /*
715 * SPRG3 contains the CPU in the bottom 16 bits and the NUMA node in
716 * the next 16 bits. The VDSO uses this to implement getcpu().
717 */
718 cpu = get_cpu();
719 WARN_ON_ONCE(cpu > 0xffff);
720
721 node = cpu_to_node(cpu);
722 WARN_ON_ONCE(node > 0xffff);
723
724 val = (cpu & 0xfff) | ((node & 0xffff) << 16);
725 mtspr(SPRN_SPRG3, val);
726#ifdef CONFIG_KVM_BOOK3S_HANDLER
727 get_paca()->kvm_hstate.sprg3 = val;
728#endif
729
730 put_cpu();
731
732 return 0;
733}
734/* We need to call this before SMP init */
735early_initcall(vdso_getcpu_init);
736#endif
709 737
710static int __init vdso_init(void) 738static int __init vdso_init(void)
711{ 739{
diff --git a/arch/powerpc/kernel/vdso32/Makefile b/arch/powerpc/kernel/vdso32/Makefile
index 9a7946c4173..53e6c9b979e 100644
--- a/arch/powerpc/kernel/vdso32/Makefile
+++ b/arch/powerpc/kernel/vdso32/Makefile
@@ -1,7 +1,9 @@
1 1
2# List of files in the vdso, has to be asm only for now 2# List of files in the vdso, has to be asm only for now
3 3
4obj-vdso32 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o 4obj-vdso32-$(CONFIG_PPC64) = getcpu.o
5obj-vdso32 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o \
6 $(obj-vdso32-y)
5 7
6# Build rules 8# Build rules
7 9
diff --git a/arch/powerpc/kernel/vdso32/getcpu.S b/arch/powerpc/kernel/vdso32/getcpu.S
new file mode 100644
index 00000000000..47afd08c90f
--- /dev/null
+++ b/arch/powerpc/kernel/vdso32/getcpu.S
@@ -0,0 +1,45 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 *
16 * Copyright (C) IBM Corporation, 2012
17 *
18 * Author: Anton Blanchard <anton@au.ibm.com>
19 */
20#include <asm/ppc_asm.h>
21#include <asm/vdso.h>
22
23 .text
24/*
25 * Exact prototype of getcpu
26 *
27 * int __kernel_getcpu(unsigned *cpu, unsigned *node);
28 *
29 */
30V_FUNCTION_BEGIN(__kernel_getcpu)
31 .cfi_startproc
32 mfspr r5,SPRN_USPRG3
33 cmpdi cr0,r3,0
34 cmpdi cr1,r4,0
35 clrlwi r6,r5,16
36 rlwinm r7,r5,16,31-15,31-0
37 beq cr0,1f
38 stw r6,0(r3)
391: beq cr1,2f
40 stw r7,0(r4)
412: crclr cr0*4+so
42 li r3,0 /* always success */
43 blr
44 .cfi_endproc
45V_FUNCTION_END(__kernel_getcpu)
diff --git a/arch/powerpc/kernel/vdso32/vdso32.lds.S b/arch/powerpc/kernel/vdso32/vdso32.lds.S
index 0546bcd49cd..43200ba2e57 100644
--- a/arch/powerpc/kernel/vdso32/vdso32.lds.S
+++ b/arch/powerpc/kernel/vdso32/vdso32.lds.S
@@ -147,6 +147,9 @@ VERSION
147 __kernel_sync_dicache_p5; 147 __kernel_sync_dicache_p5;
148 __kernel_sigtramp32; 148 __kernel_sigtramp32;
149 __kernel_sigtramp_rt32; 149 __kernel_sigtramp_rt32;
150#ifdef CONFIG_PPC64
151 __kernel_getcpu;
152#endif
150 153
151 local: *; 154 local: *;
152 }; 155 };
diff --git a/arch/powerpc/kernel/vdso64/Makefile b/arch/powerpc/kernel/vdso64/Makefile
index 8c500d8622e..effca9404b1 100644
--- a/arch/powerpc/kernel/vdso64/Makefile
+++ b/arch/powerpc/kernel/vdso64/Makefile
@@ -1,6 +1,6 @@
1# List of files in the vdso, has to be asm only for now 1# List of files in the vdso, has to be asm only for now
2 2
3obj-vdso64 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o 3obj-vdso64 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o getcpu.o
4 4
5# Build rules 5# Build rules
6 6
diff --git a/arch/powerpc/kernel/vdso64/getcpu.S b/arch/powerpc/kernel/vdso64/getcpu.S
new file mode 100644
index 00000000000..47afd08c90f
--- /dev/null
+++ b/arch/powerpc/kernel/vdso64/getcpu.S
@@ -0,0 +1,45 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 *
16 * Copyright (C) IBM Corporation, 2012
17 *
18 * Author: Anton Blanchard <anton@au.ibm.com>
19 */
20#include <asm/ppc_asm.h>
21#include <asm/vdso.h>
22
23 .text
24/*
25 * Exact prototype of getcpu
26 *
27 * int __kernel_getcpu(unsigned *cpu, unsigned *node);
28 *
29 */
30V_FUNCTION_BEGIN(__kernel_getcpu)
31 .cfi_startproc
32 mfspr r5,SPRN_USPRG3
33 cmpdi cr0,r3,0
34 cmpdi cr1,r4,0
35 clrlwi r6,r5,16
36 rlwinm r7,r5,16,31-15,31-0
37 beq cr0,1f
38 stw r6,0(r3)
391: beq cr1,2f
40 stw r7,0(r4)
412: crclr cr0*4+so
42 li r3,0 /* always success */
43 blr
44 .cfi_endproc
45V_FUNCTION_END(__kernel_getcpu)
diff --git a/arch/powerpc/kernel/vdso64/vdso64.lds.S b/arch/powerpc/kernel/vdso64/vdso64.lds.S
index 0e615404e24..e6c1758f358 100644
--- a/arch/powerpc/kernel/vdso64/vdso64.lds.S
+++ b/arch/powerpc/kernel/vdso64/vdso64.lds.S
@@ -146,6 +146,7 @@ VERSION
146 __kernel_sync_dicache; 146 __kernel_sync_dicache;
147 __kernel_sync_dicache_p5; 147 __kernel_sync_dicache_p5;
148 __kernel_sigtramp_rt64; 148 __kernel_sigtramp_rt64;
149 __kernel_getcpu;
149 150
150 local: *; 151 local: *;
151 }; 152 };
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index cb87301ccd5..02b32216bbc 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -37,8 +37,6 @@
37#include <asm/page.h> 37#include <asm/page.h>
38#include <asm/hvcall.h> 38#include <asm/hvcall.h>
39 39
40static struct bus_type vio_bus_type;
41
42static struct vio_dev vio_bus_device = { /* fake "parent" device */ 40static struct vio_dev vio_bus_device = { /* fake "parent" device */
43 .name = "vio", 41 .name = "vio",
44 .type = "", 42 .type = "",
@@ -613,6 +611,7 @@ static u64 vio_dma_get_required_mask(struct device *dev)
613struct dma_map_ops vio_dma_mapping_ops = { 611struct dma_map_ops vio_dma_mapping_ops = {
614 .alloc = vio_dma_iommu_alloc_coherent, 612 .alloc = vio_dma_iommu_alloc_coherent,
615 .free = vio_dma_iommu_free_coherent, 613 .free = vio_dma_iommu_free_coherent,
614 .mmap = dma_direct_mmap_coherent,
616 .map_sg = vio_dma_iommu_map_sg, 615 .map_sg = vio_dma_iommu_map_sg,
617 .unmap_sg = vio_dma_iommu_unmap_sg, 616 .unmap_sg = vio_dma_iommu_unmap_sg,
618 .map_page = vio_dma_iommu_map_page, 617 .map_page = vio_dma_iommu_map_page,
@@ -625,7 +624,7 @@ struct dma_map_ops vio_dma_mapping_ops = {
625 * vio_cmo_set_dev_desired - Set desired entitlement for a device 624 * vio_cmo_set_dev_desired - Set desired entitlement for a device
626 * 625 *
627 * @viodev: struct vio_dev for device to alter 626 * @viodev: struct vio_dev for device to alter
628 * @new_desired: new desired entitlement level in bytes 627 * @desired: new desired entitlement level in bytes
629 * 628 *
630 * For use by devices to request a change to their entitlement at runtime or 629 * For use by devices to request a change to their entitlement at runtime or
631 * through sysfs. The desired entitlement level is changed and a balancing 630 * through sysfs. The desired entitlement level is changed and a balancing
@@ -1262,7 +1261,7 @@ static int vio_bus_remove(struct device *dev)
1262 1261
1263/** 1262/**
1264 * vio_register_driver: - Register a new vio driver 1263 * vio_register_driver: - Register a new vio driver
1265 * @drv: The vio_driver structure to be registered. 1264 * @viodrv: The vio_driver structure to be registered.
1266 */ 1265 */
1267int __vio_register_driver(struct vio_driver *viodrv, struct module *owner, 1266int __vio_register_driver(struct vio_driver *viodrv, struct module *owner,
1268 const char *mod_name) 1267 const char *mod_name)
@@ -1282,7 +1281,7 @@ EXPORT_SYMBOL(__vio_register_driver);
1282 1281
1283/** 1282/**
1284 * vio_unregister_driver - Remove registration of vio driver. 1283 * vio_unregister_driver - Remove registration of vio driver.
1285 * @driver: The vio_driver struct to be removed form registration 1284 * @viodrv: The vio_driver struct to be removed form registration
1286 */ 1285 */
1287void vio_unregister_driver(struct vio_driver *viodrv) 1286void vio_unregister_driver(struct vio_driver *viodrv)
1288{ 1287{
@@ -1296,8 +1295,7 @@ static void __devinit vio_dev_release(struct device *dev)
1296 struct iommu_table *tbl = get_iommu_table_base(dev); 1295 struct iommu_table *tbl = get_iommu_table_base(dev);
1297 1296
1298 if (tbl) 1297 if (tbl)
1299 iommu_free_table(tbl, dev->of_node ? 1298 iommu_free_table(tbl, of_node_full_name(dev->of_node));
1300 dev->of_node->full_name : dev_name(dev));
1301 of_node_put(dev->of_node); 1299 of_node_put(dev->of_node);
1302 kfree(to_vio_dev(dev)); 1300 kfree(to_vio_dev(dev));
1303} 1301}
@@ -1397,21 +1395,27 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
1397 viodev->name = of_node->name; 1395 viodev->name = of_node->name;
1398 viodev->dev.of_node = of_node_get(of_node); 1396 viodev->dev.of_node = of_node_get(of_node);
1399 1397
1400 if (firmware_has_feature(FW_FEATURE_CMO))
1401 vio_cmo_set_dma_ops(viodev);
1402 else
1403 set_dma_ops(&viodev->dev, &dma_iommu_ops);
1404 set_iommu_table_base(&viodev->dev, vio_build_iommu_table(viodev));
1405 set_dev_node(&viodev->dev, of_node_to_nid(of_node)); 1398 set_dev_node(&viodev->dev, of_node_to_nid(of_node));
1406 1399
1407 /* init generic 'struct device' fields: */ 1400 /* init generic 'struct device' fields: */
1408 viodev->dev.parent = &vio_bus_device.dev; 1401 viodev->dev.parent = &vio_bus_device.dev;
1409 viodev->dev.bus = &vio_bus_type; 1402 viodev->dev.bus = &vio_bus_type;
1410 viodev->dev.release = vio_dev_release; 1403 viodev->dev.release = vio_dev_release;
1411 /* needed to ensure proper operation of coherent allocations 1404
1412 * later, in case driver doesn't set it explicitly */ 1405 if (of_get_property(viodev->dev.of_node, "ibm,my-dma-window", NULL)) {
1413 dma_set_mask(&viodev->dev, DMA_BIT_MASK(64)); 1406 if (firmware_has_feature(FW_FEATURE_CMO))
1414 dma_set_coherent_mask(&viodev->dev, DMA_BIT_MASK(64)); 1407 vio_cmo_set_dma_ops(viodev);
1408 else
1409 set_dma_ops(&viodev->dev, &dma_iommu_ops);
1410
1411 set_iommu_table_base(&viodev->dev,
1412 vio_build_iommu_table(viodev));
1413
1414 /* needed to ensure proper operation of coherent allocations
1415 * later, in case driver doesn't set it explicitly */
1416 dma_set_mask(&viodev->dev, DMA_BIT_MASK(64));
1417 dma_set_coherent_mask(&viodev->dev, DMA_BIT_MASK(64));
1418 }
1415 1419
1416 /* register with generic device framework */ 1420 /* register with generic device framework */
1417 if (device_register(&viodev->dev)) { 1421 if (device_register(&viodev->dev)) {
@@ -1491,12 +1495,18 @@ static int __init vio_bus_init(void)
1491 if (firmware_has_feature(FW_FEATURE_CMO)) 1495 if (firmware_has_feature(FW_FEATURE_CMO))
1492 vio_cmo_bus_init(); 1496 vio_cmo_bus_init();
1493 1497
1498 return 0;
1499}
1500postcore_initcall(vio_bus_init);
1501
1502static int __init vio_device_init(void)
1503{
1494 vio_bus_scan_register_devices("vdevice"); 1504 vio_bus_scan_register_devices("vdevice");
1495 vio_bus_scan_register_devices("ibm,platform-facilities"); 1505 vio_bus_scan_register_devices("ibm,platform-facilities");
1496 1506
1497 return 0; 1507 return 0;
1498} 1508}
1499__initcall(vio_bus_init); 1509device_initcall(vio_device_init);
1500 1510
1501static ssize_t name_show(struct device *dev, 1511static ssize_t name_show(struct device *dev,
1502 struct device_attribute *attr, char *buf) 1512 struct device_attribute *attr, char *buf)
@@ -1509,7 +1519,7 @@ static ssize_t devspec_show(struct device *dev,
1509{ 1519{
1510 struct device_node *of_node = dev->of_node; 1520 struct device_node *of_node = dev->of_node;
1511 1521
1512 return sprintf(buf, "%s\n", of_node ? of_node->full_name : "none"); 1522 return sprintf(buf, "%s\n", of_node_full_name(of_node));
1513} 1523}
1514 1524
1515static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, 1525static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
@@ -1568,7 +1578,7 @@ static int vio_hotplug(struct device *dev, struct kobj_uevent_env *env)
1568 return 0; 1578 return 0;
1569} 1579}
1570 1580
1571static struct bus_type vio_bus_type = { 1581struct bus_type vio_bus_type = {
1572 .name = "vio", 1582 .name = "vio",
1573 .dev_attrs = vio_dev_attrs, 1583 .dev_attrs = vio_dev_attrs,
1574 .uevent = vio_hotplug, 1584 .uevent = vio_hotplug,
diff --git a/arch/powerpc/kvm/book3s_32_mmu_host.c b/arch/powerpc/kvm/book3s_32_mmu_host.c
index f922c29bb23..837f13e7b6b 100644
--- a/arch/powerpc/kvm/book3s_32_mmu_host.c
+++ b/arch/powerpc/kvm/book3s_32_mmu_host.c
@@ -211,6 +211,9 @@ next_pteg:
211 pteg1 |= PP_RWRX; 211 pteg1 |= PP_RWRX;
212 } 212 }
213 213
214 if (orig_pte->may_execute)
215 kvmppc_mmu_flush_icache(hpaddr >> PAGE_SHIFT);
216
214 local_irq_disable(); 217 local_irq_disable();
215 218
216 if (pteg[rr]) { 219 if (pteg[rr]) {
diff --git a/arch/powerpc/kvm/book3s_64_mmu_host.c b/arch/powerpc/kvm/book3s_64_mmu_host.c
index 10fc8ec9d2a..0688b6b3958 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_host.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_host.c
@@ -126,6 +126,8 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte)
126 126
127 if (!orig_pte->may_execute) 127 if (!orig_pte->may_execute)
128 rflags |= HPTE_R_N; 128 rflags |= HPTE_R_N;
129 else
130 kvmppc_mmu_flush_icache(hpaddr >> PAGE_SHIFT);
129 131
130 hash = hpt_hash(va, PTE_SIZE, MMU_SEGSIZE_256M); 132 hash = hpt_hash(va, PTE_SIZE, MMU_SEGSIZE_256M);
131 133
diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
index 80a57751758..d03eb6f7b05 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
@@ -37,56 +37,121 @@
37/* POWER7 has 10-bit LPIDs, PPC970 has 6-bit LPIDs */ 37/* POWER7 has 10-bit LPIDs, PPC970 has 6-bit LPIDs */
38#define MAX_LPID_970 63 38#define MAX_LPID_970 63
39 39
40long kvmppc_alloc_hpt(struct kvm *kvm) 40/* Power architecture requires HPT is at least 256kB */
41#define PPC_MIN_HPT_ORDER 18
42
43long kvmppc_alloc_hpt(struct kvm *kvm, u32 *htab_orderp)
41{ 44{
42 unsigned long hpt; 45 unsigned long hpt;
43 long lpid;
44 struct revmap_entry *rev; 46 struct revmap_entry *rev;
45 struct kvmppc_linear_info *li; 47 struct kvmppc_linear_info *li;
48 long order = kvm_hpt_order;
46 49
47 /* Allocate guest's hashed page table */ 50 if (htab_orderp) {
48 li = kvm_alloc_hpt(); 51 order = *htab_orderp;
49 if (li) { 52 if (order < PPC_MIN_HPT_ORDER)
50 /* using preallocated memory */ 53 order = PPC_MIN_HPT_ORDER;
51 hpt = (ulong)li->base_virt; 54 }
52 kvm->arch.hpt_li = li; 55
53 } else { 56 /*
54 /* using dynamic memory */ 57 * If the user wants a different size from default,
58 * try first to allocate it from the kernel page allocator.
59 */
60 hpt = 0;
61 if (order != kvm_hpt_order) {
55 hpt = __get_free_pages(GFP_KERNEL|__GFP_ZERO|__GFP_REPEAT| 62 hpt = __get_free_pages(GFP_KERNEL|__GFP_ZERO|__GFP_REPEAT|
56 __GFP_NOWARN, HPT_ORDER - PAGE_SHIFT); 63 __GFP_NOWARN, order - PAGE_SHIFT);
64 if (!hpt)
65 --order;
57 } 66 }
58 67
68 /* Next try to allocate from the preallocated pool */
59 if (!hpt) { 69 if (!hpt) {
60 pr_err("kvm_alloc_hpt: Couldn't alloc HPT\n"); 70 li = kvm_alloc_hpt();
61 return -ENOMEM; 71 if (li) {
72 hpt = (ulong)li->base_virt;
73 kvm->arch.hpt_li = li;
74 order = kvm_hpt_order;
75 }
62 } 76 }
77
78 /* Lastly try successively smaller sizes from the page allocator */
79 while (!hpt && order > PPC_MIN_HPT_ORDER) {
80 hpt = __get_free_pages(GFP_KERNEL|__GFP_ZERO|__GFP_REPEAT|
81 __GFP_NOWARN, order - PAGE_SHIFT);
82 if (!hpt)
83 --order;
84 }
85
86 if (!hpt)
87 return -ENOMEM;
88
63 kvm->arch.hpt_virt = hpt; 89 kvm->arch.hpt_virt = hpt;
90 kvm->arch.hpt_order = order;
91 /* HPTEs are 2**4 bytes long */
92 kvm->arch.hpt_npte = 1ul << (order - 4);
93 /* 128 (2**7) bytes in each HPTEG */
94 kvm->arch.hpt_mask = (1ul << (order - 7)) - 1;
64 95
65 /* Allocate reverse map array */ 96 /* Allocate reverse map array */
66 rev = vmalloc(sizeof(struct revmap_entry) * HPT_NPTE); 97 rev = vmalloc(sizeof(struct revmap_entry) * kvm->arch.hpt_npte);
67 if (!rev) { 98 if (!rev) {
68 pr_err("kvmppc_alloc_hpt: Couldn't alloc reverse map array\n"); 99 pr_err("kvmppc_alloc_hpt: Couldn't alloc reverse map array\n");
69 goto out_freehpt; 100 goto out_freehpt;
70 } 101 }
71 kvm->arch.revmap = rev; 102 kvm->arch.revmap = rev;
103 kvm->arch.sdr1 = __pa(hpt) | (order - 18);
72 104
73 lpid = kvmppc_alloc_lpid(); 105 pr_info("KVM guest htab at %lx (order %ld), LPID %x\n",
74 if (lpid < 0) 106 hpt, order, kvm->arch.lpid);
75 goto out_freeboth;
76 107
77 kvm->arch.sdr1 = __pa(hpt) | (HPT_ORDER - 18); 108 if (htab_orderp)
78 kvm->arch.lpid = lpid; 109 *htab_orderp = order;
79
80 pr_info("KVM guest htab at %lx, LPID %lx\n", hpt, lpid);
81 return 0; 110 return 0;
82 111
83 out_freeboth:
84 vfree(rev);
85 out_freehpt: 112 out_freehpt:
86 free_pages(hpt, HPT_ORDER - PAGE_SHIFT); 113 if (kvm->arch.hpt_li)
114 kvm_release_hpt(kvm->arch.hpt_li);
115 else
116 free_pages(hpt, order - PAGE_SHIFT);
87 return -ENOMEM; 117 return -ENOMEM;
88} 118}
89 119
120long kvmppc_alloc_reset_hpt(struct kvm *kvm, u32 *htab_orderp)
121{
122 long err = -EBUSY;
123 long order;
124
125 mutex_lock(&kvm->lock);
126 if (kvm->arch.rma_setup_done) {
127 kvm->arch.rma_setup_done = 0;
128 /* order rma_setup_done vs. vcpus_running */
129 smp_mb();
130 if (atomic_read(&kvm->arch.vcpus_running)) {
131 kvm->arch.rma_setup_done = 1;
132 goto out;
133 }
134 }
135 if (kvm->arch.hpt_virt) {
136 order = kvm->arch.hpt_order;
137 /* Set the entire HPT to 0, i.e. invalid HPTEs */
138 memset((void *)kvm->arch.hpt_virt, 0, 1ul << order);
139 /*
140 * Set the whole last_vcpu array to an invalid vcpu number.
141 * This ensures that each vcpu will flush its TLB on next entry.
142 */
143 memset(kvm->arch.last_vcpu, 0xff, sizeof(kvm->arch.last_vcpu));
144 *htab_orderp = order;
145 err = 0;
146 } else {
147 err = kvmppc_alloc_hpt(kvm, htab_orderp);
148 order = *htab_orderp;
149 }
150 out:
151 mutex_unlock(&kvm->lock);
152 return err;
153}
154
90void kvmppc_free_hpt(struct kvm *kvm) 155void kvmppc_free_hpt(struct kvm *kvm)
91{ 156{
92 kvmppc_free_lpid(kvm->arch.lpid); 157 kvmppc_free_lpid(kvm->arch.lpid);
@@ -94,7 +159,8 @@ void kvmppc_free_hpt(struct kvm *kvm)
94 if (kvm->arch.hpt_li) 159 if (kvm->arch.hpt_li)
95 kvm_release_hpt(kvm->arch.hpt_li); 160 kvm_release_hpt(kvm->arch.hpt_li);
96 else 161 else
97 free_pages(kvm->arch.hpt_virt, HPT_ORDER - PAGE_SHIFT); 162 free_pages(kvm->arch.hpt_virt,
163 kvm->arch.hpt_order - PAGE_SHIFT);
98} 164}
99 165
100/* Bits in first HPTE dword for pagesize 4k, 64k or 16M */ 166/* Bits in first HPTE dword for pagesize 4k, 64k or 16M */
@@ -119,6 +185,7 @@ void kvmppc_map_vrma(struct kvm_vcpu *vcpu, struct kvm_memory_slot *memslot,
119 unsigned long psize; 185 unsigned long psize;
120 unsigned long hp0, hp1; 186 unsigned long hp0, hp1;
121 long ret; 187 long ret;
188 struct kvm *kvm = vcpu->kvm;
122 189
123 psize = 1ul << porder; 190 psize = 1ul << porder;
124 npages = memslot->npages >> (porder - PAGE_SHIFT); 191 npages = memslot->npages >> (porder - PAGE_SHIFT);
@@ -127,8 +194,8 @@ void kvmppc_map_vrma(struct kvm_vcpu *vcpu, struct kvm_memory_slot *memslot,
127 if (npages > 1ul << (40 - porder)) 194 if (npages > 1ul << (40 - porder))
128 npages = 1ul << (40 - porder); 195 npages = 1ul << (40 - porder);
129 /* Can't use more than 1 HPTE per HPTEG */ 196 /* Can't use more than 1 HPTE per HPTEG */
130 if (npages > HPT_NPTEG) 197 if (npages > kvm->arch.hpt_mask + 1)
131 npages = HPT_NPTEG; 198 npages = kvm->arch.hpt_mask + 1;
132 199
133 hp0 = HPTE_V_1TB_SEG | (VRMA_VSID << (40 - 16)) | 200 hp0 = HPTE_V_1TB_SEG | (VRMA_VSID << (40 - 16)) |
134 HPTE_V_BOLTED | hpte0_pgsize_encoding(psize); 201 HPTE_V_BOLTED | hpte0_pgsize_encoding(psize);
@@ -138,7 +205,7 @@ void kvmppc_map_vrma(struct kvm_vcpu *vcpu, struct kvm_memory_slot *memslot,
138 for (i = 0; i < npages; ++i) { 205 for (i = 0; i < npages; ++i) {
139 addr = i << porder; 206 addr = i << porder;
140 /* can't use hpt_hash since va > 64 bits */ 207 /* can't use hpt_hash since va > 64 bits */
141 hash = (i ^ (VRMA_VSID ^ (VRMA_VSID << 25))) & HPT_HASH_MASK; 208 hash = (i ^ (VRMA_VSID ^ (VRMA_VSID << 25))) & kvm->arch.hpt_mask;
142 /* 209 /*
143 * We assume that the hash table is empty and no 210 * We assume that the hash table is empty and no
144 * vcpus are using it at this stage. Since we create 211 * vcpus are using it at this stage. Since we create
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 3abe1b86e58..83e929e66f9 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -56,7 +56,7 @@
56/* #define EXIT_DEBUG_INT */ 56/* #define EXIT_DEBUG_INT */
57 57
58static void kvmppc_end_cede(struct kvm_vcpu *vcpu); 58static void kvmppc_end_cede(struct kvm_vcpu *vcpu);
59static int kvmppc_hv_setup_rma(struct kvm_vcpu *vcpu); 59static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu);
60 60
61void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu) 61void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
62{ 62{
@@ -1104,11 +1104,15 @@ int kvmppc_vcpu_run(struct kvm_run *run, struct kvm_vcpu *vcpu)
1104 return -EINTR; 1104 return -EINTR;
1105 } 1105 }
1106 1106
1107 /* On the first time here, set up VRMA or RMA */ 1107 atomic_inc(&vcpu->kvm->arch.vcpus_running);
1108 /* Order vcpus_running vs. rma_setup_done, see kvmppc_alloc_reset_hpt */
1109 smp_mb();
1110
1111 /* On the first time here, set up HTAB and VRMA or RMA */
1108 if (!vcpu->kvm->arch.rma_setup_done) { 1112 if (!vcpu->kvm->arch.rma_setup_done) {
1109 r = kvmppc_hv_setup_rma(vcpu); 1113 r = kvmppc_hv_setup_htab_rma(vcpu);
1110 if (r) 1114 if (r)
1111 return r; 1115 goto out;
1112 } 1116 }
1113 1117
1114 flush_fp_to_thread(current); 1118 flush_fp_to_thread(current);
@@ -1126,6 +1130,9 @@ int kvmppc_vcpu_run(struct kvm_run *run, struct kvm_vcpu *vcpu)
1126 kvmppc_core_prepare_to_enter(vcpu); 1130 kvmppc_core_prepare_to_enter(vcpu);
1127 } 1131 }
1128 } while (r == RESUME_GUEST); 1132 } while (r == RESUME_GUEST);
1133
1134 out:
1135 atomic_dec(&vcpu->kvm->arch.vcpus_running);
1129 return r; 1136 return r;
1130} 1137}
1131 1138
@@ -1341,7 +1348,7 @@ void kvmppc_core_commit_memory_region(struct kvm *kvm,
1341{ 1348{
1342} 1349}
1343 1350
1344static int kvmppc_hv_setup_rma(struct kvm_vcpu *vcpu) 1351static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu)
1345{ 1352{
1346 int err = 0; 1353 int err = 0;
1347 struct kvm *kvm = vcpu->kvm; 1354 struct kvm *kvm = vcpu->kvm;
@@ -1360,6 +1367,15 @@ static int kvmppc_hv_setup_rma(struct kvm_vcpu *vcpu)
1360 if (kvm->arch.rma_setup_done) 1367 if (kvm->arch.rma_setup_done)
1361 goto out; /* another vcpu beat us to it */ 1368 goto out; /* another vcpu beat us to it */
1362 1369
1370 /* Allocate hashed page table (if not done already) and reset it */
1371 if (!kvm->arch.hpt_virt) {
1372 err = kvmppc_alloc_hpt(kvm, NULL);
1373 if (err) {
1374 pr_err("KVM: Couldn't alloc HPT\n");
1375 goto out;
1376 }
1377 }
1378
1363 /* Look up the memslot for guest physical address 0 */ 1379 /* Look up the memslot for guest physical address 0 */
1364 memslot = gfn_to_memslot(kvm, 0); 1380 memslot = gfn_to_memslot(kvm, 0);
1365 1381
@@ -1471,13 +1487,14 @@ static int kvmppc_hv_setup_rma(struct kvm_vcpu *vcpu)
1471 1487
1472int kvmppc_core_init_vm(struct kvm *kvm) 1488int kvmppc_core_init_vm(struct kvm *kvm)
1473{ 1489{
1474 long r; 1490 unsigned long lpcr, lpid;
1475 unsigned long lpcr;
1476 1491
1477 /* Allocate hashed page table */ 1492 /* Allocate the guest's logical partition ID */
1478 r = kvmppc_alloc_hpt(kvm); 1493
1479 if (r) 1494 lpid = kvmppc_alloc_lpid();
1480 return r; 1495 if (lpid < 0)
1496 return -ENOMEM;
1497 kvm->arch.lpid = lpid;
1481 1498
1482 INIT_LIST_HEAD(&kvm->arch.spapr_tce_tables); 1499 INIT_LIST_HEAD(&kvm->arch.spapr_tce_tables);
1483 1500
@@ -1487,7 +1504,6 @@ int kvmppc_core_init_vm(struct kvm *kvm)
1487 1504
1488 if (cpu_has_feature(CPU_FTR_ARCH_201)) { 1505 if (cpu_has_feature(CPU_FTR_ARCH_201)) {
1489 /* PPC970; HID4 is effectively the LPCR */ 1506 /* PPC970; HID4 is effectively the LPCR */
1490 unsigned long lpid = kvm->arch.lpid;
1491 kvm->arch.host_lpid = 0; 1507 kvm->arch.host_lpid = 0;
1492 kvm->arch.host_lpcr = lpcr = mfspr(SPRN_HID4); 1508 kvm->arch.host_lpcr = lpcr = mfspr(SPRN_HID4);
1493 lpcr &= ~((3 << HID4_LPID1_SH) | (0xful << HID4_LPID5_SH)); 1509 lpcr &= ~((3 << HID4_LPID1_SH) | (0xful << HID4_LPID5_SH));
diff --git a/arch/powerpc/kvm/book3s_hv_builtin.c b/arch/powerpc/kvm/book3s_hv_builtin.c
index e1b60f56f2a..fb4eac290fe 100644
--- a/arch/powerpc/kvm/book3s_hv_builtin.c
+++ b/arch/powerpc/kvm/book3s_hv_builtin.c
@@ -25,6 +25,9 @@ static void __init kvm_linear_init_one(ulong size, int count, int type);
25static struct kvmppc_linear_info *kvm_alloc_linear(int type); 25static struct kvmppc_linear_info *kvm_alloc_linear(int type);
26static void kvm_release_linear(struct kvmppc_linear_info *ri); 26static void kvm_release_linear(struct kvmppc_linear_info *ri);
27 27
28int kvm_hpt_order = KVM_DEFAULT_HPT_ORDER;
29EXPORT_SYMBOL_GPL(kvm_hpt_order);
30
28/*************** RMA *************/ 31/*************** RMA *************/
29 32
30/* 33/*
@@ -209,7 +212,7 @@ static void kvm_release_linear(struct kvmppc_linear_info *ri)
209void __init kvm_linear_init(void) 212void __init kvm_linear_init(void)
210{ 213{
211 /* HPT */ 214 /* HPT */
212 kvm_linear_init_one(1 << HPT_ORDER, kvm_hpt_count, KVM_LINEAR_HPT); 215 kvm_linear_init_one(1 << kvm_hpt_order, kvm_hpt_count, KVM_LINEAR_HPT);
213 216
214 /* RMA */ 217 /* RMA */
215 /* Only do this on PPC970 in HV mode */ 218 /* Only do this on PPC970 in HV mode */
diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
index cec4daddbf3..5c70d19494f 100644
--- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
+++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
@@ -237,7 +237,7 @@ long kvmppc_h_enter(struct kvm_vcpu *vcpu, unsigned long flags,
237 237
238 /* Find and lock the HPTEG slot to use */ 238 /* Find and lock the HPTEG slot to use */
239 do_insert: 239 do_insert:
240 if (pte_index >= HPT_NPTE) 240 if (pte_index >= kvm->arch.hpt_npte)
241 return H_PARAMETER; 241 return H_PARAMETER;
242 if (likely((flags & H_EXACT) == 0)) { 242 if (likely((flags & H_EXACT) == 0)) {
243 pte_index &= ~7UL; 243 pte_index &= ~7UL;
@@ -352,7 +352,7 @@ long kvmppc_h_remove(struct kvm_vcpu *vcpu, unsigned long flags,
352 unsigned long v, r, rb; 352 unsigned long v, r, rb;
353 struct revmap_entry *rev; 353 struct revmap_entry *rev;
354 354
355 if (pte_index >= HPT_NPTE) 355 if (pte_index >= kvm->arch.hpt_npte)
356 return H_PARAMETER; 356 return H_PARAMETER;
357 hpte = (unsigned long *)(kvm->arch.hpt_virt + (pte_index << 4)); 357 hpte = (unsigned long *)(kvm->arch.hpt_virt + (pte_index << 4));
358 while (!try_lock_hpte(hpte, HPTE_V_HVLOCK)) 358 while (!try_lock_hpte(hpte, HPTE_V_HVLOCK))
@@ -419,7 +419,8 @@ long kvmppc_h_bulk_remove(struct kvm_vcpu *vcpu)
419 i = 4; 419 i = 4;
420 break; 420 break;
421 } 421 }
422 if (req != 1 || flags == 3 || pte_index >= HPT_NPTE) { 422 if (req != 1 || flags == 3 ||
423 pte_index >= kvm->arch.hpt_npte) {
423 /* parameter error */ 424 /* parameter error */
424 args[j] = ((0xa0 | flags) << 56) + pte_index; 425 args[j] = ((0xa0 | flags) << 56) + pte_index;
425 ret = H_PARAMETER; 426 ret = H_PARAMETER;
@@ -521,7 +522,7 @@ long kvmppc_h_protect(struct kvm_vcpu *vcpu, unsigned long flags,
521 struct revmap_entry *rev; 522 struct revmap_entry *rev;
522 unsigned long v, r, rb, mask, bits; 523 unsigned long v, r, rb, mask, bits;
523 524
524 if (pte_index >= HPT_NPTE) 525 if (pte_index >= kvm->arch.hpt_npte)
525 return H_PARAMETER; 526 return H_PARAMETER;
526 527
527 hpte = (unsigned long *)(kvm->arch.hpt_virt + (pte_index << 4)); 528 hpte = (unsigned long *)(kvm->arch.hpt_virt + (pte_index << 4));
@@ -583,7 +584,7 @@ long kvmppc_h_read(struct kvm_vcpu *vcpu, unsigned long flags,
583 int i, n = 1; 584 int i, n = 1;
584 struct revmap_entry *rev = NULL; 585 struct revmap_entry *rev = NULL;
585 586
586 if (pte_index >= HPT_NPTE) 587 if (pte_index >= kvm->arch.hpt_npte)
587 return H_PARAMETER; 588 return H_PARAMETER;
588 if (flags & H_READ_4) { 589 if (flags & H_READ_4) {
589 pte_index &= ~3; 590 pte_index &= ~3;
@@ -678,7 +679,7 @@ long kvmppc_hv_find_lock_hpte(struct kvm *kvm, gva_t eaddr, unsigned long slb_v,
678 somask = (1UL << 28) - 1; 679 somask = (1UL << 28) - 1;
679 vsid = (slb_v & ~SLB_VSID_B) >> SLB_VSID_SHIFT; 680 vsid = (slb_v & ~SLB_VSID_B) >> SLB_VSID_SHIFT;
680 } 681 }
681 hash = (vsid ^ ((eaddr & somask) >> pshift)) & HPT_HASH_MASK; 682 hash = (vsid ^ ((eaddr & somask) >> pshift)) & kvm->arch.hpt_mask;
682 avpn = slb_v & ~(somask >> 16); /* also includes B */ 683 avpn = slb_v & ~(somask >> 16); /* also includes B */
683 avpn |= (eaddr & somask) >> 16; 684 avpn |= (eaddr & somask) >> 16;
684 685
@@ -723,7 +724,7 @@ long kvmppc_hv_find_lock_hpte(struct kvm *kvm, gva_t eaddr, unsigned long slb_v,
723 if (val & HPTE_V_SECONDARY) 724 if (val & HPTE_V_SECONDARY)
724 break; 725 break;
725 val |= HPTE_V_SECONDARY; 726 val |= HPTE_V_SECONDARY;
726 hash = hash ^ HPT_HASH_MASK; 727 hash = hash ^ kvm->arch.hpt_mask;
727 } 728 }
728 return -1; 729 return -1;
729} 730}
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index a1044f43bec..44b72feaff7 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -72,9 +72,6 @@ _GLOBAL(kvmppc_hv_entry_trampoline)
72 mtsrr1 r6 72 mtsrr1 r6
73 RFI 73 RFI
74 74
75#define ULONG_SIZE 8
76#define VCPU_GPR(n) (VCPU_GPRS + (n * ULONG_SIZE))
77
78/****************************************************************************** 75/******************************************************************************
79 * * 76 * *
80 * Entry code * 77 * Entry code *
@@ -206,24 +203,24 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
206 /* Load up FP, VMX and VSX registers */ 203 /* Load up FP, VMX and VSX registers */
207 bl kvmppc_load_fp 204 bl kvmppc_load_fp
208 205
209 ld r14, VCPU_GPR(r14)(r4) 206 ld r14, VCPU_GPR(R14)(r4)
210 ld r15, VCPU_GPR(r15)(r4) 207 ld r15, VCPU_GPR(R15)(r4)
211 ld r16, VCPU_GPR(r16)(r4) 208 ld r16, VCPU_GPR(R16)(r4)
212 ld r17, VCPU_GPR(r17)(r4) 209 ld r17, VCPU_GPR(R17)(r4)
213 ld r18, VCPU_GPR(r18)(r4) 210 ld r18, VCPU_GPR(R18)(r4)
214 ld r19, VCPU_GPR(r19)(r4) 211 ld r19, VCPU_GPR(R19)(r4)
215 ld r20, VCPU_GPR(r20)(r4) 212 ld r20, VCPU_GPR(R20)(r4)
216 ld r21, VCPU_GPR(r21)(r4) 213 ld r21, VCPU_GPR(R21)(r4)
217 ld r22, VCPU_GPR(r22)(r4) 214 ld r22, VCPU_GPR(R22)(r4)
218 ld r23, VCPU_GPR(r23)(r4) 215 ld r23, VCPU_GPR(R23)(r4)
219 ld r24, VCPU_GPR(r24)(r4) 216 ld r24, VCPU_GPR(R24)(r4)
220 ld r25, VCPU_GPR(r25)(r4) 217 ld r25, VCPU_GPR(R25)(r4)
221 ld r26, VCPU_GPR(r26)(r4) 218 ld r26, VCPU_GPR(R26)(r4)
222 ld r27, VCPU_GPR(r27)(r4) 219 ld r27, VCPU_GPR(R27)(r4)
223 ld r28, VCPU_GPR(r28)(r4) 220 ld r28, VCPU_GPR(R28)(r4)
224 ld r29, VCPU_GPR(r29)(r4) 221 ld r29, VCPU_GPR(R29)(r4)
225 ld r30, VCPU_GPR(r30)(r4) 222 ld r30, VCPU_GPR(R30)(r4)
226 ld r31, VCPU_GPR(r31)(r4) 223 ld r31, VCPU_GPR(R31)(r4)
227 224
228BEGIN_FTR_SECTION 225BEGIN_FTR_SECTION
229 /* Switch DSCR to guest value */ 226 /* Switch DSCR to guest value */
@@ -547,21 +544,21 @@ fast_guest_return:
547 mtlr r5 544 mtlr r5
548 mtcr r6 545 mtcr r6
549 546
550 ld r0, VCPU_GPR(r0)(r4) 547 ld r0, VCPU_GPR(R0)(r4)
551 ld r1, VCPU_GPR(r1)(r4) 548 ld r1, VCPU_GPR(R1)(r4)
552 ld r2, VCPU_GPR(r2)(r4) 549 ld r2, VCPU_GPR(R2)(r4)
553 ld r3, VCPU_GPR(r3)(r4) 550 ld r3, VCPU_GPR(R3)(r4)
554 ld r5, VCPU_GPR(r5)(r4) 551 ld r5, VCPU_GPR(R5)(r4)
555 ld r6, VCPU_GPR(r6)(r4) 552 ld r6, VCPU_GPR(R6)(r4)
556 ld r7, VCPU_GPR(r7)(r4) 553 ld r7, VCPU_GPR(R7)(r4)
557 ld r8, VCPU_GPR(r8)(r4) 554 ld r8, VCPU_GPR(R8)(r4)
558 ld r9, VCPU_GPR(r9)(r4) 555 ld r9, VCPU_GPR(R9)(r4)
559 ld r10, VCPU_GPR(r10)(r4) 556 ld r10, VCPU_GPR(R10)(r4)
560 ld r11, VCPU_GPR(r11)(r4) 557 ld r11, VCPU_GPR(R11)(r4)
561 ld r12, VCPU_GPR(r12)(r4) 558 ld r12, VCPU_GPR(R12)(r4)
562 ld r13, VCPU_GPR(r13)(r4) 559 ld r13, VCPU_GPR(R13)(r4)
563 560
564 ld r4, VCPU_GPR(r4)(r4) 561 ld r4, VCPU_GPR(R4)(r4)
565 562
566 hrfid 563 hrfid
567 b . 564 b .
@@ -590,22 +587,22 @@ kvmppc_interrupt:
590 587
591 /* Save registers */ 588 /* Save registers */
592 589
593 std r0, VCPU_GPR(r0)(r9) 590 std r0, VCPU_GPR(R0)(r9)
594 std r1, VCPU_GPR(r1)(r9) 591 std r1, VCPU_GPR(R1)(r9)
595 std r2, VCPU_GPR(r2)(r9) 592 std r2, VCPU_GPR(R2)(r9)
596 std r3, VCPU_GPR(r3)(r9) 593 std r3, VCPU_GPR(R3)(r9)
597 std r4, VCPU_GPR(r4)(r9) 594 std r4, VCPU_GPR(R4)(r9)
598 std r5, VCPU_GPR(r5)(r9) 595 std r5, VCPU_GPR(R5)(r9)
599 std r6, VCPU_GPR(r6)(r9) 596 std r6, VCPU_GPR(R6)(r9)
600 std r7, VCPU_GPR(r7)(r9) 597 std r7, VCPU_GPR(R7)(r9)
601 std r8, VCPU_GPR(r8)(r9) 598 std r8, VCPU_GPR(R8)(r9)
602 ld r0, HSTATE_HOST_R2(r13) 599 ld r0, HSTATE_HOST_R2(r13)
603 std r0, VCPU_GPR(r9)(r9) 600 std r0, VCPU_GPR(R9)(r9)
604 std r10, VCPU_GPR(r10)(r9) 601 std r10, VCPU_GPR(R10)(r9)
605 std r11, VCPU_GPR(r11)(r9) 602 std r11, VCPU_GPR(R11)(r9)
606 ld r3, HSTATE_SCRATCH0(r13) 603 ld r3, HSTATE_SCRATCH0(r13)
607 lwz r4, HSTATE_SCRATCH1(r13) 604 lwz r4, HSTATE_SCRATCH1(r13)
608 std r3, VCPU_GPR(r12)(r9) 605 std r3, VCPU_GPR(R12)(r9)
609 stw r4, VCPU_CR(r9) 606 stw r4, VCPU_CR(r9)
610 607
611 /* Restore R1/R2 so we can handle faults */ 608 /* Restore R1/R2 so we can handle faults */
@@ -626,7 +623,7 @@ kvmppc_interrupt:
626 623
627 GET_SCRATCH0(r3) 624 GET_SCRATCH0(r3)
628 mflr r4 625 mflr r4
629 std r3, VCPU_GPR(r13)(r9) 626 std r3, VCPU_GPR(R13)(r9)
630 std r4, VCPU_LR(r9) 627 std r4, VCPU_LR(r9)
631 628
632 /* Unset guest mode */ 629 /* Unset guest mode */
@@ -968,24 +965,24 @@ BEGIN_FTR_SECTION
968END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) 965END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
969 966
970 /* Save non-volatile GPRs */ 967 /* Save non-volatile GPRs */
971 std r14, VCPU_GPR(r14)(r9) 968 std r14, VCPU_GPR(R14)(r9)
972 std r15, VCPU_GPR(r15)(r9) 969 std r15, VCPU_GPR(R15)(r9)
973 std r16, VCPU_GPR(r16)(r9) 970 std r16, VCPU_GPR(R16)(r9)
974 std r17, VCPU_GPR(r17)(r9) 971 std r17, VCPU_GPR(R17)(r9)
975 std r18, VCPU_GPR(r18)(r9) 972 std r18, VCPU_GPR(R18)(r9)
976 std r19, VCPU_GPR(r19)(r9) 973 std r19, VCPU_GPR(R19)(r9)
977 std r20, VCPU_GPR(r20)(r9) 974 std r20, VCPU_GPR(R20)(r9)
978 std r21, VCPU_GPR(r21)(r9) 975 std r21, VCPU_GPR(R21)(r9)
979 std r22, VCPU_GPR(r22)(r9) 976 std r22, VCPU_GPR(R22)(r9)
980 std r23, VCPU_GPR(r23)(r9) 977 std r23, VCPU_GPR(R23)(r9)
981 std r24, VCPU_GPR(r24)(r9) 978 std r24, VCPU_GPR(R24)(r9)
982 std r25, VCPU_GPR(r25)(r9) 979 std r25, VCPU_GPR(R25)(r9)
983 std r26, VCPU_GPR(r26)(r9) 980 std r26, VCPU_GPR(R26)(r9)
984 std r27, VCPU_GPR(r27)(r9) 981 std r27, VCPU_GPR(R27)(r9)
985 std r28, VCPU_GPR(r28)(r9) 982 std r28, VCPU_GPR(R28)(r9)
986 std r29, VCPU_GPR(r29)(r9) 983 std r29, VCPU_GPR(R29)(r9)
987 std r30, VCPU_GPR(r30)(r9) 984 std r30, VCPU_GPR(R30)(r9)
988 std r31, VCPU_GPR(r31)(r9) 985 std r31, VCPU_GPR(R31)(r9)
989 986
990 /* Save SPRGs */ 987 /* Save SPRGs */
991 mfspr r3, SPRN_SPRG0 988 mfspr r3, SPRN_SPRG0
@@ -1067,6 +1064,10 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
1067 mtspr SPRN_DABR,r5 1064 mtspr SPRN_DABR,r5
1068 mtspr SPRN_DABRX,r6 1065 mtspr SPRN_DABRX,r6
1069 1066
1067 /* Restore SPRG3 */
1068 ld r3,HSTATE_SPRG3(r13)
1069 mtspr SPRN_SPRG3,r3
1070
1070 /* 1071 /*
1071 * Reload DEC. HDEC interrupts were disabled when 1072 * Reload DEC. HDEC interrupts were disabled when
1072 * we reloaded the host's LPCR value. 1073 * we reloaded the host's LPCR value.
@@ -1160,7 +1161,7 @@ kvmppc_hdsi:
1160 andi. r0, r11, MSR_DR /* data relocation enabled? */ 1161 andi. r0, r11, MSR_DR /* data relocation enabled? */
1161 beq 3f 1162 beq 3f
1162 clrrdi r0, r4, 28 1163 clrrdi r0, r4, 28
1163 PPC_SLBFEE_DOT(r5, r0) /* if so, look up SLB */ 1164 PPC_SLBFEE_DOT(R5, R0) /* if so, look up SLB */
1164 bne 1f /* if no SLB entry found */ 1165 bne 1f /* if no SLB entry found */
11654: std r4, VCPU_FAULT_DAR(r9) 11664: std r4, VCPU_FAULT_DAR(r9)
1166 stw r6, VCPU_FAULT_DSISR(r9) 1167 stw r6, VCPU_FAULT_DSISR(r9)
@@ -1234,7 +1235,7 @@ kvmppc_hisi:
1234 andi. r0, r11, MSR_IR /* instruction relocation enabled? */ 1235 andi. r0, r11, MSR_IR /* instruction relocation enabled? */
1235 beq 3f 1236 beq 3f
1236 clrrdi r0, r10, 28 1237 clrrdi r0, r10, 28
1237 PPC_SLBFEE_DOT(r5, r0) /* if so, look up SLB */ 1238 PPC_SLBFEE_DOT(R5, R0) /* if so, look up SLB */
1238 bne 1f /* if no SLB entry found */ 1239 bne 1f /* if no SLB entry found */
12394: 12404:
1240 /* Search the hash table. */ 1241 /* Search the hash table. */
@@ -1278,7 +1279,7 @@ kvmppc_hisi:
1278 */ 1279 */
1279 .globl hcall_try_real_mode 1280 .globl hcall_try_real_mode
1280hcall_try_real_mode: 1281hcall_try_real_mode:
1281 ld r3,VCPU_GPR(r3)(r9) 1282 ld r3,VCPU_GPR(R3)(r9)
1282 andi. r0,r11,MSR_PR 1283 andi. r0,r11,MSR_PR
1283 bne hcall_real_cont 1284 bne hcall_real_cont
1284 clrrdi r3,r3,2 1285 clrrdi r3,r3,2
@@ -1291,12 +1292,12 @@ hcall_try_real_mode:
1291 add r3,r3,r4 1292 add r3,r3,r4
1292 mtctr r3 1293 mtctr r3
1293 mr r3,r9 /* get vcpu pointer */ 1294 mr r3,r9 /* get vcpu pointer */
1294 ld r4,VCPU_GPR(r4)(r9) 1295 ld r4,VCPU_GPR(R4)(r9)
1295 bctrl 1296 bctrl
1296 cmpdi r3,H_TOO_HARD 1297 cmpdi r3,H_TOO_HARD
1297 beq hcall_real_fallback 1298 beq hcall_real_fallback
1298 ld r4,HSTATE_KVM_VCPU(r13) 1299 ld r4,HSTATE_KVM_VCPU(r13)
1299 std r3,VCPU_GPR(r3)(r4) 1300 std r3,VCPU_GPR(R3)(r4)
1300 ld r10,VCPU_PC(r4) 1301 ld r10,VCPU_PC(r4)
1301 ld r11,VCPU_MSR(r4) 1302 ld r11,VCPU_MSR(r4)
1302 b fast_guest_return 1303 b fast_guest_return
@@ -1420,13 +1421,13 @@ _GLOBAL(kvmppc_h_cede)
1420 sync /* order setting ceded vs. testing prodded */ 1421 sync /* order setting ceded vs. testing prodded */
1421 lbz r5,VCPU_PRODDED(r3) 1422 lbz r5,VCPU_PRODDED(r3)
1422 cmpwi r5,0 1423 cmpwi r5,0
1423 bne 1f 1424 bne kvm_cede_prodded
1424 li r0,0 /* set trap to 0 to say hcall is handled */ 1425 li r0,0 /* set trap to 0 to say hcall is handled */
1425 stw r0,VCPU_TRAP(r3) 1426 stw r0,VCPU_TRAP(r3)
1426 li r0,H_SUCCESS 1427 li r0,H_SUCCESS
1427 std r0,VCPU_GPR(r3)(r3) 1428 std r0,VCPU_GPR(R3)(r3)
1428BEGIN_FTR_SECTION 1429BEGIN_FTR_SECTION
1429 b 2f /* just send it up to host on 970 */ 1430 b kvm_cede_exit /* just send it up to host on 970 */
1430END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_206) 1431END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_206)
1431 1432
1432 /* 1433 /*
@@ -1443,9 +1444,9 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_206)
1443 addi r6,r5,VCORE_NAPPING_THREADS 1444 addi r6,r5,VCORE_NAPPING_THREADS
144431: lwarx r4,0,r6 144531: lwarx r4,0,r6
1445 or r4,r4,r0 1446 or r4,r4,r0
1446 PPC_POPCNTW(r7,r4) 1447 PPC_POPCNTW(R7,R4)
1447 cmpw r7,r8 1448 cmpw r7,r8
1448 bge 2f 1449 bge kvm_cede_exit
1449 stwcx. r4,0,r6 1450 stwcx. r4,0,r6
1450 bne 31b 1451 bne 31b
1451 li r0,1 1452 li r0,1
@@ -1464,24 +1465,24 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_206)
1464 * DAR, DSISR, DABR, DABRX, DSCR, PMCx, MMCRx, SIAR, SDAR. 1465 * DAR, DSISR, DABR, DABRX, DSCR, PMCx, MMCRx, SIAR, SDAR.
1465 */ 1466 */
1466 /* Save non-volatile GPRs */ 1467 /* Save non-volatile GPRs */
1467 std r14, VCPU_GPR(r14)(r3) 1468 std r14, VCPU_GPR(R14)(r3)
1468 std r15, VCPU_GPR(r15)(r3) 1469 std r15, VCPU_GPR(R15)(r3)
1469 std r16, VCPU_GPR(r16)(r3) 1470 std r16, VCPU_GPR(R16)(r3)
1470 std r17, VCPU_GPR(r17)(r3) 1471 std r17, VCPU_GPR(R17)(r3)
1471 std r18, VCPU_GPR(r18)(r3) 1472 std r18, VCPU_GPR(R18)(r3)
1472 std r19, VCPU_GPR(r19)(r3) 1473 std r19, VCPU_GPR(R19)(r3)
1473 std r20, VCPU_GPR(r20)(r3) 1474 std r20, VCPU_GPR(R20)(r3)
1474 std r21, VCPU_GPR(r21)(r3) 1475 std r21, VCPU_GPR(R21)(r3)
1475 std r22, VCPU_GPR(r22)(r3) 1476 std r22, VCPU_GPR(R22)(r3)
1476 std r23, VCPU_GPR(r23)(r3) 1477 std r23, VCPU_GPR(R23)(r3)
1477 std r24, VCPU_GPR(r24)(r3) 1478 std r24, VCPU_GPR(R24)(r3)
1478 std r25, VCPU_GPR(r25)(r3) 1479 std r25, VCPU_GPR(R25)(r3)
1479 std r26, VCPU_GPR(r26)(r3) 1480 std r26, VCPU_GPR(R26)(r3)
1480 std r27, VCPU_GPR(r27)(r3) 1481 std r27, VCPU_GPR(R27)(r3)
1481 std r28, VCPU_GPR(r28)(r3) 1482 std r28, VCPU_GPR(R28)(r3)
1482 std r29, VCPU_GPR(r29)(r3) 1483 std r29, VCPU_GPR(R29)(r3)
1483 std r30, VCPU_GPR(r30)(r3) 1484 std r30, VCPU_GPR(R30)(r3)
1484 std r31, VCPU_GPR(r31)(r3) 1485 std r31, VCPU_GPR(R31)(r3)
1485 1486
1486 /* save FP state */ 1487 /* save FP state */
1487 bl .kvmppc_save_fp 1488 bl .kvmppc_save_fp
@@ -1513,24 +1514,24 @@ kvm_end_cede:
1513 bl kvmppc_load_fp 1514 bl kvmppc_load_fp
1514 1515
1515 /* Load NV GPRS */ 1516 /* Load NV GPRS */
1516 ld r14, VCPU_GPR(r14)(r4) 1517 ld r14, VCPU_GPR(R14)(r4)
1517 ld r15, VCPU_GPR(r15)(r4) 1518 ld r15, VCPU_GPR(R15)(r4)
1518 ld r16, VCPU_GPR(r16)(r4) 1519 ld r16, VCPU_GPR(R16)(r4)
1519 ld r17, VCPU_GPR(r17)(r4) 1520 ld r17, VCPU_GPR(R17)(r4)
1520 ld r18, VCPU_GPR(r18)(r4) 1521 ld r18, VCPU_GPR(R18)(r4)
1521 ld r19, VCPU_GPR(r19)(r4) 1522 ld r19, VCPU_GPR(R19)(r4)
1522 ld r20, VCPU_GPR(r20)(r4) 1523 ld r20, VCPU_GPR(R20)(r4)
1523 ld r21, VCPU_GPR(r21)(r4) 1524 ld r21, VCPU_GPR(R21)(r4)
1524 ld r22, VCPU_GPR(r22)(r4) 1525 ld r22, VCPU_GPR(R22)(r4)
1525 ld r23, VCPU_GPR(r23)(r4) 1526 ld r23, VCPU_GPR(R23)(r4)
1526 ld r24, VCPU_GPR(r24)(r4) 1527 ld r24, VCPU_GPR(R24)(r4)
1527 ld r25, VCPU_GPR(r25)(r4) 1528 ld r25, VCPU_GPR(R25)(r4)
1528 ld r26, VCPU_GPR(r26)(r4) 1529 ld r26, VCPU_GPR(R26)(r4)
1529 ld r27, VCPU_GPR(r27)(r4) 1530 ld r27, VCPU_GPR(R27)(r4)
1530 ld r28, VCPU_GPR(r28)(r4) 1531 ld r28, VCPU_GPR(R28)(r4)
1531 ld r29, VCPU_GPR(r29)(r4) 1532 ld r29, VCPU_GPR(R29)(r4)
1532 ld r30, VCPU_GPR(r30)(r4) 1533 ld r30, VCPU_GPR(R30)(r4)
1533 ld r31, VCPU_GPR(r31)(r4) 1534 ld r31, VCPU_GPR(R31)(r4)
1534 1535
1535 /* clear our bit in vcore->napping_threads */ 1536 /* clear our bit in vcore->napping_threads */
153633: ld r5,HSTATE_KVM_VCORE(r13) 153733: ld r5,HSTATE_KVM_VCORE(r13)
@@ -1554,7 +1555,8 @@ kvm_end_cede:
1554 b hcall_real_fallback 1555 b hcall_real_fallback
1555 1556
1556 /* cede when already previously prodded case */ 1557 /* cede when already previously prodded case */
15571: li r0,0 1558kvm_cede_prodded:
1559 li r0,0
1558 stb r0,VCPU_PRODDED(r3) 1560 stb r0,VCPU_PRODDED(r3)
1559 sync /* order testing prodded vs. clearing ceded */ 1561 sync /* order testing prodded vs. clearing ceded */
1560 stb r0,VCPU_CEDED(r3) 1562 stb r0,VCPU_CEDED(r3)
@@ -1562,7 +1564,8 @@ kvm_end_cede:
1562 blr 1564 blr
1563 1565
1564 /* we've ceded but we want to give control to the host */ 1566 /* we've ceded but we want to give control to the host */
15652: li r3,H_TOO_HARD 1567kvm_cede_exit:
1568 li r3,H_TOO_HARD
1566 blr 1569 blr
1567 1570
1568secondary_too_late: 1571secondary_too_late:
@@ -1649,7 +1652,7 @@ BEGIN_FTR_SECTION
1649 reg = 0 1652 reg = 0
1650 .rept 32 1653 .rept 32
1651 li r6,reg*16+VCPU_VSRS 1654 li r6,reg*16+VCPU_VSRS
1652 STXVD2X(reg,r6,r3) 1655 STXVD2X(reg,R6,R3)
1653 reg = reg + 1 1656 reg = reg + 1
1654 .endr 1657 .endr
1655FTR_SECTION_ELSE 1658FTR_SECTION_ELSE
@@ -1711,7 +1714,7 @@ BEGIN_FTR_SECTION
1711 reg = 0 1714 reg = 0
1712 .rept 32 1715 .rept 32
1713 li r7,reg*16+VCPU_VSRS 1716 li r7,reg*16+VCPU_VSRS
1714 LXVD2X(reg,r7,r4) 1717 LXVD2X(reg,R7,R4)
1715 reg = reg + 1 1718 reg = reg + 1
1716 .endr 1719 .endr
1717FTR_SECTION_ELSE 1720FTR_SECTION_ELSE
diff --git a/arch/powerpc/kvm/book3s_interrupts.S b/arch/powerpc/kvm/book3s_interrupts.S
index 3e35383bdb2..48cbbf86295 100644
--- a/arch/powerpc/kvm/book3s_interrupts.S
+++ b/arch/powerpc/kvm/book3s_interrupts.S
@@ -25,38 +25,30 @@
25#include <asm/exception-64s.h> 25#include <asm/exception-64s.h>
26 26
27#if defined(CONFIG_PPC_BOOK3S_64) 27#if defined(CONFIG_PPC_BOOK3S_64)
28
29#define ULONG_SIZE 8
30#define FUNC(name) GLUE(.,name) 28#define FUNC(name) GLUE(.,name)
31
32#elif defined(CONFIG_PPC_BOOK3S_32) 29#elif defined(CONFIG_PPC_BOOK3S_32)
33
34#define ULONG_SIZE 4
35#define FUNC(name) name 30#define FUNC(name) name
36
37#endif /* CONFIG_PPC_BOOK3S_XX */ 31#endif /* CONFIG_PPC_BOOK3S_XX */
38 32
39
40#define VCPU_GPR(n) (VCPU_GPRS + (n * ULONG_SIZE))
41#define VCPU_LOAD_NVGPRS(vcpu) \ 33#define VCPU_LOAD_NVGPRS(vcpu) \
42 PPC_LL r14, VCPU_GPR(r14)(vcpu); \ 34 PPC_LL r14, VCPU_GPR(R14)(vcpu); \
43 PPC_LL r15, VCPU_GPR(r15)(vcpu); \ 35 PPC_LL r15, VCPU_GPR(R15)(vcpu); \
44 PPC_LL r16, VCPU_GPR(r16)(vcpu); \ 36 PPC_LL r16, VCPU_GPR(R16)(vcpu); \
45 PPC_LL r17, VCPU_GPR(r17)(vcpu); \ 37 PPC_LL r17, VCPU_GPR(R17)(vcpu); \
46 PPC_LL r18, VCPU_GPR(r18)(vcpu); \ 38 PPC_LL r18, VCPU_GPR(R18)(vcpu); \
47 PPC_LL r19, VCPU_GPR(r19)(vcpu); \ 39 PPC_LL r19, VCPU_GPR(R19)(vcpu); \
48 PPC_LL r20, VCPU_GPR(r20)(vcpu); \ 40 PPC_LL r20, VCPU_GPR(R20)(vcpu); \
49 PPC_LL r21, VCPU_GPR(r21)(vcpu); \ 41 PPC_LL r21, VCPU_GPR(R21)(vcpu); \
50 PPC_LL r22, VCPU_GPR(r22)(vcpu); \ 42 PPC_LL r22, VCPU_GPR(R22)(vcpu); \
51 PPC_LL r23, VCPU_GPR(r23)(vcpu); \ 43 PPC_LL r23, VCPU_GPR(R23)(vcpu); \
52 PPC_LL r24, VCPU_GPR(r24)(vcpu); \ 44 PPC_LL r24, VCPU_GPR(R24)(vcpu); \
53 PPC_LL r25, VCPU_GPR(r25)(vcpu); \ 45 PPC_LL r25, VCPU_GPR(R25)(vcpu); \
54 PPC_LL r26, VCPU_GPR(r26)(vcpu); \ 46 PPC_LL r26, VCPU_GPR(R26)(vcpu); \
55 PPC_LL r27, VCPU_GPR(r27)(vcpu); \ 47 PPC_LL r27, VCPU_GPR(R27)(vcpu); \
56 PPC_LL r28, VCPU_GPR(r28)(vcpu); \ 48 PPC_LL r28, VCPU_GPR(R28)(vcpu); \
57 PPC_LL r29, VCPU_GPR(r29)(vcpu); \ 49 PPC_LL r29, VCPU_GPR(R29)(vcpu); \
58 PPC_LL r30, VCPU_GPR(r30)(vcpu); \ 50 PPC_LL r30, VCPU_GPR(R30)(vcpu); \
59 PPC_LL r31, VCPU_GPR(r31)(vcpu); \ 51 PPC_LL r31, VCPU_GPR(R31)(vcpu); \
60 52
61/***************************************************************************** 53/*****************************************************************************
62 * * 54 * *
@@ -131,24 +123,24 @@ kvmppc_handler_highmem:
131 /* R7 = vcpu */ 123 /* R7 = vcpu */
132 PPC_LL r7, GPR4(r1) 124 PPC_LL r7, GPR4(r1)
133 125
134 PPC_STL r14, VCPU_GPR(r14)(r7) 126 PPC_STL r14, VCPU_GPR(R14)(r7)
135 PPC_STL r15, VCPU_GPR(r15)(r7) 127 PPC_STL r15, VCPU_GPR(R15)(r7)
136 PPC_STL r16, VCPU_GPR(r16)(r7) 128 PPC_STL r16, VCPU_GPR(R16)(r7)
137 PPC_STL r17, VCPU_GPR(r17)(r7) 129 PPC_STL r17, VCPU_GPR(R17)(r7)
138 PPC_STL r18, VCPU_GPR(r18)(r7) 130 PPC_STL r18, VCPU_GPR(R18)(r7)
139 PPC_STL r19, VCPU_GPR(r19)(r7) 131 PPC_STL r19, VCPU_GPR(R19)(r7)
140 PPC_STL r20, VCPU_GPR(r20)(r7) 132 PPC_STL r20, VCPU_GPR(R20)(r7)
141 PPC_STL r21, VCPU_GPR(r21)(r7) 133 PPC_STL r21, VCPU_GPR(R21)(r7)
142 PPC_STL r22, VCPU_GPR(r22)(r7) 134 PPC_STL r22, VCPU_GPR(R22)(r7)
143 PPC_STL r23, VCPU_GPR(r23)(r7) 135 PPC_STL r23, VCPU_GPR(R23)(r7)
144 PPC_STL r24, VCPU_GPR(r24)(r7) 136 PPC_STL r24, VCPU_GPR(R24)(r7)
145 PPC_STL r25, VCPU_GPR(r25)(r7) 137 PPC_STL r25, VCPU_GPR(R25)(r7)
146 PPC_STL r26, VCPU_GPR(r26)(r7) 138 PPC_STL r26, VCPU_GPR(R26)(r7)
147 PPC_STL r27, VCPU_GPR(r27)(r7) 139 PPC_STL r27, VCPU_GPR(R27)(r7)
148 PPC_STL r28, VCPU_GPR(r28)(r7) 140 PPC_STL r28, VCPU_GPR(R28)(r7)
149 PPC_STL r29, VCPU_GPR(r29)(r7) 141 PPC_STL r29, VCPU_GPR(R29)(r7)
150 PPC_STL r30, VCPU_GPR(r30)(r7) 142 PPC_STL r30, VCPU_GPR(R30)(r7)
151 PPC_STL r31, VCPU_GPR(r31)(r7) 143 PPC_STL r31, VCPU_GPR(R31)(r7)
152 144
153 /* Pass the exit number as 3rd argument to kvmppc_handle_exit */ 145 /* Pass the exit number as 3rd argument to kvmppc_handle_exit */
154 mr r5, r12 146 mr r5, r12
diff --git a/arch/powerpc/kvm/book3s_rmhandlers.S b/arch/powerpc/kvm/book3s_rmhandlers.S
index 34187585c50..9ecf6e35cd8 100644
--- a/arch/powerpc/kvm/book3s_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_rmhandlers.S
@@ -37,7 +37,6 @@
37#if defined(CONFIG_PPC_BOOK3S_64) 37#if defined(CONFIG_PPC_BOOK3S_64)
38 38
39#define FUNC(name) GLUE(.,name) 39#define FUNC(name) GLUE(.,name)
40#define MTMSR_EERI(reg) mtmsrd (reg),1
41 40
42 .globl kvmppc_skip_interrupt 41 .globl kvmppc_skip_interrupt
43kvmppc_skip_interrupt: 42kvmppc_skip_interrupt:
@@ -68,7 +67,6 @@ kvmppc_skip_Hinterrupt:
68#elif defined(CONFIG_PPC_BOOK3S_32) 67#elif defined(CONFIG_PPC_BOOK3S_32)
69 68
70#define FUNC(name) name 69#define FUNC(name) name
71#define MTMSR_EERI(reg) mtmsr (reg)
72 70
73.macro INTERRUPT_TRAMPOLINE intno 71.macro INTERRUPT_TRAMPOLINE intno
74 72
diff --git a/arch/powerpc/kvm/book3s_segment.S b/arch/powerpc/kvm/book3s_segment.S
index 798491a268b..1abe4788191 100644
--- a/arch/powerpc/kvm/book3s_segment.S
+++ b/arch/powerpc/kvm/book3s_segment.S
@@ -23,7 +23,6 @@
23 23
24#define GET_SHADOW_VCPU(reg) \ 24#define GET_SHADOW_VCPU(reg) \
25 mr reg, r13 25 mr reg, r13
26#define MTMSR_EERI(reg) mtmsrd (reg),1
27 26
28#elif defined(CONFIG_PPC_BOOK3S_32) 27#elif defined(CONFIG_PPC_BOOK3S_32)
29 28
@@ -31,7 +30,6 @@
31 tophys(reg, r2); \ 30 tophys(reg, r2); \
32 lwz reg, (THREAD + THREAD_KVM_SVCPU)(reg); \ 31 lwz reg, (THREAD + THREAD_KVM_SVCPU)(reg); \
33 tophys(reg, reg) 32 tophys(reg, reg)
34#define MTMSR_EERI(reg) mtmsr (reg)
35 33
36#endif 34#endif
37 35
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 72f13f4a06e..d25a097c852 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -612,6 +612,12 @@ static void kvmppc_fill_pt_regs(struct pt_regs *regs)
612 regs->link = lr; 612 regs->link = lr;
613} 613}
614 614
615/*
616 * For interrupts needed to be handled by host interrupt handlers,
617 * corresponding host handler are called from here in similar way
618 * (but not exact) as they are called from low level handler
619 * (such as from arch/powerpc/kernel/head_fsl_booke.S).
620 */
615static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu, 621static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,
616 unsigned int exit_nr) 622 unsigned int exit_nr)
617{ 623{
@@ -639,6 +645,17 @@ static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,
639 kvmppc_fill_pt_regs(&regs); 645 kvmppc_fill_pt_regs(&regs);
640 performance_monitor_exception(&regs); 646 performance_monitor_exception(&regs);
641 break; 647 break;
648 case BOOKE_INTERRUPT_WATCHDOG:
649 kvmppc_fill_pt_regs(&regs);
650#ifdef CONFIG_BOOKE_WDT
651 WatchdogException(&regs);
652#else
653 unknown_exception(&regs);
654#endif
655 break;
656 case BOOKE_INTERRUPT_CRITICAL:
657 unknown_exception(&regs);
658 break;
642 } 659 }
643} 660}
644 661
@@ -683,6 +700,10 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
683 r = RESUME_GUEST; 700 r = RESUME_GUEST;
684 break; 701 break;
685 702
703 case BOOKE_INTERRUPT_WATCHDOG:
704 r = RESUME_GUEST;
705 break;
706
686 case BOOKE_INTERRUPT_DOORBELL: 707 case BOOKE_INTERRUPT_DOORBELL:
687 kvmppc_account_exit(vcpu, DBELL_EXITS); 708 kvmppc_account_exit(vcpu, DBELL_EXITS);
688 r = RESUME_GUEST; 709 r = RESUME_GUEST;
@@ -1267,6 +1288,11 @@ void kvmppc_decrementer_func(unsigned long data)
1267{ 1288{
1268 struct kvm_vcpu *vcpu = (struct kvm_vcpu *)data; 1289 struct kvm_vcpu *vcpu = (struct kvm_vcpu *)data;
1269 1290
1291 if (vcpu->arch.tcr & TCR_ARE) {
1292 vcpu->arch.dec = vcpu->arch.decar;
1293 kvmppc_emulate_dec(vcpu);
1294 }
1295
1270 kvmppc_set_tsr_bits(vcpu, TSR_DIS); 1296 kvmppc_set_tsr_bits(vcpu, TSR_DIS);
1271} 1297}
1272 1298
diff --git a/arch/powerpc/kvm/booke_emulate.c b/arch/powerpc/kvm/booke_emulate.c
index 6c76397f2af..12834bb608a 100644
--- a/arch/powerpc/kvm/booke_emulate.c
+++ b/arch/powerpc/kvm/booke_emulate.c
@@ -24,6 +24,7 @@
24#include "booke.h" 24#include "booke.h"
25 25
26#define OP_19_XOP_RFI 50 26#define OP_19_XOP_RFI 50
27#define OP_19_XOP_RFCI 51
27 28
28#define OP_31_XOP_MFMSR 83 29#define OP_31_XOP_MFMSR 83
29#define OP_31_XOP_WRTEE 131 30#define OP_31_XOP_WRTEE 131
@@ -36,6 +37,12 @@ static void kvmppc_emul_rfi(struct kvm_vcpu *vcpu)
36 kvmppc_set_msr(vcpu, vcpu->arch.shared->srr1); 37 kvmppc_set_msr(vcpu, vcpu->arch.shared->srr1);
37} 38}
38 39
40static void kvmppc_emul_rfci(struct kvm_vcpu *vcpu)
41{
42 vcpu->arch.pc = vcpu->arch.csrr0;
43 kvmppc_set_msr(vcpu, vcpu->arch.csrr1);
44}
45
39int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, 46int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
40 unsigned int inst, int *advance) 47 unsigned int inst, int *advance)
41{ 48{
@@ -52,6 +59,12 @@ int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
52 *advance = 0; 59 *advance = 0;
53 break; 60 break;
54 61
62 case OP_19_XOP_RFCI:
63 kvmppc_emul_rfci(vcpu);
64 kvmppc_set_exit_type(vcpu, EMULATED_RFCI_EXITS);
65 *advance = 0;
66 break;
67
55 default: 68 default:
56 emulated = EMULATE_FAIL; 69 emulated = EMULATE_FAIL;
57 break; 70 break;
@@ -113,6 +126,12 @@ int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)
113 case SPRN_ESR: 126 case SPRN_ESR:
114 vcpu->arch.shared->esr = spr_val; 127 vcpu->arch.shared->esr = spr_val;
115 break; 128 break;
129 case SPRN_CSRR0:
130 vcpu->arch.csrr0 = spr_val;
131 break;
132 case SPRN_CSRR1:
133 vcpu->arch.csrr1 = spr_val;
134 break;
116 case SPRN_DBCR0: 135 case SPRN_DBCR0:
117 vcpu->arch.dbcr0 = spr_val; 136 vcpu->arch.dbcr0 = spr_val;
118 break; 137 break;
@@ -129,6 +148,9 @@ int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)
129 kvmppc_set_tcr(vcpu, spr_val); 148 kvmppc_set_tcr(vcpu, spr_val);
130 break; 149 break;
131 150
151 case SPRN_DECAR:
152 vcpu->arch.decar = spr_val;
153 break;
132 /* 154 /*
133 * Note: SPRG4-7 are user-readable. 155 * Note: SPRG4-7 are user-readable.
134 * These values are loaded into the real SPRGs when resuming the 156 * These values are loaded into the real SPRGs when resuming the
@@ -229,6 +251,12 @@ int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val)
229 case SPRN_ESR: 251 case SPRN_ESR:
230 *spr_val = vcpu->arch.shared->esr; 252 *spr_val = vcpu->arch.shared->esr;
231 break; 253 break;
254 case SPRN_CSRR0:
255 *spr_val = vcpu->arch.csrr0;
256 break;
257 case SPRN_CSRR1:
258 *spr_val = vcpu->arch.csrr1;
259 break;
232 case SPRN_DBCR0: 260 case SPRN_DBCR0:
233 *spr_val = vcpu->arch.dbcr0; 261 *spr_val = vcpu->arch.dbcr0;
234 break; 262 break;
diff --git a/arch/powerpc/kvm/booke_interrupts.S b/arch/powerpc/kvm/booke_interrupts.S
index 8feec2ff392..bb46b32f981 100644
--- a/arch/powerpc/kvm/booke_interrupts.S
+++ b/arch/powerpc/kvm/booke_interrupts.S
@@ -25,8 +25,6 @@
25#include <asm/page.h> 25#include <asm/page.h>
26#include <asm/asm-offsets.h> 26#include <asm/asm-offsets.h>
27 27
28#define VCPU_GPR(n) (VCPU_GPRS + (n * 4))
29
30/* The host stack layout: */ 28/* The host stack layout: */
31#define HOST_R1 0 /* Implied by stwu. */ 29#define HOST_R1 0 /* Implied by stwu. */
32#define HOST_CALLEE_LR 4 30#define HOST_CALLEE_LR 4
@@ -36,8 +34,9 @@
36#define HOST_R2 12 34#define HOST_R2 12
37#define HOST_CR 16 35#define HOST_CR 16
38#define HOST_NV_GPRS 20 36#define HOST_NV_GPRS 20
39#define HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * 4)) 37#define __HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * 4))
40#define HOST_MIN_STACK_SIZE (HOST_NV_GPR(31) + 4) 38#define HOST_NV_GPR(n) __HOST_NV_GPR(__REG_##n)
39#define HOST_MIN_STACK_SIZE (HOST_NV_GPR(R31) + 4)
41#define HOST_STACK_SIZE (((HOST_MIN_STACK_SIZE + 15) / 16) * 16) /* Align. */ 40#define HOST_STACK_SIZE (((HOST_MIN_STACK_SIZE + 15) / 16) * 16) /* Align. */
42#define HOST_STACK_LR (HOST_STACK_SIZE + 4) /* In caller stack frame. */ 41#define HOST_STACK_LR (HOST_STACK_SIZE + 4) /* In caller stack frame. */
43 42
@@ -53,16 +52,21 @@
53 (1<<BOOKE_INTERRUPT_PROGRAM) | \ 52 (1<<BOOKE_INTERRUPT_PROGRAM) | \
54 (1<<BOOKE_INTERRUPT_DTLB_MISS)) 53 (1<<BOOKE_INTERRUPT_DTLB_MISS))
55 54
56.macro KVM_HANDLER ivor_nr 55.macro KVM_HANDLER ivor_nr scratch srr0
57_GLOBAL(kvmppc_handler_\ivor_nr) 56_GLOBAL(kvmppc_handler_\ivor_nr)
58 /* Get pointer to vcpu and record exit number. */ 57 /* Get pointer to vcpu and record exit number. */
59 mtspr SPRN_SPRG_WSCRATCH0, r4 58 mtspr \scratch , r4
60 mfspr r4, SPRN_SPRG_RVCPU 59 mfspr r4, SPRN_SPRG_RVCPU
61 stw r5, VCPU_GPR(r5)(r4) 60 stw r3, VCPU_GPR(R3)(r4)
62 stw r6, VCPU_GPR(r6)(r4) 61 stw r5, VCPU_GPR(R5)(r4)
62 stw r6, VCPU_GPR(R6)(r4)
63 mfspr r3, \scratch
63 mfctr r5 64 mfctr r5
64 lis r6, kvmppc_resume_host@h 65 stw r3, VCPU_GPR(R4)(r4)
65 stw r5, VCPU_CTR(r4) 66 stw r5, VCPU_CTR(r4)
67 mfspr r3, \srr0
68 lis r6, kvmppc_resume_host@h
69 stw r3, VCPU_PC(r4)
66 li r5, \ivor_nr 70 li r5, \ivor_nr
67 ori r6, r6, kvmppc_resume_host@l 71 ori r6, r6, kvmppc_resume_host@l
68 mtctr r6 72 mtctr r6
@@ -70,42 +74,40 @@ _GLOBAL(kvmppc_handler_\ivor_nr)
70.endm 74.endm
71 75
72_GLOBAL(kvmppc_handlers_start) 76_GLOBAL(kvmppc_handlers_start)
73KVM_HANDLER BOOKE_INTERRUPT_CRITICAL 77KVM_HANDLER BOOKE_INTERRUPT_CRITICAL SPRN_SPRG_RSCRATCH_CRIT SPRN_CSRR0
74KVM_HANDLER BOOKE_INTERRUPT_MACHINE_CHECK 78KVM_HANDLER BOOKE_INTERRUPT_MACHINE_CHECK SPRN_SPRG_RSCRATCH_MC SPRN_MCSRR0
75KVM_HANDLER BOOKE_INTERRUPT_DATA_STORAGE 79KVM_HANDLER BOOKE_INTERRUPT_DATA_STORAGE SPRN_SPRG_RSCRATCH0 SPRN_SRR0
76KVM_HANDLER BOOKE_INTERRUPT_INST_STORAGE 80KVM_HANDLER BOOKE_INTERRUPT_INST_STORAGE SPRN_SPRG_RSCRATCH0 SPRN_SRR0
77KVM_HANDLER BOOKE_INTERRUPT_EXTERNAL 81KVM_HANDLER BOOKE_INTERRUPT_EXTERNAL SPRN_SPRG_RSCRATCH0 SPRN_SRR0
78KVM_HANDLER BOOKE_INTERRUPT_ALIGNMENT 82KVM_HANDLER BOOKE_INTERRUPT_ALIGNMENT SPRN_SPRG_RSCRATCH0 SPRN_SRR0
79KVM_HANDLER BOOKE_INTERRUPT_PROGRAM 83KVM_HANDLER BOOKE_INTERRUPT_PROGRAM SPRN_SPRG_RSCRATCH0 SPRN_SRR0
80KVM_HANDLER BOOKE_INTERRUPT_FP_UNAVAIL 84KVM_HANDLER BOOKE_INTERRUPT_FP_UNAVAIL SPRN_SPRG_RSCRATCH0 SPRN_SRR0
81KVM_HANDLER BOOKE_INTERRUPT_SYSCALL 85KVM_HANDLER BOOKE_INTERRUPT_SYSCALL SPRN_SPRG_RSCRATCH0 SPRN_SRR0
82KVM_HANDLER BOOKE_INTERRUPT_AP_UNAVAIL 86KVM_HANDLER BOOKE_INTERRUPT_AP_UNAVAIL SPRN_SPRG_RSCRATCH0 SPRN_SRR0
83KVM_HANDLER BOOKE_INTERRUPT_DECREMENTER 87KVM_HANDLER BOOKE_INTERRUPT_DECREMENTER SPRN_SPRG_RSCRATCH0 SPRN_SRR0
84KVM_HANDLER BOOKE_INTERRUPT_FIT 88KVM_HANDLER BOOKE_INTERRUPT_FIT SPRN_SPRG_RSCRATCH0 SPRN_SRR0
85KVM_HANDLER BOOKE_INTERRUPT_WATCHDOG 89KVM_HANDLER BOOKE_INTERRUPT_WATCHDOG SPRN_SPRG_RSCRATCH_CRIT SPRN_CSRR0
86KVM_HANDLER BOOKE_INTERRUPT_DTLB_MISS 90KVM_HANDLER BOOKE_INTERRUPT_DTLB_MISS SPRN_SPRG_RSCRATCH0 SPRN_SRR0
87KVM_HANDLER BOOKE_INTERRUPT_ITLB_MISS 91KVM_HANDLER BOOKE_INTERRUPT_ITLB_MISS SPRN_SPRG_RSCRATCH0 SPRN_SRR0
88KVM_HANDLER BOOKE_INTERRUPT_DEBUG 92KVM_HANDLER BOOKE_INTERRUPT_DEBUG SPRN_SPRG_RSCRATCH_CRIT SPRN_CSRR0
89KVM_HANDLER BOOKE_INTERRUPT_SPE_UNAVAIL 93KVM_HANDLER BOOKE_INTERRUPT_SPE_UNAVAIL SPRN_SPRG_RSCRATCH0 SPRN_SRR0
90KVM_HANDLER BOOKE_INTERRUPT_SPE_FP_DATA 94KVM_HANDLER BOOKE_INTERRUPT_SPE_FP_DATA SPRN_SPRG_RSCRATCH0 SPRN_SRR0
91KVM_HANDLER BOOKE_INTERRUPT_SPE_FP_ROUND 95KVM_HANDLER BOOKE_INTERRUPT_SPE_FP_ROUND SPRN_SPRG_RSCRATCH0 SPRN_SRR0
92 96
93_GLOBAL(kvmppc_handler_len) 97_GLOBAL(kvmppc_handler_len)
94 .long kvmppc_handler_1 - kvmppc_handler_0 98 .long kvmppc_handler_1 - kvmppc_handler_0
95 99
96
97/* Registers: 100/* Registers:
98 * SPRG_SCRATCH0: guest r4 101 * SPRG_SCRATCH0: guest r4
99 * r4: vcpu pointer 102 * r4: vcpu pointer
100 * r5: KVM exit number 103 * r5: KVM exit number
101 */ 104 */
102_GLOBAL(kvmppc_resume_host) 105_GLOBAL(kvmppc_resume_host)
103 stw r3, VCPU_GPR(r3)(r4)
104 mfcr r3 106 mfcr r3
105 stw r3, VCPU_CR(r4) 107 stw r3, VCPU_CR(r4)
106 stw r7, VCPU_GPR(r7)(r4) 108 stw r7, VCPU_GPR(R7)(r4)
107 stw r8, VCPU_GPR(r8)(r4) 109 stw r8, VCPU_GPR(R8)(r4)
108 stw r9, VCPU_GPR(r9)(r4) 110 stw r9, VCPU_GPR(R9)(r4)
109 111
110 li r6, 1 112 li r6, 1
111 slw r6, r6, r5 113 slw r6, r6, r5
@@ -135,23 +137,23 @@ _GLOBAL(kvmppc_resume_host)
135 isync 137 isync
136 stw r9, VCPU_LAST_INST(r4) 138 stw r9, VCPU_LAST_INST(r4)
137 139
138 stw r15, VCPU_GPR(r15)(r4) 140 stw r15, VCPU_GPR(R15)(r4)
139 stw r16, VCPU_GPR(r16)(r4) 141 stw r16, VCPU_GPR(R16)(r4)
140 stw r17, VCPU_GPR(r17)(r4) 142 stw r17, VCPU_GPR(R17)(r4)
141 stw r18, VCPU_GPR(r18)(r4) 143 stw r18, VCPU_GPR(R18)(r4)
142 stw r19, VCPU_GPR(r19)(r4) 144 stw r19, VCPU_GPR(R19)(r4)
143 stw r20, VCPU_GPR(r20)(r4) 145 stw r20, VCPU_GPR(R20)(r4)
144 stw r21, VCPU_GPR(r21)(r4) 146 stw r21, VCPU_GPR(R21)(r4)
145 stw r22, VCPU_GPR(r22)(r4) 147 stw r22, VCPU_GPR(R22)(r4)
146 stw r23, VCPU_GPR(r23)(r4) 148 stw r23, VCPU_GPR(R23)(r4)
147 stw r24, VCPU_GPR(r24)(r4) 149 stw r24, VCPU_GPR(R24)(r4)
148 stw r25, VCPU_GPR(r25)(r4) 150 stw r25, VCPU_GPR(R25)(r4)
149 stw r26, VCPU_GPR(r26)(r4) 151 stw r26, VCPU_GPR(R26)(r4)
150 stw r27, VCPU_GPR(r27)(r4) 152 stw r27, VCPU_GPR(R27)(r4)
151 stw r28, VCPU_GPR(r28)(r4) 153 stw r28, VCPU_GPR(R28)(r4)
152 stw r29, VCPU_GPR(r29)(r4) 154 stw r29, VCPU_GPR(R29)(r4)
153 stw r30, VCPU_GPR(r30)(r4) 155 stw r30, VCPU_GPR(R30)(r4)
154 stw r31, VCPU_GPR(r31)(r4) 156 stw r31, VCPU_GPR(R31)(r4)
155..skip_inst_copy: 157..skip_inst_copy:
156 158
157 /* Also grab DEAR and ESR before the host can clobber them. */ 159 /* Also grab DEAR and ESR before the host can clobber them. */
@@ -169,22 +171,18 @@ _GLOBAL(kvmppc_resume_host)
169..skip_esr: 171..skip_esr:
170 172
171 /* Save remaining volatile guest register state to vcpu. */ 173 /* Save remaining volatile guest register state to vcpu. */
172 stw r0, VCPU_GPR(r0)(r4) 174 stw r0, VCPU_GPR(R0)(r4)
173 stw r1, VCPU_GPR(r1)(r4) 175 stw r1, VCPU_GPR(R1)(r4)
174 stw r2, VCPU_GPR(r2)(r4) 176 stw r2, VCPU_GPR(R2)(r4)
175 stw r10, VCPU_GPR(r10)(r4) 177 stw r10, VCPU_GPR(R10)(r4)
176 stw r11, VCPU_GPR(r11)(r4) 178 stw r11, VCPU_GPR(R11)(r4)
177 stw r12, VCPU_GPR(r12)(r4) 179 stw r12, VCPU_GPR(R12)(r4)
178 stw r13, VCPU_GPR(r13)(r4) 180 stw r13, VCPU_GPR(R13)(r4)
179 stw r14, VCPU_GPR(r14)(r4) /* We need a NV GPR below. */ 181 stw r14, VCPU_GPR(R14)(r4) /* We need a NV GPR below. */
180 mflr r3 182 mflr r3
181 stw r3, VCPU_LR(r4) 183 stw r3, VCPU_LR(r4)
182 mfxer r3 184 mfxer r3
183 stw r3, VCPU_XER(r4) 185 stw r3, VCPU_XER(r4)
184 mfspr r3, SPRN_SPRG_RSCRATCH0
185 stw r3, VCPU_GPR(r4)(r4)
186 mfspr r3, SPRN_SRR0
187 stw r3, VCPU_PC(r4)
188 186
189 /* Restore host stack pointer and PID before IVPR, since the host 187 /* Restore host stack pointer and PID before IVPR, since the host
190 * exception handlers use them. */ 188 * exception handlers use them. */
@@ -214,28 +212,28 @@ _GLOBAL(kvmppc_resume_host)
214 212
215 /* Restore vcpu pointer and the nonvolatiles we used. */ 213 /* Restore vcpu pointer and the nonvolatiles we used. */
216 mr r4, r14 214 mr r4, r14
217 lwz r14, VCPU_GPR(r14)(r4) 215 lwz r14, VCPU_GPR(R14)(r4)
218 216
219 /* Sometimes instruction emulation must restore complete GPR state. */ 217 /* Sometimes instruction emulation must restore complete GPR state. */
220 andi. r5, r3, RESUME_FLAG_NV 218 andi. r5, r3, RESUME_FLAG_NV
221 beq ..skip_nv_load 219 beq ..skip_nv_load
222 lwz r15, VCPU_GPR(r15)(r4) 220 lwz r15, VCPU_GPR(R15)(r4)
223 lwz r16, VCPU_GPR(r16)(r4) 221 lwz r16, VCPU_GPR(R16)(r4)
224 lwz r17, VCPU_GPR(r17)(r4) 222 lwz r17, VCPU_GPR(R17)(r4)
225 lwz r18, VCPU_GPR(r18)(r4) 223 lwz r18, VCPU_GPR(R18)(r4)
226 lwz r19, VCPU_GPR(r19)(r4) 224 lwz r19, VCPU_GPR(R19)(r4)
227 lwz r20, VCPU_GPR(r20)(r4) 225 lwz r20, VCPU_GPR(R20)(r4)
228 lwz r21, VCPU_GPR(r21)(r4) 226 lwz r21, VCPU_GPR(R21)(r4)
229 lwz r22, VCPU_GPR(r22)(r4) 227 lwz r22, VCPU_GPR(R22)(r4)
230 lwz r23, VCPU_GPR(r23)(r4) 228 lwz r23, VCPU_GPR(R23)(r4)
231 lwz r24, VCPU_GPR(r24)(r4) 229 lwz r24, VCPU_GPR(R24)(r4)
232 lwz r25, VCPU_GPR(r25)(r4) 230 lwz r25, VCPU_GPR(R25)(r4)
233 lwz r26, VCPU_GPR(r26)(r4) 231 lwz r26, VCPU_GPR(R26)(r4)
234 lwz r27, VCPU_GPR(r27)(r4) 232 lwz r27, VCPU_GPR(R27)(r4)
235 lwz r28, VCPU_GPR(r28)(r4) 233 lwz r28, VCPU_GPR(R28)(r4)
236 lwz r29, VCPU_GPR(r29)(r4) 234 lwz r29, VCPU_GPR(R29)(r4)
237 lwz r30, VCPU_GPR(r30)(r4) 235 lwz r30, VCPU_GPR(R30)(r4)
238 lwz r31, VCPU_GPR(r31)(r4) 236 lwz r31, VCPU_GPR(R31)(r4)
239..skip_nv_load: 237..skip_nv_load:
240 238
241 /* Should we return to the guest? */ 239 /* Should we return to the guest? */
@@ -257,43 +255,43 @@ heavyweight_exit:
257 255
258 /* We already saved guest volatile register state; now save the 256 /* We already saved guest volatile register state; now save the
259 * non-volatiles. */ 257 * non-volatiles. */
260 stw r15, VCPU_GPR(r15)(r4) 258 stw r15, VCPU_GPR(R15)(r4)
261 stw r16, VCPU_GPR(r16)(r4) 259 stw r16, VCPU_GPR(R16)(r4)
262 stw r17, VCPU_GPR(r17)(r4) 260 stw r17, VCPU_GPR(R17)(r4)
263 stw r18, VCPU_GPR(r18)(r4) 261 stw r18, VCPU_GPR(R18)(r4)
264 stw r19, VCPU_GPR(r19)(r4) 262 stw r19, VCPU_GPR(R19)(r4)
265 stw r20, VCPU_GPR(r20)(r4) 263 stw r20, VCPU_GPR(R20)(r4)
266 stw r21, VCPU_GPR(r21)(r4) 264 stw r21, VCPU_GPR(R21)(r4)
267 stw r22, VCPU_GPR(r22)(r4) 265 stw r22, VCPU_GPR(R22)(r4)
268 stw r23, VCPU_GPR(r23)(r4) 266 stw r23, VCPU_GPR(R23)(r4)
269 stw r24, VCPU_GPR(r24)(r4) 267 stw r24, VCPU_GPR(R24)(r4)
270 stw r25, VCPU_GPR(r25)(r4) 268 stw r25, VCPU_GPR(R25)(r4)
271 stw r26, VCPU_GPR(r26)(r4) 269 stw r26, VCPU_GPR(R26)(r4)
272 stw r27, VCPU_GPR(r27)(r4) 270 stw r27, VCPU_GPR(R27)(r4)
273 stw r28, VCPU_GPR(r28)(r4) 271 stw r28, VCPU_GPR(R28)(r4)
274 stw r29, VCPU_GPR(r29)(r4) 272 stw r29, VCPU_GPR(R29)(r4)
275 stw r30, VCPU_GPR(r30)(r4) 273 stw r30, VCPU_GPR(R30)(r4)
276 stw r31, VCPU_GPR(r31)(r4) 274 stw r31, VCPU_GPR(R31)(r4)
277 275
278 /* Load host non-volatile register state from host stack. */ 276 /* Load host non-volatile register state from host stack. */
279 lwz r14, HOST_NV_GPR(r14)(r1) 277 lwz r14, HOST_NV_GPR(R14)(r1)
280 lwz r15, HOST_NV_GPR(r15)(r1) 278 lwz r15, HOST_NV_GPR(R15)(r1)
281 lwz r16, HOST_NV_GPR(r16)(r1) 279 lwz r16, HOST_NV_GPR(R16)(r1)
282 lwz r17, HOST_NV_GPR(r17)(r1) 280 lwz r17, HOST_NV_GPR(R17)(r1)
283 lwz r18, HOST_NV_GPR(r18)(r1) 281 lwz r18, HOST_NV_GPR(R18)(r1)
284 lwz r19, HOST_NV_GPR(r19)(r1) 282 lwz r19, HOST_NV_GPR(R19)(r1)
285 lwz r20, HOST_NV_GPR(r20)(r1) 283 lwz r20, HOST_NV_GPR(R20)(r1)
286 lwz r21, HOST_NV_GPR(r21)(r1) 284 lwz r21, HOST_NV_GPR(R21)(r1)
287 lwz r22, HOST_NV_GPR(r22)(r1) 285 lwz r22, HOST_NV_GPR(R22)(r1)
288 lwz r23, HOST_NV_GPR(r23)(r1) 286 lwz r23, HOST_NV_GPR(R23)(r1)
289 lwz r24, HOST_NV_GPR(r24)(r1) 287 lwz r24, HOST_NV_GPR(R24)(r1)
290 lwz r25, HOST_NV_GPR(r25)(r1) 288 lwz r25, HOST_NV_GPR(R25)(r1)
291 lwz r26, HOST_NV_GPR(r26)(r1) 289 lwz r26, HOST_NV_GPR(R26)(r1)
292 lwz r27, HOST_NV_GPR(r27)(r1) 290 lwz r27, HOST_NV_GPR(R27)(r1)
293 lwz r28, HOST_NV_GPR(r28)(r1) 291 lwz r28, HOST_NV_GPR(R28)(r1)
294 lwz r29, HOST_NV_GPR(r29)(r1) 292 lwz r29, HOST_NV_GPR(R29)(r1)
295 lwz r30, HOST_NV_GPR(r30)(r1) 293 lwz r30, HOST_NV_GPR(R30)(r1)
296 lwz r31, HOST_NV_GPR(r31)(r1) 294 lwz r31, HOST_NV_GPR(R31)(r1)
297 295
298 /* Return to kvm_vcpu_run(). */ 296 /* Return to kvm_vcpu_run(). */
299 lwz r4, HOST_STACK_LR(r1) 297 lwz r4, HOST_STACK_LR(r1)
@@ -321,44 +319,44 @@ _GLOBAL(__kvmppc_vcpu_run)
321 stw r5, HOST_CR(r1) 319 stw r5, HOST_CR(r1)
322 320
323 /* Save host non-volatile register state to stack. */ 321 /* Save host non-volatile register state to stack. */
324 stw r14, HOST_NV_GPR(r14)(r1) 322 stw r14, HOST_NV_GPR(R14)(r1)
325 stw r15, HOST_NV_GPR(r15)(r1) 323 stw r15, HOST_NV_GPR(R15)(r1)
326 stw r16, HOST_NV_GPR(r16)(r1) 324 stw r16, HOST_NV_GPR(R16)(r1)
327 stw r17, HOST_NV_GPR(r17)(r1) 325 stw r17, HOST_NV_GPR(R17)(r1)
328 stw r18, HOST_NV_GPR(r18)(r1) 326 stw r18, HOST_NV_GPR(R18)(r1)
329 stw r19, HOST_NV_GPR(r19)(r1) 327 stw r19, HOST_NV_GPR(R19)(r1)
330 stw r20, HOST_NV_GPR(r20)(r1) 328 stw r20, HOST_NV_GPR(R20)(r1)
331 stw r21, HOST_NV_GPR(r21)(r1) 329 stw r21, HOST_NV_GPR(R21)(r1)
332 stw r22, HOST_NV_GPR(r22)(r1) 330 stw r22, HOST_NV_GPR(R22)(r1)
333 stw r23, HOST_NV_GPR(r23)(r1) 331 stw r23, HOST_NV_GPR(R23)(r1)
334 stw r24, HOST_NV_GPR(r24)(r1) 332 stw r24, HOST_NV_GPR(R24)(r1)
335 stw r25, HOST_NV_GPR(r25)(r1) 333 stw r25, HOST_NV_GPR(R25)(r1)
336 stw r26, HOST_NV_GPR(r26)(r1) 334 stw r26, HOST_NV_GPR(R26)(r1)
337 stw r27, HOST_NV_GPR(r27)(r1) 335 stw r27, HOST_NV_GPR(R27)(r1)
338 stw r28, HOST_NV_GPR(r28)(r1) 336 stw r28, HOST_NV_GPR(R28)(r1)
339 stw r29, HOST_NV_GPR(r29)(r1) 337 stw r29, HOST_NV_GPR(R29)(r1)
340 stw r30, HOST_NV_GPR(r30)(r1) 338 stw r30, HOST_NV_GPR(R30)(r1)
341 stw r31, HOST_NV_GPR(r31)(r1) 339 stw r31, HOST_NV_GPR(R31)(r1)
342 340
343 /* Load guest non-volatiles. */ 341 /* Load guest non-volatiles. */
344 lwz r14, VCPU_GPR(r14)(r4) 342 lwz r14, VCPU_GPR(R14)(r4)
345 lwz r15, VCPU_GPR(r15)(r4) 343 lwz r15, VCPU_GPR(R15)(r4)
346 lwz r16, VCPU_GPR(r16)(r4) 344 lwz r16, VCPU_GPR(R16)(r4)
347 lwz r17, VCPU_GPR(r17)(r4) 345 lwz r17, VCPU_GPR(R17)(r4)
348 lwz r18, VCPU_GPR(r18)(r4) 346 lwz r18, VCPU_GPR(R18)(r4)
349 lwz r19, VCPU_GPR(r19)(r4) 347 lwz r19, VCPU_GPR(R19)(r4)
350 lwz r20, VCPU_GPR(r20)(r4) 348 lwz r20, VCPU_GPR(R20)(r4)
351 lwz r21, VCPU_GPR(r21)(r4) 349 lwz r21, VCPU_GPR(R21)(r4)
352 lwz r22, VCPU_GPR(r22)(r4) 350 lwz r22, VCPU_GPR(R22)(r4)
353 lwz r23, VCPU_GPR(r23)(r4) 351 lwz r23, VCPU_GPR(R23)(r4)
354 lwz r24, VCPU_GPR(r24)(r4) 352 lwz r24, VCPU_GPR(R24)(r4)
355 lwz r25, VCPU_GPR(r25)(r4) 353 lwz r25, VCPU_GPR(R25)(r4)
356 lwz r26, VCPU_GPR(r26)(r4) 354 lwz r26, VCPU_GPR(R26)(r4)
357 lwz r27, VCPU_GPR(r27)(r4) 355 lwz r27, VCPU_GPR(R27)(r4)
358 lwz r28, VCPU_GPR(r28)(r4) 356 lwz r28, VCPU_GPR(R28)(r4)
359 lwz r29, VCPU_GPR(r29)(r4) 357 lwz r29, VCPU_GPR(R29)(r4)
360 lwz r30, VCPU_GPR(r30)(r4) 358 lwz r30, VCPU_GPR(R30)(r4)
361 lwz r31, VCPU_GPR(r31)(r4) 359 lwz r31, VCPU_GPR(R31)(r4)
362 360
363#ifdef CONFIG_SPE 361#ifdef CONFIG_SPE
364 /* save host SPEFSCR and load guest SPEFSCR */ 362 /* save host SPEFSCR and load guest SPEFSCR */
@@ -386,13 +384,13 @@ lightweight_exit:
386#endif 384#endif
387 385
388 /* Load some guest volatiles. */ 386 /* Load some guest volatiles. */
389 lwz r0, VCPU_GPR(r0)(r4) 387 lwz r0, VCPU_GPR(R0)(r4)
390 lwz r2, VCPU_GPR(r2)(r4) 388 lwz r2, VCPU_GPR(R2)(r4)
391 lwz r9, VCPU_GPR(r9)(r4) 389 lwz r9, VCPU_GPR(R9)(r4)
392 lwz r10, VCPU_GPR(r10)(r4) 390 lwz r10, VCPU_GPR(R10)(r4)
393 lwz r11, VCPU_GPR(r11)(r4) 391 lwz r11, VCPU_GPR(R11)(r4)
394 lwz r12, VCPU_GPR(r12)(r4) 392 lwz r12, VCPU_GPR(R12)(r4)
395 lwz r13, VCPU_GPR(r13)(r4) 393 lwz r13, VCPU_GPR(R13)(r4)
396 lwz r3, VCPU_LR(r4) 394 lwz r3, VCPU_LR(r4)
397 mtlr r3 395 mtlr r3
398 lwz r3, VCPU_XER(r4) 396 lwz r3, VCPU_XER(r4)
@@ -411,7 +409,7 @@ lightweight_exit:
411 409
412 /* Can't switch the stack pointer until after IVPR is switched, 410 /* Can't switch the stack pointer until after IVPR is switched,
413 * because host interrupt handlers would get confused. */ 411 * because host interrupt handlers would get confused. */
414 lwz r1, VCPU_GPR(r1)(r4) 412 lwz r1, VCPU_GPR(R1)(r4)
415 413
416 /* 414 /*
417 * Host interrupt handlers may have clobbered these 415 * Host interrupt handlers may have clobbered these
@@ -449,10 +447,10 @@ lightweight_exit:
449 mtcr r5 447 mtcr r5
450 mtsrr0 r6 448 mtsrr0 r6
451 mtsrr1 r7 449 mtsrr1 r7
452 lwz r5, VCPU_GPR(r5)(r4) 450 lwz r5, VCPU_GPR(R5)(r4)
453 lwz r6, VCPU_GPR(r6)(r4) 451 lwz r6, VCPU_GPR(R6)(r4)
454 lwz r7, VCPU_GPR(r7)(r4) 452 lwz r7, VCPU_GPR(R7)(r4)
455 lwz r8, VCPU_GPR(r8)(r4) 453 lwz r8, VCPU_GPR(R8)(r4)
456 454
457 /* Clear any debug events which occurred since we disabled MSR[DE]. 455 /* Clear any debug events which occurred since we disabled MSR[DE].
458 * XXX This gives us a 3-instruction window in which a breakpoint 456 * XXX This gives us a 3-instruction window in which a breakpoint
@@ -461,8 +459,8 @@ lightweight_exit:
461 ori r3, r3, 0xffff 459 ori r3, r3, 0xffff
462 mtspr SPRN_DBSR, r3 460 mtspr SPRN_DBSR, r3
463 461
464 lwz r3, VCPU_GPR(r3)(r4) 462 lwz r3, VCPU_GPR(R3)(r4)
465 lwz r4, VCPU_GPR(r4)(r4) 463 lwz r4, VCPU_GPR(R4)(r4)
466 rfi 464 rfi
467 465
468#ifdef CONFIG_SPE 466#ifdef CONFIG_SPE
diff --git a/arch/powerpc/kvm/bookehv_interrupts.S b/arch/powerpc/kvm/bookehv_interrupts.S
index 6048a00515d..099fe8272b5 100644
--- a/arch/powerpc/kvm/bookehv_interrupts.S
+++ b/arch/powerpc/kvm/bookehv_interrupts.S
@@ -37,7 +37,6 @@
37 37
38#define LONGBYTES (BITS_PER_LONG / 8) 38#define LONGBYTES (BITS_PER_LONG / 8)
39 39
40#define VCPU_GPR(n) (VCPU_GPRS + (n * LONGBYTES))
41#define VCPU_GUEST_SPRG(n) (VCPU_GUEST_SPRGS + (n * LONGBYTES)) 40#define VCPU_GUEST_SPRG(n) (VCPU_GUEST_SPRGS + (n * LONGBYTES))
42 41
43/* The host stack layout: */ 42/* The host stack layout: */
@@ -51,8 +50,9 @@
51#define HOST_R2 (3 * LONGBYTES) 50#define HOST_R2 (3 * LONGBYTES)
52#define HOST_CR (4 * LONGBYTES) 51#define HOST_CR (4 * LONGBYTES)
53#define HOST_NV_GPRS (5 * LONGBYTES) 52#define HOST_NV_GPRS (5 * LONGBYTES)
54#define HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * LONGBYTES)) 53#define __HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * LONGBYTES))
55#define HOST_MIN_STACK_SIZE (HOST_NV_GPR(31) + LONGBYTES) 54#define HOST_NV_GPR(n) __HOST_NV_GPR(__REG_##n)
55#define HOST_MIN_STACK_SIZE (HOST_NV_GPR(R31) + LONGBYTES)
56#define HOST_STACK_SIZE ((HOST_MIN_STACK_SIZE + 15) & ~15) /* Align. */ 56#define HOST_STACK_SIZE ((HOST_MIN_STACK_SIZE + 15) & ~15) /* Align. */
57#define HOST_STACK_LR (HOST_STACK_SIZE + LONGBYTES) /* In caller stack frame. */ 57#define HOST_STACK_LR (HOST_STACK_SIZE + LONGBYTES) /* In caller stack frame. */
58 58
@@ -67,15 +67,15 @@
67 */ 67 */
68.macro kvm_handler_common intno, srr0, flags 68.macro kvm_handler_common intno, srr0, flags
69 /* Restore host stack pointer */ 69 /* Restore host stack pointer */
70 PPC_STL r1, VCPU_GPR(r1)(r4) 70 PPC_STL r1, VCPU_GPR(R1)(r4)
71 PPC_STL r2, VCPU_GPR(r2)(r4) 71 PPC_STL r2, VCPU_GPR(R2)(r4)
72 PPC_LL r1, VCPU_HOST_STACK(r4) 72 PPC_LL r1, VCPU_HOST_STACK(r4)
73 PPC_LL r2, HOST_R2(r1) 73 PPC_LL r2, HOST_R2(r1)
74 74
75 mfspr r10, SPRN_PID 75 mfspr r10, SPRN_PID
76 lwz r8, VCPU_HOST_PID(r4) 76 lwz r8, VCPU_HOST_PID(r4)
77 PPC_LL r11, VCPU_SHARED(r4) 77 PPC_LL r11, VCPU_SHARED(r4)
78 PPC_STL r14, VCPU_GPR(r14)(r4) /* We need a non-volatile GPR. */ 78 PPC_STL r14, VCPU_GPR(R14)(r4) /* We need a non-volatile GPR. */
79 li r14, \intno 79 li r14, \intno
80 80
81 stw r10, VCPU_GUEST_PID(r4) 81 stw r10, VCPU_GUEST_PID(r4)
@@ -137,35 +137,31 @@
137 */ 137 */
138 138
139 mfspr r3, SPRN_EPLC /* will already have correct ELPID and EGS */ 139 mfspr r3, SPRN_EPLC /* will already have correct ELPID and EGS */
140 PPC_STL r15, VCPU_GPR(r15)(r4) 140 PPC_STL r15, VCPU_GPR(R15)(r4)
141 PPC_STL r16, VCPU_GPR(r16)(r4) 141 PPC_STL r16, VCPU_GPR(R16)(r4)
142 PPC_STL r17, VCPU_GPR(r17)(r4) 142 PPC_STL r17, VCPU_GPR(R17)(r4)
143 PPC_STL r18, VCPU_GPR(r18)(r4) 143 PPC_STL r18, VCPU_GPR(R18)(r4)
144 PPC_STL r19, VCPU_GPR(r19)(r4) 144 PPC_STL r19, VCPU_GPR(R19)(r4)
145 mr r8, r3 145 mr r8, r3
146 PPC_STL r20, VCPU_GPR(r20)(r4) 146 PPC_STL r20, VCPU_GPR(R20)(r4)
147 rlwimi r8, r6, EPC_EAS_SHIFT - MSR_IR_LG, EPC_EAS 147 rlwimi r8, r6, EPC_EAS_SHIFT - MSR_IR_LG, EPC_EAS
148 PPC_STL r21, VCPU_GPR(r21)(r4) 148 PPC_STL r21, VCPU_GPR(R21)(r4)
149 rlwimi r8, r6, EPC_EPR_SHIFT - MSR_PR_LG, EPC_EPR 149 rlwimi r8, r6, EPC_EPR_SHIFT - MSR_PR_LG, EPC_EPR
150 PPC_STL r22, VCPU_GPR(r22)(r4) 150 PPC_STL r22, VCPU_GPR(R22)(r4)
151 rlwimi r8, r10, EPC_EPID_SHIFT, EPC_EPID 151 rlwimi r8, r10, EPC_EPID_SHIFT, EPC_EPID
152 PPC_STL r23, VCPU_GPR(r23)(r4) 152 PPC_STL r23, VCPU_GPR(R23)(r4)
153 PPC_STL r24, VCPU_GPR(r24)(r4) 153 PPC_STL r24, VCPU_GPR(R24)(r4)
154 PPC_STL r25, VCPU_GPR(r25)(r4) 154 PPC_STL r25, VCPU_GPR(R25)(r4)
155 PPC_STL r26, VCPU_GPR(r26)(r4) 155 PPC_STL r26, VCPU_GPR(R26)(r4)
156 PPC_STL r27, VCPU_GPR(r27)(r4) 156 PPC_STL r27, VCPU_GPR(R27)(r4)
157 PPC_STL r28, VCPU_GPR(r28)(r4) 157 PPC_STL r28, VCPU_GPR(R28)(r4)
158 PPC_STL r29, VCPU_GPR(r29)(r4) 158 PPC_STL r29, VCPU_GPR(R29)(r4)
159 PPC_STL r30, VCPU_GPR(r30)(r4) 159 PPC_STL r30, VCPU_GPR(R30)(r4)
160 PPC_STL r31, VCPU_GPR(r31)(r4) 160 PPC_STL r31, VCPU_GPR(R31)(r4)
161 mtspr SPRN_EPLC, r8 161 mtspr SPRN_EPLC, r8
162 162
163 /* disable preemption, so we are sure we hit the fixup handler */ 163 /* disable preemption, so we are sure we hit the fixup handler */
164#ifdef CONFIG_PPC64 164 CURRENT_THREAD_INFO(r8, r1)
165 clrrdi r8,r1,THREAD_SHIFT
166#else
167 rlwinm r8,r1,0,0,31-THREAD_SHIFT /* current thread_info */
168#endif
169 li r7, 1 165 li r7, 1
170 stw r7, TI_PREEMPT(r8) 166 stw r7, TI_PREEMPT(r8)
171 167
@@ -211,24 +207,24 @@
211.macro kvm_handler intno srr0, srr1, flags 207.macro kvm_handler intno srr0, srr1, flags
212_GLOBAL(kvmppc_handler_\intno\()_\srr1) 208_GLOBAL(kvmppc_handler_\intno\()_\srr1)
213 GET_VCPU(r11, r10) 209 GET_VCPU(r11, r10)
214 PPC_STL r3, VCPU_GPR(r3)(r11) 210 PPC_STL r3, VCPU_GPR(R3)(r11)
215 mfspr r3, SPRN_SPRG_RSCRATCH0 211 mfspr r3, SPRN_SPRG_RSCRATCH0
216 PPC_STL r4, VCPU_GPR(r4)(r11) 212 PPC_STL r4, VCPU_GPR(R4)(r11)
217 PPC_LL r4, THREAD_NORMSAVE(0)(r10) 213 PPC_LL r4, THREAD_NORMSAVE(0)(r10)
218 PPC_STL r5, VCPU_GPR(r5)(r11) 214 PPC_STL r5, VCPU_GPR(R5)(r11)
219 stw r13, VCPU_CR(r11) 215 stw r13, VCPU_CR(r11)
220 mfspr r5, \srr0 216 mfspr r5, \srr0
221 PPC_STL r3, VCPU_GPR(r10)(r11) 217 PPC_STL r3, VCPU_GPR(R10)(r11)
222 PPC_LL r3, THREAD_NORMSAVE(2)(r10) 218 PPC_LL r3, THREAD_NORMSAVE(2)(r10)
223 PPC_STL r6, VCPU_GPR(r6)(r11) 219 PPC_STL r6, VCPU_GPR(R6)(r11)
224 PPC_STL r4, VCPU_GPR(r11)(r11) 220 PPC_STL r4, VCPU_GPR(R11)(r11)
225 mfspr r6, \srr1 221 mfspr r6, \srr1
226 PPC_STL r7, VCPU_GPR(r7)(r11) 222 PPC_STL r7, VCPU_GPR(R7)(r11)
227 PPC_STL r8, VCPU_GPR(r8)(r11) 223 PPC_STL r8, VCPU_GPR(R8)(r11)
228 PPC_STL r9, VCPU_GPR(r9)(r11) 224 PPC_STL r9, VCPU_GPR(R9)(r11)
229 PPC_STL r3, VCPU_GPR(r13)(r11) 225 PPC_STL r3, VCPU_GPR(R13)(r11)
230 mfctr r7 226 mfctr r7
231 PPC_STL r12, VCPU_GPR(r12)(r11) 227 PPC_STL r12, VCPU_GPR(R12)(r11)
232 PPC_STL r7, VCPU_CTR(r11) 228 PPC_STL r7, VCPU_CTR(r11)
233 mr r4, r11 229 mr r4, r11
234 kvm_handler_common \intno, \srr0, \flags 230 kvm_handler_common \intno, \srr0, \flags
@@ -238,25 +234,25 @@ _GLOBAL(kvmppc_handler_\intno\()_\srr1)
238_GLOBAL(kvmppc_handler_\intno\()_\srr1) 234_GLOBAL(kvmppc_handler_\intno\()_\srr1)
239 mfspr r10, SPRN_SPRG_THREAD 235 mfspr r10, SPRN_SPRG_THREAD
240 GET_VCPU(r11, r10) 236 GET_VCPU(r11, r10)
241 PPC_STL r3, VCPU_GPR(r3)(r11) 237 PPC_STL r3, VCPU_GPR(R3)(r11)
242 mfspr r3, \scratch 238 mfspr r3, \scratch
243 PPC_STL r4, VCPU_GPR(r4)(r11) 239 PPC_STL r4, VCPU_GPR(R4)(r11)
244 PPC_LL r4, GPR9(r8) 240 PPC_LL r4, GPR9(r8)
245 PPC_STL r5, VCPU_GPR(r5)(r11) 241 PPC_STL r5, VCPU_GPR(R5)(r11)
246 stw r9, VCPU_CR(r11) 242 stw r9, VCPU_CR(r11)
247 mfspr r5, \srr0 243 mfspr r5, \srr0
248 PPC_STL r3, VCPU_GPR(r8)(r11) 244 PPC_STL r3, VCPU_GPR(R8)(r11)
249 PPC_LL r3, GPR10(r8) 245 PPC_LL r3, GPR10(r8)
250 PPC_STL r6, VCPU_GPR(r6)(r11) 246 PPC_STL r6, VCPU_GPR(R6)(r11)
251 PPC_STL r4, VCPU_GPR(r9)(r11) 247 PPC_STL r4, VCPU_GPR(R9)(r11)
252 mfspr r6, \srr1 248 mfspr r6, \srr1
253 PPC_LL r4, GPR11(r8) 249 PPC_LL r4, GPR11(r8)
254 PPC_STL r7, VCPU_GPR(r7)(r11) 250 PPC_STL r7, VCPU_GPR(R7)(r11)
255 PPC_STL r3, VCPU_GPR(r10)(r11) 251 PPC_STL r3, VCPU_GPR(R10)(r11)
256 mfctr r7 252 mfctr r7
257 PPC_STL r12, VCPU_GPR(r12)(r11) 253 PPC_STL r12, VCPU_GPR(R12)(r11)
258 PPC_STL r13, VCPU_GPR(r13)(r11) 254 PPC_STL r13, VCPU_GPR(R13)(r11)
259 PPC_STL r4, VCPU_GPR(r11)(r11) 255 PPC_STL r4, VCPU_GPR(R11)(r11)
260 PPC_STL r7, VCPU_CTR(r11) 256 PPC_STL r7, VCPU_CTR(r11)
261 mr r4, r11 257 mr r4, r11
262 kvm_handler_common \intno, \srr0, \flags 258 kvm_handler_common \intno, \srr0, \flags
@@ -267,7 +263,7 @@ kvm_lvl_handler BOOKE_INTERRUPT_CRITICAL, \
267kvm_lvl_handler BOOKE_INTERRUPT_MACHINE_CHECK, \ 263kvm_lvl_handler BOOKE_INTERRUPT_MACHINE_CHECK, \
268 SPRN_SPRG_RSCRATCH_MC, SPRN_MCSRR0, SPRN_MCSRR1, 0 264 SPRN_SPRG_RSCRATCH_MC, SPRN_MCSRR0, SPRN_MCSRR1, 0
269kvm_handler BOOKE_INTERRUPT_DATA_STORAGE, \ 265kvm_handler BOOKE_INTERRUPT_DATA_STORAGE, \
270 SPRN_SRR0, SPRN_SRR1, (NEED_EMU | NEED_DEAR) 266 SPRN_SRR0, SPRN_SRR1, (NEED_EMU | NEED_DEAR | NEED_ESR)
271kvm_handler BOOKE_INTERRUPT_INST_STORAGE, SPRN_SRR0, SPRN_SRR1, NEED_ESR 267kvm_handler BOOKE_INTERRUPT_INST_STORAGE, SPRN_SRR0, SPRN_SRR1, NEED_ESR
272kvm_handler BOOKE_INTERRUPT_EXTERNAL, SPRN_SRR0, SPRN_SRR1, 0 268kvm_handler BOOKE_INTERRUPT_EXTERNAL, SPRN_SRR0, SPRN_SRR1, 0
273kvm_handler BOOKE_INTERRUPT_ALIGNMENT, \ 269kvm_handler BOOKE_INTERRUPT_ALIGNMENT, \
@@ -310,7 +306,7 @@ kvm_lvl_handler BOOKE_INTERRUPT_DEBUG, \
310_GLOBAL(kvmppc_resume_host) 306_GLOBAL(kvmppc_resume_host)
311 /* Save remaining volatile guest register state to vcpu. */ 307 /* Save remaining volatile guest register state to vcpu. */
312 mfspr r3, SPRN_VRSAVE 308 mfspr r3, SPRN_VRSAVE
313 PPC_STL r0, VCPU_GPR(r0)(r4) 309 PPC_STL r0, VCPU_GPR(R0)(r4)
314 mflr r5 310 mflr r5
315 mfspr r6, SPRN_SPRG4 311 mfspr r6, SPRN_SPRG4
316 PPC_STL r5, VCPU_LR(r4) 312 PPC_STL r5, VCPU_LR(r4)
@@ -358,27 +354,27 @@ _GLOBAL(kvmppc_resume_host)
358 354
359 /* Restore vcpu pointer and the nonvolatiles we used. */ 355 /* Restore vcpu pointer and the nonvolatiles we used. */
360 mr r4, r14 356 mr r4, r14
361 PPC_LL r14, VCPU_GPR(r14)(r4) 357 PPC_LL r14, VCPU_GPR(R14)(r4)
362 358
363 andi. r5, r3, RESUME_FLAG_NV 359 andi. r5, r3, RESUME_FLAG_NV
364 beq skip_nv_load 360 beq skip_nv_load
365 PPC_LL r15, VCPU_GPR(r15)(r4) 361 PPC_LL r15, VCPU_GPR(R15)(r4)
366 PPC_LL r16, VCPU_GPR(r16)(r4) 362 PPC_LL r16, VCPU_GPR(R16)(r4)
367 PPC_LL r17, VCPU_GPR(r17)(r4) 363 PPC_LL r17, VCPU_GPR(R17)(r4)
368 PPC_LL r18, VCPU_GPR(r18)(r4) 364 PPC_LL r18, VCPU_GPR(R18)(r4)
369 PPC_LL r19, VCPU_GPR(r19)(r4) 365 PPC_LL r19, VCPU_GPR(R19)(r4)
370 PPC_LL r20, VCPU_GPR(r20)(r4) 366 PPC_LL r20, VCPU_GPR(R20)(r4)
371 PPC_LL r21, VCPU_GPR(r21)(r4) 367 PPC_LL r21, VCPU_GPR(R21)(r4)
372 PPC_LL r22, VCPU_GPR(r22)(r4) 368 PPC_LL r22, VCPU_GPR(R22)(r4)
373 PPC_LL r23, VCPU_GPR(r23)(r4) 369 PPC_LL r23, VCPU_GPR(R23)(r4)
374 PPC_LL r24, VCPU_GPR(r24)(r4) 370 PPC_LL r24, VCPU_GPR(R24)(r4)
375 PPC_LL r25, VCPU_GPR(r25)(r4) 371 PPC_LL r25, VCPU_GPR(R25)(r4)
376 PPC_LL r26, VCPU_GPR(r26)(r4) 372 PPC_LL r26, VCPU_GPR(R26)(r4)
377 PPC_LL r27, VCPU_GPR(r27)(r4) 373 PPC_LL r27, VCPU_GPR(R27)(r4)
378 PPC_LL r28, VCPU_GPR(r28)(r4) 374 PPC_LL r28, VCPU_GPR(R28)(r4)
379 PPC_LL r29, VCPU_GPR(r29)(r4) 375 PPC_LL r29, VCPU_GPR(R29)(r4)
380 PPC_LL r30, VCPU_GPR(r30)(r4) 376 PPC_LL r30, VCPU_GPR(R30)(r4)
381 PPC_LL r31, VCPU_GPR(r31)(r4) 377 PPC_LL r31, VCPU_GPR(R31)(r4)
382skip_nv_load: 378skip_nv_load:
383 /* Should we return to the guest? */ 379 /* Should we return to the guest? */
384 andi. r5, r3, RESUME_FLAG_HOST 380 andi. r5, r3, RESUME_FLAG_HOST
@@ -396,43 +392,43 @@ heavyweight_exit:
396 * non-volatiles. 392 * non-volatiles.
397 */ 393 */
398 394
399 PPC_STL r15, VCPU_GPR(r15)(r4) 395 PPC_STL r15, VCPU_GPR(R15)(r4)
400 PPC_STL r16, VCPU_GPR(r16)(r4) 396 PPC_STL r16, VCPU_GPR(R16)(r4)
401 PPC_STL r17, VCPU_GPR(r17)(r4) 397 PPC_STL r17, VCPU_GPR(R17)(r4)
402 PPC_STL r18, VCPU_GPR(r18)(r4) 398 PPC_STL r18, VCPU_GPR(R18)(r4)
403 PPC_STL r19, VCPU_GPR(r19)(r4) 399 PPC_STL r19, VCPU_GPR(R19)(r4)
404 PPC_STL r20, VCPU_GPR(r20)(r4) 400 PPC_STL r20, VCPU_GPR(R20)(r4)
405 PPC_STL r21, VCPU_GPR(r21)(r4) 401 PPC_STL r21, VCPU_GPR(R21)(r4)
406 PPC_STL r22, VCPU_GPR(r22)(r4) 402 PPC_STL r22, VCPU_GPR(R22)(r4)
407 PPC_STL r23, VCPU_GPR(r23)(r4) 403 PPC_STL r23, VCPU_GPR(R23)(r4)
408 PPC_STL r24, VCPU_GPR(r24)(r4) 404 PPC_STL r24, VCPU_GPR(R24)(r4)
409 PPC_STL r25, VCPU_GPR(r25)(r4) 405 PPC_STL r25, VCPU_GPR(R25)(r4)
410 PPC_STL r26, VCPU_GPR(r26)(r4) 406 PPC_STL r26, VCPU_GPR(R26)(r4)
411 PPC_STL r27, VCPU_GPR(r27)(r4) 407 PPC_STL r27, VCPU_GPR(R27)(r4)
412 PPC_STL r28, VCPU_GPR(r28)(r4) 408 PPC_STL r28, VCPU_GPR(R28)(r4)
413 PPC_STL r29, VCPU_GPR(r29)(r4) 409 PPC_STL r29, VCPU_GPR(R29)(r4)
414 PPC_STL r30, VCPU_GPR(r30)(r4) 410 PPC_STL r30, VCPU_GPR(R30)(r4)
415 PPC_STL r31, VCPU_GPR(r31)(r4) 411 PPC_STL r31, VCPU_GPR(R31)(r4)
416 412
417 /* Load host non-volatile register state from host stack. */ 413 /* Load host non-volatile register state from host stack. */
418 PPC_LL r14, HOST_NV_GPR(r14)(r1) 414 PPC_LL r14, HOST_NV_GPR(R14)(r1)
419 PPC_LL r15, HOST_NV_GPR(r15)(r1) 415 PPC_LL r15, HOST_NV_GPR(R15)(r1)
420 PPC_LL r16, HOST_NV_GPR(r16)(r1) 416 PPC_LL r16, HOST_NV_GPR(R16)(r1)
421 PPC_LL r17, HOST_NV_GPR(r17)(r1) 417 PPC_LL r17, HOST_NV_GPR(R17)(r1)
422 PPC_LL r18, HOST_NV_GPR(r18)(r1) 418 PPC_LL r18, HOST_NV_GPR(R18)(r1)
423 PPC_LL r19, HOST_NV_GPR(r19)(r1) 419 PPC_LL r19, HOST_NV_GPR(R19)(r1)
424 PPC_LL r20, HOST_NV_GPR(r20)(r1) 420 PPC_LL r20, HOST_NV_GPR(R20)(r1)
425 PPC_LL r21, HOST_NV_GPR(r21)(r1) 421 PPC_LL r21, HOST_NV_GPR(R21)(r1)
426 PPC_LL r22, HOST_NV_GPR(r22)(r1) 422 PPC_LL r22, HOST_NV_GPR(R22)(r1)
427 PPC_LL r23, HOST_NV_GPR(r23)(r1) 423 PPC_LL r23, HOST_NV_GPR(R23)(r1)
428 PPC_LL r24, HOST_NV_GPR(r24)(r1) 424 PPC_LL r24, HOST_NV_GPR(R24)(r1)
429 PPC_LL r25, HOST_NV_GPR(r25)(r1) 425 PPC_LL r25, HOST_NV_GPR(R25)(r1)
430 PPC_LL r26, HOST_NV_GPR(r26)(r1) 426 PPC_LL r26, HOST_NV_GPR(R26)(r1)
431 PPC_LL r27, HOST_NV_GPR(r27)(r1) 427 PPC_LL r27, HOST_NV_GPR(R27)(r1)
432 PPC_LL r28, HOST_NV_GPR(r28)(r1) 428 PPC_LL r28, HOST_NV_GPR(R28)(r1)
433 PPC_LL r29, HOST_NV_GPR(r29)(r1) 429 PPC_LL r29, HOST_NV_GPR(R29)(r1)
434 PPC_LL r30, HOST_NV_GPR(r30)(r1) 430 PPC_LL r30, HOST_NV_GPR(R30)(r1)
435 PPC_LL r31, HOST_NV_GPR(r31)(r1) 431 PPC_LL r31, HOST_NV_GPR(R31)(r1)
436 432
437 /* Return to kvm_vcpu_run(). */ 433 /* Return to kvm_vcpu_run(). */
438 mtlr r5 434 mtlr r5
@@ -458,44 +454,44 @@ _GLOBAL(__kvmppc_vcpu_run)
458 stw r5, HOST_CR(r1) 454 stw r5, HOST_CR(r1)
459 455
460 /* Save host non-volatile register state to stack. */ 456 /* Save host non-volatile register state to stack. */
461 PPC_STL r14, HOST_NV_GPR(r14)(r1) 457 PPC_STL r14, HOST_NV_GPR(R14)(r1)
462 PPC_STL r15, HOST_NV_GPR(r15)(r1) 458 PPC_STL r15, HOST_NV_GPR(R15)(r1)
463 PPC_STL r16, HOST_NV_GPR(r16)(r1) 459 PPC_STL r16, HOST_NV_GPR(R16)(r1)
464 PPC_STL r17, HOST_NV_GPR(r17)(r1) 460 PPC_STL r17, HOST_NV_GPR(R17)(r1)
465 PPC_STL r18, HOST_NV_GPR(r18)(r1) 461 PPC_STL r18, HOST_NV_GPR(R18)(r1)
466 PPC_STL r19, HOST_NV_GPR(r19)(r1) 462 PPC_STL r19, HOST_NV_GPR(R19)(r1)
467 PPC_STL r20, HOST_NV_GPR(r20)(r1) 463 PPC_STL r20, HOST_NV_GPR(R20)(r1)
468 PPC_STL r21, HOST_NV_GPR(r21)(r1) 464 PPC_STL r21, HOST_NV_GPR(R21)(r1)
469 PPC_STL r22, HOST_NV_GPR(r22)(r1) 465 PPC_STL r22, HOST_NV_GPR(R22)(r1)
470 PPC_STL r23, HOST_NV_GPR(r23)(r1) 466 PPC_STL r23, HOST_NV_GPR(R23)(r1)
471 PPC_STL r24, HOST_NV_GPR(r24)(r1) 467 PPC_STL r24, HOST_NV_GPR(R24)(r1)
472 PPC_STL r25, HOST_NV_GPR(r25)(r1) 468 PPC_STL r25, HOST_NV_GPR(R25)(r1)
473 PPC_STL r26, HOST_NV_GPR(r26)(r1) 469 PPC_STL r26, HOST_NV_GPR(R26)(r1)
474 PPC_STL r27, HOST_NV_GPR(r27)(r1) 470 PPC_STL r27, HOST_NV_GPR(R27)(r1)
475 PPC_STL r28, HOST_NV_GPR(r28)(r1) 471 PPC_STL r28, HOST_NV_GPR(R28)(r1)
476 PPC_STL r29, HOST_NV_GPR(r29)(r1) 472 PPC_STL r29, HOST_NV_GPR(R29)(r1)
477 PPC_STL r30, HOST_NV_GPR(r30)(r1) 473 PPC_STL r30, HOST_NV_GPR(R30)(r1)
478 PPC_STL r31, HOST_NV_GPR(r31)(r1) 474 PPC_STL r31, HOST_NV_GPR(R31)(r1)
479 475
480 /* Load guest non-volatiles. */ 476 /* Load guest non-volatiles. */
481 PPC_LL r14, VCPU_GPR(r14)(r4) 477 PPC_LL r14, VCPU_GPR(R14)(r4)
482 PPC_LL r15, VCPU_GPR(r15)(r4) 478 PPC_LL r15, VCPU_GPR(R15)(r4)
483 PPC_LL r16, VCPU_GPR(r16)(r4) 479 PPC_LL r16, VCPU_GPR(R16)(r4)
484 PPC_LL r17, VCPU_GPR(r17)(r4) 480 PPC_LL r17, VCPU_GPR(R17)(r4)
485 PPC_LL r18, VCPU_GPR(r18)(r4) 481 PPC_LL r18, VCPU_GPR(R18)(r4)
486 PPC_LL r19, VCPU_GPR(r19)(r4) 482 PPC_LL r19, VCPU_GPR(R19)(r4)
487 PPC_LL r20, VCPU_GPR(r20)(r4) 483 PPC_LL r20, VCPU_GPR(R20)(r4)
488 PPC_LL r21, VCPU_GPR(r21)(r4) 484 PPC_LL r21, VCPU_GPR(R21)(r4)
489 PPC_LL r22, VCPU_GPR(r22)(r4) 485 PPC_LL r22, VCPU_GPR(R22)(r4)
490 PPC_LL r23, VCPU_GPR(r23)(r4) 486 PPC_LL r23, VCPU_GPR(R23)(r4)
491 PPC_LL r24, VCPU_GPR(r24)(r4) 487 PPC_LL r24, VCPU_GPR(R24)(r4)
492 PPC_LL r25, VCPU_GPR(r25)(r4) 488 PPC_LL r25, VCPU_GPR(R25)(r4)
493 PPC_LL r26, VCPU_GPR(r26)(r4) 489 PPC_LL r26, VCPU_GPR(R26)(r4)
494 PPC_LL r27, VCPU_GPR(r27)(r4) 490 PPC_LL r27, VCPU_GPR(R27)(r4)
495 PPC_LL r28, VCPU_GPR(r28)(r4) 491 PPC_LL r28, VCPU_GPR(R28)(r4)
496 PPC_LL r29, VCPU_GPR(r29)(r4) 492 PPC_LL r29, VCPU_GPR(R29)(r4)
497 PPC_LL r30, VCPU_GPR(r30)(r4) 493 PPC_LL r30, VCPU_GPR(R30)(r4)
498 PPC_LL r31, VCPU_GPR(r31)(r4) 494 PPC_LL r31, VCPU_GPR(R31)(r4)
499 495
500 496
501lightweight_exit: 497lightweight_exit:
@@ -554,13 +550,13 @@ lightweight_exit:
554 lwz r7, VCPU_CR(r4) 550 lwz r7, VCPU_CR(r4)
555 PPC_LL r8, VCPU_PC(r4) 551 PPC_LL r8, VCPU_PC(r4)
556 PPC_LD(r9, VCPU_SHARED_MSR, r11) 552 PPC_LD(r9, VCPU_SHARED_MSR, r11)
557 PPC_LL r0, VCPU_GPR(r0)(r4) 553 PPC_LL r0, VCPU_GPR(R0)(r4)
558 PPC_LL r1, VCPU_GPR(r1)(r4) 554 PPC_LL r1, VCPU_GPR(R1)(r4)
559 PPC_LL r2, VCPU_GPR(r2)(r4) 555 PPC_LL r2, VCPU_GPR(R2)(r4)
560 PPC_LL r10, VCPU_GPR(r10)(r4) 556 PPC_LL r10, VCPU_GPR(R10)(r4)
561 PPC_LL r11, VCPU_GPR(r11)(r4) 557 PPC_LL r11, VCPU_GPR(R11)(r4)
562 PPC_LL r12, VCPU_GPR(r12)(r4) 558 PPC_LL r12, VCPU_GPR(R12)(r4)
563 PPC_LL r13, VCPU_GPR(r13)(r4) 559 PPC_LL r13, VCPU_GPR(R13)(r4)
564 mtlr r3 560 mtlr r3
565 mtxer r5 561 mtxer r5
566 mtctr r6 562 mtctr r6
@@ -586,12 +582,12 @@ lightweight_exit:
586 mtcr r7 582 mtcr r7
587 583
588 /* Finish loading guest volatiles and jump to guest. */ 584 /* Finish loading guest volatiles and jump to guest. */
589 PPC_LL r5, VCPU_GPR(r5)(r4) 585 PPC_LL r5, VCPU_GPR(R5)(r4)
590 PPC_LL r6, VCPU_GPR(r6)(r4) 586 PPC_LL r6, VCPU_GPR(R6)(r4)
591 PPC_LL r7, VCPU_GPR(r7)(r4) 587 PPC_LL r7, VCPU_GPR(R7)(r4)
592 PPC_LL r8, VCPU_GPR(r8)(r4) 588 PPC_LL r8, VCPU_GPR(R8)(r4)
593 PPC_LL r9, VCPU_GPR(r9)(r4) 589 PPC_LL r9, VCPU_GPR(R9)(r4)
594 590
595 PPC_LL r3, VCPU_GPR(r3)(r4) 591 PPC_LL r3, VCPU_GPR(R3)(r4)
596 PPC_LL r4, VCPU_GPR(r4)(r4) 592 PPC_LL r4, VCPU_GPR(R4)(r4)
597 rfi 593 rfi
diff --git a/arch/powerpc/kvm/e500_emulate.c b/arch/powerpc/kvm/e500_emulate.c
index 8b99e076dc8..e04b0ef55ce 100644
--- a/arch/powerpc/kvm/e500_emulate.c
+++ b/arch/powerpc/kvm/e500_emulate.c
@@ -269,6 +269,9 @@ int kvmppc_core_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val)
269 *spr_val = vcpu->arch.shared->mas7_3 >> 32; 269 *spr_val = vcpu->arch.shared->mas7_3 >> 32;
270 break; 270 break;
271#endif 271#endif
272 case SPRN_DECAR:
273 *spr_val = vcpu->arch.decar;
274 break;
272 case SPRN_TLB0CFG: 275 case SPRN_TLB0CFG:
273 *spr_val = vcpu->arch.tlbcfg[0]; 276 *spr_val = vcpu->arch.tlbcfg[0];
274 break; 277 break;
diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c
index c510fc96130..a2b66717813 100644
--- a/arch/powerpc/kvm/e500_tlb.c
+++ b/arch/powerpc/kvm/e500_tlb.c
@@ -322,11 +322,11 @@ static inline void kvmppc_e500_ref_release(struct tlbe_ref *ref)
322static void clear_tlb1_bitmap(struct kvmppc_vcpu_e500 *vcpu_e500) 322static void clear_tlb1_bitmap(struct kvmppc_vcpu_e500 *vcpu_e500)
323{ 323{
324 if (vcpu_e500->g2h_tlb1_map) 324 if (vcpu_e500->g2h_tlb1_map)
325 memset(vcpu_e500->g2h_tlb1_map, 325 memset(vcpu_e500->g2h_tlb1_map, 0,
326 sizeof(u64) * vcpu_e500->gtlb_params[1].entries, 0); 326 sizeof(u64) * vcpu_e500->gtlb_params[1].entries);
327 if (vcpu_e500->h2g_tlb1_rmap) 327 if (vcpu_e500->h2g_tlb1_rmap)
328 memset(vcpu_e500->h2g_tlb1_rmap, 328 memset(vcpu_e500->h2g_tlb1_rmap, 0,
329 sizeof(unsigned int) * host_tlb_params[1].entries, 0); 329 sizeof(unsigned int) * host_tlb_params[1].entries);
330} 330}
331 331
332static void clear_tlb_privs(struct kvmppc_vcpu_e500 *vcpu_e500) 332static void clear_tlb_privs(struct kvmppc_vcpu_e500 *vcpu_e500)
@@ -539,6 +539,9 @@ static inline void kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
539 539
540 kvmppc_e500_setup_stlbe(&vcpu_e500->vcpu, gtlbe, tsize, 540 kvmppc_e500_setup_stlbe(&vcpu_e500->vcpu, gtlbe, tsize,
541 ref, gvaddr, stlbe); 541 ref, gvaddr, stlbe);
542
543 /* Clear i-cache for new pages */
544 kvmppc_mmu_flush_icache(pfn);
542} 545}
543 546
544/* XXX only map the one-one case, for now use TLB0 */ 547/* XXX only map the one-one case, for now use TLB0 */
diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c
index fe6c1de6b70..1f89d26e65f 100644
--- a/arch/powerpc/kvm/e500mc.c
+++ b/arch/powerpc/kvm/e500mc.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All rights reserved. 2 * Copyright (C) 2010,2012 Freescale Semiconductor, Inc. All rights reserved.
3 * 3 *
4 * Author: Varun Sethi, <varun.sethi@freescale.com> 4 * Author: Varun Sethi, <varun.sethi@freescale.com>
5 * 5 *
@@ -57,7 +57,8 @@ void kvmppc_e500_tlbil_one(struct kvmppc_vcpu_e500 *vcpu_e500,
57 struct kvm_book3e_206_tlb_entry *gtlbe) 57 struct kvm_book3e_206_tlb_entry *gtlbe)
58{ 58{
59 unsigned int tid, ts; 59 unsigned int tid, ts;
60 u32 val, eaddr, lpid; 60 gva_t eaddr;
61 u32 val, lpid;
61 unsigned long flags; 62 unsigned long flags;
62 63
63 ts = get_tlb_ts(gtlbe); 64 ts = get_tlb_ts(gtlbe);
@@ -183,6 +184,9 @@ int kvmppc_core_vcpu_setup(struct kvm_vcpu *vcpu)
183 184
184 vcpu->arch.shadow_epcr = SPRN_EPCR_DSIGS | SPRN_EPCR_DGTMI | \ 185 vcpu->arch.shadow_epcr = SPRN_EPCR_DSIGS | SPRN_EPCR_DGTMI | \
185 SPRN_EPCR_DUVD; 186 SPRN_EPCR_DUVD;
187#ifdef CONFIG_64BIT
188 vcpu->arch.shadow_epcr |= SPRN_EPCR_ICM;
189#endif
186 vcpu->arch.shadow_msrp = MSRP_UCLEP | MSRP_DEP | MSRP_PMMP; 190 vcpu->arch.shadow_msrp = MSRP_UCLEP | MSRP_DEP | MSRP_PMMP;
187 vcpu->arch.eplc = EPC_EGS | (vcpu->kvm->arch.lpid << EPC_ELPID_SHIFT); 191 vcpu->arch.eplc = EPC_EGS | (vcpu->kvm->arch.lpid << EPC_ELPID_SHIFT);
188 vcpu->arch.epsc = vcpu->arch.eplc; 192 vcpu->arch.epsc = vcpu->arch.eplc;
diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c
index f90e86dea7a..ee04abaefe2 100644
--- a/arch/powerpc/kvm/emulate.c
+++ b/arch/powerpc/kvm/emulate.c
@@ -59,11 +59,13 @@
59#define OP_31_XOP_STHBRX 918 59#define OP_31_XOP_STHBRX 918
60 60
61#define OP_LWZ 32 61#define OP_LWZ 32
62#define OP_LD 58
62#define OP_LWZU 33 63#define OP_LWZU 33
63#define OP_LBZ 34 64#define OP_LBZ 34
64#define OP_LBZU 35 65#define OP_LBZU 35
65#define OP_STW 36 66#define OP_STW 36
66#define OP_STWU 37 67#define OP_STWU 37
68#define OP_STD 62
67#define OP_STB 38 69#define OP_STB 38
68#define OP_STBU 39 70#define OP_STBU 39
69#define OP_LHZ 40 71#define OP_LHZ 40
@@ -392,6 +394,12 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
392 emulated = kvmppc_handle_load(run, vcpu, rt, 4, 1); 394 emulated = kvmppc_handle_load(run, vcpu, rt, 4, 1);
393 break; 395 break;
394 396
397 /* TBD: Add support for other 64 bit load variants like ldu, ldux, ldx etc. */
398 case OP_LD:
399 rt = get_rt(inst);
400 emulated = kvmppc_handle_load(run, vcpu, rt, 8, 1);
401 break;
402
395 case OP_LWZU: 403 case OP_LWZU:
396 emulated = kvmppc_handle_load(run, vcpu, rt, 4, 1); 404 emulated = kvmppc_handle_load(run, vcpu, rt, 4, 1);
397 kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed); 405 kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
@@ -412,6 +420,14 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
412 4, 1); 420 4, 1);
413 break; 421 break;
414 422
423 /* TBD: Add support for other 64 bit store variants like stdu, stdux, stdx etc. */
424 case OP_STD:
425 rs = get_rs(inst);
426 emulated = kvmppc_handle_store(run, vcpu,
427 kvmppc_get_gpr(vcpu, rs),
428 8, 1);
429 break;
430
415 case OP_STWU: 431 case OP_STWU:
416 emulated = kvmppc_handle_store(run, vcpu, 432 emulated = kvmppc_handle_store(run, vcpu,
417 kvmppc_get_gpr(vcpu, rs), 433 kvmppc_get_gpr(vcpu, rs),
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 1493c8de947..87f4dc88607 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -246,6 +246,7 @@ int kvm_dev_ioctl_check_extension(long ext)
246#endif 246#endif
247#ifdef CONFIG_PPC_BOOK3S_64 247#ifdef CONFIG_PPC_BOOK3S_64
248 case KVM_CAP_SPAPR_TCE: 248 case KVM_CAP_SPAPR_TCE:
249 case KVM_CAP_PPC_ALLOC_HTAB:
249 r = 1; 250 r = 1;
250 break; 251 break;
251#endif /* CONFIG_PPC_BOOK3S_64 */ 252#endif /* CONFIG_PPC_BOOK3S_64 */
@@ -802,6 +803,23 @@ long kvm_arch_vm_ioctl(struct file *filp,
802 r = -EFAULT; 803 r = -EFAULT;
803 break; 804 break;
804 } 805 }
806
807 case KVM_PPC_ALLOCATE_HTAB: {
808 struct kvm *kvm = filp->private_data;
809 u32 htab_order;
810
811 r = -EFAULT;
812 if (get_user(htab_order, (u32 __user *)argp))
813 break;
814 r = kvmppc_alloc_reset_hpt(kvm, &htab_order);
815 if (r)
816 break;
817 r = -EFAULT;
818 if (put_user(htab_order, (u32 __user *)argp))
819 break;
820 r = 0;
821 break;
822 }
805#endif /* CONFIG_KVM_BOOK3S_64_HV */ 823#endif /* CONFIG_KVM_BOOK3S_64_HV */
806 824
807#ifdef CONFIG_PPC_BOOK3S_64 825#ifdef CONFIG_PPC_BOOK3S_64
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index 7735a2c2e6d..746e0c895cd 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -17,14 +17,15 @@ obj-$(CONFIG_HAS_IOMEM) += devres.o
17obj-$(CONFIG_PPC64) += copypage_64.o copyuser_64.o \ 17obj-$(CONFIG_PPC64) += copypage_64.o copyuser_64.o \
18 memcpy_64.o usercopy_64.o mem_64.o string.o \ 18 memcpy_64.o usercopy_64.o mem_64.o string.o \
19 checksum_wrappers_64.o hweight_64.o \ 19 checksum_wrappers_64.o hweight_64.o \
20 copyuser_power7.o 20 copyuser_power7.o string_64.o copypage_power7.o \
21 memcpy_power7.o
21obj-$(CONFIG_XMON) += sstep.o ldstfp.o 22obj-$(CONFIG_XMON) += sstep.o ldstfp.o
22obj-$(CONFIG_KPROBES) += sstep.o ldstfp.o 23obj-$(CONFIG_KPROBES) += sstep.o ldstfp.o
23obj-$(CONFIG_HAVE_HW_BREAKPOINT) += sstep.o ldstfp.o 24obj-$(CONFIG_HAVE_HW_BREAKPOINT) += sstep.o ldstfp.o
24 25
25ifeq ($(CONFIG_PPC64),y) 26ifeq ($(CONFIG_PPC64),y)
26obj-$(CONFIG_SMP) += locks.o 27obj-$(CONFIG_SMP) += locks.o
27obj-$(CONFIG_ALTIVEC) += copyuser_power7_vmx.o 28obj-$(CONFIG_ALTIVEC) += vmx-helper.o
28endif 29endif
29 30
30obj-$(CONFIG_PPC_LIB_RHEAP) += rheap.o 31obj-$(CONFIG_PPC_LIB_RHEAP) += rheap.o
diff --git a/arch/powerpc/lib/checksum_64.S b/arch/powerpc/lib/checksum_64.S
index 18245af38ae..167f72555d6 100644
--- a/arch/powerpc/lib/checksum_64.S
+++ b/arch/powerpc/lib/checksum_64.S
@@ -65,9 +65,6 @@ _GLOBAL(csum_tcpudp_magic)
65 srwi r3,r3,16 65 srwi r3,r3,16
66 blr 66 blr
67 67
68#define STACKFRAMESIZE 256
69#define STK_REG(i) (112 + ((i)-14)*8)
70
71/* 68/*
72 * Computes the checksum of a memory block at buff, length len, 69 * Computes the checksum of a memory block at buff, length len,
73 * and adds in "sum" (32-bit). 70 * and adds in "sum" (32-bit).
@@ -114,9 +111,9 @@ _GLOBAL(csum_partial)
114 mtctr r6 111 mtctr r6
115 112
116 stdu r1,-STACKFRAMESIZE(r1) 113 stdu r1,-STACKFRAMESIZE(r1)
117 std r14,STK_REG(r14)(r1) 114 std r14,STK_REG(R14)(r1)
118 std r15,STK_REG(r15)(r1) 115 std r15,STK_REG(R15)(r1)
119 std r16,STK_REG(r16)(r1) 116 std r16,STK_REG(R16)(r1)
120 117
121 ld r6,0(r3) 118 ld r6,0(r3)
122 ld r9,8(r3) 119 ld r9,8(r3)
@@ -175,9 +172,9 @@ _GLOBAL(csum_partial)
175 adde r0,r0,r15 172 adde r0,r0,r15
176 adde r0,r0,r16 173 adde r0,r0,r16
177 174
178 ld r14,STK_REG(r14)(r1) 175 ld r14,STK_REG(R14)(r1)
179 ld r15,STK_REG(r15)(r1) 176 ld r15,STK_REG(R15)(r1)
180 ld r16,STK_REG(r16)(r1) 177 ld r16,STK_REG(R16)(r1)
181 addi r1,r1,STACKFRAMESIZE 178 addi r1,r1,STACKFRAMESIZE
182 179
183 andi. r4,r4,63 180 andi. r4,r4,63
@@ -299,9 +296,9 @@ dest; sth r6,0(r4)
299 mtctr r6 296 mtctr r6
300 297
301 stdu r1,-STACKFRAMESIZE(r1) 298 stdu r1,-STACKFRAMESIZE(r1)
302 std r14,STK_REG(r14)(r1) 299 std r14,STK_REG(R14)(r1)
303 std r15,STK_REG(r15)(r1) 300 std r15,STK_REG(R15)(r1)
304 std r16,STK_REG(r16)(r1) 301 std r16,STK_REG(R16)(r1)
305 302
306source; ld r6,0(r3) 303source; ld r6,0(r3)
307source; ld r9,8(r3) 304source; ld r9,8(r3)
@@ -382,9 +379,9 @@ dest; std r16,56(r4)
382 adde r0,r0,r15 379 adde r0,r0,r15
383 adde r0,r0,r16 380 adde r0,r0,r16
384 381
385 ld r14,STK_REG(r14)(r1) 382 ld r14,STK_REG(R14)(r1)
386 ld r15,STK_REG(r15)(r1) 383 ld r15,STK_REG(R15)(r1)
387 ld r16,STK_REG(r16)(r1) 384 ld r16,STK_REG(R16)(r1)
388 addi r1,r1,STACKFRAMESIZE 385 addi r1,r1,STACKFRAMESIZE
389 386
390 andi. r5,r5,63 387 andi. r5,r5,63
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
index 7c975d43e3f..17e5b236431 100644
--- a/arch/powerpc/lib/code-patching.c
+++ b/arch/powerpc/lib/code-patching.c
@@ -13,17 +13,23 @@
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <asm/page.h> 14#include <asm/page.h>
15#include <asm/code-patching.h> 15#include <asm/code-patching.h>
16#include <asm/uaccess.h>
16 17
17 18
18void patch_instruction(unsigned int *addr, unsigned int instr) 19int patch_instruction(unsigned int *addr, unsigned int instr)
19{ 20{
20 *addr = instr; 21 int err;
22
23 __put_user_size(instr, addr, 4, err);
24 if (err)
25 return err;
21 asm ("dcbst 0, %0; sync; icbi 0,%0; sync; isync" : : "r" (addr)); 26 asm ("dcbst 0, %0; sync; icbi 0,%0; sync; isync" : : "r" (addr));
27 return 0;
22} 28}
23 29
24void patch_branch(unsigned int *addr, unsigned long target, int flags) 30int patch_branch(unsigned int *addr, unsigned long target, int flags)
25{ 31{
26 patch_instruction(addr, create_branch(addr, target, flags)); 32 return patch_instruction(addr, create_branch(addr, target, flags));
27} 33}
28 34
29unsigned int create_branch(const unsigned int *addr, 35unsigned int create_branch(const unsigned int *addr,
diff --git a/arch/powerpc/lib/copypage_64.S b/arch/powerpc/lib/copypage_64.S
index 53dcb6b1b70..9f9434a8526 100644
--- a/arch/powerpc/lib/copypage_64.S
+++ b/arch/powerpc/lib/copypage_64.S
@@ -17,7 +17,11 @@ PPC64_CACHES:
17 .section ".text" 17 .section ".text"
18 18
19_GLOBAL(copy_page) 19_GLOBAL(copy_page)
20BEGIN_FTR_SECTION
20 lis r5,PAGE_SIZE@h 21 lis r5,PAGE_SIZE@h
22FTR_SECTION_ELSE
23 b .copypage_power7
24ALT_FTR_SECTION_END_IFCLR(CPU_FTR_VMX_COPY)
21 ori r5,r5,PAGE_SIZE@l 25 ori r5,r5,PAGE_SIZE@l
22BEGIN_FTR_SECTION 26BEGIN_FTR_SECTION
23 ld r10,PPC64_CACHES@toc(r2) 27 ld r10,PPC64_CACHES@toc(r2)
diff --git a/arch/powerpc/lib/copypage_power7.S b/arch/powerpc/lib/copypage_power7.S
new file mode 100644
index 00000000000..0ef75bf0695
--- /dev/null
+++ b/arch/powerpc/lib/copypage_power7.S
@@ -0,0 +1,165 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 *
16 * Copyright (C) IBM Corporation, 2012
17 *
18 * Author: Anton Blanchard <anton@au.ibm.com>
19 */
20#include <asm/page.h>
21#include <asm/ppc_asm.h>
22
23_GLOBAL(copypage_power7)
24 /*
25 * We prefetch both the source and destination using enhanced touch
26 * instructions. We use a stream ID of 0 for the load side and
27 * 1 for the store side. Since source and destination are page
28 * aligned we don't need to clear the bottom 7 bits of either
29 * address.
30 */
31 ori r9,r3,1 /* stream=1 */
32
33#ifdef CONFIG_PPC_64K_PAGES
34 lis r7,0x0E01 /* depth=7, units=512 */
35#else
36 lis r7,0x0E00 /* depth=7 */
37 ori r7,r7,0x1000 /* units=32 */
38#endif
39 ori r10,r7,1 /* stream=1 */
40
41 lis r8,0x8000 /* GO=1 */
42 clrldi r8,r8,32
43
44.machine push
45.machine "power4"
46 dcbt r0,r4,0b01000
47 dcbt r0,r7,0b01010
48 dcbtst r0,r9,0b01000
49 dcbtst r0,r10,0b01010
50 eieio
51 dcbt r0,r8,0b01010 /* GO */
52.machine pop
53
54#ifdef CONFIG_ALTIVEC
55 mflr r0
56 std r3,48(r1)
57 std r4,56(r1)
58 std r0,16(r1)
59 stdu r1,-STACKFRAMESIZE(r1)
60 bl .enter_vmx_copy
61 cmpwi r3,0
62 ld r0,STACKFRAMESIZE+16(r1)
63 ld r3,STACKFRAMESIZE+48(r1)
64 ld r4,STACKFRAMESIZE+56(r1)
65 mtlr r0
66
67 li r0,(PAGE_SIZE/128)
68 mtctr r0
69
70 beq .Lnonvmx_copy
71
72 addi r1,r1,STACKFRAMESIZE
73
74 li r6,16
75 li r7,32
76 li r8,48
77 li r9,64
78 li r10,80
79 li r11,96
80 li r12,112
81
82 .align 5
831: lvx vr7,r0,r4
84 lvx vr6,r4,r6
85 lvx vr5,r4,r7
86 lvx vr4,r4,r8
87 lvx vr3,r4,r9
88 lvx vr2,r4,r10
89 lvx vr1,r4,r11
90 lvx vr0,r4,r12
91 addi r4,r4,128
92 stvx vr7,r0,r3
93 stvx vr6,r3,r6
94 stvx vr5,r3,r7
95 stvx vr4,r3,r8
96 stvx vr3,r3,r9
97 stvx vr2,r3,r10
98 stvx vr1,r3,r11
99 stvx vr0,r3,r12
100 addi r3,r3,128
101 bdnz 1b
102
103 b .exit_vmx_copy /* tail call optimise */
104
105#else
106 li r0,(PAGE_SIZE/128)
107 mtctr r0
108
109 stdu r1,-STACKFRAMESIZE(r1)
110#endif
111
112.Lnonvmx_copy:
113 std r14,STK_REG(R14)(r1)
114 std r15,STK_REG(R15)(r1)
115 std r16,STK_REG(R16)(r1)
116 std r17,STK_REG(R17)(r1)
117 std r18,STK_REG(R18)(r1)
118 std r19,STK_REG(R19)(r1)
119 std r20,STK_REG(R20)(r1)
120
1211: ld r0,0(r4)
122 ld r5,8(r4)
123 ld r6,16(r4)
124 ld r7,24(r4)
125 ld r8,32(r4)
126 ld r9,40(r4)
127 ld r10,48(r4)
128 ld r11,56(r4)
129 ld r12,64(r4)
130 ld r14,72(r4)
131 ld r15,80(r4)
132 ld r16,88(r4)
133 ld r17,96(r4)
134 ld r18,104(r4)
135 ld r19,112(r4)
136 ld r20,120(r4)
137 addi r4,r4,128
138 std r0,0(r3)
139 std r5,8(r3)
140 std r6,16(r3)
141 std r7,24(r3)
142 std r8,32(r3)
143 std r9,40(r3)
144 std r10,48(r3)
145 std r11,56(r3)
146 std r12,64(r3)
147 std r14,72(r3)
148 std r15,80(r3)
149 std r16,88(r3)
150 std r17,96(r3)
151 std r18,104(r3)
152 std r19,112(r3)
153 std r20,120(r3)
154 addi r3,r3,128
155 bdnz 1b
156
157 ld r14,STK_REG(R14)(r1)
158 ld r15,STK_REG(R15)(r1)
159 ld r16,STK_REG(R16)(r1)
160 ld r17,STK_REG(R17)(r1)
161 ld r18,STK_REG(R18)(r1)
162 ld r19,STK_REG(R19)(r1)
163 ld r20,STK_REG(R20)(r1)
164 addi r1,r1,STACKFRAMESIZE
165 blr
diff --git a/arch/powerpc/lib/copyuser_power7.S b/arch/powerpc/lib/copyuser_power7.S
index 497db7b23bb..0d24ff15f5f 100644
--- a/arch/powerpc/lib/copyuser_power7.S
+++ b/arch/powerpc/lib/copyuser_power7.S
@@ -19,9 +19,6 @@
19 */ 19 */
20#include <asm/ppc_asm.h> 20#include <asm/ppc_asm.h>
21 21
22#define STACKFRAMESIZE 256
23#define STK_REG(i) (112 + ((i)-14)*8)
24
25 .macro err1 22 .macro err1
26100: 23100:
27 .section __ex_table,"a" 24 .section __ex_table,"a"
@@ -57,26 +54,26 @@
57 54
58 55
59.Ldo_err4: 56.Ldo_err4:
60 ld r16,STK_REG(r16)(r1) 57 ld r16,STK_REG(R16)(r1)
61 ld r15,STK_REG(r15)(r1) 58 ld r15,STK_REG(R15)(r1)
62 ld r14,STK_REG(r14)(r1) 59 ld r14,STK_REG(R14)(r1)
63.Ldo_err3: 60.Ldo_err3:
64 bl .exit_vmx_copy 61 bl .exit_vmx_usercopy
65 ld r0,STACKFRAMESIZE+16(r1) 62 ld r0,STACKFRAMESIZE+16(r1)
66 mtlr r0 63 mtlr r0
67 b .Lexit 64 b .Lexit
68#endif /* CONFIG_ALTIVEC */ 65#endif /* CONFIG_ALTIVEC */
69 66
70.Ldo_err2: 67.Ldo_err2:
71 ld r22,STK_REG(r22)(r1) 68 ld r22,STK_REG(R22)(r1)
72 ld r21,STK_REG(r21)(r1) 69 ld r21,STK_REG(R21)(r1)
73 ld r20,STK_REG(r20)(r1) 70 ld r20,STK_REG(R20)(r1)
74 ld r19,STK_REG(r19)(r1) 71 ld r19,STK_REG(R19)(r1)
75 ld r18,STK_REG(r18)(r1) 72 ld r18,STK_REG(R18)(r1)
76 ld r17,STK_REG(r17)(r1) 73 ld r17,STK_REG(R17)(r1)
77 ld r16,STK_REG(r16)(r1) 74 ld r16,STK_REG(R16)(r1)
78 ld r15,STK_REG(r15)(r1) 75 ld r15,STK_REG(R15)(r1)
79 ld r14,STK_REG(r14)(r1) 76 ld r14,STK_REG(R14)(r1)
80.Lexit: 77.Lexit:
81 addi r1,r1,STACKFRAMESIZE 78 addi r1,r1,STACKFRAMESIZE
82.Ldo_err1: 79.Ldo_err1:
@@ -137,15 +134,15 @@ err1; stw r0,0(r3)
137 134
138 mflr r0 135 mflr r0
139 stdu r1,-STACKFRAMESIZE(r1) 136 stdu r1,-STACKFRAMESIZE(r1)
140 std r14,STK_REG(r14)(r1) 137 std r14,STK_REG(R14)(r1)
141 std r15,STK_REG(r15)(r1) 138 std r15,STK_REG(R15)(r1)
142 std r16,STK_REG(r16)(r1) 139 std r16,STK_REG(R16)(r1)
143 std r17,STK_REG(r17)(r1) 140 std r17,STK_REG(R17)(r1)
144 std r18,STK_REG(r18)(r1) 141 std r18,STK_REG(R18)(r1)
145 std r19,STK_REG(r19)(r1) 142 std r19,STK_REG(R19)(r1)
146 std r20,STK_REG(r20)(r1) 143 std r20,STK_REG(R20)(r1)
147 std r21,STK_REG(r21)(r1) 144 std r21,STK_REG(R21)(r1)
148 std r22,STK_REG(r22)(r1) 145 std r22,STK_REG(R22)(r1)
149 std r0,STACKFRAMESIZE+16(r1) 146 std r0,STACKFRAMESIZE+16(r1)
150 147
151 srdi r6,r5,7 148 srdi r6,r5,7
@@ -192,15 +189,15 @@ err2; std r21,120(r3)
192 189
193 clrldi r5,r5,(64-7) 190 clrldi r5,r5,(64-7)
194 191
195 ld r14,STK_REG(r14)(r1) 192 ld r14,STK_REG(R14)(r1)
196 ld r15,STK_REG(r15)(r1) 193 ld r15,STK_REG(R15)(r1)
197 ld r16,STK_REG(r16)(r1) 194 ld r16,STK_REG(R16)(r1)
198 ld r17,STK_REG(r17)(r1) 195 ld r17,STK_REG(R17)(r1)
199 ld r18,STK_REG(r18)(r1) 196 ld r18,STK_REG(R18)(r1)
200 ld r19,STK_REG(r19)(r1) 197 ld r19,STK_REG(R19)(r1)
201 ld r20,STK_REG(r20)(r1) 198 ld r20,STK_REG(R20)(r1)
202 ld r21,STK_REG(r21)(r1) 199 ld r21,STK_REG(R21)(r1)
203 ld r22,STK_REG(r22)(r1) 200 ld r22,STK_REG(R22)(r1)
204 addi r1,r1,STACKFRAMESIZE 201 addi r1,r1,STACKFRAMESIZE
205 202
206 /* Up to 127B to go */ 203 /* Up to 127B to go */
@@ -290,15 +287,46 @@ err1; stb r0,0(r3)
290 mflr r0 287 mflr r0
291 std r0,16(r1) 288 std r0,16(r1)
292 stdu r1,-STACKFRAMESIZE(r1) 289 stdu r1,-STACKFRAMESIZE(r1)
293 bl .enter_vmx_copy 290 bl .enter_vmx_usercopy
294 cmpwi r3,0 291 cmpwi cr1,r3,0
295 ld r0,STACKFRAMESIZE+16(r1) 292 ld r0,STACKFRAMESIZE+16(r1)
296 ld r3,STACKFRAMESIZE+48(r1) 293 ld r3,STACKFRAMESIZE+48(r1)
297 ld r4,STACKFRAMESIZE+56(r1) 294 ld r4,STACKFRAMESIZE+56(r1)
298 ld r5,STACKFRAMESIZE+64(r1) 295 ld r5,STACKFRAMESIZE+64(r1)
299 mtlr r0 296 mtlr r0
300 297
301 beq .Lunwind_stack_nonvmx_copy 298 /*
299 * We prefetch both the source and destination using enhanced touch
300 * instructions. We use a stream ID of 0 for the load side and
301 * 1 for the store side.
302 */
303 clrrdi r6,r4,7
304 clrrdi r9,r3,7
305 ori r9,r9,1 /* stream=1 */
306
307 srdi r7,r5,7 /* length in cachelines, capped at 0x3FF */
308 cmpldi r7,0x3FF
309 ble 1f
310 li r7,0x3FF
3111: lis r0,0x0E00 /* depth=7 */
312 sldi r7,r7,7
313 or r7,r7,r0
314 ori r10,r7,1 /* stream=1 */
315
316 lis r8,0x8000 /* GO=1 */
317 clrldi r8,r8,32
318
319.machine push
320.machine "power4"
321 dcbt r0,r6,0b01000
322 dcbt r0,r7,0b01010
323 dcbtst r0,r9,0b01000
324 dcbtst r0,r10,0b01010
325 eieio
326 dcbt r0,r8,0b01010 /* GO */
327.machine pop
328
329 beq cr1,.Lunwind_stack_nonvmx_copy
302 330
303 /* 331 /*
304 * If source and destination are not relatively aligned we use a 332 * If source and destination are not relatively aligned we use a
@@ -378,9 +406,9 @@ err3; stvx vr0,r3,r11
3787: sub r5,r5,r6 4067: sub r5,r5,r6
379 srdi r6,r5,7 407 srdi r6,r5,7
380 408
381 std r14,STK_REG(r14)(r1) 409 std r14,STK_REG(R14)(r1)
382 std r15,STK_REG(r15)(r1) 410 std r15,STK_REG(R15)(r1)
383 std r16,STK_REG(r16)(r1) 411 std r16,STK_REG(R16)(r1)
384 412
385 li r12,64 413 li r12,64
386 li r14,80 414 li r14,80
@@ -415,9 +443,9 @@ err4; stvx vr0,r3,r16
415 addi r3,r3,128 443 addi r3,r3,128
416 bdnz 8b 444 bdnz 8b
417 445
418 ld r14,STK_REG(r14)(r1) 446 ld r14,STK_REG(R14)(r1)
419 ld r15,STK_REG(r15)(r1) 447 ld r15,STK_REG(R15)(r1)
420 ld r16,STK_REG(r16)(r1) 448 ld r16,STK_REG(R16)(r1)
421 449
422 /* Up to 127B to go */ 450 /* Up to 127B to go */
423 clrldi r5,r5,(64-7) 451 clrldi r5,r5,(64-7)
@@ -476,7 +504,7 @@ err3; lbz r0,0(r4)
476err3; stb r0,0(r3) 504err3; stb r0,0(r3)
477 505
47815: addi r1,r1,STACKFRAMESIZE 50615: addi r1,r1,STACKFRAMESIZE
479 b .exit_vmx_copy /* tail call optimise */ 507 b .exit_vmx_usercopy /* tail call optimise */
480 508
481.Lvmx_unaligned_copy: 509.Lvmx_unaligned_copy:
482 /* Get the destination 16B aligned */ 510 /* Get the destination 16B aligned */
@@ -563,9 +591,9 @@ err3; stvx vr11,r3,r11
5637: sub r5,r5,r6 5917: sub r5,r5,r6
564 srdi r6,r5,7 592 srdi r6,r5,7
565 593
566 std r14,STK_REG(r14)(r1) 594 std r14,STK_REG(R14)(r1)
567 std r15,STK_REG(r15)(r1) 595 std r15,STK_REG(R15)(r1)
568 std r16,STK_REG(r16)(r1) 596 std r16,STK_REG(R16)(r1)
569 597
570 li r12,64 598 li r12,64
571 li r14,80 599 li r14,80
@@ -608,9 +636,9 @@ err4; stvx vr15,r3,r16
608 addi r3,r3,128 636 addi r3,r3,128
609 bdnz 8b 637 bdnz 8b
610 638
611 ld r14,STK_REG(r14)(r1) 639 ld r14,STK_REG(R14)(r1)
612 ld r15,STK_REG(r15)(r1) 640 ld r15,STK_REG(R15)(r1)
613 ld r16,STK_REG(r16)(r1) 641 ld r16,STK_REG(R16)(r1)
614 642
615 /* Up to 127B to go */ 643 /* Up to 127B to go */
616 clrldi r5,r5,(64-7) 644 clrldi r5,r5,(64-7)
@@ -679,5 +707,5 @@ err3; lbz r0,0(r4)
679err3; stb r0,0(r3) 707err3; stb r0,0(r3)
680 708
68115: addi r1,r1,STACKFRAMESIZE 70915: addi r1,r1,STACKFRAMESIZE
682 b .exit_vmx_copy /* tail call optimise */ 710 b .exit_vmx_usercopy /* tail call optimise */
683#endif /* CONFiG_ALTIVEC */ 711#endif /* CONFiG_ALTIVEC */
diff --git a/arch/powerpc/lib/crtsavres.S b/arch/powerpc/lib/crtsavres.S
index 1c893f05d22..b2c68ce139a 100644
--- a/arch/powerpc/lib/crtsavres.S
+++ b/arch/powerpc/lib/crtsavres.S
@@ -41,12 +41,13 @@
41#include <asm/ppc_asm.h> 41#include <asm/ppc_asm.h>
42 42
43 .file "crtsavres.S" 43 .file "crtsavres.S"
44 .section ".text"
45 44
46#ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE 45#ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
47 46
48#ifndef CONFIG_PPC64 47#ifndef CONFIG_PPC64
49 48
49 .section ".text"
50
50/* Routines for saving integer registers, called by the compiler. */ 51/* Routines for saving integer registers, called by the compiler. */
51/* Called with r11 pointing to the stack header word of the caller of the */ 52/* Called with r11 pointing to the stack header word of the caller of the */
52/* function, just beyond the end of the integer save area. */ 53/* function, just beyond the end of the integer save area. */
@@ -232,6 +233,8 @@ _GLOBAL(_rest32gpr_31_x)
232 233
233#else /* CONFIG_PPC64 */ 234#else /* CONFIG_PPC64 */
234 235
236 .section ".text.save.restore","ax",@progbits
237
235.globl _savegpr0_14 238.globl _savegpr0_14
236_savegpr0_14: 239_savegpr0_14:
237 std r14,-144(r1) 240 std r14,-144(r1)
diff --git a/arch/powerpc/lib/hweight_64.S b/arch/powerpc/lib/hweight_64.S
index fda27868cf8..9b96ff2ecd4 100644
--- a/arch/powerpc/lib/hweight_64.S
+++ b/arch/powerpc/lib/hweight_64.S
@@ -28,7 +28,7 @@ BEGIN_FTR_SECTION
28 nop 28 nop
29 nop 29 nop
30FTR_SECTION_ELSE 30FTR_SECTION_ELSE
31 PPC_POPCNTB(r3,r3) 31 PPC_POPCNTB(R3,R3)
32 clrldi r3,r3,64-8 32 clrldi r3,r3,64-8
33 blr 33 blr
34ALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB) 34ALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB)
@@ -42,14 +42,14 @@ BEGIN_FTR_SECTION
42 nop 42 nop
43FTR_SECTION_ELSE 43FTR_SECTION_ELSE
44 BEGIN_FTR_SECTION_NESTED(50) 44 BEGIN_FTR_SECTION_NESTED(50)
45 PPC_POPCNTB(r3,r3) 45 PPC_POPCNTB(R3,R3)
46 srdi r4,r3,8 46 srdi r4,r3,8
47 add r3,r4,r3 47 add r3,r4,r3
48 clrldi r3,r3,64-8 48 clrldi r3,r3,64-8
49 blr 49 blr
50 FTR_SECTION_ELSE_NESTED(50) 50 FTR_SECTION_ELSE_NESTED(50)
51 clrlwi r3,r3,16 51 clrlwi r3,r3,16
52 PPC_POPCNTW(r3,r3) 52 PPC_POPCNTW(R3,R3)
53 clrldi r3,r3,64-8 53 clrldi r3,r3,64-8
54 blr 54 blr
55 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 50) 55 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 50)
@@ -66,7 +66,7 @@ BEGIN_FTR_SECTION
66 nop 66 nop
67FTR_SECTION_ELSE 67FTR_SECTION_ELSE
68 BEGIN_FTR_SECTION_NESTED(51) 68 BEGIN_FTR_SECTION_NESTED(51)
69 PPC_POPCNTB(r3,r3) 69 PPC_POPCNTB(R3,R3)
70 srdi r4,r3,16 70 srdi r4,r3,16
71 add r3,r4,r3 71 add r3,r4,r3
72 srdi r4,r3,8 72 srdi r4,r3,8
@@ -74,7 +74,7 @@ FTR_SECTION_ELSE
74 clrldi r3,r3,64-8 74 clrldi r3,r3,64-8
75 blr 75 blr
76 FTR_SECTION_ELSE_NESTED(51) 76 FTR_SECTION_ELSE_NESTED(51)
77 PPC_POPCNTW(r3,r3) 77 PPC_POPCNTW(R3,R3)
78 clrldi r3,r3,64-8 78 clrldi r3,r3,64-8
79 blr 79 blr
80 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 51) 80 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 51)
@@ -93,7 +93,7 @@ BEGIN_FTR_SECTION
93 nop 93 nop
94FTR_SECTION_ELSE 94FTR_SECTION_ELSE
95 BEGIN_FTR_SECTION_NESTED(52) 95 BEGIN_FTR_SECTION_NESTED(52)
96 PPC_POPCNTB(r3,r3) 96 PPC_POPCNTB(R3,R3)
97 srdi r4,r3,32 97 srdi r4,r3,32
98 add r3,r4,r3 98 add r3,r4,r3
99 srdi r4,r3,16 99 srdi r4,r3,16
@@ -103,7 +103,7 @@ FTR_SECTION_ELSE
103 clrldi r3,r3,64-8 103 clrldi r3,r3,64-8
104 blr 104 blr
105 FTR_SECTION_ELSE_NESTED(52) 105 FTR_SECTION_ELSE_NESTED(52)
106 PPC_POPCNTD(r3,r3) 106 PPC_POPCNTD(R3,R3)
107 clrldi r3,r3,64-8 107 clrldi r3,r3,64-8
108 blr 108 blr
109 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 52) 109 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 52)
diff --git a/arch/powerpc/lib/ldstfp.S b/arch/powerpc/lib/ldstfp.S
index 6a85380520b..85aec08ab23 100644
--- a/arch/powerpc/lib/ldstfp.S
+++ b/arch/powerpc/lib/ldstfp.S
@@ -330,13 +330,13 @@ _GLOBAL(do_lxvd2x)
330 MTMSRD(r7) 330 MTMSRD(r7)
331 isync 331 isync
332 beq cr7,1f 332 beq cr7,1f
333 STXVD2X(0,r1,r8) 333 STXVD2X(0,R1,R8)
3341: li r9,-EFAULT 3341: li r9,-EFAULT
3352: LXVD2X(0,0,r4) 3352: LXVD2X(0,R0,R4)
336 li r9,0 336 li r9,0
3373: beq cr7,4f 3373: beq cr7,4f
338 bl put_vsr 338 bl put_vsr
339 LXVD2X(0,r1,r8) 339 LXVD2X(0,R1,R8)
3404: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1) 3404: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1)
341 mtlr r0 341 mtlr r0
342 MTMSRD(r6) 342 MTMSRD(r6)
@@ -358,13 +358,13 @@ _GLOBAL(do_stxvd2x)
358 MTMSRD(r7) 358 MTMSRD(r7)
359 isync 359 isync
360 beq cr7,1f 360 beq cr7,1f
361 STXVD2X(0,r1,r8) 361 STXVD2X(0,R1,R8)
362 bl get_vsr 362 bl get_vsr
3631: li r9,-EFAULT 3631: li r9,-EFAULT
3642: STXVD2X(0,0,r4) 3642: STXVD2X(0,R0,R4)
365 li r9,0 365 li r9,0
3663: beq cr7,4f 3663: beq cr7,4f
367 LXVD2X(0,r1,r8) 367 LXVD2X(0,R1,R8)
3684: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1) 3684: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1)
369 mtlr r0 369 mtlr r0
370 MTMSRD(r6) 370 MTMSRD(r6)
diff --git a/arch/powerpc/lib/memcpy_64.S b/arch/powerpc/lib/memcpy_64.S
index 82fea3963e1..d2bbbc8d7dc 100644
--- a/arch/powerpc/lib/memcpy_64.S
+++ b/arch/powerpc/lib/memcpy_64.S
@@ -11,7 +11,11 @@
11 11
12 .align 7 12 .align 7
13_GLOBAL(memcpy) 13_GLOBAL(memcpy)
14BEGIN_FTR_SECTION
14 std r3,48(r1) /* save destination pointer for return value */ 15 std r3,48(r1) /* save destination pointer for return value */
16FTR_SECTION_ELSE
17 b memcpy_power7
18ALT_FTR_SECTION_END_IFCLR(CPU_FTR_VMX_COPY)
15 PPC_MTOCRF(0x01,r5) 19 PPC_MTOCRF(0x01,r5)
16 cmpldi cr1,r5,16 20 cmpldi cr1,r5,16
17 neg r6,r3 # LS 3 bits = # bytes to 8-byte dest bdry 21 neg r6,r3 # LS 3 bits = # bytes to 8-byte dest bdry
diff --git a/arch/powerpc/lib/memcpy_power7.S b/arch/powerpc/lib/memcpy_power7.S
new file mode 100644
index 00000000000..7ba6c96de77
--- /dev/null
+++ b/arch/powerpc/lib/memcpy_power7.S
@@ -0,0 +1,647 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 *
16 * Copyright (C) IBM Corporation, 2012
17 *
18 * Author: Anton Blanchard <anton@au.ibm.com>
19 */
20#include <asm/ppc_asm.h>
21
22_GLOBAL(memcpy_power7)
23#ifdef CONFIG_ALTIVEC
24 cmpldi r5,16
25 cmpldi cr1,r5,4096
26
27 std r3,48(r1)
28
29 blt .Lshort_copy
30 bgt cr1,.Lvmx_copy
31#else
32 cmpldi r5,16
33
34 std r3,48(r1)
35
36 blt .Lshort_copy
37#endif
38
39.Lnonvmx_copy:
40 /* Get the source 8B aligned */
41 neg r6,r4
42 mtocrf 0x01,r6
43 clrldi r6,r6,(64-3)
44
45 bf cr7*4+3,1f
46 lbz r0,0(r4)
47 addi r4,r4,1
48 stb r0,0(r3)
49 addi r3,r3,1
50
511: bf cr7*4+2,2f
52 lhz r0,0(r4)
53 addi r4,r4,2
54 sth r0,0(r3)
55 addi r3,r3,2
56
572: bf cr7*4+1,3f
58 lwz r0,0(r4)
59 addi r4,r4,4
60 stw r0,0(r3)
61 addi r3,r3,4
62
633: sub r5,r5,r6
64 cmpldi r5,128
65 blt 5f
66
67 mflr r0
68 stdu r1,-STACKFRAMESIZE(r1)
69 std r14,STK_REG(R14)(r1)
70 std r15,STK_REG(R15)(r1)
71 std r16,STK_REG(R16)(r1)
72 std r17,STK_REG(R17)(r1)
73 std r18,STK_REG(R18)(r1)
74 std r19,STK_REG(R19)(r1)
75 std r20,STK_REG(R20)(r1)
76 std r21,STK_REG(R21)(r1)
77 std r22,STK_REG(R22)(r1)
78 std r0,STACKFRAMESIZE+16(r1)
79
80 srdi r6,r5,7
81 mtctr r6
82
83 /* Now do cacheline (128B) sized loads and stores. */
84 .align 5
854:
86 ld r0,0(r4)
87 ld r6,8(r4)
88 ld r7,16(r4)
89 ld r8,24(r4)
90 ld r9,32(r4)
91 ld r10,40(r4)
92 ld r11,48(r4)
93 ld r12,56(r4)
94 ld r14,64(r4)
95 ld r15,72(r4)
96 ld r16,80(r4)
97 ld r17,88(r4)
98 ld r18,96(r4)
99 ld r19,104(r4)
100 ld r20,112(r4)
101 ld r21,120(r4)
102 addi r4,r4,128
103 std r0,0(r3)
104 std r6,8(r3)
105 std r7,16(r3)
106 std r8,24(r3)
107 std r9,32(r3)
108 std r10,40(r3)
109 std r11,48(r3)
110 std r12,56(r3)
111 std r14,64(r3)
112 std r15,72(r3)
113 std r16,80(r3)
114 std r17,88(r3)
115 std r18,96(r3)
116 std r19,104(r3)
117 std r20,112(r3)
118 std r21,120(r3)
119 addi r3,r3,128
120 bdnz 4b
121
122 clrldi r5,r5,(64-7)
123
124 ld r14,STK_REG(R14)(r1)
125 ld r15,STK_REG(R15)(r1)
126 ld r16,STK_REG(R16)(r1)
127 ld r17,STK_REG(R17)(r1)
128 ld r18,STK_REG(R18)(r1)
129 ld r19,STK_REG(R19)(r1)
130 ld r20,STK_REG(R20)(r1)
131 ld r21,STK_REG(R21)(r1)
132 ld r22,STK_REG(R22)(r1)
133 addi r1,r1,STACKFRAMESIZE
134
135 /* Up to 127B to go */
1365: srdi r6,r5,4
137 mtocrf 0x01,r6
138
1396: bf cr7*4+1,7f
140 ld r0,0(r4)
141 ld r6,8(r4)
142 ld r7,16(r4)
143 ld r8,24(r4)
144 ld r9,32(r4)
145 ld r10,40(r4)
146 ld r11,48(r4)
147 ld r12,56(r4)
148 addi r4,r4,64
149 std r0,0(r3)
150 std r6,8(r3)
151 std r7,16(r3)
152 std r8,24(r3)
153 std r9,32(r3)
154 std r10,40(r3)
155 std r11,48(r3)
156 std r12,56(r3)
157 addi r3,r3,64
158
159 /* Up to 63B to go */
1607: bf cr7*4+2,8f
161 ld r0,0(r4)
162 ld r6,8(r4)
163 ld r7,16(r4)
164 ld r8,24(r4)
165 addi r4,r4,32
166 std r0,0(r3)
167 std r6,8(r3)
168 std r7,16(r3)
169 std r8,24(r3)
170 addi r3,r3,32
171
172 /* Up to 31B to go */
1738: bf cr7*4+3,9f
174 ld r0,0(r4)
175 ld r6,8(r4)
176 addi r4,r4,16
177 std r0,0(r3)
178 std r6,8(r3)
179 addi r3,r3,16
180
1819: clrldi r5,r5,(64-4)
182
183 /* Up to 15B to go */
184.Lshort_copy:
185 mtocrf 0x01,r5
186 bf cr7*4+0,12f
187 lwz r0,0(r4) /* Less chance of a reject with word ops */
188 lwz r6,4(r4)
189 addi r4,r4,8
190 stw r0,0(r3)
191 stw r6,4(r3)
192 addi r3,r3,8
193
19412: bf cr7*4+1,13f
195 lwz r0,0(r4)
196 addi r4,r4,4
197 stw r0,0(r3)
198 addi r3,r3,4
199
20013: bf cr7*4+2,14f
201 lhz r0,0(r4)
202 addi r4,r4,2
203 sth r0,0(r3)
204 addi r3,r3,2
205
20614: bf cr7*4+3,15f
207 lbz r0,0(r4)
208 stb r0,0(r3)
209
21015: ld r3,48(r1)
211 blr
212
213.Lunwind_stack_nonvmx_copy:
214 addi r1,r1,STACKFRAMESIZE
215 b .Lnonvmx_copy
216
217#ifdef CONFIG_ALTIVEC
218.Lvmx_copy:
219 mflr r0
220 std r4,56(r1)
221 std r5,64(r1)
222 std r0,16(r1)
223 stdu r1,-STACKFRAMESIZE(r1)
224 bl .enter_vmx_copy
225 cmpwi cr1,r3,0
226 ld r0,STACKFRAMESIZE+16(r1)
227 ld r3,STACKFRAMESIZE+48(r1)
228 ld r4,STACKFRAMESIZE+56(r1)
229 ld r5,STACKFRAMESIZE+64(r1)
230 mtlr r0
231
232 /*
233 * We prefetch both the source and destination using enhanced touch
234 * instructions. We use a stream ID of 0 for the load side and
235 * 1 for the store side.
236 */
237 clrrdi r6,r4,7
238 clrrdi r9,r3,7
239 ori r9,r9,1 /* stream=1 */
240
241 srdi r7,r5,7 /* length in cachelines, capped at 0x3FF */
242 cmpldi cr1,r7,0x3FF
243 ble cr1,1f
244 li r7,0x3FF
2451: lis r0,0x0E00 /* depth=7 */
246 sldi r7,r7,7
247 or r7,r7,r0
248 ori r10,r7,1 /* stream=1 */
249
250 lis r8,0x8000 /* GO=1 */
251 clrldi r8,r8,32
252
253.machine push
254.machine "power4"
255 dcbt r0,r6,0b01000
256 dcbt r0,r7,0b01010
257 dcbtst r0,r9,0b01000
258 dcbtst r0,r10,0b01010
259 eieio
260 dcbt r0,r8,0b01010 /* GO */
261.machine pop
262
263 beq cr1,.Lunwind_stack_nonvmx_copy
264
265 /*
266 * If source and destination are not relatively aligned we use a
267 * slower permute loop.
268 */
269 xor r6,r4,r3
270 rldicl. r6,r6,0,(64-4)
271 bne .Lvmx_unaligned_copy
272
273 /* Get the destination 16B aligned */
274 neg r6,r3
275 mtocrf 0x01,r6
276 clrldi r6,r6,(64-4)
277
278 bf cr7*4+3,1f
279 lbz r0,0(r4)
280 addi r4,r4,1
281 stb r0,0(r3)
282 addi r3,r3,1
283
2841: bf cr7*4+2,2f
285 lhz r0,0(r4)
286 addi r4,r4,2
287 sth r0,0(r3)
288 addi r3,r3,2
289
2902: bf cr7*4+1,3f
291 lwz r0,0(r4)
292 addi r4,r4,4
293 stw r0,0(r3)
294 addi r3,r3,4
295
2963: bf cr7*4+0,4f
297 ld r0,0(r4)
298 addi r4,r4,8
299 std r0,0(r3)
300 addi r3,r3,8
301
3024: sub r5,r5,r6
303
304 /* Get the desination 128B aligned */
305 neg r6,r3
306 srdi r7,r6,4
307 mtocrf 0x01,r7
308 clrldi r6,r6,(64-7)
309
310 li r9,16
311 li r10,32
312 li r11,48
313
314 bf cr7*4+3,5f
315 lvx vr1,r0,r4
316 addi r4,r4,16
317 stvx vr1,r0,r3
318 addi r3,r3,16
319
3205: bf cr7*4+2,6f
321 lvx vr1,r0,r4
322 lvx vr0,r4,r9
323 addi r4,r4,32
324 stvx vr1,r0,r3
325 stvx vr0,r3,r9
326 addi r3,r3,32
327
3286: bf cr7*4+1,7f
329 lvx vr3,r0,r4
330 lvx vr2,r4,r9
331 lvx vr1,r4,r10
332 lvx vr0,r4,r11
333 addi r4,r4,64
334 stvx vr3,r0,r3
335 stvx vr2,r3,r9
336 stvx vr1,r3,r10
337 stvx vr0,r3,r11
338 addi r3,r3,64
339
3407: sub r5,r5,r6
341 srdi r6,r5,7
342
343 std r14,STK_REG(R14)(r1)
344 std r15,STK_REG(R15)(r1)
345 std r16,STK_REG(R16)(r1)
346
347 li r12,64
348 li r14,80
349 li r15,96
350 li r16,112
351
352 mtctr r6
353
354 /*
355 * Now do cacheline sized loads and stores. By this stage the
356 * cacheline stores are also cacheline aligned.
357 */
358 .align 5
3598:
360 lvx vr7,r0,r4
361 lvx vr6,r4,r9
362 lvx vr5,r4,r10
363 lvx vr4,r4,r11
364 lvx vr3,r4,r12
365 lvx vr2,r4,r14
366 lvx vr1,r4,r15
367 lvx vr0,r4,r16
368 addi r4,r4,128
369 stvx vr7,r0,r3
370 stvx vr6,r3,r9
371 stvx vr5,r3,r10
372 stvx vr4,r3,r11
373 stvx vr3,r3,r12
374 stvx vr2,r3,r14
375 stvx vr1,r3,r15
376 stvx vr0,r3,r16
377 addi r3,r3,128
378 bdnz 8b
379
380 ld r14,STK_REG(R14)(r1)
381 ld r15,STK_REG(R15)(r1)
382 ld r16,STK_REG(R16)(r1)
383
384 /* Up to 127B to go */
385 clrldi r5,r5,(64-7)
386 srdi r6,r5,4
387 mtocrf 0x01,r6
388
389 bf cr7*4+1,9f
390 lvx vr3,r0,r4
391 lvx vr2,r4,r9
392 lvx vr1,r4,r10
393 lvx vr0,r4,r11
394 addi r4,r4,64
395 stvx vr3,r0,r3
396 stvx vr2,r3,r9
397 stvx vr1,r3,r10
398 stvx vr0,r3,r11
399 addi r3,r3,64
400
4019: bf cr7*4+2,10f
402 lvx vr1,r0,r4
403 lvx vr0,r4,r9
404 addi r4,r4,32
405 stvx vr1,r0,r3
406 stvx vr0,r3,r9
407 addi r3,r3,32
408
40910: bf cr7*4+3,11f
410 lvx vr1,r0,r4
411 addi r4,r4,16
412 stvx vr1,r0,r3
413 addi r3,r3,16
414
415 /* Up to 15B to go */
41611: clrldi r5,r5,(64-4)
417 mtocrf 0x01,r5
418 bf cr7*4+0,12f
419 ld r0,0(r4)
420 addi r4,r4,8
421 std r0,0(r3)
422 addi r3,r3,8
423
42412: bf cr7*4+1,13f
425 lwz r0,0(r4)
426 addi r4,r4,4
427 stw r0,0(r3)
428 addi r3,r3,4
429
43013: bf cr7*4+2,14f
431 lhz r0,0(r4)
432 addi r4,r4,2
433 sth r0,0(r3)
434 addi r3,r3,2
435
43614: bf cr7*4+3,15f
437 lbz r0,0(r4)
438 stb r0,0(r3)
439
44015: addi r1,r1,STACKFRAMESIZE
441 ld r3,48(r1)
442 b .exit_vmx_copy /* tail call optimise */
443
444.Lvmx_unaligned_copy:
445 /* Get the destination 16B aligned */
446 neg r6,r3
447 mtocrf 0x01,r6
448 clrldi r6,r6,(64-4)
449
450 bf cr7*4+3,1f
451 lbz r0,0(r4)
452 addi r4,r4,1
453 stb r0,0(r3)
454 addi r3,r3,1
455
4561: bf cr7*4+2,2f
457 lhz r0,0(r4)
458 addi r4,r4,2
459 sth r0,0(r3)
460 addi r3,r3,2
461
4622: bf cr7*4+1,3f
463 lwz r0,0(r4)
464 addi r4,r4,4
465 stw r0,0(r3)
466 addi r3,r3,4
467
4683: bf cr7*4+0,4f
469 lwz r0,0(r4) /* Less chance of a reject with word ops */
470 lwz r7,4(r4)
471 addi r4,r4,8
472 stw r0,0(r3)
473 stw r7,4(r3)
474 addi r3,r3,8
475
4764: sub r5,r5,r6
477
478 /* Get the desination 128B aligned */
479 neg r6,r3
480 srdi r7,r6,4
481 mtocrf 0x01,r7
482 clrldi r6,r6,(64-7)
483
484 li r9,16
485 li r10,32
486 li r11,48
487
488 lvsl vr16,0,r4 /* Setup permute control vector */
489 lvx vr0,0,r4
490 addi r4,r4,16
491
492 bf cr7*4+3,5f
493 lvx vr1,r0,r4
494 vperm vr8,vr0,vr1,vr16
495 addi r4,r4,16
496 stvx vr8,r0,r3
497 addi r3,r3,16
498 vor vr0,vr1,vr1
499
5005: bf cr7*4+2,6f
501 lvx vr1,r0,r4
502 vperm vr8,vr0,vr1,vr16
503 lvx vr0,r4,r9
504 vperm vr9,vr1,vr0,vr16
505 addi r4,r4,32
506 stvx vr8,r0,r3
507 stvx vr9,r3,r9
508 addi r3,r3,32
509
5106: bf cr7*4+1,7f
511 lvx vr3,r0,r4
512 vperm vr8,vr0,vr3,vr16
513 lvx vr2,r4,r9
514 vperm vr9,vr3,vr2,vr16
515 lvx vr1,r4,r10
516 vperm vr10,vr2,vr1,vr16
517 lvx vr0,r4,r11
518 vperm vr11,vr1,vr0,vr16
519 addi r4,r4,64
520 stvx vr8,r0,r3
521 stvx vr9,r3,r9
522 stvx vr10,r3,r10
523 stvx vr11,r3,r11
524 addi r3,r3,64
525
5267: sub r5,r5,r6
527 srdi r6,r5,7
528
529 std r14,STK_REG(R14)(r1)
530 std r15,STK_REG(R15)(r1)
531 std r16,STK_REG(R16)(r1)
532
533 li r12,64
534 li r14,80
535 li r15,96
536 li r16,112
537
538 mtctr r6
539
540 /*
541 * Now do cacheline sized loads and stores. By this stage the
542 * cacheline stores are also cacheline aligned.
543 */
544 .align 5
5458:
546 lvx vr7,r0,r4
547 vperm vr8,vr0,vr7,vr16
548 lvx vr6,r4,r9
549 vperm vr9,vr7,vr6,vr16
550 lvx vr5,r4,r10
551 vperm vr10,vr6,vr5,vr16
552 lvx vr4,r4,r11
553 vperm vr11,vr5,vr4,vr16
554 lvx vr3,r4,r12
555 vperm vr12,vr4,vr3,vr16
556 lvx vr2,r4,r14
557 vperm vr13,vr3,vr2,vr16
558 lvx vr1,r4,r15
559 vperm vr14,vr2,vr1,vr16
560 lvx vr0,r4,r16
561 vperm vr15,vr1,vr0,vr16
562 addi r4,r4,128
563 stvx vr8,r0,r3
564 stvx vr9,r3,r9
565 stvx vr10,r3,r10
566 stvx vr11,r3,r11
567 stvx vr12,r3,r12
568 stvx vr13,r3,r14
569 stvx vr14,r3,r15
570 stvx vr15,r3,r16
571 addi r3,r3,128
572 bdnz 8b
573
574 ld r14,STK_REG(R14)(r1)
575 ld r15,STK_REG(R15)(r1)
576 ld r16,STK_REG(R16)(r1)
577
578 /* Up to 127B to go */
579 clrldi r5,r5,(64-7)
580 srdi r6,r5,4
581 mtocrf 0x01,r6
582
583 bf cr7*4+1,9f
584 lvx vr3,r0,r4
585 vperm vr8,vr0,vr3,vr16
586 lvx vr2,r4,r9
587 vperm vr9,vr3,vr2,vr16
588 lvx vr1,r4,r10
589 vperm vr10,vr2,vr1,vr16
590 lvx vr0,r4,r11
591 vperm vr11,vr1,vr0,vr16
592 addi r4,r4,64
593 stvx vr8,r0,r3
594 stvx vr9,r3,r9
595 stvx vr10,r3,r10
596 stvx vr11,r3,r11
597 addi r3,r3,64
598
5999: bf cr7*4+2,10f
600 lvx vr1,r0,r4
601 vperm vr8,vr0,vr1,vr16
602 lvx vr0,r4,r9
603 vperm vr9,vr1,vr0,vr16
604 addi r4,r4,32
605 stvx vr8,r0,r3
606 stvx vr9,r3,r9
607 addi r3,r3,32
608
60910: bf cr7*4+3,11f
610 lvx vr1,r0,r4
611 vperm vr8,vr0,vr1,vr16
612 addi r4,r4,16
613 stvx vr8,r0,r3
614 addi r3,r3,16
615
616 /* Up to 15B to go */
61711: clrldi r5,r5,(64-4)
618 addi r4,r4,-16 /* Unwind the +16 load offset */
619 mtocrf 0x01,r5
620 bf cr7*4+0,12f
621 lwz r0,0(r4) /* Less chance of a reject with word ops */
622 lwz r6,4(r4)
623 addi r4,r4,8
624 stw r0,0(r3)
625 stw r6,4(r3)
626 addi r3,r3,8
627
62812: bf cr7*4+1,13f
629 lwz r0,0(r4)
630 addi r4,r4,4
631 stw r0,0(r3)
632 addi r3,r3,4
633
63413: bf cr7*4+2,14f
635 lhz r0,0(r4)
636 addi r4,r4,2
637 sth r0,0(r3)
638 addi r3,r3,2
639
64014: bf cr7*4+3,15f
641 lbz r0,0(r4)
642 stb r0,0(r3)
643
64415: addi r1,r1,STACKFRAMESIZE
645 ld r3,48(r1)
646 b .exit_vmx_copy /* tail call optimise */
647#endif /* CONFiG_ALTIVEC */
diff --git a/arch/powerpc/lib/string.S b/arch/powerpc/lib/string.S
index 093d6316435..1b5a0a09d60 100644
--- a/arch/powerpc/lib/string.S
+++ b/arch/powerpc/lib/string.S
@@ -119,6 +119,7 @@ _GLOBAL(memchr)
1192: li r3,0 1192: li r3,0
120 blr 120 blr
121 121
122#ifdef CONFIG_PPC32
122_GLOBAL(__clear_user) 123_GLOBAL(__clear_user)
123 addi r6,r3,-4 124 addi r6,r3,-4
124 li r3,0 125 li r3,0
@@ -160,3 +161,4 @@ _GLOBAL(__clear_user)
160 PPC_LONG 1b,91b 161 PPC_LONG 1b,91b
161 PPC_LONG 8b,92b 162 PPC_LONG 8b,92b
162 .text 163 .text
164#endif
diff --git a/arch/powerpc/lib/string_64.S b/arch/powerpc/lib/string_64.S
new file mode 100644
index 00000000000..3b1e48049fa
--- /dev/null
+++ b/arch/powerpc/lib/string_64.S
@@ -0,0 +1,202 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 *
16 * Copyright (C) IBM Corporation, 2012
17 *
18 * Author: Anton Blanchard <anton@au.ibm.com>
19 */
20
21#include <asm/ppc_asm.h>
22#include <asm/asm-offsets.h>
23
24 .section ".toc","aw"
25PPC64_CACHES:
26 .tc ppc64_caches[TC],ppc64_caches
27 .section ".text"
28
29/**
30 * __clear_user: - Zero a block of memory in user space, with less checking.
31 * @to: Destination address, in user space.
32 * @n: Number of bytes to zero.
33 *
34 * Zero a block of memory in user space. Caller must check
35 * the specified block with access_ok() before calling this function.
36 *
37 * Returns number of bytes that could not be cleared.
38 * On success, this will be zero.
39 */
40
41 .macro err1
42100:
43 .section __ex_table,"a"
44 .align 3
45 .llong 100b,.Ldo_err1
46 .previous
47 .endm
48
49 .macro err2
50200:
51 .section __ex_table,"a"
52 .align 3
53 .llong 200b,.Ldo_err2
54 .previous
55 .endm
56
57 .macro err3
58300:
59 .section __ex_table,"a"
60 .align 3
61 .llong 300b,.Ldo_err3
62 .previous
63 .endm
64
65.Ldo_err1:
66 mr r3,r8
67
68.Ldo_err2:
69 mtctr r4
701:
71err3; stb r0,0(r3)
72 addi r3,r3,1
73 addi r4,r4,-1
74 bdnz 1b
75
76.Ldo_err3:
77 mr r3,r4
78 blr
79
80_GLOBAL(__clear_user)
81 cmpdi r4,32
82 neg r6,r3
83 li r0,0
84 blt .Lshort_clear
85 mr r8,r3
86 mtocrf 0x01,r6
87 clrldi r6,r6,(64-3)
88
89 /* Get the destination 8 byte aligned */
90 bf cr7*4+3,1f
91err1; stb r0,0(r3)
92 addi r3,r3,1
93
941: bf cr7*4+2,2f
95err1; sth r0,0(r3)
96 addi r3,r3,2
97
982: bf cr7*4+1,3f
99err1; stw r0,0(r3)
100 addi r3,r3,4
101
1023: sub r4,r4,r6
103
104 cmpdi r4,32
105 cmpdi cr1,r4,512
106 blt .Lshort_clear
107 bgt cr1,.Llong_clear
108
109.Lmedium_clear:
110 srdi r6,r4,5
111 mtctr r6
112
113 /* Do 32 byte chunks */
1144:
115err2; std r0,0(r3)
116err2; std r0,8(r3)
117err2; std r0,16(r3)
118err2; std r0,24(r3)
119 addi r3,r3,32
120 addi r4,r4,-32
121 bdnz 4b
122
123.Lshort_clear:
124 /* up to 31 bytes to go */
125 cmpdi r4,16
126 blt 6f
127err2; std r0,0(r3)
128err2; std r0,8(r3)
129 addi r3,r3,16
130 addi r4,r4,-16
131
132 /* Up to 15 bytes to go */
1336: mr r8,r3
134 clrldi r4,r4,(64-4)
135 mtocrf 0x01,r4
136 bf cr7*4+0,7f
137err1; std r0,0(r3)
138 addi r3,r3,8
139
1407: bf cr7*4+1,8f
141err1; stw r0,0(r3)
142 addi r3,r3,4
143
1448: bf cr7*4+2,9f
145err1; sth r0,0(r3)
146 addi r3,r3,2
147
1489: bf cr7*4+3,10f
149err1; stb r0,0(r3)
150
15110: li r3,0
152 blr
153
154.Llong_clear:
155 ld r5,PPC64_CACHES@toc(r2)
156
157 bf cr7*4+0,11f
158err2; std r0,0(r3)
159 addi r3,r3,8
160 addi r4,r4,-8
161
162 /* Destination is 16 byte aligned, need to get it cacheline aligned */
16311: lwz r7,DCACHEL1LOGLINESIZE(r5)
164 lwz r9,DCACHEL1LINESIZE(r5)
165
166 /*
167 * With worst case alignment the long clear loop takes a minimum
168 * of 1 byte less than 2 cachelines.
169 */
170 sldi r10,r9,2
171 cmpd r4,r10
172 blt .Lmedium_clear
173
174 neg r6,r3
175 addi r10,r9,-1
176 and. r5,r6,r10
177 beq 13f
178
179 srdi r6,r5,4
180 mtctr r6
181 mr r8,r3
18212:
183err1; std r0,0(r3)
184err1; std r0,8(r3)
185 addi r3,r3,16
186 bdnz 12b
187
188 sub r4,r4,r5
189
19013: srd r6,r4,r7
191 mtctr r6
192 mr r8,r3
19314:
194err1; dcbz r0,r3
195 add r3,r3,r9
196 bdnz 14b
197
198 and r4,r4,r10
199
200 cmpdi r4,32
201 blt .Lshort_clear
202 b .Lmedium_clear
diff --git a/arch/powerpc/lib/copyuser_power7_vmx.c b/arch/powerpc/lib/vmx-helper.c
index bf2654f2b68..3cf529ceec5 100644
--- a/arch/powerpc/lib/copyuser_power7_vmx.c
+++ b/arch/powerpc/lib/vmx-helper.c
@@ -22,7 +22,7 @@
22#include <linux/hardirq.h> 22#include <linux/hardirq.h>
23#include <asm/switch_to.h> 23#include <asm/switch_to.h>
24 24
25int enter_vmx_copy(void) 25int enter_vmx_usercopy(void)
26{ 26{
27 if (in_interrupt()) 27 if (in_interrupt())
28 return 0; 28 return 0;
@@ -44,8 +44,31 @@ int enter_vmx_copy(void)
44 * This function must return 0 because we tail call optimise when calling 44 * This function must return 0 because we tail call optimise when calling
45 * from __copy_tofrom_user_power7 which returns 0 on success. 45 * from __copy_tofrom_user_power7 which returns 0 on success.
46 */ 46 */
47int exit_vmx_copy(void) 47int exit_vmx_usercopy(void)
48{ 48{
49 pagefault_enable(); 49 pagefault_enable();
50 return 0; 50 return 0;
51} 51}
52
53int enter_vmx_copy(void)
54{
55 if (in_interrupt())
56 return 0;
57
58 preempt_disable();
59
60 enable_kernel_altivec();
61
62 return 1;
63}
64
65/*
66 * All calls to this function will be optimised into tail calls. We are
67 * passed a pointer to the destination which we return as required by a
68 * memcpy implementation.
69 */
70void *exit_vmx_copy(void *dest)
71{
72 preempt_enable();
73 return dest;
74}
diff --git a/arch/powerpc/mm/hash_low_32.S b/arch/powerpc/mm/hash_low_32.S
index b13d58932bf..115347f74ce 100644
--- a/arch/powerpc/mm/hash_low_32.S
+++ b/arch/powerpc/mm/hash_low_32.S
@@ -184,7 +184,7 @@ _GLOBAL(add_hash_page)
184 add r3,r3,r0 /* note create_hpte trims to 24 bits */ 184 add r3,r3,r0 /* note create_hpte trims to 24 bits */
185 185
186#ifdef CONFIG_SMP 186#ifdef CONFIG_SMP
187 rlwinm r8,r1,0,0,(31-THREAD_SHIFT) /* use cpu number to make tag */ 187 CURRENT_THREAD_INFO(r8, r1) /* use cpu number to make tag */
188 lwz r8,TI_CPU(r8) /* to go in mmu_hash_lock */ 188 lwz r8,TI_CPU(r8) /* to go in mmu_hash_lock */
189 oris r8,r8,12 189 oris r8,r8,12
190#endif /* CONFIG_SMP */ 190#endif /* CONFIG_SMP */
@@ -545,7 +545,7 @@ _GLOBAL(flush_hash_pages)
545#ifdef CONFIG_SMP 545#ifdef CONFIG_SMP
546 addis r9,r7,mmu_hash_lock@ha 546 addis r9,r7,mmu_hash_lock@ha
547 addi r9,r9,mmu_hash_lock@l 547 addi r9,r9,mmu_hash_lock@l
548 rlwinm r8,r1,0,0,(31-THREAD_SHIFT) 548 CURRENT_THREAD_INFO(r8, r1)
549 add r8,r8,r7 549 add r8,r8,r7
550 lwz r8,TI_CPU(r8) 550 lwz r8,TI_CPU(r8)
551 oris r8,r8,9 551 oris r8,r8,9
@@ -639,7 +639,7 @@ _GLOBAL(flush_hash_patch_B)
639 */ 639 */
640_GLOBAL(_tlbie) 640_GLOBAL(_tlbie)
641#ifdef CONFIG_SMP 641#ifdef CONFIG_SMP
642 rlwinm r8,r1,0,0,(31-THREAD_SHIFT) 642 CURRENT_THREAD_INFO(r8, r1)
643 lwz r8,TI_CPU(r8) 643 lwz r8,TI_CPU(r8)
644 oris r8,r8,11 644 oris r8,r8,11
645 mfmsr r10 645 mfmsr r10
@@ -677,7 +677,7 @@ _GLOBAL(_tlbie)
677 */ 677 */
678_GLOBAL(_tlbia) 678_GLOBAL(_tlbia)
679#if defined(CONFIG_SMP) 679#if defined(CONFIG_SMP)
680 rlwinm r8,r1,0,0,(31-THREAD_SHIFT) 680 CURRENT_THREAD_INFO(r8, r1)
681 lwz r8,TI_CPU(r8) 681 lwz r8,TI_CPU(r8)
682 oris r8,r8,10 682 oris r8,r8,10
683 mfmsr r10 683 mfmsr r10
diff --git a/arch/powerpc/mm/hash_low_64.S b/arch/powerpc/mm/hash_low_64.S
index a242b5d7cbe..602aeb06d29 100644
--- a/arch/powerpc/mm/hash_low_64.S
+++ b/arch/powerpc/mm/hash_low_64.S
@@ -34,14 +34,6 @@
34 * | CR save area (SP + 8) 34 * | CR save area (SP + 8)
35 * SP ---> +-- Back chain (SP + 0) 35 * SP ---> +-- Back chain (SP + 0)
36 */ 36 */
37#define STACKFRAMESIZE 256
38
39/* Save parameters offsets */
40#define STK_PARM(i) (STACKFRAMESIZE + 48 + ((i)-3)*8)
41
42/* Save non-volatile offsets */
43#define STK_REG(i) (112 + ((i)-14)*8)
44
45 37
46#ifndef CONFIG_PPC_64K_PAGES 38#ifndef CONFIG_PPC_64K_PAGES
47 39
@@ -64,9 +56,9 @@ _GLOBAL(__hash_page_4K)
64 std r0,16(r1) 56 std r0,16(r1)
65 stdu r1,-STACKFRAMESIZE(r1) 57 stdu r1,-STACKFRAMESIZE(r1)
66 /* Save all params that we need after a function call */ 58 /* Save all params that we need after a function call */
67 std r6,STK_PARM(r6)(r1) 59 std r6,STK_PARAM(R6)(r1)
68 std r8,STK_PARM(r8)(r1) 60 std r8,STK_PARAM(R8)(r1)
69 std r9,STK_PARM(r9)(r1) 61 std r9,STK_PARAM(R9)(r1)
70 62
71 /* Save non-volatile registers. 63 /* Save non-volatile registers.
72 * r31 will hold "old PTE" 64 * r31 will hold "old PTE"
@@ -75,11 +67,11 @@ _GLOBAL(__hash_page_4K)
75 * r28 is a hash value 67 * r28 is a hash value
76 * r27 is hashtab mask (maybe dynamic patched instead ?) 68 * r27 is hashtab mask (maybe dynamic patched instead ?)
77 */ 69 */
78 std r27,STK_REG(r27)(r1) 70 std r27,STK_REG(R27)(r1)
79 std r28,STK_REG(r28)(r1) 71 std r28,STK_REG(R28)(r1)
80 std r29,STK_REG(r29)(r1) 72 std r29,STK_REG(R29)(r1)
81 std r30,STK_REG(r30)(r1) 73 std r30,STK_REG(R30)(r1)
82 std r31,STK_REG(r31)(r1) 74 std r31,STK_REG(R31)(r1)
83 75
84 /* Step 1: 76 /* Step 1:
85 * 77 *
@@ -162,7 +154,7 @@ END_FTR_SECTION(CPU_FTR_NOEXECUTE|CPU_FTR_COHERENT_ICACHE, CPU_FTR_NOEXECUTE)
162 /* At this point, r3 contains new PP bits, save them in 154 /* At this point, r3 contains new PP bits, save them in
163 * place of "access" in the param area (sic) 155 * place of "access" in the param area (sic)
164 */ 156 */
165 std r3,STK_PARM(r4)(r1) 157 std r3,STK_PARAM(R4)(r1)
166 158
167 /* Get htab_hash_mask */ 159 /* Get htab_hash_mask */
168 ld r4,htab_hash_mask@got(2) 160 ld r4,htab_hash_mask@got(2)
@@ -192,11 +184,11 @@ htab_insert_pte:
192 rldicr r3,r0,3,63-3 /* r3 = (hash & mask) << 3 */ 184 rldicr r3,r0,3,63-3 /* r3 = (hash & mask) << 3 */
193 185
194 /* Call ppc_md.hpte_insert */ 186 /* Call ppc_md.hpte_insert */
195 ld r6,STK_PARM(r4)(r1) /* Retrieve new pp bits */ 187 ld r6,STK_PARAM(R4)(r1) /* Retrieve new pp bits */
196 mr r4,r29 /* Retrieve va */ 188 mr r4,r29 /* Retrieve va */
197 li r7,0 /* !bolted, !secondary */ 189 li r7,0 /* !bolted, !secondary */
198 li r8,MMU_PAGE_4K /* page size */ 190 li r8,MMU_PAGE_4K /* page size */
199 ld r9,STK_PARM(r9)(r1) /* segment size */ 191 ld r9,STK_PARAM(R9)(r1) /* segment size */
200_GLOBAL(htab_call_hpte_insert1) 192_GLOBAL(htab_call_hpte_insert1)
201 bl . /* Patched by htab_finish_init() */ 193 bl . /* Patched by htab_finish_init() */
202 cmpdi 0,r3,0 194 cmpdi 0,r3,0
@@ -215,11 +207,11 @@ _GLOBAL(htab_call_hpte_insert1)
215 rldicr r3,r0,3,63-3 /* r0 = (~hash & mask) << 3 */ 207 rldicr r3,r0,3,63-3 /* r0 = (~hash & mask) << 3 */
216 208
217 /* Call ppc_md.hpte_insert */ 209 /* Call ppc_md.hpte_insert */
218 ld r6,STK_PARM(r4)(r1) /* Retrieve new pp bits */ 210 ld r6,STK_PARAM(R4)(r1) /* Retrieve new pp bits */
219 mr r4,r29 /* Retrieve va */ 211 mr r4,r29 /* Retrieve va */
220 li r7,HPTE_V_SECONDARY /* !bolted, secondary */ 212 li r7,HPTE_V_SECONDARY /* !bolted, secondary */
221 li r8,MMU_PAGE_4K /* page size */ 213 li r8,MMU_PAGE_4K /* page size */
222 ld r9,STK_PARM(r9)(r1) /* segment size */ 214 ld r9,STK_PARAM(R9)(r1) /* segment size */
223_GLOBAL(htab_call_hpte_insert2) 215_GLOBAL(htab_call_hpte_insert2)
224 bl . /* Patched by htab_finish_init() */ 216 bl . /* Patched by htab_finish_init() */
225 cmpdi 0,r3,0 217 cmpdi 0,r3,0
@@ -255,15 +247,15 @@ htab_pte_insert_ok:
255 * (maybe add eieio may be good still ?) 247 * (maybe add eieio may be good still ?)
256 */ 248 */
257htab_write_out_pte: 249htab_write_out_pte:
258 ld r6,STK_PARM(r6)(r1) 250 ld r6,STK_PARAM(R6)(r1)
259 std r30,0(r6) 251 std r30,0(r6)
260 li r3, 0 252 li r3, 0
261htab_bail: 253htab_bail:
262 ld r27,STK_REG(r27)(r1) 254 ld r27,STK_REG(R27)(r1)
263 ld r28,STK_REG(r28)(r1) 255 ld r28,STK_REG(R28)(r1)
264 ld r29,STK_REG(r29)(r1) 256 ld r29,STK_REG(R29)(r1)
265 ld r30,STK_REG(r30)(r1) 257 ld r30,STK_REG(R30)(r1)
266 ld r31,STK_REG(r31)(r1) 258 ld r31,STK_REG(R31)(r1)
267 addi r1,r1,STACKFRAMESIZE 259 addi r1,r1,STACKFRAMESIZE
268 ld r0,16(r1) 260 ld r0,16(r1)
269 mtlr r0 261 mtlr r0
@@ -288,8 +280,8 @@ htab_modify_pte:
288 /* Call ppc_md.hpte_updatepp */ 280 /* Call ppc_md.hpte_updatepp */
289 mr r5,r29 /* va */ 281 mr r5,r29 /* va */
290 li r6,MMU_PAGE_4K /* page size */ 282 li r6,MMU_PAGE_4K /* page size */
291 ld r7,STK_PARM(r9)(r1) /* segment size */ 283 ld r7,STK_PARAM(R9)(r1) /* segment size */
292 ld r8,STK_PARM(r8)(r1) /* get "local" param */ 284 ld r8,STK_PARAM(R8)(r1) /* get "local" param */
293_GLOBAL(htab_call_hpte_updatepp) 285_GLOBAL(htab_call_hpte_updatepp)
294 bl . /* Patched by htab_finish_init() */ 286 bl . /* Patched by htab_finish_init() */
295 287
@@ -312,7 +304,7 @@ htab_wrong_access:
312 304
313htab_pte_insert_failure: 305htab_pte_insert_failure:
314 /* Bail out restoring old PTE */ 306 /* Bail out restoring old PTE */
315 ld r6,STK_PARM(r6)(r1) 307 ld r6,STK_PARAM(R6)(r1)
316 std r31,0(r6) 308 std r31,0(r6)
317 li r3,-1 309 li r3,-1
318 b htab_bail 310 b htab_bail
@@ -340,9 +332,9 @@ _GLOBAL(__hash_page_4K)
340 std r0,16(r1) 332 std r0,16(r1)
341 stdu r1,-STACKFRAMESIZE(r1) 333 stdu r1,-STACKFRAMESIZE(r1)
342 /* Save all params that we need after a function call */ 334 /* Save all params that we need after a function call */
343 std r6,STK_PARM(r6)(r1) 335 std r6,STK_PARAM(R6)(r1)
344 std r8,STK_PARM(r8)(r1) 336 std r8,STK_PARAM(R8)(r1)
345 std r9,STK_PARM(r9)(r1) 337 std r9,STK_PARAM(R9)(r1)
346 338
347 /* Save non-volatile registers. 339 /* Save non-volatile registers.
348 * r31 will hold "old PTE" 340 * r31 will hold "old PTE"
@@ -353,13 +345,13 @@ _GLOBAL(__hash_page_4K)
353 * r26 is the hidx mask 345 * r26 is the hidx mask
354 * r25 is the index in combo page 346 * r25 is the index in combo page
355 */ 347 */
356 std r25,STK_REG(r25)(r1) 348 std r25,STK_REG(R25)(r1)
357 std r26,STK_REG(r26)(r1) 349 std r26,STK_REG(R26)(r1)
358 std r27,STK_REG(r27)(r1) 350 std r27,STK_REG(R27)(r1)
359 std r28,STK_REG(r28)(r1) 351 std r28,STK_REG(R28)(r1)
360 std r29,STK_REG(r29)(r1) 352 std r29,STK_REG(R29)(r1)
361 std r30,STK_REG(r30)(r1) 353 std r30,STK_REG(R30)(r1)
362 std r31,STK_REG(r31)(r1) 354 std r31,STK_REG(R31)(r1)
363 355
364 /* Step 1: 356 /* Step 1:
365 * 357 *
@@ -452,7 +444,7 @@ END_FTR_SECTION(CPU_FTR_NOEXECUTE|CPU_FTR_COHERENT_ICACHE, CPU_FTR_NOEXECUTE)
452 /* At this point, r3 contains new PP bits, save them in 444 /* At this point, r3 contains new PP bits, save them in
453 * place of "access" in the param area (sic) 445 * place of "access" in the param area (sic)
454 */ 446 */
455 std r3,STK_PARM(r4)(r1) 447 std r3,STK_PARAM(R4)(r1)
456 448
457 /* Get htab_hash_mask */ 449 /* Get htab_hash_mask */
458 ld r4,htab_hash_mask@got(2) 450 ld r4,htab_hash_mask@got(2)
@@ -473,7 +465,7 @@ END_FTR_SECTION(CPU_FTR_NOEXECUTE|CPU_FTR_COHERENT_ICACHE, CPU_FTR_NOEXECUTE)
473 andis. r0,r31,_PAGE_COMBO@h 465 andis. r0,r31,_PAGE_COMBO@h
474 beq htab_inval_old_hpte 466 beq htab_inval_old_hpte
475 467
476 ld r6,STK_PARM(r6)(r1) 468 ld r6,STK_PARAM(R6)(r1)
477 ori r26,r6,0x8000 /* Load the hidx mask */ 469 ori r26,r6,0x8000 /* Load the hidx mask */
478 ld r26,0(r26) 470 ld r26,0(r26)
479 addi r5,r25,36 /* Check actual HPTE_SUB bit, this */ 471 addi r5,r25,36 /* Check actual HPTE_SUB bit, this */
@@ -495,11 +487,11 @@ htab_special_pfn:
495 rldicr r3,r0,3,63-3 /* r0 = (hash & mask) << 3 */ 487 rldicr r3,r0,3,63-3 /* r0 = (hash & mask) << 3 */
496 488
497 /* Call ppc_md.hpte_insert */ 489 /* Call ppc_md.hpte_insert */
498 ld r6,STK_PARM(r4)(r1) /* Retrieve new pp bits */ 490 ld r6,STK_PARAM(R4)(r1) /* Retrieve new pp bits */
499 mr r4,r29 /* Retrieve va */ 491 mr r4,r29 /* Retrieve va */
500 li r7,0 /* !bolted, !secondary */ 492 li r7,0 /* !bolted, !secondary */
501 li r8,MMU_PAGE_4K /* page size */ 493 li r8,MMU_PAGE_4K /* page size */
502 ld r9,STK_PARM(r9)(r1) /* segment size */ 494 ld r9,STK_PARAM(R9)(r1) /* segment size */
503_GLOBAL(htab_call_hpte_insert1) 495_GLOBAL(htab_call_hpte_insert1)
504 bl . /* patched by htab_finish_init() */ 496 bl . /* patched by htab_finish_init() */
505 cmpdi 0,r3,0 497 cmpdi 0,r3,0
@@ -522,11 +514,11 @@ _GLOBAL(htab_call_hpte_insert1)
522 rldicr r3,r0,3,63-3 /* r0 = (~hash & mask) << 3 */ 514 rldicr r3,r0,3,63-3 /* r0 = (~hash & mask) << 3 */
523 515
524 /* Call ppc_md.hpte_insert */ 516 /* Call ppc_md.hpte_insert */
525 ld r6,STK_PARM(r4)(r1) /* Retrieve new pp bits */ 517 ld r6,STK_PARAM(R4)(r1) /* Retrieve new pp bits */
526 mr r4,r29 /* Retrieve va */ 518 mr r4,r29 /* Retrieve va */
527 li r7,HPTE_V_SECONDARY /* !bolted, secondary */ 519 li r7,HPTE_V_SECONDARY /* !bolted, secondary */
528 li r8,MMU_PAGE_4K /* page size */ 520 li r8,MMU_PAGE_4K /* page size */
529 ld r9,STK_PARM(r9)(r1) /* segment size */ 521 ld r9,STK_PARAM(R9)(r1) /* segment size */
530_GLOBAL(htab_call_hpte_insert2) 522_GLOBAL(htab_call_hpte_insert2)
531 bl . /* patched by htab_finish_init() */ 523 bl . /* patched by htab_finish_init() */
532 cmpdi 0,r3,0 524 cmpdi 0,r3,0
@@ -559,8 +551,8 @@ htab_inval_old_hpte:
559 mr r4,r31 /* PTE.pte */ 551 mr r4,r31 /* PTE.pte */
560 li r5,0 /* PTE.hidx */ 552 li r5,0 /* PTE.hidx */
561 li r6,MMU_PAGE_64K /* psize */ 553 li r6,MMU_PAGE_64K /* psize */
562 ld r7,STK_PARM(r9)(r1) /* ssize */ 554 ld r7,STK_PARAM(R9)(r1) /* ssize */
563 ld r8,STK_PARM(r8)(r1) /* local */ 555 ld r8,STK_PARAM(R8)(r1) /* local */
564 bl .flush_hash_page 556 bl .flush_hash_page
565 /* Clear out _PAGE_HPTE_SUB bits in the new linux PTE */ 557 /* Clear out _PAGE_HPTE_SUB bits in the new linux PTE */
566 lis r0,_PAGE_HPTE_SUB@h 558 lis r0,_PAGE_HPTE_SUB@h
@@ -576,7 +568,7 @@ htab_pte_insert_ok:
576 /* Insert slot number & secondary bit in PTE second half, 568 /* Insert slot number & secondary bit in PTE second half,
577 * clear _PAGE_BUSY and set approriate HPTE slot bit 569 * clear _PAGE_BUSY and set approriate HPTE slot bit
578 */ 570 */
579 ld r6,STK_PARM(r6)(r1) 571 ld r6,STK_PARAM(R6)(r1)
580 li r0,_PAGE_BUSY 572 li r0,_PAGE_BUSY
581 andc r30,r30,r0 573 andc r30,r30,r0
582 /* HPTE SUB bit */ 574 /* HPTE SUB bit */
@@ -597,13 +589,13 @@ htab_pte_insert_ok:
597 std r30,0(r6) 589 std r30,0(r6)
598 li r3, 0 590 li r3, 0
599htab_bail: 591htab_bail:
600 ld r25,STK_REG(r25)(r1) 592 ld r25,STK_REG(R25)(r1)
601 ld r26,STK_REG(r26)(r1) 593 ld r26,STK_REG(R26)(r1)
602 ld r27,STK_REG(r27)(r1) 594 ld r27,STK_REG(R27)(r1)
603 ld r28,STK_REG(r28)(r1) 595 ld r28,STK_REG(R28)(r1)
604 ld r29,STK_REG(r29)(r1) 596 ld r29,STK_REG(R29)(r1)
605 ld r30,STK_REG(r30)(r1) 597 ld r30,STK_REG(R30)(r1)
606 ld r31,STK_REG(r31)(r1) 598 ld r31,STK_REG(R31)(r1)
607 addi r1,r1,STACKFRAMESIZE 599 addi r1,r1,STACKFRAMESIZE
608 ld r0,16(r1) 600 ld r0,16(r1)
609 mtlr r0 601 mtlr r0
@@ -630,8 +622,8 @@ htab_modify_pte:
630 /* Call ppc_md.hpte_updatepp */ 622 /* Call ppc_md.hpte_updatepp */
631 mr r5,r29 /* va */ 623 mr r5,r29 /* va */
632 li r6,MMU_PAGE_4K /* page size */ 624 li r6,MMU_PAGE_4K /* page size */
633 ld r7,STK_PARM(r9)(r1) /* segment size */ 625 ld r7,STK_PARAM(R9)(r1) /* segment size */
634 ld r8,STK_PARM(r8)(r1) /* get "local" param */ 626 ld r8,STK_PARAM(R8)(r1) /* get "local" param */
635_GLOBAL(htab_call_hpte_updatepp) 627_GLOBAL(htab_call_hpte_updatepp)
636 bl . /* patched by htab_finish_init() */ 628 bl . /* patched by htab_finish_init() */
637 629
@@ -644,7 +636,7 @@ _GLOBAL(htab_call_hpte_updatepp)
644 /* Clear the BUSY bit and Write out the PTE */ 636 /* Clear the BUSY bit and Write out the PTE */
645 li r0,_PAGE_BUSY 637 li r0,_PAGE_BUSY
646 andc r30,r30,r0 638 andc r30,r30,r0
647 ld r6,STK_PARM(r6)(r1) 639 ld r6,STK_PARAM(R6)(r1)
648 std r30,0(r6) 640 std r30,0(r6)
649 li r3,0 641 li r3,0
650 b htab_bail 642 b htab_bail
@@ -657,7 +649,7 @@ htab_wrong_access:
657 649
658htab_pte_insert_failure: 650htab_pte_insert_failure:
659 /* Bail out restoring old PTE */ 651 /* Bail out restoring old PTE */
660 ld r6,STK_PARM(r6)(r1) 652 ld r6,STK_PARAM(R6)(r1)
661 std r31,0(r6) 653 std r31,0(r6)
662 li r3,-1 654 li r3,-1
663 b htab_bail 655 b htab_bail
@@ -677,9 +669,9 @@ _GLOBAL(__hash_page_64K)
677 std r0,16(r1) 669 std r0,16(r1)
678 stdu r1,-STACKFRAMESIZE(r1) 670 stdu r1,-STACKFRAMESIZE(r1)
679 /* Save all params that we need after a function call */ 671 /* Save all params that we need after a function call */
680 std r6,STK_PARM(r6)(r1) 672 std r6,STK_PARAM(R6)(r1)
681 std r8,STK_PARM(r8)(r1) 673 std r8,STK_PARAM(R8)(r1)
682 std r9,STK_PARM(r9)(r1) 674 std r9,STK_PARAM(R9)(r1)
683 675
684 /* Save non-volatile registers. 676 /* Save non-volatile registers.
685 * r31 will hold "old PTE" 677 * r31 will hold "old PTE"
@@ -688,11 +680,11 @@ _GLOBAL(__hash_page_64K)
688 * r28 is a hash value 680 * r28 is a hash value
689 * r27 is hashtab mask (maybe dynamic patched instead ?) 681 * r27 is hashtab mask (maybe dynamic patched instead ?)
690 */ 682 */
691 std r27,STK_REG(r27)(r1) 683 std r27,STK_REG(R27)(r1)
692 std r28,STK_REG(r28)(r1) 684 std r28,STK_REG(R28)(r1)
693 std r29,STK_REG(r29)(r1) 685 std r29,STK_REG(R29)(r1)
694 std r30,STK_REG(r30)(r1) 686 std r30,STK_REG(R30)(r1)
695 std r31,STK_REG(r31)(r1) 687 std r31,STK_REG(R31)(r1)
696 688
697 /* Step 1: 689 /* Step 1:
698 * 690 *
@@ -780,7 +772,7 @@ END_FTR_SECTION(CPU_FTR_NOEXECUTE|CPU_FTR_COHERENT_ICACHE, CPU_FTR_NOEXECUTE)
780 /* At this point, r3 contains new PP bits, save them in 772 /* At this point, r3 contains new PP bits, save them in
781 * place of "access" in the param area (sic) 773 * place of "access" in the param area (sic)
782 */ 774 */
783 std r3,STK_PARM(r4)(r1) 775 std r3,STK_PARAM(R4)(r1)
784 776
785 /* Get htab_hash_mask */ 777 /* Get htab_hash_mask */
786 ld r4,htab_hash_mask@got(2) 778 ld r4,htab_hash_mask@got(2)
@@ -813,11 +805,11 @@ ht64_insert_pte:
813 rldicr r3,r0,3,63-3 /* r0 = (hash & mask) << 3 */ 805 rldicr r3,r0,3,63-3 /* r0 = (hash & mask) << 3 */
814 806
815 /* Call ppc_md.hpte_insert */ 807 /* Call ppc_md.hpte_insert */
816 ld r6,STK_PARM(r4)(r1) /* Retrieve new pp bits */ 808 ld r6,STK_PARAM(R4)(r1) /* Retrieve new pp bits */
817 mr r4,r29 /* Retrieve va */ 809 mr r4,r29 /* Retrieve va */
818 li r7,0 /* !bolted, !secondary */ 810 li r7,0 /* !bolted, !secondary */
819 li r8,MMU_PAGE_64K 811 li r8,MMU_PAGE_64K
820 ld r9,STK_PARM(r9)(r1) /* segment size */ 812 ld r9,STK_PARAM(R9)(r1) /* segment size */
821_GLOBAL(ht64_call_hpte_insert1) 813_GLOBAL(ht64_call_hpte_insert1)
822 bl . /* patched by htab_finish_init() */ 814 bl . /* patched by htab_finish_init() */
823 cmpdi 0,r3,0 815 cmpdi 0,r3,0
@@ -836,11 +828,11 @@ _GLOBAL(ht64_call_hpte_insert1)
836 rldicr r3,r0,3,63-3 /* r0 = (~hash & mask) << 3 */ 828 rldicr r3,r0,3,63-3 /* r0 = (~hash & mask) << 3 */
837 829
838 /* Call ppc_md.hpte_insert */ 830 /* Call ppc_md.hpte_insert */
839 ld r6,STK_PARM(r4)(r1) /* Retrieve new pp bits */ 831 ld r6,STK_PARAM(R4)(r1) /* Retrieve new pp bits */
840 mr r4,r29 /* Retrieve va */ 832 mr r4,r29 /* Retrieve va */
841 li r7,HPTE_V_SECONDARY /* !bolted, secondary */ 833 li r7,HPTE_V_SECONDARY /* !bolted, secondary */
842 li r8,MMU_PAGE_64K 834 li r8,MMU_PAGE_64K
843 ld r9,STK_PARM(r9)(r1) /* segment size */ 835 ld r9,STK_PARAM(R9)(r1) /* segment size */
844_GLOBAL(ht64_call_hpte_insert2) 836_GLOBAL(ht64_call_hpte_insert2)
845 bl . /* patched by htab_finish_init() */ 837 bl . /* patched by htab_finish_init() */
846 cmpdi 0,r3,0 838 cmpdi 0,r3,0
@@ -876,15 +868,15 @@ ht64_pte_insert_ok:
876 * (maybe add eieio may be good still ?) 868 * (maybe add eieio may be good still ?)
877 */ 869 */
878ht64_write_out_pte: 870ht64_write_out_pte:
879 ld r6,STK_PARM(r6)(r1) 871 ld r6,STK_PARAM(R6)(r1)
880 std r30,0(r6) 872 std r30,0(r6)
881 li r3, 0 873 li r3, 0
882ht64_bail: 874ht64_bail:
883 ld r27,STK_REG(r27)(r1) 875 ld r27,STK_REG(R27)(r1)
884 ld r28,STK_REG(r28)(r1) 876 ld r28,STK_REG(R28)(r1)
885 ld r29,STK_REG(r29)(r1) 877 ld r29,STK_REG(R29)(r1)
886 ld r30,STK_REG(r30)(r1) 878 ld r30,STK_REG(R30)(r1)
887 ld r31,STK_REG(r31)(r1) 879 ld r31,STK_REG(R31)(r1)
888 addi r1,r1,STACKFRAMESIZE 880 addi r1,r1,STACKFRAMESIZE
889 ld r0,16(r1) 881 ld r0,16(r1)
890 mtlr r0 882 mtlr r0
@@ -909,8 +901,8 @@ ht64_modify_pte:
909 /* Call ppc_md.hpte_updatepp */ 901 /* Call ppc_md.hpte_updatepp */
910 mr r5,r29 /* va */ 902 mr r5,r29 /* va */
911 li r6,MMU_PAGE_64K 903 li r6,MMU_PAGE_64K
912 ld r7,STK_PARM(r9)(r1) /* segment size */ 904 ld r7,STK_PARAM(R9)(r1) /* segment size */
913 ld r8,STK_PARM(r8)(r1) /* get "local" param */ 905 ld r8,STK_PARAM(R8)(r1) /* get "local" param */
914_GLOBAL(ht64_call_hpte_updatepp) 906_GLOBAL(ht64_call_hpte_updatepp)
915 bl . /* patched by htab_finish_init() */ 907 bl . /* patched by htab_finish_init() */
916 908
@@ -933,7 +925,7 @@ ht64_wrong_access:
933 925
934ht64_pte_insert_failure: 926ht64_pte_insert_failure:
935 /* Bail out restoring old PTE */ 927 /* Bail out restoring old PTE */
936 ld r6,STK_PARM(r6)(r1) 928 ld r6,STK_PARAM(R6)(r1)
937 std r31,0(r6) 929 std r31,0(r6)
938 li r3,-1 930 li r3,-1
939 b ht64_bail 931 b ht64_bail
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index baaafde7d13..fbdad0e3929 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -469,6 +469,7 @@ void flush_dcache_icache_page(struct page *page)
469 __flush_dcache_icache_phys(page_to_pfn(page) << PAGE_SHIFT); 469 __flush_dcache_icache_phys(page_to_pfn(page) << PAGE_SHIFT);
470#endif 470#endif
471} 471}
472EXPORT_SYMBOL(flush_dcache_icache_page);
472 473
473void clear_user_page(void *page, unsigned long vaddr, struct page *pg) 474void clear_user_page(void *page, unsigned long vaddr, struct page *pg)
474{ 475{
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 1e95556dc69..59213cfaeca 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -340,6 +340,8 @@ static int __init find_min_common_depth(void)
340 dbg("Using form 1 affinity\n"); 340 dbg("Using form 1 affinity\n");
341 form1_affinity = 1; 341 form1_affinity = 1;
342 } 342 }
343
344 of_node_put(chosen);
343 } 345 }
344 } 346 }
345 347
@@ -1434,11 +1436,11 @@ static long vphn_get_associativity(unsigned long cpu,
1434 1436
1435/* 1437/*
1436 * Update the node maps and sysfs entries for each cpu whose home node 1438 * Update the node maps and sysfs entries for each cpu whose home node
1437 * has changed. 1439 * has changed. Returns 1 when the topology has changed, and 0 otherwise.
1438 */ 1440 */
1439int arch_update_cpu_topology(void) 1441int arch_update_cpu_topology(void)
1440{ 1442{
1441 int cpu, nid, old_nid; 1443 int cpu, nid, old_nid, changed = 0;
1442 unsigned int associativity[VPHN_ASSOC_BUFSIZE] = {0}; 1444 unsigned int associativity[VPHN_ASSOC_BUFSIZE] = {0};
1443 struct device *dev; 1445 struct device *dev;
1444 1446
@@ -1464,9 +1466,10 @@ int arch_update_cpu_topology(void)
1464 dev = get_cpu_device(cpu); 1466 dev = get_cpu_device(cpu);
1465 if (dev) 1467 if (dev)
1466 kobject_uevent(&dev->kobj, KOBJ_CHANGE); 1468 kobject_uevent(&dev->kobj, KOBJ_CHANGE);
1469 changed = 1;
1467 } 1470 }
1468 1471
1469 return 1; 1472 return changed;
1470} 1473}
1471 1474
1472static void topology_work_fn(struct work_struct *work) 1475static void topology_work_fn(struct work_struct *work)
diff --git a/arch/powerpc/mm/tlb_low_64e.S b/arch/powerpc/mm/tlb_low_64e.S
index ff672bd8fea..f09d48e3268 100644
--- a/arch/powerpc/mm/tlb_low_64e.S
+++ b/arch/powerpc/mm/tlb_low_64e.S
@@ -126,7 +126,7 @@ BEGIN_MMU_FTR_SECTION
126 /* Set the TLB reservation and search for existing entry. Then load 126 /* Set the TLB reservation and search for existing entry. Then load
127 * the entry. 127 * the entry.
128 */ 128 */
129 PPC_TLBSRX_DOT(0,r16) 129 PPC_TLBSRX_DOT(0,R16)
130 ldx r14,r14,r15 /* grab pgd entry */ 130 ldx r14,r14,r15 /* grab pgd entry */
131 beq normal_tlb_miss_done /* tlb exists already, bail */ 131 beq normal_tlb_miss_done /* tlb exists already, bail */
132MMU_FTR_SECTION_ELSE 132MMU_FTR_SECTION_ELSE
@@ -395,7 +395,7 @@ BEGIN_MMU_FTR_SECTION
395 /* Set the TLB reservation and search for existing entry. Then load 395 /* Set the TLB reservation and search for existing entry. Then load
396 * the entry. 396 * the entry.
397 */ 397 */
398 PPC_TLBSRX_DOT(0,r16) 398 PPC_TLBSRX_DOT(0,R16)
399 ld r14,0(r10) 399 ld r14,0(r10)
400 beq normal_tlb_miss_done 400 beq normal_tlb_miss_done
401MMU_FTR_SECTION_ELSE 401MMU_FTR_SECTION_ELSE
@@ -528,7 +528,7 @@ BEGIN_MMU_FTR_SECTION
528 /* Search if we already have a TLB entry for that virtual address, and 528 /* Search if we already have a TLB entry for that virtual address, and
529 * if we do, bail out. 529 * if we do, bail out.
530 */ 530 */
531 PPC_TLBSRX_DOT(0,r16) 531 PPC_TLBSRX_DOT(0,R16)
532 beq virt_page_table_tlb_miss_done 532 beq virt_page_table_tlb_miss_done
533END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_TLBRSRV) 533END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_TLBRSRV)
534 534
@@ -779,7 +779,7 @@ htw_tlb_miss:
779 * 779 *
780 * MAS1:IND should be already set based on MAS4 780 * MAS1:IND should be already set based on MAS4
781 */ 781 */
782 PPC_TLBSRX_DOT(0,r16) 782 PPC_TLBSRX_DOT(0,R16)
783 beq htw_tlb_miss_done 783 beq htw_tlb_miss_done
784 784
785 /* Now, we need to walk the page tables. First check if we are in 785 /* Now, we need to walk the page tables. First check if we are in
@@ -919,7 +919,7 @@ tlb_load_linear:
919 mtspr SPRN_MAS1,r15 919 mtspr SPRN_MAS1,r15
920 920
921 /* Already somebody there ? */ 921 /* Already somebody there ? */
922 PPC_TLBSRX_DOT(0,r16) 922 PPC_TLBSRX_DOT(0,R16)
923 beq tlb_load_linear_done 923 beq tlb_load_linear_done
924 924
925 /* Now we build the remaining MAS. MAS0 and 2 should be fine 925 /* Now we build the remaining MAS. MAS0 and 2 should be fine
diff --git a/arch/powerpc/mm/tlb_nohash_low.S b/arch/powerpc/mm/tlb_nohash_low.S
index 7c63c0ed4f1..fab919fd138 100644
--- a/arch/powerpc/mm/tlb_nohash_low.S
+++ b/arch/powerpc/mm/tlb_nohash_low.S
@@ -266,7 +266,7 @@ BEGIN_MMU_FTR_SECTION
266 andi. r3,r3,MMUCSR0_TLBFI@l 266 andi. r3,r3,MMUCSR0_TLBFI@l
267 bne 1b 267 bne 1b
268MMU_FTR_SECTION_ELSE 268MMU_FTR_SECTION_ELSE
269 PPC_TLBILX_ALL(0,0) 269 PPC_TLBILX_ALL(0,R0)
270ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_USE_TLBILX) 270ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_USE_TLBILX)
271 msync 271 msync
272 isync 272 isync
@@ -279,7 +279,7 @@ BEGIN_MMU_FTR_SECTION
279 wrteei 0 279 wrteei 0
280 mfspr r4,SPRN_MAS6 /* save MAS6 */ 280 mfspr r4,SPRN_MAS6 /* save MAS6 */
281 mtspr SPRN_MAS6,r3 281 mtspr SPRN_MAS6,r3
282 PPC_TLBILX_PID(0,0) 282 PPC_TLBILX_PID(0,R0)
283 mtspr SPRN_MAS6,r4 /* restore MAS6 */ 283 mtspr SPRN_MAS6,r4 /* restore MAS6 */
284 wrtee r10 284 wrtee r10
285MMU_FTR_SECTION_ELSE 285MMU_FTR_SECTION_ELSE
@@ -313,7 +313,7 @@ BEGIN_MMU_FTR_SECTION
313 mtspr SPRN_MAS1,r4 313 mtspr SPRN_MAS1,r4
314 tlbwe 314 tlbwe
315MMU_FTR_SECTION_ELSE 315MMU_FTR_SECTION_ELSE
316 PPC_TLBILX_VA(0,r3) 316 PPC_TLBILX_VA(0,R3)
317ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_USE_TLBILX) 317ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_USE_TLBILX)
318 msync 318 msync
319 isync 319 isync
@@ -331,7 +331,7 @@ _GLOBAL(_tlbil_pid)
331 mfmsr r10 331 mfmsr r10
332 wrteei 0 332 wrteei 0
333 mtspr SPRN_MAS6,r4 333 mtspr SPRN_MAS6,r4
334 PPC_TLBILX_PID(0,0) 334 PPC_TLBILX_PID(0,R0)
335 wrtee r10 335 wrtee r10
336 msync 336 msync
337 isync 337 isync
@@ -343,14 +343,14 @@ _GLOBAL(_tlbil_pid_noind)
343 ori r4,r4,MAS6_SIND 343 ori r4,r4,MAS6_SIND
344 wrteei 0 344 wrteei 0
345 mtspr SPRN_MAS6,r4 345 mtspr SPRN_MAS6,r4
346 PPC_TLBILX_PID(0,0) 346 PPC_TLBILX_PID(0,R0)
347 wrtee r10 347 wrtee r10
348 msync 348 msync
349 isync 349 isync
350 blr 350 blr
351 351
352_GLOBAL(_tlbil_all) 352_GLOBAL(_tlbil_all)
353 PPC_TLBILX_ALL(0,0) 353 PPC_TLBILX_ALL(0,R0)
354 msync 354 msync
355 isync 355 isync
356 blr 356 blr
@@ -364,7 +364,7 @@ _GLOBAL(_tlbil_va)
364 beq 1f 364 beq 1f
365 rlwimi r4,r6,MAS6_SIND_SHIFT,MAS6_SIND 365 rlwimi r4,r6,MAS6_SIND_SHIFT,MAS6_SIND
3661: mtspr SPRN_MAS6,r4 /* assume AS=0 for now */ 3661: mtspr SPRN_MAS6,r4 /* assume AS=0 for now */
367 PPC_TLBILX_VA(0,r3) 367 PPC_TLBILX_VA(0,R3)
368 msync 368 msync
369 isync 369 isync
370 wrtee r10 370 wrtee r10
@@ -379,7 +379,7 @@ _GLOBAL(_tlbivax_bcast)
379 beq 1f 379 beq 1f
380 rlwimi r4,r6,MAS6_SIND_SHIFT,MAS6_SIND 380 rlwimi r4,r6,MAS6_SIND_SHIFT,MAS6_SIND
3811: mtspr SPRN_MAS6,r4 /* assume AS=0 for now */ 3811: mtspr SPRN_MAS6,r4 /* assume AS=0 for now */
382 PPC_TLBIVAX(0,r3) 382 PPC_TLBIVAX(0,R3)
383 eieio 383 eieio
384 tlbsync 384 tlbsync
385 sync 385 sync
diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
index 5c3cf2d04e4..1fc8109bf2f 100644
--- a/arch/powerpc/net/bpf_jit.h
+++ b/arch/powerpc/net/bpf_jit.h
@@ -75,23 +75,23 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh);
75#define PPC_NOP() EMIT(PPC_INST_NOP) 75#define PPC_NOP() EMIT(PPC_INST_NOP)
76#define PPC_BLR() EMIT(PPC_INST_BLR) 76#define PPC_BLR() EMIT(PPC_INST_BLR)
77#define PPC_BLRL() EMIT(PPC_INST_BLRL) 77#define PPC_BLRL() EMIT(PPC_INST_BLRL)
78#define PPC_MTLR(r) EMIT(PPC_INST_MTLR | __PPC_RT(r)) 78#define PPC_MTLR(r) EMIT(PPC_INST_MTLR | ___PPC_RT(r))
79#define PPC_ADDI(d, a, i) EMIT(PPC_INST_ADDI | __PPC_RT(d) | \ 79#define PPC_ADDI(d, a, i) EMIT(PPC_INST_ADDI | ___PPC_RT(d) | \
80 __PPC_RA(a) | IMM_L(i)) 80 ___PPC_RA(a) | IMM_L(i))
81#define PPC_MR(d, a) PPC_OR(d, a, a) 81#define PPC_MR(d, a) PPC_OR(d, a, a)
82#define PPC_LI(r, i) PPC_ADDI(r, 0, i) 82#define PPC_LI(r, i) PPC_ADDI(r, 0, i)
83#define PPC_ADDIS(d, a, i) EMIT(PPC_INST_ADDIS | \ 83#define PPC_ADDIS(d, a, i) EMIT(PPC_INST_ADDIS | \
84 __PPC_RS(d) | __PPC_RA(a) | IMM_L(i)) 84 ___PPC_RS(d) | ___PPC_RA(a) | IMM_L(i))
85#define PPC_LIS(r, i) PPC_ADDIS(r, 0, i) 85#define PPC_LIS(r, i) PPC_ADDIS(r, 0, i)
86#define PPC_STD(r, base, i) EMIT(PPC_INST_STD | __PPC_RS(r) | \ 86#define PPC_STD(r, base, i) EMIT(PPC_INST_STD | ___PPC_RS(r) | \
87 __PPC_RA(base) | ((i) & 0xfffc)) 87 ___PPC_RA(base) | ((i) & 0xfffc))
88 88
89#define PPC_LD(r, base, i) EMIT(PPC_INST_LD | __PPC_RT(r) | \ 89#define PPC_LD(r, base, i) EMIT(PPC_INST_LD | ___PPC_RT(r) | \
90 __PPC_RA(base) | IMM_L(i)) 90 ___PPC_RA(base) | IMM_L(i))
91#define PPC_LWZ(r, base, i) EMIT(PPC_INST_LWZ | __PPC_RT(r) | \ 91#define PPC_LWZ(r, base, i) EMIT(PPC_INST_LWZ | ___PPC_RT(r) | \
92 __PPC_RA(base) | IMM_L(i)) 92 ___PPC_RA(base) | IMM_L(i))
93#define PPC_LHZ(r, base, i) EMIT(PPC_INST_LHZ | __PPC_RT(r) | \ 93#define PPC_LHZ(r, base, i) EMIT(PPC_INST_LHZ | ___PPC_RT(r) | \
94 __PPC_RA(base) | IMM_L(i)) 94 ___PPC_RA(base) | IMM_L(i))
95/* Convenience helpers for the above with 'far' offsets: */ 95/* Convenience helpers for the above with 'far' offsets: */
96#define PPC_LD_OFFS(r, base, i) do { if ((i) < 32768) PPC_LD(r, base, i); \ 96#define PPC_LD_OFFS(r, base, i) do { if ((i) < 32768) PPC_LD(r, base, i); \
97 else { PPC_ADDIS(r, base, IMM_HA(i)); \ 97 else { PPC_ADDIS(r, base, IMM_HA(i)); \
@@ -105,52 +105,52 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh);
105 else { PPC_ADDIS(r, base, IMM_HA(i)); \ 105 else { PPC_ADDIS(r, base, IMM_HA(i)); \
106 PPC_LHZ(r, r, IMM_L(i)); } } while(0) 106 PPC_LHZ(r, r, IMM_L(i)); } } while(0)
107 107
108#define PPC_CMPWI(a, i) EMIT(PPC_INST_CMPWI | __PPC_RA(a) | IMM_L(i)) 108#define PPC_CMPWI(a, i) EMIT(PPC_INST_CMPWI | ___PPC_RA(a) | IMM_L(i))
109#define PPC_CMPDI(a, i) EMIT(PPC_INST_CMPDI | __PPC_RA(a) | IMM_L(i)) 109#define PPC_CMPDI(a, i) EMIT(PPC_INST_CMPDI | ___PPC_RA(a) | IMM_L(i))
110#define PPC_CMPLWI(a, i) EMIT(PPC_INST_CMPLWI | __PPC_RA(a) | IMM_L(i)) 110#define PPC_CMPLWI(a, i) EMIT(PPC_INST_CMPLWI | ___PPC_RA(a) | IMM_L(i))
111#define PPC_CMPLW(a, b) EMIT(PPC_INST_CMPLW | __PPC_RA(a) | __PPC_RB(b)) 111#define PPC_CMPLW(a, b) EMIT(PPC_INST_CMPLW | ___PPC_RA(a) | ___PPC_RB(b))
112 112
113#define PPC_SUB(d, a, b) EMIT(PPC_INST_SUB | __PPC_RT(d) | \ 113#define PPC_SUB(d, a, b) EMIT(PPC_INST_SUB | ___PPC_RT(d) | \
114 __PPC_RB(a) | __PPC_RA(b)) 114 ___PPC_RB(a) | ___PPC_RA(b))
115#define PPC_ADD(d, a, b) EMIT(PPC_INST_ADD | __PPC_RT(d) | \ 115#define PPC_ADD(d, a, b) EMIT(PPC_INST_ADD | ___PPC_RT(d) | \
116 __PPC_RA(a) | __PPC_RB(b)) 116 ___PPC_RA(a) | ___PPC_RB(b))
117#define PPC_MUL(d, a, b) EMIT(PPC_INST_MULLW | __PPC_RT(d) | \ 117#define PPC_MUL(d, a, b) EMIT(PPC_INST_MULLW | ___PPC_RT(d) | \
118 __PPC_RA(a) | __PPC_RB(b)) 118 ___PPC_RA(a) | ___PPC_RB(b))
119#define PPC_MULHWU(d, a, b) EMIT(PPC_INST_MULHWU | __PPC_RT(d) | \ 119#define PPC_MULHWU(d, a, b) EMIT(PPC_INST_MULHWU | ___PPC_RT(d) | \
120 __PPC_RA(a) | __PPC_RB(b)) 120 ___PPC_RA(a) | ___PPC_RB(b))
121#define PPC_MULI(d, a, i) EMIT(PPC_INST_MULLI | __PPC_RT(d) | \ 121#define PPC_MULI(d, a, i) EMIT(PPC_INST_MULLI | ___PPC_RT(d) | \
122 __PPC_RA(a) | IMM_L(i)) 122 ___PPC_RA(a) | IMM_L(i))
123#define PPC_DIVWU(d, a, b) EMIT(PPC_INST_DIVWU | __PPC_RT(d) | \ 123#define PPC_DIVWU(d, a, b) EMIT(PPC_INST_DIVWU | ___PPC_RT(d) | \
124 __PPC_RA(a) | __PPC_RB(b)) 124 ___PPC_RA(a) | ___PPC_RB(b))
125#define PPC_AND(d, a, b) EMIT(PPC_INST_AND | __PPC_RA(d) | \ 125#define PPC_AND(d, a, b) EMIT(PPC_INST_AND | ___PPC_RA(d) | \
126 __PPC_RS(a) | __PPC_RB(b)) 126 ___PPC_RS(a) | ___PPC_RB(b))
127#define PPC_ANDI(d, a, i) EMIT(PPC_INST_ANDI | __PPC_RA(d) | \ 127#define PPC_ANDI(d, a, i) EMIT(PPC_INST_ANDI | ___PPC_RA(d) | \
128 __PPC_RS(a) | IMM_L(i)) 128 ___PPC_RS(a) | IMM_L(i))
129#define PPC_AND_DOT(d, a, b) EMIT(PPC_INST_ANDDOT | __PPC_RA(d) | \ 129#define PPC_AND_DOT(d, a, b) EMIT(PPC_INST_ANDDOT | ___PPC_RA(d) | \
130 __PPC_RS(a) | __PPC_RB(b)) 130 ___PPC_RS(a) | ___PPC_RB(b))
131#define PPC_OR(d, a, b) EMIT(PPC_INST_OR | __PPC_RA(d) | \ 131#define PPC_OR(d, a, b) EMIT(PPC_INST_OR | ___PPC_RA(d) | \
132 __PPC_RS(a) | __PPC_RB(b)) 132 ___PPC_RS(a) | ___PPC_RB(b))
133#define PPC_ORI(d, a, i) EMIT(PPC_INST_ORI | __PPC_RA(d) | \ 133#define PPC_ORI(d, a, i) EMIT(PPC_INST_ORI | ___PPC_RA(d) | \
134 __PPC_RS(a) | IMM_L(i)) 134 ___PPC_RS(a) | IMM_L(i))
135#define PPC_ORIS(d, a, i) EMIT(PPC_INST_ORIS | __PPC_RA(d) | \ 135#define PPC_ORIS(d, a, i) EMIT(PPC_INST_ORIS | ___PPC_RA(d) | \
136 __PPC_RS(a) | IMM_L(i)) 136 ___PPC_RS(a) | IMM_L(i))
137#define PPC_SLW(d, a, s) EMIT(PPC_INST_SLW | __PPC_RA(d) | \ 137#define PPC_SLW(d, a, s) EMIT(PPC_INST_SLW | ___PPC_RA(d) | \
138 __PPC_RS(a) | __PPC_RB(s)) 138 ___PPC_RS(a) | ___PPC_RB(s))
139#define PPC_SRW(d, a, s) EMIT(PPC_INST_SRW | __PPC_RA(d) | \ 139#define PPC_SRW(d, a, s) EMIT(PPC_INST_SRW | ___PPC_RA(d) | \
140 __PPC_RS(a) | __PPC_RB(s)) 140 ___PPC_RS(a) | ___PPC_RB(s))
141/* slwi = rlwinm Rx, Ry, n, 0, 31-n */ 141/* slwi = rlwinm Rx, Ry, n, 0, 31-n */
142#define PPC_SLWI(d, a, i) EMIT(PPC_INST_RLWINM | __PPC_RA(d) | \ 142#define PPC_SLWI(d, a, i) EMIT(PPC_INST_RLWINM | ___PPC_RA(d) | \
143 __PPC_RS(a) | __PPC_SH(i) | \ 143 ___PPC_RS(a) | __PPC_SH(i) | \
144 __PPC_MB(0) | __PPC_ME(31-(i))) 144 __PPC_MB(0) | __PPC_ME(31-(i)))
145/* srwi = rlwinm Rx, Ry, 32-n, n, 31 */ 145/* srwi = rlwinm Rx, Ry, 32-n, n, 31 */
146#define PPC_SRWI(d, a, i) EMIT(PPC_INST_RLWINM | __PPC_RA(d) | \ 146#define PPC_SRWI(d, a, i) EMIT(PPC_INST_RLWINM | ___PPC_RA(d) | \
147 __PPC_RS(a) | __PPC_SH(32-(i)) | \ 147 ___PPC_RS(a) | __PPC_SH(32-(i)) | \
148 __PPC_MB(i) | __PPC_ME(31)) 148 __PPC_MB(i) | __PPC_ME(31))
149/* sldi = rldicr Rx, Ry, n, 63-n */ 149/* sldi = rldicr Rx, Ry, n, 63-n */
150#define PPC_SLDI(d, a, i) EMIT(PPC_INST_RLDICR | __PPC_RA(d) | \ 150#define PPC_SLDI(d, a, i) EMIT(PPC_INST_RLDICR | ___PPC_RA(d) | \
151 __PPC_RS(a) | __PPC_SH(i) | \ 151 ___PPC_RS(a) | __PPC_SH(i) | \
152 __PPC_MB(63-(i)) | (((i) & 0x20) >> 4)) 152 __PPC_MB(63-(i)) | (((i) & 0x20) >> 4))
153#define PPC_NEG(d, a) EMIT(PPC_INST_NEG | __PPC_RT(d) | __PPC_RA(a)) 153#define PPC_NEG(d, a) EMIT(PPC_INST_NEG | ___PPC_RT(d) | ___PPC_RA(a))
154 154
155/* Long jump; (unconditional 'branch') */ 155/* Long jump; (unconditional 'branch') */
156#define PPC_JMP(dest) EMIT(PPC_INST_BRANCH | \ 156#define PPC_JMP(dest) EMIT(PPC_INST_BRANCH | \
diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
index 2dc8b148484..dd1130642d0 100644
--- a/arch/powerpc/net/bpf_jit_comp.c
+++ b/arch/powerpc/net/bpf_jit_comp.c
@@ -39,7 +39,7 @@ static void bpf_jit_build_prologue(struct sk_filter *fp, u32 *image,
39 /* Make stackframe */ 39 /* Make stackframe */
40 if (ctx->seen & SEEN_DATAREF) { 40 if (ctx->seen & SEEN_DATAREF) {
41 /* If we call any helpers (for loads), save LR */ 41 /* If we call any helpers (for loads), save LR */
42 EMIT(PPC_INST_MFLR | __PPC_RT(0)); 42 EMIT(PPC_INST_MFLR | __PPC_RT(R0));
43 PPC_STD(0, 1, 16); 43 PPC_STD(0, 1, 16);
44 44
45 /* Back up non-volatile regs. */ 45 /* Back up non-volatile regs. */
@@ -56,7 +56,7 @@ static void bpf_jit_build_prologue(struct sk_filter *fp, u32 *image,
56 PPC_STD(i, 1, -(8*(32-i))); 56 PPC_STD(i, 1, -(8*(32-i)));
57 } 57 }
58 } 58 }
59 EMIT(PPC_INST_STDU | __PPC_RS(1) | __PPC_RA(1) | 59 EMIT(PPC_INST_STDU | __PPC_RS(R1) | __PPC_RA(R1) |
60 (-BPF_PPC_STACKFRAME & 0xfffc)); 60 (-BPF_PPC_STACKFRAME & 0xfffc));
61 } 61 }
62 62
diff --git a/arch/powerpc/perf/callchain.c b/arch/powerpc/perf/callchain.c
index e8a18d1cc7c..74d1e780748 100644
--- a/arch/powerpc/perf/callchain.c
+++ b/arch/powerpc/perf/callchain.c
@@ -57,7 +57,7 @@ perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
57 57
58 lr = regs->link; 58 lr = regs->link;
59 sp = regs->gpr[1]; 59 sp = regs->gpr[1];
60 perf_callchain_store(entry, regs->nip); 60 perf_callchain_store(entry, perf_instruction_pointer(regs));
61 61
62 if (!validate_sp(sp, current, STACK_FRAME_OVERHEAD)) 62 if (!validate_sp(sp, current, STACK_FRAME_OVERHEAD))
63 return; 63 return;
@@ -238,7 +238,7 @@ static void perf_callchain_user_64(struct perf_callchain_entry *entry,
238 struct signal_frame_64 __user *sigframe; 238 struct signal_frame_64 __user *sigframe;
239 unsigned long __user *fp, *uregs; 239 unsigned long __user *fp, *uregs;
240 240
241 next_ip = regs->nip; 241 next_ip = perf_instruction_pointer(regs);
242 lr = regs->link; 242 lr = regs->link;
243 sp = regs->gpr[1]; 243 sp = regs->gpr[1];
244 perf_callchain_store(entry, next_ip); 244 perf_callchain_store(entry, next_ip);
@@ -444,7 +444,7 @@ static void perf_callchain_user_32(struct perf_callchain_entry *entry,
444 long level = 0; 444 long level = 0;
445 unsigned int __user *fp, *uregs; 445 unsigned int __user *fp, *uregs;
446 446
447 next_ip = regs->nip; 447 next_ip = perf_instruction_pointer(regs);
448 lr = regs->link; 448 lr = regs->link;
449 sp = regs->gpr[1]; 449 sp = regs->gpr[1];
450 perf_callchain_store(entry, next_ip); 450 perf_callchain_store(entry, next_ip);
diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index 8f84bcba18d..7cd2dbd6e4c 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -73,7 +73,10 @@ static inline u32 perf_get_misc_flags(struct pt_regs *regs)
73{ 73{
74 return 0; 74 return 0;
75} 75}
76static inline void perf_read_regs(struct pt_regs *regs) { } 76static inline void perf_read_regs(struct pt_regs *regs)
77{
78 regs->result = 0;
79}
77static inline int perf_intr_is_nmi(struct pt_regs *regs) 80static inline int perf_intr_is_nmi(struct pt_regs *regs)
78{ 81{
79 return 0; 82 return 0;
@@ -116,6 +119,26 @@ static inline void perf_get_data_addr(struct pt_regs *regs, u64 *addrp)
116 *addrp = mfspr(SPRN_SDAR); 119 *addrp = mfspr(SPRN_SDAR);
117} 120}
118 121
122static bool mmcra_sihv(unsigned long mmcra)
123{
124 unsigned long sihv = MMCRA_SIHV;
125
126 if (ppmu->flags & PPMU_ALT_SIPR)
127 sihv = POWER6_MMCRA_SIHV;
128
129 return !!(mmcra & sihv);
130}
131
132static bool mmcra_sipr(unsigned long mmcra)
133{
134 unsigned long sipr = MMCRA_SIPR;
135
136 if (ppmu->flags & PPMU_ALT_SIPR)
137 sipr = POWER6_MMCRA_SIPR;
138
139 return !!(mmcra & sipr);
140}
141
119static inline u32 perf_flags_from_msr(struct pt_regs *regs) 142static inline u32 perf_flags_from_msr(struct pt_regs *regs)
120{ 143{
121 if (regs->msr & MSR_PR) 144 if (regs->msr & MSR_PR)
@@ -128,19 +151,9 @@ static inline u32 perf_flags_from_msr(struct pt_regs *regs)
128static inline u32 perf_get_misc_flags(struct pt_regs *regs) 151static inline u32 perf_get_misc_flags(struct pt_regs *regs)
129{ 152{
130 unsigned long mmcra = regs->dsisr; 153 unsigned long mmcra = regs->dsisr;
131 unsigned long sihv = MMCRA_SIHV; 154 unsigned long use_siar = regs->result;
132 unsigned long sipr = MMCRA_SIPR;
133 155
134 /* Not a PMU interrupt: Make up flags from regs->msr */ 156 if (!use_siar)
135 if (TRAP(regs) != 0xf00)
136 return perf_flags_from_msr(regs);
137
138 /*
139 * If we don't support continuous sampling and this
140 * is not a marked event, same deal
141 */
142 if ((ppmu->flags & PPMU_NO_CONT_SAMPLING) &&
143 !(mmcra & MMCRA_SAMPLE_ENABLE))
144 return perf_flags_from_msr(regs); 157 return perf_flags_from_msr(regs);
145 158
146 /* 159 /*
@@ -156,15 +169,10 @@ static inline u32 perf_get_misc_flags(struct pt_regs *regs)
156 return PERF_RECORD_MISC_USER; 169 return PERF_RECORD_MISC_USER;
157 } 170 }
158 171
159 if (ppmu->flags & PPMU_ALT_SIPR) {
160 sihv = POWER6_MMCRA_SIHV;
161 sipr = POWER6_MMCRA_SIPR;
162 }
163
164 /* PR has priority over HV, so order below is important */ 172 /* PR has priority over HV, so order below is important */
165 if (mmcra & sipr) 173 if (mmcra_sipr(mmcra))
166 return PERF_RECORD_MISC_USER; 174 return PERF_RECORD_MISC_USER;
167 if ((mmcra & sihv) && (freeze_events_kernel != MMCR0_FCHV)) 175 if (mmcra_sihv(mmcra) && (freeze_events_kernel != MMCR0_FCHV))
168 return PERF_RECORD_MISC_HYPERVISOR; 176 return PERF_RECORD_MISC_HYPERVISOR;
169 return PERF_RECORD_MISC_KERNEL; 177 return PERF_RECORD_MISC_KERNEL;
170} 178}
@@ -172,10 +180,45 @@ static inline u32 perf_get_misc_flags(struct pt_regs *regs)
172/* 180/*
173 * Overload regs->dsisr to store MMCRA so we only need to read it once 181 * Overload regs->dsisr to store MMCRA so we only need to read it once
174 * on each interrupt. 182 * on each interrupt.
183 * Overload regs->result to specify whether we should use the MSR (result
184 * is zero) or the SIAR (result is non zero).
175 */ 185 */
176static inline void perf_read_regs(struct pt_regs *regs) 186static inline void perf_read_regs(struct pt_regs *regs)
177{ 187{
178 regs->dsisr = mfspr(SPRN_MMCRA); 188 unsigned long mmcra = mfspr(SPRN_MMCRA);
189 int marked = mmcra & MMCRA_SAMPLE_ENABLE;
190 int use_siar;
191
192 /*
193 * If this isn't a PMU exception (eg a software event) the SIAR is
194 * not valid. Use pt_regs.
195 *
196 * If it is a marked event use the SIAR.
197 *
198 * If the PMU doesn't update the SIAR for non marked events use
199 * pt_regs.
200 *
201 * If the PMU has HV/PR flags then check to see if they
202 * place the exception in userspace. If so, use pt_regs. In
203 * continuous sampling mode the SIAR and the PMU exception are
204 * not synchronised, so they may be many instructions apart.
205 * This can result in confusing backtraces. We still want
206 * hypervisor samples as well as samples in the kernel with
207 * interrupts off hence the userspace check.
208 */
209 if (TRAP(regs) != 0xf00)
210 use_siar = 0;
211 else if (marked)
212 use_siar = 1;
213 else if ((ppmu->flags & PPMU_NO_CONT_SAMPLING))
214 use_siar = 0;
215 else if (!(ppmu->flags & PPMU_NO_SIPR) && mmcra_sipr(mmcra))
216 use_siar = 0;
217 else
218 use_siar = 1;
219
220 regs->dsisr = mmcra;
221 regs->result = use_siar;
179} 222}
180 223
181/* 224/*
@@ -1329,18 +1372,12 @@ unsigned long perf_misc_flags(struct pt_regs *regs)
1329 */ 1372 */
1330unsigned long perf_instruction_pointer(struct pt_regs *regs) 1373unsigned long perf_instruction_pointer(struct pt_regs *regs)
1331{ 1374{
1332 unsigned long mmcra = regs->dsisr; 1375 unsigned long use_siar = regs->result;
1333 1376
1334 /* Not a PMU interrupt */ 1377 if (use_siar)
1335 if (TRAP(regs) != 0xf00) 1378 return mfspr(SPRN_SIAR) + perf_ip_adjust(regs);
1336 return regs->nip; 1379 else
1337
1338 /* Processor doesn't support sampling non marked events */
1339 if ((ppmu->flags & PPMU_NO_CONT_SAMPLING) &&
1340 !(mmcra & MMCRA_SAMPLE_ENABLE))
1341 return regs->nip; 1380 return regs->nip;
1342
1343 return mfspr(SPRN_SIAR) + perf_ip_adjust(regs);
1344} 1381}
1345 1382
1346static bool pmc_overflow(unsigned long val) 1383static bool pmc_overflow(unsigned long val)
@@ -1394,7 +1431,7 @@ static void perf_event_interrupt(struct pt_regs *regs)
1394 if (!event->hw.idx || is_limited_pmc(event->hw.idx)) 1431 if (!event->hw.idx || is_limited_pmc(event->hw.idx))
1395 continue; 1432 continue;
1396 val = read_pmc(event->hw.idx); 1433 val = read_pmc(event->hw.idx);
1397 if ((int)val < 0) { 1434 if (pmc_overflow(val)) {
1398 /* event has overflowed */ 1435 /* event has overflowed */
1399 found = 1; 1436 found = 1;
1400 record_and_restart(event, val, regs); 1437 record_and_restart(event, val, regs);
diff --git a/arch/powerpc/platforms/44x/currituck.c b/arch/powerpc/platforms/44x/currituck.c
index 583e67fee37..9f6c33d63a4 100644
--- a/arch/powerpc/platforms/44x/currituck.c
+++ b/arch/powerpc/platforms/44x/currituck.c
@@ -160,7 +160,7 @@ static void __init ppc47x_setup_arch(void)
160 /* No need to check the DMA config as we /know/ our windows are all of 160 /* No need to check the DMA config as we /know/ our windows are all of
161 * RAM. Lets hope that doesn't change */ 161 * RAM. Lets hope that doesn't change */
162#ifdef CONFIG_SWIOTLB 162#ifdef CONFIG_SWIOTLB
163 if (memblock_end_of_DRAM() > 0xffffffff) { 163 if ((memblock_end_of_DRAM() - 1) > 0xffffffff) {
164 ppc_swiotlb_enable = 1; 164 ppc_swiotlb_enable = 1;
165 set_pci_dma_ops(&swiotlb_dma_ops); 165 set_pci_dma_ops(&swiotlb_dma_ops);
166 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; 166 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
diff --git a/arch/powerpc/platforms/82xx/km82xx.c b/arch/powerpc/platforms/82xx/km82xx.c
index 3661bcdc326..cf964e19573 100644
--- a/arch/powerpc/platforms/82xx/km82xx.c
+++ b/arch/powerpc/platforms/82xx/km82xx.c
@@ -128,6 +128,11 @@ static __initdata struct cpm_pin km82xx_pins[] = {
128 {3, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, /* TXP */ 128 {3, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, /* TXP */
129 {3, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, /* TXN */ 129 {3, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, /* TXN */
130 {3, 25, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* RXD */ 130 {3, 25, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* RXD */
131
132 /* SPI */
133 {3, 16, CPM_PIN_INPUT | CPM_PIN_SECONDARY},/* SPI_MISO PD16 */
134 {3, 17, CPM_PIN_INPUT | CPM_PIN_SECONDARY},/* SPI_MOSI PD17 */
135 {3, 18, CPM_PIN_INPUT | CPM_PIN_SECONDARY},/* SPI_CLK PD18 */
131}; 136};
132 137
133static void __init init_ioports(void) 138static void __init init_ioports(void)
diff --git a/arch/powerpc/platforms/83xx/km83xx.c b/arch/powerpc/platforms/83xx/km83xx.c
index a266ba87686..89923d72334 100644
--- a/arch/powerpc/platforms/83xx/km83xx.c
+++ b/arch/powerpc/platforms/83xx/km83xx.c
@@ -3,7 +3,7 @@
3 * Author: Heiko Schocher <hs@denx.de> 3 * Author: Heiko Schocher <hs@denx.de>
4 * 4 *
5 * Description: 5 * Description:
6 * Keymile KMETER1 board specific routines. 6 * Keymile 83xx platform specific routines.
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify it 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 9 * under the terms of the GNU General Public License as published by the
@@ -70,54 +70,88 @@ static void __init mpc83xx_km_setup_arch(void)
70 for_each_node_by_name(np, "spi") 70 for_each_node_by_name(np, "spi")
71 par_io_of_config(np); 71 par_io_of_config(np);
72 72
73 for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;) 73 for_each_node_by_name(np, "ucc")
74 par_io_of_config(np); 74 par_io_of_config(np);
75 } 75 }
76 76
77 np = of_find_compatible_node(NULL, "network", "ucc_geth"); 77 np = of_find_compatible_node(NULL, "network", "ucc_geth");
78 if (np != NULL) { 78 if (np != NULL) {
79 uint svid; 79 /*
80 * handle mpc8360E Erratum QE_ENET10:
81 * RGMII AC values do not meet the specification
82 */
83 uint svid = mfspr(SPRN_SVR);
84 struct device_node *np_par;
85 struct resource res;
86 void __iomem *base;
87 int ret;
88
89 np_par = of_find_node_by_name(NULL, "par_io");
90 if (np_par == NULL) {
91 printk(KERN_WARNING "%s couldn;t find par_io node\n",
92 __func__);
93 return;
94 }
95 /* Map Parallel I/O ports registers */
96 ret = of_address_to_resource(np_par, 0, &res);
97 if (ret) {
98 printk(KERN_WARNING "%s couldn;t map par_io registers\n",
99 __func__);
100 return;
101 }
102
103 base = ioremap(res.start, res.end - res.start + 1);
104
105 /*
106 * set output delay adjustments to default values according
107 * table 5 in Errata Rev. 5, 9/2011:
108 *
109 * write 0b01 to UCC1 bits 18:19
110 * write 0b01 to UCC2 option 1 bits 4:5
111 * write 0b01 to UCC2 option 2 bits 16:17
112 */
113 clrsetbits_be32((base + 0xa8), 0x0c00f000, 0x04005000);
114
115 /*
116 * set output delay adjustments to default values according
117 * table 3-13 in Reference Manual Rev.3 05/2010:
118 *
119 * write 0b01 to UCC2 option 2 bits 16:17
120 * write 0b0101 to UCC1 bits 20:23
121 * write 0b0101 to UCC2 option 1 bits 24:27
122 */
123 clrsetbits_be32((base + 0xac), 0x0000cff0, 0x00004550);
80 124
81 /* handle mpc8360ea rev.2.1 erratum 2: RGMII Timing */
82 svid = mfspr(SPRN_SVR);
83 if (SVR_REV(svid) == 0x0021) { 125 if (SVR_REV(svid) == 0x0021) {
84 struct device_node *np_par; 126 /*
85 struct resource res; 127 * UCC2 option 1: write 0b1010 to bits 24:27
86 void __iomem *base; 128 * at address IMMRBAR+0x14AC
87 int ret; 129 */
88 130 clrsetbits_be32((base + 0xac), 0x000000f0, 0x000000a0);
89 np_par = of_find_node_by_name(NULL, "par_io"); 131 } else if (SVR_REV(svid) == 0x0020) {
90 if (np_par == NULL) { 132 /*
91 printk(KERN_WARNING "%s couldn;t find par_io node\n", 133 * UCC1: write 0b11 to bits 18:19
92 __func__); 134 * at address IMMRBAR+0x14A8
93 return; 135 */
94 } 136 setbits32((base + 0xa8), 0x00003000);
95 /* Map Parallel I/O ports registers */
96 ret = of_address_to_resource(np_par, 0, &res);
97 if (ret) {
98 printk(KERN_WARNING "%s couldn;t map par_io registers\n",
99 __func__);
100 return;
101 }
102 base = ioremap(res.start, resource_size(&res));
103 137
104 /* 138 /*
105 * IMMR + 0x14A8[4:5] = 11 (clk delay for UCC 2) 139 * UCC2 option 1: write 0b11 to bits 4:5
106 * IMMR + 0x14A8[18:19] = 11 (clk delay for UCC 1) 140 * at address IMMRBAR+0x14A8
107 */ 141 */
108 setbits32((base + 0xa8), 0x0c003000); 142 setbits32((base + 0xa8), 0x0c000000);
109 143
110 /* 144 /*
111 * IMMR + 0x14AC[20:27] = 10101010 145 * UCC2 option 2: write 0b11 to bits 16:17
112 * (data delay for both UCC's) 146 * at address IMMRBAR+0x14AC
113 */ 147 */
114 clrsetbits_be32((base + 0xac), 0xff0, 0xaa0); 148 setbits32((base + 0xac), 0x0000c000);
115 iounmap(base);
116 of_node_put(np_par);
117 } 149 }
150 iounmap(base);
151 of_node_put(np_par);
118 of_node_put(np); 152 of_node_put(np);
119 } 153 }
120#endif /* CONFIG_QUICC_ENGINE */ 154#endif /* CONFIG_QUICC_ENGINE */
121} 155}
122 156
123machine_device_initcall(mpc83xx_km, mpc83xx_declare_of_platform_devices); 157machine_device_initcall(mpc83xx_km, mpc83xx_declare_of_platform_devices);
diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig
index f000d81c4e3..159c01e9146 100644
--- a/arch/powerpc/platforms/85xx/Kconfig
+++ b/arch/powerpc/platforms/85xx/Kconfig
@@ -23,6 +23,15 @@ config FSL_85XX_CACHE_SRAM
23 cache-sram-size and cache-sram-offset kernel boot 23 cache-sram-size and cache-sram-offset kernel boot
24 parameters should be passed when this option is enabled. 24 parameters should be passed when this option is enabled.
25 25
26config BSC9131_RDB
27 bool "Freescale BSC9131RDB"
28 select DEFAULT_UIMAGE
29 help
30 This option enables support for the Freescale BSC9131RDB board.
31 The BSC9131 is a heterogeneous SoC containing an e500v2 powerpc and a
32 StarCore SC3850 DSP
33 Manufacturer : Freescale Semiconductor, Inc
34
26config MPC8540_ADS 35config MPC8540_ADS
27 bool "Freescale MPC8540 ADS" 36 bool "Freescale MPC8540 ADS"
28 select DEFAULT_UIMAGE 37 select DEFAULT_UIMAGE
@@ -175,12 +184,6 @@ config SBC8548
175 help 184 help
176 This option enables support for the Wind River SBC8548 board 185 This option enables support for the Wind River SBC8548 board
177 186
178config SBC8560
179 bool "Wind River SBC8560"
180 select DEFAULT_UIMAGE
181 help
182 This option enables support for the Wind River SBC8560 board
183
184config GE_IMP3A 187config GE_IMP3A
185 bool "GE Intelligent Platforms IMP3A" 188 bool "GE Intelligent Platforms IMP3A"
186 select DEFAULT_UIMAGE 189 select DEFAULT_UIMAGE
@@ -222,18 +225,6 @@ config P3041_DS
222 help 225 help
223 This option enables support for the P3041 DS board 226 This option enables support for the P3041 DS board
224 227
225config P3060_QDS
226 bool "Freescale P3060 QDS"
227 select DEFAULT_UIMAGE
228 select PPC_E500MC
229 select PHYS_64BIT
230 select SWIOTLB
231 select GPIO_MPC8XXX
232 select HAS_RAPIDIO
233 select PPC_EPAPR_HV_PIC
234 help
235 This option enables support for the P3060 QDS board
236
237config P4080_DS 228config P4080_DS
238 bool "Freescale P4080 DS" 229 bool "Freescale P4080 DS"
239 select DEFAULT_UIMAGE 230 select DEFAULT_UIMAGE
@@ -263,6 +254,22 @@ config P5020_DS
263 help 254 help
264 This option enables support for the P5020 DS board 255 This option enables support for the P5020 DS board
265 256
257config PPC_QEMU_E500
258 bool "QEMU generic e500 platform"
259 depends on EXPERIMENTAL
260 select DEFAULT_UIMAGE
261 help
262 This option enables support for running as a QEMU guest using
263 QEMU's generic e500 machine. This is not required if you're
264 using a QEMU machine that targets a specific board, such as
265 mpc8544ds.
266
267 Unlike most e500 boards that target a specific CPU, this
268 platform works with any e500-family CPU that QEMU supports.
269 Thus, you'll need to make sure CONFIG_PPC_E500MC is set or
270 unset based on the emulated CPU (or actual host CPU in the case
271 of KVM).
272
266endif # FSL_SOC_BOOKE 273endif # FSL_SOC_BOOKE
267 274
268config TQM85xx 275config TQM85xx
diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index 2125d4ca068..3dfe8117503 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_SMP) += smp.o
5 5
6obj-y += common.o 6obj-y += common.o
7 7
8obj-$(CONFIG_BSC9131_RDB) += bsc913x_rdb.o
8obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o 9obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o
9obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o 10obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o
10obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o 11obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o
@@ -17,14 +18,13 @@ obj-$(CONFIG_P1022_DS) += p1022_ds.o
17obj-$(CONFIG_P1023_RDS) += p1023_rds.o 18obj-$(CONFIG_P1023_RDS) += p1023_rds.o
18obj-$(CONFIG_P2041_RDB) += p2041_rdb.o corenet_ds.o 19obj-$(CONFIG_P2041_RDB) += p2041_rdb.o corenet_ds.o
19obj-$(CONFIG_P3041_DS) += p3041_ds.o corenet_ds.o 20obj-$(CONFIG_P3041_DS) += p3041_ds.o corenet_ds.o
20obj-$(CONFIG_P3060_QDS) += p3060_qds.o corenet_ds.o
21obj-$(CONFIG_P4080_DS) += p4080_ds.o corenet_ds.o 21obj-$(CONFIG_P4080_DS) += p4080_ds.o corenet_ds.o
22obj-$(CONFIG_P5020_DS) += p5020_ds.o corenet_ds.o 22obj-$(CONFIG_P5020_DS) += p5020_ds.o corenet_ds.o
23obj-$(CONFIG_STX_GP3) += stx_gp3.o 23obj-$(CONFIG_STX_GP3) += stx_gp3.o
24obj-$(CONFIG_TQM85xx) += tqm85xx.o 24obj-$(CONFIG_TQM85xx) += tqm85xx.o
25obj-$(CONFIG_SBC8560) += sbc8560.o
26obj-$(CONFIG_SBC8548) += sbc8548.o 25obj-$(CONFIG_SBC8548) += sbc8548.o
27obj-$(CONFIG_SOCRATES) += socrates.o socrates_fpga_pic.o 26obj-$(CONFIG_SOCRATES) += socrates.o socrates_fpga_pic.o
28obj-$(CONFIG_KSI8560) += ksi8560.o 27obj-$(CONFIG_KSI8560) += ksi8560.o
29obj-$(CONFIG_XES_MPC85xx) += xes_mpc85xx.o 28obj-$(CONFIG_XES_MPC85xx) += xes_mpc85xx.o
30obj-$(CONFIG_GE_IMP3A) += ge_imp3a.o 29obj-$(CONFIG_GE_IMP3A) += ge_imp3a.o
30obj-$(CONFIG_PPC_QEMU_E500) += qemu_e500.o
diff --git a/arch/powerpc/platforms/85xx/bsc913x_rdb.c b/arch/powerpc/platforms/85xx/bsc913x_rdb.c
new file mode 100644
index 00000000000..9d57bedb940
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/bsc913x_rdb.c
@@ -0,0 +1,67 @@
1/*
2 * BSC913xRDB Board Setup
3 *
4 * Author: Priyanka Jain <Priyanka.Jain@freescale.com>
5 *
6 * Copyright 2011-2012 Freescale Semiconductor Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/of_platform.h>
15#include <linux/pci.h>
16#include <asm/mpic.h>
17#include <sysdev/fsl_soc.h>
18#include <asm/udbg.h>
19
20#include "mpc85xx.h"
21
22void __init bsc913x_rdb_pic_init(void)
23{
24 struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
25 MPIC_SINGLE_DEST_CPU,
26 0, 256, " OpenPIC ");
27
28 if (!mpic)
29 pr_err("bsc913x: Failed to allocate MPIC structure\n");
30 else
31 mpic_init(mpic);
32}
33
34/*
35 * Setup the architecture
36 */
37static void __init bsc913x_rdb_setup_arch(void)
38{
39 if (ppc_md.progress)
40 ppc_md.progress("bsc913x_rdb_setup_arch()", 0);
41
42 pr_info("bsc913x board from Freescale Semiconductor\n");
43}
44
45machine_device_initcall(bsc9131_rdb, mpc85xx_common_publish_devices);
46
47/*
48 * Called very early, device-tree isn't unflattened
49 */
50
51static int __init bsc9131_rdb_probe(void)
52{
53 unsigned long root = of_get_flat_dt_root();
54
55 return of_flat_dt_is_compatible(root, "fsl,bsc9131rdb");
56}
57
58define_machine(bsc9131_rdb) {
59 .name = "BSC9131 RDB",
60 .probe = bsc9131_rdb_probe,
61 .setup_arch = bsc913x_rdb_setup_arch,
62 .init_IRQ = bsc913x_rdb_pic_init,
63 .get_irq = mpic_get_irq,
64 .restart = fsl_rstcr_restart,
65 .calibrate_decr = generic_calibrate_decr,
66 .progress = udbg_progress,
67};
diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c b/arch/powerpc/platforms/85xx/corenet_ds.c
index dd3617c531d..925b0287423 100644
--- a/arch/powerpc/platforms/85xx/corenet_ds.c
+++ b/arch/powerpc/platforms/85xx/corenet_ds.c
@@ -77,7 +77,7 @@ void __init corenet_ds_setup_arch(void)
77#endif 77#endif
78 78
79#ifdef CONFIG_SWIOTLB 79#ifdef CONFIG_SWIOTLB
80 if (memblock_end_of_DRAM() > max) { 80 if ((memblock_end_of_DRAM() - 1) > max) {
81 ppc_swiotlb_enable = 1; 81 ppc_swiotlb_enable = 1;
82 set_pci_dma_ops(&swiotlb_dma_ops); 82 set_pci_dma_ops(&swiotlb_dma_ops);
83 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; 83 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
diff --git a/arch/powerpc/platforms/85xx/ge_imp3a.c b/arch/powerpc/platforms/85xx/ge_imp3a.c
index 18014629416..b6a728b0a8c 100644
--- a/arch/powerpc/platforms/85xx/ge_imp3a.c
+++ b/arch/powerpc/platforms/85xx/ge_imp3a.c
@@ -125,7 +125,7 @@ static void __init ge_imp3a_setup_arch(void)
125 mpc85xx_smp_init(); 125 mpc85xx_smp_init();
126 126
127#ifdef CONFIG_SWIOTLB 127#ifdef CONFIG_SWIOTLB
128 if (memblock_end_of_DRAM() > max) { 128 if ((memblock_end_of_DRAM() - 1) > max) {
129 ppc_swiotlb_enable = 1; 129 ppc_swiotlb_enable = 1;
130 set_pci_dma_ops(&swiotlb_dma_ops); 130 set_pci_dma_ops(&swiotlb_dma_ops);
131 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; 131 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index 585bd22b140..767c7cf18a9 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -75,7 +75,7 @@ static void __init mpc8536_ds_setup_arch(void)
75#endif 75#endif
76 76
77#ifdef CONFIG_SWIOTLB 77#ifdef CONFIG_SWIOTLB
78 if (memblock_end_of_DRAM() > max) { 78 if ((memblock_end_of_DRAM() - 1) > max) {
79 ppc_swiotlb_enable = 1; 79 ppc_swiotlb_enable = 1;
80 set_pci_dma_ops(&swiotlb_dma_ops); 80 set_pci_dma_ops(&swiotlb_dma_ops);
81 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; 81 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 1fd91e9e0ff..6d3265fe771 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -114,71 +114,53 @@ void __init mpc85xx_ds_pic_init(void)
114} 114}
115 115
116#ifdef CONFIG_PCI 116#ifdef CONFIG_PCI
117static int primary_phb_addr;
118extern int uli_exclude_device(struct pci_controller *hose, 117extern int uli_exclude_device(struct pci_controller *hose,
119 u_char bus, u_char devfn); 118 u_char bus, u_char devfn);
120 119
120static struct device_node *pci_with_uli;
121
121static int mpc85xx_exclude_device(struct pci_controller *hose, 122static int mpc85xx_exclude_device(struct pci_controller *hose,
122 u_char bus, u_char devfn) 123 u_char bus, u_char devfn)
123{ 124{
124 struct device_node* node; 125 if (hose->dn == pci_with_uli)
125 struct resource rsrc;
126
127 node = hose->dn;
128 of_address_to_resource(node, 0, &rsrc);
129
130 if ((rsrc.start & 0xfffff) == primary_phb_addr) {
131 return uli_exclude_device(hose, bus, devfn); 126 return uli_exclude_device(hose, bus, devfn);
132 }
133 127
134 return PCIBIOS_SUCCESSFUL; 128 return PCIBIOS_SUCCESSFUL;
135} 129}
136#endif /* CONFIG_PCI */ 130#endif /* CONFIG_PCI */
137 131
138/* 132static void __init mpc85xx_ds_pci_init(void)
139 * Setup the architecture
140 */
141static void __init mpc85xx_ds_setup_arch(void)
142{ 133{
143#ifdef CONFIG_PCI 134#ifdef CONFIG_PCI
144 struct device_node *np; 135 struct device_node *node;
145 struct pci_controller *hose;
146#endif
147 dma_addr_t max = 0xffffffff;
148 136
149 if (ppc_md.progress) 137 fsl_pci_init();
150 ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
151 138
152#ifdef CONFIG_PCI 139 /* See if we have a ULI under the primary */
153 for_each_node_by_type(np, "pci") { 140
154 if (of_device_is_compatible(np, "fsl,mpc8540-pci") || 141 node = of_find_node_by_name(NULL, "uli1575");
155 of_device_is_compatible(np, "fsl,mpc8548-pcie") || 142 while ((pci_with_uli = of_get_parent(node))) {
156 of_device_is_compatible(np, "fsl,p2020-pcie")) { 143 of_node_put(node);
157 struct resource rsrc; 144 node = pci_with_uli;
158 of_address_to_resource(np, 0, &rsrc); 145
159 if ((rsrc.start & 0xfffff) == primary_phb_addr) 146 if (pci_with_uli == fsl_pci_primary) {
160 fsl_add_bridge(np, 1); 147 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
161 else 148 break;
162 fsl_add_bridge(np, 0);
163
164 hose = pci_find_hose_for_OF_device(np);
165 max = min(max, hose->dma_window_base_cur +
166 hose->dma_window_size);
167 } 149 }
168 } 150 }
169
170 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
171#endif 151#endif
152}
172 153
173 mpc85xx_smp_init(); 154/*
155 * Setup the architecture
156 */
157static void __init mpc85xx_ds_setup_arch(void)
158{
159 if (ppc_md.progress)
160 ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
174 161
175#ifdef CONFIG_SWIOTLB 162 mpc85xx_ds_pci_init();
176 if (memblock_end_of_DRAM() > max) { 163 mpc85xx_smp_init();
177 ppc_swiotlb_enable = 1;
178 set_pci_dma_ops(&swiotlb_dma_ops);
179 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
180 }
181#endif
182 164
183 printk("MPC85xx DS board from Freescale Semiconductor\n"); 165 printk("MPC85xx DS board from Freescale Semiconductor\n");
184} 166}
@@ -190,14 +172,7 @@ static int __init mpc8544_ds_probe(void)
190{ 172{
191 unsigned long root = of_get_flat_dt_root(); 173 unsigned long root = of_get_flat_dt_root();
192 174
193 if (of_flat_dt_is_compatible(root, "MPC8544DS")) { 175 return !!of_flat_dt_is_compatible(root, "MPC8544DS");
194#ifdef CONFIG_PCI
195 primary_phb_addr = 0xb000;
196#endif
197 return 1;
198 }
199
200 return 0;
201} 176}
202 177
203machine_device_initcall(mpc8544_ds, mpc85xx_common_publish_devices); 178machine_device_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
@@ -215,14 +190,7 @@ static int __init mpc8572_ds_probe(void)
215{ 190{
216 unsigned long root = of_get_flat_dt_root(); 191 unsigned long root = of_get_flat_dt_root();
217 192
218 if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS")) { 193 return !!of_flat_dt_is_compatible(root, "fsl,MPC8572DS");
219#ifdef CONFIG_PCI
220 primary_phb_addr = 0x8000;
221#endif
222 return 1;
223 }
224
225 return 0;
226} 194}
227 195
228/* 196/*
@@ -232,14 +200,7 @@ static int __init p2020_ds_probe(void)
232{ 200{
233 unsigned long root = of_get_flat_dt_root(); 201 unsigned long root = of_get_flat_dt_root();
234 202
235 if (of_flat_dt_is_compatible(root, "fsl,P2020DS")) { 203 return !!of_flat_dt_is_compatible(root, "fsl,P2020DS");
236#ifdef CONFIG_PCI
237 primary_phb_addr = 0x9000;
238#endif
239 return 1;
240 }
241
242 return 0;
243} 204}
244 205
245define_machine(mpc8544_ds) { 206define_machine(mpc8544_ds) {
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index d208ebccb91..8e4b094c553 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -359,7 +359,7 @@ static void __init mpc85xx_mds_setup_arch(void)
359 mpc85xx_mds_qe_init(); 359 mpc85xx_mds_qe_init();
360 360
361#ifdef CONFIG_SWIOTLB 361#ifdef CONFIG_SWIOTLB
362 if (memblock_end_of_DRAM() > max) { 362 if ((memblock_end_of_DRAM() - 1) > max) {
363 ppc_swiotlb_enable = 1; 363 ppc_swiotlb_enable = 1;
364 set_pci_dma_ops(&swiotlb_dma_ops); 364 set_pci_dma_ops(&swiotlb_dma_ops);
365 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; 365 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index 313fce4f557..1910fdcb75b 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -169,6 +169,7 @@ machine_device_initcall(p1020_rdb_pc, mpc85xx_common_publish_devices);
169machine_device_initcall(p1020_utm_pc, mpc85xx_common_publish_devices); 169machine_device_initcall(p1020_utm_pc, mpc85xx_common_publish_devices);
170machine_device_initcall(p1021_rdb_pc, mpc85xx_common_publish_devices); 170machine_device_initcall(p1021_rdb_pc, mpc85xx_common_publish_devices);
171machine_device_initcall(p1025_rdb, mpc85xx_common_publish_devices); 171machine_device_initcall(p1025_rdb, mpc85xx_common_publish_devices);
172machine_device_initcall(p1024_rdb, mpc85xx_common_publish_devices);
172 173
173/* 174/*
174 * Called very early, device-tree isn't unflattened 175 * Called very early, device-tree isn't unflattened
@@ -237,6 +238,13 @@ static int __init p1020_utm_pc_probe(void)
237 return of_flat_dt_is_compatible(root, "fsl,P1020UTM-PC"); 238 return of_flat_dt_is_compatible(root, "fsl,P1020UTM-PC");
238} 239}
239 240
241static int __init p1024_rdb_probe(void)
242{
243 unsigned long root = of_get_flat_dt_root();
244
245 return of_flat_dt_is_compatible(root, "fsl,P1024RDB");
246}
247
240define_machine(p2020_rdb) { 248define_machine(p2020_rdb) {
241 .name = "P2020 RDB", 249 .name = "P2020 RDB",
242 .probe = p2020_rdb_probe, 250 .probe = p2020_rdb_probe,
@@ -348,3 +356,17 @@ define_machine(p1020_rdb_pc) {
348 .calibrate_decr = generic_calibrate_decr, 356 .calibrate_decr = generic_calibrate_decr,
349 .progress = udbg_progress, 357 .progress = udbg_progress,
350}; 358};
359
360define_machine(p1024_rdb) {
361 .name = "P1024 RDB",
362 .probe = p1024_rdb_probe,
363 .setup_arch = mpc85xx_rdb_setup_arch,
364 .init_IRQ = mpc85xx_rdb_pic_init,
365#ifdef CONFIG_PCI
366 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
367#endif
368 .get_irq = mpic_get_irq,
369 .restart = fsl_rstcr_restart,
370 .calibrate_decr = generic_calibrate_decr,
371 .progress = udbg_progress,
372};
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index f700c81a132..3c732acf331 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -27,6 +27,7 @@
27#include <sysdev/fsl_pci.h> 27#include <sysdev/fsl_pci.h>
28#include <asm/udbg.h> 28#include <asm/udbg.h>
29#include <asm/fsl_guts.h> 29#include <asm/fsl_guts.h>
30#include <asm/fsl_lbc.h>
30#include "smp.h" 31#include "smp.h"
31 32
32#include "mpc85xx.h" 33#include "mpc85xx.h"
@@ -142,17 +143,74 @@ static void p1022ds_set_gamma_table(enum fsl_diu_monitor_port port,
142{ 143{
143} 144}
144 145
146struct fsl_law {
147 u32 lawbar;
148 u32 reserved1;
149 u32 lawar;
150 u32 reserved[5];
151};
152
153#define LAWBAR_MASK 0x00F00000
154#define LAWBAR_SHIFT 12
155
156#define LAWAR_EN 0x80000000
157#define LAWAR_TGT_MASK 0x01F00000
158#define LAW_TRGT_IF_LBC (0x04 << 20)
159
160#define LAWAR_MASK (LAWAR_EN | LAWAR_TGT_MASK)
161#define LAWAR_MATCH (LAWAR_EN | LAW_TRGT_IF_LBC)
162
163#define BR_BA 0xFFFF8000
164
165/*
166 * Map a BRx value to a physical address
167 *
168 * The localbus BRx registers only store the lower 32 bits of the address. To
169 * obtain the upper four bits, we need to scan the LAW table. The entry which
170 * maps to the localbus will contain the upper four bits.
171 */
172static phys_addr_t lbc_br_to_phys(const void *ecm, unsigned int count, u32 br)
173{
174#ifndef CONFIG_PHYS_64BIT
175 /*
176 * If we only have 32-bit addressing, then the BRx address *is* the
177 * physical address.
178 */
179 return br & BR_BA;
180#else
181 const struct fsl_law *law = ecm + 0xc08;
182 unsigned int i;
183
184 for (i = 0; i < count; i++) {
185 u64 lawbar = in_be32(&law[i].lawbar);
186 u32 lawar = in_be32(&law[i].lawar);
187
188 if ((lawar & LAWAR_MASK) == LAWAR_MATCH)
189 /* Extract the upper four bits */
190 return (br & BR_BA) | ((lawbar & LAWBAR_MASK) << 12);
191 }
192
193 return 0;
194#endif
195}
196
145/** 197/**
146 * p1022ds_set_monitor_port: switch the output to a different monitor port 198 * p1022ds_set_monitor_port: switch the output to a different monitor port
147 *
148 */ 199 */
149static void p1022ds_set_monitor_port(enum fsl_diu_monitor_port port) 200static void p1022ds_set_monitor_port(enum fsl_diu_monitor_port port)
150{ 201{
151 struct device_node *guts_node; 202 struct device_node *guts_node;
152 struct device_node *indirect_node = NULL; 203 struct device_node *lbc_node = NULL;
204 struct device_node *law_node = NULL;
153 struct ccsr_guts __iomem *guts; 205 struct ccsr_guts __iomem *guts;
206 struct fsl_lbc_regs *lbc = NULL;
207 void *ecm = NULL;
154 u8 __iomem *lbc_lcs0_ba = NULL; 208 u8 __iomem *lbc_lcs0_ba = NULL;
155 u8 __iomem *lbc_lcs1_ba = NULL; 209 u8 __iomem *lbc_lcs1_ba = NULL;
210 phys_addr_t cs0_addr, cs1_addr;
211 u32 br0, or0, br1, or1;
212 const __be32 *iprop;
213 unsigned int num_laws;
156 u8 b; 214 u8 b;
157 215
158 /* Map the global utilities registers. */ 216 /* Map the global utilities registers. */
@@ -168,22 +226,99 @@ static void p1022ds_set_monitor_port(enum fsl_diu_monitor_port port)
168 goto exit; 226 goto exit;
169 } 227 }
170 228
171 indirect_node = of_find_compatible_node(NULL, NULL, 229 lbc_node = of_find_compatible_node(NULL, NULL, "fsl,p1022-elbc");
172 "fsl,p1022ds-indirect-pixis"); 230 if (!lbc_node) {
173 if (!indirect_node) { 231 pr_err("p1022ds: missing localbus node\n");
174 pr_err("p1022ds: missing pixis indirect mode node\n");
175 goto exit; 232 goto exit;
176 } 233 }
177 234
178 lbc_lcs0_ba = of_iomap(indirect_node, 0); 235 lbc = of_iomap(lbc_node, 0);
179 if (!lbc_lcs0_ba) { 236 if (!lbc) {
180 pr_err("p1022ds: could not map localbus chip select 0\n"); 237 pr_err("p1022ds: could not map localbus node\n");
238 goto exit;
239 }
240
241 law_node = of_find_compatible_node(NULL, NULL, "fsl,ecm-law");
242 if (!law_node) {
243 pr_err("p1022ds: missing local access window node\n");
244 goto exit;
245 }
246
247 ecm = of_iomap(law_node, 0);
248 if (!ecm) {
249 pr_err("p1022ds: could not map local access window node\n");
250 goto exit;
251 }
252
253 iprop = of_get_property(law_node, "fsl,num-laws", 0);
254 if (!iprop) {
255 pr_err("p1022ds: LAW node is missing fsl,num-laws property\n");
256 goto exit;
257 }
258 num_laws = be32_to_cpup(iprop);
259
260 /*
261 * Indirect mode requires both BR0 and BR1 to be set to "GPCM",
262 * otherwise writes to these addresses won't actually appear on the
263 * local bus, and so the PIXIS won't see them.
264 *
265 * In FCM mode, writes go to the NAND controller, which does not pass
266 * them to the localbus directly. So we force BR0 and BR1 into GPCM
267 * mode, since we don't care about what's behind the localbus any
268 * more.
269 */
270 br0 = in_be32(&lbc->bank[0].br);
271 br1 = in_be32(&lbc->bank[1].br);
272 or0 = in_be32(&lbc->bank[0].or);
273 or1 = in_be32(&lbc->bank[1].or);
274
275 /* Make sure CS0 and CS1 are programmed */
276 if (!(br0 & BR_V) || !(br1 & BR_V)) {
277 pr_err("p1022ds: CS0 and/or CS1 is not programmed\n");
278 goto exit;
279 }
280
281 /*
282 * Use the existing BRx/ORx values if it's already GPCM. Otherwise,
283 * force the values to simple 32KB GPCM windows with the most
284 * conservative timing.
285 */
286 if ((br0 & BR_MSEL) != BR_MS_GPCM) {
287 br0 = (br0 & BR_BA) | BR_V;
288 or0 = 0xFFFF8000 | 0xFF7;
289 out_be32(&lbc->bank[0].br, br0);
290 out_be32(&lbc->bank[0].or, or0);
291 }
292 if ((br1 & BR_MSEL) != BR_MS_GPCM) {
293 br1 = (br1 & BR_BA) | BR_V;
294 or1 = 0xFFFF8000 | 0xFF7;
295 out_be32(&lbc->bank[1].br, br1);
296 out_be32(&lbc->bank[1].or, or1);
297 }
298
299 cs0_addr = lbc_br_to_phys(ecm, num_laws, br0);
300 if (!cs0_addr) {
301 pr_err("p1022ds: could not determine physical address for CS0"
302 " (BR0=%08x)\n", br0);
303 goto exit;
304 }
305 cs1_addr = lbc_br_to_phys(ecm, num_laws, br1);
306 if (!cs0_addr) {
307 pr_err("p1022ds: could not determine physical address for CS1"
308 " (BR1=%08x)\n", br1);
181 goto exit; 309 goto exit;
182 } 310 }
183 311
184 lbc_lcs1_ba = of_iomap(indirect_node, 1); 312 lbc_lcs0_ba = ioremap(cs0_addr, 1);
313 if (!lbc_lcs0_ba) {
314 pr_err("p1022ds: could not ioremap CS0 address %llx\n",
315 (unsigned long long)cs0_addr);
316 goto exit;
317 }
318 lbc_lcs1_ba = ioremap(cs1_addr, 1);
185 if (!lbc_lcs1_ba) { 319 if (!lbc_lcs1_ba) {
186 pr_err("p1022ds: could not map localbus chip select 1\n"); 320 pr_err("p1022ds: could not ioremap CS1 address %llx\n",
321 (unsigned long long)cs1_addr);
187 goto exit; 322 goto exit;
188 } 323 }
189 324
@@ -254,10 +389,15 @@ exit:
254 iounmap(lbc_lcs1_ba); 389 iounmap(lbc_lcs1_ba);
255 if (lbc_lcs0_ba) 390 if (lbc_lcs0_ba)
256 iounmap(lbc_lcs0_ba); 391 iounmap(lbc_lcs0_ba);
392 if (lbc)
393 iounmap(lbc);
394 if (ecm)
395 iounmap(ecm);
257 if (guts) 396 if (guts)
258 iounmap(guts); 397 iounmap(guts);
259 398
260 of_node_put(indirect_node); 399 of_node_put(law_node);
400 of_node_put(lbc_node);
261 of_node_put(guts_node); 401 of_node_put(guts_node);
262} 402}
263 403
@@ -339,24 +479,6 @@ void __init p1022_ds_pic_init(void)
339 479
340#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE) 480#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
341 481
342/*
343 * Disables a node in the device tree.
344 *
345 * This function is called before kmalloc() is available, so the 'new' object
346 * should be allocated in the global area. The easiest way is to do that is
347 * to allocate one static local variable for each call to this function.
348 */
349static void __init disable_one_node(struct device_node *np, struct property *new)
350{
351 struct property *old;
352
353 old = of_find_property(np, new->name, NULL);
354 if (old)
355 prom_update_property(np, new, old);
356 else
357 prom_add_property(np, new);
358}
359
360/* TRUE if there is a "video=fslfb" command-line parameter. */ 482/* TRUE if there is a "video=fslfb" command-line parameter. */
361static bool fslfb; 483static bool fslfb;
362 484
@@ -419,28 +541,58 @@ static void __init p1022_ds_setup_arch(void)
419 diu_ops.valid_monitor_port = p1022ds_valid_monitor_port; 541 diu_ops.valid_monitor_port = p1022ds_valid_monitor_port;
420 542
421 /* 543 /*
422 * Disable the NOR flash node if there is video=fslfb... command-line 544 * Disable the NOR and NAND flash nodes if there is video=fslfb...
423 * parameter. When the DIU is active, NOR flash is unavailable, so we 545 * command-line parameter. When the DIU is active, the localbus is
424 * have to disable the node before the MTD driver loads. 546 * unavailable, so we have to disable these nodes before the MTD
547 * driver loads.
425 */ 548 */
426 if (fslfb) { 549 if (fslfb) {
427 struct device_node *np = 550 struct device_node *np =
428 of_find_compatible_node(NULL, NULL, "fsl,p1022-elbc"); 551 of_find_compatible_node(NULL, NULL, "fsl,p1022-elbc");
429 552
430 if (np) { 553 if (np) {
431 np = of_find_compatible_node(np, NULL, "cfi-flash"); 554 struct device_node *np2;
432 if (np) { 555
556 of_node_get(np);
557 np2 = of_find_compatible_node(np, NULL, "cfi-flash");
558 if (np2) {
433 static struct property nor_status = { 559 static struct property nor_status = {
434 .name = "status", 560 .name = "status",
435 .value = "disabled", 561 .value = "disabled",
436 .length = sizeof("disabled"), 562 .length = sizeof("disabled"),
437 }; 563 };
438 564
565 /*
566 * prom_update_property() is called before
567 * kmalloc() is available, so the 'new' object
568 * should be allocated in the global area.
569 * The easiest way is to do that is to
570 * allocate one static local variable for each
571 * call to this function.
572 */
573 pr_info("p1022ds: disabling %s node",
574 np2->full_name);
575 prom_update_property(np2, &nor_status);
576 of_node_put(np2);
577 }
578
579 of_node_get(np);
580 np2 = of_find_compatible_node(np, NULL,
581 "fsl,elbc-fcm-nand");
582 if (np2) {
583 static struct property nand_status = {
584 .name = "status",
585 .value = "disabled",
586 .length = sizeof("disabled"),
587 };
588
439 pr_info("p1022ds: disabling %s node", 589 pr_info("p1022ds: disabling %s node",
440 np->full_name); 590 np2->full_name);
441 disable_one_node(np, &nor_status); 591 prom_update_property(np2, &nand_status);
442 of_node_put(np); 592 of_node_put(np2);
443 } 593 }
594
595 of_node_put(np);
444 } 596 }
445 597
446 } 598 }
@@ -450,7 +602,7 @@ static void __init p1022_ds_setup_arch(void)
450 mpc85xx_smp_init(); 602 mpc85xx_smp_init();
451 603
452#ifdef CONFIG_SWIOTLB 604#ifdef CONFIG_SWIOTLB
453 if (memblock_end_of_DRAM() > max) { 605 if ((memblock_end_of_DRAM() - 1) > max) {
454 ppc_swiotlb_enable = 1; 606 ppc_swiotlb_enable = 1;
455 set_pci_dma_ops(&swiotlb_dma_ops); 607 set_pci_dma_ops(&swiotlb_dma_ops);
456 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; 608 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
diff --git a/arch/powerpc/platforms/85xx/p3060_qds.c b/arch/powerpc/platforms/85xx/p3060_qds.c
deleted file mode 100644
index 081cf4ac188..00000000000
--- a/arch/powerpc/platforms/85xx/p3060_qds.c
+++ /dev/null
@@ -1,77 +0,0 @@
1/*
2 * P3060 QDS Setup
3 *
4 * Copyright 2011 Freescale Semiconductor Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/interrupt.h>
14#include <linux/phy.h>
15#include <asm/machdep.h>
16#include <asm/udbg.h>
17#include <asm/mpic.h>
18#include <linux/of_platform.h>
19#include <sysdev/fsl_soc.h>
20#include <sysdev/fsl_pci.h>
21#include <asm/ehv_pic.h>
22#include "corenet_ds.h"
23
24/*
25 * Called very early, device-tree isn't unflattened
26 */
27static int __init p3060_qds_probe(void)
28{
29 unsigned long root = of_get_flat_dt_root();
30#ifdef CONFIG_SMP
31 extern struct smp_ops_t smp_85xx_ops;
32#endif
33
34 if (of_flat_dt_is_compatible(root, "fsl,P3060QDS"))
35 return 1;
36
37 /* Check if we're running under the Freescale hypervisor */
38 if (of_flat_dt_is_compatible(root, "fsl,P3060QDS-hv")) {
39 ppc_md.init_IRQ = ehv_pic_init;
40 ppc_md.get_irq = ehv_pic_get_irq;
41 ppc_md.restart = fsl_hv_restart;
42 ppc_md.power_off = fsl_hv_halt;
43 ppc_md.halt = fsl_hv_halt;
44#ifdef CONFIG_SMP
45 /*
46 * Disable the timebase sync operations because we can't write
47 * to the timebase registers under the hypervisor.
48 */
49 smp_85xx_ops.give_timebase = NULL;
50 smp_85xx_ops.take_timebase = NULL;
51#endif
52 return 1;
53 }
54
55 return 0;
56}
57
58define_machine(p3060_qds) {
59 .name = "P3060 QDS",
60 .probe = p3060_qds_probe,
61 .setup_arch = corenet_ds_setup_arch,
62 .init_IRQ = corenet_ds_pic_init,
63#ifdef CONFIG_PCI
64 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
65#endif
66 .get_irq = mpic_get_coreint_irq,
67 .restart = fsl_rstcr_restart,
68 .calibrate_decr = generic_calibrate_decr,
69 .progress = udbg_progress,
70 .power_save = e500_idle,
71};
72
73machine_device_initcall(p3060_qds, corenet_ds_publish_devices);
74
75#ifdef CONFIG_SWIOTLB
76machine_arch_initcall(p3060_qds, swiotlb_setup_bus_notifier);
77#endif
diff --git a/arch/powerpc/platforms/85xx/qemu_e500.c b/arch/powerpc/platforms/85xx/qemu_e500.c
new file mode 100644
index 00000000000..95a2e53af71
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/qemu_e500.c
@@ -0,0 +1,72 @@
1/*
2 * Paravirt target for a generic QEMU e500 machine
3 *
4 * This is intended to be a flexible device-tree-driven platform, not fixed
5 * to a particular piece of hardware or a particular spec of virtual hardware,
6 * beyond the assumption of an e500-family CPU. Some things are still hardcoded
7 * here, such as MPIC, but this is a limitation of the current code rather than
8 * an interface contract with QEMU.
9 *
10 * Copyright 2012 Freescale Semiconductor Inc.
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */
17
18#include <linux/kernel.h>
19#include <linux/of_fdt.h>
20#include <asm/machdep.h>
21#include <asm/time.h>
22#include <asm/udbg.h>
23#include <asm/mpic.h>
24#include <sysdev/fsl_soc.h>
25#include <sysdev/fsl_pci.h>
26#include "smp.h"
27#include "mpc85xx.h"
28
29void __init qemu_e500_pic_init(void)
30{
31 struct mpic *mpic;
32
33 mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN | MPIC_SINGLE_DEST_CPU,
34 0, 256, " OpenPIC ");
35
36 BUG_ON(mpic == NULL);
37 mpic_init(mpic);
38}
39
40static void __init qemu_e500_setup_arch(void)
41{
42 ppc_md.progress("qemu_e500_setup_arch()", 0);
43
44 fsl_pci_init();
45 mpc85xx_smp_init();
46}
47
48/*
49 * Called very early, device-tree isn't unflattened
50 */
51static int __init qemu_e500_probe(void)
52{
53 unsigned long root = of_get_flat_dt_root();
54
55 return !!of_flat_dt_is_compatible(root, "fsl,qemu-e500");
56}
57
58machine_device_initcall(qemu_e500, mpc85xx_common_publish_devices);
59
60define_machine(qemu_e500) {
61 .name = "QEMU e500",
62 .probe = qemu_e500_probe,
63 .setup_arch = qemu_e500_setup_arch,
64 .init_IRQ = qemu_e500_pic_init,
65#ifdef CONFIG_PCI
66 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
67#endif
68 .get_irq = mpic_get_irq,
69 .restart = fsl_rstcr_restart,
70 .calibrate_decr = generic_calibrate_decr,
71 .progress = udbg_progress,
72};
diff --git a/arch/powerpc/platforms/85xx/sbc8560.c b/arch/powerpc/platforms/85xx/sbc8560.c
deleted file mode 100644
index b1be632ede4..00000000000
--- a/arch/powerpc/platforms/85xx/sbc8560.c
+++ /dev/null
@@ -1,254 +0,0 @@
1/*
2 * Wind River SBC8560 setup and early boot code.
3 *
4 * Copyright 2007 Wind River Systems Inc.
5 *
6 * By Paul Gortmaker (see MAINTAINERS for contact information)
7 *
8 * Based largely on the MPC8560ADS support - Copyright 2005 Freescale Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 */
15
16#include <linux/stddef.h>
17#include <linux/kernel.h>
18#include <linux/pci.h>
19#include <linux/kdev_t.h>
20#include <linux/delay.h>
21#include <linux/seq_file.h>
22#include <linux/of_platform.h>
23
24#include <asm/time.h>
25#include <asm/machdep.h>
26#include <asm/pci-bridge.h>
27#include <asm/mpic.h>
28#include <mm/mmu_decl.h>
29#include <asm/udbg.h>
30
31#include <sysdev/fsl_soc.h>
32#include <sysdev/fsl_pci.h>
33
34#include "mpc85xx.h"
35
36#ifdef CONFIG_CPM2
37#include <asm/cpm2.h>
38#include <sysdev/cpm2_pic.h>
39#endif
40
41static void __init sbc8560_pic_init(void)
42{
43 struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN,
44 0, 256, " OpenPIC ");
45 BUG_ON(mpic == NULL);
46 mpic_init(mpic);
47
48 mpc85xx_cpm2_pic_init();
49}
50
51/*
52 * Setup the architecture
53 */
54#ifdef CONFIG_CPM2
55struct cpm_pin {
56 int port, pin, flags;
57};
58
59static const struct cpm_pin sbc8560_pins[] = {
60 /* SCC1 */
61 {3, 29, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
62 {3, 30, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
63 {3, 31, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
64
65 /* SCC2 */
66 {3, 26, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
67 {3, 27, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
68 {3, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
69
70 /* FCC2 */
71 {1, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
72 {1, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
73 {1, 20, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
74 {1, 21, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
75 {1, 22, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
76 {1, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
77 {1, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
78 {1, 25, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
79 {1, 26, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
80 {1, 27, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
81 {1, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
82 {1, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
83 {1, 30, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
84 {1, 31, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
85 {2, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK14 */
86 {2, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK13 */
87
88 /* FCC3 */
89 {1, 4, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
90 {1, 5, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
91 {1, 6, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
92 {1, 7, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
93 {1, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
94 {1, 9, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
95 {1, 10, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
96 {1, 11, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
97 {1, 12, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
98 {1, 13, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
99 {1, 14, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
100 {1, 15, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
101 {1, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
102 {1, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
103 {2, 16, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* CLK16 */
104 {2, 17, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* CLK15 */
105};
106
107static void __init init_ioports(void)
108{
109 int i;
110
111 for (i = 0; i < ARRAY_SIZE(sbc8560_pins); i++) {
112 const struct cpm_pin *pin = &sbc8560_pins[i];
113 cpm2_set_pin(pin->port, pin->pin, pin->flags);
114 }
115
116 cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_RX);
117 cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_TX);
118 cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_RX);
119 cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_TX);
120 cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK13, CPM_CLK_RX);
121 cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK14, CPM_CLK_TX);
122 cpm2_clk_setup(CPM_CLK_FCC3, CPM_CLK15, CPM_CLK_RX);
123 cpm2_clk_setup(CPM_CLK_FCC3, CPM_CLK16, CPM_CLK_TX);
124}
125#endif
126
127static void __init sbc8560_setup_arch(void)
128{
129#ifdef CONFIG_PCI
130 struct device_node *np;
131#endif
132
133 if (ppc_md.progress)
134 ppc_md.progress("sbc8560_setup_arch()", 0);
135
136#ifdef CONFIG_CPM2
137 cpm2_reset();
138 init_ioports();
139#endif
140
141#ifdef CONFIG_PCI
142 for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")
143 fsl_add_bridge(np, 1);
144#endif
145}
146
147static void sbc8560_show_cpuinfo(struct seq_file *m)
148{
149 uint pvid, svid, phid1;
150
151 pvid = mfspr(SPRN_PVR);
152 svid = mfspr(SPRN_SVR);
153
154 seq_printf(m, "Vendor\t\t: Wind River\n");
155 seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
156 seq_printf(m, "SVR\t\t: 0x%x\n", svid);
157
158 /* Display cpu Pll setting */
159 phid1 = mfspr(SPRN_HID1);
160 seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
161}
162
163machine_device_initcall(sbc8560, mpc85xx_common_publish_devices);
164
165/*
166 * Called very early, device-tree isn't unflattened
167 */
168static int __init sbc8560_probe(void)
169{
170 unsigned long root = of_get_flat_dt_root();
171
172 return of_flat_dt_is_compatible(root, "SBC8560");
173}
174
175#ifdef CONFIG_RTC_DRV_M48T59
176static int __init sbc8560_rtc_init(void)
177{
178 struct device_node *np;
179 struct resource res;
180 struct platform_device *rtc_dev;
181
182 np = of_find_compatible_node(NULL, NULL, "m48t59");
183 if (np == NULL) {
184 printk("No RTC in DTB. Has it been eaten by wild dogs?\n");
185 return -ENODEV;
186 }
187
188 of_address_to_resource(np, 0, &res);
189 of_node_put(np);
190
191 printk("Found RTC (m48t59) at i/o 0x%x\n", res.start);
192
193 rtc_dev = platform_device_register_simple("rtc-m48t59", 0, &res, 1);
194
195 if (IS_ERR(rtc_dev)) {
196 printk("Registering sbc8560 RTC device failed\n");
197 return PTR_ERR(rtc_dev);
198 }
199
200 return 0;
201}
202
203arch_initcall(sbc8560_rtc_init);
204
205#endif /* M48T59 */
206
207static __u8 __iomem *brstcr;
208
209static int __init sbc8560_bdrstcr_init(void)
210{
211 struct device_node *np;
212 struct resource res;
213
214 np = of_find_compatible_node(NULL, NULL, "wrs,sbc8560-brstcr");
215 if (np == NULL) {
216 printk(KERN_WARNING "sbc8560: No board specific RSTCR in DTB.\n");
217 return -ENODEV;
218 }
219
220 of_address_to_resource(np, 0, &res);
221
222 printk(KERN_INFO "sbc8560: Found BRSTCR at %pR\n", &res);
223
224 brstcr = ioremap(res.start, resource_size(&res));
225 if(!brstcr)
226 printk(KERN_WARNING "sbc8560: ioremap of brstcr failed.\n");
227
228 of_node_put(np);
229
230 return 0;
231}
232
233arch_initcall(sbc8560_bdrstcr_init);
234
235void sbc8560_rstcr_restart(char * cmd)
236{
237 local_irq_disable();
238 if(brstcr)
239 clrbits8(brstcr, 0x80);
240
241 while(1);
242}
243
244define_machine(sbc8560) {
245 .name = "SBC8560",
246 .probe = sbc8560_probe,
247 .setup_arch = sbc8560_setup_arch,
248 .init_IRQ = sbc8560_pic_init,
249 .show_cpuinfo = sbc8560_show_cpuinfo,
250 .get_irq = mpic_get_irq,
251 .restart = sbc8560_rstcr_restart,
252 .calibrate_decr = generic_calibrate_decr,
253 .progress = udbg_progress,
254};
diff --git a/arch/powerpc/platforms/85xx/tqm85xx.c b/arch/powerpc/platforms/85xx/tqm85xx.c
index 4d786c25d3e..3e70a2035e5 100644
--- a/arch/powerpc/platforms/85xx/tqm85xx.c
+++ b/arch/powerpc/platforms/85xx/tqm85xx.c
@@ -102,7 +102,7 @@ static void tqm85xx_show_cpuinfo(struct seq_file *m)
102 seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f)); 102 seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
103} 103}
104 104
105static void __init tqm85xx_ti1520_fixup(struct pci_dev *pdev) 105static void __devinit tqm85xx_ti1520_fixup(struct pci_dev *pdev)
106{ 106{
107 unsigned int val; 107 unsigned int val;
108 108
diff --git a/arch/powerpc/platforms/86xx/gef_ppc9a.c b/arch/powerpc/platforms/86xx/gef_ppc9a.c
index 1fca663f1b2..563aafa8629 100644
--- a/arch/powerpc/platforms/86xx/gef_ppc9a.c
+++ b/arch/powerpc/platforms/86xx/gef_ppc9a.c
@@ -164,7 +164,7 @@ static void gef_ppc9a_show_cpuinfo(struct seq_file *m)
164 gef_ppc9a_get_vme_is_syscon() ? "yes" : "no"); 164 gef_ppc9a_get_vme_is_syscon() ? "yes" : "no");
165} 165}
166 166
167static void __init gef_ppc9a_nec_fixup(struct pci_dev *pdev) 167static void __devinit gef_ppc9a_nec_fixup(struct pci_dev *pdev)
168{ 168{
169 unsigned int val; 169 unsigned int val;
170 170
diff --git a/arch/powerpc/platforms/86xx/gef_sbc310.c b/arch/powerpc/platforms/86xx/gef_sbc310.c
index 14e0e576bcb..cc6a91ae088 100644
--- a/arch/powerpc/platforms/86xx/gef_sbc310.c
+++ b/arch/powerpc/platforms/86xx/gef_sbc310.c
@@ -152,7 +152,7 @@ static void gef_sbc310_show_cpuinfo(struct seq_file *m)
152 152
153} 153}
154 154
155static void __init gef_sbc310_nec_fixup(struct pci_dev *pdev) 155static void __devinit gef_sbc310_nec_fixup(struct pci_dev *pdev)
156{ 156{
157 unsigned int val; 157 unsigned int val;
158 158
diff --git a/arch/powerpc/platforms/86xx/gef_sbc610.c b/arch/powerpc/platforms/86xx/gef_sbc610.c
index 1638f43599f..aead6b337f4 100644
--- a/arch/powerpc/platforms/86xx/gef_sbc610.c
+++ b/arch/powerpc/platforms/86xx/gef_sbc610.c
@@ -141,7 +141,7 @@ static void gef_sbc610_show_cpuinfo(struct seq_file *m)
141 seq_printf(m, "SVR\t\t: 0x%x\n", svid); 141 seq_printf(m, "SVR\t\t: 0x%x\n", svid);
142} 142}
143 143
144static void __init gef_sbc610_nec_fixup(struct pci_dev *pdev) 144static void __devinit gef_sbc610_nec_fixup(struct pci_dev *pdev)
145{ 145{
146 unsigned int val; 146 unsigned int val;
147 147
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index 3755e61d7ec..817245bc021 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -102,7 +102,7 @@ mpc86xx_hpcn_setup_arch(void)
102#endif 102#endif
103 103
104#ifdef CONFIG_SWIOTLB 104#ifdef CONFIG_SWIOTLB
105 if (memblock_end_of_DRAM() > max) { 105 if ((memblock_end_of_DRAM() - 1) > max) {
106 ppc_swiotlb_enable = 1; 106 ppc_swiotlb_enable = 1;
107 set_pci_dma_ops(&swiotlb_dma_ops); 107 set_pci_dma_ops(&swiotlb_dma_ops);
108 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; 108 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
index a35ca44ade6..e7a896acd98 100644
--- a/arch/powerpc/platforms/Kconfig
+++ b/arch/powerpc/platforms/Kconfig
@@ -25,6 +25,7 @@ source "arch/powerpc/platforms/wsp/Kconfig"
25config KVM_GUEST 25config KVM_GUEST
26 bool "KVM Guest support" 26 bool "KVM Guest support"
27 default n 27 default n
28 select EPAPR_PARAVIRT
28 ---help--- 29 ---help---
29 This option enables various optimizations for running under the KVM 30 This option enables various optimizations for running under the KVM
30 hypervisor. Overhead for the kernel when not running inside KVM should 31 hypervisor. Overhead for the kernel when not running inside KVM should
@@ -32,6 +33,14 @@ config KVM_GUEST
32 33
33 In case of doubt, say Y 34 In case of doubt, say Y
34 35
36config EPAPR_PARAVIRT
37 bool "ePAPR para-virtualization support"
38 default n
39 help
40 Enables ePAPR para-virtualization support for guests.
41
42 In case of doubt, say Y
43
35config PPC_NATIVE 44config PPC_NATIVE
36 bool 45 bool
37 depends on 6xx || PPC64 46 depends on 6xx || PPC64
diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index 61c9550819a..30fd01de6be 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -159,6 +159,10 @@ config PPC_E500MC
159 bool "e500mc Support" 159 bool "e500mc Support"
160 select PPC_FPU 160 select PPC_FPU
161 depends on E500 161 depends on E500
162 help
163 This must be enabled for running on e500mc (and derivatives
164 such as e5500/e6500), and must be disabled for running on
165 e500v1 or e500v2.
162 166
163config PPC_FPU 167config PPC_FPU
164 bool 168 bool
diff --git a/arch/powerpc/platforms/cell/beat_hvCall.S b/arch/powerpc/platforms/cell/beat_hvCall.S
index 74c81744894..96c80190712 100644
--- a/arch/powerpc/platforms/cell/beat_hvCall.S
+++ b/arch/powerpc/platforms/cell/beat_hvCall.S
@@ -22,8 +22,6 @@
22 22
23#include <asm/ppc_asm.h> 23#include <asm/ppc_asm.h>
24 24
25#define STK_PARM(i) (48 + ((i)-3)*8)
26
27/* Not implemented on Beat, now */ 25/* Not implemented on Beat, now */
28#define HCALL_INST_PRECALL 26#define HCALL_INST_PRECALL
29#define HCALL_INST_POSTCALL 27#define HCALL_INST_POSTCALL
@@ -74,7 +72,7 @@ _GLOBAL(beat_hcall_norets8)
74 mr r6,r7 72 mr r6,r7
75 mr r7,r8 73 mr r7,r8
76 mr r8,r9 74 mr r8,r9
77 ld r10,STK_PARM(r10)(r1) 75 ld r10,STK_PARAM(R10)(r1)
78 76
79 HVSC /* invoke the hypervisor */ 77 HVSC /* invoke the hypervisor */
80 78
@@ -94,7 +92,7 @@ _GLOBAL(beat_hcall1)
94 92
95 HCALL_INST_PRECALL 93 HCALL_INST_PRECALL
96 94
97 std r4,STK_PARM(r4)(r1) /* save ret buffer */ 95 std r4,STK_PARAM(R4)(r1) /* save ret buffer */
98 96
99 mr r11,r3 97 mr r11,r3
100 mr r3,r5 98 mr r3,r5
@@ -108,7 +106,7 @@ _GLOBAL(beat_hcall1)
108 106
109 HCALL_INST_POSTCALL 107 HCALL_INST_POSTCALL
110 108
111 ld r12,STK_PARM(r4)(r1) 109 ld r12,STK_PARAM(R4)(r1)
112 std r4, 0(r12) 110 std r4, 0(r12)
113 111
114 lwz r0,8(r1) 112 lwz r0,8(r1)
@@ -125,7 +123,7 @@ _GLOBAL(beat_hcall2)
125 123
126 HCALL_INST_PRECALL 124 HCALL_INST_PRECALL
127 125
128 std r4,STK_PARM(r4)(r1) /* save ret buffer */ 126 std r4,STK_PARAM(R4)(r1) /* save ret buffer */
129 127
130 mr r11,r3 128 mr r11,r3
131 mr r3,r5 129 mr r3,r5
@@ -139,7 +137,7 @@ _GLOBAL(beat_hcall2)
139 137
140 HCALL_INST_POSTCALL 138 HCALL_INST_POSTCALL
141 139
142 ld r12,STK_PARM(r4)(r1) 140 ld r12,STK_PARAM(R4)(r1)
143 std r4, 0(r12) 141 std r4, 0(r12)
144 std r5, 8(r12) 142 std r5, 8(r12)
145 143
@@ -157,7 +155,7 @@ _GLOBAL(beat_hcall3)
157 155
158 HCALL_INST_PRECALL 156 HCALL_INST_PRECALL
159 157
160 std r4,STK_PARM(r4)(r1) /* save ret buffer */ 158 std r4,STK_PARAM(R4)(r1) /* save ret buffer */
161 159
162 mr r11,r3 160 mr r11,r3
163 mr r3,r5 161 mr r3,r5
@@ -171,7 +169,7 @@ _GLOBAL(beat_hcall3)
171 169
172 HCALL_INST_POSTCALL 170 HCALL_INST_POSTCALL
173 171
174 ld r12,STK_PARM(r4)(r1) 172 ld r12,STK_PARAM(R4)(r1)
175 std r4, 0(r12) 173 std r4, 0(r12)
176 std r5, 8(r12) 174 std r5, 8(r12)
177 std r6, 16(r12) 175 std r6, 16(r12)
@@ -190,7 +188,7 @@ _GLOBAL(beat_hcall4)
190 188
191 HCALL_INST_PRECALL 189 HCALL_INST_PRECALL
192 190
193 std r4,STK_PARM(r4)(r1) /* save ret buffer */ 191 std r4,STK_PARAM(R4)(r1) /* save ret buffer */
194 192
195 mr r11,r3 193 mr r11,r3
196 mr r3,r5 194 mr r3,r5
@@ -204,7 +202,7 @@ _GLOBAL(beat_hcall4)
204 202
205 HCALL_INST_POSTCALL 203 HCALL_INST_POSTCALL
206 204
207 ld r12,STK_PARM(r4)(r1) 205 ld r12,STK_PARAM(R4)(r1)
208 std r4, 0(r12) 206 std r4, 0(r12)
209 std r5, 8(r12) 207 std r5, 8(r12)
210 std r6, 16(r12) 208 std r6, 16(r12)
@@ -224,7 +222,7 @@ _GLOBAL(beat_hcall5)
224 222
225 HCALL_INST_PRECALL 223 HCALL_INST_PRECALL
226 224
227 std r4,STK_PARM(r4)(r1) /* save ret buffer */ 225 std r4,STK_PARAM(R4)(r1) /* save ret buffer */
228 226
229 mr r11,r3 227 mr r11,r3
230 mr r3,r5 228 mr r3,r5
@@ -238,7 +236,7 @@ _GLOBAL(beat_hcall5)
238 236
239 HCALL_INST_POSTCALL 237 HCALL_INST_POSTCALL
240 238
241 ld r12,STK_PARM(r4)(r1) 239 ld r12,STK_PARAM(R4)(r1)
242 std r4, 0(r12) 240 std r4, 0(r12)
243 std r5, 8(r12) 241 std r5, 8(r12)
244 std r6, 16(r12) 242 std r6, 16(r12)
@@ -259,7 +257,7 @@ _GLOBAL(beat_hcall6)
259 257
260 HCALL_INST_PRECALL 258 HCALL_INST_PRECALL
261 259
262 std r4,STK_PARM(r4)(r1) /* save ret buffer */ 260 std r4,STK_PARAM(R4)(r1) /* save ret buffer */
263 261
264 mr r11,r3 262 mr r11,r3
265 mr r3,r5 263 mr r3,r5
@@ -273,7 +271,7 @@ _GLOBAL(beat_hcall6)
273 271
274 HCALL_INST_POSTCALL 272 HCALL_INST_POSTCALL
275 273
276 ld r12,STK_PARM(r4)(r1) 274 ld r12,STK_PARAM(R4)(r1)
277 std r4, 0(r12) 275 std r4, 0(r12)
278 std r5, 8(r12) 276 std r5, 8(r12)
279 std r6, 16(r12) 277 std r6, 16(r12)
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index b9f509a34c0..dca21366674 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -518,7 +518,6 @@ cell_iommu_setup_window(struct cbe_iommu *iommu, struct device_node *np,
518 __set_bit(0, window->table.it_map); 518 __set_bit(0, window->table.it_map);
519 tce_build_cell(&window->table, window->table.it_offset, 1, 519 tce_build_cell(&window->table, window->table.it_offset, 1,
520 (unsigned long)iommu->pad_page, DMA_TO_DEVICE, NULL); 520 (unsigned long)iommu->pad_page, DMA_TO_DEVICE, NULL);
521 window->table.it_hint = window->table.it_blocksize;
522 521
523 return window; 522 return window;
524} 523}
@@ -552,8 +551,7 @@ static struct iommu_table *cell_get_iommu_table(struct device *dev)
552 iommu = cell_iommu_for_node(dev_to_node(dev)); 551 iommu = cell_iommu_for_node(dev_to_node(dev));
553 if (iommu == NULL || list_empty(&iommu->windows)) { 552 if (iommu == NULL || list_empty(&iommu->windows)) {
554 printk(KERN_ERR "iommu: missing iommu for %s (node %d)\n", 553 printk(KERN_ERR "iommu: missing iommu for %s (node %d)\n",
555 dev->of_node ? dev->of_node->full_name : "?", 554 of_node_full_name(dev->of_node), dev_to_node(dev));
556 dev_to_node(dev));
557 return NULL; 555 return NULL;
558 } 556 }
559 window = list_entry(iommu->windows.next, struct iommu_window, list); 557 window = list_entry(iommu->windows.next, struct iommu_window, list);
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index 66519d263da..dba1ce235da 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -186,10 +186,13 @@ static void spufs_prune_dir(struct dentry *dir)
186static int spufs_rmdir(struct inode *parent, struct dentry *dir) 186static int spufs_rmdir(struct inode *parent, struct dentry *dir)
187{ 187{
188 /* remove all entries */ 188 /* remove all entries */
189 int res;
189 spufs_prune_dir(dir); 190 spufs_prune_dir(dir);
190 d_drop(dir); 191 d_drop(dir);
191 192 res = simple_rmdir(parent, dir);
192 return simple_rmdir(parent, dir); 193 /* We have to give up the mm_struct */
194 spu_forget(SPUFS_I(dir->d_inode)->i_ctx);
195 return res;
193} 196}
194 197
195static int spufs_fill_dir(struct dentry *dir, 198static int spufs_fill_dir(struct dentry *dir,
@@ -245,9 +248,6 @@ static int spufs_dir_close(struct inode *inode, struct file *file)
245 mutex_unlock(&parent->i_mutex); 248 mutex_unlock(&parent->i_mutex);
246 WARN_ON(ret); 249 WARN_ON(ret);
247 250
248 /* We have to give up the mm_struct */
249 spu_forget(ctx);
250
251 return dcache_dir_close(inode, file); 251 return dcache_dir_close(inode, file);
252} 252}
253 253
@@ -317,28 +317,23 @@ out:
317 return ret; 317 return ret;
318} 318}
319 319
320static int spufs_context_open(struct dentry *dentry, struct vfsmount *mnt) 320static int spufs_context_open(struct path *path)
321{ 321{
322 int ret; 322 int ret;
323 struct file *filp; 323 struct file *filp;
324 324
325 ret = get_unused_fd(); 325 ret = get_unused_fd();
326 if (ret < 0) { 326 if (ret < 0)
327 dput(dentry); 327 return ret;
328 mntput(mnt);
329 goto out;
330 }
331 328
332 filp = dentry_open(dentry, mnt, O_RDONLY, current_cred()); 329 filp = dentry_open(path, O_RDONLY, current_cred());
333 if (IS_ERR(filp)) { 330 if (IS_ERR(filp)) {
334 put_unused_fd(ret); 331 put_unused_fd(ret);
335 ret = PTR_ERR(filp); 332 return PTR_ERR(filp);
336 goto out;
337 } 333 }
338 334
339 filp->f_op = &spufs_context_fops; 335 filp->f_op = &spufs_context_fops;
340 fd_install(ret, filp); 336 fd_install(ret, filp);
341out:
342 return ret; 337 return ret;
343} 338}
344 339
@@ -453,29 +448,26 @@ spufs_create_context(struct inode *inode, struct dentry *dentry,
453 int affinity; 448 int affinity;
454 struct spu_gang *gang; 449 struct spu_gang *gang;
455 struct spu_context *neighbor; 450 struct spu_context *neighbor;
451 struct path path = {.mnt = mnt, .dentry = dentry};
456 452
457 ret = -EPERM;
458 if ((flags & SPU_CREATE_NOSCHED) && 453 if ((flags & SPU_CREATE_NOSCHED) &&
459 !capable(CAP_SYS_NICE)) 454 !capable(CAP_SYS_NICE))
460 goto out_unlock; 455 return -EPERM;
461 456
462 ret = -EINVAL;
463 if ((flags & (SPU_CREATE_NOSCHED | SPU_CREATE_ISOLATE)) 457 if ((flags & (SPU_CREATE_NOSCHED | SPU_CREATE_ISOLATE))
464 == SPU_CREATE_ISOLATE) 458 == SPU_CREATE_ISOLATE)
465 goto out_unlock; 459 return -EINVAL;
466 460
467 ret = -ENODEV;
468 if ((flags & SPU_CREATE_ISOLATE) && !isolated_loader) 461 if ((flags & SPU_CREATE_ISOLATE) && !isolated_loader)
469 goto out_unlock; 462 return -ENODEV;
470 463
471 gang = NULL; 464 gang = NULL;
472 neighbor = NULL; 465 neighbor = NULL;
473 affinity = flags & (SPU_CREATE_AFFINITY_MEM | SPU_CREATE_AFFINITY_SPU); 466 affinity = flags & (SPU_CREATE_AFFINITY_MEM | SPU_CREATE_AFFINITY_SPU);
474 if (affinity) { 467 if (affinity) {
475 gang = SPUFS_I(inode)->i_gang; 468 gang = SPUFS_I(inode)->i_gang;
476 ret = -EINVAL;
477 if (!gang) 469 if (!gang)
478 goto out_unlock; 470 return -EINVAL;
479 mutex_lock(&gang->aff_mutex); 471 mutex_lock(&gang->aff_mutex);
480 neighbor = spufs_assert_affinity(flags, gang, aff_filp); 472 neighbor = spufs_assert_affinity(flags, gang, aff_filp);
481 if (IS_ERR(neighbor)) { 473 if (IS_ERR(neighbor)) {
@@ -495,27 +487,13 @@ spufs_create_context(struct inode *inode, struct dentry *dentry,
495 put_spu_context(neighbor); 487 put_spu_context(neighbor);
496 } 488 }
497 489
498 /* 490 ret = spufs_context_open(&path);
499 * get references for dget and mntget, will be released 491 if (ret < 0)
500 * in error path of *_open().
501 */
502 ret = spufs_context_open(dget(dentry), mntget(mnt));
503 if (ret < 0) {
504 WARN_ON(spufs_rmdir(inode, dentry)); 492 WARN_ON(spufs_rmdir(inode, dentry));
505 if (affinity)
506 mutex_unlock(&gang->aff_mutex);
507 mutex_unlock(&inode->i_mutex);
508 spu_forget(SPUFS_I(dentry->d_inode)->i_ctx);
509 goto out;
510 }
511 493
512out_aff_unlock: 494out_aff_unlock:
513 if (affinity) 495 if (affinity)
514 mutex_unlock(&gang->aff_mutex); 496 mutex_unlock(&gang->aff_mutex);
515out_unlock:
516 mutex_unlock(&inode->i_mutex);
517out:
518 dput(dentry);
519 return ret; 497 return ret;
520} 498}
521 499
@@ -556,28 +534,27 @@ out:
556 return ret; 534 return ret;
557} 535}
558 536
559static int spufs_gang_open(struct dentry *dentry, struct vfsmount *mnt) 537static int spufs_gang_open(struct path *path)
560{ 538{
561 int ret; 539 int ret;
562 struct file *filp; 540 struct file *filp;
563 541
564 ret = get_unused_fd(); 542 ret = get_unused_fd();
565 if (ret < 0) { 543 if (ret < 0)
566 dput(dentry); 544 return ret;
567 mntput(mnt);
568 goto out;
569 }
570 545
571 filp = dentry_open(dentry, mnt, O_RDONLY, current_cred()); 546 /*
547 * get references for dget and mntget, will be released
548 * in error path of *_open().
549 */
550 filp = dentry_open(path, O_RDONLY, current_cred());
572 if (IS_ERR(filp)) { 551 if (IS_ERR(filp)) {
573 put_unused_fd(ret); 552 put_unused_fd(ret);
574 ret = PTR_ERR(filp); 553 return PTR_ERR(filp);
575 goto out;
576 } 554 }
577 555
578 filp->f_op = &simple_dir_operations; 556 filp->f_op = &simple_dir_operations;
579 fd_install(ret, filp); 557 fd_install(ret, filp);
580out:
581 return ret; 558 return ret;
582} 559}
583 560
@@ -585,25 +562,17 @@ static int spufs_create_gang(struct inode *inode,
585 struct dentry *dentry, 562 struct dentry *dentry,
586 struct vfsmount *mnt, umode_t mode) 563 struct vfsmount *mnt, umode_t mode)
587{ 564{
565 struct path path = {.mnt = mnt, .dentry = dentry};
588 int ret; 566 int ret;
589 567
590 ret = spufs_mkgang(inode, dentry, mode & S_IRWXUGO); 568 ret = spufs_mkgang(inode, dentry, mode & S_IRWXUGO);
591 if (ret) 569 if (!ret) {
592 goto out; 570 ret = spufs_gang_open(&path);
593 571 if (ret < 0) {
594 /* 572 int err = simple_rmdir(inode, dentry);
595 * get references for dget and mntget, will be released 573 WARN_ON(err);
596 * in error path of *_open(). 574 }
597 */
598 ret = spufs_gang_open(dget(dentry), mntget(mnt));
599 if (ret < 0) {
600 int err = simple_rmdir(inode, dentry);
601 WARN_ON(err);
602 } 575 }
603
604out:
605 mutex_unlock(&inode->i_mutex);
606 dput(dentry);
607 return ret; 576 return ret;
608} 577}
609 578
@@ -613,40 +582,32 @@ static struct file_system_type spufs_type;
613long spufs_create(struct path *path, struct dentry *dentry, 582long spufs_create(struct path *path, struct dentry *dentry,
614 unsigned int flags, umode_t mode, struct file *filp) 583 unsigned int flags, umode_t mode, struct file *filp)
615{ 584{
585 struct inode *dir = path->dentry->d_inode;
616 int ret; 586 int ret;
617 587
618 ret = -EINVAL;
619 /* check if we are on spufs */ 588 /* check if we are on spufs */
620 if (path->dentry->d_sb->s_type != &spufs_type) 589 if (path->dentry->d_sb->s_type != &spufs_type)
621 goto out; 590 return -EINVAL;
622 591
623 /* don't accept undefined flags */ 592 /* don't accept undefined flags */
624 if (flags & (~SPU_CREATE_FLAG_ALL)) 593 if (flags & (~SPU_CREATE_FLAG_ALL))
625 goto out; 594 return -EINVAL;
626 595
627 /* only threads can be underneath a gang */ 596 /* only threads can be underneath a gang */
628 if (path->dentry != path->dentry->d_sb->s_root) { 597 if (path->dentry != path->dentry->d_sb->s_root)
629 if ((flags & SPU_CREATE_GANG) || 598 if ((flags & SPU_CREATE_GANG) || !SPUFS_I(dir)->i_gang)
630 !SPUFS_I(path->dentry->d_inode)->i_gang) 599 return -EINVAL;
631 goto out;
632 }
633 600
634 mode &= ~current_umask(); 601 mode &= ~current_umask();
635 602
636 if (flags & SPU_CREATE_GANG) 603 if (flags & SPU_CREATE_GANG)
637 ret = spufs_create_gang(path->dentry->d_inode, 604 ret = spufs_create_gang(dir, dentry, path->mnt, mode);
638 dentry, path->mnt, mode);
639 else 605 else
640 ret = spufs_create_context(path->dentry->d_inode, 606 ret = spufs_create_context(dir, dentry, path->mnt, flags, mode,
641 dentry, path->mnt, flags, mode,
642 filp); 607 filp);
643 if (ret >= 0) 608 if (ret >= 0)
644 fsnotify_mkdir(path->dentry->d_inode, dentry); 609 fsnotify_mkdir(dir, dentry);
645 return ret;
646 610
647out:
648 mutex_unlock(&path->dentry->d_inode->i_mutex);
649 dput(dentry);
650 return ret; 611 return ret;
651} 612}
652 613
diff --git a/arch/powerpc/platforms/cell/spufs/syscalls.c b/arch/powerpc/platforms/cell/spufs/syscalls.c
index 5665dcc382c..5b7d8ffbf89 100644
--- a/arch/powerpc/platforms/cell/spufs/syscalls.c
+++ b/arch/powerpc/platforms/cell/spufs/syscalls.c
@@ -70,7 +70,7 @@ static long do_spu_create(const char __user *pathname, unsigned int flags,
70 ret = PTR_ERR(dentry); 70 ret = PTR_ERR(dentry);
71 if (!IS_ERR(dentry)) { 71 if (!IS_ERR(dentry)) {
72 ret = spufs_create(&path, dentry, flags, mode, neighbor); 72 ret = spufs_create(&path, dentry, flags, mode, neighbor);
73 path_put(&path); 73 done_path_create(&path, dentry);
74 } 74 }
75 75
76 return ret; 76 return ret;
diff --git a/arch/powerpc/platforms/powernv/opal-takeover.S b/arch/powerpc/platforms/powernv/opal-takeover.S
index 77b48b2b930..3cd262897c2 100644
--- a/arch/powerpc/platforms/powernv/opal-takeover.S
+++ b/arch/powerpc/platforms/powernv/opal-takeover.S
@@ -14,8 +14,6 @@
14#include <asm/asm-offsets.h> 14#include <asm/asm-offsets.h>
15#include <asm/opal.h> 15#include <asm/opal.h>
16 16
17#define STK_PARAM(i) (48 + ((i)-3)*8)
18
19#define H_HAL_TAKEOVER 0x5124 17#define H_HAL_TAKEOVER 0x5124
20#define H_HAL_TAKEOVER_QUERY_MAGIC -1 18#define H_HAL_TAKEOVER_QUERY_MAGIC -1
21 19
@@ -23,14 +21,14 @@
23_GLOBAL(opal_query_takeover) 21_GLOBAL(opal_query_takeover)
24 mfcr r0 22 mfcr r0
25 stw r0,8(r1) 23 stw r0,8(r1)
26 std r3,STK_PARAM(r3)(r1) 24 std r3,STK_PARAM(R3)(r1)
27 std r4,STK_PARAM(r4)(r1) 25 std r4,STK_PARAM(R4)(r1)
28 li r3,H_HAL_TAKEOVER 26 li r3,H_HAL_TAKEOVER
29 li r4,H_HAL_TAKEOVER_QUERY_MAGIC 27 li r4,H_HAL_TAKEOVER_QUERY_MAGIC
30 HVSC 28 HVSC
31 ld r10,STK_PARAM(r3)(r1) 29 ld r10,STK_PARAM(R3)(r1)
32 std r4,0(r10) 30 std r4,0(r10)
33 ld r10,STK_PARAM(r4)(r1) 31 ld r10,STK_PARAM(R4)(r1)
34 std r5,0(r10) 32 std r5,0(r10)
35 lwz r0,8(r1) 33 lwz r0,8(r1)
36 mtcrf 0xff,r0 34 mtcrf 0xff,r0
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index fbdd74dac3a..9cda6a1ad0c 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -589,7 +589,7 @@ static int __devinit pnv_ioda_configure_pe(struct pnv_phb *phb,
589 dcomp = OPAL_IGNORE_RID_DEVICE_NUMBER; 589 dcomp = OPAL_IGNORE_RID_DEVICE_NUMBER;
590 fcomp = OPAL_IGNORE_RID_FUNCTION_NUMBER; 590 fcomp = OPAL_IGNORE_RID_FUNCTION_NUMBER;
591 parent = pe->pbus->self; 591 parent = pe->pbus->self;
592 count = pe->pbus->subordinate - pe->pbus->secondary + 1; 592 count = pe->pbus->busn_res.end - pe->pbus->busn_res.start + 1;
593 switch(count) { 593 switch(count) {
594 case 1: bcomp = OpalPciBusAll; break; 594 case 1: bcomp = OpalPciBusAll; break;
595 case 2: bcomp = OpalPciBus7Bits; break; 595 case 2: bcomp = OpalPciBus7Bits; break;
@@ -816,11 +816,11 @@ static void __devinit pnv_ioda_setup_bus_PE(struct pci_dev *dev,
816 pe->pdev = NULL; 816 pe->pdev = NULL;
817 pe->tce32_seg = -1; 817 pe->tce32_seg = -1;
818 pe->mve_number = -1; 818 pe->mve_number = -1;
819 pe->rid = bus->secondary << 8; 819 pe->rid = bus->busn_res.start << 8;
820 pe->dma_weight = 0; 820 pe->dma_weight = 0;
821 821
822 pe_info(pe, "Secondary busses %d..%d associated with PE\n", 822 pe_info(pe, "Secondary busses %pR associated with PE\n",
823 bus->secondary, bus->subordinate); 823 &bus->busn_res);
824 824
825 if (pnv_ioda_configure_pe(phb, pe)) { 825 if (pnv_ioda_configure_pe(phb, pe)) {
826 /* XXX What do we do here ? */ 826 /* XXX What do we do here ? */
diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c
index 3ef46254c35..7698b6e13c5 100644
--- a/arch/powerpc/platforms/powernv/smp.c
+++ b/arch/powerpc/platforms/powernv/smp.c
@@ -106,14 +106,6 @@ static void pnv_smp_cpu_kill_self(void)
106{ 106{
107 unsigned int cpu; 107 unsigned int cpu;
108 108
109 /* If powersave_nap is enabled, use NAP mode, else just
110 * spin aimlessly
111 */
112 if (!powersave_nap) {
113 generic_mach_cpu_die();
114 return;
115 }
116
117 /* Standard hot unplug procedure */ 109 /* Standard hot unplug procedure */
118 local_irq_disable(); 110 local_irq_disable();
119 idle_task_exit(); 111 idle_task_exit();
@@ -128,7 +120,7 @@ static void pnv_smp_cpu_kill_self(void)
128 */ 120 */
129 mtspr(SPRN_LPCR, mfspr(SPRN_LPCR) & ~(u64)LPCR_PECE1); 121 mtspr(SPRN_LPCR, mfspr(SPRN_LPCR) & ~(u64)LPCR_PECE1);
130 while (!generic_check_cpu_restart(cpu)) { 122 while (!generic_check_cpu_restart(cpu)) {
131 power7_idle(); 123 power7_nap();
132 if (!generic_check_cpu_restart(cpu)) { 124 if (!generic_check_cpu_restart(cpu)) {
133 DBG("CPU%d Unexpected exit while offline !\n", cpu); 125 DBG("CPU%d Unexpected exit while offline !\n", cpu);
134 /* We may be getting an IPI, so we re-enable 126 /* We may be getting an IPI, so we re-enable
diff --git a/arch/powerpc/platforms/pseries/eeh_event.c b/arch/powerpc/platforms/pseries/eeh_event.c
index 4cb375c0f8d..fb506317ebb 100644
--- a/arch/powerpc/platforms/pseries/eeh_event.c
+++ b/arch/powerpc/platforms/pseries/eeh_event.c
@@ -85,8 +85,10 @@ static int eeh_event_handler(void * dummy)
85 set_current_state(TASK_INTERRUPTIBLE); /* Don't add to load average */ 85 set_current_state(TASK_INTERRUPTIBLE); /* Don't add to load average */
86 edev = handle_eeh_events(event); 86 edev = handle_eeh_events(event);
87 87
88 eeh_clear_slot(eeh_dev_to_of_node(edev), EEH_MODE_RECOVERING); 88 if (edev) {
89 pci_dev_put(edev->pdev); 89 eeh_clear_slot(eeh_dev_to_of_node(edev), EEH_MODE_RECOVERING);
90 pci_dev_put(edev->pdev);
91 }
90 92
91 kfree(event); 93 kfree(event);
92 mutex_unlock(&eeh_event_mutex); 94 mutex_unlock(&eeh_event_mutex);
diff --git a/arch/powerpc/platforms/pseries/eeh_pseries.c b/arch/powerpc/platforms/pseries/eeh_pseries.c
index 8752f79a6af..c33360ec4f4 100644
--- a/arch/powerpc/platforms/pseries/eeh_pseries.c
+++ b/arch/powerpc/platforms/pseries/eeh_pseries.c
@@ -81,7 +81,7 @@ static int pseries_eeh_init(void)
81 ibm_get_config_addr_info2 = rtas_token("ibm,get-config-addr-info2"); 81 ibm_get_config_addr_info2 = rtas_token("ibm,get-config-addr-info2");
82 ibm_get_config_addr_info = rtas_token("ibm,get-config-addr-info"); 82 ibm_get_config_addr_info = rtas_token("ibm,get-config-addr-info");
83 ibm_configure_pe = rtas_token("ibm,configure-pe"); 83 ibm_configure_pe = rtas_token("ibm,configure-pe");
84 ibm_configure_bridge = rtas_token ("ibm,configure-bridge"); 84 ibm_configure_bridge = rtas_token("ibm,configure-bridge");
85 85
86 /* necessary sanity check */ 86 /* necessary sanity check */
87 if (ibm_set_eeh_option == RTAS_UNKNOWN_SERVICE) { 87 if (ibm_set_eeh_option == RTAS_UNKNOWN_SERVICE) {
@@ -89,7 +89,7 @@ static int pseries_eeh_init(void)
89 __func__); 89 __func__);
90 return -EINVAL; 90 return -EINVAL;
91 } else if (ibm_set_slot_reset == RTAS_UNKNOWN_SERVICE) { 91 } else if (ibm_set_slot_reset == RTAS_UNKNOWN_SERVICE) {
92 pr_warning("%s: RTAS service <ibm, set-slot-reset> invalid\n", 92 pr_warning("%s: RTAS service <ibm,set-slot-reset> invalid\n",
93 __func__); 93 __func__);
94 return -EINVAL; 94 return -EINVAL;
95 } else if (ibm_read_slot_reset_state2 == RTAS_UNKNOWN_SERVICE && 95 } else if (ibm_read_slot_reset_state2 == RTAS_UNKNOWN_SERVICE &&
diff --git a/arch/powerpc/platforms/pseries/hvCall.S b/arch/powerpc/platforms/pseries/hvCall.S
index 3ce73d0052b..444fe7759e5 100644
--- a/arch/powerpc/platforms/pseries/hvCall.S
+++ b/arch/powerpc/platforms/pseries/hvCall.S
@@ -13,8 +13,6 @@
13#include <asm/asm-offsets.h> 13#include <asm/asm-offsets.h>
14#include <asm/ptrace.h> 14#include <asm/ptrace.h>
15 15
16#define STK_PARM(i) (48 + ((i)-3)*8)
17
18#ifdef CONFIG_TRACEPOINTS 16#ifdef CONFIG_TRACEPOINTS
19 17
20 .section ".toc","aw" 18 .section ".toc","aw"
@@ -26,7 +24,7 @@ hcall_tracepoint_refcount:
26 .section ".text" 24 .section ".text"
27 25
28/* 26/*
29 * precall must preserve all registers. use unused STK_PARM() 27 * precall must preserve all registers. use unused STK_PARAM()
30 * areas to save snapshots and opcode. We branch around this 28 * areas to save snapshots and opcode. We branch around this
31 * in early init (eg when populating the MMU hashtable) by using an 29 * in early init (eg when populating the MMU hashtable) by using an
32 * unconditional cpu feature. 30 * unconditional cpu feature.
@@ -40,28 +38,28 @@ END_FTR_SECTION(0, 1); \
40 cmpdi r12,0; \ 38 cmpdi r12,0; \
41 beq+ 1f; \ 39 beq+ 1f; \
42 mflr r0; \ 40 mflr r0; \
43 std r3,STK_PARM(r3)(r1); \ 41 std r3,STK_PARAM(R3)(r1); \
44 std r4,STK_PARM(r4)(r1); \ 42 std r4,STK_PARAM(R4)(r1); \
45 std r5,STK_PARM(r5)(r1); \ 43 std r5,STK_PARAM(R5)(r1); \
46 std r6,STK_PARM(r6)(r1); \ 44 std r6,STK_PARAM(R6)(r1); \
47 std r7,STK_PARM(r7)(r1); \ 45 std r7,STK_PARAM(R7)(r1); \
48 std r8,STK_PARM(r8)(r1); \ 46 std r8,STK_PARAM(R8)(r1); \
49 std r9,STK_PARM(r9)(r1); \ 47 std r9,STK_PARAM(R9)(r1); \
50 std r10,STK_PARM(r10)(r1); \ 48 std r10,STK_PARAM(R10)(r1); \
51 std r0,16(r1); \ 49 std r0,16(r1); \
52 addi r4,r1,STK_PARM(FIRST_REG); \ 50 addi r4,r1,STK_PARAM(FIRST_REG); \
53 stdu r1,-STACK_FRAME_OVERHEAD(r1); \ 51 stdu r1,-STACK_FRAME_OVERHEAD(r1); \
54 bl .__trace_hcall_entry; \ 52 bl .__trace_hcall_entry; \
55 addi r1,r1,STACK_FRAME_OVERHEAD; \ 53 addi r1,r1,STACK_FRAME_OVERHEAD; \
56 ld r0,16(r1); \ 54 ld r0,16(r1); \
57 ld r3,STK_PARM(r3)(r1); \ 55 ld r3,STK_PARAM(R3)(r1); \
58 ld r4,STK_PARM(r4)(r1); \ 56 ld r4,STK_PARAM(R4)(r1); \
59 ld r5,STK_PARM(r5)(r1); \ 57 ld r5,STK_PARAM(R5)(r1); \
60 ld r6,STK_PARM(r6)(r1); \ 58 ld r6,STK_PARAM(R6)(r1); \
61 ld r7,STK_PARM(r7)(r1); \ 59 ld r7,STK_PARAM(R7)(r1); \
62 ld r8,STK_PARM(r8)(r1); \ 60 ld r8,STK_PARAM(R8)(r1); \
63 ld r9,STK_PARM(r9)(r1); \ 61 ld r9,STK_PARAM(R9)(r1); \
64 ld r10,STK_PARM(r10)(r1); \ 62 ld r10,STK_PARAM(R10)(r1); \
65 mtlr r0; \ 63 mtlr r0; \
661: 641:
67 65
@@ -79,8 +77,8 @@ END_FTR_SECTION(0, 1); \
79 cmpdi r12,0; \ 77 cmpdi r12,0; \
80 beq+ 1f; \ 78 beq+ 1f; \
81 mflr r0; \ 79 mflr r0; \
82 ld r6,STK_PARM(r3)(r1); \ 80 ld r6,STK_PARAM(R3)(r1); \
83 std r3,STK_PARM(r3)(r1); \ 81 std r3,STK_PARAM(R3)(r1); \
84 mr r4,r3; \ 82 mr r4,r3; \
85 mr r3,r6; \ 83 mr r3,r6; \
86 std r0,16(r1); \ 84 std r0,16(r1); \
@@ -88,7 +86,7 @@ END_FTR_SECTION(0, 1); \
88 bl .__trace_hcall_exit; \ 86 bl .__trace_hcall_exit; \
89 addi r1,r1,STACK_FRAME_OVERHEAD; \ 87 addi r1,r1,STACK_FRAME_OVERHEAD; \
90 ld r0,16(r1); \ 88 ld r0,16(r1); \
91 ld r3,STK_PARM(r3)(r1); \ 89 ld r3,STK_PARAM(R3)(r1); \
92 mtlr r0; \ 90 mtlr r0; \
931: 911:
94 92
@@ -114,7 +112,7 @@ _GLOBAL(plpar_hcall_norets)
114 mfcr r0 112 mfcr r0
115 stw r0,8(r1) 113 stw r0,8(r1)
116 114
117 HCALL_INST_PRECALL(r4) 115 HCALL_INST_PRECALL(R4)
118 116
119 HVSC /* invoke the hypervisor */ 117 HVSC /* invoke the hypervisor */
120 118
@@ -130,9 +128,9 @@ _GLOBAL(plpar_hcall)
130 mfcr r0 128 mfcr r0
131 stw r0,8(r1) 129 stw r0,8(r1)
132 130
133 HCALL_INST_PRECALL(r5) 131 HCALL_INST_PRECALL(R5)
134 132
135 std r4,STK_PARM(r4)(r1) /* Save ret buffer */ 133 std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
136 134
137 mr r4,r5 135 mr r4,r5
138 mr r5,r6 136 mr r5,r6
@@ -143,7 +141,7 @@ _GLOBAL(plpar_hcall)
143 141
144 HVSC /* invoke the hypervisor */ 142 HVSC /* invoke the hypervisor */
145 143
146 ld r12,STK_PARM(r4)(r1) 144 ld r12,STK_PARAM(R4)(r1)
147 std r4, 0(r12) 145 std r4, 0(r12)
148 std r5, 8(r12) 146 std r5, 8(r12)
149 std r6, 16(r12) 147 std r6, 16(r12)
@@ -168,7 +166,7 @@ _GLOBAL(plpar_hcall_raw)
168 mfcr r0 166 mfcr r0
169 stw r0,8(r1) 167 stw r0,8(r1)
170 168
171 std r4,STK_PARM(r4)(r1) /* Save ret buffer */ 169 std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
172 170
173 mr r4,r5 171 mr r4,r5
174 mr r5,r6 172 mr r5,r6
@@ -179,7 +177,7 @@ _GLOBAL(plpar_hcall_raw)
179 177
180 HVSC /* invoke the hypervisor */ 178 HVSC /* invoke the hypervisor */
181 179
182 ld r12,STK_PARM(r4)(r1) 180 ld r12,STK_PARAM(R4)(r1)
183 std r4, 0(r12) 181 std r4, 0(r12)
184 std r5, 8(r12) 182 std r5, 8(r12)
185 std r6, 16(r12) 183 std r6, 16(r12)
@@ -196,9 +194,9 @@ _GLOBAL(plpar_hcall9)
196 mfcr r0 194 mfcr r0
197 stw r0,8(r1) 195 stw r0,8(r1)
198 196
199 HCALL_INST_PRECALL(r5) 197 HCALL_INST_PRECALL(R5)
200 198
201 std r4,STK_PARM(r4)(r1) /* Save ret buffer */ 199 std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
202 200
203 mr r4,r5 201 mr r4,r5
204 mr r5,r6 202 mr r5,r6
@@ -206,14 +204,14 @@ _GLOBAL(plpar_hcall9)
206 mr r7,r8 204 mr r7,r8
207 mr r8,r9 205 mr r8,r9
208 mr r9,r10 206 mr r9,r10
209 ld r10,STK_PARM(r11)(r1) /* put arg7 in R10 */ 207 ld r10,STK_PARAM(R11)(r1) /* put arg7 in R10 */
210 ld r11,STK_PARM(r12)(r1) /* put arg8 in R11 */ 208 ld r11,STK_PARAM(R12)(r1) /* put arg8 in R11 */
211 ld r12,STK_PARM(r13)(r1) /* put arg9 in R12 */ 209 ld r12,STK_PARAM(R13)(r1) /* put arg9 in R12 */
212 210
213 HVSC /* invoke the hypervisor */ 211 HVSC /* invoke the hypervisor */
214 212
215 mr r0,r12 213 mr r0,r12
216 ld r12,STK_PARM(r4)(r1) 214 ld r12,STK_PARAM(R4)(r1)
217 std r4, 0(r12) 215 std r4, 0(r12)
218 std r5, 8(r12) 216 std r5, 8(r12)
219 std r6, 16(r12) 217 std r6, 16(r12)
@@ -238,7 +236,7 @@ _GLOBAL(plpar_hcall9_raw)
238 mfcr r0 236 mfcr r0
239 stw r0,8(r1) 237 stw r0,8(r1)
240 238
241 std r4,STK_PARM(r4)(r1) /* Save ret buffer */ 239 std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
242 240
243 mr r4,r5 241 mr r4,r5
244 mr r5,r6 242 mr r5,r6
@@ -246,14 +244,14 @@ _GLOBAL(plpar_hcall9_raw)
246 mr r7,r8 244 mr r7,r8
247 mr r8,r9 245 mr r8,r9
248 mr r9,r10 246 mr r9,r10
249 ld r10,STK_PARM(r11)(r1) /* put arg7 in R10 */ 247 ld r10,STK_PARAM(R11)(r1) /* put arg7 in R10 */
250 ld r11,STK_PARM(r12)(r1) /* put arg8 in R11 */ 248 ld r11,STK_PARAM(R12)(r1) /* put arg8 in R11 */
251 ld r12,STK_PARM(r13)(r1) /* put arg9 in R12 */ 249 ld r12,STK_PARAM(R13)(r1) /* put arg9 in R12 */
252 250
253 HVSC /* invoke the hypervisor */ 251 HVSC /* invoke the hypervisor */
254 252
255 mr r0,r12 253 mr r0,r12
256 ld r12,STK_PARM(r4)(r1) 254 ld r12,STK_PARAM(R4)(r1)
257 std r4, 0(r12) 255 std r4, 0(r12)
258 std r5, 8(r12) 256 std r5, 8(r12)
259 std r6, 16(r12) 257 std r6, 16(r12)
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index 2d311c0caf8..bca220f2873 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -192,12 +192,15 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
192 long l, limit; 192 long l, limit;
193 long tcenum_start = tcenum, npages_start = npages; 193 long tcenum_start = tcenum, npages_start = npages;
194 int ret = 0; 194 int ret = 0;
195 unsigned long flags;
195 196
196 if (npages == 1) { 197 if (npages == 1) {
197 return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr, 198 return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr,
198 direction, attrs); 199 direction, attrs);
199 } 200 }
200 201
202 local_irq_save(flags); /* to protect tcep and the page behind it */
203
201 tcep = __get_cpu_var(tce_page); 204 tcep = __get_cpu_var(tce_page);
202 205
203 /* This is safe to do since interrupts are off when we're called 206 /* This is safe to do since interrupts are off when we're called
@@ -207,6 +210,7 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
207 tcep = (u64 *)__get_free_page(GFP_ATOMIC); 210 tcep = (u64 *)__get_free_page(GFP_ATOMIC);
208 /* If allocation fails, fall back to the loop implementation */ 211 /* If allocation fails, fall back to the loop implementation */
209 if (!tcep) { 212 if (!tcep) {
213 local_irq_restore(flags);
210 return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr, 214 return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr,
211 direction, attrs); 215 direction, attrs);
212 } 216 }
@@ -240,6 +244,8 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
240 tcenum += limit; 244 tcenum += limit;
241 } while (npages > 0 && !rc); 245 } while (npages > 0 && !rc);
242 246
247 local_irq_restore(flags);
248
243 if (unlikely(rc == H_NOT_ENOUGH_RESOURCES)) { 249 if (unlikely(rc == H_NOT_ENOUGH_RESOURCES)) {
244 ret = (int)rc; 250 ret = (int)rc;
245 tce_freemulti_pSeriesLP(tbl, tcenum_start, 251 tce_freemulti_pSeriesLP(tbl, tcenum_start,
@@ -707,6 +713,21 @@ static int __init disable_ddw_setup(char *str)
707 713
708early_param("disable_ddw", disable_ddw_setup); 714early_param("disable_ddw", disable_ddw_setup);
709 715
716static inline void __remove_ddw(struct device_node *np, const u32 *ddw_avail, u64 liobn)
717{
718 int ret;
719
720 ret = rtas_call(ddw_avail[2], 1, 1, NULL, liobn);
721 if (ret)
722 pr_warning("%s: failed to remove DMA window: rtas returned "
723 "%d to ibm,remove-pe-dma-window(%x) %llx\n",
724 np->full_name, ret, ddw_avail[2], liobn);
725 else
726 pr_debug("%s: successfully removed DMA window: rtas returned "
727 "%d to ibm,remove-pe-dma-window(%x) %llx\n",
728 np->full_name, ret, ddw_avail[2], liobn);
729}
730
710static void remove_ddw(struct device_node *np) 731static void remove_ddw(struct device_node *np)
711{ 732{
712 struct dynamic_dma_window_prop *dwp; 733 struct dynamic_dma_window_prop *dwp;
@@ -736,15 +757,7 @@ static void remove_ddw(struct device_node *np)
736 pr_debug("%s successfully cleared tces in window.\n", 757 pr_debug("%s successfully cleared tces in window.\n",
737 np->full_name); 758 np->full_name);
738 759
739 ret = rtas_call(ddw_avail[2], 1, 1, NULL, liobn); 760 __remove_ddw(np, ddw_avail, liobn);
740 if (ret)
741 pr_warning("%s: failed to remove direct window: rtas returned "
742 "%d to ibm,remove-pe-dma-window(%x) %llx\n",
743 np->full_name, ret, ddw_avail[2], liobn);
744 else
745 pr_debug("%s: successfully removed direct window: rtas returned "
746 "%d to ibm,remove-pe-dma-window(%x) %llx\n",
747 np->full_name, ret, ddw_avail[2], liobn);
748 761
749delprop: 762delprop:
750 ret = prom_remove_property(np, win64); 763 ret = prom_remove_property(np, win64);
@@ -869,6 +882,35 @@ static int create_ddw(struct pci_dev *dev, const u32 *ddw_avail,
869 return ret; 882 return ret;
870} 883}
871 884
885static void restore_default_window(struct pci_dev *dev,
886 u32 ddw_restore_token, unsigned long liobn)
887{
888 struct eeh_dev *edev;
889 u32 cfg_addr;
890 u64 buid;
891 int ret;
892
893 /*
894 * Get the config address and phb buid of the PE window.
895 * Rely on eeh to retrieve this for us.
896 * Retrieve them from the pci device, not the node with the
897 * dma-window property
898 */
899 edev = pci_dev_to_eeh_dev(dev);
900 cfg_addr = edev->config_addr;
901 if (edev->pe_config_addr)
902 cfg_addr = edev->pe_config_addr;
903 buid = edev->phb->buid;
904
905 do {
906 ret = rtas_call(ddw_restore_token, 3, 1, NULL, cfg_addr,
907 BUID_HI(buid), BUID_LO(buid));
908 } while (rtas_busy_delay(ret));
909 dev_info(&dev->dev,
910 "ibm,reset-pe-dma-windows(%x) %x %x %x returned %d\n",
911 ddw_restore_token, cfg_addr, BUID_HI(buid), BUID_LO(buid), ret);
912}
913
872/* 914/*
873 * If the PE supports dynamic dma windows, and there is space for a table 915 * If the PE supports dynamic dma windows, and there is space for a table
874 * that can map all pages in a linear offset, then setup such a table, 916 * that can map all pages in a linear offset, then setup such a table,
@@ -889,9 +931,13 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
889 u64 dma_addr, max_addr; 931 u64 dma_addr, max_addr;
890 struct device_node *dn; 932 struct device_node *dn;
891 const u32 *uninitialized_var(ddw_avail); 933 const u32 *uninitialized_var(ddw_avail);
934 const u32 *uninitialized_var(ddw_extensions);
935 u32 ddw_restore_token = 0;
892 struct direct_window *window; 936 struct direct_window *window;
893 struct property *win64; 937 struct property *win64;
894 struct dynamic_dma_window_prop *ddwprop; 938 struct dynamic_dma_window_prop *ddwprop;
939 const void *dma_window = NULL;
940 unsigned long liobn, offset, size;
895 941
896 mutex_lock(&direct_window_init_mutex); 942 mutex_lock(&direct_window_init_mutex);
897 943
@@ -911,7 +957,40 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
911 if (!ddw_avail || len < 3 * sizeof(u32)) 957 if (!ddw_avail || len < 3 * sizeof(u32))
912 goto out_unlock; 958 goto out_unlock;
913 959
914 /* 960 /*
961 * the extensions property is only required to exist in certain
962 * levels of firmware and later
963 * the ibm,ddw-extensions property is a list with the first
964 * element containing the number of extensions and each
965 * subsequent entry is a value corresponding to that extension
966 */
967 ddw_extensions = of_get_property(pdn, "ibm,ddw-extensions", &len);
968 if (ddw_extensions) {
969 /*
970 * each new defined extension length should be added to
971 * the top of the switch so the "earlier" entries also
972 * get picked up
973 */
974 switch (ddw_extensions[0]) {
975 /* ibm,reset-pe-dma-windows */
976 case 1:
977 ddw_restore_token = ddw_extensions[1];
978 break;
979 }
980 }
981
982 /*
983 * Only remove the existing DMA window if we can restore back to
984 * the default state. Removing the existing window maximizes the
985 * resources available to firmware for dynamic window creation.
986 */
987 if (ddw_restore_token) {
988 dma_window = of_get_property(pdn, "ibm,dma-window", NULL);
989 of_parse_dma_window(pdn, dma_window, &liobn, &offset, &size);
990 __remove_ddw(pdn, ddw_avail, liobn);
991 }
992
993 /*
915 * Query if there is a second window of size to map the 994 * Query if there is a second window of size to map the
916 * whole partition. Query returns number of windows, largest 995 * whole partition. Query returns number of windows, largest
917 * block assigned to PE (partition endpoint), and two bitmasks 996 * block assigned to PE (partition endpoint), and two bitmasks
@@ -920,7 +999,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
920 dn = pci_device_to_OF_node(dev); 999 dn = pci_device_to_OF_node(dev);
921 ret = query_ddw(dev, ddw_avail, &query); 1000 ret = query_ddw(dev, ddw_avail, &query);
922 if (ret != 0) 1001 if (ret != 0)
923 goto out_unlock; 1002 goto out_restore_window;
924 1003
925 if (query.windows_available == 0) { 1004 if (query.windows_available == 0) {
926 /* 1005 /*
@@ -929,7 +1008,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
929 * trading in for a larger page size. 1008 * trading in for a larger page size.
930 */ 1009 */
931 dev_dbg(&dev->dev, "no free dynamic windows"); 1010 dev_dbg(&dev->dev, "no free dynamic windows");
932 goto out_unlock; 1011 goto out_restore_window;
933 } 1012 }
934 if (query.page_size & 4) { 1013 if (query.page_size & 4) {
935 page_shift = 24; /* 16MB */ 1014 page_shift = 24; /* 16MB */
@@ -940,7 +1019,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
940 } else { 1019 } else {
941 dev_dbg(&dev->dev, "no supported direct page size in mask %x", 1020 dev_dbg(&dev->dev, "no supported direct page size in mask %x",
942 query.page_size); 1021 query.page_size);
943 goto out_unlock; 1022 goto out_restore_window;
944 } 1023 }
945 /* verify the window * number of ptes will map the partition */ 1024 /* verify the window * number of ptes will map the partition */
946 /* check largest block * page size > max memory hotplug addr */ 1025 /* check largest block * page size > max memory hotplug addr */
@@ -949,14 +1028,14 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
949 dev_dbg(&dev->dev, "can't map partiton max 0x%llx with %u " 1028 dev_dbg(&dev->dev, "can't map partiton max 0x%llx with %u "
950 "%llu-sized pages\n", max_addr, query.largest_available_block, 1029 "%llu-sized pages\n", max_addr, query.largest_available_block,
951 1ULL << page_shift); 1030 1ULL << page_shift);
952 goto out_unlock; 1031 goto out_restore_window;
953 } 1032 }
954 len = order_base_2(max_addr); 1033 len = order_base_2(max_addr);
955 win64 = kzalloc(sizeof(struct property), GFP_KERNEL); 1034 win64 = kzalloc(sizeof(struct property), GFP_KERNEL);
956 if (!win64) { 1035 if (!win64) {
957 dev_info(&dev->dev, 1036 dev_info(&dev->dev,
958 "couldn't allocate property for 64bit dma window\n"); 1037 "couldn't allocate property for 64bit dma window\n");
959 goto out_unlock; 1038 goto out_restore_window;
960 } 1039 }
961 win64->name = kstrdup(DIRECT64_PROPNAME, GFP_KERNEL); 1040 win64->name = kstrdup(DIRECT64_PROPNAME, GFP_KERNEL);
962 win64->value = ddwprop = kmalloc(sizeof(*ddwprop), GFP_KERNEL); 1041 win64->value = ddwprop = kmalloc(sizeof(*ddwprop), GFP_KERNEL);
@@ -1018,6 +1097,10 @@ out_free_prop:
1018 kfree(win64->value); 1097 kfree(win64->value);
1019 kfree(win64); 1098 kfree(win64);
1020 1099
1100out_restore_window:
1101 if (ddw_restore_token)
1102 restore_default_window(dev, ddw_restore_token, liobn);
1103
1021out_unlock: 1104out_unlock:
1022 mutex_unlock(&direct_window_init_mutex); 1105 mutex_unlock(&direct_window_init_mutex);
1023 return dma_addr; 1106 return dma_addr;
@@ -1051,7 +1134,7 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
1051 if (!pdn || !PCI_DN(pdn)) { 1134 if (!pdn || !PCI_DN(pdn)) {
1052 printk(KERN_WARNING "pci_dma_dev_setup_pSeriesLP: " 1135 printk(KERN_WARNING "pci_dma_dev_setup_pSeriesLP: "
1053 "no DMA window found for pci dev=%s dn=%s\n", 1136 "no DMA window found for pci dev=%s dn=%s\n",
1054 pci_name(dev), dn? dn->full_name : "<null>"); 1137 pci_name(dev), of_node_full_name(dn));
1055 return; 1138 return;
1056 } 1139 }
1057 pr_debug(" parent is %s\n", pdn->full_name); 1140 pr_debug(" parent is %s\n", pdn->full_name);
diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c
index 029a562af37..dd30b12edfe 100644
--- a/arch/powerpc/platforms/pseries/mobility.c
+++ b/arch/powerpc/platforms/pseries/mobility.c
@@ -67,7 +67,6 @@ static int update_dt_property(struct device_node *dn, struct property **prop,
67 const char *name, u32 vd, char *value) 67 const char *name, u32 vd, char *value)
68{ 68{
69 struct property *new_prop = *prop; 69 struct property *new_prop = *prop;
70 struct property *old_prop;
71 int more = 0; 70 int more = 0;
72 71
73 /* A negative 'vd' value indicates that only part of the new property 72 /* A negative 'vd' value indicates that only part of the new property
@@ -117,12 +116,7 @@ static int update_dt_property(struct device_node *dn, struct property **prop,
117 } 116 }
118 117
119 if (!more) { 118 if (!more) {
120 old_prop = of_find_property(dn, new_prop->name, NULL); 119 prom_update_property(dn, new_prop);
121 if (old_prop)
122 prom_update_property(dn, new_prop, old_prop);
123 else
124 prom_add_property(dn, new_prop);
125
126 new_prop = NULL; 120 new_prop = NULL;
127 } 121 }
128 122
diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c
index 8b7bafa489c..3ccebc83dc0 100644
--- a/arch/powerpc/platforms/pseries/pci_dlpar.c
+++ b/arch/powerpc/platforms/pseries/pci_dlpar.c
@@ -121,7 +121,7 @@ void pcibios_add_pci_devices(struct pci_bus * bus)
121 if (!num) 121 if (!num)
122 return; 122 return;
123 pcibios_setup_bus_devices(bus); 123 pcibios_setup_bus_devices(bus);
124 max = bus->secondary; 124 max = bus->busn_res.start;
125 for (pass=0; pass < 2; pass++) 125 for (pass=0; pass < 2; pass++)
126 list_for_each_entry(dev, &bus->devices, bus_list) { 126 list_for_each_entry(dev, &bus->devices, bus_list) {
127 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || 127 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
diff --git a/arch/powerpc/platforms/pseries/processor_idle.c b/arch/powerpc/platforms/pseries/processor_idle.c
index c71be66bd5d..455760b1fe6 100644
--- a/arch/powerpc/platforms/pseries/processor_idle.c
+++ b/arch/powerpc/platforms/pseries/processor_idle.c
@@ -11,6 +11,7 @@
11#include <linux/moduleparam.h> 11#include <linux/moduleparam.h>
12#include <linux/cpuidle.h> 12#include <linux/cpuidle.h>
13#include <linux/cpu.h> 13#include <linux/cpu.h>
14#include <linux/notifier.h>
14 15
15#include <asm/paca.h> 16#include <asm/paca.h>
16#include <asm/reg.h> 17#include <asm/reg.h>
@@ -189,17 +190,40 @@ static struct cpuidle_state shared_states[MAX_IDLE_STATE_COUNT] = {
189 .enter = &shared_cede_loop }, 190 .enter = &shared_cede_loop },
190}; 191};
191 192
192int pseries_notify_cpuidle_add_cpu(int cpu) 193static int pseries_cpuidle_add_cpu_notifier(struct notifier_block *n,
194 unsigned long action, void *hcpu)
193{ 195{
196 int hotcpu = (unsigned long)hcpu;
194 struct cpuidle_device *dev = 197 struct cpuidle_device *dev =
195 per_cpu_ptr(pseries_cpuidle_devices, cpu); 198 per_cpu_ptr(pseries_cpuidle_devices, hotcpu);
199
196 if (dev && cpuidle_get_driver()) { 200 if (dev && cpuidle_get_driver()) {
197 cpuidle_disable_device(dev); 201 switch (action) {
198 cpuidle_enable_device(dev); 202 case CPU_ONLINE:
203 case CPU_ONLINE_FROZEN:
204 cpuidle_pause_and_lock();
205 cpuidle_enable_device(dev);
206 cpuidle_resume_and_unlock();
207 break;
208
209 case CPU_DEAD:
210 case CPU_DEAD_FROZEN:
211 cpuidle_pause_and_lock();
212 cpuidle_disable_device(dev);
213 cpuidle_resume_and_unlock();
214 break;
215
216 default:
217 return NOTIFY_DONE;
218 }
199 } 219 }
200 return 0; 220 return NOTIFY_OK;
201} 221}
202 222
223static struct notifier_block setup_hotplug_notifier = {
224 .notifier_call = pseries_cpuidle_add_cpu_notifier,
225};
226
203/* 227/*
204 * pseries_cpuidle_driver_init() 228 * pseries_cpuidle_driver_init()
205 */ 229 */
@@ -324,6 +348,7 @@ static int __init pseries_processor_idle_init(void)
324 return retval; 348 return retval;
325 } 349 }
326 350
351 register_cpu_notifier(&setup_hotplug_notifier);
327 printk(KERN_DEBUG "pseries_idle_driver registered\n"); 352 printk(KERN_DEBUG "pseries_idle_driver registered\n");
328 353
329 return 0; 354 return 0;
@@ -332,6 +357,7 @@ static int __init pseries_processor_idle_init(void)
332static void __exit pseries_processor_idle_exit(void) 357static void __exit pseries_processor_idle_exit(void)
333{ 358{
334 359
360 unregister_cpu_notifier(&setup_hotplug_notifier);
335 pseries_idle_devices_uninit(); 361 pseries_idle_devices_uninit();
336 cpuidle_unregister_driver(&pseries_idle_driver); 362 cpuidle_unregister_driver(&pseries_idle_driver);
337 363
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
index 7b3bf76ef83..39f71fba9b3 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -432,7 +432,7 @@ static int do_update_property(char *buf, size_t bufsize)
432 unsigned char *value; 432 unsigned char *value;
433 char *name, *end, *next_prop; 433 char *name, *end, *next_prop;
434 int rc, length; 434 int rc, length;
435 struct property *newprop, *oldprop; 435 struct property *newprop;
436 buf = parse_node(buf, bufsize, &np); 436 buf = parse_node(buf, bufsize, &np);
437 end = buf + bufsize; 437 end = buf + bufsize;
438 438
@@ -443,6 +443,9 @@ static int do_update_property(char *buf, size_t bufsize)
443 if (!next_prop) 443 if (!next_prop)
444 return -EINVAL; 444 return -EINVAL;
445 445
446 if (!strlen(name))
447 return -ENODEV;
448
446 newprop = new_property(name, length, value, NULL); 449 newprop = new_property(name, length, value, NULL);
447 if (!newprop) 450 if (!newprop)
448 return -ENOMEM; 451 return -ENOMEM;
@@ -450,18 +453,11 @@ static int do_update_property(char *buf, size_t bufsize)
450 if (!strcmp(name, "slb-size") || !strcmp(name, "ibm,slb-size")) 453 if (!strcmp(name, "slb-size") || !strcmp(name, "ibm,slb-size"))
451 slb_set_size(*(int *)value); 454 slb_set_size(*(int *)value);
452 455
453 oldprop = of_find_property(np, name,NULL);
454 if (!oldprop) {
455 if (strlen(name))
456 return prom_add_property(np, newprop);
457 return -ENODEV;
458 }
459
460 upd_value.node = np; 456 upd_value.node = np;
461 upd_value.property = newprop; 457 upd_value.property = newprop;
462 pSeries_reconfig_notify(PSERIES_UPDATE_PROPERTY, &upd_value); 458 pSeries_reconfig_notify(PSERIES_UPDATE_PROPERTY, &upd_value);
463 459
464 rc = prom_update_property(np, newprop, oldprop); 460 rc = prom_update_property(np, newprop);
465 if (rc) 461 if (rc)
466 return rc; 462 return rc;
467 463
@@ -486,7 +482,7 @@ static int do_update_property(char *buf, size_t bufsize)
486 482
487 rc = pSeries_reconfig_notify(action, value); 483 rc = pSeries_reconfig_notify(action, value);
488 if (rc) { 484 if (rc) {
489 prom_update_property(np, oldprop, newprop); 485 prom_update_property(np, newprop);
490 return rc; 486 return rc;
491 } 487 }
492 } 488 }
diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
index e16bb8d4855..71706bc34a0 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -147,7 +147,6 @@ static void __devinit smp_xics_setup_cpu(int cpu)
147 set_cpu_current_state(cpu, CPU_STATE_ONLINE); 147 set_cpu_current_state(cpu, CPU_STATE_ONLINE);
148 set_default_offline_state(cpu); 148 set_default_offline_state(cpu);
149#endif 149#endif
150 pseries_notify_cpuidle_add_cpu(cpu);
151} 150}
152 151
153static int __devinit smp_pSeries_kick_cpu(int nr) 152static int __devinit smp_pSeries_kick_cpu(int nr)
diff --git a/arch/powerpc/sysdev/6xx-suspend.S b/arch/powerpc/sysdev/6xx-suspend.S
index 21cda085d92..cf48e9cb257 100644
--- a/arch/powerpc/sysdev/6xx-suspend.S
+++ b/arch/powerpc/sysdev/6xx-suspend.S
@@ -29,7 +29,7 @@ _GLOBAL(mpc6xx_enter_standby)
29 ori r5, r5, ret_from_standby@l 29 ori r5, r5, ret_from_standby@l
30 mtlr r5 30 mtlr r5
31 31
32 rlwinm r5, r1, 0, 0, 31-THREAD_SHIFT 32 CURRENT_THREAD_INFO(r5, r1)
33 lwz r6, TI_LOCAL_FLAGS(r5) 33 lwz r6, TI_LOCAL_FLAGS(r5)
34 ori r6, r6, _TLF_SLEEPING 34 ori r6, r6, _TLF_SLEEPING
35 stw r6, TI_LOCAL_FLAGS(r5) 35 stw r6, TI_LOCAL_FLAGS(r5)
diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h b/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h
index 60c9c0bd5ba..2aa97ddb7b7 100644
--- a/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h
+++ b/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright 2009-2010 Freescale Semiconductor, Inc 2 * Copyright 2009-2010, 2012 Freescale Semiconductor, Inc
3 * 3 *
4 * QorIQ based Cache Controller Memory Mapped Registers 4 * QorIQ based Cache Controller Memory Mapped Registers
5 * 5 *
@@ -91,7 +91,7 @@ struct mpc85xx_l2ctlr {
91 91
92struct sram_parameters { 92struct sram_parameters {
93 unsigned int sram_size; 93 unsigned int sram_size;
94 uint64_t sram_offset; 94 phys_addr_t sram_offset;
95}; 95};
96 96
97extern int instantiate_cache_sram(struct platform_device *dev, 97extern int instantiate_cache_sram(struct platform_device *dev,
diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
index cedabd0f4bf..68ac3aacb19 100644
--- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
+++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright 2009-2010 Freescale Semiconductor, Inc. 2 * Copyright 2009-2010, 2012 Freescale Semiconductor, Inc.
3 * 3 *
4 * QorIQ (P1/P2) L2 controller init for Cache-SRAM instantiation 4 * QorIQ (P1/P2) L2 controller init for Cache-SRAM instantiation
5 * 5 *
@@ -31,24 +31,21 @@ static char *sram_size;
31static char *sram_offset; 31static char *sram_offset;
32struct mpc85xx_l2ctlr __iomem *l2ctlr; 32struct mpc85xx_l2ctlr __iomem *l2ctlr;
33 33
34static long get_cache_sram_size(void) 34static int get_cache_sram_params(struct sram_parameters *sram_params)
35{ 35{
36 unsigned long val; 36 unsigned long long addr;
37 unsigned int size;
37 38
38 if (!sram_size || (strict_strtoul(sram_size, 0, &val) < 0)) 39 if (!sram_size || (kstrtouint(sram_size, 0, &size) < 0))
39 return -EINVAL; 40 return -EINVAL;
40 41
41 return val; 42 if (!sram_offset || (kstrtoull(sram_offset, 0, &addr) < 0))
42}
43
44static long get_cache_sram_offset(void)
45{
46 unsigned long val;
47
48 if (!sram_offset || (strict_strtoul(sram_offset, 0, &val) < 0))
49 return -EINVAL; 43 return -EINVAL;
50 44
51 return val; 45 sram_params->sram_offset = addr;
46 sram_params->sram_size = size;
47
48 return 0;
52} 49}
53 50
54static int __init get_size_from_cmdline(char *str) 51static int __init get_size_from_cmdline(char *str)
@@ -93,17 +90,9 @@ static int __devinit mpc85xx_l2ctlr_of_probe(struct platform_device *dev)
93 } 90 }
94 l2cache_size = *prop; 91 l2cache_size = *prop;
95 92
96 sram_params.sram_size = get_cache_sram_size(); 93 if (get_cache_sram_params(&sram_params)) {
97 if ((int)sram_params.sram_size <= 0) {
98 dev_err(&dev->dev,
99 "Entire L2 as cache, Aborting Cache-SRAM stuff\n");
100 return -EINVAL;
101 }
102
103 sram_params.sram_offset = get_cache_sram_offset();
104 if ((int64_t)sram_params.sram_offset <= 0) {
105 dev_err(&dev->dev, 94 dev_err(&dev->dev,
106 "Entire L2 as cache, provide a valid sram offset\n"); 95 "Entire L2 as cache, provide valid sram offset and size\n");
107 return -EINVAL; 96 return -EINVAL;
108 } 97 }
109 98
@@ -125,14 +114,14 @@ static int __devinit mpc85xx_l2ctlr_of_probe(struct platform_device *dev)
125 * Write bits[0-17] to srbar0 114 * Write bits[0-17] to srbar0
126 */ 115 */
127 out_be32(&l2ctlr->srbar0, 116 out_be32(&l2ctlr->srbar0,
128 sram_params.sram_offset & L2SRAM_BAR_MSK_LO18); 117 lower_32_bits(sram_params.sram_offset) & L2SRAM_BAR_MSK_LO18);
129 118
130 /* 119 /*
131 * Write bits[18-21] to srbare0 120 * Write bits[18-21] to srbare0
132 */ 121 */
133#ifdef CONFIG_PHYS_64BIT 122#ifdef CONFIG_PHYS_64BIT
134 out_be32(&l2ctlr->srbarea0, 123 out_be32(&l2ctlr->srbarea0,
135 (sram_params.sram_offset >> 32) & L2SRAM_BARE_MSK_HI4); 124 upper_32_bits(sram_params.sram_offset) & L2SRAM_BARE_MSK_HI4);
136#endif 125#endif
137 126
138 clrsetbits_be32(&l2ctlr->ctl, L2CR_L2E, L2CR_L2FI); 127 clrsetbits_be32(&l2ctlr->ctl, L2CR_L2E, L2CR_L2FI);
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index 6073288fed2..c37f4613632 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * MPC83xx/85xx/86xx PCI/PCIE support routing. 2 * MPC83xx/85xx/86xx PCI/PCIE support routing.
3 * 3 *
4 * Copyright 2007-2011 Freescale Semiconductor, Inc. 4 * Copyright 2007-2012 Freescale Semiconductor, Inc.
5 * Copyright 2008-2009 MontaVista Software, Inc. 5 * Copyright 2008-2009 MontaVista Software, Inc.
6 * 6 *
7 * Initial author: Xianghua Xiao <x.xiao@freescale.com> 7 * Initial author: Xianghua Xiao <x.xiao@freescale.com>
@@ -36,7 +36,7 @@
36 36
37static int fsl_pcie_bus_fixup, is_mpc83xx_pci; 37static int fsl_pcie_bus_fixup, is_mpc83xx_pci;
38 38
39static void __init quirk_fsl_pcie_header(struct pci_dev *dev) 39static void __devinit quirk_fsl_pcie_header(struct pci_dev *dev)
40{ 40{
41 u8 progif; 41 u8 progif;
42 42
@@ -465,7 +465,7 @@ int __init fsl_add_bridge(struct device_node *dev, int is_primary)
465 iounmap(hose->cfg_data); 465 iounmap(hose->cfg_data);
466 iounmap(hose->cfg_addr); 466 iounmap(hose->cfg_addr);
467 pcibios_free_controller(hose); 467 pcibios_free_controller(hose);
468 return 0; 468 return -ENODEV;
469 } 469 }
470 470
471 setup_pci_cmd(hose); 471 setup_pci_cmd(hose);
@@ -807,3 +807,75 @@ u64 fsl_pci_immrbar_base(struct pci_controller *hose)
807 807
808 return 0; 808 return 0;
809} 809}
810
811#if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx)
812static const struct of_device_id pci_ids[] = {
813 { .compatible = "fsl,mpc8540-pci", },
814 { .compatible = "fsl,mpc8548-pcie", },
815 { .compatible = "fsl,mpc8610-pci", },
816 { .compatible = "fsl,mpc8641-pcie", },
817 { .compatible = "fsl,p1022-pcie", },
818 { .compatible = "fsl,p1010-pcie", },
819 { .compatible = "fsl,p1023-pcie", },
820 { .compatible = "fsl,p4080-pcie", },
821 { .compatible = "fsl,qoriq-pcie-v2.3", },
822 { .compatible = "fsl,qoriq-pcie-v2.2", },
823 {},
824};
825
826struct device_node *fsl_pci_primary;
827
828void __devinit fsl_pci_init(void)
829{
830 int ret;
831 struct device_node *node;
832 struct pci_controller *hose;
833 dma_addr_t max = 0xffffffff;
834
835 /* Callers can specify the primary bus using other means. */
836 if (!fsl_pci_primary) {
837 /* If a PCI host bridge contains an ISA node, it's primary. */
838 node = of_find_node_by_type(NULL, "isa");
839 while ((fsl_pci_primary = of_get_parent(node))) {
840 of_node_put(node);
841 node = fsl_pci_primary;
842
843 if (of_match_node(pci_ids, node))
844 break;
845 }
846 }
847
848 node = NULL;
849 for_each_node_by_type(node, "pci") {
850 if (of_match_node(pci_ids, node)) {
851 /*
852 * If there's no PCI host bridge with ISA, arbitrarily
853 * designate one as primary. This can go away once
854 * various bugs with primary-less systems are fixed.
855 */
856 if (!fsl_pci_primary)
857 fsl_pci_primary = node;
858
859 ret = fsl_add_bridge(node, fsl_pci_primary == node);
860 if (ret == 0) {
861 hose = pci_find_hose_for_OF_device(node);
862 max = min(max, hose->dma_window_base_cur +
863 hose->dma_window_size);
864 }
865 }
866 }
867
868#ifdef CONFIG_SWIOTLB
869 /*
870 * if we couldn't map all of DRAM via the dma windows
871 * we need SWIOTLB to handle buffers located outside of
872 * dma capable memory region
873 */
874 if (memblock_end_of_DRAM() - 1 > max) {
875 ppc_swiotlb_enable = 1;
876 set_pci_dma_ops(&swiotlb_dma_ops);
877 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
878 }
879#endif
880}
881#endif
diff --git a/arch/powerpc/sysdev/fsl_pci.h b/arch/powerpc/sysdev/fsl_pci.h
index a39ed5cc2c5..baa0fd18289 100644
--- a/arch/powerpc/sysdev/fsl_pci.h
+++ b/arch/powerpc/sysdev/fsl_pci.h
@@ -93,5 +93,13 @@ extern void fsl_pcibios_fixup_bus(struct pci_bus *bus);
93extern int mpc83xx_add_bridge(struct device_node *dev); 93extern int mpc83xx_add_bridge(struct device_node *dev);
94u64 fsl_pci_immrbar_base(struct pci_controller *hose); 94u64 fsl_pci_immrbar_base(struct pci_controller *hose);
95 95
96extern struct device_node *fsl_pci_primary;
97
98#ifdef CONFIG_FSL_PCI
99void fsl_pci_init(void);
100#else
101static inline void fsl_pci_init(void) {}
102#endif
103
96#endif /* __POWERPC_FSL_PCI_H */ 104#endif /* __POWERPC_FSL_PCI_H */
97#endif /* __KERNEL__ */ 105#endif /* __KERNEL__ */
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 395af134774..bfc6211e542 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1211,7 +1211,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1211 if (of_get_property(node, "single-cpu-affinity", NULL)) 1211 if (of_get_property(node, "single-cpu-affinity", NULL))
1212 flags |= MPIC_SINGLE_DEST_CPU; 1212 flags |= MPIC_SINGLE_DEST_CPU;
1213 if (of_device_is_compatible(node, "fsl,mpic")) 1213 if (of_device_is_compatible(node, "fsl,mpic"))
1214 flags |= MPIC_FSL; 1214 flags |= MPIC_FSL | MPIC_LARGE_VECTORS;
1215 1215
1216 mpic = kzalloc(sizeof(struct mpic), GFP_KERNEL); 1216 mpic = kzalloc(sizeof(struct mpic), GFP_KERNEL);
1217 if (mpic == NULL) 1217 if (mpic == NULL)
@@ -1376,7 +1376,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1376 mpic->isu_mask = (1 << mpic->isu_shift) - 1; 1376 mpic->isu_mask = (1 << mpic->isu_shift) - 1;
1377 1377
1378 mpic->irqhost = irq_domain_add_linear(mpic->node, 1378 mpic->irqhost = irq_domain_add_linear(mpic->node,
1379 last_irq + 1, 1379 intvec_top,
1380 &mpic_host_ops, mpic); 1380 &mpic_host_ops, mpic);
1381 1381
1382 /* 1382 /*
diff --git a/arch/powerpc/sysdev/mpic_msgr.c b/arch/powerpc/sysdev/mpic_msgr.c
index 483d8fa72e8..e961f8c4a8f 100644
--- a/arch/powerpc/sysdev/mpic_msgr.c
+++ b/arch/powerpc/sysdev/mpic_msgr.c
@@ -14,6 +14,9 @@
14#include <linux/list.h> 14#include <linux/list.h>
15#include <linux/of_platform.h> 15#include <linux/of_platform.h>
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/err.h>
18#include <linux/export.h>
19#include <linux/slab.h>
17#include <asm/prom.h> 20#include <asm/prom.h>
18#include <asm/hw_irq.h> 21#include <asm/hw_irq.h>
19#include <asm/ppc-pci.h> 22#include <asm/ppc-pci.h>
diff --git a/arch/powerpc/sysdev/mv64x60_pci.c b/arch/powerpc/sysdev/mv64x60_pci.c
index b0037cefaad..364b14d4754 100644
--- a/arch/powerpc/sysdev/mv64x60_pci.c
+++ b/arch/powerpc/sysdev/mv64x60_pci.c
@@ -104,7 +104,7 @@ subsys_initcall(mv64x60_sysfs_init);
104 104
105#endif /* CONFIG_SYSFS */ 105#endif /* CONFIG_SYSFS */
106 106
107static void __init mv64x60_pci_fixup_early(struct pci_dev *dev) 107static void __devinit mv64x60_pci_fixup_early(struct pci_dev *dev)
108{ 108{
109 /* 109 /*
110 * Set the host bridge hdr_type to an invalid value so that 110 * Set the host bridge hdr_type to an invalid value so that
diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c
index 818e763f826..b0436752972 100644
--- a/arch/powerpc/sysdev/qe_lib/qe.c
+++ b/arch/powerpc/sysdev/qe_lib/qe.c
@@ -395,6 +395,9 @@ static void qe_upload_microcode(const void *base,
395 395
396 for (i = 0; i < be32_to_cpu(ucode->count); i++) 396 for (i = 0; i < be32_to_cpu(ucode->count); i++)
397 out_be32(&qe_immr->iram.idata, be32_to_cpu(code[i])); 397 out_be32(&qe_immr->iram.idata, be32_to_cpu(code[i]));
398
399 /* Set I-RAM Ready Register */
400 out_be32(&qe_immr->iram.iready, be32_to_cpu(QE_IRAM_READY));
398} 401}
399 402
400/* 403/*
diff --git a/arch/powerpc/sysdev/xics/icp-hv.c b/arch/powerpc/sysdev/xics/icp-hv.c
index 253dce98c16..df0fc582146 100644
--- a/arch/powerpc/sysdev/xics/icp-hv.c
+++ b/arch/powerpc/sysdev/xics/icp-hv.c
@@ -65,7 +65,11 @@ static inline void icp_hv_set_xirr(unsigned int value)
65static inline void icp_hv_set_qirr(int n_cpu , u8 value) 65static inline void icp_hv_set_qirr(int n_cpu , u8 value)
66{ 66{
67 int hw_cpu = get_hard_smp_processor_id(n_cpu); 67 int hw_cpu = get_hard_smp_processor_id(n_cpu);
68 long rc = plpar_hcall_norets(H_IPI, hw_cpu, value); 68 long rc;
69
70 /* Make sure all previous accesses are ordered before IPI sending */
71 mb();
72 rc = plpar_hcall_norets(H_IPI, hw_cpu, value);
69 if (rc != H_SUCCESS) { 73 if (rc != H_SUCCESS) {
70 pr_err("%s: bad return code qirr cpu=%d hw_cpu=%d mfrr=0x%x " 74 pr_err("%s: bad return code qirr cpu=%d hw_cpu=%d mfrr=0x%x "
71 "returned %ld\n", __func__, n_cpu, hw_cpu, value, rc); 75 "returned %ld\n", __func__, n_cpu, hw_cpu, value, rc);
@@ -111,7 +115,7 @@ static unsigned int icp_hv_get_irq(void)
111 if (vec == XICS_IRQ_SPURIOUS) 115 if (vec == XICS_IRQ_SPURIOUS)
112 return NO_IRQ; 116 return NO_IRQ;
113 117
114 irq = irq_radix_revmap_lookup(xics_host, vec); 118 irq = irq_find_mapping(xics_host, vec);
115 if (likely(irq != NO_IRQ)) { 119 if (likely(irq != NO_IRQ)) {
116 xics_push_cppr(vec); 120 xics_push_cppr(vec);
117 return irq; 121 return irq;
diff --git a/arch/powerpc/sysdev/xics/icp-native.c b/arch/powerpc/sysdev/xics/icp-native.c
index 4c79b6fbee1..48861d3fcd0 100644
--- a/arch/powerpc/sysdev/xics/icp-native.c
+++ b/arch/powerpc/sysdev/xics/icp-native.c
@@ -119,7 +119,7 @@ static unsigned int icp_native_get_irq(void)
119 if (vec == XICS_IRQ_SPURIOUS) 119 if (vec == XICS_IRQ_SPURIOUS)
120 return NO_IRQ; 120 return NO_IRQ;
121 121
122 irq = irq_radix_revmap_lookup(xics_host, vec); 122 irq = irq_find_mapping(xics_host, vec);
123 if (likely(irq != NO_IRQ)) { 123 if (likely(irq != NO_IRQ)) {
124 xics_push_cppr(vec); 124 xics_push_cppr(vec);
125 return irq; 125 return irq;
diff --git a/arch/powerpc/sysdev/xics/xics-common.c b/arch/powerpc/sysdev/xics/xics-common.c
index cd1d18db92c..9049d9f4448 100644
--- a/arch/powerpc/sysdev/xics/xics-common.c
+++ b/arch/powerpc/sysdev/xics/xics-common.c
@@ -329,9 +329,6 @@ static int xics_host_map(struct irq_domain *h, unsigned int virq,
329 329
330 pr_devel("xics: map virq %d, hwirq 0x%lx\n", virq, hw); 330 pr_devel("xics: map virq %d, hwirq 0x%lx\n", virq, hw);
331 331
332 /* Insert the interrupt mapping into the radix tree for fast lookup */
333 irq_radix_revmap_insert(xics_host, virq, hw);
334
335 /* They aren't all level sensitive but we just don't really know */ 332 /* They aren't all level sensitive but we just don't really know */
336 irq_set_status_flags(virq, IRQ_LEVEL); 333 irq_set_status_flags(virq, IRQ_LEVEL);
337 334
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index eab3492a45c..9b49c65ee7a 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -17,6 +17,7 @@
17#include <linux/reboot.h> 17#include <linux/reboot.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/kallsyms.h> 19#include <linux/kallsyms.h>
20#include <linux/kmsg_dump.h>
20#include <linux/cpumask.h> 21#include <linux/cpumask.h>
21#include <linux/export.h> 22#include <linux/export.h>
22#include <linux/sysrq.h> 23#include <linux/sysrq.h>
@@ -894,13 +895,13 @@ cmds(struct pt_regs *excp)
894#endif 895#endif
895 default: 896 default:
896 printf("Unrecognized command: "); 897 printf("Unrecognized command: ");
897 do { 898 do {
898 if (' ' < cmd && cmd <= '~') 899 if (' ' < cmd && cmd <= '~')
899 putchar(cmd); 900 putchar(cmd);
900 else 901 else
901 printf("\\x%x", cmd); 902 printf("\\x%x", cmd);
902 cmd = inchar(); 903 cmd = inchar();
903 } while (cmd != '\n'); 904 } while (cmd != '\n');
904 printf(" (type ? for help)\n"); 905 printf(" (type ? for help)\n");
905 break; 906 break;
906 } 907 }
@@ -1097,7 +1098,7 @@ static long check_bp_loc(unsigned long addr)
1097 return 1; 1098 return 1;
1098} 1099}
1099 1100
1100static char *breakpoint_help_string = 1101static char *breakpoint_help_string =
1101 "Breakpoint command usage:\n" 1102 "Breakpoint command usage:\n"
1102 "b show breakpoints\n" 1103 "b show breakpoints\n"
1103 "b <addr> [cnt] set breakpoint at given instr addr\n" 1104 "b <addr> [cnt] set breakpoint at given instr addr\n"
@@ -1193,7 +1194,7 @@ bpt_cmds(void)
1193 1194
1194 default: 1195 default:
1195 termch = cmd; 1196 termch = cmd;
1196 cmd = skipbl(); 1197 cmd = skipbl();
1197 if (cmd == '?') { 1198 if (cmd == '?') {
1198 printf(breakpoint_help_string); 1199 printf(breakpoint_help_string);
1199 break; 1200 break;
@@ -1359,7 +1360,7 @@ static void xmon_show_stack(unsigned long sp, unsigned long lr,
1359 sp + REGS_OFFSET); 1360 sp + REGS_OFFSET);
1360 break; 1361 break;
1361 } 1362 }
1362 printf("--- Exception: %lx %s at ", regs.trap, 1363 printf("--- Exception: %lx %s at ", regs.trap,
1363 getvecname(TRAP(&regs))); 1364 getvecname(TRAP(&regs)));
1364 pc = regs.nip; 1365 pc = regs.nip;
1365 lr = regs.link; 1366 lr = regs.link;
@@ -1623,14 +1624,14 @@ static void super_regs(void)
1623 1624
1624 cmd = skipbl(); 1625 cmd = skipbl();
1625 if (cmd == '\n') { 1626 if (cmd == '\n') {
1626 unsigned long sp, toc; 1627 unsigned long sp, toc;
1627 asm("mr %0,1" : "=r" (sp) :); 1628 asm("mr %0,1" : "=r" (sp) :);
1628 asm("mr %0,2" : "=r" (toc) :); 1629 asm("mr %0,2" : "=r" (toc) :);
1629 1630
1630 printf("msr = "REG" sprg0= "REG"\n", 1631 printf("msr = "REG" sprg0= "REG"\n",
1631 mfmsr(), mfspr(SPRN_SPRG0)); 1632 mfmsr(), mfspr(SPRN_SPRG0));
1632 printf("pvr = "REG" sprg1= "REG"\n", 1633 printf("pvr = "REG" sprg1= "REG"\n",
1633 mfspr(SPRN_PVR), mfspr(SPRN_SPRG1)); 1634 mfspr(SPRN_PVR), mfspr(SPRN_SPRG1));
1634 printf("dec = "REG" sprg2= "REG"\n", 1635 printf("dec = "REG" sprg2= "REG"\n",
1635 mfspr(SPRN_DEC), mfspr(SPRN_SPRG2)); 1636 mfspr(SPRN_DEC), mfspr(SPRN_SPRG2));
1636 printf("sp = "REG" sprg3= "REG"\n", sp, mfspr(SPRN_SPRG3)); 1637 printf("sp = "REG" sprg3= "REG"\n", sp, mfspr(SPRN_SPRG3));
@@ -1783,7 +1784,7 @@ byterev(unsigned char *val, int size)
1783static int brev; 1784static int brev;
1784static int mnoread; 1785static int mnoread;
1785 1786
1786static char *memex_help_string = 1787static char *memex_help_string =
1787 "Memory examine command usage:\n" 1788 "Memory examine command usage:\n"
1788 "m [addr] [flags] examine/change memory\n" 1789 "m [addr] [flags] examine/change memory\n"
1789 " addr is optional. will start where left off.\n" 1790 " addr is optional. will start where left off.\n"
@@ -1798,7 +1799,7 @@ static char *memex_help_string =
1798 "NOTE: flags are saved as defaults\n" 1799 "NOTE: flags are saved as defaults\n"
1799 ""; 1800 "";
1800 1801
1801static char *memex_subcmd_help_string = 1802static char *memex_subcmd_help_string =
1802 "Memory examine subcommands:\n" 1803 "Memory examine subcommands:\n"
1803 " hexval write this val to current location\n" 1804 " hexval write this val to current location\n"
1804 " 'string' write chars from string to this location\n" 1805 " 'string' write chars from string to this location\n"
@@ -2064,7 +2065,7 @@ prdump(unsigned long adrs, long ndump)
2064 nr = mread(adrs, temp, r); 2065 nr = mread(adrs, temp, r);
2065 adrs += nr; 2066 adrs += nr;
2066 for (m = 0; m < r; ++m) { 2067 for (m = 0; m < r; ++m) {
2067 if ((m & (sizeof(long) - 1)) == 0 && m > 0) 2068 if ((m & (sizeof(long) - 1)) == 0 && m > 0)
2068 putchar(' '); 2069 putchar(' ');
2069 if (m < nr) 2070 if (m < nr)
2070 printf("%.2x", temp[m]); 2071 printf("%.2x", temp[m]);
@@ -2072,7 +2073,7 @@ prdump(unsigned long adrs, long ndump)
2072 printf("%s", fault_chars[fault_type]); 2073 printf("%s", fault_chars[fault_type]);
2073 } 2074 }
2074 for (; m < 16; ++m) { 2075 for (; m < 16; ++m) {
2075 if ((m & (sizeof(long) - 1)) == 0) 2076 if ((m & (sizeof(long) - 1)) == 0)
2076 putchar(' '); 2077 putchar(' ');
2077 printf(" "); 2078 printf(" ");
2078 } 2079 }
@@ -2148,45 +2149,28 @@ print_address(unsigned long addr)
2148void 2149void
2149dump_log_buf(void) 2150dump_log_buf(void)
2150{ 2151{
2151 const unsigned long size = 128; 2152 struct kmsg_dumper dumper = { .active = 1 };
2152 unsigned long end, addr; 2153 unsigned char buf[128];
2153 unsigned char buf[size + 1]; 2154 size_t len;
2154 2155
2155 addr = 0; 2156 if (setjmp(bus_error_jmp) != 0) {
2156 buf[size] = '\0'; 2157 printf("Error dumping printk buffer!\n");
2157 2158 return;
2158 if (setjmp(bus_error_jmp) != 0) { 2159 }
2159 printf("Unable to lookup symbol __log_buf!\n"); 2160
2160 return; 2161 catch_memory_errors = 1;
2161 } 2162 sync();
2162 2163
2163 catch_memory_errors = 1; 2164 kmsg_dump_rewind_nolock(&dumper);
2164 sync(); 2165 while (kmsg_dump_get_line_nolock(&dumper, false, buf, sizeof(buf), &len)) {
2165 addr = kallsyms_lookup_name("__log_buf"); 2166 buf[len] = '\0';
2166 2167 printf("%s", buf);
2167 if (! addr) 2168 }
2168 printf("Symbol __log_buf not found!\n"); 2169
2169 else { 2170 sync();
2170 end = addr + (1 << CONFIG_LOG_BUF_SHIFT); 2171 /* wait a little while to see if we get a machine check */
2171 while (addr < end) { 2172 __delay(200);
2172 if (! mread(addr, buf, size)) { 2173 catch_memory_errors = 0;
2173 printf("Can't read memory at address 0x%lx\n", addr);
2174 break;
2175 }
2176
2177 printf("%s", buf);
2178
2179 if (strlen(buf) < size)
2180 break;
2181
2182 addr += size;
2183 }
2184 }
2185
2186 sync();
2187 /* wait a little while to see if we get a machine check */
2188 __delay(200);
2189 catch_memory_errors = 0;
2190} 2174}
2191 2175
2192/* 2176/*
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index a39b4690c17..107610e01a2 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -85,10 +85,12 @@ config S390
85 select HAVE_ARCH_MUTEX_CPU_RELAX 85 select HAVE_ARCH_MUTEX_CPU_RELAX
86 select HAVE_ARCH_JUMP_LABEL if !MARCH_G5 86 select HAVE_ARCH_JUMP_LABEL if !MARCH_G5
87 select ARCH_SAVE_PAGE_KEYS if HIBERNATION 87 select ARCH_SAVE_PAGE_KEYS if HIBERNATION
88 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
88 select HAVE_MEMBLOCK 89 select HAVE_MEMBLOCK
89 select HAVE_MEMBLOCK_NODE_MAP 90 select HAVE_MEMBLOCK_NODE_MAP
90 select HAVE_CMPXCHG_LOCAL 91 select HAVE_CMPXCHG_LOCAL
91 select ARCH_DISCARD_MEMBLOCK 92 select ARCH_DISCARD_MEMBLOCK
93 select BUILDTIME_EXTABLE_SORT
92 select ARCH_INLINE_SPIN_TRYLOCK 94 select ARCH_INLINE_SPIN_TRYLOCK
93 select ARCH_INLINE_SPIN_TRYLOCK_BH 95 select ARCH_INLINE_SPIN_TRYLOCK_BH
94 select ARCH_INLINE_SPIN_LOCK 96 select ARCH_INLINE_SPIN_LOCK
@@ -117,10 +119,12 @@ config S390
117 select ARCH_INLINE_WRITE_UNLOCK_BH 119 select ARCH_INLINE_WRITE_UNLOCK_BH
118 select ARCH_INLINE_WRITE_UNLOCK_IRQ 120 select ARCH_INLINE_WRITE_UNLOCK_IRQ
119 select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE 121 select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE
122 select ARCH_WANT_IPC_PARSE_VERSION
120 select GENERIC_SMP_IDLE_THREAD 123 select GENERIC_SMP_IDLE_THREAD
121 select GENERIC_TIME_VSYSCALL 124 select GENERIC_TIME_VSYSCALL
122 select GENERIC_CLOCKEVENTS 125 select GENERIC_CLOCKEVENTS
123 select KTIME_SCALAR if 32BIT 126 select KTIME_SCALAR if 32BIT
127 select HAVE_ARCH_SECCOMP_FILTER
124 128
125config SCHED_OMIT_FRAME_POINTER 129config SCHED_OMIT_FRAME_POINTER
126 def_bool y 130 def_bool y
diff --git a/arch/s390/appldata/appldata.h b/arch/s390/appldata/appldata.h
index f0b23fc759b..4a67f2b5f6a 100644
--- a/arch/s390/appldata/appldata.h
+++ b/arch/s390/appldata/appldata.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/s390/appldata/appldata.h
3 *
4 * Definitions and interface for Linux - z/VM Monitor Stream. 2 * Definitions and interface for Linux - z/VM Monitor Stream.
5 * 3 *
6 * Copyright IBM Corp. 2003, 2008 4 * Copyright IBM Corp. 2003, 2008
diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c
index 24bff4f1cc5..bae0f402bf2 100644
--- a/arch/s390/appldata/appldata_base.c
+++ b/arch/s390/appldata/appldata_base.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/s390/appldata/appldata_base.c
3 *
4 * Base infrastructure for Linux-z/VM Monitor Stream, Stage 1. 2 * Base infrastructure for Linux-z/VM Monitor Stream, Stage 1.
5 * Exports appldata_register_ops() and appldata_unregister_ops() for the 3 * Exports appldata_register_ops() and appldata_unregister_ops() for the
6 * data gathering modules. 4 * data gathering modules.
@@ -29,7 +27,7 @@
29#include <linux/suspend.h> 27#include <linux/suspend.h>
30#include <linux/platform_device.h> 28#include <linux/platform_device.h>
31#include <asm/appldata.h> 29#include <asm/appldata.h>
32#include <asm/timer.h> 30#include <asm/vtimer.h>
33#include <asm/uaccess.h> 31#include <asm/uaccess.h>
34#include <asm/io.h> 32#include <asm/io.h>
35#include <asm/smp.h> 33#include <asm/smp.h>
@@ -84,8 +82,7 @@ static struct ctl_table appldata_dir_table[] = {
84/* 82/*
85 * Timer 83 * Timer
86 */ 84 */
87static DEFINE_PER_CPU(struct vtimer_list, appldata_timer); 85static struct vtimer_list appldata_timer;
88static atomic_t appldata_expire_count = ATOMIC_INIT(0);
89 86
90static DEFINE_SPINLOCK(appldata_timer_lock); 87static DEFINE_SPINLOCK(appldata_timer_lock);
91static int appldata_interval = APPLDATA_CPU_INTERVAL; 88static int appldata_interval = APPLDATA_CPU_INTERVAL;
@@ -115,10 +112,7 @@ static LIST_HEAD(appldata_ops_list);
115 */ 112 */
116static void appldata_timer_function(unsigned long data) 113static void appldata_timer_function(unsigned long data)
117{ 114{
118 if (atomic_dec_and_test(&appldata_expire_count)) { 115 queue_work(appldata_wq, (struct work_struct *) data);
119 atomic_set(&appldata_expire_count, num_online_cpus());
120 queue_work(appldata_wq, (struct work_struct *) data);
121 }
122} 116}
123 117
124/* 118/*
@@ -131,7 +125,6 @@ static void appldata_work_fn(struct work_struct *work)
131 struct list_head *lh; 125 struct list_head *lh;
132 struct appldata_ops *ops; 126 struct appldata_ops *ops;
133 127
134 get_online_cpus();
135 mutex_lock(&appldata_ops_mutex); 128 mutex_lock(&appldata_ops_mutex);
136 list_for_each(lh, &appldata_ops_list) { 129 list_for_each(lh, &appldata_ops_list) {
137 ops = list_entry(lh, struct appldata_ops, list); 130 ops = list_entry(lh, struct appldata_ops, list);
@@ -140,7 +133,6 @@ static void appldata_work_fn(struct work_struct *work)
140 } 133 }
141 } 134 }
142 mutex_unlock(&appldata_ops_mutex); 135 mutex_unlock(&appldata_ops_mutex);
143 put_online_cpus();
144} 136}
145 137
146/* 138/*
@@ -168,20 +160,6 @@ int appldata_diag(char record_nr, u16 function, unsigned long buffer,
168 160
169/****************************** /proc stuff **********************************/ 161/****************************** /proc stuff **********************************/
170 162
171/*
172 * appldata_mod_vtimer_wrap()
173 *
174 * wrapper function for mod_virt_timer(), because smp_call_function_single()
175 * accepts only one parameter.
176 */
177static void __appldata_mod_vtimer_wrap(void *p) {
178 struct {
179 struct vtimer_list *timer;
180 u64 expires;
181 } *args = p;
182 mod_virt_timer_periodic(args->timer, args->expires);
183}
184
185#define APPLDATA_ADD_TIMER 0 163#define APPLDATA_ADD_TIMER 0
186#define APPLDATA_DEL_TIMER 1 164#define APPLDATA_DEL_TIMER 1
187#define APPLDATA_MOD_TIMER 2 165#define APPLDATA_MOD_TIMER 2
@@ -192,49 +170,28 @@ static void __appldata_mod_vtimer_wrap(void *p) {
192 * Add, delete or modify virtual timers on all online cpus. 170 * Add, delete or modify virtual timers on all online cpus.
193 * The caller needs to get the appldata_timer_lock spinlock. 171 * The caller needs to get the appldata_timer_lock spinlock.
194 */ 172 */
195static void 173static void __appldata_vtimer_setup(int cmd)
196__appldata_vtimer_setup(int cmd)
197{ 174{
198 u64 per_cpu_interval; 175 u64 timer_interval = (u64) appldata_interval * 1000 * TOD_MICRO;
199 int i;
200 176
201 switch (cmd) { 177 switch (cmd) {
202 case APPLDATA_ADD_TIMER: 178 case APPLDATA_ADD_TIMER:
203 if (appldata_timer_active) 179 if (appldata_timer_active)
204 break; 180 break;
205 per_cpu_interval = (u64) (appldata_interval*1000 / 181 appldata_timer.expires = timer_interval;
206 num_online_cpus()) * TOD_MICRO; 182 add_virt_timer_periodic(&appldata_timer);
207 for_each_online_cpu(i) {
208 per_cpu(appldata_timer, i).expires = per_cpu_interval;
209 smp_call_function_single(i, add_virt_timer_periodic,
210 &per_cpu(appldata_timer, i),
211 1);
212 }
213 appldata_timer_active = 1; 183 appldata_timer_active = 1;
214 break; 184 break;
215 case APPLDATA_DEL_TIMER: 185 case APPLDATA_DEL_TIMER:
216 for_each_online_cpu(i) 186 del_virt_timer(&appldata_timer);
217 del_virt_timer(&per_cpu(appldata_timer, i));
218 if (!appldata_timer_active) 187 if (!appldata_timer_active)
219 break; 188 break;
220 appldata_timer_active = 0; 189 appldata_timer_active = 0;
221 atomic_set(&appldata_expire_count, num_online_cpus());
222 break; 190 break;
223 case APPLDATA_MOD_TIMER: 191 case APPLDATA_MOD_TIMER:
224 per_cpu_interval = (u64) (appldata_interval*1000 /
225 num_online_cpus()) * TOD_MICRO;
226 if (!appldata_timer_active) 192 if (!appldata_timer_active)
227 break; 193 break;
228 for_each_online_cpu(i) { 194 mod_virt_timer_periodic(&appldata_timer, timer_interval);
229 struct {
230 struct vtimer_list *timer;
231 u64 expires;
232 } args;
233 args.timer = &per_cpu(appldata_timer, i);
234 args.expires = per_cpu_interval;
235 smp_call_function_single(i, __appldata_mod_vtimer_wrap,
236 &args, 1);
237 }
238 } 195 }
239} 196}
240 197
@@ -265,14 +222,12 @@ appldata_timer_handler(ctl_table *ctl, int write,
265 len = *lenp; 222 len = *lenp;
266 if (copy_from_user(buf, buffer, len > sizeof(buf) ? sizeof(buf) : len)) 223 if (copy_from_user(buf, buffer, len > sizeof(buf) ? sizeof(buf) : len))
267 return -EFAULT; 224 return -EFAULT;
268 get_online_cpus();
269 spin_lock(&appldata_timer_lock); 225 spin_lock(&appldata_timer_lock);
270 if (buf[0] == '1') 226 if (buf[0] == '1')
271 __appldata_vtimer_setup(APPLDATA_ADD_TIMER); 227 __appldata_vtimer_setup(APPLDATA_ADD_TIMER);
272 else if (buf[0] == '0') 228 else if (buf[0] == '0')
273 __appldata_vtimer_setup(APPLDATA_DEL_TIMER); 229 __appldata_vtimer_setup(APPLDATA_DEL_TIMER);
274 spin_unlock(&appldata_timer_lock); 230 spin_unlock(&appldata_timer_lock);
275 put_online_cpus();
276out: 231out:
277 *lenp = len; 232 *lenp = len;
278 *ppos += len; 233 *ppos += len;
@@ -305,20 +260,17 @@ appldata_interval_handler(ctl_table *ctl, int write,
305 goto out; 260 goto out;
306 } 261 }
307 len = *lenp; 262 len = *lenp;
308 if (copy_from_user(buf, buffer, len > sizeof(buf) ? sizeof(buf) : len)) { 263 if (copy_from_user(buf, buffer, len > sizeof(buf) ? sizeof(buf) : len))
309 return -EFAULT; 264 return -EFAULT;
310 }
311 interval = 0; 265 interval = 0;
312 sscanf(buf, "%i", &interval); 266 sscanf(buf, "%i", &interval);
313 if (interval <= 0) 267 if (interval <= 0)
314 return -EINVAL; 268 return -EINVAL;
315 269
316 get_online_cpus();
317 spin_lock(&appldata_timer_lock); 270 spin_lock(&appldata_timer_lock);
318 appldata_interval = interval; 271 appldata_interval = interval;
319 __appldata_vtimer_setup(APPLDATA_MOD_TIMER); 272 __appldata_vtimer_setup(APPLDATA_MOD_TIMER);
320 spin_unlock(&appldata_timer_lock); 273 spin_unlock(&appldata_timer_lock);
321 put_online_cpus();
322out: 274out:
323 *lenp = len; 275 *lenp = len;
324 *ppos += len; 276 *ppos += len;
@@ -485,14 +437,12 @@ static int appldata_freeze(struct device *dev)
485 int rc; 437 int rc;
486 struct list_head *lh; 438 struct list_head *lh;
487 439
488 get_online_cpus();
489 spin_lock(&appldata_timer_lock); 440 spin_lock(&appldata_timer_lock);
490 if (appldata_timer_active) { 441 if (appldata_timer_active) {
491 __appldata_vtimer_setup(APPLDATA_DEL_TIMER); 442 __appldata_vtimer_setup(APPLDATA_DEL_TIMER);
492 appldata_timer_suspended = 1; 443 appldata_timer_suspended = 1;
493 } 444 }
494 spin_unlock(&appldata_timer_lock); 445 spin_unlock(&appldata_timer_lock);
495 put_online_cpus();
496 446
497 mutex_lock(&appldata_ops_mutex); 447 mutex_lock(&appldata_ops_mutex);
498 list_for_each(lh, &appldata_ops_list) { 448 list_for_each(lh, &appldata_ops_list) {
@@ -516,14 +466,12 @@ static int appldata_restore(struct device *dev)
516 int rc; 466 int rc;
517 struct list_head *lh; 467 struct list_head *lh;
518 468
519 get_online_cpus();
520 spin_lock(&appldata_timer_lock); 469 spin_lock(&appldata_timer_lock);
521 if (appldata_timer_suspended) { 470 if (appldata_timer_suspended) {
522 __appldata_vtimer_setup(APPLDATA_ADD_TIMER); 471 __appldata_vtimer_setup(APPLDATA_ADD_TIMER);
523 appldata_timer_suspended = 0; 472 appldata_timer_suspended = 0;
524 } 473 }
525 spin_unlock(&appldata_timer_lock); 474 spin_unlock(&appldata_timer_lock);
526 put_online_cpus();
527 475
528 mutex_lock(&appldata_ops_mutex); 476 mutex_lock(&appldata_ops_mutex);
529 list_for_each(lh, &appldata_ops_list) { 477 list_for_each(lh, &appldata_ops_list) {
@@ -567,53 +515,6 @@ static struct platform_driver appldata_pdrv = {
567 515
568/******************************* init / exit *********************************/ 516/******************************* init / exit *********************************/
569 517
570static void __cpuinit appldata_online_cpu(int cpu)
571{
572 init_virt_timer(&per_cpu(appldata_timer, cpu));
573 per_cpu(appldata_timer, cpu).function = appldata_timer_function;
574 per_cpu(appldata_timer, cpu).data = (unsigned long)
575 &appldata_work;
576 atomic_inc(&appldata_expire_count);
577 spin_lock(&appldata_timer_lock);
578 __appldata_vtimer_setup(APPLDATA_MOD_TIMER);
579 spin_unlock(&appldata_timer_lock);
580}
581
582static void __cpuinit appldata_offline_cpu(int cpu)
583{
584 del_virt_timer(&per_cpu(appldata_timer, cpu));
585 if (atomic_dec_and_test(&appldata_expire_count)) {
586 atomic_set(&appldata_expire_count, num_online_cpus());
587 queue_work(appldata_wq, &appldata_work);
588 }
589 spin_lock(&appldata_timer_lock);
590 __appldata_vtimer_setup(APPLDATA_MOD_TIMER);
591 spin_unlock(&appldata_timer_lock);
592}
593
594static int __cpuinit appldata_cpu_notify(struct notifier_block *self,
595 unsigned long action,
596 void *hcpu)
597{
598 switch (action) {
599 case CPU_ONLINE:
600 case CPU_ONLINE_FROZEN:
601 appldata_online_cpu((long) hcpu);
602 break;
603 case CPU_DEAD:
604 case CPU_DEAD_FROZEN:
605 appldata_offline_cpu((long) hcpu);
606 break;
607 default:
608 break;
609 }
610 return NOTIFY_OK;
611}
612
613static struct notifier_block __cpuinitdata appldata_nb = {
614 .notifier_call = appldata_cpu_notify,
615};
616
617/* 518/*
618 * appldata_init() 519 * appldata_init()
619 * 520 *
@@ -621,7 +522,10 @@ static struct notifier_block __cpuinitdata appldata_nb = {
621 */ 522 */
622static int __init appldata_init(void) 523static int __init appldata_init(void)
623{ 524{
624 int i, rc; 525 int rc;
526
527 appldata_timer.function = appldata_timer_function;
528 appldata_timer.data = (unsigned long) &appldata_work;
625 529
626 rc = platform_driver_register(&appldata_pdrv); 530 rc = platform_driver_register(&appldata_pdrv);
627 if (rc) 531 if (rc)
@@ -639,14 +543,6 @@ static int __init appldata_init(void)
639 goto out_device; 543 goto out_device;
640 } 544 }
641 545
642 get_online_cpus();
643 for_each_online_cpu(i)
644 appldata_online_cpu(i);
645 put_online_cpus();
646
647 /* Register cpu hotplug notifier */
648 register_hotcpu_notifier(&appldata_nb);
649
650 appldata_sysctl_header = register_sysctl_table(appldata_dir_table); 546 appldata_sysctl_header = register_sysctl_table(appldata_dir_table);
651 return 0; 547 return 0;
652 548
diff --git a/arch/s390/appldata/appldata_mem.c b/arch/s390/appldata/appldata_mem.c
index f7d3dc555bd..02d9a1cf505 100644
--- a/arch/s390/appldata/appldata_mem.c
+++ b/arch/s390/appldata/appldata_mem.c
@@ -1,10 +1,8 @@
1/* 1/*
2 * arch/s390/appldata/appldata_mem.c
3 *
4 * Data gathering module for Linux-VM Monitor Stream, Stage 1. 2 * Data gathering module for Linux-VM Monitor Stream, Stage 1.
5 * Collects data related to memory management. 3 * Collects data related to memory management.
6 * 4 *
7 * Copyright (C) 2003,2006 IBM Corporation, IBM Deutschland Entwicklung GmbH. 5 * Copyright IBM Corp. 2003, 2006
8 * 6 *
9 * Author: Gerald Schaefer <gerald.schaefer@de.ibm.com> 7 * Author: Gerald Schaefer <gerald.schaefer@de.ibm.com>
10 */ 8 */
diff --git a/arch/s390/appldata/appldata_net_sum.c b/arch/s390/appldata/appldata_net_sum.c
index 5da7c562a90..1370e358d49 100644
--- a/arch/s390/appldata/appldata_net_sum.c
+++ b/arch/s390/appldata/appldata_net_sum.c
@@ -1,11 +1,9 @@
1/* 1/*
2 * arch/s390/appldata/appldata_net_sum.c
3 *
4 * Data gathering module for Linux-VM Monitor Stream, Stage 1. 2 * Data gathering module for Linux-VM Monitor Stream, Stage 1.
5 * Collects accumulated network statistics (Packets received/transmitted, 3 * Collects accumulated network statistics (Packets received/transmitted,
6 * dropped, errors, ...). 4 * dropped, errors, ...).
7 * 5 *
8 * Copyright (C) 2003,2006 IBM Corporation, IBM Deutschland Entwicklung GmbH. 6 * Copyright IBM Corp. 2003, 2006
9 * 7 *
10 * Author: Gerald Schaefer <gerald.schaefer@de.ibm.com> 8 * Author: Gerald Schaefer <gerald.schaefer@de.ibm.com>
11 */ 9 */
diff --git a/arch/s390/appldata/appldata_os.c b/arch/s390/appldata/appldata_os.c
index 4de031d6b76..87521ba682e 100644
--- a/arch/s390/appldata/appldata_os.c
+++ b/arch/s390/appldata/appldata_os.c
@@ -1,10 +1,8 @@
1/* 1/*
2 * arch/s390/appldata/appldata_os.c
3 *
4 * Data gathering module for Linux-VM Monitor Stream, Stage 1. 2 * Data gathering module for Linux-VM Monitor Stream, Stage 1.
5 * Collects misc. OS related data (CPU utilization, running processes). 3 * Collects misc. OS related data (CPU utilization, running processes).
6 * 4 *
7 * Copyright (C) 2003,2006 IBM Corporation, IBM Deutschland Entwicklung GmbH. 5 * Copyright IBM Corp. 2003, 2006
8 * 6 *
9 * Author: Gerald Schaefer <gerald.schaefer@de.ibm.com> 7 * Author: Gerald Schaefer <gerald.schaefer@de.ibm.com>
10 */ 8 */
diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c
index a9ce135893f..e402a9dd4ed 100644
--- a/arch/s390/crypto/aes_s390.c
+++ b/arch/s390/crypto/aes_s390.c
@@ -4,7 +4,7 @@
4 * s390 implementation of the AES Cipher Algorithm. 4 * s390 implementation of the AES Cipher Algorithm.
5 * 5 *
6 * s390 Version: 6 * s390 Version:
7 * Copyright IBM Corp. 2005,2007 7 * Copyright IBM Corp. 2005, 2007
8 * Author(s): Jan Glauber (jang@de.ibm.com) 8 * Author(s): Jan Glauber (jang@de.ibm.com)
9 * Sebastian Siewior (sebastian@breakpoint.cc> SW-Fallback 9 * Sebastian Siewior (sebastian@breakpoint.cc> SW-Fallback
10 * 10 *
diff --git a/arch/s390/crypto/crypt_s390.h b/arch/s390/crypto/crypt_s390.h
index 9178db6db0a..6c5cc6da711 100644
--- a/arch/s390/crypto/crypt_s390.h
+++ b/arch/s390/crypto/crypt_s390.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * Support for s390 cryptographic instructions. 4 * Support for s390 cryptographic instructions.
5 * 5 *
6 * Copyright IBM Corp. 2003,2007 6 * Copyright IBM Corp. 2003, 2007
7 * Author(s): Thomas Spatzier 7 * Author(s): Thomas Spatzier
8 * Jan Glauber (jan.glauber@de.ibm.com) 8 * Jan Glauber (jan.glauber@de.ibm.com)
9 * 9 *
diff --git a/arch/s390/crypto/crypto_des.h b/arch/s390/crypto/crypto_des.h
deleted file mode 100644
index 6210457ceeb..00000000000
--- a/arch/s390/crypto/crypto_des.h
+++ /dev/null
@@ -1,18 +0,0 @@
1/*
2 * Cryptographic API.
3 *
4 * Function for checking keys for the DES and Tripple DES Encryption
5 * algorithms.
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 as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 */
13#ifndef __CRYPTO_DES_H__
14#define __CRYPTO_DES_H__
15
16extern int crypto_des_check_key(const u8*, unsigned int, u32*);
17
18#endif /*__CRYPTO_DES_H__*/
diff --git a/arch/s390/crypto/des_s390.c b/arch/s390/crypto/des_s390.c
index a52bfd124d8..1eaa371ca3e 100644
--- a/arch/s390/crypto/des_s390.c
+++ b/arch/s390/crypto/des_s390.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * s390 implementation of the DES Cipher Algorithm. 4 * s390 implementation of the DES Cipher Algorithm.
5 * 5 *
6 * Copyright IBM Corp. 2003,2011 6 * Copyright IBM Corp. 2003, 2011
7 * Author(s): Thomas Spatzier 7 * Author(s): Thomas Spatzier
8 * Jan Glauber (jan.glauber@de.ibm.com) 8 * Jan Glauber (jan.glauber@de.ibm.com)
9 * 9 *
diff --git a/arch/s390/crypto/prng.c b/arch/s390/crypto/prng.c
index 0808fbf0f7d..94a35a4c1b4 100644
--- a/arch/s390/crypto/prng.c
+++ b/arch/s390/crypto/prng.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright IBM Corp. 2006,2007 2 * Copyright IBM Corp. 2006, 2007
3 * Author(s): Jan Glauber <jan.glauber@de.ibm.com> 3 * Author(s): Jan Glauber <jan.glauber@de.ibm.com>
4 * Driver for the s390 pseudo random number generator 4 * Driver for the s390 pseudo random number generator
5 */ 5 */
diff --git a/arch/s390/crypto/sha1_s390.c b/arch/s390/crypto/sha1_s390.c
index e9868c6e0a0..a1b3a9dc9d8 100644
--- a/arch/s390/crypto/sha1_s390.c
+++ b/arch/s390/crypto/sha1_s390.c
@@ -8,7 +8,7 @@
8 * implementation written by Steve Reid. 8 * implementation written by Steve Reid.
9 * 9 *
10 * s390 Version: 10 * s390 Version:
11 * Copyright IBM Corp. 2003,2007 11 * Copyright IBM Corp. 2003, 2007
12 * Author(s): Thomas Spatzier 12 * Author(s): Thomas Spatzier
13 * Jan Glauber (jan.glauber@de.ibm.com) 13 * Jan Glauber (jan.glauber@de.ibm.com)
14 * 14 *
diff --git a/arch/s390/crypto/sha256_s390.c b/arch/s390/crypto/sha256_s390.c
index 0317a3547cb..9b853809a49 100644
--- a/arch/s390/crypto/sha256_s390.c
+++ b/arch/s390/crypto/sha256_s390.c
@@ -4,7 +4,7 @@
4 * s390 implementation of the SHA256 and SHA224 Secure Hash Algorithm. 4 * s390 implementation of the SHA256 and SHA224 Secure Hash Algorithm.
5 * 5 *
6 * s390 Version: 6 * s390 Version:
7 * Copyright IBM Corp. 2005,2011 7 * Copyright IBM Corp. 2005, 2011
8 * Author(s): Jan Glauber (jang@de.ibm.com) 8 * Author(s): Jan Glauber (jang@de.ibm.com)
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it 10 * This program is free software; you can redistribute it and/or modify it
diff --git a/arch/s390/defconfig b/arch/s390/defconfig
index 37d2bf26796..f39cd710980 100644
--- a/arch/s390/defconfig
+++ b/arch/s390/defconfig
@@ -7,13 +7,16 @@ CONFIG_TASK_DELAY_ACCT=y
7CONFIG_TASK_XACCT=y 7CONFIG_TASK_XACCT=y
8CONFIG_TASK_IO_ACCOUNTING=y 8CONFIG_TASK_IO_ACCOUNTING=y
9CONFIG_AUDIT=y 9CONFIG_AUDIT=y
10CONFIG_NO_HZ=y
11CONFIG_HIGH_RES_TIMERS=y
12CONFIG_RCU_FAST_NO_HZ=y
10CONFIG_IKCONFIG=y 13CONFIG_IKCONFIG=y
11CONFIG_IKCONFIG_PROC=y 14CONFIG_IKCONFIG_PROC=y
12CONFIG_CGROUPS=y 15CONFIG_CGROUPS=y
13CONFIG_CPUSETS=y 16CONFIG_CPUSETS=y
14CONFIG_CGROUP_CPUACCT=y 17CONFIG_CGROUP_CPUACCT=y
15CONFIG_RESOURCE_COUNTERS=y 18CONFIG_RESOURCE_COUNTERS=y
16CONFIG_CGROUP_MEM_RES_CTLR=y 19CONFIG_CGROUP_MEMCG=y
17CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y 20CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y
18CONFIG_CGROUP_SCHED=y 21CONFIG_CGROUP_SCHED=y
19CONFIG_RT_GROUP_SCHED=y 22CONFIG_RT_GROUP_SCHED=y
@@ -35,8 +38,6 @@ CONFIG_MODVERSIONS=y
35CONFIG_PARTITION_ADVANCED=y 38CONFIG_PARTITION_ADVANCED=y
36CONFIG_IBM_PARTITION=y 39CONFIG_IBM_PARTITION=y
37CONFIG_DEFAULT_DEADLINE=y 40CONFIG_DEFAULT_DEADLINE=y
38CONFIG_NO_HZ=y
39CONFIG_HIGH_RES_TIMERS=y
40CONFIG_PREEMPT=y 41CONFIG_PREEMPT=y
41CONFIG_MEMORY_HOTPLUG=y 42CONFIG_MEMORY_HOTPLUG=y
42CONFIG_MEMORY_HOTREMOVE=y 43CONFIG_MEMORY_HOTREMOVE=y
diff --git a/arch/s390/hypfs/hypfs.h b/arch/s390/hypfs/hypfs.h
index d9df5a060a8..f41e0ef7fdf 100644
--- a/arch/s390/hypfs/hypfs.h
+++ b/arch/s390/hypfs/hypfs.h
@@ -1,8 +1,7 @@
1/* 1/*
2 * arch/s390/hypfs/hypfs.h
3 * Hypervisor filesystem for Linux on s390. 2 * Hypervisor filesystem for Linux on s390.
4 * 3 *
5 * Copyright (C) IBM Corp. 2006 4 * Copyright IBM Corp. 2006
6 * Author(s): Michael Holzheu <holzheu@de.ibm.com> 5 * Author(s): Michael Holzheu <holzheu@de.ibm.com>
7 */ 6 */
8 7
diff --git a/arch/s390/hypfs/hypfs_dbfs.c b/arch/s390/hypfs/hypfs_dbfs.c
index b478013b7fe..13e76dabbe8 100644
--- a/arch/s390/hypfs/hypfs_dbfs.c
+++ b/arch/s390/hypfs/hypfs_dbfs.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Hypervisor filesystem for Linux on s390 - debugfs interface 2 * Hypervisor filesystem for Linux on s390 - debugfs interface
3 * 3 *
4 * Copyright (C) IBM Corp. 2010 4 * Copyright IBM Corp. 2010
5 * Author(s): Michael Holzheu <holzheu@linux.vnet.ibm.com> 5 * Author(s): Michael Holzheu <holzheu@linux.vnet.ibm.com>
6 */ 6 */
7 7
diff --git a/arch/s390/hypfs/hypfs_diag.c b/arch/s390/hypfs/hypfs_diag.c
index 74c8f5e76ce..7fd3690b676 100644
--- a/arch/s390/hypfs/hypfs_diag.c
+++ b/arch/s390/hypfs/hypfs_diag.c
@@ -1,5 +1,4 @@
1/* 1/*
2 * arch/s390/hypfs/hypfs_diag.c
3 * Hypervisor filesystem for Linux on s390. Diag 204 and 224 2 * Hypervisor filesystem for Linux on s390. Diag 204 and 224
4 * implementation. 3 * implementation.
5 * 4 *
diff --git a/arch/s390/hypfs/hypfs_vm.c b/arch/s390/hypfs/hypfs_vm.c
index e54796002f6..4f6afaa8bd8 100644
--- a/arch/s390/hypfs/hypfs_vm.c
+++ b/arch/s390/hypfs/hypfs_vm.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Hypervisor filesystem for Linux on s390. z/VM implementation. 2 * Hypervisor filesystem for Linux on s390. z/VM implementation.
3 * 3 *
4 * Copyright (C) IBM Corp. 2006 4 * Copyright IBM Corp. 2006
5 * Author(s): Michael Holzheu <holzheu@de.ibm.com> 5 * Author(s): Michael Holzheu <holzheu@de.ibm.com>
6 */ 6 */
7 7
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index 73dae8b9b77..6767b437a10 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -1,5 +1,4 @@
1/* 1/*
2 * arch/s390/hypfs/inode.c
3 * Hypervisor filesystem for Linux on s390. 2 * Hypervisor filesystem for Linux on s390.
4 * 3 *
5 * Copyright IBM Corp. 2006, 2008 4 * Copyright IBM Corp. 2006, 2008
@@ -103,6 +102,7 @@ static struct inode *hypfs_make_inode(struct super_block *sb, umode_t mode)
103 102
104 if (ret) { 103 if (ret) {
105 struct hypfs_sb_info *hypfs_info = sb->s_fs_info; 104 struct hypfs_sb_info *hypfs_info = sb->s_fs_info;
105 ret->i_ino = get_next_ino();
106 ret->i_mode = mode; 106 ret->i_mode = mode;
107 ret->i_uid = hypfs_info->uid; 107 ret->i_uid = hypfs_info->uid;
108 ret->i_gid = hypfs_info->gid; 108 ret->i_gid = hypfs_info->gid;
diff --git a/arch/s390/include/asm/airq.h b/arch/s390/include/asm/airq.h
index 1ac80d6b058..9819891ed7a 100644
--- a/arch/s390/include/asm/airq.h
+++ b/arch/s390/include/asm/airq.h
@@ -1,7 +1,5 @@
1/* 1/*
2 * include/asm-s390/airq.h 2 * Copyright IBM Corp. 2002, 2007
3 *
4 * Copyright IBM Corp. 2002,2007
5 * Author(s): Ingo Adlung <adlung@de.ibm.com> 3 * Author(s): Ingo Adlung <adlung@de.ibm.com>
6 * Cornelia Huck <cornelia.huck@de.ibm.com> 4 * Cornelia Huck <cornelia.huck@de.ibm.com>
7 * Arnd Bergmann <arndb@de.ibm.com> 5 * Arnd Bergmann <arndb@de.ibm.com>
diff --git a/arch/s390/include/asm/appldata.h b/arch/s390/include/asm/appldata.h
index 79283dac828..f328294faea 100644
--- a/arch/s390/include/asm/appldata.h
+++ b/arch/s390/include/asm/appldata.h
@@ -1,7 +1,5 @@
1/* 1/*
2 * include/asm-s390/appldata.h 2 * Copyright IBM Corp. 2006
3 *
4 * Copyright (C) IBM Corp. 2006
5 * 3 *
6 * Author(s): Melissa Howland <melissah@us.ibm.com> 4 * Author(s): Melissa Howland <melissah@us.ibm.com>
7 */ 5 */
diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
index 748347baecb..c797832daa5 100644
--- a/arch/s390/include/asm/atomic.h
+++ b/arch/s390/include/asm/atomic.h
@@ -1,8 +1,5 @@
1#ifndef __ARCH_S390_ATOMIC__
2#define __ARCH_S390_ATOMIC__
3
4/* 1/*
5 * Copyright 1999,2009 IBM Corp. 2 * Copyright IBM Corp. 1999, 2009
6 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>, 3 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>,
7 * Denis Joseph Barrow, 4 * Denis Joseph Barrow,
8 * Arnd Bergmann <arndb@de.ibm.com>, 5 * Arnd Bergmann <arndb@de.ibm.com>,
@@ -13,6 +10,9 @@
13 * 10 *
14 */ 11 */
15 12
13#ifndef __ARCH_S390_ATOMIC__
14#define __ARCH_S390_ATOMIC__
15
16#include <linux/compiler.h> 16#include <linux/compiler.h>
17#include <linux/types.h> 17#include <linux/types.h>
18#include <asm/cmpxchg.h> 18#include <asm/cmpxchg.h>
diff --git a/arch/s390/include/asm/bitops.h b/arch/s390/include/asm/bitops.h
index a6ff5a83e22..6f573890fb2 100644
--- a/arch/s390/include/asm/bitops.h
+++ b/arch/s390/include/asm/bitops.h
@@ -1,11 +1,6 @@
1#ifndef _S390_BITOPS_H
2#define _S390_BITOPS_H
3
4/* 1/*
5 * include/asm-s390/bitops.h
6 *
7 * S390 version 2 * S390 version
8 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999
9 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 4 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
10 * 5 *
11 * Derived from "include/asm-i386/bitops.h" 6 * Derived from "include/asm-i386/bitops.h"
@@ -13,6 +8,9 @@
13 * 8 *
14 */ 9 */
15 10
11#ifndef _S390_BITOPS_H
12#define _S390_BITOPS_H
13
16#ifndef _LINUX_BITOPS_H 14#ifndef _LINUX_BITOPS_H
17#error only <linux/bitops.h> can be included directly 15#error only <linux/bitops.h> can be included directly
18#endif 16#endif
diff --git a/arch/s390/include/asm/bugs.h b/arch/s390/include/asm/bugs.h
index 011f1e6a2a6..0f5bd894f4d 100644
--- a/arch/s390/include/asm/bugs.h
+++ b/arch/s390/include/asm/bugs.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/bugs.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 4 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 * 5 *
8 * Derived from "include/asm-i386/bugs.h" 6 * Derived from "include/asm-i386/bugs.h"
diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
index 2a30d5ac066..4d7ccac5fd1 100644
--- a/arch/s390/include/asm/cache.h
+++ b/arch/s390/include/asm/cache.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/cache.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999
6 * 4 *
7 * Derived from "include/asm-i386/cache.h" 5 * Derived from "include/asm-i386/cache.h"
8 * Copyright (C) 1992, Linus Torvalds 6 * Copyright (C) 1992, Linus Torvalds
diff --git a/arch/s390/include/asm/ccwdev.h b/arch/s390/include/asm/ccwdev.h
index 9381c92cc77..1cb4bb3f32d 100644
--- a/arch/s390/include/asm/ccwdev.h
+++ b/arch/s390/include/asm/ccwdev.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright IBM Corp. 2002, 2009 2 * Copyright IBM Corp. 2002, 2009
3 * 3 *
4 * Author(s): Arnd Bergmann <arndb@de.ibm.com> 4 * Author(s): Arnd Bergmann <arndb@de.ibm.com>
5 * 5 *
diff --git a/arch/s390/include/asm/ccwgroup.h b/arch/s390/include/asm/ccwgroup.h
index f2ef34f6d6e..01a905eb11e 100644
--- a/arch/s390/include/asm/ccwgroup.h
+++ b/arch/s390/include/asm/ccwgroup.h
@@ -6,14 +6,12 @@ struct ccw_driver;
6 6
7/** 7/**
8 * struct ccwgroup_device - ccw group device 8 * struct ccwgroup_device - ccw group device
9 * @creator_id: unique number of the driver
10 * @state: online/offline state 9 * @state: online/offline state
11 * @count: number of attached slave devices 10 * @count: number of attached slave devices
12 * @dev: embedded device structure 11 * @dev: embedded device structure
13 * @cdev: variable number of slave devices, allocated as needed 12 * @cdev: variable number of slave devices, allocated as needed
14 */ 13 */
15struct ccwgroup_device { 14struct ccwgroup_device {
16 unsigned long creator_id;
17 enum { 15 enum {
18 CCWGROUP_OFFLINE, 16 CCWGROUP_OFFLINE,
19 CCWGROUP_ONLINE, 17 CCWGROUP_ONLINE,
diff --git a/arch/s390/include/asm/checksum.h b/arch/s390/include/asm/checksum.h
index 6c00f6800a3..4f57a4f3909 100644
--- a/arch/s390/include/asm/checksum.h
+++ b/arch/s390/include/asm/checksum.h
@@ -1,18 +1,16 @@
1#ifndef _S390_CHECKSUM_H
2#define _S390_CHECKSUM_H
3
4/* 1/*
5 * include/asm-s390/checksum.h
6 * S390 fast network checksum routines 2 * S390 fast network checksum routines
7 * see also arch/S390/lib/checksum.c
8 * 3 *
9 * S390 version 4 * S390 version
10 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 5 * Copyright IBM Corp. 1999
11 * Author(s): Ulrich Hild (first version) 6 * Author(s): Ulrich Hild (first version)
12 * Martin Schwidefsky (heavily optimized CKSM version) 7 * Martin Schwidefsky (heavily optimized CKSM version)
13 * D.J. Barrow (third attempt) 8 * D.J. Barrow (third attempt)
14 */ 9 */
15 10
11#ifndef _S390_CHECKSUM_H
12#define _S390_CHECKSUM_H
13
16#include <asm/uaccess.h> 14#include <asm/uaccess.h>
17 15
18/* 16/*
diff --git a/arch/s390/include/asm/chpid.h b/arch/s390/include/asm/chpid.h
index 8e88e222177..e5bde9f9291 100644
--- a/arch/s390/include/asm/chpid.h
+++ b/arch/s390/include/asm/chpid.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * drivers/s390/cio/chpid.h
3 *
4 * Copyright IBM Corp. 2007 2 * Copyright IBM Corp. 2007
5 * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com> 3 * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
6 */ 4 */
diff --git a/arch/s390/include/asm/chsc.h b/arch/s390/include/asm/chsc.h
index 4943654ed7f..bf115b49f44 100644
--- a/arch/s390/include/asm/chsc.h
+++ b/arch/s390/include/asm/chsc.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * ioctl interface for /dev/chsc 2 * ioctl interface for /dev/chsc
3 * 3 *
4 * Copyright 2008 IBM Corp. 4 * Copyright IBM Corp. 2008
5 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com> 5 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
6 */ 6 */
7 7
diff --git a/arch/s390/include/asm/cio.h b/arch/s390/include/asm/cio.h
index 4c8d4d5b8bd..77043aa44d6 100644
--- a/arch/s390/include/asm/cio.h
+++ b/arch/s390/include/asm/cio.h
@@ -1,7 +1,4 @@
1/* 1/*
2 * include/asm-s390/cio.h
3 * include/asm-s390x/cio.h
4 *
5 * Common interface for I/O on S/390 2 * Common interface for I/O on S/390
6 */ 3 */
7#ifndef _ASM_S390_CIO_H_ 4#ifndef _ASM_S390_CIO_H_
diff --git a/arch/s390/include/asm/cpcmd.h b/arch/s390/include/asm/cpcmd.h
index 48a9eab1642..3dfadb5d648 100644
--- a/arch/s390/include/asm/cpcmd.h
+++ b/arch/s390/include/asm/cpcmd.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * arch/s390/kernel/cpcmd.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 4 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
7 * Christian Borntraeger (cborntra@de.ibm.com), 5 * Christian Borntraeger (cborntra@de.ibm.com),
8 */ 6 */
diff --git a/arch/s390/include/asm/cpu.h b/arch/s390/include/asm/cpu.h
index e0b69540216..f5a8e2fcde0 100644
--- a/arch/s390/include/asm/cpu.h
+++ b/arch/s390/include/asm/cpu.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright IBM Corp. 2000,2009 2 * Copyright IBM Corp. 2000, 2009
3 * Author(s): Hartmut Penner <hp@de.ibm.com>, 3 * Author(s): Hartmut Penner <hp@de.ibm.com>,
4 * Martin Schwidefsky <schwidefsky@de.ibm.com>, 4 * Martin Schwidefsky <schwidefsky@de.ibm.com>,
5 * Christian Ehrhardt <ehrhardt@de.ibm.com>, 5 * Christian Ehrhardt <ehrhardt@de.ibm.com>,
diff --git a/arch/s390/include/asm/cputime.h b/arch/s390/include/asm/cputime.h
index 718374de9c7..8709bdef233 100644
--- a/arch/s390/include/asm/cputime.h
+++ b/arch/s390/include/asm/cputime.h
@@ -1,7 +1,5 @@
1/* 1/*
2 * include/asm-s390/cputime.h 2 * Copyright IBM Corp. 2004
3 *
4 * (C) Copyright IBM Corp. 2004
5 * 3 *
6 * Author: Martin Schwidefsky <schwidefsky@de.ibm.com> 4 * Author: Martin Schwidefsky <schwidefsky@de.ibm.com>
7 */ 5 */
@@ -167,12 +165,14 @@ static inline clock_t cputime64_to_clock_t(cputime64_t cputime)
167} 165}
168 166
169struct s390_idle_data { 167struct s390_idle_data {
168 int nohz_delay;
170 unsigned int sequence; 169 unsigned int sequence;
171 unsigned long long idle_count; 170 unsigned long long idle_count;
172 unsigned long long idle_enter;
173 unsigned long long idle_exit;
174 unsigned long long idle_time; 171 unsigned long long idle_time;
175 int nohz_delay; 172 unsigned long long clock_idle_enter;
173 unsigned long long clock_idle_exit;
174 unsigned long long timer_idle_enter;
175 unsigned long long timer_idle_exit;
176}; 176};
177 177
178DECLARE_PER_CPU(struct s390_idle_data, s390_idle); 178DECLARE_PER_CPU(struct s390_idle_data, s390_idle);
diff --git a/arch/s390/include/asm/crw.h b/arch/s390/include/asm/crw.h
index 749a97e61be..7c31d3e25cd 100644
--- a/arch/s390/include/asm/crw.h
+++ b/arch/s390/include/asm/crw.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * Data definitions for channel report processing 2 * Data definitions for channel report processing
3 * Copyright IBM Corp. 2000,2009 3 * Copyright IBM Corp. 2000, 2009
4 * Author(s): Ingo Adlung <adlung@de.ibm.com>, 4 * Author(s): Ingo Adlung <adlung@de.ibm.com>,
5 * Martin Schwidefsky <schwidefsky@de.ibm.com>, 5 * Martin Schwidefsky <schwidefsky@de.ibm.com>,
6 * Cornelia Huck <cornelia.huck@de.ibm.com>, 6 * Cornelia Huck <cornelia.huck@de.ibm.com>,
diff --git a/arch/s390/include/asm/current.h b/arch/s390/include/asm/current.h
index 7a68084ec2f..b80941f30df 100644
--- a/arch/s390/include/asm/current.h
+++ b/arch/s390/include/asm/current.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/current.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 4 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 * 5 *
8 * Derived from "include/asm-i386/current.h" 6 * Derived from "include/asm-i386/current.h"
diff --git a/arch/s390/include/asm/dasd.h b/arch/s390/include/asm/dasd.h
index 0be28efe5b6..38eca3ba40e 100644
--- a/arch/s390/include/asm/dasd.h
+++ b/arch/s390/include/asm/dasd.h
@@ -1,8 +1,7 @@
1/* 1/*
2 * File...........: linux/drivers/s390/block/dasd.c
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> 2 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Bugreports.to..: <Linux390@de.ibm.com> 3 * Bugreports.to..: <Linux390@de.ibm.com>
5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 4 * Copyright IBM Corp. 1999, 2000
6 * EMC Symmetrix ioctl Copyright EMC Corporation, 2008 5 * EMC Symmetrix ioctl Copyright EMC Corporation, 2008
7 * Author.........: Nigel Hislop <hislop_nigel@emc.com> 6 * Author.........: Nigel Hislop <hislop_nigel@emc.com>
8 * 7 *
diff --git a/arch/s390/include/asm/debug.h b/arch/s390/include/asm/debug.h
index 8a8245ed14d..f39677e6ccd 100644
--- a/arch/s390/include/asm/debug.h
+++ b/arch/s390/include/asm/debug.h
@@ -1,9 +1,7 @@
1/* 1/*
2 * include/asm-s390/debug.h
3 * S/390 debug facility 2 * S/390 debug facility
4 * 3 *
5 * Copyright (C) 1999, 2000 IBM Deutschland Entwicklung GmbH, 4 * Copyright IBM Corp. 1999, 2000
6 * IBM Corporation
7 */ 5 */
8 6
9#ifndef DEBUG_H 7#ifndef DEBUG_H
diff --git a/arch/s390/include/asm/delay.h b/arch/s390/include/asm/delay.h
index 0e3b35f96be..3f6e4095f47 100644
--- a/arch/s390/include/asm/delay.h
+++ b/arch/s390/include/asm/delay.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/delay.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 4 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 * 5 *
8 * Derived from "include/asm-i386/delay.h" 6 * Derived from "include/asm-i386/delay.h"
diff --git a/arch/s390/include/asm/dma.h b/arch/s390/include/asm/dma.h
index 7425c6af6cd..6fb6de4f15b 100644
--- a/arch/s390/include/asm/dma.h
+++ b/arch/s390/include/asm/dma.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/dma.h
3 *
4 * S390 version 2 * S390 version
5 */ 3 */
6 4
diff --git a/arch/s390/include/asm/ebcdic.h b/arch/s390/include/asm/ebcdic.h
index 7f6f641d32f..c5befc5a3bf 100644
--- a/arch/s390/include/asm/ebcdic.h
+++ b/arch/s390/include/asm/ebcdic.h
@@ -1,9 +1,8 @@
1/* 1/*
2 * include/asm-s390/ebcdic.h
3 * EBCDIC -> ASCII, ASCII -> EBCDIC conversion routines. 2 * EBCDIC -> ASCII, ASCII -> EBCDIC conversion routines.
4 * 3 *
5 * S390 version 4 * S390 version
6 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 5 * Copyright IBM Corp. 1999
7 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 6 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
8 */ 7 */
9 8
diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
index 06151e6a309..9b94a160fe7 100644
--- a/arch/s390/include/asm/elf.h
+++ b/arch/s390/include/asm/elf.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/elf.h
3 *
4 * S390 version 2 * S390 version
5 * 3 *
6 * Derived from "include/asm-i386/elf.h" 4 * Derived from "include/asm-i386/elf.h"
@@ -182,7 +180,8 @@ extern char elf_platform[];
182#define ELF_PLATFORM (elf_platform) 180#define ELF_PLATFORM (elf_platform)
183 181
184#ifndef CONFIG_64BIT 182#ifndef CONFIG_64BIT
185#define SET_PERSONALITY(ex) set_personality(PER_LINUX) 183#define SET_PERSONALITY(ex) \
184 set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
186#else /* CONFIG_64BIT */ 185#else /* CONFIG_64BIT */
187#define SET_PERSONALITY(ex) \ 186#define SET_PERSONALITY(ex) \
188do { \ 187do { \
diff --git a/arch/s390/include/asm/errno.h b/arch/s390/include/asm/errno.h
index e41d5b37c4d..395e97d8005 100644
--- a/arch/s390/include/asm/errno.h
+++ b/arch/s390/include/asm/errno.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/errno.h
3 *
4 * S390 version 2 * S390 version
5 * 3 *
6 */ 4 */
diff --git a/arch/s390/include/asm/etr.h b/arch/s390/include/asm/etr.h
index 538e1b36a72..a24b03b9fb6 100644
--- a/arch/s390/include/asm/etr.h
+++ b/arch/s390/include/asm/etr.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/etr.h
3 *
4 * Copyright IBM Corp. 2006 2 * Copyright IBM Corp. 2006
5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 3 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
6 */ 4 */
diff --git a/arch/s390/include/asm/extmem.h b/arch/s390/include/asm/extmem.h
index 33837d75618..6276002d76b 100644
--- a/arch/s390/include/asm/extmem.h
+++ b/arch/s390/include/asm/extmem.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390x/extmem.h
3 *
4 * definitions for external memory segment support 2 * definitions for external memory segment support
5 * Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 2003
6 */ 4 */
7 5
8#ifndef _ASM_S390X_DCSS_H 6#ifndef _ASM_S390X_DCSS_H
diff --git a/arch/s390/include/asm/hardirq.h b/arch/s390/include/asm/hardirq.h
index 510ba9ef424..0c82ba86e99 100644
--- a/arch/s390/include/asm/hardirq.h
+++ b/arch/s390/include/asm/hardirq.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/hardirq.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999, 2000
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 4 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
7 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com) 5 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
8 * 6 *
diff --git a/arch/s390/include/asm/idals.h b/arch/s390/include/asm/idals.h
index aef0dde340d..ea5a6e45fd9 100644
--- a/arch/s390/include/asm/idals.h
+++ b/arch/s390/include/asm/idals.h
@@ -1,10 +1,9 @@
1/* 1/*
2 * File...........: linux/include/asm-s390x/idals.h
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> 2 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Martin Schwidefsky <schwidefsky@de.ibm.com> 3 * Martin Schwidefsky <schwidefsky@de.ibm.com>
5 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000a 5 * Copyright IBM Corp. 2000
7 6 *
8 * History of changes 7 * History of changes
9 * 07/24/00 new file 8 * 07/24/00 new file
10 * 05/04/02 code restructuring. 9 * 05/04/02 code restructuring.
diff --git a/arch/s390/include/asm/io.h b/arch/s390/include/asm/io.h
index f81a0975cbe..559e921a6bb 100644
--- a/arch/s390/include/asm/io.h
+++ b/arch/s390/include/asm/io.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/io.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 4 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 * 5 *
8 * Derived from "include/asm-i386/io.h" 6 * Derived from "include/asm-i386/io.h"
diff --git a/arch/s390/include/asm/irqflags.h b/arch/s390/include/asm/irqflags.h
index 38fdf451feb..37b9091ab8c 100644
--- a/arch/s390/include/asm/irqflags.h
+++ b/arch/s390/include/asm/irqflags.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright IBM Corp. 2006,2010 2 * Copyright IBM Corp. 2006, 2010
3 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 3 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
4 */ 4 */
5 5
diff --git a/arch/s390/include/asm/kexec.h b/arch/s390/include/asm/kexec.h
index f4f38826eeb..694bcd6bd92 100644
--- a/arch/s390/include/asm/kexec.h
+++ b/arch/s390/include/asm/kexec.h
@@ -1,7 +1,5 @@
1/* 1/*
2 * include/asm-s390/kexec.h 2 * Copyright IBM Corp. 2005
3 *
4 * (C) Copyright IBM Corp. 2005
5 * 3 *
6 * Author(s): Rolf Adelsberger <adelsberger@de.ibm.com> 4 * Author(s): Rolf Adelsberger <adelsberger@de.ibm.com>
7 * 5 *
diff --git a/arch/s390/include/asm/kprobes.h b/arch/s390/include/asm/kprobes.h
index a231a9439c4..dcf6948a875 100644
--- a/arch/s390/include/asm/kprobes.h
+++ b/arch/s390/include/asm/kprobes.h
@@ -17,7 +17,7 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * 19 *
20 * Copyright (C) IBM Corporation, 2002, 2006 20 * Copyright IBM Corp. 2002, 2006
21 * 21 *
22 * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel 22 * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel
23 * Probes initial implementation ( includes suggestions from 23 * Probes initial implementation ( includes suggestions from
diff --git a/arch/s390/include/asm/kvm.h b/arch/s390/include/asm/kvm.h
index bdcbe0f8dd7..d25da598ec6 100644
--- a/arch/s390/include/asm/kvm.h
+++ b/arch/s390/include/asm/kvm.h
@@ -1,7 +1,7 @@
1#ifndef __LINUX_KVM_S390_H 1#ifndef __LINUX_KVM_S390_H
2#define __LINUX_KVM_S390_H 2#define __LINUX_KVM_S390_H
3/* 3/*
4 * asm-s390/kvm.h - KVM s390 specific structures and definitions 4 * KVM s390 specific structures and definitions
5 * 5 *
6 * Copyright IBM Corp. 2008 6 * Copyright IBM Corp. 2008
7 * 7 *
diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index dd17537b9a9..b7841546991 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * asm-s390/kvm_host.h - definition for kernel virtual machines on s390 2 * definition for kernel virtual machines on s390
3 * 3 *
4 * Copyright IBM Corp. 2008,2009 4 * Copyright IBM Corp. 2008, 2009
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License (version 2 only) 7 * it under the terms of the GNU General Public License (version 2 only)
diff --git a/arch/s390/include/asm/kvm_para.h b/arch/s390/include/asm/kvm_para.h
index a9883296103..da44867de60 100644
--- a/arch/s390/include/asm/kvm_para.h
+++ b/arch/s390/include/asm/kvm_para.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * asm-s390/kvm_para.h - definition for paravirtual devices on s390 2 * definition for paravirtual devices on s390
3 * 3 *
4 * Copyright IBM Corp. 2008 4 * Copyright IBM Corp. 2008
5 * 5 *
diff --git a/arch/s390/include/asm/kvm_virtio.h b/arch/s390/include/asm/kvm_virtio.h
index 72f614181ef..44a438ca9e7 100644
--- a/arch/s390/include/asm/kvm_virtio.h
+++ b/arch/s390/include/asm/kvm_virtio.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * kvm_virtio.h - definition for virtio for kvm on s390 2 * definition for virtio for kvm on s390
3 * 3 *
4 * Copyright IBM Corp. 2008 4 * Copyright IBM Corp. 2008
5 * 5 *
diff --git a/arch/s390/include/asm/lowcore.h b/arch/s390/include/asm/lowcore.h
index 47853debb3b..aab5555bbbd 100644
--- a/arch/s390/include/asm/lowcore.h
+++ b/arch/s390/include/asm/lowcore.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright IBM Corp. 1999,2012 2 * Copyright IBM Corp. 1999, 2012
3 * Author(s): Hartmut Penner <hp@de.ibm.com>, 3 * Author(s): Hartmut Penner <hp@de.ibm.com>,
4 * Martin Schwidefsky <schwidefsky@de.ibm.com>, 4 * Martin Schwidefsky <schwidefsky@de.ibm.com>,
5 * Denis Joseph Barrow, 5 * Denis Joseph Barrow,
@@ -302,12 +302,7 @@ struct _lowcore {
302 */ 302 */
303 __u64 ipib; /* 0x0e00 */ 303 __u64 ipib; /* 0x0e00 */
304 __u32 ipib_checksum; /* 0x0e08 */ 304 __u32 ipib_checksum; /* 0x0e08 */
305 /* 305 __u64 vmcore_info; /* 0x0e0c */
306 * Because the vmcore_info pointer is not 8 byte aligned it never
307 * should not be accessed directly. For accessing the pointer, first
308 * copy it to a local pointer variable.
309 */
310 __u8 vmcore_info[8]; /* 0x0e0c */
311 __u8 pad_0x0e14[0x0e18-0x0e14]; /* 0x0e14 */ 306 __u8 pad_0x0e14[0x0e18-0x0e14]; /* 0x0e14 */
312 __u64 os_info; /* 0x0e18 */ 307 __u64 os_info; /* 0x0e18 */
313 __u8 pad_0x0e20[0x0f00-0x0e20]; /* 0x0e20 */ 308 __u8 pad_0x0e20[0x0f00-0x0e20]; /* 0x0e20 */
diff --git a/arch/s390/include/asm/mathemu.h b/arch/s390/include/asm/mathemu.h
index e8dd1ba8edb..614dfaf47f7 100644
--- a/arch/s390/include/asm/mathemu.h
+++ b/arch/s390/include/asm/mathemu.h
@@ -1,9 +1,8 @@
1/* 1/*
2 * arch/s390/kernel/mathemu.h
3 * IEEE floating point emulation. 2 * IEEE floating point emulation.
4 * 3 *
5 * S390 version 4 * S390 version
6 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 5 * Copyright IBM Corp. 1999
7 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
8 */ 7 */
9 8
diff --git a/arch/s390/include/asm/mman.h b/arch/s390/include/asm/mman.h
index d49760e6350..abc1932ac4e 100644
--- a/arch/s390/include/asm/mman.h
+++ b/arch/s390/include/asm/mman.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/mman.h
3 *
4 * S390 version 2 * S390 version
5 * 3 *
6 * Derived from "include/asm-i386/mman.h" 4 * Derived from "include/asm-i386/mman.h"
diff --git a/arch/s390/include/asm/mmu_context.h b/arch/s390/include/asm/mmu_context.h
index 69bdf72e95e..b749c573365 100644
--- a/arch/s390/include/asm/mmu_context.h
+++ b/arch/s390/include/asm/mmu_context.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/mmu_context.h
3 *
4 * S390 version 2 * S390 version
5 * 3 *
6 * Derived from "include/asm-i386/mmu_context.h" 4 * Derived from "include/asm-i386/mmu_context.h"
@@ -13,7 +11,6 @@
13#include <asm/uaccess.h> 11#include <asm/uaccess.h>
14#include <asm/tlbflush.h> 12#include <asm/tlbflush.h>
15#include <asm/ctl_reg.h> 13#include <asm/ctl_reg.h>
16#include <asm-generic/mm_hooks.h>
17 14
18static inline int init_new_context(struct task_struct *tsk, 15static inline int init_new_context(struct task_struct *tsk,
19 struct mm_struct *mm) 16 struct mm_struct *mm)
@@ -60,7 +57,7 @@ static inline void update_mm(struct mm_struct *mm, struct task_struct *tsk)
60 pgd_t *pgd = mm->pgd; 57 pgd_t *pgd = mm->pgd;
61 58
62 S390_lowcore.user_asce = mm->context.asce_bits | __pa(pgd); 59 S390_lowcore.user_asce = mm->context.asce_bits | __pa(pgd);
63 if (user_mode != HOME_SPACE_MODE) { 60 if (addressing_mode != HOME_SPACE_MODE) {
64 /* Load primary space page table origin. */ 61 /* Load primary space page table origin. */
65 asm volatile(LCTL_OPCODE" 1,1,%0\n" 62 asm volatile(LCTL_OPCODE" 1,1,%0\n"
66 : : "m" (S390_lowcore.user_asce) ); 63 : : "m" (S390_lowcore.user_asce) );
@@ -93,4 +90,17 @@ static inline void activate_mm(struct mm_struct *prev,
93 switch_mm(prev, next, current); 90 switch_mm(prev, next, current);
94} 91}
95 92
93static inline void arch_dup_mmap(struct mm_struct *oldmm,
94 struct mm_struct *mm)
95{
96#ifdef CONFIG_64BIT
97 if (oldmm->context.asce_limit < mm->context.asce_limit)
98 crst_table_downgrade(mm, oldmm->context.asce_limit);
99#endif
100}
101
102static inline void arch_exit_mmap(struct mm_struct *mm)
103{
104}
105
96#endif /* __S390_MMU_CONTEXT_H */ 106#endif /* __S390_MMU_CONTEXT_H */
diff --git a/arch/s390/include/asm/monwriter.h b/arch/s390/include/asm/monwriter.h
index f0cbf96c52e..f845c8e2f86 100644
--- a/arch/s390/include/asm/monwriter.h
+++ b/arch/s390/include/asm/monwriter.h
@@ -1,7 +1,5 @@
1/* 1/*
2 * include/asm-s390/monwriter.h 2 * Copyright IBM Corp. 2006
3 *
4 * Copyright (C) IBM Corp. 2006
5 * Character device driver for writing z/VM APPLDATA monitor records 3 * Character device driver for writing z/VM APPLDATA monitor records
6 * Version 1.0 4 * Version 1.0
7 * Author(s): Melissa Howland <melissah@us.ibm.com> 5 * Author(s): Melissa Howland <melissah@us.ibm.com>
diff --git a/arch/s390/include/asm/nmi.h b/arch/s390/include/asm/nmi.h
index f4b60441adc..35f8ec18561 100644
--- a/arch/s390/include/asm/nmi.h
+++ b/arch/s390/include/asm/nmi.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Machine check handler definitions 2 * Machine check handler definitions
3 * 3 *
4 * Copyright IBM Corp. 2000,2009 4 * Copyright IBM Corp. 2000, 2009
5 * Author(s): Ingo Adlung <adlung@de.ibm.com>, 5 * Author(s): Ingo Adlung <adlung@de.ibm.com>,
6 * Martin Schwidefsky <schwidefsky@de.ibm.com>, 6 * Martin Schwidefsky <schwidefsky@de.ibm.com>,
7 * Cornelia Huck <cornelia.huck@de.ibm.com>, 7 * Cornelia Huck <cornelia.huck@de.ibm.com>,
diff --git a/arch/s390/include/asm/page.h b/arch/s390/include/asm/page.h
index f7ec548c2b9..27ab3c7c1e8 100644
--- a/arch/s390/include/asm/page.h
+++ b/arch/s390/include/asm/page.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/page.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999, 2000
6 * Author(s): Hartmut Penner (hp@de.ibm.com) 4 * Author(s): Hartmut Penner (hp@de.ibm.com)
7 */ 5 */
8 6
diff --git a/arch/s390/include/asm/pgalloc.h b/arch/s390/include/asm/pgalloc.h
index 43078c19439..590c3219c63 100644
--- a/arch/s390/include/asm/pgalloc.h
+++ b/arch/s390/include/asm/pgalloc.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/pgalloc.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999, 2000
6 * Author(s): Hartmut Penner (hp@de.ibm.com) 4 * Author(s): Hartmut Penner (hp@de.ibm.com)
7 * Martin Schwidefsky (schwidefsky@de.ibm.com) 5 * Martin Schwidefsky (schwidefsky@de.ibm.com)
8 * 6 *
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index b3227415abd..6bd7d748301 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/pgtable.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999, 2000
6 * Author(s): Hartmut Penner (hp@de.ibm.com) 4 * Author(s): Hartmut Penner (hp@de.ibm.com)
7 * Ulrich Weigand (weigand@de.ibm.com) 5 * Ulrich Weigand (weigand@de.ibm.com)
8 * Martin Schwidefsky (schwidefsky@de.ibm.com) 6 * Martin Schwidefsky (schwidefsky@de.ibm.com)
diff --git a/arch/s390/include/asm/posix_types.h b/arch/s390/include/asm/posix_types.h
index 7be104c0f19..bf2a2ad2f80 100644
--- a/arch/s390/include/asm/posix_types.h
+++ b/arch/s390/include/asm/posix_types.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/posix_types.h
3 *
4 * S390 version 2 * S390 version
5 * 3 *
6 */ 4 */
@@ -15,6 +13,7 @@
15 */ 13 */
16 14
17typedef unsigned long __kernel_size_t; 15typedef unsigned long __kernel_size_t;
16typedef long __kernel_ssize_t;
18#define __kernel_size_t __kernel_size_t 17#define __kernel_size_t __kernel_size_t
19 18
20typedef unsigned short __kernel_old_dev_t; 19typedef unsigned short __kernel_old_dev_t;
@@ -27,7 +26,6 @@ typedef unsigned short __kernel_mode_t;
27typedef unsigned short __kernel_ipc_pid_t; 26typedef unsigned short __kernel_ipc_pid_t;
28typedef unsigned short __kernel_uid_t; 27typedef unsigned short __kernel_uid_t;
29typedef unsigned short __kernel_gid_t; 28typedef unsigned short __kernel_gid_t;
30typedef int __kernel_ssize_t;
31typedef int __kernel_ptrdiff_t; 29typedef int __kernel_ptrdiff_t;
32 30
33#else /* __s390x__ */ 31#else /* __s390x__ */
@@ -37,7 +35,6 @@ typedef unsigned int __kernel_mode_t;
37typedef int __kernel_ipc_pid_t; 35typedef int __kernel_ipc_pid_t;
38typedef unsigned int __kernel_uid_t; 36typedef unsigned int __kernel_uid_t;
39typedef unsigned int __kernel_gid_t; 37typedef unsigned int __kernel_gid_t;
40typedef long __kernel_ssize_t;
41typedef long __kernel_ptrdiff_t; 38typedef long __kernel_ptrdiff_t;
42typedef unsigned long __kernel_sigset_t; /* at least 32 bits */ 39typedef unsigned long __kernel_sigset_t; /* at least 32 bits */
43 40
diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h
index 20d0585cf90..11e4e323693 100644
--- a/arch/s390/include/asm/processor.h
+++ b/arch/s390/include/asm/processor.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/processor.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999
6 * Author(s): Hartmut Penner (hp@de.ibm.com), 4 * Author(s): Hartmut Penner (hp@de.ibm.com),
7 * Martin Schwidefsky (schwidefsky@de.ibm.com) 5 * Martin Schwidefsky (schwidefsky@de.ibm.com)
8 * 6 *
@@ -122,7 +120,9 @@ struct stack_frame {
122 regs->psw.mask = psw_user_bits | PSW_MASK_BA; \ 120 regs->psw.mask = psw_user_bits | PSW_MASK_BA; \
123 regs->psw.addr = new_psw | PSW_ADDR_AMODE; \ 121 regs->psw.addr = new_psw | PSW_ADDR_AMODE; \
124 regs->gprs[15] = new_stackp; \ 122 regs->gprs[15] = new_stackp; \
123 __tlb_flush_mm(current->mm); \
125 crst_table_downgrade(current->mm, 1UL << 31); \ 124 crst_table_downgrade(current->mm, 1UL << 31); \
125 update_mm(current->mm, current); \
126} while (0) 126} while (0)
127 127
128/* Forward declaration, a strange C thing */ 128/* Forward declaration, a strange C thing */
@@ -348,4 +348,14 @@ extern void (*s390_base_ext_handler_fn)(void);
348 ".previous\n" 348 ".previous\n"
349#endif 349#endif
350 350
351extern int memcpy_real(void *, void *, size_t);
352extern void memcpy_absolute(void *, void *, size_t);
353
354#define mem_assign_absolute(dest, val) { \
355 __typeof__(dest) __tmp = (val); \
356 \
357 BUILD_BUG_ON(sizeof(__tmp) != sizeof(val)); \
358 memcpy_absolute(&(dest), &__tmp, sizeof(__tmp)); \
359}
360
351#endif /* __ASM_S390_PROCESSOR_H */ 361#endif /* __ASM_S390_PROCESSOR_H */
diff --git a/arch/s390/include/asm/ptrace.h b/arch/s390/include/asm/ptrace.h
index aeb77f01798..d5f08ea566e 100644
--- a/arch/s390/include/asm/ptrace.h
+++ b/arch/s390/include/asm/ptrace.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/ptrace.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999, 2000
6 * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com) 4 * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
7 */ 5 */
8 6
diff --git a/arch/s390/include/asm/qdio.h b/arch/s390/include/asm/qdio.h
index f039d86adf6..57d0d7e794b 100644
--- a/arch/s390/include/asm/qdio.h
+++ b/arch/s390/include/asm/qdio.h
@@ -1,7 +1,5 @@
1/* 1/*
2 * linux/include/asm-s390/qdio.h 2 * Copyright IBM Corp. 2000, 2008
3 *
4 * Copyright 2000,2008 IBM Corp.
5 * Author(s): Utz Bacher <utz.bacher@de.ibm.com> 3 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>
6 * Jan Glauber <jang@linux.vnet.ibm.com> 4 * Jan Glauber <jang@linux.vnet.ibm.com>
7 * 5 *
diff --git a/arch/s390/include/asm/qeth.h b/arch/s390/include/asm/qeth.h
index 2c7c898c03e..3a896cf5258 100644
--- a/arch/s390/include/asm/qeth.h
+++ b/arch/s390/include/asm/qeth.h
@@ -1,9 +1,7 @@
1/* 1/*
2 * include/asm-s390/qeth.h
3 *
4 * ioctl definitions for qeth driver 2 * ioctl definitions for qeth driver
5 * 3 *
6 * Copyright (C) 2004 IBM Corporation 4 * Copyright IBM Corp. 2004
7 * 5 *
8 * Author(s): Thomas Spatzier <tspat@de.ibm.com> 6 * Author(s): Thomas Spatzier <tspat@de.ibm.com>
9 * 7 *
diff --git a/arch/s390/include/asm/reset.h b/arch/s390/include/asm/reset.h
index 3d6ad4ad2a3..804578587a7 100644
--- a/arch/s390/include/asm/reset.h
+++ b/arch/s390/include/asm/reset.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/reset.h
3 *
4 * Copyright IBM Corp. 2006 2 * Copyright IBM Corp. 2006
5 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com> 3 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
6 */ 4 */
diff --git a/arch/s390/include/asm/resource.h b/arch/s390/include/asm/resource.h
index 366c01de04f..ec23d1c73c9 100644
--- a/arch/s390/include/asm/resource.h
+++ b/arch/s390/include/asm/resource.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/resource.h
3 *
4 * S390 version 2 * S390 version
5 * 3 *
6 * Derived from "include/asm-i386/resources.h" 4 * Derived from "include/asm-i386/resources.h"
diff --git a/arch/s390/include/asm/rwsem.h b/arch/s390/include/asm/rwsem.h
index 1ceee10264c..487f9b64efb 100644
--- a/arch/s390/include/asm/rwsem.h
+++ b/arch/s390/include/asm/rwsem.h
@@ -2,10 +2,8 @@
2#define _S390_RWSEM_H 2#define _S390_RWSEM_H
3 3
4/* 4/*
5 * include/asm-s390/rwsem.h
6 *
7 * S390 version 5 * S390 version
8 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation 6 * Copyright IBM Corp. 2002
9 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 7 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
10 * 8 *
11 * Based on asm-alpha/semaphore.h and asm-i386/rwsem.h 9 * Based on asm-alpha/semaphore.h and asm-i386/rwsem.h
diff --git a/arch/s390/include/asm/sclp.h b/arch/s390/include/asm/sclp.h
index bf238c55740..e62a555557e 100644
--- a/arch/s390/include/asm/sclp.h
+++ b/arch/s390/include/asm/sclp.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/sclp.h
3 *
4 * Copyright IBM Corp. 2007 2 * Copyright IBM Corp. 2007
5 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com> 3 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
6 */ 4 */
@@ -55,5 +53,7 @@ int sclp_chp_configure(struct chp_id chpid);
55int sclp_chp_deconfigure(struct chp_id chpid); 53int sclp_chp_deconfigure(struct chp_id chpid);
56int sclp_chp_read_info(struct sclp_chp_info *info); 54int sclp_chp_read_info(struct sclp_chp_info *info);
57void sclp_get_ipl_info(struct sclp_ipl_info *info); 55void sclp_get_ipl_info(struct sclp_ipl_info *info);
56bool sclp_has_linemode(void);
57bool sclp_has_vt220(void);
58 58
59#endif /* _ASM_S390_SCLP_H */ 59#endif /* _ASM_S390_SCLP_H */
diff --git a/arch/s390/include/asm/scsw.h b/arch/s390/include/asm/scsw.h
index de389cb54d2..4071d00978c 100644
--- a/arch/s390/include/asm/scsw.h
+++ b/arch/s390/include/asm/scsw.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Helper functions for scsw access. 2 * Helper functions for scsw access.
3 * 3 *
4 * Copyright IBM Corp. 2008,2009 4 * Copyright IBM Corp. 2008, 2009
5 * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com> 5 * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
6 */ 6 */
7 7
diff --git a/arch/s390/include/asm/setup.h b/arch/s390/include/asm/setup.h
index 40eb2ff88e9..e6859d16ee2 100644
--- a/arch/s390/include/asm/setup.h
+++ b/arch/s390/include/asm/setup.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/setup.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright IBM Corp. 1999,2010 3 * Copyright IBM Corp. 1999, 2010
6 */ 4 */
7 5
8#ifndef _ASM_S390_SETUP_H 6#ifndef _ASM_S390_SETUP_H
@@ -62,7 +60,7 @@ void create_mem_hole(struct mem_chunk memory_chunk[], unsigned long addr,
62#define SECONDARY_SPACE_MODE 2 60#define SECONDARY_SPACE_MODE 2
63#define HOME_SPACE_MODE 3 61#define HOME_SPACE_MODE 3
64 62
65extern unsigned int user_mode; 63extern unsigned int addressing_mode;
66 64
67/* 65/*
68 * Machine features detected in head.S 66 * Machine features detected in head.S
diff --git a/arch/s390/include/asm/shmparam.h b/arch/s390/include/asm/shmparam.h
index c2e0c0508e7..e985182738f 100644
--- a/arch/s390/include/asm/shmparam.h
+++ b/arch/s390/include/asm/shmparam.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/shmparam.h
3 *
4 * S390 version 2 * S390 version
5 * 3 *
6 * Derived from "include/asm-i386/shmparam.h" 4 * Derived from "include/asm-i386/shmparam.h"
diff --git a/arch/s390/include/asm/sigcontext.h b/arch/s390/include/asm/sigcontext.h
index aeb6e0b1332..584787f6ce4 100644
--- a/arch/s390/include/asm/sigcontext.h
+++ b/arch/s390/include/asm/sigcontext.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/sigcontext.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999, 2000
6 */ 4 */
7 5
8#ifndef _ASM_S390_SIGCONTEXT_H 6#ifndef _ASM_S390_SIGCONTEXT_H
diff --git a/arch/s390/include/asm/siginfo.h b/arch/s390/include/asm/siginfo.h
index e0ff1ab054b..91fd3e4b70c 100644
--- a/arch/s390/include/asm/siginfo.h
+++ b/arch/s390/include/asm/siginfo.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/siginfo.h
3 *
4 * S390 version 2 * S390 version
5 * 3 *
6 * Derived from "include/asm-i386/siginfo.h" 4 * Derived from "include/asm-i386/siginfo.h"
diff --git a/arch/s390/include/asm/signal.h b/arch/s390/include/asm/signal.h
index cdf5cb2fe03..6d4d9d1faee 100644
--- a/arch/s390/include/asm/signal.h
+++ b/arch/s390/include/asm/signal.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/signal.h
3 *
4 * S390 version 2 * S390 version
5 * 3 *
6 * Derived from "include/asm-i386/signal.h" 4 * Derived from "include/asm-i386/signal.h"
diff --git a/arch/s390/include/asm/sigp.h b/arch/s390/include/asm/sigp.h
new file mode 100644
index 00000000000..5a87d16d3e7
--- /dev/null
+++ b/arch/s390/include/asm/sigp.h
@@ -0,0 +1,32 @@
1#ifndef __S390_ASM_SIGP_H
2#define __S390_ASM_SIGP_H
3
4/* SIGP order codes */
5#define SIGP_SENSE 1
6#define SIGP_EXTERNAL_CALL 2
7#define SIGP_EMERGENCY_SIGNAL 3
8#define SIGP_STOP 5
9#define SIGP_RESTART 6
10#define SIGP_STOP_AND_STORE_STATUS 9
11#define SIGP_INITIAL_CPU_RESET 11
12#define SIGP_SET_PREFIX 13
13#define SIGP_STORE_STATUS_AT_ADDRESS 14
14#define SIGP_SET_ARCHITECTURE 18
15#define SIGP_SENSE_RUNNING 21
16
17/* SIGP condition codes */
18#define SIGP_CC_ORDER_CODE_ACCEPTED 0
19#define SIGP_CC_STATUS_STORED 1
20#define SIGP_CC_BUSY 2
21#define SIGP_CC_NOT_OPERATIONAL 3
22
23/* SIGP cpu status bits */
24
25#define SIGP_STATUS_CHECK_STOP 0x00000010UL
26#define SIGP_STATUS_STOPPED 0x00000040UL
27#define SIGP_STATUS_EXT_CALL_PENDING 0x00000080UL
28#define SIGP_STATUS_INVALID_PARAMETER 0x00000100UL
29#define SIGP_STATUS_INCORRECT_STATE 0x00000200UL
30#define SIGP_STATUS_NOT_RUNNING 0x00000400UL
31
32#endif /* __S390_ASM_SIGP_H */
diff --git a/arch/s390/include/asm/smp.h b/arch/s390/include/asm/smp.h
index 0b6f586c138..ce26ac3cb16 100644
--- a/arch/s390/include/asm/smp.h
+++ b/arch/s390/include/asm/smp.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright IBM Corp. 1999,2012 2 * Copyright IBM Corp. 1999, 2012
3 * Author(s): Denis Joseph Barrow, 3 * Author(s): Denis Joseph Barrow,
4 * Martin Schwidefsky <schwidefsky@de.ibm.com>, 4 * Martin Schwidefsky <schwidefsky@de.ibm.com>,
5 * Heiko Carstens <heiko.carstens@de.ibm.com>, 5 * Heiko Carstens <heiko.carstens@de.ibm.com>,
@@ -44,6 +44,7 @@ static inline void smp_call_online_cpu(void (*func)(void *), void *data)
44} 44}
45 45
46static inline int smp_find_processor_id(int address) { return 0; } 46static inline int smp_find_processor_id(int address) { return 0; }
47static inline int smp_store_status(int cpu) { return 0; }
47static inline int smp_vcpu_scheduled(int cpu) { return 1; } 48static inline int smp_vcpu_scheduled(int cpu) { return 1; }
48static inline void smp_yield_cpu(int cpu) { } 49static inline void smp_yield_cpu(int cpu) { }
49static inline void smp_yield(void) { } 50static inline void smp_yield(void) { }
diff --git a/arch/s390/include/asm/socket.h b/arch/s390/include/asm/socket.h
index c91b720965c..69718cd6d63 100644
--- a/arch/s390/include/asm/socket.h
+++ b/arch/s390/include/asm/socket.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/socket.h
3 *
4 * S390 version 2 * S390 version
5 * 3 *
6 * Derived from "include/asm-i386/socket.h" 4 * Derived from "include/asm-i386/socket.h"
diff --git a/arch/s390/include/asm/sparsemem.h b/arch/s390/include/asm/sparsemem.h
index 0fb34027d3f..a60d085ddb4 100644
--- a/arch/s390/include/asm/sparsemem.h
+++ b/arch/s390/include/asm/sparsemem.h
@@ -4,13 +4,11 @@
4#ifdef CONFIG_64BIT 4#ifdef CONFIG_64BIT
5 5
6#define SECTION_SIZE_BITS 28 6#define SECTION_SIZE_BITS 28
7#define MAX_PHYSADDR_BITS 46
8#define MAX_PHYSMEM_BITS 46 7#define MAX_PHYSMEM_BITS 46
9 8
10#else 9#else
11 10
12#define SECTION_SIZE_BITS 25 11#define SECTION_SIZE_BITS 25
13#define MAX_PHYSADDR_BITS 31
14#define MAX_PHYSMEM_BITS 31 12#define MAX_PHYSMEM_BITS 31
15 13
16#endif /* CONFIG_64BIT */ 14#endif /* CONFIG_64BIT */
diff --git a/arch/s390/include/asm/spinlock.h b/arch/s390/include/asm/spinlock.h
index fd94dfec8d0..701fe8c59e1 100644
--- a/arch/s390/include/asm/spinlock.h
+++ b/arch/s390/include/asm/spinlock.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/spinlock.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 4 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 * 5 *
8 * Derived from "include/asm-i386/spinlock.h" 6 * Derived from "include/asm-i386/spinlock.h"
diff --git a/arch/s390/include/asm/stat.h b/arch/s390/include/asm/stat.h
index d92959eebb6..b4ca97d9146 100644
--- a/arch/s390/include/asm/stat.h
+++ b/arch/s390/include/asm/stat.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/stat.h
3 *
4 * S390 version 2 * S390 version
5 * 3 *
6 * Derived from "include/asm-i386/stat.h" 4 * Derived from "include/asm-i386/stat.h"
diff --git a/arch/s390/include/asm/statfs.h b/arch/s390/include/asm/statfs.h
index 3be7fbd406c..5acca0a34c2 100644
--- a/arch/s390/include/asm/statfs.h
+++ b/arch/s390/include/asm/statfs.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/statfs.h
3 *
4 * S390 version 2 * S390 version
5 * 3 *
6 * Derived from "include/asm-i386/statfs.h" 4 * Derived from "include/asm-i386/statfs.h"
diff --git a/arch/s390/include/asm/string.h b/arch/s390/include/asm/string.h
index 8cc160c9e1c..1bd1352fa3b 100644
--- a/arch/s390/include/asm/string.h
+++ b/arch/s390/include/asm/string.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/string.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 4 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
7 */ 5 */
8 6
diff --git a/arch/s390/include/asm/swab.h b/arch/s390/include/asm/swab.h
index a3e4ebb3209..da3bfe5cc16 100644
--- a/arch/s390/include/asm/swab.h
+++ b/arch/s390/include/asm/swab.h
@@ -2,10 +2,8 @@
2#define _S390_SWAB_H 2#define _S390_SWAB_H
3 3
4/* 4/*
5 * include/asm-s390/swab.h
6 *
7 * S390 version 5 * S390 version
8 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 6 * Copyright IBM Corp. 1999
9 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 7 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
10 */ 8 */
11 9
diff --git a/arch/s390/include/asm/syscall.h b/arch/s390/include/asm/syscall.h
index fb214dd9b7e..fe7b99759e1 100644
--- a/arch/s390/include/asm/syscall.h
+++ b/arch/s390/include/asm/syscall.h
@@ -12,6 +12,7 @@
12#ifndef _ASM_SYSCALL_H 12#ifndef _ASM_SYSCALL_H
13#define _ASM_SYSCALL_H 1 13#define _ASM_SYSCALL_H 1
14 14
15#include <linux/audit.h>
15#include <linux/sched.h> 16#include <linux/sched.h>
16#include <linux/err.h> 17#include <linux/err.h>
17#include <asm/ptrace.h> 18#include <asm/ptrace.h>
@@ -87,4 +88,13 @@ static inline void syscall_set_arguments(struct task_struct *task,
87 regs->orig_gpr2 = args[0]; 88 regs->orig_gpr2 = args[0];
88} 89}
89 90
91static inline int syscall_get_arch(struct task_struct *task,
92 struct pt_regs *regs)
93{
94#ifdef CONFIG_COMPAT
95 if (test_tsk_thread_flag(task, TIF_31BIT))
96 return AUDIT_ARCH_S390;
97#endif
98 return sizeof(long) == 8 ? AUDIT_ARCH_S390X : AUDIT_ARCH_S390;
99}
90#endif /* _ASM_SYSCALL_H */ 100#endif /* _ASM_SYSCALL_H */
diff --git a/arch/s390/include/asm/sysinfo.h b/arch/s390/include/asm/sysinfo.h
index 79d3d6e2e9c..282ee36f616 100644
--- a/arch/s390/include/asm/sysinfo.h
+++ b/arch/s390/include/asm/sysinfo.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * definition for store system information stsi 2 * definition for store system information stsi
3 * 3 *
4 * Copyright IBM Corp. 2001,2008 4 * Copyright IBM Corp. 2001, 2008
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License (version 2 only) 7 * it under the terms of the GNU General Public License (version 2 only)
diff --git a/arch/s390/include/asm/tape390.h b/arch/s390/include/asm/tape390.h
index 884fba48f1f..b2bc4bab792 100644
--- a/arch/s390/include/asm/tape390.h
+++ b/arch/s390/include/asm/tape390.h
@@ -1,10 +1,9 @@
1/************************************************************************* 1/*************************************************************************
2 * 2 *
3 * tape390.h
4 * enables user programs to display messages and control encryption 3 * enables user programs to display messages and control encryption
5 * on s390 tape devices 4 * on s390 tape devices
6 * 5 *
7 * Copyright IBM Corp. 2001,2006 6 * Copyright IBM Corp. 2001, 2006
8 * Author(s): Michael Holzheu <holzheu@de.ibm.com> 7 * Author(s): Michael Holzheu <holzheu@de.ibm.com>
9 * 8 *
10 *************************************************************************/ 9 *************************************************************************/
diff --git a/arch/s390/include/asm/termios.h b/arch/s390/include/asm/termios.h
index bc3a35cefc9..cb9fe2786b8 100644
--- a/arch/s390/include/asm/termios.h
+++ b/arch/s390/include/asm/termios.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/termios.h
3 *
4 * S390 version 2 * S390 version
5 * 3 *
6 * Derived from "include/asm-i386/termios.h" 4 * Derived from "include/asm-i386/termios.h"
diff --git a/arch/s390/include/asm/thread_info.h b/arch/s390/include/asm/thread_info.h
index 4e40b25cd06..bb08e2afc5d 100644
--- a/arch/s390/include/asm/thread_info.h
+++ b/arch/s390/include/asm/thread_info.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/thread_info.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) IBM Corp. 2002,2006 3 * Copyright IBM Corp. 2002, 2006
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 4 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 */ 5 */
8 6
diff --git a/arch/s390/include/asm/timer.h b/arch/s390/include/asm/timer.h
deleted file mode 100644
index 15d647901e5..00000000000
--- a/arch/s390/include/asm/timer.h
+++ /dev/null
@@ -1,51 +0,0 @@
1/*
2 * include/asm-s390/timer.h
3 *
4 * (C) Copyright IBM Corp. 2003,2006
5 * Virtual CPU timer
6 *
7 * Author: Jan Glauber (jang@de.ibm.com)
8 */
9
10#ifndef _ASM_S390_TIMER_H
11#define _ASM_S390_TIMER_H
12
13#include <linux/timer.h>
14
15#define VTIMER_MAX_SLICE (0x7ffffffffffff000LL)
16
17struct vtimer_list {
18 struct list_head entry;
19
20 int cpu;
21 __u64 expires;
22 __u64 interval;
23
24 void (*function)(unsigned long);
25 unsigned long data;
26};
27
28/* the vtimer value will wrap after ca. 71 years */
29struct vtimer_queue {
30 struct list_head list;
31 spinlock_t lock;
32 __u64 timer; /* last programmed timer */
33 __u64 elapsed; /* elapsed time of timer expire values */
34 __u64 idle_enter; /* cpu timer on idle enter */
35 __u64 idle_exit; /* cpu timer on idle exit */
36};
37
38extern void init_virt_timer(struct vtimer_list *timer);
39extern void add_virt_timer(void *new);
40extern void add_virt_timer_periodic(void *new);
41extern int mod_virt_timer(struct vtimer_list *timer, __u64 expires);
42extern int mod_virt_timer_periodic(struct vtimer_list *timer, __u64 expires);
43extern int del_virt_timer(struct vtimer_list *timer);
44
45extern void init_cpu_vtimer(void);
46extern void vtime_init(void);
47
48extern void vtime_stop_cpu(void);
49extern void vtime_start_leave(void);
50
51#endif /* _ASM_S390_TIMER_H */
diff --git a/arch/s390/include/asm/timex.h b/arch/s390/include/asm/timex.h
index 239ece9e53c..fba4d66788a 100644
--- a/arch/s390/include/asm/timex.h
+++ b/arch/s390/include/asm/timex.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/timex.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999
6 * 4 *
7 * Derived from "include/asm-i386/timex.h" 5 * Derived from "include/asm-i386/timex.h"
8 * Copyright (C) 1992, Linus Torvalds 6 * Copyright (C) 1992, Linus Torvalds
diff --git a/arch/s390/include/asm/types.h b/arch/s390/include/asm/types.h
index 6c8c35f8df1..6ba7c2c7217 100644
--- a/arch/s390/include/asm/types.h
+++ b/arch/s390/include/asm/types.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/types.h
3 *
4 * S390 version 2 * S390 version
5 * 3 *
6 * Derived from "include/asm-i386/types.h" 4 * Derived from "include/asm-i386/types.h"
diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
index 1f3a79bcd26..a8ab18b18b5 100644
--- a/arch/s390/include/asm/uaccess.h
+++ b/arch/s390/include/asm/uaccess.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * include/asm-s390/uaccess.h
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999, 2000
6 * Author(s): Hartmut Penner (hp@de.ibm.com), 4 * Author(s): Hartmut Penner (hp@de.ibm.com),
7 * Martin Schwidefsky (schwidefsky@de.ibm.com) 5 * Martin Schwidefsky (schwidefsky@de.ibm.com)
8 * 6 *
@@ -381,8 +379,6 @@ clear_user(void __user *to, unsigned long n)
381 return n; 379 return n;
382} 380}
383 381
384extern int memcpy_real(void *, void *, size_t);
385extern void memcpy_absolute(void *, void *, size_t);
386extern int copy_to_user_real(void __user *dest, void *src, size_t count); 382extern int copy_to_user_real(void __user *dest, void *src, size_t count);
387extern int copy_from_user_real(void *dest, void __user *src, size_t count); 383extern int copy_from_user_real(void *dest, void __user *src, size_t count);
388 384
diff --git a/arch/s390/include/asm/ucontext.h b/arch/s390/include/asm/ucontext.h
index cfb874e66c9..200e06325c6 100644
--- a/arch/s390/include/asm/ucontext.h
+++ b/arch/s390/include/asm/ucontext.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/ucontext.h
3 *
4 * S390 version 2 * S390 version
5 * 3 *
6 * Derived from "include/asm-i386/ucontext.h" 4 * Derived from "include/asm-i386/ucontext.h"
diff --git a/arch/s390/include/asm/unistd.h b/arch/s390/include/asm/unistd.h
index 8a8008fe7b8..6756e78f480 100644
--- a/arch/s390/include/asm/unistd.h
+++ b/arch/s390/include/asm/unistd.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/unistd.h
3 *
4 * S390 version 2 * S390 version
5 * 3 *
6 * Derived from "include/asm-i386/unistd.h" 4 * Derived from "include/asm-i386/unistd.h"
@@ -390,7 +388,6 @@
390#define __IGNORE_recvmmsg 388#define __IGNORE_recvmmsg
391#define __IGNORE_sendmmsg 389#define __IGNORE_sendmmsg
392 390
393#define __ARCH_WANT_IPC_PARSE_VERSION
394#define __ARCH_WANT_OLD_READDIR 391#define __ARCH_WANT_OLD_READDIR
395#define __ARCH_WANT_SYS_ALARM 392#define __ARCH_WANT_SYS_ALARM
396#define __ARCH_WANT_SYS_GETHOSTNAME 393#define __ARCH_WANT_SYS_GETHOSTNAME
diff --git a/arch/s390/include/asm/user.h b/arch/s390/include/asm/user.h
index 1b050e35fdc..6ed1d188633 100644
--- a/arch/s390/include/asm/user.h
+++ b/arch/s390/include/asm/user.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-s390/user.h
3 *
4 * S390 version 2 * S390 version
5 * 3 *
6 * Derived from "include/asm-i386/usr.h" 4 * Derived from "include/asm-i386/usr.h"
diff --git a/arch/s390/include/asm/vtimer.h b/arch/s390/include/asm/vtimer.h
new file mode 100644
index 00000000000..bfe25d513ad
--- /dev/null
+++ b/arch/s390/include/asm/vtimer.h
@@ -0,0 +1,33 @@
1/*
2 * Copyright IBM Corp. 2003, 2012
3 * Virtual CPU timer
4 *
5 * Author(s): Jan Glauber <jan.glauber@de.ibm.com>
6 */
7
8#ifndef _ASM_S390_TIMER_H
9#define _ASM_S390_TIMER_H
10
11#define VTIMER_MAX_SLICE (0x7fffffffffffffffULL)
12
13struct vtimer_list {
14 struct list_head entry;
15 u64 expires;
16 u64 interval;
17 void (*function)(unsigned long);
18 unsigned long data;
19};
20
21extern void init_virt_timer(struct vtimer_list *timer);
22extern void add_virt_timer(struct vtimer_list *timer);
23extern void add_virt_timer_periodic(struct vtimer_list *timer);
24extern int mod_virt_timer(struct vtimer_list *timer, u64 expires);
25extern int mod_virt_timer_periodic(struct vtimer_list *timer, u64 expires);
26extern int del_virt_timer(struct vtimer_list *timer);
27
28extern void init_cpu_vtimer(void);
29extern void vtime_init(void);
30
31extern void vtime_stop_cpu(void);
32
33#endif /* _ASM_S390_TIMER_H */
diff --git a/arch/s390/include/asm/vtoc.h b/arch/s390/include/asm/vtoc.h
index 8406a2b3157..221419de275 100644
--- a/arch/s390/include/asm/vtoc.h
+++ b/arch/s390/include/asm/vtoc.h
@@ -1,9 +1,7 @@
1/* 1/*
2 * include/asm-s390/vtoc.h
3 *
4 * This file contains volume label definitions for DASD devices. 2 * This file contains volume label definitions for DASD devices.
5 * 3 *
6 * (C) Copyright IBM Corp. 2005 4 * Copyright IBM Corp. 2005
7 * 5 *
8 * Author(s): Volker Sameske <sameske@de.ibm.com> 6 * Author(s): Volker Sameske <sameske@de.ibm.com>
9 * 7 *
diff --git a/arch/s390/include/asm/zcrypt.h b/arch/s390/include/asm/zcrypt.h
index 00d3bbd4411..e83fc116f5b 100644
--- a/arch/s390/include/asm/zcrypt.h
+++ b/arch/s390/include/asm/zcrypt.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * zcrypt 2.1.0 (user-visible header) 4 * zcrypt 2.1.0 (user-visible header)
5 * 5 *
6 * Copyright (C) 2001, 2006 IBM Corporation 6 * Copyright IBM Corp. 2001, 2006
7 * Author(s): Robert Burroughs 7 * Author(s): Robert Burroughs
8 * Eric Rossman (edrossma@us.ibm.com) 8 * Eric Rossman (edrossma@us.ibm.com)
9 * 9 *
diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
index 83e6edf5cf1..45ef1a7b08f 100644
--- a/arch/s390/kernel/asm-offsets.c
+++ b/arch/s390/kernel/asm-offsets.c
@@ -9,7 +9,6 @@
9#include <linux/kbuild.h> 9#include <linux/kbuild.h>
10#include <linux/sched.h> 10#include <linux/sched.h>
11#include <asm/cputime.h> 11#include <asm/cputime.h>
12#include <asm/timer.h>
13#include <asm/vdso.h> 12#include <asm/vdso.h>
14#include <asm/pgtable.h> 13#include <asm/pgtable.h>
15 14
@@ -72,11 +71,10 @@ int main(void)
72 DEFINE(__CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC); 71 DEFINE(__CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC);
73 BLANK(); 72 BLANK();
74 /* idle data offsets */ 73 /* idle data offsets */
75 DEFINE(__IDLE_ENTER, offsetof(struct s390_idle_data, idle_enter)); 74 DEFINE(__CLOCK_IDLE_ENTER, offsetof(struct s390_idle_data, clock_idle_enter));
76 DEFINE(__IDLE_EXIT, offsetof(struct s390_idle_data, idle_exit)); 75 DEFINE(__CLOCK_IDLE_EXIT, offsetof(struct s390_idle_data, clock_idle_exit));
77 /* vtimer queue offsets */ 76 DEFINE(__TIMER_IDLE_ENTER, offsetof(struct s390_idle_data, timer_idle_enter));
78 DEFINE(__VQ_IDLE_ENTER, offsetof(struct vtimer_queue, idle_enter)); 77 DEFINE(__TIMER_IDLE_EXIT, offsetof(struct s390_idle_data, timer_idle_exit));
79 DEFINE(__VQ_IDLE_EXIT, offsetof(struct vtimer_queue, idle_exit));
80 /* lowcore offsets */ 78 /* lowcore offsets */
81 DEFINE(__LC_EXT_PARAMS, offsetof(struct _lowcore, ext_params)); 79 DEFINE(__LC_EXT_PARAMS, offsetof(struct _lowcore, ext_params));
82 DEFINE(__LC_EXT_CPU_ADDR, offsetof(struct _lowcore, ext_cpu_addr)); 80 DEFINE(__LC_EXT_CPU_ADDR, offsetof(struct _lowcore, ext_cpu_addr));
@@ -131,6 +129,8 @@ int main(void)
131 DEFINE(__LC_PANIC_STACK, offsetof(struct _lowcore, panic_stack)); 129 DEFINE(__LC_PANIC_STACK, offsetof(struct _lowcore, panic_stack));
132 DEFINE(__LC_RESTART_STACK, offsetof(struct _lowcore, restart_stack)); 130 DEFINE(__LC_RESTART_STACK, offsetof(struct _lowcore, restart_stack));
133 DEFINE(__LC_RESTART_FN, offsetof(struct _lowcore, restart_fn)); 131 DEFINE(__LC_RESTART_FN, offsetof(struct _lowcore, restart_fn));
132 DEFINE(__LC_RESTART_DATA, offsetof(struct _lowcore, restart_data));
133 DEFINE(__LC_RESTART_SOURCE, offsetof(struct _lowcore, restart_source));
134 DEFINE(__LC_USER_ASCE, offsetof(struct _lowcore, user_asce)); 134 DEFINE(__LC_USER_ASCE, offsetof(struct _lowcore, user_asce));
135 DEFINE(__LC_INT_CLOCK, offsetof(struct _lowcore, int_clock)); 135 DEFINE(__LC_INT_CLOCK, offsetof(struct _lowcore, int_clock));
136 DEFINE(__LC_MCCK_CLOCK, offsetof(struct _lowcore, mcck_clock)); 136 DEFINE(__LC_MCCK_CLOCK, offsetof(struct _lowcore, mcck_clock));
diff --git a/arch/s390/kernel/base.S b/arch/s390/kernel/base.S
index c880ff72db4..797a823a227 100644
--- a/arch/s390/kernel/base.S
+++ b/arch/s390/kernel/base.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/s390/kernel/base.S 2 * arch/s390/kernel/base.S
3 * 3 *
4 * Copyright IBM Corp. 2006,2007 4 * Copyright IBM Corp. 2006, 2007
5 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com> 5 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
6 * Michael Holzheu <holzheu@de.ibm.com> 6 * Michael Holzheu <holzheu@de.ibm.com>
7 */ 7 */
@@ -9,6 +9,7 @@
9#include <linux/linkage.h> 9#include <linux/linkage.h>
10#include <asm/asm-offsets.h> 10#include <asm/asm-offsets.h>
11#include <asm/ptrace.h> 11#include <asm/ptrace.h>
12#include <asm/sigp.h>
12 13
13#ifdef CONFIG_64BIT 14#ifdef CONFIG_64BIT
14 15
@@ -100,7 +101,7 @@ ENTRY(diag308_reset)
100.Lrestart_part2: 101.Lrestart_part2:
101 lhi %r0,0 # Load r0 with zero 102 lhi %r0,0 # Load r0 with zero
102 lhi %r1,2 # Use mode 2 = ESAME (dump) 103 lhi %r1,2 # Use mode 2 = ESAME (dump)
103 sigp %r1,%r0,0x12 # Switch to ESAME mode 104 sigp %r1,%r0,SIGP_SET_ARCHITECTURE # Switch to ESAME mode
104 sam64 # Switch to 64 bit addressing mode 105 sam64 # Switch to 64 bit addressing mode
105 larl %r4,.Lctlregs # Restore control registers 106 larl %r4,.Lctlregs # Restore control registers
106 lctlg %c0,%c15,0(%r4) 107 lctlg %c0,%c15,0(%r4)
diff --git a/arch/s390/kernel/bitmap.c b/arch/s390/kernel/bitmap.c
index 3ae4757b006..102da5e2303 100644
--- a/arch/s390/kernel/bitmap.c
+++ b/arch/s390/kernel/bitmap.c
@@ -2,7 +2,7 @@
2 * Bitmaps for set_bit, clear_bit, test_and_set_bit, ... 2 * Bitmaps for set_bit, clear_bit, test_and_set_bit, ...
3 * See include/asm/{bitops.h|posix_types.h} for details 3 * See include/asm/{bitops.h|posix_types.h} for details
4 * 4 *
5 * Copyright IBM Corp. 1999,2009 5 * Copyright IBM Corp. 1999, 2009
6 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>, 6 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>,
7 */ 7 */
8 8
diff --git a/arch/s390/kernel/compat_exec_domain.c b/arch/s390/kernel/compat_exec_domain.c
index 914d49444f9..765fabdada9 100644
--- a/arch/s390/kernel/compat_exec_domain.c
+++ b/arch/s390/kernel/compat_exec_domain.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Support for 32-bit Linux for S390 personality. 2 * Support for 32-bit Linux for S390 personality.
3 * 3 *
4 * Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation 4 * Copyright IBM Corp. 2000
5 * Author(s): Gerhard Tonn (ton@de.ibm.com) 5 * Author(s): Gerhard Tonn (ton@de.ibm.com)
6 * 6 *
7 * 7 *
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
index 65426525d9f..f606d935f49 100644
--- a/arch/s390/kernel/compat_linux.c
+++ b/arch/s390/kernel/compat_linux.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * arch/s390x/kernel/linux32.c
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 2000
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 4 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
7 * Gerhard Tonn (ton@de.ibm.com) 5 * Gerhard Tonn (ton@de.ibm.com)
8 * Thomas Spatzier (tspat@de.ibm.com) 6 * Thomas Spatzier (tspat@de.ibm.com)
@@ -622,7 +620,6 @@ asmlinkage unsigned long old32_mmap(struct mmap_arg_struct_emu31 __user *arg)
622 return -EFAULT; 620 return -EFAULT;
623 if (a.offset & ~PAGE_MASK) 621 if (a.offset & ~PAGE_MASK)
624 return -EINVAL; 622 return -EINVAL;
625 a.addr = (unsigned long) compat_ptr(a.addr);
626 return sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, 623 return sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
627 a.offset >> PAGE_SHIFT); 624 a.offset >> PAGE_SHIFT);
628} 625}
@@ -633,7 +630,6 @@ asmlinkage long sys32_mmap2(struct mmap_arg_struct_emu31 __user *arg)
633 630
634 if (copy_from_user(&a, arg, sizeof(a))) 631 if (copy_from_user(&a, arg, sizeof(a)))
635 return -EFAULT; 632 return -EFAULT;
636 a.addr = (unsigned long) compat_ptr(a.addr);
637 return sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset); 633 return sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
638} 634}
639 635
diff --git a/arch/s390/kernel/compat_signal.c b/arch/s390/kernel/compat_signal.c
index 3c0c19830c3..a1e8a8694bb 100644
--- a/arch/s390/kernel/compat_signal.c
+++ b/arch/s390/kernel/compat_signal.c
@@ -1,7 +1,5 @@
1/* 1/*
2 * arch/s390/kernel/compat_signal.c 2 * Copyright IBM Corp. 2000, 2006
3 *
4 * Copyright (C) IBM Corp. 2000,2006
5 * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com) 3 * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
6 * Gerhard Tonn (ton@de.ibm.com) 4 * Gerhard Tonn (ton@de.ibm.com)
7 * 5 *
diff --git a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S
index ff605a39cf4..2d82cfcbce5 100644
--- a/arch/s390/kernel/compat_wrapper.S
+++ b/arch/s390/kernel/compat_wrapper.S
@@ -1,8 +1,7 @@
1/* 1/*
2* arch/s390/kernel/compat_wrapper.S
3* wrapper for 31 bit compatible system calls. 2* wrapper for 31 bit compatible system calls.
4* 3*
5* Copyright (C) IBM Corp. 2000,2006 4* Copyright IBM Corp. 2000, 2006
6* Author(s): Gerhard Tonn (ton@de.ibm.com), 5* Author(s): Gerhard Tonn (ton@de.ibm.com),
7* Thomas Spatzier (tspat@de.ibm.com) 6* Thomas Spatzier (tspat@de.ibm.com)
8*/ 7*/
@@ -1636,7 +1635,7 @@ ENTRY(compat_sys_process_vm_readv_wrapper)
1636 llgfr %r6,%r6 # unsigned long 1635 llgfr %r6,%r6 # unsigned long
1637 llgf %r0,164(%r15) # unsigned long 1636 llgf %r0,164(%r15) # unsigned long
1638 stg %r0,160(%r15) 1637 stg %r0,160(%r15)
1639 jg sys_process_vm_readv 1638 jg compat_sys_process_vm_readv
1640 1639
1641ENTRY(compat_sys_process_vm_writev_wrapper) 1640ENTRY(compat_sys_process_vm_writev_wrapper)
1642 lgfr %r2,%r2 # compat_pid_t 1641 lgfr %r2,%r2 # compat_pid_t
@@ -1646,4 +1645,4 @@ ENTRY(compat_sys_process_vm_writev_wrapper)
1646 llgfr %r6,%r6 # unsigned long 1645 llgfr %r6,%r6 # unsigned long
1647 llgf %r0,164(%r15) # unsigned long 1646 llgf %r0,164(%r15) # unsigned long
1648 stg %r0,160(%r15) 1647 stg %r0,160(%r15)
1649 jg sys_process_vm_writev 1648 jg compat_sys_process_vm_writev
diff --git a/arch/s390/kernel/cpcmd.c b/arch/s390/kernel/cpcmd.c
index e3dd886e1b3..d7b0c4d2788 100644
--- a/arch/s390/kernel/cpcmd.c
+++ b/arch/s390/kernel/cpcmd.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * arch/s390/kernel/cpcmd.c
3 *
4 * S390 version 2 * S390 version
5 * Copyright IBM Corp. 1999,2007 3 * Copyright IBM Corp. 1999, 2007
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 4 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
7 * Christian Borntraeger (cborntra@de.ibm.com), 5 * Christian Borntraeger (cborntra@de.ibm.com),
8 */ 6 */
diff --git a/arch/s390/kernel/crash.c b/arch/s390/kernel/crash.c
index 8cc7c9fa64f..3819153de8b 100644
--- a/arch/s390/kernel/crash.c
+++ b/arch/s390/kernel/crash.c
@@ -1,7 +1,5 @@
1/* 1/*
2 * arch/s390/kernel/crash.c 2 * Copyright IBM Corp. 2005
3 *
4 * (C) Copyright IBM Corp. 2005
5 * 3 *
6 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com> 4 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
7 * 5 *
diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 19e5e9eba54..ba500d8dc39 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -1,5 +1,4 @@
1/* 1/*
2 * arch/s390/kernel/debug.c
3 * S/390 debug facility 2 * S/390 debug facility
4 * 3 *
5 * Copyright IBM Corp. 1999, 2012 4 * Copyright IBM Corp. 1999, 2012
@@ -111,6 +110,7 @@ struct debug_view debug_raw_view = {
111 NULL, 110 NULL,
112 NULL 111 NULL
113}; 112};
113EXPORT_SYMBOL(debug_raw_view);
114 114
115struct debug_view debug_hex_ascii_view = { 115struct debug_view debug_hex_ascii_view = {
116 "hex_ascii", 116 "hex_ascii",
@@ -120,6 +120,7 @@ struct debug_view debug_hex_ascii_view = {
120 NULL, 120 NULL,
121 NULL 121 NULL
122}; 122};
123EXPORT_SYMBOL(debug_hex_ascii_view);
123 124
124static struct debug_view debug_level_view = { 125static struct debug_view debug_level_view = {
125 "level", 126 "level",
@@ -156,6 +157,7 @@ struct debug_view debug_sprintf_view = {
156 NULL, 157 NULL,
157 NULL 158 NULL
158}; 159};
160EXPORT_SYMBOL(debug_sprintf_view);
159 161
160/* used by dump analysis tools to determine version of debug feature */ 162/* used by dump analysis tools to determine version of debug feature */
161static unsigned int __used debug_feature_version = __DEBUG_FEATURE_VERSION; 163static unsigned int __used debug_feature_version = __DEBUG_FEATURE_VERSION;
@@ -731,6 +733,7 @@ debug_info_t *debug_register(const char *name, int pages_per_area,
731 return debug_register_mode(name, pages_per_area, nr_areas, buf_size, 733 return debug_register_mode(name, pages_per_area, nr_areas, buf_size,
732 S_IRUSR | S_IWUSR, 0, 0); 734 S_IRUSR | S_IWUSR, 0, 0);
733} 735}
736EXPORT_SYMBOL(debug_register);
734 737
735/* 738/*
736 * debug_unregister: 739 * debug_unregister:
@@ -749,6 +752,7 @@ debug_unregister(debug_info_t * id)
749out: 752out:
750 return; 753 return;
751} 754}
755EXPORT_SYMBOL(debug_unregister);
752 756
753/* 757/*
754 * debug_set_size: 758 * debug_set_size:
@@ -811,7 +815,7 @@ debug_set_level(debug_info_t* id, int new_level)
811 } 815 }
812 spin_unlock_irqrestore(&id->lock,flags); 816 spin_unlock_irqrestore(&id->lock,flags);
813} 817}
814 818EXPORT_SYMBOL(debug_set_level);
815 819
816/* 820/*
817 * proceed_active_entry: 821 * proceed_active_entry:
@@ -931,7 +935,7 @@ debug_stop_all(void)
931 if (debug_stoppable) 935 if (debug_stoppable)
932 debug_active = 0; 936 debug_active = 0;
933} 937}
934 938EXPORT_SYMBOL(debug_stop_all);
935 939
936void debug_set_critical(void) 940void debug_set_critical(void)
937{ 941{
@@ -964,6 +968,7 @@ debug_event_common(debug_info_t * id, int level, const void *buf, int len)
964 968
965 return active; 969 return active;
966} 970}
971EXPORT_SYMBOL(debug_event_common);
967 972
968/* 973/*
969 * debug_exception_common: 974 * debug_exception_common:
@@ -991,6 +996,7 @@ debug_entry_t
991 996
992 return active; 997 return active;
993} 998}
999EXPORT_SYMBOL(debug_exception_common);
994 1000
995/* 1001/*
996 * counts arguments in format string for sprintf view 1002 * counts arguments in format string for sprintf view
@@ -1044,6 +1050,7 @@ debug_sprintf_event(debug_info_t* id, int level,char *string,...)
1044 1050
1045 return active; 1051 return active;
1046} 1052}
1053EXPORT_SYMBOL(debug_sprintf_event);
1047 1054
1048/* 1055/*
1049 * debug_sprintf_exception: 1056 * debug_sprintf_exception:
@@ -1082,25 +1089,7 @@ debug_sprintf_exception(debug_info_t* id, int level,char *string,...)
1082 1089
1083 return active; 1090 return active;
1084} 1091}
1085 1092EXPORT_SYMBOL(debug_sprintf_exception);
1086/*
1087 * debug_init:
1088 * - is called exactly once to initialize the debug feature
1089 */
1090
1091static int
1092__init debug_init(void)
1093{
1094 int rc = 0;
1095
1096 s390dbf_sysctl_header = register_sysctl_table(s390dbf_dir_table);
1097 mutex_lock(&debug_mutex);
1098 debug_debugfs_root_entry = debugfs_create_dir(DEBUG_DIR_ROOT,NULL);
1099 initialized = 1;
1100 mutex_unlock(&debug_mutex);
1101
1102 return rc;
1103}
1104 1093
1105/* 1094/*
1106 * debug_register_view: 1095 * debug_register_view:
@@ -1148,6 +1137,7 @@ debug_register_view(debug_info_t * id, struct debug_view *view)
1148out: 1137out:
1149 return rc; 1138 return rc;
1150} 1139}
1140EXPORT_SYMBOL(debug_register_view);
1151 1141
1152/* 1142/*
1153 * debug_unregister_view: 1143 * debug_unregister_view:
@@ -1177,6 +1167,7 @@ debug_unregister_view(debug_info_t * id, struct debug_view *view)
1177out: 1167out:
1178 return rc; 1168 return rc;
1179} 1169}
1170EXPORT_SYMBOL(debug_unregister_view);
1180 1171
1181static inline char * 1172static inline char *
1182debug_get_user_string(const char __user *user_buf, size_t user_len) 1173debug_get_user_string(const char __user *user_buf, size_t user_len)
@@ -1486,6 +1477,7 @@ debug_dflt_header_fn(debug_info_t * id, struct debug_view *view,
1486 except_str, entry->id.fields.cpuid, (void *) caller); 1477 except_str, entry->id.fields.cpuid, (void *) caller);
1487 return rc; 1478 return rc;
1488} 1479}
1480EXPORT_SYMBOL(debug_dflt_header_fn);
1489 1481
1490/* 1482/*
1491 * prints debug data sprintf-formated: 1483 * prints debug data sprintf-formated:
@@ -1534,33 +1526,16 @@ out:
1534} 1526}
1535 1527
1536/* 1528/*
1537 * clean up module 1529 * debug_init:
1530 * - is called exactly once to initialize the debug feature
1538 */ 1531 */
1539static void __exit debug_exit(void) 1532static int __init debug_init(void)
1540{ 1533{
1541 debugfs_remove(debug_debugfs_root_entry); 1534 s390dbf_sysctl_header = register_sysctl_table(s390dbf_dir_table);
1542 unregister_sysctl_table(s390dbf_sysctl_header); 1535 mutex_lock(&debug_mutex);
1543 return; 1536 debug_debugfs_root_entry = debugfs_create_dir(DEBUG_DIR_ROOT, NULL);
1537 initialized = 1;
1538 mutex_unlock(&debug_mutex);
1539 return 0;
1544} 1540}
1545
1546/*
1547 * module definitions
1548 */
1549postcore_initcall(debug_init); 1541postcore_initcall(debug_init);
1550module_exit(debug_exit);
1551MODULE_LICENSE("GPL");
1552
1553EXPORT_SYMBOL(debug_register);
1554EXPORT_SYMBOL(debug_unregister);
1555EXPORT_SYMBOL(debug_set_level);
1556EXPORT_SYMBOL(debug_stop_all);
1557EXPORT_SYMBOL(debug_register_view);
1558EXPORT_SYMBOL(debug_unregister_view);
1559EXPORT_SYMBOL(debug_event_common);
1560EXPORT_SYMBOL(debug_exception_common);
1561EXPORT_SYMBOL(debug_hex_ascii_view);
1562EXPORT_SYMBOL(debug_raw_view);
1563EXPORT_SYMBOL(debug_dflt_header_fn);
1564EXPORT_SYMBOL(debug_sprintf_view);
1565EXPORT_SYMBOL(debug_sprintf_exception);
1566EXPORT_SYMBOL(debug_sprintf_event);
diff --git a/arch/s390/kernel/dis.c b/arch/s390/kernel/dis.c
index 3221c6fca8b..619c5d35072 100644
--- a/arch/s390/kernel/dis.c
+++ b/arch/s390/kernel/dis.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/s390/kernel/dis.c
3 *
4 * Disassemble s390 instructions. 2 * Disassemble s390 instructions.
5 * 3 *
6 * Copyright IBM Corp. 2007 4 * Copyright IBM Corp. 2007
@@ -613,6 +611,7 @@ static struct insn opcode_b2[] = {
613 { "sie", 0x14, INSTR_S_RD }, 611 { "sie", 0x14, INSTR_S_RD },
614 { "pc", 0x18, INSTR_S_RD }, 612 { "pc", 0x18, INSTR_S_RD },
615 { "sac", 0x19, INSTR_S_RD }, 613 { "sac", 0x19, INSTR_S_RD },
614 { "servc", 0x20, INSTR_RRE_RR },
616 { "cfc", 0x1a, INSTR_S_RD }, 615 { "cfc", 0x1a, INSTR_S_RD },
617 { "ipte", 0x21, INSTR_RRE_RR }, 616 { "ipte", 0x21, INSTR_RRE_RR },
618 { "ipm", 0x22, INSTR_RRE_R0 }, 617 { "ipm", 0x22, INSTR_RRE_R0 },
@@ -1532,7 +1531,7 @@ static int print_insn(char *buffer, unsigned char *code, unsigned long addr)
1532 1531
1533void show_code(struct pt_regs *regs) 1532void show_code(struct pt_regs *regs)
1534{ 1533{
1535 char *mode = (regs->psw.mask & PSW_MASK_PSTATE) ? "User" : "Krnl"; 1534 char *mode = user_mode(regs) ? "User" : "Krnl";
1536 unsigned char code[64]; 1535 unsigned char code[64];
1537 char buffer[64], *ptr; 1536 char buffer[64], *ptr;
1538 mm_segment_t old_fs; 1537 mm_segment_t old_fs;
@@ -1541,7 +1540,7 @@ void show_code(struct pt_regs *regs)
1541 1540
1542 /* Get a snapshot of the 64 bytes surrounding the fault address. */ 1541 /* Get a snapshot of the 64 bytes surrounding the fault address. */
1543 old_fs = get_fs(); 1542 old_fs = get_fs();
1544 set_fs((regs->psw.mask & PSW_MASK_PSTATE) ? USER_DS : KERNEL_DS); 1543 set_fs(user_mode(regs) ? USER_DS : KERNEL_DS);
1545 for (start = 32; start && regs->psw.addr >= 34 - start; start -= 2) { 1544 for (start = 32; start && regs->psw.addr >= 34 - start; start -= 2) {
1546 addr = regs->psw.addr - 34 + start; 1545 addr = regs->psw.addr - 34 + start;
1547 if (__copy_from_user(code + start - 2, 1546 if (__copy_from_user(code + start - 2,
diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c
index 6684fff1755..83c3271c442 100644
--- a/arch/s390/kernel/early.c
+++ b/arch/s390/kernel/early.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/s390/kernel/early.c
3 *
4 * Copyright IBM Corp. 2007, 2009 2 * Copyright IBM Corp. 2007, 2009
5 * Author(s): Hongjie Yang <hongjie@us.ibm.com>, 3 * Author(s): Hongjie Yang <hongjie@us.ibm.com>,
6 * Heiko Carstens <heiko.carstens@de.ibm.com> 4 * Heiko Carstens <heiko.carstens@de.ibm.com>
@@ -457,7 +455,6 @@ void __init startup_init(void)
457 init_kernel_storage_key(); 455 init_kernel_storage_key();
458 lockdep_init(); 456 lockdep_init();
459 lockdep_off(); 457 lockdep_off();
460 sort_main_extable();
461 setup_lowcore_early(); 458 setup_lowcore_early();
462 setup_facility_list(); 459 setup_facility_list();
463 detect_machine_type(); 460 detect_machine_type();
diff --git a/arch/s390/kernel/ebcdic.c b/arch/s390/kernel/ebcdic.c
index cc0dc609d73..b971c6be629 100644
--- a/arch/s390/kernel/ebcdic.c
+++ b/arch/s390/kernel/ebcdic.c
@@ -1,10 +1,9 @@
1/* 1/*
2 * arch/s390/kernel/ebcdic.c
3 * ECBDIC -> ASCII, ASCII -> ECBDIC, 2 * ECBDIC -> ASCII, ASCII -> ECBDIC,
4 * upper to lower case (EBCDIC) conversion tables. 3 * upper to lower case (EBCDIC) conversion tables.
5 * 4 *
6 * S390 version 5 * S390 version
7 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 6 * Copyright IBM Corp. 1999
8 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 7 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
9 * Martin Peschke <peschke@fh-brandenburg.de> 8 * Martin Peschke <peschke@fh-brandenburg.de>
10 */ 9 */
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index 1ae93b573d7..870bad6d56f 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -1,8 +1,7 @@
1/* 1/*
2 * arch/s390/kernel/entry.S
3 * S390 low-level entry points. 2 * S390 low-level entry points.
4 * 3 *
5 * Copyright (C) IBM Corp. 1999,2012 4 * Copyright IBM Corp. 1999, 2012
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
7 * Hartmut Penner (hp@de.ibm.com), 6 * Hartmut Penner (hp@de.ibm.com),
8 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com), 7 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
@@ -18,6 +17,7 @@
18#include <asm/asm-offsets.h> 17#include <asm/asm-offsets.h>
19#include <asm/unistd.h> 18#include <asm/unistd.h>
20#include <asm/page.h> 19#include <asm/page.h>
20#include <asm/sigp.h>
21 21
22__PT_R0 = __PT_GPRS 22__PT_R0 = __PT_GPRS
23__PT_R1 = __PT_GPRS + 4 23__PT_R1 = __PT_GPRS + 4
@@ -616,17 +616,13 @@ ext_skip:
616 * Load idle PSW. The second "half" of this function is in cleanup_idle. 616 * Load idle PSW. The second "half" of this function is in cleanup_idle.
617 */ 617 */
618ENTRY(psw_idle) 618ENTRY(psw_idle)
619 st %r4,__SF_EMPTY(%r15) 619 st %r3,__SF_EMPTY(%r15)
620 basr %r1,0 620 basr %r1,0
621 la %r1,psw_idle_lpsw+4-.(%r1) 621 la %r1,psw_idle_lpsw+4-.(%r1)
622 st %r1,__SF_EMPTY+4(%r15) 622 st %r1,__SF_EMPTY+4(%r15)
623 oi __SF_EMPTY+4(%r15),0x80 623 oi __SF_EMPTY+4(%r15),0x80
624 la %r1,.Lvtimer_max-psw_idle_lpsw-4(%r1) 624 stck __CLOCK_IDLE_ENTER(%r2)
625 stck __IDLE_ENTER(%r2) 625 stpt __TIMER_IDLE_ENTER(%r2)
626 ltr %r5,%r5
627 stpt __VQ_IDLE_ENTER(%r3)
628 jz psw_idle_lpsw
629 spt 0(%r1)
630psw_idle_lpsw: 626psw_idle_lpsw:
631 lpsw __SF_EMPTY(%r15) 627 lpsw __SF_EMPTY(%r15)
632 br %r14 628 br %r14
@@ -723,15 +719,17 @@ ENTRY(restart_int_handler)
723 mvc __PT_PSW(8,%r15),__LC_RST_OLD_PSW # store restart old psw 719 mvc __PT_PSW(8,%r15),__LC_RST_OLD_PSW # store restart old psw
724 ahi %r15,-STACK_FRAME_OVERHEAD # create stack frame on stack 720 ahi %r15,-STACK_FRAME_OVERHEAD # create stack frame on stack
725 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15) 721 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
726 lm %r1,%r3,__LC_RESTART_FN # load fn, parm & source cpu 722 l %r1,__LC_RESTART_FN # load fn, parm & source cpu
723 l %r2,__LC_RESTART_DATA
724 l %r3,__LC_RESTART_SOURCE
727 ltr %r3,%r3 # test source cpu address 725 ltr %r3,%r3 # test source cpu address
728 jm 1f # negative -> skip source stop 726 jm 1f # negative -> skip source stop
7290: sigp %r4,%r3,1 # sigp sense to source cpu 7270: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
730 brc 10,0b # wait for status stored 728 brc 10,0b # wait for status stored
7311: basr %r14,%r1 # call function 7291: basr %r14,%r1 # call function
732 stap __SF_EMPTY(%r15) # store cpu address 730 stap __SF_EMPTY(%r15) # store cpu address
733 lh %r3,__SF_EMPTY(%r15) 731 lh %r3,__SF_EMPTY(%r15)
7342: sigp %r4,%r3,5 # sigp stop to current cpu 7322: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
735 brc 2,2b 733 brc 2,2b
7363: j 3b 7343: j 3b
737 735
@@ -883,33 +881,28 @@ cleanup_io_restore_insn:
883 881
884cleanup_idle: 882cleanup_idle:
885 # copy interrupt clock & cpu timer 883 # copy interrupt clock & cpu timer
886 mvc __IDLE_EXIT(8,%r2),__LC_INT_CLOCK 884 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_INT_CLOCK
887 mvc __VQ_IDLE_EXIT(8,%r3),__LC_ASYNC_ENTER_TIMER 885 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_ASYNC_ENTER_TIMER
888 chi %r11,__LC_SAVE_AREA_ASYNC 886 chi %r11,__LC_SAVE_AREA_ASYNC
889 je 0f 887 je 0f
890 mvc __IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK 888 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
891 mvc __VQ_IDLE_EXIT(8,%r3),__LC_MCCK_ENTER_TIMER 889 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_MCCK_ENTER_TIMER
8920: # check if stck has been executed 8900: # check if stck has been executed
893 cl %r9,BASED(cleanup_idle_insn) 891 cl %r9,BASED(cleanup_idle_insn)
894 jhe 1f 892 jhe 1f
895 mvc __IDLE_ENTER(8,%r2),__IDLE_EXIT(%r2) 893 mvc __CLOCK_IDLE_ENTER(8,%r2),__CLOCK_IDLE_EXIT(%r2)
896 mvc __VQ_IDLE_ENTER(8,%r3),__VQ_IDLE_EXIT(%r3) 894 mvc __TIMER_IDLE_ENTER(8,%r2),__TIMER_IDLE_EXIT(%r3)
897 j 2f 8951: # account system time going idle
8981: # check if the cpu timer has been reprogrammed
899 ltr %r5,%r5
900 jz 2f
901 spt __VQ_IDLE_ENTER(%r3)
9022: # account system time going idle
903 lm %r9,%r10,__LC_STEAL_TIMER 896 lm %r9,%r10,__LC_STEAL_TIMER
904 ADD64 %r9,%r10,__IDLE_ENTER(%r2) 897 ADD64 %r9,%r10,__CLOCK_IDLE_ENTER(%r2)
905 SUB64 %r9,%r10,__LC_LAST_UPDATE_CLOCK 898 SUB64 %r9,%r10,__LC_LAST_UPDATE_CLOCK
906 stm %r9,%r10,__LC_STEAL_TIMER 899 stm %r9,%r10,__LC_STEAL_TIMER
907 mvc __LC_LAST_UPDATE_CLOCK(8),__IDLE_EXIT(%r2) 900 mvc __LC_LAST_UPDATE_CLOCK(8),__CLOCK_IDLE_EXIT(%r2)
908 lm %r9,%r10,__LC_SYSTEM_TIMER 901 lm %r9,%r10,__LC_SYSTEM_TIMER
909 ADD64 %r9,%r10,__LC_LAST_UPDATE_TIMER 902 ADD64 %r9,%r10,__LC_LAST_UPDATE_TIMER
910 SUB64 %r9,%r10,__VQ_IDLE_ENTER(%r3) 903 SUB64 %r9,%r10,__TIMER_IDLE_ENTER(%r2)
911 stm %r9,%r10,__LC_SYSTEM_TIMER 904 stm %r9,%r10,__LC_SYSTEM_TIMER
912 mvc __LC_LAST_UPDATE_TIMER(8),__VQ_IDLE_EXIT(%r3) 905 mvc __LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2)
913 # prepare return psw 906 # prepare return psw
914 n %r8,BASED(cleanup_idle_wait) # clear wait state bit 907 n %r8,BASED(cleanup_idle_wait) # clear wait state bit
915 l %r9,24(%r11) # return from psw_idle 908 l %r9,24(%r11) # return from psw_idle
diff --git a/arch/s390/kernel/entry.h b/arch/s390/kernel/entry.h
index f66a229ab0b..a5f4dc42a5d 100644
--- a/arch/s390/kernel/entry.h
+++ b/arch/s390/kernel/entry.h
@@ -5,7 +5,6 @@
5#include <linux/signal.h> 5#include <linux/signal.h>
6#include <asm/ptrace.h> 6#include <asm/ptrace.h>
7#include <asm/cputime.h> 7#include <asm/cputime.h>
8#include <asm/timer.h>
9 8
10extern void (*pgm_check_table[128])(struct pt_regs *); 9extern void (*pgm_check_table[128])(struct pt_regs *);
11extern void *restart_stack; 10extern void *restart_stack;
@@ -17,8 +16,7 @@ void io_int_handler(void);
17void mcck_int_handler(void); 16void mcck_int_handler(void);
18void restart_int_handler(void); 17void restart_int_handler(void);
19void restart_call_handler(void); 18void restart_call_handler(void);
20void psw_idle(struct s390_idle_data *, struct vtimer_queue *, 19void psw_idle(struct s390_idle_data *, unsigned long);
21 unsigned long, int);
22 20
23asmlinkage long do_syscall_trace_enter(struct pt_regs *regs); 21asmlinkage long do_syscall_trace_enter(struct pt_regs *regs);
24asmlinkage void do_syscall_trace_exit(struct pt_regs *regs); 22asmlinkage void do_syscall_trace_exit(struct pt_regs *regs);
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
index 229fe1d0774..349b7eeb348 100644
--- a/arch/s390/kernel/entry64.S
+++ b/arch/s390/kernel/entry64.S
@@ -1,8 +1,7 @@
1/* 1/*
2 * arch/s390/kernel/entry64.S
3 * S390 low-level entry points. 2 * S390 low-level entry points.
4 * 3 *
5 * Copyright (C) IBM Corp. 1999,2012 4 * Copyright IBM Corp. 1999, 2012
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
7 * Hartmut Penner (hp@de.ibm.com), 6 * Hartmut Penner (hp@de.ibm.com),
8 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com), 7 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
@@ -18,6 +17,7 @@
18#include <asm/asm-offsets.h> 17#include <asm/asm-offsets.h>
19#include <asm/unistd.h> 18#include <asm/unistd.h>
20#include <asm/page.h> 19#include <asm/page.h>
20#include <asm/sigp.h>
21 21
22__PT_R0 = __PT_GPRS 22__PT_R0 = __PT_GPRS
23__PT_R1 = __PT_GPRS + 8 23__PT_R1 = __PT_GPRS + 8
@@ -642,15 +642,11 @@ ext_skip:
642 * Load idle PSW. The second "half" of this function is in cleanup_idle. 642 * Load idle PSW. The second "half" of this function is in cleanup_idle.
643 */ 643 */
644ENTRY(psw_idle) 644ENTRY(psw_idle)
645 stg %r4,__SF_EMPTY(%r15) 645 stg %r3,__SF_EMPTY(%r15)
646 larl %r1,psw_idle_lpsw+4 646 larl %r1,psw_idle_lpsw+4
647 stg %r1,__SF_EMPTY+8(%r15) 647 stg %r1,__SF_EMPTY+8(%r15)
648 larl %r1,.Lvtimer_max 648 STCK __CLOCK_IDLE_ENTER(%r2)
649 STCK __IDLE_ENTER(%r2) 649 stpt __TIMER_IDLE_ENTER(%r2)
650 ltr %r5,%r5
651 stpt __VQ_IDLE_ENTER(%r3)
652 jz psw_idle_lpsw
653 spt 0(%r1)
654psw_idle_lpsw: 650psw_idle_lpsw:
655 lpswe __SF_EMPTY(%r15) 651 lpswe __SF_EMPTY(%r15)
656 br %r14 652 br %r14
@@ -750,15 +746,17 @@ ENTRY(restart_int_handler)
750 mvc __PT_PSW(16,%r15),__LC_RST_OLD_PSW # store restart old psw 746 mvc __PT_PSW(16,%r15),__LC_RST_OLD_PSW # store restart old psw
751 aghi %r15,-STACK_FRAME_OVERHEAD # create stack frame on stack 747 aghi %r15,-STACK_FRAME_OVERHEAD # create stack frame on stack
752 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15) 748 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
753 lmg %r1,%r3,__LC_RESTART_FN # load fn, parm & source cpu 749 lg %r1,__LC_RESTART_FN # load fn, parm & source cpu
750 lg %r2,__LC_RESTART_DATA
751 lg %r3,__LC_RESTART_SOURCE
754 ltgr %r3,%r3 # test source cpu address 752 ltgr %r3,%r3 # test source cpu address
755 jm 1f # negative -> skip source stop 753 jm 1f # negative -> skip source stop
7560: sigp %r4,%r3,1 # sigp sense to source cpu 7540: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
757 brc 10,0b # wait for status stored 755 brc 10,0b # wait for status stored
7581: basr %r14,%r1 # call function 7561: basr %r14,%r1 # call function
759 stap __SF_EMPTY(%r15) # store cpu address 757 stap __SF_EMPTY(%r15) # store cpu address
760 llgh %r3,__SF_EMPTY(%r15) 758 llgh %r3,__SF_EMPTY(%r15)
7612: sigp %r4,%r3,5 # sigp stop to current cpu 7592: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
762 brc 2,2b 760 brc 2,2b
7633: j 3b 7613: j 3b
764 762
@@ -916,33 +914,28 @@ cleanup_io_restore_insn:
916 914
917cleanup_idle: 915cleanup_idle:
918 # copy interrupt clock & cpu timer 916 # copy interrupt clock & cpu timer
919 mvc __IDLE_EXIT(8,%r2),__LC_INT_CLOCK 917 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_INT_CLOCK
920 mvc __VQ_IDLE_EXIT(8,%r3),__LC_ASYNC_ENTER_TIMER 918 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_ASYNC_ENTER_TIMER
921 cghi %r11,__LC_SAVE_AREA_ASYNC 919 cghi %r11,__LC_SAVE_AREA_ASYNC
922 je 0f 920 je 0f
923 mvc __IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK 921 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
924 mvc __VQ_IDLE_EXIT(8,%r3),__LC_MCCK_ENTER_TIMER 922 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_MCCK_ENTER_TIMER
9250: # check if stck & stpt have been executed 9230: # check if stck & stpt have been executed
926 clg %r9,BASED(cleanup_idle_insn) 924 clg %r9,BASED(cleanup_idle_insn)
927 jhe 1f 925 jhe 1f
928 mvc __IDLE_ENTER(8,%r2),__IDLE_EXIT(%r2) 926 mvc __CLOCK_IDLE_ENTER(8,%r2),__CLOCK_IDLE_EXIT(%r2)
929 mvc __VQ_IDLE_ENTER(8,%r3),__VQ_IDLE_EXIT(%r3) 927 mvc __TIMER_IDLE_ENTER(8,%r2),__TIMER_IDLE_EXIT(%r2)
930 j 2f 9281: # account system time going idle
9311: # check if the cpu timer has been reprogrammed
932 ltr %r5,%r5
933 jz 2f
934 spt __VQ_IDLE_ENTER(%r3)
9352: # account system time going idle
936 lg %r9,__LC_STEAL_TIMER 929 lg %r9,__LC_STEAL_TIMER
937 alg %r9,__IDLE_ENTER(%r2) 930 alg %r9,__CLOCK_IDLE_ENTER(%r2)
938 slg %r9,__LC_LAST_UPDATE_CLOCK 931 slg %r9,__LC_LAST_UPDATE_CLOCK
939 stg %r9,__LC_STEAL_TIMER 932 stg %r9,__LC_STEAL_TIMER
940 mvc __LC_LAST_UPDATE_CLOCK(8),__IDLE_EXIT(%r2) 933 mvc __LC_LAST_UPDATE_CLOCK(8),__CLOCK_IDLE_EXIT(%r2)
941 lg %r9,__LC_SYSTEM_TIMER 934 lg %r9,__LC_SYSTEM_TIMER
942 alg %r9,__LC_LAST_UPDATE_TIMER 935 alg %r9,__LC_LAST_UPDATE_TIMER
943 slg %r9,__VQ_IDLE_ENTER(%r3) 936 slg %r9,__TIMER_IDLE_ENTER(%r2)
944 stg %r9,__LC_SYSTEM_TIMER 937 stg %r9,__LC_SYSTEM_TIMER
945 mvc __LC_LAST_UPDATE_TIMER(8),__VQ_IDLE_EXIT(%r3) 938 mvc __LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2)
946 # prepare return psw 939 # prepare return psw
947 nihh %r8,0xfffd # clear wait state bit 940 nihh %r8,0xfffd # clear wait state bit
948 lg %r9,48(%r11) # return from psw_idle 941 lg %r9,48(%r11) # return from psw_idle
@@ -958,8 +951,6 @@ cleanup_idle_insn:
958 .quad __critical_start 951 .quad __critical_start
959.Lcritical_length: 952.Lcritical_length:
960 .quad __critical_end - __critical_start 953 .quad __critical_end - __critical_start
961.Lvtimer_max:
962 .quad 0x7fffffffffffffff
963 954
964 955
965#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE) 956#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
@@ -974,7 +965,6 @@ ENTRY(sie64a)
974 stg %r3,__SF_EMPTY+8(%r15) # save guest register save area 965 stg %r3,__SF_EMPTY+8(%r15) # save guest register save area
975 xc __SF_EMPTY+16(8,%r15),__SF_EMPTY+16(%r15) # host id == 0 966 xc __SF_EMPTY+16(8,%r15),__SF_EMPTY+16(%r15) # host id == 0
976 lmg %r0,%r13,0(%r3) # load guest gprs 0-13 967 lmg %r0,%r13,0(%r3) # load guest gprs 0-13
977 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
978sie_loop: 968sie_loop:
979 lg %r14,__LC_THREAD_INFO # pointer thread_info struct 969 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
980 tm __TI_flags+7(%r14),_TIF_EXIT_SIE 970 tm __TI_flags+7(%r14),_TIF_EXIT_SIE
diff --git a/arch/s390/kernel/head.S b/arch/s390/kernel/head.S
index 4939d15375a..805b6686b64 100644
--- a/arch/s390/kernel/head.S
+++ b/arch/s390/kernel/head.S
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright IBM Corp. 1999,2010 2 * Copyright IBM Corp. 1999, 2010
3 * 3 *
4 * Author(s): Hartmut Penner <hp@de.ibm.com> 4 * Author(s): Hartmut Penner <hp@de.ibm.com>
5 * Martin Schwidefsky <schwidefsky@de.ibm.com> 5 * Martin Schwidefsky <schwidefsky@de.ibm.com>
diff --git a/arch/s390/kernel/head31.S b/arch/s390/kernel/head31.S
index d3f1ab7d90a..a1372ae24ae 100644
--- a/arch/s390/kernel/head31.S
+++ b/arch/s390/kernel/head31.S
@@ -1,7 +1,5 @@
1/* 1/*
2 * arch/s390/kernel/head31.S 2 * Copyright IBM Corp. 2005, 2010
3 *
4 * Copyright (C) IBM Corp. 2005,2010
5 * 3 *
6 * Author(s): Hartmut Penner <hp@de.ibm.com> 4 * Author(s): Hartmut Penner <hp@de.ibm.com>
7 * Martin Schwidefsky <schwidefsky@de.ibm.com> 5 * Martin Schwidefsky <schwidefsky@de.ibm.com>
diff --git a/arch/s390/kernel/head64.S b/arch/s390/kernel/head64.S
index 99348c0eaa4..c108af28bbe 100644
--- a/arch/s390/kernel/head64.S
+++ b/arch/s390/kernel/head64.S
@@ -1,7 +1,5 @@
1/* 1/*
2 * arch/s390/kernel/head64.S 2 * Copyright IBM Corp. 1999, 2010
3 *
4 * Copyright (C) IBM Corp. 1999,2010
5 * 3 *
6 * Author(s): Hartmut Penner <hp@de.ibm.com> 4 * Author(s): Hartmut Penner <hp@de.ibm.com>
7 * Martin Schwidefsky <schwidefsky@de.ibm.com> 5 * Martin Schwidefsky <schwidefsky@de.ibm.com>
diff --git a/arch/s390/kernel/head_kdump.S b/arch/s390/kernel/head_kdump.S
index 796c976b5fd..acaaaf4b705 100644
--- a/arch/s390/kernel/head_kdump.S
+++ b/arch/s390/kernel/head_kdump.S
@@ -5,6 +5,8 @@
5 * Author(s): Michael Holzheu <holzheu@linux.vnet.ibm.com> 5 * Author(s): Michael Holzheu <holzheu@linux.vnet.ibm.com>
6 */ 6 */
7 7
8#include <asm/sigp.h>
9
8#define DATAMOVER_ADDR 0x4000 10#define DATAMOVER_ADDR 0x4000
9#define COPY_PAGE_ADDR 0x6000 11#define COPY_PAGE_ADDR 0x6000
10 12
@@ -19,7 +21,7 @@
19.align 2 21.align 2
20.Lep_startup_kdump: 22.Lep_startup_kdump:
21 lhi %r1,2 # mode 2 = esame (dump) 23 lhi %r1,2 # mode 2 = esame (dump)
22 sigp %r1,%r0,0x12 # Switch to esame mode 24 sigp %r1,%r0,SIGP_SET_ARCHITECTURE # Switch to esame mode
23 sam64 # Switch to 64 bit addressing 25 sam64 # Switch to 64 bit addressing
24 basr %r13,0 26 basr %r13,0
25.Lbase: 27.Lbase:
@@ -88,7 +90,7 @@ startup_kdump_relocated:
88 sam31 # Switch to 31 bit addr mode 90 sam31 # Switch to 31 bit addr mode
89 sr %r1,%r1 # Erase register r1 91 sr %r1,%r1 # Erase register r1
90 sr %r2,%r2 # Erase register r2 92 sr %r2,%r2 # Erase register r2
91 sigp %r1,%r2,0x12 # Switch to 31 bit arch mode 93 sigp %r1,%r2,SIGP_SET_ARCHITECTURE # Switch to 31 bit arch mode
92 lpsw 0 # Start new kernel... 94 lpsw 0 # Start new kernel...
93.align 8 95.align 8
94.Lrestart_psw: 96.Lrestart_psw:
diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
index 2f6cfd460cb..6ffcd320321 100644
--- a/arch/s390/kernel/ipl.c
+++ b/arch/s390/kernel/ipl.c
@@ -1,8 +1,7 @@
1/* 1/*
2 * arch/s390/kernel/ipl.c
3 * ipl/reipl/dump support for Linux on s390. 2 * ipl/reipl/dump support for Linux on s390.
4 * 3 *
5 * Copyright IBM Corp. 2005,2012 4 * Copyright IBM Corp. 2005, 2012
6 * Author(s): Michael Holzheu <holzheu@de.ibm.com> 5 * Author(s): Michael Holzheu <holzheu@de.ibm.com>
7 * Heiko Carstens <heiko.carstens@de.ibm.com> 6 * Heiko Carstens <heiko.carstens@de.ibm.com>
8 * Volker Sameske <sameske@de.ibm.com> 7 * Volker Sameske <sameske@de.ibm.com>
@@ -1528,15 +1527,12 @@ static struct shutdown_action __refdata dump_action = {
1528 1527
1529static void dump_reipl_run(struct shutdown_trigger *trigger) 1528static void dump_reipl_run(struct shutdown_trigger *trigger)
1530{ 1529{
1531 struct { 1530 unsigned long ipib = (unsigned long) reipl_block_actual;
1532 void *addr; 1531 unsigned int csum;
1533 __u32 csum;
1534 } __packed ipib;
1535 1532
1536 ipib.csum = csum_partial(reipl_block_actual, 1533 csum = csum_partial(reipl_block_actual, reipl_block_actual->hdr.len, 0);
1537 reipl_block_actual->hdr.len, 0); 1534 mem_assign_absolute(S390_lowcore.ipib, ipib);
1538 ipib.addr = reipl_block_actual; 1535 mem_assign_absolute(S390_lowcore.ipib_checksum, csum);
1539 memcpy_absolute(&S390_lowcore.ipib, &ipib, sizeof(ipib));
1540 dump_run(trigger); 1536 dump_run(trigger);
1541} 1537}
1542 1538
@@ -1587,7 +1583,7 @@ static struct kset *vmcmd_kset;
1587 1583
1588static void vmcmd_run(struct shutdown_trigger *trigger) 1584static void vmcmd_run(struct shutdown_trigger *trigger)
1589{ 1585{
1590 char *cmd, *next_cmd; 1586 char *cmd;
1591 1587
1592 if (strcmp(trigger->name, ON_REIPL_STR) == 0) 1588 if (strcmp(trigger->name, ON_REIPL_STR) == 0)
1593 cmd = vmcmd_on_reboot; 1589 cmd = vmcmd_on_reboot;
@@ -1604,15 +1600,7 @@ static void vmcmd_run(struct shutdown_trigger *trigger)
1604 1600
1605 if (strlen(cmd) == 0) 1601 if (strlen(cmd) == 0)
1606 return; 1602 return;
1607 do { 1603 __cpcmd(cmd, NULL, 0, NULL);
1608 next_cmd = strchr(cmd, '\n');
1609 if (next_cmd) {
1610 next_cmd[0] = 0;
1611 next_cmd += 1;
1612 }
1613 __cpcmd(cmd, NULL, 0, NULL);
1614 cmd = next_cmd;
1615 } while (cmd != NULL);
1616} 1604}
1617 1605
1618static int vmcmd_init(void) 1606static int vmcmd_init(void)
diff --git a/arch/s390/kernel/irq.c b/arch/s390/kernel/irq.c
index b4f4a7133fa..dd7630d8aab 100644
--- a/arch/s390/kernel/irq.c
+++ b/arch/s390/kernel/irq.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright IBM Corp. 2004,2011 2 * Copyright IBM Corp. 2004, 2011
3 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>, 3 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>,
4 * Holger Smolinski <Holger.Smolinski@de.ibm.com>, 4 * Holger Smolinski <Holger.Smolinski@de.ibm.com>,
5 * Thomas Spatzier <tspat@de.ibm.com>, 5 * Thomas Spatzier <tspat@de.ibm.com>,
diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
index 64b761aef00..8aa634f5944 100644
--- a/arch/s390/kernel/kprobes.c
+++ b/arch/s390/kernel/kprobes.c
@@ -15,7 +15,7 @@
15 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 * 17 *
18 * Copyright (C) IBM Corporation, 2002, 2006 18 * Copyright IBM Corp. 2002, 2006
19 * 19 *
20 * s390 port, used ppc64 as template. Mike Grundy <grundym@us.ibm.com> 20 * s390 port, used ppc64 as template. Mike Grundy <grundym@us.ibm.com>
21 */ 21 */
diff --git a/arch/s390/kernel/lgr.c b/arch/s390/kernel/lgr.c
index 87f080b17af..eca94e74d19 100644
--- a/arch/s390/kernel/lgr.c
+++ b/arch/s390/kernel/lgr.c
@@ -45,7 +45,7 @@ struct lgr_info {
45/* 45/*
46 * LGR globals 46 * LGR globals
47 */ 47 */
48static void *lgr_page; 48static char lgr_page[PAGE_SIZE] __aligned(PAGE_SIZE);
49static struct lgr_info lgr_info_last; 49static struct lgr_info lgr_info_last;
50static struct lgr_info lgr_info_cur; 50static struct lgr_info lgr_info_cur;
51static struct debug_info *lgr_dbf; 51static struct debug_info *lgr_dbf;
@@ -74,7 +74,7 @@ static void cpascii(char *dst, char *src, int size)
74 */ 74 */
75static void lgr_stsi_1_1_1(struct lgr_info *lgr_info) 75static void lgr_stsi_1_1_1(struct lgr_info *lgr_info)
76{ 76{
77 struct sysinfo_1_1_1 *si = lgr_page; 77 struct sysinfo_1_1_1 *si = (void *) lgr_page;
78 78
79 if (stsi(si, 1, 1, 1) == -ENOSYS) 79 if (stsi(si, 1, 1, 1) == -ENOSYS)
80 return; 80 return;
@@ -91,7 +91,7 @@ static void lgr_stsi_1_1_1(struct lgr_info *lgr_info)
91 */ 91 */
92static void lgr_stsi_2_2_2(struct lgr_info *lgr_info) 92static void lgr_stsi_2_2_2(struct lgr_info *lgr_info)
93{ 93{
94 struct sysinfo_2_2_2 *si = lgr_page; 94 struct sysinfo_2_2_2 *si = (void *) lgr_page;
95 95
96 if (stsi(si, 2, 2, 2) == -ENOSYS) 96 if (stsi(si, 2, 2, 2) == -ENOSYS)
97 return; 97 return;
@@ -105,7 +105,7 @@ static void lgr_stsi_2_2_2(struct lgr_info *lgr_info)
105 */ 105 */
106static void lgr_stsi_3_2_2(struct lgr_info *lgr_info) 106static void lgr_stsi_3_2_2(struct lgr_info *lgr_info)
107{ 107{
108 struct sysinfo_3_2_2 *si = lgr_page; 108 struct sysinfo_3_2_2 *si = (void *) lgr_page;
109 int i; 109 int i;
110 110
111 if (stsi(si, 3, 2, 2) == -ENOSYS) 111 if (stsi(si, 3, 2, 2) == -ENOSYS)
@@ -183,14 +183,9 @@ static void lgr_timer_set(void)
183 */ 183 */
184static int __init lgr_init(void) 184static int __init lgr_init(void)
185{ 185{
186 lgr_page = (void *) __get_free_pages(GFP_KERNEL, 0);
187 if (!lgr_page)
188 return -ENOMEM;
189 lgr_dbf = debug_register("lgr", 1, 1, sizeof(struct lgr_info)); 186 lgr_dbf = debug_register("lgr", 1, 1, sizeof(struct lgr_info));
190 if (!lgr_dbf) { 187 if (!lgr_dbf)
191 free_page((unsigned long) lgr_page);
192 return -ENOMEM; 188 return -ENOMEM;
193 }
194 debug_register_view(lgr_dbf, &debug_hex_ascii_view); 189 debug_register_view(lgr_dbf, &debug_hex_ascii_view);
195 lgr_info_get(&lgr_info_last); 190 lgr_info_get(&lgr_info_last);
196 debug_event(lgr_dbf, 1, &lgr_info_last, sizeof(lgr_info_last)); 191 debug_event(lgr_dbf, 1, &lgr_info_last, sizeof(lgr_info_last));
diff --git a/arch/s390/kernel/machine_kexec.c b/arch/s390/kernel/machine_kexec.c
index cdacf8f91b2..493304bdf1c 100644
--- a/arch/s390/kernel/machine_kexec.c
+++ b/arch/s390/kernel/machine_kexec.c
@@ -1,7 +1,5 @@
1/* 1/*
2 * arch/s390/kernel/machine_kexec.c 2 * Copyright IBM Corp. 2005, 2011
3 *
4 * Copyright IBM Corp. 2005,2011
5 * 3 *
6 * Author(s): Rolf Adelsberger, 4 * Author(s): Rolf Adelsberger,
7 * Heiko Carstens <heiko.carstens@de.ibm.com> 5 * Heiko Carstens <heiko.carstens@de.ibm.com>
diff --git a/arch/s390/kernel/mcount.S b/arch/s390/kernel/mcount.S
index 7e2c38ba137..4567ce20d90 100644
--- a/arch/s390/kernel/mcount.S
+++ b/arch/s390/kernel/mcount.S
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright IBM Corp. 2008,2009 2 * Copyright IBM Corp. 2008, 2009
3 * 3 *
4 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>, 4 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>,
5 * 5 *
diff --git a/arch/s390/kernel/mcount64.S b/arch/s390/kernel/mcount64.S
index f70cadec68f..11332193db3 100644
--- a/arch/s390/kernel/mcount64.S
+++ b/arch/s390/kernel/mcount64.S
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright IBM Corp. 2008,2009 2 * Copyright IBM Corp. 2008, 2009
3 * 3 *
4 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>, 4 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>,
5 * 5 *
diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
index dfcb3436bad..46412b1d7e1 100644
--- a/arch/s390/kernel/module.c
+++ b/arch/s390/kernel/module.c
@@ -1,9 +1,8 @@
1/* 1/*
2 * arch/s390/kernel/module.c - Kernel module help for s390. 2 * Kernel module help for s390.
3 * 3 *
4 * S390 version 4 * S390 version
5 * Copyright (C) 2002, 2003 IBM Deutschland Entwicklung GmbH, 5 * Copyright IBM Corp. 2002, 2003
6 * IBM Corporation
7 * Author(s): Arnd Bergmann (arndb@de.ibm.com) 6 * Author(s): Arnd Bergmann (arndb@de.ibm.com)
8 * Martin Schwidefsky (schwidefsky@de.ibm.com) 7 * Martin Schwidefsky (schwidefsky@de.ibm.com)
9 * 8 *
diff --git a/arch/s390/kernel/nmi.c b/arch/s390/kernel/nmi.c
index 8c372ca6135..a6daa5c5cdb 100644
--- a/arch/s390/kernel/nmi.c
+++ b/arch/s390/kernel/nmi.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Machine check handler 2 * Machine check handler
3 * 3 *
4 * Copyright IBM Corp. 2000,2009 4 * Copyright IBM Corp. 2000, 2009
5 * Author(s): Ingo Adlung <adlung@de.ibm.com>, 5 * Author(s): Ingo Adlung <adlung@de.ibm.com>,
6 * Martin Schwidefsky <schwidefsky@de.ibm.com>, 6 * Martin Schwidefsky <schwidefsky@de.ibm.com>,
7 * Cornelia Huck <cornelia.huck@de.ibm.com>, 7 * Cornelia Huck <cornelia.huck@de.ibm.com>,
diff --git a/arch/s390/kernel/os_info.c b/arch/s390/kernel/os_info.c
index 95fa5ac6c4c..46480d81df0 100644
--- a/arch/s390/kernel/os_info.c
+++ b/arch/s390/kernel/os_info.c
@@ -60,7 +60,7 @@ void __init os_info_init(void)
60 os_info.version_minor = OS_INFO_VERSION_MINOR; 60 os_info.version_minor = OS_INFO_VERSION_MINOR;
61 os_info.magic = OS_INFO_MAGIC; 61 os_info.magic = OS_INFO_MAGIC;
62 os_info.csum = os_info_csum(&os_info); 62 os_info.csum = os_info_csum(&os_info);
63 memcpy_absolute(&S390_lowcore.os_info, &ptr, sizeof(ptr)); 63 mem_assign_absolute(S390_lowcore.os_info, (unsigned long) ptr);
64} 64}
65 65
66#ifdef CONFIG_CRASH_DUMP 66#ifdef CONFIG_CRASH_DUMP
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index 60055cefdd0..733175373a4 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * This file handles the architecture dependent parts of process handling. 2 * This file handles the architecture dependent parts of process handling.
3 * 3 *
4 * Copyright IBM Corp. 1999,2009 4 * Copyright IBM Corp. 1999, 2009
5 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>, 5 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>,
6 * Hartmut Penner <hp@de.ibm.com>, 6 * Hartmut Penner <hp@de.ibm.com>,
7 * Denis Joseph Barrow, 7 * Denis Joseph Barrow,
@@ -25,8 +25,8 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <asm/io.h> 26#include <asm/io.h>
27#include <asm/processor.h> 27#include <asm/processor.h>
28#include <asm/vtimer.h>
28#include <asm/irq.h> 29#include <asm/irq.h>
29#include <asm/timer.h>
30#include <asm/nmi.h> 30#include <asm/nmi.h>
31#include <asm/smp.h> 31#include <asm/smp.h>
32#include <asm/switch_to.h> 32#include <asm/switch_to.h>
diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c
index 6e0073e43f5..572d4c9cb33 100644
--- a/arch/s390/kernel/processor.c
+++ b/arch/s390/kernel/processor.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/s390/kernel/processor.c
3 *
4 * Copyright IBM Corp. 2008 2 * Copyright IBM Corp. 2008
5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 3 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
6 */ 4 */
@@ -25,13 +23,15 @@ static DEFINE_PER_CPU(struct cpuid, cpu_id);
25 */ 23 */
26void __cpuinit cpu_init(void) 24void __cpuinit cpu_init(void)
27{ 25{
28 struct cpuid *id = &per_cpu(cpu_id, smp_processor_id()); 26 struct s390_idle_data *idle = &__get_cpu_var(s390_idle);
27 struct cpuid *id = &__get_cpu_var(cpu_id);
29 28
30 get_cpu_id(id); 29 get_cpu_id(id);
31 atomic_inc(&init_mm.mm_count); 30 atomic_inc(&init_mm.mm_count);
32 current->active_mm = &init_mm; 31 current->active_mm = &init_mm;
33 BUG_ON(current->mm); 32 BUG_ON(current->mm);
34 enter_lazy_tlb(&init_mm, current); 33 enter_lazy_tlb(&init_mm, current);
34 memset(idle, 0, sizeof(*idle));
35} 35}
36 36
37/* 37/*
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index 4993e689b2c..e4be113fbac 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Ptrace user space interface. 2 * Ptrace user space interface.
3 * 3 *
4 * Copyright IBM Corp. 1999,2010 4 * Copyright IBM Corp. 1999, 2010
5 * Author(s): Denis Joseph Barrow 5 * Author(s): Denis Joseph Barrow
6 * Martin Schwidefsky (schwidefsky@de.ibm.com) 6 * Martin Schwidefsky (schwidefsky@de.ibm.com)
7 */ 7 */
@@ -719,7 +719,11 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
719 long ret = 0; 719 long ret = 0;
720 720
721 /* Do the secure computing check first. */ 721 /* Do the secure computing check first. */
722 secure_computing_strict(regs->gprs[2]); 722 if (secure_computing(regs->gprs[2])) {
723 /* seccomp failures shouldn't expose any additional code. */
724 ret = -1;
725 goto out;
726 }
723 727
724 /* 728 /*
725 * The sysc_tracesys code in entry.S stored the system 729 * The sysc_tracesys code in entry.S stored the system
@@ -745,6 +749,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
745 regs->gprs[2], regs->orig_gpr2, 749 regs->gprs[2], regs->orig_gpr2,
746 regs->gprs[3], regs->gprs[4], 750 regs->gprs[3], regs->gprs[4],
747 regs->gprs[5]); 751 regs->gprs[5]);
752out:
748 return ret ?: regs->gprs[2]; 753 return ret ?: regs->gprs[2];
749} 754}
750 755
diff --git a/arch/s390/kernel/reipl.S b/arch/s390/kernel/reipl.S
index ad67c214be0..dd8016b0477 100644
--- a/arch/s390/kernel/reipl.S
+++ b/arch/s390/kernel/reipl.S
@@ -1,13 +1,12 @@
1/* 1/*
2 * arch/s390/kernel/reipl.S
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 2000
6 * Author(s): Holger Smolinski (Holger.Smolinski@de.ibm.com) 4 * Author(s): Holger Smolinski (Holger.Smolinski@de.ibm.com)
7 */ 5 */
8 6
9#include <linux/linkage.h> 7#include <linux/linkage.h>
10#include <asm/asm-offsets.h> 8#include <asm/asm-offsets.h>
9#include <asm/sigp.h>
11 10
12# 11#
13# store_status: Empty implementation until kdump is supported on 31 bit 12# store_status: Empty implementation until kdump is supported on 31 bit
@@ -60,7 +59,7 @@ ENTRY(do_reipl_asm)
60 bas %r14,.Ldisab-.Lpg0(%r13) 59 bas %r14,.Ldisab-.Lpg0(%r13)
61.L003: st %r1,__LC_SUBCHANNEL_ID 60.L003: st %r1,__LC_SUBCHANNEL_ID
62 lpsw 0 61 lpsw 0
63 sigp 0,0,0(6) 62 sigp 0,0,SIGP_RESTART
64.Ldisab: st %r14,.Ldispsw+4-.Lpg0(%r13) 63.Ldisab: st %r14,.Ldispsw+4-.Lpg0(%r13)
65 lpsw .Ldispsw-.Lpg0(%r13) 64 lpsw .Ldispsw-.Lpg0(%r13)
66 .align 8 65 .align 8
diff --git a/arch/s390/kernel/reipl64.S b/arch/s390/kernel/reipl64.S
index 36b32658fb2..dc3b1273c4d 100644
--- a/arch/s390/kernel/reipl64.S
+++ b/arch/s390/kernel/reipl64.S
@@ -1,11 +1,12 @@
1/* 1/*
2 * Copyright IBM Corp 2000,2011 2 * Copyright IBM Corp 2000, 2011
3 * Author(s): Holger Smolinski <Holger.Smolinski@de.ibm.com>, 3 * Author(s): Holger Smolinski <Holger.Smolinski@de.ibm.com>,
4 * Denis Joseph Barrow, 4 * Denis Joseph Barrow,
5 */ 5 */
6 6
7#include <linux/linkage.h> 7#include <linux/linkage.h>
8#include <asm/asm-offsets.h> 8#include <asm/asm-offsets.h>
9#include <asm/sigp.h>
9 10
10# 11#
11# store_status 12# store_status
@@ -106,7 +107,7 @@ ENTRY(do_reipl_asm)
106.L003: st %r1,__LC_SUBCHANNEL_ID 107.L003: st %r1,__LC_SUBCHANNEL_ID
107 lhi %r1,0 # mode 0 = esa 108 lhi %r1,0 # mode 0 = esa
108 slr %r0,%r0 # set cpuid to zero 109 slr %r0,%r0 # set cpuid to zero
109 sigp %r1,%r0,0x12 # switch to esa mode 110 sigp %r1,%r0,SIGP_SET_ARCHITECTURE # switch to esa mode
110 lpsw 0 111 lpsw 0
111.Ldisab: sll %r14,1 112.Ldisab: sll %r14,1
112 srl %r14,1 # need to kill hi bit to avoid specification exceptions. 113 srl %r14,1 # need to kill hi bit to avoid specification exceptions.
diff --git a/arch/s390/kernel/relocate_kernel.S b/arch/s390/kernel/relocate_kernel.S
index c91d70aede9..f4e6f20e117 100644
--- a/arch/s390/kernel/relocate_kernel.S
+++ b/arch/s390/kernel/relocate_kernel.S
@@ -1,7 +1,5 @@
1/* 1/*
2 * arch/s390/kernel/relocate_kernel.S 2 * Copyright IBM Corp. 2005
3 *
4 * (C) Copyright IBM Corp. 2005
5 * 3 *
6 * Author(s): Rolf Adelsberger, 4 * Author(s): Rolf Adelsberger,
7 * Heiko Carstens <heiko.carstens@de.ibm.com> 5 * Heiko Carstens <heiko.carstens@de.ibm.com>
@@ -9,6 +7,7 @@
9 */ 7 */
10 8
11#include <linux/linkage.h> 9#include <linux/linkage.h>
10#include <asm/sigp.h>
12 11
13/* 12/*
14 * moves the new kernel to its destination... 13 * moves the new kernel to its destination...
@@ -93,7 +92,7 @@ ENTRY(relocate_kernel)
93 .no_diag308: 92 .no_diag308:
94 sr %r1,%r1 # clear %r1 93 sr %r1,%r1 # clear %r1
95 sr %r2,%r2 # clear %r2 94 sr %r2,%r2 # clear %r2
96 sigp %r1,%r2,0x12 # set cpuid to zero 95 sigp %r1,%r2,SIGP_SET_ARCHITECTURE # set cpuid to zero
97 lpsw 0 # hopefully start new kernel... 96 lpsw 0 # hopefully start new kernel...
98 97
99 .align 8 98 .align 8
diff --git a/arch/s390/kernel/relocate_kernel64.S b/arch/s390/kernel/relocate_kernel64.S
index 7c3ce589a7f..cfac28330b0 100644
--- a/arch/s390/kernel/relocate_kernel64.S
+++ b/arch/s390/kernel/relocate_kernel64.S
@@ -1,7 +1,5 @@
1/* 1/*
2 * arch/s390/kernel/relocate_kernel64.S 2 * Copyright IBM Corp. 2005
3 *
4 * (C) Copyright IBM Corp. 2005
5 * 3 *
6 * Author(s): Rolf Adelsberger, 4 * Author(s): Rolf Adelsberger,
7 * Heiko Carstens <heiko.carstens@de.ibm.com> 5 * Heiko Carstens <heiko.carstens@de.ibm.com>
@@ -9,6 +7,7 @@
9 */ 7 */
10 8
11#include <linux/linkage.h> 9#include <linux/linkage.h>
10#include <asm/sigp.h>
12 11
13/* 12/*
14 * moves the new kernel to its destination... 13 * moves the new kernel to its destination...
@@ -45,7 +44,7 @@ ENTRY(relocate_kernel)
45 diag %r0,%r0,0x308 44 diag %r0,%r0,0x308
46 .back: 45 .back:
47 lhi %r1,1 # mode 1 = esame 46 lhi %r1,1 # mode 1 = esame
48 sigp %r1,%r0,0x12 # switch to esame mode 47 sigp %r1,%r0,SIGP_SET_ARCHITECTURE # switch to esame mode
49 sam64 # switch to 64 bit addressing mode 48 sam64 # switch to 64 bit addressing mode
50 basr %r13,0 49 basr %r13,0
51 .back_base: 50 .back_base:
@@ -96,7 +95,7 @@ ENTRY(relocate_kernel)
96 sam31 # 31 bit mode 95 sam31 # 31 bit mode
97 sr %r1,%r1 # erase register r1 96 sr %r1,%r1 # erase register r1
98 sr %r2,%r2 # erase register r2 97 sr %r2,%r2 # erase register r2
99 sigp %r1,%r2,0x12 # set cpuid to zero 98 sigp %r1,%r2,SIGP_SET_ARCHITECTURE # set cpuid to zero
100 lpsw 0 # hopefully start new kernel... 99 lpsw 0 # hopefully start new kernel...
101 100
102 .align 8 101 .align 8
diff --git a/arch/s390/kernel/sclp.S b/arch/s390/kernel/sclp.S
index 95792d846bb..bf053898630 100644
--- a/arch/s390/kernel/sclp.S
+++ b/arch/s390/kernel/sclp.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * Mini SCLP driver. 2 * Mini SCLP driver.
3 * 3 *
4 * Copyright IBM Corp. 2004,2009 4 * Copyright IBM Corp. 2004, 2009
5 * 5 *
6 * Author(s): Peter Oberparleiter <Peter.Oberparleiter@de.ibm.com>, 6 * Author(s): Peter Oberparleiter <Peter.Oberparleiter@de.ibm.com>,
7 * Heiko Carstens <heiko.carstens@de.ibm.com>, 7 * Heiko Carstens <heiko.carstens@de.ibm.com>,
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 489d1d8d96b..f86c81e13c3 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * arch/s390/kernel/setup.c
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) IBM Corp. 1999,2012 3 * Copyright IBM Corp. 1999, 2012
6 * Author(s): Hartmut Penner (hp@de.ibm.com), 4 * Author(s): Hartmut Penner (hp@de.ibm.com),
7 * Martin Schwidefsky (schwidefsky@de.ibm.com) 5 * Martin Schwidefsky (schwidefsky@de.ibm.com)
8 * 6 *
@@ -63,6 +61,7 @@
63#include <asm/kvm_virtio.h> 61#include <asm/kvm_virtio.h>
64#include <asm/diag.h> 62#include <asm/diag.h>
65#include <asm/os_info.h> 63#include <asm/os_info.h>
64#include <asm/sclp.h>
66#include "entry.h" 65#include "entry.h"
67 66
68long psw_kernel_bits = PSW_DEFAULT_KEY | PSW_MASK_BASE | PSW_ASC_PRIMARY | 67long psw_kernel_bits = PSW_DEFAULT_KEY | PSW_MASK_BASE | PSW_ASC_PRIMARY |
@@ -138,9 +137,14 @@ __setup("condev=", condev_setup);
138 137
139static void __init set_preferred_console(void) 138static void __init set_preferred_console(void)
140{ 139{
141 if (MACHINE_IS_KVM) 140 if (MACHINE_IS_KVM) {
142 add_preferred_console("hvc", 0, NULL); 141 if (sclp_has_vt220())
143 else if (CONSOLE_IS_3215 || CONSOLE_IS_SCLP) 142 add_preferred_console("ttyS", 1, NULL);
143 else if (sclp_has_linemode())
144 add_preferred_console("ttyS", 0, NULL);
145 else
146 add_preferred_console("hvc", 0, NULL);
147 } else if (CONSOLE_IS_3215 || CONSOLE_IS_SCLP)
144 add_preferred_console("ttyS", 0, NULL); 148 add_preferred_console("ttyS", 0, NULL);
145 else if (CONSOLE_IS_3270) 149 else if (CONSOLE_IS_3270)
146 add_preferred_console("tty3270", 0, NULL); 150 add_preferred_console("tty3270", 0, NULL);
@@ -298,8 +302,8 @@ static int __init parse_vmalloc(char *arg)
298} 302}
299early_param("vmalloc", parse_vmalloc); 303early_param("vmalloc", parse_vmalloc);
300 304
301unsigned int user_mode = HOME_SPACE_MODE; 305unsigned int addressing_mode = HOME_SPACE_MODE;
302EXPORT_SYMBOL_GPL(user_mode); 306EXPORT_SYMBOL_GPL(addressing_mode);
303 307
304static int set_amode_primary(void) 308static int set_amode_primary(void)
305{ 309{
@@ -324,7 +328,7 @@ static int set_amode_primary(void)
324 */ 328 */
325static int __init early_parse_switch_amode(char *p) 329static int __init early_parse_switch_amode(char *p)
326{ 330{
327 user_mode = PRIMARY_SPACE_MODE; 331 addressing_mode = PRIMARY_SPACE_MODE;
328 return 0; 332 return 0;
329} 333}
330early_param("switch_amode", early_parse_switch_amode); 334early_param("switch_amode", early_parse_switch_amode);
@@ -332,9 +336,9 @@ early_param("switch_amode", early_parse_switch_amode);
332static int __init early_parse_user_mode(char *p) 336static int __init early_parse_user_mode(char *p)
333{ 337{
334 if (p && strcmp(p, "primary") == 0) 338 if (p && strcmp(p, "primary") == 0)
335 user_mode = PRIMARY_SPACE_MODE; 339 addressing_mode = PRIMARY_SPACE_MODE;
336 else if (!p || strcmp(p, "home") == 0) 340 else if (!p || strcmp(p, "home") == 0)
337 user_mode = HOME_SPACE_MODE; 341 addressing_mode = HOME_SPACE_MODE;
338 else 342 else
339 return 1; 343 return 1;
340 return 0; 344 return 0;
@@ -343,7 +347,7 @@ early_param("user_mode", early_parse_user_mode);
343 347
344static void setup_addressing_mode(void) 348static void setup_addressing_mode(void)
345{ 349{
346 if (user_mode == PRIMARY_SPACE_MODE) { 350 if (addressing_mode == PRIMARY_SPACE_MODE) {
347 if (set_amode_primary()) 351 if (set_amode_primary())
348 pr_info("Address spaces switched, " 352 pr_info("Address spaces switched, "
349 "mvcos available\n"); 353 "mvcos available\n");
@@ -430,10 +434,11 @@ static void __init setup_lowcore(void)
430 lc->restart_source = -1UL; 434 lc->restart_source = -1UL;
431 435
432 /* Setup absolute zero lowcore */ 436 /* Setup absolute zero lowcore */
433 memcpy_absolute(&S390_lowcore.restart_stack, &lc->restart_stack, 437 mem_assign_absolute(S390_lowcore.restart_stack, lc->restart_stack);
434 4 * sizeof(unsigned long)); 438 mem_assign_absolute(S390_lowcore.restart_fn, lc->restart_fn);
435 memcpy_absolute(&S390_lowcore.restart_psw, &lc->restart_psw, 439 mem_assign_absolute(S390_lowcore.restart_data, lc->restart_data);
436 sizeof(lc->restart_psw)); 440 mem_assign_absolute(S390_lowcore.restart_source, lc->restart_source);
441 mem_assign_absolute(S390_lowcore.restart_psw, lc->restart_psw);
437 442
438 set_prefix((u32)(unsigned long) lc); 443 set_prefix((u32)(unsigned long) lc);
439 lowcore_ptr[0] = lc; 444 lowcore_ptr[0] = lc;
@@ -598,9 +603,7 @@ static void __init setup_memory_end(void)
598static void __init setup_vmcoreinfo(void) 603static void __init setup_vmcoreinfo(void)
599{ 604{
600#ifdef CONFIG_KEXEC 605#ifdef CONFIG_KEXEC
601 unsigned long ptr = paddr_vmcoreinfo_note(); 606 mem_assign_absolute(S390_lowcore.vmcore_info, paddr_vmcoreinfo_note());
602
603 memcpy_absolute(&S390_lowcore.vmcore_info, &ptr, sizeof(ptr));
604#endif 607#endif
605} 608}
606 609
diff --git a/arch/s390/kernel/signal.c b/arch/s390/kernel/signal.c
index ac565b44aab..c13a2a37ef0 100644
--- a/arch/s390/kernel/signal.c
+++ b/arch/s390/kernel/signal.c
@@ -1,7 +1,5 @@
1/* 1/*
2 * arch/s390/kernel/signal.c 2 * Copyright IBM Corp. 1999, 2006
3 *
4 * Copyright (C) IBM Corp. 1999,2006
5 * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com) 3 * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
6 * 4 *
7 * Based on Intel version 5 * Based on Intel version
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 15cca26ccb6..720fda1620f 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * SMP related functions 2 * SMP related functions
3 * 3 *
4 * Copyright IBM Corp. 1999,2012 4 * Copyright IBM Corp. 1999, 2012
5 * Author(s): Denis Joseph Barrow, 5 * Author(s): Denis Joseph Barrow,
6 * Martin Schwidefsky <schwidefsky@de.ibm.com>, 6 * Martin Schwidefsky <schwidefsky@de.ibm.com>,
7 * Heiko Carstens <heiko.carstens@de.ibm.com>, 7 * Heiko Carstens <heiko.carstens@de.ibm.com>,
@@ -38,40 +38,16 @@
38#include <asm/setup.h> 38#include <asm/setup.h>
39#include <asm/irq.h> 39#include <asm/irq.h>
40#include <asm/tlbflush.h> 40#include <asm/tlbflush.h>
41#include <asm/timer.h> 41#include <asm/vtimer.h>
42#include <asm/lowcore.h> 42#include <asm/lowcore.h>
43#include <asm/sclp.h> 43#include <asm/sclp.h>
44#include <asm/vdso.h> 44#include <asm/vdso.h>
45#include <asm/debug.h> 45#include <asm/debug.h>
46#include <asm/os_info.h> 46#include <asm/os_info.h>
47#include <asm/sigp.h>
47#include "entry.h" 48#include "entry.h"
48 49
49enum { 50enum {
50 sigp_sense = 1,
51 sigp_external_call = 2,
52 sigp_emergency_signal = 3,
53 sigp_start = 4,
54 sigp_stop = 5,
55 sigp_restart = 6,
56 sigp_stop_and_store_status = 9,
57 sigp_initial_cpu_reset = 11,
58 sigp_cpu_reset = 12,
59 sigp_set_prefix = 13,
60 sigp_store_status_at_address = 14,
61 sigp_store_extended_status_at_address = 15,
62 sigp_set_architecture = 18,
63 sigp_conditional_emergency_signal = 19,
64 sigp_sense_running = 21,
65};
66
67enum {
68 sigp_order_code_accepted = 0,
69 sigp_status_stored = 1,
70 sigp_busy = 2,
71 sigp_not_operational = 3,
72};
73
74enum {
75 ec_schedule = 0, 51 ec_schedule = 0,
76 ec_call_function, 52 ec_call_function,
77 ec_call_function_single, 53 ec_call_function_single,
@@ -124,7 +100,7 @@ static inline int __pcpu_sigp_relax(u16 addr, u8 order, u32 parm, u32 *status)
124 100
125 while (1) { 101 while (1) {
126 cc = __pcpu_sigp(addr, order, parm, status); 102 cc = __pcpu_sigp(addr, order, parm, status);
127 if (cc != sigp_busy) 103 if (cc != SIGP_CC_BUSY)
128 return cc; 104 return cc;
129 cpu_relax(); 105 cpu_relax();
130 } 106 }
@@ -136,7 +112,7 @@ static int pcpu_sigp_retry(struct pcpu *pcpu, u8 order, u32 parm)
136 112
137 for (retry = 0; ; retry++) { 113 for (retry = 0; ; retry++) {
138 cc = __pcpu_sigp(pcpu->address, order, parm, &pcpu->status); 114 cc = __pcpu_sigp(pcpu->address, order, parm, &pcpu->status);
139 if (cc != sigp_busy) 115 if (cc != SIGP_CC_BUSY)
140 break; 116 break;
141 if (retry >= 3) 117 if (retry >= 3)
142 udelay(10); 118 udelay(10);
@@ -146,20 +122,19 @@ static int pcpu_sigp_retry(struct pcpu *pcpu, u8 order, u32 parm)
146 122
147static inline int pcpu_stopped(struct pcpu *pcpu) 123static inline int pcpu_stopped(struct pcpu *pcpu)
148{ 124{
149 if (__pcpu_sigp(pcpu->address, sigp_sense, 125 if (__pcpu_sigp(pcpu->address, SIGP_SENSE,
150 0, &pcpu->status) != sigp_status_stored) 126 0, &pcpu->status) != SIGP_CC_STATUS_STORED)
151 return 0; 127 return 0;
152 /* Check for stopped and check stop state */ 128 return !!(pcpu->status & (SIGP_STATUS_CHECK_STOP|SIGP_STATUS_STOPPED));
153 return !!(pcpu->status & 0x50);
154} 129}
155 130
156static inline int pcpu_running(struct pcpu *pcpu) 131static inline int pcpu_running(struct pcpu *pcpu)
157{ 132{
158 if (__pcpu_sigp(pcpu->address, sigp_sense_running, 133 if (__pcpu_sigp(pcpu->address, SIGP_SENSE_RUNNING,
159 0, &pcpu->status) != sigp_status_stored) 134 0, &pcpu->status) != SIGP_CC_STATUS_STORED)
160 return 1; 135 return 1;
161 /* Check for running status */ 136 /* Status stored condition code is equivalent to cpu not running. */
162 return !(pcpu->status & 0x400); 137 return 0;
163} 138}
164 139
165/* 140/*
@@ -181,7 +156,7 @@ static void pcpu_ec_call(struct pcpu *pcpu, int ec_bit)
181 156
182 set_bit(ec_bit, &pcpu->ec_mask); 157 set_bit(ec_bit, &pcpu->ec_mask);
183 order = pcpu_running(pcpu) ? 158 order = pcpu_running(pcpu) ?
184 sigp_external_call : sigp_emergency_signal; 159 SIGP_EXTERNAL_CALL : SIGP_EMERGENCY_SIGNAL;
185 pcpu_sigp_retry(pcpu, order, 0); 160 pcpu_sigp_retry(pcpu, order, 0);
186} 161}
187 162
@@ -214,7 +189,7 @@ static int __cpuinit pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu)
214 goto out; 189 goto out;
215#endif 190#endif
216 lowcore_ptr[cpu] = lc; 191 lowcore_ptr[cpu] = lc;
217 pcpu_sigp_retry(pcpu, sigp_set_prefix, (u32)(unsigned long) lc); 192 pcpu_sigp_retry(pcpu, SIGP_SET_PREFIX, (u32)(unsigned long) lc);
218 return 0; 193 return 0;
219out: 194out:
220 if (pcpu != &pcpu_devices[0]) { 195 if (pcpu != &pcpu_devices[0]) {
@@ -229,7 +204,7 @@ out:
229 204
230static void pcpu_free_lowcore(struct pcpu *pcpu) 205static void pcpu_free_lowcore(struct pcpu *pcpu)
231{ 206{
232 pcpu_sigp_retry(pcpu, sigp_set_prefix, 0); 207 pcpu_sigp_retry(pcpu, SIGP_SET_PREFIX, 0);
233 lowcore_ptr[pcpu - pcpu_devices] = NULL; 208 lowcore_ptr[pcpu - pcpu_devices] = NULL;
234#ifndef CONFIG_64BIT 209#ifndef CONFIG_64BIT
235 if (MACHINE_HAS_IEEE) { 210 if (MACHINE_HAS_IEEE) {
@@ -288,7 +263,7 @@ static void pcpu_start_fn(struct pcpu *pcpu, void (*func)(void *), void *data)
288 lc->restart_fn = (unsigned long) func; 263 lc->restart_fn = (unsigned long) func;
289 lc->restart_data = (unsigned long) data; 264 lc->restart_data = (unsigned long) data;
290 lc->restart_source = -1UL; 265 lc->restart_source = -1UL;
291 pcpu_sigp_retry(pcpu, sigp_restart, 0); 266 pcpu_sigp_retry(pcpu, SIGP_RESTART, 0);
292} 267}
293 268
294/* 269/*
@@ -298,26 +273,26 @@ static void pcpu_delegate(struct pcpu *pcpu, void (*func)(void *),
298 void *data, unsigned long stack) 273 void *data, unsigned long stack)
299{ 274{
300 struct _lowcore *lc = lowcore_ptr[pcpu - pcpu_devices]; 275 struct _lowcore *lc = lowcore_ptr[pcpu - pcpu_devices];
301 struct { 276 unsigned long source_cpu = stap();
302 unsigned long stack;
303 void *func;
304 void *data;
305 unsigned long source;
306 } restart = { stack, func, data, stap() };
307 277
308 __load_psw_mask(psw_kernel_bits); 278 __load_psw_mask(psw_kernel_bits);
309 if (pcpu->address == restart.source) 279 if (pcpu->address == source_cpu)
310 func(data); /* should not return */ 280 func(data); /* should not return */
311 /* Stop target cpu (if func returns this stops the current cpu). */ 281 /* Stop target cpu (if func returns this stops the current cpu). */
312 pcpu_sigp_retry(pcpu, sigp_stop, 0); 282 pcpu_sigp_retry(pcpu, SIGP_STOP, 0);
313 /* Restart func on the target cpu and stop the current cpu. */ 283 /* Restart func on the target cpu and stop the current cpu. */
314 memcpy_absolute(&lc->restart_stack, &restart, sizeof(restart)); 284 mem_assign_absolute(lc->restart_stack, stack);
285 mem_assign_absolute(lc->restart_fn, (unsigned long) func);
286 mem_assign_absolute(lc->restart_data, (unsigned long) data);
287 mem_assign_absolute(lc->restart_source, source_cpu);
315 asm volatile( 288 asm volatile(
316 "0: sigp 0,%0,6 # sigp restart to target cpu\n" 289 "0: sigp 0,%0,%2 # sigp restart to target cpu\n"
317 " brc 2,0b # busy, try again\n" 290 " brc 2,0b # busy, try again\n"
318 "1: sigp 0,%1,5 # sigp stop to current cpu\n" 291 "1: sigp 0,%1,%3 # sigp stop to current cpu\n"
319 " brc 2,1b # busy, try again\n" 292 " brc 2,1b # busy, try again\n"
320 : : "d" (pcpu->address), "d" (restart.source) : "0", "1", "cc"); 293 : : "d" (pcpu->address), "d" (source_cpu),
294 "K" (SIGP_RESTART), "K" (SIGP_STOP)
295 : "0", "1", "cc");
321 for (;;) ; 296 for (;;) ;
322} 297}
323 298
@@ -388,8 +363,8 @@ void smp_emergency_stop(cpumask_t *cpumask)
388 for_each_cpu(cpu, cpumask) { 363 for_each_cpu(cpu, cpumask) {
389 struct pcpu *pcpu = pcpu_devices + cpu; 364 struct pcpu *pcpu = pcpu_devices + cpu;
390 set_bit(ec_stop_cpu, &pcpu->ec_mask); 365 set_bit(ec_stop_cpu, &pcpu->ec_mask);
391 while (__pcpu_sigp(pcpu->address, sigp_emergency_signal, 366 while (__pcpu_sigp(pcpu->address, SIGP_EMERGENCY_SIGNAL,
392 0, NULL) == sigp_busy && 367 0, NULL) == SIGP_CC_BUSY &&
393 get_clock() < end) 368 get_clock() < end)
394 cpu_relax(); 369 cpu_relax();
395 } 370 }
@@ -425,7 +400,7 @@ void smp_send_stop(void)
425 /* stop all processors */ 400 /* stop all processors */
426 for_each_cpu(cpu, &cpumask) { 401 for_each_cpu(cpu, &cpumask) {
427 struct pcpu *pcpu = pcpu_devices + cpu; 402 struct pcpu *pcpu = pcpu_devices + cpu;
428 pcpu_sigp_retry(pcpu, sigp_stop, 0); 403 pcpu_sigp_retry(pcpu, SIGP_STOP, 0);
429 while (!pcpu_stopped(pcpu)) 404 while (!pcpu_stopped(pcpu))
430 cpu_relax(); 405 cpu_relax();
431 } 406 }
@@ -436,7 +411,7 @@ void smp_send_stop(void)
436 */ 411 */
437void smp_stop_cpu(void) 412void smp_stop_cpu(void)
438{ 413{
439 pcpu_sigp_retry(pcpu_devices + smp_processor_id(), sigp_stop, 0); 414 pcpu_sigp_retry(pcpu_devices + smp_processor_id(), SIGP_STOP, 0);
440 for (;;) ; 415 for (;;) ;
441} 416}
442 417
@@ -590,7 +565,7 @@ static void __init smp_get_save_area(int cpu, u16 address)
590 } 565 }
591#endif 566#endif
592 /* Get the registers of a non-boot cpu. */ 567 /* Get the registers of a non-boot cpu. */
593 __pcpu_sigp_relax(address, sigp_stop_and_store_status, 0, NULL); 568 __pcpu_sigp_relax(address, SIGP_STOP_AND_STORE_STATUS, 0, NULL);
594 memcpy_real(save_area, lc + SAVE_AREA_BASE, sizeof(*save_area)); 569 memcpy_real(save_area, lc + SAVE_AREA_BASE, sizeof(*save_area));
595} 570}
596 571
@@ -599,8 +574,8 @@ int smp_store_status(int cpu)
599 struct pcpu *pcpu; 574 struct pcpu *pcpu;
600 575
601 pcpu = pcpu_devices + cpu; 576 pcpu = pcpu_devices + cpu;
602 if (__pcpu_sigp_relax(pcpu->address, sigp_stop_and_store_status, 577 if (__pcpu_sigp_relax(pcpu->address, SIGP_STOP_AND_STORE_STATUS,
603 0, NULL) != sigp_order_code_accepted) 578 0, NULL) != SIGP_CC_ORDER_CODE_ACCEPTED)
604 return -EIO; 579 return -EIO;
605 return 0; 580 return 0;
606} 581}
@@ -621,8 +596,8 @@ static struct sclp_cpu_info *smp_get_cpu_info(void)
621 if (info && (use_sigp_detection || sclp_get_cpu_info(info))) { 596 if (info && (use_sigp_detection || sclp_get_cpu_info(info))) {
622 use_sigp_detection = 1; 597 use_sigp_detection = 1;
623 for (address = 0; address <= MAX_CPU_ADDRESS; address++) { 598 for (address = 0; address <= MAX_CPU_ADDRESS; address++) {
624 if (__pcpu_sigp_relax(address, sigp_sense, 0, NULL) == 599 if (__pcpu_sigp_relax(address, SIGP_SENSE, 0, NULL) ==
625 sigp_not_operational) 600 SIGP_CC_NOT_OPERATIONAL)
626 continue; 601 continue;
627 info->cpu[info->configured].address = address; 602 info->cpu[info->configured].address = address;
628 info->configured++; 603 info->configured++;
@@ -717,9 +692,7 @@ static void __cpuinit smp_start_secondary(void *cpuvoid)
717 init_cpu_vtimer(); 692 init_cpu_vtimer();
718 pfault_init(); 693 pfault_init();
719 notify_cpu_starting(smp_processor_id()); 694 notify_cpu_starting(smp_processor_id());
720 ipi_call_lock();
721 set_cpu_online(smp_processor_id(), true); 695 set_cpu_online(smp_processor_id(), true);
722 ipi_call_unlock();
723 local_irq_enable(); 696 local_irq_enable();
724 /* cpu_idle will call schedule for us */ 697 /* cpu_idle will call schedule for us */
725 cpu_idle(); 698 cpu_idle();
@@ -734,8 +707,8 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
734 pcpu = pcpu_devices + cpu; 707 pcpu = pcpu_devices + cpu;
735 if (pcpu->state != CPU_STATE_CONFIGURED) 708 if (pcpu->state != CPU_STATE_CONFIGURED)
736 return -EIO; 709 return -EIO;
737 if (pcpu_sigp_retry(pcpu, sigp_initial_cpu_reset, 0) != 710 if (pcpu_sigp_retry(pcpu, SIGP_INITIAL_CPU_RESET, 0) !=
738 sigp_order_code_accepted) 711 SIGP_CC_ORDER_CODE_ACCEPTED)
739 return -EIO; 712 return -EIO;
740 713
741 rc = pcpu_alloc_lowcore(pcpu, cpu); 714 rc = pcpu_alloc_lowcore(pcpu, cpu);
@@ -795,7 +768,7 @@ void __cpu_die(unsigned int cpu)
795void __noreturn cpu_die(void) 768void __noreturn cpu_die(void)
796{ 769{
797 idle_task_exit(); 770 idle_task_exit();
798 pcpu_sigp_retry(pcpu_devices + smp_processor_id(), sigp_stop, 0); 771 pcpu_sigp_retry(pcpu_devices + smp_processor_id(), SIGP_STOP, 0);
799 for (;;) ; 772 for (;;) ;
800} 773}
801 774
@@ -942,7 +915,7 @@ static ssize_t show_idle_count(struct device *dev,
942 do { 915 do {
943 sequence = ACCESS_ONCE(idle->sequence); 916 sequence = ACCESS_ONCE(idle->sequence);
944 idle_count = ACCESS_ONCE(idle->idle_count); 917 idle_count = ACCESS_ONCE(idle->idle_count);
945 if (ACCESS_ONCE(idle->idle_enter)) 918 if (ACCESS_ONCE(idle->clock_idle_enter))
946 idle_count++; 919 idle_count++;
947 } while ((sequence & 1) || (idle->sequence != sequence)); 920 } while ((sequence & 1) || (idle->sequence != sequence));
948 return sprintf(buf, "%llu\n", idle_count); 921 return sprintf(buf, "%llu\n", idle_count);
@@ -960,8 +933,8 @@ static ssize_t show_idle_time(struct device *dev,
960 now = get_clock(); 933 now = get_clock();
961 sequence = ACCESS_ONCE(idle->sequence); 934 sequence = ACCESS_ONCE(idle->sequence);
962 idle_time = ACCESS_ONCE(idle->idle_time); 935 idle_time = ACCESS_ONCE(idle->idle_time);
963 idle_enter = ACCESS_ONCE(idle->idle_enter); 936 idle_enter = ACCESS_ONCE(idle->clock_idle_enter);
964 idle_exit = ACCESS_ONCE(idle->idle_exit); 937 idle_exit = ACCESS_ONCE(idle->clock_idle_exit);
965 } while ((sequence & 1) || (idle->sequence != sequence)); 938 } while ((sequence & 1) || (idle->sequence != sequence));
966 idle_time += idle_enter ? ((idle_exit ? : now) - idle_enter) : 0; 939 idle_time += idle_enter ? ((idle_exit ? : now) - idle_enter) : 0;
967 return sprintf(buf, "%llu\n", idle_time >> 12); 940 return sprintf(buf, "%llu\n", idle_time >> 12);
@@ -984,14 +957,11 @@ static int __cpuinit smp_cpu_notify(struct notifier_block *self,
984 unsigned int cpu = (unsigned int)(long)hcpu; 957 unsigned int cpu = (unsigned int)(long)hcpu;
985 struct cpu *c = &pcpu_devices[cpu].cpu; 958 struct cpu *c = &pcpu_devices[cpu].cpu;
986 struct device *s = &c->dev; 959 struct device *s = &c->dev;
987 struct s390_idle_data *idle;
988 int err = 0; 960 int err = 0;
989 961
990 switch (action) { 962 switch (action) {
991 case CPU_ONLINE: 963 case CPU_ONLINE:
992 case CPU_ONLINE_FROZEN: 964 case CPU_ONLINE_FROZEN:
993 idle = &per_cpu(s390_idle, cpu);
994 memset(idle, 0, sizeof(struct s390_idle_data));
995 err = sysfs_create_group(&s->kobj, &cpu_online_attr_group); 965 err = sysfs_create_group(&s->kobj, &cpu_online_attr_group);
996 break; 966 break;
997 case CPU_DEAD: 967 case CPU_DEAD:
diff --git a/arch/s390/kernel/stacktrace.c b/arch/s390/kernel/stacktrace.c
index 8841919ef7e..1785cd82253 100644
--- a/arch/s390/kernel/stacktrace.c
+++ b/arch/s390/kernel/stacktrace.c
@@ -1,9 +1,7 @@
1/* 1/*
2 * arch/s390/kernel/stacktrace.c
3 *
4 * Stack trace management functions 2 * Stack trace management functions
5 * 3 *
6 * Copyright (C) IBM Corp. 2006 4 * Copyright IBM Corp. 2006
7 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com> 5 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
8 */ 6 */
9 7
diff --git a/arch/s390/kernel/swsusp_asm64.S b/arch/s390/kernel/swsusp_asm64.S
index dd70ef04605..d4ca4e0617b 100644
--- a/arch/s390/kernel/swsusp_asm64.S
+++ b/arch/s390/kernel/swsusp_asm64.S
@@ -12,6 +12,7 @@
12#include <asm/ptrace.h> 12#include <asm/ptrace.h>
13#include <asm/thread_info.h> 13#include <asm/thread_info.h>
14#include <asm/asm-offsets.h> 14#include <asm/asm-offsets.h>
15#include <asm/sigp.h>
15 16
16/* 17/*
17 * Save register context in absolute 0 lowcore and call swsusp_save() to 18 * Save register context in absolute 0 lowcore and call swsusp_save() to
@@ -163,7 +164,7 @@ ENTRY(swsusp_arch_resume)
163 diag %r0,%r0,0x308 164 diag %r0,%r0,0x308
164restart_entry: 165restart_entry:
165 lhi %r1,1 166 lhi %r1,1
166 sigp %r1,%r0,0x12 167 sigp %r1,%r0,SIGP_SET_ARCHITECTURE
167 sam64 168 sam64
168 larl %r1,.Lnew_pgm_check_psw 169 larl %r1,.Lnew_pgm_check_psw
169 lpswe 0(%r1) 170 lpswe 0(%r1)
@@ -179,7 +180,7 @@ pgm_check_entry:
179 larl %r4,.Lrestart_suspend_psw /* Set new restart PSW */ 180 larl %r4,.Lrestart_suspend_psw /* Set new restart PSW */
180 mvc __LC_RST_NEW_PSW(16,%r0),0(%r4) 181 mvc __LC_RST_NEW_PSW(16,%r0),0(%r4)
1813: 1823:
182 sigp %r9,%r1,11 /* sigp initial cpu reset */ 183 sigp %r9,%r1,SIGP_INITIAL_CPU_RESET /* sigp initial cpu reset */
183 brc 8,4f /* accepted */ 184 brc 8,4f /* accepted */
184 brc 2,3b /* busy, try again */ 185 brc 2,3b /* busy, try again */
185 186
@@ -190,16 +191,16 @@ pgm_check_entry:
190 larl %r3,_sclp_print_early 191 larl %r3,_sclp_print_early
191 lghi %r1,0 192 lghi %r1,0
192 sam31 193 sam31
193 sigp %r1,%r0,0x12 194 sigp %r1,%r0,SIGP_SET_ARCHITECTURE
194 basr %r14,%r3 195 basr %r14,%r3
195 larl %r3,.Ldisabled_wait_31 196 larl %r3,.Ldisabled_wait_31
196 lpsw 0(%r3) 197 lpsw 0(%r3)
1974: 1984:
198 /* Switch to suspend CPU */ 199 /* Switch to suspend CPU */
199 sigp %r9,%r1,6 /* sigp restart to suspend CPU */ 200 sigp %r9,%r1,SIGP_RESTART /* sigp restart to suspend CPU */
200 brc 2,4b /* busy, try again */ 201 brc 2,4b /* busy, try again */
2015: 2025:
202 sigp %r9,%r2,5 /* sigp stop to current resume CPU */ 203 sigp %r9,%r2,SIGP_STOP /* sigp stop to current resume CPU */
203 brc 2,5b /* busy, try again */ 204 brc 2,5b /* busy, try again */
2046: j 6b 2056: j 6b
205 206
@@ -207,7 +208,7 @@ restart_suspend:
207 larl %r1,.Lresume_cpu 208 larl %r1,.Lresume_cpu
208 llgh %r2,0(%r1) 209 llgh %r2,0(%r1)
2097: 2107:
210 sigp %r9,%r2,1 /* sigp sense, wait for resume CPU */ 211 sigp %r9,%r2,SIGP_SENSE /* sigp sense, wait for resume CPU */
211 brc 8,7b /* accepted, status 0, still running */ 212 brc 8,7b /* accepted, status 0, still running */
212 brc 2,7b /* busy, try again */ 213 brc 2,7b /* busy, try again */
213 tmll %r9,0x40 /* Test if resume CPU is stopped */ 214 tmll %r9,0x40 /* Test if resume CPU is stopped */
diff --git a/arch/s390/kernel/sys_s390.c b/arch/s390/kernel/sys_s390.c
index 78ea1948ff5..d0964d22adb 100644
--- a/arch/s390/kernel/sys_s390.c
+++ b/arch/s390/kernel/sys_s390.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * arch/s390/kernel/sys_s390.c
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999, 2000
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 4 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
7 * Thomas Spatzier (tspat@de.ibm.com) 5 * Thomas Spatzier (tspat@de.ibm.com)
8 * 6 *
@@ -83,11 +81,12 @@ SYSCALL_DEFINE1(s390_personality, unsigned int, personality)
83{ 81{
84 unsigned int ret; 82 unsigned int ret;
85 83
86 if (current->personality == PER_LINUX32 && personality == PER_LINUX) 84 if (personality(current->personality) == PER_LINUX32 &&
87 personality = PER_LINUX32; 85 personality(personality) == PER_LINUX)
86 personality |= PER_LINUX32;
88 ret = sys_personality(personality); 87 ret = sys_personality(personality);
89 if (ret == PER_LINUX32) 88 if (personality(ret) == PER_LINUX32)
90 ret = PER_LINUX; 89 ret &= ~PER_LINUX32;
91 90
92 return ret; 91 return ret;
93} 92}
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
index d4e1cb1dbcd..dcec960fc72 100644
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -1,5 +1,4 @@
1/* 1/*
2 * arch/s390/kernel/time.c
3 * Time of day based timer functions. 2 * Time of day based timer functions.
4 * 3 *
5 * S390 version 4 * S390 version
@@ -45,7 +44,7 @@
45#include <asm/vdso.h> 44#include <asm/vdso.h>
46#include <asm/irq.h> 45#include <asm/irq.h>
47#include <asm/irq_regs.h> 46#include <asm/irq_regs.h>
48#include <asm/timer.h> 47#include <asm/vtimer.h>
49#include <asm/etr.h> 48#include <asm/etr.h>
50#include <asm/cio.h> 49#include <asm/cio.h>
51#include "entry.h" 50#include "entry.h"
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
index 4f8dc942257..05151e06c38 100644
--- a/arch/s390/kernel/topology.c
+++ b/arch/s390/kernel/topology.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright IBM Corp. 2007,2011 2 * Copyright IBM Corp. 2007, 2011
3 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com> 3 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
4 */ 4 */
5 5
diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c
index 77cdf4234eb..01775c04a90 100644
--- a/arch/s390/kernel/traps.c
+++ b/arch/s390/kernel/traps.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * arch/s390/kernel/traps.c
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999, 2000
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 4 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
7 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com), 5 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
8 * 6 *
@@ -187,7 +185,7 @@ void show_registers(struct pt_regs *regs)
187{ 185{
188 char *mode; 186 char *mode;
189 187
190 mode = (regs->psw.mask & PSW_MASK_PSTATE) ? "User" : "Krnl"; 188 mode = user_mode(regs) ? "User" : "Krnl";
191 printk("%s PSW : %p %p", 189 printk("%s PSW : %p %p",
192 mode, (void *) regs->psw.mask, 190 mode, (void *) regs->psw.mask,
193 (void *) regs->psw.addr); 191 (void *) regs->psw.addr);
@@ -227,7 +225,7 @@ void show_regs(struct pt_regs *regs)
227 (void *) current->thread.ksp); 225 (void *) current->thread.ksp);
228 show_registers(regs); 226 show_registers(regs);
229 /* Show stack backtrace if pt_regs is from kernel mode */ 227 /* Show stack backtrace if pt_regs is from kernel mode */
230 if (!(regs->psw.mask & PSW_MASK_PSTATE)) 228 if (!user_mode(regs))
231 show_trace(NULL, (unsigned long *) regs->gprs[15]); 229 show_trace(NULL, (unsigned long *) regs->gprs[15]);
232 show_last_breaking_event(regs); 230 show_last_breaking_event(regs);
233} 231}
@@ -302,7 +300,7 @@ static void __kprobes do_trap(struct pt_regs *regs,
302 regs->int_code, si_signo) == NOTIFY_STOP) 300 regs->int_code, si_signo) == NOTIFY_STOP)
303 return; 301 return;
304 302
305 if (regs->psw.mask & PSW_MASK_PSTATE) { 303 if (user_mode(regs)) {
306 info.si_signo = si_signo; 304 info.si_signo = si_signo;
307 info.si_errno = 0; 305 info.si_errno = 0;
308 info.si_code = si_code; 306 info.si_code = si_code;
@@ -343,7 +341,7 @@ void __kprobes do_per_trap(struct pt_regs *regs)
343 341
344static void default_trap_handler(struct pt_regs *regs) 342static void default_trap_handler(struct pt_regs *regs)
345{ 343{
346 if (regs->psw.mask & PSW_MASK_PSTATE) { 344 if (user_mode(regs)) {
347 report_user_fault(regs, SIGSEGV); 345 report_user_fault(regs, SIGSEGV);
348 do_exit(SIGSEGV); 346 do_exit(SIGSEGV);
349 } else 347 } else
@@ -412,7 +410,7 @@ static void __kprobes illegal_op(struct pt_regs *regs)
412 410
413 location = get_psw_address(regs); 411 location = get_psw_address(regs);
414 412
415 if (regs->psw.mask & PSW_MASK_PSTATE) { 413 if (user_mode(regs)) {
416 if (get_user(*((__u16 *) opcode), (__u16 __user *) location)) 414 if (get_user(*((__u16 *) opcode), (__u16 __user *) location))
417 return; 415 return;
418 if (*((__u16 *) opcode) == S390_BREAKPOINT_U16) { 416 if (*((__u16 *) opcode) == S390_BREAKPOINT_U16) {
@@ -480,7 +478,7 @@ void specification_exception(struct pt_regs *regs)
480 478
481 location = (__u16 __user *) get_psw_address(regs); 479 location = (__u16 __user *) get_psw_address(regs);
482 480
483 if (regs->psw.mask & PSW_MASK_PSTATE) { 481 if (user_mode(regs)) {
484 get_user(*((__u16 *) opcode), location); 482 get_user(*((__u16 *) opcode), location);
485 switch (opcode[0]) { 483 switch (opcode[0]) {
486 case 0x28: /* LDR Rx,Ry */ 484 case 0x28: /* LDR Rx,Ry */
@@ -533,7 +531,7 @@ static void data_exception(struct pt_regs *regs)
533 asm volatile("stfpc %0" : "=m" (current->thread.fp_regs.fpc)); 531 asm volatile("stfpc %0" : "=m" (current->thread.fp_regs.fpc));
534 532
535#ifdef CONFIG_MATHEMU 533#ifdef CONFIG_MATHEMU
536 else if (regs->psw.mask & PSW_MASK_PSTATE) { 534 else if (user_mode(regs)) {
537 __u8 opcode[6]; 535 __u8 opcode[6];
538 get_user(*((__u16 *) opcode), location); 536 get_user(*((__u16 *) opcode), location);
539 switch (opcode[0]) { 537 switch (opcode[0]) {
@@ -600,7 +598,7 @@ static void data_exception(struct pt_regs *regs)
600static void space_switch_exception(struct pt_regs *regs) 598static void space_switch_exception(struct pt_regs *regs)
601{ 599{
602 /* Set user psw back to home space mode. */ 600 /* Set user psw back to home space mode. */
603 if (regs->psw.mask & PSW_MASK_PSTATE) 601 if (user_mode(regs))
604 regs->psw.mask |= PSW_ASC_HOME; 602 regs->psw.mask |= PSW_ASC_HOME;
605 /* Send SIGILL. */ 603 /* Send SIGILL. */
606 do_trap(regs, SIGILL, ILL_PRVOPC, "space switch event"); 604 do_trap(regs, SIGILL, ILL_PRVOPC, "space switch event");
diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c
index ea5590fdca3..9a19ca367c1 100644
--- a/arch/s390/kernel/vdso.c
+++ b/arch/s390/kernel/vdso.c
@@ -84,7 +84,8 @@ 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 vd->ectg_available = user_mode != HOME_SPACE_MODE && test_facility(31); 87 vd->ectg_available =
88 addressing_mode != HOME_SPACE_MODE && test_facility(31);
88} 89}
89 90
90#ifdef CONFIG_64BIT 91#ifdef CONFIG_64BIT
@@ -101,7 +102,7 @@ int vdso_alloc_per_cpu(struct _lowcore *lowcore)
101 102
102 lowcore->vdso_per_cpu_data = __LC_PASTE; 103 lowcore->vdso_per_cpu_data = __LC_PASTE;
103 104
104 if (user_mode == HOME_SPACE_MODE || !vdso_enabled) 105 if (addressing_mode == HOME_SPACE_MODE || !vdso_enabled)
105 return 0; 106 return 0;
106 107
107 segment_table = __get_free_pages(GFP_KERNEL, SEGMENT_ORDER); 108 segment_table = __get_free_pages(GFP_KERNEL, SEGMENT_ORDER);
@@ -146,7 +147,7 @@ void vdso_free_per_cpu(struct _lowcore *lowcore)
146 unsigned long segment_table, page_table, page_frame; 147 unsigned long segment_table, page_table, page_frame;
147 u32 *psal, *aste; 148 u32 *psal, *aste;
148 149
149 if (user_mode == HOME_SPACE_MODE || !vdso_enabled) 150 if (addressing_mode == HOME_SPACE_MODE || !vdso_enabled)
150 return; 151 return;
151 152
152 psal = (u32 *)(addr_t) lowcore->paste[4]; 153 psal = (u32 *)(addr_t) lowcore->paste[4];
@@ -164,7 +165,7 @@ static void vdso_init_cr5(void)
164{ 165{
165 unsigned long cr5; 166 unsigned long cr5;
166 167
167 if (user_mode == HOME_SPACE_MODE || !vdso_enabled) 168 if (addressing_mode == HOME_SPACE_MODE || !vdso_enabled)
168 return; 169 return;
169 cr5 = offsetof(struct _lowcore, paste); 170 cr5 = offsetof(struct _lowcore, paste);
170 __ctl_load(cr5, 5, 5); 171 __ctl_load(cr5, 5, 5);
diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S
index 21109c63eb1..de8fa9bbd35 100644
--- a/arch/s390/kernel/vmlinux.lds.S
+++ b/arch/s390/kernel/vmlinux.lds.S
@@ -45,7 +45,7 @@ SECTIONS
45 45
46 .dummy : { *(.dummy) } :data 46 .dummy : { *(.dummy) } :data
47 47
48 RODATA 48 RO_DATA_SECTION(PAGE_SIZE)
49 49
50#ifdef CONFIG_SHARED_KERNEL 50#ifdef CONFIG_SHARED_KERNEL
51 . = ALIGN(0x100000); /* VM shared segments are 1MB aligned */ 51 . = ALIGN(0x100000); /* VM shared segments are 1MB aligned */
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index 39ebff50694..4fc97b40a6e 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -1,71 +1,82 @@
1/* 1/*
2 * arch/s390/kernel/vtime.c
3 * Virtual cpu timer based timer functions. 2 * Virtual cpu timer based timer functions.
4 * 3 *
5 * S390 version 4 * Copyright IBM Corp. 2004, 2012
6 * Copyright (C) 2004 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Author(s): Jan Glauber <jan.glauber@de.ibm.com> 5 * Author(s): Jan Glauber <jan.glauber@de.ibm.com>
8 */ 6 */
9 7
10#include <linux/module.h> 8#include <linux/kernel_stat.h>
9#include <linux/notifier.h>
10#include <linux/kprobes.h>
11#include <linux/export.h>
11#include <linux/kernel.h> 12#include <linux/kernel.h>
12#include <linux/time.h>
13#include <linux/delay.h>
14#include <linux/init.h>
15#include <linux/smp.h>
16#include <linux/types.h>
17#include <linux/timex.h> 13#include <linux/timex.h>
18#include <linux/notifier.h> 14#include <linux/types.h>
19#include <linux/kernel_stat.h> 15#include <linux/time.h>
20#include <linux/rcupdate.h>
21#include <linux/posix-timers.h>
22#include <linux/cpu.h> 16#include <linux/cpu.h>
23#include <linux/kprobes.h> 17#include <linux/smp.h>
24 18
25#include <asm/timer.h>
26#include <asm/irq_regs.h> 19#include <asm/irq_regs.h>
27#include <asm/cputime.h> 20#include <asm/cputime.h>
21#include <asm/vtimer.h>
28#include <asm/irq.h> 22#include <asm/irq.h>
29#include "entry.h" 23#include "entry.h"
30 24
31static DEFINE_PER_CPU(struct vtimer_queue, virt_cpu_timer); 25static void virt_timer_expire(void);
32 26
33DEFINE_PER_CPU(struct s390_idle_data, s390_idle); 27DEFINE_PER_CPU(struct s390_idle_data, s390_idle);
34 28
35static inline __u64 get_vtimer(void) 29static LIST_HEAD(virt_timer_list);
30static DEFINE_SPINLOCK(virt_timer_lock);
31static atomic64_t virt_timer_current;
32static atomic64_t virt_timer_elapsed;
33
34static inline u64 get_vtimer(void)
36{ 35{
37 __u64 timer; 36 u64 timer;
38 37
39 asm volatile("STPT %0" : "=m" (timer)); 38 asm volatile("stpt %0" : "=m" (timer));
40 return timer; 39 return timer;
41} 40}
42 41
43static inline void set_vtimer(__u64 expires) 42static inline void set_vtimer(u64 expires)
44{ 43{
45 __u64 timer; 44 u64 timer;
46 45
47 asm volatile (" STPT %0\n" /* Store current cpu timer value */ 46 asm volatile(
48 " SPT %1" /* Set new value immediately afterwards */ 47 " stpt %0\n" /* Store current cpu timer value */
49 : "=m" (timer) : "m" (expires) ); 48 " spt %1" /* Set new value imm. afterwards */
49 : "=m" (timer) : "m" (expires));
50 S390_lowcore.system_timer += S390_lowcore.last_update_timer - timer; 50 S390_lowcore.system_timer += S390_lowcore.last_update_timer - timer;
51 S390_lowcore.last_update_timer = expires; 51 S390_lowcore.last_update_timer = expires;
52} 52}
53 53
54static inline int virt_timer_forward(u64 elapsed)
55{
56 BUG_ON(!irqs_disabled());
57
58 if (list_empty(&virt_timer_list))
59 return 0;
60 elapsed = atomic64_add_return(elapsed, &virt_timer_elapsed);
61 return elapsed >= atomic64_read(&virt_timer_current);
62}
63
54/* 64/*
55 * Update process times based on virtual cpu times stored by entry.S 65 * Update process times based on virtual cpu times stored by entry.S
56 * to the lowcore fields user_timer, system_timer & steal_clock. 66 * to the lowcore fields user_timer, system_timer & steal_clock.
57 */ 67 */
58static void do_account_vtime(struct task_struct *tsk, int hardirq_offset) 68static int do_account_vtime(struct task_struct *tsk, int hardirq_offset)
59{ 69{
60 struct thread_info *ti = task_thread_info(tsk); 70 struct thread_info *ti = task_thread_info(tsk);
61 __u64 timer, clock, user, system, steal; 71 u64 timer, clock, user, system, steal;
62 72
63 timer = S390_lowcore.last_update_timer; 73 timer = S390_lowcore.last_update_timer;
64 clock = S390_lowcore.last_update_clock; 74 clock = S390_lowcore.last_update_clock;
65 asm volatile (" STPT %0\n" /* Store current cpu timer value */ 75 asm volatile(
66 " STCK %1" /* Store current tod clock value */ 76 " stpt %0\n" /* Store current cpu timer value */
67 : "=m" (S390_lowcore.last_update_timer), 77 " stck %1" /* Store current tod clock value */
68 "=m" (S390_lowcore.last_update_clock) ); 78 : "=m" (S390_lowcore.last_update_timer),
79 "=m" (S390_lowcore.last_update_clock));
69 S390_lowcore.system_timer += timer - S390_lowcore.last_update_timer; 80 S390_lowcore.system_timer += timer - S390_lowcore.last_update_timer;
70 S390_lowcore.steal_timer += S390_lowcore.last_update_clock - clock; 81 S390_lowcore.steal_timer += S390_lowcore.last_update_clock - clock;
71 82
@@ -84,6 +95,8 @@ static void do_account_vtime(struct task_struct *tsk, int hardirq_offset)
84 S390_lowcore.steal_timer = 0; 95 S390_lowcore.steal_timer = 0;
85 account_steal_time(steal); 96 account_steal_time(steal);
86 } 97 }
98
99 return virt_timer_forward(user + system);
87} 100}
88 101
89void account_vtime(struct task_struct *prev, struct task_struct *next) 102void account_vtime(struct task_struct *prev, struct task_struct *next)
@@ -101,7 +114,8 @@ void account_vtime(struct task_struct *prev, struct task_struct *next)
101 114
102void account_process_tick(struct task_struct *tsk, int user_tick) 115void account_process_tick(struct task_struct *tsk, int user_tick)
103{ 116{
104 do_account_vtime(tsk, HARDIRQ_OFFSET); 117 if (do_account_vtime(tsk, HARDIRQ_OFFSET))
118 virt_timer_expire();
105} 119}
106 120
107/* 121/*
@@ -111,7 +125,7 @@ void account_process_tick(struct task_struct *tsk, int user_tick)
111void account_system_vtime(struct task_struct *tsk) 125void account_system_vtime(struct task_struct *tsk)
112{ 126{
113 struct thread_info *ti = task_thread_info(tsk); 127 struct thread_info *ti = task_thread_info(tsk);
114 __u64 timer, system; 128 u64 timer, system;
115 129
116 timer = S390_lowcore.last_update_timer; 130 timer = S390_lowcore.last_update_timer;
117 S390_lowcore.last_update_timer = get_vtimer(); 131 S390_lowcore.last_update_timer = get_vtimer();
@@ -121,13 +135,14 @@ void account_system_vtime(struct task_struct *tsk)
121 S390_lowcore.steal_timer -= system; 135 S390_lowcore.steal_timer -= system;
122 ti->system_timer = S390_lowcore.system_timer; 136 ti->system_timer = S390_lowcore.system_timer;
123 account_system_time(tsk, 0, system, system); 137 account_system_time(tsk, 0, system, system);
138
139 virt_timer_forward(system);
124} 140}
125EXPORT_SYMBOL_GPL(account_system_vtime); 141EXPORT_SYMBOL_GPL(account_system_vtime);
126 142
127void __kprobes vtime_stop_cpu(void) 143void __kprobes vtime_stop_cpu(void)
128{ 144{
129 struct s390_idle_data *idle = &__get_cpu_var(s390_idle); 145 struct s390_idle_data *idle = &__get_cpu_var(s390_idle);
130 struct vtimer_queue *vq = &__get_cpu_var(virt_cpu_timer);
131 unsigned long long idle_time; 146 unsigned long long idle_time;
132 unsigned long psw_mask; 147 unsigned long psw_mask;
133 148
@@ -141,7 +156,7 @@ void __kprobes vtime_stop_cpu(void)
141 idle->nohz_delay = 0; 156 idle->nohz_delay = 0;
142 157
143 /* Call the assembler magic in entry.S */ 158 /* Call the assembler magic in entry.S */
144 psw_idle(idle, vq, psw_mask, !list_empty(&vq->list)); 159 psw_idle(idle, psw_mask);
145 160
146 /* Reenable preemption tracer. */ 161 /* Reenable preemption tracer. */
147 start_critical_timings(); 162 start_critical_timings();
@@ -149,9 +164,9 @@ void __kprobes vtime_stop_cpu(void)
149 /* Account time spent with enabled wait psw loaded as idle time. */ 164 /* Account time spent with enabled wait psw loaded as idle time. */
150 idle->sequence++; 165 idle->sequence++;
151 smp_wmb(); 166 smp_wmb();
152 idle_time = idle->idle_exit - idle->idle_enter; 167 idle_time = idle->clock_idle_exit - idle->clock_idle_enter;
168 idle->clock_idle_enter = idle->clock_idle_exit = 0ULL;
153 idle->idle_time += idle_time; 169 idle->idle_time += idle_time;
154 idle->idle_enter = idle->idle_exit = 0ULL;
155 idle->idle_count++; 170 idle->idle_count++;
156 account_idle_time(idle_time); 171 account_idle_time(idle_time);
157 smp_wmb(); 172 smp_wmb();
@@ -167,10 +182,10 @@ cputime64_t s390_get_idle_time(int cpu)
167 do { 182 do {
168 now = get_clock(); 183 now = get_clock();
169 sequence = ACCESS_ONCE(idle->sequence); 184 sequence = ACCESS_ONCE(idle->sequence);
170 idle_enter = ACCESS_ONCE(idle->idle_enter); 185 idle_enter = ACCESS_ONCE(idle->clock_idle_enter);
171 idle_exit = ACCESS_ONCE(idle->idle_exit); 186 idle_exit = ACCESS_ONCE(idle->clock_idle_exit);
172 } while ((sequence & 1) || (idle->sequence != sequence)); 187 } while ((sequence & 1) || (idle->sequence != sequence));
173 return idle_enter ? ((idle_exit ? : now) - idle_enter) : 0; 188 return idle_enter ? ((idle_exit ?: now) - idle_enter) : 0;
174} 189}
175 190
176/* 191/*
@@ -179,11 +194,11 @@ cputime64_t s390_get_idle_time(int cpu)
179 */ 194 */
180static void list_add_sorted(struct vtimer_list *timer, struct list_head *head) 195static void list_add_sorted(struct vtimer_list *timer, struct list_head *head)
181{ 196{
182 struct vtimer_list *event; 197 struct vtimer_list *tmp;
183 198
184 list_for_each_entry(event, head, entry) { 199 list_for_each_entry(tmp, head, entry) {
185 if (event->expires > timer->expires) { 200 if (tmp->expires > timer->expires) {
186 list_add_tail(&timer->entry, &event->entry); 201 list_add_tail(&timer->entry, &tmp->entry);
187 return; 202 return;
188 } 203 }
189 } 204 }
@@ -191,82 +206,45 @@ static void list_add_sorted(struct vtimer_list *timer, struct list_head *head)
191} 206}
192 207
193/* 208/*
194 * Do the callback functions of expired vtimer events. 209 * Handler for expired virtual CPU timer.
195 * Called from within the interrupt handler.
196 */
197static void do_callbacks(struct list_head *cb_list)
198{
199 struct vtimer_queue *vq;
200 struct vtimer_list *event, *tmp;
201
202 if (list_empty(cb_list))
203 return;
204
205 vq = &__get_cpu_var(virt_cpu_timer);
206
207 list_for_each_entry_safe(event, tmp, cb_list, entry) {
208 list_del_init(&event->entry);
209 (event->function)(event->data);
210 if (event->interval) {
211 /* Recharge interval timer */
212 event->expires = event->interval + vq->elapsed;
213 spin_lock(&vq->lock);
214 list_add_sorted(event, &vq->list);
215 spin_unlock(&vq->lock);
216 }
217 }
218}
219
220/*
221 * Handler for the virtual CPU timer.
222 */ 210 */
223static void do_cpu_timer_interrupt(struct ext_code ext_code, 211static void virt_timer_expire(void)
224 unsigned int param32, unsigned long param64)
225{ 212{
226 struct vtimer_queue *vq; 213 struct vtimer_list *timer, *tmp;
227 struct vtimer_list *event, *tmp; 214 unsigned long elapsed;
228 struct list_head cb_list; /* the callback queue */ 215 LIST_HEAD(cb_list);
229 __u64 elapsed, next; 216
230 217 /* walk timer list, fire all expired timers */
231 kstat_cpu(smp_processor_id()).irqs[EXTINT_TMR]++; 218 spin_lock(&virt_timer_lock);
232 INIT_LIST_HEAD(&cb_list); 219 elapsed = atomic64_read(&virt_timer_elapsed);
233 vq = &__get_cpu_var(virt_cpu_timer); 220 list_for_each_entry_safe(timer, tmp, &virt_timer_list, entry) {
234 221 if (timer->expires < elapsed)
235 /* walk timer list, fire all expired events */
236 spin_lock(&vq->lock);
237
238 elapsed = vq->elapsed + (vq->timer - S390_lowcore.async_enter_timer);
239 BUG_ON((s64) elapsed < 0);
240 vq->elapsed = 0;
241 list_for_each_entry_safe(event, tmp, &vq->list, entry) {
242 if (event->expires < elapsed)
243 /* move expired timer to the callback queue */ 222 /* move expired timer to the callback queue */
244 list_move_tail(&event->entry, &cb_list); 223 list_move_tail(&timer->entry, &cb_list);
245 else 224 else
246 event->expires -= elapsed; 225 timer->expires -= elapsed;
247 } 226 }
248 spin_unlock(&vq->lock); 227 if (!list_empty(&virt_timer_list)) {
249 228 timer = list_first_entry(&virt_timer_list,
250 do_callbacks(&cb_list); 229 struct vtimer_list, entry);
251 230 atomic64_set(&virt_timer_current, timer->expires);
252 /* next event is first in list */ 231 }
253 next = VTIMER_MAX_SLICE; 232 atomic64_sub(elapsed, &virt_timer_elapsed);
254 spin_lock(&vq->lock); 233 spin_unlock(&virt_timer_lock);
255 if (!list_empty(&vq->list)) { 234
256 event = list_first_entry(&vq->list, struct vtimer_list, entry); 235 /* Do callbacks and recharge periodic timers */
257 next = event->expires; 236 list_for_each_entry_safe(timer, tmp, &cb_list, entry) {
237 list_del_init(&timer->entry);
238 timer->function(timer->data);
239 if (timer->interval) {
240 /* Recharge interval timer */
241 timer->expires = timer->interval +
242 atomic64_read(&virt_timer_elapsed);
243 spin_lock(&virt_timer_lock);
244 list_add_sorted(timer, &virt_timer_list);
245 spin_unlock(&virt_timer_lock);
246 }
258 } 247 }
259 spin_unlock(&vq->lock);
260 /*
261 * To improve precision add the time spent by the
262 * interrupt handler to the elapsed time.
263 * Note: CPU timer counts down and we got an interrupt,
264 * the current content is negative
265 */
266 elapsed = S390_lowcore.async_enter_timer - get_vtimer();
267 set_vtimer(next - elapsed);
268 vq->timer = next - elapsed;
269 vq->elapsed = elapsed;
270} 248}
271 249
272void init_virt_timer(struct vtimer_list *timer) 250void init_virt_timer(struct vtimer_list *timer)
@@ -278,179 +256,108 @@ EXPORT_SYMBOL(init_virt_timer);
278 256
279static inline int vtimer_pending(struct vtimer_list *timer) 257static inline int vtimer_pending(struct vtimer_list *timer)
280{ 258{
281 return (!list_empty(&timer->entry)); 259 return !list_empty(&timer->entry);
282} 260}
283 261
284/*
285 * this function should only run on the specified CPU
286 */
287static void internal_add_vtimer(struct vtimer_list *timer) 262static void internal_add_vtimer(struct vtimer_list *timer)
288{ 263{
289 struct vtimer_queue *vq; 264 if (list_empty(&virt_timer_list)) {
290 unsigned long flags; 265 /* First timer, just program it. */
291 __u64 left, expires; 266 atomic64_set(&virt_timer_current, timer->expires);
292 267 atomic64_set(&virt_timer_elapsed, 0);
293 vq = &per_cpu(virt_cpu_timer, timer->cpu); 268 list_add(&timer->entry, &virt_timer_list);
294 spin_lock_irqsave(&vq->lock, flags);
295
296 BUG_ON(timer->cpu != smp_processor_id());
297
298 if (list_empty(&vq->list)) {
299 /* First timer on this cpu, just program it. */
300 list_add(&timer->entry, &vq->list);
301 set_vtimer(timer->expires);
302 vq->timer = timer->expires;
303 vq->elapsed = 0;
304 } else { 269 } else {
305 /* Check progress of old timers. */ 270 /* Update timer against current base. */
306 expires = timer->expires; 271 timer->expires += atomic64_read(&virt_timer_elapsed);
307 left = get_vtimer(); 272 if (likely((s64) timer->expires <
308 if (likely((s64) expires < (s64) left)) { 273 (s64) atomic64_read(&virt_timer_current)))
309 /* The new timer expires before the current timer. */ 274 /* The new timer expires before the current timer. */
310 set_vtimer(expires); 275 atomic64_set(&virt_timer_current, timer->expires);
311 vq->elapsed += vq->timer - left; 276 /* Insert new timer into the list. */
312 vq->timer = expires; 277 list_add_sorted(timer, &virt_timer_list);
313 } else {
314 vq->elapsed += vq->timer - left;
315 vq->timer = left;
316 }
317 /* Insert new timer into per cpu list. */
318 timer->expires += vq->elapsed;
319 list_add_sorted(timer, &vq->list);
320 } 278 }
321
322 spin_unlock_irqrestore(&vq->lock, flags);
323 /* release CPU acquired in prepare_vtimer or mod_virt_timer() */
324 put_cpu();
325} 279}
326 280
327static inline void prepare_vtimer(struct vtimer_list *timer) 281static void __add_vtimer(struct vtimer_list *timer, int periodic)
328{ 282{
329 BUG_ON(!timer->function); 283 unsigned long flags;
330 BUG_ON(!timer->expires || timer->expires > VTIMER_MAX_SLICE); 284
331 BUG_ON(vtimer_pending(timer)); 285 timer->interval = periodic ? timer->expires : 0;
332 timer->cpu = get_cpu(); 286 spin_lock_irqsave(&virt_timer_lock, flags);
287 internal_add_vtimer(timer);
288 spin_unlock_irqrestore(&virt_timer_lock, flags);
333} 289}
334 290
335/* 291/*
336 * add_virt_timer - add an oneshot virtual CPU timer 292 * add_virt_timer - add an oneshot virtual CPU timer
337 */ 293 */
338void add_virt_timer(void *new) 294void add_virt_timer(struct vtimer_list *timer)
339{ 295{
340 struct vtimer_list *timer; 296 __add_vtimer(timer, 0);
341
342 timer = (struct vtimer_list *)new;
343 prepare_vtimer(timer);
344 timer->interval = 0;
345 internal_add_vtimer(timer);
346} 297}
347EXPORT_SYMBOL(add_virt_timer); 298EXPORT_SYMBOL(add_virt_timer);
348 299
349/* 300/*
350 * add_virt_timer_int - add an interval virtual CPU timer 301 * add_virt_timer_int - add an interval virtual CPU timer
351 */ 302 */
352void add_virt_timer_periodic(void *new) 303void add_virt_timer_periodic(struct vtimer_list *timer)
353{ 304{
354 struct vtimer_list *timer; 305 __add_vtimer(timer, 1);
355
356 timer = (struct vtimer_list *)new;
357 prepare_vtimer(timer);
358 timer->interval = timer->expires;
359 internal_add_vtimer(timer);
360} 306}
361EXPORT_SYMBOL(add_virt_timer_periodic); 307EXPORT_SYMBOL(add_virt_timer_periodic);
362 308
363static int __mod_vtimer(struct vtimer_list *timer, __u64 expires, int periodic) 309static int __mod_vtimer(struct vtimer_list *timer, u64 expires, int periodic)
364{ 310{
365 struct vtimer_queue *vq;
366 unsigned long flags; 311 unsigned long flags;
367 int cpu; 312 int rc;
368 313
369 BUG_ON(!timer->function); 314 BUG_ON(!timer->function);
370 BUG_ON(!expires || expires > VTIMER_MAX_SLICE);
371 315
372 if (timer->expires == expires && vtimer_pending(timer)) 316 if (timer->expires == expires && vtimer_pending(timer))
373 return 1; 317 return 1;
374 318 spin_lock_irqsave(&virt_timer_lock, flags);
375 cpu = get_cpu(); 319 rc = vtimer_pending(timer);
376 vq = &per_cpu(virt_cpu_timer, cpu); 320 if (rc)
377 321 list_del_init(&timer->entry);
378 /* disable interrupts before test if timer is pending */ 322 timer->interval = periodic ? expires : 0;
379 spin_lock_irqsave(&vq->lock, flags);
380
381 /* if timer isn't pending add it on the current CPU */
382 if (!vtimer_pending(timer)) {
383 spin_unlock_irqrestore(&vq->lock, flags);
384
385 if (periodic)
386 timer->interval = expires;
387 else
388 timer->interval = 0;
389 timer->expires = expires;
390 timer->cpu = cpu;
391 internal_add_vtimer(timer);
392 return 0;
393 }
394
395 /* check if we run on the right CPU */
396 BUG_ON(timer->cpu != cpu);
397
398 list_del_init(&timer->entry);
399 timer->expires = expires; 323 timer->expires = expires;
400 if (periodic)
401 timer->interval = expires;
402
403 /* the timer can't expire anymore so we can release the lock */
404 spin_unlock_irqrestore(&vq->lock, flags);
405 internal_add_vtimer(timer); 324 internal_add_vtimer(timer);
406 return 1; 325 spin_unlock_irqrestore(&virt_timer_lock, flags);
326 return rc;
407} 327}
408 328
409/* 329/*
410 * If we change a pending timer the function must be called on the CPU
411 * where the timer is running on.
412 *
413 * returns whether it has modified a pending timer (1) or not (0) 330 * returns whether it has modified a pending timer (1) or not (0)
414 */ 331 */
415int mod_virt_timer(struct vtimer_list *timer, __u64 expires) 332int mod_virt_timer(struct vtimer_list *timer, u64 expires)
416{ 333{
417 return __mod_vtimer(timer, expires, 0); 334 return __mod_vtimer(timer, expires, 0);
418} 335}
419EXPORT_SYMBOL(mod_virt_timer); 336EXPORT_SYMBOL(mod_virt_timer);
420 337
421/* 338/*
422 * If we change a pending timer the function must be called on the CPU
423 * where the timer is running on.
424 *
425 * returns whether it has modified a pending timer (1) or not (0) 339 * returns whether it has modified a pending timer (1) or not (0)
426 */ 340 */
427int mod_virt_timer_periodic(struct vtimer_list *timer, __u64 expires) 341int mod_virt_timer_periodic(struct vtimer_list *timer, u64 expires)
428{ 342{
429 return __mod_vtimer(timer, expires, 1); 343 return __mod_vtimer(timer, expires, 1);
430} 344}
431EXPORT_SYMBOL(mod_virt_timer_periodic); 345EXPORT_SYMBOL(mod_virt_timer_periodic);
432 346
433/* 347/*
434 * delete a virtual timer 348 * Delete a virtual timer.
435 * 349 *
436 * returns whether the deleted timer was pending (1) or not (0) 350 * returns whether the deleted timer was pending (1) or not (0)
437 */ 351 */
438int del_virt_timer(struct vtimer_list *timer) 352int del_virt_timer(struct vtimer_list *timer)
439{ 353{
440 unsigned long flags; 354 unsigned long flags;
441 struct vtimer_queue *vq;
442 355
443 /* check if timer is pending */
444 if (!vtimer_pending(timer)) 356 if (!vtimer_pending(timer))
445 return 0; 357 return 0;
446 358 spin_lock_irqsave(&virt_timer_lock, flags);
447 vq = &per_cpu(virt_cpu_timer, timer->cpu);
448 spin_lock_irqsave(&vq->lock, flags);
449
450 /* we don't interrupt a running timer, just let it expire! */
451 list_del_init(&timer->entry); 359 list_del_init(&timer->entry);
452 360 spin_unlock_irqrestore(&virt_timer_lock, flags);
453 spin_unlock_irqrestore(&vq->lock, flags);
454 return 1; 361 return 1;
455} 362}
456EXPORT_SYMBOL(del_virt_timer); 363EXPORT_SYMBOL(del_virt_timer);
@@ -458,20 +365,10 @@ EXPORT_SYMBOL(del_virt_timer);
458/* 365/*
459 * Start the virtual CPU timer on the current CPU. 366 * Start the virtual CPU timer on the current CPU.
460 */ 367 */
461void init_cpu_vtimer(void) 368void __cpuinit init_cpu_vtimer(void)
462{ 369{
463 struct vtimer_queue *vq;
464
465 /* initialize per cpu vtimer structure */
466 vq = &__get_cpu_var(virt_cpu_timer);
467 INIT_LIST_HEAD(&vq->list);
468 spin_lock_init(&vq->lock);
469
470 /* enable cpu timer interrupts */
471 __ctl_set_bit(0,10);
472
473 /* set initial cpu timer */ 370 /* set initial cpu timer */
474 set_vtimer(0x7fffffffffffffffULL); 371 set_vtimer(VTIMER_MAX_SLICE);
475} 372}
476 373
477static int __cpuinit s390_nohz_notify(struct notifier_block *self, 374static int __cpuinit s390_nohz_notify(struct notifier_block *self,
@@ -493,12 +390,7 @@ static int __cpuinit s390_nohz_notify(struct notifier_block *self,
493 390
494void __init vtime_init(void) 391void __init vtime_init(void)
495{ 392{
496 /* request the cpu timer external interrupt */
497 if (register_external_interrupt(0x1005, do_cpu_timer_interrupt))
498 panic("Couldn't request external interrupt 0x1005");
499
500 /* Enable cpu timer interrupts on the boot cpu. */ 393 /* Enable cpu timer interrupts on the boot cpu. */
501 init_cpu_vtimer(); 394 init_cpu_vtimer();
502 cpu_notifier(s390_nohz_notify, 0); 395 cpu_notifier(s390_nohz_notify, 0);
503} 396}
504
diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c
index b23d9ac77df..c88bb779339 100644
--- a/arch/s390/kvm/diag.c
+++ b/arch/s390/kvm/diag.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * diag.c - handling diagnose instructions 2 * handling diagnose instructions
3 * 3 *
4 * Copyright IBM Corp. 2008,2011 4 * Copyright IBM Corp. 2008, 2011
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License (version 2 only) 7 * it under the terms of the GNU General Public License (version 2 only)
diff --git a/arch/s390/kvm/gaccess.h b/arch/s390/kvm/gaccess.h
index c86f6ae43f7..4703f129e95 100644
--- a/arch/s390/kvm/gaccess.h
+++ b/arch/s390/kvm/gaccess.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * access.h - access guest memory 2 * access guest memory
3 * 3 *
4 * Copyright IBM Corp. 2008,2009 4 * Copyright IBM Corp. 2008, 2009
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License (version 2 only) 7 * it under the terms of the GNU General Public License (version 2 only)
diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c
index 979cbe55bf5..adae539f12e 100644
--- a/arch/s390/kvm/intercept.c
+++ b/arch/s390/kvm/intercept.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * intercept.c - in-kernel handling for sie intercepts 2 * in-kernel handling for sie intercepts
3 * 3 *
4 * Copyright IBM Corp. 2008,2009 4 * Copyright IBM Corp. 2008, 2009
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License (version 2 only) 7 * it under the terms of the GNU General Public License (version 2 only)
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index 2d9f9a72bb8..b7bc1aac8ed 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * interrupt.c - handling kvm guest interrupts 2 * handling kvm guest interrupts
3 * 3 *
4 * Copyright IBM Corp. 2008 4 * Copyright IBM Corp. 2008
5 * 5 *
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 664766d0c83..d470ccbfaba 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * s390host.c -- hosting zSeries kernel virtual machines 2 * hosting zSeries kernel virtual machines
3 * 3 *
4 * Copyright IBM Corp. 2008,2009 4 * Copyright IBM Corp. 2008, 2009
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License (version 2 only) 7 * it under the terms of the GNU General Public License (version 2 only)
@@ -347,6 +347,7 @@ static void kvm_s390_vcpu_initial_reset(struct kvm_vcpu *vcpu)
347 vcpu->arch.guest_fpregs.fpc = 0; 347 vcpu->arch.guest_fpregs.fpc = 0;
348 asm volatile("lfpc %0" : : "Q" (vcpu->arch.guest_fpregs.fpc)); 348 asm volatile("lfpc %0" : : "Q" (vcpu->arch.guest_fpregs.fpc));
349 vcpu->arch.sie_block->gbea = 1; 349 vcpu->arch.sie_block->gbea = 1;
350 atomic_set_mask(CPUSTAT_STOPPED, &vcpu->arch.sie_block->cpuflags);
350} 351}
351 352
352int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) 353int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
index 2294377975e..d75bc5e92c5 100644
--- a/arch/s390/kvm/kvm-s390.h
+++ b/arch/s390/kvm/kvm-s390.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * kvm_s390.h - definition for kvm on s390 2 * definition for kvm on s390
3 * 3 *
4 * Copyright IBM Corp. 2008,2009 4 * Copyright IBM Corp. 2008, 2009
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License (version 2 only) 7 * it under the terms of the GNU General Public License (version 2 only)
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index 68a6b2ed16b..60da903d6f3 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * priv.c - handling privileged instructions 2 * handling privileged instructions
3 * 3 *
4 * Copyright IBM Corp. 2008 4 * Copyright IBM Corp. 2008
5 * 5 *
diff --git a/arch/s390/kvm/sigp.c b/arch/s390/kvm/sigp.c
index 0ad4cf23839..56f80e1f98f 100644
--- a/arch/s390/kvm/sigp.c
+++ b/arch/s390/kvm/sigp.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * sigp.c - handlinge interprocessor communication 2 * handling interprocessor communication
3 * 3 *
4 * Copyright IBM Corp. 2008,2009 4 * Copyright IBM Corp. 2008, 2009
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License (version 2 only) 7 * it under the terms of the GNU General Public License (version 2 only)
@@ -15,38 +15,10 @@
15#include <linux/kvm.h> 15#include <linux/kvm.h>
16#include <linux/kvm_host.h> 16#include <linux/kvm_host.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <asm/sigp.h>
18#include "gaccess.h" 19#include "gaccess.h"
19#include "kvm-s390.h" 20#include "kvm-s390.h"
20 21
21/* sigp order codes */
22#define SIGP_SENSE 0x01
23#define SIGP_EXTERNAL_CALL 0x02
24#define SIGP_EMERGENCY 0x03
25#define SIGP_START 0x04
26#define SIGP_STOP 0x05
27#define SIGP_RESTART 0x06
28#define SIGP_STOP_STORE_STATUS 0x09
29#define SIGP_INITIAL_CPU_RESET 0x0b
30#define SIGP_CPU_RESET 0x0c
31#define SIGP_SET_PREFIX 0x0d
32#define SIGP_STORE_STATUS_ADDR 0x0e
33#define SIGP_SET_ARCH 0x12
34#define SIGP_SENSE_RUNNING 0x15
35
36/* cpu status bits */
37#define SIGP_STAT_EQUIPMENT_CHECK 0x80000000UL
38#define SIGP_STAT_NOT_RUNNING 0x00000400UL
39#define SIGP_STAT_INCORRECT_STATE 0x00000200UL
40#define SIGP_STAT_INVALID_PARAMETER 0x00000100UL
41#define SIGP_STAT_EXT_CALL_PENDING 0x00000080UL
42#define SIGP_STAT_STOPPED 0x00000040UL
43#define SIGP_STAT_OPERATOR_INTERV 0x00000020UL
44#define SIGP_STAT_CHECK_STOP 0x00000010UL
45#define SIGP_STAT_INOPERATIVE 0x00000004UL
46#define SIGP_STAT_INVALID_ORDER 0x00000002UL
47#define SIGP_STAT_RECEIVER_CHECK 0x00000001UL
48
49
50static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr, 22static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr,
51 u64 *reg) 23 u64 *reg)
52{ 24{
@@ -54,19 +26,23 @@ static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr,
54 int rc; 26 int rc;
55 27
56 if (cpu_addr >= KVM_MAX_VCPUS) 28 if (cpu_addr >= KVM_MAX_VCPUS)
57 return 3; /* not operational */ 29 return SIGP_CC_NOT_OPERATIONAL;
58 30
59 spin_lock(&fi->lock); 31 spin_lock(&fi->lock);
60 if (fi->local_int[cpu_addr] == NULL) 32 if (fi->local_int[cpu_addr] == NULL)
61 rc = 3; /* not operational */ 33 rc = SIGP_CC_NOT_OPERATIONAL;
62 else if (!(atomic_read(fi->local_int[cpu_addr]->cpuflags) 34 else if (!(atomic_read(fi->local_int[cpu_addr]->cpuflags)
63 & CPUSTAT_STOPPED)) { 35 & (CPUSTAT_ECALL_PEND | CPUSTAT_STOPPED)))
64 *reg &= 0xffffffff00000000UL; 36 rc = SIGP_CC_ORDER_CODE_ACCEPTED;
65 rc = 1; /* status stored */ 37 else {
66 } else {
67 *reg &= 0xffffffff00000000UL; 38 *reg &= 0xffffffff00000000UL;
68 *reg |= SIGP_STAT_STOPPED; 39 if (atomic_read(fi->local_int[cpu_addr]->cpuflags)
69 rc = 1; /* status stored */ 40 & CPUSTAT_ECALL_PEND)
41 *reg |= SIGP_STATUS_EXT_CALL_PENDING;
42 if (atomic_read(fi->local_int[cpu_addr]->cpuflags)
43 & CPUSTAT_STOPPED)
44 *reg |= SIGP_STATUS_STOPPED;
45 rc = SIGP_CC_STATUS_STORED;
70 } 46 }
71 spin_unlock(&fi->lock); 47 spin_unlock(&fi->lock);
72 48
@@ -82,7 +58,7 @@ static int __sigp_emergency(struct kvm_vcpu *vcpu, u16 cpu_addr)
82 int rc; 58 int rc;
83 59
84 if (cpu_addr >= KVM_MAX_VCPUS) 60 if (cpu_addr >= KVM_MAX_VCPUS)
85 return 3; /* not operational */ 61 return SIGP_CC_NOT_OPERATIONAL;
86 62
87 inti = kzalloc(sizeof(*inti), GFP_KERNEL); 63 inti = kzalloc(sizeof(*inti), GFP_KERNEL);
88 if (!inti) 64 if (!inti)
@@ -94,7 +70,7 @@ static int __sigp_emergency(struct kvm_vcpu *vcpu, u16 cpu_addr)
94 spin_lock(&fi->lock); 70 spin_lock(&fi->lock);
95 li = fi->local_int[cpu_addr]; 71 li = fi->local_int[cpu_addr];
96 if (li == NULL) { 72 if (li == NULL) {
97 rc = 3; /* not operational */ 73 rc = SIGP_CC_NOT_OPERATIONAL;
98 kfree(inti); 74 kfree(inti);
99 goto unlock; 75 goto unlock;
100 } 76 }
@@ -105,7 +81,7 @@ static int __sigp_emergency(struct kvm_vcpu *vcpu, u16 cpu_addr)
105 if (waitqueue_active(&li->wq)) 81 if (waitqueue_active(&li->wq))
106 wake_up_interruptible(&li->wq); 82 wake_up_interruptible(&li->wq);
107 spin_unlock_bh(&li->lock); 83 spin_unlock_bh(&li->lock);
108 rc = 0; /* order accepted */ 84 rc = SIGP_CC_ORDER_CODE_ACCEPTED;
109 VCPU_EVENT(vcpu, 4, "sent sigp emerg to cpu %x", cpu_addr); 85 VCPU_EVENT(vcpu, 4, "sent sigp emerg to cpu %x", cpu_addr);
110unlock: 86unlock:
111 spin_unlock(&fi->lock); 87 spin_unlock(&fi->lock);
@@ -120,7 +96,7 @@ static int __sigp_external_call(struct kvm_vcpu *vcpu, u16 cpu_addr)
120 int rc; 96 int rc;
121 97
122 if (cpu_addr >= KVM_MAX_VCPUS) 98 if (cpu_addr >= KVM_MAX_VCPUS)
123 return 3; /* not operational */ 99 return SIGP_CC_NOT_OPERATIONAL;
124 100
125 inti = kzalloc(sizeof(*inti), GFP_KERNEL); 101 inti = kzalloc(sizeof(*inti), GFP_KERNEL);
126 if (!inti) 102 if (!inti)
@@ -132,7 +108,7 @@ static int __sigp_external_call(struct kvm_vcpu *vcpu, u16 cpu_addr)
132 spin_lock(&fi->lock); 108 spin_lock(&fi->lock);
133 li = fi->local_int[cpu_addr]; 109 li = fi->local_int[cpu_addr];
134 if (li == NULL) { 110 if (li == NULL) {
135 rc = 3; /* not operational */ 111 rc = SIGP_CC_NOT_OPERATIONAL;
136 kfree(inti); 112 kfree(inti);
137 goto unlock; 113 goto unlock;
138 } 114 }
@@ -143,7 +119,7 @@ static int __sigp_external_call(struct kvm_vcpu *vcpu, u16 cpu_addr)
143 if (waitqueue_active(&li->wq)) 119 if (waitqueue_active(&li->wq))
144 wake_up_interruptible(&li->wq); 120 wake_up_interruptible(&li->wq);
145 spin_unlock_bh(&li->lock); 121 spin_unlock_bh(&li->lock);
146 rc = 0; /* order accepted */ 122 rc = SIGP_CC_ORDER_CODE_ACCEPTED;
147 VCPU_EVENT(vcpu, 4, "sent sigp ext call to cpu %x", cpu_addr); 123 VCPU_EVENT(vcpu, 4, "sent sigp ext call to cpu %x", cpu_addr);
148unlock: 124unlock:
149 spin_unlock(&fi->lock); 125 spin_unlock(&fi->lock);
@@ -171,7 +147,7 @@ static int __inject_sigp_stop(struct kvm_s390_local_interrupt *li, int action)
171out: 147out:
172 spin_unlock_bh(&li->lock); 148 spin_unlock_bh(&li->lock);
173 149
174 return 0; /* order accepted */ 150 return SIGP_CC_ORDER_CODE_ACCEPTED;
175} 151}
176 152
177static int __sigp_stop(struct kvm_vcpu *vcpu, u16 cpu_addr, int action) 153static int __sigp_stop(struct kvm_vcpu *vcpu, u16 cpu_addr, int action)
@@ -181,12 +157,12 @@ static int __sigp_stop(struct kvm_vcpu *vcpu, u16 cpu_addr, int action)
181 int rc; 157 int rc;
182 158
183 if (cpu_addr >= KVM_MAX_VCPUS) 159 if (cpu_addr >= KVM_MAX_VCPUS)
184 return 3; /* not operational */ 160 return SIGP_CC_NOT_OPERATIONAL;
185 161
186 spin_lock(&fi->lock); 162 spin_lock(&fi->lock);
187 li = fi->local_int[cpu_addr]; 163 li = fi->local_int[cpu_addr];
188 if (li == NULL) { 164 if (li == NULL) {
189 rc = 3; /* not operational */ 165 rc = SIGP_CC_NOT_OPERATIONAL;
190 goto unlock; 166 goto unlock;
191 } 167 }
192 168
@@ -210,11 +186,11 @@ static int __sigp_set_arch(struct kvm_vcpu *vcpu, u32 parameter)
210 186
211 switch (parameter & 0xff) { 187 switch (parameter & 0xff) {
212 case 0: 188 case 0:
213 rc = 3; /* not operational */ 189 rc = SIGP_CC_NOT_OPERATIONAL;
214 break; 190 break;
215 case 1: 191 case 1:
216 case 2: 192 case 2:
217 rc = 0; /* order accepted */ 193 rc = SIGP_CC_ORDER_CODE_ACCEPTED;
218 break; 194 break;
219 default: 195 default:
220 rc = -EOPNOTSUPP; 196 rc = -EOPNOTSUPP;
@@ -235,21 +211,23 @@ static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address,
235 address = address & 0x7fffe000u; 211 address = address & 0x7fffe000u;
236 if (copy_from_guest_absolute(vcpu, &tmp, address, 1) || 212 if (copy_from_guest_absolute(vcpu, &tmp, address, 1) ||
237 copy_from_guest_absolute(vcpu, &tmp, address + PAGE_SIZE, 1)) { 213 copy_from_guest_absolute(vcpu, &tmp, address + PAGE_SIZE, 1)) {
238 *reg |= SIGP_STAT_INVALID_PARAMETER; 214 *reg &= 0xffffffff00000000UL;
239 return 1; /* invalid parameter */ 215 *reg |= SIGP_STATUS_INVALID_PARAMETER;
216 return SIGP_CC_STATUS_STORED;
240 } 217 }
241 218
242 inti = kzalloc(sizeof(*inti), GFP_KERNEL); 219 inti = kzalloc(sizeof(*inti), GFP_KERNEL);
243 if (!inti) 220 if (!inti)
244 return 2; /* busy */ 221 return SIGP_CC_BUSY;
245 222
246 spin_lock(&fi->lock); 223 spin_lock(&fi->lock);
247 if (cpu_addr < KVM_MAX_VCPUS) 224 if (cpu_addr < KVM_MAX_VCPUS)
248 li = fi->local_int[cpu_addr]; 225 li = fi->local_int[cpu_addr];
249 226
250 if (li == NULL) { 227 if (li == NULL) {
251 rc = 1; /* incorrect state */ 228 *reg &= 0xffffffff00000000UL;
252 *reg &= SIGP_STAT_INCORRECT_STATE; 229 *reg |= SIGP_STATUS_INCORRECT_STATE;
230 rc = SIGP_CC_STATUS_STORED;
253 kfree(inti); 231 kfree(inti);
254 goto out_fi; 232 goto out_fi;
255 } 233 }
@@ -257,8 +235,9 @@ static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address,
257 spin_lock_bh(&li->lock); 235 spin_lock_bh(&li->lock);
258 /* cpu must be in stopped state */ 236 /* cpu must be in stopped state */
259 if (!(atomic_read(li->cpuflags) & CPUSTAT_STOPPED)) { 237 if (!(atomic_read(li->cpuflags) & CPUSTAT_STOPPED)) {
260 rc = 1; /* incorrect state */ 238 *reg &= 0xffffffff00000000UL;
261 *reg &= SIGP_STAT_INCORRECT_STATE; 239 *reg |= SIGP_STATUS_INCORRECT_STATE;
240 rc = SIGP_CC_STATUS_STORED;
262 kfree(inti); 241 kfree(inti);
263 goto out_li; 242 goto out_li;
264 } 243 }
@@ -270,7 +249,7 @@ static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address,
270 atomic_set(&li->active, 1); 249 atomic_set(&li->active, 1);
271 if (waitqueue_active(&li->wq)) 250 if (waitqueue_active(&li->wq))
272 wake_up_interruptible(&li->wq); 251 wake_up_interruptible(&li->wq);
273 rc = 0; /* order accepted */ 252 rc = SIGP_CC_ORDER_CODE_ACCEPTED;
274 253
275 VCPU_EVENT(vcpu, 4, "set prefix of cpu %02x to %x", cpu_addr, address); 254 VCPU_EVENT(vcpu, 4, "set prefix of cpu %02x to %x", cpu_addr, address);
276out_li: 255out_li:
@@ -287,21 +266,21 @@ static int __sigp_sense_running(struct kvm_vcpu *vcpu, u16 cpu_addr,
287 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int; 266 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
288 267
289 if (cpu_addr >= KVM_MAX_VCPUS) 268 if (cpu_addr >= KVM_MAX_VCPUS)
290 return 3; /* not operational */ 269 return SIGP_CC_NOT_OPERATIONAL;
291 270
292 spin_lock(&fi->lock); 271 spin_lock(&fi->lock);
293 if (fi->local_int[cpu_addr] == NULL) 272 if (fi->local_int[cpu_addr] == NULL)
294 rc = 3; /* not operational */ 273 rc = SIGP_CC_NOT_OPERATIONAL;
295 else { 274 else {
296 if (atomic_read(fi->local_int[cpu_addr]->cpuflags) 275 if (atomic_read(fi->local_int[cpu_addr]->cpuflags)
297 & CPUSTAT_RUNNING) { 276 & CPUSTAT_RUNNING) {
298 /* running */ 277 /* running */
299 rc = 1; 278 rc = SIGP_CC_ORDER_CODE_ACCEPTED;
300 } else { 279 } else {
301 /* not running */ 280 /* not running */
302 *reg &= 0xffffffff00000000UL; 281 *reg &= 0xffffffff00000000UL;
303 *reg |= SIGP_STAT_NOT_RUNNING; 282 *reg |= SIGP_STATUS_NOT_RUNNING;
304 rc = 0; 283 rc = SIGP_CC_STATUS_STORED;
305 } 284 }
306 } 285 }
307 spin_unlock(&fi->lock); 286 spin_unlock(&fi->lock);
@@ -314,23 +293,23 @@ static int __sigp_sense_running(struct kvm_vcpu *vcpu, u16 cpu_addr,
314 293
315static int __sigp_restart(struct kvm_vcpu *vcpu, u16 cpu_addr) 294static int __sigp_restart(struct kvm_vcpu *vcpu, u16 cpu_addr)
316{ 295{
317 int rc = 0;
318 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int; 296 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
319 struct kvm_s390_local_interrupt *li; 297 struct kvm_s390_local_interrupt *li;
298 int rc = SIGP_CC_ORDER_CODE_ACCEPTED;
320 299
321 if (cpu_addr >= KVM_MAX_VCPUS) 300 if (cpu_addr >= KVM_MAX_VCPUS)
322 return 3; /* not operational */ 301 return SIGP_CC_NOT_OPERATIONAL;
323 302
324 spin_lock(&fi->lock); 303 spin_lock(&fi->lock);
325 li = fi->local_int[cpu_addr]; 304 li = fi->local_int[cpu_addr];
326 if (li == NULL) { 305 if (li == NULL) {
327 rc = 3; /* not operational */ 306 rc = SIGP_CC_NOT_OPERATIONAL;
328 goto out; 307 goto out;
329 } 308 }
330 309
331 spin_lock_bh(&li->lock); 310 spin_lock_bh(&li->lock);
332 if (li->action_bits & ACTION_STOP_ON_STOP) 311 if (li->action_bits & ACTION_STOP_ON_STOP)
333 rc = 2; /* busy */ 312 rc = SIGP_CC_BUSY;
334 else 313 else
335 VCPU_EVENT(vcpu, 4, "sigp restart %x to handle userspace", 314 VCPU_EVENT(vcpu, 4, "sigp restart %x to handle userspace",
336 cpu_addr); 315 cpu_addr);
@@ -375,7 +354,7 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)
375 vcpu->stat.instruction_sigp_external_call++; 354 vcpu->stat.instruction_sigp_external_call++;
376 rc = __sigp_external_call(vcpu, cpu_addr); 355 rc = __sigp_external_call(vcpu, cpu_addr);
377 break; 356 break;
378 case SIGP_EMERGENCY: 357 case SIGP_EMERGENCY_SIGNAL:
379 vcpu->stat.instruction_sigp_emergency++; 358 vcpu->stat.instruction_sigp_emergency++;
380 rc = __sigp_emergency(vcpu, cpu_addr); 359 rc = __sigp_emergency(vcpu, cpu_addr);
381 break; 360 break;
@@ -383,12 +362,12 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)
383 vcpu->stat.instruction_sigp_stop++; 362 vcpu->stat.instruction_sigp_stop++;
384 rc = __sigp_stop(vcpu, cpu_addr, ACTION_STOP_ON_STOP); 363 rc = __sigp_stop(vcpu, cpu_addr, ACTION_STOP_ON_STOP);
385 break; 364 break;
386 case SIGP_STOP_STORE_STATUS: 365 case SIGP_STOP_AND_STORE_STATUS:
387 vcpu->stat.instruction_sigp_stop++; 366 vcpu->stat.instruction_sigp_stop++;
388 rc = __sigp_stop(vcpu, cpu_addr, ACTION_STORE_ON_STOP | 367 rc = __sigp_stop(vcpu, cpu_addr, ACTION_STORE_ON_STOP |
389 ACTION_STOP_ON_STOP); 368 ACTION_STOP_ON_STOP);
390 break; 369 break;
391 case SIGP_SET_ARCH: 370 case SIGP_SET_ARCHITECTURE:
392 vcpu->stat.instruction_sigp_arch++; 371 vcpu->stat.instruction_sigp_arch++;
393 rc = __sigp_set_arch(vcpu, parameter); 372 rc = __sigp_set_arch(vcpu, parameter);
394 break; 373 break;
@@ -405,7 +384,7 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)
405 case SIGP_RESTART: 384 case SIGP_RESTART:
406 vcpu->stat.instruction_sigp_restart++; 385 vcpu->stat.instruction_sigp_restart++;
407 rc = __sigp_restart(vcpu, cpu_addr); 386 rc = __sigp_restart(vcpu, cpu_addr);
408 if (rc == 2) /* busy */ 387 if (rc == SIGP_CC_BUSY)
409 break; 388 break;
410 /* user space must know about restart */ 389 /* user space must know about restart */
411 default: 390 default:
diff --git a/arch/s390/lib/delay.c b/arch/s390/lib/delay.c
index 9f1f71e8577..42d0cf89121 100644
--- a/arch/s390/lib/delay.c
+++ b/arch/s390/lib/delay.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Precise Delay Loops for S390 2 * Precise Delay Loops for S390
3 * 3 *
4 * Copyright IBM Corp. 1999,2008 4 * Copyright IBM Corp. 1999, 2008
5 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>, 5 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>,
6 * Heiko Carstens <heiko.carstens@de.ibm.com>, 6 * Heiko Carstens <heiko.carstens@de.ibm.com>,
7 */ 7 */
@@ -12,8 +12,8 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/irqflags.h> 13#include <linux/irqflags.h>
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <asm/vtimer.h>
15#include <asm/div64.h> 16#include <asm/div64.h>
16#include <asm/timer.h>
17 17
18void __delay(unsigned long loops) 18void __delay(unsigned long loops)
19{ 19{
diff --git a/arch/s390/lib/div64.c b/arch/s390/lib/div64.c
index d9e62c0b576..261152f8324 100644
--- a/arch/s390/lib/div64.c
+++ b/arch/s390/lib/div64.c
@@ -1,9 +1,7 @@
1/* 1/*
2 * arch/s390/lib/div64.c
3 *
4 * __div64_32 implementation for 31 bit. 2 * __div64_32 implementation for 31 bit.
5 * 3 *
6 * Copyright (C) IBM Corp. 2006 4 * Copyright IBM Corp. 2006
7 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
8 */ 6 */
9 7
diff --git a/arch/s390/lib/spinlock.c b/arch/s390/lib/spinlock.c
index 093eb694d9c..f709983f41f 100644
--- a/arch/s390/lib/spinlock.c
+++ b/arch/s390/lib/spinlock.c
@@ -1,8 +1,7 @@
1/* 1/*
2 * arch/s390/lib/spinlock.c
3 * Out of line spinlock code. 2 * Out of line spinlock code.
4 * 3 *
5 * Copyright (C) IBM Corp. 2004, 2006 4 * Copyright IBM Corp. 2004, 2006
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 */ 6 */
8 7
diff --git a/arch/s390/lib/string.c b/arch/s390/lib/string.c
index 4143b7c1909..846ec64ab2c 100644
--- a/arch/s390/lib/string.c
+++ b/arch/s390/lib/string.c
@@ -1,9 +1,8 @@
1/* 1/*
2 * arch/s390/lib/string.c
3 * Optimized string functions 2 * Optimized string functions
4 * 3 *
5 * S390 version 4 * S390 version
6 * Copyright (C) 2004 IBM Deutschland Entwicklung GmbH, IBM Corporation 5 * Copyright IBM Corp. 2004
7 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
8 */ 7 */
9 8
diff --git a/arch/s390/lib/uaccess.h b/arch/s390/lib/uaccess.h
index 1d2536cb630..315dbe09983 100644
--- a/arch/s390/lib/uaccess.h
+++ b/arch/s390/lib/uaccess.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/s390/uaccess.h
3 *
4 * Copyright IBM Corp. 2007 2 * Copyright IBM Corp. 2007
5 * 3 *
6 */ 4 */
diff --git a/arch/s390/lib/uaccess_mvcos.c b/arch/s390/lib/uaccess_mvcos.c
index 58a75a8ae90..2443ae476e3 100644
--- a/arch/s390/lib/uaccess_mvcos.c
+++ b/arch/s390/lib/uaccess_mvcos.c
@@ -1,9 +1,7 @@
1/* 1/*
2 * arch/s390/lib/uaccess_mvcos.c
3 *
4 * Optimized user space space access functions based on mvcos. 2 * Optimized user space space access functions based on mvcos.
5 * 3 *
6 * Copyright (C) IBM Corp. 2006 4 * Copyright IBM Corp. 2006
7 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
8 * Gerald Schaefer (gerald.schaefer@de.ibm.com) 6 * Gerald Schaefer (gerald.schaefer@de.ibm.com)
9 */ 7 */
diff --git a/arch/s390/lib/uaccess_pt.c b/arch/s390/lib/uaccess_pt.c
index 342ae35a5ba..60ee2b88379 100644
--- a/arch/s390/lib/uaccess_pt.c
+++ b/arch/s390/lib/uaccess_pt.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/s390/lib/uaccess_pt.c
3 *
4 * User access functions based on page table walks for enhanced 2 * User access functions based on page table walks for enhanced
5 * system layout without hardware support. 3 * system layout without hardware support.
6 * 4 *
diff --git a/arch/s390/lib/uaccess_std.c b/arch/s390/lib/uaccess_std.c
index 57e94298539..6fbd0633827 100644
--- a/arch/s390/lib/uaccess_std.c
+++ b/arch/s390/lib/uaccess_std.c
@@ -1,10 +1,8 @@
1/* 1/*
2 * arch/s390/lib/uaccess_std.c
3 *
4 * Standard user space access functions based on mvcp/mvcs and doing 2 * Standard user space access functions based on mvcp/mvcs and doing
5 * interesting things in the secondary space mode. 3 * interesting things in the secondary space mode.
6 * 4 *
7 * Copyright (C) IBM Corp. 2006 5 * Copyright IBM Corp. 2006
8 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
9 * Gerald Schaefer (gerald.schaefer@de.ibm.com) 7 * Gerald Schaefer (gerald.schaefer@de.ibm.com)
10 */ 8 */
diff --git a/arch/s390/math-emu/math.c b/arch/s390/math-emu/math.c
index cd4e9c168dd..58bff541fde 100644
--- a/arch/s390/math-emu/math.c
+++ b/arch/s390/math-emu/math.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * arch/s390/math-emu/math.c
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999-2001 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999, 2001
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 4 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
7 * 5 *
8 * 'math.c' emulates IEEE instructions on a S390 processor 6 * 'math.c' emulates IEEE instructions on a S390 processor
diff --git a/arch/s390/mm/cmm.c b/arch/s390/mm/cmm.c
index 1f1dba9dcf5..479e9428291 100644
--- a/arch/s390/mm/cmm.c
+++ b/arch/s390/mm/cmm.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Collaborative memory management interface. 2 * Collaborative memory management interface.
3 * 3 *
4 * Copyright IBM Corp 2003,2010 4 * Copyright IBM Corp 2003, 2010
5 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>, 5 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>,
6 * 6 *
7 */ 7 */
diff --git a/arch/s390/mm/extmem.c b/arch/s390/mm/extmem.c
index 075ddada491..519bba716cc 100644
--- a/arch/s390/mm/extmem.c
+++ b/arch/s390/mm/extmem.c
@@ -1,10 +1,9 @@
1/* 1/*
2 * File...........: arch/s390/mm/extmem.c
3 * Author(s)......: Carsten Otte <cotte@de.ibm.com> 2 * Author(s)......: Carsten Otte <cotte@de.ibm.com>
4 * Rob M van der Heij <rvdheij@nl.ibm.com> 3 * Rob M van der Heij <rvdheij@nl.ibm.com>
5 * Steven Shultz <shultzss@us.ibm.com> 4 * Steven Shultz <shultzss@us.ibm.com>
6 * Bugreports.to..: <Linux390@de.ibm.com> 5 * Bugreports.to..: <Linux390@de.ibm.com>
7 * (C) IBM Corporation 2002-2004 6 * Copyright IBM Corp. 2002, 2004
8 */ 7 */
9 8
10#define KMSG_COMPONENT "extmem" 9#define KMSG_COMPONENT "extmem"
diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
index 72cec9ecd96..6c013f54414 100644
--- a/arch/s390/mm/fault.c
+++ b/arch/s390/mm/fault.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * arch/s390/mm/fault.c
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999
6 * Author(s): Hartmut Penner (hp@de.ibm.com) 4 * Author(s): Hartmut Penner (hp@de.ibm.com)
7 * Ulrich Weigand (uweigand@de.ibm.com) 5 * Ulrich Weigand (uweigand@de.ibm.com)
8 * 6 *
@@ -51,6 +49,7 @@
51#define VM_FAULT_BADCONTEXT 0x010000 49#define VM_FAULT_BADCONTEXT 0x010000
52#define VM_FAULT_BADMAP 0x020000 50#define VM_FAULT_BADMAP 0x020000
53#define VM_FAULT_BADACCESS 0x040000 51#define VM_FAULT_BADACCESS 0x040000
52#define VM_FAULT_SIGNAL 0x080000
54 53
55static unsigned long store_indication; 54static unsigned long store_indication;
56 55
@@ -112,7 +111,7 @@ static inline int user_space_fault(unsigned long trans_exc_code)
112 if (trans_exc_code == 2) 111 if (trans_exc_code == 2)
113 /* Access via secondary space, set_fs setting decides */ 112 /* Access via secondary space, set_fs setting decides */
114 return current->thread.mm_segment.ar4; 113 return current->thread.mm_segment.ar4;
115 if (user_mode == HOME_SPACE_MODE) 114 if (addressing_mode == HOME_SPACE_MODE)
116 /* User space if the access has been done via home space. */ 115 /* User space if the access has been done via home space. */
117 return trans_exc_code == 3; 116 return trans_exc_code == 3;
118 /* 117 /*
@@ -221,7 +220,7 @@ static noinline void do_fault_error(struct pt_regs *regs, int fault)
221 case VM_FAULT_BADACCESS: 220 case VM_FAULT_BADACCESS:
222 case VM_FAULT_BADMAP: 221 case VM_FAULT_BADMAP:
223 /* Bad memory access. Check if it is kernel or user space. */ 222 /* Bad memory access. Check if it is kernel or user space. */
224 if (regs->psw.mask & PSW_MASK_PSTATE) { 223 if (user_mode(regs)) {
225 /* User mode accesses just cause a SIGSEGV */ 224 /* User mode accesses just cause a SIGSEGV */
226 si_code = (fault == VM_FAULT_BADMAP) ? 225 si_code = (fault == VM_FAULT_BADMAP) ?
227 SEGV_MAPERR : SEGV_ACCERR; 226 SEGV_MAPERR : SEGV_ACCERR;
@@ -231,15 +230,19 @@ static noinline void do_fault_error(struct pt_regs *regs, int fault)
231 case VM_FAULT_BADCONTEXT: 230 case VM_FAULT_BADCONTEXT:
232 do_no_context(regs); 231 do_no_context(regs);
233 break; 232 break;
233 case VM_FAULT_SIGNAL:
234 if (!user_mode(regs))
235 do_no_context(regs);
236 break;
234 default: /* fault & VM_FAULT_ERROR */ 237 default: /* fault & VM_FAULT_ERROR */
235 if (fault & VM_FAULT_OOM) { 238 if (fault & VM_FAULT_OOM) {
236 if (!(regs->psw.mask & PSW_MASK_PSTATE)) 239 if (!user_mode(regs))
237 do_no_context(regs); 240 do_no_context(regs);
238 else 241 else
239 pagefault_out_of_memory(); 242 pagefault_out_of_memory();
240 } else if (fault & VM_FAULT_SIGBUS) { 243 } else if (fault & VM_FAULT_SIGBUS) {
241 /* Kernel mode? Handle exceptions or die */ 244 /* Kernel mode? Handle exceptions or die */
242 if (!(regs->psw.mask & PSW_MASK_PSTATE)) 245 if (!user_mode(regs))
243 do_no_context(regs); 246 do_no_context(regs);
244 else 247 else
245 do_sigbus(regs); 248 do_sigbus(regs);
@@ -288,7 +291,7 @@ static inline int do_exception(struct pt_regs *regs, int access)
288 291
289 address = trans_exc_code & __FAIL_ADDR_MASK; 292 address = trans_exc_code & __FAIL_ADDR_MASK;
290 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); 293 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
291 flags = FAULT_FLAG_ALLOW_RETRY; 294 flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
292 if (access == VM_WRITE || (trans_exc_code & store_indication) == 0x400) 295 if (access == VM_WRITE || (trans_exc_code & store_indication) == 0x400)
293 flags |= FAULT_FLAG_WRITE; 296 flags |= FAULT_FLAG_WRITE;
294 down_read(&mm->mmap_sem); 297 down_read(&mm->mmap_sem);
@@ -337,6 +340,11 @@ retry:
337 * the fault. 340 * the fault.
338 */ 341 */
339 fault = handle_mm_fault(mm, vma, address, flags); 342 fault = handle_mm_fault(mm, vma, address, flags);
343 /* No reason to continue if interrupted by SIGKILL. */
344 if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) {
345 fault = VM_FAULT_SIGNAL;
346 goto out;
347 }
340 if (unlikely(fault & VM_FAULT_ERROR)) 348 if (unlikely(fault & VM_FAULT_ERROR))
341 goto out_up; 349 goto out_up;
342 350
@@ -428,7 +436,7 @@ void __kprobes do_asce_exception(struct pt_regs *regs)
428 } 436 }
429 437
430 /* User mode accesses just cause a SIGSEGV */ 438 /* User mode accesses just cause a SIGSEGV */
431 if (regs->psw.mask & PSW_MASK_PSTATE) { 439 if (user_mode(regs)) {
432 do_sigsegv(regs, SEGV_MAPERR); 440 do_sigsegv(regs, SEGV_MAPERR);
433 return; 441 return;
434 } 442 }
@@ -443,6 +451,7 @@ int __handle_fault(unsigned long uaddr, unsigned long pgm_int_code, int write)
443 struct pt_regs regs; 451 struct pt_regs regs;
444 int access, fault; 452 int access, fault;
445 453
454 /* Emulate a uaccess fault from kernel mode. */
446 regs.psw.mask = psw_kernel_bits | PSW_MASK_DAT | PSW_MASK_MCHECK; 455 regs.psw.mask = psw_kernel_bits | PSW_MASK_DAT | PSW_MASK_MCHECK;
447 if (!irqs_disabled()) 456 if (!irqs_disabled())
448 regs.psw.mask |= PSW_MASK_IO | PSW_MASK_EXT; 457 regs.psw.mask |= PSW_MASK_IO | PSW_MASK_EXT;
@@ -452,12 +461,12 @@ int __handle_fault(unsigned long uaddr, unsigned long pgm_int_code, int write)
452 regs.int_parm_long = (uaddr & PAGE_MASK) | 2; 461 regs.int_parm_long = (uaddr & PAGE_MASK) | 2;
453 access = write ? VM_WRITE : VM_READ; 462 access = write ? VM_WRITE : VM_READ;
454 fault = do_exception(&regs, access); 463 fault = do_exception(&regs, access);
455 if (unlikely(fault)) { 464 /*
456 if (fault & VM_FAULT_OOM) 465 * Since the fault happened in kernel mode while performing a uaccess
457 return -EFAULT; 466 * all we need to do now is emulating a fixup in case "fault" is not
458 else if (fault & VM_FAULT_SIGBUS) 467 * zero.
459 do_sigbus(&regs); 468 * For the calling uaccess functions this results always in -EFAULT.
460 } 469 */
461 return fault ? -EFAULT : 0; 470 return fault ? -EFAULT : 0;
462} 471}
463 472
diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c
index 900de2b3cf2..532525ec88c 100644
--- a/arch/s390/mm/hugetlbpage.c
+++ b/arch/s390/mm/hugetlbpage.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * IBM System z Huge TLB Page Support for Kernel. 2 * IBM System z Huge TLB Page Support for Kernel.
3 * 3 *
4 * Copyright 2007 IBM Corp. 4 * Copyright IBM Corp. 2007
5 * Author(s): Gerald Schaefer <gerald.schaefer@de.ibm.com> 5 * Author(s): Gerald Schaefer <gerald.schaefer@de.ibm.com>
6 */ 6 */
7 7
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index 2bea0605856..6adbc082618 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * arch/s390/mm/init.c
3 *
4 * S390 version 2 * S390 version
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 1999
6 * Author(s): Hartmut Penner (hp@de.ibm.com) 4 * Author(s): Hartmut Penner (hp@de.ibm.com)
7 * 5 *
8 * Derived from "arch/i386/mm/init.c" 6 * Derived from "arch/i386/mm/init.c"
diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
index 2857c48486e..c59a5efa58b 100644
--- a/arch/s390/mm/mmap.c
+++ b/arch/s390/mm/mmap.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/s390/mm/mmap.c
3 *
4 * flexible mmap layout support 2 * flexible mmap layout support
5 * 3 *
6 * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina. 4 * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
@@ -105,9 +103,15 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
105 103
106int s390_mmap_check(unsigned long addr, unsigned long len) 104int s390_mmap_check(unsigned long addr, unsigned long len)
107{ 105{
106 int rc;
107
108 if (!is_compat_task() && 108 if (!is_compat_task() &&
109 len >= TASK_SIZE && TASK_SIZE < (1UL << 53)) 109 len >= TASK_SIZE && TASK_SIZE < (1UL << 53)) {
110 return crst_table_upgrade(current->mm, 1UL << 53); 110 rc = crst_table_upgrade(current->mm, 1UL << 53);
111 if (rc)
112 return rc;
113 update_mm(current->mm, current);
114 }
111 return 0; 115 return 0;
112} 116}
113 117
@@ -127,6 +131,7 @@ s390_get_unmapped_area(struct file *filp, unsigned long addr,
127 rc = crst_table_upgrade(mm, 1UL << 53); 131 rc = crst_table_upgrade(mm, 1UL << 53);
128 if (rc) 132 if (rc)
129 return (unsigned long) rc; 133 return (unsigned long) rc;
134 update_mm(mm, current);
130 area = arch_get_unmapped_area(filp, addr, len, pgoff, flags); 135 area = arch_get_unmapped_area(filp, addr, len, pgoff, flags);
131 } 136 }
132 return area; 137 return area;
@@ -149,6 +154,7 @@ s390_get_unmapped_area_topdown(struct file *filp, const unsigned long addr,
149 rc = crst_table_upgrade(mm, 1UL << 53); 154 rc = crst_table_upgrade(mm, 1UL << 53);
150 if (rc) 155 if (rc)
151 return (unsigned long) rc; 156 return (unsigned long) rc;
157 update_mm(mm, current);
152 area = arch_get_unmapped_area_topdown(filp, addr, len, 158 area = arch_get_unmapped_area_topdown(filp, addr, len,
153 pgoff, flags); 159 pgoff, flags);
154 } 160 }
diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
index a3db5a3ea08..18df31d1f2c 100644
--- a/arch/s390/mm/pgtable.c
+++ b/arch/s390/mm/pgtable.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright IBM Corp. 2007,2011 2 * Copyright IBM Corp. 2007, 2011
3 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 3 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
4 */ 4 */
5 5
@@ -85,7 +85,6 @@ repeat:
85 crst_table_free(mm, table); 85 crst_table_free(mm, table);
86 if (mm->context.asce_limit < limit) 86 if (mm->context.asce_limit < limit)
87 goto repeat; 87 goto repeat;
88 update_mm(mm, current);
89 return 0; 88 return 0;
90} 89}
91 90
@@ -93,9 +92,6 @@ void crst_table_downgrade(struct mm_struct *mm, unsigned long limit)
93{ 92{
94 pgd_t *pgd; 93 pgd_t *pgd;
95 94
96 if (mm->context.asce_limit <= limit)
97 return;
98 __tlb_flush_mm(mm);
99 while (mm->context.asce_limit > limit) { 95 while (mm->context.asce_limit > limit) {
100 pgd = mm->pgd; 96 pgd = mm->pgd;
101 switch (pgd_val(*pgd) & _REGION_ENTRY_TYPE_MASK) { 97 switch (pgd_val(*pgd) & _REGION_ENTRY_TYPE_MASK) {
@@ -118,7 +114,6 @@ void crst_table_downgrade(struct mm_struct *mm, unsigned long limit)
118 mm->task_size = mm->context.asce_limit; 114 mm->task_size = mm->context.asce_limit;
119 crst_table_free(mm, (unsigned long *) pgd); 115 crst_table_free(mm, (unsigned long *) pgd);
120 } 116 }
121 update_mm(mm, current);
122} 117}
123#endif 118#endif
124 119
@@ -801,7 +796,7 @@ int s390_enable_sie(void)
801 struct mm_struct *mm, *old_mm; 796 struct mm_struct *mm, *old_mm;
802 797
803 /* Do we have switched amode? If no, we cannot do sie */ 798 /* Do we have switched amode? If no, we cannot do sie */
804 if (user_mode == HOME_SPACE_MODE) 799 if (addressing_mode == HOME_SPACE_MODE)
805 return -EINVAL; 800 return -EINVAL;
806 801
807 /* Do we have pgstes? if yes, we are done */ 802 /* Do we have pgstes? if yes, we are done */
diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c
index 71ae20df674..6f896e75ab4 100644
--- a/arch/s390/mm/vmem.c
+++ b/arch/s390/mm/vmem.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/s390/mm/vmem.c
3 *
4 * Copyright IBM Corp. 2006 2 * Copyright IBM Corp. 2006
5 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com> 3 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
6 */ 4 */
diff --git a/arch/s390/oprofile/backtrace.c b/arch/s390/oprofile/backtrace.c
index bc4b84a35ca..8a6811b2cdb 100644
--- a/arch/s390/oprofile/backtrace.c
+++ b/arch/s390/oprofile/backtrace.c
@@ -1,8 +1,6 @@
1/** 1/*
2 * arch/s390/oprofile/backtrace.c
3 *
4 * S390 Version 2 * S390 Version
5 * Copyright (C) 2005 IBM Corporation, IBM Deutschland Entwicklung GmbH. 3 * Copyright IBM Corp. 2005
6 * Author(s): Andreas Krebbel <Andreas.Krebbel@de.ibm.com> 4 * Author(s): Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
7 */ 5 */
8 6
@@ -60,7 +58,7 @@ void s390_backtrace(struct pt_regs * const regs, unsigned int depth)
60 unsigned long head; 58 unsigned long head;
61 struct stack_frame* head_sf; 59 struct stack_frame* head_sf;
62 60
63 if (user_mode (regs)) 61 if (user_mode(regs))
64 return; 62 return;
65 63
66 head = regs->gprs[15]; 64 head = regs->gprs[15];
diff --git a/arch/s390/oprofile/hwsampler.c b/arch/s390/oprofile/hwsampler.c
index a4a89fa980d..0cb385da202 100644
--- a/arch/s390/oprofile/hwsampler.c
+++ b/arch/s390/oprofile/hwsampler.c
@@ -1,6 +1,4 @@
1/** 1/*
2 * arch/s390/oprofile/hwsampler.c
3 *
4 * Copyright IBM Corp. 2010 2 * Copyright IBM Corp. 2010
5 * Author: Heinz Graalfs <graalfs@de.ibm.com> 3 * Author: Heinz Graalfs <graalfs@de.ibm.com>
6 */ 4 */
diff --git a/arch/s390/oprofile/init.c b/arch/s390/oprofile/init.c
index 2297be406c6..a1e9d69a9c9 100644
--- a/arch/s390/oprofile/init.c
+++ b/arch/s390/oprofile/init.c
@@ -1,8 +1,6 @@
1/** 1/*
2 * arch/s390/oprofile/init.c
3 *
4 * S390 Version 2 * S390 Version
5 * Copyright (C) 2002-2011 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright IBM Corp. 2002, 2011
6 * Author(s): Thomas Spatzier (tspat@de.ibm.com) 4 * Author(s): Thomas Spatzier (tspat@de.ibm.com)
7 * Author(s): Mahesh Salgaonkar (mahesh@linux.vnet.ibm.com) 5 * Author(s): Mahesh Salgaonkar (mahesh@linux.vnet.ibm.com)
8 * Author(s): Heinz Graalfs (graalfs@linux.vnet.ibm.com) 6 * Author(s): Heinz Graalfs (graalfs@linux.vnet.ibm.com)
diff --git a/arch/s390/oprofile/op_counter.h b/arch/s390/oprofile/op_counter.h
index 1a8d3ca0901..61b2531eef1 100644
--- a/arch/s390/oprofile/op_counter.h
+++ b/arch/s390/oprofile/op_counter.h
@@ -1,7 +1,5 @@
1/** 1/*
2 * arch/s390/oprofile/op_counter.h 2 * Copyright IBM Corp. 2011
3 *
4 * Copyright (C) 2011 IBM Deutschland Entwicklung GmbH, IBM Corporation
5 * Author(s): Andreas Krebbel (krebbel@linux.vnet.ibm.com) 3 * Author(s): Andreas Krebbel (krebbel@linux.vnet.ibm.com)
6 * 4 *
7 * @remark Copyright 2011 OProfile authors 5 * @remark Copyright 2011 OProfile authors
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 31d9db7913e..36f5141e804 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -21,6 +21,7 @@ config SUPERH
21 select HAVE_KERNEL_LZMA 21 select HAVE_KERNEL_LZMA
22 select HAVE_KERNEL_XZ 22 select HAVE_KERNEL_XZ
23 select HAVE_KERNEL_LZO 23 select HAVE_KERNEL_LZO
24 select ARCH_WANT_IPC_PARSE_VERSION
24 select HAVE_SYSCALL_TRACEPOINTS 25 select HAVE_SYSCALL_TRACEPOINTS
25 select HAVE_REGS_AND_STACK_ACCESS_API 26 select HAVE_REGS_AND_STACK_ACCESS_API
26 select HAVE_GENERIC_HARDIRQS 27 select HAVE_GENERIC_HARDIRQS
@@ -50,6 +51,7 @@ config SUPERH32
50 select HAVE_DYNAMIC_FTRACE 51 select HAVE_DYNAMIC_FTRACE
51 select HAVE_FUNCTION_TRACE_MCOUNT_TEST 52 select HAVE_FUNCTION_TRACE_MCOUNT_TEST
52 select HAVE_FTRACE_NMI_ENTER if DYNAMIC_FTRACE 53 select HAVE_FTRACE_NMI_ENTER if DYNAMIC_FTRACE
54 select ARCH_WANT_IPC_PARSE_VERSION
53 select HAVE_FUNCTION_GRAPH_TRACER 55 select HAVE_FUNCTION_GRAPH_TRACER
54 select HAVE_ARCH_KGDB 56 select HAVE_ARCH_KGDB
55 select HAVE_HW_BREAKPOINT 57 select HAVE_HW_BREAKPOINT
@@ -60,6 +62,7 @@ config SUPERH32
60 62
61config SUPERH64 63config SUPERH64
62 def_bool ARCH = "sh64" 64 def_bool ARCH = "sh64"
65 select KALLSYMS
63 66
64config ARCH_DEFCONFIG 67config ARCH_DEFCONFIG
65 string 68 string
diff --git a/arch/sh/boards/Kconfig b/arch/sh/boards/Kconfig
index 1f56b35d324..fb5805745ac 100644
--- a/arch/sh/boards/Kconfig
+++ b/arch/sh/boards/Kconfig
@@ -44,6 +44,8 @@ config SH_7721_SOLUTION_ENGINE
44config SH_7722_SOLUTION_ENGINE 44config SH_7722_SOLUTION_ENGINE
45 bool "SolutionEngine7722" 45 bool "SolutionEngine7722"
46 select SOLUTION_ENGINE 46 select SOLUTION_ENGINE
47 select GENERIC_IRQ_CHIP
48 select IRQ_DOMAIN
47 depends on CPU_SUBTYPE_SH7722 49 depends on CPU_SUBTYPE_SH7722
48 help 50 help
49 Select 7722 SolutionEngine if configuring for a Hitachi SH772 51 Select 7722 SolutionEngine if configuring for a Hitachi SH772
@@ -55,6 +57,7 @@ config SH_7724_SOLUTION_ENGINE
55 depends on CPU_SUBTYPE_SH7724 57 depends on CPU_SUBTYPE_SH7724
56 select ARCH_REQUIRE_GPIOLIB 58 select ARCH_REQUIRE_GPIOLIB
57 select SND_SOC_AK4642 if SND_SIMPLE_CARD 59 select SND_SOC_AK4642 if SND_SIMPLE_CARD
60 select REGULATOR_FIXED_VOLTAGE if REGULATOR
58 help 61 help
59 Select 7724 SolutionEngine if configuring for a Hitachi SH7724 62 Select 7724 SolutionEngine if configuring for a Hitachi SH7724
60 evaluation board. 63 evaluation board.
@@ -80,6 +83,8 @@ config SH_7780_SOLUTION_ENGINE
80config SH_7343_SOLUTION_ENGINE 83config SH_7343_SOLUTION_ENGINE
81 bool "SolutionEngine7343" 84 bool "SolutionEngine7343"
82 select SOLUTION_ENGINE 85 select SOLUTION_ENGINE
86 select GENERIC_IRQ_CHIP
87 select IRQ_DOMAIN
83 depends on CPU_SUBTYPE_SH7343 88 depends on CPU_SUBTYPE_SH7343
84 help 89 help
85 Select 7343 SolutionEngine if configuring for a Hitachi 90 Select 7343 SolutionEngine if configuring for a Hitachi
@@ -136,6 +141,7 @@ config SH_RSK
136 bool "Renesas Starter Kit" 141 bool "Renesas Starter Kit"
137 depends on CPU_SUBTYPE_SH7201 || CPU_SUBTYPE_SH7203 || \ 142 depends on CPU_SUBTYPE_SH7201 || CPU_SUBTYPE_SH7203 || \
138 CPU_SUBTYPE_SH7264 || CPU_SUBTYPE_SH7269 143 CPU_SUBTYPE_SH7264 || CPU_SUBTYPE_SH7269
144 select REGULATOR_FIXED_VOLTAGE if REGULATOR
139 help 145 help
140 Select this option if configuring for any of the RSK+ MCU 146 Select this option if configuring for any of the RSK+ MCU
141 evaluation platforms. 147 evaluation platforms.
@@ -155,6 +161,7 @@ config SH_SDK7786
155 select NO_IOPORT if !PCI 161 select NO_IOPORT if !PCI
156 select ARCH_WANT_OPTIONAL_GPIOLIB 162 select ARCH_WANT_OPTIONAL_GPIOLIB
157 select HAVE_SRAM_POOL 163 select HAVE_SRAM_POOL
164 select REGULATOR_FIXED_VOLTAGE if REGULATOR
158 help 165 help
159 Select SDK7786 if configuring for a Renesas Technology Europe 166 Select SDK7786 if configuring for a Renesas Technology Europe
160 SH7786-65nm board. 167 SH7786-65nm board.
@@ -169,6 +176,7 @@ config SH_SH7757LCR
169 bool "SH7757LCR" 176 bool "SH7757LCR"
170 depends on CPU_SUBTYPE_SH7757 177 depends on CPU_SUBTYPE_SH7757
171 select ARCH_REQUIRE_GPIOLIB 178 select ARCH_REQUIRE_GPIOLIB
179 select REGULATOR_FIXED_VOLTAGE if REGULATOR
172 180
173config SH_SH7785LCR 181config SH_SH7785LCR
174 bool "SH7785LCR" 182 bool "SH7785LCR"
@@ -202,6 +210,7 @@ config SH_MIGOR
202 bool "Migo-R" 210 bool "Migo-R"
203 depends on CPU_SUBTYPE_SH7722 211 depends on CPU_SUBTYPE_SH7722
204 select ARCH_REQUIRE_GPIOLIB 212 select ARCH_REQUIRE_GPIOLIB
213 select REGULATOR_FIXED_VOLTAGE if REGULATOR
205 help 214 help
206 Select Migo-R if configuring for the SH7722 Migo-R platform 215 Select Migo-R if configuring for the SH7722 Migo-R platform
207 by Renesas System Solutions Asia Pte. Ltd. 216 by Renesas System Solutions Asia Pte. Ltd.
@@ -210,6 +219,7 @@ config SH_AP325RXA
210 bool "AP-325RXA" 219 bool "AP-325RXA"
211 depends on CPU_SUBTYPE_SH7723 220 depends on CPU_SUBTYPE_SH7723
212 select ARCH_REQUIRE_GPIOLIB 221 select ARCH_REQUIRE_GPIOLIB
222 select REGULATOR_FIXED_VOLTAGE if REGULATOR
213 help 223 help
214 Renesas "AP-325RXA" support. 224 Renesas "AP-325RXA" support.
215 Compatible with ALGO SYSTEM CO.,LTD. "AP-320A" 225 Compatible with ALGO SYSTEM CO.,LTD. "AP-320A"
@@ -218,6 +228,7 @@ config SH_KFR2R09
218 bool "KFR2R09" 228 bool "KFR2R09"
219 depends on CPU_SUBTYPE_SH7724 229 depends on CPU_SUBTYPE_SH7724
220 select ARCH_REQUIRE_GPIOLIB 230 select ARCH_REQUIRE_GPIOLIB
231 select REGULATOR_FIXED_VOLTAGE if REGULATOR
221 help 232 help
222 "Kit For R2R for 2009" support. 233 "Kit For R2R for 2009" support.
223 234
@@ -226,6 +237,7 @@ config SH_ECOVEC
226 depends on CPU_SUBTYPE_SH7724 237 depends on CPU_SUBTYPE_SH7724
227 select ARCH_REQUIRE_GPIOLIB 238 select ARCH_REQUIRE_GPIOLIB
228 select SND_SOC_DA7210 if SND_SIMPLE_CARD 239 select SND_SOC_DA7210 if SND_SIMPLE_CARD
240 select REGULATOR_FIXED_VOLTAGE if REGULATOR
229 help 241 help
230 Renesas "R0P7724LC0011/21RL (EcoVec)" support. 242 Renesas "R0P7724LC0011/21RL (EcoVec)" support.
231 243
@@ -295,11 +307,13 @@ config SH_X3PROTO
295 bool "SH-X3 Prototype board" 307 bool "SH-X3 Prototype board"
296 depends on CPU_SUBTYPE_SHX3 308 depends on CPU_SUBTYPE_SHX3
297 select NO_IOPORT if !PCI 309 select NO_IOPORT if !PCI
310 select IRQ_DOMAIN
298 311
299config SH_MAGIC_PANEL_R2 312config SH_MAGIC_PANEL_R2
300 bool "Magic Panel R2" 313 bool "Magic Panel R2"
301 depends on CPU_SUBTYPE_SH7720 314 depends on CPU_SUBTYPE_SH7720
302 select ARCH_REQUIRE_GPIOLIB 315 select ARCH_REQUIRE_GPIOLIB
316 select REGULATOR_FIXED_VOLTAGE if REGULATOR
303 help 317 help
304 Select Magic Panel R2 if configuring for Magic Panel R2. 318 Select Magic Panel R2 if configuring for Magic Panel R2.
305 319
@@ -311,6 +325,7 @@ config SH_CAYMAN
311config SH_POLARIS 325config SH_POLARIS
312 bool "SMSC Polaris" 326 bool "SMSC Polaris"
313 select CPU_HAS_IPR_IRQ 327 select CPU_HAS_IPR_IRQ
328 select REGULATOR_FIXED_VOLTAGE if REGULATOR
314 depends on CPU_SUBTYPE_SH7709 329 depends on CPU_SUBTYPE_SH7709
315 help 330 help
316 Select if configuring for an SMSC Polaris development board 331 Select if configuring for an SMSC Polaris development board
@@ -318,6 +333,7 @@ config SH_POLARIS
318config SH_SH2007 333config SH_SH2007
319 bool "SH-2007 board" 334 bool "SH-2007 board"
320 select NO_IOPORT 335 select NO_IOPORT
336 select REGULATOR_FIXED_VOLTAGE if REGULATOR
321 depends on CPU_SUBTYPE_SH7780 337 depends on CPU_SUBTYPE_SH7780
322 help 338 help
323 SH-2007 is a single-board computer based around SH7780 chip 339 SH-2007 is a single-board computer based around SH7780 chip
@@ -329,6 +345,7 @@ config SH_SH2007
329config SH_APSH4A3A 345config SH_APSH4A3A
330 bool "AP-SH4A-3A" 346 bool "AP-SH4A-3A"
331 select SH_ALPHA_BOARD 347 select SH_ALPHA_BOARD
348 select REGULATOR_FIXED_VOLTAGE if REGULATOR
332 depends on CPU_SUBTYPE_SH7785 349 depends on CPU_SUBTYPE_SH7785
333 help 350 help
334 Select AP-SH4A-3A if configuring for an ALPHAPROJECT AP-SH4A-3A. 351 Select AP-SH4A-3A if configuring for an ALPHAPROJECT AP-SH4A-3A.
@@ -337,6 +354,7 @@ config SH_APSH4AD0A
337 bool "AP-SH4AD-0A" 354 bool "AP-SH4AD-0A"
338 select SH_ALPHA_BOARD 355 select SH_ALPHA_BOARD
339 select SYS_SUPPORTS_PCI 356 select SYS_SUPPORTS_PCI
357 select REGULATOR_FIXED_VOLTAGE if REGULATOR
340 depends on CPU_SUBTYPE_SH7786 358 depends on CPU_SUBTYPE_SH7786
341 help 359 help
342 Select AP-SH4AD-0A if configuring for an ALPHAPROJECT AP-SH4AD-0A. 360 Select AP-SH4AD-0A if configuring for an ALPHAPROJECT AP-SH4AD-0A.
diff --git a/arch/sh/boards/board-apsh4a3a.c b/arch/sh/boards/board-apsh4a3a.c
index 2823619c600..0a39c241628 100644
--- a/arch/sh/boards/board-apsh4a3a.c
+++ b/arch/sh/boards/board-apsh4a3a.c
@@ -13,6 +13,8 @@
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/mtd/physmap.h> 15#include <linux/mtd/physmap.h>
16#include <linux/regulator/fixed.h>
17#include <linux/regulator/machine.h>
16#include <linux/smsc911x.h> 18#include <linux/smsc911x.h>
17#include <linux/irq.h> 19#include <linux/irq.h>
18#include <linux/clk.h> 20#include <linux/clk.h>
@@ -66,6 +68,12 @@ static struct platform_device nor_flash_device = {
66 .resource = nor_flash_resources, 68 .resource = nor_flash_resources,
67}; 69};
68 70
71/* Dummy supplies, where voltage doesn't matter */
72static struct regulator_consumer_supply dummy_supplies[] = {
73 REGULATOR_SUPPLY("vddvario", "smsc911x"),
74 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
75};
76
69static struct resource smsc911x_resources[] = { 77static struct resource smsc911x_resources[] = {
70 [0] = { 78 [0] = {
71 .name = "smsc911x-memory", 79 .name = "smsc911x-memory",
@@ -105,6 +113,8 @@ static struct platform_device *apsh4a3a_devices[] __initdata = {
105 113
106static int __init apsh4a3a_devices_setup(void) 114static int __init apsh4a3a_devices_setup(void)
107{ 115{
116 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
117
108 return platform_add_devices(apsh4a3a_devices, 118 return platform_add_devices(apsh4a3a_devices,
109 ARRAY_SIZE(apsh4a3a_devices)); 119 ARRAY_SIZE(apsh4a3a_devices));
110} 120}
diff --git a/arch/sh/boards/board-apsh4ad0a.c b/arch/sh/boards/board-apsh4ad0a.c
index b4d6292a924..92eac3a9918 100644
--- a/arch/sh/boards/board-apsh4ad0a.c
+++ b/arch/sh/boards/board-apsh4ad0a.c
@@ -12,12 +12,20 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/regulator/fixed.h>
16#include <linux/regulator/machine.h>
15#include <linux/smsc911x.h> 17#include <linux/smsc911x.h>
16#include <linux/irq.h> 18#include <linux/irq.h>
17#include <linux/clk.h> 19#include <linux/clk.h>
18#include <asm/machvec.h> 20#include <asm/machvec.h>
19#include <asm/sizes.h> 21#include <asm/sizes.h>
20 22
23/* Dummy supplies, where voltage doesn't matter */
24static struct regulator_consumer_supply dummy_supplies[] = {
25 REGULATOR_SUPPLY("vddvario", "smsc911x"),
26 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
27};
28
21static struct resource smsc911x_resources[] = { 29static struct resource smsc911x_resources[] = {
22 [0] = { 30 [0] = {
23 .name = "smsc911x-memory", 31 .name = "smsc911x-memory",
@@ -56,6 +64,8 @@ static struct platform_device *apsh4ad0a_devices[] __initdata = {
56 64
57static int __init apsh4ad0a_devices_setup(void) 65static int __init apsh4ad0a_devices_setup(void)
58{ 66{
67 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
68
59 return platform_add_devices(apsh4ad0a_devices, 69 return platform_add_devices(apsh4ad0a_devices,
60 ARRAY_SIZE(apsh4ad0a_devices)); 70 ARRAY_SIZE(apsh4ad0a_devices));
61} 71}
diff --git a/arch/sh/boards/board-magicpanelr2.c b/arch/sh/boards/board-magicpanelr2.c
index 90568f9de3a..20500858b56 100644
--- a/arch/sh/boards/board-magicpanelr2.c
+++ b/arch/sh/boards/board-magicpanelr2.c
@@ -14,6 +14,8 @@
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/gpio.h> 16#include <linux/gpio.h>
17#include <linux/regulator/fixed.h>
18#include <linux/regulator/machine.h>
17#include <linux/smsc911x.h> 19#include <linux/smsc911x.h>
18#include <linux/mtd/mtd.h> 20#include <linux/mtd/mtd.h>
19#include <linux/mtd/partitions.h> 21#include <linux/mtd/partitions.h>
@@ -24,6 +26,12 @@
24#include <asm/heartbeat.h> 26#include <asm/heartbeat.h>
25#include <cpu/sh7720.h> 27#include <cpu/sh7720.h>
26 28
29/* Dummy supplies, where voltage doesn't matter */
30static struct regulator_consumer_supply dummy_supplies[] = {
31 REGULATOR_SUPPLY("vddvario", "smsc911x"),
32 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
33};
34
27#define LAN9115_READY (__raw_readl(0xA8000084UL) & 0x00000001UL) 35#define LAN9115_READY (__raw_readl(0xA8000084UL) & 0x00000001UL)
28 36
29/* Wait until reset finished. Timeout is 100ms. */ 37/* Wait until reset finished. Timeout is 100ms. */
@@ -348,6 +356,8 @@ static struct platform_device *mpr2_devices[] __initdata = {
348 356
349static int __init mpr2_devices_setup(void) 357static int __init mpr2_devices_setup(void)
350{ 358{
359 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
360
351 return platform_add_devices(mpr2_devices, ARRAY_SIZE(mpr2_devices)); 361 return platform_add_devices(mpr2_devices, ARRAY_SIZE(mpr2_devices));
352} 362}
353device_initcall(mpr2_devices_setup); 363device_initcall(mpr2_devices_setup);
diff --git a/arch/sh/boards/board-polaris.c b/arch/sh/boards/board-polaris.c
index 37d03c097ae..37a08d09472 100644
--- a/arch/sh/boards/board-polaris.c
+++ b/arch/sh/boards/board-polaris.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * June 2006 steve.glendinning@smsc.com 2 * June 2006 Steve Glendinning <steve.glendinning@shawell.net>
3 * 3 *
4 * Polaris-specific resource declaration 4 * Polaris-specific resource declaration
5 * 5 *
@@ -9,6 +9,8 @@
9#include <linux/interrupt.h> 9#include <linux/interrupt.h>
10#include <linux/irq.h> 10#include <linux/irq.h>
11#include <linux/platform_device.h> 11#include <linux/platform_device.h>
12#include <linux/regulator/fixed.h>
13#include <linux/regulator/machine.h>
12#include <linux/smsc911x.h> 14#include <linux/smsc911x.h>
13#include <linux/io.h> 15#include <linux/io.h>
14#include <asm/irq.h> 16#include <asm/irq.h>
@@ -22,6 +24,12 @@
22#define AREA5_WAIT_CTRL (0x1C00) 24#define AREA5_WAIT_CTRL (0x1C00)
23#define WAIT_STATES_10 (0x7) 25#define WAIT_STATES_10 (0x7)
24 26
27/* Dummy supplies, where voltage doesn't matter */
28static struct regulator_consumer_supply dummy_supplies[] = {
29 REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
30 REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
31};
32
25static struct resource smsc911x_resources[] = { 33static struct resource smsc911x_resources[] = {
26 [0] = { 34 [0] = {
27 .name = "smsc911x-memory", 35 .name = "smsc911x-memory",
@@ -88,6 +96,8 @@ static int __init polaris_initialise(void)
88 96
89 printk(KERN_INFO "Configuring Polaris external bus\n"); 97 printk(KERN_INFO "Configuring Polaris external bus\n");
90 98
99 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
100
91 /* Configure area 5 with 2 wait states */ 101 /* Configure area 5 with 2 wait states */
92 wcr = __raw_readw(WCR2); 102 wcr = __raw_readw(WCR2);
93 wcr &= (~AREA5_WAIT_CTRL); 103 wcr &= (~AREA5_WAIT_CTRL);
diff --git a/arch/sh/boards/board-sh2007.c b/arch/sh/boards/board-sh2007.c
index b90b78f6a82..1980bb7e578 100644
--- a/arch/sh/boards/board-sh2007.c
+++ b/arch/sh/boards/board-sh2007.c
@@ -6,6 +6,8 @@
6 */ 6 */
7#include <linux/init.h> 7#include <linux/init.h>
8#include <linux/irq.h> 8#include <linux/irq.h>
9#include <linux/regulator/fixed.h>
10#include <linux/regulator/machine.h>
9#include <linux/smsc911x.h> 11#include <linux/smsc911x.h>
10#include <linux/platform_device.h> 12#include <linux/platform_device.h>
11#include <linux/ata_platform.h> 13#include <linux/ata_platform.h>
@@ -13,6 +15,14 @@
13#include <asm/machvec.h> 15#include <asm/machvec.h>
14#include <mach/sh2007.h> 16#include <mach/sh2007.h>
15 17
18/* Dummy supplies, where voltage doesn't matter */
19static struct regulator_consumer_supply dummy_supplies[] = {
20 REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
21 REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
22 REGULATOR_SUPPLY("vddvario", "smsc911x.1"),
23 REGULATOR_SUPPLY("vdd33a", "smsc911x.1"),
24};
25
16struct smsc911x_platform_config smc911x_info = { 26struct smsc911x_platform_config smc911x_info = {
17 .flags = SMSC911X_USE_32BIT, 27 .flags = SMSC911X_USE_32BIT,
18 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, 28 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
@@ -98,6 +108,8 @@ static struct platform_device *sh2007_devices[] __initdata = {
98 108
99static int __init sh2007_io_init(void) 109static int __init sh2007_io_init(void)
100{ 110{
111 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
112
101 platform_add_devices(sh2007_devices, ARRAY_SIZE(sh2007_devices)); 113 platform_add_devices(sh2007_devices, ARRAY_SIZE(sh2007_devices));
102 return 0; 114 return 0;
103} 115}
diff --git a/arch/sh/boards/board-sh7757lcr.c b/arch/sh/boards/board-sh7757lcr.c
index 5087f8bb4cf..41f86702eb9 100644
--- a/arch/sh/boards/board-sh7757lcr.c
+++ b/arch/sh/boards/board-sh7757lcr.c
@@ -12,6 +12,8 @@
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include <linux/gpio.h> 13#include <linux/gpio.h>
14#include <linux/irq.h> 14#include <linux/irq.h>
15#include <linux/regulator/fixed.h>
16#include <linux/regulator/machine.h>
15#include <linux/spi/spi.h> 17#include <linux/spi/spi.h>
16#include <linux/spi/flash.h> 18#include <linux/spi/flash.h>
17#include <linux/io.h> 19#include <linux/io.h>
@@ -199,6 +201,15 @@ static struct platform_device sh7757_eth_giga1_device = {
199 }, 201 },
200}; 202};
201 203
204/* Fixed 3.3V regulator to be used by SDHI0, MMCIF */
205static struct regulator_consumer_supply fixed3v3_power_consumers[] =
206{
207 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
208 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
209 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
210 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
211};
212
202/* SH_MMCIF */ 213/* SH_MMCIF */
203static struct resource sh_mmcif_resources[] = { 214static struct resource sh_mmcif_resources[] = {
204 [0] = { 215 [0] = {
@@ -329,6 +340,9 @@ static struct spi_board_info spi_board_info[] = {
329 340
330static int __init sh7757lcr_devices_setup(void) 341static int __init sh7757lcr_devices_setup(void)
331{ 342{
343 regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
344 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
345
332 /* RGMII (PTA) */ 346 /* RGMII (PTA) */
333 gpio_request(GPIO_FN_ET0_MDC, NULL); 347 gpio_request(GPIO_FN_ET0_MDC, NULL);
334 gpio_request(GPIO_FN_ET0_MDIO, NULL); 348 gpio_request(GPIO_FN_ET0_MDIO, NULL);
diff --git a/arch/sh/boards/mach-ap325rxa/setup.c b/arch/sh/boards/mach-ap325rxa/setup.c
index f33ebf44707..9e963c1d144 100644
--- a/arch/sh/boards/mach-ap325rxa/setup.c
+++ b/arch/sh/boards/mach-ap325rxa/setup.c
@@ -20,6 +20,8 @@
20#include <linux/mtd/sh_flctl.h> 20#include <linux/mtd/sh_flctl.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/i2c.h> 22#include <linux/i2c.h>
23#include <linux/regulator/fixed.h>
24#include <linux/regulator/machine.h>
23#include <linux/smsc911x.h> 25#include <linux/smsc911x.h>
24#include <linux/gpio.h> 26#include <linux/gpio.h>
25#include <linux/videodev2.h> 27#include <linux/videodev2.h>
@@ -34,6 +36,12 @@
34#include <asm/suspend.h> 36#include <asm/suspend.h>
35#include <cpu/sh7723.h> 37#include <cpu/sh7723.h>
36 38
39/* Dummy supplies, where voltage doesn't matter */
40static struct regulator_consumer_supply dummy_supplies[] = {
41 REGULATOR_SUPPLY("vddvario", "smsc911x"),
42 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
43};
44
37static struct smsc911x_platform_config smsc911x_config = { 45static struct smsc911x_platform_config smsc911x_config = {
38 .phy_interface = PHY_INTERFACE_MODE_MII, 46 .phy_interface = PHY_INTERFACE_MODE_MII,
39 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, 47 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
@@ -423,6 +431,15 @@ static struct platform_device ceu_device = {
423 }, 431 },
424}; 432};
425 433
434/* Fixed 3.3V regulators to be used by SDHI0, SDHI1 */
435static struct regulator_consumer_supply fixed3v3_power_consumers[] =
436{
437 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
438 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
439 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
440 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
441};
442
426static struct resource sdhi0_cn3_resources[] = { 443static struct resource sdhi0_cn3_resources[] = {
427 [0] = { 444 [0] = {
428 .name = "SDHI0", 445 .name = "SDHI0",
@@ -544,6 +561,10 @@ static int __init ap325rxa_devices_setup(void)
544 &ap325rxa_sdram_leave_start, 561 &ap325rxa_sdram_leave_start,
545 &ap325rxa_sdram_leave_end); 562 &ap325rxa_sdram_leave_end);
546 563
564 regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
565 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
566 regulator_register_fixed(1, dummy_supplies, ARRAY_SIZE(dummy_supplies));
567
547 /* LD3 and LD4 LEDs */ 568 /* LD3 and LD4 LEDs */
548 gpio_request(GPIO_PTX5, NULL); /* RUN */ 569 gpio_request(GPIO_PTX5, NULL); /* RUN */
549 gpio_direction_output(GPIO_PTX5, 1); 570 gpio_direction_output(GPIO_PTX5, 1);
diff --git a/arch/sh/boards/mach-dreamcast/irq.c b/arch/sh/boards/mach-dreamcast/irq.c
index f63d323f411..2789647abeb 100644
--- a/arch/sh/boards/mach-dreamcast/irq.c
+++ b/arch/sh/boards/mach-dreamcast/irq.c
@@ -8,10 +8,11 @@
8 * This file is part of the LinuxDC project (www.linuxdc.org) 8 * This file is part of the LinuxDC project (www.linuxdc.org)
9 * Released under the terms of the GNU GPL v2.0 9 * Released under the terms of the GNU GPL v2.0
10 */ 10 */
11
12#include <linux/irq.h> 11#include <linux/irq.h>
13#include <linux/io.h> 12#include <linux/io.h>
14#include <asm/irq.h> 13#include <linux/irq.h>
14#include <linux/export.h>
15#include <linux/err.h>
15#include <mach/sysasic.h> 16#include <mach/sysasic.h>
16 17
17/* 18/*
@@ -141,26 +142,15 @@ int systemasic_irq_demux(int irq)
141 142
142void systemasic_irq_init(void) 143void systemasic_irq_init(void)
143{ 144{
144 int i, nid = cpu_to_node(boot_cpu_data); 145 int irq_base, i;
145
146 /* Assign all virtual IRQs to the System ASIC int. handler */
147 for (i = HW_EVENT_IRQ_BASE; i < HW_EVENT_IRQ_MAX; i++) {
148 unsigned int irq;
149
150 irq = create_irq_nr(i, nid);
151 if (unlikely(irq == 0)) {
152 pr_err("%s: failed hooking irq %d for systemasic\n",
153 __func__, i);
154 return;
155 }
156 146
157 if (unlikely(irq != i)) { 147 irq_base = irq_alloc_descs(HW_EVENT_IRQ_BASE, HW_EVENT_IRQ_BASE,
158 pr_err("%s: got irq %d but wanted %d, bailing.\n", 148 HW_EVENT_IRQ_MAX - HW_EVENT_IRQ_BASE, -1);
159 __func__, irq, i); 149 if (IS_ERR_VALUE(irq_base)) {
160 destroy_irq(irq); 150 pr_err("%s: failed hooking irqs\n", __func__);
161 return; 151 return;
162 } 152 }
163 153
154 for (i = HW_EVENT_IRQ_BASE; i < HW_EVENT_IRQ_MAX; i++)
164 irq_set_chip_and_handler(i, &systemasic_int, handle_level_irq); 155 irq_set_chip_and_handler(i, &systemasic_int, handle_level_irq);
165 }
166} 156}
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 4158d70c0de..64559e8af14 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -19,6 +19,8 @@
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/regulator/fixed.h>
23#include <linux/regulator/machine.h>
22#include <linux/usb/r8a66597.h> 24#include <linux/usb/r8a66597.h>
23#include <linux/usb/renesas_usbhs.h> 25#include <linux/usb/renesas_usbhs.h>
24#include <linux/i2c.h> 26#include <linux/i2c.h>
@@ -242,9 +244,17 @@ static int usbhs_get_id(struct platform_device *pdev)
242 return gpio_get_value(GPIO_PTB3); 244 return gpio_get_value(GPIO_PTB3);
243} 245}
244 246
247static void usbhs_phy_reset(struct platform_device *pdev)
248{
249 /* enable vbus if HOST */
250 if (!gpio_get_value(GPIO_PTB3))
251 gpio_set_value(GPIO_PTB5, 1);
252}
253
245static struct renesas_usbhs_platform_info usbhs_info = { 254static struct renesas_usbhs_platform_info usbhs_info = {
246 .platform_callback = { 255 .platform_callback = {
247 .get_id = usbhs_get_id, 256 .get_id = usbhs_get_id,
257 .phy_reset = usbhs_phy_reset,
248 }, 258 },
249 .driver_param = { 259 .driver_param = {
250 .buswait_bwait = 4, 260 .buswait_bwait = 4,
@@ -518,10 +528,86 @@ static struct i2c_board_info ts_i2c_clients = {
518 .irq = IRQ0, 528 .irq = IRQ0,
519}; 529};
520 530
531static struct regulator_consumer_supply cn12_power_consumers[] =
532{
533 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
534 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
535 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
536 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
537};
538
539static struct regulator_init_data cn12_power_init_data = {
540 .constraints = {
541 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
542 },
543 .num_consumer_supplies = ARRAY_SIZE(cn12_power_consumers),
544 .consumer_supplies = cn12_power_consumers,
545};
546
547static struct fixed_voltage_config cn12_power_info = {
548 .supply_name = "CN12 SD/MMC Vdd",
549 .microvolts = 3300000,
550 .gpio = GPIO_PTB7,
551 .enable_high = 1,
552 .init_data = &cn12_power_init_data,
553};
554
555static struct platform_device cn12_power = {
556 .name = "reg-fixed-voltage",
557 .id = 0,
558 .dev = {
559 .platform_data = &cn12_power_info,
560 },
561};
562
521#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) 563#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
522/* SDHI0 */ 564/* SDHI0 */
565static struct regulator_consumer_supply sdhi0_power_consumers[] =
566{
567 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
568 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
569};
570
571static struct regulator_init_data sdhi0_power_init_data = {
572 .constraints = {
573 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
574 },
575 .num_consumer_supplies = ARRAY_SIZE(sdhi0_power_consumers),
576 .consumer_supplies = sdhi0_power_consumers,
577};
578
579static struct fixed_voltage_config sdhi0_power_info = {
580 .supply_name = "CN11 SD/MMC Vdd",
581 .microvolts = 3300000,
582 .gpio = GPIO_PTB6,
583 .enable_high = 1,
584 .init_data = &sdhi0_power_init_data,
585};
586
587static struct platform_device sdhi0_power = {
588 .name = "reg-fixed-voltage",
589 .id = 1,
590 .dev = {
591 .platform_data = &sdhi0_power_info,
592 },
593};
594
523static void sdhi0_set_pwr(struct platform_device *pdev, int state) 595static void sdhi0_set_pwr(struct platform_device *pdev, int state)
524{ 596{
597 static int power_gpio = -EINVAL;
598
599 if (power_gpio < 0) {
600 int ret = gpio_request(GPIO_PTB6, NULL);
601 if (!ret) {
602 power_gpio = GPIO_PTB6;
603 gpio_direction_output(power_gpio, 0);
604 }
605 }
606
607 /*
608 * Toggle the GPIO regardless, whether we managed to grab it above or
609 * the fixed regulator driver did.
610 */
525 gpio_set_value(GPIO_PTB6, state); 611 gpio_set_value(GPIO_PTB6, state);
526} 612}
527 613
@@ -562,13 +648,27 @@ static struct platform_device sdhi0_device = {
562 }, 648 },
563}; 649};
564 650
565#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) 651static void cn12_set_pwr(struct platform_device *pdev, int state)
566/* SDHI1 */
567static void sdhi1_set_pwr(struct platform_device *pdev, int state)
568{ 652{
653 static int power_gpio = -EINVAL;
654
655 if (power_gpio < 0) {
656 int ret = gpio_request(GPIO_PTB7, NULL);
657 if (!ret) {
658 power_gpio = GPIO_PTB7;
659 gpio_direction_output(power_gpio, 0);
660 }
661 }
662
663 /*
664 * Toggle the GPIO regardless, whether we managed to grab it above or
665 * the fixed regulator driver did.
666 */
569 gpio_set_value(GPIO_PTB7, state); 667 gpio_set_value(GPIO_PTB7, state);
570} 668}
571 669
670#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
671/* SDHI1 */
572static int sdhi1_get_cd(struct platform_device *pdev) 672static int sdhi1_get_cd(struct platform_device *pdev)
573{ 673{
574 return !gpio_get_value(GPIO_PTW7); 674 return !gpio_get_value(GPIO_PTW7);
@@ -579,7 +679,7 @@ static struct sh_mobile_sdhi_info sdhi1_info = {
579 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX, 679 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
580 .tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD | 680 .tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
581 MMC_CAP_NEEDS_POLL, 681 MMC_CAP_NEEDS_POLL,
582 .set_pwr = sdhi1_set_pwr, 682 .set_pwr = cn12_set_pwr,
583 .get_cd = sdhi1_get_cd, 683 .get_cd = sdhi1_get_cd,
584}; 684};
585 685
@@ -899,14 +999,9 @@ static struct platform_device vou_device = {
899 999
900#if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE) 1000#if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
901/* SH_MMCIF */ 1001/* SH_MMCIF */
902static void mmcif_set_pwr(struct platform_device *pdev, int state)
903{
904 gpio_set_value(GPIO_PTB7, state);
905}
906
907static void mmcif_down_pwr(struct platform_device *pdev) 1002static void mmcif_down_pwr(struct platform_device *pdev)
908{ 1003{
909 gpio_set_value(GPIO_PTB7, 0); 1004 cn12_set_pwr(pdev, 0);
910} 1005}
911 1006
912static struct resource sh_mmcif_resources[] = { 1007static struct resource sh_mmcif_resources[] = {
@@ -929,7 +1024,7 @@ static struct resource sh_mmcif_resources[] = {
929}; 1024};
930 1025
931static struct sh_mmcif_plat_data sh_mmcif_plat = { 1026static struct sh_mmcif_plat_data sh_mmcif_plat = {
932 .set_pwr = mmcif_set_pwr, 1027 .set_pwr = cn12_set_pwr,
933 .down_pwr = mmcif_down_pwr, 1028 .down_pwr = mmcif_down_pwr,
934 .sup_pclk = 0, /* SH7724: Max Pclk/2 */ 1029 .sup_pclk = 0, /* SH7724: Max Pclk/2 */
935 .caps = MMC_CAP_4_BIT_DATA | 1030 .caps = MMC_CAP_4_BIT_DATA |
@@ -960,7 +1055,9 @@ static struct platform_device *ecovec_devices[] __initdata = {
960 &ceu0_device, 1055 &ceu0_device,
961 &ceu1_device, 1056 &ceu1_device,
962 &keysc_device, 1057 &keysc_device,
1058 &cn12_power,
963#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) 1059#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
1060 &sdhi0_power,
964 &sdhi0_device, 1061 &sdhi0_device,
965#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) 1062#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
966 &sdhi1_device, 1063 &sdhi1_device,
@@ -1258,8 +1355,6 @@ static int __init arch_setup(void)
1258 gpio_request(GPIO_FN_SDHI0D2, NULL); 1355 gpio_request(GPIO_FN_SDHI0D2, NULL);
1259 gpio_request(GPIO_FN_SDHI0D1, NULL); 1356 gpio_request(GPIO_FN_SDHI0D1, NULL);
1260 gpio_request(GPIO_FN_SDHI0D0, NULL); 1357 gpio_request(GPIO_FN_SDHI0D0, NULL);
1261 gpio_request(GPIO_PTB6, NULL);
1262 gpio_direction_output(GPIO_PTB6, 0);
1263#else 1358#else
1264 /* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */ 1359 /* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
1265 gpio_request(GPIO_FN_MSIOF0_TXD, NULL); 1360 gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
@@ -1288,8 +1383,6 @@ static int __init arch_setup(void)
1288 gpio_request(GPIO_FN_MMC_D0, NULL); 1383 gpio_request(GPIO_FN_MMC_D0, NULL);
1289 gpio_request(GPIO_FN_MMC_CLK, NULL); 1384 gpio_request(GPIO_FN_MMC_CLK, NULL);
1290 gpio_request(GPIO_FN_MMC_CMD, NULL); 1385 gpio_request(GPIO_FN_MMC_CMD, NULL);
1291 gpio_request(GPIO_PTB7, NULL);
1292 gpio_direction_output(GPIO_PTB7, 0);
1293 1386
1294 cn12_enabled = true; 1387 cn12_enabled = true;
1295#elif defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) 1388#elif defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
@@ -1301,8 +1394,6 @@ static int __init arch_setup(void)
1301 gpio_request(GPIO_FN_SDHI1D2, NULL); 1394 gpio_request(GPIO_FN_SDHI1D2, NULL);
1302 gpio_request(GPIO_FN_SDHI1D1, NULL); 1395 gpio_request(GPIO_FN_SDHI1D1, NULL);
1303 gpio_request(GPIO_FN_SDHI1D0, NULL); 1396 gpio_request(GPIO_FN_SDHI1D0, NULL);
1304 gpio_request(GPIO_PTB7, NULL);
1305 gpio_direction_output(GPIO_PTB7, 0);
1306 1397
1307 /* Card-detect, used on CN12 with SDHI1 */ 1398 /* Card-detect, used on CN12 with SDHI1 */
1308 gpio_request(GPIO_PTW7, NULL); 1399 gpio_request(GPIO_PTW7, NULL);
diff --git a/arch/sh/boards/mach-kfr2r09/setup.c b/arch/sh/boards/mach-kfr2r09/setup.c
index 43a179ce9af..f2a4304fbe2 100644
--- a/arch/sh/boards/mach-kfr2r09/setup.c
+++ b/arch/sh/boards/mach-kfr2r09/setup.c
@@ -21,6 +21,8 @@
21#include <linux/input.h> 21#include <linux/input.h>
22#include <linux/input/sh_keysc.h> 22#include <linux/input/sh_keysc.h>
23#include <linux/i2c.h> 23#include <linux/i2c.h>
24#include <linux/regulator/fixed.h>
25#include <linux/regulator/machine.h>
24#include <linux/usb/r8a66597.h> 26#include <linux/usb/r8a66597.h>
25#include <linux/videodev2.h> 27#include <linux/videodev2.h>
26#include <linux/sh_intc.h> 28#include <linux/sh_intc.h>
@@ -341,6 +343,13 @@ static struct platform_device kfr2r09_camera = {
341 }, 343 },
342}; 344};
343 345
346/* Fixed 3.3V regulator to be used by SDHI0 */
347static struct regulator_consumer_supply fixed3v3_power_consumers[] =
348{
349 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
350 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
351};
352
344static struct resource kfr2r09_sh_sdhi0_resources[] = { 353static struct resource kfr2r09_sh_sdhi0_resources[] = {
345 [0] = { 354 [0] = {
346 .name = "SDHI0", 355 .name = "SDHI0",
@@ -523,6 +532,9 @@ static int __init kfr2r09_devices_setup(void)
523 &kfr2r09_sdram_leave_start, 532 &kfr2r09_sdram_leave_start,
524 &kfr2r09_sdram_leave_end); 533 &kfr2r09_sdram_leave_end);
525 534
535 regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
536 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
537
526 /* enable SCIF1 serial port for YC401 console support */ 538 /* enable SCIF1 serial port for YC401 console support */
527 gpio_request(GPIO_FN_SCIF1_RXD, NULL); 539 gpio_request(GPIO_FN_SCIF1_RXD, NULL);
528 gpio_request(GPIO_FN_SCIF1_TXD, NULL); 540 gpio_request(GPIO_FN_SCIF1_TXD, NULL);
diff --git a/arch/sh/boards/mach-migor/setup.c b/arch/sh/boards/mach-migor/setup.c
index a8a1ca741c8..8b73194ed2c 100644
--- a/arch/sh/boards/mach-migor/setup.c
+++ b/arch/sh/boards/mach-migor/setup.c
@@ -17,6 +17,8 @@
17#include <linux/mtd/physmap.h> 17#include <linux/mtd/physmap.h>
18#include <linux/mtd/nand.h> 18#include <linux/mtd/nand.h>
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/regulator/fixed.h>
21#include <linux/regulator/machine.h>
20#include <linux/smc91x.h> 22#include <linux/smc91x.h>
21#include <linux/delay.h> 23#include <linux/delay.h>
22#include <linux/clk.h> 24#include <linux/clk.h>
@@ -386,6 +388,13 @@ static struct platform_device migor_ceu_device = {
386 }, 388 },
387}; 389};
388 390
391/* Fixed 3.3V regulator to be used by SDHI0 */
392static struct regulator_consumer_supply fixed3v3_power_consumers[] =
393{
394 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
395 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
396};
397
389static struct resource sdhi_cn9_resources[] = { 398static struct resource sdhi_cn9_resources[] = {
390 [0] = { 399 [0] = {
391 .name = "SDHI", 400 .name = "SDHI",
@@ -498,6 +507,10 @@ static int __init migor_devices_setup(void)
498 &migor_sdram_enter_end, 507 &migor_sdram_enter_end,
499 &migor_sdram_leave_start, 508 &migor_sdram_leave_start,
500 &migor_sdram_leave_end); 509 &migor_sdram_leave_end);
510
511 regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
512 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
513
501 /* Let D11 LED show STATUS0 */ 514 /* Let D11 LED show STATUS0 */
502 gpio_request(GPIO_FN_STATUS0, NULL); 515 gpio_request(GPIO_FN_STATUS0, NULL);
503 516
diff --git a/arch/sh/boards/mach-rsk/setup.c b/arch/sh/boards/mach-rsk/setup.c
index 895f030070d..2685ea03b06 100644
--- a/arch/sh/boards/mach-rsk/setup.c
+++ b/arch/sh/boards/mach-rsk/setup.c
@@ -16,9 +16,17 @@
16#include <linux/mtd/partitions.h> 16#include <linux/mtd/partitions.h>
17#include <linux/mtd/physmap.h> 17#include <linux/mtd/physmap.h>
18#include <linux/mtd/map.h> 18#include <linux/mtd/map.h>
19#include <linux/regulator/fixed.h>
20#include <linux/regulator/machine.h>
19#include <asm/machvec.h> 21#include <asm/machvec.h>
20#include <asm/io.h> 22#include <asm/io.h>
21 23
24/* Dummy supplies, where voltage doesn't matter */
25static struct regulator_consumer_supply dummy_supplies[] = {
26 REGULATOR_SUPPLY("vddvario", "smsc911x"),
27 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
28};
29
22static const char *part_probes[] = { "cmdlinepart", NULL }; 30static const char *part_probes[] = { "cmdlinepart", NULL };
23 31
24static struct mtd_partition rsk_partitions[] = { 32static struct mtd_partition rsk_partitions[] = {
@@ -67,6 +75,8 @@ static struct platform_device *rsk_devices[] __initdata = {
67 75
68static int __init rsk_devices_setup(void) 76static int __init rsk_devices_setup(void)
69{ 77{
78 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
79
70 return platform_add_devices(rsk_devices, 80 return platform_add_devices(rsk_devices,
71 ARRAY_SIZE(rsk_devices)); 81 ARRAY_SIZE(rsk_devices));
72} 82}
diff --git a/arch/sh/boards/mach-sdk7786/setup.c b/arch/sh/boards/mach-sdk7786/setup.c
index 27a2314f50a..c29268bfd34 100644
--- a/arch/sh/boards/mach-sdk7786/setup.c
+++ b/arch/sh/boards/mach-sdk7786/setup.c
@@ -11,6 +11,8 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include <linux/io.h> 13#include <linux/io.h>
14#include <linux/regulator/fixed.h>
15#include <linux/regulator/machine.h>
14#include <linux/smsc911x.h> 16#include <linux/smsc911x.h>
15#include <linux/i2c.h> 17#include <linux/i2c.h>
16#include <linux/irq.h> 18#include <linux/irq.h>
@@ -38,6 +40,12 @@ static struct platform_device heartbeat_device = {
38 .resource = &heartbeat_resource, 40 .resource = &heartbeat_resource,
39}; 41};
40 42
43/* Dummy supplies, where voltage doesn't matter */
44static struct regulator_consumer_supply dummy_supplies[] = {
45 REGULATOR_SUPPLY("vddvario", "smsc911x"),
46 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
47};
48
41static struct resource smsc911x_resources[] = { 49static struct resource smsc911x_resources[] = {
42 [0] = { 50 [0] = {
43 .name = "smsc911x-memory", 51 .name = "smsc911x-memory",
@@ -236,6 +244,8 @@ static void __init sdk7786_setup(char **cmdline_p)
236{ 244{
237 pr_info("Renesas Technology Europe SDK7786 support:\n"); 245 pr_info("Renesas Technology Europe SDK7786 support:\n");
238 246
247 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
248
239 sdk7786_fpga_init(); 249 sdk7786_fpga_init();
240 sdk7786_nmi_init(); 250 sdk7786_nmi_init();
241 251
diff --git a/arch/sh/boards/mach-se/7343/irq.c b/arch/sh/boards/mach-se/7343/irq.c
index fd45ffc4834..7646bf0486c 100644
--- a/arch/sh/boards/mach-se/7343/irq.c
+++ b/arch/sh/boards/mach-se/7343/irq.c
@@ -1,86 +1,129 @@
1/* 1/*
2 * linux/arch/sh/boards/se/7343/irq.c 2 * Hitachi UL SolutionEngine 7343 FPGA IRQ Support.
3 * 3 *
4 * Copyright (C) 2008 Yoshihiro Shimoda 4 * Copyright (C) 2008 Yoshihiro Shimoda
5 * Copyright (C) 2012 Paul Mundt
5 * 6 *
6 * Based on linux/arch/sh/boards/se/7722/irq.c 7 * Based on linux/arch/sh/boards/se/7343/irq.c
7 * Copyright (C) 2007 Nobuhiro Iwamatsu 8 * Copyright (C) 2007 Nobuhiro Iwamatsu
8 * 9 *
9 * 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
10 * 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
11 * for more details. 12 * for more details.
12 */ 13 */
14#define DRV_NAME "SE7343-FPGA"
15#define pr_fmt(fmt) DRV_NAME ": " fmt
16
17#define irq_reg_readl ioread16
18#define irq_reg_writel iowrite16
19
13#include <linux/init.h> 20#include <linux/init.h>
14#include <linux/irq.h> 21#include <linux/irq.h>
15#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/irqdomain.h>
16#include <linux/io.h> 24#include <linux/io.h>
25#include <asm/sizes.h>
17#include <mach-se/mach/se7343.h> 26#include <mach-se/mach/se7343.h>
18 27
19unsigned int se7343_fpga_irq[SE7343_FPGA_IRQ_NR] = { 0, }; 28#define PA_CPLD_BASE_ADDR 0x11400000
29#define PA_CPLD_ST_REG 0x08 /* CPLD Interrupt status register */
30#define PA_CPLD_IMSK_REG 0x0a /* CPLD Interrupt mask register */
20 31
21static void disable_se7343_irq(struct irq_data *data) 32static void __iomem *se7343_irq_regs;
22{ 33struct irq_domain *se7343_irq_domain;
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);
25}
26 34
27static void enable_se7343_irq(struct irq_data *data) 35static void se7343_irq_demux(unsigned int irq, struct irq_desc *desc)
28{ 36{
29 unsigned int bit = (unsigned int)irq_data_get_irq_chip_data(data); 37 struct irq_data *data = irq_get_irq_data(irq);
30 __raw_writew(__raw_readw(PA_CPLD_IMSK) & ~(1 << bit), PA_CPLD_IMSK); 38 struct irq_chip *chip = irq_data_get_irq_chip(data);
31} 39 unsigned long mask;
40 int bit;
32 41
33static struct irq_chip se7343_irq_chip __read_mostly = { 42 chip->irq_mask_ack(data);
34 .name = "SE7343-FPGA",
35 .irq_mask = disable_se7343_irq,
36 .irq_unmask = enable_se7343_irq,
37};
38 43
39static void se7343_irq_demux(unsigned int irq, struct irq_desc *desc) 44 mask = ioread16(se7343_irq_regs + PA_CPLD_ST_REG);
45
46 for_each_set_bit(bit, &mask, SE7343_FPGA_IRQ_NR)
47 generic_handle_irq(irq_linear_revmap(se7343_irq_domain, bit));
48
49 chip->irq_unmask(data);
50}
51
52static void __init se7343_domain_init(void)
40{ 53{
41 unsigned short intv = __raw_readw(PA_CPLD_ST); 54 int i;
42 unsigned int ext_irq = 0;
43 55
44 intv &= (1 << SE7343_FPGA_IRQ_NR) - 1; 56 se7343_irq_domain = irq_domain_add_linear(NULL, SE7343_FPGA_IRQ_NR,
57 &irq_domain_simple_ops, NULL);
58 if (unlikely(!se7343_irq_domain)) {
59 printk("Failed to get IRQ domain\n");
60 return;
61 }
45 62
46 for (; intv; intv >>= 1, ext_irq++) { 63 for (i = 0; i < SE7343_FPGA_IRQ_NR; i++) {
47 if (!(intv & 1)) 64 int irq = irq_create_mapping(se7343_irq_domain, i);
48 continue;
49 65
50 generic_handle_irq(se7343_fpga_irq[ext_irq]); 66 if (unlikely(irq == 0)) {
67 printk("Failed to allocate IRQ %d\n", i);
68 return;
69 }
51 } 70 }
52} 71}
53 72
54/* 73static void __init se7343_gc_init(void)
55 * Initialize IRQ setting
56 */
57void __init init_7343se_IRQ(void)
58{ 74{
59 int i, irq; 75 struct irq_chip_generic *gc;
76 struct irq_chip_type *ct;
77 unsigned int irq_base;
60 78
61 __raw_writew(0, PA_CPLD_IMSK); /* disable all irqs */ 79 irq_base = irq_linear_revmap(se7343_irq_domain, 0);
62 __raw_writew(0x2000, 0xb03fffec); /* mrshpc irq enable */
63 80
64 for (i = 0; i < SE7343_FPGA_IRQ_NR; i++) { 81 gc = irq_alloc_generic_chip(DRV_NAME, 1, irq_base, se7343_irq_regs,
65 irq = create_irq(); 82 handle_level_irq);
66 if (irq < 0) 83 if (unlikely(!gc))
67 return; 84 return;
68 se7343_fpga_irq[i] = irq;
69 85
70 irq_set_chip_and_handler_name(se7343_fpga_irq[i], 86 ct = gc->chip_types;
71 &se7343_irq_chip, 87 ct->chip.irq_mask = irq_gc_mask_set_bit;
72 handle_level_irq, 88 ct->chip.irq_unmask = irq_gc_mask_clr_bit;
73 "level");
74 89
75 irq_set_chip_data(se7343_fpga_irq[i], (void *)i); 90 ct->regs.mask = PA_CPLD_IMSK_REG;
76 } 91
92 irq_setup_generic_chip(gc, IRQ_MSK(SE7343_FPGA_IRQ_NR),
93 IRQ_GC_INIT_MASK_CACHE,
94 IRQ_NOREQUEST | IRQ_NOPROBE, 0);
77 95
78 irq_set_chained_handler(IRQ0_IRQ, se7343_irq_demux); 96 irq_set_chained_handler(IRQ0_IRQ, se7343_irq_demux);
79 irq_set_irq_type(IRQ0_IRQ, IRQ_TYPE_LEVEL_LOW); 97 irq_set_irq_type(IRQ0_IRQ, IRQ_TYPE_LEVEL_LOW);
98
80 irq_set_chained_handler(IRQ1_IRQ, se7343_irq_demux); 99 irq_set_chained_handler(IRQ1_IRQ, se7343_irq_demux);
81 irq_set_irq_type(IRQ1_IRQ, IRQ_TYPE_LEVEL_LOW); 100 irq_set_irq_type(IRQ1_IRQ, IRQ_TYPE_LEVEL_LOW);
101
82 irq_set_chained_handler(IRQ4_IRQ, se7343_irq_demux); 102 irq_set_chained_handler(IRQ4_IRQ, se7343_irq_demux);
83 irq_set_irq_type(IRQ4_IRQ, IRQ_TYPE_LEVEL_LOW); 103 irq_set_irq_type(IRQ4_IRQ, IRQ_TYPE_LEVEL_LOW);
104
84 irq_set_chained_handler(IRQ5_IRQ, se7343_irq_demux); 105 irq_set_chained_handler(IRQ5_IRQ, se7343_irq_demux);
85 irq_set_irq_type(IRQ5_IRQ, IRQ_TYPE_LEVEL_LOW); 106 irq_set_irq_type(IRQ5_IRQ, IRQ_TYPE_LEVEL_LOW);
86} 107}
108
109/*
110 * Initialize IRQ setting
111 */
112void __init init_7343se_IRQ(void)
113{
114 se7343_irq_regs = ioremap(PA_CPLD_BASE_ADDR, SZ_16);
115 if (unlikely(!se7343_irq_regs)) {
116 pr_err("Failed to remap CPLD\n");
117 return;
118 }
119
120 /*
121 * All FPGA IRQs disabled by default
122 */
123 iowrite16(0, se7343_irq_regs + PA_CPLD_IMSK_REG);
124
125 __raw_writew(0x2000, 0xb03fffec); /* mrshpc irq enable */
126
127 se7343_domain_init();
128 se7343_gc_init();
129}
diff --git a/arch/sh/boards/mach-se/7343/setup.c b/arch/sh/boards/mach-se/7343/setup.c
index d2370af56d7..8ce4f2a202a 100644
--- a/arch/sh/boards/mach-se/7343/setup.c
+++ b/arch/sh/boards/mach-se/7343/setup.c
@@ -5,6 +5,7 @@
5#include <linux/serial_reg.h> 5#include <linux/serial_reg.h>
6#include <linux/usb/isp116x.h> 6#include <linux/usb/isp116x.h>
7#include <linux/delay.h> 7#include <linux/delay.h>
8#include <linux/irqdomain.h>
8#include <asm/machvec.h> 9#include <asm/machvec.h>
9#include <mach-se/mach/se7343.h> 10#include <mach-se/mach/se7343.h>
10#include <asm/heartbeat.h> 11#include <asm/heartbeat.h>
@@ -145,11 +146,12 @@ static struct platform_device *sh7343se_platform_devices[] __initdata = {
145static int __init sh7343se_devices_setup(void) 146static int __init sh7343se_devices_setup(void)
146{ 147{
147 /* Wire-up dynamic vectors */ 148 /* Wire-up dynamic vectors */
148 serial_platform_data[0].irq = se7343_fpga_irq[SE7343_FPGA_IRQ_UARTA]; 149 serial_platform_data[0].irq = irq_find_mapping(se7343_irq_domain,
149 serial_platform_data[1].irq = se7343_fpga_irq[SE7343_FPGA_IRQ_UARTB]; 150 SE7343_FPGA_IRQ_UARTA);
150 151 serial_platform_data[1].irq = irq_find_mapping(se7343_irq_domain,
152 SE7343_FPGA_IRQ_UARTB);
151 usb_resources[2].start = usb_resources[2].end = 153 usb_resources[2].start = usb_resources[2].end =
152 se7343_fpga_irq[SE7343_FPGA_IRQ_USB]; 154 irq_find_mapping(se7343_irq_domain, SE7343_FPGA_IRQ_USB);
153 155
154 return platform_add_devices(sh7343se_platform_devices, 156 return platform_add_devices(sh7343se_platform_devices,
155 ARRAY_SIZE(sh7343se_platform_devices)); 157 ARRAY_SIZE(sh7343se_platform_devices));
diff --git a/arch/sh/boards/mach-se/7722/irq.c b/arch/sh/boards/mach-se/7722/irq.c
index aac92f21ebd..f5e2af1bf04 100644
--- a/arch/sh/boards/mach-se/7722/irq.c
+++ b/arch/sh/boards/mach-se/7722/irq.c
@@ -1,79 +1,96 @@
1/* 1/*
2 * linux/arch/sh/boards/se/7722/irq.c 2 * Hitachi UL SolutionEngine 7722 FPGA IRQ Support.
3 * 3 *
4 * Copyright (C) 2007 Nobuhiro Iwamatsu 4 * Copyright (C) 2007 Nobuhiro Iwamatsu
5 * 5 * Copyright (C) 2012 Paul Mundt
6 * Hitachi UL SolutionEngine 7722 Support.
7 * 6 *
8 * This file is subject to the terms and conditions of the GNU General Public 7 * 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 8 * License. See the file "COPYING" in the main directory of this archive
10 * for more details. 9 * for more details.
11 */ 10 */
11#define DRV_NAME "SE7722-FPGA"
12#define pr_fmt(fmt) DRV_NAME ": " fmt
13
14#define irq_reg_readl ioread16
15#define irq_reg_writel iowrite16
16
12#include <linux/init.h> 17#include <linux/init.h>
13#include <linux/irq.h> 18#include <linux/irq.h>
14#include <linux/interrupt.h> 19#include <linux/interrupt.h>
15#include <asm/irq.h> 20#include <linux/irqdomain.h>
16#include <asm/io.h> 21#include <linux/io.h>
22#include <linux/err.h>
23#include <asm/sizes.h>
17#include <mach-se/mach/se7722.h> 24#include <mach-se/mach/se7722.h>
18 25
19unsigned int se7722_fpga_irq[SE7722_FPGA_IRQ_NR] = { 0, }; 26#define IRQ01_BASE_ADDR 0x11800000
27#define IRQ01_MODE_REG 0
28#define IRQ01_STS_REG 4
29#define IRQ01_MASK_REG 8
20 30
21static void disable_se7722_irq(struct irq_data *data) 31static void __iomem *se7722_irq_regs;
22{ 32struct irq_domain *se7722_irq_domain;
23 unsigned int bit = (unsigned int)irq_data_get_irq_chip_data(data);
24 __raw_writew(__raw_readw(IRQ01_MASK) | 1 << bit, IRQ01_MASK);
25}
26 33
27static void enable_se7722_irq(struct irq_data *data) 34static void se7722_irq_demux(unsigned int irq, struct irq_desc *desc)
28{ 35{
29 unsigned int bit = (unsigned int)irq_data_get_irq_chip_data(data); 36 struct irq_data *data = irq_get_irq_data(irq);
30 __raw_writew(__raw_readw(IRQ01_MASK) & ~(1 << bit), IRQ01_MASK); 37 struct irq_chip *chip = irq_data_get_irq_chip(data);
31} 38 unsigned long mask;
39 int bit;
32 40
33static struct irq_chip se7722_irq_chip __read_mostly = { 41 chip->irq_mask_ack(data);
34 .name = "SE7722-FPGA",
35 .irq_mask = disable_se7722_irq,
36 .irq_unmask = enable_se7722_irq,
37};
38 42
39static void se7722_irq_demux(unsigned int irq, struct irq_desc *desc) 43 mask = ioread16(se7722_irq_regs + IRQ01_STS_REG);
44
45 for_each_set_bit(bit, &mask, SE7722_FPGA_IRQ_NR)
46 generic_handle_irq(irq_linear_revmap(se7722_irq_domain, bit));
47
48 chip->irq_unmask(data);
49}
50
51static void __init se7722_domain_init(void)
40{ 52{
41 unsigned short intv = __raw_readw(IRQ01_STS); 53 int i;
42 unsigned int ext_irq = 0;
43 54
44 intv &= (1 << SE7722_FPGA_IRQ_NR) - 1; 55 se7722_irq_domain = irq_domain_add_linear(NULL, SE7722_FPGA_IRQ_NR,
56 &irq_domain_simple_ops, NULL);
57 if (unlikely(!se7722_irq_domain)) {
58 printk("Failed to get IRQ domain\n");
59 return;
60 }
45 61
46 for (; intv; intv >>= 1, ext_irq++) { 62 for (i = 0; i < SE7722_FPGA_IRQ_NR; i++) {
47 if (!(intv & 1)) 63 int irq = irq_create_mapping(se7722_irq_domain, i);
48 continue;
49 64
50 generic_handle_irq(se7722_fpga_irq[ext_irq]); 65 if (unlikely(irq == 0)) {
66 printk("Failed to allocate IRQ %d\n", i);
67 return;
68 }
51 } 69 }
52} 70}
53 71
54/* 72static void __init se7722_gc_init(void)
55 * Initialize IRQ setting
56 */
57void __init init_se7722_IRQ(void)
58{ 73{
59 int i, irq; 74 struct irq_chip_generic *gc;
75 struct irq_chip_type *ct;
76 unsigned int irq_base;
60 77
61 __raw_writew(0, IRQ01_MASK); /* disable all irqs */ 78 irq_base = irq_linear_revmap(se7722_irq_domain, 0);
62 __raw_writew(0x2000, 0xb03fffec); /* mrshpc irq enable */
63 79
64 for (i = 0; i < SE7722_FPGA_IRQ_NR; i++) { 80 gc = irq_alloc_generic_chip(DRV_NAME, 1, irq_base, se7722_irq_regs,
65 irq = create_irq(); 81 handle_level_irq);
66 if (irq < 0) 82 if (unlikely(!gc))
67 return; 83 return;
68 se7722_fpga_irq[i] = irq;
69 84
70 irq_set_chip_and_handler_name(se7722_fpga_irq[i], 85 ct = gc->chip_types;
71 &se7722_irq_chip, 86 ct->chip.irq_mask = irq_gc_mask_set_bit;
72 handle_level_irq, 87 ct->chip.irq_unmask = irq_gc_mask_clr_bit;
73 "level");
74 88
75 irq_set_chip_data(se7722_fpga_irq[i], (void *)i); 89 ct->regs.mask = IRQ01_MASK_REG;
76 } 90
91 irq_setup_generic_chip(gc, IRQ_MSK(SE7722_FPGA_IRQ_NR),
92 IRQ_GC_INIT_MASK_CACHE,
93 IRQ_NOREQUEST | IRQ_NOPROBE, 0);
77 94
78 irq_set_chained_handler(IRQ0_IRQ, se7722_irq_demux); 95 irq_set_chained_handler(IRQ0_IRQ, se7722_irq_demux);
79 irq_set_irq_type(IRQ0_IRQ, IRQ_TYPE_LEVEL_LOW); 96 irq_set_irq_type(IRQ0_IRQ, IRQ_TYPE_LEVEL_LOW);
@@ -81,3 +98,25 @@ void __init init_se7722_IRQ(void)
81 irq_set_chained_handler(IRQ1_IRQ, se7722_irq_demux); 98 irq_set_chained_handler(IRQ1_IRQ, se7722_irq_demux);
82 irq_set_irq_type(IRQ1_IRQ, IRQ_TYPE_LEVEL_LOW); 99 irq_set_irq_type(IRQ1_IRQ, IRQ_TYPE_LEVEL_LOW);
83} 100}
101
102/*
103 * Initialize FPGA IRQs
104 */
105void __init init_se7722_IRQ(void)
106{
107 se7722_irq_regs = ioremap(IRQ01_BASE_ADDR, SZ_16);
108 if (unlikely(!se7722_irq_regs)) {
109 printk("Failed to remap IRQ01 regs\n");
110 return;
111 }
112
113 /*
114 * All FPGA IRQs disabled by default
115 */
116 iowrite16(0, se7722_irq_regs + IRQ01_MASK_REG);
117
118 __raw_writew(0x2000, 0xb03fffec); /* mrshpc irq enable */
119
120 se7722_domain_init();
121 se7722_gc_init();
122}
diff --git a/arch/sh/boards/mach-se/7722/setup.c b/arch/sh/boards/mach-se/7722/setup.c
index 8f7f0550cfd..e04e2bc4698 100644
--- a/arch/sh/boards/mach-se/7722/setup.c
+++ b/arch/sh/boards/mach-se/7722/setup.c
@@ -2,6 +2,7 @@
2 * linux/arch/sh/boards/se/7722/setup.c 2 * linux/arch/sh/boards/se/7722/setup.c
3 * 3 *
4 * Copyright (C) 2007 Nobuhiro Iwamatsu 4 * Copyright (C) 2007 Nobuhiro Iwamatsu
5 * Copyright (C) 2012 Paul Mundt
5 * 6 *
6 * Hitachi UL SolutionEngine 7722 Support. 7 * Hitachi UL SolutionEngine 7722 Support.
7 * 8 *
@@ -15,6 +16,7 @@
15#include <linux/ata_platform.h> 16#include <linux/ata_platform.h>
16#include <linux/input.h> 17#include <linux/input.h>
17#include <linux/input/sh_keysc.h> 18#include <linux/input/sh_keysc.h>
19#include <linux/irqdomain.h>
18#include <linux/smc91x.h> 20#include <linux/smc91x.h>
19#include <linux/sh_intc.h> 21#include <linux/sh_intc.h>
20#include <mach-se/mach/se7722.h> 22#include <mach-se/mach/se7722.h>
@@ -143,10 +145,10 @@ static int __init se7722_devices_setup(void)
143 145
144 /* Wire-up dynamic vectors */ 146 /* Wire-up dynamic vectors */
145 cf_ide_resources[2].start = cf_ide_resources[2].end = 147 cf_ide_resources[2].start = cf_ide_resources[2].end =
146 se7722_fpga_irq[SE7722_FPGA_IRQ_MRSHPC0]; 148 irq_find_mapping(se7722_irq_domain, SE7722_FPGA_IRQ_MRSHPC0);
147 149
148 smc91x_eth_resources[1].start = smc91x_eth_resources[1].end = 150 smc91x_eth_resources[1].start = smc91x_eth_resources[1].end =
149 se7722_fpga_irq[SE7722_FPGA_IRQ_SMC]; 151 irq_find_mapping(se7722_irq_domain, SE7722_FPGA_IRQ_SMC);
150 152
151 return platform_add_devices(se7722_devices, ARRAY_SIZE(se7722_devices)); 153 return platform_add_devices(se7722_devices, ARRAY_SIZE(se7722_devices));
152} 154}
diff --git a/arch/sh/boards/mach-se/7724/irq.c b/arch/sh/boards/mach-se/7724/irq.c
index c6342ce7768..5d1d3ec9a6c 100644
--- a/arch/sh/boards/mach-se/7724/irq.c
+++ b/arch/sh/boards/mach-se/7724/irq.c
@@ -17,8 +17,10 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/irq.h> 18#include <linux/irq.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <asm/irq.h> 20#include <linux/export.h>
21#include <asm/io.h> 21#include <linux/topology.h>
22#include <linux/io.h>
23#include <linux/err.h>
22#include <mach-se/mach/se7724.h> 24#include <mach-se/mach/se7724.h>
23 25
24struct fpga_irq { 26struct fpga_irq {
@@ -111,7 +113,7 @@ static void se7724_irq_demux(unsigned int irq, struct irq_desc *desc)
111 */ 113 */
112void __init init_se7724_IRQ(void) 114void __init init_se7724_IRQ(void)
113{ 115{
114 int i, nid = cpu_to_node(boot_cpu_data); 116 int irq_base, i;
115 117
116 __raw_writew(0xffff, IRQ0_MR); /* mask all */ 118 __raw_writew(0xffff, IRQ0_MR); /* mask all */
117 __raw_writew(0xffff, IRQ1_MR); /* mask all */ 119 __raw_writew(0xffff, IRQ1_MR); /* mask all */
@@ -121,28 +123,16 @@ void __init init_se7724_IRQ(void)
121 __raw_writew(0x0000, IRQ2_SR); /* clear irq */ 123 __raw_writew(0x0000, IRQ2_SR); /* clear irq */
122 __raw_writew(0x002a, IRQ_MODE); /* set irq type */ 124 __raw_writew(0x002a, IRQ_MODE); /* set irq type */
123 125
124 for (i = 0; i < SE7724_FPGA_IRQ_NR; i++) { 126 irq_base = irq_alloc_descs(SE7724_FPGA_IRQ_BASE, SE7724_FPGA_IRQ_BASE,
125 int irq, wanted; 127 SE7724_FPGA_IRQ_NR, numa_node_id());
126 128 if (IS_ERR_VALUE(irq_base)) {
127 wanted = SE7724_FPGA_IRQ_BASE + i; 129 pr_err("%s: failed hooking irqs for FPGA\n", __func__);
128 130 return;
129 irq = create_irq_nr(wanted, nid); 131 }
130 if (unlikely(irq == 0)) {
131 pr_err("%s: failed hooking irq %d for FPGA\n",
132 __func__, wanted);
133 return;
134 }
135
136 if (unlikely(irq != wanted)) {
137 pr_err("%s: got irq %d but wanted %d, bailing.\n",
138 __func__, irq, wanted);
139 destroy_irq(irq);
140 return;
141 }
142 132
143 irq_set_chip_and_handler_name(irq, &se7724_irq_chip, 133 for (i = 0; i < SE7724_FPGA_IRQ_NR; i++)
134 irq_set_chip_and_handler_name(irq_base + i, &se7724_irq_chip,
144 handle_level_irq, "level"); 135 handle_level_irq, "level");
145 }
146 136
147 irq_set_chained_handler(IRQ0_IRQ, se7724_irq_demux); 137 irq_set_chained_handler(IRQ0_IRQ, se7724_irq_demux);
148 irq_set_irq_type(IRQ0_IRQ, IRQ_TYPE_LEVEL_LOW); 138 irq_set_irq_type(IRQ0_IRQ, IRQ_TYPE_LEVEL_LOW);
diff --git a/arch/sh/boards/mach-se/7724/setup.c b/arch/sh/boards/mach-se/7724/setup.c
index ffbf5bc7366..35f6efa3ac0 100644
--- a/arch/sh/boards/mach-se/7724/setup.c
+++ b/arch/sh/boards/mach-se/7724/setup.c
@@ -18,6 +18,8 @@
18#include <linux/mmc/sh_mobile_sdhi.h> 18#include <linux/mmc/sh_mobile_sdhi.h>
19#include <linux/mtd/physmap.h> 19#include <linux/mtd/physmap.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/regulator/fixed.h>
22#include <linux/regulator/machine.h>
21#include <linux/smc91x.h> 23#include <linux/smc91x.h>
22#include <linux/gpio.h> 24#include <linux/gpio.h>
23#include <linux/input.h> 25#include <linux/input.h>
@@ -454,6 +456,15 @@ static struct platform_device sh7724_usb1_gadget_device = {
454 .resource = sh7724_usb1_gadget_resources, 456 .resource = sh7724_usb1_gadget_resources,
455}; 457};
456 458
459/* Fixed 3.3V regulator to be used by SDHI0, SDHI1 */
460static struct regulator_consumer_supply fixed3v3_power_consumers[] =
461{
462 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
463 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
464 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
465 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
466};
467
457static struct resource sdhi0_cn7_resources[] = { 468static struct resource sdhi0_cn7_resources[] = {
458 [0] = { 469 [0] = {
459 .name = "SDHI0", 470 .name = "SDHI0",
@@ -684,6 +695,10 @@ static int __init devices_setup(void)
684 &ms7724se_sdram_enter_end, 695 &ms7724se_sdram_enter_end,
685 &ms7724se_sdram_leave_start, 696 &ms7724se_sdram_leave_start,
686 &ms7724se_sdram_leave_end); 697 &ms7724se_sdram_leave_end);
698
699 regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
700 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
701
687 /* Reset Release */ 702 /* Reset Release */
688 fpga_out = __raw_readw(FPGA_OUT); 703 fpga_out = __raw_readw(FPGA_OUT);
689 /* bit4: NTSC_PDN, bit5: NTSC_RESET */ 704 /* bit4: NTSC_PDN, bit5: NTSC_RESET */
diff --git a/arch/sh/boards/mach-x3proto/gpio.c b/arch/sh/boards/mach-x3proto/gpio.c
index f33b2b57019..3ea65e9b56e 100644
--- a/arch/sh/boards/mach-x3proto/gpio.c
+++ b/arch/sh/boards/mach-x3proto/gpio.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Renesas SH-X3 Prototype Baseboard GPIO Support. 4 * Renesas SH-X3 Prototype Baseboard GPIO Support.
5 * 5 *
6 * Copyright (C) 2010 Paul Mundt 6 * Copyright (C) 2010 - 2012 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
@@ -17,6 +17,7 @@
17#include <linux/irq.h> 17#include <linux/irq.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/spinlock.h> 19#include <linux/spinlock.h>
20#include <linux/irqdomain.h>
20#include <linux/io.h> 21#include <linux/io.h>
21#include <mach/ilsel.h> 22#include <mach/ilsel.h>
22#include <mach/hardware.h> 23#include <mach/hardware.h>
@@ -26,7 +27,7 @@
26#define KEYDETR 0xb81c0004 27#define KEYDETR 0xb81c0004
27 28
28static DEFINE_SPINLOCK(x3proto_gpio_lock); 29static DEFINE_SPINLOCK(x3proto_gpio_lock);
29static unsigned int x3proto_gpio_irq_map[NR_BASEBOARD_GPIOS] = { 0, }; 30static struct irq_domain *x3proto_irq_domain;
30 31
31static int x3proto_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) 32static int x3proto_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
32{ 33{
@@ -49,7 +50,14 @@ static int x3proto_gpio_get(struct gpio_chip *chip, unsigned gpio)
49 50
50static int x3proto_gpio_to_irq(struct gpio_chip *chip, unsigned gpio) 51static int x3proto_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
51{ 52{
52 return x3proto_gpio_irq_map[gpio]; 53 int virq;
54
55 if (gpio < chip->ngpio)
56 virq = irq_create_mapping(x3proto_irq_domain, gpio);
57 else
58 virq = -ENXIO;
59
60 return virq;
53} 61}
54 62
55static void x3proto_gpio_irq_handler(unsigned int irq, struct irq_desc *desc) 63static void x3proto_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
@@ -62,9 +70,8 @@ static void x3proto_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
62 chip->irq_mask_ack(data); 70 chip->irq_mask_ack(data);
63 71
64 mask = __raw_readw(KEYDETR); 72 mask = __raw_readw(KEYDETR);
65
66 for_each_set_bit(pin, &mask, NR_BASEBOARD_GPIOS) 73 for_each_set_bit(pin, &mask, NR_BASEBOARD_GPIOS)
67 generic_handle_irq(x3proto_gpio_to_irq(NULL, pin)); 74 generic_handle_irq(irq_linear_revmap(x3proto_irq_domain, pin));
68 75
69 chip->irq_unmask(data); 76 chip->irq_unmask(data);
70} 77}
@@ -78,10 +85,23 @@ struct gpio_chip x3proto_gpio_chip = {
78 .ngpio = NR_BASEBOARD_GPIOS, 85 .ngpio = NR_BASEBOARD_GPIOS,
79}; 86};
80 87
88static int x3proto_gpio_irq_map(struct irq_domain *domain, unsigned int virq,
89 irq_hw_number_t hwirq)
90{
91 irq_set_chip_and_handler_name(virq, &dummy_irq_chip, handle_simple_irq,
92 "gpio");
93
94 return 0;
95}
96
97static struct irq_domain_ops x3proto_gpio_irq_ops = {
98 .map = x3proto_gpio_irq_map,
99 .xlate = irq_domain_xlate_twocell,
100};
101
81int __init x3proto_gpio_setup(void) 102int __init x3proto_gpio_setup(void)
82{ 103{
83 int ilsel; 104 int ilsel, ret;
84 int ret, i;
85 105
86 ilsel = ilsel_enable(ILSEL_KEY); 106 ilsel = ilsel_enable(ILSEL_KEY);
87 if (unlikely(ilsel < 0)) 107 if (unlikely(ilsel < 0))
@@ -91,21 +111,10 @@ int __init x3proto_gpio_setup(void)
91 if (unlikely(ret)) 111 if (unlikely(ret))
92 goto err_gpio; 112 goto err_gpio;
93 113
94 for (i = 0; i < NR_BASEBOARD_GPIOS; i++) { 114 x3proto_irq_domain = irq_domain_add_linear(NULL, NR_BASEBOARD_GPIOS,
95 unsigned long flags; 115 &x3proto_gpio_irq_ops, NULL);
96 int irq = create_irq(); 116 if (unlikely(!x3proto_irq_domain))
97 117 goto err_irq;
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 irq_set_chip_and_handler_name(irq, &dummy_irq_chip,
106 handle_simple_irq, "gpio");
107 spin_unlock_irqrestore(&x3proto_gpio_lock, flags);
108 }
109 118
110 pr_info("registering '%s' support, handling GPIOs %u -> %u, " 119 pr_info("registering '%s' support, handling GPIOs %u -> %u, "
111 "bound to IRQ %u\n", 120 "bound to IRQ %u\n",
@@ -119,10 +128,6 @@ int __init x3proto_gpio_setup(void)
119 return 0; 128 return 0;
120 129
121err_irq: 130err_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); 131 ret = gpiochip_remove(&x3proto_gpio_chip);
127 if (unlikely(ret)) 132 if (unlikely(ret))
128 pr_err("Failed deregistering GPIO\n"); 133 pr_err("Failed deregistering GPIO\n");
diff --git a/arch/sh/cchips/hd6446x/hd64461.c b/arch/sh/cchips/hd6446x/hd64461.c
index eb4ea4d44d5..e9735616bdc 100644
--- a/arch/sh/cchips/hd6446x/hd64461.c
+++ b/arch/sh/cchips/hd6446x/hd64461.c
@@ -73,10 +73,7 @@ static void hd64461_irq_demux(unsigned int irq, struct irq_desc *desc)
73 73
74int __init setup_hd64461(void) 74int __init setup_hd64461(void)
75{ 75{
76 int i, nid = cpu_to_node(boot_cpu_data); 76 int irq_base, i;
77
78 if (!MACH_HD64461)
79 return 0;
80 77
81 printk(KERN_INFO 78 printk(KERN_INFO
82 "HD64461 configured at 0x%x on irq %d(mapped into %d to %d)\n", 79 "HD64461 configured at 0x%x on irq %d(mapped into %d to %d)\n",
@@ -89,28 +86,16 @@ int __init setup_hd64461(void)
89#endif 86#endif
90 __raw_writew(0xffff, HD64461_NIMR); 87 __raw_writew(0xffff, HD64461_NIMR);
91 88
92 /* IRQ 80 -> 95 belongs to HD64461 */ 89 irq_base = irq_alloc_descs(HD64461_IRQBASE, HD64461_IRQBASE, 16, -1);
93 for (i = HD64461_IRQBASE; i < HD64461_IRQBASE + 16; i++) { 90 if (IS_ERR_VALUE(irq_base)) {
94 unsigned int irq; 91 pr_err("%s: failed hooking irqs for HD64461\n", __func__);
95 92 return irq_base;
96 irq = create_irq_nr(i, nid);
97 if (unlikely(irq == 0)) {
98 pr_err("%s: failed hooking irq %d for HD64461\n",
99 __func__, i);
100 return -EBUSY;
101 }
102
103 if (unlikely(irq != i)) {
104 pr_err("%s: got irq %d but wanted %d, bailing.\n",
105 __func__, irq, i);
106 destroy_irq(irq);
107 return -EINVAL;
108 }
109
110 irq_set_chip_and_handler(i, &hd64461_irq_chip,
111 handle_level_irq);
112 } 93 }
113 94
95 for (i = 0; i < 16; i++)
96 irq_set_chip_and_handler(irq_base + i, &hd64461_irq_chip,
97 handle_level_irq);
98
114 irq_set_chained_handler(CONFIG_HD64461_IRQ, hd64461_irq_demux); 99 irq_set_chained_handler(CONFIG_HD64461_IRQ, hd64461_irq_demux);
115 irq_set_irq_type(CONFIG_HD64461_IRQ, IRQ_TYPE_LEVEL_LOW); 100 irq_set_irq_type(CONFIG_HD64461_IRQ, IRQ_TYPE_LEVEL_LOW);
116 101
diff --git a/arch/sh/configs/apsh4ad0a_defconfig b/arch/sh/configs/apsh4ad0a_defconfig
index e7583484cc0..95ae23fcfdd 100644
--- a/arch/sh/configs/apsh4ad0a_defconfig
+++ b/arch/sh/configs/apsh4ad0a_defconfig
@@ -11,7 +11,7 @@ CONFIG_CGROUP_FREEZER=y
11CONFIG_CGROUP_DEVICE=y 11CONFIG_CGROUP_DEVICE=y
12CONFIG_CGROUP_CPUACCT=y 12CONFIG_CGROUP_CPUACCT=y
13CONFIG_RESOURCE_COUNTERS=y 13CONFIG_RESOURCE_COUNTERS=y
14CONFIG_CGROUP_MEM_RES_CTLR=y 14CONFIG_CGROUP_MEMCG=y
15CONFIG_BLK_CGROUP=y 15CONFIG_BLK_CGROUP=y
16CONFIG_NAMESPACES=y 16CONFIG_NAMESPACES=y
17CONFIG_BLK_DEV_INITRD=y 17CONFIG_BLK_DEV_INITRD=y
diff --git a/arch/sh/configs/sdk7786_defconfig b/arch/sh/configs/sdk7786_defconfig
index 8a7dd7b59c5..76a76a295d7 100644
--- a/arch/sh/configs/sdk7786_defconfig
+++ b/arch/sh/configs/sdk7786_defconfig
@@ -18,8 +18,8 @@ CONFIG_CPUSETS=y
18# CONFIG_PROC_PID_CPUSET is not set 18# CONFIG_PROC_PID_CPUSET is not set
19CONFIG_CGROUP_CPUACCT=y 19CONFIG_CGROUP_CPUACCT=y
20CONFIG_RESOURCE_COUNTERS=y 20CONFIG_RESOURCE_COUNTERS=y
21CONFIG_CGROUP_MEM_RES_CTLR=y 21CONFIG_CGROUP_MEMCG=y
22CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y 22CONFIG_CGROUP_MEMCG_SWAP=y
23CONFIG_CGROUP_SCHED=y 23CONFIG_CGROUP_SCHED=y
24CONFIG_RT_GROUP_SCHED=y 24CONFIG_RT_GROUP_SCHED=y
25CONFIG_BLK_CGROUP=y 25CONFIG_BLK_CGROUP=y
diff --git a/arch/sh/configs/se7206_defconfig b/arch/sh/configs/se7206_defconfig
index 72c3fad7383..6bc30ab9fd1 100644
--- a/arch/sh/configs/se7206_defconfig
+++ b/arch/sh/configs/se7206_defconfig
@@ -11,7 +11,7 @@ CONFIG_CGROUP_DEBUG=y
11CONFIG_CGROUP_DEVICE=y 11CONFIG_CGROUP_DEVICE=y
12CONFIG_CGROUP_CPUACCT=y 12CONFIG_CGROUP_CPUACCT=y
13CONFIG_RESOURCE_COUNTERS=y 13CONFIG_RESOURCE_COUNTERS=y
14CONFIG_CGROUP_MEM_RES_CTLR=y 14CONFIG_CGROUP_MEMCG=y
15CONFIG_RELAY=y 15CONFIG_RELAY=y
16CONFIG_NAMESPACES=y 16CONFIG_NAMESPACES=y
17CONFIG_UTS_NS=y 17CONFIG_UTS_NS=y
diff --git a/arch/sh/configs/shx3_defconfig b/arch/sh/configs/shx3_defconfig
index 6bb41303689..cd6c519f8fa 100644
--- a/arch/sh/configs/shx3_defconfig
+++ b/arch/sh/configs/shx3_defconfig
@@ -13,7 +13,7 @@ CONFIG_CGROUP_FREEZER=y
13CONFIG_CGROUP_DEVICE=y 13CONFIG_CGROUP_DEVICE=y
14CONFIG_CGROUP_CPUACCT=y 14CONFIG_CGROUP_CPUACCT=y
15CONFIG_RESOURCE_COUNTERS=y 15CONFIG_RESOURCE_COUNTERS=y
16CONFIG_CGROUP_MEM_RES_CTLR=y 16CONFIG_CGROUP_MEMCG=y
17CONFIG_RELAY=y 17CONFIG_RELAY=y
18CONFIG_NAMESPACES=y 18CONFIG_NAMESPACES=y
19CONFIG_UTS_NS=y 19CONFIG_UTS_NS=y
diff --git a/arch/sh/configs/urquell_defconfig b/arch/sh/configs/urquell_defconfig
index 8bfa4d056d7..d7f89be9f47 100644
--- a/arch/sh/configs/urquell_defconfig
+++ b/arch/sh/configs/urquell_defconfig
@@ -15,8 +15,8 @@ CONFIG_CPUSETS=y
15# CONFIG_PROC_PID_CPUSET is not set 15# CONFIG_PROC_PID_CPUSET is not set
16CONFIG_CGROUP_CPUACCT=y 16CONFIG_CGROUP_CPUACCT=y
17CONFIG_RESOURCE_COUNTERS=y 17CONFIG_RESOURCE_COUNTERS=y
18CONFIG_CGROUP_MEM_RES_CTLR=y 18CONFIG_CGROUP_MEMCG=y
19CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y 19CONFIG_CGROUP_MEMCG_SWAP=y
20CONFIG_CGROUP_SCHED=y 20CONFIG_CGROUP_SCHED=y
21CONFIG_RT_GROUP_SCHED=y 21CONFIG_RT_GROUP_SCHED=y
22CONFIG_BLK_DEV_INITRD=y 22CONFIG_BLK_DEV_INITRD=y
diff --git a/arch/sh/drivers/dma/dma-sh.c b/arch/sh/drivers/dma/dma-sh.c
index 4c171f13b0e..b2256562314 100644
--- a/arch/sh/drivers/dma/dma-sh.c
+++ b/arch/sh/drivers/dma/dma-sh.c
@@ -335,7 +335,7 @@ static int dmae_irq_init(void)
335 335
336 for (n = 0; n < NR_DMAE; n++) { 336 for (n = 0; n < NR_DMAE; n++) {
337 int i = request_irq(get_dma_error_irq(n), dma_err, 337 int i = request_irq(get_dma_error_irq(n), dma_err,
338 IRQF_SHARED, dmae_name[n], NULL); 338 IRQF_SHARED, dmae_name[n], (void *)dmae_name[n]);
339 if (unlikely(i < 0)) { 339 if (unlikely(i < 0)) {
340 printk(KERN_ERR "%s request_irq fail\n", dmae_name[n]); 340 printk(KERN_ERR "%s request_irq fail\n", dmae_name[n]);
341 return i; 341 return i;
diff --git a/arch/sh/drivers/pci/fixups-dreamcast.c b/arch/sh/drivers/pci/fixups-dreamcast.c
index edeea8960c3..a5fe1b54c95 100644
--- a/arch/sh/drivers/pci/fixups-dreamcast.c
+++ b/arch/sh/drivers/pci/fixups-dreamcast.c
@@ -28,7 +28,7 @@
28#include <asm/irq.h> 28#include <asm/irq.h>
29#include <mach/pci.h> 29#include <mach/pci.h>
30 30
31static void __init gapspci_fixup_resources(struct pci_dev *dev) 31static void __devinit gapspci_fixup_resources(struct pci_dev *dev)
32{ 32{
33 struct pci_channel *p = dev->sysdata; 33 struct pci_channel *p = dev->sysdata;
34 34
diff --git a/arch/sh/drivers/pci/fixups-sdk7786.c b/arch/sh/drivers/pci/fixups-sdk7786.c
index 0e18ee33255..36eb6fc3c18 100644
--- a/arch/sh/drivers/pci/fixups-sdk7786.c
+++ b/arch/sh/drivers/pci/fixups-sdk7786.c
@@ -23,9 +23,9 @@
23 * Misconfigurations can be detected through the FPGA via the slot 23 * Misconfigurations can be detected through the FPGA via the slot
24 * resistors to determine card presence. Hotplug remains unsupported. 24 * resistors to determine card presence. Hotplug remains unsupported.
25 */ 25 */
26static unsigned int slot4en __devinitdata; 26static unsigned int slot4en __initdata;
27 27
28char *__devinit pcibios_setup(char *str) 28char *__init pcibios_setup(char *str)
29{ 29{
30 if (strcmp(str, "slot4en") == 0) { 30 if (strcmp(str, "slot4en") == 0) {
31 slot4en = 1; 31 slot4en = 1;
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 9d10a3cb879..40db2d0aef3 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -59,7 +59,7 @@ static void __devinit pcibios_scanbus(struct pci_channel *hose)
59 need_domain_info = need_domain_info || hose->index; 59 need_domain_info = need_domain_info || hose->index;
60 hose->need_domain_info = need_domain_info; 60 hose->need_domain_info = need_domain_info;
61 if (bus) { 61 if (bus) {
62 next_busno = bus->subordinate + 1; 62 next_busno = bus->busn_res.end + 1;
63 /* Don't allow 8-bit bus number overflow inside the hose - 63 /* Don't allow 8-bit bus number overflow inside the hose -
64 reserve some space for bridges. */ 64 reserve some space for bridges. */
65 if (next_busno > 224) { 65 if (next_busno > 224) {
@@ -197,11 +197,6 @@ void __init pcibios_update_irq(struct pci_dev *dev, int irq)
197 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 197 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
198} 198}
199 199
200char * __devinit __weak pcibios_setup(char *str)
201{
202 return str;
203}
204
205static void __init 200static void __init
206pcibios_bus_report_status_early(struct pci_channel *hose, 201pcibios_bus_report_status_early(struct pci_channel *hose,
207 int top_bus, int current_bus, 202 int top_bus, int current_bus,
diff --git a/arch/sh/include/asm/bug.h b/arch/sh/include/asm/bug.h
index 2b87d86bfc4..dcf27807542 100644
--- a/arch/sh/include/asm/bug.h
+++ b/arch/sh/include/asm/bug.h
@@ -110,6 +110,10 @@ do { \
110#include <asm-generic/bug.h> 110#include <asm-generic/bug.h>
111 111
112struct pt_regs; 112struct pt_regs;
113
114/* arch/sh/kernel/traps.c */
113extern void die(const char *str, struct pt_regs *regs, long err) __attribute__ ((noreturn)); 115extern void die(const char *str, struct pt_regs *regs, long err) __attribute__ ((noreturn));
116extern void die_if_kernel(const char *str, struct pt_regs *regs, long err);
117extern void die_if_no_fixup(const char *str, struct pt_regs *regs, long err);
114 118
115#endif /* __ASM_SH_BUG_H */ 119#endif /* __ASM_SH_BUG_H */
diff --git a/arch/sh/include/asm/kdebug.h b/arch/sh/include/asm/kdebug.h
index a6201f10c27..8d6a831e7ba 100644
--- a/arch/sh/include/asm/kdebug.h
+++ b/arch/sh/include/asm/kdebug.h
@@ -10,6 +10,8 @@ enum die_val {
10 DIE_SSTEP, 10 DIE_SSTEP,
11}; 11};
12 12
13/* arch/sh/kernel/dumpstack.c */
13extern void printk_address(unsigned long address, int reliable); 14extern void printk_address(unsigned long address, int reliable);
15extern void dump_mem(const char *str, unsigned long bottom, unsigned long top);
14 16
15#endif /* __ASM_SH_KDEBUG_H */ 17#endif /* __ASM_SH_KDEBUG_H */
diff --git a/arch/sh/include/asm/sections.h b/arch/sh/include/asm/sections.h
index 4a5350037c8..1b6199740e9 100644
--- a/arch/sh/include/asm/sections.h
+++ b/arch/sh/include/asm/sections.h
@@ -6,7 +6,6 @@
6extern long __nosave_begin, __nosave_end; 6extern long __nosave_begin, __nosave_end;
7extern long __machvec_start, __machvec_end; 7extern long __machvec_start, __machvec_end;
8extern char __uncached_start, __uncached_end; 8extern char __uncached_start, __uncached_end;
9extern char _ebss[];
10extern char __start_eh_frame[], __stop_eh_frame[]; 9extern char __start_eh_frame[], __stop_eh_frame[];
11 10
12#endif /* __ASM_SH_SECTIONS_H */ 11#endif /* __ASM_SH_SECTIONS_H */
diff --git a/arch/sh/include/asm/siu.h b/arch/sh/include/asm/siu.h
index 1d95c78808d..580b7ac228b 100644
--- a/arch/sh/include/asm/siu.h
+++ b/arch/sh/include/asm/siu.h
@@ -14,7 +14,6 @@
14struct device; 14struct device;
15 15
16struct siu_platform { 16struct siu_platform {
17 struct device *dma_dev;
18 unsigned int dma_slave_tx_a; 17 unsigned int dma_slave_tx_a;
19 unsigned int dma_slave_rx_a; 18 unsigned int dma_slave_rx_a;
20 unsigned int dma_slave_tx_b; 19 unsigned int dma_slave_tx_b;
diff --git a/arch/sh/include/asm/unistd.h b/arch/sh/include/asm/unistd.h
index e800a38c9f8..7bc67076baa 100644
--- a/arch/sh/include/asm/unistd.h
+++ b/arch/sh/include/asm/unistd.h
@@ -6,7 +6,6 @@
6# endif 6# endif
7 7
8# define __ARCH_WANT_SYS_RT_SIGSUSPEND 8# define __ARCH_WANT_SYS_RT_SIGSUSPEND
9# define __ARCH_WANT_IPC_PARSE_VERSION
10# define __ARCH_WANT_OLD_READDIR 9# define __ARCH_WANT_OLD_READDIR
11# define __ARCH_WANT_OLD_STAT 10# define __ARCH_WANT_OLD_STAT
12# define __ARCH_WANT_STAT64 11# define __ARCH_WANT_STAT64
diff --git a/arch/sh/include/cpu-sh2a/cpu/sh7269.h b/arch/sh/include/cpu-sh2a/cpu/sh7269.h
index 48d14498e77..2a0ca8780f0 100644
--- a/arch/sh/include/cpu-sh2a/cpu/sh7269.h
+++ b/arch/sh/include/cpu-sh2a/cpu/sh7269.h
@@ -183,18 +183,30 @@ enum {
183 GPIO_FN_DV_DATA1, GPIO_FN_DV_DATA0, 183 GPIO_FN_DV_DATA1, GPIO_FN_DV_DATA0,
184 GPIO_FN_LCD_CLK, GPIO_FN_LCD_EXTCLK, 184 GPIO_FN_LCD_CLK, GPIO_FN_LCD_EXTCLK,
185 GPIO_FN_LCD_VSYNC, GPIO_FN_LCD_HSYNC, GPIO_FN_LCD_DE, 185 GPIO_FN_LCD_VSYNC, GPIO_FN_LCD_HSYNC, GPIO_FN_LCD_DE,
186 GPIO_FN_LCD_DATA23, GPIO_FN_LCD_DATA22, 186 GPIO_FN_LCD_DATA23_PG23, GPIO_FN_LCD_DATA22_PG22,
187 GPIO_FN_LCD_DATA21, GPIO_FN_LCD_DATA20, 187 GPIO_FN_LCD_DATA21_PG21, GPIO_FN_LCD_DATA20_PG20,
188 GPIO_FN_LCD_DATA19, GPIO_FN_LCD_DATA18, 188 GPIO_FN_LCD_DATA19_PG19, GPIO_FN_LCD_DATA18_PG18,
189 GPIO_FN_LCD_DATA17, GPIO_FN_LCD_DATA16, 189 GPIO_FN_LCD_DATA17_PG17, GPIO_FN_LCD_DATA16_PG16,
190 GPIO_FN_LCD_DATA15, GPIO_FN_LCD_DATA14, 190 GPIO_FN_LCD_DATA15_PG15, GPIO_FN_LCD_DATA14_PG14,
191 GPIO_FN_LCD_DATA13, GPIO_FN_LCD_DATA12, 191 GPIO_FN_LCD_DATA13_PG13, GPIO_FN_LCD_DATA12_PG12,
192 GPIO_FN_LCD_DATA11, GPIO_FN_LCD_DATA10, 192 GPIO_FN_LCD_DATA11_PG11, GPIO_FN_LCD_DATA10_PG10,
193 GPIO_FN_LCD_DATA9, GPIO_FN_LCD_DATA8, 193 GPIO_FN_LCD_DATA9_PG9, GPIO_FN_LCD_DATA8_PG8,
194 GPIO_FN_LCD_DATA7, GPIO_FN_LCD_DATA6, 194 GPIO_FN_LCD_DATA7_PG7, GPIO_FN_LCD_DATA6_PG6,
195 GPIO_FN_LCD_DATA5, GPIO_FN_LCD_DATA4, 195 GPIO_FN_LCD_DATA5_PG5, GPIO_FN_LCD_DATA4_PG4,
196 GPIO_FN_LCD_DATA3, GPIO_FN_LCD_DATA2, 196 GPIO_FN_LCD_DATA3_PG3, GPIO_FN_LCD_DATA2_PG2,
197 GPIO_FN_LCD_DATA1, GPIO_FN_LCD_DATA0, 197 GPIO_FN_LCD_DATA1_PG1, GPIO_FN_LCD_DATA0_PG0,
198 GPIO_FN_LCD_DATA23_PJ23, GPIO_FN_LCD_DATA22_PJ22,
199 GPIO_FN_LCD_DATA21_PJ21, GPIO_FN_LCD_DATA20_PJ20,
200 GPIO_FN_LCD_DATA19_PJ19, GPIO_FN_LCD_DATA18_PJ18,
201 GPIO_FN_LCD_DATA17_PJ17, GPIO_FN_LCD_DATA16_PJ16,
202 GPIO_FN_LCD_DATA15_PJ15, GPIO_FN_LCD_DATA14_PJ14,
203 GPIO_FN_LCD_DATA13_PJ13, GPIO_FN_LCD_DATA12_PJ12,
204 GPIO_FN_LCD_DATA11_PJ11, GPIO_FN_LCD_DATA10_PJ10,
205 GPIO_FN_LCD_DATA9_PJ9, GPIO_FN_LCD_DATA8_PJ8,
206 GPIO_FN_LCD_DATA7_PJ7, GPIO_FN_LCD_DATA6_PJ6,
207 GPIO_FN_LCD_DATA5_PJ5, GPIO_FN_LCD_DATA4_PJ4,
208 GPIO_FN_LCD_DATA3_PJ3, GPIO_FN_LCD_DATA2_PJ2,
209 GPIO_FN_LCD_DATA1_PJ1, GPIO_FN_LCD_DATA0_PJ0,
198 GPIO_FN_LCD_M_DISP, 210 GPIO_FN_LCD_M_DISP,
199}; 211};
200 212
diff --git a/arch/sh/include/cpu-sh4/cpu/sh7757.h b/arch/sh/include/cpu-sh4/cpu/sh7757.h
index 41f9f8b9db7..5340f3bc186 100644
--- a/arch/sh/include/cpu-sh4/cpu/sh7757.h
+++ b/arch/sh/include/cpu-sh4/cpu/sh7757.h
@@ -283,5 +283,7 @@ enum {
283 SHDMA_SLAVE_RIIC8_RX, 283 SHDMA_SLAVE_RIIC8_RX,
284 SHDMA_SLAVE_RIIC9_TX, 284 SHDMA_SLAVE_RIIC9_TX,
285 SHDMA_SLAVE_RIIC9_RX, 285 SHDMA_SLAVE_RIIC9_RX,
286 SHDMA_SLAVE_RSPI_TX,
287 SHDMA_SLAVE_RSPI_RX,
286}; 288};
287#endif /* __ASM_SH7757_H__ */ 289#endif /* __ASM_SH7757_H__ */
diff --git a/arch/sh/include/mach-se/mach/se7343.h b/arch/sh/include/mach-se/mach/se7343.h
index 50b5d575dff..542521c970c 100644
--- a/arch/sh/include/mach-se/mach/se7343.h
+++ b/arch/sh/include/mach-se/mach/se7343.h
@@ -50,9 +50,6 @@
50#define PA_LED 0xb0C00000 /* LED */ 50#define PA_LED 0xb0C00000 /* LED */
51#define LED_SHIFT 0 51#define LED_SHIFT 0
52#define PA_DIPSW 0xb0900000 /* Dip switch 31 */ 52#define PA_DIPSW 0xb0900000 /* Dip switch 31 */
53#define PA_CPLD_MODESET 0xb1400004 /* CPLD Mode set register */
54#define PA_CPLD_ST 0xb1400008 /* CPLD Interrupt status register */
55#define PA_CPLD_IMSK 0xb140000a /* CPLD Interrupt mask register */
56/* Area 5 */ 53/* Area 5 */
57#define PA_EXT5 0x14000000 54#define PA_EXT5 0x14000000
58#define PA_EXT5_SIZE 0x04000000 55#define PA_EXT5_SIZE 0x04000000
@@ -135,8 +132,10 @@
135 132
136#define SE7343_FPGA_IRQ_NR 12 133#define SE7343_FPGA_IRQ_NR 12
137 134
135struct irq_domain;
136
138/* arch/sh/boards/se/7343/irq.c */ 137/* arch/sh/boards/se/7343/irq.c */
139extern unsigned int se7343_fpga_irq[]; 138extern struct irq_domain *se7343_irq_domain;
140 139
141void init_7343se_IRQ(void); 140void init_7343se_IRQ(void);
142 141
diff --git a/arch/sh/include/mach-se/mach/se7722.h b/arch/sh/include/mach-se/mach/se7722.h
index 201081ebdbc..637e7ac753f 100644
--- a/arch/sh/include/mach-se/mach/se7722.h
+++ b/arch/sh/include/mach-se/mach/se7722.h
@@ -81,12 +81,6 @@
81#define IRQ0_IRQ evt2irq(0x600) 81#define IRQ0_IRQ evt2irq(0x600)
82#define IRQ1_IRQ evt2irq(0x620) 82#define IRQ1_IRQ evt2irq(0x620)
83 83
84#define IRQ01_MODE 0xb1800000
85#define IRQ01_STS 0xb1800004
86#define IRQ01_MASK 0xb1800008
87
88/* Bits in IRQ01_* registers */
89
90#define SE7722_FPGA_IRQ_USB 0 /* IRQ0 */ 84#define SE7722_FPGA_IRQ_USB 0 /* IRQ0 */
91#define SE7722_FPGA_IRQ_SMC 1 /* IRQ0 */ 85#define SE7722_FPGA_IRQ_SMC 1 /* IRQ0 */
92#define SE7722_FPGA_IRQ_MRSHPC0 2 /* IRQ1 */ 86#define SE7722_FPGA_IRQ_MRSHPC0 2 /* IRQ1 */
@@ -95,8 +89,10 @@
95#define SE7722_FPGA_IRQ_MRSHPC3 5 /* IRQ1 */ 89#define SE7722_FPGA_IRQ_MRSHPC3 5 /* IRQ1 */
96#define SE7722_FPGA_IRQ_NR 6 90#define SE7722_FPGA_IRQ_NR 6
97 91
92struct irq_domain;
93
98/* arch/sh/boards/se/7722/irq.c */ 94/* arch/sh/boards/se/7722/irq.c */
99extern unsigned int se7722_fpga_irq[]; 95extern struct irq_domain *se7722_irq_domain;
100 96
101void init_se7722_IRQ(void); 97void init_se7722_IRQ(void);
102 98
diff --git a/arch/sh/kernel/cpu/sh2a/pinmux-sh7269.c b/arch/sh/kernel/cpu/sh2a/pinmux-sh7269.c
index f25127c46ec..039e4587dd9 100644
--- a/arch/sh/kernel/cpu/sh2a/pinmux-sh7269.c
+++ b/arch/sh/kernel/cpu/sh2a/pinmux-sh7269.c
@@ -758,12 +758,22 @@ enum {
758 DV_DATA3_MARK, DV_DATA2_MARK, DV_DATA1_MARK, DV_DATA0_MARK, 758 DV_DATA3_MARK, DV_DATA2_MARK, DV_DATA1_MARK, DV_DATA0_MARK,
759 LCD_CLK_MARK, LCD_EXTCLK_MARK, 759 LCD_CLK_MARK, LCD_EXTCLK_MARK,
760 LCD_VSYNC_MARK, LCD_HSYNC_MARK, LCD_DE_MARK, 760 LCD_VSYNC_MARK, LCD_HSYNC_MARK, LCD_DE_MARK,
761 LCD_DATA23_MARK, LCD_DATA22_MARK, LCD_DATA21_MARK, LCD_DATA20_MARK, 761 LCD_DATA23_PG23_MARK, LCD_DATA22_PG22_MARK, LCD_DATA21_PG21_MARK,
762 LCD_DATA19_MARK, LCD_DATA18_MARK, LCD_DATA17_MARK, LCD_DATA16_MARK, 762 LCD_DATA20_PG20_MARK, LCD_DATA19_PG19_MARK, LCD_DATA18_PG18_MARK,
763 LCD_DATA15_MARK, LCD_DATA14_MARK, LCD_DATA13_MARK, LCD_DATA12_MARK, 763 LCD_DATA17_PG17_MARK, LCD_DATA16_PG16_MARK, LCD_DATA15_PG15_MARK,
764 LCD_DATA11_MARK, LCD_DATA10_MARK, LCD_DATA9_MARK, LCD_DATA8_MARK, 764 LCD_DATA14_PG14_MARK, LCD_DATA13_PG13_MARK, LCD_DATA12_PG12_MARK,
765 LCD_DATA7_MARK, LCD_DATA6_MARK, LCD_DATA5_MARK, LCD_DATA4_MARK, 765 LCD_DATA11_PG11_MARK, LCD_DATA10_PG10_MARK, LCD_DATA9_PG9_MARK,
766 LCD_DATA3_MARK, LCD_DATA2_MARK, LCD_DATA1_MARK, LCD_DATA0_MARK, 766 LCD_DATA8_PG8_MARK, LCD_DATA7_PG7_MARK, LCD_DATA6_PG6_MARK,
767 LCD_DATA5_PG5_MARK, LCD_DATA4_PG4_MARK, LCD_DATA3_PG3_MARK,
768 LCD_DATA2_PG2_MARK, LCD_DATA1_PG1_MARK, LCD_DATA0_PG0_MARK,
769 LCD_DATA23_PJ23_MARK, LCD_DATA22_PJ22_MARK, LCD_DATA21_PJ21_MARK,
770 LCD_DATA20_PJ20_MARK, LCD_DATA19_PJ19_MARK, LCD_DATA18_PJ18_MARK,
771 LCD_DATA17_PJ17_MARK, LCD_DATA16_PJ16_MARK, LCD_DATA15_PJ15_MARK,
772 LCD_DATA14_PJ14_MARK, LCD_DATA13_PJ13_MARK, LCD_DATA12_PJ12_MARK,
773 LCD_DATA11_PJ11_MARK, LCD_DATA10_PJ10_MARK, LCD_DATA9_PJ9_MARK,
774 LCD_DATA8_PJ8_MARK, LCD_DATA7_PJ7_MARK, LCD_DATA6_PJ6_MARK,
775 LCD_DATA5_PJ5_MARK, LCD_DATA4_PJ4_MARK, LCD_DATA3_PJ3_MARK,
776 LCD_DATA2_PJ2_MARK, LCD_DATA1_PJ1_MARK, LCD_DATA0_PJ0_MARK,
767 LCD_TCON6_MARK, LCD_TCON5_MARK, LCD_TCON4_MARK, 777 LCD_TCON6_MARK, LCD_TCON5_MARK, LCD_TCON4_MARK,
768 LCD_TCON3_MARK, LCD_TCON2_MARK, LCD_TCON1_MARK, LCD_TCON0_MARK, 778 LCD_TCON3_MARK, LCD_TCON2_MARK, LCD_TCON1_MARK, LCD_TCON0_MARK,
769 LCD_M_DISP_MARK, 779 LCD_M_DISP_MARK,
@@ -1036,6 +1046,7 @@ static pinmux_enum_t pinmux_data[] = {
1036 1046
1037 PINMUX_DATA(PF1_DATA, PF1MD_000), 1047 PINMUX_DATA(PF1_DATA, PF1MD_000),
1038 PINMUX_DATA(BACK_MARK, PF1MD_001), 1048 PINMUX_DATA(BACK_MARK, PF1MD_001),
1049 PINMUX_DATA(SSL10_MARK, PF1MD_011),
1039 PINMUX_DATA(TIOC4B_MARK, PF1MD_100), 1050 PINMUX_DATA(TIOC4B_MARK, PF1MD_100),
1040 PINMUX_DATA(DACK0_MARK, PF1MD_101), 1051 PINMUX_DATA(DACK0_MARK, PF1MD_101),
1041 1052
@@ -1049,47 +1060,50 @@ static pinmux_enum_t pinmux_data[] = {
1049 PINMUX_DATA(PG27_DATA, PG27MD_00), 1060 PINMUX_DATA(PG27_DATA, PG27MD_00),
1050 PINMUX_DATA(LCD_TCON2_MARK, PG27MD_10), 1061 PINMUX_DATA(LCD_TCON2_MARK, PG27MD_10),
1051 PINMUX_DATA(LCD_EXTCLK_MARK, PG27MD_11), 1062 PINMUX_DATA(LCD_EXTCLK_MARK, PG27MD_11),
1063 PINMUX_DATA(LCD_DE_MARK, PG27MD_11),
1052 1064
1053 PINMUX_DATA(PG26_DATA, PG26MD_00), 1065 PINMUX_DATA(PG26_DATA, PG26MD_00),
1054 PINMUX_DATA(LCD_TCON1_MARK, PG26MD_10), 1066 PINMUX_DATA(LCD_TCON1_MARK, PG26MD_10),
1067 PINMUX_DATA(LCD_HSYNC_MARK, PG26MD_10),
1055 1068
1056 PINMUX_DATA(PG25_DATA, PG25MD_00), 1069 PINMUX_DATA(PG25_DATA, PG25MD_00),
1057 PINMUX_DATA(LCD_TCON0_MARK, PG25MD_10), 1070 PINMUX_DATA(LCD_TCON0_MARK, PG25MD_10),
1071 PINMUX_DATA(LCD_VSYNC_MARK, PG25MD_10),
1058 1072
1059 PINMUX_DATA(PG24_DATA, PG24MD_00), 1073 PINMUX_DATA(PG24_DATA, PG24MD_00),
1060 PINMUX_DATA(LCD_CLK_MARK, PG24MD_10), 1074 PINMUX_DATA(LCD_CLK_MARK, PG24MD_10),
1061 1075
1062 PINMUX_DATA(PG23_DATA, PG23MD_000), 1076 PINMUX_DATA(PG23_DATA, PG23MD_000),
1063 PINMUX_DATA(LCD_DATA23_MARK, PG23MD_010), 1077 PINMUX_DATA(LCD_DATA23_PG23_MARK, PG23MD_010),
1064 PINMUX_DATA(LCD_TCON6_MARK, PG23MD_011), 1078 PINMUX_DATA(LCD_TCON6_MARK, PG23MD_011),
1065 PINMUX_DATA(TXD5_MARK, PG23MD_100), 1079 PINMUX_DATA(TXD5_MARK, PG23MD_100),
1066 1080
1067 PINMUX_DATA(PG22_DATA, PG22MD_000), 1081 PINMUX_DATA(PG22_DATA, PG22MD_000),
1068 PINMUX_DATA(LCD_DATA22_MARK, PG22MD_010), 1082 PINMUX_DATA(LCD_DATA22_PG22_MARK, PG22MD_010),
1069 PINMUX_DATA(LCD_TCON5_MARK, PG22MD_011), 1083 PINMUX_DATA(LCD_TCON5_MARK, PG22MD_011),
1070 PINMUX_DATA(RXD5_MARK, PG22MD_100), 1084 PINMUX_DATA(RXD5_MARK, PG22MD_100),
1071 1085
1072 PINMUX_DATA(PG21_DATA, PG21MD_000), 1086 PINMUX_DATA(PG21_DATA, PG21MD_000),
1073 PINMUX_DATA(DV_DATA7_MARK, PG21MD_001), 1087 PINMUX_DATA(DV_DATA7_MARK, PG21MD_001),
1074 PINMUX_DATA(LCD_DATA21_MARK, PG21MD_010), 1088 PINMUX_DATA(LCD_DATA21_PG21_MARK, PG21MD_010),
1075 PINMUX_DATA(LCD_TCON4_MARK, PG21MD_011), 1089 PINMUX_DATA(LCD_TCON4_MARK, PG21MD_011),
1076 PINMUX_DATA(TXD4_MARK, PG21MD_100), 1090 PINMUX_DATA(TXD4_MARK, PG21MD_100),
1077 1091
1078 PINMUX_DATA(PG20_DATA, PG20MD_000), 1092 PINMUX_DATA(PG20_DATA, PG20MD_000),
1079 PINMUX_DATA(DV_DATA6_MARK, PG20MD_001), 1093 PINMUX_DATA(DV_DATA6_MARK, PG20MD_001),
1080 PINMUX_DATA(LCD_DATA20_MARK, PG21MD_010), 1094 PINMUX_DATA(LCD_DATA20_PG20_MARK, PG21MD_010),
1081 PINMUX_DATA(LCD_TCON3_MARK, PG20MD_011), 1095 PINMUX_DATA(LCD_TCON3_MARK, PG20MD_011),
1082 PINMUX_DATA(RXD4_MARK, PG20MD_100), 1096 PINMUX_DATA(RXD4_MARK, PG20MD_100),
1083 1097
1084 PINMUX_DATA(PG19_DATA, PG19MD_000), 1098 PINMUX_DATA(PG19_DATA, PG19MD_000),
1085 PINMUX_DATA(DV_DATA5_MARK, PG19MD_001), 1099 PINMUX_DATA(DV_DATA5_MARK, PG19MD_001),
1086 PINMUX_DATA(LCD_DATA19_MARK, PG19MD_010), 1100 PINMUX_DATA(LCD_DATA19_PG19_MARK, PG19MD_010),
1087 PINMUX_DATA(SPDIF_OUT_MARK, PG19MD_011), 1101 PINMUX_DATA(SPDIF_OUT_MARK, PG19MD_011),
1088 PINMUX_DATA(SCK5_MARK, PG19MD_100), 1102 PINMUX_DATA(SCK5_MARK, PG19MD_100),
1089 1103
1090 PINMUX_DATA(PG18_DATA, PG18MD_000), 1104 PINMUX_DATA(PG18_DATA, PG18MD_000),
1091 PINMUX_DATA(DV_DATA4_MARK, PG18MD_001), 1105 PINMUX_DATA(DV_DATA4_MARK, PG18MD_001),
1092 PINMUX_DATA(LCD_DATA18_MARK, PG18MD_010), 1106 PINMUX_DATA(LCD_DATA18_PG18_MARK, PG18MD_010),
1093 PINMUX_DATA(SPDIF_IN_MARK, PG18MD_011), 1107 PINMUX_DATA(SPDIF_IN_MARK, PG18MD_011),
1094 PINMUX_DATA(SCK4_MARK, PG18MD_100), 1108 PINMUX_DATA(SCK4_MARK, PG18MD_100),
1095 1109
@@ -1097,103 +1111,103 @@ static pinmux_enum_t pinmux_data[] = {
1097// we're going with 2 bits 1111// we're going with 2 bits
1098 PINMUX_DATA(PG17_DATA, PG17MD_00), 1112 PINMUX_DATA(PG17_DATA, PG17MD_00),
1099 PINMUX_DATA(WE3ICIOWRAHDQMUU_MARK, PG17MD_01), 1113 PINMUX_DATA(WE3ICIOWRAHDQMUU_MARK, PG17MD_01),
1100 PINMUX_DATA(LCD_DATA17_MARK, PG17MD_10), 1114 PINMUX_DATA(LCD_DATA17_PG17_MARK, PG17MD_10),
1101 1115
1102// TODO hardware manual has PG16 3 bits wide in reg picture and 2 bits in description 1116// TODO hardware manual has PG16 3 bits wide in reg picture and 2 bits in description
1103// we're going with 2 bits 1117// we're going with 2 bits
1104 PINMUX_DATA(PG16_DATA, PG16MD_00), 1118 PINMUX_DATA(PG16_DATA, PG16MD_00),
1105 PINMUX_DATA(WE2ICIORDDQMUL_MARK, PG16MD_01), 1119 PINMUX_DATA(WE2ICIORDDQMUL_MARK, PG16MD_01),
1106 PINMUX_DATA(LCD_DATA16_MARK, PG16MD_10), 1120 PINMUX_DATA(LCD_DATA16_PG16_MARK, PG16MD_10),
1107 1121
1108 PINMUX_DATA(PG15_DATA, PG15MD_00), 1122 PINMUX_DATA(PG15_DATA, PG15MD_00),
1109 PINMUX_DATA(D31_MARK, PG15MD_01), 1123 PINMUX_DATA(D31_MARK, PG15MD_01),
1110 PINMUX_DATA(LCD_DATA15_MARK, PG15MD_10), 1124 PINMUX_DATA(LCD_DATA15_PG15_MARK, PG15MD_10),
1111 PINMUX_DATA(PINT7_PG_MARK, PG15MD_11), 1125 PINMUX_DATA(PINT7_PG_MARK, PG15MD_11),
1112 1126
1113 PINMUX_DATA(PG14_DATA, PG14MD_00), 1127 PINMUX_DATA(PG14_DATA, PG14MD_00),
1114 PINMUX_DATA(D30_MARK, PG14MD_01), 1128 PINMUX_DATA(D30_MARK, PG14MD_01),
1115 PINMUX_DATA(LCD_DATA14_MARK, PG14MD_10), 1129 PINMUX_DATA(LCD_DATA14_PG14_MARK, PG14MD_10),
1116 PINMUX_DATA(PINT6_PG_MARK, PG14MD_11), 1130 PINMUX_DATA(PINT6_PG_MARK, PG14MD_11),
1117 1131
1118 PINMUX_DATA(PG13_DATA, PG13MD_00), 1132 PINMUX_DATA(PG13_DATA, PG13MD_00),
1119 PINMUX_DATA(D29_MARK, PG13MD_01), 1133 PINMUX_DATA(D29_MARK, PG13MD_01),
1120 PINMUX_DATA(LCD_DATA13_MARK, PG13MD_10), 1134 PINMUX_DATA(LCD_DATA13_PG13_MARK, PG13MD_10),
1121 PINMUX_DATA(PINT5_PG_MARK, PG13MD_11), 1135 PINMUX_DATA(PINT5_PG_MARK, PG13MD_11),
1122 1136
1123 PINMUX_DATA(PG12_DATA, PG12MD_00), 1137 PINMUX_DATA(PG12_DATA, PG12MD_00),
1124 PINMUX_DATA(D28_MARK, PG12MD_01), 1138 PINMUX_DATA(D28_MARK, PG12MD_01),
1125 PINMUX_DATA(LCD_DATA12_MARK, PG12MD_10), 1139 PINMUX_DATA(LCD_DATA12_PG12_MARK, PG12MD_10),
1126 PINMUX_DATA(PINT4_PG_MARK, PG12MD_11), 1140 PINMUX_DATA(PINT4_PG_MARK, PG12MD_11),
1127 1141
1128 PINMUX_DATA(PG11_DATA, PG11MD_000), 1142 PINMUX_DATA(PG11_DATA, PG11MD_000),
1129 PINMUX_DATA(D27_MARK, PG11MD_001), 1143 PINMUX_DATA(D27_MARK, PG11MD_001),
1130 PINMUX_DATA(LCD_DATA11_MARK, PG11MD_010), 1144 PINMUX_DATA(LCD_DATA11_PG11_MARK, PG11MD_010),
1131 PINMUX_DATA(PINT3_PG_MARK, PG11MD_011), 1145 PINMUX_DATA(PINT3_PG_MARK, PG11MD_011),
1132 PINMUX_DATA(TIOC3D_MARK, PG11MD_100), 1146 PINMUX_DATA(TIOC3D_MARK, PG11MD_100),
1133 1147
1134 PINMUX_DATA(PG10_DATA, PG10MD_000), 1148 PINMUX_DATA(PG10_DATA, PG10MD_000),
1135 PINMUX_DATA(D26_MARK, PG10MD_001), 1149 PINMUX_DATA(D26_MARK, PG10MD_001),
1136 PINMUX_DATA(LCD_DATA10_MARK, PG10MD_010), 1150 PINMUX_DATA(LCD_DATA10_PG10_MARK, PG10MD_010),
1137 PINMUX_DATA(PINT2_PG_MARK, PG10MD_011), 1151 PINMUX_DATA(PINT2_PG_MARK, PG10MD_011),
1138 PINMUX_DATA(TIOC3C_MARK, PG10MD_100), 1152 PINMUX_DATA(TIOC3C_MARK, PG10MD_100),
1139 1153
1140 PINMUX_DATA(PG9_DATA, PG9MD_000), 1154 PINMUX_DATA(PG9_DATA, PG9MD_000),
1141 PINMUX_DATA(D25_MARK, PG9MD_001), 1155 PINMUX_DATA(D25_MARK, PG9MD_001),
1142 PINMUX_DATA(LCD_DATA9_MARK, PG9MD_010), 1156 PINMUX_DATA(LCD_DATA9_PG9_MARK, PG9MD_010),
1143 PINMUX_DATA(PINT1_PG_MARK, PG9MD_011), 1157 PINMUX_DATA(PINT1_PG_MARK, PG9MD_011),
1144 PINMUX_DATA(TIOC3B_MARK, PG9MD_100), 1158 PINMUX_DATA(TIOC3B_MARK, PG9MD_100),
1145 1159
1146 PINMUX_DATA(PG8_DATA, PG8MD_000), 1160 PINMUX_DATA(PG8_DATA, PG8MD_000),
1147 PINMUX_DATA(D24_MARK, PG8MD_001), 1161 PINMUX_DATA(D24_MARK, PG8MD_001),
1148 PINMUX_DATA(LCD_DATA8_MARK, PG8MD_010), 1162 PINMUX_DATA(LCD_DATA8_PG8_MARK, PG8MD_010),
1149 PINMUX_DATA(PINT0_PG_MARK, PG8MD_011), 1163 PINMUX_DATA(PINT0_PG_MARK, PG8MD_011),
1150 PINMUX_DATA(TIOC3A_MARK, PG8MD_100), 1164 PINMUX_DATA(TIOC3A_MARK, PG8MD_100),
1151 1165
1152 PINMUX_DATA(PG7_DATA, PG7MD_000), 1166 PINMUX_DATA(PG7_DATA, PG7MD_000),
1153 PINMUX_DATA(D23_MARK, PG7MD_001), 1167 PINMUX_DATA(D23_MARK, PG7MD_001),
1154 PINMUX_DATA(LCD_DATA7_MARK, PG7MD_010), 1168 PINMUX_DATA(LCD_DATA7_PG7_MARK, PG7MD_010),
1155 PINMUX_DATA(IRQ7_PG_MARK, PG7MD_011), 1169 PINMUX_DATA(IRQ7_PG_MARK, PG7MD_011),
1156 PINMUX_DATA(TIOC2B_MARK, PG7MD_100), 1170 PINMUX_DATA(TIOC2B_MARK, PG7MD_100),
1157 1171
1158 PINMUX_DATA(PG6_DATA, PG6MD_000), 1172 PINMUX_DATA(PG6_DATA, PG6MD_000),
1159 PINMUX_DATA(D22_MARK, PG6MD_001), 1173 PINMUX_DATA(D22_MARK, PG6MD_001),
1160 PINMUX_DATA(LCD_DATA6_MARK, PG6MD_010), 1174 PINMUX_DATA(LCD_DATA6_PG6_MARK, PG6MD_010),
1161 PINMUX_DATA(IRQ6_PG_MARK, PG6MD_011), 1175 PINMUX_DATA(IRQ6_PG_MARK, PG6MD_011),
1162 PINMUX_DATA(TIOC2A_MARK, PG6MD_100), 1176 PINMUX_DATA(TIOC2A_MARK, PG6MD_100),
1163 1177
1164 PINMUX_DATA(PG5_DATA, PG5MD_000), 1178 PINMUX_DATA(PG5_DATA, PG5MD_000),
1165 PINMUX_DATA(D21_MARK, PG5MD_001), 1179 PINMUX_DATA(D21_MARK, PG5MD_001),
1166 PINMUX_DATA(LCD_DATA5_MARK, PG5MD_010), 1180 PINMUX_DATA(LCD_DATA5_PG5_MARK, PG5MD_010),
1167 PINMUX_DATA(IRQ5_PG_MARK, PG5MD_011), 1181 PINMUX_DATA(IRQ5_PG_MARK, PG5MD_011),
1168 PINMUX_DATA(TIOC1B_MARK, PG5MD_100), 1182 PINMUX_DATA(TIOC1B_MARK, PG5MD_100),
1169 1183
1170 PINMUX_DATA(PG4_DATA, PG4MD_000), 1184 PINMUX_DATA(PG4_DATA, PG4MD_000),
1171 PINMUX_DATA(D20_MARK, PG4MD_001), 1185 PINMUX_DATA(D20_MARK, PG4MD_001),
1172 PINMUX_DATA(LCD_DATA4_MARK, PG4MD_010), 1186 PINMUX_DATA(LCD_DATA4_PG4_MARK, PG4MD_010),
1173 PINMUX_DATA(IRQ4_PG_MARK, PG4MD_011), 1187 PINMUX_DATA(IRQ4_PG_MARK, PG4MD_011),
1174 PINMUX_DATA(TIOC1A_MARK, PG4MD_100), 1188 PINMUX_DATA(TIOC1A_MARK, PG4MD_100),
1175 1189
1176 PINMUX_DATA(PG3_DATA, PG3MD_000), 1190 PINMUX_DATA(PG3_DATA, PG3MD_000),
1177 PINMUX_DATA(D19_MARK, PG3MD_001), 1191 PINMUX_DATA(D19_MARK, PG3MD_001),
1178 PINMUX_DATA(LCD_DATA3_MARK, PG3MD_010), 1192 PINMUX_DATA(LCD_DATA3_PG3_MARK, PG3MD_010),
1179 PINMUX_DATA(IRQ3_PG_MARK, PG3MD_011), 1193 PINMUX_DATA(IRQ3_PG_MARK, PG3MD_011),
1180 PINMUX_DATA(TIOC0D_MARK, PG3MD_100), 1194 PINMUX_DATA(TIOC0D_MARK, PG3MD_100),
1181 1195
1182 PINMUX_DATA(PG2_DATA, PG2MD_000), 1196 PINMUX_DATA(PG2_DATA, PG2MD_000),
1183 PINMUX_DATA(D18_MARK, PG2MD_001), 1197 PINMUX_DATA(D18_MARK, PG2MD_001),
1184 PINMUX_DATA(LCD_DATA2_MARK, PG2MD_010), 1198 PINMUX_DATA(LCD_DATA2_PG2_MARK, PG2MD_010),
1185 PINMUX_DATA(IRQ2_PG_MARK, PG2MD_011), 1199 PINMUX_DATA(IRQ2_PG_MARK, PG2MD_011),
1186 PINMUX_DATA(TIOC0C_MARK, PG2MD_100), 1200 PINMUX_DATA(TIOC0C_MARK, PG2MD_100),
1187 1201
1188 PINMUX_DATA(PG1_DATA, PG1MD_000), 1202 PINMUX_DATA(PG1_DATA, PG1MD_000),
1189 PINMUX_DATA(D17_MARK, PG1MD_001), 1203 PINMUX_DATA(D17_MARK, PG1MD_001),
1190 PINMUX_DATA(LCD_DATA1_MARK, PG1MD_010), 1204 PINMUX_DATA(LCD_DATA1_PG1_MARK, PG1MD_010),
1191 PINMUX_DATA(IRQ1_PG_MARK, PG1MD_011), 1205 PINMUX_DATA(IRQ1_PG_MARK, PG1MD_011),
1192 PINMUX_DATA(TIOC0B_MARK, PG1MD_100), 1206 PINMUX_DATA(TIOC0B_MARK, PG1MD_100),
1193 1207
1194 PINMUX_DATA(PG0_DATA, PG0MD_000), 1208 PINMUX_DATA(PG0_DATA, PG0MD_000),
1195 PINMUX_DATA(D16_MARK, PG0MD_001), 1209 PINMUX_DATA(D16_MARK, PG0MD_001),
1196 PINMUX_DATA(LCD_DATA0_MARK, PG0MD_010), 1210 PINMUX_DATA(LCD_DATA0_PG0_MARK, PG0MD_010),
1197 PINMUX_DATA(IRQ0_PG_MARK, PG0MD_011), 1211 PINMUX_DATA(IRQ0_PG_MARK, PG0MD_011),
1198 PINMUX_DATA(TIOC0A_MARK, PG0MD_100), 1212 PINMUX_DATA(TIOC0A_MARK, PG0MD_100),
1199 1213
@@ -1275,14 +1289,14 @@ static pinmux_enum_t pinmux_data[] = {
1275 1289
1276 PINMUX_DATA(PJ23_DATA, PJ23MD_000), 1290 PINMUX_DATA(PJ23_DATA, PJ23MD_000),
1277 PINMUX_DATA(DV_DATA23_MARK, PJ23MD_001), 1291 PINMUX_DATA(DV_DATA23_MARK, PJ23MD_001),
1278 PINMUX_DATA(LCD_DATA23_MARK, PJ23MD_010), 1292 PINMUX_DATA(LCD_DATA23_PJ23_MARK, PJ23MD_010),
1279 PINMUX_DATA(LCD_TCON6_MARK, PJ23MD_011), 1293 PINMUX_DATA(LCD_TCON6_MARK, PJ23MD_011),
1280 PINMUX_DATA(IRQ3_PJ_MARK, PJ23MD_100), 1294 PINMUX_DATA(IRQ3_PJ_MARK, PJ23MD_100),
1281 PINMUX_DATA(CTX1_MARK, PJ23MD_101), 1295 PINMUX_DATA(CTX1_MARK, PJ23MD_101),
1282 1296
1283 PINMUX_DATA(PJ22_DATA, PJ22MD_000), 1297 PINMUX_DATA(PJ22_DATA, PJ22MD_000),
1284 PINMUX_DATA(DV_DATA22_MARK, PJ22MD_001), 1298 PINMUX_DATA(DV_DATA22_MARK, PJ22MD_001),
1285 PINMUX_DATA(LCD_DATA22_MARK, PJ22MD_010), 1299 PINMUX_DATA(LCD_DATA22_PJ22_MARK, PJ22MD_010),
1286 PINMUX_DATA(LCD_TCON5_MARK, PJ22MD_011), 1300 PINMUX_DATA(LCD_TCON5_MARK, PJ22MD_011),
1287 PINMUX_DATA(IRQ2_PJ_MARK, PJ22MD_100), 1301 PINMUX_DATA(IRQ2_PJ_MARK, PJ22MD_100),
1288 PINMUX_DATA(CRX1_MARK, PJ22MD_101), 1302 PINMUX_DATA(CRX1_MARK, PJ22MD_101),
@@ -1290,14 +1304,14 @@ static pinmux_enum_t pinmux_data[] = {
1290 1304
1291 PINMUX_DATA(PJ21_DATA, PJ21MD_000), 1305 PINMUX_DATA(PJ21_DATA, PJ21MD_000),
1292 PINMUX_DATA(DV_DATA21_MARK, PJ21MD_001), 1306 PINMUX_DATA(DV_DATA21_MARK, PJ21MD_001),
1293 PINMUX_DATA(LCD_DATA21_MARK, PJ21MD_010), 1307 PINMUX_DATA(LCD_DATA21_PJ21_MARK, PJ21MD_010),
1294 PINMUX_DATA(LCD_TCON4_MARK, PJ21MD_011), 1308 PINMUX_DATA(LCD_TCON4_MARK, PJ21MD_011),
1295 PINMUX_DATA(IRQ1_PJ_MARK, PJ21MD_100), 1309 PINMUX_DATA(IRQ1_PJ_MARK, PJ21MD_100),
1296 PINMUX_DATA(CTX2_MARK, PJ21MD_101), 1310 PINMUX_DATA(CTX2_MARK, PJ21MD_101),
1297 1311
1298 PINMUX_DATA(PJ20_DATA, PJ20MD_000), 1312 PINMUX_DATA(PJ20_DATA, PJ20MD_000),
1299 PINMUX_DATA(DV_DATA20_MARK, PJ20MD_001), 1313 PINMUX_DATA(DV_DATA20_MARK, PJ20MD_001),
1300 PINMUX_DATA(LCD_DATA20_MARK, PJ20MD_010), 1314 PINMUX_DATA(LCD_DATA20_PJ20_MARK, PJ20MD_010),
1301 PINMUX_DATA(LCD_TCON3_MARK, PJ20MD_011), 1315 PINMUX_DATA(LCD_TCON3_MARK, PJ20MD_011),
1302 PINMUX_DATA(IRQ0_PJ_MARK, PJ20MD_100), 1316 PINMUX_DATA(IRQ0_PJ_MARK, PJ20MD_100),
1303 PINMUX_DATA(CRX2_MARK, PJ20MD_101), 1317 PINMUX_DATA(CRX2_MARK, PJ20MD_101),
@@ -1305,7 +1319,7 @@ static pinmux_enum_t pinmux_data[] = {
1305 1319
1306 PINMUX_DATA(PJ19_DATA, PJ19MD_000), 1320 PINMUX_DATA(PJ19_DATA, PJ19MD_000),
1307 PINMUX_DATA(DV_DATA19_MARK, PJ19MD_001), 1321 PINMUX_DATA(DV_DATA19_MARK, PJ19MD_001),
1308 PINMUX_DATA(LCD_DATA19_MARK, PJ19MD_010), 1322 PINMUX_DATA(LCD_DATA19_PJ19_MARK, PJ19MD_010),
1309 PINMUX_DATA(MISO0_PJ19_MARK, PJ19MD_011), 1323 PINMUX_DATA(MISO0_PJ19_MARK, PJ19MD_011),
1310 PINMUX_DATA(TIOC0D_MARK, PJ19MD_100), 1324 PINMUX_DATA(TIOC0D_MARK, PJ19MD_100),
1311 PINMUX_DATA(SIOFRXD_MARK, PJ19MD_101), 1325 PINMUX_DATA(SIOFRXD_MARK, PJ19MD_101),
@@ -1313,126 +1327,126 @@ static pinmux_enum_t pinmux_data[] = {
1313 1327
1314 PINMUX_DATA(PJ18_DATA, PJ18MD_000), 1328 PINMUX_DATA(PJ18_DATA, PJ18MD_000),
1315 PINMUX_DATA(DV_DATA18_MARK, PJ18MD_001), 1329 PINMUX_DATA(DV_DATA18_MARK, PJ18MD_001),
1316 PINMUX_DATA(LCD_DATA18_MARK, PJ18MD_010), 1330 PINMUX_DATA(LCD_DATA18_PJ18_MARK, PJ18MD_010),
1317 PINMUX_DATA(MOSI0_PJ18_MARK, PJ18MD_011), 1331 PINMUX_DATA(MOSI0_PJ18_MARK, PJ18MD_011),
1318 PINMUX_DATA(TIOC0C_MARK, PJ18MD_100), 1332 PINMUX_DATA(TIOC0C_MARK, PJ18MD_100),
1319 PINMUX_DATA(SIOFTXD_MARK, PJ18MD_101), 1333 PINMUX_DATA(SIOFTXD_MARK, PJ18MD_101),
1320 1334
1321 PINMUX_DATA(PJ17_DATA, PJ17MD_000), 1335 PINMUX_DATA(PJ17_DATA, PJ17MD_000),
1322 PINMUX_DATA(DV_DATA17_MARK, PJ17MD_001), 1336 PINMUX_DATA(DV_DATA17_MARK, PJ17MD_001),
1323 PINMUX_DATA(LCD_DATA17_MARK, PJ17MD_010), 1337 PINMUX_DATA(LCD_DATA17_PJ17_MARK, PJ17MD_010),
1324 PINMUX_DATA(SSL00_PJ17_MARK, PJ17MD_011), 1338 PINMUX_DATA(SSL00_PJ17_MARK, PJ17MD_011),
1325 PINMUX_DATA(TIOC0B_MARK, PJ17MD_100), 1339 PINMUX_DATA(TIOC0B_MARK, PJ17MD_100),
1326 PINMUX_DATA(SIOFSYNC_MARK, PJ17MD_101), 1340 PINMUX_DATA(SIOFSYNC_MARK, PJ17MD_101),
1327 1341
1328 PINMUX_DATA(PJ16_DATA, PJ16MD_000), 1342 PINMUX_DATA(PJ16_DATA, PJ16MD_000),
1329 PINMUX_DATA(DV_DATA16_MARK, PJ16MD_001), 1343 PINMUX_DATA(DV_DATA16_MARK, PJ16MD_001),
1330 PINMUX_DATA(LCD_DATA16_MARK, PJ16MD_010), 1344 PINMUX_DATA(LCD_DATA16_PJ16_MARK, PJ16MD_010),
1331 PINMUX_DATA(RSPCK0_PJ16_MARK, PJ16MD_011), 1345 PINMUX_DATA(RSPCK0_PJ16_MARK, PJ16MD_011),
1332 PINMUX_DATA(TIOC0A_MARK, PJ16MD_100), 1346 PINMUX_DATA(TIOC0A_MARK, PJ16MD_100),
1333 PINMUX_DATA(SIOFSCK_MARK, PJ16MD_101), 1347 PINMUX_DATA(SIOFSCK_MARK, PJ16MD_101),
1334 1348
1335 PINMUX_DATA(PJ15_DATA, PJ15MD_000), 1349 PINMUX_DATA(PJ15_DATA, PJ15MD_000),
1336 PINMUX_DATA(DV_DATA15_MARK, PJ15MD_001), 1350 PINMUX_DATA(DV_DATA15_MARK, PJ15MD_001),
1337 PINMUX_DATA(LCD_DATA15_MARK, PJ15MD_010), 1351 PINMUX_DATA(LCD_DATA15_PJ15_MARK, PJ15MD_010),
1338 PINMUX_DATA(PINT7_PJ_MARK, PJ15MD_011), 1352 PINMUX_DATA(PINT7_PJ_MARK, PJ15MD_011),
1339 PINMUX_DATA(PWM2H_MARK, PJ15MD_100), 1353 PINMUX_DATA(PWM2H_MARK, PJ15MD_100),
1340 PINMUX_DATA(TXD7_MARK, PJ15MD_101), 1354 PINMUX_DATA(TXD7_MARK, PJ15MD_101),
1341 1355
1342 PINMUX_DATA(PJ14_DATA, PJ14MD_000), 1356 PINMUX_DATA(PJ14_DATA, PJ14MD_000),
1343 PINMUX_DATA(DV_DATA14_MARK, PJ14MD_001), 1357 PINMUX_DATA(DV_DATA14_MARK, PJ14MD_001),
1344 PINMUX_DATA(LCD_DATA14_MARK, PJ14MD_010), 1358 PINMUX_DATA(LCD_DATA14_PJ14_MARK, PJ14MD_010),
1345 PINMUX_DATA(PINT6_PJ_MARK, PJ14MD_011), 1359 PINMUX_DATA(PINT6_PJ_MARK, PJ14MD_011),
1346 PINMUX_DATA(PWM2G_MARK, PJ14MD_100), 1360 PINMUX_DATA(PWM2G_MARK, PJ14MD_100),
1347 PINMUX_DATA(TXD6_MARK, PJ14MD_101), 1361 PINMUX_DATA(TXD6_MARK, PJ14MD_101),
1348 1362
1349 PINMUX_DATA(PJ13_DATA, PJ13MD_000), 1363 PINMUX_DATA(PJ13_DATA, PJ13MD_000),
1350 PINMUX_DATA(DV_DATA13_MARK, PJ13MD_001), 1364 PINMUX_DATA(DV_DATA13_MARK, PJ13MD_001),
1351 PINMUX_DATA(LCD_DATA13_MARK, PJ13MD_010), 1365 PINMUX_DATA(LCD_DATA13_PJ13_MARK, PJ13MD_010),
1352 PINMUX_DATA(PINT5_PJ_MARK, PJ13MD_011), 1366 PINMUX_DATA(PINT5_PJ_MARK, PJ13MD_011),
1353 PINMUX_DATA(PWM2F_MARK, PJ13MD_100), 1367 PINMUX_DATA(PWM2F_MARK, PJ13MD_100),
1354 PINMUX_DATA(TXD5_MARK, PJ13MD_101), 1368 PINMUX_DATA(TXD5_MARK, PJ13MD_101),
1355 1369
1356 PINMUX_DATA(PJ12_DATA, PJ12MD_000), 1370 PINMUX_DATA(PJ12_DATA, PJ12MD_000),
1357 PINMUX_DATA(DV_DATA12_MARK, PJ12MD_001), 1371 PINMUX_DATA(DV_DATA12_MARK, PJ12MD_001),
1358 PINMUX_DATA(LCD_DATA12_MARK, PJ12MD_010), 1372 PINMUX_DATA(LCD_DATA12_PJ12_MARK, PJ12MD_010),
1359 PINMUX_DATA(PINT4_PJ_MARK, PJ12MD_011), 1373 PINMUX_DATA(PINT4_PJ_MARK, PJ12MD_011),
1360 PINMUX_DATA(PWM2E_MARK, PJ12MD_100), 1374 PINMUX_DATA(PWM2E_MARK, PJ12MD_100),
1361 PINMUX_DATA(SCK7_MARK, PJ12MD_101), 1375 PINMUX_DATA(SCK7_MARK, PJ12MD_101),
1362 1376
1363 PINMUX_DATA(PJ11_DATA, PJ11MD_000), 1377 PINMUX_DATA(PJ11_DATA, PJ11MD_000),
1364 PINMUX_DATA(DV_DATA11_MARK, PJ11MD_001), 1378 PINMUX_DATA(DV_DATA11_MARK, PJ11MD_001),
1365 PINMUX_DATA(LCD_DATA11_MARK, PJ11MD_010), 1379 PINMUX_DATA(LCD_DATA11_PJ11_MARK, PJ11MD_010),
1366 PINMUX_DATA(PINT3_PJ_MARK, PJ11MD_011), 1380 PINMUX_DATA(PINT3_PJ_MARK, PJ11MD_011),
1367 PINMUX_DATA(PWM2D_MARK, PJ11MD_100), 1381 PINMUX_DATA(PWM2D_MARK, PJ11MD_100),
1368 PINMUX_DATA(SCK6_MARK, PJ11MD_101), 1382 PINMUX_DATA(SCK6_MARK, PJ11MD_101),
1369 1383
1370 PINMUX_DATA(PJ10_DATA, PJ10MD_000), 1384 PINMUX_DATA(PJ10_DATA, PJ10MD_000),
1371 PINMUX_DATA(DV_DATA10_MARK, PJ10MD_001), 1385 PINMUX_DATA(DV_DATA10_MARK, PJ10MD_001),
1372 PINMUX_DATA(LCD_DATA10_MARK, PJ10MD_010), 1386 PINMUX_DATA(LCD_DATA10_PJ10_MARK, PJ10MD_010),
1373 PINMUX_DATA(PINT2_PJ_MARK, PJ10MD_011), 1387 PINMUX_DATA(PINT2_PJ_MARK, PJ10MD_011),
1374 PINMUX_DATA(PWM2C_MARK, PJ10MD_100), 1388 PINMUX_DATA(PWM2C_MARK, PJ10MD_100),
1375 PINMUX_DATA(SCK5_MARK, PJ10MD_101), 1389 PINMUX_DATA(SCK5_MARK, PJ10MD_101),
1376 1390
1377 PINMUX_DATA(PJ9_DATA, PJ9MD_000), 1391 PINMUX_DATA(PJ9_DATA, PJ9MD_000),
1378 PINMUX_DATA(DV_DATA9_MARK, PJ9MD_001), 1392 PINMUX_DATA(DV_DATA9_MARK, PJ9MD_001),
1379 PINMUX_DATA(LCD_DATA9_MARK, PJ9MD_010), 1393 PINMUX_DATA(LCD_DATA9_PJ9_MARK, PJ9MD_010),
1380 PINMUX_DATA(PINT1_PJ_MARK, PJ9MD_011), 1394 PINMUX_DATA(PINT1_PJ_MARK, PJ9MD_011),
1381 PINMUX_DATA(PWM2B_MARK, PJ9MD_100), 1395 PINMUX_DATA(PWM2B_MARK, PJ9MD_100),
1382 PINMUX_DATA(RTS5_MARK, PJ9MD_101), 1396 PINMUX_DATA(RTS5_MARK, PJ9MD_101),
1383 1397
1384 PINMUX_DATA(PJ8_DATA, PJ8MD_000), 1398 PINMUX_DATA(PJ8_DATA, PJ8MD_000),
1385 PINMUX_DATA(DV_DATA8_MARK, PJ8MD_001), 1399 PINMUX_DATA(DV_DATA8_MARK, PJ8MD_001),
1386 PINMUX_DATA(LCD_DATA8_MARK, PJ8MD_010), 1400 PINMUX_DATA(LCD_DATA8_PJ8_MARK, PJ8MD_010),
1387 PINMUX_DATA(PINT0_PJ_MARK, PJ8MD_011), 1401 PINMUX_DATA(PINT0_PJ_MARK, PJ8MD_011),
1388 PINMUX_DATA(PWM2A_MARK, PJ8MD_100), 1402 PINMUX_DATA(PWM2A_MARK, PJ8MD_100),
1389 PINMUX_DATA(CTS5_MARK, PJ8MD_101), 1403 PINMUX_DATA(CTS5_MARK, PJ8MD_101),
1390 1404
1391 PINMUX_DATA(PJ7_DATA, PJ7MD_000), 1405 PINMUX_DATA(PJ7_DATA, PJ7MD_000),
1392 PINMUX_DATA(DV_DATA7_MARK, PJ7MD_001), 1406 PINMUX_DATA(DV_DATA7_MARK, PJ7MD_001),
1393 PINMUX_DATA(LCD_DATA7_MARK, PJ7MD_010), 1407 PINMUX_DATA(LCD_DATA7_PJ7_MARK, PJ7MD_010),
1394 PINMUX_DATA(SD_D2_MARK, PJ7MD_011), 1408 PINMUX_DATA(SD_D2_MARK, PJ7MD_011),
1395 PINMUX_DATA(PWM1H_MARK, PJ7MD_100), 1409 PINMUX_DATA(PWM1H_MARK, PJ7MD_100),
1396 1410
1397 PINMUX_DATA(PJ6_DATA, PJ6MD_000), 1411 PINMUX_DATA(PJ6_DATA, PJ6MD_000),
1398 PINMUX_DATA(DV_DATA6_MARK, PJ6MD_001), 1412 PINMUX_DATA(DV_DATA6_MARK, PJ6MD_001),
1399 PINMUX_DATA(LCD_DATA6_MARK, PJ6MD_010), 1413 PINMUX_DATA(LCD_DATA6_PJ6_MARK, PJ6MD_010),
1400 PINMUX_DATA(SD_D3_MARK, PJ6MD_011), 1414 PINMUX_DATA(SD_D3_MARK, PJ6MD_011),
1401 PINMUX_DATA(PWM1G_MARK, PJ6MD_100), 1415 PINMUX_DATA(PWM1G_MARK, PJ6MD_100),
1402 1416
1403 PINMUX_DATA(PJ5_DATA, PJ5MD_000), 1417 PINMUX_DATA(PJ5_DATA, PJ5MD_000),
1404 PINMUX_DATA(DV_DATA5_MARK, PJ5MD_001), 1418 PINMUX_DATA(DV_DATA5_MARK, PJ5MD_001),
1405 PINMUX_DATA(LCD_DATA5_MARK, PJ5MD_010), 1419 PINMUX_DATA(LCD_DATA5_PJ5_MARK, PJ5MD_010),
1406 PINMUX_DATA(SD_CMD_MARK, PJ5MD_011), 1420 PINMUX_DATA(SD_CMD_MARK, PJ5MD_011),
1407 PINMUX_DATA(PWM1F_MARK, PJ5MD_100), 1421 PINMUX_DATA(PWM1F_MARK, PJ5MD_100),
1408 1422
1409 PINMUX_DATA(PJ4_DATA, PJ4MD_000), 1423 PINMUX_DATA(PJ4_DATA, PJ4MD_000),
1410 PINMUX_DATA(DV_DATA4_MARK, PJ4MD_001), 1424 PINMUX_DATA(DV_DATA4_MARK, PJ4MD_001),
1411 PINMUX_DATA(LCD_DATA4_MARK, PJ4MD_010), 1425 PINMUX_DATA(LCD_DATA4_PJ4_MARK, PJ4MD_010),
1412 PINMUX_DATA(SD_CLK_MARK, PJ4MD_011), 1426 PINMUX_DATA(SD_CLK_MARK, PJ4MD_011),
1413 PINMUX_DATA(PWM1E_MARK, PJ4MD_100), 1427 PINMUX_DATA(PWM1E_MARK, PJ4MD_100),
1414 1428
1415 PINMUX_DATA(PJ3_DATA, PJ3MD_000), 1429 PINMUX_DATA(PJ3_DATA, PJ3MD_000),
1416 PINMUX_DATA(DV_DATA3_MARK, PJ3MD_001), 1430 PINMUX_DATA(DV_DATA3_MARK, PJ3MD_001),
1417 PINMUX_DATA(LCD_DATA3_MARK, PJ3MD_010), 1431 PINMUX_DATA(LCD_DATA3_PJ3_MARK, PJ3MD_010),
1418 PINMUX_DATA(SD_D0_MARK, PJ3MD_011), 1432 PINMUX_DATA(SD_D0_MARK, PJ3MD_011),
1419 PINMUX_DATA(PWM1D_MARK, PJ3MD_100), 1433 PINMUX_DATA(PWM1D_MARK, PJ3MD_100),
1420 1434
1421 PINMUX_DATA(PJ2_DATA, PJ2MD_000), 1435 PINMUX_DATA(PJ2_DATA, PJ2MD_000),
1422 PINMUX_DATA(DV_DATA2_MARK, PJ2MD_001), 1436 PINMUX_DATA(DV_DATA2_MARK, PJ2MD_001),
1423 PINMUX_DATA(LCD_DATA2_MARK, PJ2MD_010), 1437 PINMUX_DATA(LCD_DATA2_PJ2_MARK, PJ2MD_010),
1424 PINMUX_DATA(SD_D1_MARK, PJ2MD_011), 1438 PINMUX_DATA(SD_D1_MARK, PJ2MD_011),
1425 PINMUX_DATA(PWM1C_MARK, PJ2MD_100), 1439 PINMUX_DATA(PWM1C_MARK, PJ2MD_100),
1426 1440
1427 PINMUX_DATA(PJ1_DATA, PJ1MD_000), 1441 PINMUX_DATA(PJ1_DATA, PJ1MD_000),
1428 PINMUX_DATA(DV_DATA1_MARK, PJ1MD_001), 1442 PINMUX_DATA(DV_DATA1_MARK, PJ1MD_001),
1429 PINMUX_DATA(LCD_DATA1_MARK, PJ1MD_010), 1443 PINMUX_DATA(LCD_DATA1_PJ1_MARK, PJ1MD_010),
1430 PINMUX_DATA(SD_WP_MARK, PJ1MD_011), 1444 PINMUX_DATA(SD_WP_MARK, PJ1MD_011),
1431 PINMUX_DATA(PWM1B_MARK, PJ1MD_100), 1445 PINMUX_DATA(PWM1B_MARK, PJ1MD_100),
1432 1446
1433 PINMUX_DATA(PJ0_DATA, PJ0MD_000), 1447 PINMUX_DATA(PJ0_DATA, PJ0MD_000),
1434 PINMUX_DATA(DV_DATA0_MARK, PJ0MD_001), 1448 PINMUX_DATA(DV_DATA0_MARK, PJ0MD_001),
1435 PINMUX_DATA(LCD_DATA0_MARK, PJ0MD_010), 1449 PINMUX_DATA(LCD_DATA0_PJ0_MARK, PJ0MD_010),
1436 PINMUX_DATA(SD_CD_MARK, PJ0MD_011), 1450 PINMUX_DATA(SD_CD_MARK, PJ0MD_011),
1437 PINMUX_DATA(PWM1A_MARK, PJ0MD_100), 1451 PINMUX_DATA(PWM1A_MARK, PJ0MD_100),
1438}; 1452};
@@ -1877,30 +1891,55 @@ static struct pinmux_gpio pinmux_gpios[] = {
1877 PINMUX_GPIO(GPIO_FN_LCD_HSYNC, LCD_HSYNC_MARK), 1891 PINMUX_GPIO(GPIO_FN_LCD_HSYNC, LCD_HSYNC_MARK),
1878 PINMUX_GPIO(GPIO_FN_LCD_DE, LCD_DE_MARK), 1892 PINMUX_GPIO(GPIO_FN_LCD_DE, LCD_DE_MARK),
1879 1893
1880 PINMUX_GPIO(GPIO_FN_LCD_DATA23, LCD_DATA23_MARK), 1894 PINMUX_GPIO(GPIO_FN_LCD_DATA23_PG23, LCD_DATA23_PG23_MARK),
1881 PINMUX_GPIO(GPIO_FN_LCD_DATA22, LCD_DATA22_MARK), 1895 PINMUX_GPIO(GPIO_FN_LCD_DATA22_PG22, LCD_DATA22_PG22_MARK),
1882 PINMUX_GPIO(GPIO_FN_LCD_DATA21, LCD_DATA21_MARK), 1896 PINMUX_GPIO(GPIO_FN_LCD_DATA21_PG21, LCD_DATA21_PG21_MARK),
1883 PINMUX_GPIO(GPIO_FN_LCD_DATA20, LCD_DATA20_MARK), 1897 PINMUX_GPIO(GPIO_FN_LCD_DATA20_PG20, LCD_DATA20_PG20_MARK),
1884 PINMUX_GPIO(GPIO_FN_LCD_DATA19, LCD_DATA19_MARK), 1898 PINMUX_GPIO(GPIO_FN_LCD_DATA19_PG19, LCD_DATA19_PG19_MARK),
1885 PINMUX_GPIO(GPIO_FN_LCD_DATA18, LCD_DATA18_MARK), 1899 PINMUX_GPIO(GPIO_FN_LCD_DATA18_PG18, LCD_DATA18_PG18_MARK),
1886 PINMUX_GPIO(GPIO_FN_LCD_DATA17, LCD_DATA17_MARK), 1900 PINMUX_GPIO(GPIO_FN_LCD_DATA17_PG17, LCD_DATA17_PG17_MARK),
1887 PINMUX_GPIO(GPIO_FN_LCD_DATA16, LCD_DATA16_MARK), 1901 PINMUX_GPIO(GPIO_FN_LCD_DATA16_PG16, LCD_DATA16_PG16_MARK),
1888 PINMUX_GPIO(GPIO_FN_LCD_DATA15, LCD_DATA15_MARK), 1902 PINMUX_GPIO(GPIO_FN_LCD_DATA15_PG15, LCD_DATA15_PG15_MARK),
1889 PINMUX_GPIO(GPIO_FN_LCD_DATA14, LCD_DATA14_MARK), 1903 PINMUX_GPIO(GPIO_FN_LCD_DATA14_PG14, LCD_DATA14_PG14_MARK),
1890 PINMUX_GPIO(GPIO_FN_LCD_DATA13, LCD_DATA13_MARK), 1904 PINMUX_GPIO(GPIO_FN_LCD_DATA13_PG13, LCD_DATA13_PG13_MARK),
1891 PINMUX_GPIO(GPIO_FN_LCD_DATA12, LCD_DATA12_MARK), 1905 PINMUX_GPIO(GPIO_FN_LCD_DATA12_PG12, LCD_DATA12_PG12_MARK),
1892 PINMUX_GPIO(GPIO_FN_LCD_DATA11, LCD_DATA11_MARK), 1906 PINMUX_GPIO(GPIO_FN_LCD_DATA11_PG11, LCD_DATA11_PG11_MARK),
1893 PINMUX_GPIO(GPIO_FN_LCD_DATA10, LCD_DATA10_MARK), 1907 PINMUX_GPIO(GPIO_FN_LCD_DATA10_PG10, LCD_DATA10_PG10_MARK),
1894 PINMUX_GPIO(GPIO_FN_LCD_DATA9, LCD_DATA9_MARK), 1908 PINMUX_GPIO(GPIO_FN_LCD_DATA9_PG9, LCD_DATA9_PG9_MARK),
1895 PINMUX_GPIO(GPIO_FN_LCD_DATA8, LCD_DATA8_MARK), 1909 PINMUX_GPIO(GPIO_FN_LCD_DATA8_PG8, LCD_DATA8_PG8_MARK),
1896 PINMUX_GPIO(GPIO_FN_LCD_DATA7, LCD_DATA7_MARK), 1910 PINMUX_GPIO(GPIO_FN_LCD_DATA7_PG7, LCD_DATA7_PG7_MARK),
1897 PINMUX_GPIO(GPIO_FN_LCD_DATA6, LCD_DATA6_MARK), 1911 PINMUX_GPIO(GPIO_FN_LCD_DATA6_PG6, LCD_DATA6_PG6_MARK),
1898 PINMUX_GPIO(GPIO_FN_LCD_DATA5, LCD_DATA5_MARK), 1912 PINMUX_GPIO(GPIO_FN_LCD_DATA5_PG5, LCD_DATA5_PG5_MARK),
1899 PINMUX_GPIO(GPIO_FN_LCD_DATA4, LCD_DATA4_MARK), 1913 PINMUX_GPIO(GPIO_FN_LCD_DATA4_PG4, LCD_DATA4_PG4_MARK),
1900 PINMUX_GPIO(GPIO_FN_LCD_DATA3, LCD_DATA3_MARK), 1914 PINMUX_GPIO(GPIO_FN_LCD_DATA3_PG3, LCD_DATA3_PG3_MARK),
1901 PINMUX_GPIO(GPIO_FN_LCD_DATA2, LCD_DATA2_MARK), 1915 PINMUX_GPIO(GPIO_FN_LCD_DATA2_PG2, LCD_DATA2_PG2_MARK),
1902 PINMUX_GPIO(GPIO_FN_LCD_DATA1, LCD_DATA1_MARK), 1916 PINMUX_GPIO(GPIO_FN_LCD_DATA1_PG1, LCD_DATA1_PG1_MARK),
1903 PINMUX_GPIO(GPIO_FN_LCD_DATA0, LCD_DATA0_MARK), 1917 PINMUX_GPIO(GPIO_FN_LCD_DATA0_PG0, LCD_DATA0_PG0_MARK),
1918
1919 PINMUX_GPIO(GPIO_FN_LCD_DATA23_PJ23, LCD_DATA23_PJ23_MARK),
1920 PINMUX_GPIO(GPIO_FN_LCD_DATA22_PJ22, LCD_DATA22_PJ22_MARK),
1921 PINMUX_GPIO(GPIO_FN_LCD_DATA21_PJ21, LCD_DATA21_PJ21_MARK),
1922 PINMUX_GPIO(GPIO_FN_LCD_DATA20_PJ20, LCD_DATA20_PJ20_MARK),
1923 PINMUX_GPIO(GPIO_FN_LCD_DATA19_PJ19, LCD_DATA19_PJ19_MARK),
1924 PINMUX_GPIO(GPIO_FN_LCD_DATA18_PJ18, LCD_DATA18_PJ18_MARK),
1925 PINMUX_GPIO(GPIO_FN_LCD_DATA17_PJ17, LCD_DATA17_PJ17_MARK),
1926 PINMUX_GPIO(GPIO_FN_LCD_DATA16_PJ16, LCD_DATA16_PJ16_MARK),
1927 PINMUX_GPIO(GPIO_FN_LCD_DATA15_PJ15, LCD_DATA15_PJ15_MARK),
1928 PINMUX_GPIO(GPIO_FN_LCD_DATA14_PJ14, LCD_DATA14_PJ14_MARK),
1929 PINMUX_GPIO(GPIO_FN_LCD_DATA13_PJ13, LCD_DATA13_PJ13_MARK),
1930 PINMUX_GPIO(GPIO_FN_LCD_DATA12_PJ12, LCD_DATA12_PJ12_MARK),
1931 PINMUX_GPIO(GPIO_FN_LCD_DATA11_PJ11, LCD_DATA11_PJ11_MARK),
1932 PINMUX_GPIO(GPIO_FN_LCD_DATA10_PJ10, LCD_DATA10_PJ10_MARK),
1933 PINMUX_GPIO(GPIO_FN_LCD_DATA9_PJ9, LCD_DATA9_PJ9_MARK),
1934 PINMUX_GPIO(GPIO_FN_LCD_DATA8_PJ8, LCD_DATA8_PJ8_MARK),
1935 PINMUX_GPIO(GPIO_FN_LCD_DATA7_PJ7, LCD_DATA7_PJ7_MARK),
1936 PINMUX_GPIO(GPIO_FN_LCD_DATA6_PJ6, LCD_DATA6_PJ6_MARK),
1937 PINMUX_GPIO(GPIO_FN_LCD_DATA5_PJ5, LCD_DATA5_PJ5_MARK),
1938 PINMUX_GPIO(GPIO_FN_LCD_DATA4_PJ4, LCD_DATA4_PJ4_MARK),
1939 PINMUX_GPIO(GPIO_FN_LCD_DATA3_PJ3, LCD_DATA3_PJ3_MARK),
1940 PINMUX_GPIO(GPIO_FN_LCD_DATA2_PJ2, LCD_DATA2_PJ2_MARK),
1941 PINMUX_GPIO(GPIO_FN_LCD_DATA1_PJ1, LCD_DATA1_PJ1_MARK),
1942 PINMUX_GPIO(GPIO_FN_LCD_DATA0_PJ0, LCD_DATA0_PJ0_MARK),
1904 1943
1905 PINMUX_GPIO(GPIO_FN_LCD_M_DISP, LCD_M_DISP_MARK), 1944 PINMUX_GPIO(GPIO_FN_LCD_M_DISP, LCD_M_DISP_MARK),
1906}; 1945};
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
index c87e78f7323..5f30f805d2f 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
@@ -334,8 +334,8 @@ static struct clk_lookup lookups[] = {
334 CLKDEV_CON_ID("tpu0", &mstp_clks[HWBLK_TPU]), 334 CLKDEV_CON_ID("tpu0", &mstp_clks[HWBLK_TPU]),
335 CLKDEV_CON_ID("irda0", &mstp_clks[HWBLK_IRDA]), 335 CLKDEV_CON_ID("irda0", &mstp_clks[HWBLK_IRDA]),
336 CLKDEV_CON_ID("tsif0", &mstp_clks[HWBLK_TSIF]), 336 CLKDEV_CON_ID("tsif0", &mstp_clks[HWBLK_TSIF]),
337 CLKDEV_CON_ID("usb1", &mstp_clks[HWBLK_USB1]), 337 CLKDEV_DEV_ID("renesas_usbhs.1", &mstp_clks[HWBLK_USB1]),
338 CLKDEV_CON_ID("usb0", &mstp_clks[HWBLK_USB0]), 338 CLKDEV_DEV_ID("renesas_usbhs.0", &mstp_clks[HWBLK_USB0]),
339 CLKDEV_CON_ID("2dg0", &mstp_clks[HWBLK_2DG]), 339 CLKDEV_CON_ID("2dg0", &mstp_clks[HWBLK_2DG]),
340 CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[HWBLK_SDHI0]), 340 CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[HWBLK_SDHI0]),
341 CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[HWBLK_SDHI1]), 341 CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[HWBLK_SDHI1]),
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
index 0f5a21907da..6a868b091c2 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
@@ -12,6 +12,7 @@
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include <linux/serial.h> 13#include <linux/serial.h>
14#include <linux/serial_sci.h> 14#include <linux/serial_sci.h>
15#include <linux/sh_dma.h>
15#include <linux/sh_timer.h> 16#include <linux/sh_timer.h>
16#include <linux/sh_intc.h> 17#include <linux/sh_intc.h>
17#include <linux/uio_driver.h> 18#include <linux/uio_driver.h>
@@ -512,7 +513,6 @@ static struct platform_device tmu2_device = {
512}; 513};
513 514
514static struct siu_platform siu_platform_data = { 515static struct siu_platform siu_platform_data = {
515 .dma_dev = &dma_device.dev,
516 .dma_slave_tx_a = SHDMA_SLAVE_SIUA_TX, 516 .dma_slave_tx_a = SHDMA_SLAVE_SIUA_TX,
517 .dma_slave_rx_a = SHDMA_SLAVE_SIUA_RX, 517 .dma_slave_rx_a = SHDMA_SLAVE_SIUA_RX,
518 .dma_slave_tx_b = SHDMA_SLAVE_SIUB_TX, 518 .dma_slave_tx_b = SHDMA_SLAVE_SIUB_TX,
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7757.c b/arch/sh/kernel/cpu/sh4a/setup-sh7757.c
index a7708425afa..4a2f357f4df 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7757.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7757.c
@@ -216,6 +216,20 @@ static const struct sh_dmae_slave_config sh7757_dmae1_slaves[] = {
216 TS_INDEX2VAL(XMIT_SZ_8BIT), 216 TS_INDEX2VAL(XMIT_SZ_8BIT),
217 .mid_rid = 0x42, 217 .mid_rid = 0x42,
218 }, 218 },
219 {
220 .slave_id = SHDMA_SLAVE_RSPI_TX,
221 .addr = 0xfe480004,
222 .chcr = SM_INC | 0x800 | 0x40000000 |
223 TS_INDEX2VAL(XMIT_SZ_16BIT),
224 .mid_rid = 0xc1,
225 },
226 {
227 .slave_id = SHDMA_SLAVE_RSPI_RX,
228 .addr = 0xfe480004,
229 .chcr = DM_INC | 0x800 | 0x40000000 |
230 TS_INDEX2VAL(XMIT_SZ_16BIT),
231 .mid_rid = 0xc2,
232 },
219}; 233};
220 234
221static const struct sh_dmae_slave_config sh7757_dmae2_slaves[] = { 235static const struct sh_dmae_slave_config sh7757_dmae2_slaves[] = {
diff --git a/arch/sh/kernel/cpu/sh5/unwind.c b/arch/sh/kernel/cpu/sh5/unwind.c
index b205b25eaf4..10aed41757f 100644
--- a/arch/sh/kernel/cpu/sh5/unwind.c
+++ b/arch/sh/kernel/cpu/sh5/unwind.c
@@ -16,6 +16,8 @@
16#include <asm/ptrace.h> 16#include <asm/ptrace.h>
17#include <asm/processor.h> 17#include <asm/processor.h>
18#include <asm/io.h> 18#include <asm/io.h>
19#include <asm/unwinder.h>
20#include <asm/stacktrace.h>
19 21
20static u8 regcache[63]; 22static u8 regcache[63];
21 23
@@ -199,8 +201,11 @@ static int lookup_prev_stack_frame(unsigned long fp, unsigned long pc,
199 return 0; 201 return 0;
200} 202}
201 203
202/* Don't put this on the stack since we'll want to call sh64_unwind 204/*
203 * when we're close to underflowing the stack anyway. */ 205 * Don't put this on the stack since we'll want to call in to
206 * sh64_unwinder_dump() when we're close to underflowing the stack
207 * anyway.
208 */
204static struct pt_regs here_regs; 209static struct pt_regs here_regs;
205 210
206extern const char syscall_ret; 211extern const char syscall_ret;
@@ -208,17 +213,19 @@ extern const char ret_from_syscall;
208extern const char ret_from_exception; 213extern const char ret_from_exception;
209extern const char ret_from_irq; 214extern const char ret_from_irq;
210 215
211static void sh64_unwind_inner(struct pt_regs *regs); 216static void sh64_unwind_inner(const struct stacktrace_ops *ops,
217 void *data, struct pt_regs *regs);
212 218
213static void unwind_nested (unsigned long pc, unsigned long fp) 219static inline void unwind_nested(const struct stacktrace_ops *ops, void *data,
220 unsigned long pc, unsigned long fp)
214{ 221{
215 if ((fp >= __MEMORY_START) && 222 if ((fp >= __MEMORY_START) &&
216 ((fp & 7) == 0)) { 223 ((fp & 7) == 0))
217 sh64_unwind_inner((struct pt_regs *) fp); 224 sh64_unwind_inner(ops, data, (struct pt_regs *)fp);
218 }
219} 225}
220 226
221static void sh64_unwind_inner(struct pt_regs *regs) 227static void sh64_unwind_inner(const struct stacktrace_ops *ops,
228 void *data, struct pt_regs *regs)
222{ 229{
223 unsigned long pc, fp; 230 unsigned long pc, fp;
224 int ofs = 0; 231 int ofs = 0;
@@ -232,29 +239,29 @@ static void sh64_unwind_inner(struct pt_regs *regs)
232 int cond; 239 int cond;
233 unsigned long next_fp, next_pc; 240 unsigned long next_fp, next_pc;
234 241
235 if (pc == ((unsigned long) &syscall_ret & ~1)) { 242 if (pc == ((unsigned long)&syscall_ret & ~1)) {
236 printk("SYSCALL\n"); 243 printk("SYSCALL\n");
237 unwind_nested(pc,fp); 244 unwind_nested(ops, data, pc, fp);
238 return; 245 return;
239 } 246 }
240 247
241 if (pc == ((unsigned long) &ret_from_syscall & ~1)) { 248 if (pc == ((unsigned long)&ret_from_syscall & ~1)) {
242 printk("SYSCALL (PREEMPTED)\n"); 249 printk("SYSCALL (PREEMPTED)\n");
243 unwind_nested(pc,fp); 250 unwind_nested(ops, data, pc, fp);
244 return; 251 return;
245 } 252 }
246 253
247 /* In this case, the PC is discovered by lookup_prev_stack_frame but 254 /* In this case, the PC is discovered by lookup_prev_stack_frame but
248 it has 4 taken off it to look like the 'caller' */ 255 it has 4 taken off it to look like the 'caller' */
249 if (pc == ((unsigned long) &ret_from_exception & ~1)) { 256 if (pc == ((unsigned long)&ret_from_exception & ~1)) {
250 printk("EXCEPTION\n"); 257 printk("EXCEPTION\n");
251 unwind_nested(pc,fp); 258 unwind_nested(ops, data, pc, fp);
252 return; 259 return;
253 } 260 }
254 261
255 if (pc == ((unsigned long) &ret_from_irq & ~1)) { 262 if (pc == ((unsigned long)&ret_from_irq & ~1)) {
256 printk("IRQ\n"); 263 printk("IRQ\n");
257 unwind_nested(pc,fp); 264 unwind_nested(ops, data, pc, fp);
258 return; 265 return;
259 } 266 }
260 267
@@ -263,8 +270,7 @@ static void sh64_unwind_inner(struct pt_regs *regs)
263 270
264 pc -= ofs; 271 pc -= ofs;
265 272
266 printk("[<%08lx>] ", pc); 273 ops->address(data, pc, 1);
267 print_symbol("%s\n", pc);
268 274
269 if (first_pass) { 275 if (first_pass) {
270 /* If the innermost frame is a leaf function, it's 276 /* If the innermost frame is a leaf function, it's
@@ -287,10 +293,13 @@ static void sh64_unwind_inner(struct pt_regs *regs)
287 } 293 }
288 294
289 printk("\n"); 295 printk("\n");
290
291} 296}
292 297
293void sh64_unwind(struct pt_regs *regs) 298static void sh64_unwinder_dump(struct task_struct *task,
299 struct pt_regs *regs,
300 unsigned long *sp,
301 const struct stacktrace_ops *ops,
302 void *data)
294{ 303{
295 if (!regs) { 304 if (!regs) {
296 /* 305 /*
@@ -320,7 +329,17 @@ void sh64_unwind(struct pt_regs *regs)
320 ); 329 );
321 } 330 }
322 331
323 printk("\nCall Trace:\n"); 332 sh64_unwind_inner(ops, data, regs);
324 sh64_unwind_inner(regs);
325} 333}
326 334
335static struct unwinder sh64_unwinder = {
336 .name = "sh64-unwinder",
337 .dump = sh64_unwinder_dump,
338 .rating = 150,
339};
340
341static int __init sh64_unwinder_init(void)
342{
343 return unwinder_register(&sh64_unwinder);
344}
345early_initcall(sh64_unwinder_init);
diff --git a/arch/sh/kernel/dumpstack.c b/arch/sh/kernel/dumpstack.c
index 694158b9a50..7617dc4129a 100644
--- a/arch/sh/kernel/dumpstack.c
+++ b/arch/sh/kernel/dumpstack.c
@@ -2,13 +2,48 @@
2 * Copyright (C) 1991, 1992 Linus Torvalds 2 * Copyright (C) 1991, 1992 Linus Torvalds
3 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs 3 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
4 * Copyright (C) 2009 Matt Fleming 4 * Copyright (C) 2009 Matt Fleming
5 * Copyright (C) 2002 - 2012 Paul Mundt
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
5 */ 10 */
6#include <linux/kallsyms.h> 11#include <linux/kallsyms.h>
7#include <linux/ftrace.h> 12#include <linux/ftrace.h>
8#include <linux/debug_locks.h> 13#include <linux/debug_locks.h>
14#include <linux/kdebug.h>
15#include <linux/export.h>
16#include <linux/uaccess.h>
9#include <asm/unwinder.h> 17#include <asm/unwinder.h>
10#include <asm/stacktrace.h> 18#include <asm/stacktrace.h>
11 19
20void dump_mem(const char *str, unsigned long bottom, unsigned long top)
21{
22 unsigned long p;
23 int i;
24
25 printk("%s(0x%08lx to 0x%08lx)\n", str, bottom, top);
26
27 for (p = bottom & ~31; p < top; ) {
28 printk("%04lx: ", p & 0xffff);
29
30 for (i = 0; i < 8; i++, p += 4) {
31 unsigned int val;
32
33 if (p < bottom || p >= top)
34 printk(" ");
35 else {
36 if (__get_user(val, (unsigned int __user *)p)) {
37 printk("\n");
38 return;
39 }
40 printk("%08x ", val);
41 }
42 }
43 printk("\n");
44 }
45}
46
12void printk_address(unsigned long address, int reliable) 47void printk_address(unsigned long address, int reliable)
13{ 48{
14 printk(" [<%p>] %s%pS\n", (void *) address, 49 printk(" [<%p>] %s%pS\n", (void *) address,
@@ -106,3 +141,26 @@ void show_trace(struct task_struct *tsk, unsigned long *sp,
106 141
107 debug_show_held_locks(tsk); 142 debug_show_held_locks(tsk);
108} 143}
144
145void show_stack(struct task_struct *tsk, unsigned long *sp)
146{
147 unsigned long stack;
148
149 if (!tsk)
150 tsk = current;
151 if (tsk == current)
152 sp = (unsigned long *)current_stack_pointer;
153 else
154 sp = (unsigned long *)tsk->thread.sp;
155
156 stack = (unsigned long)sp;
157 dump_mem("Stack: ", stack, THREAD_SIZE +
158 (unsigned long)task_stack_page(tsk));
159 show_trace(tsk, sp, NULL);
160}
161
162void dump_stack(void)
163{
164 show_stack(NULL, NULL);
165}
166EXPORT_SYMBOL(dump_stack);
diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
index dadce735f74..063af10ff3c 100644
--- a/arch/sh/kernel/irq.c
+++ b/arch/sh/kernel/irq.c
@@ -231,16 +231,6 @@ void __init init_IRQ(void)
231 irq_ctx_init(smp_processor_id()); 231 irq_ctx_init(smp_processor_id());
232} 232}
233 233
234#ifdef CONFIG_SPARSE_IRQ
235int __init arch_probe_nr_irqs(void)
236{
237 /*
238 * No pre-allocated IRQs.
239 */
240 return 0;
241}
242#endif
243
244#ifdef CONFIG_HOTPLUG_CPU 234#ifdef CONFIG_HOTPLUG_CPU
245static void route_irq(struct irq_data *data, unsigned int irq, unsigned int cpu) 235static void route_irq(struct irq_data *data, unsigned int irq, unsigned int cpu)
246{ 236{
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 7b57bf1dc85..ebe7a7d9721 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -273,7 +273,7 @@ void __init setup_arch(char **cmdline_p)
273 data_resource.start = virt_to_phys(_etext); 273 data_resource.start = virt_to_phys(_etext);
274 data_resource.end = virt_to_phys(_edata)-1; 274 data_resource.end = virt_to_phys(_edata)-1;
275 bss_resource.start = virt_to_phys(__bss_start); 275 bss_resource.start = virt_to_phys(__bss_start);
276 bss_resource.end = virt_to_phys(_ebss)-1; 276 bss_resource.end = virt_to_phys(__bss_stop)-1;
277 277
278#ifdef CONFIG_CMDLINE_OVERWRITE 278#ifdef CONFIG_CMDLINE_OVERWRITE
279 strlcpy(command_line, CONFIG_CMDLINE, sizeof(command_line)); 279 strlcpy(command_line, CONFIG_CMDLINE, sizeof(command_line));
diff --git a/arch/sh/kernel/sh_ksyms_32.c b/arch/sh/kernel/sh_ksyms_32.c
index 3896f26efa4..2a0a596ebf6 100644
--- a/arch/sh/kernel/sh_ksyms_32.c
+++ b/arch/sh/kernel/sh_ksyms_32.c
@@ -19,7 +19,6 @@ EXPORT_SYMBOL(csum_partial);
19EXPORT_SYMBOL(csum_partial_copy_generic); 19EXPORT_SYMBOL(csum_partial_copy_generic);
20EXPORT_SYMBOL(copy_page); 20EXPORT_SYMBOL(copy_page);
21EXPORT_SYMBOL(__clear_user); 21EXPORT_SYMBOL(__clear_user);
22EXPORT_SYMBOL(_ebss);
23EXPORT_SYMBOL(empty_zero_page); 22EXPORT_SYMBOL(empty_zero_page);
24 23
25#define DECLARE_EXPORT(name) \ 24#define DECLARE_EXPORT(name) \
diff --git a/arch/sh/kernel/traps.c b/arch/sh/kernel/traps.c
index a87e58a9e38..72246bc0688 100644
--- a/arch/sh/kernel/traps.c
+++ b/arch/sh/kernel/traps.c
@@ -6,9 +6,80 @@
6#include <linux/sched.h> 6#include <linux/sched.h>
7#include <linux/uaccess.h> 7#include <linux/uaccess.h>
8#include <linux/hardirq.h> 8#include <linux/hardirq.h>
9#include <linux/kernel.h>
10#include <linux/kexec.h>
11#include <linux/module.h>
9#include <asm/unwinder.h> 12#include <asm/unwinder.h>
10#include <asm/traps.h> 13#include <asm/traps.h>
11 14
15static DEFINE_SPINLOCK(die_lock);
16
17void die(const char *str, struct pt_regs *regs, long err)
18{
19 static int die_counter;
20
21 oops_enter();
22
23 spin_lock_irq(&die_lock);
24 console_verbose();
25 bust_spinlocks(1);
26
27 printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
28 print_modules();
29 show_regs(regs);
30
31 printk("Process: %s (pid: %d, stack limit = %p)\n", current->comm,
32 task_pid_nr(current), task_stack_page(current) + 1);
33
34 if (!user_mode(regs) || in_interrupt())
35 dump_mem("Stack: ", regs->regs[15], THREAD_SIZE +
36 (unsigned long)task_stack_page(current));
37
38 notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV);
39
40 bust_spinlocks(0);
41 add_taint(TAINT_DIE);
42 spin_unlock_irq(&die_lock);
43 oops_exit();
44
45 if (kexec_should_crash(current))
46 crash_kexec(regs);
47
48 if (in_interrupt())
49 panic("Fatal exception in interrupt");
50
51 if (panic_on_oops)
52 panic("Fatal exception");
53
54 do_exit(SIGSEGV);
55}
56
57void die_if_kernel(const char *str, struct pt_regs *regs, long err)
58{
59 if (!user_mode(regs))
60 die(str, regs, err);
61}
62
63/*
64 * try and fix up kernelspace address errors
65 * - userspace errors just cause EFAULT to be returned, resulting in SEGV
66 * - kernel/userspace interfaces cause a jump to an appropriate handler
67 * - other kernel errors are bad
68 */
69void die_if_no_fixup(const char *str, struct pt_regs *regs, long err)
70{
71 if (!user_mode(regs)) {
72 const struct exception_table_entry *fixup;
73 fixup = search_exception_tables(regs->pc);
74 if (fixup) {
75 regs->pc = fixup->fixup;
76 return;
77 }
78
79 die(str, regs, err);
80 }
81}
82
12#ifdef CONFIG_GENERIC_BUG 83#ifdef CONFIG_GENERIC_BUG
13static void handle_BUG(struct pt_regs *regs) 84static void handle_BUG(struct pt_regs *regs)
14{ 85{
diff --git a/arch/sh/kernel/traps_32.c b/arch/sh/kernel/traps_32.c
index a37175deb73..5f513a64ded 100644
--- a/arch/sh/kernel/traps_32.c
+++ b/arch/sh/kernel/traps_32.c
@@ -16,13 +16,11 @@
16#include <linux/hardirq.h> 16#include <linux/hardirq.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/spinlock.h> 18#include <linux/spinlock.h>
19#include <linux/module.h>
20#include <linux/kallsyms.h> 19#include <linux/kallsyms.h>
21#include <linux/io.h> 20#include <linux/io.h>
22#include <linux/bug.h> 21#include <linux/bug.h>
23#include <linux/debug_locks.h> 22#include <linux/debug_locks.h>
24#include <linux/kdebug.h> 23#include <linux/kdebug.h>
25#include <linux/kexec.h>
26#include <linux/limits.h> 24#include <linux/limits.h>
27#include <linux/sysfs.h> 25#include <linux/sysfs.h>
28#include <linux/uaccess.h> 26#include <linux/uaccess.h>
@@ -48,102 +46,6 @@
48#define TRAP_ILLEGAL_SLOT_INST 13 46#define TRAP_ILLEGAL_SLOT_INST 13
49#endif 47#endif
50 48
51static void dump_mem(const char *str, unsigned long bottom, unsigned long top)
52{
53 unsigned long p;
54 int i;
55
56 printk("%s(0x%08lx to 0x%08lx)\n", str, bottom, top);
57
58 for (p = bottom & ~31; p < top; ) {
59 printk("%04lx: ", p & 0xffff);
60
61 for (i = 0; i < 8; i++, p += 4) {
62 unsigned int val;
63
64 if (p < bottom || p >= top)
65 printk(" ");
66 else {
67 if (__get_user(val, (unsigned int __user *)p)) {
68 printk("\n");
69 return;
70 }
71 printk("%08x ", val);
72 }
73 }
74 printk("\n");
75 }
76}
77
78static DEFINE_SPINLOCK(die_lock);
79
80void die(const char * str, struct pt_regs * regs, long err)
81{
82 static int die_counter;
83
84 oops_enter();
85
86 spin_lock_irq(&die_lock);
87 console_verbose();
88 bust_spinlocks(1);
89
90 printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
91 print_modules();
92 show_regs(regs);
93
94 printk("Process: %s (pid: %d, stack limit = %p)\n", current->comm,
95 task_pid_nr(current), task_stack_page(current) + 1);
96
97 if (!user_mode(regs) || in_interrupt())
98 dump_mem("Stack: ", regs->regs[15], THREAD_SIZE +
99 (unsigned long)task_stack_page(current));
100
101 notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV);
102
103 bust_spinlocks(0);
104 add_taint(TAINT_DIE);
105 spin_unlock_irq(&die_lock);
106 oops_exit();
107
108 if (kexec_should_crash(current))
109 crash_kexec(regs);
110
111 if (in_interrupt())
112 panic("Fatal exception in interrupt");
113
114 if (panic_on_oops)
115 panic("Fatal exception");
116
117 do_exit(SIGSEGV);
118}
119
120static inline void die_if_kernel(const char *str, struct pt_regs *regs,
121 long err)
122{
123 if (!user_mode(regs))
124 die(str, regs, err);
125}
126
127/*
128 * try and fix up kernelspace address errors
129 * - userspace errors just cause EFAULT to be returned, resulting in SEGV
130 * - kernel/userspace interfaces cause a jump to an appropriate handler
131 * - other kernel errors are bad
132 */
133static void die_if_no_fixup(const char * str, struct pt_regs * regs, long err)
134{
135 if (!user_mode(regs)) {
136 const struct exception_table_entry *fixup;
137 fixup = search_exception_tables(regs->pc);
138 if (fixup) {
139 regs->pc = fixup->fixup;
140 return;
141 }
142
143 die(str, regs, err);
144 }
145}
146
147static inline void sign_extend(unsigned int count, unsigned char *dst) 49static inline void sign_extend(unsigned int count, unsigned char *dst)
148{ 50{
149#ifdef __LITTLE_ENDIAN__ 51#ifdef __LITTLE_ENDIAN__
@@ -900,26 +802,3 @@ void __init trap_init(void)
900 set_exception_table_vec(TRAP_UBC, breakpoint_trap_handler); 802 set_exception_table_vec(TRAP_UBC, breakpoint_trap_handler);
901#endif 803#endif
902} 804}
903
904void show_stack(struct task_struct *tsk, unsigned long *sp)
905{
906 unsigned long stack;
907
908 if (!tsk)
909 tsk = current;
910 if (tsk == current)
911 sp = (unsigned long *)current_stack_pointer;
912 else
913 sp = (unsigned long *)tsk->thread.sp;
914
915 stack = (unsigned long)sp;
916 dump_mem("Stack: ", stack, THREAD_SIZE +
917 (unsigned long)task_stack_page(tsk));
918 show_trace(tsk, sp, NULL);
919}
920
921void dump_stack(void)
922{
923 show_stack(NULL, NULL);
924}
925EXPORT_SYMBOL(dump_stack);
diff --git a/arch/sh/kernel/traps_64.c b/arch/sh/kernel/traps_64.c
index 8dae93ed8af..f87d20da179 100644
--- a/arch/sh/kernel/traps_64.c
+++ b/arch/sh/kernel/traps_64.c
@@ -27,283 +27,25 @@
27#include <linux/perf_event.h> 27#include <linux/perf_event.h>
28#include <asm/uaccess.h> 28#include <asm/uaccess.h>
29#include <asm/io.h> 29#include <asm/io.h>
30#include <linux/atomic.h> 30#include <asm/alignment.h>
31#include <asm/processor.h> 31#include <asm/processor.h>
32#include <asm/pgtable.h> 32#include <asm/pgtable.h>
33#include <asm/fpu.h> 33#include <asm/fpu.h>
34 34
35#undef DEBUG_EXCEPTION 35static int read_opcode(reg_size_t pc, insn_size_t *result_opcode, int from_user_mode)
36#ifdef DEBUG_EXCEPTION
37/* implemented in ../lib/dbg.c */
38extern void show_excp_regs(char *fname, int trapnr, int signr,
39 struct pt_regs *regs);
40#else
41#define show_excp_regs(a, b, c, d)
42#endif
43
44static void do_unhandled_exception(int trapnr, int signr, char *str, char *fn_name,
45 unsigned long error_code, struct pt_regs *regs, struct task_struct *tsk);
46
47#define DO_ERROR(trapnr, signr, str, name, tsk) \
48asmlinkage void do_##name(unsigned long error_code, struct pt_regs *regs) \
49{ \
50 do_unhandled_exception(trapnr, signr, str, __stringify(name), error_code, regs, current); \
51}
52
53static DEFINE_SPINLOCK(die_lock);
54
55void die(const char * str, struct pt_regs * regs, long err)
56{
57 console_verbose();
58 spin_lock_irq(&die_lock);
59 printk("%s: %lx\n", str, (err & 0xffffff));
60 show_regs(regs);
61 spin_unlock_irq(&die_lock);
62 do_exit(SIGSEGV);
63}
64
65static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err)
66{
67 if (!user_mode(regs))
68 die(str, regs, err);
69}
70
71static void die_if_no_fixup(const char * str, struct pt_regs * regs, long err)
72{
73 if (!user_mode(regs)) {
74 const struct exception_table_entry *fixup;
75 fixup = search_exception_tables(regs->pc);
76 if (fixup) {
77 regs->pc = fixup->fixup;
78 return;
79 }
80 die(str, regs, err);
81 }
82}
83
84DO_ERROR(13, SIGILL, "illegal slot instruction", illegal_slot_inst, current)
85DO_ERROR(87, SIGSEGV, "address error (exec)", address_error_exec, current)
86
87
88/* Implement misaligned load/store handling for kernel (and optionally for user
89 mode too). Limitation : only SHmedia mode code is handled - there is no
90 handling at all for misaligned accesses occurring in SHcompact code yet. */
91
92static int misaligned_fixup(struct pt_regs *regs);
93
94asmlinkage void do_address_error_load(unsigned long error_code, struct pt_regs *regs)
95{
96 if (misaligned_fixup(regs) < 0) {
97 do_unhandled_exception(7, SIGSEGV, "address error(load)",
98 "do_address_error_load",
99 error_code, regs, current);
100 }
101 return;
102}
103
104asmlinkage void do_address_error_store(unsigned long error_code, struct pt_regs *regs)
105{
106 if (misaligned_fixup(regs) < 0) {
107 do_unhandled_exception(8, SIGSEGV, "address error(store)",
108 "do_address_error_store",
109 error_code, regs, current);
110 }
111 return;
112}
113
114#if defined(CONFIG_SH64_ID2815_WORKAROUND)
115
116#define OPCODE_INVALID 0
117#define OPCODE_USER_VALID 1
118#define OPCODE_PRIV_VALID 2
119
120/* getcon/putcon - requires checking which control register is referenced. */
121#define OPCODE_CTRL_REG 3
122
123/* Table of valid opcodes for SHmedia mode.
124 Form a 10-bit value by concatenating the major/minor opcodes i.e.
125 opcode[31:26,20:16]. The 6 MSBs of this value index into the following
126 array. The 4 LSBs select the bit-pair in the entry (bits 1:0 correspond to
127 LSBs==4'b0000 etc). */
128static unsigned long shmedia_opcode_table[64] = {
129 0x55554044,0x54445055,0x15141514,0x14541414,0x00000000,0x10001000,0x01110055,0x04050015,
130 0x00000444,0xc0000000,0x44545515,0x40405555,0x55550015,0x10005555,0x55555505,0x04050000,
131 0x00000555,0x00000404,0x00040445,0x15151414,0x00000000,0x00000000,0x00000000,0x00000000,
132 0x00000055,0x40404444,0x00000404,0xc0009495,0x00000000,0x00000000,0x00000000,0x00000000,
133 0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
134 0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
135 0x80005050,0x04005055,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
136 0x81055554,0x00000404,0x55555555,0x55555555,0x00000000,0x00000000,0x00000000,0x00000000
137};
138
139void do_reserved_inst(unsigned long error_code, struct pt_regs *regs)
140{
141 /* Workaround SH5-101 cut2 silicon defect #2815 :
142 in some situations, inter-mode branches from SHcompact -> SHmedia
143 which should take ITLBMISS or EXECPROT exceptions at the target
144 falsely take RESINST at the target instead. */
145
146 unsigned long opcode = 0x6ff4fff0; /* guaranteed reserved opcode */
147 unsigned long pc, aligned_pc;
148 int get_user_error;
149 int trapnr = 12;
150 int signr = SIGILL;
151 char *exception_name = "reserved_instruction";
152
153 pc = regs->pc;
154 if ((pc & 3) == 1) {
155 /* SHmedia : check for defect. This requires executable vmas
156 to be readable too. */
157 aligned_pc = pc & ~3;
158 if (!access_ok(VERIFY_READ, aligned_pc, sizeof(unsigned long))) {
159 get_user_error = -EFAULT;
160 } else {
161 get_user_error = __get_user(opcode, (unsigned long *)aligned_pc);
162 }
163 if (get_user_error >= 0) {
164 unsigned long index, shift;
165 unsigned long major, minor, combined;
166 unsigned long reserved_field;
167 reserved_field = opcode & 0xf; /* These bits are currently reserved as zero in all valid opcodes */
168 major = (opcode >> 26) & 0x3f;
169 minor = (opcode >> 16) & 0xf;
170 combined = (major << 4) | minor;
171 index = major;
172 shift = minor << 1;
173 if (reserved_field == 0) {
174 int opcode_state = (shmedia_opcode_table[index] >> shift) & 0x3;
175 switch (opcode_state) {
176 case OPCODE_INVALID:
177 /* Trap. */
178 break;
179 case OPCODE_USER_VALID:
180 /* Restart the instruction : the branch to the instruction will now be from an RTE
181 not from SHcompact so the silicon defect won't be triggered. */
182 return;
183 case OPCODE_PRIV_VALID:
184 if (!user_mode(regs)) {
185 /* Should only ever get here if a module has
186 SHcompact code inside it. If so, the same fix up is needed. */
187 return; /* same reason */
188 }
189 /* Otherwise, user mode trying to execute a privileged instruction -
190 fall through to trap. */
191 break;
192 case OPCODE_CTRL_REG:
193 /* If in privileged mode, return as above. */
194 if (!user_mode(regs)) return;
195 /* In user mode ... */
196 if (combined == 0x9f) { /* GETCON */
197 unsigned long regno = (opcode >> 20) & 0x3f;
198 if (regno >= 62) {
199 return;
200 }
201 /* Otherwise, reserved or privileged control register, => trap */
202 } else if (combined == 0x1bf) { /* PUTCON */
203 unsigned long regno = (opcode >> 4) & 0x3f;
204 if (regno >= 62) {
205 return;
206 }
207 /* Otherwise, reserved or privileged control register, => trap */
208 } else {
209 /* Trap */
210 }
211 break;
212 default:
213 /* Fall through to trap. */
214 break;
215 }
216 }
217 /* fall through to normal resinst processing */
218 } else {
219 /* Error trying to read opcode. This typically means a
220 real fault, not a RESINST any more. So change the
221 codes. */
222 trapnr = 87;
223 exception_name = "address error (exec)";
224 signr = SIGSEGV;
225 }
226 }
227
228 do_unhandled_exception(trapnr, signr, exception_name, "do_reserved_inst", error_code, regs, current);
229}
230
231#else /* CONFIG_SH64_ID2815_WORKAROUND */
232
233/* If the workaround isn't needed, this is just a straightforward reserved
234 instruction */
235DO_ERROR(12, SIGILL, "reserved instruction", reserved_inst, current)
236
237#endif /* CONFIG_SH64_ID2815_WORKAROUND */
238
239/* Called with interrupts disabled */
240asmlinkage void do_exception_error(unsigned long ex, struct pt_regs *regs)
241{
242 show_excp_regs(__func__, -1, -1, regs);
243 die_if_kernel("exception", regs, ex);
244}
245
246int do_unknown_trapa(unsigned long scId, struct pt_regs *regs)
247{
248 /* Syscall debug */
249 printk("System call ID error: [0x1#args:8 #syscall:16 0x%lx]\n", scId);
250
251 die_if_kernel("unknown trapa", regs, scId);
252
253 return -ENOSYS;
254}
255
256void show_stack(struct task_struct *tsk, unsigned long *sp)
257{
258#ifdef CONFIG_KALLSYMS
259 extern void sh64_unwind(struct pt_regs *regs);
260 struct pt_regs *regs;
261
262 regs = tsk ? tsk->thread.kregs : NULL;
263
264 sh64_unwind(regs);
265#else
266 printk(KERN_ERR "Can't backtrace on sh64 without CONFIG_KALLSYMS\n");
267#endif
268}
269
270void show_task(unsigned long *sp)
271{
272 show_stack(NULL, sp);
273}
274
275void dump_stack(void)
276{
277 show_task(NULL);
278}
279/* Needed by any user of WARN_ON in view of the defn in include/asm-sh/bug.h */
280EXPORT_SYMBOL(dump_stack);
281
282static void do_unhandled_exception(int trapnr, int signr, char *str, char *fn_name,
283 unsigned long error_code, struct pt_regs *regs, struct task_struct *tsk)
284{
285 show_excp_regs(fn_name, trapnr, signr, regs);
286
287 if (user_mode(regs))
288 force_sig(signr, tsk);
289
290 die_if_no_fixup(str, regs, error_code);
291}
292
293static int read_opcode(unsigned long long pc, unsigned long *result_opcode, int from_user_mode)
294{ 36{
295 int get_user_error; 37 int get_user_error;
296 unsigned long aligned_pc; 38 unsigned long aligned_pc;
297 unsigned long opcode; 39 insn_size_t opcode;
298 40
299 if ((pc & 3) == 1) { 41 if ((pc & 3) == 1) {
300 /* SHmedia */ 42 /* SHmedia */
301 aligned_pc = pc & ~3; 43 aligned_pc = pc & ~3;
302 if (from_user_mode) { 44 if (from_user_mode) {
303 if (!access_ok(VERIFY_READ, aligned_pc, sizeof(unsigned long))) { 45 if (!access_ok(VERIFY_READ, aligned_pc, sizeof(insn_size_t))) {
304 get_user_error = -EFAULT; 46 get_user_error = -EFAULT;
305 } else { 47 } else {
306 get_user_error = __get_user(opcode, (unsigned long *)aligned_pc); 48 get_user_error = __get_user(opcode, (insn_size_t *)aligned_pc);
307 *result_opcode = opcode; 49 *result_opcode = opcode;
308 } 50 }
309 return get_user_error; 51 return get_user_error;
@@ -311,7 +53,7 @@ static int read_opcode(unsigned long long pc, unsigned long *result_opcode, int
311 /* If the fault was in the kernel, we can either read 53 /* If the fault was in the kernel, we can either read
312 * this directly, or if not, we fault. 54 * this directly, or if not, we fault.
313 */ 55 */
314 *result_opcode = *(unsigned long *) aligned_pc; 56 *result_opcode = *(insn_size_t *)aligned_pc;
315 return 0; 57 return 0;
316 } 58 }
317 } else if ((pc & 1) == 0) { 59 } else if ((pc & 1) == 0) {
@@ -337,17 +79,23 @@ static int address_is_sign_extended(__u64 a)
337#endif 79#endif
338} 80}
339 81
82/* return -1 for fault, 0 for OK */
340static int generate_and_check_address(struct pt_regs *regs, 83static int generate_and_check_address(struct pt_regs *regs,
341 __u32 opcode, 84 insn_size_t opcode,
342 int displacement_not_indexed, 85 int displacement_not_indexed,
343 int width_shift, 86 int width_shift,
344 __u64 *address) 87 __u64 *address)
345{ 88{
346 /* return -1 for fault, 0 for OK */
347
348 __u64 base_address, addr; 89 __u64 base_address, addr;
349 int basereg; 90 int basereg;
350 91
92 switch (1 << width_shift) {
93 case 1: inc_unaligned_byte_access(); break;
94 case 2: inc_unaligned_word_access(); break;
95 case 4: inc_unaligned_dword_access(); break;
96 case 8: inc_unaligned_multi_access(); break;
97 }
98
351 basereg = (opcode >> 20) & 0x3f; 99 basereg = (opcode >> 20) & 0x3f;
352 base_address = regs->regs[basereg]; 100 base_address = regs->regs[basereg];
353 if (displacement_not_indexed) { 101 if (displacement_not_indexed) {
@@ -364,28 +112,28 @@ static int generate_and_check_address(struct pt_regs *regs,
364 } 112 }
365 113
366 /* Check sign extended */ 114 /* Check sign extended */
367 if (!address_is_sign_extended(addr)) { 115 if (!address_is_sign_extended(addr))
368 return -1; 116 return -1;
369 }
370 117
371 /* Check accessible. For misaligned access in the kernel, assume the 118 /* Check accessible. For misaligned access in the kernel, assume the
372 address is always accessible (and if not, just fault when the 119 address is always accessible (and if not, just fault when the
373 load/store gets done.) */ 120 load/store gets done.) */
374 if (user_mode(regs)) { 121 if (user_mode(regs)) {
375 if (addr >= TASK_SIZE) { 122 inc_unaligned_user_access();
123
124 if (addr >= TASK_SIZE)
376 return -1; 125 return -1;
377 } 126 } else
378 /* Do access_ok check later - it depends on whether it's a load or a store. */ 127 inc_unaligned_kernel_access();
379 }
380 128
381 *address = addr; 129 *address = addr;
130
131 perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, addr);
132 unaligned_fixups_notify(current, opcode, regs);
133
382 return 0; 134 return 0;
383} 135}
384 136
385static int user_mode_unaligned_fixup_count = 10;
386static int user_mode_unaligned_fixup_enable = 1;
387static int kernel_mode_unaligned_fixup_count = 32;
388
389static void misaligned_kernel_word_load(__u64 address, int do_sign_extend, __u64 *result) 137static void misaligned_kernel_word_load(__u64 address, int do_sign_extend, __u64 *result)
390{ 138{
391 unsigned short x; 139 unsigned short x;
@@ -415,7 +163,7 @@ static void misaligned_kernel_word_store(__u64 address, __u64 value)
415} 163}
416 164
417static int misaligned_load(struct pt_regs *regs, 165static int misaligned_load(struct pt_regs *regs,
418 __u32 opcode, 166 insn_size_t opcode,
419 int displacement_not_indexed, 167 int displacement_not_indexed,
420 int width_shift, 168 int width_shift,
421 int do_sign_extend) 169 int do_sign_extend)
@@ -427,11 +175,8 @@ static int misaligned_load(struct pt_regs *regs,
427 175
428 error = generate_and_check_address(regs, opcode, 176 error = generate_and_check_address(regs, opcode,
429 displacement_not_indexed, width_shift, &address); 177 displacement_not_indexed, width_shift, &address);
430 if (error < 0) { 178 if (error < 0)
431 return error; 179 return error;
432 }
433
434 perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, address);
435 180
436 destreg = (opcode >> 4) & 0x3f; 181 destreg = (opcode >> 4) & 0x3f;
437 if (user_mode(regs)) { 182 if (user_mode(regs)) {
@@ -490,11 +235,10 @@ static int misaligned_load(struct pt_regs *regs,
490 } 235 }
491 236
492 return 0; 237 return 0;
493
494} 238}
495 239
496static int misaligned_store(struct pt_regs *regs, 240static int misaligned_store(struct pt_regs *regs,
497 __u32 opcode, 241 insn_size_t opcode,
498 int displacement_not_indexed, 242 int displacement_not_indexed,
499 int width_shift) 243 int width_shift)
500{ 244{
@@ -505,11 +249,8 @@ static int misaligned_store(struct pt_regs *regs,
505 249
506 error = generate_and_check_address(regs, opcode, 250 error = generate_and_check_address(regs, opcode,
507 displacement_not_indexed, width_shift, &address); 251 displacement_not_indexed, width_shift, &address);
508 if (error < 0) { 252 if (error < 0)
509 return error; 253 return error;
510 }
511
512 perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, address);
513 254
514 srcreg = (opcode >> 4) & 0x3f; 255 srcreg = (opcode >> 4) & 0x3f;
515 if (user_mode(regs)) { 256 if (user_mode(regs)) {
@@ -563,13 +304,12 @@ static int misaligned_store(struct pt_regs *regs,
563 } 304 }
564 305
565 return 0; 306 return 0;
566
567} 307}
568 308
569/* Never need to fix up misaligned FPU accesses within the kernel since that's a real 309/* Never need to fix up misaligned FPU accesses within the kernel since that's a real
570 error. */ 310 error. */
571static int misaligned_fpu_load(struct pt_regs *regs, 311static int misaligned_fpu_load(struct pt_regs *regs,
572 __u32 opcode, 312 insn_size_t opcode,
573 int displacement_not_indexed, 313 int displacement_not_indexed,
574 int width_shift, 314 int width_shift,
575 int do_paired_load) 315 int do_paired_load)
@@ -581,11 +321,8 @@ static int misaligned_fpu_load(struct pt_regs *regs,
581 321
582 error = generate_and_check_address(regs, opcode, 322 error = generate_and_check_address(regs, opcode,
583 displacement_not_indexed, width_shift, &address); 323 displacement_not_indexed, width_shift, &address);
584 if (error < 0) { 324 if (error < 0)
585 return error; 325 return error;
586 }
587
588 perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, address);
589 326
590 destreg = (opcode >> 4) & 0x3f; 327 destreg = (opcode >> 4) & 0x3f;
591 if (user_mode(regs)) { 328 if (user_mode(regs)) {
@@ -641,12 +378,10 @@ static int misaligned_fpu_load(struct pt_regs *regs,
641 die ("Misaligned FPU load inside kernel", regs, 0); 378 die ("Misaligned FPU load inside kernel", regs, 0);
642 return -1; 379 return -1;
643 } 380 }
644
645
646} 381}
647 382
648static int misaligned_fpu_store(struct pt_regs *regs, 383static int misaligned_fpu_store(struct pt_regs *regs,
649 __u32 opcode, 384 insn_size_t opcode,
650 int displacement_not_indexed, 385 int displacement_not_indexed,
651 int width_shift, 386 int width_shift,
652 int do_paired_load) 387 int do_paired_load)
@@ -658,11 +393,8 @@ static int misaligned_fpu_store(struct pt_regs *regs,
658 393
659 error = generate_and_check_address(regs, opcode, 394 error = generate_and_check_address(regs, opcode,
660 displacement_not_indexed, width_shift, &address); 395 displacement_not_indexed, width_shift, &address);
661 if (error < 0) { 396 if (error < 0)
662 return error; 397 return error;
663 }
664
665 perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, address);
666 398
667 srcreg = (opcode >> 4) & 0x3f; 399 srcreg = (opcode >> 4) & 0x3f;
668 if (user_mode(regs)) { 400 if (user_mode(regs)) {
@@ -723,11 +455,13 @@ static int misaligned_fpu_store(struct pt_regs *regs,
723 455
724static int misaligned_fixup(struct pt_regs *regs) 456static int misaligned_fixup(struct pt_regs *regs)
725{ 457{
726 unsigned long opcode; 458 insn_size_t opcode;
727 int error; 459 int error;
728 int major, minor; 460 int major, minor;
461 unsigned int user_action;
729 462
730 if (!user_mode_unaligned_fixup_enable) 463 user_action = unaligned_user_action();
464 if (!(user_action & UM_FIXUP))
731 return -1; 465 return -1;
732 466
733 error = read_opcode(regs->pc, &opcode, user_mode(regs)); 467 error = read_opcode(regs->pc, &opcode, user_mode(regs));
@@ -737,23 +471,6 @@ static int misaligned_fixup(struct pt_regs *regs)
737 major = (opcode >> 26) & 0x3f; 471 major = (opcode >> 26) & 0x3f;
738 minor = (opcode >> 16) & 0xf; 472 minor = (opcode >> 16) & 0xf;
739 473
740 if (user_mode(regs) && (user_mode_unaligned_fixup_count > 0)) {
741 --user_mode_unaligned_fixup_count;
742 /* Only do 'count' worth of these reports, to remove a potential DoS against syslog */
743 printk("Fixing up unaligned userspace access in \"%s\" pid=%d pc=0x%08x ins=0x%08lx\n",
744 current->comm, task_pid_nr(current), (__u32)regs->pc, opcode);
745 } else if (!user_mode(regs) && (kernel_mode_unaligned_fixup_count > 0)) {
746 --kernel_mode_unaligned_fixup_count;
747 if (in_interrupt()) {
748 printk("Fixing up unaligned kernelspace access in interrupt pc=0x%08x ins=0x%08lx\n",
749 (__u32)regs->pc, opcode);
750 } else {
751 printk("Fixing up unaligned kernelspace access in \"%s\" pid=%d pc=0x%08x ins=0x%08lx\n",
752 current->comm, task_pid_nr(current), (__u32)regs->pc, opcode);
753 }
754 }
755
756
757 switch (major) { 474 switch (major) {
758 case (0x84>>2): /* LD.W */ 475 case (0x84>>2): /* LD.W */
759 error = misaligned_load(regs, opcode, 1, 1, 1); 476 error = misaligned_load(regs, opcode, 1, 1, 1);
@@ -878,59 +595,202 @@ static int misaligned_fixup(struct pt_regs *regs)
878 regs->pc += 4; /* Skip the instruction that's just been emulated */ 595 regs->pc += 4; /* Skip the instruction that's just been emulated */
879 return 0; 596 return 0;
880 } 597 }
598}
599
600static void do_unhandled_exception(int signr, char *str, unsigned long error,
601 struct pt_regs *regs)
602{
603 if (user_mode(regs))
604 force_sig(signr, current);
881 605
606 die_if_no_fixup(str, regs, error);
882} 607}
883 608
884static ctl_table unaligned_table[] = { 609#define DO_ERROR(signr, str, name) \
885 { 610asmlinkage void do_##name(unsigned long error_code, struct pt_regs *regs) \
886 .procname = "kernel_reports", 611{ \
887 .data = &kernel_mode_unaligned_fixup_count, 612 do_unhandled_exception(signr, str, error_code, regs); \
888 .maxlen = sizeof(int), 613}
889 .mode = 0644,
890 .proc_handler = proc_dointvec
891 },
892 {
893 .procname = "user_reports",
894 .data = &user_mode_unaligned_fixup_count,
895 .maxlen = sizeof(int),
896 .mode = 0644,
897 .proc_handler = proc_dointvec
898 },
899 {
900 .procname = "user_enable",
901 .data = &user_mode_unaligned_fixup_enable,
902 .maxlen = sizeof(int),
903 .mode = 0644,
904 .proc_handler = proc_dointvec},
905 {}
906};
907 614
908static ctl_table unaligned_root[] = { 615DO_ERROR(SIGILL, "illegal slot instruction", illegal_slot_inst)
909 { 616DO_ERROR(SIGSEGV, "address error (exec)", address_error_exec)
910 .procname = "unaligned_fixup", 617
911 .mode = 0555, 618#if defined(CONFIG_SH64_ID2815_WORKAROUND)
912 .child = unaligned_table 619
913 }, 620#define OPCODE_INVALID 0
914 {} 621#define OPCODE_USER_VALID 1
915}; 622#define OPCODE_PRIV_VALID 2
916 623
917static ctl_table sh64_root[] = { 624/* getcon/putcon - requires checking which control register is referenced. */
918 { 625#define OPCODE_CTRL_REG 3
919 .procname = "sh64", 626
920 .mode = 0555, 627/* Table of valid opcodes for SHmedia mode.
921 .child = unaligned_root 628 Form a 10-bit value by concatenating the major/minor opcodes i.e.
922 }, 629 opcode[31:26,20:16]. The 6 MSBs of this value index into the following
923 {} 630 array. The 4 LSBs select the bit-pair in the entry (bits 1:0 correspond to
631 LSBs==4'b0000 etc). */
632static unsigned long shmedia_opcode_table[64] = {
633 0x55554044,0x54445055,0x15141514,0x14541414,0x00000000,0x10001000,0x01110055,0x04050015,
634 0x00000444,0xc0000000,0x44545515,0x40405555,0x55550015,0x10005555,0x55555505,0x04050000,
635 0x00000555,0x00000404,0x00040445,0x15151414,0x00000000,0x00000000,0x00000000,0x00000000,
636 0x00000055,0x40404444,0x00000404,0xc0009495,0x00000000,0x00000000,0x00000000,0x00000000,
637 0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
638 0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
639 0x80005050,0x04005055,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
640 0x81055554,0x00000404,0x55555555,0x55555555,0x00000000,0x00000000,0x00000000,0x00000000
924}; 641};
925static struct ctl_table_header *sysctl_header; 642
926static int __init init_sysctl(void) 643/* Workaround SH5-101 cut2 silicon defect #2815 :
644 in some situations, inter-mode branches from SHcompact -> SHmedia
645 which should take ITLBMISS or EXECPROT exceptions at the target
646 falsely take RESINST at the target instead. */
647void do_reserved_inst(unsigned long error_code, struct pt_regs *regs)
927{ 648{
928 sysctl_header = register_sysctl_table(sh64_root); 649 insn_size_t opcode = 0x6ff4fff0; /* guaranteed reserved opcode */
929 return 0; 650 unsigned long pc, aligned_pc;
651 unsigned long index, shift;
652 unsigned long major, minor, combined;
653 unsigned long reserved_field;
654 int opcode_state;
655 int get_user_error;
656 int signr = SIGILL;
657 char *exception_name = "reserved_instruction";
658
659 pc = regs->pc;
660
661 /* SHcompact is not handled */
662 if (unlikely((pc & 3) == 0))
663 goto out;
664
665 /* SHmedia : check for defect. This requires executable vmas
666 to be readable too. */
667 aligned_pc = pc & ~3;
668 if (!access_ok(VERIFY_READ, aligned_pc, sizeof(insn_size_t)))
669 get_user_error = -EFAULT;
670 else
671 get_user_error = __get_user(opcode, (insn_size_t *)aligned_pc);
672
673 if (get_user_error < 0) {
674 /*
675 * Error trying to read opcode. This typically means a
676 * real fault, not a RESINST any more. So change the
677 * codes.
678 */
679 exception_name = "address error (exec)";
680 signr = SIGSEGV;
681 goto out;
682 }
683
684 /* These bits are currently reserved as zero in all valid opcodes */
685 reserved_field = opcode & 0xf;
686 if (unlikely(reserved_field))
687 goto out; /* invalid opcode */
688
689 major = (opcode >> 26) & 0x3f;
690 minor = (opcode >> 16) & 0xf;
691 combined = (major << 4) | minor;
692 index = major;
693 shift = minor << 1;
694 opcode_state = (shmedia_opcode_table[index] >> shift) & 0x3;
695 switch (opcode_state) {
696 case OPCODE_INVALID:
697 /* Trap. */
698 break;
699 case OPCODE_USER_VALID:
700 /*
701 * Restart the instruction: the branch to the instruction
702 * will now be from an RTE not from SHcompact so the
703 * silicon defect won't be triggered.
704 */
705 return;
706 case OPCODE_PRIV_VALID:
707 if (!user_mode(regs)) {
708 /*
709 * Should only ever get here if a module has
710 * SHcompact code inside it. If so, the same fix
711 * up is needed.
712 */
713 return; /* same reason */
714 }
715
716 /*
717 * Otherwise, user mode trying to execute a privileged
718 * instruction - fall through to trap.
719 */
720 break;
721 case OPCODE_CTRL_REG:
722 /* If in privileged mode, return as above. */
723 if (!user_mode(regs))
724 return;
725
726 /* In user mode ... */
727 if (combined == 0x9f) { /* GETCON */
728 unsigned long regno = (opcode >> 20) & 0x3f;
729
730 if (regno >= 62)
731 return;
732
733 /* reserved/privileged control register => trap */
734 } else if (combined == 0x1bf) { /* PUTCON */
735 unsigned long regno = (opcode >> 4) & 0x3f;
736
737 if (regno >= 62)
738 return;
739
740 /* reserved/privileged control register => trap */
741 }
742
743 break;
744 default:
745 /* Fall through to trap. */
746 break;
747 }
748
749out:
750 do_unhandled_exception(signr, exception_name, error_code, regs);
930} 751}
931 752
932__initcall(init_sysctl); 753#else /* CONFIG_SH64_ID2815_WORKAROUND */
933 754
755/* If the workaround isn't needed, this is just a straightforward reserved
756 instruction */
757DO_ERROR(SIGILL, "reserved instruction", reserved_inst)
758
759#endif /* CONFIG_SH64_ID2815_WORKAROUND */
760
761/* Called with interrupts disabled */
762asmlinkage void do_exception_error(unsigned long ex, struct pt_regs *regs)
763{
764 die_if_kernel("exception", regs, ex);
765}
766
767asmlinkage int do_unknown_trapa(unsigned long scId, struct pt_regs *regs)
768{
769 /* Syscall debug */
770 printk("System call ID error: [0x1#args:8 #syscall:16 0x%lx]\n", scId);
771
772 die_if_kernel("unknown trapa", regs, scId);
773
774 return -ENOSYS;
775}
776
777/* Implement misaligned load/store handling for kernel (and optionally for user
778 mode too). Limitation : only SHmedia mode code is handled - there is no
779 handling at all for misaligned accesses occurring in SHcompact code yet. */
780
781asmlinkage void do_address_error_load(unsigned long error_code, struct pt_regs *regs)
782{
783 if (misaligned_fixup(regs) < 0)
784 do_unhandled_exception(SIGSEGV, "address error(load)",
785 error_code, regs);
786}
787
788asmlinkage void do_address_error_store(unsigned long error_code, struct pt_regs *regs)
789{
790 if (misaligned_fixup(regs) < 0)
791 do_unhandled_exception(SIGSEGV, "address error(store)",
792 error_code, regs);
793}
934 794
935asmlinkage void do_debug_interrupt(unsigned long code, struct pt_regs *regs) 795asmlinkage void do_debug_interrupt(unsigned long code, struct pt_regs *regs)
936{ 796{
@@ -942,10 +802,9 @@ asmlinkage void do_debug_interrupt(unsigned long code, struct pt_regs *regs)
942 of access we make to them - just go direct to their physical 802 of access we make to them - just go direct to their physical
943 addresses. */ 803 addresses. */
944 exp_cause = peek_real_address_q(DM_EXP_CAUSE_PHY); 804 exp_cause = peek_real_address_q(DM_EXP_CAUSE_PHY);
945 if (exp_cause & ~4) { 805 if (exp_cause & ~4)
946 printk("DM.EXP_CAUSE had unexpected bits set (=%08lx)\n", 806 printk("DM.EXP_CAUSE had unexpected bits set (=%08lx)\n",
947 (unsigned long)(exp_cause & 0xffffffff)); 807 (unsigned long)(exp_cause & 0xffffffff));
948 }
949 show_state(); 808 show_state();
950 /* Clear all DEBUGINT causes */ 809 /* Clear all DEBUGINT causes */
951 poke_real_address_q(DM_EXP_CAUSE_PHY, 0x0); 810 poke_real_address_q(DM_EXP_CAUSE_PHY, 0x0);
diff --git a/arch/sh/kernel/vmlinux.lds.S b/arch/sh/kernel/vmlinux.lds.S
index c98905f71e2..db88cbf9eaf 100644
--- a/arch/sh/kernel/vmlinux.lds.S
+++ b/arch/sh/kernel/vmlinux.lds.S
@@ -78,7 +78,6 @@ SECTIONS
78 . = ALIGN(PAGE_SIZE); 78 . = ALIGN(PAGE_SIZE);
79 __init_end = .; 79 __init_end = .;
80 BSS_SECTION(0, PAGE_SIZE, 4) 80 BSS_SECTION(0, PAGE_SIZE, 4)
81 _ebss = .; /* uClinux MTD sucks */
82 _end = . ; 81 _end = . ;
83 82
84 STABS_DEBUG 83 STABS_DEBUG
diff --git a/arch/sh/lib/mcount.S b/arch/sh/lib/mcount.S
index 84a57761f17..60164e65d66 100644
--- a/arch/sh/lib/mcount.S
+++ b/arch/sh/lib/mcount.S
@@ -39,7 +39,7 @@
39 * 39 *
40 * Make sure the stack pointer contains a valid address. Valid 40 * Make sure the stack pointer contains a valid address. Valid
41 * addresses for kernel stacks are anywhere after the bss 41 * addresses for kernel stacks are anywhere after the bss
42 * (after _ebss) and anywhere in init_thread_union (init_stack). 42 * (after __bss_stop) and anywhere in init_thread_union (init_stack).
43 */ 43 */
44#define STACK_CHECK() \ 44#define STACK_CHECK() \
45 mov #(THREAD_SIZE >> 10), r0; \ 45 mov #(THREAD_SIZE >> 10), r0; \
@@ -60,7 +60,7 @@
60 cmp/hi r2, r1; \ 60 cmp/hi r2, r1; \
61 bf stack_panic; \ 61 bf stack_panic; \
62 \ 62 \
63 /* If sp > _ebss then we're OK. */ \ 63 /* If sp > __bss_stop then we're OK. */ \
64 mov.l .L_ebss, r1; \ 64 mov.l .L_ebss, r1; \
65 cmp/hi r1, r15; \ 65 cmp/hi r1, r15; \
66 bt 1f; \ 66 bt 1f; \
@@ -70,7 +70,7 @@
70 cmp/hs r1, r15; \ 70 cmp/hs r1, r15; \
71 bf stack_panic; \ 71 bf stack_panic; \
72 \ 72 \
73 /* If sp > init_stack && sp < _ebss, not OK. */ \ 73 /* If sp > init_stack && sp < __bss_stop, not OK. */ \
74 add r0, r1; \ 74 add r0, r1; \
75 cmp/hs r1, r15; \ 75 cmp/hs r1, r15; \
76 bt stack_panic; \ 76 bt stack_panic; \
@@ -292,8 +292,6 @@ stack_panic:
292 nop 292 nop
293 293
294 .align 2 294 .align 2
295.L_ebss:
296 .long _ebss
297.L_init_thread_union: 295.L_init_thread_union:
298 .long init_thread_union 296 .long init_thread_union
299.Lpanic: 297.Lpanic:
diff --git a/arch/sh/lib64/Makefile b/arch/sh/lib64/Makefile
index 1fee75aa1f9..69779ff741d 100644
--- a/arch/sh/lib64/Makefile
+++ b/arch/sh/lib64/Makefile
@@ -10,7 +10,7 @@
10# 10#
11 11
12# Panic should really be compiled as PIC 12# Panic should really be compiled as PIC
13lib-y := udelay.o dbg.o panic.o memcpy.o memset.o \ 13lib-y := udelay.o panic.o memcpy.o memset.o \
14 copy_user_memcpy.o copy_page.o strcpy.o strlen.o 14 copy_user_memcpy.o copy_page.o strcpy.o strlen.o
15 15
16# Extracted from libgcc 16# Extracted from libgcc
diff --git a/arch/sh/lib64/dbg.c b/arch/sh/lib64/dbg.c
deleted file mode 100644
index 6152a6a6d9c..00000000000
--- a/arch/sh/lib64/dbg.c
+++ /dev/null
@@ -1,248 +0,0 @@
1/*--------------------------------------------------------------------------
2--
3-- Identity : Linux50 Debug Funcions
4--
5-- File : arch/sh/lib64/dbg.c
6--
7-- Copyright 2000, 2001 STMicroelectronics Limited.
8-- Copyright 2004 Richard Curnow (evt_debug etc)
9--
10--------------------------------------------------------------------------*/
11#include <linux/types.h>
12#include <linux/kernel.h>
13#include <linux/sched.h>
14#include <linux/mm.h>
15#include <linux/fs.h>
16#include <asm/mmu_context.h>
17
18typedef u64 regType_t;
19
20static regType_t getConfigReg(u64 id)
21{
22 register u64 reg __asm__("r2");
23 asm volatile ("getcfg %1, 0, %0":"=r" (reg):"r"(id));
24 return (reg);
25}
26
27/* ======================================================================= */
28
29static char *szTab[] = { "4k", "64k", "1M", "512M" };
30static char *protTab[] = { "----",
31 "---R",
32 "--X-",
33 "--XR",
34 "-W--",
35 "-W-R",
36 "-WX-",
37 "-WXR",
38 "U---",
39 "U--R",
40 "U-X-",
41 "U-XR",
42 "UW--",
43 "UW-R",
44 "UWX-",
45 "UWXR"
46};
47#define ITLB_BASE 0x00000000
48#define DTLB_BASE 0x00800000
49#define MAX_TLBs 64
50/* PTE High */
51#define GET_VALID(pte) ((pte) & 0x1)
52#define GET_SHARED(pte) ((pte) & 0x2)
53#define GET_ASID(pte) ((pte >> 2) & 0x0ff)
54#define GET_EPN(pte) ((pte) & 0xfffff000)
55
56/* PTE Low */
57#define GET_CBEHAVIOR(pte) ((pte) & 0x3)
58#define GET_PAGE_SIZE(pte) szTab[((pte >> 3) & 0x3)]
59#define GET_PROTECTION(pte) protTab[((pte >> 6) & 0xf)]
60#define GET_PPN(pte) ((pte) & 0xfffff000)
61
62#define PAGE_1K_MASK 0x00000000
63#define PAGE_4K_MASK 0x00000010
64#define PAGE_64K_MASK 0x00000080
65#define MMU_PAGESIZE_MASK (PAGE_64K_MASK | PAGE_4K_MASK)
66#define PAGE_1MB_MASK MMU_PAGESIZE_MASK
67#define PAGE_1K (1024)
68#define PAGE_4K (1024 * 4)
69#define PAGE_64K (1024 * 64)
70#define PAGE_1MB (1024 * 1024)
71
72#define HOW_TO_READ_TLB_CONTENT \
73 "[ ID] PPN EPN ASID Share CB P.Size PROT.\n"
74
75void print_single_tlb(unsigned long tlb, int single_print)
76{
77 regType_t pteH;
78 regType_t pteL;
79 unsigned int valid, shared, asid, epn, cb, ppn;
80 char *pSize;
81 char *pProt;
82
83 /*
84 ** in case of single print <single_print> is true, this implies:
85 ** 1) print the TLB in any case also if NOT VALID
86 ** 2) print out the header
87 */
88
89 pteH = getConfigReg(tlb);
90 valid = GET_VALID(pteH);
91 if (single_print)
92 printk(HOW_TO_READ_TLB_CONTENT);
93 else if (!valid)
94 return;
95
96 pteL = getConfigReg(tlb + 1);
97
98 shared = GET_SHARED(pteH);
99 asid = GET_ASID(pteH);
100 epn = GET_EPN(pteH);
101 cb = GET_CBEHAVIOR(pteL);
102 pSize = GET_PAGE_SIZE(pteL);
103 pProt = GET_PROTECTION(pteL);
104 ppn = GET_PPN(pteL);
105 printk("[%c%2ld] 0x%08x 0x%08x %03d %02x %02x %4s %s\n",
106 ((valid) ? ' ' : 'u'), ((tlb & 0x0ffff) / TLB_STEP),
107 ppn, epn, asid, shared, cb, pSize, pProt);
108}
109
110void print_dtlb(void)
111{
112 int count;
113 unsigned long tlb;
114
115 printk(" ================= SH-5 D-TLBs Status ===================\n");
116 printk(HOW_TO_READ_TLB_CONTENT);
117 tlb = DTLB_BASE;
118 for (count = 0; count < MAX_TLBs; count++, tlb += TLB_STEP)
119 print_single_tlb(tlb, 0);
120 printk
121 (" =============================================================\n");
122}
123
124void print_itlb(void)
125{
126 int count;
127 unsigned long tlb;
128
129 printk(" ================= SH-5 I-TLBs Status ===================\n");
130 printk(HOW_TO_READ_TLB_CONTENT);
131 tlb = ITLB_BASE;
132 for (count = 0; count < MAX_TLBs; count++, tlb += TLB_STEP)
133 print_single_tlb(tlb, 0);
134 printk
135 (" =============================================================\n");
136}
137
138void show_excp_regs(char *from, int trapnr, int signr, struct pt_regs *regs)
139{
140
141 unsigned long long ah, al, bh, bl, ch, cl;
142
143 printk("\n");
144 printk("EXCEPTION - %s: task %d; Linux trap # %d; signal = %d\n",
145 ((from) ? from : "???"), current->pid, trapnr, signr);
146
147 asm volatile ("getcon " __EXPEVT ", %0":"=r"(ah));
148 asm volatile ("getcon " __EXPEVT ", %0":"=r"(al));
149 ah = (ah) >> 32;
150 al = (al) & 0xffffffff;
151 asm volatile ("getcon " __KCR1 ", %0":"=r"(bh));
152 asm volatile ("getcon " __KCR1 ", %0":"=r"(bl));
153 bh = (bh) >> 32;
154 bl = (bl) & 0xffffffff;
155 asm volatile ("getcon " __INTEVT ", %0":"=r"(ch));
156 asm volatile ("getcon " __INTEVT ", %0":"=r"(cl));
157 ch = (ch) >> 32;
158 cl = (cl) & 0xffffffff;
159 printk("EXPE: %08Lx%08Lx KCR1: %08Lx%08Lx INTE: %08Lx%08Lx\n",
160 ah, al, bh, bl, ch, cl);
161
162 asm volatile ("getcon " __PEXPEVT ", %0":"=r"(ah));
163 asm volatile ("getcon " __PEXPEVT ", %0":"=r"(al));
164 ah = (ah) >> 32;
165 al = (al) & 0xffffffff;
166 asm volatile ("getcon " __PSPC ", %0":"=r"(bh));
167 asm volatile ("getcon " __PSPC ", %0":"=r"(bl));
168 bh = (bh) >> 32;
169 bl = (bl) & 0xffffffff;
170 asm volatile ("getcon " __PSSR ", %0":"=r"(ch));
171 asm volatile ("getcon " __PSSR ", %0":"=r"(cl));
172 ch = (ch) >> 32;
173 cl = (cl) & 0xffffffff;
174 printk("PEXP: %08Lx%08Lx PSPC: %08Lx%08Lx PSSR: %08Lx%08Lx\n",
175 ah, al, bh, bl, ch, cl);
176
177 ah = (regs->pc) >> 32;
178 al = (regs->pc) & 0xffffffff;
179 bh = (regs->regs[18]) >> 32;
180 bl = (regs->regs[18]) & 0xffffffff;
181 ch = (regs->regs[15]) >> 32;
182 cl = (regs->regs[15]) & 0xffffffff;
183 printk("PC : %08Lx%08Lx LINK: %08Lx%08Lx SP : %08Lx%08Lx\n",
184 ah, al, bh, bl, ch, cl);
185
186 ah = (regs->sr) >> 32;
187 al = (regs->sr) & 0xffffffff;
188 asm volatile ("getcon " __TEA ", %0":"=r"(bh));
189 asm volatile ("getcon " __TEA ", %0":"=r"(bl));
190 bh = (bh) >> 32;
191 bl = (bl) & 0xffffffff;
192 asm volatile ("getcon " __KCR0 ", %0":"=r"(ch));
193 asm volatile ("getcon " __KCR0 ", %0":"=r"(cl));
194 ch = (ch) >> 32;
195 cl = (cl) & 0xffffffff;
196 printk("SR : %08Lx%08Lx TEA : %08Lx%08Lx KCR0: %08Lx%08Lx\n",
197 ah, al, bh, bl, ch, cl);
198
199 ah = (regs->regs[0]) >> 32;
200 al = (regs->regs[0]) & 0xffffffff;
201 bh = (regs->regs[1]) >> 32;
202 bl = (regs->regs[1]) & 0xffffffff;
203 ch = (regs->regs[2]) >> 32;
204 cl = (regs->regs[2]) & 0xffffffff;
205 printk("R0 : %08Lx%08Lx R1 : %08Lx%08Lx R2 : %08Lx%08Lx\n",
206 ah, al, bh, bl, ch, cl);
207
208 ah = (regs->regs[3]) >> 32;
209 al = (regs->regs[3]) & 0xffffffff;
210 bh = (regs->regs[4]) >> 32;
211 bl = (regs->regs[4]) & 0xffffffff;
212 ch = (regs->regs[5]) >> 32;
213 cl = (regs->regs[5]) & 0xffffffff;
214 printk("R3 : %08Lx%08Lx R4 : %08Lx%08Lx R5 : %08Lx%08Lx\n",
215 ah, al, bh, bl, ch, cl);
216
217 ah = (regs->regs[6]) >> 32;
218 al = (regs->regs[6]) & 0xffffffff;
219 bh = (regs->regs[7]) >> 32;
220 bl = (regs->regs[7]) & 0xffffffff;
221 ch = (regs->regs[8]) >> 32;
222 cl = (regs->regs[8]) & 0xffffffff;
223 printk("R6 : %08Lx%08Lx R7 : %08Lx%08Lx R8 : %08Lx%08Lx\n",
224 ah, al, bh, bl, ch, cl);
225
226 ah = (regs->regs[9]) >> 32;
227 al = (regs->regs[9]) & 0xffffffff;
228 bh = (regs->regs[10]) >> 32;
229 bl = (regs->regs[10]) & 0xffffffff;
230 ch = (regs->regs[11]) >> 32;
231 cl = (regs->regs[11]) & 0xffffffff;
232 printk("R9 : %08Lx%08Lx R10 : %08Lx%08Lx R11 : %08Lx%08Lx\n",
233 ah, al, bh, bl, ch, cl);
234 printk("....\n");
235
236 ah = (regs->tregs[0]) >> 32;
237 al = (regs->tregs[0]) & 0xffffffff;
238 bh = (regs->tregs[1]) >> 32;
239 bl = (regs->tregs[1]) & 0xffffffff;
240 ch = (regs->tregs[2]) >> 32;
241 cl = (regs->tregs[2]) & 0xffffffff;
242 printk("T0 : %08Lx%08Lx T1 : %08Lx%08Lx T2 : %08Lx%08Lx\n",
243 ah, al, bh, bl, ch, cl);
244 printk("....\n");
245
246 print_dtlb();
247 print_itlb();
248}
diff --git a/arch/sh/mm/fault.c b/arch/sh/mm/fault.c
index 1fc25d85e51..3bdc1ad9a34 100644
--- a/arch/sh/mm/fault.c
+++ b/arch/sh/mm/fault.c
@@ -58,11 +58,15 @@ static void show_pte(struct mm_struct *mm, unsigned long addr)
58{ 58{
59 pgd_t *pgd; 59 pgd_t *pgd;
60 60
61 if (mm) 61 if (mm) {
62 pgd = mm->pgd; 62 pgd = mm->pgd;
63 else 63 } else {
64 pgd = get_TTB(); 64 pgd = get_TTB();
65 65
66 if (unlikely(!pgd))
67 pgd = swapper_pg_dir;
68 }
69
66 printk(KERN_ALERT "pgd = %p\n", pgd); 70 printk(KERN_ALERT "pgd = %p\n", pgd);
67 pgd += pgd_index(addr); 71 pgd += pgd_index(addr);
68 printk(KERN_ALERT "[%08lx] *pgd=%0*Lx", addr, 72 printk(KERN_ALERT "[%08lx] *pgd=%0*Lx", addr,
diff --git a/arch/sh/mm/tlb-sh5.c b/arch/sh/mm/tlb-sh5.c
index 3aea25dc431..ff1c40a31cb 100644
--- a/arch/sh/mm/tlb-sh5.c
+++ b/arch/sh/mm/tlb-sh5.c
@@ -17,7 +17,7 @@
17/** 17/**
18 * sh64_tlb_init - Perform initial setup for the DTLB and ITLB. 18 * sh64_tlb_init - Perform initial setup for the DTLB and ITLB.
19 */ 19 */
20int __init sh64_tlb_init(void) 20int __cpuinit sh64_tlb_init(void)
21{ 21{
22 /* Assign some sane DTLB defaults */ 22 /* Assign some sane DTLB defaults */
23 cpu_data->dtlb.entries = 64; 23 cpu_data->dtlb.entries = 64;
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index e74ff137762..67f1f6f5f4e 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -27,6 +27,7 @@ config SPARC
27 select HAVE_ARCH_JUMP_LABEL 27 select HAVE_ARCH_JUMP_LABEL
28 select HAVE_GENERIC_HARDIRQS 28 select HAVE_GENERIC_HARDIRQS
29 select GENERIC_IRQ_SHOW 29 select GENERIC_IRQ_SHOW
30 select ARCH_WANT_IPC_PARSE_VERSION
30 select USE_GENERIC_SMP_HELPERS if SMP 31 select USE_GENERIC_SMP_HELPERS if SMP
31 select GENERIC_PCI_IOMAP 32 select GENERIC_PCI_IOMAP
32 select HAVE_NMI_WATCHDOG if SPARC64 33 select HAVE_NMI_WATCHDOG if SPARC64
diff --git a/arch/sparc/include/asm/fixmap.h b/arch/sparc/include/asm/fixmap.h
deleted file mode 100644
index f18fc0755ad..00000000000
--- a/arch/sparc/include/asm/fixmap.h
+++ /dev/null
@@ -1,110 +0,0 @@
1/*
2 * fixmap.h: compile-time virtual memory allocation
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 1998 Ingo Molnar
9 *
10 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
11 */
12
13#ifndef _ASM_FIXMAP_H
14#define _ASM_FIXMAP_H
15
16#include <linux/kernel.h>
17#include <asm/page.h>
18#ifdef CONFIG_HIGHMEM
19#include <linux/threads.h>
20#include <asm/kmap_types.h>
21#endif
22
23/*
24 * Here we define all the compile-time 'special' virtual
25 * addresses. The point is to have a constant address at
26 * compile time, but to set the physical address only
27 * in the boot process. We allocate these special addresses
28 * from the top of unused virtual memory (0xfd000000 - 1 page) backwards.
29 * Also this lets us do fail-safe vmalloc(), we
30 * can guarantee that these special addresses and
31 * vmalloc()-ed addresses never overlap.
32 *
33 * these 'compile-time allocated' memory buffers are
34 * fixed-size 4k pages. (or larger if used with an increment
35 * highger than 1) use fixmap_set(idx,phys) to associate
36 * physical memory with fixmap indices.
37 *
38 * TLB entries of such buffers will not be flushed across
39 * task switches.
40 */
41
42/*
43 * on UP currently we will have no trace of the fixmap mechanism,
44 * no page table allocations, etc. This might change in the
45 * future, say framebuffers for the console driver(s) could be
46 * fix-mapped?
47 */
48enum fixed_addresses {
49 FIX_HOLE,
50#ifdef CONFIG_HIGHMEM
51 FIX_KMAP_BEGIN,
52 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
53#endif
54 __end_of_fixed_addresses
55};
56
57extern void __set_fixmap (enum fixed_addresses idx,
58 unsigned long phys, pgprot_t flags);
59
60#define set_fixmap(idx, phys) \
61 __set_fixmap(idx, phys, PAGE_KERNEL)
62/*
63 * Some hardware wants to get fixmapped without caching.
64 */
65#define set_fixmap_nocache(idx, phys) \
66 __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
67/*
68 * used by vmalloc.c.
69 *
70 * Leave one empty page between IO pages at 0xfd000000 and
71 * the start of the fixmap.
72 */
73#define FIXADDR_TOP (0xfcfff000UL)
74#define FIXADDR_SIZE ((__end_of_fixed_addresses) << PAGE_SHIFT)
75#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
76
77#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
78#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
79
80extern void __this_fixmap_does_not_exist(void);
81
82/*
83 * 'index to address' translation. If anyone tries to use the idx
84 * directly without tranlation, we catch the bug with a NULL-deference
85 * kernel oops. Illegal ranges of incoming indices are caught too.
86 */
87static inline unsigned long fix_to_virt(const unsigned int idx)
88{
89 /*
90 * this branch gets completely eliminated after inlining,
91 * except when someone tries to use fixaddr indices in an
92 * illegal way. (such as mixing up address types or using
93 * out-of-range indices).
94 *
95 * If it doesn't get removed, the linker will complain
96 * loudly with a reasonably clear error message..
97 */
98 if (idx >= __end_of_fixed_addresses)
99 __this_fixmap_does_not_exist();
100
101 return __fix_to_virt(idx);
102}
103
104static inline unsigned long virt_to_fix(const unsigned long vaddr)
105{
106 BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
107 return __virt_to_fix(vaddr);
108}
109
110#endif
diff --git a/arch/sparc/include/asm/highmem.h b/arch/sparc/include/asm/highmem.h
index 3b6e00dd96e..4f9e15c757e 100644
--- a/arch/sparc/include/asm/highmem.h
+++ b/arch/sparc/include/asm/highmem.h
@@ -21,7 +21,6 @@
21#ifdef __KERNEL__ 21#ifdef __KERNEL__
22 22
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <asm/fixmap.h>
25#include <asm/vaddrs.h> 24#include <asm/vaddrs.h>
26#include <asm/kmap_types.h> 25#include <asm/kmap_types.h>
27#include <asm/pgtable.h> 26#include <asm/pgtable.h>
@@ -29,7 +28,6 @@
29/* declarations for highmem.c */ 28/* declarations for highmem.c */
30extern unsigned long highstart_pfn, highend_pfn; 29extern unsigned long highstart_pfn, highend_pfn;
31 30
32extern pte_t *kmap_pte;
33extern pgprot_t kmap_prot; 31extern pgprot_t kmap_prot;
34extern pte_t *pkmap_page_table; 32extern pte_t *pkmap_page_table;
35 33
@@ -72,7 +70,6 @@ static inline void kunmap(struct page *page)
72 70
73extern void *kmap_atomic(struct page *page); 71extern void *kmap_atomic(struct page *page);
74extern void __kunmap_atomic(void *kvaddr); 72extern void __kunmap_atomic(void *kvaddr);
75extern struct page *kmap_atomic_to_page(void *vaddr);
76 73
77#define flush_cache_kmaps() flush_cache_all() 74#define flush_cache_kmaps() flush_cache_all()
78 75
diff --git a/arch/sparc/include/asm/leon.h b/arch/sparc/include/asm/leon.h
index 3375c629389..15a716934e4 100644
--- a/arch/sparc/include/asm/leon.h
+++ b/arch/sparc/include/asm/leon.h
@@ -82,7 +82,6 @@ static inline unsigned long leon_load_reg(unsigned long paddr)
82#define LEON_BYPASS_LOAD_PA(x) leon_load_reg((unsigned long)(x)) 82#define LEON_BYPASS_LOAD_PA(x) leon_load_reg((unsigned long)(x))
83#define LEON_BYPASS_STORE_PA(x, v) leon_store_reg((unsigned long)(x), (unsigned long)(v)) 83#define LEON_BYPASS_STORE_PA(x, v) leon_store_reg((unsigned long)(x), (unsigned long)(v))
84 84
85extern void leon_init(void);
86extern void leon_switch_mm(void); 85extern void leon_switch_mm(void);
87extern void leon_init_IRQ(void); 86extern void leon_init_IRQ(void);
88 87
diff --git a/arch/sparc/include/asm/mmu_context_32.h b/arch/sparc/include/asm/mmu_context_32.h
index 01456c90072..2df2a9be8f6 100644
--- a/arch/sparc/include/asm/mmu_context_32.h
+++ b/arch/sparc/include/asm/mmu_context_32.h
@@ -9,14 +9,12 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
9{ 9{
10} 10}
11 11
12/* 12/* Initialize a new mmu context. This is invoked when a new
13 * Initialize a new mmu context. This is invoked when a new
14 * address space instance (unique or shared) is instantiated. 13 * address space instance (unique or shared) is instantiated.
15 */ 14 */
16#define init_new_context(tsk, mm) (((mm)->context = NO_CONTEXT), 0) 15int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
17 16
18/* 17/* Destroy a dead context. This occurs when mmput drops the
19 * Destroy a dead context. This occurs when mmput drops the
20 * mm_users count to zero, the mmaps have been released, and 18 * mm_users count to zero, the mmaps have been released, and
21 * all the page tables have been flushed. Our job is to destroy 19 * all the page tables have been flushed. Our job is to destroy
22 * any remaining processor-specific state. 20 * any remaining processor-specific state.
diff --git a/arch/sparc/include/asm/page_32.h b/arch/sparc/include/asm/page_32.h
index fab78a308eb..f82a1f36b65 100644
--- a/arch/sparc/include/asm/page_32.h
+++ b/arch/sparc/include/asm/page_32.h
@@ -107,8 +107,7 @@ typedef unsigned long iopgprot_t;
107 107
108typedef struct page *pgtable_t; 108typedef struct page *pgtable_t;
109 109
110extern unsigned long sparc_unmapped_base; 110#define TASK_UNMAPPED_BASE 0x50000000
111#define TASK_UNMAPPED_BASE sparc_unmapped_base
112 111
113#else /* !(__ASSEMBLY__) */ 112#else /* !(__ASSEMBLY__) */
114 113
diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
index e5b169b46d2..9b1c36de0f1 100644
--- a/arch/sparc/include/asm/pgalloc_32.h
+++ b/arch/sparc/include/asm/pgalloc_32.h
@@ -11,28 +11,15 @@
11 11
12struct page; 12struct page;
13 13
14extern struct pgtable_cache_struct { 14void *srmmu_get_nocache(int size, int align);
15 unsigned long *pgd_cache; 15void srmmu_free_nocache(void *addr, int size);
16 unsigned long *pte_cache;
17 unsigned long pgtable_cache_sz;
18 unsigned long pgd_cache_sz;
19} pgt_quicklists;
20
21unsigned long srmmu_get_nocache(int size, int align);
22void srmmu_free_nocache(unsigned long vaddr, int size);
23
24#define pgd_quicklist (pgt_quicklists.pgd_cache)
25#define pmd_quicklist ((unsigned long *)0)
26#define pte_quicklist (pgt_quicklists.pte_cache)
27#define pgtable_cache_size (pgt_quicklists.pgtable_cache_sz)
28#define pgd_cache_size (pgt_quicklists.pgd_cache_sz)
29 16
30#define check_pgt_cache() do { } while (0) 17#define check_pgt_cache() do { } while (0)
31 18
32pgd_t *get_pgd_fast(void); 19pgd_t *get_pgd_fast(void);
33static inline void free_pgd_fast(pgd_t *pgd) 20static inline void free_pgd_fast(pgd_t *pgd)
34{ 21{
35 srmmu_free_nocache((unsigned long)pgd, SRMMU_PGD_TABLE_SIZE); 22 srmmu_free_nocache(pgd, SRMMU_PGD_TABLE_SIZE);
36} 23}
37 24
38#define pgd_free(mm, pgd) free_pgd_fast(pgd) 25#define pgd_free(mm, pgd) free_pgd_fast(pgd)
@@ -50,13 +37,13 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
50static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, 37static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
51 unsigned long address) 38 unsigned long address)
52{ 39{
53 return (pmd_t *)srmmu_get_nocache(SRMMU_PMD_TABLE_SIZE, 40 return srmmu_get_nocache(SRMMU_PMD_TABLE_SIZE,
54 SRMMU_PMD_TABLE_SIZE); 41 SRMMU_PMD_TABLE_SIZE);
55} 42}
56 43
57static inline void free_pmd_fast(pmd_t * pmd) 44static inline void free_pmd_fast(pmd_t * pmd)
58{ 45{
59 srmmu_free_nocache((unsigned long)pmd, SRMMU_PMD_TABLE_SIZE); 46 srmmu_free_nocache(pmd, SRMMU_PMD_TABLE_SIZE);
60} 47}
61 48
62#define pmd_free(mm, pmd) free_pmd_fast(pmd) 49#define pmd_free(mm, pmd) free_pmd_fast(pmd)
@@ -73,13 +60,13 @@ pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address);
73static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 60static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
74 unsigned long address) 61 unsigned long address)
75{ 62{
76 return (pte_t *)srmmu_get_nocache(PTE_SIZE, PTE_SIZE); 63 return srmmu_get_nocache(PTE_SIZE, PTE_SIZE);
77} 64}
78 65
79 66
80static inline void free_pte_fast(pte_t *pte) 67static inline void free_pte_fast(pte_t *pte)
81{ 68{
82 srmmu_free_nocache((unsigned long)pte, PTE_SIZE); 69 srmmu_free_nocache(pte, PTE_SIZE);
83} 70}
84 71
85#define pte_free_kernel(mm, pte) free_pte_fast(pte) 72#define pte_free_kernel(mm, pte) free_pte_fast(pte)
diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
index cbbbed5cb3a..6fc13483f70 100644
--- a/arch/sparc/include/asm/pgtable_32.h
+++ b/arch/sparc/include/asm/pgtable_32.h
@@ -52,8 +52,9 @@ extern unsigned long calc_highpages(void);
52#define PAGE_READONLY SRMMU_PAGE_RDONLY 52#define PAGE_READONLY SRMMU_PAGE_RDONLY
53#define PAGE_KERNEL SRMMU_PAGE_KERNEL 53#define PAGE_KERNEL SRMMU_PAGE_KERNEL
54 54
55/* Top-level page directory */ 55/* Top-level page directory - dummy used by init-mm.
56extern pgd_t swapper_pg_dir[1024]; 56 * srmmu.c will assign the real one (which is dynamically sized) */
57#define swapper_pg_dir NULL
57 58
58extern void paging_init(void); 59extern void paging_init(void);
59 60
@@ -78,8 +79,6 @@ extern unsigned long ptr_in_current_pgd;
78#define __S110 PAGE_SHARED 79#define __S110 PAGE_SHARED
79#define __S111 PAGE_SHARED 80#define __S111 PAGE_SHARED
80 81
81extern int num_contexts;
82
83/* First physical page can be anywhere, the following is needed so that 82/* First physical page can be anywhere, the following is needed so that
84 * va-->pa and vice versa conversions work properly without performance 83 * va-->pa and vice versa conversions work properly without performance
85 * hit for all __pa()/__va() operations. 84 * hit for all __pa()/__va() operations.
@@ -88,18 +87,11 @@ extern unsigned long phys_base;
88extern unsigned long pfn_base; 87extern unsigned long pfn_base;
89 88
90/* 89/*
91 * BAD_PAGETABLE is used when we need a bogus page-table, while
92 * BAD_PAGE is used for a bogus page.
93 *
94 * ZERO_PAGE is a global shared page that is always zero: used 90 * ZERO_PAGE is a global shared page that is always zero: used
95 * for zero-mapped memory areas etc.. 91 * for zero-mapped memory areas etc..
96 */ 92 */
97extern pte_t * __bad_pagetable(void);
98extern pte_t __bad_page(void);
99extern unsigned long empty_zero_page; 93extern unsigned long empty_zero_page;
100 94
101#define BAD_PAGETABLE __bad_pagetable()
102#define BAD_PAGE __bad_page()
103#define ZERO_PAGE(vaddr) (virt_to_page(&empty_zero_page)) 95#define ZERO_PAGE(vaddr) (virt_to_page(&empty_zero_page))
104 96
105/* 97/*
@@ -398,36 +390,6 @@ static inline pte_t pgoff_to_pte(unsigned long pgoff)
398 */ 390 */
399#define PTE_FILE_MAX_BITS 24 391#define PTE_FILE_MAX_BITS 24
400 392
401/*
402 */
403struct ctx_list {
404 struct ctx_list *next;
405 struct ctx_list *prev;
406 unsigned int ctx_number;
407 struct mm_struct *ctx_mm;
408};
409
410extern struct ctx_list *ctx_list_pool; /* Dynamically allocated */
411extern struct ctx_list ctx_free; /* Head of free list */
412extern struct ctx_list ctx_used; /* Head of used contexts list */
413
414#define NO_CONTEXT -1
415
416static inline void remove_from_ctx_list(struct ctx_list *entry)
417{
418 entry->next->prev = entry->prev;
419 entry->prev->next = entry->next;
420}
421
422static inline void add_to_ctx_list(struct ctx_list *head, struct ctx_list *entry)
423{
424 entry->next = head;
425 (entry->prev = head->prev)->next = entry;
426 head->prev = entry;
427}
428#define add_to_free_ctxlist(entry) add_to_ctx_list(&ctx_free, entry)
429#define add_to_used_ctxlist(entry) add_to_ctx_list(&ctx_used, entry)
430
431static inline unsigned long 393static inline unsigned long
432__get_phys (unsigned long addr) 394__get_phys (unsigned long addr)
433{ 395{
diff --git a/arch/sparc/include/asm/unistd.h b/arch/sparc/include/asm/unistd.h
index c7cb0af0eb5..fb269346480 100644
--- a/arch/sparc/include/asm/unistd.h
+++ b/arch/sparc/include/asm/unistd.h
@@ -423,7 +423,6 @@
423#endif 423#endif
424 424
425#ifdef __KERNEL__ 425#ifdef __KERNEL__
426#define __ARCH_WANT_IPC_PARSE_VERSION
427#define __ARCH_WANT_OLD_READDIR 426#define __ARCH_WANT_OLD_READDIR
428#define __ARCH_WANT_STAT64 427#define __ARCH_WANT_STAT64
429#define __ARCH_WANT_SYS_ALARM 428#define __ARCH_WANT_SYS_ALARM
diff --git a/arch/sparc/include/asm/vaddrs.h b/arch/sparc/include/asm/vaddrs.h
index da6535d88a7..c3dbcf90203 100644
--- a/arch/sparc/include/asm/vaddrs.h
+++ b/arch/sparc/include/asm/vaddrs.h
@@ -30,6 +30,28 @@
30 */ 30 */
31#define SRMMU_NOCACHE_ALCRATIO 64 /* 256 pages per 64MB of system RAM */ 31#define SRMMU_NOCACHE_ALCRATIO 64 /* 256 pages per 64MB of system RAM */
32 32
33#ifndef __ASSEMBLY__
34#include <asm/kmap_types.h>
35
36enum fixed_addresses {
37 FIX_HOLE,
38#ifdef CONFIG_HIGHMEM
39 FIX_KMAP_BEGIN,
40 FIX_KMAP_END = (KM_TYPE_NR * NR_CPUS),
41#endif
42 __end_of_fixed_addresses
43};
44#endif
45
46/* Leave one empty page between IO pages at 0xfd000000 and
47 * the top of the fixmap.
48 */
49#define FIXADDR_TOP (0xfcfff000UL)
50#define FIXADDR_SIZE ((FIX_KMAP_END + 1) << PAGE_SHIFT)
51#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
52
53#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
54
33#define SUN4M_IOBASE_VADDR 0xfd000000 /* Base for mapping pages */ 55#define SUN4M_IOBASE_VADDR 0xfd000000 /* Base for mapping pages */
34#define IOBASE_VADDR 0xfe000000 56#define IOBASE_VADDR 0xfe000000
35#define IOBASE_END 0xfe600000 57#define IOBASE_END 0xfe600000
diff --git a/arch/sparc/kernel/head_32.S b/arch/sparc/kernel/head_32.S
index afeb1d77030..3d92c0a8f6c 100644
--- a/arch/sparc/kernel/head_32.S
+++ b/arch/sparc/kernel/head_32.S
@@ -58,8 +58,6 @@ sun4e_notsup:
58/* This was the only reasonable way I could think of to properly align 58/* This was the only reasonable way I could think of to properly align
59 * these page-table data structures. 59 * these page-table data structures.
60 */ 60 */
61 .globl swapper_pg_dir
62swapper_pg_dir: .skip PAGE_SIZE
63 .globl empty_zero_page 61 .globl empty_zero_page
64empty_zero_page: .skip PAGE_SIZE 62empty_zero_page: .skip PAGE_SIZE
65 63
diff --git a/arch/sparc/kernel/ldc.c b/arch/sparc/kernel/ldc.c
index 435e406fdec..81d92fc9983 100644
--- a/arch/sparc/kernel/ldc.c
+++ b/arch/sparc/kernel/ldc.c
@@ -1250,14 +1250,12 @@ int ldc_bind(struct ldc_channel *lp, const char *name)
1250 snprintf(lp->rx_irq_name, LDC_IRQ_NAME_MAX, "%s RX", name); 1250 snprintf(lp->rx_irq_name, LDC_IRQ_NAME_MAX, "%s RX", name);
1251 snprintf(lp->tx_irq_name, LDC_IRQ_NAME_MAX, "%s TX", name); 1251 snprintf(lp->tx_irq_name, LDC_IRQ_NAME_MAX, "%s TX", name);
1252 1252
1253 err = request_irq(lp->cfg.rx_irq, ldc_rx, 1253 err = request_irq(lp->cfg.rx_irq, ldc_rx, IRQF_DISABLED,
1254 IRQF_SAMPLE_RANDOM | IRQF_DISABLED,
1255 lp->rx_irq_name, lp); 1254 lp->rx_irq_name, lp);
1256 if (err) 1255 if (err)
1257 return err; 1256 return err;
1258 1257
1259 err = request_irq(lp->cfg.tx_irq, ldc_tx, 1258 err = request_irq(lp->cfg.tx_irq, ldc_tx, IRQF_DISABLED,
1260 IRQF_SAMPLE_RANDOM | IRQF_DISABLED,
1261 lp->tx_irq_name, lp); 1259 lp->tx_irq_name, lp);
1262 if (err) { 1260 if (err) {
1263 free_irq(lp->cfg.rx_irq, lp); 1261 free_irq(lp->cfg.rx_irq, lp);
diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c
index e34e2c40c06..f8b6eee40bd 100644
--- a/arch/sparc/kernel/leon_kernel.c
+++ b/arch/sparc/kernel/leon_kernel.c
@@ -486,17 +486,6 @@ void __init leon_trans_init(struct device_node *dp)
486 } 486 }
487} 487}
488 488
489void __initdata (*prom_amba_init)(struct device_node *dp, struct device_node ***nextp) = 0;
490
491void __init leon_node_init(struct device_node *dp, struct device_node ***nextp)
492{
493 if (prom_amba_init &&
494 strcmp(dp->type, "ambapp") == 0 &&
495 strcmp(dp->name, "ambapp0") == 0) {
496 prom_amba_init(dp, nextp);
497 }
498}
499
500#ifdef CONFIG_SMP 489#ifdef CONFIG_SMP
501void leon_clear_profile_irq(int cpu) 490void leon_clear_profile_irq(int cpu)
502{ 491{
@@ -522,8 +511,3 @@ void __init leon_init_IRQ(void)
522 sparc_config.clear_clock_irq = leon_clear_clock_irq; 511 sparc_config.clear_clock_irq = leon_clear_clock_irq;
523 sparc_config.load_profile_irq = leon_load_profile_irq; 512 sparc_config.load_profile_irq = leon_load_profile_irq;
524} 513}
525
526void __init leon_init(void)
527{
528 of_pdt_build_more = &leon_node_init;
529}
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index 19f56058742..21dcda75a52 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -91,14 +91,6 @@ void __devinit pcibios_fixup_bus(struct pci_bus *pbus)
91 } 91 }
92} 92}
93 93
94/*
95 * Other archs parse arguments here.
96 */
97char * __devinit pcibios_setup(char *str)
98{
99 return str;
100}
101
102resource_size_t pcibios_align_resource(void *data, const struct resource *res, 94resource_size_t pcibios_align_resource(void *data, const struct resource *res,
103 resource_size_t size, resource_size_t align) 95 resource_size_t size, resource_size_t align)
104{ 96{
diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c
index 7a3be6f6737..7bbdc26d951 100644
--- a/arch/sparc/kernel/of_device_64.c
+++ b/arch/sparc/kernel/of_device_64.c
@@ -580,7 +580,7 @@ static unsigned int __init build_one_device_irq(struct platform_device *op,
580 printk("%s: Apply [%s:%x] imap --> [%s:%x]\n", 580 printk("%s: Apply [%s:%x] imap --> [%s:%x]\n",
581 op->dev.of_node->full_name, 581 op->dev.of_node->full_name,
582 pp->full_name, this_orig_irq, 582 pp->full_name, this_orig_irq,
583 (iret ? iret->full_name : "NULL"), irq); 583 of_node_full_name(iret), irq);
584 584
585 if (!iret) 585 if (!iret)
586 break; 586 break;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index fdaf2181167..065b88c4f86 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -375,93 +375,6 @@ static void __devinit apb_calc_first_last(u8 map, u32 *first_p, u32 *last_p)
375 *last_p = last; 375 *last_p = last;
376} 376}
377 377
378/* For PCI bus devices which lack a 'ranges' property we interrogate
379 * the config space values to set the resources, just like the generic
380 * Linux PCI probing code does.
381 */
382static void __devinit pci_cfg_fake_ranges(struct pci_dev *dev,
383 struct pci_bus *bus,
384 struct pci_pbm_info *pbm)
385{
386 struct pci_bus_region region;
387 struct resource *res, res2;
388 u8 io_base_lo, io_limit_lo;
389 u16 mem_base_lo, mem_limit_lo;
390 unsigned long base, limit;
391
392 pci_read_config_byte(dev, PCI_IO_BASE, &io_base_lo);
393 pci_read_config_byte(dev, PCI_IO_LIMIT, &io_limit_lo);
394 base = (io_base_lo & PCI_IO_RANGE_MASK) << 8;
395 limit = (io_limit_lo & PCI_IO_RANGE_MASK) << 8;
396
397 if ((io_base_lo & PCI_IO_RANGE_TYPE_MASK) == PCI_IO_RANGE_TYPE_32) {
398 u16 io_base_hi, io_limit_hi;
399
400 pci_read_config_word(dev, PCI_IO_BASE_UPPER16, &io_base_hi);
401 pci_read_config_word(dev, PCI_IO_LIMIT_UPPER16, &io_limit_hi);
402 base |= (io_base_hi << 16);
403 limit |= (io_limit_hi << 16);
404 }
405
406 res = bus->resource[0];
407 if (base <= limit) {
408 res->flags = (io_base_lo & PCI_IO_RANGE_TYPE_MASK) | IORESOURCE_IO;
409 res2.flags = res->flags;
410 region.start = base;
411 region.end = limit + 0xfff;
412 pcibios_bus_to_resource(dev, &res2, &region);
413 if (!res->start)
414 res->start = res2.start;
415 if (!res->end)
416 res->end = res2.end;
417 }
418
419 pci_read_config_word(dev, PCI_MEMORY_BASE, &mem_base_lo);
420 pci_read_config_word(dev, PCI_MEMORY_LIMIT, &mem_limit_lo);
421 base = (mem_base_lo & PCI_MEMORY_RANGE_MASK) << 16;
422 limit = (mem_limit_lo & PCI_MEMORY_RANGE_MASK) << 16;
423
424 res = bus->resource[1];
425 if (base <= limit) {
426 res->flags = ((mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) |
427 IORESOURCE_MEM);
428 region.start = base;
429 region.end = limit + 0xfffff;
430 pcibios_bus_to_resource(dev, res, &region);
431 }
432
433 pci_read_config_word(dev, PCI_PREF_MEMORY_BASE, &mem_base_lo);
434 pci_read_config_word(dev, PCI_PREF_MEMORY_LIMIT, &mem_limit_lo);
435 base = (mem_base_lo & PCI_PREF_RANGE_MASK) << 16;
436 limit = (mem_limit_lo & PCI_PREF_RANGE_MASK) << 16;
437
438 if ((mem_base_lo & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) {
439 u32 mem_base_hi, mem_limit_hi;
440
441 pci_read_config_dword(dev, PCI_PREF_BASE_UPPER32, &mem_base_hi);
442 pci_read_config_dword(dev, PCI_PREF_LIMIT_UPPER32, &mem_limit_hi);
443
444 /*
445 * Some bridges set the base > limit by default, and some
446 * (broken) BIOSes do not initialize them. If we find
447 * this, just assume they are not being used.
448 */
449 if (mem_base_hi <= mem_limit_hi) {
450 base |= ((long) mem_base_hi) << 32;
451 limit |= ((long) mem_limit_hi) << 32;
452 }
453 }
454
455 res = bus->resource[2];
456 if (base <= limit) {
457 res->flags = ((mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) |
458 IORESOURCE_MEM | IORESOURCE_PREFETCH);
459 region.start = base;
460 region.end = limit + 0xfffff;
461 pcibios_bus_to_resource(dev, res, &region);
462 }
463}
464
465/* Cook up fake bus resources for SUNW,simba PCI bridges which lack 378/* Cook up fake bus resources for SUNW,simba PCI bridges which lack
466 * a proper 'ranges' property. 379 * a proper 'ranges' property.
467 */ 380 */
@@ -535,7 +448,7 @@ static void __devinit of_scan_pci_bridge(struct pci_pbm_info *pbm,
535 } 448 }
536 449
537 bus->primary = dev->bus->number; 450 bus->primary = dev->bus->number;
538 bus->subordinate = busrange[1]; 451 pci_bus_insert_busn_res(bus, busrange[0], busrange[1]);
539 bus->bridge_ctl = 0; 452 bus->bridge_ctl = 0;
540 453
541 /* parse ranges property, or cook one up by hand for Simba */ 454 /* parse ranges property, or cook one up by hand for Simba */
@@ -550,7 +463,7 @@ static void __devinit of_scan_pci_bridge(struct pci_pbm_info *pbm,
550 apb_fake_ranges(dev, bus, pbm); 463 apb_fake_ranges(dev, bus, pbm);
551 goto after_ranges; 464 goto after_ranges;
552 } else if (ranges == NULL) { 465 } else if (ranges == NULL) {
553 pci_cfg_fake_ranges(dev, bus, pbm); 466 pci_read_bridge_bases(bus);
554 goto after_ranges; 467 goto after_ranges;
555 } 468 }
556 i = 1; 469 i = 1;
@@ -685,6 +598,10 @@ struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm,
685 pbm->io_space.start); 598 pbm->io_space.start);
686 pci_add_resource_offset(&resources, &pbm->mem_space, 599 pci_add_resource_offset(&resources, &pbm->mem_space,
687 pbm->mem_space.start); 600 pbm->mem_space.start);
601 pbm->busn.start = pbm->pci_first_busno;
602 pbm->busn.end = pbm->pci_last_busno;
603 pbm->busn.flags = IORESOURCE_BUS;
604 pci_add_resource(&resources, &pbm->busn);
688 bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops, 605 bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
689 pbm, &resources); 606 pbm, &resources);
690 if (!bus) { 607 if (!bus) {
@@ -693,8 +610,6 @@ struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm,
693 pci_free_resource_list(&resources); 610 pci_free_resource_list(&resources);
694 return NULL; 611 return NULL;
695 } 612 }
696 bus->secondary = pbm->pci_first_busno;
697 bus->subordinate = pbm->pci_last_busno;
698 613
699 pci_of_scan_bus(pbm, node, bus); 614 pci_of_scan_bus(pbm, node, bus);
700 pci_bus_add_devices(bus); 615 pci_bus_add_devices(bus);
@@ -747,11 +662,6 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
747 return 0; 662 return 0;
748} 663}
749 664
750char * __devinit pcibios_setup(char *str)
751{
752 return str;
753}
754
755/* Platform support for /proc/bus/pci/X/Y mmap()s. */ 665/* Platform support for /proc/bus/pci/X/Y mmap()s. */
756 666
757/* If the user uses a host-bridge as the PCI device, he may use 667/* If the user uses a host-bridge as the PCI device, he may use
diff --git a/arch/sparc/kernel/pci_impl.h b/arch/sparc/kernel/pci_impl.h
index 6beb60df31d..918a2031c8b 100644
--- a/arch/sparc/kernel/pci_impl.h
+++ b/arch/sparc/kernel/pci_impl.h
@@ -97,6 +97,7 @@ struct pci_pbm_info {
97 /* PBM I/O and Memory space resources. */ 97 /* PBM I/O and Memory space resources. */
98 struct resource io_space; 98 struct resource io_space;
99 struct resource mem_space; 99 struct resource mem_space;
100 struct resource busn;
100 101
101 /* Base of PCI Config space, can be per-PBM or shared. */ 102 /* Base of PCI Config space, can be per-PBM or shared. */
102 unsigned long config_space; 103 unsigned long config_space;
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index ded3f6090c3..521fdf1b20e 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -767,14 +767,6 @@ static void watchdog_reset() {
767} 767}
768#endif 768#endif
769 769
770/*
771 * Other archs parse arguments here.
772 */
773char * __devinit pcibios_setup(char *str)
774{
775 return str;
776}
777
778resource_size_t pcibios_align_resource(void *data, const struct resource *res, 770resource_size_t pcibios_align_resource(void *data, const struct resource *res,
779 resource_size_t size, resource_size_t align) 771 resource_size_t size, resource_size_t align)
780{ 772{
@@ -884,11 +876,6 @@ void __init sun4m_pci_init_IRQ(void)
884 sparc_config.load_profile_irq = pcic_load_profile_irq; 876 sparc_config.load_profile_irq = pcic_load_profile_irq;
885} 877}
886 878
887int pcibios_assign_resource(struct pci_dev *pdev, int resource)
888{
889 return -ENXIO;
890}
891
892/* 879/*
893 * This probably belongs here rather than ioport.c because 880 * This probably belongs here rather than ioport.c because
894 * we do not want this crud linked into SBus kernels. 881 * we do not want this crud linked into SBus kernels.
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
index cb36e82dcd5..14006d8aca2 100644
--- a/arch/sparc/kernel/process_32.c
+++ b/arch/sparc/kernel/process_32.c
@@ -333,9 +333,6 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
333 put_psr(get_psr() | PSR_EF); 333 put_psr(get_psr() | PSR_EF);
334 fpsave(&p->thread.float_regs[0], &p->thread.fsr, 334 fpsave(&p->thread.float_regs[0], &p->thread.fsr,
335 &p->thread.fpqueue[0], &p->thread.fpqdepth); 335 &p->thread.fpqueue[0], &p->thread.fpqdepth);
336#ifdef CONFIG_SMP
337 clear_thread_flag(TIF_USEDFPU);
338#endif
339 } 336 }
340 337
341 /* 338 /*
@@ -413,6 +410,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
413#ifdef CONFIG_SMP 410#ifdef CONFIG_SMP
414 /* FPU must be disabled on SMP. */ 411 /* FPU must be disabled on SMP. */
415 childregs->psr &= ~PSR_EF; 412 childregs->psr &= ~PSR_EF;
413 clear_tsk_thread_flag(p, TIF_USEDFPU);
416#endif 414#endif
417 415
418 /* Set the return value for the child. */ 416 /* Set the return value for the child. */
diff --git a/arch/sparc/kernel/setup_32.c b/arch/sparc/kernel/setup_32.c
index efe3e64bba3..38bf80a22f0 100644
--- a/arch/sparc/kernel/setup_32.c
+++ b/arch/sparc/kernel/setup_32.c
@@ -371,7 +371,6 @@ void __init setup_arch(char **cmdline_p)
371 (*(linux_dbvec->teach_debugger))(); 371 (*(linux_dbvec->teach_debugger))();
372 } 372 }
373 373
374 init_mm.context = (unsigned long) NO_CONTEXT;
375 init_task.thread.kregs = &fake_swapper_regs; 374 init_task.thread.kregs = &fake_swapper_regs;
376 375
377 /* Run-time patch instructions to match the cpu model */ 376 /* Run-time patch instructions to match the cpu model */
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index f591598d92f..781bcb10b8b 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -103,8 +103,6 @@ void __cpuinit smp_callin(void)
103 if (cheetah_pcache_forced_on) 103 if (cheetah_pcache_forced_on)
104 cheetah_enable_pcache(); 104 cheetah_enable_pcache();
105 105
106 local_irq_enable();
107
108 callin_flag = 1; 106 callin_flag = 1;
109 __asm__ __volatile__("membar #Sync\n\t" 107 __asm__ __volatile__("membar #Sync\n\t"
110 "flush %%g6" : : : "memory"); 108 "flush %%g6" : : : "memory");
@@ -124,9 +122,8 @@ void __cpuinit smp_callin(void)
124 while (!cpumask_test_cpu(cpuid, &smp_commenced_mask)) 122 while (!cpumask_test_cpu(cpuid, &smp_commenced_mask))
125 rmb(); 123 rmb();
126 124
127 ipi_call_lock_irq();
128 set_cpu_online(cpuid, true); 125 set_cpu_online(cpuid, true);
129 ipi_call_unlock_irq(); 126 local_irq_enable();
130 127
131 /* idle thread is expected to have preempt disabled */ 128 /* idle thread is expected to have preempt disabled */
132 preempt_disable(); 129 preempt_disable();
@@ -1308,9 +1305,7 @@ int __cpu_disable(void)
1308 mdelay(1); 1305 mdelay(1);
1309 local_irq_disable(); 1306 local_irq_disable();
1310 1307
1311 ipi_call_lock();
1312 set_cpu_online(cpu, false); 1308 set_cpu_online(cpu, false);
1313 ipi_call_unlock();
1314 1309
1315 cpu_map_rebuild(); 1310 cpu_map_rebuild();
1316 1311
diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
index 275f74fd6f6..11c6c9603e7 100644
--- a/arch/sparc/kernel/sys_sparc_64.c
+++ b/arch/sparc/kernel/sys_sparc_64.c
@@ -66,23 +66,6 @@ static inline int invalid_64bit_range(unsigned long addr, unsigned long len)
66 return 0; 66 return 0;
67} 67}
68 68
69/* Does start,end straddle the VA-space hole? */
70static inline int straddles_64bit_va_hole(unsigned long start, unsigned long end)
71{
72 unsigned long va_exclude_start, va_exclude_end;
73
74 va_exclude_start = VA_EXCLUDE_START;
75 va_exclude_end = VA_EXCLUDE_END;
76
77 if (likely(start < va_exclude_start && end < va_exclude_start))
78 return 0;
79
80 if (likely(start >= va_exclude_end && end >= va_exclude_end))
81 return 0;
82
83 return 1;
84}
85
86/* These functions differ from the default implementations in 69/* These functions differ from the default implementations in
87 * mm/mmap.c in two ways: 70 * mm/mmap.c in two ways:
88 * 71 *
@@ -487,7 +470,7 @@ SYSCALL_DEFINE6(sparc_ipc, unsigned int, call, int, first, unsigned long, second
487 switch (call) { 470 switch (call) {
488 case SHMAT: { 471 case SHMAT: {
489 ulong raddr; 472 ulong raddr;
490 err = do_shmat(first, ptr, (int)second, &raddr); 473 err = do_shmat(first, ptr, (int)second, &raddr, SHMLBA);
491 if (!err) { 474 if (!err) {
492 if (put_user(raddr, 475 if (put_user(raddr,
493 (ulong __user *) third)) 476 (ulong __user *) third))
@@ -519,12 +502,12 @@ SYSCALL_DEFINE1(sparc64_personality, unsigned long, personality)
519{ 502{
520 int ret; 503 int ret;
521 504
522 if (current->personality == PER_LINUX32 && 505 if (personality(current->personality) == PER_LINUX32 &&
523 personality == PER_LINUX) 506 personality(personality) == PER_LINUX)
524 personality = PER_LINUX32; 507 personality |= PER_LINUX32;
525 ret = sys_personality(personality); 508 ret = sys_personality(personality);
526 if (ret == PER_LINUX32) 509 if (personality(ret) == PER_LINUX32)
527 ret = PER_LINUX; 510 ret &= ~PER_LINUX32;
528 511
529 return ret; 512 return ret;
530} 513}
diff --git a/arch/sparc/lib/NG2memcpy.S b/arch/sparc/lib/NG2memcpy.S
index 0aed75653b5..03eadf66b0d 100644
--- a/arch/sparc/lib/NG2memcpy.S
+++ b/arch/sparc/lib/NG2memcpy.S
@@ -90,49 +90,49 @@
90 faligndata %x7, %x8, %f14; 90 faligndata %x7, %x8, %f14;
91 91
92#define FREG_MOVE_1(x0) \ 92#define FREG_MOVE_1(x0) \
93 fmovd %x0, %f0; 93 fsrc2 %x0, %f0;
94#define FREG_MOVE_2(x0, x1) \ 94#define FREG_MOVE_2(x0, x1) \
95 fmovd %x0, %f0; \ 95 fsrc2 %x0, %f0; \
96 fmovd %x1, %f2; 96 fsrc2 %x1, %f2;
97#define FREG_MOVE_3(x0, x1, x2) \ 97#define FREG_MOVE_3(x0, x1, x2) \
98 fmovd %x0, %f0; \ 98 fsrc2 %x0, %f0; \
99 fmovd %x1, %f2; \ 99 fsrc2 %x1, %f2; \
100 fmovd %x2, %f4; 100 fsrc2 %x2, %f4;
101#define FREG_MOVE_4(x0, x1, x2, x3) \ 101#define FREG_MOVE_4(x0, x1, x2, x3) \
102 fmovd %x0, %f0; \ 102 fsrc2 %x0, %f0; \
103 fmovd %x1, %f2; \ 103 fsrc2 %x1, %f2; \
104 fmovd %x2, %f4; \ 104 fsrc2 %x2, %f4; \
105 fmovd %x3, %f6; 105 fsrc2 %x3, %f6;
106#define FREG_MOVE_5(x0, x1, x2, x3, x4) \ 106#define FREG_MOVE_5(x0, x1, x2, x3, x4) \
107 fmovd %x0, %f0; \ 107 fsrc2 %x0, %f0; \
108 fmovd %x1, %f2; \ 108 fsrc2 %x1, %f2; \
109 fmovd %x2, %f4; \ 109 fsrc2 %x2, %f4; \
110 fmovd %x3, %f6; \ 110 fsrc2 %x3, %f6; \
111 fmovd %x4, %f8; 111 fsrc2 %x4, %f8;
112#define FREG_MOVE_6(x0, x1, x2, x3, x4, x5) \ 112#define FREG_MOVE_6(x0, x1, x2, x3, x4, x5) \
113 fmovd %x0, %f0; \ 113 fsrc2 %x0, %f0; \
114 fmovd %x1, %f2; \ 114 fsrc2 %x1, %f2; \
115 fmovd %x2, %f4; \ 115 fsrc2 %x2, %f4; \
116 fmovd %x3, %f6; \ 116 fsrc2 %x3, %f6; \
117 fmovd %x4, %f8; \ 117 fsrc2 %x4, %f8; \
118 fmovd %x5, %f10; 118 fsrc2 %x5, %f10;
119#define FREG_MOVE_7(x0, x1, x2, x3, x4, x5, x6) \ 119#define FREG_MOVE_7(x0, x1, x2, x3, x4, x5, x6) \
120 fmovd %x0, %f0; \ 120 fsrc2 %x0, %f0; \
121 fmovd %x1, %f2; \ 121 fsrc2 %x1, %f2; \
122 fmovd %x2, %f4; \ 122 fsrc2 %x2, %f4; \
123 fmovd %x3, %f6; \ 123 fsrc2 %x3, %f6; \
124 fmovd %x4, %f8; \ 124 fsrc2 %x4, %f8; \
125 fmovd %x5, %f10; \ 125 fsrc2 %x5, %f10; \
126 fmovd %x6, %f12; 126 fsrc2 %x6, %f12;
127#define FREG_MOVE_8(x0, x1, x2, x3, x4, x5, x6, x7) \ 127#define FREG_MOVE_8(x0, x1, x2, x3, x4, x5, x6, x7) \
128 fmovd %x0, %f0; \ 128 fsrc2 %x0, %f0; \
129 fmovd %x1, %f2; \ 129 fsrc2 %x1, %f2; \
130 fmovd %x2, %f4; \ 130 fsrc2 %x2, %f4; \
131 fmovd %x3, %f6; \ 131 fsrc2 %x3, %f6; \
132 fmovd %x4, %f8; \ 132 fsrc2 %x4, %f8; \
133 fmovd %x5, %f10; \ 133 fsrc2 %x5, %f10; \
134 fmovd %x6, %f12; \ 134 fsrc2 %x6, %f12; \
135 fmovd %x7, %f14; 135 fsrc2 %x7, %f14;
136#define FREG_LOAD_1(base, x0) \ 136#define FREG_LOAD_1(base, x0) \
137 EX_LD(LOAD(ldd, base + 0x00, %x0)) 137 EX_LD(LOAD(ldd, base + 0x00, %x0))
138#define FREG_LOAD_2(base, x0, x1) \ 138#define FREG_LOAD_2(base, x0, x1) \
diff --git a/arch/sparc/lib/U1memcpy.S b/arch/sparc/lib/U1memcpy.S
index bafd2fc07ac..b67142b7768 100644
--- a/arch/sparc/lib/U1memcpy.S
+++ b/arch/sparc/lib/U1memcpy.S
@@ -109,7 +109,7 @@
109#define UNEVEN_VISCHUNK_LAST(dest, f0, f1, left) \ 109#define UNEVEN_VISCHUNK_LAST(dest, f0, f1, left) \
110 subcc %left, 8, %left; \ 110 subcc %left, 8, %left; \
111 bl,pn %xcc, 95f; \ 111 bl,pn %xcc, 95f; \
112 fsrc1 %f0, %f1; 112 fsrc2 %f0, %f1;
113 113
114#define UNEVEN_VISCHUNK(dest, f0, f1, left) \ 114#define UNEVEN_VISCHUNK(dest, f0, f1, left) \
115 UNEVEN_VISCHUNK_LAST(dest, f0, f1, left) \ 115 UNEVEN_VISCHUNK_LAST(dest, f0, f1, left) \
@@ -201,7 +201,7 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
201 andn %o1, (0x40 - 1), %o1 201 andn %o1, (0x40 - 1), %o1
202 and %g2, 7, %g2 202 and %g2, 7, %g2
203 andncc %g3, 0x7, %g3 203 andncc %g3, 0x7, %g3
204 fmovd %f0, %f2 204 fsrc2 %f0, %f2
205 sub %g3, 0x8, %g3 205 sub %g3, 0x8, %g3
206 sub %o2, %GLOBAL_SPARE, %o2 206 sub %o2, %GLOBAL_SPARE, %o2
207 207
diff --git a/arch/sparc/lib/copy_page.S b/arch/sparc/lib/copy_page.S
index b243d3b606b..4d2df328e51 100644
--- a/arch/sparc/lib/copy_page.S
+++ b/arch/sparc/lib/copy_page.S
@@ -34,10 +34,10 @@
34#endif 34#endif
35 35
36#define TOUCH(reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7) \ 36#define TOUCH(reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7) \
37 fmovd %reg0, %f48; fmovd %reg1, %f50; \ 37 fsrc2 %reg0, %f48; fsrc2 %reg1, %f50; \
38 fmovd %reg2, %f52; fmovd %reg3, %f54; \ 38 fsrc2 %reg2, %f52; fsrc2 %reg3, %f54; \
39 fmovd %reg4, %f56; fmovd %reg5, %f58; \ 39 fsrc2 %reg4, %f56; fsrc2 %reg5, %f58; \
40 fmovd %reg6, %f60; fmovd %reg7, %f62; 40 fsrc2 %reg6, %f60; fsrc2 %reg7, %f62;
41 41
42 .text 42 .text
43 43
@@ -104,60 +104,60 @@ cheetah_copy_page_insn:
104 prefetch [%o1 + 0x140], #one_read 104 prefetch [%o1 + 0x140], #one_read
105 ldd [%o1 + 0x010], %f4 105 ldd [%o1 + 0x010], %f4
106 prefetch [%o1 + 0x180], #one_read 106 prefetch [%o1 + 0x180], #one_read
107 fmovd %f0, %f16 107 fsrc2 %f0, %f16
108 ldd [%o1 + 0x018], %f6 108 ldd [%o1 + 0x018], %f6
109 fmovd %f2, %f18 109 fsrc2 %f2, %f18
110 ldd [%o1 + 0x020], %f8 110 ldd [%o1 + 0x020], %f8
111 fmovd %f4, %f20 111 fsrc2 %f4, %f20
112 ldd [%o1 + 0x028], %f10 112 ldd [%o1 + 0x028], %f10
113 fmovd %f6, %f22 113 fsrc2 %f6, %f22
114 ldd [%o1 + 0x030], %f12 114 ldd [%o1 + 0x030], %f12
115 fmovd %f8, %f24 115 fsrc2 %f8, %f24
116 ldd [%o1 + 0x038], %f14 116 ldd [%o1 + 0x038], %f14
117 fmovd %f10, %f26 117 fsrc2 %f10, %f26
118 ldd [%o1 + 0x040], %f0 118 ldd [%o1 + 0x040], %f0
1191: ldd [%o1 + 0x048], %f2 1191: ldd [%o1 + 0x048], %f2
120 fmovd %f12, %f28 120 fsrc2 %f12, %f28
121 ldd [%o1 + 0x050], %f4 121 ldd [%o1 + 0x050], %f4
122 fmovd %f14, %f30 122 fsrc2 %f14, %f30
123 stda %f16, [%o0] ASI_BLK_P 123 stda %f16, [%o0] ASI_BLK_P
124 ldd [%o1 + 0x058], %f6 124 ldd [%o1 + 0x058], %f6
125 fmovd %f0, %f16 125 fsrc2 %f0, %f16
126 ldd [%o1 + 0x060], %f8 126 ldd [%o1 + 0x060], %f8
127 fmovd %f2, %f18 127 fsrc2 %f2, %f18
128 ldd [%o1 + 0x068], %f10 128 ldd [%o1 + 0x068], %f10
129 fmovd %f4, %f20 129 fsrc2 %f4, %f20
130 ldd [%o1 + 0x070], %f12 130 ldd [%o1 + 0x070], %f12
131 fmovd %f6, %f22 131 fsrc2 %f6, %f22
132 ldd [%o1 + 0x078], %f14 132 ldd [%o1 + 0x078], %f14
133 fmovd %f8, %f24 133 fsrc2 %f8, %f24
134 ldd [%o1 + 0x080], %f0 134 ldd [%o1 + 0x080], %f0
135 prefetch [%o1 + 0x180], #one_read 135 prefetch [%o1 + 0x180], #one_read
136 fmovd %f10, %f26 136 fsrc2 %f10, %f26
137 subcc %o2, 1, %o2 137 subcc %o2, 1, %o2
138 add %o0, 0x40, %o0 138 add %o0, 0x40, %o0
139 bne,pt %xcc, 1b 139 bne,pt %xcc, 1b
140 add %o1, 0x40, %o1 140 add %o1, 0x40, %o1
141 141
142 ldd [%o1 + 0x048], %f2 142 ldd [%o1 + 0x048], %f2
143 fmovd %f12, %f28 143 fsrc2 %f12, %f28
144 ldd [%o1 + 0x050], %f4 144 ldd [%o1 + 0x050], %f4
145 fmovd %f14, %f30 145 fsrc2 %f14, %f30
146 stda %f16, [%o0] ASI_BLK_P 146 stda %f16, [%o0] ASI_BLK_P
147 ldd [%o1 + 0x058], %f6 147 ldd [%o1 + 0x058], %f6
148 fmovd %f0, %f16 148 fsrc2 %f0, %f16
149 ldd [%o1 + 0x060], %f8 149 ldd [%o1 + 0x060], %f8
150 fmovd %f2, %f18 150 fsrc2 %f2, %f18
151 ldd [%o1 + 0x068], %f10 151 ldd [%o1 + 0x068], %f10
152 fmovd %f4, %f20 152 fsrc2 %f4, %f20
153 ldd [%o1 + 0x070], %f12 153 ldd [%o1 + 0x070], %f12
154 fmovd %f6, %f22 154 fsrc2 %f6, %f22
155 add %o0, 0x40, %o0 155 add %o0, 0x40, %o0
156 ldd [%o1 + 0x078], %f14 156 ldd [%o1 + 0x078], %f14
157 fmovd %f8, %f24 157 fsrc2 %f8, %f24
158 fmovd %f10, %f26 158 fsrc2 %f10, %f26
159 fmovd %f12, %f28 159 fsrc2 %f12, %f28
160 fmovd %f14, %f30 160 fsrc2 %f14, %f30
161 stda %f16, [%o0] ASI_BLK_P 161 stda %f16, [%o0] ASI_BLK_P
162 membar #Sync 162 membar #Sync
163 VISExitHalf 163 VISExitHalf
diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
index f46cf6be337..77ac917be15 100644
--- a/arch/sparc/mm/fault_32.c
+++ b/arch/sparc/mm/fault_32.c
@@ -32,24 +32,6 @@
32 32
33int show_unhandled_signals = 1; 33int show_unhandled_signals = 1;
34 34
35/* At boot time we determine these two values necessary for setting
36 * up the segment maps and page table entries (pte's).
37 */
38
39int num_contexts;
40
41/* Return how much physical memory we have. */
42unsigned long probe_memory(void)
43{
44 unsigned long total = 0;
45 int i;
46
47 for (i = 0; sp_banks[i].num_bytes; i++)
48 total += sp_banks[i].num_bytes;
49
50 return total;
51}
52
53static void unhandled_fault(unsigned long, struct task_struct *, 35static void unhandled_fault(unsigned long, struct task_struct *,
54 struct pt_regs *) __attribute__ ((noreturn)); 36 struct pt_regs *) __attribute__ ((noreturn));
55 37
diff --git a/arch/sparc/mm/highmem.c b/arch/sparc/mm/highmem.c
index 055c66cf1bf..449f864f0ce 100644
--- a/arch/sparc/mm/highmem.c
+++ b/arch/sparc/mm/highmem.c
@@ -22,13 +22,31 @@
22 * shared by CPUs, and so precious, and establishing them requires IPI. 22 * shared by CPUs, and so precious, and establishing them requires IPI.
23 * Atomic kmaps are lightweight and we may have NCPUS more of them. 23 * Atomic kmaps are lightweight and we may have NCPUS more of them.
24 */ 24 */
25#include <linux/mm.h>
26#include <linux/highmem.h> 25#include <linux/highmem.h>
27#include <linux/export.h> 26#include <linux/export.h>
28#include <asm/pgalloc.h> 27#include <linux/mm.h>
28
29#include <asm/cacheflush.h> 29#include <asm/cacheflush.h>
30#include <asm/tlbflush.h> 30#include <asm/tlbflush.h>
31#include <asm/fixmap.h> 31#include <asm/pgalloc.h>
32#include <asm/vaddrs.h>
33
34pgprot_t kmap_prot;
35
36static pte_t *kmap_pte;
37
38void __init kmap_init(void)
39{
40 unsigned long address;
41 pmd_t *dir;
42
43 address = __fix_to_virt(FIX_KMAP_BEGIN);
44 dir = pmd_offset(pgd_offset_k(address), address);
45
46 /* cache the first kmap pte */
47 kmap_pte = pte_offset_kernel(dir, address);
48 kmap_prot = __pgprot(SRMMU_ET_PTE | SRMMU_PRIV | SRMMU_CACHE);
49}
32 50
33void *kmap_atomic(struct page *page) 51void *kmap_atomic(struct page *page)
34{ 52{
@@ -110,21 +128,3 @@ void __kunmap_atomic(void *kvaddr)
110 pagefault_enable(); 128 pagefault_enable();
111} 129}
112EXPORT_SYMBOL(__kunmap_atomic); 130EXPORT_SYMBOL(__kunmap_atomic);
113
114/* We may be fed a pagetable here by ptep_to_xxx and others. */
115struct page *kmap_atomic_to_page(void *ptr)
116{
117 unsigned long idx, vaddr = (unsigned long)ptr;
118 pte_t *pte;
119
120 if (vaddr < SRMMU_NOCACHE_VADDR)
121 return virt_to_page(ptr);
122 if (vaddr < PKMAP_BASE)
123 return pfn_to_page(__nocache_pa(vaddr) >> PAGE_SHIFT);
124 BUG_ON(vaddr < FIXADDR_START);
125 BUG_ON(vaddr > FIXADDR_TOP);
126
127 idx = virt_to_fix(vaddr);
128 pte = kmap_pte - (idx - FIX_KMAP_BEGIN);
129 return pte_page(*pte);
130}
diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c
index ef5c779ec85..dde85ef1c56 100644
--- a/arch/sparc/mm/init_32.c
+++ b/arch/sparc/mm/init_32.c
@@ -45,9 +45,6 @@ unsigned long pfn_base;
45EXPORT_SYMBOL(pfn_base); 45EXPORT_SYMBOL(pfn_base);
46 46
47struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS+1]; 47struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS+1];
48unsigned long sparc_unmapped_base;
49
50struct pgtable_cache_struct pgt_quicklists;
51 48
52/* Initial ramdisk setup */ 49/* Initial ramdisk setup */
53extern unsigned int sparc_ramdisk_image; 50extern unsigned int sparc_ramdisk_image;
@@ -55,19 +52,6 @@ extern unsigned int sparc_ramdisk_size;
55 52
56unsigned long highstart_pfn, highend_pfn; 53unsigned long highstart_pfn, highend_pfn;
57 54
58pte_t *kmap_pte;
59pgprot_t kmap_prot;
60
61#define kmap_get_fixmap_pte(vaddr) \
62 pte_offset_kernel(pmd_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr))
63
64void __init kmap_init(void)
65{
66 /* cache the first kmap pte */
67 kmap_pte = kmap_get_fixmap_pte(__fix_to_virt(FIX_KMAP_BEGIN));
68 kmap_prot = __pgprot(SRMMU_ET_PTE | SRMMU_PRIV | SRMMU_CACHE);
69}
70
71void show_mem(unsigned int filter) 55void show_mem(unsigned int filter)
72{ 56{
73 printk("Mem-info:\n"); 57 printk("Mem-info:\n");
@@ -76,33 +60,8 @@ void show_mem(unsigned int filter)
76 nr_swap_pages << (PAGE_SHIFT-10)); 60 nr_swap_pages << (PAGE_SHIFT-10));
77 printk("%ld pages of RAM\n", totalram_pages); 61 printk("%ld pages of RAM\n", totalram_pages);
78 printk("%ld free pages\n", nr_free_pages()); 62 printk("%ld free pages\n", nr_free_pages());
79#if 0 /* undefined pgtable_cache_size, pgd_cache_size */
80 printk("%ld pages in page table cache\n",pgtable_cache_size);
81#ifndef CONFIG_SMP
82 if (sparc_cpu_model == sun4m || sparc_cpu_model == sun4d)
83 printk("%ld entries in page dir cache\n",pgd_cache_size);
84#endif
85#endif
86} 63}
87 64
88void __init sparc_context_init(int numctx)
89{
90 int ctx;
91
92 ctx_list_pool = __alloc_bootmem(numctx * sizeof(struct ctx_list), SMP_CACHE_BYTES, 0UL);
93
94 for(ctx = 0; ctx < numctx; ctx++) {
95 struct ctx_list *clist;
96
97 clist = (ctx_list_pool + ctx);
98 clist->ctx_number = ctx;
99 clist->ctx_mm = NULL;
100 }
101 ctx_free.next = ctx_free.prev = &ctx_free;
102 ctx_used.next = ctx_used.prev = &ctx_used;
103 for(ctx = 0; ctx < numctx; ctx++)
104 add_to_free_ctxlist(ctx_list_pool + ctx);
105}
106 65
107extern unsigned long cmdline_memory_size; 66extern unsigned long cmdline_memory_size;
108unsigned long last_valid_pfn; 67unsigned long last_valid_pfn;
@@ -292,22 +251,7 @@ extern void device_scan(void);
292 251
293void __init paging_init(void) 252void __init paging_init(void)
294{ 253{
295 switch(sparc_cpu_model) { 254 srmmu_paging_init();
296 case sparc_leon:
297 leon_init();
298 /* fall through */
299 case sun4m:
300 case sun4d:
301 srmmu_paging_init();
302 sparc_unmapped_base = 0x50000000;
303 break;
304 default:
305 prom_printf("paging_init: Cannot init paging on this Sparc\n");
306 prom_printf("paging_init: sparc_cpu_model = %d\n", sparc_cpu_model);
307 prom_printf("paging_init: Halting...\n");
308 prom_halt();
309 }
310
311 prom_build_devicetree(); 255 prom_build_devicetree();
312 of_fill_in_cpu_data(); 256 of_fill_in_cpu_data();
313 device_scan(); 257 device_scan();
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index 6026fdd1b2e..d58edf5fefd 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -2020,6 +2020,9 @@ EXPORT_SYMBOL(_PAGE_CACHE);
2020#ifdef CONFIG_SPARSEMEM_VMEMMAP 2020#ifdef CONFIG_SPARSEMEM_VMEMMAP
2021unsigned long vmemmap_table[VMEMMAP_SIZE]; 2021unsigned long vmemmap_table[VMEMMAP_SIZE];
2022 2022
2023static long __meminitdata addr_start, addr_end;
2024static int __meminitdata node_start;
2025
2023int __meminit vmemmap_populate(struct page *start, unsigned long nr, int node) 2026int __meminit vmemmap_populate(struct page *start, unsigned long nr, int node)
2024{ 2027{
2025 unsigned long vstart = (unsigned long) start; 2028 unsigned long vstart = (unsigned long) start;
@@ -2050,15 +2053,30 @@ int __meminit vmemmap_populate(struct page *start, unsigned long nr, int node)
2050 2053
2051 *vmem_pp = pte_base | __pa(block); 2054 *vmem_pp = pte_base | __pa(block);
2052 2055
2053 printk(KERN_INFO "[%p-%p] page_structs=%lu " 2056 /* check to see if we have contiguous blocks */
2054 "node=%d entry=%lu/%lu\n", start, block, nr, 2057 if (addr_end != addr || node_start != node) {
2055 node, 2058 if (addr_start)
2056 addr >> VMEMMAP_CHUNK_SHIFT, 2059 printk(KERN_DEBUG " [%lx-%lx] on node %d\n",
2057 VMEMMAP_SIZE); 2060 addr_start, addr_end-1, node_start);
2061 addr_start = addr;
2062 node_start = node;
2063 }
2064 addr_end = addr + VMEMMAP_CHUNK;
2058 } 2065 }
2059 } 2066 }
2060 return 0; 2067 return 0;
2061} 2068}
2069
2070void __meminit vmemmap_populate_print_last(void)
2071{
2072 if (addr_start) {
2073 printk(KERN_DEBUG " [%lx-%lx] on node %d\n",
2074 addr_start, addr_end-1, node_start);
2075 addr_start = 0;
2076 addr_end = 0;
2077 node_start = 0;
2078 }
2079}
2062#endif /* CONFIG_SPARSEMEM_VMEMMAP */ 2080#endif /* CONFIG_SPARSEMEM_VMEMMAP */
2063 2081
2064static void prot_init_common(unsigned long page_none, 2082static void prot_init_common(unsigned long page_none,
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index 62e3f577330..c38bb72e3e8 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -8,45 +8,45 @@
8 * Copyright (C) 1999,2000 Anton Blanchard (anton@samba.org) 8 * Copyright (C) 1999,2000 Anton Blanchard (anton@samba.org)
9 */ 9 */
10 10
11#include <linux/kernel.h> 11#include <linux/seq_file.h>
12#include <linux/mm.h>
13#include <linux/vmalloc.h>
14#include <linux/pagemap.h>
15#include <linux/init.h>
16#include <linux/spinlock.h> 12#include <linux/spinlock.h>
17#include <linux/bootmem.h> 13#include <linux/bootmem.h>
18#include <linux/fs.h> 14#include <linux/pagemap.h>
19#include <linux/seq_file.h> 15#include <linux/vmalloc.h>
20#include <linux/kdebug.h> 16#include <linux/kdebug.h>
17#include <linux/kernel.h>
18#include <linux/init.h>
21#include <linux/log2.h> 19#include <linux/log2.h>
22#include <linux/gfp.h> 20#include <linux/gfp.h>
21#include <linux/fs.h>
22#include <linux/mm.h>
23 23
24#include <asm/bitext.h> 24#include <asm/mmu_context.h>
25#include <asm/page.h> 25#include <asm/cacheflush.h>
26#include <asm/tlbflush.h>
27#include <asm/io-unit.h>
26#include <asm/pgalloc.h> 28#include <asm/pgalloc.h>
27#include <asm/pgtable.h> 29#include <asm/pgtable.h>
28#include <asm/io.h> 30#include <asm/bitext.h>
29#include <asm/vaddrs.h> 31#include <asm/vaddrs.h>
30#include <asm/traps.h>
31#include <asm/smp.h>
32#include <asm/mbus.h>
33#include <asm/cache.h> 32#include <asm/cache.h>
33#include <asm/traps.h>
34#include <asm/oplib.h> 34#include <asm/oplib.h>
35#include <asm/mbus.h>
36#include <asm/page.h>
35#include <asm/asi.h> 37#include <asm/asi.h>
36#include <asm/msi.h> 38#include <asm/msi.h>
37#include <asm/mmu_context.h> 39#include <asm/smp.h>
38#include <asm/io-unit.h> 40#include <asm/io.h>
39#include <asm/cacheflush.h>
40#include <asm/tlbflush.h>
41 41
42/* Now the cpu specific definitions. */ 42/* Now the cpu specific definitions. */
43#include <asm/viking.h> 43#include <asm/turbosparc.h>
44#include <asm/mxcc.h>
45#include <asm/ross.h>
46#include <asm/tsunami.h> 44#include <asm/tsunami.h>
45#include <asm/viking.h>
47#include <asm/swift.h> 46#include <asm/swift.h>
48#include <asm/turbosparc.h>
49#include <asm/leon.h> 47#include <asm/leon.h>
48#include <asm/mxcc.h>
49#include <asm/ross.h>
50 50
51#include "srmmu.h" 51#include "srmmu.h"
52 52
@@ -55,10 +55,6 @@ static unsigned int hwbug_bitmask;
55int vac_cache_size; 55int vac_cache_size;
56int vac_line_size; 56int vac_line_size;
57 57
58struct ctx_list *ctx_list_pool;
59struct ctx_list ctx_free;
60struct ctx_list ctx_used;
61
62extern struct resource sparc_iomap; 58extern struct resource sparc_iomap;
63 59
64extern unsigned long last_valid_pfn; 60extern unsigned long last_valid_pfn;
@@ -136,8 +132,8 @@ void pmd_populate(struct mm_struct *mm, pmd_t *pmdp, struct page *ptep)
136 } 132 }
137} 133}
138 134
139/* Find an entry in the third-level page table.. */ 135/* Find an entry in the third-level page table.. */
140pte_t *pte_offset_kernel(pmd_t * dir, unsigned long address) 136pte_t *pte_offset_kernel(pmd_t *dir, unsigned long address)
141{ 137{
142 void *pte; 138 void *pte;
143 139
@@ -151,55 +147,61 @@ pte_t *pte_offset_kernel(pmd_t * dir, unsigned long address)
151 * align: bytes, number to align at. 147 * align: bytes, number to align at.
152 * Returns the virtual address of the allocated area. 148 * Returns the virtual address of the allocated area.
153 */ 149 */
154static unsigned long __srmmu_get_nocache(int size, int align) 150static void *__srmmu_get_nocache(int size, int align)
155{ 151{
156 int offset; 152 int offset;
153 unsigned long addr;
157 154
158 if (size < SRMMU_NOCACHE_BITMAP_SHIFT) { 155 if (size < SRMMU_NOCACHE_BITMAP_SHIFT) {
159 printk("Size 0x%x too small for nocache request\n", size); 156 printk(KERN_ERR "Size 0x%x too small for nocache request\n",
157 size);
160 size = SRMMU_NOCACHE_BITMAP_SHIFT; 158 size = SRMMU_NOCACHE_BITMAP_SHIFT;
161 } 159 }
162 if (size & (SRMMU_NOCACHE_BITMAP_SHIFT-1)) { 160 if (size & (SRMMU_NOCACHE_BITMAP_SHIFT - 1)) {
163 printk("Size 0x%x unaligned int nocache request\n", size); 161 printk(KERN_ERR "Size 0x%x unaligned int nocache request\n",
164 size += SRMMU_NOCACHE_BITMAP_SHIFT-1; 162 size);
163 size += SRMMU_NOCACHE_BITMAP_SHIFT - 1;
165 } 164 }
166 BUG_ON(align > SRMMU_NOCACHE_ALIGN_MAX); 165 BUG_ON(align > SRMMU_NOCACHE_ALIGN_MAX);
167 166
168 offset = bit_map_string_get(&srmmu_nocache_map, 167 offset = bit_map_string_get(&srmmu_nocache_map,
169 size >> SRMMU_NOCACHE_BITMAP_SHIFT, 168 size >> SRMMU_NOCACHE_BITMAP_SHIFT,
170 align >> SRMMU_NOCACHE_BITMAP_SHIFT); 169 align >> SRMMU_NOCACHE_BITMAP_SHIFT);
171 if (offset == -1) { 170 if (offset == -1) {
172 printk("srmmu: out of nocache %d: %d/%d\n", 171 printk(KERN_ERR "srmmu: out of nocache %d: %d/%d\n",
173 size, (int) srmmu_nocache_size, 172 size, (int) srmmu_nocache_size,
174 srmmu_nocache_map.used << SRMMU_NOCACHE_BITMAP_SHIFT); 173 srmmu_nocache_map.used << SRMMU_NOCACHE_BITMAP_SHIFT);
175 return 0; 174 return 0;
176 } 175 }
177 176
178 return (SRMMU_NOCACHE_VADDR + (offset << SRMMU_NOCACHE_BITMAP_SHIFT)); 177 addr = SRMMU_NOCACHE_VADDR + (offset << SRMMU_NOCACHE_BITMAP_SHIFT);
178 return (void *)addr;
179} 179}
180 180
181unsigned long srmmu_get_nocache(int size, int align) 181void *srmmu_get_nocache(int size, int align)
182{ 182{
183 unsigned long tmp; 183 void *tmp;
184 184
185 tmp = __srmmu_get_nocache(size, align); 185 tmp = __srmmu_get_nocache(size, align);
186 186
187 if (tmp) 187 if (tmp)
188 memset((void *)tmp, 0, size); 188 memset(tmp, 0, size);
189 189
190 return tmp; 190 return tmp;
191} 191}
192 192
193void srmmu_free_nocache(unsigned long vaddr, int size) 193void srmmu_free_nocache(void *addr, int size)
194{ 194{
195 unsigned long vaddr;
195 int offset; 196 int offset;
196 197
198 vaddr = (unsigned long)addr;
197 if (vaddr < SRMMU_NOCACHE_VADDR) { 199 if (vaddr < SRMMU_NOCACHE_VADDR) {
198 printk("Vaddr %lx is smaller than nocache base 0x%lx\n", 200 printk("Vaddr %lx is smaller than nocache base 0x%lx\n",
199 vaddr, (unsigned long)SRMMU_NOCACHE_VADDR); 201 vaddr, (unsigned long)SRMMU_NOCACHE_VADDR);
200 BUG(); 202 BUG();
201 } 203 }
202 if (vaddr+size > srmmu_nocache_end) { 204 if (vaddr + size > srmmu_nocache_end) {
203 printk("Vaddr %lx is bigger than nocache end 0x%lx\n", 205 printk("Vaddr %lx is bigger than nocache end 0x%lx\n",
204 vaddr, srmmu_nocache_end); 206 vaddr, srmmu_nocache_end);
205 BUG(); 207 BUG();
@@ -212,7 +214,7 @@ void srmmu_free_nocache(unsigned long vaddr, int size)
212 printk("Size 0x%x is too small\n", size); 214 printk("Size 0x%x is too small\n", size);
213 BUG(); 215 BUG();
214 } 216 }
215 if (vaddr & (size-1)) { 217 if (vaddr & (size - 1)) {
216 printk("Vaddr %lx is not aligned to size 0x%x\n", vaddr, size); 218 printk("Vaddr %lx is not aligned to size 0x%x\n", vaddr, size);
217 BUG(); 219 BUG();
218 } 220 }
@@ -226,13 +228,23 @@ void srmmu_free_nocache(unsigned long vaddr, int size)
226static void srmmu_early_allocate_ptable_skeleton(unsigned long start, 228static void srmmu_early_allocate_ptable_skeleton(unsigned long start,
227 unsigned long end); 229 unsigned long end);
228 230
229extern unsigned long probe_memory(void); /* in fault.c */ 231/* Return how much physical memory we have. */
232static unsigned long __init probe_memory(void)
233{
234 unsigned long total = 0;
235 int i;
236
237 for (i = 0; sp_banks[i].num_bytes; i++)
238 total += sp_banks[i].num_bytes;
239
240 return total;
241}
230 242
231/* 243/*
232 * Reserve nocache dynamically proportionally to the amount of 244 * Reserve nocache dynamically proportionally to the amount of
233 * system RAM. -- Tomas Szepe <szepe@pinerecords.com>, June 2002 245 * system RAM. -- Tomas Szepe <szepe@pinerecords.com>, June 2002
234 */ 246 */
235static void srmmu_nocache_calcsize(void) 247static void __init srmmu_nocache_calcsize(void)
236{ 248{
237 unsigned long sysmemavail = probe_memory() / 1024; 249 unsigned long sysmemavail = probe_memory() / 1024;
238 int srmmu_nocache_npages; 250 int srmmu_nocache_npages;
@@ -271,7 +283,7 @@ static void __init srmmu_nocache_init(void)
271 srmmu_nocache_bitmap = __alloc_bootmem(bitmap_bits >> 3, SMP_CACHE_BYTES, 0UL); 283 srmmu_nocache_bitmap = __alloc_bootmem(bitmap_bits >> 3, SMP_CACHE_BYTES, 0UL);
272 bit_map_init(&srmmu_nocache_map, srmmu_nocache_bitmap, bitmap_bits); 284 bit_map_init(&srmmu_nocache_map, srmmu_nocache_bitmap, bitmap_bits);
273 285
274 srmmu_swapper_pg_dir = (pgd_t *)__srmmu_get_nocache(SRMMU_PGD_TABLE_SIZE, SRMMU_PGD_TABLE_SIZE); 286 srmmu_swapper_pg_dir = __srmmu_get_nocache(SRMMU_PGD_TABLE_SIZE, SRMMU_PGD_TABLE_SIZE);
275 memset(__nocache_fix(srmmu_swapper_pg_dir), 0, SRMMU_PGD_TABLE_SIZE); 287 memset(__nocache_fix(srmmu_swapper_pg_dir), 0, SRMMU_PGD_TABLE_SIZE);
276 init_mm.pgd = srmmu_swapper_pg_dir; 288 init_mm.pgd = srmmu_swapper_pg_dir;
277 289
@@ -304,7 +316,7 @@ pgd_t *get_pgd_fast(void)
304{ 316{
305 pgd_t *pgd = NULL; 317 pgd_t *pgd = NULL;
306 318
307 pgd = (pgd_t *)__srmmu_get_nocache(SRMMU_PGD_TABLE_SIZE, SRMMU_PGD_TABLE_SIZE); 319 pgd = __srmmu_get_nocache(SRMMU_PGD_TABLE_SIZE, SRMMU_PGD_TABLE_SIZE);
308 if (pgd) { 320 if (pgd) {
309 pgd_t *init = pgd_offset_k(0); 321 pgd_t *init = pgd_offset_k(0);
310 memset(pgd, 0, USER_PTRS_PER_PGD * sizeof(pgd_t)); 322 memset(pgd, 0, USER_PTRS_PER_PGD * sizeof(pgd_t));
@@ -330,7 +342,7 @@ pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address)
330 342
331 if ((pte = (unsigned long)pte_alloc_one_kernel(mm, address)) == 0) 343 if ((pte = (unsigned long)pte_alloc_one_kernel(mm, address)) == 0)
332 return NULL; 344 return NULL;
333 page = pfn_to_page( __nocache_pa(pte) >> PAGE_SHIFT ); 345 page = pfn_to_page(__nocache_pa(pte) >> PAGE_SHIFT);
334 pgtable_page_ctor(page); 346 pgtable_page_ctor(page);
335 return page; 347 return page;
336} 348}
@@ -344,18 +356,50 @@ void pte_free(struct mm_struct *mm, pgtable_t pte)
344 if (p == 0) 356 if (p == 0)
345 BUG(); 357 BUG();
346 p = page_to_pfn(pte) << PAGE_SHIFT; /* Physical address */ 358 p = page_to_pfn(pte) << PAGE_SHIFT; /* Physical address */
347 p = (unsigned long) __nocache_va(p); /* Nocached virtual */ 359
348 srmmu_free_nocache(p, PTE_SIZE); 360 /* free non cached virtual address*/
361 srmmu_free_nocache(__nocache_va(p), PTE_SIZE);
349} 362}
350 363
351/* 364/* context handling - a dynamically sized pool is used */
352 */ 365#define NO_CONTEXT -1
366
367struct ctx_list {
368 struct ctx_list *next;
369 struct ctx_list *prev;
370 unsigned int ctx_number;
371 struct mm_struct *ctx_mm;
372};
373
374static struct ctx_list *ctx_list_pool;
375static struct ctx_list ctx_free;
376static struct ctx_list ctx_used;
377
378/* At boot time we determine the number of contexts */
379static int num_contexts;
380
381static inline void remove_from_ctx_list(struct ctx_list *entry)
382{
383 entry->next->prev = entry->prev;
384 entry->prev->next = entry->next;
385}
386
387static inline void add_to_ctx_list(struct ctx_list *head, struct ctx_list *entry)
388{
389 entry->next = head;
390 (entry->prev = head->prev)->next = entry;
391 head->prev = entry;
392}
393#define add_to_free_ctxlist(entry) add_to_ctx_list(&ctx_free, entry)
394#define add_to_used_ctxlist(entry) add_to_ctx_list(&ctx_used, entry)
395
396
353static inline void alloc_context(struct mm_struct *old_mm, struct mm_struct *mm) 397static inline void alloc_context(struct mm_struct *old_mm, struct mm_struct *mm)
354{ 398{
355 struct ctx_list *ctxp; 399 struct ctx_list *ctxp;
356 400
357 ctxp = ctx_free.next; 401 ctxp = ctx_free.next;
358 if(ctxp != &ctx_free) { 402 if (ctxp != &ctx_free) {
359 remove_from_ctx_list(ctxp); 403 remove_from_ctx_list(ctxp);
360 add_to_used_ctxlist(ctxp); 404 add_to_used_ctxlist(ctxp);
361 mm->context = ctxp->ctx_number; 405 mm->context = ctxp->ctx_number;
@@ -363,9 +407,9 @@ static inline void alloc_context(struct mm_struct *old_mm, struct mm_struct *mm)
363 return; 407 return;
364 } 408 }
365 ctxp = ctx_used.next; 409 ctxp = ctx_used.next;
366 if(ctxp->ctx_mm == old_mm) 410 if (ctxp->ctx_mm == old_mm)
367 ctxp = ctxp->next; 411 ctxp = ctxp->next;
368 if(ctxp == &ctx_used) 412 if (ctxp == &ctx_used)
369 panic("out of mmu contexts"); 413 panic("out of mmu contexts");
370 flush_cache_mm(ctxp->ctx_mm); 414 flush_cache_mm(ctxp->ctx_mm);
371 flush_tlb_mm(ctxp->ctx_mm); 415 flush_tlb_mm(ctxp->ctx_mm);
@@ -385,11 +429,31 @@ static inline void free_context(int context)
385 add_to_free_ctxlist(ctx_old); 429 add_to_free_ctxlist(ctx_old);
386} 430}
387 431
432static void __init sparc_context_init(int numctx)
433{
434 int ctx;
435 unsigned long size;
436
437 size = numctx * sizeof(struct ctx_list);
438 ctx_list_pool = __alloc_bootmem(size, SMP_CACHE_BYTES, 0UL);
439
440 for (ctx = 0; ctx < numctx; ctx++) {
441 struct ctx_list *clist;
442
443 clist = (ctx_list_pool + ctx);
444 clist->ctx_number = ctx;
445 clist->ctx_mm = NULL;
446 }
447 ctx_free.next = ctx_free.prev = &ctx_free;
448 ctx_used.next = ctx_used.prev = &ctx_used;
449 for (ctx = 0; ctx < numctx; ctx++)
450 add_to_free_ctxlist(ctx_list_pool + ctx);
451}
388 452
389void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm, 453void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm,
390 struct task_struct *tsk) 454 struct task_struct *tsk)
391{ 455{
392 if(mm->context == NO_CONTEXT) { 456 if (mm->context == NO_CONTEXT) {
393 spin_lock(&srmmu_context_spinlock); 457 spin_lock(&srmmu_context_spinlock);
394 alloc_context(old_mm, mm); 458 alloc_context(old_mm, mm);
395 spin_unlock(&srmmu_context_spinlock); 459 spin_unlock(&srmmu_context_spinlock);
@@ -407,7 +471,7 @@ void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm,
407 471
408/* Low level IO area allocation on the SRMMU. */ 472/* Low level IO area allocation on the SRMMU. */
409static inline void srmmu_mapioaddr(unsigned long physaddr, 473static inline void srmmu_mapioaddr(unsigned long physaddr,
410 unsigned long virt_addr, int bus_type) 474 unsigned long virt_addr, int bus_type)
411{ 475{
412 pgd_t *pgdp; 476 pgd_t *pgdp;
413 pmd_t *pmdp; 477 pmd_t *pmdp;
@@ -420,8 +484,7 @@ static inline void srmmu_mapioaddr(unsigned long physaddr,
420 ptep = pte_offset_kernel(pmdp, virt_addr); 484 ptep = pte_offset_kernel(pmdp, virt_addr);
421 tmp = (physaddr >> 4) | SRMMU_ET_PTE; 485 tmp = (physaddr >> 4) | SRMMU_ET_PTE;
422 486
423 /* 487 /* I need to test whether this is consistent over all
424 * I need to test whether this is consistent over all
425 * sun4m's. The bus_type represents the upper 4 bits of 488 * sun4m's. The bus_type represents the upper 4 bits of
426 * 36-bit physical address on the I/O space lines... 489 * 36-bit physical address on the I/O space lines...
427 */ 490 */
@@ -591,10 +654,10 @@ static void __init srmmu_early_allocate_ptable_skeleton(unsigned long start,
591 pmd_t *pmdp; 654 pmd_t *pmdp;
592 pte_t *ptep; 655 pte_t *ptep;
593 656
594 while(start < end) { 657 while (start < end) {
595 pgdp = pgd_offset_k(start); 658 pgdp = pgd_offset_k(start);
596 if (pgd_none(*(pgd_t *)__nocache_fix(pgdp))) { 659 if (pgd_none(*(pgd_t *)__nocache_fix(pgdp))) {
597 pmdp = (pmd_t *) __srmmu_get_nocache( 660 pmdp = __srmmu_get_nocache(
598 SRMMU_PMD_TABLE_SIZE, SRMMU_PMD_TABLE_SIZE); 661 SRMMU_PMD_TABLE_SIZE, SRMMU_PMD_TABLE_SIZE);
599 if (pmdp == NULL) 662 if (pmdp == NULL)
600 early_pgtable_allocfail("pmd"); 663 early_pgtable_allocfail("pmd");
@@ -602,8 +665,8 @@ static void __init srmmu_early_allocate_ptable_skeleton(unsigned long start,
602 pgd_set(__nocache_fix(pgdp), pmdp); 665 pgd_set(__nocache_fix(pgdp), pmdp);
603 } 666 }
604 pmdp = pmd_offset(__nocache_fix(pgdp), start); 667 pmdp = pmd_offset(__nocache_fix(pgdp), start);
605 if(srmmu_pmd_none(*(pmd_t *)__nocache_fix(pmdp))) { 668 if (srmmu_pmd_none(*(pmd_t *)__nocache_fix(pmdp))) {
606 ptep = (pte_t *)__srmmu_get_nocache(PTE_SIZE, PTE_SIZE); 669 ptep = __srmmu_get_nocache(PTE_SIZE, PTE_SIZE);
607 if (ptep == NULL) 670 if (ptep == NULL)
608 early_pgtable_allocfail("pte"); 671 early_pgtable_allocfail("pte");
609 memset(__nocache_fix(ptep), 0, PTE_SIZE); 672 memset(__nocache_fix(ptep), 0, PTE_SIZE);
@@ -622,18 +685,18 @@ static void __init srmmu_allocate_ptable_skeleton(unsigned long start,
622 pmd_t *pmdp; 685 pmd_t *pmdp;
623 pte_t *ptep; 686 pte_t *ptep;
624 687
625 while(start < end) { 688 while (start < end) {
626 pgdp = pgd_offset_k(start); 689 pgdp = pgd_offset_k(start);
627 if (pgd_none(*pgdp)) { 690 if (pgd_none(*pgdp)) {
628 pmdp = (pmd_t *)__srmmu_get_nocache(SRMMU_PMD_TABLE_SIZE, SRMMU_PMD_TABLE_SIZE); 691 pmdp = __srmmu_get_nocache(SRMMU_PMD_TABLE_SIZE, SRMMU_PMD_TABLE_SIZE);
629 if (pmdp == NULL) 692 if (pmdp == NULL)
630 early_pgtable_allocfail("pmd"); 693 early_pgtable_allocfail("pmd");
631 memset(pmdp, 0, SRMMU_PMD_TABLE_SIZE); 694 memset(pmdp, 0, SRMMU_PMD_TABLE_SIZE);
632 pgd_set(pgdp, pmdp); 695 pgd_set(pgdp, pmdp);
633 } 696 }
634 pmdp = pmd_offset(pgdp, start); 697 pmdp = pmd_offset(pgdp, start);
635 if(srmmu_pmd_none(*pmdp)) { 698 if (srmmu_pmd_none(*pmdp)) {
636 ptep = (pte_t *) __srmmu_get_nocache(PTE_SIZE, 699 ptep = __srmmu_get_nocache(PTE_SIZE,
637 PTE_SIZE); 700 PTE_SIZE);
638 if (ptep == NULL) 701 if (ptep == NULL)
639 early_pgtable_allocfail("pte"); 702 early_pgtable_allocfail("pte");
@@ -671,72 +734,76 @@ static inline unsigned long srmmu_probe(unsigned long vaddr)
671static void __init srmmu_inherit_prom_mappings(unsigned long start, 734static void __init srmmu_inherit_prom_mappings(unsigned long start,
672 unsigned long end) 735 unsigned long end)
673{ 736{
737 unsigned long probed;
738 unsigned long addr;
674 pgd_t *pgdp; 739 pgd_t *pgdp;
675 pmd_t *pmdp; 740 pmd_t *pmdp;
676 pte_t *ptep; 741 pte_t *ptep;
677 int what = 0; /* 0 = normal-pte, 1 = pmd-level pte, 2 = pgd-level pte */ 742 int what; /* 0 = normal-pte, 1 = pmd-level pte, 2 = pgd-level pte */
678 unsigned long prompte;
679 743
680 while(start <= end) { 744 while (start <= end) {
681 if (start == 0) 745 if (start == 0)
682 break; /* probably wrap around */ 746 break; /* probably wrap around */
683 if(start == 0xfef00000) 747 if (start == 0xfef00000)
684 start = KADB_DEBUGGER_BEGVM; 748 start = KADB_DEBUGGER_BEGVM;
685 if(!(prompte = srmmu_probe(start))) { 749 probed = srmmu_probe(start);
750 if (!probed) {
751 /* continue probing until we find an entry */
686 start += PAGE_SIZE; 752 start += PAGE_SIZE;
687 continue; 753 continue;
688 } 754 }
689 755
690 /* A red snapper, see what it really is. */ 756 /* A red snapper, see what it really is. */
691 what = 0; 757 what = 0;
692 758 addr = start - PAGE_SIZE;
693 if(!(start & ~(SRMMU_REAL_PMD_MASK))) { 759
694 if(srmmu_probe((start-PAGE_SIZE) + SRMMU_REAL_PMD_SIZE) == prompte) 760 if (!(start & ~(SRMMU_REAL_PMD_MASK))) {
761 if (srmmu_probe(addr + SRMMU_REAL_PMD_SIZE) == probed)
695 what = 1; 762 what = 1;
696 } 763 }
697 764
698 if(!(start & ~(SRMMU_PGDIR_MASK))) { 765 if (!(start & ~(SRMMU_PGDIR_MASK))) {
699 if(srmmu_probe((start-PAGE_SIZE) + SRMMU_PGDIR_SIZE) == 766 if (srmmu_probe(addr + SRMMU_PGDIR_SIZE) == probed)
700 prompte)
701 what = 2; 767 what = 2;
702 } 768 }
703 769
704 pgdp = pgd_offset_k(start); 770 pgdp = pgd_offset_k(start);
705 if(what == 2) { 771 if (what == 2) {
706 *(pgd_t *)__nocache_fix(pgdp) = __pgd(prompte); 772 *(pgd_t *)__nocache_fix(pgdp) = __pgd(probed);
707 start += SRMMU_PGDIR_SIZE; 773 start += SRMMU_PGDIR_SIZE;
708 continue; 774 continue;
709 } 775 }
710 if (pgd_none(*(pgd_t *)__nocache_fix(pgdp))) { 776 if (pgd_none(*(pgd_t *)__nocache_fix(pgdp))) {
711 pmdp = (pmd_t *)__srmmu_get_nocache(SRMMU_PMD_TABLE_SIZE, SRMMU_PMD_TABLE_SIZE); 777 pmdp = __srmmu_get_nocache(SRMMU_PMD_TABLE_SIZE,
778 SRMMU_PMD_TABLE_SIZE);
712 if (pmdp == NULL) 779 if (pmdp == NULL)
713 early_pgtable_allocfail("pmd"); 780 early_pgtable_allocfail("pmd");
714 memset(__nocache_fix(pmdp), 0, SRMMU_PMD_TABLE_SIZE); 781 memset(__nocache_fix(pmdp), 0, SRMMU_PMD_TABLE_SIZE);
715 pgd_set(__nocache_fix(pgdp), pmdp); 782 pgd_set(__nocache_fix(pgdp), pmdp);
716 } 783 }
717 pmdp = pmd_offset(__nocache_fix(pgdp), start); 784 pmdp = pmd_offset(__nocache_fix(pgdp), start);
718 if(srmmu_pmd_none(*(pmd_t *)__nocache_fix(pmdp))) { 785 if (srmmu_pmd_none(*(pmd_t *)__nocache_fix(pmdp))) {
719 ptep = (pte_t *) __srmmu_get_nocache(PTE_SIZE, 786 ptep = __srmmu_get_nocache(PTE_SIZE, PTE_SIZE);
720 PTE_SIZE);
721 if (ptep == NULL) 787 if (ptep == NULL)
722 early_pgtable_allocfail("pte"); 788 early_pgtable_allocfail("pte");
723 memset(__nocache_fix(ptep), 0, PTE_SIZE); 789 memset(__nocache_fix(ptep), 0, PTE_SIZE);
724 pmd_set(__nocache_fix(pmdp), ptep); 790 pmd_set(__nocache_fix(pmdp), ptep);
725 } 791 }
726 if(what == 1) { 792 if (what == 1) {
727 /* 793 /* We bend the rule where all 16 PTPs in a pmd_t point
728 * We bend the rule where all 16 PTPs in a pmd_t point
729 * inside the same PTE page, and we leak a perfectly 794 * inside the same PTE page, and we leak a perfectly
730 * good hardware PTE piece. Alternatives seem worse. 795 * good hardware PTE piece. Alternatives seem worse.
731 */ 796 */
732 unsigned int x; /* Index of HW PMD in soft cluster */ 797 unsigned int x; /* Index of HW PMD in soft cluster */
798 unsigned long *val;
733 x = (start >> PMD_SHIFT) & 15; 799 x = (start >> PMD_SHIFT) & 15;
734 *(unsigned long *)__nocache_fix(&pmdp->pmdv[x]) = prompte; 800 val = &pmdp->pmdv[x];
801 *(unsigned long *)__nocache_fix(val) = probed;
735 start += SRMMU_REAL_PMD_SIZE; 802 start += SRMMU_REAL_PMD_SIZE;
736 continue; 803 continue;
737 } 804 }
738 ptep = pte_offset_kernel(__nocache_fix(pmdp), start); 805 ptep = pte_offset_kernel(__nocache_fix(pmdp), start);
739 *(pte_t *)__nocache_fix(ptep) = __pte(prompte); 806 *(pte_t *)__nocache_fix(ptep) = __pte(probed);
740 start += PAGE_SIZE; 807 start += PAGE_SIZE;
741 } 808 }
742} 809}
@@ -765,18 +832,18 @@ static unsigned long __init map_spbank(unsigned long vbase, int sp_entry)
765 832
766 if (vstart < min_vaddr || vstart >= max_vaddr) 833 if (vstart < min_vaddr || vstart >= max_vaddr)
767 return vstart; 834 return vstart;
768 835
769 if (vend > max_vaddr || vend < min_vaddr) 836 if (vend > max_vaddr || vend < min_vaddr)
770 vend = max_vaddr; 837 vend = max_vaddr;
771 838
772 while(vstart < vend) { 839 while (vstart < vend) {
773 do_large_mapping(vstart, pstart); 840 do_large_mapping(vstart, pstart);
774 vstart += SRMMU_PGDIR_SIZE; pstart += SRMMU_PGDIR_SIZE; 841 vstart += SRMMU_PGDIR_SIZE; pstart += SRMMU_PGDIR_SIZE;
775 } 842 }
776 return vstart; 843 return vstart;
777} 844}
778 845
779static inline void map_kernel(void) 846static void __init map_kernel(void)
780{ 847{
781 int i; 848 int i;
782 849
@@ -789,9 +856,6 @@ static inline void map_kernel(void)
789 } 856 }
790} 857}
791 858
792/* Paging initialization on the Sparc Reference MMU. */
793extern void sparc_context_init(int);
794
795void (*poke_srmmu)(void) __cpuinitdata = NULL; 859void (*poke_srmmu)(void) __cpuinitdata = NULL;
796 860
797extern unsigned long bootmem_init(unsigned long *pages_avail); 861extern unsigned long bootmem_init(unsigned long *pages_avail);
@@ -806,6 +870,7 @@ void __init srmmu_paging_init(void)
806 pte_t *pte; 870 pte_t *pte;
807 unsigned long pages_avail; 871 unsigned long pages_avail;
808 872
873 init_mm.context = (unsigned long) NO_CONTEXT;
809 sparc_iomap.start = SUN4M_IOBASE_VADDR; /* 16MB of IOSPACE on all sun4m's. */ 874 sparc_iomap.start = SUN4M_IOBASE_VADDR; /* 16MB of IOSPACE on all sun4m's. */
810 875
811 if (sparc_cpu_model == sun4d) 876 if (sparc_cpu_model == sun4d)
@@ -814,9 +879,9 @@ void __init srmmu_paging_init(void)
814 /* Find the number of contexts on the srmmu. */ 879 /* Find the number of contexts on the srmmu. */
815 cpunode = prom_getchild(prom_root_node); 880 cpunode = prom_getchild(prom_root_node);
816 num_contexts = 0; 881 num_contexts = 0;
817 while(cpunode != 0) { 882 while (cpunode != 0) {
818 prom_getstring(cpunode, "device_type", node_str, sizeof(node_str)); 883 prom_getstring(cpunode, "device_type", node_str, sizeof(node_str));
819 if(!strcmp(node_str, "cpu")) { 884 if (!strcmp(node_str, "cpu")) {
820 num_contexts = prom_getintdefault(cpunode, "mmu-nctx", 0x8); 885 num_contexts = prom_getintdefault(cpunode, "mmu-nctx", 0x8);
821 break; 886 break;
822 } 887 }
@@ -824,7 +889,7 @@ void __init srmmu_paging_init(void)
824 } 889 }
825 } 890 }
826 891
827 if(!num_contexts) { 892 if (!num_contexts) {
828 prom_printf("Something wrong, can't find cpu node in paging_init.\n"); 893 prom_printf("Something wrong, can't find cpu node in paging_init.\n");
829 prom_halt(); 894 prom_halt();
830 } 895 }
@@ -834,14 +899,14 @@ void __init srmmu_paging_init(void)
834 899
835 srmmu_nocache_calcsize(); 900 srmmu_nocache_calcsize();
836 srmmu_nocache_init(); 901 srmmu_nocache_init();
837 srmmu_inherit_prom_mappings(0xfe400000,(LINUX_OPPROM_ENDVM-PAGE_SIZE)); 902 srmmu_inherit_prom_mappings(0xfe400000, (LINUX_OPPROM_ENDVM - PAGE_SIZE));
838 map_kernel(); 903 map_kernel();
839 904
840 /* ctx table has to be physically aligned to its size */ 905 /* ctx table has to be physically aligned to its size */
841 srmmu_context_table = (ctxd_t *)__srmmu_get_nocache(num_contexts*sizeof(ctxd_t), num_contexts*sizeof(ctxd_t)); 906 srmmu_context_table = __srmmu_get_nocache(num_contexts * sizeof(ctxd_t), num_contexts * sizeof(ctxd_t));
842 srmmu_ctx_table_phys = (ctxd_t *)__nocache_pa((unsigned long)srmmu_context_table); 907 srmmu_ctx_table_phys = (ctxd_t *)__nocache_pa((unsigned long)srmmu_context_table);
843 908
844 for(i = 0; i < num_contexts; i++) 909 for (i = 0; i < num_contexts; i++)
845 srmmu_ctxd_set((ctxd_t *)__nocache_fix(&srmmu_context_table[i]), srmmu_swapper_pg_dir); 910 srmmu_ctxd_set((ctxd_t *)__nocache_fix(&srmmu_context_table[i]), srmmu_swapper_pg_dir);
846 911
847 flush_cache_all(); 912 flush_cache_all();
@@ -897,7 +962,7 @@ void __init srmmu_paging_init(void)
897 962
898void mmu_info(struct seq_file *m) 963void mmu_info(struct seq_file *m)
899{ 964{
900 seq_printf(m, 965 seq_printf(m,
901 "MMU type\t: %s\n" 966 "MMU type\t: %s\n"
902 "contexts\t: %d\n" 967 "contexts\t: %d\n"
903 "nocache total\t: %ld\n" 968 "nocache total\t: %ld\n"
@@ -908,10 +973,16 @@ void mmu_info(struct seq_file *m)
908 srmmu_nocache_map.used << SRMMU_NOCACHE_BITMAP_SHIFT); 973 srmmu_nocache_map.used << SRMMU_NOCACHE_BITMAP_SHIFT);
909} 974}
910 975
976int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
977{
978 mm->context = NO_CONTEXT;
979 return 0;
980}
981
911void destroy_context(struct mm_struct *mm) 982void destroy_context(struct mm_struct *mm)
912{ 983{
913 984
914 if(mm->context != NO_CONTEXT) { 985 if (mm->context != NO_CONTEXT) {
915 flush_cache_mm(mm); 986 flush_cache_mm(mm);
916 srmmu_ctxd_set(&srmmu_context_table[mm->context], srmmu_swapper_pg_dir); 987 srmmu_ctxd_set(&srmmu_context_table[mm->context], srmmu_swapper_pg_dir);
917 flush_tlb_mm(mm); 988 flush_tlb_mm(mm);
@@ -941,13 +1012,12 @@ static void __init init_vac_layout(void)
941#endif 1012#endif
942 1013
943 nd = prom_getchild(prom_root_node); 1014 nd = prom_getchild(prom_root_node);
944 while((nd = prom_getsibling(nd)) != 0) { 1015 while ((nd = prom_getsibling(nd)) != 0) {
945 prom_getstring(nd, "device_type", node_str, sizeof(node_str)); 1016 prom_getstring(nd, "device_type", node_str, sizeof(node_str));
946 if(!strcmp(node_str, "cpu")) { 1017 if (!strcmp(node_str, "cpu")) {
947 vac_line_size = prom_getint(nd, "cache-line-size"); 1018 vac_line_size = prom_getint(nd, "cache-line-size");
948 if (vac_line_size == -1) { 1019 if (vac_line_size == -1) {
949 prom_printf("can't determine cache-line-size, " 1020 prom_printf("can't determine cache-line-size, halting.\n");
950 "halting.\n");
951 prom_halt(); 1021 prom_halt();
952 } 1022 }
953 cache_lines = prom_getint(nd, "cache-nlines"); 1023 cache_lines = prom_getint(nd, "cache-nlines");
@@ -958,9 +1028,9 @@ static void __init init_vac_layout(void)
958 1028
959 vac_cache_size = cache_lines * vac_line_size; 1029 vac_cache_size = cache_lines * vac_line_size;
960#ifdef CONFIG_SMP 1030#ifdef CONFIG_SMP
961 if(vac_cache_size > max_size) 1031 if (vac_cache_size > max_size)
962 max_size = vac_cache_size; 1032 max_size = vac_cache_size;
963 if(vac_line_size < min_line_size) 1033 if (vac_line_size < min_line_size)
964 min_line_size = vac_line_size; 1034 min_line_size = vac_line_size;
965 //FIXME: cpus not contiguous!! 1035 //FIXME: cpus not contiguous!!
966 cpu++; 1036 cpu++;
@@ -971,7 +1041,7 @@ static void __init init_vac_layout(void)
971#endif 1041#endif
972 } 1042 }
973 } 1043 }
974 if(nd == 0) { 1044 if (nd == 0) {
975 prom_printf("No CPU nodes found, halting.\n"); 1045 prom_printf("No CPU nodes found, halting.\n");
976 prom_halt(); 1046 prom_halt();
977 } 1047 }
@@ -1082,7 +1152,7 @@ static void __init init_swift(void)
1082 "=r" (swift_rev) : 1152 "=r" (swift_rev) :
1083 "r" (SWIFT_MASKID_ADDR), "i" (ASI_M_BYPASS)); 1153 "r" (SWIFT_MASKID_ADDR), "i" (ASI_M_BYPASS));
1084 srmmu_name = "Fujitsu Swift"; 1154 srmmu_name = "Fujitsu Swift";
1085 switch(swift_rev) { 1155 switch (swift_rev) {
1086 case 0x11: 1156 case 0x11:
1087 case 0x20: 1157 case 0x20:
1088 case 0x23: 1158 case 0x23:
@@ -1222,10 +1292,11 @@ static void __cpuinit poke_turbosparc(void)
1222 1292
1223 /* Clear any crap from the cache or else... */ 1293 /* Clear any crap from the cache or else... */
1224 turbosparc_flush_cache_all(); 1294 turbosparc_flush_cache_all();
1225 mreg &= ~(TURBOSPARC_ICENABLE | TURBOSPARC_DCENABLE); /* Temporarily disable I & D caches */ 1295 /* Temporarily disable I & D caches */
1296 mreg &= ~(TURBOSPARC_ICENABLE | TURBOSPARC_DCENABLE);
1226 mreg &= ~(TURBOSPARC_PCENABLE); /* Don't check parity */ 1297 mreg &= ~(TURBOSPARC_PCENABLE); /* Don't check parity */
1227 srmmu_set_mmureg(mreg); 1298 srmmu_set_mmureg(mreg);
1228 1299
1229 ccreg = turbosparc_get_ccreg(); 1300 ccreg = turbosparc_get_ccreg();
1230 1301
1231#ifdef TURBOSPARC_WRITEBACK 1302#ifdef TURBOSPARC_WRITEBACK
@@ -1248,7 +1319,7 @@ static void __cpuinit poke_turbosparc(void)
1248 default: 1319 default:
1249 ccreg |= (TURBOSPARC_SCENABLE); 1320 ccreg |= (TURBOSPARC_SCENABLE);
1250 } 1321 }
1251 turbosparc_set_ccreg (ccreg); 1322 turbosparc_set_ccreg(ccreg);
1252 1323
1253 mreg |= (TURBOSPARC_ICENABLE | TURBOSPARC_DCENABLE); /* I & D caches on */ 1324 mreg |= (TURBOSPARC_ICENABLE | TURBOSPARC_DCENABLE); /* I & D caches on */
1254 mreg |= (TURBOSPARC_ICSNOOP); /* Icache snooping on */ 1325 mreg |= (TURBOSPARC_ICSNOOP); /* Icache snooping on */
@@ -1342,7 +1413,7 @@ static void __cpuinit poke_viking(void)
1342 unsigned long bpreg; 1413 unsigned long bpreg;
1343 1414
1344 mreg &= ~(VIKING_TCENABLE); 1415 mreg &= ~(VIKING_TCENABLE);
1345 if(smp_catch++) { 1416 if (smp_catch++) {
1346 /* Must disable mixed-cmd mode here for other cpu's. */ 1417 /* Must disable mixed-cmd mode here for other cpu's. */
1347 bpreg = viking_get_bpreg(); 1418 bpreg = viking_get_bpreg();
1348 bpreg &= ~(VIKING_ACTION_MIX); 1419 bpreg &= ~(VIKING_ACTION_MIX);
@@ -1411,7 +1482,7 @@ static void __init init_viking(void)
1411 unsigned long mreg = srmmu_get_mmureg(); 1482 unsigned long mreg = srmmu_get_mmureg();
1412 1483
1413 /* Ahhh, the viking. SRMMU VLSI abortion number two... */ 1484 /* Ahhh, the viking. SRMMU VLSI abortion number two... */
1414 if(mreg & VIKING_MMODE) { 1485 if (mreg & VIKING_MMODE) {
1415 srmmu_name = "TI Viking"; 1486 srmmu_name = "TI Viking";
1416 viking_mxcc_present = 0; 1487 viking_mxcc_present = 0;
1417 msi_set_sync(); 1488 msi_set_sync();
@@ -1467,8 +1538,8 @@ static void __init get_srmmu_type(void)
1467 } 1538 }
1468 1539
1469 /* Second, check for HyperSparc or Cypress. */ 1540 /* Second, check for HyperSparc or Cypress. */
1470 if(mod_typ == 1) { 1541 if (mod_typ == 1) {
1471 switch(mod_rev) { 1542 switch (mod_rev) {
1472 case 7: 1543 case 7:
1473 /* UP or MP Hypersparc */ 1544 /* UP or MP Hypersparc */
1474 init_hypersparc(); 1545 init_hypersparc();
@@ -1488,9 +1559,8 @@ static void __init get_srmmu_type(void)
1488 } 1559 }
1489 return; 1560 return;
1490 } 1561 }
1491 1562
1492 /* 1563 /* Now Fujitsu TurboSparc. It might happen that it is
1493 * Now Fujitsu TurboSparc. It might happen that it is
1494 * in Swift emulation mode, so we will check later... 1564 * in Swift emulation mode, so we will check later...
1495 */ 1565 */
1496 if (psr_typ == 0 && psr_vers == 5) { 1566 if (psr_typ == 0 && psr_vers == 5) {
@@ -1499,15 +1569,15 @@ static void __init get_srmmu_type(void)
1499 } 1569 }
1500 1570
1501 /* Next check for Fujitsu Swift. */ 1571 /* Next check for Fujitsu Swift. */
1502 if(psr_typ == 0 && psr_vers == 4) { 1572 if (psr_typ == 0 && psr_vers == 4) {
1503 phandle cpunode; 1573 phandle cpunode;
1504 char node_str[128]; 1574 char node_str[128];
1505 1575
1506 /* Look if it is not a TurboSparc emulating Swift... */ 1576 /* Look if it is not a TurboSparc emulating Swift... */
1507 cpunode = prom_getchild(prom_root_node); 1577 cpunode = prom_getchild(prom_root_node);
1508 while((cpunode = prom_getsibling(cpunode)) != 0) { 1578 while ((cpunode = prom_getsibling(cpunode)) != 0) {
1509 prom_getstring(cpunode, "device_type", node_str, sizeof(node_str)); 1579 prom_getstring(cpunode, "device_type", node_str, sizeof(node_str));
1510 if(!strcmp(node_str, "cpu")) { 1580 if (!strcmp(node_str, "cpu")) {
1511 if (!prom_getintdefault(cpunode, "psr-implementation", 1) && 1581 if (!prom_getintdefault(cpunode, "psr-implementation", 1) &&
1512 prom_getintdefault(cpunode, "psr-version", 1) == 5) { 1582 prom_getintdefault(cpunode, "psr-version", 1) == 5) {
1513 init_turbosparc(); 1583 init_turbosparc();
@@ -1516,13 +1586,13 @@ static void __init get_srmmu_type(void)
1516 break; 1586 break;
1517 } 1587 }
1518 } 1588 }
1519 1589
1520 init_swift(); 1590 init_swift();
1521 return; 1591 return;
1522 } 1592 }
1523 1593
1524 /* Now the Viking family of srmmu. */ 1594 /* Now the Viking family of srmmu. */
1525 if(psr_typ == 4 && 1595 if (psr_typ == 4 &&
1526 ((psr_vers == 0) || 1596 ((psr_vers == 0) ||
1527 ((psr_vers == 1) && (mod_typ == 0) && (mod_rev == 0)))) { 1597 ((psr_vers == 1) && (mod_typ == 0) && (mod_rev == 0)))) {
1528 init_viking(); 1598 init_viking();
@@ -1530,7 +1600,7 @@ static void __init get_srmmu_type(void)
1530 } 1600 }
1531 1601
1532 /* Finally the Tsunami. */ 1602 /* Finally the Tsunami. */
1533 if(psr_typ == 4 && psr_vers == 1 && (mod_typ || mod_rev)) { 1603 if (psr_typ == 4 && psr_vers == 1 && (mod_typ || mod_rev)) {
1534 init_tsunami(); 1604 init_tsunami();
1535 return; 1605 return;
1536 } 1606 }
diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
index 1a69244e785..e9073e9501b 100644
--- a/arch/sparc/net/bpf_jit_comp.c
+++ b/arch/sparc/net/bpf_jit_comp.c
@@ -96,6 +96,7 @@ static void bpf_flush_icache(void *start_, void *end_)
96#define AND F3(2, 0x01) 96#define AND F3(2, 0x01)
97#define ANDCC F3(2, 0x11) 97#define ANDCC F3(2, 0x11)
98#define OR F3(2, 0x02) 98#define OR F3(2, 0x02)
99#define XOR F3(2, 0x03)
99#define SUB F3(2, 0x04) 100#define SUB F3(2, 0x04)
100#define SUBCC F3(2, 0x14) 101#define SUBCC F3(2, 0x14)
101#define MUL F3(2, 0x0a) /* umul */ 102#define MUL F3(2, 0x0a) /* umul */
@@ -462,6 +463,9 @@ void bpf_jit_compile(struct sk_filter *fp)
462 case BPF_S_ALU_OR_K: /* A |= K */ 463 case BPF_S_ALU_OR_K: /* A |= K */
463 emit_alu_K(OR, K); 464 emit_alu_K(OR, K);
464 break; 465 break;
466 case BPF_S_ANC_ALU_XOR_X: /* A ^= X; */
467 emit_alu_X(XOR);
468 break;
465 case BPF_S_ALU_LSH_X: /* A <<= X */ 469 case BPF_S_ALU_LSH_X: /* A <<= X */
466 emit_alu_X(SLL); 470 emit_alu_X(SLL);
467 break; 471 break;
diff --git a/arch/sparc/prom/init_32.c b/arch/sparc/prom/init_32.c
index 26c64cea3c9..9ac30c2b7db 100644
--- a/arch/sparc/prom/init_32.c
+++ b/arch/sparc/prom/init_32.c
@@ -27,13 +27,10 @@ EXPORT_SYMBOL(prom_root_node);
27struct linux_nodeops *prom_nodeops; 27struct linux_nodeops *prom_nodeops;
28 28
29/* You must call prom_init() before you attempt to use any of the 29/* You must call prom_init() before you attempt to use any of the
30 * routines in the prom library. It returns 0 on success, 1 on 30 * routines in the prom library.
31 * failure. It gets passed the pointer to the PROM vector. 31 * It gets passed the pointer to the PROM vector.
32 */ 32 */
33 33
34extern void prom_meminit(void);
35extern void prom_ranges_init(void);
36
37void __init prom_init(struct linux_romvec *rp) 34void __init prom_init(struct linux_romvec *rp)
38{ 35{
39 romvec = rp; 36 romvec = rp;
diff --git a/arch/sparc/prom/init_64.c b/arch/sparc/prom/init_64.c
index 5016c5e2057..d95db755828 100644
--- a/arch/sparc/prom/init_64.c
+++ b/arch/sparc/prom/init_64.c
@@ -22,8 +22,8 @@ int prom_stdout;
22phandle 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.
26 * failure. It gets passed the pointer to the PROM vector. 26 * It gets passed the pointer to the PROM vector.
27 */ 27 */
28 28
29extern void prom_cif_init(void *, void *); 29extern void prom_cif_init(void *, void *);
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
index fe128816c44..932e4430f7f 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -3,6 +3,8 @@
3 3
4config TILE 4config TILE
5 def_bool y 5 def_bool y
6 select HAVE_DMA_ATTRS
7 select HAVE_DMA_API_DEBUG
6 select HAVE_KVM if !TILEGX 8 select HAVE_KVM if !TILEGX
7 select GENERIC_FIND_FIRST_BIT 9 select GENERIC_FIND_FIRST_BIT
8 select USE_GENERIC_SMP_HELPERS 10 select USE_GENERIC_SMP_HELPERS
@@ -79,6 +81,9 @@ config ARCH_DMA_ADDR_T_64BIT
79config NEED_DMA_MAP_STATE 81config NEED_DMA_MAP_STATE
80 def_bool y 82 def_bool y
81 83
84config ARCH_HAS_DMA_SET_COHERENT_MASK
85 bool
86
82config LOCKDEP_SUPPORT 87config LOCKDEP_SUPPORT
83 def_bool y 88 def_bool y
84 89
@@ -212,6 +217,22 @@ config HIGHMEM
212 217
213 If unsure, say "true". 218 If unsure, say "true".
214 219
220config ZONE_DMA
221 def_bool y
222
223config IOMMU_HELPER
224 bool
225
226config NEED_SG_DMA_LENGTH
227 bool
228
229config SWIOTLB
230 bool
231 default TILEGX
232 select IOMMU_HELPER
233 select NEED_SG_DMA_LENGTH
234 select ARCH_HAS_DMA_SET_COHERENT_MASK
235
215# We do not currently support disabling NUMA. 236# We do not currently support disabling NUMA.
216config NUMA 237config NUMA
217 bool # "NUMA Memory Allocation and Scheduler Support" 238 bool # "NUMA Memory Allocation and Scheduler Support"
@@ -345,6 +366,8 @@ config KERNEL_PL
345 kernel will be built to run at. Generally you should use 366 kernel will be built to run at. Generally you should use
346 the default value here. 367 the default value here.
347 368
369source "arch/tile/gxio/Kconfig"
370
348endmenu # Tilera-specific configuration 371endmenu # Tilera-specific configuration
349 372
350menu "Bus options" 373menu "Bus options"
@@ -354,6 +377,9 @@ config PCI
354 default y 377 default y
355 select PCI_DOMAINS 378 select PCI_DOMAINS
356 select GENERIC_PCI_IOMAP 379 select GENERIC_PCI_IOMAP
380 select TILE_GXIO_TRIO if TILEGX
381 select ARCH_SUPPORTS_MSI if TILEGX
382 select PCI_MSI if TILEGX
357 ---help--- 383 ---help---
358 Enable PCI root complex support, so PCIe endpoint devices can 384 Enable PCI root complex support, so PCIe endpoint devices can
359 be attached to the Tile chip. Many, but not all, PCI devices 385 be attached to the Tile chip. Many, but not all, PCI devices
@@ -370,6 +396,22 @@ config NO_IOPORT
370 396
371source "drivers/pci/Kconfig" 397source "drivers/pci/Kconfig"
372 398
399config TILE_USB
400 tristate "Tilera USB host adapter support"
401 default y
402 depends on USB
403 depends on TILEGX
404 select TILE_GXIO_USB_HOST
405 ---help---
406 Provides USB host adapter support for the built-in EHCI and OHCI
407 interfaces on TILE-Gx chips.
408
409# USB OHCI needs the bounce pool since tilegx will often have more
410# than 4GB of memory, but we don't currently use the IOTLB to present
411# a 32-bit address to OHCI. So we need to use a bounce pool instead.
412config NEED_BOUNCE_POOL
413 def_bool USB_OHCI_HCD
414
373config HOTPLUG 415config HOTPLUG
374 bool "Support for hot-pluggable devices" 416 bool "Support for hot-pluggable devices"
375 ---help--- 417 ---help---
diff --git a/arch/tile/Makefile b/arch/tile/Makefile
index e20b0a0b64a..55640cf9259 100644
--- a/arch/tile/Makefile
+++ b/arch/tile/Makefile
@@ -59,6 +59,8 @@ libs-y += $(LIBGCC_PATH)
59# See arch/tile/Kbuild for content of core part of the kernel 59# See arch/tile/Kbuild for content of core part of the kernel
60core-y += arch/tile/ 60core-y += arch/tile/
61 61
62core-$(CONFIG_TILE_GXIO) += arch/tile/gxio/
63
62ifdef TILERA_ROOT 64ifdef TILERA_ROOT
63INSTALL_PATH ?= $(TILERA_ROOT)/tile/boot 65INSTALL_PATH ?= $(TILERA_ROOT)/tile/boot
64endif 66endif
diff --git a/arch/tile/configs/tilegx_defconfig b/arch/tile/configs/tilegx_defconfig
index b8d99aca543..0270620a169 100644
--- a/arch/tile/configs/tilegx_defconfig
+++ b/arch/tile/configs/tilegx_defconfig
@@ -18,8 +18,8 @@ CONFIG_CGROUP_DEVICE=y
18CONFIG_CPUSETS=y 18CONFIG_CPUSETS=y
19CONFIG_CGROUP_CPUACCT=y 19CONFIG_CGROUP_CPUACCT=y
20CONFIG_RESOURCE_COUNTERS=y 20CONFIG_RESOURCE_COUNTERS=y
21CONFIG_CGROUP_MEM_RES_CTLR=y 21CONFIG_CGROUP_MEMCG=y
22CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y 22CONFIG_CGROUP_MEMCG_SWAP=y
23CONFIG_CGROUP_SCHED=y 23CONFIG_CGROUP_SCHED=y
24CONFIG_RT_GROUP_SCHED=y 24CONFIG_RT_GROUP_SCHED=y
25CONFIG_BLK_CGROUP=y 25CONFIG_BLK_CGROUP=y
diff --git a/arch/tile/configs/tilepro_defconfig b/arch/tile/configs/tilepro_defconfig
index 2b1fd31894f..c11de27a9bc 100644
--- a/arch/tile/configs/tilepro_defconfig
+++ b/arch/tile/configs/tilepro_defconfig
@@ -17,8 +17,8 @@ CONFIG_CGROUP_DEVICE=y
17CONFIG_CPUSETS=y 17CONFIG_CPUSETS=y
18CONFIG_CGROUP_CPUACCT=y 18CONFIG_CGROUP_CPUACCT=y
19CONFIG_RESOURCE_COUNTERS=y 19CONFIG_RESOURCE_COUNTERS=y
20CONFIG_CGROUP_MEM_RES_CTLR=y 20CONFIG_CGROUP_MEMCG=y
21CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y 21CONFIG_CGROUP_MEMCG_SWAP=y
22CONFIG_CGROUP_SCHED=y 22CONFIG_CGROUP_SCHED=y
23CONFIG_RT_GROUP_SCHED=y 23CONFIG_RT_GROUP_SCHED=y
24CONFIG_BLK_CGROUP=y 24CONFIG_BLK_CGROUP=y
diff --git a/arch/tile/gxio/Kconfig b/arch/tile/gxio/Kconfig
new file mode 100644
index 00000000000..d221f8d6de8
--- /dev/null
+++ b/arch/tile/gxio/Kconfig
@@ -0,0 +1,28 @@
1# Support direct access to TILE-Gx hardware from user space, via the
2# gxio library, or from kernel space, via kernel IORPC support.
3config TILE_GXIO
4 bool
5 depends on TILEGX
6
7# Support direct access to the common I/O DMA facility within the
8# TILE-Gx mPIPE and Trio hardware from kernel space.
9config TILE_GXIO_DMA
10 bool
11 select TILE_GXIO
12
13# Support direct access to the TILE-Gx mPIPE hardware from kernel space.
14config TILE_GXIO_MPIPE
15 bool
16 select TILE_GXIO
17 select TILE_GXIO_DMA
18
19# Support direct access to the TILE-Gx TRIO hardware from kernel space.
20config TILE_GXIO_TRIO
21 bool
22 select TILE_GXIO
23 select TILE_GXIO_DMA
24
25# Support direct access to the TILE-Gx USB hardware from kernel space.
26config TILE_GXIO_USB_HOST
27 bool
28 select TILE_GXIO
diff --git a/arch/tile/gxio/Makefile b/arch/tile/gxio/Makefile
new file mode 100644
index 00000000000..8684bcaa74e
--- /dev/null
+++ b/arch/tile/gxio/Makefile
@@ -0,0 +1,9 @@
1#
2# Makefile for the Tile-Gx device access support.
3#
4
5obj-$(CONFIG_TILE_GXIO) += iorpc_globals.o kiorpc.o
6obj-$(CONFIG_TILE_GXIO_DMA) += dma_queue.o
7obj-$(CONFIG_TILE_GXIO_MPIPE) += mpipe.o iorpc_mpipe.o iorpc_mpipe_info.o
8obj-$(CONFIG_TILE_GXIO_TRIO) += trio.o iorpc_trio.o
9obj-$(CONFIG_TILE_GXIO_USB_HOST) += usb_host.o iorpc_usb_host.o
diff --git a/arch/tile/gxio/dma_queue.c b/arch/tile/gxio/dma_queue.c
new file mode 100644
index 00000000000..baa60357f8b
--- /dev/null
+++ b/arch/tile/gxio/dma_queue.c
@@ -0,0 +1,176 @@
1/*
2 * Copyright 2012 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#include <linux/io.h>
16#include <linux/atomic.h>
17#include <linux/module.h>
18#include <gxio/dma_queue.h>
19
20/* Wait for a memory read to complete. */
21#define wait_for_value(val) \
22 __asm__ __volatile__("move %0, %0" :: "r"(val))
23
24/* The index is in the low 16. */
25#define DMA_QUEUE_INDEX_MASK ((1 << 16) - 1)
26
27/*
28 * The hardware descriptor-ring type.
29 * This matches the types used by mpipe (MPIPE_EDMA_POST_REGION_VAL_t)
30 * and trio (TRIO_PUSH_DMA_REGION_VAL_t or TRIO_PULL_DMA_REGION_VAL_t).
31 * See those types for more documentation on the individual fields.
32 */
33typedef union {
34 struct {
35#ifndef __BIG_ENDIAN__
36 uint64_t ring_idx:16;
37 uint64_t count:16;
38 uint64_t gen:1;
39 uint64_t __reserved:31;
40#else
41 uint64_t __reserved:31;
42 uint64_t gen:1;
43 uint64_t count:16;
44 uint64_t ring_idx:16;
45#endif
46 };
47 uint64_t word;
48} __gxio_ring_t;
49
50void __gxio_dma_queue_init(__gxio_dma_queue_t *dma_queue,
51 void *post_region_addr, unsigned int num_entries)
52{
53 /*
54 * Limit 65536 entry rings to 65535 credits because we only have a
55 * 16 bit completion counter.
56 */
57 int64_t credits = (num_entries < 65536) ? num_entries : 65535;
58
59 memset(dma_queue, 0, sizeof(*dma_queue));
60
61 dma_queue->post_region_addr = post_region_addr;
62 dma_queue->hw_complete_count = 0;
63 dma_queue->credits_and_next_index = credits << DMA_QUEUE_CREDIT_SHIFT;
64}
65
66EXPORT_SYMBOL_GPL(__gxio_dma_queue_init);
67
68void __gxio_dma_queue_update_credits(__gxio_dma_queue_t *dma_queue)
69{
70 __gxio_ring_t val;
71 uint64_t count;
72 uint64_t delta;
73 uint64_t new_count;
74
75 /*
76 * Read the 64-bit completion count without touching the cache, so
77 * we later avoid having to evict any sharers of this cache line
78 * when we update it below.
79 */
80 uint64_t orig_hw_complete_count =
81 cmpxchg(&dma_queue->hw_complete_count,
82 -1, -1);
83
84 /* Make sure the load completes before we access the hardware. */
85 wait_for_value(orig_hw_complete_count);
86
87 /* Read the 16-bit count of how many packets it has completed. */
88 val.word = __gxio_mmio_read(dma_queue->post_region_addr);
89 count = val.count;
90
91 /*
92 * Calculate the number of completions since we last updated the
93 * 64-bit counter. It's safe to ignore the high bits because the
94 * maximum credit value is 65535.
95 */
96 delta = (count - orig_hw_complete_count) & 0xffff;
97 if (delta == 0)
98 return;
99
100 /*
101 * Try to write back the count, advanced by delta. If we race with
102 * another thread, this might fail, in which case we return
103 * immediately on the assumption that some credits are (or at least
104 * were) available.
105 */
106 new_count = orig_hw_complete_count + delta;
107 if (cmpxchg(&dma_queue->hw_complete_count,
108 orig_hw_complete_count,
109 new_count) != orig_hw_complete_count)
110 return;
111
112 /*
113 * We succeeded in advancing the completion count; add back the
114 * corresponding number of egress credits.
115 */
116 __insn_fetchadd(&dma_queue->credits_and_next_index,
117 (delta << DMA_QUEUE_CREDIT_SHIFT));
118}
119
120EXPORT_SYMBOL_GPL(__gxio_dma_queue_update_credits);
121
122/*
123 * A separate 'blocked' method for put() so that backtraces and
124 * profiles will clearly indicate that we're wasting time spinning on
125 * egress availability rather than actually posting commands.
126 */
127int64_t __gxio_dma_queue_wait_for_credits(__gxio_dma_queue_t *dma_queue,
128 int64_t modifier)
129{
130 int backoff = 16;
131 int64_t old;
132
133 do {
134 int i;
135 /* Back off to avoid spamming memory networks. */
136 for (i = backoff; i > 0; i--)
137 __insn_mfspr(SPR_PASS);
138
139 /* Check credits again. */
140 __gxio_dma_queue_update_credits(dma_queue);
141 old = __insn_fetchaddgez(&dma_queue->credits_and_next_index,
142 modifier);
143
144 /* Calculate bounded exponential backoff for next iteration. */
145 if (backoff < 256)
146 backoff *= 2;
147 } while (old + modifier < 0);
148
149 return old;
150}
151
152EXPORT_SYMBOL_GPL(__gxio_dma_queue_wait_for_credits);
153
154int64_t __gxio_dma_queue_reserve_aux(__gxio_dma_queue_t *dma_queue,
155 unsigned int num, int wait)
156{
157 return __gxio_dma_queue_reserve(dma_queue, num, wait != 0, true);
158}
159
160EXPORT_SYMBOL_GPL(__gxio_dma_queue_reserve_aux);
161
162int __gxio_dma_queue_is_complete(__gxio_dma_queue_t *dma_queue,
163 int64_t completion_slot, int update)
164{
165 if (update) {
166 if (ACCESS_ONCE(dma_queue->hw_complete_count) >
167 completion_slot)
168 return 1;
169
170 __gxio_dma_queue_update_credits(dma_queue);
171 }
172
173 return ACCESS_ONCE(dma_queue->hw_complete_count) > completion_slot;
174}
175
176EXPORT_SYMBOL_GPL(__gxio_dma_queue_is_complete);
diff --git a/arch/tile/gxio/iorpc_globals.c b/arch/tile/gxio/iorpc_globals.c
new file mode 100644
index 00000000000..e178e90805a
--- /dev/null
+++ b/arch/tile/gxio/iorpc_globals.c
@@ -0,0 +1,89 @@
1/*
2 * Copyright 2012 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/* This file is machine-generated; DO NOT EDIT! */
16#include "gxio/iorpc_globals.h"
17
18struct arm_pollfd_param {
19 union iorpc_pollfd pollfd;
20};
21
22int __iorpc_arm_pollfd(int fd, int pollfd_cookie)
23{
24 struct arm_pollfd_param temp;
25 struct arm_pollfd_param *params = &temp;
26
27 params->pollfd.kernel.cookie = pollfd_cookie;
28
29 return hv_dev_pwrite(fd, 0, (HV_VirtAddr) params, sizeof(*params),
30 IORPC_OP_ARM_POLLFD);
31}
32
33EXPORT_SYMBOL(__iorpc_arm_pollfd);
34
35struct close_pollfd_param {
36 union iorpc_pollfd pollfd;
37};
38
39int __iorpc_close_pollfd(int fd, int pollfd_cookie)
40{
41 struct close_pollfd_param temp;
42 struct close_pollfd_param *params = &temp;
43
44 params->pollfd.kernel.cookie = pollfd_cookie;
45
46 return hv_dev_pwrite(fd, 0, (HV_VirtAddr) params, sizeof(*params),
47 IORPC_OP_CLOSE_POLLFD);
48}
49
50EXPORT_SYMBOL(__iorpc_close_pollfd);
51
52struct get_mmio_base_param {
53 HV_PTE base;
54};
55
56int __iorpc_get_mmio_base(int fd, HV_PTE *base)
57{
58 int __result;
59 struct get_mmio_base_param temp;
60 struct get_mmio_base_param *params = &temp;
61
62 __result =
63 hv_dev_pread(fd, 0, (HV_VirtAddr) params, sizeof(*params),
64 IORPC_OP_GET_MMIO_BASE);
65 *base = params->base;
66
67 return __result;
68}
69
70EXPORT_SYMBOL(__iorpc_get_mmio_base);
71
72struct check_mmio_offset_param {
73 unsigned long offset;
74 unsigned long size;
75};
76
77int __iorpc_check_mmio_offset(int fd, unsigned long offset, unsigned long size)
78{
79 struct check_mmio_offset_param temp;
80 struct check_mmio_offset_param *params = &temp;
81
82 params->offset = offset;
83 params->size = size;
84
85 return hv_dev_pwrite(fd, 0, (HV_VirtAddr) params, sizeof(*params),
86 IORPC_OP_CHECK_MMIO_OFFSET);
87}
88
89EXPORT_SYMBOL(__iorpc_check_mmio_offset);
diff --git a/arch/tile/gxio/iorpc_mpipe.c b/arch/tile/gxio/iorpc_mpipe.c
new file mode 100644
index 00000000000..31b87bf8c02
--- /dev/null
+++ b/arch/tile/gxio/iorpc_mpipe.c
@@ -0,0 +1,529 @@
1/*
2 * Copyright 2012 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/* This file is machine-generated; DO NOT EDIT! */
16#include "gxio/iorpc_mpipe.h"
17
18struct alloc_buffer_stacks_param {
19 unsigned int count;
20 unsigned int first;
21 unsigned int flags;
22};
23
24int gxio_mpipe_alloc_buffer_stacks(gxio_mpipe_context_t * context,
25 unsigned int count, unsigned int first,
26 unsigned int flags)
27{
28 struct alloc_buffer_stacks_param temp;
29 struct alloc_buffer_stacks_param *params = &temp;
30
31 params->count = count;
32 params->first = first;
33 params->flags = flags;
34
35 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
36 sizeof(*params),
37 GXIO_MPIPE_OP_ALLOC_BUFFER_STACKS);
38}
39
40EXPORT_SYMBOL(gxio_mpipe_alloc_buffer_stacks);
41
42struct init_buffer_stack_aux_param {
43 union iorpc_mem_buffer buffer;
44 unsigned int stack;
45 unsigned int buffer_size_enum;
46};
47
48int gxio_mpipe_init_buffer_stack_aux(gxio_mpipe_context_t * context,
49 void *mem_va, size_t mem_size,
50 unsigned int mem_flags, unsigned int stack,
51 unsigned int buffer_size_enum)
52{
53 int __result;
54 unsigned long long __cpa;
55 pte_t __pte;
56 struct init_buffer_stack_aux_param temp;
57 struct init_buffer_stack_aux_param *params = &temp;
58
59 __result = va_to_cpa_and_pte(mem_va, &__cpa, &__pte);
60 if (__result != 0)
61 return __result;
62 params->buffer.kernel.cpa = __cpa;
63 params->buffer.kernel.size = mem_size;
64 params->buffer.kernel.pte = __pte;
65 params->buffer.kernel.flags = mem_flags;
66 params->stack = stack;
67 params->buffer_size_enum = buffer_size_enum;
68
69 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
70 sizeof(*params),
71 GXIO_MPIPE_OP_INIT_BUFFER_STACK_AUX);
72}
73
74EXPORT_SYMBOL(gxio_mpipe_init_buffer_stack_aux);
75
76
77struct alloc_notif_rings_param {
78 unsigned int count;
79 unsigned int first;
80 unsigned int flags;
81};
82
83int gxio_mpipe_alloc_notif_rings(gxio_mpipe_context_t * context,
84 unsigned int count, unsigned int first,
85 unsigned int flags)
86{
87 struct alloc_notif_rings_param temp;
88 struct alloc_notif_rings_param *params = &temp;
89
90 params->count = count;
91 params->first = first;
92 params->flags = flags;
93
94 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
95 sizeof(*params), GXIO_MPIPE_OP_ALLOC_NOTIF_RINGS);
96}
97
98EXPORT_SYMBOL(gxio_mpipe_alloc_notif_rings);
99
100struct init_notif_ring_aux_param {
101 union iorpc_mem_buffer buffer;
102 unsigned int ring;
103};
104
105int gxio_mpipe_init_notif_ring_aux(gxio_mpipe_context_t * context, void *mem_va,
106 size_t mem_size, unsigned int mem_flags,
107 unsigned int ring)
108{
109 int __result;
110 unsigned long long __cpa;
111 pte_t __pte;
112 struct init_notif_ring_aux_param temp;
113 struct init_notif_ring_aux_param *params = &temp;
114
115 __result = va_to_cpa_and_pte(mem_va, &__cpa, &__pte);
116 if (__result != 0)
117 return __result;
118 params->buffer.kernel.cpa = __cpa;
119 params->buffer.kernel.size = mem_size;
120 params->buffer.kernel.pte = __pte;
121 params->buffer.kernel.flags = mem_flags;
122 params->ring = ring;
123
124 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
125 sizeof(*params),
126 GXIO_MPIPE_OP_INIT_NOTIF_RING_AUX);
127}
128
129EXPORT_SYMBOL(gxio_mpipe_init_notif_ring_aux);
130
131struct request_notif_ring_interrupt_param {
132 union iorpc_interrupt interrupt;
133 unsigned int ring;
134};
135
136int gxio_mpipe_request_notif_ring_interrupt(gxio_mpipe_context_t * context,
137 int inter_x, int inter_y,
138 int inter_ipi, int inter_event,
139 unsigned int ring)
140{
141 struct request_notif_ring_interrupt_param temp;
142 struct request_notif_ring_interrupt_param *params = &temp;
143
144 params->interrupt.kernel.x = inter_x;
145 params->interrupt.kernel.y = inter_y;
146 params->interrupt.kernel.ipi = inter_ipi;
147 params->interrupt.kernel.event = inter_event;
148 params->ring = ring;
149
150 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
151 sizeof(*params),
152 GXIO_MPIPE_OP_REQUEST_NOTIF_RING_INTERRUPT);
153}
154
155EXPORT_SYMBOL(gxio_mpipe_request_notif_ring_interrupt);
156
157struct enable_notif_ring_interrupt_param {
158 unsigned int ring;
159};
160
161int gxio_mpipe_enable_notif_ring_interrupt(gxio_mpipe_context_t * context,
162 unsigned int ring)
163{
164 struct enable_notif_ring_interrupt_param temp;
165 struct enable_notif_ring_interrupt_param *params = &temp;
166
167 params->ring = ring;
168
169 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
170 sizeof(*params),
171 GXIO_MPIPE_OP_ENABLE_NOTIF_RING_INTERRUPT);
172}
173
174EXPORT_SYMBOL(gxio_mpipe_enable_notif_ring_interrupt);
175
176struct alloc_notif_groups_param {
177 unsigned int count;
178 unsigned int first;
179 unsigned int flags;
180};
181
182int gxio_mpipe_alloc_notif_groups(gxio_mpipe_context_t * context,
183 unsigned int count, unsigned int first,
184 unsigned int flags)
185{
186 struct alloc_notif_groups_param temp;
187 struct alloc_notif_groups_param *params = &temp;
188
189 params->count = count;
190 params->first = first;
191 params->flags = flags;
192
193 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
194 sizeof(*params), GXIO_MPIPE_OP_ALLOC_NOTIF_GROUPS);
195}
196
197EXPORT_SYMBOL(gxio_mpipe_alloc_notif_groups);
198
199struct init_notif_group_param {
200 unsigned int group;
201 gxio_mpipe_notif_group_bits_t bits;
202};
203
204int gxio_mpipe_init_notif_group(gxio_mpipe_context_t * context,
205 unsigned int group,
206 gxio_mpipe_notif_group_bits_t bits)
207{
208 struct init_notif_group_param temp;
209 struct init_notif_group_param *params = &temp;
210
211 params->group = group;
212 params->bits = bits;
213
214 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
215 sizeof(*params), GXIO_MPIPE_OP_INIT_NOTIF_GROUP);
216}
217
218EXPORT_SYMBOL(gxio_mpipe_init_notif_group);
219
220struct alloc_buckets_param {
221 unsigned int count;
222 unsigned int first;
223 unsigned int flags;
224};
225
226int gxio_mpipe_alloc_buckets(gxio_mpipe_context_t * context, unsigned int count,
227 unsigned int first, unsigned int flags)
228{
229 struct alloc_buckets_param temp;
230 struct alloc_buckets_param *params = &temp;
231
232 params->count = count;
233 params->first = first;
234 params->flags = flags;
235
236 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
237 sizeof(*params), GXIO_MPIPE_OP_ALLOC_BUCKETS);
238}
239
240EXPORT_SYMBOL(gxio_mpipe_alloc_buckets);
241
242struct init_bucket_param {
243 unsigned int bucket;
244 MPIPE_LBL_INIT_DAT_BSTS_TBL_t bucket_info;
245};
246
247int gxio_mpipe_init_bucket(gxio_mpipe_context_t * context, unsigned int bucket,
248 MPIPE_LBL_INIT_DAT_BSTS_TBL_t bucket_info)
249{
250 struct init_bucket_param temp;
251 struct init_bucket_param *params = &temp;
252
253 params->bucket = bucket;
254 params->bucket_info = bucket_info;
255
256 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
257 sizeof(*params), GXIO_MPIPE_OP_INIT_BUCKET);
258}
259
260EXPORT_SYMBOL(gxio_mpipe_init_bucket);
261
262struct alloc_edma_rings_param {
263 unsigned int count;
264 unsigned int first;
265 unsigned int flags;
266};
267
268int gxio_mpipe_alloc_edma_rings(gxio_mpipe_context_t * context,
269 unsigned int count, unsigned int first,
270 unsigned int flags)
271{
272 struct alloc_edma_rings_param temp;
273 struct alloc_edma_rings_param *params = &temp;
274
275 params->count = count;
276 params->first = first;
277 params->flags = flags;
278
279 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
280 sizeof(*params), GXIO_MPIPE_OP_ALLOC_EDMA_RINGS);
281}
282
283EXPORT_SYMBOL(gxio_mpipe_alloc_edma_rings);
284
285struct init_edma_ring_aux_param {
286 union iorpc_mem_buffer buffer;
287 unsigned int ring;
288 unsigned int channel;
289};
290
291int gxio_mpipe_init_edma_ring_aux(gxio_mpipe_context_t * context, void *mem_va,
292 size_t mem_size, unsigned int mem_flags,
293 unsigned int ring, unsigned int channel)
294{
295 int __result;
296 unsigned long long __cpa;
297 pte_t __pte;
298 struct init_edma_ring_aux_param temp;
299 struct init_edma_ring_aux_param *params = &temp;
300
301 __result = va_to_cpa_and_pte(mem_va, &__cpa, &__pte);
302 if (__result != 0)
303 return __result;
304 params->buffer.kernel.cpa = __cpa;
305 params->buffer.kernel.size = mem_size;
306 params->buffer.kernel.pte = __pte;
307 params->buffer.kernel.flags = mem_flags;
308 params->ring = ring;
309 params->channel = channel;
310
311 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
312 sizeof(*params), GXIO_MPIPE_OP_INIT_EDMA_RING_AUX);
313}
314
315EXPORT_SYMBOL(gxio_mpipe_init_edma_ring_aux);
316
317
318int gxio_mpipe_commit_rules(gxio_mpipe_context_t * context, const void *blob,
319 size_t blob_size)
320{
321 const void *params = blob;
322
323 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params, blob_size,
324 GXIO_MPIPE_OP_COMMIT_RULES);
325}
326
327EXPORT_SYMBOL(gxio_mpipe_commit_rules);
328
329struct register_client_memory_param {
330 unsigned int iotlb;
331 HV_PTE pte;
332 unsigned int flags;
333};
334
335int gxio_mpipe_register_client_memory(gxio_mpipe_context_t * context,
336 unsigned int iotlb, HV_PTE pte,
337 unsigned int flags)
338{
339 struct register_client_memory_param temp;
340 struct register_client_memory_param *params = &temp;
341
342 params->iotlb = iotlb;
343 params->pte = pte;
344 params->flags = flags;
345
346 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
347 sizeof(*params),
348 GXIO_MPIPE_OP_REGISTER_CLIENT_MEMORY);
349}
350
351EXPORT_SYMBOL(gxio_mpipe_register_client_memory);
352
353struct link_open_aux_param {
354 _gxio_mpipe_link_name_t name;
355 unsigned int flags;
356};
357
358int gxio_mpipe_link_open_aux(gxio_mpipe_context_t * context,
359 _gxio_mpipe_link_name_t name, unsigned int flags)
360{
361 struct link_open_aux_param temp;
362 struct link_open_aux_param *params = &temp;
363
364 params->name = name;
365 params->flags = flags;
366
367 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
368 sizeof(*params), GXIO_MPIPE_OP_LINK_OPEN_AUX);
369}
370
371EXPORT_SYMBOL(gxio_mpipe_link_open_aux);
372
373struct link_close_aux_param {
374 int mac;
375};
376
377int gxio_mpipe_link_close_aux(gxio_mpipe_context_t * context, int mac)
378{
379 struct link_close_aux_param temp;
380 struct link_close_aux_param *params = &temp;
381
382 params->mac = mac;
383
384 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
385 sizeof(*params), GXIO_MPIPE_OP_LINK_CLOSE_AUX);
386}
387
388EXPORT_SYMBOL(gxio_mpipe_link_close_aux);
389
390
391struct get_timestamp_aux_param {
392 uint64_t sec;
393 uint64_t nsec;
394 uint64_t cycles;
395};
396
397int gxio_mpipe_get_timestamp_aux(gxio_mpipe_context_t * context, uint64_t * sec,
398 uint64_t * nsec, uint64_t * cycles)
399{
400 int __result;
401 struct get_timestamp_aux_param temp;
402 struct get_timestamp_aux_param *params = &temp;
403
404 __result =
405 hv_dev_pread(context->fd, 0, (HV_VirtAddr) params, sizeof(*params),
406 GXIO_MPIPE_OP_GET_TIMESTAMP_AUX);
407 *sec = params->sec;
408 *nsec = params->nsec;
409 *cycles = params->cycles;
410
411 return __result;
412}
413
414EXPORT_SYMBOL(gxio_mpipe_get_timestamp_aux);
415
416struct set_timestamp_aux_param {
417 uint64_t sec;
418 uint64_t nsec;
419 uint64_t cycles;
420};
421
422int gxio_mpipe_set_timestamp_aux(gxio_mpipe_context_t * context, uint64_t sec,
423 uint64_t nsec, uint64_t cycles)
424{
425 struct set_timestamp_aux_param temp;
426 struct set_timestamp_aux_param *params = &temp;
427
428 params->sec = sec;
429 params->nsec = nsec;
430 params->cycles = cycles;
431
432 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
433 sizeof(*params), GXIO_MPIPE_OP_SET_TIMESTAMP_AUX);
434}
435
436EXPORT_SYMBOL(gxio_mpipe_set_timestamp_aux);
437
438struct adjust_timestamp_aux_param {
439 int64_t nsec;
440};
441
442int gxio_mpipe_adjust_timestamp_aux(gxio_mpipe_context_t * context,
443 int64_t nsec)
444{
445 struct adjust_timestamp_aux_param temp;
446 struct adjust_timestamp_aux_param *params = &temp;
447
448 params->nsec = nsec;
449
450 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
451 sizeof(*params),
452 GXIO_MPIPE_OP_ADJUST_TIMESTAMP_AUX);
453}
454
455EXPORT_SYMBOL(gxio_mpipe_adjust_timestamp_aux);
456
457struct arm_pollfd_param {
458 union iorpc_pollfd pollfd;
459};
460
461int gxio_mpipe_arm_pollfd(gxio_mpipe_context_t * context, int pollfd_cookie)
462{
463 struct arm_pollfd_param temp;
464 struct arm_pollfd_param *params = &temp;
465
466 params->pollfd.kernel.cookie = pollfd_cookie;
467
468 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
469 sizeof(*params), GXIO_MPIPE_OP_ARM_POLLFD);
470}
471
472EXPORT_SYMBOL(gxio_mpipe_arm_pollfd);
473
474struct close_pollfd_param {
475 union iorpc_pollfd pollfd;
476};
477
478int gxio_mpipe_close_pollfd(gxio_mpipe_context_t * context, int pollfd_cookie)
479{
480 struct close_pollfd_param temp;
481 struct close_pollfd_param *params = &temp;
482
483 params->pollfd.kernel.cookie = pollfd_cookie;
484
485 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
486 sizeof(*params), GXIO_MPIPE_OP_CLOSE_POLLFD);
487}
488
489EXPORT_SYMBOL(gxio_mpipe_close_pollfd);
490
491struct get_mmio_base_param {
492 HV_PTE base;
493};
494
495int gxio_mpipe_get_mmio_base(gxio_mpipe_context_t * context, HV_PTE *base)
496{
497 int __result;
498 struct get_mmio_base_param temp;
499 struct get_mmio_base_param *params = &temp;
500
501 __result =
502 hv_dev_pread(context->fd, 0, (HV_VirtAddr) params, sizeof(*params),
503 GXIO_MPIPE_OP_GET_MMIO_BASE);
504 *base = params->base;
505
506 return __result;
507}
508
509EXPORT_SYMBOL(gxio_mpipe_get_mmio_base);
510
511struct check_mmio_offset_param {
512 unsigned long offset;
513 unsigned long size;
514};
515
516int gxio_mpipe_check_mmio_offset(gxio_mpipe_context_t * context,
517 unsigned long offset, unsigned long size)
518{
519 struct check_mmio_offset_param temp;
520 struct check_mmio_offset_param *params = &temp;
521
522 params->offset = offset;
523 params->size = size;
524
525 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
526 sizeof(*params), GXIO_MPIPE_OP_CHECK_MMIO_OFFSET);
527}
528
529EXPORT_SYMBOL(gxio_mpipe_check_mmio_offset);
diff --git a/arch/tile/gxio/iorpc_mpipe_info.c b/arch/tile/gxio/iorpc_mpipe_info.c
new file mode 100644
index 00000000000..d0254aa60cb
--- /dev/null
+++ b/arch/tile/gxio/iorpc_mpipe_info.c
@@ -0,0 +1,85 @@
1/*
2 * Copyright 2012 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/* This file is machine-generated; DO NOT EDIT! */
16#include "gxio/iorpc_mpipe_info.h"
17
18
19struct enumerate_aux_param {
20 _gxio_mpipe_link_name_t name;
21 _gxio_mpipe_link_mac_t mac;
22};
23
24int gxio_mpipe_info_enumerate_aux(gxio_mpipe_info_context_t * context,
25 unsigned int idx,
26 _gxio_mpipe_link_name_t * name,
27 _gxio_mpipe_link_mac_t * mac)
28{
29 int __result;
30 struct enumerate_aux_param temp;
31 struct enumerate_aux_param *params = &temp;
32
33 __result =
34 hv_dev_pread(context->fd, 0, (HV_VirtAddr) params, sizeof(*params),
35 (((uint64_t) idx << 32) |
36 GXIO_MPIPE_INFO_OP_ENUMERATE_AUX));
37 *name = params->name;
38 *mac = params->mac;
39
40 return __result;
41}
42
43EXPORT_SYMBOL(gxio_mpipe_info_enumerate_aux);
44
45struct get_mmio_base_param {
46 HV_PTE base;
47};
48
49int gxio_mpipe_info_get_mmio_base(gxio_mpipe_info_context_t * context,
50 HV_PTE *base)
51{
52 int __result;
53 struct get_mmio_base_param temp;
54 struct get_mmio_base_param *params = &temp;
55
56 __result =
57 hv_dev_pread(context->fd, 0, (HV_VirtAddr) params, sizeof(*params),
58 GXIO_MPIPE_INFO_OP_GET_MMIO_BASE);
59 *base = params->base;
60
61 return __result;
62}
63
64EXPORT_SYMBOL(gxio_mpipe_info_get_mmio_base);
65
66struct check_mmio_offset_param {
67 unsigned long offset;
68 unsigned long size;
69};
70
71int gxio_mpipe_info_check_mmio_offset(gxio_mpipe_info_context_t * context,
72 unsigned long offset, unsigned long size)
73{
74 struct check_mmio_offset_param temp;
75 struct check_mmio_offset_param *params = &temp;
76
77 params->offset = offset;
78 params->size = size;
79
80 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
81 sizeof(*params),
82 GXIO_MPIPE_INFO_OP_CHECK_MMIO_OFFSET);
83}
84
85EXPORT_SYMBOL(gxio_mpipe_info_check_mmio_offset);
diff --git a/arch/tile/gxio/iorpc_trio.c b/arch/tile/gxio/iorpc_trio.c
new file mode 100644
index 00000000000..cef4b2209cd
--- /dev/null
+++ b/arch/tile/gxio/iorpc_trio.c
@@ -0,0 +1,327 @@
1/*
2 * Copyright 2012 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/* This file is machine-generated; DO NOT EDIT! */
16#include "gxio/iorpc_trio.h"
17
18struct alloc_asids_param {
19 unsigned int count;
20 unsigned int first;
21 unsigned int flags;
22};
23
24int gxio_trio_alloc_asids(gxio_trio_context_t * context, unsigned int count,
25 unsigned int first, unsigned int flags)
26{
27 struct alloc_asids_param temp;
28 struct alloc_asids_param *params = &temp;
29
30 params->count = count;
31 params->first = first;
32 params->flags = flags;
33
34 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
35 sizeof(*params), GXIO_TRIO_OP_ALLOC_ASIDS);
36}
37
38EXPORT_SYMBOL(gxio_trio_alloc_asids);
39
40
41struct alloc_memory_maps_param {
42 unsigned int count;
43 unsigned int first;
44 unsigned int flags;
45};
46
47int gxio_trio_alloc_memory_maps(gxio_trio_context_t * context,
48 unsigned int count, unsigned int first,
49 unsigned int flags)
50{
51 struct alloc_memory_maps_param temp;
52 struct alloc_memory_maps_param *params = &temp;
53
54 params->count = count;
55 params->first = first;
56 params->flags = flags;
57
58 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
59 sizeof(*params), GXIO_TRIO_OP_ALLOC_MEMORY_MAPS);
60}
61
62EXPORT_SYMBOL(gxio_trio_alloc_memory_maps);
63
64
65struct alloc_pio_regions_param {
66 unsigned int count;
67 unsigned int first;
68 unsigned int flags;
69};
70
71int gxio_trio_alloc_pio_regions(gxio_trio_context_t * context,
72 unsigned int count, unsigned int first,
73 unsigned int flags)
74{
75 struct alloc_pio_regions_param temp;
76 struct alloc_pio_regions_param *params = &temp;
77
78 params->count = count;
79 params->first = first;
80 params->flags = flags;
81
82 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
83 sizeof(*params), GXIO_TRIO_OP_ALLOC_PIO_REGIONS);
84}
85
86EXPORT_SYMBOL(gxio_trio_alloc_pio_regions);
87
88struct init_pio_region_aux_param {
89 unsigned int pio_region;
90 unsigned int mac;
91 uint32_t bus_address_hi;
92 unsigned int flags;
93};
94
95int gxio_trio_init_pio_region_aux(gxio_trio_context_t * context,
96 unsigned int pio_region, unsigned int mac,
97 uint32_t bus_address_hi, unsigned int flags)
98{
99 struct init_pio_region_aux_param temp;
100 struct init_pio_region_aux_param *params = &temp;
101
102 params->pio_region = pio_region;
103 params->mac = mac;
104 params->bus_address_hi = bus_address_hi;
105 params->flags = flags;
106
107 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
108 sizeof(*params), GXIO_TRIO_OP_INIT_PIO_REGION_AUX);
109}
110
111EXPORT_SYMBOL(gxio_trio_init_pio_region_aux);
112
113
114struct init_memory_map_mmu_aux_param {
115 unsigned int map;
116 unsigned long va;
117 uint64_t size;
118 unsigned int asid;
119 unsigned int mac;
120 uint64_t bus_address;
121 unsigned int node;
122 unsigned int order_mode;
123};
124
125int gxio_trio_init_memory_map_mmu_aux(gxio_trio_context_t * context,
126 unsigned int map, unsigned long va,
127 uint64_t size, unsigned int asid,
128 unsigned int mac, uint64_t bus_address,
129 unsigned int node,
130 unsigned int order_mode)
131{
132 struct init_memory_map_mmu_aux_param temp;
133 struct init_memory_map_mmu_aux_param *params = &temp;
134
135 params->map = map;
136 params->va = va;
137 params->size = size;
138 params->asid = asid;
139 params->mac = mac;
140 params->bus_address = bus_address;
141 params->node = node;
142 params->order_mode = order_mode;
143
144 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
145 sizeof(*params),
146 GXIO_TRIO_OP_INIT_MEMORY_MAP_MMU_AUX);
147}
148
149EXPORT_SYMBOL(gxio_trio_init_memory_map_mmu_aux);
150
151struct get_port_property_param {
152 struct pcie_trio_ports_property trio_ports;
153};
154
155int gxio_trio_get_port_property(gxio_trio_context_t * context,
156 struct pcie_trio_ports_property *trio_ports)
157{
158 int __result;
159 struct get_port_property_param temp;
160 struct get_port_property_param *params = &temp;
161
162 __result =
163 hv_dev_pread(context->fd, 0, (HV_VirtAddr) params, sizeof(*params),
164 GXIO_TRIO_OP_GET_PORT_PROPERTY);
165 *trio_ports = params->trio_ports;
166
167 return __result;
168}
169
170EXPORT_SYMBOL(gxio_trio_get_port_property);
171
172struct config_legacy_intr_param {
173 union iorpc_interrupt interrupt;
174 unsigned int mac;
175 unsigned int intx;
176};
177
178int gxio_trio_config_legacy_intr(gxio_trio_context_t * context, int inter_x,
179 int inter_y, int inter_ipi, int inter_event,
180 unsigned int mac, unsigned int intx)
181{
182 struct config_legacy_intr_param temp;
183 struct config_legacy_intr_param *params = &temp;
184
185 params->interrupt.kernel.x = inter_x;
186 params->interrupt.kernel.y = inter_y;
187 params->interrupt.kernel.ipi = inter_ipi;
188 params->interrupt.kernel.event = inter_event;
189 params->mac = mac;
190 params->intx = intx;
191
192 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
193 sizeof(*params), GXIO_TRIO_OP_CONFIG_LEGACY_INTR);
194}
195
196EXPORT_SYMBOL(gxio_trio_config_legacy_intr);
197
198struct config_msi_intr_param {
199 union iorpc_interrupt interrupt;
200 unsigned int mac;
201 unsigned int mem_map;
202 uint64_t mem_map_base;
203 uint64_t mem_map_limit;
204 unsigned int asid;
205};
206
207int gxio_trio_config_msi_intr(gxio_trio_context_t * context, int inter_x,
208 int inter_y, int inter_ipi, int inter_event,
209 unsigned int mac, unsigned int mem_map,
210 uint64_t mem_map_base, uint64_t mem_map_limit,
211 unsigned int asid)
212{
213 struct config_msi_intr_param temp;
214 struct config_msi_intr_param *params = &temp;
215
216 params->interrupt.kernel.x = inter_x;
217 params->interrupt.kernel.y = inter_y;
218 params->interrupt.kernel.ipi = inter_ipi;
219 params->interrupt.kernel.event = inter_event;
220 params->mac = mac;
221 params->mem_map = mem_map;
222 params->mem_map_base = mem_map_base;
223 params->mem_map_limit = mem_map_limit;
224 params->asid = asid;
225
226 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
227 sizeof(*params), GXIO_TRIO_OP_CONFIG_MSI_INTR);
228}
229
230EXPORT_SYMBOL(gxio_trio_config_msi_intr);
231
232
233struct set_mps_mrs_param {
234 uint16_t mps;
235 uint16_t mrs;
236 unsigned int mac;
237};
238
239int gxio_trio_set_mps_mrs(gxio_trio_context_t * context, uint16_t mps,
240 uint16_t mrs, unsigned int mac)
241{
242 struct set_mps_mrs_param temp;
243 struct set_mps_mrs_param *params = &temp;
244
245 params->mps = mps;
246 params->mrs = mrs;
247 params->mac = mac;
248
249 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
250 sizeof(*params), GXIO_TRIO_OP_SET_MPS_MRS);
251}
252
253EXPORT_SYMBOL(gxio_trio_set_mps_mrs);
254
255struct force_rc_link_up_param {
256 unsigned int mac;
257};
258
259int gxio_trio_force_rc_link_up(gxio_trio_context_t * context, unsigned int mac)
260{
261 struct force_rc_link_up_param temp;
262 struct force_rc_link_up_param *params = &temp;
263
264 params->mac = mac;
265
266 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
267 sizeof(*params), GXIO_TRIO_OP_FORCE_RC_LINK_UP);
268}
269
270EXPORT_SYMBOL(gxio_trio_force_rc_link_up);
271
272struct force_ep_link_up_param {
273 unsigned int mac;
274};
275
276int gxio_trio_force_ep_link_up(gxio_trio_context_t * context, unsigned int mac)
277{
278 struct force_ep_link_up_param temp;
279 struct force_ep_link_up_param *params = &temp;
280
281 params->mac = mac;
282
283 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
284 sizeof(*params), GXIO_TRIO_OP_FORCE_EP_LINK_UP);
285}
286
287EXPORT_SYMBOL(gxio_trio_force_ep_link_up);
288
289struct get_mmio_base_param {
290 HV_PTE base;
291};
292
293int gxio_trio_get_mmio_base(gxio_trio_context_t * context, HV_PTE *base)
294{
295 int __result;
296 struct get_mmio_base_param temp;
297 struct get_mmio_base_param *params = &temp;
298
299 __result =
300 hv_dev_pread(context->fd, 0, (HV_VirtAddr) params, sizeof(*params),
301 GXIO_TRIO_OP_GET_MMIO_BASE);
302 *base = params->base;
303
304 return __result;
305}
306
307EXPORT_SYMBOL(gxio_trio_get_mmio_base);
308
309struct check_mmio_offset_param {
310 unsigned long offset;
311 unsigned long size;
312};
313
314int gxio_trio_check_mmio_offset(gxio_trio_context_t * context,
315 unsigned long offset, unsigned long size)
316{
317 struct check_mmio_offset_param temp;
318 struct check_mmio_offset_param *params = &temp;
319
320 params->offset = offset;
321 params->size = size;
322
323 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
324 sizeof(*params), GXIO_TRIO_OP_CHECK_MMIO_OFFSET);
325}
326
327EXPORT_SYMBOL(gxio_trio_check_mmio_offset);
diff --git a/arch/tile/gxio/iorpc_usb_host.c b/arch/tile/gxio/iorpc_usb_host.c
new file mode 100644
index 00000000000..cf3c3cc1220
--- /dev/null
+++ b/arch/tile/gxio/iorpc_usb_host.c
@@ -0,0 +1,99 @@
1/*
2 * Copyright 2012 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/* This file is machine-generated; DO NOT EDIT! */
16#include "gxio/iorpc_usb_host.h"
17
18struct cfg_interrupt_param {
19 union iorpc_interrupt interrupt;
20};
21
22int gxio_usb_host_cfg_interrupt(gxio_usb_host_context_t * context, int inter_x,
23 int inter_y, int inter_ipi, int inter_event)
24{
25 struct cfg_interrupt_param temp;
26 struct cfg_interrupt_param *params = &temp;
27
28 params->interrupt.kernel.x = inter_x;
29 params->interrupt.kernel.y = inter_y;
30 params->interrupt.kernel.ipi = inter_ipi;
31 params->interrupt.kernel.event = inter_event;
32
33 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
34 sizeof(*params), GXIO_USB_HOST_OP_CFG_INTERRUPT);
35}
36
37EXPORT_SYMBOL(gxio_usb_host_cfg_interrupt);
38
39struct register_client_memory_param {
40 HV_PTE pte;
41 unsigned int flags;
42};
43
44int gxio_usb_host_register_client_memory(gxio_usb_host_context_t * context,
45 HV_PTE pte, unsigned int flags)
46{
47 struct register_client_memory_param temp;
48 struct register_client_memory_param *params = &temp;
49
50 params->pte = pte;
51 params->flags = flags;
52
53 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
54 sizeof(*params),
55 GXIO_USB_HOST_OP_REGISTER_CLIENT_MEMORY);
56}
57
58EXPORT_SYMBOL(gxio_usb_host_register_client_memory);
59
60struct get_mmio_base_param {
61 HV_PTE base;
62};
63
64int gxio_usb_host_get_mmio_base(gxio_usb_host_context_t * context, HV_PTE *base)
65{
66 int __result;
67 struct get_mmio_base_param temp;
68 struct get_mmio_base_param *params = &temp;
69
70 __result =
71 hv_dev_pread(context->fd, 0, (HV_VirtAddr) params, sizeof(*params),
72 GXIO_USB_HOST_OP_GET_MMIO_BASE);
73 *base = params->base;
74
75 return __result;
76}
77
78EXPORT_SYMBOL(gxio_usb_host_get_mmio_base);
79
80struct check_mmio_offset_param {
81 unsigned long offset;
82 unsigned long size;
83};
84
85int gxio_usb_host_check_mmio_offset(gxio_usb_host_context_t * context,
86 unsigned long offset, unsigned long size)
87{
88 struct check_mmio_offset_param temp;
89 struct check_mmio_offset_param *params = &temp;
90
91 params->offset = offset;
92 params->size = size;
93
94 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
95 sizeof(*params),
96 GXIO_USB_HOST_OP_CHECK_MMIO_OFFSET);
97}
98
99EXPORT_SYMBOL(gxio_usb_host_check_mmio_offset);
diff --git a/arch/tile/gxio/kiorpc.c b/arch/tile/gxio/kiorpc.c
new file mode 100644
index 00000000000..c8096aa5a3f
--- /dev/null
+++ b/arch/tile/gxio/kiorpc.c
@@ -0,0 +1,61 @@
1/*
2 * Copyright 2012 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 * TILE-Gx IORPC support for kernel I/O drivers.
15 */
16
17#include <linux/mmzone.h>
18#include <linux/module.h>
19#include <linux/io.h>
20#include <gxio/iorpc_globals.h>
21#include <gxio/kiorpc.h>
22
23#ifdef DEBUG_IORPC
24#define TRACE(FMT, ...) pr_info(SIMPLE_MSG_LINE FMT, ## __VA_ARGS__)
25#else
26#define TRACE(...)
27#endif
28
29/* Create kernel-VA-space MMIO mapping for an on-chip IO device. */
30void __iomem *iorpc_ioremap(int hv_fd, resource_size_t offset,
31 unsigned long size)
32{
33 pgprot_t mmio_base, prot = { 0 };
34 unsigned long pfn;
35 int err;
36
37 /* Look up the shim's lotar and base PA. */
38 err = __iorpc_get_mmio_base(hv_fd, &mmio_base);
39 if (err) {
40 TRACE("get_mmio_base() failure: %d\n", err);
41 return NULL;
42 }
43
44 /* Make sure the HV driver approves of our offset and size. */
45 err = __iorpc_check_mmio_offset(hv_fd, offset, size);
46 if (err) {
47 TRACE("check_mmio_offset() failure: %d\n", err);
48 return NULL;
49 }
50
51 /*
52 * mmio_base contains a base pfn and homing coordinates. Turn
53 * it into an MMIO pgprot and offset pfn.
54 */
55 prot = hv_pte_set_lotar(prot, hv_pte_get_lotar(mmio_base));
56 pfn = pte_pfn(mmio_base) + PFN_DOWN(offset);
57
58 return ioremap_prot(PFN_PHYS(pfn), size, prot);
59}
60
61EXPORT_SYMBOL(iorpc_ioremap);
diff --git a/arch/tile/gxio/mpipe.c b/arch/tile/gxio/mpipe.c
new file mode 100644
index 00000000000..e71c63390ac
--- /dev/null
+++ b/arch/tile/gxio/mpipe.c
@@ -0,0 +1,545 @@
1/*
2 * Copyright 2012 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 * Implementation of mpipe gxio calls.
17 */
18
19#include <linux/errno.h>
20#include <linux/io.h>
21#include <linux/module.h>
22
23#include <gxio/iorpc_globals.h>
24#include <gxio/iorpc_mpipe.h>
25#include <gxio/iorpc_mpipe_info.h>
26#include <gxio/kiorpc.h>
27#include <gxio/mpipe.h>
28
29/* HACK: Avoid pointless "shadow" warnings. */
30#define link link_shadow
31
32int gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index)
33{
34 char file[32];
35
36 int fd;
37 int i;
38
39 snprintf(file, sizeof(file), "mpipe/%d/iorpc", mpipe_index);
40 fd = hv_dev_open((HV_VirtAddr) file, 0);
41 if (fd < 0) {
42 if (fd >= GXIO_ERR_MIN && fd <= GXIO_ERR_MAX)
43 return fd;
44 else
45 return -ENODEV;
46 }
47
48 context->fd = fd;
49
50 /* Map in the MMIO space. */
51 context->mmio_cfg_base = (void __force *)
52 iorpc_ioremap(fd, HV_MPIPE_CONFIG_MMIO_OFFSET,
53 HV_MPIPE_CONFIG_MMIO_SIZE);
54 if (context->mmio_cfg_base == NULL)
55 goto cfg_failed;
56
57 context->mmio_fast_base = (void __force *)
58 iorpc_ioremap(fd, HV_MPIPE_FAST_MMIO_OFFSET,
59 HV_MPIPE_FAST_MMIO_SIZE);
60 if (context->mmio_fast_base == NULL)
61 goto fast_failed;
62
63 /* Initialize the stacks. */
64 for (i = 0; i < 8; i++)
65 context->__stacks.stacks[i] = 255;
66
67 return 0;
68
69 fast_failed:
70 iounmap((void __force __iomem *)(context->mmio_cfg_base));
71 cfg_failed:
72 hv_dev_close(context->fd);
73 return -ENODEV;
74}
75
76EXPORT_SYMBOL_GPL(gxio_mpipe_init);
77
78int gxio_mpipe_destroy(gxio_mpipe_context_t *context)
79{
80 iounmap((void __force __iomem *)(context->mmio_cfg_base));
81 iounmap((void __force __iomem *)(context->mmio_fast_base));
82 return hv_dev_close(context->fd);
83}
84
85EXPORT_SYMBOL_GPL(gxio_mpipe_destroy);
86
87static int16_t gxio_mpipe_buffer_sizes[8] =
88 { 128, 256, 512, 1024, 1664, 4096, 10368, 16384 };
89
90gxio_mpipe_buffer_size_enum_t gxio_mpipe_buffer_size_to_buffer_size_enum(size_t
91 size)
92{
93 int i;
94 for (i = 0; i < 7; i++)
95 if (size <= gxio_mpipe_buffer_sizes[i])
96 break;
97 return i;
98}
99
100EXPORT_SYMBOL_GPL(gxio_mpipe_buffer_size_to_buffer_size_enum);
101
102size_t gxio_mpipe_buffer_size_enum_to_buffer_size(gxio_mpipe_buffer_size_enum_t
103 buffer_size_enum)
104{
105 if (buffer_size_enum > 7)
106 buffer_size_enum = 7;
107
108 return gxio_mpipe_buffer_sizes[buffer_size_enum];
109}
110
111EXPORT_SYMBOL_GPL(gxio_mpipe_buffer_size_enum_to_buffer_size);
112
113size_t gxio_mpipe_calc_buffer_stack_bytes(unsigned long buffers)
114{
115 const int BUFFERS_PER_LINE = 12;
116
117 /* Count the number of cachlines. */
118 unsigned long lines =
119 (buffers + BUFFERS_PER_LINE - 1) / BUFFERS_PER_LINE;
120
121 /* Convert to bytes. */
122 return lines * CHIP_L2_LINE_SIZE();
123}
124
125EXPORT_SYMBOL_GPL(gxio_mpipe_calc_buffer_stack_bytes);
126
127int gxio_mpipe_init_buffer_stack(gxio_mpipe_context_t *context,
128 unsigned int stack,
129 gxio_mpipe_buffer_size_enum_t
130 buffer_size_enum, void *mem, size_t mem_size,
131 unsigned int mem_flags)
132{
133 int result;
134
135 memset(mem, 0, mem_size);
136
137 result = gxio_mpipe_init_buffer_stack_aux(context, mem, mem_size,
138 mem_flags, stack,
139 buffer_size_enum);
140 if (result < 0)
141 return result;
142
143 /* Save the stack. */
144 context->__stacks.stacks[buffer_size_enum] = stack;
145
146 return 0;
147}
148
149EXPORT_SYMBOL_GPL(gxio_mpipe_init_buffer_stack);
150
151int gxio_mpipe_init_notif_ring(gxio_mpipe_context_t *context,
152 unsigned int ring,
153 void *mem, size_t mem_size,
154 unsigned int mem_flags)
155{
156 return gxio_mpipe_init_notif_ring_aux(context, mem, mem_size,
157 mem_flags, ring);
158}
159
160EXPORT_SYMBOL_GPL(gxio_mpipe_init_notif_ring);
161
162int gxio_mpipe_init_notif_group_and_buckets(gxio_mpipe_context_t *context,
163 unsigned int group,
164 unsigned int ring,
165 unsigned int num_rings,
166 unsigned int bucket,
167 unsigned int num_buckets,
168 gxio_mpipe_bucket_mode_t mode)
169{
170 int i;
171 int result;
172
173 gxio_mpipe_bucket_info_t bucket_info = { {
174 .group = group,
175 .mode = mode,
176 }
177 };
178
179 gxio_mpipe_notif_group_bits_t bits = { {0} };
180
181 for (i = 0; i < num_rings; i++)
182 gxio_mpipe_notif_group_add_ring(&bits, ring + i);
183
184 result = gxio_mpipe_init_notif_group(context, group, bits);
185 if (result != 0)
186 return result;
187
188 for (i = 0; i < num_buckets; i++) {
189 bucket_info.notifring = ring + (i % num_rings);
190
191 result = gxio_mpipe_init_bucket(context, bucket + i,
192 bucket_info);
193 if (result != 0)
194 return result;
195 }
196
197 return 0;
198}
199
200EXPORT_SYMBOL_GPL(gxio_mpipe_init_notif_group_and_buckets);
201
202int gxio_mpipe_init_edma_ring(gxio_mpipe_context_t *context,
203 unsigned int ring, unsigned int channel,
204 void *mem, size_t mem_size,
205 unsigned int mem_flags)
206{
207 memset(mem, 0, mem_size);
208
209 return gxio_mpipe_init_edma_ring_aux(context, mem, mem_size, mem_flags,
210 ring, channel);
211}
212
213EXPORT_SYMBOL_GPL(gxio_mpipe_init_edma_ring);
214
215void gxio_mpipe_rules_init(gxio_mpipe_rules_t *rules,
216 gxio_mpipe_context_t *context)
217{
218 rules->context = context;
219 memset(&rules->list, 0, sizeof(rules->list));
220}
221
222EXPORT_SYMBOL_GPL(gxio_mpipe_rules_init);
223
224int gxio_mpipe_rules_begin(gxio_mpipe_rules_t *rules,
225 unsigned int bucket, unsigned int num_buckets,
226 gxio_mpipe_rules_stacks_t *stacks)
227{
228 int i;
229 int stack = 255;
230
231 gxio_mpipe_rules_list_t *list = &rules->list;
232
233 /* Current rule. */
234 gxio_mpipe_rules_rule_t *rule =
235 (gxio_mpipe_rules_rule_t *) (list->rules + list->head);
236
237 unsigned int head = list->tail;
238
239 /*
240 * Align next rule properly.
241 *Note that "dmacs_and_vlans" will also be aligned.
242 */
243 unsigned int pad = 0;
244 while (((head + pad) % __alignof__(gxio_mpipe_rules_rule_t)) != 0)
245 pad++;
246
247 /*
248 * Verify room.
249 * ISSUE: Mark rules as broken on error?
250 */
251 if (head + pad + sizeof(*rule) >= sizeof(list->rules))
252 return GXIO_MPIPE_ERR_RULES_FULL;
253
254 /* Verify num_buckets is a power of 2. */
255 if (__builtin_popcount(num_buckets) != 1)
256 return GXIO_MPIPE_ERR_RULES_INVALID;
257
258 /* Add padding to previous rule. */
259 rule->size += pad;
260
261 /* Start a new rule. */
262 list->head = head + pad;
263
264 rule = (gxio_mpipe_rules_rule_t *) (list->rules + list->head);
265
266 /* Default some values. */
267 rule->headroom = 2;
268 rule->tailroom = 0;
269 rule->capacity = 16384;
270
271 /* Save the bucket info. */
272 rule->bucket_mask = num_buckets - 1;
273 rule->bucket_first = bucket;
274
275 for (i = 8 - 1; i >= 0; i--) {
276 int maybe =
277 stacks ? stacks->stacks[i] : rules->context->__stacks.
278 stacks[i];
279 if (maybe != 255)
280 stack = maybe;
281 rule->stacks.stacks[i] = stack;
282 }
283
284 if (stack == 255)
285 return GXIO_MPIPE_ERR_RULES_INVALID;
286
287 /* NOTE: Only entries at the end of the array can be 255. */
288 for (i = 8 - 1; i > 0; i--) {
289 if (rule->stacks.stacks[i] == 255) {
290 rule->stacks.stacks[i] = stack;
291 rule->capacity =
292 gxio_mpipe_buffer_size_enum_to_buffer_size(i -
293 1);
294 }
295 }
296
297 rule->size = sizeof(*rule);
298 list->tail = list->head + rule->size;
299
300 return 0;
301}
302
303EXPORT_SYMBOL_GPL(gxio_mpipe_rules_begin);
304
305int gxio_mpipe_rules_add_channel(gxio_mpipe_rules_t *rules,
306 unsigned int channel)
307{
308 gxio_mpipe_rules_list_t *list = &rules->list;
309
310 gxio_mpipe_rules_rule_t *rule =
311 (gxio_mpipe_rules_rule_t *) (list->rules + list->head);
312
313 /* Verify channel. */
314 if (channel >= 32)
315 return GXIO_MPIPE_ERR_RULES_INVALID;
316
317 /* Verify begun. */
318 if (list->tail == 0)
319 return GXIO_MPIPE_ERR_RULES_EMPTY;
320
321 rule->channel_bits |= (1UL << channel);
322
323 return 0;
324}
325
326EXPORT_SYMBOL_GPL(gxio_mpipe_rules_add_channel);
327
328int gxio_mpipe_rules_set_headroom(gxio_mpipe_rules_t *rules, uint8_t headroom)
329{
330 gxio_mpipe_rules_list_t *list = &rules->list;
331
332 gxio_mpipe_rules_rule_t *rule =
333 (gxio_mpipe_rules_rule_t *) (list->rules + list->head);
334
335 /* Verify begun. */
336 if (list->tail == 0)
337 return GXIO_MPIPE_ERR_RULES_EMPTY;
338
339 rule->headroom = headroom;
340
341 return 0;
342}
343
344EXPORT_SYMBOL_GPL(gxio_mpipe_rules_set_headroom);
345
346int gxio_mpipe_rules_commit(gxio_mpipe_rules_t *rules)
347{
348 gxio_mpipe_rules_list_t *list = &rules->list;
349 unsigned int size =
350 offsetof(gxio_mpipe_rules_list_t, rules) + list->tail;
351 return gxio_mpipe_commit_rules(rules->context, list, size);
352}
353
354EXPORT_SYMBOL_GPL(gxio_mpipe_rules_commit);
355
356int gxio_mpipe_iqueue_init(gxio_mpipe_iqueue_t *iqueue,
357 gxio_mpipe_context_t *context,
358 unsigned int ring,
359 void *mem, size_t mem_size, unsigned int mem_flags)
360{
361 /* The init call below will verify that "mem_size" is legal. */
362 unsigned int num_entries = mem_size / sizeof(gxio_mpipe_idesc_t);
363
364 iqueue->context = context;
365 iqueue->idescs = (gxio_mpipe_idesc_t *)mem;
366 iqueue->ring = ring;
367 iqueue->num_entries = num_entries;
368 iqueue->mask_num_entries = num_entries - 1;
369 iqueue->log2_num_entries = __builtin_ctz(num_entries);
370 iqueue->head = 1;
371#ifdef __BIG_ENDIAN__
372 iqueue->swapped = 0;
373#endif
374
375 /* Initialize the "tail". */
376 __gxio_mmio_write(mem, iqueue->head);
377
378 return gxio_mpipe_init_notif_ring(context, ring, mem, mem_size,
379 mem_flags);
380}
381
382EXPORT_SYMBOL_GPL(gxio_mpipe_iqueue_init);
383
384int gxio_mpipe_equeue_init(gxio_mpipe_equeue_t *equeue,
385 gxio_mpipe_context_t *context,
386 unsigned int edma_ring_id,
387 unsigned int channel,
388 void *mem, unsigned int mem_size,
389 unsigned int mem_flags)
390{
391 /* The init call below will verify that "mem_size" is legal. */
392 unsigned int num_entries = mem_size / sizeof(gxio_mpipe_edesc_t);
393
394 /* Offset used to read number of completed commands. */
395 MPIPE_EDMA_POST_REGION_ADDR_t offset;
396
397 int result = gxio_mpipe_init_edma_ring(context, edma_ring_id, channel,
398 mem, mem_size, mem_flags);
399 if (result < 0)
400 return result;
401
402 memset(equeue, 0, sizeof(*equeue));
403
404 offset.word = 0;
405 offset.region =
406 MPIPE_MMIO_ADDR__REGION_VAL_EDMA -
407 MPIPE_MMIO_ADDR__REGION_VAL_IDMA;
408 offset.ring = edma_ring_id;
409
410 __gxio_dma_queue_init(&equeue->dma_queue,
411 context->mmio_fast_base + offset.word,
412 num_entries);
413 equeue->edescs = mem;
414 equeue->mask_num_entries = num_entries - 1;
415 equeue->log2_num_entries = __builtin_ctz(num_entries);
416
417 return 0;
418}
419
420EXPORT_SYMBOL_GPL(gxio_mpipe_equeue_init);
421
422int gxio_mpipe_set_timestamp(gxio_mpipe_context_t *context,
423 const struct timespec *ts)
424{
425 cycles_t cycles = get_cycles();
426 return gxio_mpipe_set_timestamp_aux(context, (uint64_t)ts->tv_sec,
427 (uint64_t)ts->tv_nsec,
428 (uint64_t)cycles);
429}
430
431int gxio_mpipe_get_timestamp(gxio_mpipe_context_t *context,
432 struct timespec *ts)
433{
434 int ret;
435 cycles_t cycles_prev, cycles_now, clock_rate;
436 cycles_prev = get_cycles();
437 ret = gxio_mpipe_get_timestamp_aux(context, (uint64_t *)&ts->tv_sec,
438 (uint64_t *)&ts->tv_nsec,
439 (uint64_t *)&cycles_now);
440 if (ret < 0) {
441 return ret;
442 }
443
444 clock_rate = get_clock_rate();
445 ts->tv_nsec -= (cycles_now - cycles_prev) * 1000000000LL / clock_rate;
446 if (ts->tv_nsec < 0) {
447 ts->tv_nsec += 1000000000LL;
448 ts->tv_sec -= 1;
449 }
450 return ret;
451}
452
453int gxio_mpipe_adjust_timestamp(gxio_mpipe_context_t *context, int64_t delta)
454{
455 return gxio_mpipe_adjust_timestamp_aux(context, delta);
456}
457
458/* Get our internal context used for link name access. This context is
459 * special in that it is not associated with an mPIPE service domain.
460 */
461static gxio_mpipe_context_t *_gxio_get_link_context(void)
462{
463 static gxio_mpipe_context_t context;
464 static gxio_mpipe_context_t *contextp;
465 static int tried_open = 0;
466 static DEFINE_MUTEX(mutex);
467
468 mutex_lock(&mutex);
469
470 if (!tried_open) {
471 int i = 0;
472 tried_open = 1;
473
474 /*
475 * "4" here is the maximum possible number of mPIPE shims; it's
476 * an exaggeration but we shouldn't ever go beyond 2 anyway.
477 */
478 for (i = 0; i < 4; i++) {
479 char file[80];
480
481 snprintf(file, sizeof(file), "mpipe/%d/iorpc_info", i);
482 context.fd = hv_dev_open((HV_VirtAddr) file, 0);
483 if (context.fd < 0)
484 continue;
485
486 contextp = &context;
487 break;
488 }
489 }
490
491 mutex_unlock(&mutex);
492
493 return contextp;
494}
495
496int gxio_mpipe_link_enumerate_mac(int idx, char *link_name, uint8_t *link_mac)
497{
498 int rv;
499 _gxio_mpipe_link_name_t name;
500 _gxio_mpipe_link_mac_t mac;
501
502 gxio_mpipe_context_t *context = _gxio_get_link_context();
503 if (!context)
504 return GXIO_ERR_NO_DEVICE;
505
506 rv = gxio_mpipe_info_enumerate_aux(context, idx, &name, &mac);
507 if (rv >= 0) {
508 strncpy(link_name, name.name, sizeof(name.name));
509 memcpy(link_mac, mac.mac, sizeof(mac.mac));
510 }
511
512 return rv;
513}
514
515EXPORT_SYMBOL_GPL(gxio_mpipe_link_enumerate_mac);
516
517int gxio_mpipe_link_open(gxio_mpipe_link_t *link,
518 gxio_mpipe_context_t *context, const char *link_name,
519 unsigned int flags)
520{
521 _gxio_mpipe_link_name_t name;
522 int rv;
523
524 strncpy(name.name, link_name, sizeof(name.name));
525 name.name[GXIO_MPIPE_LINK_NAME_LEN - 1] = '\0';
526
527 rv = gxio_mpipe_link_open_aux(context, name, flags);
528 if (rv < 0)
529 return rv;
530
531 link->context = context;
532 link->channel = rv >> 8;
533 link->mac = rv & 0xFF;
534
535 return 0;
536}
537
538EXPORT_SYMBOL_GPL(gxio_mpipe_link_open);
539
540int gxio_mpipe_link_close(gxio_mpipe_link_t *link)
541{
542 return gxio_mpipe_link_close_aux(link->context, link->mac);
543}
544
545EXPORT_SYMBOL_GPL(gxio_mpipe_link_close);
diff --git a/arch/tile/gxio/trio.c b/arch/tile/gxio/trio.c
new file mode 100644
index 00000000000..69f0b8df3ce
--- /dev/null
+++ b/arch/tile/gxio/trio.c
@@ -0,0 +1,49 @@
1/*
2 * Copyright 2012 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 * Implementation of trio gxio calls.
17 */
18
19#include <linux/errno.h>
20#include <linux/io.h>
21#include <linux/module.h>
22
23#include <gxio/trio.h>
24#include <gxio/iorpc_globals.h>
25#include <gxio/iorpc_trio.h>
26#include <gxio/kiorpc.h>
27
28int gxio_trio_init(gxio_trio_context_t *context, unsigned int trio_index)
29{
30 char file[32];
31 int fd;
32
33 snprintf(file, sizeof(file), "trio/%d/iorpc", trio_index);
34 fd = hv_dev_open((HV_VirtAddr) file, 0);
35 if (fd < 0) {
36 context->fd = -1;
37
38 if (fd >= GXIO_ERR_MIN && fd <= GXIO_ERR_MAX)
39 return fd;
40 else
41 return -ENODEV;
42 }
43
44 context->fd = fd;
45
46 return 0;
47}
48
49EXPORT_SYMBOL_GPL(gxio_trio_init);
diff --git a/arch/tile/gxio/usb_host.c b/arch/tile/gxio/usb_host.c
new file mode 100644
index 00000000000..66b002f54ec
--- /dev/null
+++ b/arch/tile/gxio/usb_host.c
@@ -0,0 +1,91 @@
1/*
2 * Copyright 2012 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 *
17 * Implementation of USB gxio calls.
18 */
19
20#include <linux/io.h>
21#include <linux/errno.h>
22#include <linux/module.h>
23
24#include <gxio/iorpc_globals.h>
25#include <gxio/iorpc_usb_host.h>
26#include <gxio/kiorpc.h>
27#include <gxio/usb_host.h>
28
29int gxio_usb_host_init(gxio_usb_host_context_t * context, int usb_index,
30 int is_ehci)
31{
32 char file[32];
33 int fd;
34
35 if (is_ehci)
36 snprintf(file, sizeof(file), "usb_host/%d/iorpc/ehci",
37 usb_index);
38 else
39 snprintf(file, sizeof(file), "usb_host/%d/iorpc/ohci",
40 usb_index);
41
42 fd = hv_dev_open((HV_VirtAddr) file, 0);
43 if (fd < 0) {
44 if (fd >= GXIO_ERR_MIN && fd <= GXIO_ERR_MAX)
45 return fd;
46 else
47 return -ENODEV;
48 }
49
50 context->fd = fd;
51
52 // Map in the MMIO space.
53 context->mmio_base =
54 (void __force *)iorpc_ioremap(fd, 0, HV_USB_HOST_MMIO_SIZE);
55
56 if (context->mmio_base == NULL) {
57 hv_dev_close(context->fd);
58 return -ENODEV;
59 }
60
61 return 0;
62}
63
64EXPORT_SYMBOL_GPL(gxio_usb_host_init);
65
66int gxio_usb_host_destroy(gxio_usb_host_context_t * context)
67{
68 iounmap((void __force __iomem *)(context->mmio_base));
69 hv_dev_close(context->fd);
70
71 context->mmio_base = NULL;
72 context->fd = -1;
73
74 return 0;
75}
76
77EXPORT_SYMBOL_GPL(gxio_usb_host_destroy);
78
79void *gxio_usb_host_get_reg_start(gxio_usb_host_context_t * context)
80{
81 return context->mmio_base;
82}
83
84EXPORT_SYMBOL_GPL(gxio_usb_host_get_reg_start);
85
86size_t gxio_usb_host_get_reg_len(gxio_usb_host_context_t * context)
87{
88 return HV_USB_HOST_MMIO_SIZE;
89}
90
91EXPORT_SYMBOL_GPL(gxio_usb_host_get_reg_len);
diff --git a/arch/tile/include/arch/mpipe.h b/arch/tile/include/arch/mpipe.h
new file mode 100644
index 00000000000..8a33912fd6c
--- /dev/null
+++ b/arch/tile/include/arch/mpipe.h
@@ -0,0 +1,359 @@
1/*
2 * Copyright 2012 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/* Machine-generated file; do not edit. */
16
17#ifndef __ARCH_MPIPE_H__
18#define __ARCH_MPIPE_H__
19
20#include <arch/abi.h>
21#include <arch/mpipe_def.h>
22
23#ifndef __ASSEMBLER__
24
25/*
26 * MMIO Ingress DMA Release Region Address.
27 * This is a description of the physical addresses used to manipulate ingress
28 * credit counters. Accesses to this address space should use an address of
29 * this form and a value like that specified in IDMA_RELEASE_REGION_VAL.
30 */
31
32__extension__
33typedef union
34{
35 struct
36 {
37#ifndef __BIG_ENDIAN__
38 /* Reserved. */
39 uint_reg_t __reserved_0 : 3;
40 /* NotifRing to be released */
41 uint_reg_t ring : 8;
42 /* Bucket to be released */
43 uint_reg_t bucket : 13;
44 /* Enable NotifRing release */
45 uint_reg_t ring_enable : 1;
46 /* Enable Bucket release */
47 uint_reg_t bucket_enable : 1;
48 /*
49 * This field of the address selects the region (address space) to be
50 * accessed. For the iDMA release region, this field must be 4.
51 */
52 uint_reg_t region : 3;
53 /* Reserved. */
54 uint_reg_t __reserved_1 : 6;
55 /* This field of the address indexes the 32 entry service domain table. */
56 uint_reg_t svc_dom : 5;
57 /* Reserved. */
58 uint_reg_t __reserved_2 : 24;
59#else /* __BIG_ENDIAN__ */
60 uint_reg_t __reserved_2 : 24;
61 uint_reg_t svc_dom : 5;
62 uint_reg_t __reserved_1 : 6;
63 uint_reg_t region : 3;
64 uint_reg_t bucket_enable : 1;
65 uint_reg_t ring_enable : 1;
66 uint_reg_t bucket : 13;
67 uint_reg_t ring : 8;
68 uint_reg_t __reserved_0 : 3;
69#endif
70 };
71
72 uint_reg_t word;
73} MPIPE_IDMA_RELEASE_REGION_ADDR_t;
74
75/*
76 * MMIO Ingress DMA Release Region Value - Release NotifRing and/or Bucket.
77 * Provides release of the associated NotifRing. The address of the MMIO
78 * operation is described in IDMA_RELEASE_REGION_ADDR.
79 */
80
81__extension__
82typedef union
83{
84 struct
85 {
86#ifndef __BIG_ENDIAN__
87 /*
88 * Number of packets being released. The load balancer's count of
89 * inflight packets will be decremented by this amount for the associated
90 * Bucket and/or NotifRing
91 */
92 uint_reg_t count : 16;
93 /* Reserved. */
94 uint_reg_t __reserved : 48;
95#else /* __BIG_ENDIAN__ */
96 uint_reg_t __reserved : 48;
97 uint_reg_t count : 16;
98#endif
99 };
100
101 uint_reg_t word;
102} MPIPE_IDMA_RELEASE_REGION_VAL_t;
103
104/*
105 * MMIO Buffer Stack Manager Region Address.
106 * This MMIO region is used for posting or fetching buffers to/from the
107 * buffer stack manager. On an MMIO load, this pops a buffer descriptor from
108 * the top of stack if one is available. On an MMIO store, this pushes a
109 * buffer to the stack. The value read or written is described in
110 * BSM_REGION_VAL.
111 */
112
113__extension__
114typedef union
115{
116 struct
117 {
118#ifndef __BIG_ENDIAN__
119 /* Reserved. */
120 uint_reg_t __reserved_0 : 3;
121 /* BufferStack being accessed. */
122 uint_reg_t stack : 5;
123 /* Reserved. */
124 uint_reg_t __reserved_1 : 18;
125 /*
126 * This field of the address selects the region (address space) to be
127 * accessed. For the buffer stack manager region, this field must be 6.
128 */
129 uint_reg_t region : 3;
130 /* Reserved. */
131 uint_reg_t __reserved_2 : 6;
132 /* This field of the address indexes the 32 entry service domain table. */
133 uint_reg_t svc_dom : 5;
134 /* Reserved. */
135 uint_reg_t __reserved_3 : 24;
136#else /* __BIG_ENDIAN__ */
137 uint_reg_t __reserved_3 : 24;
138 uint_reg_t svc_dom : 5;
139 uint_reg_t __reserved_2 : 6;
140 uint_reg_t region : 3;
141 uint_reg_t __reserved_1 : 18;
142 uint_reg_t stack : 5;
143 uint_reg_t __reserved_0 : 3;
144#endif
145 };
146
147 uint_reg_t word;
148} MPIPE_BSM_REGION_ADDR_t;
149
150/*
151 * MMIO Buffer Stack Manager Region Value.
152 * This MMIO region is used for posting or fetching buffers to/from the
153 * buffer stack manager. On an MMIO load, this pops a buffer descriptor from
154 * the top of stack if one is available. On an MMIO store, this pushes a
155 * buffer to the stack. The address of the MMIO operation is described in
156 * BSM_REGION_ADDR.
157 */
158
159__extension__
160typedef union
161{
162 struct
163 {
164#ifndef __BIG_ENDIAN__
165 /* Reserved. */
166 uint_reg_t __reserved_0 : 7;
167 /*
168 * Base virtual address of the buffer. Must be sign extended by consumer.
169 */
170 int_reg_t va : 35;
171 /* Reserved. */
172 uint_reg_t __reserved_1 : 6;
173 /*
174 * Index of the buffer stack to which this buffer belongs. Ignored on
175 * writes since the offset bits specify the stack being accessed.
176 */
177 uint_reg_t stack_idx : 5;
178 /* Reserved. */
179 uint_reg_t __reserved_2 : 5;
180 /*
181 * Reads as one to indicate that this is a hardware managed buffer.
182 * Ignored on writes since all buffers on a given stack are the same size.
183 */
184 uint_reg_t hwb : 1;
185 /*
186 * Encoded size of buffer (ignored on writes):
187 * 0 = 128 bytes
188 * 1 = 256 bytes
189 * 2 = 512 bytes
190 * 3 = 1024 bytes
191 * 4 = 1664 bytes
192 * 5 = 4096 bytes
193 * 6 = 10368 bytes
194 * 7 = 16384 bytes
195 */
196 uint_reg_t size : 3;
197 /*
198 * Valid indication for the buffer. Ignored on writes.
199 * 0 : Valid buffer descriptor popped from stack.
200 * 3 : Could not pop a buffer from the stack. Either the stack is empty,
201 * or the hardware's prefetch buffer is empty for this stack.
202 */
203 uint_reg_t c : 2;
204#else /* __BIG_ENDIAN__ */
205 uint_reg_t c : 2;
206 uint_reg_t size : 3;
207 uint_reg_t hwb : 1;
208 uint_reg_t __reserved_2 : 5;
209 uint_reg_t stack_idx : 5;
210 uint_reg_t __reserved_1 : 6;
211 int_reg_t va : 35;
212 uint_reg_t __reserved_0 : 7;
213#endif
214 };
215
216 uint_reg_t word;
217} MPIPE_BSM_REGION_VAL_t;
218
219/*
220 * MMIO Egress DMA Post Region Address.
221 * Used to post descriptor locations to the eDMA descriptor engine. The
222 * value to be written is described in EDMA_POST_REGION_VAL
223 */
224
225__extension__
226typedef union
227{
228 struct
229 {
230#ifndef __BIG_ENDIAN__
231 /* Reserved. */
232 uint_reg_t __reserved_0 : 3;
233 /* eDMA ring being accessed */
234 uint_reg_t ring : 5;
235 /* Reserved. */
236 uint_reg_t __reserved_1 : 18;
237 /*
238 * This field of the address selects the region (address space) to be
239 * accessed. For the egress DMA post region, this field must be 5.
240 */
241 uint_reg_t region : 3;
242 /* Reserved. */
243 uint_reg_t __reserved_2 : 6;
244 /* This field of the address indexes the 32 entry service domain table. */
245 uint_reg_t svc_dom : 5;
246 /* Reserved. */
247 uint_reg_t __reserved_3 : 24;
248#else /* __BIG_ENDIAN__ */
249 uint_reg_t __reserved_3 : 24;
250 uint_reg_t svc_dom : 5;
251 uint_reg_t __reserved_2 : 6;
252 uint_reg_t region : 3;
253 uint_reg_t __reserved_1 : 18;
254 uint_reg_t ring : 5;
255 uint_reg_t __reserved_0 : 3;
256#endif
257 };
258
259 uint_reg_t word;
260} MPIPE_EDMA_POST_REGION_ADDR_t;
261
262/*
263 * MMIO Egress DMA Post Region Value.
264 * Used to post descriptor locations to the eDMA descriptor engine. The
265 * address is described in EDMA_POST_REGION_ADDR.
266 */
267
268__extension__
269typedef union
270{
271 struct
272 {
273#ifndef __BIG_ENDIAN__
274 /*
275 * For writes, this specifies the current ring tail pointer prior to any
276 * post. For example, to post 1 or more descriptors starting at location
277 * 23, this would contain 23 (not 24). On writes, this index must be
278 * masked based on the ring size. The new tail pointer after this post
279 * is COUNT+RING_IDX (masked by the ring size).
280 *
281 * For reads, this provides the hardware descriptor fetcher's head
282 * pointer. The descriptors prior to the head pointer, however, may not
283 * yet have been processed so this indicator is only used to determine
284 * how full the ring is and if software may post more descriptors.
285 */
286 uint_reg_t ring_idx : 16;
287 /*
288 * For writes, this specifies number of contiguous descriptors that are
289 * being posted. Software may post up to RingSize descriptors with a
290 * single MMIO store. A zero in this field on a write will "wake up" an
291 * eDMA ring and cause it fetch descriptors regardless of the hardware's
292 * current view of the state of the tail pointer.
293 *
294 * For reads, this field provides a rolling count of the number of
295 * descriptors that have been completely processed. This may be used by
296 * software to determine when buffers associated with a descriptor may be
297 * returned or reused. When the ring's flush bit is cleared by software
298 * (after having been set by HW or SW), the COUNT will be cleared.
299 */
300 uint_reg_t count : 16;
301 /*
302 * For writes, this specifies the generation number of the tail being
303 * posted. Note that if tail+cnt wraps to the beginning of the ring, the
304 * eDMA hardware assumes that the descriptors posted at the beginning of
305 * the ring are also valid so it is okay to post around the wrap point.
306 *
307 * For reads, this is the current generation number. Valid descriptors
308 * will have the inverse of this generation number.
309 */
310 uint_reg_t gen : 1;
311 /* Reserved. */
312 uint_reg_t __reserved : 31;
313#else /* __BIG_ENDIAN__ */
314 uint_reg_t __reserved : 31;
315 uint_reg_t gen : 1;
316 uint_reg_t count : 16;
317 uint_reg_t ring_idx : 16;
318#endif
319 };
320
321 uint_reg_t word;
322} MPIPE_EDMA_POST_REGION_VAL_t;
323
324/*
325 * Load Balancer Bucket Status Data.
326 * Read/Write data for load balancer Bucket-Status Table. 4160 entries
327 * indexed by LBL_INIT_CTL.IDX when LBL_INIT_CTL.STRUCT_SEL is BSTS_TBL
328 */
329
330__extension__
331typedef union
332{
333 struct
334 {
335#ifndef __BIG_ENDIAN__
336 /* NotifRing currently assigned to this bucket. */
337 uint_reg_t notifring : 8;
338 /* Current reference count. */
339 uint_reg_t count : 16;
340 /* Group associated with this bucket. */
341 uint_reg_t group : 5;
342 /* Mode select for this bucket. */
343 uint_reg_t mode : 3;
344 /* Reserved. */
345 uint_reg_t __reserved : 32;
346#else /* __BIG_ENDIAN__ */
347 uint_reg_t __reserved : 32;
348 uint_reg_t mode : 3;
349 uint_reg_t group : 5;
350 uint_reg_t count : 16;
351 uint_reg_t notifring : 8;
352#endif
353 };
354
355 uint_reg_t word;
356} MPIPE_LBL_INIT_DAT_BSTS_TBL_t;
357#endif /* !defined(__ASSEMBLER__) */
358
359#endif /* !defined(__ARCH_MPIPE_H__) */
diff --git a/arch/tile/include/arch/mpipe_constants.h b/arch/tile/include/arch/mpipe_constants.h
new file mode 100644
index 00000000000..410a0400e05
--- /dev/null
+++ b/arch/tile/include/arch/mpipe_constants.h
@@ -0,0 +1,42 @@
1/*
2 * Copyright 2012 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#ifndef __ARCH_MPIPE_CONSTANTS_H__
17#define __ARCH_MPIPE_CONSTANTS_H__
18
19#define MPIPE_NUM_CLASSIFIERS 10
20#define MPIPE_CLS_MHZ 1200
21
22#define MPIPE_NUM_EDMA_RINGS 32
23
24#define MPIPE_NUM_SGMII_MACS 16
25#define MPIPE_NUM_XAUI_MACS 4
26#define MPIPE_NUM_LOOPBACK_CHANNELS 4
27#define MPIPE_NUM_NON_LB_CHANNELS 28
28
29#define MPIPE_NUM_IPKT_BLOCKS 1536
30
31#define MPIPE_NUM_BUCKETS 4160
32
33#define MPIPE_NUM_NOTIF_RINGS 256
34
35#define MPIPE_NUM_NOTIF_GROUPS 32
36
37#define MPIPE_NUM_TLBS_PER_ASID 16
38#define MPIPE_TLB_IDX_WIDTH 4
39
40#define MPIPE_MMIO_NUM_SVC_DOM 32
41
42#endif /* __ARCH_MPIPE_CONSTANTS_H__ */
diff --git a/arch/tile/include/arch/mpipe_def.h b/arch/tile/include/arch/mpipe_def.h
new file mode 100644
index 00000000000..c3d30217fc6
--- /dev/null
+++ b/arch/tile/include/arch/mpipe_def.h
@@ -0,0 +1,39 @@
1/*
2 * Copyright 2012 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/* Machine-generated file; do not edit. */
16
17#ifndef __ARCH_MPIPE_DEF_H__
18#define __ARCH_MPIPE_DEF_H__
19#define MPIPE_MMIO_ADDR__REGION_SHIFT 26
20#define MPIPE_MMIO_ADDR__REGION_VAL_CFG 0x0
21#define MPIPE_MMIO_ADDR__REGION_VAL_IDMA 0x4
22#define MPIPE_MMIO_ADDR__REGION_VAL_EDMA 0x5
23#define MPIPE_MMIO_ADDR__REGION_VAL_BSM 0x6
24#define MPIPE_BSM_REGION_VAL__VA_SHIFT 7
25#define MPIPE_BSM_INIT_DAT_1__SIZE_VAL_BSZ_128 0x0
26#define MPIPE_BSM_INIT_DAT_1__SIZE_VAL_BSZ_256 0x1
27#define MPIPE_BSM_INIT_DAT_1__SIZE_VAL_BSZ_512 0x2
28#define MPIPE_BSM_INIT_DAT_1__SIZE_VAL_BSZ_1024 0x3
29#define MPIPE_BSM_INIT_DAT_1__SIZE_VAL_BSZ_1664 0x4
30#define MPIPE_BSM_INIT_DAT_1__SIZE_VAL_BSZ_4096 0x5
31#define MPIPE_BSM_INIT_DAT_1__SIZE_VAL_BSZ_10368 0x6
32#define MPIPE_BSM_INIT_DAT_1__SIZE_VAL_BSZ_16384 0x7
33#define MPIPE_LBL_INIT_DAT_BSTS_TBL__MODE_VAL_DFA 0x0
34#define MPIPE_LBL_INIT_DAT_BSTS_TBL__MODE_VAL_FIXED 0x1
35#define MPIPE_LBL_INIT_DAT_BSTS_TBL__MODE_VAL_ALWAYS_PICK 0x2
36#define MPIPE_LBL_INIT_DAT_BSTS_TBL__MODE_VAL_STICKY 0x3
37#define MPIPE_LBL_INIT_DAT_BSTS_TBL__MODE_VAL_STICKY_RAND 0x7
38#define MPIPE_LBL_NR_STATE__FIRST_WORD 0x2138
39#endif /* !defined(__ARCH_MPIPE_DEF_H__) */
diff --git a/arch/tile/include/arch/mpipe_shm.h b/arch/tile/include/arch/mpipe_shm.h
new file mode 100644
index 00000000000..f2e9e122818
--- /dev/null
+++ b/arch/tile/include/arch/mpipe_shm.h
@@ -0,0 +1,509 @@
1/*
2 * Copyright 2012 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/* Machine-generated file; do not edit. */
16
17
18#ifndef __ARCH_MPIPE_SHM_H__
19#define __ARCH_MPIPE_SHM_H__
20
21#include <arch/abi.h>
22#include <arch/mpipe_shm_def.h>
23
24#ifndef __ASSEMBLER__
25/**
26 * MPIPE eDMA Descriptor.
27 * The eDMA descriptor is written by software and consumed by hardware. It
28 * is used to specify the location of egress packet data to be sent out of
29 * the chip via one of the packet interfaces.
30 */
31
32__extension__
33typedef union
34{
35 struct
36 {
37 /* Word 0 */
38
39#ifndef __BIG_ENDIAN__
40 /**
41 * Generation number. Used to indicate a valid descriptor in ring. When
42 * a new descriptor is written into the ring, software must toggle this
43 * bit. The net effect is that the GEN bit being written into new
44 * descriptors toggles each time the ring tail pointer wraps.
45 */
46 uint_reg_t gen : 1;
47 /** Reserved. Must be zero. */
48 uint_reg_t r0 : 7;
49 /** Checksum generation enabled for this transfer. */
50 uint_reg_t csum : 1;
51 /**
52 * Nothing to be sent. Used, for example, when software has dropped a
53 * packet but still wishes to return all of the associated buffers.
54 */
55 uint_reg_t ns : 1;
56 /**
57 * Notification interrupt will be delivered when packet has been egressed.
58 */
59 uint_reg_t notif : 1;
60 /**
61 * Boundary indicator. When 1, this transfer includes the EOP for this
62 * command. Must be clear on all but the last descriptor for an egress
63 * packet.
64 */
65 uint_reg_t bound : 1;
66 /** Reserved. Must be zero. */
67 uint_reg_t r1 : 4;
68 /**
69 * Number of bytes to be sent for this descriptor. When zero, no data
70 * will be moved and the buffer descriptor will be ignored. If the
71 * buffer descriptor indicates that it is chained, the low 7 bits of the
72 * VA indicate the offset within the first buffer (e.g. 127 bytes is the
73 * maximum offset into the first buffer). If the size exceeds a single
74 * buffer, subsequent buffer descriptors will be fetched prior to
75 * processing the next eDMA descriptor in the ring.
76 */
77 uint_reg_t xfer_size : 14;
78 /** Reserved. Must be zero. */
79 uint_reg_t r2 : 2;
80 /**
81 * Destination of checksum relative to CSUM_START relative to the first
82 * byte moved by this descriptor. Must be zero if CSUM=0 in this
83 * descriptor. Must be less than XFER_SIZE (e.g. the first byte of the
84 * CSUM_DEST must be within the span of this descriptor).
85 */
86 uint_reg_t csum_dest : 8;
87 /**
88 * Start byte of checksum relative to the first byte moved by this
89 * descriptor. If this is not the first descriptor for the egress
90 * packet, CSUM_START is still relative to the first byte in this
91 * descriptor. Must be zero if CSUM=0 in this descriptor.
92 */
93 uint_reg_t csum_start : 8;
94 /**
95 * Initial value for 16-bit 1's compliment checksum if enabled via CSUM.
96 * Specified in network order. That is, bits[7:0] will be added to the
97 * byte pointed to by CSUM_START and bits[15:8] will be added to the byte
98 * pointed to by CSUM_START+1 (with appropriate 1's compliment carries).
99 * Must be zero if CSUM=0 in this descriptor.
100 */
101 uint_reg_t csum_seed : 16;
102#else /* __BIG_ENDIAN__ */
103 uint_reg_t csum_seed : 16;
104 uint_reg_t csum_start : 8;
105 uint_reg_t csum_dest : 8;
106 uint_reg_t r2 : 2;
107 uint_reg_t xfer_size : 14;
108 uint_reg_t r1 : 4;
109 uint_reg_t bound : 1;
110 uint_reg_t notif : 1;
111 uint_reg_t ns : 1;
112 uint_reg_t csum : 1;
113 uint_reg_t r0 : 7;
114 uint_reg_t gen : 1;
115#endif
116
117 /* Word 1 */
118
119#ifndef __BIG_ENDIAN__
120 /** Virtual address. Must be sign extended by consumer. */
121 int_reg_t va : 42;
122 /** Reserved. */
123 uint_reg_t __reserved_0 : 6;
124 /** Index of the buffer stack to which this buffer belongs. */
125 uint_reg_t stack_idx : 5;
126 /** Reserved. */
127 uint_reg_t __reserved_1 : 3;
128 /**
129 * Instance ID. For devices that support more than one mPIPE instance,
130 * this field indicates the buffer owner. If the INST field does not
131 * match the mPIPE's instance number when a packet is egressed, buffers
132 * with HWB set will be returned to the other mPIPE instance.
133 */
134 uint_reg_t inst : 1;
135 /** Reserved. */
136 uint_reg_t __reserved_2 : 1;
137 /**
138 * Always set to one by hardware in iDMA packet descriptors. For eDMA,
139 * indicates whether the buffer will be released to the buffer stack
140 * manager. When 0, software is responsible for releasing the buffer.
141 */
142 uint_reg_t hwb : 1;
143 /**
144 * Encoded size of buffer. Set by the ingress hardware for iDMA packet
145 * descriptors. For eDMA descriptors, indicates the buffer size if .c
146 * indicates a chained packet. If an eDMA descriptor is not chained and
147 * the .hwb bit is not set, this field is ignored and the size is
148 * specified by the .xfer_size field.
149 * 0 = 128 bytes
150 * 1 = 256 bytes
151 * 2 = 512 bytes
152 * 3 = 1024 bytes
153 * 4 = 1664 bytes
154 * 5 = 4096 bytes
155 * 6 = 10368 bytes
156 * 7 = 16384 bytes
157 */
158 uint_reg_t size : 3;
159 /**
160 * Chaining configuration for the buffer. Indicates that an ingress
161 * packet or egress command is chained across multiple buffers, with each
162 * buffer's size indicated by the .size field.
163 */
164 uint_reg_t c : 2;
165#else /* __BIG_ENDIAN__ */
166 uint_reg_t c : 2;
167 uint_reg_t size : 3;
168 uint_reg_t hwb : 1;
169 uint_reg_t __reserved_2 : 1;
170 uint_reg_t inst : 1;
171 uint_reg_t __reserved_1 : 3;
172 uint_reg_t stack_idx : 5;
173 uint_reg_t __reserved_0 : 6;
174 int_reg_t va : 42;
175#endif
176
177 };
178
179 /** Word access */
180 uint_reg_t words[2];
181} MPIPE_EDMA_DESC_t;
182
183/**
184 * MPIPE Packet Descriptor.
185 * The packet descriptor is filled by the mPIPE's classification,
186 * load-balancing, and buffer management services. Some fields are consumed
187 * by mPIPE hardware, and others are consumed by Tile software.
188 */
189
190__extension__
191typedef union
192{
193 struct
194 {
195 /* Word 0 */
196
197#ifndef __BIG_ENDIAN__
198 /**
199 * Notification ring into which this packet descriptor is written.
200 * Typically written by load balancer, but can be overridden by
201 * classification program if NR is asserted.
202 */
203 uint_reg_t notif_ring : 8;
204 /** Source channel for this packet. Written by mPIPE DMA hardware. */
205 uint_reg_t channel : 5;
206 /** Reserved. */
207 uint_reg_t __reserved_0 : 1;
208 /**
209 * MAC Error.
210 * Generated by the MAC interface. Asserted if there was an overrun of
211 * the MAC's receive FIFO. This condition generally only occurs if the
212 * mPIPE clock is running too slowly.
213 */
214 uint_reg_t me : 1;
215 /**
216 * Truncation Error.
217 * Written by the iDMA hardware. Asserted if packet was truncated due to
218 * insufficient space in iPkt buffer
219 */
220 uint_reg_t tr : 1;
221 /**
222 * Written by the iDMA hardware. Indicates the number of bytes written
223 * to Tile memory. In general, this is the actual size of the packet as
224 * received from the MAC. But if the packet is truncated due to running
225 * out of buffers or due to the iPkt buffer filling up, then the L2_SIZE
226 * will be reduced to reflect the actual number of valid bytes written to
227 * Tile memory.
228 */
229 uint_reg_t l2_size : 14;
230 /**
231 * CRC Error.
232 * Generated by the MAC. Asserted if MAC indicated an L2 CRC error or
233 * other L2 error (bad length etc.) on the packet.
234 */
235 uint_reg_t ce : 1;
236 /**
237 * Cut Through.
238 * Written by the iDMA hardware. Asserted if packet was not completely
239 * received before being sent to classifier. L2_Size will indicate
240 * number of bytes received so far.
241 */
242 uint_reg_t ct : 1;
243 /**
244 * Written by the classification program. Used by the load balancer to
245 * select the ring into which this packet descriptor is written.
246 */
247 uint_reg_t bucket_id : 13;
248 /** Reserved. */
249 uint_reg_t __reserved_1 : 3;
250 /**
251 * Checksum.
252 * Written by classification program. When 1, the checksum engine will
253 * perform checksum based on the CSUM_SEED, CSUM_START, and CSUM_BYTES
254 * fields. The result will be placed in CSUM_VAL.
255 */
256 uint_reg_t cs : 1;
257 /**
258 * Notification Ring Select.
259 * Written by the classification program. When 1, the NotifRingIDX is
260 * set by classification program rather than being set by load balancer.
261 */
262 uint_reg_t nr : 1;
263 /**
264 * Written by classification program. Indicates whether packet and
265 * descriptor should both be dropped, both be delivered, or only the
266 * descriptor should be delivered.
267 */
268 uint_reg_t dest : 2;
269 /**
270 * General Purpose Sequence Number Enable.
271 * Written by the classification program. When 1, the GP_SQN_SEL field
272 * contains the sequence number selector and the GP_SQN field will be
273 * replaced with the associated sequence number. When clear, the GP_SQN
274 * field is left intact and be used as "Custom" bytes.
275 */
276 uint_reg_t sq : 1;
277 /**
278 * TimeStamp Enable.
279 * Enable TimeStamp insertion. When clear, timestamp field may be filled
280 * with custom data by classifier. When set, hardware inserts the
281 * timestamp when the start of packet is received from the MAC.
282 */
283 uint_reg_t ts : 1;
284 /**
285 * Packet Sequence Number Enable.
286 * Enable PacketSQN insertion. When clear, PacketSQN field may be filled
287 * with custom data by classifier. When set, hardware inserts the packet
288 * sequence number when the packet descriptor is written to a
289 * notification ring.
290 */
291 uint_reg_t ps : 1;
292 /**
293 * Buffer Error.
294 * Written by the iDMA hardware. Asserted if iDMA ran out of buffers
295 * while writing the packet. Software must still return any buffer
296 * descriptors whose C field indicates a valid descriptor was consumed.
297 */
298 uint_reg_t be : 1;
299 /**
300 * Written by the classification program. The associated counter is
301 * incremented when the packet is sent.
302 */
303 uint_reg_t ctr0 : 5;
304 /** Reserved. */
305 uint_reg_t __reserved_2 : 3;
306#else /* __BIG_ENDIAN__ */
307 uint_reg_t __reserved_2 : 3;
308 uint_reg_t ctr0 : 5;
309 uint_reg_t be : 1;
310 uint_reg_t ps : 1;
311 uint_reg_t ts : 1;
312 uint_reg_t sq : 1;
313 uint_reg_t dest : 2;
314 uint_reg_t nr : 1;
315 uint_reg_t cs : 1;
316 uint_reg_t __reserved_1 : 3;
317 uint_reg_t bucket_id : 13;
318 uint_reg_t ct : 1;
319 uint_reg_t ce : 1;
320 uint_reg_t l2_size : 14;
321 uint_reg_t tr : 1;
322 uint_reg_t me : 1;
323 uint_reg_t __reserved_0 : 1;
324 uint_reg_t channel : 5;
325 uint_reg_t notif_ring : 8;
326#endif
327
328 /* Word 1 */
329
330#ifndef __BIG_ENDIAN__
331 /**
332 * Written by the classification program. The associated counter is
333 * incremented when the packet is sent.
334 */
335 uint_reg_t ctr1 : 5;
336 /** Reserved. */
337 uint_reg_t __reserved_3 : 3;
338 /**
339 * Written by classification program. Indicates the start byte for
340 * checksum. Relative to 1st byte received from MAC.
341 */
342 uint_reg_t csum_start : 8;
343 /**
344 * Checksum seed written by classification program. Overwritten with
345 * resultant checksum if CS bit is asserted. The endianness of the CSUM
346 * value bits when viewed by Tile software match the packet byte order.
347 * That is, bits[7:0] of the resulting checksum value correspond to
348 * earlier (more significant) bytes in the packet. To avoid classifier
349 * software from having to byte swap the CSUM_SEED, the iDMA checksum
350 * engine byte swaps the classifier's result before seeding the checksum
351 * calculation. Thus, the CSUM_START byte of packet data is added to
352 * bits[15:8] of the CSUM_SEED field generated by the classifier. This
353 * byte swap will be visible to Tile software if the CS bit is clear.
354 */
355 uint_reg_t csum_seed_val : 16;
356 /**
357 * Written by the classification program. Not interpreted by mPIPE
358 * hardware.
359 */
360 uint_reg_t custom0 : 32;
361#else /* __BIG_ENDIAN__ */
362 uint_reg_t custom0 : 32;
363 uint_reg_t csum_seed_val : 16;
364 uint_reg_t csum_start : 8;
365 uint_reg_t __reserved_3 : 3;
366 uint_reg_t ctr1 : 5;
367#endif
368
369 /* Word 2 */
370
371#ifndef __BIG_ENDIAN__
372 /**
373 * Written by the classification program. Not interpreted by mPIPE
374 * hardware.
375 */
376 uint_reg_t custom1 : 64;
377#else /* __BIG_ENDIAN__ */
378 uint_reg_t custom1 : 64;
379#endif
380
381 /* Word 3 */
382
383#ifndef __BIG_ENDIAN__
384 /**
385 * Written by the classification program. Not interpreted by mPIPE
386 * hardware.
387 */
388 uint_reg_t custom2 : 64;
389#else /* __BIG_ENDIAN__ */
390 uint_reg_t custom2 : 64;
391#endif
392
393 /* Word 4 */
394
395#ifndef __BIG_ENDIAN__
396 /**
397 * Written by the classification program. Not interpreted by mPIPE
398 * hardware.
399 */
400 uint_reg_t custom3 : 64;
401#else /* __BIG_ENDIAN__ */
402 uint_reg_t custom3 : 64;
403#endif
404
405 /* Word 5 */
406
407#ifndef __BIG_ENDIAN__
408 /**
409 * Sequence number applied when packet is distributed. Classifier
410 * selects which sequence number is to be applied by writing the 13-bit
411 * SQN-selector into this field.
412 */
413 uint_reg_t gp_sqn : 16;
414 /**
415 * Written by notification hardware. The packet sequence number is
416 * incremented for each packet that wasn't dropped.
417 */
418 uint_reg_t packet_sqn : 48;
419#else /* __BIG_ENDIAN__ */
420 uint_reg_t packet_sqn : 48;
421 uint_reg_t gp_sqn : 16;
422#endif
423
424 /* Word 6 */
425
426#ifndef __BIG_ENDIAN__
427 /**
428 * Written by hardware when the start-of-packet is received by the mPIPE
429 * from the MAC. This is the nanoseconds part of the packet timestamp.
430 */
431 uint_reg_t time_stamp_ns : 32;
432 /**
433 * Written by hardware when the start-of-packet is received by the mPIPE
434 * from the MAC. This is the seconds part of the packet timestamp.
435 */
436 uint_reg_t time_stamp_sec : 32;
437#else /* __BIG_ENDIAN__ */
438 uint_reg_t time_stamp_sec : 32;
439 uint_reg_t time_stamp_ns : 32;
440#endif
441
442 /* Word 7 */
443
444#ifndef __BIG_ENDIAN__
445 /** Virtual address. Must be sign extended by consumer. */
446 int_reg_t va : 42;
447 /** Reserved. */
448 uint_reg_t __reserved_4 : 6;
449 /** Index of the buffer stack to which this buffer belongs. */
450 uint_reg_t stack_idx : 5;
451 /** Reserved. */
452 uint_reg_t __reserved_5 : 3;
453 /**
454 * Instance ID. For devices that support more than one mPIPE instance,
455 * this field indicates the buffer owner. If the INST field does not
456 * match the mPIPE's instance number when a packet is egressed, buffers
457 * with HWB set will be returned to the other mPIPE instance.
458 */
459 uint_reg_t inst : 1;
460 /** Reserved. */
461 uint_reg_t __reserved_6 : 1;
462 /**
463 * Always set to one by hardware in iDMA packet descriptors. For eDMA,
464 * indicates whether the buffer will be released to the buffer stack
465 * manager. When 0, software is responsible for releasing the buffer.
466 */
467 uint_reg_t hwb : 1;
468 /**
469 * Encoded size of buffer. Set by the ingress hardware for iDMA packet
470 * descriptors. For eDMA descriptors, indicates the buffer size if .c
471 * indicates a chained packet. If an eDMA descriptor is not chained and
472 * the .hwb bit is not set, this field is ignored and the size is
473 * specified by the .xfer_size field.
474 * 0 = 128 bytes
475 * 1 = 256 bytes
476 * 2 = 512 bytes
477 * 3 = 1024 bytes
478 * 4 = 1664 bytes
479 * 5 = 4096 bytes
480 * 6 = 10368 bytes
481 * 7 = 16384 bytes
482 */
483 uint_reg_t size : 3;
484 /**
485 * Chaining configuration for the buffer. Indicates that an ingress
486 * packet or egress command is chained across multiple buffers, with each
487 * buffer's size indicated by the .size field.
488 */
489 uint_reg_t c : 2;
490#else /* __BIG_ENDIAN__ */
491 uint_reg_t c : 2;
492 uint_reg_t size : 3;
493 uint_reg_t hwb : 1;
494 uint_reg_t __reserved_6 : 1;
495 uint_reg_t inst : 1;
496 uint_reg_t __reserved_5 : 3;
497 uint_reg_t stack_idx : 5;
498 uint_reg_t __reserved_4 : 6;
499 int_reg_t va : 42;
500#endif
501
502 };
503
504 /** Word access */
505 uint_reg_t words[8];
506} MPIPE_PDESC_t;
507#endif /* !defined(__ASSEMBLER__) */
508
509#endif /* !defined(__ARCH_MPIPE_SHM_H__) */
diff --git a/arch/tile/include/arch/mpipe_shm_def.h b/arch/tile/include/arch/mpipe_shm_def.h
new file mode 100644
index 00000000000..6124d39c831
--- /dev/null
+++ b/arch/tile/include/arch/mpipe_shm_def.h
@@ -0,0 +1,23 @@
1/*
2 * Copyright 2012 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/* Machine-generated file; do not edit. */
16
17#ifndef __ARCH_MPIPE_SHM_DEF_H__
18#define __ARCH_MPIPE_SHM_DEF_H__
19#define MPIPE_EDMA_DESC_WORD1__C_VAL_UNCHAINED 0x0
20#define MPIPE_EDMA_DESC_WORD1__C_VAL_CHAINED 0x1
21#define MPIPE_EDMA_DESC_WORD1__C_VAL_NOT_RDY 0x2
22#define MPIPE_EDMA_DESC_WORD1__C_VAL_INVALID 0x3
23#endif /* !defined(__ARCH_MPIPE_SHM_DEF_H__) */
diff --git a/arch/tile/include/arch/trio.h b/arch/tile/include/arch/trio.h
new file mode 100644
index 00000000000..d3000a871a2
--- /dev/null
+++ b/arch/tile/include/arch/trio.h
@@ -0,0 +1,72 @@
1/*
2 * Copyright 2012 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/* Machine-generated file; do not edit. */
16
17#ifndef __ARCH_TRIO_H__
18#define __ARCH_TRIO_H__
19
20#include <arch/abi.h>
21#include <arch/trio_def.h>
22
23#ifndef __ASSEMBLER__
24
25/*
26 * Tile PIO Region Configuration - CFG Address Format.
27 * This register describes the address format for PIO accesses when the
28 * associated region is setup with TYPE=CFG.
29 */
30
31__extension__
32typedef union
33{
34 struct
35 {
36#ifndef __BIG_ENDIAN__
37 /* Register Address (full byte address). */
38 uint_reg_t reg_addr : 12;
39 /* Function Number */
40 uint_reg_t fn : 3;
41 /* Device Number */
42 uint_reg_t dev : 5;
43 /* BUS Number */
44 uint_reg_t bus : 8;
45 /* Config Type: 0 for access to directly-attached device. 1 otherwise. */
46 uint_reg_t type : 1;
47 /* Reserved. */
48 uint_reg_t __reserved_0 : 1;
49 /*
50 * MAC select. This must match the configuration in
51 * TILE_PIO_REGION_SETUP.MAC.
52 */
53 uint_reg_t mac : 2;
54 /* Reserved. */
55 uint_reg_t __reserved_1 : 32;
56#else /* __BIG_ENDIAN__ */
57 uint_reg_t __reserved_1 : 32;
58 uint_reg_t mac : 2;
59 uint_reg_t __reserved_0 : 1;
60 uint_reg_t type : 1;
61 uint_reg_t bus : 8;
62 uint_reg_t dev : 5;
63 uint_reg_t fn : 3;
64 uint_reg_t reg_addr : 12;
65#endif
66 };
67
68 uint_reg_t word;
69} TRIO_TILE_PIO_REGION_SETUP_CFG_ADDR_t;
70#endif /* !defined(__ASSEMBLER__) */
71
72#endif /* !defined(__ARCH_TRIO_H__) */
diff --git a/arch/tile/include/arch/trio_constants.h b/arch/tile/include/arch/trio_constants.h
new file mode 100644
index 00000000000..628b045436b
--- /dev/null
+++ b/arch/tile/include/arch/trio_constants.h
@@ -0,0 +1,36 @@
1/*
2 * Copyright 2012 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#ifndef __ARCH_TRIO_CONSTANTS_H__
17#define __ARCH_TRIO_CONSTANTS_H__
18
19#define TRIO_NUM_ASIDS 16
20#define TRIO_NUM_TLBS_PER_ASID 16
21
22#define TRIO_NUM_TPIO_REGIONS 8
23#define TRIO_LOG2_NUM_TPIO_REGIONS 3
24
25#define TRIO_NUM_MAP_MEM_REGIONS 16
26#define TRIO_LOG2_NUM_MAP_MEM_REGIONS 4
27#define TRIO_NUM_MAP_SQ_REGIONS 8
28#define TRIO_LOG2_NUM_MAP_SQ_REGIONS 3
29
30#define TRIO_LOG2_NUM_SQ_FIFO_ENTRIES 6
31
32#define TRIO_NUM_PUSH_DMA_RINGS 32
33
34#define TRIO_NUM_PULL_DMA_RINGS 32
35
36#endif /* __ARCH_TRIO_CONSTANTS_H__ */
diff --git a/arch/tile/include/arch/trio_def.h b/arch/tile/include/arch/trio_def.h
new file mode 100644
index 00000000000..e80500317dc
--- /dev/null
+++ b/arch/tile/include/arch/trio_def.h
@@ -0,0 +1,41 @@
1/*
2 * Copyright 2012 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/* Machine-generated file; do not edit. */
16
17#ifndef __ARCH_TRIO_DEF_H__
18#define __ARCH_TRIO_DEF_H__
19#define TRIO_CFG_REGION_ADDR__REG_SHIFT 0
20#define TRIO_CFG_REGION_ADDR__INTFC_SHIFT 16
21#define TRIO_CFG_REGION_ADDR__INTFC_VAL_TRIO 0x0
22#define TRIO_CFG_REGION_ADDR__INTFC_VAL_MAC_INTERFACE 0x1
23#define TRIO_CFG_REGION_ADDR__INTFC_VAL_MAC_STANDARD 0x2
24#define TRIO_CFG_REGION_ADDR__INTFC_VAL_MAC_PROTECTED 0x3
25#define TRIO_CFG_REGION_ADDR__MAC_SEL_SHIFT 18
26#define TRIO_CFG_REGION_ADDR__PROT_SHIFT 20
27#define TRIO_PIO_REGIONS_ADDR__REGION_SHIFT 32
28#define TRIO_MAP_MEM_REG_INT0 0x1000000000
29#define TRIO_MAP_MEM_REG_INT1 0x1000000008
30#define TRIO_MAP_MEM_REG_INT2 0x1000000010
31#define TRIO_MAP_MEM_REG_INT3 0x1000000018
32#define TRIO_MAP_MEM_REG_INT4 0x1000000020
33#define TRIO_MAP_MEM_REG_INT5 0x1000000028
34#define TRIO_MAP_MEM_REG_INT6 0x1000000030
35#define TRIO_MAP_MEM_REG_INT7 0x1000000038
36#define TRIO_MAP_MEM_LIM__ADDR_SHIFT 12
37#define TRIO_MAP_MEM_SETUP__ORDER_MODE_VAL_UNORDERED 0x0
38#define TRIO_MAP_MEM_SETUP__ORDER_MODE_VAL_STRICT 0x1
39#define TRIO_MAP_MEM_SETUP__ORDER_MODE_VAL_REL_ORD 0x2
40#define TRIO_TILE_PIO_REGION_SETUP_CFG_ADDR__MAC_SHIFT 30
41#endif /* !defined(__ARCH_TRIO_DEF_H__) */
diff --git a/arch/tile/include/arch/trio_pcie_intfc.h b/arch/tile/include/arch/trio_pcie_intfc.h
new file mode 100644
index 00000000000..0487fdb9d58
--- /dev/null
+++ b/arch/tile/include/arch/trio_pcie_intfc.h
@@ -0,0 +1,229 @@
1/*
2 * Copyright 2012 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/* Machine-generated file; do not edit. */
16
17#ifndef __ARCH_TRIO_PCIE_INTFC_H__
18#define __ARCH_TRIO_PCIE_INTFC_H__
19
20#include <arch/abi.h>
21#include <arch/trio_pcie_intfc_def.h>
22
23#ifndef __ASSEMBLER__
24
25/*
26 * Port Configuration.
27 * Configuration of the PCIe Port
28 */
29
30__extension__
31typedef union
32{
33 struct
34 {
35#ifndef __BIG_ENDIAN__
36 /* Provides the state of the strapping pins for this port. */
37 uint_reg_t strap_state : 3;
38 /* Reserved. */
39 uint_reg_t __reserved_0 : 1;
40 /*
41 * When 1, the device type will be overridden using OVD_DEV_TYPE_VAL.
42 * When 0, the device type is determined based on the STRAP_STATE.
43 */
44 uint_reg_t ovd_dev_type : 1;
45 /* Provides the device type when OVD_DEV_TYPE is 1. */
46 uint_reg_t ovd_dev_type_val : 4;
47 /* Determines how link is trained. */
48 uint_reg_t train_mode : 2;
49 /* Reserved. */
50 uint_reg_t __reserved_1 : 1;
51 /*
52 * For PCIe, used to flip physical RX lanes that were not properly wired.
53 * This is not the same as lane reversal which is handled automatically
54 * during link training. When 0, RX Lane0 must be wired to the link
55 * partner (either to its Lane0 or it's LaneN). When RX_LANE_FLIP is 1,
56 * the highest numbered lane for this port becomes Lane0 and Lane0 does
57 * NOT have to be wired to the link partner.
58 */
59 uint_reg_t rx_lane_flip : 1;
60 /*
61 * For PCIe, used to flip physical TX lanes that were not properly wired.
62 * This is not the same as lane reversal which is handled automatically
63 * during link training. When 0, TX Lane0 must be wired to the link
64 * partner (either to its Lane0 or it's LaneN). When TX_LANE_FLIP is 1,
65 * the highest numbered lane for this port becomes Lane0 and Lane0 does
66 * NOT have to be wired to the link partner.
67 */
68 uint_reg_t tx_lane_flip : 1;
69 /*
70 * For StreamIO port, configures the width of the port when TRAIN_MODE is
71 * not STRAP.
72 */
73 uint_reg_t stream_width : 2;
74 /*
75 * For StreamIO port, configures the rate of the port when TRAIN_MODE is
76 * not STRAP.
77 */
78 uint_reg_t stream_rate : 2;
79 /* Reserved. */
80 uint_reg_t __reserved_2 : 46;
81#else /* __BIG_ENDIAN__ */
82 uint_reg_t __reserved_2 : 46;
83 uint_reg_t stream_rate : 2;
84 uint_reg_t stream_width : 2;
85 uint_reg_t tx_lane_flip : 1;
86 uint_reg_t rx_lane_flip : 1;
87 uint_reg_t __reserved_1 : 1;
88 uint_reg_t train_mode : 2;
89 uint_reg_t ovd_dev_type_val : 4;
90 uint_reg_t ovd_dev_type : 1;
91 uint_reg_t __reserved_0 : 1;
92 uint_reg_t strap_state : 3;
93#endif
94 };
95
96 uint_reg_t word;
97} TRIO_PCIE_INTFC_PORT_CONFIG_t;
98
99/*
100 * Port Status.
101 * Status of the PCIe Port. This register applies to the StreamIO port when
102 * StreamIO is enabled.
103 */
104
105__extension__
106typedef union
107{
108 struct
109 {
110#ifndef __BIG_ENDIAN__
111 /*
112 * Indicates the DL state of the port. When 1, the port is up and ready
113 * to receive traffic.
114 */
115 uint_reg_t dl_up : 1;
116 /*
117 * Indicates the number of times the link has gone down. Clears on read.
118 */
119 uint_reg_t dl_down_cnt : 7;
120 /* Indicates the SERDES PLL has spun up and is providing a valid clock. */
121 uint_reg_t clock_ready : 1;
122 /* Reserved. */
123 uint_reg_t __reserved_0 : 7;
124 /* Device revision ID. */
125 uint_reg_t device_rev : 8;
126 /* Link state (PCIe). */
127 uint_reg_t ltssm_state : 6;
128 /* Link power management state (PCIe). */
129 uint_reg_t pm_state : 3;
130 /* Reserved. */
131 uint_reg_t __reserved_1 : 31;
132#else /* __BIG_ENDIAN__ */
133 uint_reg_t __reserved_1 : 31;
134 uint_reg_t pm_state : 3;
135 uint_reg_t ltssm_state : 6;
136 uint_reg_t device_rev : 8;
137 uint_reg_t __reserved_0 : 7;
138 uint_reg_t clock_ready : 1;
139 uint_reg_t dl_down_cnt : 7;
140 uint_reg_t dl_up : 1;
141#endif
142 };
143
144 uint_reg_t word;
145} TRIO_PCIE_INTFC_PORT_STATUS_t;
146
147/*
148 * Transmit FIFO Control.
149 * Contains TX FIFO thresholds. These registers are for diagnostics purposes
150 * only. Changing these values causes undefined behavior.
151 */
152
153__extension__
154typedef union
155{
156 struct
157 {
158#ifndef __BIG_ENDIAN__
159 /*
160 * Almost-Empty level for TX0 data. Typically set to at least
161 * roundup(38.0*M/N) where N=tclk frequency and M=MAC symbol rate in MHz
162 * for a x4 port (250MHz).
163 */
164 uint_reg_t tx0_data_ae_lvl : 7;
165 /* Reserved. */
166 uint_reg_t __reserved_0 : 1;
167 /* Almost-Empty level for TX1 data. */
168 uint_reg_t tx1_data_ae_lvl : 7;
169 /* Reserved. */
170 uint_reg_t __reserved_1 : 1;
171 /* Almost-Full level for TX0 data. */
172 uint_reg_t tx0_data_af_lvl : 7;
173 /* Reserved. */
174 uint_reg_t __reserved_2 : 1;
175 /* Almost-Full level for TX1 data. */
176 uint_reg_t tx1_data_af_lvl : 7;
177 /* Reserved. */
178 uint_reg_t __reserved_3 : 1;
179 /* Almost-Full level for TX0 info. */
180 uint_reg_t tx0_info_af_lvl : 5;
181 /* Reserved. */
182 uint_reg_t __reserved_4 : 3;
183 /* Almost-Full level for TX1 info. */
184 uint_reg_t tx1_info_af_lvl : 5;
185 /* Reserved. */
186 uint_reg_t __reserved_5 : 3;
187 /*
188 * This register provides performance adjustment for high bandwidth
189 * flows. The MAC will assert almost-full to TRIO if non-posted credits
190 * fall below this level. Note that setting this larger than the initial
191 * PORT_CREDIT.NPH value will cause READS to never be sent. If the
192 * initial credit value from the link partner is smaller than this value
193 * when the link comes up, the value will be reset to the initial credit
194 * value to prevent lockup.
195 */
196 uint_reg_t min_np_credits : 8;
197 /*
198 * This register provides performance adjustment for high bandwidth
199 * flows. The MAC will assert almost-full to TRIO if posted credits fall
200 * below this level. Note that setting this larger than the initial
201 * PORT_CREDIT.PH value will cause WRITES to never be sent. If the
202 * initial credit value from the link partner is smaller than this value
203 * when the link comes up, the value will be reset to the initial credit
204 * value to prevent lockup.
205 */
206 uint_reg_t min_p_credits : 8;
207#else /* __BIG_ENDIAN__ */
208 uint_reg_t min_p_credits : 8;
209 uint_reg_t min_np_credits : 8;
210 uint_reg_t __reserved_5 : 3;
211 uint_reg_t tx1_info_af_lvl : 5;
212 uint_reg_t __reserved_4 : 3;
213 uint_reg_t tx0_info_af_lvl : 5;
214 uint_reg_t __reserved_3 : 1;
215 uint_reg_t tx1_data_af_lvl : 7;
216 uint_reg_t __reserved_2 : 1;
217 uint_reg_t tx0_data_af_lvl : 7;
218 uint_reg_t __reserved_1 : 1;
219 uint_reg_t tx1_data_ae_lvl : 7;
220 uint_reg_t __reserved_0 : 1;
221 uint_reg_t tx0_data_ae_lvl : 7;
222#endif
223 };
224
225 uint_reg_t word;
226} TRIO_PCIE_INTFC_TX_FIFO_CTL_t;
227#endif /* !defined(__ASSEMBLER__) */
228
229#endif /* !defined(__ARCH_TRIO_PCIE_INTFC_H__) */
diff --git a/arch/tile/include/arch/trio_pcie_intfc_def.h b/arch/tile/include/arch/trio_pcie_intfc_def.h
new file mode 100644
index 00000000000..d3fd6781fb2
--- /dev/null
+++ b/arch/tile/include/arch/trio_pcie_intfc_def.h
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2012 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/* Machine-generated file; do not edit. */
16
17#ifndef __ARCH_TRIO_PCIE_INTFC_DEF_H__
18#define __ARCH_TRIO_PCIE_INTFC_DEF_H__
19#define TRIO_PCIE_INTFC_MAC_INT_STS 0x0000
20#define TRIO_PCIE_INTFC_MAC_INT_STS__INT_LEVEL_MASK 0xf000
21#define TRIO_PCIE_INTFC_PORT_CONFIG 0x0018
22#define TRIO_PCIE_INTFC_PORT_CONFIG__STRAP_STATE_VAL_DISABLED 0x0
23#define TRIO_PCIE_INTFC_PORT_CONFIG__STRAP_STATE_VAL_AUTO_CONFIG_ENDPOINT 0x1
24#define TRIO_PCIE_INTFC_PORT_CONFIG__STRAP_STATE_VAL_AUTO_CONFIG_RC 0x2
25#define TRIO_PCIE_INTFC_PORT_CONFIG__STRAP_STATE_VAL_AUTO_CONFIG_ENDPOINT_G1 0x3
26#define TRIO_PCIE_INTFC_PORT_CONFIG__STRAP_STATE_VAL_AUTO_CONFIG_RC_G1 0x4
27#define TRIO_PCIE_INTFC_PORT_CONFIG__STRAP_STATE_VAL_AUTO_XLINK 0x5
28#define TRIO_PCIE_INTFC_PORT_CONFIG__STRAP_STATE_VAL_STREAM_X1 0x6
29#define TRIO_PCIE_INTFC_PORT_CONFIG__STRAP_STATE_VAL_STREAM_X4 0x7
30#define TRIO_PCIE_INTFC_PORT_STATUS 0x0020
31#define TRIO_PCIE_INTFC_TX_FIFO_CTL 0x0050
32#endif /* !defined(__ARCH_TRIO_PCIE_INTFC_DEF_H__) */
diff --git a/arch/tile/include/arch/trio_pcie_rc.h b/arch/tile/include/arch/trio_pcie_rc.h
new file mode 100644
index 00000000000..6a25d0aca85
--- /dev/null
+++ b/arch/tile/include/arch/trio_pcie_rc.h
@@ -0,0 +1,156 @@
1/*
2 * Copyright 2012 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/* Machine-generated file; do not edit. */
16
17#ifndef __ARCH_TRIO_PCIE_RC_H__
18#define __ARCH_TRIO_PCIE_RC_H__
19
20#include <arch/abi.h>
21#include <arch/trio_pcie_rc_def.h>
22
23#ifndef __ASSEMBLER__
24
25/* Device Capabilities Register. */
26
27__extension__
28typedef union
29{
30 struct
31 {
32#ifndef __BIG_ENDIAN__
33 /*
34 * Max_Payload_Size Supported, writablethrough the MAC_STANDARD interface
35 */
36 uint_reg_t mps_sup : 3;
37 /*
38 * This field is writable through the MAC_STANDARD interface. However,
39 * Phantom Function is not supported. Therefore, the application must
40 * not write any value other than 0x0 to this field.
41 */
42 uint_reg_t phantom_function_supported : 2;
43 /* This bit is writable through the MAC_STANDARD interface. */
44 uint_reg_t ext_tag_field_supported : 1;
45 /* Reserved. */
46 uint_reg_t __reserved_0 : 3;
47 /* Endpoint L1 Acceptable Latency Must be 0x0 for non-Endpoint devices. */
48 uint_reg_t l1_lat : 3;
49 /*
50 * Undefined since PCI Express 1.1 (Was Attention Button Present for PCI
51 * Express 1.0a)
52 */
53 uint_reg_t r1 : 1;
54 /*
55 * Undefined since PCI Express 1.1 (Was Attention Indicator Present for
56 * PCI Express 1.0a)
57 */
58 uint_reg_t r2 : 1;
59 /*
60 * Undefined since PCI Express 1.1 (Was Power Indicator Present for PCI
61 * Express 1.0a)
62 */
63 uint_reg_t r3 : 1;
64 /*
65 * Role-Based Error Reporting, writable through the MAC_STANDARD
66 * interface. Required to be set for device compliant to 1.1 spec and
67 * later.
68 */
69 uint_reg_t rer : 1;
70 /* Reserved. */
71 uint_reg_t __reserved_1 : 2;
72 /* Captured Slot Power Limit Value Upstream port only. */
73 uint_reg_t slot_pwr_lim : 8;
74 /* Captured Slot Power Limit Scale Upstream port only. */
75 uint_reg_t slot_pwr_scale : 2;
76 /* Reserved. */
77 uint_reg_t __reserved_2 : 4;
78 /* Endpoint L0s Acceptable LatencyMust be 0x0 for non-Endpoint devices. */
79 uint_reg_t l0s_lat : 1;
80 /* Reserved. */
81 uint_reg_t __reserved_3 : 31;
82#else /* __BIG_ENDIAN__ */
83 uint_reg_t __reserved_3 : 31;
84 uint_reg_t l0s_lat : 1;
85 uint_reg_t __reserved_2 : 4;
86 uint_reg_t slot_pwr_scale : 2;
87 uint_reg_t slot_pwr_lim : 8;
88 uint_reg_t __reserved_1 : 2;
89 uint_reg_t rer : 1;
90 uint_reg_t r3 : 1;
91 uint_reg_t r2 : 1;
92 uint_reg_t r1 : 1;
93 uint_reg_t l1_lat : 3;
94 uint_reg_t __reserved_0 : 3;
95 uint_reg_t ext_tag_field_supported : 1;
96 uint_reg_t phantom_function_supported : 2;
97 uint_reg_t mps_sup : 3;
98#endif
99 };
100
101 uint_reg_t word;
102} TRIO_PCIE_RC_DEVICE_CAP_t;
103
104/* Device Control Register. */
105
106__extension__
107typedef union
108{
109 struct
110 {
111#ifndef __BIG_ENDIAN__
112 /* Correctable Error Reporting Enable */
113 uint_reg_t cor_err_ena : 1;
114 /* Non-Fatal Error Reporting Enable */
115 uint_reg_t nf_err_ena : 1;
116 /* Fatal Error Reporting Enable */
117 uint_reg_t fatal_err_ena : 1;
118 /* Unsupported Request Reporting Enable */
119 uint_reg_t ur_ena : 1;
120 /* Relaxed orderring enable */
121 uint_reg_t ro_ena : 1;
122 /* Max Payload Size */
123 uint_reg_t max_payload_size : 3;
124 /* Extended Tag Field Enable */
125 uint_reg_t ext_tag : 1;
126 /* Phantom Function Enable */
127 uint_reg_t ph_fn_ena : 1;
128 /* AUX Power PM Enable */
129 uint_reg_t aux_pm_ena : 1;
130 /* Enable NoSnoop */
131 uint_reg_t no_snoop : 1;
132 /* Max read request size */
133 uint_reg_t max_read_req_sz : 3;
134 /* Reserved. */
135 uint_reg_t __reserved : 49;
136#else /* __BIG_ENDIAN__ */
137 uint_reg_t __reserved : 49;
138 uint_reg_t max_read_req_sz : 3;
139 uint_reg_t no_snoop : 1;
140 uint_reg_t aux_pm_ena : 1;
141 uint_reg_t ph_fn_ena : 1;
142 uint_reg_t ext_tag : 1;
143 uint_reg_t max_payload_size : 3;
144 uint_reg_t ro_ena : 1;
145 uint_reg_t ur_ena : 1;
146 uint_reg_t fatal_err_ena : 1;
147 uint_reg_t nf_err_ena : 1;
148 uint_reg_t cor_err_ena : 1;
149#endif
150 };
151
152 uint_reg_t word;
153} TRIO_PCIE_RC_DEVICE_CONTROL_t;
154#endif /* !defined(__ASSEMBLER__) */
155
156#endif /* !defined(__ARCH_TRIO_PCIE_RC_H__) */
diff --git a/arch/tile/include/arch/trio_pcie_rc_def.h b/arch/tile/include/arch/trio_pcie_rc_def.h
new file mode 100644
index 00000000000..74081a65b6f
--- /dev/null
+++ b/arch/tile/include/arch/trio_pcie_rc_def.h
@@ -0,0 +1,24 @@
1/*
2 * Copyright 2012 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/* Machine-generated file; do not edit. */
16
17#ifndef __ARCH_TRIO_PCIE_RC_DEF_H__
18#define __ARCH_TRIO_PCIE_RC_DEF_H__
19#define TRIO_PCIE_RC_DEVICE_CAP 0x0074
20#define TRIO_PCIE_RC_DEVICE_CONTROL 0x0078
21#define TRIO_PCIE_RC_DEVICE_ID_VEN_ID 0x0000
22#define TRIO_PCIE_RC_DEVICE_ID_VEN_ID__DEV_ID_SHIFT 16
23#define TRIO_PCIE_RC_REVISION_ID 0x0008
24#endif /* !defined(__ARCH_TRIO_PCIE_RC_DEF_H__) */
diff --git a/arch/tile/include/arch/trio_shm.h b/arch/tile/include/arch/trio_shm.h
new file mode 100644
index 00000000000..3382e38245a
--- /dev/null
+++ b/arch/tile/include/arch/trio_shm.h
@@ -0,0 +1,125 @@
1/*
2 * Copyright 2012 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/* Machine-generated file; do not edit. */
16
17
18#ifndef __ARCH_TRIO_SHM_H__
19#define __ARCH_TRIO_SHM_H__
20
21#include <arch/abi.h>
22#include <arch/trio_shm_def.h>
23
24#ifndef __ASSEMBLER__
25/**
26 * TRIO DMA Descriptor.
27 * The TRIO DMA descriptor is written by software and consumed by hardware.
28 * It is used to specify the location of transaction data in the IO and Tile
29 * domains.
30 */
31
32__extension__
33typedef union
34{
35 struct
36 {
37 /* Word 0 */
38
39#ifndef __BIG_ENDIAN__
40 /** Tile side virtual address. */
41 int_reg_t va : 42;
42 /**
43 * Encoded size of buffer used on push DMA when C=1:
44 * 0 = 128 bytes
45 * 1 = 256 bytes
46 * 2 = 512 bytes
47 * 3 = 1024 bytes
48 * 4 = 1664 bytes
49 * 5 = 4096 bytes
50 * 6 = 10368 bytes
51 * 7 = 16384 bytes
52 */
53 uint_reg_t bsz : 3;
54 /**
55 * Chaining designation. Always zero for pull DMA
56 * 0 : Unchained buffer pointer
57 * 1 : Chained buffer pointer. Next buffer descriptor (e.g. VA) stored
58 * in 1st 8-bytes in buffer. For chained buffers, first 8-bytes of each
59 * buffer contain the next buffer descriptor formatted exactly like a PDE
60 * buffer descriptor. This allows a chained PDE buffer to be sent using
61 * push DMA.
62 */
63 uint_reg_t c : 1;
64 /**
65 * Notification interrupt will be delivered when the transaction has
66 * completed (all data has been read from or written to the Tile-side
67 * buffer).
68 */
69 uint_reg_t notif : 1;
70 /**
71 * When 0, the XSIZE field specifies the total byte count for the
72 * transaction. When 1, the XSIZE field is encoded as 2^(N+14) for N in
73 * {0..6}:
74 * 0 = 16KB
75 * 1 = 32KB
76 * 2 = 64KB
77 * 3 = 128KB
78 * 4 = 256KB
79 * 5 = 512KB
80 * 6 = 1MB
81 * All other encodings of the XSIZE field are reserved when SMOD=1
82 */
83 uint_reg_t smod : 1;
84 /**
85 * Total number of bytes to move for this transaction. When SMOD=1,
86 * this field is encoded - see SMOD description.
87 */
88 uint_reg_t xsize : 14;
89 /** Reserved. */
90 uint_reg_t __reserved_0 : 1;
91 /**
92 * Generation number. Used to indicate a valid descriptor in ring. When
93 * a new descriptor is written into the ring, software must toggle this
94 * bit. The net effect is that the GEN bit being written into new
95 * descriptors toggles each time the ring tail pointer wraps.
96 */
97 uint_reg_t gen : 1;
98#else /* __BIG_ENDIAN__ */
99 uint_reg_t gen : 1;
100 uint_reg_t __reserved_0 : 1;
101 uint_reg_t xsize : 14;
102 uint_reg_t smod : 1;
103 uint_reg_t notif : 1;
104 uint_reg_t c : 1;
105 uint_reg_t bsz : 3;
106 int_reg_t va : 42;
107#endif
108
109 /* Word 1 */
110
111#ifndef __BIG_ENDIAN__
112 /** IO-side address */
113 uint_reg_t io_address : 64;
114#else /* __BIG_ENDIAN__ */
115 uint_reg_t io_address : 64;
116#endif
117
118 };
119
120 /** Word access */
121 uint_reg_t words[2];
122} TRIO_DMA_DESC_t;
123#endif /* !defined(__ASSEMBLER__) */
124
125#endif /* !defined(__ARCH_TRIO_SHM_H__) */
diff --git a/arch/tile/include/arch/trio_shm_def.h b/arch/tile/include/arch/trio_shm_def.h
new file mode 100644
index 00000000000..72a59c88b06
--- /dev/null
+++ b/arch/tile/include/arch/trio_shm_def.h
@@ -0,0 +1,19 @@
1/*
2 * Copyright 2012 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/* Machine-generated file; do not edit. */
16
17#ifndef __ARCH_TRIO_SHM_DEF_H__
18#define __ARCH_TRIO_SHM_DEF_H__
19#endif /* !defined(__ARCH_TRIO_SHM_DEF_H__) */
diff --git a/arch/tile/include/arch/usb_host.h b/arch/tile/include/arch/usb_host.h
new file mode 100644
index 00000000000..d09f3268396
--- /dev/null
+++ b/arch/tile/include/arch/usb_host.h
@@ -0,0 +1,26 @@
1/*
2 * Copyright 2012 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/* Machine-generated file; do not edit. */
16
17#ifndef __ARCH_USB_HOST_H__
18#define __ARCH_USB_HOST_H__
19
20#include <arch/abi.h>
21#include <arch/usb_host_def.h>
22
23#ifndef __ASSEMBLER__
24#endif /* !defined(__ASSEMBLER__) */
25
26#endif /* !defined(__ARCH_USB_HOST_H__) */
diff --git a/arch/tile/include/arch/usb_host_def.h b/arch/tile/include/arch/usb_host_def.h
new file mode 100644
index 00000000000..aeed7753e8e
--- /dev/null
+++ b/arch/tile/include/arch/usb_host_def.h
@@ -0,0 +1,19 @@
1/*
2 * Copyright 2012 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/* Machine-generated file; do not edit. */
16
17#ifndef __ARCH_USB_HOST_DEF_H__
18#define __ARCH_USB_HOST_DEF_H__
19#endif /* !defined(__ARCH_USB_HOST_DEF_H__) */
diff --git a/arch/tile/include/asm/Kbuild b/arch/tile/include/asm/Kbuild
index 143473e3a0b..5bd71994452 100644
--- a/arch/tile/include/asm/Kbuild
+++ b/arch/tile/include/asm/Kbuild
@@ -9,7 +9,6 @@ header-y += hardwall.h
9generic-y += bug.h 9generic-y += bug.h
10generic-y += bugs.h 10generic-y += bugs.h
11generic-y += cputime.h 11generic-y += cputime.h
12generic-y += device.h
13generic-y += div64.h 12generic-y += div64.h
14generic-y += emergency-restart.h 13generic-y += emergency-restart.h
15generic-y += errno.h 14generic-y += errno.h
@@ -17,7 +16,6 @@ generic-y += fb.h
17generic-y += fcntl.h 16generic-y += fcntl.h
18generic-y += ioctl.h 17generic-y += ioctl.h
19generic-y += ioctls.h 18generic-y += ioctls.h
20generic-y += ipc.h
21generic-y += ipcbuf.h 19generic-y += ipcbuf.h
22generic-y += irq_regs.h 20generic-y += irq_regs.h
23generic-y += kdebug.h 21generic-y += kdebug.h
diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
index 392e5333dd8..a9a529964e0 100644
--- a/arch/tile/include/asm/cache.h
+++ b/arch/tile/include/asm/cache.h
@@ -27,11 +27,17 @@
27#define L2_CACHE_ALIGN(x) (((x)+(L2_CACHE_BYTES-1)) & -L2_CACHE_BYTES) 27#define L2_CACHE_ALIGN(x) (((x)+(L2_CACHE_BYTES-1)) & -L2_CACHE_BYTES)
28 28
29/* 29/*
30 * TILE-Gx is fully coherent so we don't need to define ARCH_DMA_MINALIGN. 30 * TILEPro I/O is not always coherent (networking typically uses coherent
31 * I/O, but PCI traffic does not) and setting ARCH_DMA_MINALIGN to the
32 * L2 cacheline size helps ensure that kernel heap allocations are aligned.
33 * TILE-Gx I/O is always coherent when used on hash-for-home pages.
34 *
35 * However, it's possible at runtime to request not to use hash-for-home
36 * for the kernel heap, in which case the kernel will use flush-and-inval
37 * to manage coherence. As a result, we use L2_CACHE_BYTES for the
38 * DMA minimum alignment to avoid false sharing in the kernel heap.
31 */ 39 */
32#ifndef __tilegx__
33#define ARCH_DMA_MINALIGN L2_CACHE_BYTES 40#define ARCH_DMA_MINALIGN L2_CACHE_BYTES
34#endif
35 41
36/* use the cache line size for the L2, which is where it counts */ 42/* use the cache line size for the L2, which is where it counts */
37#define SMP_CACHE_BYTES_SHIFT L2_CACHE_SHIFT 43#define SMP_CACHE_BYTES_SHIFT L2_CACHE_SHIFT
diff --git a/arch/tile/include/asm/checksum.h b/arch/tile/include/asm/checksum.h
index a120766c726..b21a2fdec9f 100644
--- a/arch/tile/include/asm/checksum.h
+++ b/arch/tile/include/asm/checksum.h
@@ -21,4 +21,22 @@
21__wsum do_csum(const unsigned char *buff, int len); 21__wsum do_csum(const unsigned char *buff, int len);
22#define do_csum do_csum 22#define do_csum do_csum
23 23
24/*
25 * Return the sum of all the 16-bit subwords in a long.
26 * This sums two subwords on a 32-bit machine, and four on 64 bits.
27 * The implementation does two vector adds to capture any overflow.
28 */
29static inline unsigned int csum_long(unsigned long x)
30{
31 unsigned long ret;
32#ifdef __tilegx__
33 ret = __insn_v2sadu(x, 0);
34 ret = __insn_v2sadu(ret, 0);
35#else
36 ret = __insn_sadh_u(x, 0);
37 ret = __insn_sadh_u(ret, 0);
38#endif
39 return ret;
40}
41
24#endif /* _ASM_TILE_CHECKSUM_H */ 42#endif /* _ASM_TILE_CHECKSUM_H */
diff --git a/arch/tile/include/asm/device.h b/arch/tile/include/asm/device.h
new file mode 100644
index 00000000000..5182705bd05
--- /dev/null
+++ b/arch/tile/include/asm/device.h
@@ -0,0 +1,33 @@
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 * Arch specific extensions to struct device
14 */
15
16#ifndef _ASM_TILE_DEVICE_H
17#define _ASM_TILE_DEVICE_H
18
19struct dev_archdata {
20 /* DMA operations on that device */
21 struct dma_map_ops *dma_ops;
22
23 /* Offset of the DMA address from the PA. */
24 dma_addr_t dma_offset;
25
26 /* Highest DMA address that can be generated by this device. */
27 dma_addr_t max_direct_dma_addr;
28};
29
30struct pdev_archdata {
31};
32
33#endif /* _ASM_TILE_DEVICE_H */
diff --git a/arch/tile/include/asm/dma-mapping.h b/arch/tile/include/asm/dma-mapping.h
index eaa06d175b3..4b6247d1a31 100644
--- a/arch/tile/include/asm/dma-mapping.h
+++ b/arch/tile/include/asm/dma-mapping.h
@@ -20,69 +20,80 @@
20#include <linux/cache.h> 20#include <linux/cache.h>
21#include <linux/io.h> 21#include <linux/io.h>
22 22
23/* 23extern struct dma_map_ops *tile_dma_map_ops;
24 * Note that on x86 and powerpc, there is a "struct dma_mapping_ops" 24extern struct dma_map_ops *gx_pci_dma_map_ops;
25 * that is used for all the DMA operations. For now, we don't have an 25extern struct dma_map_ops *gx_legacy_pci_dma_map_ops;
26 * equivalent on tile, because we only have a single way of doing DMA. 26
27 * (Tilera bug 7994 to use dma_mapping_ops.) 27static inline struct dma_map_ops *get_dma_ops(struct device *dev)
28 */ 28{
29 if (dev && dev->archdata.dma_ops)
30 return dev->archdata.dma_ops;
31 else
32 return tile_dma_map_ops;
33}
34
35static inline dma_addr_t get_dma_offset(struct device *dev)
36{
37 return dev->archdata.dma_offset;
38}
39
40static inline void set_dma_offset(struct device *dev, dma_addr_t off)
41{
42 dev->archdata.dma_offset = off;
43}
29 44
30#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 45static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
31#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 46{
32 47 return paddr + get_dma_offset(dev);
33extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size, 48}
34 enum dma_data_direction); 49
35extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, 50static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
36 size_t size, enum dma_data_direction); 51{
37extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, 52 return daddr - get_dma_offset(dev);
38 enum dma_data_direction); 53}
39extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg, 54
40 int nhwentries, enum dma_data_direction); 55static inline void dma_mark_clean(void *addr, size_t size) {}
41extern dma_addr_t dma_map_page(struct device *dev, struct page *page, 56
42 unsigned long offset, size_t size, 57#include <asm-generic/dma-mapping-common.h>
43 enum dma_data_direction); 58
44extern void dma_unmap_page(struct device *dev, dma_addr_t dma_address, 59static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops)
45 size_t size, enum dma_data_direction); 60{
46extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, 61 dev->archdata.dma_ops = ops;
47 int nelems, enum dma_data_direction); 62}
48extern void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, 63
49 int nelems, enum dma_data_direction); 64static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
50 65{
51 66 if (!dev->dma_mask)
52void *dma_alloc_coherent(struct device *dev, size_t size, 67 return 0;
53 dma_addr_t *dma_handle, gfp_t flag); 68
54 69 return addr + size - 1 <= *dev->dma_mask;
55void dma_free_coherent(struct device *dev, size_t size, 70}
56 void *vaddr, dma_addr_t dma_handle);
57
58extern void dma_sync_single_for_cpu(struct device *, dma_addr_t, size_t,
59 enum dma_data_direction);
60extern void dma_sync_single_for_device(struct device *, dma_addr_t,
61 size_t, enum dma_data_direction);
62extern void dma_sync_single_range_for_cpu(struct device *, dma_addr_t,
63 unsigned long offset, size_t,
64 enum dma_data_direction);
65extern void dma_sync_single_range_for_device(struct device *, dma_addr_t,
66 unsigned long offset, size_t,
67 enum dma_data_direction);
68extern void dma_cache_sync(struct device *dev, void *vaddr, size_t,
69 enum dma_data_direction);
70 71
71static inline int 72static inline int
72dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 73dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
73{ 74{
74 return 0; 75 return get_dma_ops(dev)->mapping_error(dev, dma_addr);
75} 76}
76 77
77static inline int 78static inline int
78dma_supported(struct device *dev, u64 mask) 79dma_supported(struct device *dev, u64 mask)
79{ 80{
80 return 1; 81 return get_dma_ops(dev)->dma_supported(dev, mask);
81} 82}
82 83
83static inline int 84static inline int
84dma_set_mask(struct device *dev, u64 mask) 85dma_set_mask(struct device *dev, u64 mask)
85{ 86{
87 struct dma_map_ops *dma_ops = get_dma_ops(dev);
88
89 /* Handle legacy PCI devices with limited memory addressability. */
90 if ((dma_ops == gx_pci_dma_map_ops) && (mask <= DMA_BIT_MASK(32))) {
91 set_dma_ops(dev, gx_legacy_pci_dma_map_ops);
92 set_dma_offset(dev, 0);
93 if (mask > dev->archdata.max_direct_dma_addr)
94 mask = dev->archdata.max_direct_dma_addr;
95 }
96
86 if (!dev->dma_mask || !dma_supported(dev, mask)) 97 if (!dev->dma_mask || !dma_supported(dev, mask))
87 return -EIO; 98 return -EIO;
88 99
@@ -91,4 +102,43 @@ dma_set_mask(struct device *dev, u64 mask)
91 return 0; 102 return 0;
92} 103}
93 104
105static inline void *dma_alloc_attrs(struct device *dev, size_t size,
106 dma_addr_t *dma_handle, gfp_t flag,
107 struct dma_attrs *attrs)
108{
109 struct dma_map_ops *dma_ops = get_dma_ops(dev);
110 void *cpu_addr;
111
112 cpu_addr = dma_ops->alloc(dev, size, dma_handle, flag, attrs);
113
114 debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_addr);
115
116 return cpu_addr;
117}
118
119static inline void dma_free_attrs(struct device *dev, size_t size,
120 void *cpu_addr, dma_addr_t dma_handle,
121 struct dma_attrs *attrs)
122{
123 struct dma_map_ops *dma_ops = get_dma_ops(dev);
124
125 debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
126
127 dma_ops->free(dev, size, cpu_addr, dma_handle, attrs);
128}
129
130#define dma_alloc_coherent(d, s, h, f) dma_alloc_attrs(d, s, h, f, NULL)
131#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_attrs(d, s, h, f, NULL)
132#define dma_free_coherent(d, s, v, h) dma_free_attrs(d, s, v, h, NULL)
133#define dma_free_noncoherent(d, s, v, h) dma_free_attrs(d, s, v, h, NULL)
134
135/*
136 * dma_alloc_noncoherent() is #defined to return coherent memory,
137 * so there's no need to do any flushing here.
138 */
139static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
140 enum dma_data_direction direction)
141{
142}
143
94#endif /* _ASM_TILE_DMA_MAPPING_H */ 144#endif /* _ASM_TILE_DMA_MAPPING_H */
diff --git a/arch/tile/include/asm/fixmap.h b/arch/tile/include/asm/fixmap.h
index c66f7933bea..e16dbf929cb 100644
--- a/arch/tile/include/asm/fixmap.h
+++ b/arch/tile/include/asm/fixmap.h
@@ -45,15 +45,23 @@
45 * 45 *
46 * TLB entries of such buffers will not be flushed across 46 * TLB entries of such buffers will not be flushed across
47 * task switches. 47 * task switches.
48 *
49 * We don't bother with a FIX_HOLE since above the fixmaps
50 * is unmapped memory in any case.
51 */ 48 */
52enum fixed_addresses { 49enum fixed_addresses {
50#ifdef __tilegx__
51 /*
52 * TILEPro has unmapped memory above so the hole isn't needed,
53 * and in any case the hole pushes us over a single 16MB pmd.
54 */
55 FIX_HOLE,
56#endif
53#ifdef CONFIG_HIGHMEM 57#ifdef CONFIG_HIGHMEM
54 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ 58 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
55 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1, 59 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
56#endif 60#endif
61#ifdef __tilegx__ /* see homecache.c */
62 FIX_HOMECACHE_BEGIN,
63 FIX_HOMECACHE_END = FIX_HOMECACHE_BEGIN+(NR_CPUS)-1,
64#endif
57 __end_of_permanent_fixed_addresses, 65 __end_of_permanent_fixed_addresses,
58 66
59 /* 67 /*
diff --git a/arch/tile/include/asm/homecache.h b/arch/tile/include/asm/homecache.h
index a8243865d49..7b777132864 100644
--- a/arch/tile/include/asm/homecache.h
+++ b/arch/tile/include/asm/homecache.h
@@ -79,10 +79,17 @@ extern void homecache_change_page_home(struct page *, int order, int home);
79/* 79/*
80 * Flush a page out of whatever cache(s) it is in. 80 * Flush a page out of whatever cache(s) it is in.
81 * This is more than just finv, since it properly handles waiting 81 * This is more than just finv, since it properly handles waiting
82 * for the data to reach memory on tilepro, but it can be quite 82 * for the data to reach memory, but it can be quite
83 * heavyweight, particularly on hash-for-home memory. 83 * heavyweight, particularly on incoherent or immutable memory.
84 */ 84 */
85extern void homecache_flush_cache(struct page *, int order); 85extern void homecache_finv_page(struct page *);
86
87/*
88 * Flush a page out of the specified home cache.
89 * Note that the specified home need not be the actual home of the page,
90 * as for example might be the case when coordinating with I/O devices.
91 */
92extern void homecache_finv_map_page(struct page *, int home);
86 93
87/* 94/*
88 * Allocate a page with the given GFP flags, home, and optionally 95 * Allocate a page with the given GFP flags, home, and optionally
@@ -104,10 +111,10 @@ extern struct page *homecache_alloc_pages_node(int nid, gfp_t gfp_mask,
104 * routines use homecache_change_page_home() to reset the home 111 * routines use homecache_change_page_home() to reset the home
105 * back to the default before returning the page to the allocator. 112 * back to the default before returning the page to the allocator.
106 */ 113 */
114void __homecache_free_pages(struct page *, unsigned int order);
107void homecache_free_pages(unsigned long addr, unsigned int order); 115void homecache_free_pages(unsigned long addr, unsigned int order);
108#define homecache_free_page(page) \ 116#define __homecache_free_page(page) __homecache_free_pages((page), 0)
109 homecache_free_pages((page), 0) 117#define homecache_free_page(page) homecache_free_pages((page), 0)
110
111 118
112 119
113/* 120/*
diff --git a/arch/tile/include/asm/io.h b/arch/tile/include/asm/io.h
index d2152deb1f3..2a9b293fece 100644
--- a/arch/tile/include/asm/io.h
+++ b/arch/tile/include/asm/io.h
@@ -62,6 +62,92 @@ extern void iounmap(volatile void __iomem *addr);
62#define mm_ptov(addr) ((void *)phys_to_virt(addr)) 62#define mm_ptov(addr) ((void *)phys_to_virt(addr))
63#define mm_vtop(addr) ((unsigned long)virt_to_phys(addr)) 63#define mm_vtop(addr) ((unsigned long)virt_to_phys(addr))
64 64
65#if CHIP_HAS_MMIO()
66
67/*
68 * We use inline assembly to guarantee that the compiler does not
69 * split an access into multiple byte-sized accesses as it might
70 * sometimes do if a register data structure is marked "packed".
71 * Obviously on tile we can't tolerate such an access being
72 * actually unaligned, but we want to avoid the case where the
73 * compiler conservatively would generate multiple accesses even
74 * for an aligned read or write.
75 */
76
77static inline u8 __raw_readb(const volatile void __iomem *addr)
78{
79 return *(const volatile u8 __force *)addr;
80}
81
82static inline u16 __raw_readw(const volatile void __iomem *addr)
83{
84 u16 ret;
85 asm volatile("ld2u %0, %1" : "=r" (ret) : "r" (addr));
86 barrier();
87 return le16_to_cpu(ret);
88}
89
90static inline u32 __raw_readl(const volatile void __iomem *addr)
91{
92 u32 ret;
93 /* Sign-extend to conform to u32 ABI sign-extension convention. */
94 asm volatile("ld4s %0, %1" : "=r" (ret) : "r" (addr));
95 barrier();
96 return le32_to_cpu(ret);
97}
98
99static inline u64 __raw_readq(const volatile void __iomem *addr)
100{
101 u64 ret;
102 asm volatile("ld %0, %1" : "=r" (ret) : "r" (addr));
103 barrier();
104 return le64_to_cpu(ret);
105}
106
107static inline void __raw_writeb(u8 val, volatile void __iomem *addr)
108{
109 *(volatile u8 __force *)addr = val;
110}
111
112static inline void __raw_writew(u16 val, volatile void __iomem *addr)
113{
114 asm volatile("st2 %0, %1" :: "r" (addr), "r" (cpu_to_le16(val)));
115}
116
117static inline void __raw_writel(u32 val, volatile void __iomem *addr)
118{
119 asm volatile("st4 %0, %1" :: "r" (addr), "r" (cpu_to_le32(val)));
120}
121
122static inline void __raw_writeq(u64 val, volatile void __iomem *addr)
123{
124 asm volatile("st %0, %1" :: "r" (addr), "r" (cpu_to_le64(val)));
125}
126
127/*
128 * The on-chip I/O hardware on tilegx is configured with VA=PA for the
129 * kernel's PA range. The low-level APIs and field names use "va" and
130 * "void *" nomenclature, to be consistent with the general notion
131 * that the addresses in question are virtualizable, but in the kernel
132 * context we are actually manipulating PA values. (In other contexts,
133 * e.g. access from user space, we do in fact use real virtual addresses
134 * in the va fields.) To allow readers of the code to understand what's
135 * happening, we direct their attention to this comment by using the
136 * following two functions that just duplicate __va() and __pa().
137 */
138typedef unsigned long tile_io_addr_t;
139static inline tile_io_addr_t va_to_tile_io_addr(void *va)
140{
141 BUILD_BUG_ON(sizeof(phys_addr_t) != sizeof(tile_io_addr_t));
142 return __pa(va);
143}
144static inline void *tile_io_addr_to_va(tile_io_addr_t tile_io_addr)
145{
146 return __va(tile_io_addr);
147}
148
149#else /* CHIP_HAS_MMIO() */
150
65#ifdef CONFIG_PCI 151#ifdef CONFIG_PCI
66 152
67extern u8 _tile_readb(unsigned long addr); 153extern u8 _tile_readb(unsigned long addr);
@@ -73,10 +159,19 @@ extern void _tile_writew(u16 val, unsigned long addr);
73extern void _tile_writel(u32 val, unsigned long addr); 159extern void _tile_writel(u32 val, unsigned long addr);
74extern void _tile_writeq(u64 val, unsigned long addr); 160extern void _tile_writeq(u64 val, unsigned long addr);
75 161
76#else 162#define __raw_readb(addr) _tile_readb((unsigned long)addr)
163#define __raw_readw(addr) _tile_readw((unsigned long)addr)
164#define __raw_readl(addr) _tile_readl((unsigned long)addr)
165#define __raw_readq(addr) _tile_readq((unsigned long)addr)
166#define __raw_writeb(val, addr) _tile_writeb(val, (unsigned long)addr)
167#define __raw_writew(val, addr) _tile_writew(val, (unsigned long)addr)
168#define __raw_writel(val, addr) _tile_writel(val, (unsigned long)addr)
169#define __raw_writeq(val, addr) _tile_writeq(val, (unsigned long)addr)
170
171#else /* CONFIG_PCI */
77 172
78/* 173/*
79 * The Tile architecture does not support IOMEM unless PCI is enabled. 174 * The tilepro architecture does not support IOMEM unless PCI is enabled.
80 * Unfortunately we can't yet simply not declare these methods, 175 * Unfortunately we can't yet simply not declare these methods,
81 * since some generic code that compiles into the kernel, but 176 * since some generic code that compiles into the kernel, but
82 * we never run, uses them unconditionally. 177 * we never run, uses them unconditionally.
@@ -88,65 +183,58 @@ static inline int iomem_panic(void)
88 return 0; 183 return 0;
89} 184}
90 185
91static inline u8 _tile_readb(unsigned long addr) 186static inline u8 readb(unsigned long addr)
92{ 187{
93 return iomem_panic(); 188 return iomem_panic();
94} 189}
95 190
96static inline u16 _tile_readw(unsigned long addr) 191static inline u16 _readw(unsigned long addr)
97{ 192{
98 return iomem_panic(); 193 return iomem_panic();
99} 194}
100 195
101static inline u32 _tile_readl(unsigned long addr) 196static inline u32 readl(unsigned long addr)
102{ 197{
103 return iomem_panic(); 198 return iomem_panic();
104} 199}
105 200
106static inline u64 _tile_readq(unsigned long addr) 201static inline u64 readq(unsigned long addr)
107{ 202{
108 return iomem_panic(); 203 return iomem_panic();
109} 204}
110 205
111static inline void _tile_writeb(u8 val, unsigned long addr) 206static inline void writeb(u8 val, unsigned long addr)
112{ 207{
113 iomem_panic(); 208 iomem_panic();
114} 209}
115 210
116static inline void _tile_writew(u16 val, unsigned long addr) 211static inline void writew(u16 val, unsigned long addr)
117{ 212{
118 iomem_panic(); 213 iomem_panic();
119} 214}
120 215
121static inline void _tile_writel(u32 val, unsigned long addr) 216static inline void writel(u32 val, unsigned long addr)
122{ 217{
123 iomem_panic(); 218 iomem_panic();
124} 219}
125 220
126static inline void _tile_writeq(u64 val, unsigned long addr) 221static inline void writeq(u64 val, unsigned long addr)
127{ 222{
128 iomem_panic(); 223 iomem_panic();
129} 224}
130 225
131#endif 226#endif /* CONFIG_PCI */
227
228#endif /* CHIP_HAS_MMIO() */
132 229
133#define readb(addr) _tile_readb((unsigned long)addr) 230#define readb __raw_readb
134#define readw(addr) _tile_readw((unsigned long)addr) 231#define readw __raw_readw
135#define readl(addr) _tile_readl((unsigned long)addr) 232#define readl __raw_readl
136#define readq(addr) _tile_readq((unsigned long)addr) 233#define readq __raw_readq
137#define writeb(val, addr) _tile_writeb(val, (unsigned long)addr) 234#define writeb __raw_writeb
138#define writew(val, addr) _tile_writew(val, (unsigned long)addr) 235#define writew __raw_writew
139#define writel(val, addr) _tile_writel(val, (unsigned long)addr) 236#define writel __raw_writel
140#define writeq(val, addr) _tile_writeq(val, (unsigned long)addr) 237#define writeq __raw_writeq
141
142#define __raw_readb readb
143#define __raw_readw readw
144#define __raw_readl readl
145#define __raw_readq readq
146#define __raw_writeb writeb
147#define __raw_writew writew
148#define __raw_writel writel
149#define __raw_writeq writeq
150 238
151#define readb_relaxed readb 239#define readb_relaxed readb
152#define readw_relaxed readw 240#define readw_relaxed readw
diff --git a/arch/tile/include/asm/kmap_types.h b/arch/tile/include/asm/kmap_types.h
index 3d0f2024626..92b28e3e997 100644
--- a/arch/tile/include/asm/kmap_types.h
+++ b/arch/tile/include/asm/kmap_types.h
@@ -23,35 +23,6 @@
23 * adds 4MB of required address-space. For now we leave KM_TYPE_NR 23 * adds 4MB of required address-space. For now we leave KM_TYPE_NR
24 * set to depth 8. 24 * set to depth 8.
25 */ 25 */
26enum km_type { 26#define KM_TYPE_NR 8
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 {
35 KM_BOUNCE_READ,
36 KM_SKB_SUNRPC_DATA,
37 KM_SKB_DATA_SOFTIRQ,
38 KM_USER0,
39 KM_USER1,
40 KM_BIO_SRC_IRQ,
41 KM_BIO_DST_IRQ,
42 KM_PTE0,
43 KM_PTE1,
44 KM_IRQ0,
45 KM_IRQ1,
46 KM_SOFTIRQ0,
47 KM_SOFTIRQ1,
48 KM_SYNC_ICACHE,
49 KM_SYNC_DCACHE,
50 KM_UML_USERCOPY,
51 KM_IRQ_PTE,
52 KM_NMI,
53 KM_NMI_PTE,
54 KM_KDB
55};
56 27
57#endif /* _ASM_TILE_KMAP_TYPES_H */ 28#endif /* _ASM_TILE_KMAP_TYPES_H */
diff --git a/arch/tile/include/asm/memprof.h b/arch/tile/include/asm/memprof.h
deleted file mode 100644
index 359949be28c..00000000000
--- a/arch/tile/include/asm/memprof.h
+++ /dev/null
@@ -1,33 +0,0 @@
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 * The hypervisor's memory controller profiling infrastructure allows
15 * the programmer to find out what fraction of the available memory
16 * bandwidth is being consumed at each memory controller. The
17 * profiler provides start, stop, and clear operations to allows
18 * profiling over a specific time window, as well as an interface for
19 * reading the most recent profile values.
20 *
21 * This header declares IOCTL codes necessary to control memprof.
22 */
23#ifndef _ASM_TILE_MEMPROF_H
24#define _ASM_TILE_MEMPROF_H
25
26#include <linux/ioctl.h>
27
28#define MEMPROF_IOCTL_TYPE 0xB4
29#define MEMPROF_IOCTL_START _IO(MEMPROF_IOCTL_TYPE, 0)
30#define MEMPROF_IOCTL_STOP _IO(MEMPROF_IOCTL_TYPE, 1)
31#define MEMPROF_IOCTL_CLEAR _IO(MEMPROF_IOCTL_TYPE, 2)
32
33#endif /* _ASM_TILE_MEMPROF_H */
diff --git a/arch/tile/include/asm/page.h b/arch/tile/include/asm/page.h
index 9d9131e5c55..dd033a4fd62 100644
--- a/arch/tile/include/asm/page.h
+++ b/arch/tile/include/asm/page.h
@@ -174,7 +174,9 @@ static inline __attribute_const__ int get_order(unsigned long size)
174#define MEM_LOW_END (HALF_VA_SPACE - 1) /* low half */ 174#define MEM_LOW_END (HALF_VA_SPACE - 1) /* low half */
175#define MEM_HIGH_START (-HALF_VA_SPACE) /* high half */ 175#define MEM_HIGH_START (-HALF_VA_SPACE) /* high half */
176#define PAGE_OFFSET MEM_HIGH_START 176#define PAGE_OFFSET MEM_HIGH_START
177#define _VMALLOC_START _AC(0xfffffff500000000, UL) /* 4 GB */ 177#define FIXADDR_BASE _AC(0xfffffff400000000, UL) /* 4 GB */
178#define FIXADDR_TOP _AC(0xfffffff500000000, UL) /* 4 GB */
179#define _VMALLOC_START FIXADDR_TOP
178#define HUGE_VMAP_BASE _AC(0xfffffff600000000, UL) /* 4 GB */ 180#define HUGE_VMAP_BASE _AC(0xfffffff600000000, UL) /* 4 GB */
179#define MEM_SV_START _AC(0xfffffff700000000, UL) /* 256 MB */ 181#define MEM_SV_START _AC(0xfffffff700000000, UL) /* 256 MB */
180#define MEM_SV_INTRPT MEM_SV_START 182#define MEM_SV_INTRPT MEM_SV_START
@@ -185,9 +187,6 @@ static inline __attribute_const__ int get_order(unsigned long size)
185/* Highest DTLB address we will use */ 187/* Highest DTLB address we will use */
186#define KERNEL_HIGH_VADDR MEM_SV_START 188#define KERNEL_HIGH_VADDR MEM_SV_START
187 189
188/* Since we don't currently provide any fixmaps, we use an impossible VA. */
189#define FIXADDR_TOP MEM_HV_START
190
191#else /* !__tilegx__ */ 190#else /* !__tilegx__ */
192 191
193/* 192/*
diff --git a/arch/tile/include/asm/pci.h b/arch/tile/include/asm/pci.h
index 32e6cbe8dff..302cdf71cee 100644
--- a/arch/tile/include/asm/pci.h
+++ b/arch/tile/include/asm/pci.h
@@ -15,9 +15,13 @@
15#ifndef _ASM_TILE_PCI_H 15#ifndef _ASM_TILE_PCI_H
16#define _ASM_TILE_PCI_H 16#define _ASM_TILE_PCI_H
17 17
18#include <linux/dma-mapping.h>
18#include <linux/pci.h> 19#include <linux/pci.h>
20#include <linux/numa.h>
19#include <asm-generic/pci_iomap.h> 21#include <asm-generic/pci_iomap.h>
20 22
23#ifndef __tilegx__
24
21/* 25/*
22 * Structure of a PCI controller (host bridge) 26 * Structure of a PCI controller (host bridge)
23 */ 27 */
@@ -41,21 +45,151 @@ struct pci_controller {
41}; 45};
42 46
43/* 47/*
48 * This flag tells if the platform is TILEmpower that needs
49 * special configuration for the PLX switch chip.
50 */
51extern int tile_plx_gen1;
52
53static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) {}
54
55#define TILE_NUM_PCIE 2
56
57/*
44 * The hypervisor maps the entirety of CPA-space as bus addresses, so 58 * The hypervisor maps the entirety of CPA-space as bus addresses, so
45 * bus addresses are physical addresses. The networking and block 59 * bus addresses are physical addresses. The networking and block
46 * device layers use this boolean for bounce buffer decisions. 60 * device layers use this boolean for bounce buffer decisions.
47 */ 61 */
48#define PCI_DMA_BUS_IS_PHYS 1 62#define PCI_DMA_BUS_IS_PHYS 1
49 63
64/* generic pci stuff */
65#include <asm-generic/pci.h>
66
67#else
68
69#include <asm/page.h>
70#include <gxio/trio.h>
71
72/**
73 * We reserve the hugepage-size address range at the top of the 64-bit address
74 * space to serve as the PCI window, emulating the BAR0 space of an endpoint
75 * device. This window is used by the chip-to-chip applications running on
76 * the RC node. The reason for carving out this window is that Mem-Maps that
77 * back up this window will not overlap with those that map the real physical
78 * memory.
79 */
80#define PCIE_HOST_BAR0_SIZE HPAGE_SIZE
81#define PCIE_HOST_BAR0_START HPAGE_MASK
82
83/**
84 * The first PAGE_SIZE of the above "BAR" window is mapped to the
85 * gxpci_host_regs structure.
86 */
87#define PCIE_HOST_REGS_SIZE PAGE_SIZE
88
89/*
90 * This is the PCI address where the Mem-Map interrupt regions start.
91 * We use the 2nd to the last huge page of the 64-bit address space.
92 * The last huge page is used for the rootcomplex "bar", for C2C purpose.
93 */
94#define MEM_MAP_INTR_REGIONS_BASE (HPAGE_MASK - HPAGE_SIZE)
95
96/*
97 * Each Mem-Map interrupt region occupies 4KB.
98 */
99#define MEM_MAP_INTR_REGION_SIZE (1 << TRIO_MAP_MEM_LIM__ADDR_SHIFT)
100
101/*
102 * Allocate the PCI BAR window right below 4GB.
103 */
104#define TILE_PCI_BAR_WINDOW_TOP (1ULL << 32)
105
106/*
107 * Allocate 1GB for the PCI BAR window.
108 */
109#define TILE_PCI_BAR_WINDOW_SIZE (1 << 30)
110
111/*
112 * This is the highest bus address targeting the host memory that
113 * can be generated by legacy PCI devices with 32-bit or less
114 * DMA capability, dictated by the BAR window size and location.
115 */
116#define TILE_PCI_MAX_DIRECT_DMA_ADDRESS \
117 (TILE_PCI_BAR_WINDOW_TOP - TILE_PCI_BAR_WINDOW_SIZE - 1)
118
119/*
120 * We shift the PCI bus range for all the physical memory up by the whole PA
121 * range. The corresponding CPA of an incoming PCI request will be the PCI
122 * address minus TILE_PCI_MEM_MAP_BASE_OFFSET. This also implies
123 * that the 64-bit capable devices will be given DMA addresses as
124 * the CPA plus TILE_PCI_MEM_MAP_BASE_OFFSET. To support 32-bit
125 * devices, we create a separate map region that handles the low
126 * 4GB.
127 */
128#define TILE_PCI_MEM_MAP_BASE_OFFSET (1ULL << CHIP_PA_WIDTH())
129
130/*
131 * Start of the PCI memory resource, which starts at the end of the
132 * maximum system physical RAM address.
133 */
134#define TILE_PCI_MEM_START (1ULL << CHIP_PA_WIDTH())
135
136/*
137 * Structure of a PCI controller (host bridge) on Gx.
138 */
139struct pci_controller {
140
141 /* Pointer back to the TRIO that this PCIe port is connected to. */
142 gxio_trio_context_t *trio;
143 int mac; /* PCIe mac index on the TRIO shim */
144 int trio_index; /* Index of TRIO shim that contains the MAC. */
145
146 int pio_mem_index; /* PIO region index for memory access */
147
148 /*
149 * Mem-Map regions for all the memory controllers so that Linux can
150 * map all of its physical memory space to the PCI bus.
151 */
152 int mem_maps[MAX_NUMNODES];
153
154 int index; /* PCI domain number */
155 struct pci_bus *root_bus;
156
157 /* PCI memory space resource for this controller. */
158 struct resource mem_space;
159 char mem_space_name[32];
160
161 uint64_t mem_offset; /* cpu->bus memory mapping offset. */
162
163 int first_busno;
164
165 struct pci_ops *ops;
166
167 /* Table that maps the INTx numbers to Linux irq numbers. */
168 int irq_intx_table[4];
169
170 /* Address ranges that are routed to this controller/bridge. */
171 struct resource mem_resources[3];
172};
173
174extern struct pci_controller pci_controllers[TILEGX_NUM_TRIO * TILEGX_TRIO_PCIES];
175extern gxio_trio_context_t trio_contexts[TILEGX_NUM_TRIO];
176
177extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
178
179/*
180 * The PCI address space does not equal the physical memory address
181 * space (we have an IOMMU). The IDE and SCSI device layers use this
182 * boolean for bounce buffer decisions.
183 */
184#define PCI_DMA_BUS_IS_PHYS 0
185
186#endif /* __tilegx__ */
187
50int __init tile_pci_init(void); 188int __init tile_pci_init(void);
51int __init pcibios_init(void); 189int __init pcibios_init(void);
52 190
53static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) {}
54
55void __devinit pcibios_fixup_bus(struct pci_bus *bus); 191void __devinit pcibios_fixup_bus(struct pci_bus *bus);
56 192
57#define TILE_NUM_PCIE 2
58
59#define pci_domain_nr(bus) (((struct pci_controller *)(bus)->sysdata)->index) 193#define pci_domain_nr(bus) (((struct pci_controller *)(bus)->sysdata)->index)
60 194
61/* 195/*
@@ -79,19 +213,10 @@ static inline int pcibios_assign_all_busses(void)
79#define PCIBIOS_MIN_MEM 0 213#define PCIBIOS_MIN_MEM 0
80#define PCIBIOS_MIN_IO 0 214#define PCIBIOS_MIN_IO 0
81 215
82/*
83 * This flag tells if the platform is TILEmpower that needs
84 * special configuration for the PLX switch chip.
85 */
86extern int tile_plx_gen1;
87
88/* Use any cpu for PCI. */ 216/* Use any cpu for PCI. */
89#define cpumask_of_pcibus(bus) cpu_online_mask 217#define cpumask_of_pcibus(bus) cpu_online_mask
90 218
91/* implement the pci_ DMA API in terms of the generic device dma_ one */ 219/* implement the pci_ DMA API in terms of the generic device dma_ one */
92#include <asm-generic/pci-dma-compat.h> 220#include <asm-generic/pci-dma-compat.h>
93 221
94/* generic pci stuff */
95#include <asm-generic/pci.h>
96
97#endif /* _ASM_TILE_PCI_H */ 222#endif /* _ASM_TILE_PCI_H */
diff --git a/arch/tile/include/gxio/common.h b/arch/tile/include/gxio/common.h
new file mode 100644
index 00000000000..724595a24d0
--- /dev/null
+++ b/arch/tile/include/gxio/common.h
@@ -0,0 +1,40 @@
1/*
2 * Copyright 2012 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#ifndef _GXIO_COMMON_H_
16#define _GXIO_COMMON_H_
17
18/*
19 * Routines shared between the various GXIO device components.
20 */
21
22#include <hv/iorpc.h>
23
24#include <linux/types.h>
25#include <linux/compiler.h>
26#include <linux/io.h>
27
28/* Define the standard gxio MMIO functions using kernel functions. */
29#define __gxio_mmio_read8(addr) readb(addr)
30#define __gxio_mmio_read16(addr) readw(addr)
31#define __gxio_mmio_read32(addr) readl(addr)
32#define __gxio_mmio_read64(addr) readq(addr)
33#define __gxio_mmio_write8(addr, val) writeb((val), (addr))
34#define __gxio_mmio_write16(addr, val) writew((val), (addr))
35#define __gxio_mmio_write32(addr, val) writel((val), (addr))
36#define __gxio_mmio_write64(addr, val) writeq((val), (addr))
37#define __gxio_mmio_read(addr) __gxio_mmio_read64(addr)
38#define __gxio_mmio_write(addr, val) __gxio_mmio_write64((addr), (val))
39
40#endif /* !_GXIO_COMMON_H_ */
diff --git a/arch/tile/include/gxio/dma_queue.h b/arch/tile/include/gxio/dma_queue.h
new file mode 100644
index 00000000000..00654feb7db
--- /dev/null
+++ b/arch/tile/include/gxio/dma_queue.h
@@ -0,0 +1,161 @@
1/*
2 * Copyright 2012 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#ifndef _GXIO_DMA_QUEUE_H_
16#define _GXIO_DMA_QUEUE_H_
17
18/*
19 * DMA queue management APIs shared between TRIO and mPIPE.
20 */
21
22#include "common.h"
23
24/* The credit counter lives in the high 32 bits. */
25#define DMA_QUEUE_CREDIT_SHIFT 32
26
27/*
28 * State object that tracks a DMA queue's head and tail indices, as
29 * well as the number of commands posted and completed. The
30 * structure is accessed via a thread-safe, lock-free algorithm.
31 */
32typedef struct {
33 /*
34 * Address of a MPIPE_EDMA_POST_REGION_VAL_t,
35 * TRIO_PUSH_DMA_REGION_VAL_t, or TRIO_PULL_DMA_REGION_VAL_t
36 * register. These register have identical encodings and provide
37 * information about how many commands have been processed.
38 */
39 void *post_region_addr;
40
41 /*
42 * A lazily-updated count of how many edescs the hardware has
43 * completed.
44 */
45 uint64_t hw_complete_count __attribute__ ((aligned(64)));
46
47 /*
48 * High 32 bits are a count of available egress command credits,
49 * low 24 bits are the next egress "slot".
50 */
51 int64_t credits_and_next_index;
52
53} __gxio_dma_queue_t;
54
55/* Initialize a dma queue. */
56extern void __gxio_dma_queue_init(__gxio_dma_queue_t *dma_queue,
57 void *post_region_addr,
58 unsigned int num_entries);
59
60/*
61 * Update the "credits_and_next_index" and "hw_complete_count" fields
62 * based on pending hardware completions. Note that some other thread
63 * may have already done this and, importantly, may still be in the
64 * process of updating "credits_and_next_index".
65 */
66extern void __gxio_dma_queue_update_credits(__gxio_dma_queue_t *dma_queue);
67
68/* Wait for credits to become available. */
69extern int64_t __gxio_dma_queue_wait_for_credits(__gxio_dma_queue_t *dma_queue,
70 int64_t modifier);
71
72/* Reserve slots in the queue, optionally waiting for slots to become
73 * available, and optionally returning a "completion_slot" suitable for
74 * direct comparison to "hw_complete_count".
75 */
76static inline int64_t __gxio_dma_queue_reserve(__gxio_dma_queue_t *dma_queue,
77 unsigned int num, bool wait,
78 bool completion)
79{
80 uint64_t slot;
81
82 /*
83 * Try to reserve 'num' egress command slots. We do this by
84 * constructing a constant that subtracts N credits and adds N to
85 * the index, and using fetchaddgez to only apply it if the credits
86 * count doesn't go negative.
87 */
88 int64_t modifier = (((int64_t)(-num)) << DMA_QUEUE_CREDIT_SHIFT) | num;
89 int64_t old =
90 __insn_fetchaddgez(&dma_queue->credits_and_next_index,
91 modifier);
92
93 if (unlikely(old + modifier < 0)) {
94 /*
95 * We're out of credits. Try once to get more by checking for
96 * completed egress commands. If that fails, wait or fail.
97 */
98 __gxio_dma_queue_update_credits(dma_queue);
99 old = __insn_fetchaddgez(&dma_queue->credits_and_next_index,
100 modifier);
101 if (old + modifier < 0) {
102 if (wait)
103 old = __gxio_dma_queue_wait_for_credits
104 (dma_queue, modifier);
105 else
106 return GXIO_ERR_DMA_CREDITS;
107 }
108 }
109
110 /* The bottom 24 bits of old encode the "slot". */
111 slot = (old & 0xffffff);
112
113 if (completion) {
114 /*
115 * A "completion_slot" is a "slot" which can be compared to
116 * "hw_complete_count" at any time in the future. To convert
117 * "slot" into a "completion_slot", we access "hw_complete_count"
118 * once (knowing that we have reserved a slot, and thus, it will
119 * be "basically" accurate), and combine its high 40 bits with
120 * the 24 bit "slot", and handle "wrapping" by adding "1 << 24"
121 * if the result is LESS than "hw_complete_count".
122 */
123 uint64_t complete;
124 complete = ACCESS_ONCE(dma_queue->hw_complete_count);
125 slot |= (complete & 0xffffffffff000000);
126 if (slot < complete)
127 slot += 0x1000000;
128 }
129
130 /*
131 * If any of our slots mod 256 were equivalent to 0, go ahead and
132 * collect some egress credits, and update "hw_complete_count", and
133 * make sure the index doesn't overflow into the credits.
134 */
135 if (unlikely(((old + num) & 0xff) < num)) {
136 __gxio_dma_queue_update_credits(dma_queue);
137
138 /* Make sure the index doesn't overflow into the credits. */
139#ifdef __BIG_ENDIAN__
140 *(((uint8_t *)&dma_queue->credits_and_next_index) + 4) = 0;
141#else
142 *(((uint8_t *)&dma_queue->credits_and_next_index) + 3) = 0;
143#endif
144 }
145
146 return slot;
147}
148
149/* Non-inlinable "__gxio_dma_queue_reserve(..., true)". */
150extern int64_t __gxio_dma_queue_reserve_aux(__gxio_dma_queue_t *dma_queue,
151 unsigned int num, int wait);
152
153/* Check whether a particular "completion slot" has completed.
154 *
155 * Note that this function requires a "completion slot", and thus
156 * cannot be used with the result of any "reserve_fast" function.
157 */
158extern int __gxio_dma_queue_is_complete(__gxio_dma_queue_t *dma_queue,
159 int64_t completion_slot, int update);
160
161#endif /* !_GXIO_DMA_QUEUE_H_ */
diff --git a/arch/tile/include/gxio/iorpc_globals.h b/arch/tile/include/gxio/iorpc_globals.h
new file mode 100644
index 00000000000..52c721f8dad
--- /dev/null
+++ b/arch/tile/include/gxio/iorpc_globals.h
@@ -0,0 +1,38 @@
1/*
2 * Copyright 2012 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/* This file is machine-generated; DO NOT EDIT! */
16#ifndef __IORPC_LINUX_RPC_H__
17#define __IORPC_LINUX_RPC_H__
18
19#include <hv/iorpc.h>
20
21#include <linux/string.h>
22#include <linux/module.h>
23#include <asm/pgtable.h>
24
25#define IORPC_OP_ARM_POLLFD IORPC_OPCODE(IORPC_FORMAT_KERNEL_POLLFD, 0x9000)
26#define IORPC_OP_CLOSE_POLLFD IORPC_OPCODE(IORPC_FORMAT_KERNEL_POLLFD, 0x9001)
27#define IORPC_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000)
28#define IORPC_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001)
29
30int __iorpc_arm_pollfd(int fd, int pollfd_cookie);
31
32int __iorpc_close_pollfd(int fd, int pollfd_cookie);
33
34int __iorpc_get_mmio_base(int fd, HV_PTE *base);
35
36int __iorpc_check_mmio_offset(int fd, unsigned long offset, unsigned long size);
37
38#endif /* !__IORPC_LINUX_RPC_H__ */
diff --git a/arch/tile/include/gxio/iorpc_mpipe.h b/arch/tile/include/gxio/iorpc_mpipe.h
new file mode 100644
index 00000000000..9d50fce1b1a
--- /dev/null
+++ b/arch/tile/include/gxio/iorpc_mpipe.h
@@ -0,0 +1,136 @@
1/*
2 * Copyright 2012 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/* This file is machine-generated; DO NOT EDIT! */
16#ifndef __GXIO_MPIPE_LINUX_RPC_H__
17#define __GXIO_MPIPE_LINUX_RPC_H__
18
19#include <hv/iorpc.h>
20
21#include <hv/drv_mpipe_intf.h>
22#include <asm/page.h>
23#include <gxio/kiorpc.h>
24#include <gxio/mpipe.h>
25#include <linux/string.h>
26#include <linux/module.h>
27#include <asm/pgtable.h>
28
29#define GXIO_MPIPE_OP_ALLOC_BUFFER_STACKS IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1200)
30#define GXIO_MPIPE_OP_INIT_BUFFER_STACK_AUX IORPC_OPCODE(IORPC_FORMAT_KERNEL_MEM, 0x1201)
31
32#define GXIO_MPIPE_OP_ALLOC_NOTIF_RINGS IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1203)
33#define GXIO_MPIPE_OP_INIT_NOTIF_RING_AUX IORPC_OPCODE(IORPC_FORMAT_KERNEL_MEM, 0x1204)
34#define GXIO_MPIPE_OP_REQUEST_NOTIF_RING_INTERRUPT IORPC_OPCODE(IORPC_FORMAT_KERNEL_INTERRUPT, 0x1205)
35#define GXIO_MPIPE_OP_ENABLE_NOTIF_RING_INTERRUPT IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1206)
36#define GXIO_MPIPE_OP_ALLOC_NOTIF_GROUPS IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1207)
37#define GXIO_MPIPE_OP_INIT_NOTIF_GROUP IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1208)
38#define GXIO_MPIPE_OP_ALLOC_BUCKETS IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1209)
39#define GXIO_MPIPE_OP_INIT_BUCKET IORPC_OPCODE(IORPC_FORMAT_NONE, 0x120a)
40#define GXIO_MPIPE_OP_ALLOC_EDMA_RINGS IORPC_OPCODE(IORPC_FORMAT_NONE, 0x120b)
41#define GXIO_MPIPE_OP_INIT_EDMA_RING_AUX IORPC_OPCODE(IORPC_FORMAT_KERNEL_MEM, 0x120c)
42
43#define GXIO_MPIPE_OP_COMMIT_RULES IORPC_OPCODE(IORPC_FORMAT_NONE, 0x120f)
44#define GXIO_MPIPE_OP_REGISTER_CLIENT_MEMORY IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x1210)
45#define GXIO_MPIPE_OP_LINK_OPEN_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1211)
46#define GXIO_MPIPE_OP_LINK_CLOSE_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1212)
47
48#define GXIO_MPIPE_OP_GET_TIMESTAMP_AUX IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x121e)
49#define GXIO_MPIPE_OP_SET_TIMESTAMP_AUX IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x121f)
50#define GXIO_MPIPE_OP_ADJUST_TIMESTAMP_AUX IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x1220)
51#define GXIO_MPIPE_OP_ARM_POLLFD IORPC_OPCODE(IORPC_FORMAT_KERNEL_POLLFD, 0x9000)
52#define GXIO_MPIPE_OP_CLOSE_POLLFD IORPC_OPCODE(IORPC_FORMAT_KERNEL_POLLFD, 0x9001)
53#define GXIO_MPIPE_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000)
54#define GXIO_MPIPE_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001)
55
56int gxio_mpipe_alloc_buffer_stacks(gxio_mpipe_context_t * context,
57 unsigned int count, unsigned int first,
58 unsigned int flags);
59
60int gxio_mpipe_init_buffer_stack_aux(gxio_mpipe_context_t * context,
61 void *mem_va, size_t mem_size,
62 unsigned int mem_flags, unsigned int stack,
63 unsigned int buffer_size_enum);
64
65
66int gxio_mpipe_alloc_notif_rings(gxio_mpipe_context_t * context,
67 unsigned int count, unsigned int first,
68 unsigned int flags);
69
70int gxio_mpipe_init_notif_ring_aux(gxio_mpipe_context_t * context, void *mem_va,
71 size_t mem_size, unsigned int mem_flags,
72 unsigned int ring);
73
74int gxio_mpipe_request_notif_ring_interrupt(gxio_mpipe_context_t * context,
75 int inter_x, int inter_y,
76 int inter_ipi, int inter_event,
77 unsigned int ring);
78
79int gxio_mpipe_enable_notif_ring_interrupt(gxio_mpipe_context_t * context,
80 unsigned int ring);
81
82int gxio_mpipe_alloc_notif_groups(gxio_mpipe_context_t * context,
83 unsigned int count, unsigned int first,
84 unsigned int flags);
85
86int gxio_mpipe_init_notif_group(gxio_mpipe_context_t * context,
87 unsigned int group,
88 gxio_mpipe_notif_group_bits_t bits);
89
90int gxio_mpipe_alloc_buckets(gxio_mpipe_context_t * context, unsigned int count,
91 unsigned int first, unsigned int flags);
92
93int gxio_mpipe_init_bucket(gxio_mpipe_context_t * context, unsigned int bucket,
94 MPIPE_LBL_INIT_DAT_BSTS_TBL_t bucket_info);
95
96int gxio_mpipe_alloc_edma_rings(gxio_mpipe_context_t * context,
97 unsigned int count, unsigned int first,
98 unsigned int flags);
99
100int gxio_mpipe_init_edma_ring_aux(gxio_mpipe_context_t * context, void *mem_va,
101 size_t mem_size, unsigned int mem_flags,
102 unsigned int ring, unsigned int channel);
103
104
105int gxio_mpipe_commit_rules(gxio_mpipe_context_t * context, const void *blob,
106 size_t blob_size);
107
108int gxio_mpipe_register_client_memory(gxio_mpipe_context_t * context,
109 unsigned int iotlb, HV_PTE pte,
110 unsigned int flags);
111
112int gxio_mpipe_link_open_aux(gxio_mpipe_context_t * context,
113 _gxio_mpipe_link_name_t name, unsigned int flags);
114
115int gxio_mpipe_link_close_aux(gxio_mpipe_context_t * context, int mac);
116
117
118int gxio_mpipe_get_timestamp_aux(gxio_mpipe_context_t * context, uint64_t * sec,
119 uint64_t * nsec, uint64_t * cycles);
120
121int gxio_mpipe_set_timestamp_aux(gxio_mpipe_context_t * context, uint64_t sec,
122 uint64_t nsec, uint64_t cycles);
123
124int gxio_mpipe_adjust_timestamp_aux(gxio_mpipe_context_t * context,
125 int64_t nsec);
126
127int gxio_mpipe_arm_pollfd(gxio_mpipe_context_t * context, int pollfd_cookie);
128
129int gxio_mpipe_close_pollfd(gxio_mpipe_context_t * context, int pollfd_cookie);
130
131int gxio_mpipe_get_mmio_base(gxio_mpipe_context_t * context, HV_PTE *base);
132
133int gxio_mpipe_check_mmio_offset(gxio_mpipe_context_t * context,
134 unsigned long offset, unsigned long size);
135
136#endif /* !__GXIO_MPIPE_LINUX_RPC_H__ */
diff --git a/arch/tile/include/gxio/iorpc_mpipe_info.h b/arch/tile/include/gxio/iorpc_mpipe_info.h
new file mode 100644
index 00000000000..0bcf3f71ce8
--- /dev/null
+++ b/arch/tile/include/gxio/iorpc_mpipe_info.h
@@ -0,0 +1,46 @@
1/*
2 * Copyright 2012 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/* This file is machine-generated; DO NOT EDIT! */
16#ifndef __GXIO_MPIPE_INFO_LINUX_RPC_H__
17#define __GXIO_MPIPE_INFO_LINUX_RPC_H__
18
19#include <hv/iorpc.h>
20
21#include <hv/drv_mpipe_intf.h>
22#include <asm/page.h>
23#include <gxio/kiorpc.h>
24#include <gxio/mpipe.h>
25#include <linux/string.h>
26#include <linux/module.h>
27#include <asm/pgtable.h>
28
29
30#define GXIO_MPIPE_INFO_OP_ENUMERATE_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1251)
31#define GXIO_MPIPE_INFO_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000)
32#define GXIO_MPIPE_INFO_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001)
33
34
35int gxio_mpipe_info_enumerate_aux(gxio_mpipe_info_context_t * context,
36 unsigned int idx,
37 _gxio_mpipe_link_name_t * name,
38 _gxio_mpipe_link_mac_t * mac);
39
40int gxio_mpipe_info_get_mmio_base(gxio_mpipe_info_context_t * context,
41 HV_PTE *base);
42
43int gxio_mpipe_info_check_mmio_offset(gxio_mpipe_info_context_t * context,
44 unsigned long offset, unsigned long size);
45
46#endif /* !__GXIO_MPIPE_INFO_LINUX_RPC_H__ */
diff --git a/arch/tile/include/gxio/iorpc_trio.h b/arch/tile/include/gxio/iorpc_trio.h
new file mode 100644
index 00000000000..15fb7799208
--- /dev/null
+++ b/arch/tile/include/gxio/iorpc_trio.h
@@ -0,0 +1,97 @@
1/*
2 * Copyright 2012 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/* This file is machine-generated; DO NOT EDIT! */
16#ifndef __GXIO_TRIO_LINUX_RPC_H__
17#define __GXIO_TRIO_LINUX_RPC_H__
18
19#include <hv/iorpc.h>
20
21#include <hv/drv_trio_intf.h>
22#include <gxio/trio.h>
23#include <gxio/kiorpc.h>
24#include <linux/string.h>
25#include <linux/module.h>
26#include <asm/pgtable.h>
27
28#define GXIO_TRIO_OP_ALLOC_ASIDS IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1400)
29
30#define GXIO_TRIO_OP_ALLOC_MEMORY_MAPS IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1402)
31
32#define GXIO_TRIO_OP_ALLOC_PIO_REGIONS IORPC_OPCODE(IORPC_FORMAT_NONE, 0x140e)
33#define GXIO_TRIO_OP_INIT_PIO_REGION_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x140f)
34
35#define GXIO_TRIO_OP_INIT_MEMORY_MAP_MMU_AUX IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x1417)
36#define GXIO_TRIO_OP_GET_PORT_PROPERTY IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x1418)
37#define GXIO_TRIO_OP_CONFIG_LEGACY_INTR IORPC_OPCODE(IORPC_FORMAT_KERNEL_INTERRUPT, 0x1419)
38#define GXIO_TRIO_OP_CONFIG_MSI_INTR IORPC_OPCODE(IORPC_FORMAT_KERNEL_INTERRUPT, 0x141a)
39
40#define GXIO_TRIO_OP_SET_MPS_MRS IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x141c)
41#define GXIO_TRIO_OP_FORCE_RC_LINK_UP IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x141d)
42#define GXIO_TRIO_OP_FORCE_EP_LINK_UP IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x141e)
43#define GXIO_TRIO_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000)
44#define GXIO_TRIO_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001)
45
46int gxio_trio_alloc_asids(gxio_trio_context_t * context, unsigned int count,
47 unsigned int first, unsigned int flags);
48
49
50int gxio_trio_alloc_memory_maps(gxio_trio_context_t * context,
51 unsigned int count, unsigned int first,
52 unsigned int flags);
53
54
55int gxio_trio_alloc_pio_regions(gxio_trio_context_t * context,
56 unsigned int count, unsigned int first,
57 unsigned int flags);
58
59int gxio_trio_init_pio_region_aux(gxio_trio_context_t * context,
60 unsigned int pio_region, unsigned int mac,
61 uint32_t bus_address_hi, unsigned int flags);
62
63
64int gxio_trio_init_memory_map_mmu_aux(gxio_trio_context_t * context,
65 unsigned int map, unsigned long va,
66 uint64_t size, unsigned int asid,
67 unsigned int mac, uint64_t bus_address,
68 unsigned int node,
69 unsigned int order_mode);
70
71int gxio_trio_get_port_property(gxio_trio_context_t * context,
72 struct pcie_trio_ports_property *trio_ports);
73
74int gxio_trio_config_legacy_intr(gxio_trio_context_t * context, int inter_x,
75 int inter_y, int inter_ipi, int inter_event,
76 unsigned int mac, unsigned int intx);
77
78int gxio_trio_config_msi_intr(gxio_trio_context_t * context, int inter_x,
79 int inter_y, int inter_ipi, int inter_event,
80 unsigned int mac, unsigned int mem_map,
81 uint64_t mem_map_base, uint64_t mem_map_limit,
82 unsigned int asid);
83
84
85int gxio_trio_set_mps_mrs(gxio_trio_context_t * context, uint16_t mps,
86 uint16_t mrs, unsigned int mac);
87
88int gxio_trio_force_rc_link_up(gxio_trio_context_t * context, unsigned int mac);
89
90int gxio_trio_force_ep_link_up(gxio_trio_context_t * context, unsigned int mac);
91
92int gxio_trio_get_mmio_base(gxio_trio_context_t * context, HV_PTE *base);
93
94int gxio_trio_check_mmio_offset(gxio_trio_context_t * context,
95 unsigned long offset, unsigned long size);
96
97#endif /* !__GXIO_TRIO_LINUX_RPC_H__ */
diff --git a/arch/tile/include/gxio/iorpc_usb_host.h b/arch/tile/include/gxio/iorpc_usb_host.h
new file mode 100644
index 00000000000..8622e7d126a
--- /dev/null
+++ b/arch/tile/include/gxio/iorpc_usb_host.h
@@ -0,0 +1,46 @@
1/*
2 * Copyright 2012 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/* This file is machine-generated; DO NOT EDIT! */
16#ifndef __GXIO_USB_HOST_LINUX_RPC_H__
17#define __GXIO_USB_HOST_LINUX_RPC_H__
18
19#include <hv/iorpc.h>
20
21#include <hv/drv_usb_host_intf.h>
22#include <asm/page.h>
23#include <gxio/kiorpc.h>
24#include <gxio/usb_host.h>
25#include <linux/string.h>
26#include <linux/module.h>
27#include <asm/pgtable.h>
28
29#define GXIO_USB_HOST_OP_CFG_INTERRUPT IORPC_OPCODE(IORPC_FORMAT_KERNEL_INTERRUPT, 0x1800)
30#define GXIO_USB_HOST_OP_REGISTER_CLIENT_MEMORY IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x1801)
31#define GXIO_USB_HOST_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000)
32#define GXIO_USB_HOST_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001)
33
34int gxio_usb_host_cfg_interrupt(gxio_usb_host_context_t * context, int inter_x,
35 int inter_y, int inter_ipi, int inter_event);
36
37int gxio_usb_host_register_client_memory(gxio_usb_host_context_t * context,
38 HV_PTE pte, unsigned int flags);
39
40int gxio_usb_host_get_mmio_base(gxio_usb_host_context_t * context,
41 HV_PTE *base);
42
43int gxio_usb_host_check_mmio_offset(gxio_usb_host_context_t * context,
44 unsigned long offset, unsigned long size);
45
46#endif /* !__GXIO_USB_HOST_LINUX_RPC_H__ */
diff --git a/arch/tile/include/gxio/kiorpc.h b/arch/tile/include/gxio/kiorpc.h
new file mode 100644
index 00000000000..ee5820979ff
--- /dev/null
+++ b/arch/tile/include/gxio/kiorpc.h
@@ -0,0 +1,29 @@
1/*
2 * Copyright 2012 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 * Support routines for kernel IORPC drivers.
15 */
16
17#ifndef _GXIO_KIORPC_H
18#define _GXIO_KIORPC_H
19
20#include <linux/types.h>
21#include <asm/page.h>
22#include <arch/chip.h>
23
24#if CHIP_HAS_MMIO()
25void __iomem *iorpc_ioremap(int hv_fd, resource_size_t offset,
26 unsigned long size);
27#endif
28
29#endif /* _GXIO_KIORPC_H */
diff --git a/arch/tile/include/gxio/mpipe.h b/arch/tile/include/gxio/mpipe.h
new file mode 100644
index 00000000000..78c598618c9
--- /dev/null
+++ b/arch/tile/include/gxio/mpipe.h
@@ -0,0 +1,1736 @@
1/*
2 * Copyright 2012 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#ifndef _GXIO_MPIPE_H_
16#define _GXIO_MPIPE_H_
17
18/*
19 *
20 * An API for allocating, configuring, and manipulating mPIPE hardware
21 * resources.
22 */
23
24#include "common.h"
25#include "dma_queue.h"
26
27#include <linux/time.h>
28
29#include <arch/mpipe_def.h>
30#include <arch/mpipe_shm.h>
31
32#include <hv/drv_mpipe_intf.h>
33#include <hv/iorpc.h>
34
35/*
36 *
37 * The TILE-Gx mPIPE&tm; shim provides Ethernet connectivity, packet
38 * classification, and packet load balancing services. The
39 * gxio_mpipe_ API, declared in <gxio/mpipe.h>, allows applications to
40 * allocate mPIPE IO channels, configure packet distribution
41 * parameters, and send and receive Ethernet packets. The API is
42 * designed to be a minimal wrapper around the mPIPE hardware, making
43 * system calls only where necessary to preserve inter-process
44 * protection guarantees.
45 *
46 * The APIs described below allow the programmer to allocate and
47 * configure mPIPE resources. As described below, the mPIPE is a
48 * single shared hardware device that provides partitionable resources
49 * that are shared between all applications in the system. The
50 * gxio_mpipe_ API allows userspace code to make resource request
51 * calls to the hypervisor, which in turns keeps track of the
52 * resources in use by all applications, maintains protection
53 * guarantees, and resets resources upon application shutdown.
54 *
55 * We strongly recommend reading the mPIPE section of the IO Device
56 * Guide (UG404) before working with this API. Most functions in the
57 * gxio_mpipe_ API are directly analogous to hardware interfaces and
58 * the documentation assumes that the reader understands those
59 * hardware interfaces.
60 *
61 * @section mpipe__ingress mPIPE Ingress Hardware Resources
62 *
63 * The mPIPE ingress hardware provides extensive hardware offload for
64 * tasks like packet header parsing, load balancing, and memory
65 * management. This section provides a brief introduction to the
66 * hardware components and the gxio_mpipe_ calls used to manage them;
67 * see the IO Device Guide for a much more detailed description of the
68 * mPIPE's capabilities.
69 *
70 * When a packet arrives at one of the mPIPE's Ethernet MACs, it is
71 * assigned a channel number indicating which MAC received it. It
72 * then proceeds through the following hardware pipeline:
73 *
74 * @subsection mpipe__classification Classification
75 *
76 * A set of classification processors run header parsing code on each
77 * incoming packet, extracting information including the destination
78 * MAC address, VLAN, Ethernet type, and five-tuple hash. Some of
79 * this information is then used to choose which buffer stack will be
80 * used to hold the packet, and which bucket will be used by the load
81 * balancer to determine which application will receive the packet.
82 *
83 * The rules by which the buffer stack and bucket are chosen can be
84 * configured via the @ref gxio_mpipe_classifier API. A given app can
85 * specify multiple rules, each one specifying a bucket range, and a
86 * set of buffer stacks, to be used for packets matching the rule.
87 * Each rule can optionally specify a restricted set of channels,
88 * VLANs, and/or dMACs, in which it is interested. By default, a
89 * given rule starts out matching all channels associated with the
90 * mPIPE context's set of open links; all VLANs; and all dMACs.
91 * Subsequent restrictions can then be added.
92 *
93 * @subsection mpipe__load_balancing Load Balancing
94 *
95 * The mPIPE load balancer is responsible for choosing the NotifRing
96 * to which the packet will be delivered. This decision is based on
97 * the bucket number indicated by the classification program. In
98 * general, the bucket number is based on some number of low bits of
99 * the packet's flow hash (applications that aren't interested in flow
100 * hashing use a single bucket). Each load balancer bucket keeps a
101 * record of the NotifRing to which packets directed to that bucket
102 * are currently being delivered. Based on the bucket's load
103 * balancing mode (@ref gxio_mpipe_bucket_mode_t), the load balancer
104 * either forwards the packet to the previously assigned NotifRing or
105 * decides to choose a new NotifRing. If a new NotifRing is required,
106 * the load balancer chooses the least loaded ring in the NotifGroup
107 * associated with the bucket.
108 *
109 * The load balancer is a shared resource. Each application needs to
110 * explicitly allocate NotifRings, NotifGroups, and buckets, using
111 * gxio_mpipe_alloc_notif_rings(), gxio_mpipe_alloc_notif_groups(),
112 * and gxio_mpipe_alloc_buckets(). Then the application needs to
113 * configure them using gxio_mpipe_init_notif_ring() and
114 * gxio_mpipe_init_notif_group_and_buckets().
115 *
116 * @subsection mpipe__buffers Buffer Selection and Packet Delivery
117 *
118 * Once the load balancer has chosen the destination NotifRing, the
119 * mPIPE DMA engine pops at least one buffer off of the 'buffer stack'
120 * chosen by the classification program and DMAs the packet data into
121 * that buffer. Each buffer stack provides a hardware-accelerated
122 * stack of data buffers with the same size. If the packet data is
123 * larger than the buffers provided by the chosen buffer stack, the
124 * mPIPE hardware pops off multiple buffers and chains the packet data
125 * through a multi-buffer linked list. Once the packet data is
126 * delivered to the buffer(s), the mPIPE hardware writes the
127 * ::gxio_mpipe_idesc_t metadata object (calculated by the classifier)
128 * into the NotifRing and increments the number of packets delivered
129 * to that ring.
130 *
131 * Applications can push buffers onto a buffer stack by calling
132 * gxio_mpipe_push_buffer() or by egressing a packet with the
133 * ::gxio_mpipe_edesc_t::hwb bit set, indicating that the egressed
134 * buffers should be returned to the stack.
135 *
136 * Applications can allocate and initialize buffer stacks with the
137 * gxio_mpipe_alloc_buffer_stacks() and gxio_mpipe_init_buffer_stack()
138 * APIs.
139 *
140 * The application must also register the memory pages that will hold
141 * packets. This requires calling gxio_mpipe_register_page() for each
142 * memory page that will hold packets allocated by the application for
143 * a given buffer stack. Since each buffer stack is limited to 16
144 * registered pages, it may be necessary to use huge pages, or even
145 * extremely huge pages, to hold all the buffers.
146 *
147 * @subsection mpipe__iqueue NotifRings
148 *
149 * Each NotifRing is a region of shared memory, allocated by the
150 * application, to which the mPIPE delivers packet descriptors
151 * (::gxio_mpipe_idesc_t). The application can allocate them via
152 * gxio_mpipe_alloc_notif_rings(). The application can then either
153 * explicitly initialize them with gxio_mpipe_init_notif_ring() and
154 * then read from them manually, or can make use of the convenience
155 * wrappers provided by @ref gxio_mpipe_wrappers.
156 *
157 * @section mpipe__egress mPIPE Egress Hardware
158 *
159 * Applications use eDMA rings to queue packets for egress. The
160 * application can allocate them via gxio_mpipe_alloc_edma_rings().
161 * The application can then either explicitly initialize them with
162 * gxio_mpipe_init_edma_ring() and then write to them manually, or
163 * can make use of the convenience wrappers provided by
164 * @ref gxio_mpipe_wrappers.
165 *
166 * @section gxio__shortcomings Plans for Future API Revisions
167 *
168 * The API defined here is only an initial version of the mPIPE API.
169 * Future plans include:
170 *
171 * - Higher level wrapper functions to provide common initialization
172 * patterns. This should help users start writing mPIPE programs
173 * without having to learn the details of the hardware.
174 *
175 * - Support for reset and deallocation of resources, including
176 * cleanup upon application shutdown.
177 *
178 * - Support for calling these APIs in the BME.
179 *
180 * - Support for IO interrupts.
181 *
182 * - Clearer definitions of thread safety guarantees.
183 *
184 * @section gxio__mpipe_examples Examples
185 *
186 * See the following mPIPE example programs for more information about
187 * allocating mPIPE resources and using them in real applications:
188 *
189 * - @ref mpipe/ingress/app.c : Receiving packets.
190 *
191 * - @ref mpipe/forward/app.c : Forwarding packets.
192 *
193 * Note that there are several more examples.
194 */
195
196/* Flags that can be passed to resource allocation functions. */
197enum gxio_mpipe_alloc_flags_e {
198 /* Require an allocation to start at a specified resource index. */
199 GXIO_MPIPE_ALLOC_FIXED = HV_MPIPE_ALLOC_FIXED,
200};
201
202/* Flags that can be passed to memory registration functions. */
203enum gxio_mpipe_mem_flags_e {
204 /* Do not fill L3 when writing, and invalidate lines upon egress. */
205 GXIO_MPIPE_MEM_FLAG_NT_HINT = IORPC_MEM_BUFFER_FLAG_NT_HINT,
206
207 /* L3 cache fills should only populate IO cache ways. */
208 GXIO_MPIPE_MEM_FLAG_IO_PIN = IORPC_MEM_BUFFER_FLAG_IO_PIN,
209};
210
211/* An ingress packet descriptor. When a packet arrives, the mPIPE
212 * hardware generates this structure and writes it into a NotifRing.
213 */
214typedef MPIPE_PDESC_t gxio_mpipe_idesc_t;
215
216/* An egress command descriptor. Applications write this structure
217 * into eDMA rings and the hardware performs the indicated operation
218 * (normally involving egressing some bytes). Note that egressing a
219 * single packet may involve multiple egress command descriptors.
220 */
221typedef MPIPE_EDMA_DESC_t gxio_mpipe_edesc_t;
222
223/* Get the "va" field from an "idesc".
224 *
225 * This is the address at which the ingress hardware copied the first
226 * byte of the packet.
227 *
228 * If the classifier detected a custom header, then this will point to
229 * the custom header, and gxio_mpipe_idesc_get_l2_start() will point
230 * to the actual L2 header.
231 *
232 * Note that this value may be misleading if "idesc->be" is set.
233 *
234 * @param idesc An ingress packet descriptor.
235 */
236static inline unsigned char *gxio_mpipe_idesc_get_va(gxio_mpipe_idesc_t *idesc)
237{
238 return (unsigned char *)(long)idesc->va;
239}
240
241/* Get the "xfer_size" from an "idesc".
242 *
243 * This is the actual number of packet bytes transferred into memory
244 * by the hardware.
245 *
246 * Note that this value may be misleading if "idesc->be" is set.
247 *
248 * @param idesc An ingress packet descriptor.
249 *
250 * ISSUE: Is this the best name for this?
251 * FIXME: Add more docs about chaining, clipping, etc.
252 */
253static inline unsigned int gxio_mpipe_idesc_get_xfer_size(gxio_mpipe_idesc_t
254 *idesc)
255{
256 return idesc->l2_size;
257}
258
259/* Get the "l2_offset" from an "idesc".
260 *
261 * Extremely customized classifiers might not support this function.
262 *
263 * This is the number of bytes between the "va" and the L2 header.
264 *
265 * The L2 header consists of a destination mac address, a source mac
266 * address, and an initial ethertype. Various initial ethertypes
267 * allow encoding extra information in the L2 header, often including
268 * a vlan, and/or a new ethertype.
269 *
270 * Note that the "l2_offset" will be non-zero if (and only if) the
271 * classifier processed a custom header for the packet.
272 *
273 * @param idesc An ingress packet descriptor.
274 */
275static inline uint8_t gxio_mpipe_idesc_get_l2_offset(gxio_mpipe_idesc_t *idesc)
276{
277 return (idesc->custom1 >> 32) & 0xFF;
278}
279
280/* Get the "l2_start" from an "idesc".
281 *
282 * This is simply gxio_mpipe_idesc_get_va() plus
283 * gxio_mpipe_idesc_get_l2_offset().
284 *
285 * @param idesc An ingress packet descriptor.
286 */
287static inline unsigned char *gxio_mpipe_idesc_get_l2_start(gxio_mpipe_idesc_t
288 *idesc)
289{
290 unsigned char *va = gxio_mpipe_idesc_get_va(idesc);
291 return va + gxio_mpipe_idesc_get_l2_offset(idesc);
292}
293
294/* Get the "l2_length" from an "idesc".
295 *
296 * This is simply gxio_mpipe_idesc_get_xfer_size() minus
297 * gxio_mpipe_idesc_get_l2_offset().
298 *
299 * @param idesc An ingress packet descriptor.
300 */
301static inline unsigned int gxio_mpipe_idesc_get_l2_length(gxio_mpipe_idesc_t
302 *idesc)
303{
304 unsigned int xfer_size = idesc->l2_size;
305 return xfer_size - gxio_mpipe_idesc_get_l2_offset(idesc);
306}
307
308/* A context object used to manage mPIPE hardware resources. */
309typedef struct {
310
311 /* File descriptor for calling up to Linux (and thus the HV). */
312 int fd;
313
314 /* The VA at which configuration registers are mapped. */
315 char *mmio_cfg_base;
316
317 /* The VA at which IDMA, EDMA, and buffer manager are mapped. */
318 char *mmio_fast_base;
319
320 /* The "initialized" buffer stacks. */
321 gxio_mpipe_rules_stacks_t __stacks;
322
323} gxio_mpipe_context_t;
324
325/* This is only used internally, but it's most easily made visible here. */
326typedef gxio_mpipe_context_t gxio_mpipe_info_context_t;
327
328/* Initialize an mPIPE context.
329 *
330 * This function allocates an mPIPE "service domain" and maps the MMIO
331 * registers into the caller's VA space.
332 *
333 * @param context Context object to be initialized.
334 * @param mpipe_instance Instance number of mPIPE shim to be controlled via
335 * context.
336 */
337extern int gxio_mpipe_init(gxio_mpipe_context_t *context,
338 unsigned int mpipe_instance);
339
340/* Destroy an mPIPE context.
341 *
342 * This function frees the mPIPE "service domain" and unmaps the MMIO
343 * registers from the caller's VA space.
344 *
345 * If a user process exits without calling this routine, the kernel
346 * will destroy the mPIPE context as part of process teardown.
347 *
348 * @param context Context object to be destroyed.
349 */
350extern int gxio_mpipe_destroy(gxio_mpipe_context_t *context);
351
352/*****************************************************************
353 * Buffer Stacks *
354 ******************************************************************/
355
356/* Allocate a set of buffer stacks.
357 *
358 * The return value is NOT interesting if count is zero.
359 *
360 * @param context An initialized mPIPE context.
361 * @param count Number of stacks required.
362 * @param first Index of first stack if ::GXIO_MPIPE_ALLOC_FIXED flag is set,
363 * otherwise ignored.
364 * @param flags Flag bits from ::gxio_mpipe_alloc_flags_e.
365 * @return Index of first allocated buffer stack, or
366 * ::GXIO_MPIPE_ERR_NO_BUFFER_STACK if allocation failed.
367 */
368extern int gxio_mpipe_alloc_buffer_stacks(gxio_mpipe_context_t *context,
369 unsigned int count,
370 unsigned int first,
371 unsigned int flags);
372
373/* Enum codes for buffer sizes supported by mPIPE. */
374typedef enum {
375 /* 128 byte packet data buffer. */
376 GXIO_MPIPE_BUFFER_SIZE_128 = MPIPE_BSM_INIT_DAT_1__SIZE_VAL_BSZ_128,
377 /* 256 byte packet data buffer. */
378 GXIO_MPIPE_BUFFER_SIZE_256 = MPIPE_BSM_INIT_DAT_1__SIZE_VAL_BSZ_256,
379 /* 512 byte packet data buffer. */
380 GXIO_MPIPE_BUFFER_SIZE_512 = MPIPE_BSM_INIT_DAT_1__SIZE_VAL_BSZ_512,
381 /* 1024 byte packet data buffer. */
382 GXIO_MPIPE_BUFFER_SIZE_1024 = MPIPE_BSM_INIT_DAT_1__SIZE_VAL_BSZ_1024,
383 /* 1664 byte packet data buffer. */
384 GXIO_MPIPE_BUFFER_SIZE_1664 = MPIPE_BSM_INIT_DAT_1__SIZE_VAL_BSZ_1664,
385 /* 4096 byte packet data buffer. */
386 GXIO_MPIPE_BUFFER_SIZE_4096 = MPIPE_BSM_INIT_DAT_1__SIZE_VAL_BSZ_4096,
387 /* 10368 byte packet data buffer. */
388 GXIO_MPIPE_BUFFER_SIZE_10368 =
389 MPIPE_BSM_INIT_DAT_1__SIZE_VAL_BSZ_10368,
390 /* 16384 byte packet data buffer. */
391 GXIO_MPIPE_BUFFER_SIZE_16384 = MPIPE_BSM_INIT_DAT_1__SIZE_VAL_BSZ_16384
392} gxio_mpipe_buffer_size_enum_t;
393
394/* Convert a buffer size in bytes into a buffer size enum. */
395extern gxio_mpipe_buffer_size_enum_t
396gxio_mpipe_buffer_size_to_buffer_size_enum(size_t size);
397
398/* Convert a buffer size enum into a buffer size in bytes. */
399extern size_t
400gxio_mpipe_buffer_size_enum_to_buffer_size(gxio_mpipe_buffer_size_enum_t
401 buffer_size_enum);
402
403/* Calculate the number of bytes required to store a given number of
404 * buffers in the memory registered with a buffer stack via
405 * gxio_mpipe_init_buffer_stack().
406 */
407extern size_t gxio_mpipe_calc_buffer_stack_bytes(unsigned long buffers);
408
409/* Initialize a buffer stack. This function binds a region of memory
410 * to be used by the hardware for storing buffer addresses pushed via
411 * gxio_mpipe_push_buffer() or as the result of sending a buffer out
412 * the egress with the 'push to stack when done' bit set. Once this
413 * function returns, the memory region's contents may be arbitrarily
414 * modified by the hardware at any time and software should not access
415 * the memory region again.
416 *
417 * @param context An initialized mPIPE context.
418 * @param stack The buffer stack index.
419 * @param buffer_size_enum The size of each buffer in the buffer stack,
420 * as an enum.
421 * @param mem The address of the buffer stack. This memory must be
422 * physically contiguous and aligned to a 64kB boundary.
423 * @param mem_size The size of the buffer stack, in bytes.
424 * @param mem_flags ::gxio_mpipe_mem_flags_e memory flags.
425 * @return Zero on success, ::GXIO_MPIPE_ERR_INVAL_BUFFER_SIZE if
426 * buffer_size_enum is invalid, ::GXIO_MPIPE_ERR_BAD_BUFFER_STACK if
427 * stack has not been allocated.
428 */
429extern int gxio_mpipe_init_buffer_stack(gxio_mpipe_context_t *context,
430 unsigned int stack,
431 gxio_mpipe_buffer_size_enum_t
432 buffer_size_enum, void *mem,
433 size_t mem_size,
434 unsigned int mem_flags);
435
436/* Push a buffer onto a previously initialized buffer stack.
437 *
438 * The size of the buffer being pushed must match the size that was
439 * registered with gxio_mpipe_init_buffer_stack(). All packet buffer
440 * addresses are 128-byte aligned; the low 7 bits of the specified
441 * buffer address will be ignored.
442 *
443 * @param context An initialized mPIPE context.
444 * @param stack The buffer stack index.
445 * @param buffer The buffer (the low seven bits are ignored).
446 */
447static inline void gxio_mpipe_push_buffer(gxio_mpipe_context_t *context,
448 unsigned int stack, void *buffer)
449{
450 MPIPE_BSM_REGION_ADDR_t offset = { {0} };
451 MPIPE_BSM_REGION_VAL_t val = { {0} };
452
453 /*
454 * The mmio_fast_base region starts at the IDMA region, so subtract
455 * off that initial offset.
456 */
457 offset.region =
458 MPIPE_MMIO_ADDR__REGION_VAL_BSM -
459 MPIPE_MMIO_ADDR__REGION_VAL_IDMA;
460 offset.stack = stack;
461
462#if __SIZEOF_POINTER__ == 4
463 val.va = ((ulong) buffer) >> MPIPE_BSM_REGION_VAL__VA_SHIFT;
464#else
465 val.va = ((long)buffer) >> MPIPE_BSM_REGION_VAL__VA_SHIFT;
466#endif
467
468 __gxio_mmio_write(context->mmio_fast_base + offset.word, val.word);
469}
470
471/* Pop a buffer off of a previously initialized buffer stack.
472 *
473 * @param context An initialized mPIPE context.
474 * @param stack The buffer stack index.
475 * @return The buffer, or NULL if the stack is empty.
476 */
477static inline void *gxio_mpipe_pop_buffer(gxio_mpipe_context_t *context,
478 unsigned int stack)
479{
480 MPIPE_BSM_REGION_ADDR_t offset = { {0} };
481
482 /*
483 * The mmio_fast_base region starts at the IDMA region, so subtract
484 * off that initial offset.
485 */
486 offset.region =
487 MPIPE_MMIO_ADDR__REGION_VAL_BSM -
488 MPIPE_MMIO_ADDR__REGION_VAL_IDMA;
489 offset.stack = stack;
490
491 while (1) {
492 /*
493 * Case 1: val.c == ..._UNCHAINED, va is non-zero.
494 * Case 2: val.c == ..._INVALID, va is zero.
495 * Case 3: val.c == ..._NOT_RDY, va is zero.
496 */
497 MPIPE_BSM_REGION_VAL_t val;
498 val.word =
499 __gxio_mmio_read(context->mmio_fast_base +
500 offset.word);
501
502 /*
503 * Handle case 1 and 2 by returning the buffer (or NULL).
504 * Handle case 3 by waiting for the prefetch buffer to refill.
505 */
506 if (val.c != MPIPE_EDMA_DESC_WORD1__C_VAL_NOT_RDY)
507 return (void *)((unsigned long)val.
508 va << MPIPE_BSM_REGION_VAL__VA_SHIFT);
509 }
510}
511
512/*****************************************************************
513 * NotifRings *
514 ******************************************************************/
515
516/* Allocate a set of NotifRings.
517 *
518 * The return value is NOT interesting if count is zero.
519 *
520 * Note that NotifRings are allocated in chunks, so allocating one at
521 * a time is much less efficient than allocating several at once.
522 *
523 * @param context An initialized mPIPE context.
524 * @param count Number of NotifRings required.
525 * @param first Index of first NotifRing if ::GXIO_MPIPE_ALLOC_FIXED flag
526 * is set, otherwise ignored.
527 * @param flags Flag bits from ::gxio_mpipe_alloc_flags_e.
528 * @return Index of first allocated buffer NotifRing, or
529 * ::GXIO_MPIPE_ERR_NO_NOTIF_RING if allocation failed.
530 */
531extern int gxio_mpipe_alloc_notif_rings(gxio_mpipe_context_t *context,
532 unsigned int count, unsigned int first,
533 unsigned int flags);
534
535/* Initialize a NotifRing, using the given memory and size.
536 *
537 * @param context An initialized mPIPE context.
538 * @param ring The NotifRing index.
539 * @param mem A physically contiguous region of memory to be filled
540 * with a ring of ::gxio_mpipe_idesc_t structures.
541 * @param mem_size Number of bytes in the ring. Must be 128, 512,
542 * 2048, or 65536 * sizeof(gxio_mpipe_idesc_t).
543 * @param mem_flags ::gxio_mpipe_mem_flags_e memory flags.
544 *
545 * @return 0 on success, ::GXIO_MPIPE_ERR_BAD_NOTIF_RING or
546 * ::GXIO_ERR_INVAL_MEMORY_SIZE on failure.
547 */
548extern int gxio_mpipe_init_notif_ring(gxio_mpipe_context_t *context,
549 unsigned int ring,
550 void *mem, size_t mem_size,
551 unsigned int mem_flags);
552
553/* Configure an interrupt to be sent to a tile on incoming NotifRing
554 * traffic. Once an interrupt is sent for a particular ring, no more
555 * will be sent until gxio_mica_enable_notif_ring_interrupt() is called.
556 *
557 * @param context An initialized mPIPE context.
558 * @param x X coordinate of interrupt target tile.
559 * @param y Y coordinate of interrupt target tile.
560 * @param i Index of the IPI register which will receive the interrupt.
561 * @param e Specific event which will be set in the target IPI register when
562 * the interrupt occurs.
563 * @param ring The NotifRing index.
564 * @return Zero on success, GXIO_ERR_INVAL if params are out of range.
565 */
566extern int gxio_mpipe_request_notif_ring_interrupt(gxio_mpipe_context_t
567 *context, int x, int y,
568 int i, int e,
569 unsigned int ring);
570
571/* Enable an interrupt on incoming NotifRing traffic.
572 *
573 * @param context An initialized mPIPE context.
574 * @param ring The NotifRing index.
575 * @return Zero on success, GXIO_ERR_INVAL if params are out of range.
576 */
577extern int gxio_mpipe_enable_notif_ring_interrupt(gxio_mpipe_context_t
578 *context, unsigned int ring);
579
580/* Map all of a client's memory via the given IOTLB.
581 * @param context An initialized mPIPE context.
582 * @param iotlb IOTLB index.
583 * @param pte Page table entry.
584 * @param flags Flags.
585 * @return Zero on success, or a negative error code.
586 */
587extern int gxio_mpipe_register_client_memory(gxio_mpipe_context_t *context,
588 unsigned int iotlb, HV_PTE pte,
589 unsigned int flags);
590
591/*****************************************************************
592 * Notif Groups *
593 ******************************************************************/
594
595/* Allocate a set of NotifGroups.
596 *
597 * The return value is NOT interesting if count is zero.
598 *
599 * @param context An initialized mPIPE context.
600 * @param count Number of NotifGroups required.
601 * @param first Index of first NotifGroup if ::GXIO_MPIPE_ALLOC_FIXED flag
602 * is set, otherwise ignored.
603 * @param flags Flag bits from ::gxio_mpipe_alloc_flags_e.
604 * @return Index of first allocated buffer NotifGroup, or
605 * ::GXIO_MPIPE_ERR_NO_NOTIF_GROUP if allocation failed.
606 */
607extern int gxio_mpipe_alloc_notif_groups(gxio_mpipe_context_t *context,
608 unsigned int count,
609 unsigned int first,
610 unsigned int flags);
611
612/* Add a NotifRing to a NotifGroup. This only sets a bit in the
613 * application's 'group' object; the hardware NotifGroup can be
614 * initialized by passing 'group' to gxio_mpipe_init_notif_group() or
615 * gxio_mpipe_init_notif_group_and_buckets().
616 */
617static inline void
618gxio_mpipe_notif_group_add_ring(gxio_mpipe_notif_group_bits_t *bits, int ring)
619{
620 bits->ring_mask[ring / 64] |= (1ull << (ring % 64));
621}
622
623/* Set a particular NotifGroup bitmask. Since the load balancer
624 * makes decisions based on both bucket and NotifGroup state, most
625 * applications should use gxio_mpipe_init_notif_group_and_buckets()
626 * rather than using this function to configure just a NotifGroup.
627 */
628extern int gxio_mpipe_init_notif_group(gxio_mpipe_context_t *context,
629 unsigned int group,
630 gxio_mpipe_notif_group_bits_t bits);
631
632/*****************************************************************
633 * Load Balancer *
634 ******************************************************************/
635
636/* Allocate a set of load balancer buckets.
637 *
638 * The return value is NOT interesting if count is zero.
639 *
640 * Note that buckets are allocated in chunks, so allocating one at
641 * a time is much less efficient than allocating several at once.
642 *
643 * Note that the buckets are actually divided into two sub-ranges, of
644 * different sizes, and different chunk sizes, and the range you get
645 * by default is determined by the size of the request. Allocations
646 * cannot span the two sub-ranges.
647 *
648 * @param context An initialized mPIPE context.
649 * @param count Number of buckets required.
650 * @param first Index of first bucket if ::GXIO_MPIPE_ALLOC_FIXED flag is set,
651 * otherwise ignored.
652 * @param flags Flag bits from ::gxio_mpipe_alloc_flags_e.
653 * @return Index of first allocated buffer bucket, or
654 * ::GXIO_MPIPE_ERR_NO_BUCKET if allocation failed.
655 */
656extern int gxio_mpipe_alloc_buckets(gxio_mpipe_context_t *context,
657 unsigned int count, unsigned int first,
658 unsigned int flags);
659
660/* The legal modes for gxio_mpipe_bucket_info_t and
661 * gxio_mpipe_init_notif_group_and_buckets().
662 *
663 * All modes except ::GXIO_MPIPE_BUCKET_ROUND_ROBIN expect that the user
664 * will allocate a power-of-two number of buckets and initialize them
665 * to the same mode. The classifier program then uses the appropriate
666 * number of low bits from the incoming packet's flow hash to choose a
667 * load balancer bucket. Based on that bucket's load balancing mode,
668 * reference count, and currently active NotifRing, the load balancer
669 * chooses the NotifRing to which the packet will be delivered.
670 */
671typedef enum {
672 /* All packets for a bucket go to the same NotifRing unless the
673 * NotifRing gets full, in which case packets will be dropped. If
674 * the bucket reference count ever reaches zero, a new NotifRing may
675 * be chosen.
676 */
677 GXIO_MPIPE_BUCKET_DYNAMIC_FLOW_AFFINITY =
678 MPIPE_LBL_INIT_DAT_BSTS_TBL__MODE_VAL_DFA,
679
680 /* All packets for a bucket always go to the same NotifRing.
681 */
682 GXIO_MPIPE_BUCKET_STATIC_FLOW_AFFINITY =
683 MPIPE_LBL_INIT_DAT_BSTS_TBL__MODE_VAL_FIXED,
684
685 /* All packets for a bucket go to the least full NotifRing in the
686 * group, providing load balancing round robin behavior.
687 */
688 GXIO_MPIPE_BUCKET_ROUND_ROBIN =
689 MPIPE_LBL_INIT_DAT_BSTS_TBL__MODE_VAL_ALWAYS_PICK,
690
691 /* All packets for a bucket go to the same NotifRing unless the
692 * NotifRing gets full, at which point the bucket starts using the
693 * least full NotifRing in the group. If all NotifRings in the
694 * group are full, packets will be dropped.
695 */
696 GXIO_MPIPE_BUCKET_STICKY_FLOW_LOCALITY =
697 MPIPE_LBL_INIT_DAT_BSTS_TBL__MODE_VAL_STICKY,
698
699 /* All packets for a bucket go to the same NotifRing unless the
700 * NotifRing gets full, or a random timer fires, at which point the
701 * bucket starts using the least full NotifRing in the group. If
702 * all NotifRings in the group are full, packets will be dropped.
703 * WARNING: This mode is BROKEN on chips with fewer than 64 tiles.
704 */
705 GXIO_MPIPE_BUCKET_PREFER_FLOW_LOCALITY =
706 MPIPE_LBL_INIT_DAT_BSTS_TBL__MODE_VAL_STICKY_RAND,
707
708} gxio_mpipe_bucket_mode_t;
709
710/* Copy a set of bucket initialization values into the mPIPE
711 * hardware. Since the load balancer makes decisions based on both
712 * bucket and NotifGroup state, most applications should use
713 * gxio_mpipe_init_notif_group_and_buckets() rather than using this
714 * function to configure a single bucket.
715 *
716 * @param context An initialized mPIPE context.
717 * @param bucket Bucket index to be initialized.
718 * @param bucket_info Initial reference count, NotifRing index, and mode.
719 * @return 0 on success, ::GXIO_MPIPE_ERR_BAD_BUCKET on failure.
720 */
721extern int gxio_mpipe_init_bucket(gxio_mpipe_context_t *context,
722 unsigned int bucket,
723 gxio_mpipe_bucket_info_t bucket_info);
724
725/* Initializes a group and range of buckets and range of rings such
726 * that the load balancer runs a particular load balancing function.
727 *
728 * First, the group is initialized with the given rings.
729 *
730 * Second, each bucket is initialized with the mode and group, and a
731 * ring chosen round-robin from the given rings.
732 *
733 * Normally, the classifier picks a bucket, and then the load balancer
734 * picks a ring, based on the bucket's mode, group, and current ring,
735 * possibly updating the bucket's ring.
736 *
737 * @param context An initialized mPIPE context.
738 * @param group The group.
739 * @param ring The first ring.
740 * @param num_rings The number of rings.
741 * @param bucket The first bucket.
742 * @param num_buckets The number of buckets.
743 * @param mode The load balancing mode.
744 *
745 * @return 0 on success, ::GXIO_MPIPE_ERR_BAD_BUCKET,
746 * ::GXIO_MPIPE_ERR_BAD_NOTIF_GROUP, or
747 * ::GXIO_MPIPE_ERR_BAD_NOTIF_RING on failure.
748 */
749extern int gxio_mpipe_init_notif_group_and_buckets(gxio_mpipe_context_t
750 *context,
751 unsigned int group,
752 unsigned int ring,
753 unsigned int num_rings,
754 unsigned int bucket,
755 unsigned int num_buckets,
756 gxio_mpipe_bucket_mode_t
757 mode);
758
759/* Return credits to a NotifRing and/or bucket.
760 *
761 * @param context An initialized mPIPE context.
762 * @param ring The NotifRing index, or -1.
763 * @param bucket The bucket, or -1.
764 * @param count The number of credits to return.
765 */
766static inline void gxio_mpipe_credit(gxio_mpipe_context_t *context,
767 int ring, int bucket, unsigned int count)
768{
769 /* NOTE: Fancy struct initialization would break "C89" header test. */
770
771 MPIPE_IDMA_RELEASE_REGION_ADDR_t offset = { {0} };
772 MPIPE_IDMA_RELEASE_REGION_VAL_t val = { {0} };
773
774 /*
775 * The mmio_fast_base region starts at the IDMA region, so subtract
776 * off that initial offset.
777 */
778 offset.region =
779 MPIPE_MMIO_ADDR__REGION_VAL_IDMA -
780 MPIPE_MMIO_ADDR__REGION_VAL_IDMA;
781 offset.ring = ring;
782 offset.bucket = bucket;
783 offset.ring_enable = (ring >= 0);
784 offset.bucket_enable = (bucket >= 0);
785 val.count = count;
786
787 __gxio_mmio_write(context->mmio_fast_base + offset.word, val.word);
788}
789
790/*****************************************************************
791 * Egress Rings *
792 ******************************************************************/
793
794/* Allocate a set of eDMA rings.
795 *
796 * The return value is NOT interesting if count is zero.
797 *
798 * @param context An initialized mPIPE context.
799 * @param count Number of eDMA rings required.
800 * @param first Index of first eDMA ring if ::GXIO_MPIPE_ALLOC_FIXED flag
801 * is set, otherwise ignored.
802 * @param flags Flag bits from ::gxio_mpipe_alloc_flags_e.
803 * @return Index of first allocated buffer eDMA ring, or
804 * ::GXIO_MPIPE_ERR_NO_EDMA_RING if allocation failed.
805 */
806extern int gxio_mpipe_alloc_edma_rings(gxio_mpipe_context_t *context,
807 unsigned int count, unsigned int first,
808 unsigned int flags);
809
810/* Initialize an eDMA ring, using the given memory and size.
811 *
812 * @param context An initialized mPIPE context.
813 * @param ring The eDMA ring index.
814 * @param channel The channel to use. This must be one of the channels
815 * associated with the context's set of open links.
816 * @param mem A physically contiguous region of memory to be filled
817 * with a ring of ::gxio_mpipe_edesc_t structures.
818 * @param mem_size Number of bytes in the ring. Must be 512, 2048,
819 * 8192 or 65536, times 16 (i.e. sizeof(gxio_mpipe_edesc_t)).
820 * @param mem_flags ::gxio_mpipe_mem_flags_e memory flags.
821 *
822 * @return 0 on success, ::GXIO_MPIPE_ERR_BAD_EDMA_RING or
823 * ::GXIO_ERR_INVAL_MEMORY_SIZE on failure.
824 */
825extern int gxio_mpipe_init_edma_ring(gxio_mpipe_context_t *context,
826 unsigned int ring, unsigned int channel,
827 void *mem, size_t mem_size,
828 unsigned int mem_flags);
829
830/*****************************************************************
831 * Classifier Program *
832 ******************************************************************/
833
834/*
835 *
836 * Functions for loading or configuring the mPIPE classifier program.
837 *
838 * The mPIPE classification processors all run a special "classifier"
839 * program which, for each incoming packet, parses the packet headers,
840 * encodes some packet metadata in the "idesc", and either drops the
841 * packet, or picks a notif ring to handle the packet, and a buffer
842 * stack to contain the packet, usually based on the channel, VLAN,
843 * dMAC, flow hash, and packet size, under the guidance of the "rules"
844 * API described below.
845 *
846 * @section gxio_mpipe_classifier_default Default Classifier
847 *
848 * The MDE provides a simple "default" classifier program. It is
849 * shipped as source in "$TILERA_ROOT/src/sys/mpipe/classifier.c",
850 * which serves as its official documentation. It is shipped as a
851 * binary program in "$TILERA_ROOT/tile/boot/classifier", which is
852 * automatically included in bootroms created by "tile-monitor", and
853 * is automatically loaded by the hypervisor at boot time.
854 *
855 * The L2 analysis handles LLC packets, SNAP packets, and "VLAN
856 * wrappers" (keeping the outer VLAN).
857 *
858 * The L3 analysis handles IPv4 and IPv6, dropping packets with bad
859 * IPv4 header checksums, requesting computation of a TCP/UDP checksum
860 * if appropriate, and hashing the dest and src IP addresses, plus the
861 * ports for TCP/UDP packets, into the flow hash. No special analysis
862 * is done for "fragmented" packets or "tunneling" protocols. Thus,
863 * the first fragment of a fragmented TCP/UDP packet is hashed using
864 * src/dest IP address and ports and all subsequent fragments are only
865 * hashed according to src/dest IP address.
866 *
867 * The L3 analysis handles other packets too, hashing the dMAC
868 * smac into a flow hash.
869 *
870 * The channel, VLAN, and dMAC used to pick a "rule" (see the
871 * "rules" APIs below), which in turn is used to pick a buffer stack
872 * (based on the packet size) and a bucket (based on the flow hash).
873 *
874 * To receive traffic matching a particular (channel/VLAN/dMAC
875 * pattern, an application should allocate its own buffer stacks and
876 * load balancer buckets, and map traffic to those stacks and buckets,
877 * as decribed by the "rules" API below.
878 *
879 * Various packet metadata is encoded in the idesc. The flow hash is
880 * four bytes at 0x0C. The VLAN is two bytes at 0x10. The ethtype is
881 * two bytes at 0x12. The l3 start is one byte at 0x14. The l4 start
882 * is one byte at 0x15 for IPv4 and IPv6 packets, and otherwise zero.
883 * The protocol is one byte at 0x16 for IPv4 and IPv6 packets, and
884 * otherwise zero.
885 *
886 * @section gxio_mpipe_classifier_custom Custom Classifiers.
887 *
888 * A custom classifier may be created using "tile-mpipe-cc" with a
889 * customized version of the default classifier sources.
890 *
891 * The custom classifier may be included in bootroms using the
892 * "--classifier" option to "tile-monitor", or loaded dynamically
893 * using gxio_mpipe_classifier_load_from_file().
894 *
895 * Be aware that "extreme" customizations may break the assumptions of
896 * the "rules" APIs described below, but simple customizations, such
897 * as adding new packet metadata, should be fine.
898 */
899
900/* A set of classifier rules, plus a context. */
901typedef struct {
902
903 /* The context. */
904 gxio_mpipe_context_t *context;
905
906 /* The actual rules. */
907 gxio_mpipe_rules_list_t list;
908
909} gxio_mpipe_rules_t;
910
911/* Initialize a classifier program rules list.
912 *
913 * This function can be called on a previously initialized rules list
914 * to discard any previously added rules.
915 *
916 * @param rules Rules list to initialize.
917 * @param context An initialized mPIPE context.
918 */
919extern void gxio_mpipe_rules_init(gxio_mpipe_rules_t *rules,
920 gxio_mpipe_context_t *context);
921
922/* Begin a new rule on the indicated rules list.
923 *
924 * Note that an empty rule matches all packets, but an empty rule list
925 * matches no packets.
926 *
927 * @param rules Rules list to which new rule is appended.
928 * @param bucket First load balancer bucket to which packets will be
929 * delivered.
930 * @param num_buckets Number of buckets (must be a power of two) across
931 * which packets will be distributed based on the "flow hash".
932 * @param stacks Either NULL, to assign each packet to the smallest
933 * initialized buffer stack which does not induce chaining (and to
934 * drop packets which exceed the largest initialized buffer stack
935 * buffer size), or an array, with each entry indicating which buffer
936 * stack should be used for packets up to that size (with 255
937 * indicating that those packets should be dropped).
938 * @return 0 on success, or a negative error code on failure.
939 */
940extern int gxio_mpipe_rules_begin(gxio_mpipe_rules_t *rules,
941 unsigned int bucket,
942 unsigned int num_buckets,
943 gxio_mpipe_rules_stacks_t *stacks);
944
945/* Set the headroom of the current rule.
946 *
947 * @param rules Rules list whose current rule will be modified.
948 * @param headroom The headroom.
949 * @return 0 on success, or a negative error code on failure.
950 */
951extern int gxio_mpipe_rules_set_headroom(gxio_mpipe_rules_t *rules,
952 uint8_t headroom);
953
954/* Indicate that packets from a particular channel can be delivered
955 * to the buckets and buffer stacks associated with the current rule.
956 *
957 * Channels added must be associated with links opened by the mPIPE context
958 * used in gxio_mpipe_rules_init(). A rule with no channels is equivalent
959 * to a rule naming all such associated channels.
960 *
961 * @param rules Rules list whose current rule will be modified.
962 * @param channel The channel to add.
963 * @return 0 on success, or a negative error code on failure.
964 */
965extern int gxio_mpipe_rules_add_channel(gxio_mpipe_rules_t *rules,
966 unsigned int channel);
967
968/* Commit rules.
969 *
970 * The rules are sent to the hypervisor, where they are combined with
971 * the rules from other apps, and used to program the hardware classifier.
972 *
973 * Note that if this function returns an error, then the rules will NOT
974 * have been committed, even if the error is due to interactions with
975 * rules from another app.
976 *
977 * @param rules Rules list to commit.
978 * @return 0 on success, or a negative error code on failure.
979 */
980extern int gxio_mpipe_rules_commit(gxio_mpipe_rules_t *rules);
981
982/*****************************************************************
983 * Ingress Queue Wrapper *
984 ******************************************************************/
985
986/*
987 *
988 * Convenience functions for receiving packets from a NotifRing and
989 * sending packets via an eDMA ring.
990 *
991 * The mpipe ingress and egress hardware uses shared memory packet
992 * descriptors to describe packets that have arrived on ingress or
993 * are destined for egress. These descriptors are stored in shared
994 * memory ring buffers and written or read by hardware as necessary.
995 * The gxio library provides wrapper functions that manage the head and
996 * tail pointers for these rings, allowing the user to easily read or
997 * write packet descriptors.
998 *
999 * The initialization interface for ingress and egress rings is quite
1000 * similar. For example, to create an ingress queue, the user passes
1001 * a ::gxio_mpipe_iqueue_t state object, a ring number from
1002 * gxio_mpipe_alloc_notif_rings(), and the address of memory to hold a
1003 * ring buffer to the gxio_mpipe_iqueue_init() function. The function
1004 * returns success when the state object has been initialized and the
1005 * hardware configured to deliver packets to the specified ring
1006 * buffer. Similarly, gxio_mpipe_equeue_init() takes a
1007 * ::gxio_mpipe_equeue_t state object, a ring number from
1008 * gxio_mpipe_alloc_edma_rings(), and a shared memory buffer.
1009 *
1010 * @section gxio_mpipe_iqueue Working with Ingress Queues
1011 *
1012 * Once initialized, the gxio_mpipe_iqueue_t API provides two flows
1013 * for getting the ::gxio_mpipe_idesc_t packet descriptor associated
1014 * with incoming packets. The simplest is to call
1015 * gxio_mpipe_iqueue_get() or gxio_mpipe_iqueue_try_get(). These
1016 * functions copy the oldest packet descriptor out of the NotifRing and
1017 * into a descriptor provided by the caller. They also immediately
1018 * inform the hardware that a descriptor has been processed.
1019 *
1020 * For applications with stringent performance requirements, higher
1021 * efficiency can be achieved by avoiding the packet descriptor copy
1022 * and processing multiple descriptors at once. The
1023 * gxio_mpipe_iqueue_peek() and gxio_mpipe_iqueue_try_peek() functions
1024 * allow such optimizations. These functions provide a pointer to the
1025 * next valid ingress descriptor in the NotifRing's shared memory ring
1026 * buffer, and a count of how many contiguous descriptors are ready to
1027 * be processed. The application can then process any number of those
1028 * descriptors in place, calling gxio_mpipe_iqueue_consume() to inform
1029 * the hardware after each one has been processed.
1030 *
1031 * @section gxio_mpipe_equeue Working with Egress Queues
1032 *
1033 * Similarly, the egress queue API provides a high-performance
1034 * interface plus a simple wrapper for use in posting
1035 * ::gxio_mpipe_edesc_t egress packet descriptors. The simple
1036 * version, gxio_mpipe_equeue_put(), allows the programmer to wait for
1037 * an eDMA ring slot to become available and write a single descriptor
1038 * into the ring.
1039 *
1040 * Alternatively, you can reserve slots in the eDMA ring using
1041 * gxio_mpipe_equeue_reserve() or gxio_mpipe_equeue_try_reserve(), and
1042 * then fill in each slot using gxio_mpipe_equeue_put_at(). This
1043 * capability can be used to amortize the cost of reserving slots
1044 * across several packets. It also allows gather operations to be
1045 * performed on a shared equeue, by ensuring that the edescs for all
1046 * the fragments are all contiguous in the eDMA ring.
1047 *
1048 * The gxio_mpipe_equeue_reserve() and gxio_mpipe_equeue_try_reserve()
1049 * functions return a 63-bit "completion slot", which is actually a
1050 * sequence number, the low bits of which indicate the ring buffer
1051 * index and the high bits the number of times the application has
1052 * gone around the egress ring buffer. The extra bits allow an
1053 * application to check for egress completion by calling
1054 * gxio_mpipe_equeue_is_complete() to see whether a particular 'slot'
1055 * number has finished. Given the maximum packet rates of the Gx
1056 * processor, the 63-bit slot number will never wrap.
1057 *
1058 * In practice, most applications use the ::gxio_mpipe_edesc_t::hwb
1059 * bit to indicate that the buffers containing egress packet data
1060 * should be pushed onto a buffer stack when egress is complete. Such
1061 * applications generally do not need to know when an egress operation
1062 * completes (since there is no need to free a buffer post-egress),
1063 * and thus can use the optimized gxio_mpipe_equeue_reserve_fast() or
1064 * gxio_mpipe_equeue_try_reserve_fast() functions, which return a 24
1065 * bit "slot", instead of a 63-bit "completion slot".
1066 *
1067 * Once a slot has been "reserved", it MUST be filled. If the
1068 * application reserves a slot and then decides that it does not
1069 * actually need it, it can set the ::gxio_mpipe_edesc_t::ns (no send)
1070 * bit on the descriptor passed to gxio_mpipe_equeue_put_at() to
1071 * indicate that no data should be sent. This technique can also be
1072 * used to drop an incoming packet, instead of forwarding it, since
1073 * any buffer will still be pushed onto the buffer stack when the
1074 * egress descriptor is processed.
1075 */
1076
1077/* A convenient interface to a NotifRing, for use by a single thread.
1078 */
1079typedef struct {
1080
1081 /* The context. */
1082 gxio_mpipe_context_t *context;
1083
1084 /* The actual NotifRing. */
1085 gxio_mpipe_idesc_t *idescs;
1086
1087 /* The number of entries. */
1088 unsigned long num_entries;
1089
1090 /* The number of entries minus one. */
1091 unsigned long mask_num_entries;
1092
1093 /* The log2() of the number of entries. */
1094 unsigned long log2_num_entries;
1095
1096 /* The next entry. */
1097 unsigned int head;
1098
1099 /* The NotifRing id. */
1100 unsigned int ring;
1101
1102#ifdef __BIG_ENDIAN__
1103 /* The number of byteswapped entries. */
1104 unsigned int swapped;
1105#endif
1106
1107} gxio_mpipe_iqueue_t;
1108
1109/* Initialize an "iqueue".
1110 *
1111 * Takes the iqueue plus the same args as gxio_mpipe_init_notif_ring().
1112 */
1113extern int gxio_mpipe_iqueue_init(gxio_mpipe_iqueue_t *iqueue,
1114 gxio_mpipe_context_t *context,
1115 unsigned int ring,
1116 void *mem, size_t mem_size,
1117 unsigned int mem_flags);
1118
1119/* Advance over some old entries in an iqueue.
1120 *
1121 * Please see the documentation for gxio_mpipe_iqueue_consume().
1122 *
1123 * @param iqueue An ingress queue initialized via gxio_mpipe_iqueue_init().
1124 * @param count The number of entries to advance over.
1125 */
1126static inline void gxio_mpipe_iqueue_advance(gxio_mpipe_iqueue_t *iqueue,
1127 int count)
1128{
1129 /* Advance with proper wrap. */
1130 int head = iqueue->head + count;
1131 iqueue->head =
1132 (head & iqueue->mask_num_entries) +
1133 (head >> iqueue->log2_num_entries);
1134
1135#ifdef __BIG_ENDIAN__
1136 /* HACK: Track swapped entries. */
1137 iqueue->swapped -= count;
1138#endif
1139}
1140
1141/* Release the ring and bucket for an old entry in an iqueue.
1142 *
1143 * Releasing the ring allows more packets to be delivered to the ring.
1144 *
1145 * Releasing the bucket allows flows using the bucket to be moved to a
1146 * new ring when using GXIO_MPIPE_BUCKET_DYNAMIC_FLOW_AFFINITY.
1147 *
1148 * This function is shorthand for "gxio_mpipe_credit(iqueue->context,
1149 * iqueue->ring, idesc->bucket_id, 1)", and it may be more convenient
1150 * to make that underlying call, using those values, instead of
1151 * tracking the entire "idesc".
1152 *
1153 * If packet processing is deferred, optimal performance requires that
1154 * the releasing be deferred as well.
1155 *
1156 * Please see the documentation for gxio_mpipe_iqueue_consume().
1157 *
1158 * @param iqueue An ingress queue initialized via gxio_mpipe_iqueue_init().
1159 * @param idesc The descriptor which was processed.
1160 */
1161static inline void gxio_mpipe_iqueue_release(gxio_mpipe_iqueue_t *iqueue,
1162 gxio_mpipe_idesc_t *idesc)
1163{
1164 gxio_mpipe_credit(iqueue->context, iqueue->ring, idesc->bucket_id, 1);
1165}
1166
1167/* Consume a packet from an "iqueue".
1168 *
1169 * After processing packets peeked at via gxio_mpipe_iqueue_peek()
1170 * or gxio_mpipe_iqueue_try_peek(), you must call this function, or
1171 * gxio_mpipe_iqueue_advance() plus gxio_mpipe_iqueue_release(), to
1172 * advance over those entries, and release their rings and buckets.
1173 *
1174 * You may call this function as each packet is processed, or you can
1175 * wait until several packets have been processed.
1176 *
1177 * Note that if you are using a single bucket, and you are handling
1178 * batches of N packets, then you can replace several calls to this
1179 * function with calls to "gxio_mpipe_iqueue_advance(iqueue, N)" and
1180 * "gxio_mpipe_credit(iqueue->context, iqueue->ring, bucket, N)".
1181 *
1182 * Note that if your classifier sets "idesc->nr", then you should
1183 * explicitly call "gxio_mpipe_iqueue_advance(iqueue, idesc)" plus
1184 * "gxio_mpipe_credit(iqueue->context, iqueue->ring, -1, 1)", to
1185 * avoid incorrectly crediting the (unused) bucket.
1186 *
1187 * @param iqueue An ingress queue initialized via gxio_mpipe_iqueue_init().
1188 * @param idesc The descriptor which was processed.
1189 */
1190static inline void gxio_mpipe_iqueue_consume(gxio_mpipe_iqueue_t *iqueue,
1191 gxio_mpipe_idesc_t *idesc)
1192{
1193 gxio_mpipe_iqueue_advance(iqueue, 1);
1194 gxio_mpipe_iqueue_release(iqueue, idesc);
1195}
1196
1197/* Peek at the next packet(s) in an "iqueue", without waiting.
1198 *
1199 * If no packets are available, fills idesc_ref with NULL, and then
1200 * returns ::GXIO_MPIPE_ERR_IQUEUE_EMPTY. Otherwise, fills idesc_ref
1201 * with the address of the next valid packet descriptor, and returns
1202 * the maximum number of valid descriptors which can be processed.
1203 * You may process fewer descriptors if desired.
1204 *
1205 * Call gxio_mpipe_iqueue_consume() on each packet once it has been
1206 * processed (or dropped), to allow more packets to be delivered.
1207 *
1208 * @param iqueue An ingress queue initialized via gxio_mpipe_iqueue_init().
1209 * @param idesc_ref A pointer to a packet descriptor pointer.
1210 * @return The (positive) number of packets which can be processed,
1211 * or ::GXIO_MPIPE_ERR_IQUEUE_EMPTY if no packets are available.
1212 */
1213static inline int gxio_mpipe_iqueue_try_peek(gxio_mpipe_iqueue_t *iqueue,
1214 gxio_mpipe_idesc_t **idesc_ref)
1215{
1216 gxio_mpipe_idesc_t *next;
1217
1218 uint64_t head = iqueue->head;
1219 uint64_t tail = __gxio_mmio_read(iqueue->idescs);
1220
1221 /* Available entries. */
1222 uint64_t avail =
1223 (tail >= head) ? (tail - head) : (iqueue->num_entries - head);
1224
1225 if (avail == 0) {
1226 *idesc_ref = NULL;
1227 return GXIO_MPIPE_ERR_IQUEUE_EMPTY;
1228 }
1229
1230 next = &iqueue->idescs[head];
1231
1232 /* ISSUE: Is this helpful? */
1233 __insn_prefetch(next);
1234
1235#ifdef __BIG_ENDIAN__
1236 /* HACK: Swap new entries directly in memory. */
1237 {
1238 int i, j;
1239 for (i = iqueue->swapped; i < avail; i++) {
1240 for (j = 0; j < 8; j++)
1241 next[i].words[j] =
1242 __builtin_bswap64(next[i].words[j]);
1243 }
1244 iqueue->swapped = avail;
1245 }
1246#endif
1247
1248 *idesc_ref = next;
1249
1250 return avail;
1251}
1252
1253/* Drop a packet by pushing its buffer (if appropriate).
1254 *
1255 * NOTE: The caller must still call gxio_mpipe_iqueue_consume() if idesc
1256 * came from gxio_mpipe_iqueue_try_peek() or gxio_mpipe_iqueue_peek().
1257 *
1258 * @param iqueue An ingress queue initialized via gxio_mpipe_iqueue_init().
1259 * @param idesc A packet descriptor.
1260 */
1261static inline void gxio_mpipe_iqueue_drop(gxio_mpipe_iqueue_t *iqueue,
1262 gxio_mpipe_idesc_t *idesc)
1263{
1264 /* FIXME: Handle "chaining" properly. */
1265
1266 if (!idesc->be) {
1267 unsigned char *va = gxio_mpipe_idesc_get_va(idesc);
1268 gxio_mpipe_push_buffer(iqueue->context, idesc->stack_idx, va);
1269 }
1270}
1271
1272/*****************************************************************
1273 * Egress Queue Wrapper *
1274 ******************************************************************/
1275
1276/* A convenient, thread-safe interface to an eDMA ring. */
1277typedef struct {
1278
1279 /* State object for tracking head and tail pointers. */
1280 __gxio_dma_queue_t dma_queue;
1281
1282 /* The ring entries. */
1283 gxio_mpipe_edesc_t *edescs;
1284
1285 /* The number of entries minus one. */
1286 unsigned long mask_num_entries;
1287
1288 /* The log2() of the number of entries. */
1289 unsigned long log2_num_entries;
1290
1291} gxio_mpipe_equeue_t;
1292
1293/* Initialize an "equeue".
1294 *
1295 * Takes the equeue plus the same args as gxio_mpipe_init_edma_ring().
1296 */
1297extern int gxio_mpipe_equeue_init(gxio_mpipe_equeue_t *equeue,
1298 gxio_mpipe_context_t *context,
1299 unsigned int edma_ring_id,
1300 unsigned int channel,
1301 void *mem, unsigned int mem_size,
1302 unsigned int mem_flags);
1303
1304/* Reserve completion slots for edescs.
1305 *
1306 * Use gxio_mpipe_equeue_put_at() to actually populate the slots.
1307 *
1308 * This function is slower than gxio_mpipe_equeue_reserve_fast(), but
1309 * returns a full 64 bit completion slot, which can be used with
1310 * gxio_mpipe_equeue_is_complete().
1311 *
1312 * @param equeue An egress queue initialized via gxio_mpipe_equeue_init().
1313 * @param num Number of slots to reserve (must be non-zero).
1314 * @return The first reserved completion slot, or a negative error code.
1315 */
1316static inline int64_t gxio_mpipe_equeue_reserve(gxio_mpipe_equeue_t *equeue,
1317 unsigned int num)
1318{
1319 return __gxio_dma_queue_reserve_aux(&equeue->dma_queue, num, true);
1320}
1321
1322/* Reserve completion slots for edescs, if possible.
1323 *
1324 * Use gxio_mpipe_equeue_put_at() to actually populate the slots.
1325 *
1326 * This function is slower than gxio_mpipe_equeue_try_reserve_fast(),
1327 * but returns a full 64 bit completion slot, which can be used with
1328 * gxio_mpipe_equeue_is_complete().
1329 *
1330 * @param equeue An egress queue initialized via gxio_mpipe_equeue_init().
1331 * @param num Number of slots to reserve (must be non-zero).
1332 * @return The first reserved completion slot, or a negative error code.
1333 */
1334static inline int64_t gxio_mpipe_equeue_try_reserve(gxio_mpipe_equeue_t
1335 *equeue, unsigned int num)
1336{
1337 return __gxio_dma_queue_reserve_aux(&equeue->dma_queue, num, false);
1338}
1339
1340/* Reserve slots for edescs.
1341 *
1342 * Use gxio_mpipe_equeue_put_at() to actually populate the slots.
1343 *
1344 * This function is faster than gxio_mpipe_equeue_reserve(), but
1345 * returns a 24 bit slot (instead of a 64 bit completion slot), which
1346 * thus cannot be used with gxio_mpipe_equeue_is_complete().
1347 *
1348 * @param equeue An egress queue initialized via gxio_mpipe_equeue_init().
1349 * @param num Number of slots to reserve (should be non-zero).
1350 * @return The first reserved slot, or a negative error code.
1351 */
1352static inline int64_t gxio_mpipe_equeue_reserve_fast(gxio_mpipe_equeue_t
1353 *equeue, unsigned int num)
1354{
1355 return __gxio_dma_queue_reserve(&equeue->dma_queue, num, true, false);
1356}
1357
1358/* Reserve slots for edescs, if possible.
1359 *
1360 * Use gxio_mpipe_equeue_put_at() to actually populate the slots.
1361 *
1362 * This function is faster than gxio_mpipe_equeue_try_reserve(), but
1363 * returns a 24 bit slot (instead of a 64 bit completion slot), which
1364 * thus cannot be used with gxio_mpipe_equeue_is_complete().
1365 *
1366 * @param equeue An egress queue initialized via gxio_mpipe_equeue_init().
1367 * @param num Number of slots to reserve (should be non-zero).
1368 * @return The first reserved slot, or a negative error code.
1369 */
1370static inline int64_t gxio_mpipe_equeue_try_reserve_fast(gxio_mpipe_equeue_t
1371 *equeue,
1372 unsigned int num)
1373{
1374 return __gxio_dma_queue_reserve(&equeue->dma_queue, num, false, false);
1375}
1376
1377/*
1378 * HACK: This helper function tricks gcc 4.6 into avoiding saving
1379 * a copy of "edesc->words[0]" on the stack for no obvious reason.
1380 */
1381
1382static inline void gxio_mpipe_equeue_put_at_aux(gxio_mpipe_equeue_t *equeue,
1383 uint_reg_t ew[2],
1384 unsigned long slot)
1385{
1386 unsigned long edma_slot = slot & equeue->mask_num_entries;
1387 gxio_mpipe_edesc_t *edesc_p = &equeue->edescs[edma_slot];
1388
1389 /*
1390 * ISSUE: Could set eDMA ring to be on generation 1 at start, which
1391 * would avoid the negation here, perhaps allowing "__insn_bfins()".
1392 */
1393 ew[0] |= !((slot >> equeue->log2_num_entries) & 1);
1394
1395 /*
1396 * NOTE: We use "__gxio_mpipe_write()", plus the fact that the eDMA
1397 * queue alignment restrictions ensure that these two words are on
1398 * the same cacheline, to force proper ordering between the stores.
1399 */
1400 __gxio_mmio_write64(&edesc_p->words[1], ew[1]);
1401 __gxio_mmio_write64(&edesc_p->words[0], ew[0]);
1402}
1403
1404/* Post an edesc to a given slot in an equeue.
1405 *
1406 * This function copies the supplied edesc into entry "slot mod N" in
1407 * the underlying ring, setting the "gen" bit to the appropriate value
1408 * based on "(slot mod N*2)", where "N" is the size of the ring. Note
1409 * that the higher bits of slot are unused, and thus, this function
1410 * can handle "slots" as well as "completion slots".
1411 *
1412 * Normally this function is used to fill in slots reserved by
1413 * gxio_mpipe_equeue_try_reserve(), gxio_mpipe_equeue_reserve(),
1414 * gxio_mpipe_equeue_try_reserve_fast(), or
1415 * gxio_mpipe_equeue_reserve_fast(),
1416 *
1417 * This function can also be used without "reserving" slots, if the
1418 * application KNOWS that the ring can never overflow, for example, by
1419 * pushing fewer buffers into the buffer stacks than there are total
1420 * slots in the equeue, but this is NOT recommended.
1421 *
1422 * @param equeue An egress queue initialized via gxio_mpipe_equeue_init().
1423 * @param edesc The egress descriptor to be posted.
1424 * @param slot An egress slot (only the low bits are actually used).
1425 */
1426static inline void gxio_mpipe_equeue_put_at(gxio_mpipe_equeue_t *equeue,
1427 gxio_mpipe_edesc_t edesc,
1428 unsigned long slot)
1429{
1430 gxio_mpipe_equeue_put_at_aux(equeue, edesc.words, slot);
1431}
1432
1433/* Post an edesc to the next slot in an equeue.
1434 *
1435 * This is a convenience wrapper around
1436 * gxio_mpipe_equeue_reserve_fast() and gxio_mpipe_equeue_put_at().
1437 *
1438 * @param equeue An egress queue initialized via gxio_mpipe_equeue_init().
1439 * @param edesc The egress descriptor to be posted.
1440 * @return 0 on success.
1441 */
1442static inline int gxio_mpipe_equeue_put(gxio_mpipe_equeue_t *equeue,
1443 gxio_mpipe_edesc_t edesc)
1444{
1445 int64_t slot = gxio_mpipe_equeue_reserve_fast(equeue, 1);
1446 if (slot < 0)
1447 return (int)slot;
1448
1449 gxio_mpipe_equeue_put_at(equeue, edesc, slot);
1450
1451 return 0;
1452}
1453
1454/* Ask the mPIPE hardware to egress outstanding packets immediately.
1455 *
1456 * This call is not necessary, but may slightly reduce overall latency.
1457 *
1458 * Technically, you should flush all gxio_mpipe_equeue_put_at() writes
1459 * to memory before calling this function, to ensure the descriptors
1460 * are visible in memory before the mPIPE hardware actually looks for
1461 * them. But this should be very rare, and the only side effect would
1462 * be increased latency, so it is up to the caller to decide whether
1463 * or not to flush memory.
1464 *
1465 * @param equeue An egress queue initialized via gxio_mpipe_equeue_init().
1466 */
1467static inline void gxio_mpipe_equeue_flush(gxio_mpipe_equeue_t *equeue)
1468{
1469 /* Use "ring_idx = 0" and "count = 0" to "wake up" the eDMA ring. */
1470 MPIPE_EDMA_POST_REGION_VAL_t val = { {0} };
1471 /* Flush the write buffers. */
1472 __insn_flushwb();
1473 __gxio_mmio_write(equeue->dma_queue.post_region_addr, val.word);
1474}
1475
1476/* Determine if a given edesc has been completed.
1477 *
1478 * Note that this function requires a "completion slot", and thus may
1479 * NOT be used with a "slot" from gxio_mpipe_equeue_reserve_fast() or
1480 * gxio_mpipe_equeue_try_reserve_fast().
1481 *
1482 * @param equeue An egress queue initialized via gxio_mpipe_equeue_init().
1483 * @param completion_slot The completion slot used by the edesc.
1484 * @param update If true, and the desc does not appear to have completed
1485 * yet, then update any software cache of the hardware completion counter,
1486 * and check again. This should normally be true.
1487 * @return True iff the given edesc has been completed.
1488 */
1489static inline int gxio_mpipe_equeue_is_complete(gxio_mpipe_equeue_t *equeue,
1490 int64_t completion_slot,
1491 int update)
1492{
1493 return __gxio_dma_queue_is_complete(&equeue->dma_queue,
1494 completion_slot, update);
1495}
1496
1497/*****************************************************************
1498 * Link Management *
1499 ******************************************************************/
1500
1501/*
1502 *
1503 * Functions for manipulating and sensing the state and configuration
1504 * of physical network links.
1505 *
1506 * @section gxio_mpipe_link_perm Link Permissions
1507 *
1508 * Opening a link (with gxio_mpipe_link_open()) requests a set of link
1509 * permissions, which control what may be done with the link, and potentially
1510 * what permissions may be granted to other processes.
1511 *
1512 * Data permission allows the process to receive packets from the link by
1513 * specifying the link's channel number in mPIPE packet distribution rules,
1514 * and to send packets to the link by using the link's channel number as
1515 * the target for an eDMA ring.
1516 *
1517 * Stats permission allows the process to retrieve link attributes (such as
1518 * the speeds it is capable of running at, or whether it is currently up), and
1519 * to read and write certain statistics-related registers in the link's MAC.
1520 *
1521 * Control permission allows the process to retrieve and modify link attributes
1522 * (so that it may, for example, bring the link up and take it down), and
1523 * read and write many registers in the link's MAC and PHY.
1524 *
1525 * Any permission may be requested as shared, which allows other processes
1526 * to also request shared permission, or exclusive, which prevents other
1527 * processes from requesting it. In keeping with GXIO's typical usage in
1528 * an embedded environment, the defaults for all permissions are shared.
1529 *
1530 * Permissions are granted on a first-come, first-served basis, so if two
1531 * applications request an exclusive permission on the same link, the one
1532 * to run first will win. Note, however, that some system components, like
1533 * the kernel Ethernet driver, may get an opportunity to open links before
1534 * any applications run.
1535 *
1536 * @section gxio_mpipe_link_names Link Names
1537 *
1538 * Link names are of the form gbe<em>number</em> (for Gigabit Ethernet),
1539 * xgbe<em>number</em> (for 10 Gigabit Ethernet), loop<em>number</em> (for
1540 * internal mPIPE loopback), or ilk<em>number</em>/<em>channel</em>
1541 * (for Interlaken links); for instance, gbe0, xgbe1, loop3, and
1542 * ilk0/12 are all possible link names. The correspondence between
1543 * the link name and an mPIPE instance number or mPIPE channel number is
1544 * system-dependent; all links will not exist on all systems, and the set
1545 * of numbers used for a particular link type may not start at zero and may
1546 * not be contiguous. Use gxio_mpipe_link_enumerate() to retrieve the set of
1547 * links which exist on a system, and always use gxio_mpipe_link_instance()
1548 * to determine which mPIPE controls a particular link.
1549 *
1550 * Note that in some cases, links may share hardware, such as PHYs, or
1551 * internal mPIPE buffers; in these cases, only one of the links may be
1552 * opened at a time. This is especially common with xgbe and gbe ports,
1553 * since each xgbe port uses 4 SERDES lanes, each of which may also be
1554 * configured as one gbe port.
1555 *
1556 * @section gxio_mpipe_link_states Link States
1557 *
1558 * The mPIPE link management model revolves around three different states,
1559 * which are maintained for each link:
1560 *
1561 * 1. The <em>current</em> link state: is the link up now, and if so, at
1562 * what speed?
1563 *
1564 * 2. The <em>desired</em> link state: what do we want the link state to be?
1565 * The system is always working to make this state the current state;
1566 * thus, if the desired state is up, and the link is down, we'll be
1567 * constantly trying to bring it up, automatically.
1568 *
1569 * 3. The <em>possible</em> link state: what speeds are valid for this
1570 * particular link? Or, in other words, what are the capabilities of
1571 * the link hardware?
1572 *
1573 * These link states are not, strictly speaking, related to application
1574 * state; they may be manipulated at any time, whether or not the link
1575 * is currently being used for data transfer. However, for convenience,
1576 * gxio_mpipe_link_open() and gxio_mpipe_link_close() (or application exit)
1577 * can affect the link state. These implicit link management operations
1578 * may be modified or disabled by the use of link open flags.
1579 *
1580 * From an application, you can use gxio_mpipe_link_get_attr()
1581 * and gxio_mpipe_link_set_attr() to manipulate the link states.
1582 * gxio_mpipe_link_get_attr() with ::GXIO_MPIPE_LINK_POSSIBLE_STATE
1583 * gets you the possible link state. gxio_mpipe_link_get_attr() with
1584 * ::GXIO_MPIPE_LINK_CURRENT_STATE gets you the current link state.
1585 * Finally, gxio_mpipe_link_set_attr() and gxio_mpipe_link_get_attr()
1586 * with ::GXIO_MPIPE_LINK_DESIRED_STATE allow you to modify or retrieve
1587 * the desired link state.
1588 *
1589 * If you want to manage a link from a part of your application which isn't
1590 * involved in packet processing, you can use the ::GXIO_MPIPE_LINK_NO_DATA
1591 * flags on a gxio_mpipe_link_open() call. This opens the link, but does
1592 * not request data permission, so it does not conflict with any exclusive
1593 * permissions which may be held by other processes. You can then can use
1594 * gxio_mpipe_link_get_attr() and gxio_mpipe_link_set_attr() on this link
1595 * object to bring up or take down the link.
1596 *
1597 * Some links support link state bits which support various loopback
1598 * modes. ::GXIO_MPIPE_LINK_LOOP_MAC tests datapaths within the Tile
1599 * Processor itself; ::GXIO_MPIPE_LINK_LOOP_PHY tests the datapath between
1600 * the Tile Processor and the external physical layer interface chip; and
1601 * ::GXIO_MPIPE_LINK_LOOP_EXT tests the entire network datapath with the
1602 * aid of an external loopback connector. In addition to enabling hardware
1603 * testing, such configuration can be useful for software testing, as well.
1604 *
1605 * When LOOP_MAC or LOOP_PHY is enabled, packets transmitted on a channel
1606 * will be received by that channel, instead of being emitted on the
1607 * physical link, and packets received on the physical link will be ignored.
1608 * Other than that, all standard GXIO operations work as you might expect.
1609 * Note that loopback operation requires that the link be brought up using
1610 * one or more of the GXIO_MPIPE_LINK_SPEED_xxx link state bits.
1611 *
1612 * Those familiar with previous versions of the MDE on TILEPro hardware
1613 * will notice significant similarities between the NetIO link management
1614 * model and the mPIPE link management model. However, the NetIO model
1615 * was developed in stages, and some of its features -- for instance,
1616 * the default setting of certain flags -- were shaped by the need to be
1617 * compatible with previous versions of NetIO. Since the features provided
1618 * by the mPIPE hardware and the mPIPE GXIO library are significantly
1619 * different than those provided by NetIO, in some cases, we have made
1620 * different choices in the mPIPE link management API. Thus, please read
1621 * this documentation carefully before assuming that mPIPE link management
1622 * operations are exactly equivalent to their NetIO counterparts.
1623 */
1624
1625/* An object used to manage mPIPE link state and resources. */
1626typedef struct {
1627 /* The overall mPIPE context. */
1628 gxio_mpipe_context_t *context;
1629
1630 /* The channel number used by this link. */
1631 uint8_t channel;
1632
1633 /* The MAC index used by this link. */
1634 uint8_t mac;
1635} gxio_mpipe_link_t;
1636
1637/* Retrieve one of this system's legal link names, and its MAC address.
1638 *
1639 * @param index Link name index. If a system supports N legal link names,
1640 * then indices between 0 and N - 1, inclusive, each correspond to one of
1641 * those names. Thus, to retrieve all of a system's legal link names,
1642 * call this function in a loop, starting with an index of zero, and
1643 * incrementing it once per iteration until -1 is returned.
1644 * @param link_name Pointer to the buffer which will receive the retrieved
1645 * link name. The buffer should contain space for at least
1646 * ::GXIO_MPIPE_LINK_NAME_LEN bytes; the returned name, including the
1647 * terminating null byte, will be no longer than that.
1648 * @param link_name Pointer to the buffer which will receive the retrieved
1649 * MAC address. The buffer should contain space for at least 6 bytes.
1650 * @return Zero if a link name was successfully retrieved; -1 if one was
1651 * not.
1652 */
1653extern int gxio_mpipe_link_enumerate_mac(int index, char *link_name,
1654 uint8_t *mac_addr);
1655
1656/* Open an mPIPE link.
1657 *
1658 * A link must be opened before it may be used to send or receive packets,
1659 * and before its state may be examined or changed. Depending up on the
1660 * link's intended use, one or more link permissions may be requested via
1661 * the flags parameter; see @ref gxio_mpipe_link_perm. In addition, flags
1662 * may request that the link's state be modified at open time. See @ref
1663 * gxio_mpipe_link_states and @ref gxio_mpipe_link_open_flags for more detail.
1664 *
1665 * @param link A link state object, which will be initialized if this
1666 * function completes successfully.
1667 * @param context An initialized mPIPE context.
1668 * @param link_name Name of the link.
1669 * @param flags Zero or more @ref gxio_mpipe_link_open_flags, ORed together.
1670 * @return 0 if the link was successfully opened, or a negative error code.
1671 *
1672 */
1673extern int gxio_mpipe_link_open(gxio_mpipe_link_t *link,
1674 gxio_mpipe_context_t *context,
1675 const char *link_name, unsigned int flags);
1676
1677/* Close an mPIPE link.
1678 *
1679 * Closing a link makes it available for use by other processes. Once
1680 * a link has been closed, packets may no longer be sent on or received
1681 * from the link, and its state may not be examined or changed.
1682 *
1683 * @param link A link state object, which will no longer be initialized
1684 * if this function completes successfully.
1685 * @return 0 if the link was successfully closed, or a negative error code.
1686 *
1687 */
1688extern int gxio_mpipe_link_close(gxio_mpipe_link_t *link);
1689
1690/* Return a link's channel number.
1691 *
1692 * @param link A properly initialized link state object.
1693 * @return The channel number for the link.
1694 */
1695static inline int gxio_mpipe_link_channel(gxio_mpipe_link_t *link)
1696{
1697 return link->channel;
1698}
1699
1700///////////////////////////////////////////////////////////////////
1701// Timestamp //
1702///////////////////////////////////////////////////////////////////
1703
1704/* Get the timestamp of mPIPE when this routine is called.
1705 *
1706 * @param context An initialized mPIPE context.
1707 * @param ts A timespec structure to store the current clock.
1708 * @return If the call was successful, zero; otherwise, a negative error
1709 * code.
1710 */
1711extern int gxio_mpipe_get_timestamp(gxio_mpipe_context_t *context,
1712 struct timespec *ts);
1713
1714/* Set the timestamp of mPIPE.
1715 *
1716 * @param context An initialized mPIPE context.
1717 * @param ts A timespec structure to store the requested clock.
1718 * @return If the call was successful, zero; otherwise, a negative error
1719 * code.
1720 */
1721extern int gxio_mpipe_set_timestamp(gxio_mpipe_context_t *context,
1722 const struct timespec *ts);
1723
1724/* Adjust the timestamp of mPIPE.
1725 *
1726 * @param context An initialized mPIPE context.
1727 * @param delta A signed time offset to adjust, in nanoseconds.
1728 * The absolute value of this parameter must be less than or
1729 * equal to 1000000000.
1730 * @return If the call was successful, zero; otherwise, a negative error
1731 * code.
1732 */
1733extern int gxio_mpipe_adjust_timestamp(gxio_mpipe_context_t *context,
1734 int64_t delta);
1735
1736#endif /* !_GXIO_MPIPE_H_ */
diff --git a/arch/tile/include/gxio/trio.h b/arch/tile/include/gxio/trio.h
new file mode 100644
index 00000000000..77b80cdd46d
--- /dev/null
+++ b/arch/tile/include/gxio/trio.h
@@ -0,0 +1,298 @@
1/*
2 * Copyright 2012 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 *
17 * An API for allocating, configuring, and manipulating TRIO hardware
18 * resources
19 */
20
21/*
22 *
23 * The TILE-Gx TRIO shim provides connections to external devices via
24 * PCIe or other transaction IO standards. The gxio_trio_ API,
25 * declared in <gxio/trio.h>, allows applications to allocate and
26 * configure TRIO IO resources like DMA command rings, memory map
27 * windows, and device interrupts. The following sections introduce
28 * the various components of the API. We strongly recommend reading
29 * the TRIO section of the IO Device Guide (UG404) before working with
30 * this API.
31 *
32 * @section trio__ingress TRIO Ingress Hardware Resources
33 *
34 * The TRIO ingress hardware is responsible for examining incoming
35 * PCIe or StreamIO packets and choosing a processing mechanism based
36 * on the packets' bus address. The gxio_trio_ API can be used to
37 * configure different handlers for different ranges of bus address
38 * space. The user can configure "mapped memory" and "scatter queue"
39 * regions to match incoming packets within 4kB-aligned ranges of bus
40 * addresses. Each range specifies a different set of mapping
41 * parameters to be applied when handling the ingress packet. The
42 * following sections describe how to work with MapMem and scatter
43 * queue regions.
44 *
45 * @subsection trio__mapmem TRIO MapMem Regions
46 *
47 * TRIO mapped memory (or MapMem) regions allow the user to map
48 * incoming read and write requests directly to the application's
49 * memory space. MapMem regions are allocated via
50 * gxio_trio_alloc_memory_maps(). Given an integer MapMem number,
51 * applications can use gxio_trio_init_memory_map() to specify the
52 * range of bus addresses that will match the region and the range of
53 * virtual addresses to which those packets will be applied.
54 *
55 * As with many other gxio APIs, the programmer must be sure to
56 * register memory pages that will be used with MapMem regions. Pages
57 * can be registered with TRIO by allocating an ASID (address space
58 * identifier) and then using gxio_trio_register_page() to register up to
59 * 16 pages with the hardware. The initialization functions for
60 * resources that require registered memory (MapMem, scatter queues,
61 * push DMA, and pull DMA) then take an 'asid' parameter in order to
62 * configure which set of registered pages is used by each resource.
63 *
64 * @subsection trio__scatter_queue TRIO Scatter Queues
65 *
66 * The TRIO shim's scatter queue regions allow users to dynamically
67 * map buffers from a large address space into a small range of bus
68 * addresses. This is particularly helpful for PCIe endpoint devices,
69 * where the host generally limits the size of BARs to tens of
70 * megabytes.
71 *
72 * Each scatter queue consists of a memory map region, a queue of
73 * tile-side buffer VAs to be mapped to that region, and a bus-mapped
74 * "doorbell" register that the remote endpoint can write to trigger a
75 * dequeue of the current buffer VA, thus swapping in a new buffer.
76 * The VAs pushed onto a scatter queue must be 4kB aligned, so
77 * applications may need to use higher-level protocols to inform
78 * remote entities that they should apply some additional, sub-4kB
79 * offset when reading or writing the scatter queue region. For more
80 * information, see the IO Device Guide (UG404).
81 *
82 * @section trio__egress TRIO Egress Hardware Resources
83 *
84 * The TRIO shim supports two mechanisms for egress packet generation:
85 * programmed IO (PIO) and push/pull DMA. PIO allows applications to
86 * create MMIO mappings for PCIe or StreamIO address space, such that
87 * the application can generate word-sized read or write transactions
88 * by issuing load or store instructions. Push and pull DMA are tuned
89 * for larger transactions; they use specialized hardware engines to
90 * transfer large blocks of data at line rate.
91 *
92 * @subsection trio__pio TRIO Programmed IO
93 *
94 * Programmed IO allows applications to create MMIO mappings for PCIe
95 * or StreamIO address space. The hardware PIO regions support access
96 * to PCIe configuration, IO, and memory space, but the gxio_trio API
97 * only supports memory space accesses. PIO regions are allocated
98 * with gxio_trio_alloc_pio_regions() and initialized via
99 * gxio_trio_init_pio_region(). Once a region is bound to a range of
100 * bus address via the initialization function, the application can
101 * use gxio_trio_map_pio_region() to create MMIO mappings from its VA
102 * space onto the range of bus addresses supported by the PIO region.
103 *
104 * @subsection trio_dma TRIO Push and Pull DMA
105 *
106 * The TRIO push and pull DMA engines allow users to copy blocks of
107 * data between application memory and the bus. Push DMA generates
108 * write packets that copy from application memory to the bus and pull
109 * DMA generates read packets that copy from the bus into application
110 * memory. The DMA engines are managed via an API that is very
111 * similar to the mPIPE eDMA interface. For a detailed explanation of
112 * the eDMA queue API, see @ref gxio_mpipe_wrappers.
113 *
114 * Push and pull DMA queues are allocated via
115 * gxio_trio_alloc_push_dma_ring() / gxio_trio_alloc_pull_dma_ring().
116 * Once allocated, users generally use a ::gxio_trio_dma_queue_t
117 * object to manage the queue, providing easy wrappers for reserving
118 * command slots in the DMA command ring, filling those slots, and
119 * waiting for commands to complete. DMA queues can be initialized
120 * via gxio_trio_init_push_dma_queue() or
121 * gxio_trio_init_pull_dma_queue().
122 *
123 * See @ref trio/push_dma/app.c for an example of how to use push DMA.
124 *
125 * @section trio_shortcomings Plans for Future API Revisions
126 *
127 * The simulation framework is incomplete. Future features include:
128 *
129 * - Support for reset and deallocation of resources.
130 *
131 * - Support for pull DMA.
132 *
133 * - Support for interrupt regions and user-space interrupt delivery.
134 *
135 * - Support for getting BAR mappings and reserving regions of BAR
136 * address space.
137 */
138#ifndef _GXIO_TRIO_H_
139#define _GXIO_TRIO_H_
140
141#include <linux/types.h>
142
143#include "common.h"
144#include "dma_queue.h"
145
146#include <arch/trio_constants.h>
147#include <arch/trio.h>
148#include <arch/trio_pcie_intfc.h>
149#include <arch/trio_pcie_rc.h>
150#include <arch/trio_shm.h>
151#include <hv/drv_trio_intf.h>
152#include <hv/iorpc.h>
153
154/* A context object used to manage TRIO hardware resources. */
155typedef struct {
156
157 /* File descriptor for calling up to Linux (and thus the HV). */
158 int fd;
159
160 /* The VA at which the MAC MMIO registers are mapped. */
161 char *mmio_base_mac;
162
163 /* The VA at which the PIO config space are mapped for each PCIe MAC.
164 Gx36 has max 3 PCIe MACs per TRIO shim. */
165 char *mmio_base_pio_cfg[TILEGX_TRIO_PCIES];
166
167#ifdef USE_SHARED_PCIE_CONFIG_REGION
168 /* Index of the shared PIO region for PCI config access. */
169 int pio_cfg_index;
170#else
171 /* Index of the PIO region for PCI config access per MAC. */
172 int pio_cfg_index[TILEGX_TRIO_PCIES];
173#endif
174
175 /* The VA at which the push DMA MMIO registers are mapped. */
176 char *mmio_push_dma[TRIO_NUM_PUSH_DMA_RINGS];
177
178 /* The VA at which the pull DMA MMIO registers are mapped. */
179 char *mmio_pull_dma[TRIO_NUM_PUSH_DMA_RINGS];
180
181 /* Application space ID. */
182 unsigned int asid;
183
184} gxio_trio_context_t;
185
186/* Command descriptor for push or pull DMA. */
187typedef TRIO_DMA_DESC_t gxio_trio_dma_desc_t;
188
189/* A convenient, thread-safe interface to an eDMA ring. */
190typedef struct {
191
192 /* State object for tracking head and tail pointers. */
193 __gxio_dma_queue_t dma_queue;
194
195 /* The ring entries. */
196 gxio_trio_dma_desc_t *dma_descs;
197
198 /* The number of entries minus one. */
199 unsigned long mask_num_entries;
200
201 /* The log2() of the number of entries. */
202 unsigned int log2_num_entries;
203
204} gxio_trio_dma_queue_t;
205
206/* Initialize a TRIO context.
207 *
208 * This function allocates a TRIO "service domain" and maps the MMIO
209 * registers into the the caller's VA space.
210 *
211 * @param trio_index Which TRIO shim; Gx36 must pass 0.
212 * @param context Context object to be initialized.
213 */
214extern int gxio_trio_init(gxio_trio_context_t *context,
215 unsigned int trio_index);
216
217/* This indicates that an ASID hasn't been allocated. */
218#define GXIO_ASID_NULL -1
219
220/* Ordering modes for map memory regions and scatter queue regions. */
221typedef enum gxio_trio_order_mode_e {
222 /* Writes are not ordered. Reads always wait for previous writes. */
223 GXIO_TRIO_ORDER_MODE_UNORDERED =
224 TRIO_MAP_MEM_SETUP__ORDER_MODE_VAL_UNORDERED,
225 /* Both writes and reads wait for previous transactions to complete. */
226 GXIO_TRIO_ORDER_MODE_STRICT =
227 TRIO_MAP_MEM_SETUP__ORDER_MODE_VAL_STRICT,
228 /* Writes are ordered unless the incoming packet has the
229 relaxed-ordering attributes set. */
230 GXIO_TRIO_ORDER_MODE_OBEY_PACKET =
231 TRIO_MAP_MEM_SETUP__ORDER_MODE_VAL_REL_ORD
232} gxio_trio_order_mode_t;
233
234/* Initialize a memory mapping region.
235 *
236 * @param context An initialized TRIO context.
237 * @param map A Memory map region allocated by gxio_trio_alloc_memory_map().
238 * @param target_mem VA of backing memory, should be registered via
239 * gxio_trio_register_page() and aligned to 4kB.
240 * @param target_size Length of the memory mapping, must be a multiple
241 * of 4kB.
242 * @param asid ASID to be used for Tile-side address translation.
243 * @param mac MAC number.
244 * @param bus_address Bus address at which the mapping starts.
245 * @param order_mode Memory ordering mode for this mapping.
246 * @return Zero on success, else ::GXIO_TRIO_ERR_BAD_MEMORY_MAP,
247 * GXIO_TRIO_ERR_BAD_ASID, or ::GXIO_TRIO_ERR_BAD_BUS_RANGE.
248 */
249extern int gxio_trio_init_memory_map(gxio_trio_context_t *context,
250 unsigned int map, void *target_mem,
251 size_t target_size, unsigned int asid,
252 unsigned int mac, uint64_t bus_address,
253 gxio_trio_order_mode_t order_mode);
254
255/* Flags that can be passed to resource allocation functions. */
256enum gxio_trio_alloc_flags_e {
257 GXIO_TRIO_ALLOC_FIXED = HV_TRIO_ALLOC_FIXED,
258};
259
260/* Flags that can be passed to memory registration functions. */
261enum gxio_trio_mem_flags_e {
262 /* Do not fill L3 when writing, and invalidate lines upon egress. */
263 GXIO_TRIO_MEM_FLAG_NT_HINT = IORPC_MEM_BUFFER_FLAG_NT_HINT,
264
265 /* L3 cache fills should only populate IO cache ways. */
266 GXIO_TRIO_MEM_FLAG_IO_PIN = IORPC_MEM_BUFFER_FLAG_IO_PIN,
267};
268
269/* Flag indicating a request generator uses a special traffic
270 class. */
271#define GXIO_TRIO_FLAG_TRAFFIC_CLASS(N) HV_TRIO_FLAG_TC(N)
272
273/* Flag indicating a request generator uses a virtual function
274 number. */
275#define GXIO_TRIO_FLAG_VFUNC(N) HV_TRIO_FLAG_VFUNC(N)
276
277/*****************************************************************
278 * Memory Registration *
279 ******************************************************************/
280
281/* Allocate Application Space Identifiers (ASIDs). Each ASID can
282 * register up to 16 page translations. ASIDs are used by memory map
283 * regions, scatter queues, and DMA queues to translate application
284 * VAs into memory system PAs.
285 *
286 * @param context An initialized TRIO context.
287 * @param count Number of ASIDs required.
288 * @param first Index of first ASID if ::GXIO_TRIO_ALLOC_FIXED flag
289 * is set, otherwise ignored.
290 * @param flags Flag bits, including bits from ::gxio_trio_alloc_flags_e.
291 * @return Index of first ASID, or ::GXIO_TRIO_ERR_NO_ASID if allocation
292 * failed.
293 */
294extern int gxio_trio_alloc_asids(gxio_trio_context_t *context,
295 unsigned int count, unsigned int first,
296 unsigned int flags);
297
298#endif /* ! _GXIO_TRIO_H_ */
diff --git a/arch/tile/include/gxio/usb_host.h b/arch/tile/include/gxio/usb_host.h
new file mode 100644
index 00000000000..a60a126e456
--- /dev/null
+++ b/arch/tile/include/gxio/usb_host.h
@@ -0,0 +1,87 @@
1/*
2 * Copyright 2012 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#ifndef _GXIO_USB_H_
15#define _GXIO_USB_H_
16
17#include "common.h"
18
19#include <hv/drv_usb_host_intf.h>
20#include <hv/iorpc.h>
21
22/*
23 *
24 * An API for manipulating general-purpose I/O pins.
25 */
26
27/*
28 *
29 * The USB shim allows access to the processor's Universal Serial Bus
30 * connections.
31 */
32
33/* A context object used to manage USB hardware resources. */
34typedef struct {
35
36 /* File descriptor for calling up to the hypervisor. */
37 int fd;
38
39 /* The VA at which our MMIO registers are mapped. */
40 char *mmio_base;
41} gxio_usb_host_context_t;
42
43/* Initialize a USB context.
44 *
45 * A properly initialized context must be obtained before any of the other
46 * gxio_usb_host routines may be used.
47 *
48 * @param context Pointer to a gxio_usb_host_context_t, which will be
49 * initialized by this routine, if it succeeds.
50 * @param usb_index Index of the USB shim to use.
51 * @param is_ehci Nonzero to use the EHCI interface; zero to use the OHCI
52 * intereface.
53 * @return Zero if the context was successfully initialized, else a
54 * GXIO_ERR_xxx error code.
55 */
56extern int gxio_usb_host_init(gxio_usb_host_context_t * context, int usb_index,
57 int is_ehci);
58
59/* Destroy a USB context.
60 *
61 * Once destroyed, a context may not be used with any gxio_usb_host routines
62 * other than gxio_usb_host_init(). After this routine returns, no further
63 * interrupts or signals requested on this context will be delivered. The
64 * state and configuration of the pins which had been attached to this
65 * context are unchanged by this operation.
66 *
67 * @param context Pointer to a gxio_usb_host_context_t.
68 * @return Zero if the context was successfully destroyed, else a
69 * GXIO_ERR_xxx error code.
70 */
71extern int gxio_usb_host_destroy(gxio_usb_host_context_t * context);
72
73/* Retrieve the address of the shim's MMIO registers.
74 *
75 * @param context Pointer to a properly initialized gxio_usb_host_context_t.
76 * @return The address of the shim's MMIO registers.
77 */
78extern void *gxio_usb_host_get_reg_start(gxio_usb_host_context_t * context);
79
80/* Retrieve the length of the shim's MMIO registers.
81 *
82 * @param context Pointer to a properly initialized gxio_usb_host_context_t.
83 * @return The length of the shim's MMIO registers.
84 */
85extern size_t gxio_usb_host_get_reg_len(gxio_usb_host_context_t * context);
86
87#endif /* _GXIO_USB_H_ */
diff --git a/arch/tile/include/hv/drv_mpipe_intf.h b/arch/tile/include/hv/drv_mpipe_intf.h
new file mode 100644
index 00000000000..6cdae3bf046
--- /dev/null
+++ b/arch/tile/include/hv/drv_mpipe_intf.h
@@ -0,0 +1,602 @@
1/*
2 * Copyright 2011 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 * Interface definitions for the mpipe driver.
17 */
18
19#ifndef _SYS_HV_DRV_MPIPE_INTF_H
20#define _SYS_HV_DRV_MPIPE_INTF_H
21
22#include <arch/mpipe.h>
23#include <arch/mpipe_constants.h>
24
25
26/** Number of buffer stacks (32). */
27#define HV_MPIPE_NUM_BUFFER_STACKS \
28 (MPIPE_MMIO_INIT_DAT_GX36_1__BUFFER_STACK_MASK_WIDTH)
29
30/** Number of NotifRings (256). */
31#define HV_MPIPE_NUM_NOTIF_RINGS (MPIPE_NUM_NOTIF_RINGS)
32
33/** Number of NotifGroups (32). */
34#define HV_MPIPE_NUM_NOTIF_GROUPS (MPIPE_NUM_NOTIF_GROUPS)
35
36/** Number of buckets (4160). */
37#define HV_MPIPE_NUM_BUCKETS (MPIPE_NUM_BUCKETS)
38
39/** Number of "lo" buckets (4096). */
40#define HV_MPIPE_NUM_LO_BUCKETS 4096
41
42/** Number of "hi" buckets (64). */
43#define HV_MPIPE_NUM_HI_BUCKETS \
44 (HV_MPIPE_NUM_BUCKETS - HV_MPIPE_NUM_LO_BUCKETS)
45
46/** Number of edma rings (24). */
47#define HV_MPIPE_NUM_EDMA_RINGS \
48 (MPIPE_MMIO_INIT_DAT_GX36_1__EDMA_POST_MASK_WIDTH)
49
50
51
52
53/** A flag bit indicating a fixed resource allocation. */
54#define HV_MPIPE_ALLOC_FIXED 0x01
55
56/** Offset for the config register MMIO region. */
57#define HV_MPIPE_CONFIG_MMIO_OFFSET \
58 (MPIPE_MMIO_ADDR__REGION_VAL_CFG << MPIPE_MMIO_ADDR__REGION_SHIFT)
59
60/** Size of the config register MMIO region. */
61#define HV_MPIPE_CONFIG_MMIO_SIZE (64 * 1024)
62
63/** Offset for the config register MMIO region. */
64#define HV_MPIPE_FAST_MMIO_OFFSET \
65 (MPIPE_MMIO_ADDR__REGION_VAL_IDMA << MPIPE_MMIO_ADDR__REGION_SHIFT)
66
67/** Size of the fast register MMIO region (IDMA, EDMA, buffer stack). */
68#define HV_MPIPE_FAST_MMIO_SIZE \
69 ((MPIPE_MMIO_ADDR__REGION_VAL_BSM + 1 - MPIPE_MMIO_ADDR__REGION_VAL_IDMA) \
70 << MPIPE_MMIO_ADDR__REGION_SHIFT)
71
72
73/*
74 * Each type of resource allocation comes in quantized chunks, where
75 * XXX_BITS is the number of chunks, and XXX_RES_PER_BIT is the number
76 * of resources in each chunk.
77 */
78
79/** Number of buffer stack chunks available (32). */
80#define HV_MPIPE_ALLOC_BUFFER_STACKS_BITS \
81 MPIPE_MMIO_INIT_DAT_GX36_1__BUFFER_STACK_MASK_WIDTH
82
83/** Granularity of buffer stack allocation (1). */
84#define HV_MPIPE_ALLOC_BUFFER_STACKS_RES_PER_BIT \
85 (HV_MPIPE_NUM_BUFFER_STACKS / HV_MPIPE_ALLOC_BUFFER_STACKS_BITS)
86
87/** Number of NotifRing chunks available (32). */
88#define HV_MPIPE_ALLOC_NOTIF_RINGS_BITS \
89 MPIPE_MMIO_INIT_DAT_GX36_0__NOTIF_RING_MASK_WIDTH
90
91/** Granularity of NotifRing allocation (8). */
92#define HV_MPIPE_ALLOC_NOTIF_RINGS_RES_PER_BIT \
93 (HV_MPIPE_NUM_NOTIF_RINGS / HV_MPIPE_ALLOC_NOTIF_RINGS_BITS)
94
95/** Number of NotifGroup chunks available (32). */
96#define HV_MPIPE_ALLOC_NOTIF_GROUPS_BITS \
97 HV_MPIPE_NUM_NOTIF_GROUPS
98
99/** Granularity of NotifGroup allocation (1). */
100#define HV_MPIPE_ALLOC_NOTIF_GROUPS_RES_PER_BIT \
101 (HV_MPIPE_NUM_NOTIF_GROUPS / HV_MPIPE_ALLOC_NOTIF_GROUPS_BITS)
102
103/** Number of lo bucket chunks available (16). */
104#define HV_MPIPE_ALLOC_LO_BUCKETS_BITS \
105 MPIPE_MMIO_INIT_DAT_GX36_0__BUCKET_RELEASE_MASK_LO_WIDTH
106
107/** Granularity of lo bucket allocation (256). */
108#define HV_MPIPE_ALLOC_LO_BUCKETS_RES_PER_BIT \
109 (HV_MPIPE_NUM_LO_BUCKETS / HV_MPIPE_ALLOC_LO_BUCKETS_BITS)
110
111/** Number of hi bucket chunks available (16). */
112#define HV_MPIPE_ALLOC_HI_BUCKETS_BITS \
113 MPIPE_MMIO_INIT_DAT_GX36_0__BUCKET_RELEASE_MASK_HI_WIDTH
114
115/** Granularity of hi bucket allocation (4). */
116#define HV_MPIPE_ALLOC_HI_BUCKETS_RES_PER_BIT \
117 (HV_MPIPE_NUM_HI_BUCKETS / HV_MPIPE_ALLOC_HI_BUCKETS_BITS)
118
119/** Number of eDMA ring chunks available (24). */
120#define HV_MPIPE_ALLOC_EDMA_RINGS_BITS \
121 MPIPE_MMIO_INIT_DAT_GX36_1__EDMA_POST_MASK_WIDTH
122
123/** Granularity of eDMA ring allocation (1). */
124#define HV_MPIPE_ALLOC_EDMA_RINGS_RES_PER_BIT \
125 (HV_MPIPE_NUM_EDMA_RINGS / HV_MPIPE_ALLOC_EDMA_RINGS_BITS)
126
127
128
129
130/** Bit vector encoding which NotifRings are in a NotifGroup. */
131typedef struct
132{
133 /** The actual bits. */
134 uint64_t ring_mask[4];
135
136} gxio_mpipe_notif_group_bits_t;
137
138
139/** Another name for MPIPE_LBL_INIT_DAT_BSTS_TBL_t. */
140typedef MPIPE_LBL_INIT_DAT_BSTS_TBL_t gxio_mpipe_bucket_info_t;
141
142
143
144/** Eight buffer stack ids. */
145typedef struct
146{
147 /** The stacks. */
148 uint8_t stacks[8];
149
150} gxio_mpipe_rules_stacks_t;
151
152
153/** A destination mac address. */
154typedef struct
155{
156 /** The octets. */
157 uint8_t octets[6];
158
159} gxio_mpipe_rules_dmac_t;
160
161
162/** A vlan. */
163typedef uint16_t gxio_mpipe_rules_vlan_t;
164
165
166
167/** Maximum number of characters in a link name. */
168#define GXIO_MPIPE_LINK_NAME_LEN 32
169
170
171/** Structure holding a link name. Only needed, and only typedef'ed,
172 * because the IORPC stub generator only handles types which are single
173 * words coming before the parameter name. */
174typedef struct
175{
176 /** The name itself. */
177 char name[GXIO_MPIPE_LINK_NAME_LEN];
178}
179_gxio_mpipe_link_name_t;
180
181/** Maximum number of characters in a symbol name. */
182#define GXIO_MPIPE_SYMBOL_NAME_LEN 128
183
184
185/** Structure holding a symbol name. Only needed, and only typedef'ed,
186 * because the IORPC stub generator only handles types which are single
187 * words coming before the parameter name. */
188typedef struct
189{
190 /** The name itself. */
191 char name[GXIO_MPIPE_SYMBOL_NAME_LEN];
192}
193_gxio_mpipe_symbol_name_t;
194
195
196/** Structure holding a MAC address. */
197typedef struct
198{
199 /** The address. */
200 uint8_t mac[6];
201}
202_gxio_mpipe_link_mac_t;
203
204
205
206/** Request shared data permission -- that is, the ability to send and
207 * receive packets -- on the specified link. Other processes may also
208 * request shared data permission on the same link.
209 *
210 * No more than one of ::GXIO_MPIPE_LINK_DATA, ::GXIO_MPIPE_LINK_NO_DATA,
211 * or ::GXIO_MPIPE_LINK_EXCL_DATA may be specifed in a gxio_mpipe_link_open()
212 * call. If none are specified, ::GXIO_MPIPE_LINK_DATA is assumed.
213 */
214#define GXIO_MPIPE_LINK_DATA 0x00000001UL
215
216/** Do not request data permission on the specified link.
217 *
218 * No more than one of ::GXIO_MPIPE_LINK_DATA, ::GXIO_MPIPE_LINK_NO_DATA,
219 * or ::GXIO_MPIPE_LINK_EXCL_DATA may be specifed in a gxio_mpipe_link_open()
220 * call. If none are specified, ::GXIO_MPIPE_LINK_DATA is assumed.
221 */
222#define GXIO_MPIPE_LINK_NO_DATA 0x00000002UL
223
224/** Request exclusive data permission -- that is, the ability to send and
225 * receive packets -- on the specified link. No other processes may
226 * request data permission on this link, and if any process already has
227 * data permission on it, this open will fail.
228 *
229 * No more than one of ::GXIO_MPIPE_LINK_DATA, ::GXIO_MPIPE_LINK_NO_DATA,
230 * or ::GXIO_MPIPE_LINK_EXCL_DATA may be specifed in a gxio_mpipe_link_open()
231 * call. If none are specified, ::GXIO_MPIPE_LINK_DATA is assumed.
232 */
233#define GXIO_MPIPE_LINK_EXCL_DATA 0x00000004UL
234
235/** Request shared stats permission -- that is, the ability to read and write
236 * registers which contain link statistics, and to get link attributes --
237 * on the specified link. Other processes may also request shared stats
238 * permission on the same link.
239 *
240 * No more than one of ::GXIO_MPIPE_LINK_STATS, ::GXIO_MPIPE_LINK_NO_STATS,
241 * or ::GXIO_MPIPE_LINK_EXCL_STATS may be specifed in a gxio_mpipe_link_open()
242 * call. If none are specified, ::GXIO_MPIPE_LINK_STATS is assumed.
243 */
244#define GXIO_MPIPE_LINK_STATS 0x00000008UL
245
246/** Do not request stats permission on the specified link.
247 *
248 * No more than one of ::GXIO_MPIPE_LINK_STATS, ::GXIO_MPIPE_LINK_NO_STATS,
249 * or ::GXIO_MPIPE_LINK_EXCL_STATS may be specifed in a gxio_mpipe_link_open()
250 * call. If none are specified, ::GXIO_MPIPE_LINK_STATS is assumed.
251 */
252#define GXIO_MPIPE_LINK_NO_STATS 0x00000010UL
253
254/** Request exclusive stats permission -- that is, the ability to read and
255 * write registers which contain link statistics, and to get link
256 * attributes -- on the specified link. No other processes may request
257 * stats permission on this link, and if any process already
258 * has stats permission on it, this open will fail.
259 *
260 * Requesting exclusive stats permission is normally a very bad idea, since
261 * it prevents programs like mpipe-stat from providing information on this
262 * link. Applications should only do this if they use MAC statistics
263 * registers, and cannot tolerate any of the clear-on-read registers being
264 * reset by other statistics programs.
265 *
266 * No more than one of ::GXIO_MPIPE_LINK_STATS, ::GXIO_MPIPE_LINK_NO_STATS,
267 * or ::GXIO_MPIPE_LINK_EXCL_STATS may be specifed in a gxio_mpipe_link_open()
268 * call. If none are specified, ::GXIO_MPIPE_LINK_STATS is assumed.
269 */
270#define GXIO_MPIPE_LINK_EXCL_STATS 0x00000020UL
271
272/** Request shared control permission -- that is, the ability to modify link
273 * attributes, and read and write MAC and MDIO registers -- on the
274 * specified link. Other processes may also request shared control
275 * permission on the same link.
276 *
277 * No more than one of ::GXIO_MPIPE_LINK_CTL, ::GXIO_MPIPE_LINK_NO_CTL,
278 * or ::GXIO_MPIPE_LINK_EXCL_CTL may be specifed in a gxio_mpipe_link_open()
279 * call. If none are specified, ::GXIO_MPIPE_LINK_CTL is assumed.
280 */
281#define GXIO_MPIPE_LINK_CTL 0x00000040UL
282
283/** Do not request control permission on the specified link.
284 *
285 * No more than one of ::GXIO_MPIPE_LINK_CTL, ::GXIO_MPIPE_LINK_NO_CTL,
286 * or ::GXIO_MPIPE_LINK_EXCL_CTL may be specifed in a gxio_mpipe_link_open()
287 * call. If none are specified, ::GXIO_MPIPE_LINK_CTL is assumed.
288 */
289#define GXIO_MPIPE_LINK_NO_CTL 0x00000080UL
290
291/** Request exclusive control permission -- that is, the ability to modify
292 * link attributes, and read and write MAC and MDIO registers -- on the
293 * specified link. No other processes may request control permission on
294 * this link, and if any process already has control permission on it,
295 * this open will fail.
296 *
297 * Requesting exclusive control permission is not always a good idea, since
298 * it prevents programs like mpipe-link from configuring the link.
299 *
300 * No more than one of ::GXIO_MPIPE_LINK_CTL, ::GXIO_MPIPE_LINK_NO_CTL,
301 * or ::GXIO_MPIPE_LINK_EXCL_CTL may be specifed in a gxio_mpipe_link_open()
302 * call. If none are specified, ::GXIO_MPIPE_LINK_CTL is assumed.
303 */
304#define GXIO_MPIPE_LINK_EXCL_CTL 0x00000100UL
305
306/** Set the desired state of the link to up, allowing any speeds which are
307 * supported by the link hardware, as part of this open operation; do not
308 * change the desired state of the link when it is closed or the process
309 * exits. No more than one of ::GXIO_MPIPE_LINK_AUTO_UP,
310 * ::GXIO_MPIPE_LINK_AUTO_UPDOWN, ::GXIO_MPIPE_LINK_AUTO_DOWN, or
311 * ::GXIO_MPIPE_LINK_AUTO_NONE may be specifed in a gxio_mpipe_link_open()
312 * call. If none are specified, ::GXIO_MPIPE_LINK_AUTO_UPDOWN is assumed.
313 */
314#define GXIO_MPIPE_LINK_AUTO_UP 0x00000200UL
315
316/** Set the desired state of the link to up, allowing any speeds which are
317 * supported by the link hardware, as part of this open operation; when the
318 * link is closed or this process exits, if no other process has the link
319 * open, set the desired state of the link to down. No more than one of
320 * ::GXIO_MPIPE_LINK_AUTO_UP, ::GXIO_MPIPE_LINK_AUTO_UPDOWN,
321 * ::GXIO_MPIPE_LINK_AUTO_DOWN, or ::GXIO_MPIPE_LINK_AUTO_NONE may be
322 * specifed in a gxio_mpipe_link_open() call. If none are specified,
323 * ::GXIO_MPIPE_LINK_AUTO_UPDOWN is assumed.
324 */
325#define GXIO_MPIPE_LINK_AUTO_UPDOWN 0x00000400UL
326
327/** Do not change the desired state of the link as part of the open
328 * operation; when the link is closed or this process exits, if no other
329 * process has the link open, set the desired state of the link to down.
330 * No more than one of ::GXIO_MPIPE_LINK_AUTO_UP,
331 * ::GXIO_MPIPE_LINK_AUTO_UPDOWN, ::GXIO_MPIPE_LINK_AUTO_DOWN, or
332 * ::GXIO_MPIPE_LINK_AUTO_NONE may be specifed in a gxio_mpipe_link_open()
333 * call. If none are specified, ::GXIO_MPIPE_LINK_AUTO_UPDOWN is assumed.
334 */
335#define GXIO_MPIPE_LINK_AUTO_DOWN 0x00000800UL
336
337/** Do not change the desired state of the link as part of the open
338 * operation; do not change the desired state of the link when it is
339 * closed or the process exits. No more than one of
340 * ::GXIO_MPIPE_LINK_AUTO_UP, ::GXIO_MPIPE_LINK_AUTO_UPDOWN,
341 * ::GXIO_MPIPE_LINK_AUTO_DOWN, or ::GXIO_MPIPE_LINK_AUTO_NONE may be
342 * specifed in a gxio_mpipe_link_open() call. If none are specified,
343 * ::GXIO_MPIPE_LINK_AUTO_UPDOWN is assumed.
344 */
345#define GXIO_MPIPE_LINK_AUTO_NONE 0x00001000UL
346
347/** Request that this open call not complete until the network link is up.
348 * The process will wait as long as necessary for this to happen;
349 * applications which wish to abandon waiting for the link after a
350 * specific time period should not specify this flag when opening a link,
351 * but should instead call gxio_mpipe_link_wait() afterward. The link
352 * must be opened with stats permission. Note that this flag by itself
353 * does not change the desired link state; if other open flags or previous
354 * link state changes have not requested a desired state of up, the open
355 * call will never complete. This flag is not available to kernel
356 * clients.
357 */
358#define GXIO_MPIPE_LINK_WAIT 0x00002000UL
359
360
361/*
362 * Note: link attributes must fit in 24 bits, since we use the top 8 bits
363 * of the IORPC offset word for the channel number.
364 */
365
366/** Determine whether jumbo frames may be received. If this attribute's
367 * value value is nonzero, the MAC will accept frames of up to 10240 bytes.
368 * If the value is zero, the MAC will only accept frames of up to 1544
369 * bytes. The default value is zero. */
370#define GXIO_MPIPE_LINK_RECEIVE_JUMBO 0x010000
371
372/** Determine whether to send pause frames on this link if the mPIPE packet
373 * FIFO is nearly full. If the value is zero, pause frames are not sent.
374 * If the value is nonzero, it is the delay value which will be sent in any
375 * pause frames which are output, in units of 512 bit times.
376 *
377 * Bear in mind that in almost all circumstances, the mPIPE packet FIFO
378 * will never fill up, since mPIPE will empty it as fast as or faster than
379 * the incoming data rate, by either delivering or dropping packets. The
380 * only situation in which this is not true is if the memory and cache
381 * subsystem is extremely heavily loaded, and mPIPE cannot perform DMA of
382 * packet data to memory in a timely fashion. In particular, pause frames
383 * will <em>not</em> be sent if packets cannot be delivered because
384 * NotifRings are full, buckets are full, or buffers are not available in
385 * a buffer stack. */
386#define GXIO_MPIPE_LINK_SEND_PAUSE 0x020000
387
388/** Determine whether to suspend output on the receipt of pause frames.
389 * If the value is nonzero, mPIPE shim will suspend output on the link's
390 * channel when a pause frame is received. If the value is zero, pause
391 * frames will be ignored. The default value is zero. */
392#define GXIO_MPIPE_LINK_RECEIVE_PAUSE 0x030000
393
394/** Interface MAC address. The value is a 6-byte MAC address, in the least
395 * significant 48 bits of the value; in other words, an address which would
396 * be printed as '12:34:56:78:90:AB' in IEEE 802 canonical format would
397 * be returned as 0x12345678ab.
398 *
399 * Depending upon the overall system design, a MAC address may or may not
400 * be available for each interface. Note that the interface's MAC address
401 * does not limit the packets received on its channel, although the
402 * classifier's rules could be configured to do that. Similarly, the MAC
403 * address is not used when transmitting packets, although applications
404 * could certainly decide to use the assigned address as a source MAC
405 * address when doing so. This attribute may only be retrieved with
406 * gxio_mpipe_link_get_attr(); it may not be modified.
407 */
408#define GXIO_MPIPE_LINK_MAC 0x040000
409
410/** Determine whether to discard egress packets on link down. If this value
411 * is nonzero, packets sent on this link while the link is down will be
412 * discarded. If this value is zero, no packets will be sent on this link
413 * while it is down. The default value is one. */
414#define GXIO_MPIPE_LINK_DISCARD_IF_DOWN 0x050000
415
416/** Possible link state. The value is a combination of link state flags,
417 * ORed together, that indicate link modes which are actually supported by
418 * the hardware. This attribute may only be retrieved with
419 * gxio_mpipe_link_get_attr(); it may not be modified. */
420#define GXIO_MPIPE_LINK_POSSIBLE_STATE 0x060000
421
422/** Current link state. The value is a combination of link state flags,
423 * ORed together, that indicate the current state of the hardware. If the
424 * link is down, the value ANDed with ::GXIO_MPIPE_LINK_SPEED will be zero;
425 * if the link is up, the value ANDed with ::GXIO_MPIPE_LINK_SPEED will
426 * result in exactly one of the speed values, indicating the current speed.
427 * This attribute may only be retrieved with gxio_mpipe_link_get_attr(); it
428 * may not be modified. */
429#define GXIO_MPIPE_LINK_CURRENT_STATE 0x070000
430
431/** Desired link state. The value is a conbination of flags, which specify
432 * the desired state for the link. With gxio_mpipe_link_set_attr(), this
433 * will, in the background, attempt to bring up the link using whichever of
434 * the requested flags are reasonable, or take down the link if the flags
435 * are zero. The actual link up or down operation may happen after this
436 * call completes. If the link state changes in the future, the system
437 * will continue to try to get back to the desired link state; for
438 * instance, if the link is brought up successfully, and then the network
439 * cable is disconnected, the link will go down. However, the desired
440 * state of the link is still up, so if the cable is reconnected, the link
441 * will be brought up again.
442 *
443 * With gxio_mpipe_link_set_attr(), this will indicate the desired state
444 * for the link, as set with a previous gxio_mpipe_link_set_attr() call,
445 * or implicitly by a gxio_mpipe_link_open() or link close operation.
446 * This may not reflect the current state of the link; to get that, use
447 * ::GXIO_MPIPE_LINK_CURRENT_STATE.
448 */
449#define GXIO_MPIPE_LINK_DESIRED_STATE 0x080000
450
451
452
453/** Link can run, should run, or is running at 10 Mbps. */
454#define GXIO_MPIPE_LINK_10M 0x0000000000000001UL
455
456/** Link can run, should run, or is running at 100 Mbps. */
457#define GXIO_MPIPE_LINK_100M 0x0000000000000002UL
458
459/** Link can run, should run, or is running at 1 Gbps. */
460#define GXIO_MPIPE_LINK_1G 0x0000000000000004UL
461
462/** Link can run, should run, or is running at 10 Gbps. */
463#define GXIO_MPIPE_LINK_10G 0x0000000000000008UL
464
465/** Link can run, should run, or is running at 20 Gbps. */
466#define GXIO_MPIPE_LINK_20G 0x0000000000000010UL
467
468/** Link can run, should run, or is running at 25 Gbps. */
469#define GXIO_MPIPE_LINK_25G 0x0000000000000020UL
470
471/** Link can run, should run, or is running at 50 Gbps. */
472#define GXIO_MPIPE_LINK_50G 0x0000000000000040UL
473
474/** Link should run at the highest speed supported by the link and by
475 * the device connected to the link. Only usable as a value for
476 * the link's desired state; never returned as a value for the current
477 * or possible states. */
478#define GXIO_MPIPE_LINK_ANYSPEED 0x0000000000000800UL
479
480/** All legal link speeds. This value is provided for use in extracting
481 * the speed-related subset of the link state flags; it is not intended
482 * to be set directly as a value for one of the GXIO_MPIPE_LINK_xxx_STATE
483 * attributes. A link is up or is requested to be up if its current or
484 * desired state, respectively, ANDED with this value, is nonzero. */
485#define GXIO_MPIPE_LINK_SPEED_MASK 0x0000000000000FFFUL
486
487/** Link can run, should run, or is running in MAC loopback mode. This
488 * loops transmitted packets back to the receiver, inside the Tile
489 * Processor. */
490#define GXIO_MPIPE_LINK_LOOP_MAC 0x0000000000001000UL
491
492/** Link can run, should run, or is running in PHY loopback mode. This
493 * loops transmitted packets back to the receiver, inside the external
494 * PHY chip. */
495#define GXIO_MPIPE_LINK_LOOP_PHY 0x0000000000002000UL
496
497/** Link can run, should run, or is running in external loopback mode.
498 * This requires that an external loopback plug be installed on the
499 * Ethernet port. Note that only some links require that this be
500 * configured via the gxio_mpipe_link routines; other links can do
501 * external loopack with the plug and no special configuration. */
502#define GXIO_MPIPE_LINK_LOOP_EXT 0x0000000000004000UL
503
504/** All legal loopback types. */
505#define GXIO_MPIPE_LINK_LOOP_MASK 0x000000000000F000UL
506
507/** Link can run, should run, or is running in full-duplex mode.
508 * If neither ::GXIO_MPIPE_LINK_FDX nor ::GXIO_MPIPE_LINK_HDX are
509 * specified in a set of desired state flags, both are assumed. */
510#define GXIO_MPIPE_LINK_FDX 0x0000000000010000UL
511
512/** Link can run, should run, or is running in half-duplex mode.
513 * If neither ::GXIO_MPIPE_LINK_FDX nor ::GXIO_MPIPE_LINK_HDX are
514 * specified in a set of desired state flags, both are assumed. */
515#define GXIO_MPIPE_LINK_HDX 0x0000000000020000UL
516
517
518/** An individual rule. */
519typedef struct
520{
521 /** The total size. */
522 uint16_t size;
523
524 /** The priority. */
525 int16_t priority;
526
527 /** The "headroom" in each buffer. */
528 uint8_t headroom;
529
530 /** The "tailroom" in each buffer. */
531 uint8_t tailroom;
532
533 /** The "capacity" of the largest buffer. */
534 uint16_t capacity;
535
536 /** The mask for converting a flow hash into a bucket. */
537 uint16_t bucket_mask;
538
539 /** The offset for converting a flow hash into a bucket. */
540 uint16_t bucket_first;
541
542 /** The buffer stack ids. */
543 gxio_mpipe_rules_stacks_t stacks;
544
545 /** The actual channels. */
546 uint32_t channel_bits;
547
548 /** The number of dmacs. */
549 uint16_t num_dmacs;
550
551 /** The number of vlans. */
552 uint16_t num_vlans;
553
554 /** The actual dmacs and vlans. */
555 uint8_t dmacs_and_vlans[];
556
557} gxio_mpipe_rules_rule_t;
558
559
560/** A list of classifier rules. */
561typedef struct
562{
563 /** The offset to the end of the current rule. */
564 uint16_t tail;
565
566 /** The offset to the start of the current rule. */
567 uint16_t head;
568
569 /** The actual rules. */
570 uint8_t rules[4096 - 4];
571
572} gxio_mpipe_rules_list_t;
573
574
575
576
577/** mPIPE statistics structure. These counters include all relevant
578 * events occurring on all links within the mPIPE shim. */
579typedef struct
580{
581 /** Number of ingress packets dropped for any reason. */
582 uint64_t ingress_drops;
583 /** Number of ingress packets dropped because a buffer stack was empty. */
584 uint64_t ingress_drops_no_buf;
585 /** Number of ingress packets dropped or truncated due to lack of space in
586 * the iPkt buffer. */
587 uint64_t ingress_drops_ipkt;
588 /** Number of ingress packets dropped by the classifier or load balancer */
589 uint64_t ingress_drops_cls_lb;
590 /** Total number of ingress packets. */
591 uint64_t ingress_packets;
592 /** Total number of egress packets. */
593 uint64_t egress_packets;
594 /** Total number of ingress bytes. */
595 uint64_t ingress_bytes;
596 /** Total number of egress bytes. */
597 uint64_t egress_bytes;
598}
599gxio_mpipe_stats_t;
600
601
602#endif /* _SYS_HV_DRV_MPIPE_INTF_H */
diff --git a/arch/tile/include/hv/drv_trio_intf.h b/arch/tile/include/hv/drv_trio_intf.h
new file mode 100644
index 00000000000..ef9f3f52ee2
--- /dev/null
+++ b/arch/tile/include/hv/drv_trio_intf.h
@@ -0,0 +1,195 @@
1/*
2 * Copyright 2012 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 * Interface definitions for the trio driver.
17 */
18
19#ifndef _SYS_HV_DRV_TRIO_INTF_H
20#define _SYS_HV_DRV_TRIO_INTF_H
21
22#include <arch/trio.h>
23
24/** The vendor ID for all Tilera processors. */
25#define TILERA_VENDOR_ID 0x1a41
26
27/** The device ID for the Gx36 processor. */
28#define TILERA_GX36_DEV_ID 0x0200
29
30/** Device ID for our internal bridge when running as RC. */
31#define TILERA_GX36_RC_DEV_ID 0x2000
32
33/** Maximum number of TRIO interfaces. */
34#define TILEGX_NUM_TRIO 2
35
36/** Gx36 has max 3 PCIe MACs per TRIO interface. */
37#define TILEGX_TRIO_PCIES 3
38
39/** Specify port properties for a PCIe MAC. */
40struct pcie_port_property
41{
42 /** If true, the link can be configured in PCIe root complex mode. */
43 uint8_t allow_rc: 1;
44
45 /** If true, the link can be configured in PCIe endpoint mode. */
46 uint8_t allow_ep: 1;
47
48 /** If true, the link can be configured in StreamIO mode. */
49 uint8_t allow_sio: 1;
50
51 /** If true, the link is allowed to support 1-lane operation. Software
52 * will not consider it an error if the link comes up as a x1 link. */
53 uint8_t allow_x1: 1;
54
55 /** If true, the link is allowed to support 2-lane operation. Software
56 * will not consider it an error if the link comes up as a x2 link. */
57 uint8_t allow_x2: 1;
58
59 /** If true, the link is allowed to support 4-lane operation. Software
60 * will not consider it an error if the link comes up as a x4 link. */
61 uint8_t allow_x4: 1;
62
63 /** If true, the link is allowed to support 8-lane operation. Software
64 * will not consider it an error if the link comes up as a x8 link. */
65 uint8_t allow_x8: 1;
66
67 /** Reserved. */
68 uint8_t reserved: 1;
69
70};
71
72/** Configurations can be issued to configure a char stream interrupt. */
73typedef enum pcie_stream_intr_config_sel_e
74{
75 /** Interrupt configuration for memory map regions. */
76 MEM_MAP_SEL,
77
78 /** Interrupt configuration for push DMAs. */
79 PUSH_DMA_SEL,
80
81 /** Interrupt configuration for pull DMAs. */
82 PULL_DMA_SEL,
83}
84pcie_stream_intr_config_sel_t;
85
86
87/** The mmap file offset (PA) of the TRIO config region. */
88#define HV_TRIO_CONFIG_OFFSET \
89 ((unsigned long long)TRIO_MMIO_ADDRESS_SPACE__REGION_VAL_CFG << \
90 TRIO_MMIO_ADDRESS_SPACE__REGION_SHIFT)
91
92/** The maximum size of the TRIO config region. */
93#define HV_TRIO_CONFIG_SIZE \
94 (1ULL << TRIO_CFG_REGION_ADDR__REGION_SHIFT)
95
96/** Size of the config region mapped into client. We can't use
97 * TRIO_MMIO_ADDRESS_SPACE__OFFSET_WIDTH because it
98 * will require the kernel to allocate 4GB VA space
99 * from the VMALLOC region which has a total range
100 * of 4GB.
101 */
102#define HV_TRIO_CONFIG_IOREMAP_SIZE \
103 ((uint64_t) 1 << TRIO_CFG_REGION_ADDR__PROT_SHIFT)
104
105/** The mmap file offset (PA) of a scatter queue region. */
106#define HV_TRIO_SQ_OFFSET(queue) \
107 (((unsigned long long)TRIO_MMIO_ADDRESS_SPACE__REGION_VAL_MAP_SQ << \
108 TRIO_MMIO_ADDRESS_SPACE__REGION_SHIFT) | \
109 ((queue) << TRIO_MAP_SQ_REGION_ADDR__SQ_SEL_SHIFT))
110
111/** The maximum size of a scatter queue region. */
112#define HV_TRIO_SQ_SIZE \
113 (1ULL << TRIO_MAP_SQ_REGION_ADDR__SQ_SEL_SHIFT)
114
115
116/** The "hardware MMIO region" of the first PIO region. */
117#define HV_TRIO_FIRST_PIO_REGION 8
118
119/** The mmap file offset (PA) of a PIO region. */
120#define HV_TRIO_PIO_OFFSET(region) \
121 (((unsigned long long)(region) + HV_TRIO_FIRST_PIO_REGION) \
122 << TRIO_PIO_REGIONS_ADDR__REGION_SHIFT)
123
124/** The maximum size of a PIO region. */
125#define HV_TRIO_PIO_SIZE (1ULL << TRIO_PIO_REGIONS_ADDR__ADDR_WIDTH)
126
127
128/** The mmap file offset (PA) of a push DMA region. */
129#define HV_TRIO_PUSH_DMA_OFFSET(ring) \
130 (((unsigned long long)TRIO_MMIO_ADDRESS_SPACE__REGION_VAL_PUSH_DMA << \
131 TRIO_MMIO_ADDRESS_SPACE__REGION_SHIFT) | \
132 ((ring) << TRIO_PUSH_DMA_REGION_ADDR__RING_SEL_SHIFT))
133
134/** The mmap file offset (PA) of a pull DMA region. */
135#define HV_TRIO_PULL_DMA_OFFSET(ring) \
136 (((unsigned long long)TRIO_MMIO_ADDRESS_SPACE__REGION_VAL_PULL_DMA << \
137 TRIO_MMIO_ADDRESS_SPACE__REGION_SHIFT) | \
138 ((ring) << TRIO_PULL_DMA_REGION_ADDR__RING_SEL_SHIFT))
139
140/** The maximum size of a DMA region. */
141#define HV_TRIO_DMA_REGION_SIZE \
142 (1ULL << TRIO_PUSH_DMA_REGION_ADDR__RING_SEL_SHIFT)
143
144
145/** The mmap file offset (PA) of a Mem-Map interrupt region. */
146#define HV_TRIO_MEM_MAP_INTR_OFFSET(map) \
147 (((unsigned long long)TRIO_MMIO_ADDRESS_SPACE__REGION_VAL_MAP_MEM << \
148 TRIO_MMIO_ADDRESS_SPACE__REGION_SHIFT) | \
149 ((map) << TRIO_MAP_MEM_REGION_ADDR__MAP_SEL_SHIFT))
150
151/** The maximum size of a Mem-Map interrupt region. */
152#define HV_TRIO_MEM_MAP_INTR_SIZE \
153 (1ULL << TRIO_MAP_MEM_REGION_ADDR__MAP_SEL_SHIFT)
154
155
156/** A flag bit indicating a fixed resource allocation. */
157#define HV_TRIO_ALLOC_FIXED 0x01
158
159/** TRIO requires that all mappings have 4kB aligned start addresses. */
160#define HV_TRIO_PAGE_SHIFT 12
161
162/** TRIO requires that all mappings have 4kB aligned start addresses. */
163#define HV_TRIO_PAGE_SIZE (1ull << HV_TRIO_PAGE_SHIFT)
164
165
166/* Specify all PCIe port properties for a TRIO. */
167struct pcie_trio_ports_property
168{
169 struct pcie_port_property ports[TILEGX_TRIO_PCIES];
170};
171
172/* Flags indicating traffic class. */
173#define HV_TRIO_FLAG_TC_SHIFT 4
174#define HV_TRIO_FLAG_TC_RMASK 0xf
175#define HV_TRIO_FLAG_TC(N) \
176 ((((N) & HV_TRIO_FLAG_TC_RMASK) + 1) << HV_TRIO_FLAG_TC_SHIFT)
177
178/* Flags indicating virtual functions. */
179#define HV_TRIO_FLAG_VFUNC_SHIFT 8
180#define HV_TRIO_FLAG_VFUNC_RMASK 0xff
181#define HV_TRIO_FLAG_VFUNC(N) \
182 ((((N) & HV_TRIO_FLAG_VFUNC_RMASK) + 1) << HV_TRIO_FLAG_VFUNC_SHIFT)
183
184
185/* Flag indicating an ordered PIO region. */
186#define HV_TRIO_PIO_FLAG_ORDERED (1 << 16)
187
188/* Flags indicating special types of PIO regions. */
189#define HV_TRIO_PIO_FLAG_SPACE_SHIFT 17
190#define HV_TRIO_PIO_FLAG_SPACE_MASK (0x3 << HV_TRIO_PIO_FLAG_SPACE_SHIFT)
191#define HV_TRIO_PIO_FLAG_CONFIG_SPACE (0x1 << HV_TRIO_PIO_FLAG_SPACE_SHIFT)
192#define HV_TRIO_PIO_FLAG_IO_SPACE (0x2 << HV_TRIO_PIO_FLAG_SPACE_SHIFT)
193
194
195#endif /* _SYS_HV_DRV_TRIO_INTF_H */
diff --git a/arch/tile/include/hv/drv_usb_host_intf.h b/arch/tile/include/hv/drv_usb_host_intf.h
new file mode 100644
index 00000000000..24ce774a3f1
--- /dev/null
+++ b/arch/tile/include/hv/drv_usb_host_intf.h
@@ -0,0 +1,39 @@
1/*
2 * Copyright 2012 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 * Interface definitions for the USB host driver.
17 */
18
19#ifndef _SYS_HV_DRV_USB_HOST_INTF_H
20#define _SYS_HV_DRV_USB_HOST_INTF_H
21
22#include <arch/usb_host.h>
23
24
25/** Offset for the EHCI register MMIO region. */
26#define HV_USB_HOST_MMIO_OFFSET_EHCI ((uint64_t) USB_HOST_HCCAPBASE_REG)
27
28/** Offset for the OHCI register MMIO region. */
29#define HV_USB_HOST_MMIO_OFFSET_OHCI ((uint64_t) USB_HOST_OHCD_HC_REVISION_REG)
30
31/** Size of the register MMIO region. This turns out to be the same for
32 * both EHCI and OHCI. */
33#define HV_USB_HOST_MMIO_SIZE ((uint64_t) 0x1000)
34
35/** The number of service domains supported by the USB host shim. */
36#define HV_USB_HOST_NUM_SVC_DOM 1
37
38
39#endif /* _SYS_HV_DRV_USB_HOST_INTF_H */
diff --git a/arch/tile/include/hv/iorpc.h b/arch/tile/include/hv/iorpc.h
new file mode 100644
index 00000000000..89c72a5d934
--- /dev/null
+++ b/arch/tile/include/hv/iorpc.h
@@ -0,0 +1,714 @@
1/*
2 * Copyright 2012 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#ifndef _HV_IORPC_H_
15#define _HV_IORPC_H_
16
17/**
18 *
19 * Error codes and struct definitions for the IO RPC library.
20 *
21 * The hypervisor's IO RPC component provides a convenient way for
22 * driver authors to proxy system calls between user space, linux, and
23 * the hypervisor driver. The core of the system is a set of Python
24 * files that take ".idl" files as input and generates the following
25 * source code:
26 *
27 * - _rpc_call() routines for use in userspace IO libraries. These
28 * routines take an argument list specified in the .idl file, pack the
29 * arguments in to a buffer, and read or write that buffer via the
30 * Linux iorpc driver.
31 *
32 * - dispatch_read() and dispatch_write() routines that hypervisor
33 * drivers can use to implement most of their dev_pread() and
34 * dev_pwrite() methods. These routines decode the incoming parameter
35 * blob, permission check and translate parameters where appropriate,
36 * and then invoke a callback routine for whichever RPC call has
37 * arrived. The driver simply implements the set of callback
38 * routines.
39 *
40 * The IO RPC system also includes the Linux 'iorpc' driver, which
41 * proxies calls between the userspace library and the hypervisor
42 * driver. The Linux driver is almost entirely device agnostic; it
43 * watches for special flags indicating cases where a memory buffer
44 * address might need to be translated, etc. As a result, driver
45 * writers can avoid many of the problem cases related to registering
46 * hardware resources like memory pages or interrupts. However, the
47 * drivers must be careful to obey the conventions documented below in
48 * order to work properly with the generic Linux iorpc driver.
49 *
50 * @section iorpc_domains Service Domains
51 *
52 * All iorpc-based drivers must support a notion of service domains.
53 * A service domain is basically an application context - state
54 * indicating resources that are allocated to that particular app
55 * which it may access and (perhaps) other applications may not
56 * access. Drivers can support any number of service domains they
57 * choose. In some cases the design is limited by a number of service
58 * domains supported by the IO hardware; in other cases the service
59 * domains are a purely software concept and the driver chooses a
60 * maximum number of domains based on how much state memory it is
61 * willing to preallocate.
62 *
63 * For example, the mPIPE driver only supports as many service domains
64 * as are supported by the mPIPE hardware. This limitation is
65 * required because the hardware implements its own MMIO protection
66 * scheme to allow large MMIO mappings while still protecting small
67 * register ranges within the page that should only be accessed by the
68 * hypervisor.
69 *
70 * In contrast, drivers with no hardware service domain limitations
71 * (for instance the TRIO shim) can implement an arbitrary number of
72 * service domains. In these cases, each service domain is limited to
73 * a carefully restricted set of legal MMIO addresses if necessary to
74 * keep one application from corrupting another application's state.
75 *
76 * @section iorpc_conventions System Call Conventions
77 *
78 * The driver's open routine is responsible for allocating a new
79 * service domain for each hv_dev_open() call. By convention, the
80 * return value from open() should be the service domain number on
81 * success, or GXIO_ERR_NO_SVC_DOM if no more service domains are
82 * available.
83 *
84 * The implementations of hv_dev_pread() and hv_dev_pwrite() are
85 * responsible for validating the devhdl value passed up by the
86 * client. Since the device handle returned by hv_dev_open() should
87 * embed the positive service domain number, drivers should make sure
88 * that DRV_HDL2BITS(devhdl) is a legal service domain. If the client
89 * passes an illegal service domain number, the routine should return
90 * GXIO_ERR_INVAL_SVC_DOM. Once the service domain number has been
91 * validated, the driver can copy to/from the client buffer and call
92 * the dispatch_read() or dispatch_write() methods created by the RPC
93 * generator.
94 *
95 * The hv_dev_close() implementation should reset all service domain
96 * state and put the service domain back on a free list for
97 * reallocation by a future application. In most cases, this will
98 * require executing a hardware reset or drain flow and denying any
99 * MMIO regions that were created for the service domain.
100 *
101 * @section iorpc_data Special Data Types
102 *
103 * The .idl file syntax allows the creation of syscalls with special
104 * parameters that require permission checks or translations as part
105 * of the system call path. Because of limitations in the code
106 * generator, APIs are generally limited to just one of these special
107 * parameters per system call, and they are sometimes required to be
108 * the first or last parameter to the call. Special parameters
109 * include:
110 *
111 * @subsection iorpc_mem_buffer MEM_BUFFER
112 *
113 * The MEM_BUFFER() datatype allows user space to "register" memory
114 * buffers with a device. Registering memory accomplishes two tasks:
115 * Linux keeps track of all buffers that might be modified by a
116 * hardware device, and the hardware device drivers bind registered
117 * buffers to particular hardware resources like ingress NotifRings.
118 * The MEM_BUFFER() idl syntax can take extra flags like ALIGN_64KB,
119 * ALIGN_SELF_SIZE, and FLAGS indicating that memory buffers must have
120 * certain alignment or that the user should be able to pass a "memory
121 * flags" word specifying attributes like nt_hint or IO cache pinning.
122 * The parser will accept multiple MEM_BUFFER() flags.
123 *
124 * Implementations must obey the following conventions when
125 * registering memory buffers via the iorpc flow. These rules are a
126 * result of the Linux driver implementation, which needs to keep
127 * track of how many times a particular page has been registered with
128 * the hardware so that it can release the page when all those
129 * registrations are cleared.
130 *
131 * - Memory registrations that refer to a resource which has already
132 * been bound must return GXIO_ERR_ALREADY_INIT. Thus, it is an
133 * error to register memory twice without resetting (i.e. closing) the
134 * resource in between. This convention keeps the Linux driver from
135 * having to track which particular devices a page is bound to.
136 *
137 * - At present, a memory registration is only cleared when the
138 * service domain is reset. In this case, the Linux driver simply
139 * closes the HV device file handle and then decrements the reference
140 * counts of all pages that were previously registered with the
141 * device.
142 *
143 * - In the future, we may add a mechanism for unregistering memory.
144 * One possible implementation would require that the user specify
145 * which buffer is currently registered. The HV would then verify
146 * that that page was actually the one currently mapped and return
147 * success or failure to Linux, which would then only decrement the
148 * page reference count if the addresses were mapped. Another scheme
149 * might allow Linux to pass a token to the HV to be returned when the
150 * resource is unmapped.
151 *
152 * @subsection iorpc_interrupt INTERRUPT
153 *
154 * The INTERRUPT .idl datatype allows the client to bind hardware
155 * interrupts to a particular combination of IPI parameters - CPU, IPI
156 * PL, and event bit number. This data is passed via a special
157 * datatype so that the Linux driver can validate the CPU and PL and
158 * the HV generic iorpc code can translate client CPUs to real CPUs.
159 *
160 * @subsection iorpc_pollfd_setup POLLFD_SETUP
161 *
162 * The POLLFD_SETUP .idl datatype allows the client to set up hardware
163 * interrupt bindings which are received by Linux but which are made
164 * visible to user processes as state transitions on a file descriptor;
165 * this allows user processes to use Linux primitives, such as poll(), to
166 * await particular hardware events. This data is passed via a special
167 * datatype so that the Linux driver may recognize the pollable file
168 * descriptor and translate it to a set of interrupt target information,
169 * and so that the HV generic iorpc code can translate client CPUs to real
170 * CPUs.
171 *
172 * @subsection iorpc_pollfd POLLFD
173 *
174 * The POLLFD .idl datatype allows manipulation of hardware interrupt
175 * bindings set up via the POLLFD_SETUP datatype; common operations are
176 * resetting the state of the requested interrupt events, and unbinding any
177 * bound interrupts. This data is passed via a special datatype so that
178 * the Linux driver may recognize the pollable file descriptor and
179 * translate it to an interrupt identifier previously supplied by the
180 * hypervisor as the result of an earlier pollfd_setup operation.
181 *
182 * @subsection iorpc_blob BLOB
183 *
184 * The BLOB .idl datatype allows the client to write an arbitrary
185 * length string of bytes up to the hypervisor driver. This can be
186 * useful for passing up large, arbitrarily structured data like
187 * classifier programs. The iorpc stack takes care of validating the
188 * buffer VA and CPA as the data passes up to the hypervisor. Unlike
189 * MEM_BUFFER(), the buffer is not registered - Linux does not bump
190 * page refcounts and the HV driver should not reuse the buffer once
191 * the system call is complete.
192 *
193 * @section iorpc_translation Translating User Space Calls
194 *
195 * The ::iorpc_offset structure describes the formatting of the offset
196 * that is passed to pread() or pwrite() as part of the generated RPC code.
197 * When the user calls up to Linux, the rpc code fills in all the fields of
198 * the offset, including a 16-bit opcode, a 16 bit format indicator, and 32
199 * bits of user-specified "sub-offset". The opcode indicates which syscall
200 * is being requested. The format indicates whether there is a "prefix
201 * struct" at the start of the memory buffer passed to pwrite(), and if so
202 * what data is in that prefix struct. These prefix structs are used to
203 * implement special datatypes like MEM_BUFFER() and INTERRUPT - we arrange
204 * to put data that needs translation and permission checks at the start of
205 * the buffer so that the Linux driver and generic portions of the HV iorpc
206 * code can easily access the data. The 32 bits of user-specified
207 * "sub-offset" are most useful for pread() calls where the user needs to
208 * also pass in a few bits indicating which register to read, etc.
209 *
210 * The Linux iorpc driver watches for system calls that contain prefix
211 * structs so that it can translate parameters and bump reference
212 * counts as appropriate. It does not (currently) have any knowledge
213 * of the per-device opcodes - it doesn't care what operation you're
214 * doing to mPIPE, so long as it can do all the generic book-keeping.
215 * The hv/iorpc.h header file defines all of the generic encoding bits
216 * needed to translate iorpc calls without knowing which particular
217 * opcode is being issued.
218 *
219 * @section iorpc_globals Global iorpc Calls
220 *
221 * Implementing mmap() required adding some special iorpc syscalls
222 * that are only called by the Linux driver, never by userspace.
223 * These include get_mmio_base() and check_mmio_offset(). These
224 * routines are described in globals.idl and must be included in every
225 * iorpc driver. By providing these routines in every driver, Linux's
226 * mmap implementation can easily get the PTE bits it needs and
227 * validate the PA offset without needing to know the per-device
228 * opcodes to perform those tasks.
229 *
230 * @section iorpc_kernel Supporting gxio APIs in the Kernel
231 *
232 * The iorpc code generator also supports generation of kernel code
233 * implementing the gxio APIs. This capability is currently used by
234 * the mPIPE network driver, and will likely be used by the TRIO root
235 * complex and endpoint drivers and perhaps an in-kernel crypto
236 * driver. Each driver that wants to instantiate iorpc calls in the
237 * kernel needs to generate a kernel version of the generate rpc code
238 * and (probably) copy any related gxio source files into the kernel.
239 * The mPIPE driver provides a good example of this pattern.
240 */
241
242#ifdef __KERNEL__
243#include <linux/stddef.h>
244#else
245#include <stddef.h>
246#endif
247
248#if defined(__HV__)
249#include <hv/hypervisor.h>
250#elif defined(__KERNEL__)
251#include "hypervisor.h"
252#include <linux/types.h>
253#else
254#include <stdint.h>
255#endif
256
257
258/** Code indicating translation services required within the RPC path.
259 * These indicate whether there is a translatable struct at the start
260 * of the RPC buffer and what information that struct contains.
261 */
262enum iorpc_format_e
263{
264 /** No translation required, no prefix struct. */
265 IORPC_FORMAT_NONE,
266
267 /** No translation required, no prefix struct, no access to this
268 * operation from user space. */
269 IORPC_FORMAT_NONE_NOUSER,
270
271 /** Prefix struct contains user VA and size. */
272 IORPC_FORMAT_USER_MEM,
273
274 /** Prefix struct contains CPA, size, and homing bits. */
275 IORPC_FORMAT_KERNEL_MEM,
276
277 /** Prefix struct contains interrupt. */
278 IORPC_FORMAT_KERNEL_INTERRUPT,
279
280 /** Prefix struct contains user-level interrupt. */
281 IORPC_FORMAT_USER_INTERRUPT,
282
283 /** Prefix struct contains pollfd_setup (interrupt information). */
284 IORPC_FORMAT_KERNEL_POLLFD_SETUP,
285
286 /** Prefix struct contains user-level pollfd_setup (file descriptor). */
287 IORPC_FORMAT_USER_POLLFD_SETUP,
288
289 /** Prefix struct contains pollfd (interrupt cookie). */
290 IORPC_FORMAT_KERNEL_POLLFD,
291
292 /** Prefix struct contains user-level pollfd (file descriptor). */
293 IORPC_FORMAT_USER_POLLFD,
294};
295
296
297/** Generate an opcode given format and code. */
298#define IORPC_OPCODE(FORMAT, CODE) (((FORMAT) << 16) | (CODE))
299
300/** The offset passed through the read() and write() system calls
301 combines an opcode with 32 bits of user-specified offset. */
302union iorpc_offset
303{
304#ifndef __BIG_ENDIAN__
305 uint64_t offset; /**< All bits. */
306
307 struct
308 {
309 uint16_t code; /**< RPC code. */
310 uint16_t format; /**< iorpc_format_e */
311 uint32_t sub_offset; /**< caller-specified offset. */
312 };
313
314 uint32_t opcode; /**< Opcode combines code & format. */
315#else
316 uint64_t offset; /**< All bits. */
317
318 struct
319 {
320 uint32_t sub_offset; /**< caller-specified offset. */
321 uint16_t format; /**< iorpc_format_e */
322 uint16_t code; /**< RPC code. */
323 };
324
325 struct
326 {
327 uint32_t padding;
328 uint32_t opcode; /**< Opcode combines code & format. */
329 };
330#endif
331};
332
333
334/** Homing and cache hinting bits that can be used by IO devices. */
335struct iorpc_mem_attr
336{
337 unsigned int lotar_x:4; /**< lotar X bits (or Gx page_mask). */
338 unsigned int lotar_y:4; /**< lotar Y bits (or Gx page_offset). */
339 unsigned int hfh:1; /**< Uses hash-for-home. */
340 unsigned int nt_hint:1; /**< Non-temporal hint. */
341 unsigned int io_pin:1; /**< Only fill 'IO' cache ways. */
342};
343
344/** Set the nt_hint bit. */
345#define IORPC_MEM_BUFFER_FLAG_NT_HINT (1 << 0)
346
347/** Set the IO pin bit. */
348#define IORPC_MEM_BUFFER_FLAG_IO_PIN (1 << 1)
349
350
351/** A structure used to describe memory registration. Different
352 protection levels describe memory differently, so this union
353 contains all the different possible descriptions. As a request
354 moves up the call chain, each layer translates from one
355 description format to the next. In particular, the Linux iorpc
356 driver translates user VAs into CPAs and homing parameters. */
357union iorpc_mem_buffer
358{
359 struct
360 {
361 uint64_t va; /**< User virtual address. */
362 uint64_t size; /**< Buffer size. */
363 unsigned int flags; /**< nt_hint, IO pin. */
364 }
365 user; /**< Buffer as described by user apps. */
366
367 struct
368 {
369 unsigned long long cpa; /**< Client physical address. */
370#if defined(__KERNEL__) || defined(__HV__)
371 size_t size; /**< Buffer size. */
372 HV_PTE pte; /**< PTE describing memory homing. */
373#else
374 uint64_t size;
375 uint64_t pte;
376#endif
377 unsigned int flags; /**< nt_hint, IO pin. */
378 }
379 kernel; /**< Buffer as described by kernel. */
380
381 struct
382 {
383 unsigned long long pa; /**< Physical address. */
384 size_t size; /**< Buffer size. */
385 struct iorpc_mem_attr attr; /**< Homing and locality hint bits. */
386 }
387 hv; /**< Buffer parameters for HV driver. */
388};
389
390
391/** A structure used to describe interrupts. The format differs slightly
392 * for user and kernel interrupts. As with the mem_buffer_t, translation
393 * between the formats is done at each level. */
394union iorpc_interrupt
395{
396 struct
397 {
398 int cpu; /**< CPU. */
399 int event; /**< evt_num */
400 }
401 user; /**< Interrupt as described by user applications. */
402
403 struct
404 {
405 int x; /**< X coord. */
406 int y; /**< Y coord. */
407 int ipi; /**< int_num */
408 int event; /**< evt_num */
409 }
410 kernel; /**< Interrupt as described by the kernel. */
411
412};
413
414
415/** A structure used to describe interrupts used with poll(). The format
416 * differs significantly for requests from user to kernel, and kernel to
417 * hypervisor. As with the mem_buffer_t, translation between the formats
418 * is done at each level. */
419union iorpc_pollfd_setup
420{
421 struct
422 {
423 int fd; /**< Pollable file descriptor. */
424 }
425 user; /**< pollfd_setup as described by user applications. */
426
427 struct
428 {
429 int x; /**< X coord. */
430 int y; /**< Y coord. */
431 int ipi; /**< int_num */
432 int event; /**< evt_num */
433 }
434 kernel; /**< pollfd_setup as described by the kernel. */
435
436};
437
438
439/** A structure used to describe previously set up interrupts used with
440 * poll(). The format differs significantly for requests from user to
441 * kernel, and kernel to hypervisor. As with the mem_buffer_t, translation
442 * between the formats is done at each level. */
443union iorpc_pollfd
444{
445 struct
446 {
447 int fd; /**< Pollable file descriptor. */
448 }
449 user; /**< pollfd as described by user applications. */
450
451 struct
452 {
453 int cookie; /**< hv cookie returned by the pollfd_setup operation. */
454 }
455 kernel; /**< pollfd as described by the kernel. */
456
457};
458
459
460/** The various iorpc devices use error codes from -1100 to -1299.
461 *
462 * This range is distinct from netio (-700 to -799), the hypervisor
463 * (-800 to -899), tilepci (-900 to -999), ilib (-1000 to -1099),
464 * gxcr (-1300 to -1399) and gxpci (-1400 to -1499).
465 */
466enum gxio_err_e {
467
468 /** Largest iorpc error number. */
469 GXIO_ERR_MAX = -1101,
470
471
472 /********************************************************/
473 /* Generic Error Codes */
474 /********************************************************/
475
476 /** Bad RPC opcode - possible version incompatibility. */
477 GXIO_ERR_OPCODE = -1101,
478
479 /** Invalid parameter. */
480 GXIO_ERR_INVAL = -1102,
481
482 /** Memory buffer did not meet alignment requirements. */
483 GXIO_ERR_ALIGNMENT = -1103,
484
485 /** Memory buffers must be coherent and cacheable. */
486 GXIO_ERR_COHERENCE = -1104,
487
488 /** Resource already initialized. */
489 GXIO_ERR_ALREADY_INIT = -1105,
490
491 /** No service domains available. */
492 GXIO_ERR_NO_SVC_DOM = -1106,
493
494 /** Illegal service domain number. */
495 GXIO_ERR_INVAL_SVC_DOM = -1107,
496
497 /** Illegal MMIO address. */
498 GXIO_ERR_MMIO_ADDRESS = -1108,
499
500 /** Illegal interrupt binding. */
501 GXIO_ERR_INTERRUPT = -1109,
502
503 /** Unreasonable client memory. */
504 GXIO_ERR_CLIENT_MEMORY = -1110,
505
506 /** No more IOTLB entries. */
507 GXIO_ERR_IOTLB_ENTRY = -1111,
508
509 /** Invalid memory size. */
510 GXIO_ERR_INVAL_MEMORY_SIZE = -1112,
511
512 /** Unsupported operation. */
513 GXIO_ERR_UNSUPPORTED_OP = -1113,
514
515 /** Insufficient DMA credits. */
516 GXIO_ERR_DMA_CREDITS = -1114,
517
518 /** Operation timed out. */
519 GXIO_ERR_TIMEOUT = -1115,
520
521 /** No such device or object. */
522 GXIO_ERR_NO_DEVICE = -1116,
523
524 /** Device or resource busy. */
525 GXIO_ERR_BUSY = -1117,
526
527 /** I/O error. */
528 GXIO_ERR_IO = -1118,
529
530 /** Permissions error. */
531 GXIO_ERR_PERM = -1119,
532
533
534
535 /********************************************************/
536 /* Test Device Error Codes */
537 /********************************************************/
538
539 /** Illegal register number. */
540 GXIO_TEST_ERR_REG_NUMBER = -1120,
541
542 /** Illegal buffer slot. */
543 GXIO_TEST_ERR_BUFFER_SLOT = -1121,
544
545
546 /********************************************************/
547 /* MPIPE Error Codes */
548 /********************************************************/
549
550
551 /** Invalid buffer size. */
552 GXIO_MPIPE_ERR_INVAL_BUFFER_SIZE = -1131,
553
554 /** Cannot allocate buffer stack. */
555 GXIO_MPIPE_ERR_NO_BUFFER_STACK = -1140,
556
557 /** Invalid buffer stack number. */
558 GXIO_MPIPE_ERR_BAD_BUFFER_STACK = -1141,
559
560 /** Cannot allocate NotifRing. */
561 GXIO_MPIPE_ERR_NO_NOTIF_RING = -1142,
562
563 /** Invalid NotifRing number. */
564 GXIO_MPIPE_ERR_BAD_NOTIF_RING = -1143,
565
566 /** Cannot allocate NotifGroup. */
567 GXIO_MPIPE_ERR_NO_NOTIF_GROUP = -1144,
568
569 /** Invalid NotifGroup number. */
570 GXIO_MPIPE_ERR_BAD_NOTIF_GROUP = -1145,
571
572 /** Cannot allocate bucket. */
573 GXIO_MPIPE_ERR_NO_BUCKET = -1146,
574
575 /** Invalid bucket number. */
576 GXIO_MPIPE_ERR_BAD_BUCKET = -1147,
577
578 /** Cannot allocate eDMA ring. */
579 GXIO_MPIPE_ERR_NO_EDMA_RING = -1148,
580
581 /** Invalid eDMA ring number. */
582 GXIO_MPIPE_ERR_BAD_EDMA_RING = -1149,
583
584 /** Invalid channel number. */
585 GXIO_MPIPE_ERR_BAD_CHANNEL = -1150,
586
587 /** Bad configuration. */
588 GXIO_MPIPE_ERR_BAD_CONFIG = -1151,
589
590 /** Empty iqueue. */
591 GXIO_MPIPE_ERR_IQUEUE_EMPTY = -1152,
592
593 /** Empty rules. */
594 GXIO_MPIPE_ERR_RULES_EMPTY = -1160,
595
596 /** Full rules. */
597 GXIO_MPIPE_ERR_RULES_FULL = -1161,
598
599 /** Corrupt rules. */
600 GXIO_MPIPE_ERR_RULES_CORRUPT = -1162,
601
602 /** Invalid rules. */
603 GXIO_MPIPE_ERR_RULES_INVALID = -1163,
604
605 /** Classifier is too big. */
606 GXIO_MPIPE_ERR_CLASSIFIER_TOO_BIG = -1170,
607
608 /** Classifier is too complex. */
609 GXIO_MPIPE_ERR_CLASSIFIER_TOO_COMPLEX = -1171,
610
611 /** Classifier has bad header. */
612 GXIO_MPIPE_ERR_CLASSIFIER_BAD_HEADER = -1172,
613
614 /** Classifier has bad contents. */
615 GXIO_MPIPE_ERR_CLASSIFIER_BAD_CONTENTS = -1173,
616
617 /** Classifier encountered invalid symbol. */
618 GXIO_MPIPE_ERR_CLASSIFIER_INVAL_SYMBOL = -1174,
619
620 /** Classifier encountered invalid bounds. */
621 GXIO_MPIPE_ERR_CLASSIFIER_INVAL_BOUNDS = -1175,
622
623 /** Classifier encountered invalid relocation. */
624 GXIO_MPIPE_ERR_CLASSIFIER_INVAL_RELOCATION = -1176,
625
626 /** Classifier encountered undefined symbol. */
627 GXIO_MPIPE_ERR_CLASSIFIER_UNDEF_SYMBOL = -1177,
628
629
630 /********************************************************/
631 /* TRIO Error Codes */
632 /********************************************************/
633
634 /** Cannot allocate memory map region. */
635 GXIO_TRIO_ERR_NO_MEMORY_MAP = -1180,
636
637 /** Invalid memory map region number. */
638 GXIO_TRIO_ERR_BAD_MEMORY_MAP = -1181,
639
640 /** Cannot allocate scatter queue. */
641 GXIO_TRIO_ERR_NO_SCATTER_QUEUE = -1182,
642
643 /** Invalid scatter queue number. */
644 GXIO_TRIO_ERR_BAD_SCATTER_QUEUE = -1183,
645
646 /** Cannot allocate push DMA ring. */
647 GXIO_TRIO_ERR_NO_PUSH_DMA_RING = -1184,
648
649 /** Invalid push DMA ring index. */
650 GXIO_TRIO_ERR_BAD_PUSH_DMA_RING = -1185,
651
652 /** Cannot allocate pull DMA ring. */
653 GXIO_TRIO_ERR_NO_PULL_DMA_RING = -1186,
654
655 /** Invalid pull DMA ring index. */
656 GXIO_TRIO_ERR_BAD_PULL_DMA_RING = -1187,
657
658 /** Cannot allocate PIO region. */
659 GXIO_TRIO_ERR_NO_PIO = -1188,
660
661 /** Invalid PIO region index. */
662 GXIO_TRIO_ERR_BAD_PIO = -1189,
663
664 /** Cannot allocate ASID. */
665 GXIO_TRIO_ERR_NO_ASID = -1190,
666
667 /** Invalid ASID. */
668 GXIO_TRIO_ERR_BAD_ASID = -1191,
669
670
671 /********************************************************/
672 /* MICA Error Codes */
673 /********************************************************/
674
675 /** No such accelerator type. */
676 GXIO_MICA_ERR_BAD_ACCEL_TYPE = -1220,
677
678 /** Cannot allocate context. */
679 GXIO_MICA_ERR_NO_CONTEXT = -1221,
680
681 /** PKA command queue is full, can't add another command. */
682 GXIO_MICA_ERR_PKA_CMD_QUEUE_FULL = -1222,
683
684 /** PKA result queue is empty, can't get a result from the queue. */
685 GXIO_MICA_ERR_PKA_RESULT_QUEUE_EMPTY = -1223,
686
687 /********************************************************/
688 /* GPIO Error Codes */
689 /********************************************************/
690
691 /** Pin not available. Either the physical pin does not exist, or
692 * it is reserved by the hypervisor for system usage. */
693 GXIO_GPIO_ERR_PIN_UNAVAILABLE = -1240,
694
695 /** Pin busy. The pin exists, and is available for use via GXIO, but
696 * it has been attached by some other process or driver. */
697 GXIO_GPIO_ERR_PIN_BUSY = -1241,
698
699 /** Cannot access unattached pin. One or more of the pins being
700 * manipulated by this call are not attached to the requesting
701 * context. */
702 GXIO_GPIO_ERR_PIN_UNATTACHED = -1242,
703
704 /** Invalid I/O mode for pin. The wiring of the pin in the system
705 * is such that the I/O mode or electrical control parameters
706 * requested could cause damage. */
707 GXIO_GPIO_ERR_PIN_INVALID_MODE = -1243,
708
709 /** Smallest iorpc error number. */
710 GXIO_ERR_MIN = -1299
711};
712
713
714#endif /* !_HV_IORPC_H_ */
diff --git a/arch/tile/kernel/Makefile b/arch/tile/kernel/Makefile
index 5de99248d8d..5334be8e253 100644
--- a/arch/tile/kernel/Makefile
+++ b/arch/tile/kernel/Makefile
@@ -14,4 +14,9 @@ obj-$(CONFIG_SMP) += smpboot.o smp.o tlb.o
14obj-$(CONFIG_MODULES) += module.o 14obj-$(CONFIG_MODULES) += module.o
15obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 15obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
16obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel_$(BITS).o 16obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel_$(BITS).o
17ifdef CONFIG_TILEGX
18obj-$(CONFIG_PCI) += pci_gx.o
19else
17obj-$(CONFIG_PCI) += pci.o 20obj-$(CONFIG_PCI) += pci.o
21endif
22obj-$(CONFIG_TILE_USB) += usb.o
diff --git a/arch/tile/kernel/pci-dma.c b/arch/tile/kernel/pci-dma.c
index b3ed19f8779..b9fe80ec108 100644
--- a/arch/tile/kernel/pci-dma.c
+++ b/arch/tile/kernel/pci-dma.c
@@ -14,6 +14,7 @@
14 14
15#include <linux/mm.h> 15#include <linux/mm.h>
16#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
17#include <linux/swiotlb.h>
17#include <linux/vmalloc.h> 18#include <linux/vmalloc.h>
18#include <linux/export.h> 19#include <linux/export.h>
19#include <asm/tlbflush.h> 20#include <asm/tlbflush.h>
@@ -22,13 +23,18 @@
22/* Generic DMA mapping functions: */ 23/* Generic DMA mapping functions: */
23 24
24/* 25/*
25 * Allocate what Linux calls "coherent" memory, which for us just 26 * Allocate what Linux calls "coherent" memory. On TILEPro this is
26 * means uncached. 27 * uncached memory; on TILE-Gx it is hash-for-home memory.
27 */ 28 */
28void *dma_alloc_coherent(struct device *dev, 29#ifdef __tilepro__
29 size_t size, 30#define PAGE_HOME_DMA PAGE_HOME_UNCACHED
30 dma_addr_t *dma_handle, 31#else
31 gfp_t gfp) 32#define PAGE_HOME_DMA PAGE_HOME_HASH
33#endif
34
35static void *tile_dma_alloc_coherent(struct device *dev, size_t size,
36 dma_addr_t *dma_handle, gfp_t gfp,
37 struct dma_attrs *attrs)
32{ 38{
33 u64 dma_mask = dev->coherent_dma_mask ?: DMA_BIT_MASK(32); 39 u64 dma_mask = dev->coherent_dma_mask ?: DMA_BIT_MASK(32);
34 int node = dev_to_node(dev); 40 int node = dev_to_node(dev);
@@ -39,39 +45,42 @@ void *dma_alloc_coherent(struct device *dev,
39 gfp |= __GFP_ZERO; 45 gfp |= __GFP_ZERO;
40 46
41 /* 47 /*
42 * By forcing NUMA node 0 for 32-bit masks we ensure that the 48 * If the mask specifies that the memory be in the first 4 GB, then
43 * high 32 bits of the resulting PA will be zero. If the mask 49 * we force the allocation to come from the DMA zone. We also
44 * size is, e.g., 24, we may still not be able to guarantee a 50 * force the node to 0 since that's the only node where the DMA
45 * suitable memory address, in which case we will return NULL. 51 * zone isn't empty. If the mask size is smaller than 32 bits, we
46 * But such devices are uncommon. 52 * may still not be able to guarantee a suitable memory address, in
53 * which case we will return NULL. But such devices are uncommon.
47 */ 54 */
48 if (dma_mask <= DMA_BIT_MASK(32)) 55 if (dma_mask <= DMA_BIT_MASK(32)) {
56 gfp |= GFP_DMA;
49 node = 0; 57 node = 0;
58 }
50 59
51 pg = homecache_alloc_pages_node(node, gfp, order, PAGE_HOME_UNCACHED); 60 pg = homecache_alloc_pages_node(node, gfp, order, PAGE_HOME_DMA);
52 if (pg == NULL) 61 if (pg == NULL)
53 return NULL; 62 return NULL;
54 63
55 addr = page_to_phys(pg); 64 addr = page_to_phys(pg);
56 if (addr + size > dma_mask) { 65 if (addr + size > dma_mask) {
57 homecache_free_pages(addr, order); 66 __homecache_free_pages(pg, order);
58 return NULL; 67 return NULL;
59 } 68 }
60 69
61 *dma_handle = addr; 70 *dma_handle = addr;
71
62 return page_address(pg); 72 return page_address(pg);
63} 73}
64EXPORT_SYMBOL(dma_alloc_coherent);
65 74
66/* 75/*
67 * Free memory that was allocated with dma_alloc_coherent. 76 * Free memory that was allocated with tile_dma_alloc_coherent.
68 */ 77 */
69void dma_free_coherent(struct device *dev, size_t size, 78static void tile_dma_free_coherent(struct device *dev, size_t size,
70 void *vaddr, dma_addr_t dma_handle) 79 void *vaddr, dma_addr_t dma_handle,
80 struct dma_attrs *attrs)
71{ 81{
72 homecache_free_pages((unsigned long)vaddr, get_order(size)); 82 homecache_free_pages((unsigned long)vaddr, get_order(size));
73} 83}
74EXPORT_SYMBOL(dma_free_coherent);
75 84
76/* 85/*
77 * The map routines "map" the specified address range for DMA 86 * The map routines "map" the specified address range for DMA
@@ -87,52 +96,285 @@ EXPORT_SYMBOL(dma_free_coherent);
87 * can count on nothing having been touched. 96 * can count on nothing having been touched.
88 */ 97 */
89 98
90/* Flush a PA range from cache page by page. */ 99/* Set up a single page for DMA access. */
91static void __dma_map_pa_range(dma_addr_t dma_addr, size_t size) 100static void __dma_prep_page(struct page *page, unsigned long offset,
101 size_t size, enum dma_data_direction direction)
102{
103 /*
104 * Flush the page from cache if necessary.
105 * On tilegx, data is delivered to hash-for-home L3; on tilepro,
106 * data is delivered direct to memory.
107 *
108 * NOTE: If we were just doing DMA_TO_DEVICE we could optimize
109 * this to be a "flush" not a "finv" and keep some of the
110 * state in cache across the DMA operation, but it doesn't seem
111 * worth creating the necessary flush_buffer_xxx() infrastructure.
112 */
113 int home = page_home(page);
114 switch (home) {
115 case PAGE_HOME_HASH:
116#ifdef __tilegx__
117 return;
118#endif
119 break;
120 case PAGE_HOME_UNCACHED:
121#ifdef __tilepro__
122 return;
123#endif
124 break;
125 case PAGE_HOME_IMMUTABLE:
126 /* Should be going to the device only. */
127 BUG_ON(direction == DMA_FROM_DEVICE ||
128 direction == DMA_BIDIRECTIONAL);
129 return;
130 case PAGE_HOME_INCOHERENT:
131 /* Incoherent anyway, so no need to work hard here. */
132 return;
133 default:
134 BUG_ON(home < 0 || home >= NR_CPUS);
135 break;
136 }
137 homecache_finv_page(page);
138
139#ifdef DEBUG_ALIGNMENT
140 /* Warn if the region isn't cacheline aligned. */
141 if (offset & (L2_CACHE_BYTES - 1) || (size & (L2_CACHE_BYTES - 1)))
142 pr_warn("Unaligned DMA to non-hfh memory: PA %#llx/%#lx\n",
143 PFN_PHYS(page_to_pfn(page)) + offset, size);
144#endif
145}
146
147/* Make the page ready to be read by the core. */
148static void __dma_complete_page(struct page *page, unsigned long offset,
149 size_t size, enum dma_data_direction direction)
150{
151#ifdef __tilegx__
152 switch (page_home(page)) {
153 case PAGE_HOME_HASH:
154 /* I/O device delivered data the way the cpu wanted it. */
155 break;
156 case PAGE_HOME_INCOHERENT:
157 /* Incoherent anyway, so no need to work hard here. */
158 break;
159 case PAGE_HOME_IMMUTABLE:
160 /* Extra read-only copies are not a problem. */
161 break;
162 default:
163 /* Flush the bogus hash-for-home I/O entries to memory. */
164 homecache_finv_map_page(page, PAGE_HOME_HASH);
165 break;
166 }
167#endif
168}
169
170static void __dma_prep_pa_range(dma_addr_t dma_addr, size_t size,
171 enum dma_data_direction direction)
92{ 172{
93 struct page *page = pfn_to_page(PFN_DOWN(dma_addr)); 173 struct page *page = pfn_to_page(PFN_DOWN(dma_addr));
94 size_t bytesleft = PAGE_SIZE - (dma_addr & (PAGE_SIZE - 1)); 174 unsigned long offset = dma_addr & (PAGE_SIZE - 1);
175 size_t bytes = min(size, (size_t)(PAGE_SIZE - offset));
176
177 while (size != 0) {
178 __dma_prep_page(page, offset, bytes, direction);
179 size -= bytes;
180 ++page;
181 offset = 0;
182 bytes = min((size_t)PAGE_SIZE, size);
183 }
184}
95 185
96 while ((ssize_t)size > 0) { 186static void __dma_complete_pa_range(dma_addr_t dma_addr, size_t size,
97 /* Flush the page. */ 187 enum dma_data_direction direction)
98 homecache_flush_cache(page++, 0); 188{
189 struct page *page = pfn_to_page(PFN_DOWN(dma_addr));
190 unsigned long offset = dma_addr & (PAGE_SIZE - 1);
191 size_t bytes = min(size, (size_t)(PAGE_SIZE - offset));
192
193 while (size != 0) {
194 __dma_complete_page(page, offset, bytes, direction);
195 size -= bytes;
196 ++page;
197 offset = 0;
198 bytes = min((size_t)PAGE_SIZE, size);
199 }
200}
201
202static int tile_dma_map_sg(struct device *dev, struct scatterlist *sglist,
203 int nents, enum dma_data_direction direction,
204 struct dma_attrs *attrs)
205{
206 struct scatterlist *sg;
207 int i;
208
209 BUG_ON(!valid_dma_direction(direction));
210
211 WARN_ON(nents == 0 || sglist->length == 0);
99 212
100 /* Figure out if we need to continue on the next page. */ 213 for_each_sg(sglist, sg, nents, i) {
101 size -= bytesleft; 214 sg->dma_address = sg_phys(sg);
102 bytesleft = PAGE_SIZE; 215 __dma_prep_pa_range(sg->dma_address, sg->length, direction);
216#ifdef CONFIG_NEED_SG_DMA_LENGTH
217 sg->dma_length = sg->length;
218#endif
103 } 219 }
220
221 return nents;
104} 222}
105 223
106/* 224static void tile_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
107 * dma_map_single can be passed any memory address, and there appear 225 int nents, enum dma_data_direction direction,
108 * to be no alignment constraints. 226 struct dma_attrs *attrs)
109 * 227{
110 * There is a chance that the start of the buffer will share a cache 228 struct scatterlist *sg;
111 * line with some other data that has been touched in the meantime. 229 int i;
112 */ 230
113dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size, 231 BUG_ON(!valid_dma_direction(direction));
114 enum dma_data_direction direction) 232 for_each_sg(sglist, sg, nents, i) {
233 sg->dma_address = sg_phys(sg);
234 __dma_complete_pa_range(sg->dma_address, sg->length,
235 direction);
236 }
237}
238
239static dma_addr_t tile_dma_map_page(struct device *dev, struct page *page,
240 unsigned long offset, size_t size,
241 enum dma_data_direction direction,
242 struct dma_attrs *attrs)
115{ 243{
116 dma_addr_t dma_addr = __pa(ptr); 244 BUG_ON(!valid_dma_direction(direction));
245
246 BUG_ON(offset + size > PAGE_SIZE);
247 __dma_prep_page(page, offset, size, direction);
117 248
249 return page_to_pa(page) + offset;
250}
251
252static void tile_dma_unmap_page(struct device *dev, dma_addr_t dma_address,
253 size_t size, enum dma_data_direction direction,
254 struct dma_attrs *attrs)
255{
118 BUG_ON(!valid_dma_direction(direction)); 256 BUG_ON(!valid_dma_direction(direction));
119 WARN_ON(size == 0);
120 257
121 __dma_map_pa_range(dma_addr, size); 258 __dma_complete_page(pfn_to_page(PFN_DOWN(dma_address)),
259 dma_address & PAGE_OFFSET, size, direction);
260}
122 261
123 return dma_addr; 262static void tile_dma_sync_single_for_cpu(struct device *dev,
263 dma_addr_t dma_handle,
264 size_t size,
265 enum dma_data_direction direction)
266{
267 BUG_ON(!valid_dma_direction(direction));
268
269 __dma_complete_pa_range(dma_handle, size, direction);
270}
271
272static void tile_dma_sync_single_for_device(struct device *dev,
273 dma_addr_t dma_handle, size_t size,
274 enum dma_data_direction direction)
275{
276 __dma_prep_pa_range(dma_handle, size, direction);
124} 277}
125EXPORT_SYMBOL(dma_map_single);
126 278
127void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, 279static void tile_dma_sync_sg_for_cpu(struct device *dev,
128 enum dma_data_direction direction) 280 struct scatterlist *sglist, int nelems,
281 enum dma_data_direction direction)
129{ 282{
283 struct scatterlist *sg;
284 int i;
285
286 BUG_ON(!valid_dma_direction(direction));
287 WARN_ON(nelems == 0 || sglist->length == 0);
288
289 for_each_sg(sglist, sg, nelems, i) {
290 dma_sync_single_for_cpu(dev, sg->dma_address,
291 sg_dma_len(sg), direction);
292 }
293}
294
295static void tile_dma_sync_sg_for_device(struct device *dev,
296 struct scatterlist *sglist, int nelems,
297 enum dma_data_direction direction)
298{
299 struct scatterlist *sg;
300 int i;
301
130 BUG_ON(!valid_dma_direction(direction)); 302 BUG_ON(!valid_dma_direction(direction));
303 WARN_ON(nelems == 0 || sglist->length == 0);
304
305 for_each_sg(sglist, sg, nelems, i) {
306 dma_sync_single_for_device(dev, sg->dma_address,
307 sg_dma_len(sg), direction);
308 }
309}
310
311static inline int
312tile_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
313{
314 return 0;
315}
316
317static inline int
318tile_dma_supported(struct device *dev, u64 mask)
319{
320 return 1;
321}
322
323static struct dma_map_ops tile_default_dma_map_ops = {
324 .alloc = tile_dma_alloc_coherent,
325 .free = tile_dma_free_coherent,
326 .map_page = tile_dma_map_page,
327 .unmap_page = tile_dma_unmap_page,
328 .map_sg = tile_dma_map_sg,
329 .unmap_sg = tile_dma_unmap_sg,
330 .sync_single_for_cpu = tile_dma_sync_single_for_cpu,
331 .sync_single_for_device = tile_dma_sync_single_for_device,
332 .sync_sg_for_cpu = tile_dma_sync_sg_for_cpu,
333 .sync_sg_for_device = tile_dma_sync_sg_for_device,
334 .mapping_error = tile_dma_mapping_error,
335 .dma_supported = tile_dma_supported
336};
337
338struct dma_map_ops *tile_dma_map_ops = &tile_default_dma_map_ops;
339EXPORT_SYMBOL(tile_dma_map_ops);
340
341/* Generic PCI DMA mapping functions */
342
343static void *tile_pci_dma_alloc_coherent(struct device *dev, size_t size,
344 dma_addr_t *dma_handle, gfp_t gfp,
345 struct dma_attrs *attrs)
346{
347 int node = dev_to_node(dev);
348 int order = get_order(size);
349 struct page *pg;
350 dma_addr_t addr;
351
352 gfp |= __GFP_ZERO;
353
354 pg = homecache_alloc_pages_node(node, gfp, order, PAGE_HOME_DMA);
355 if (pg == NULL)
356 return NULL;
357
358 addr = page_to_phys(pg);
359
360 *dma_handle = phys_to_dma(dev, addr);
361
362 return page_address(pg);
363}
364
365/*
366 * Free memory that was allocated with tile_pci_dma_alloc_coherent.
367 */
368static void tile_pci_dma_free_coherent(struct device *dev, size_t size,
369 void *vaddr, dma_addr_t dma_handle,
370 struct dma_attrs *attrs)
371{
372 homecache_free_pages((unsigned long)vaddr, get_order(size));
131} 373}
132EXPORT_SYMBOL(dma_unmap_single);
133 374
134int dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents, 375static int tile_pci_dma_map_sg(struct device *dev, struct scatterlist *sglist,
135 enum dma_data_direction direction) 376 int nents, enum dma_data_direction direction,
377 struct dma_attrs *attrs)
136{ 378{
137 struct scatterlist *sg; 379 struct scatterlist *sg;
138 int i; 380 int i;
@@ -143,73 +385,103 @@ int dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
143 385
144 for_each_sg(sglist, sg, nents, i) { 386 for_each_sg(sglist, sg, nents, i) {
145 sg->dma_address = sg_phys(sg); 387 sg->dma_address = sg_phys(sg);
146 __dma_map_pa_range(sg->dma_address, sg->length); 388 __dma_prep_pa_range(sg->dma_address, sg->length, direction);
389
390 sg->dma_address = phys_to_dma(dev, sg->dma_address);
391#ifdef CONFIG_NEED_SG_DMA_LENGTH
392 sg->dma_length = sg->length;
393#endif
147 } 394 }
148 395
149 return nents; 396 return nents;
150} 397}
151EXPORT_SYMBOL(dma_map_sg);
152 398
153void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries, 399static void tile_pci_dma_unmap_sg(struct device *dev,
154 enum dma_data_direction direction) 400 struct scatterlist *sglist, int nents,
401 enum dma_data_direction direction,
402 struct dma_attrs *attrs)
155{ 403{
404 struct scatterlist *sg;
405 int i;
406
156 BUG_ON(!valid_dma_direction(direction)); 407 BUG_ON(!valid_dma_direction(direction));
408 for_each_sg(sglist, sg, nents, i) {
409 sg->dma_address = sg_phys(sg);
410 __dma_complete_pa_range(sg->dma_address, sg->length,
411 direction);
412 }
157} 413}
158EXPORT_SYMBOL(dma_unmap_sg);
159 414
160dma_addr_t dma_map_page(struct device *dev, struct page *page, 415static dma_addr_t tile_pci_dma_map_page(struct device *dev, struct page *page,
161 unsigned long offset, size_t size, 416 unsigned long offset, size_t size,
162 enum dma_data_direction direction) 417 enum dma_data_direction direction,
418 struct dma_attrs *attrs)
163{ 419{
164 BUG_ON(!valid_dma_direction(direction)); 420 BUG_ON(!valid_dma_direction(direction));
165 421
166 BUG_ON(offset + size > PAGE_SIZE); 422 BUG_ON(offset + size > PAGE_SIZE);
167 homecache_flush_cache(page, 0); 423 __dma_prep_page(page, offset, size, direction);
168 424
169 return page_to_pa(page) + offset; 425 return phys_to_dma(dev, page_to_pa(page) + offset);
170} 426}
171EXPORT_SYMBOL(dma_map_page);
172 427
173void dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size, 428static void tile_pci_dma_unmap_page(struct device *dev, dma_addr_t dma_address,
174 enum dma_data_direction direction) 429 size_t size,
430 enum dma_data_direction direction,
431 struct dma_attrs *attrs)
175{ 432{
176 BUG_ON(!valid_dma_direction(direction)); 433 BUG_ON(!valid_dma_direction(direction));
434
435 dma_address = dma_to_phys(dev, dma_address);
436
437 __dma_complete_page(pfn_to_page(PFN_DOWN(dma_address)),
438 dma_address & PAGE_OFFSET, size, direction);
177} 439}
178EXPORT_SYMBOL(dma_unmap_page);
179 440
180void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, 441static void tile_pci_dma_sync_single_for_cpu(struct device *dev,
181 size_t size, enum dma_data_direction direction) 442 dma_addr_t dma_handle,
443 size_t size,
444 enum dma_data_direction direction)
182{ 445{
183 BUG_ON(!valid_dma_direction(direction)); 446 BUG_ON(!valid_dma_direction(direction));
447
448 dma_handle = dma_to_phys(dev, dma_handle);
449
450 __dma_complete_pa_range(dma_handle, size, direction);
184} 451}
185EXPORT_SYMBOL(dma_sync_single_for_cpu);
186 452
187void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, 453static void tile_pci_dma_sync_single_for_device(struct device *dev,
188 size_t size, enum dma_data_direction direction) 454 dma_addr_t dma_handle,
455 size_t size,
456 enum dma_data_direction
457 direction)
189{ 458{
190 unsigned long start = PFN_DOWN(dma_handle); 459 dma_handle = dma_to_phys(dev, dma_handle);
191 unsigned long end = PFN_DOWN(dma_handle + size - 1);
192 unsigned long i;
193 460
194 BUG_ON(!valid_dma_direction(direction)); 461 __dma_prep_pa_range(dma_handle, size, direction);
195 for (i = start; i <= end; ++i)
196 homecache_flush_cache(pfn_to_page(i), 0);
197} 462}
198EXPORT_SYMBOL(dma_sync_single_for_device);
199 463
200void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems, 464static void tile_pci_dma_sync_sg_for_cpu(struct device *dev,
201 enum dma_data_direction direction) 465 struct scatterlist *sglist,
466 int nelems,
467 enum dma_data_direction direction)
202{ 468{
469 struct scatterlist *sg;
470 int i;
471
203 BUG_ON(!valid_dma_direction(direction)); 472 BUG_ON(!valid_dma_direction(direction));
204 WARN_ON(nelems == 0 || sg[0].length == 0); 473 WARN_ON(nelems == 0 || sglist->length == 0);
474
475 for_each_sg(sglist, sg, nelems, i) {
476 dma_sync_single_for_cpu(dev, sg->dma_address,
477 sg_dma_len(sg), direction);
478 }
205} 479}
206EXPORT_SYMBOL(dma_sync_sg_for_cpu);
207 480
208/* 481static void tile_pci_dma_sync_sg_for_device(struct device *dev,
209 * Flush and invalidate cache for scatterlist. 482 struct scatterlist *sglist,
210 */ 483 int nelems,
211void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sglist, 484 enum dma_data_direction direction)
212 int nelems, enum dma_data_direction direction)
213{ 485{
214 struct scatterlist *sg; 486 struct scatterlist *sg;
215 int i; 487 int i;
@@ -222,31 +494,93 @@ void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sglist,
222 sg_dma_len(sg), direction); 494 sg_dma_len(sg), direction);
223 } 495 }
224} 496}
225EXPORT_SYMBOL(dma_sync_sg_for_device);
226 497
227void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle, 498static inline int
228 unsigned long offset, size_t size, 499tile_pci_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
229 enum dma_data_direction direction)
230{ 500{
231 dma_sync_single_for_cpu(dev, dma_handle + offset, size, direction); 501 return 0;
232} 502}
233EXPORT_SYMBOL(dma_sync_single_range_for_cpu);
234 503
235void dma_sync_single_range_for_device(struct device *dev, 504static inline int
236 dma_addr_t dma_handle, 505tile_pci_dma_supported(struct device *dev, u64 mask)
237 unsigned long offset, size_t size,
238 enum dma_data_direction direction)
239{ 506{
240 dma_sync_single_for_device(dev, dma_handle + offset, size, direction); 507 return 1;
241} 508}
242EXPORT_SYMBOL(dma_sync_single_range_for_device);
243 509
244/* 510static struct dma_map_ops tile_pci_default_dma_map_ops = {
245 * dma_alloc_noncoherent() returns non-cacheable memory, so there's no 511 .alloc = tile_pci_dma_alloc_coherent,
246 * need to do any flushing here. 512 .free = tile_pci_dma_free_coherent,
247 */ 513 .map_page = tile_pci_dma_map_page,
248void dma_cache_sync(struct device *dev, void *vaddr, size_t size, 514 .unmap_page = tile_pci_dma_unmap_page,
249 enum dma_data_direction direction) 515 .map_sg = tile_pci_dma_map_sg,
516 .unmap_sg = tile_pci_dma_unmap_sg,
517 .sync_single_for_cpu = tile_pci_dma_sync_single_for_cpu,
518 .sync_single_for_device = tile_pci_dma_sync_single_for_device,
519 .sync_sg_for_cpu = tile_pci_dma_sync_sg_for_cpu,
520 .sync_sg_for_device = tile_pci_dma_sync_sg_for_device,
521 .mapping_error = tile_pci_dma_mapping_error,
522 .dma_supported = tile_pci_dma_supported
523};
524
525struct dma_map_ops *gx_pci_dma_map_ops = &tile_pci_default_dma_map_ops;
526EXPORT_SYMBOL(gx_pci_dma_map_ops);
527
528/* PCI DMA mapping functions for legacy PCI devices */
529
530#ifdef CONFIG_SWIOTLB
531static void *tile_swiotlb_alloc_coherent(struct device *dev, size_t size,
532 dma_addr_t *dma_handle, gfp_t gfp,
533 struct dma_attrs *attrs)
250{ 534{
535 gfp |= GFP_DMA;
536 return swiotlb_alloc_coherent(dev, size, dma_handle, gfp);
537}
538
539static void tile_swiotlb_free_coherent(struct device *dev, size_t size,
540 void *vaddr, dma_addr_t dma_addr,
541 struct dma_attrs *attrs)
542{
543 swiotlb_free_coherent(dev, size, vaddr, dma_addr);
544}
545
546static struct dma_map_ops pci_swiotlb_dma_ops = {
547 .alloc = tile_swiotlb_alloc_coherent,
548 .free = tile_swiotlb_free_coherent,
549 .map_page = swiotlb_map_page,
550 .unmap_page = swiotlb_unmap_page,
551 .map_sg = swiotlb_map_sg_attrs,
552 .unmap_sg = swiotlb_unmap_sg_attrs,
553 .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
554 .sync_single_for_device = swiotlb_sync_single_for_device,
555 .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
556 .sync_sg_for_device = swiotlb_sync_sg_for_device,
557 .dma_supported = swiotlb_dma_supported,
558 .mapping_error = swiotlb_dma_mapping_error,
559};
560
561struct dma_map_ops *gx_legacy_pci_dma_map_ops = &pci_swiotlb_dma_ops;
562#else
563struct dma_map_ops *gx_legacy_pci_dma_map_ops;
564#endif
565EXPORT_SYMBOL(gx_legacy_pci_dma_map_ops);
566
567#ifdef CONFIG_ARCH_HAS_DMA_SET_COHERENT_MASK
568int dma_set_coherent_mask(struct device *dev, u64 mask)
569{
570 struct dma_map_ops *dma_ops = get_dma_ops(dev);
571
572 /* Handle legacy PCI devices with limited memory addressability. */
573 if (((dma_ops == gx_pci_dma_map_ops) ||
574 (dma_ops == gx_legacy_pci_dma_map_ops)) &&
575 (mask <= DMA_BIT_MASK(32))) {
576 if (mask > dev->archdata.max_direct_dma_addr)
577 mask = dev->archdata.max_direct_dma_addr;
578 }
579
580 if (!dma_supported(dev, mask))
581 return -EIO;
582 dev->coherent_dma_mask = mask;
583 return 0;
251} 584}
252EXPORT_SYMBOL(dma_cache_sync); 585EXPORT_SYMBOL(dma_set_coherent_mask);
586#endif
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index b56d12bf590..33c10864d2f 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -310,6 +310,7 @@ int __init pcibios_init(void)
310 if (pci_scan_flags[i] == 0 && controllers[i].ops != NULL) { 310 if (pci_scan_flags[i] == 0 && controllers[i].ops != NULL) {
311 struct pci_controller *controller = &controllers[i]; 311 struct pci_controller *controller = &controllers[i];
312 struct pci_bus *bus; 312 struct pci_bus *bus;
313 LIST_HEAD(resources);
313 314
314 if (tile_init_irqs(i, controller)) { 315 if (tile_init_irqs(i, controller)) {
315 pr_err("PCI: Could not initialize IRQs\n"); 316 pr_err("PCI: Could not initialize IRQs\n");
@@ -327,9 +328,11 @@ int __init pcibios_init(void)
327 * This is inlined in linux/pci.h and calls into 328 * This is inlined in linux/pci.h and calls into
328 * pci_scan_bus_parented() in probe.c. 329 * pci_scan_bus_parented() in probe.c.
329 */ 330 */
330 bus = pci_scan_bus(0, controller->ops, controller); 331 pci_add_resource(&resources, &ioport_resource);
332 pci_add_resource(&resources, &iomem_resource);
333 bus = pci_scan_root_bus(NULL, 0, controller->ops, controller, &resources);
331 controller->root_bus = bus; 334 controller->root_bus = bus;
332 controller->last_busno = bus->subordinate; 335 controller->last_busno = bus->busn_res.end;
333 } 336 }
334 } 337 }
335 338
@@ -401,16 +404,6 @@ void pcibios_set_master(struct pci_dev *dev)
401} 404}
402 405
403/* 406/*
404 * This can be called from the generic PCI layer, but doesn't need to
405 * do anything.
406 */
407char __devinit *pcibios_setup(char *str)
408{
409 /* Nothing needs to be done. */
410 return str;
411}
412
413/*
414 * This is called from the generic Linux layer. 407 * This is called from the generic Linux layer.
415 */ 408 */
416void __devinit pcibios_update_irq(struct pci_dev *dev, int irq) 409void __devinit pcibios_update_irq(struct pci_dev *dev, int irq)
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
new file mode 100644
index 00000000000..0e213e35ffc
--- /dev/null
+++ b/arch/tile/kernel/pci_gx.c
@@ -0,0 +1,1543 @@
1/*
2 * Copyright 2012 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#include <linux/kernel.h>
16#include <linux/mmzone.h>
17#include <linux/pci.h>
18#include <linux/delay.h>
19#include <linux/string.h>
20#include <linux/init.h>
21#include <linux/capability.h>
22#include <linux/sched.h>
23#include <linux/errno.h>
24#include <linux/irq.h>
25#include <linux/msi.h>
26#include <linux/io.h>
27#include <linux/uaccess.h>
28#include <linux/ctype.h>
29
30#include <asm/processor.h>
31#include <asm/sections.h>
32#include <asm/byteorder.h>
33
34#include <gxio/iorpc_globals.h>
35#include <gxio/kiorpc.h>
36#include <gxio/trio.h>
37#include <gxio/iorpc_trio.h>
38#include <hv/drv_trio_intf.h>
39
40#include <arch/sim.h>
41
42/*
43 * This file containes the routines to search for PCI buses,
44 * enumerate the buses, and configure any attached devices.
45 */
46
47#define DEBUG_PCI_CFG 0
48
49#if DEBUG_PCI_CFG
50#define TRACE_CFG_WR(size, val, bus, dev, func, offset) \
51 pr_info("CFG WR %d-byte VAL %#x to bus %d dev %d func %d addr %u\n", \
52 size, val, bus, dev, func, offset & 0xFFF);
53#define TRACE_CFG_RD(size, val, bus, dev, func, offset) \
54 pr_info("CFG RD %d-byte VAL %#x from bus %d dev %d func %d addr %u\n", \
55 size, val, bus, dev, func, offset & 0xFFF);
56#else
57#define TRACE_CFG_WR(...)
58#define TRACE_CFG_RD(...)
59#endif
60
61static int __devinitdata pci_probe = 1;
62
63/* Information on the PCIe RC ports configuration. */
64static int __devinitdata pcie_rc[TILEGX_NUM_TRIO][TILEGX_TRIO_PCIES];
65
66/*
67 * On some platforms with one or more Gx endpoint ports, we need to
68 * delay the PCIe RC port probe for a few seconds to work around
69 * a HW PCIe link-training bug. The exact delay is specified with
70 * a kernel boot argument in the form of "pcie_rc_delay=T,P,S",
71 * where T is the TRIO instance number, P is the port number and S is
72 * the delay in seconds. If the delay is not provided, the value
73 * will be DEFAULT_RC_DELAY.
74 */
75static int __devinitdata rc_delay[TILEGX_NUM_TRIO][TILEGX_TRIO_PCIES];
76
77/* Default number of seconds that the PCIe RC port probe can be delayed. */
78#define DEFAULT_RC_DELAY 10
79
80/* Max number of seconds that the PCIe RC port probe can be delayed. */
81#define MAX_RC_DELAY 20
82
83/* Array of the PCIe ports configuration info obtained from the BIB. */
84struct pcie_port_property pcie_ports[TILEGX_NUM_TRIO][TILEGX_TRIO_PCIES];
85
86/* All drivers share the TRIO contexts defined here. */
87gxio_trio_context_t trio_contexts[TILEGX_NUM_TRIO];
88
89/* Pointer to an array of PCIe RC controllers. */
90struct pci_controller pci_controllers[TILEGX_NUM_TRIO * TILEGX_TRIO_PCIES];
91int num_rc_controllers;
92static int num_ep_controllers;
93
94static struct pci_ops tile_cfg_ops;
95
96/* Mask of CPUs that should receive PCIe interrupts. */
97static struct cpumask intr_cpus_map;
98
99/*
100 * We don't need to worry about the alignment of resources.
101 */
102resource_size_t pcibios_align_resource(void *data, const struct resource *res,
103 resource_size_t size, resource_size_t align)
104{
105 return res->start;
106}
107EXPORT_SYMBOL(pcibios_align_resource);
108
109
110/*
111 * Pick a CPU to receive and handle the PCIe interrupts, based on the IRQ #.
112 * For now, we simply send interrupts to non-dataplane CPUs.
113 * We may implement methods to allow user to specify the target CPUs,
114 * e.g. via boot arguments.
115 */
116static int tile_irq_cpu(int irq)
117{
118 unsigned int count;
119 int i = 0;
120 int cpu;
121
122 count = cpumask_weight(&intr_cpus_map);
123 if (unlikely(count == 0)) {
124 pr_warning("intr_cpus_map empty, interrupts will be"
125 " delievered to dataplane tiles\n");
126 return irq % (smp_height * smp_width);
127 }
128
129 count = irq % count;
130 for_each_cpu(cpu, &intr_cpus_map) {
131 if (i++ == count)
132 break;
133 }
134 return cpu;
135}
136
137/*
138 * Open a file descriptor to the TRIO shim.
139 */
140static int __devinit tile_pcie_open(int trio_index)
141{
142 gxio_trio_context_t *context = &trio_contexts[trio_index];
143 int ret;
144
145 /*
146 * This opens a file descriptor to the TRIO shim.
147 */
148 ret = gxio_trio_init(context, trio_index);
149 if (ret < 0)
150 return ret;
151
152 /*
153 * Allocate an ASID for the kernel.
154 */
155 ret = gxio_trio_alloc_asids(context, 1, 0, 0);
156 if (ret < 0) {
157 pr_err("PCI: ASID alloc failure on TRIO %d, give up\n",
158 trio_index);
159 goto asid_alloc_failure;
160 }
161
162 context->asid = ret;
163
164#ifdef USE_SHARED_PCIE_CONFIG_REGION
165 /*
166 * Alloc a PIO region for config access, shared by all MACs per TRIO.
167 * This shouldn't fail since the kernel is supposed to the first
168 * client of the TRIO's PIO regions.
169 */
170 ret = gxio_trio_alloc_pio_regions(context, 1, 0, 0);
171 if (ret < 0) {
172 pr_err("PCI: CFG PIO alloc failure on TRIO %d, give up\n",
173 trio_index);
174 goto pio_alloc_failure;
175 }
176
177 context->pio_cfg_index = ret;
178
179 /*
180 * For PIO CFG, the bus_address_hi parameter is 0. The mac parameter
181 * is also 0 because it is specified in PIO_REGION_SETUP_CFG_ADDR.
182 */
183 ret = gxio_trio_init_pio_region_aux(context, context->pio_cfg_index,
184 0, 0, HV_TRIO_PIO_FLAG_CONFIG_SPACE);
185 if (ret < 0) {
186 pr_err("PCI: CFG PIO init failure on TRIO %d, give up\n",
187 trio_index);
188 goto pio_alloc_failure;
189 }
190#endif
191
192 return ret;
193
194asid_alloc_failure:
195#ifdef USE_SHARED_PCIE_CONFIG_REGION
196pio_alloc_failure:
197#endif
198 hv_dev_close(context->fd);
199
200 return ret;
201}
202
203static void
204tilegx_legacy_irq_ack(struct irq_data *d)
205{
206 __insn_mtspr(SPR_IPI_EVENT_RESET_K, 1UL << d->irq);
207}
208
209static void
210tilegx_legacy_irq_mask(struct irq_data *d)
211{
212 __insn_mtspr(SPR_IPI_MASK_SET_K, 1UL << d->irq);
213}
214
215static void
216tilegx_legacy_irq_unmask(struct irq_data *d)
217{
218 __insn_mtspr(SPR_IPI_MASK_RESET_K, 1UL << d->irq);
219}
220
221static struct irq_chip tilegx_legacy_irq_chip = {
222 .name = "tilegx_legacy_irq",
223 .irq_ack = tilegx_legacy_irq_ack,
224 .irq_mask = tilegx_legacy_irq_mask,
225 .irq_unmask = tilegx_legacy_irq_unmask,
226
227 /* TBD: support set_affinity. */
228};
229
230/*
231 * This is a wrapper function of the kernel level-trigger interrupt
232 * handler handle_level_irq() for PCI legacy interrupts. The TRIO
233 * is configured such that only INTx Assert interrupts are proxied
234 * to Linux which just calls handle_level_irq() after clearing the
235 * MAC INTx Assert status bit associated with this interrupt.
236 */
237static void
238trio_handle_level_irq(unsigned int irq, struct irq_desc *desc)
239{
240 struct pci_controller *controller = irq_desc_get_handler_data(desc);
241 gxio_trio_context_t *trio_context = controller->trio;
242 uint64_t intx = (uint64_t)irq_desc_get_chip_data(desc);
243 int mac = controller->mac;
244 unsigned int reg_offset;
245 uint64_t level_mask;
246
247 handle_level_irq(irq, desc);
248
249 /*
250 * Clear the INTx Level status, otherwise future interrupts are
251 * not sent.
252 */
253 reg_offset = (TRIO_PCIE_INTFC_MAC_INT_STS <<
254 TRIO_CFG_REGION_ADDR__REG_SHIFT) |
255 (TRIO_CFG_REGION_ADDR__INTFC_VAL_MAC_INTERFACE <<
256 TRIO_CFG_REGION_ADDR__INTFC_SHIFT ) |
257 (mac << TRIO_CFG_REGION_ADDR__MAC_SEL_SHIFT);
258
259 level_mask = TRIO_PCIE_INTFC_MAC_INT_STS__INT_LEVEL_MASK << intx;
260
261 __gxio_mmio_write(trio_context->mmio_base_mac + reg_offset, level_mask);
262}
263
264/*
265 * Create kernel irqs and set up the handlers for the legacy interrupts.
266 * Also some minimum initialization for the MSI support.
267 */
268static int __devinit tile_init_irqs(struct pci_controller *controller)
269{
270 int i;
271 int j;
272 int irq;
273 int result;
274
275 cpumask_copy(&intr_cpus_map, cpu_online_mask);
276
277
278 for (i = 0; i < 4; i++) {
279 gxio_trio_context_t *context = controller->trio;
280 int cpu;
281
282 /* Ask the kernel to allocate an IRQ. */
283 irq = create_irq();
284 if (irq < 0) {
285 pr_err("PCI: no free irq vectors, failed for %d\n", i);
286
287 goto free_irqs;
288 }
289 controller->irq_intx_table[i] = irq;
290
291 /* Distribute the 4 IRQs to different tiles. */
292 cpu = tile_irq_cpu(irq);
293
294 /* Configure the TRIO intr binding for this IRQ. */
295 result = gxio_trio_config_legacy_intr(context, cpu_x(cpu),
296 cpu_y(cpu), KERNEL_PL,
297 irq, controller->mac, i);
298 if (result < 0) {
299 pr_err("PCI: MAC intx config failed for %d\n", i);
300
301 goto free_irqs;
302 }
303
304 /*
305 * Register the IRQ handler with the kernel.
306 */
307 irq_set_chip_and_handler(irq, &tilegx_legacy_irq_chip,
308 trio_handle_level_irq);
309 irq_set_chip_data(irq, (void *)(uint64_t)i);
310 irq_set_handler_data(irq, controller);
311 }
312
313 return 0;
314
315free_irqs:
316 for (j = 0; j < i; j++)
317 destroy_irq(controller->irq_intx_table[j]);
318
319 return -1;
320}
321
322/*
323 * Find valid controllers and fill in pci_controller structs for each
324 * of them.
325 *
326 * Returns the number of controllers discovered.
327 */
328int __init tile_pci_init(void)
329{
330 int num_trio_shims = 0;
331 int ctl_index = 0;
332 int i, j;
333
334 if (!pci_probe) {
335 pr_info("PCI: disabled by boot argument\n");
336 return 0;
337 }
338
339 pr_info("PCI: Searching for controllers...\n");
340
341 /*
342 * We loop over all the TRIO shims.
343 */
344 for (i = 0; i < TILEGX_NUM_TRIO; i++) {
345 int ret;
346
347 ret = tile_pcie_open(i);
348 if (ret < 0)
349 continue;
350
351 num_trio_shims++;
352 }
353
354 if (num_trio_shims == 0 || sim_is_simulator())
355 return 0;
356
357 /*
358 * Now determine which PCIe ports are configured to operate in RC mode.
359 * We look at the Board Information Block first and then see if there
360 * are any overriding configuration by the HW strapping pin.
361 */
362 for (i = 0; i < TILEGX_NUM_TRIO; i++) {
363 gxio_trio_context_t *context = &trio_contexts[i];
364 int ret;
365
366 if (context->fd < 0)
367 continue;
368
369 ret = hv_dev_pread(context->fd, 0,
370 (HV_VirtAddr)&pcie_ports[i][0],
371 sizeof(struct pcie_port_property) * TILEGX_TRIO_PCIES,
372 GXIO_TRIO_OP_GET_PORT_PROPERTY);
373 if (ret < 0) {
374 pr_err("PCI: PCIE_GET_PORT_PROPERTY failure, error %d,"
375 " on TRIO %d\n", ret, i);
376 continue;
377 }
378
379 for (j = 0; j < TILEGX_TRIO_PCIES; j++) {
380 if (pcie_ports[i][j].allow_rc) {
381 pcie_rc[i][j] = 1;
382 num_rc_controllers++;
383 }
384 else if (pcie_ports[i][j].allow_ep) {
385 num_ep_controllers++;
386 }
387 }
388 }
389
390 /*
391 * Return if no PCIe ports are configured to operate in RC mode.
392 */
393 if (num_rc_controllers == 0)
394 return 0;
395
396 /*
397 * Set the TRIO pointer and MAC index for each PCIe RC port.
398 */
399 for (i = 0; i < TILEGX_NUM_TRIO; i++) {
400 for (j = 0; j < TILEGX_TRIO_PCIES; j++) {
401 if (pcie_rc[i][j]) {
402 pci_controllers[ctl_index].trio =
403 &trio_contexts[i];
404 pci_controllers[ctl_index].mac = j;
405 pci_controllers[ctl_index].trio_index = i;
406 ctl_index++;
407 if (ctl_index == num_rc_controllers)
408 goto out;
409 }
410 }
411 }
412
413out:
414 /*
415 * Configure each PCIe RC port.
416 */
417 for (i = 0; i < num_rc_controllers; i++) {
418 /*
419 * Configure the PCIe MAC to run in RC mode.
420 */
421
422 struct pci_controller *controller = &pci_controllers[i];
423
424 controller->index = i;
425 controller->ops = &tile_cfg_ops;
426
427 /*
428 * The PCI memory resource is located above the PA space.
429 * For every host bridge, the BAR window or the MMIO aperture
430 * is in range [3GB, 4GB - 1] of a 4GB space beyond the
431 * PA space.
432 */
433
434 controller->mem_offset = TILE_PCI_MEM_START +
435 (i * TILE_PCI_BAR_WINDOW_TOP);
436 controller->mem_space.start = controller->mem_offset +
437 TILE_PCI_BAR_WINDOW_TOP - TILE_PCI_BAR_WINDOW_SIZE;
438 controller->mem_space.end = controller->mem_offset +
439 TILE_PCI_BAR_WINDOW_TOP - 1;
440 controller->mem_space.flags = IORESOURCE_MEM;
441 snprintf(controller->mem_space_name,
442 sizeof(controller->mem_space_name),
443 "PCI mem domain %d", i);
444 controller->mem_space.name = controller->mem_space_name;
445 }
446
447 return num_rc_controllers;
448}
449
450/*
451 * (pin - 1) converts from the PCI standard's [1:4] convention to
452 * a normal [0:3] range.
453 */
454static int tile_map_irq(const struct pci_dev *dev, u8 device, u8 pin)
455{
456 struct pci_controller *controller =
457 (struct pci_controller *)dev->sysdata;
458 return controller->irq_intx_table[pin - 1];
459}
460
461
462static void __devinit fixup_read_and_payload_sizes(struct pci_controller *
463 controller)
464{
465 gxio_trio_context_t *trio_context = controller->trio;
466 struct pci_bus *root_bus = controller->root_bus;
467 TRIO_PCIE_RC_DEVICE_CONTROL_t dev_control;
468 TRIO_PCIE_RC_DEVICE_CAP_t rc_dev_cap;
469 unsigned int reg_offset;
470 struct pci_bus *child;
471 int mac;
472 int err;
473
474 mac = controller->mac;
475
476 /*
477 * Set our max read request size to be 4KB.
478 */
479 reg_offset =
480 (TRIO_PCIE_RC_DEVICE_CONTROL <<
481 TRIO_CFG_REGION_ADDR__REG_SHIFT) |
482 (TRIO_CFG_REGION_ADDR__INTFC_VAL_MAC_STANDARD <<
483 TRIO_CFG_REGION_ADDR__INTFC_SHIFT ) |
484 (mac << TRIO_CFG_REGION_ADDR__MAC_SEL_SHIFT);
485
486 dev_control.word = __gxio_mmio_read32(trio_context->mmio_base_mac +
487 reg_offset);
488 dev_control.max_read_req_sz = 5;
489 __gxio_mmio_write32(trio_context->mmio_base_mac + reg_offset,
490 dev_control.word);
491
492 /*
493 * Set the max payload size supported by this Gx PCIe MAC.
494 * Though Gx PCIe supports Max Payload Size of up to 1024 bytes,
495 * experiments have shown that setting MPS to 256 yields the
496 * best performance.
497 */
498 reg_offset =
499 (TRIO_PCIE_RC_DEVICE_CAP <<
500 TRIO_CFG_REGION_ADDR__REG_SHIFT) |
501 (TRIO_CFG_REGION_ADDR__INTFC_VAL_MAC_STANDARD <<
502 TRIO_CFG_REGION_ADDR__INTFC_SHIFT ) |
503 (mac << TRIO_CFG_REGION_ADDR__MAC_SEL_SHIFT);
504
505 rc_dev_cap.word = __gxio_mmio_read32(trio_context->mmio_base_mac +
506 reg_offset);
507 rc_dev_cap.mps_sup = 1;
508 __gxio_mmio_write32(trio_context->mmio_base_mac + reg_offset,
509 rc_dev_cap.word);
510
511 /* Configure PCI Express MPS setting. */
512 list_for_each_entry(child, &root_bus->children, node) {
513 struct pci_dev *self = child->self;
514 if (!self)
515 continue;
516
517 pcie_bus_configure_settings(child, self->pcie_mpss);
518 }
519
520 /*
521 * Set the mac_config register in trio based on the MPS/MRS of the link.
522 */
523 reg_offset =
524 (TRIO_PCIE_RC_DEVICE_CONTROL <<
525 TRIO_CFG_REGION_ADDR__REG_SHIFT) |
526 (TRIO_CFG_REGION_ADDR__INTFC_VAL_MAC_STANDARD <<
527 TRIO_CFG_REGION_ADDR__INTFC_SHIFT ) |
528 (mac << TRIO_CFG_REGION_ADDR__MAC_SEL_SHIFT);
529
530 dev_control.word = __gxio_mmio_read32(trio_context->mmio_base_mac +
531 reg_offset);
532
533 err = gxio_trio_set_mps_mrs(trio_context,
534 dev_control.max_payload_size,
535 dev_control.max_read_req_sz,
536 mac);
537 if (err < 0) {
538 pr_err("PCI: PCIE_CONFIGURE_MAC_MPS_MRS failure, "
539 "MAC %d on TRIO %d\n",
540 mac, controller->trio_index);
541 }
542}
543
544static int __devinit setup_pcie_rc_delay(char *str)
545{
546 unsigned long delay = 0;
547 unsigned long trio_index;
548 unsigned long mac;
549
550 if (str == NULL || !isdigit(*str))
551 return -EINVAL;
552 trio_index = simple_strtoul(str, (char **)&str, 10);
553 if (trio_index >= TILEGX_NUM_TRIO)
554 return -EINVAL;
555
556 if (*str != ',')
557 return -EINVAL;
558
559 str++;
560 if (!isdigit(*str))
561 return -EINVAL;
562 mac = simple_strtoul(str, (char **)&str, 10);
563 if (mac >= TILEGX_TRIO_PCIES)
564 return -EINVAL;
565
566 if (*str != '\0') {
567 if (*str != ',')
568 return -EINVAL;
569
570 str++;
571 if (!isdigit(*str))
572 return -EINVAL;
573 delay = simple_strtoul(str, (char **)&str, 10);
574 if (delay > MAX_RC_DELAY)
575 return -EINVAL;
576 }
577
578 rc_delay[trio_index][mac] = delay ? : DEFAULT_RC_DELAY;
579 pr_info("Delaying PCIe RC link training for %u sec"
580 " on MAC %lu on TRIO %lu\n", rc_delay[trio_index][mac],
581 mac, trio_index);
582 return 0;
583}
584early_param("pcie_rc_delay", setup_pcie_rc_delay);
585
586/*
587 * PCI initialization entry point, called by subsys_initcall.
588 */
589int __init pcibios_init(void)
590{
591 resource_size_t offset;
592 LIST_HEAD(resources);
593 int next_busno;
594 int i;
595
596 tile_pci_init();
597
598 if (num_rc_controllers == 0 && num_ep_controllers == 0)
599 return 0;
600
601 /*
602 * We loop over all the TRIO shims and set up the MMIO mappings.
603 */
604 for (i = 0; i < TILEGX_NUM_TRIO; i++) {
605 gxio_trio_context_t *context = &trio_contexts[i];
606
607 if (context->fd < 0)
608 continue;
609
610 /*
611 * Map in the MMIO space for the MAC.
612 */
613 offset = 0;
614 context->mmio_base_mac =
615 iorpc_ioremap(context->fd, offset,
616 HV_TRIO_CONFIG_IOREMAP_SIZE);
617 if (context->mmio_base_mac == NULL) {
618 pr_err("PCI: MAC map failure on TRIO %d\n", i);
619
620 hv_dev_close(context->fd);
621 context->fd = -1;
622 continue;
623 }
624 }
625
626 /*
627 * Delay a bit in case devices aren't ready. Some devices are
628 * known to require at least 20ms here, but we use a more
629 * conservative value.
630 */
631 msleep(250);
632
633 /* Scan all of the recorded PCI controllers. */
634 for (next_busno = 0, i = 0; i < num_rc_controllers; i++) {
635 struct pci_controller *controller = &pci_controllers[i];
636 gxio_trio_context_t *trio_context = controller->trio;
637 TRIO_PCIE_INTFC_PORT_CONFIG_t port_config;
638 TRIO_PCIE_INTFC_PORT_STATUS_t port_status;
639 TRIO_PCIE_INTFC_TX_FIFO_CTL_t tx_fifo_ctl;
640 struct pci_bus *bus;
641 unsigned int reg_offset;
642 unsigned int class_code_revision;
643 int trio_index;
644 int mac;
645 int ret;
646
647 if (trio_context->fd < 0)
648 continue;
649
650 trio_index = controller->trio_index;
651 mac = controller->mac;
652
653 /*
654 * Check the port strap state which will override the BIB
655 * setting.
656 */
657
658 reg_offset =
659 (TRIO_PCIE_INTFC_PORT_CONFIG <<
660 TRIO_CFG_REGION_ADDR__REG_SHIFT) |
661 (TRIO_CFG_REGION_ADDR__INTFC_VAL_MAC_INTERFACE <<
662 TRIO_CFG_REGION_ADDR__INTFC_SHIFT ) |
663 (mac << TRIO_CFG_REGION_ADDR__MAC_SEL_SHIFT);
664
665 port_config.word =
666 __gxio_mmio_read(trio_context->mmio_base_mac +
667 reg_offset);
668
669 if ((port_config.strap_state !=
670 TRIO_PCIE_INTFC_PORT_CONFIG__STRAP_STATE_VAL_AUTO_CONFIG_RC) &&
671 (port_config.strap_state !=
672 TRIO_PCIE_INTFC_PORT_CONFIG__STRAP_STATE_VAL_AUTO_CONFIG_RC_G1)) {
673 /*
674 * If this is really intended to be an EP port,
675 * record it so that the endpoint driver will know about it.
676 */
677 if (port_config.strap_state ==
678 TRIO_PCIE_INTFC_PORT_CONFIG__STRAP_STATE_VAL_AUTO_CONFIG_ENDPOINT ||
679 port_config.strap_state ==
680 TRIO_PCIE_INTFC_PORT_CONFIG__STRAP_STATE_VAL_AUTO_CONFIG_ENDPOINT_G1)
681 pcie_ports[trio_index][mac].allow_ep = 1;
682
683 continue;
684 }
685
686 /*
687 * Delay the RC link training if needed.
688 */
689 if (rc_delay[trio_index][mac])
690 msleep(rc_delay[trio_index][mac] * 1000);
691
692 ret = gxio_trio_force_rc_link_up(trio_context, mac);
693 if (ret < 0)
694 pr_err("PCI: PCIE_FORCE_LINK_UP failure, "
695 "MAC %d on TRIO %d\n", mac, trio_index);
696
697 pr_info("PCI: Found PCI controller #%d on TRIO %d MAC %d\n", i,
698 trio_index, controller->mac);
699
700 /*
701 * Wait a bit here because some EP devices take longer
702 * to come up.
703 */
704 msleep(1000);
705
706 /*
707 * Check for PCIe link-up status.
708 */
709
710 reg_offset =
711 (TRIO_PCIE_INTFC_PORT_STATUS <<
712 TRIO_CFG_REGION_ADDR__REG_SHIFT) |
713 (TRIO_CFG_REGION_ADDR__INTFC_VAL_MAC_INTERFACE <<
714 TRIO_CFG_REGION_ADDR__INTFC_SHIFT ) |
715 (mac << TRIO_CFG_REGION_ADDR__MAC_SEL_SHIFT);
716
717 port_status.word =
718 __gxio_mmio_read(trio_context->mmio_base_mac +
719 reg_offset);
720 if (!port_status.dl_up) {
721 pr_err("PCI: link is down, MAC %d on TRIO %d\n",
722 mac, trio_index);
723 continue;
724 }
725
726 /*
727 * Ensure that the link can come out of L1 power down state.
728 * Strictly speaking, this is needed only in the case of
729 * heavy RC-initiated DMAs.
730 */
731 reg_offset =
732 (TRIO_PCIE_INTFC_TX_FIFO_CTL <<
733 TRIO_CFG_REGION_ADDR__REG_SHIFT) |
734 (TRIO_CFG_REGION_ADDR__INTFC_VAL_MAC_INTERFACE <<
735 TRIO_CFG_REGION_ADDR__INTFC_SHIFT ) |
736 (mac << TRIO_CFG_REGION_ADDR__MAC_SEL_SHIFT);
737 tx_fifo_ctl.word =
738 __gxio_mmio_read(trio_context->mmio_base_mac +
739 reg_offset);
740 tx_fifo_ctl.min_p_credits = 0;
741 __gxio_mmio_write(trio_context->mmio_base_mac + reg_offset,
742 tx_fifo_ctl.word);
743
744 /*
745 * Change the device ID so that Linux bus crawl doesn't confuse
746 * the internal bridge with any Tilera endpoints.
747 */
748
749 reg_offset =
750 (TRIO_PCIE_RC_DEVICE_ID_VEN_ID <<
751 TRIO_CFG_REGION_ADDR__REG_SHIFT) |
752 (TRIO_CFG_REGION_ADDR__INTFC_VAL_MAC_STANDARD <<
753 TRIO_CFG_REGION_ADDR__INTFC_SHIFT ) |
754 (mac << TRIO_CFG_REGION_ADDR__MAC_SEL_SHIFT);
755
756 __gxio_mmio_write32(trio_context->mmio_base_mac + reg_offset,
757 (TILERA_GX36_RC_DEV_ID <<
758 TRIO_PCIE_RC_DEVICE_ID_VEN_ID__DEV_ID_SHIFT) |
759 TILERA_VENDOR_ID);
760
761 /*
762 * Set the internal P2P bridge class code.
763 */
764
765 reg_offset =
766 (TRIO_PCIE_RC_REVISION_ID <<
767 TRIO_CFG_REGION_ADDR__REG_SHIFT) |
768 (TRIO_CFG_REGION_ADDR__INTFC_VAL_MAC_STANDARD <<
769 TRIO_CFG_REGION_ADDR__INTFC_SHIFT ) |
770 (mac << TRIO_CFG_REGION_ADDR__MAC_SEL_SHIFT);
771
772 class_code_revision =
773 __gxio_mmio_read32(trio_context->mmio_base_mac +
774 reg_offset);
775 class_code_revision = (class_code_revision & 0xff ) |
776 (PCI_CLASS_BRIDGE_PCI << 16);
777
778 __gxio_mmio_write32(trio_context->mmio_base_mac +
779 reg_offset, class_code_revision);
780
781#ifdef USE_SHARED_PCIE_CONFIG_REGION
782
783 /*
784 * Map in the MMIO space for the PIO region.
785 */
786 offset = HV_TRIO_PIO_OFFSET(trio_context->pio_cfg_index) |
787 (((unsigned long long)mac) <<
788 TRIO_TILE_PIO_REGION_SETUP_CFG_ADDR__MAC_SHIFT);
789
790#else
791
792 /*
793 * Alloc a PIO region for PCI config access per MAC.
794 */
795 ret = gxio_trio_alloc_pio_regions(trio_context, 1, 0, 0);
796 if (ret < 0) {
797 pr_err("PCI: PCI CFG PIO alloc failure for mac %d "
798 "on TRIO %d, give up\n", mac, trio_index);
799
800 continue;
801 }
802
803 trio_context->pio_cfg_index[mac] = ret;
804
805 /*
806 * For PIO CFG, the bus_address_hi parameter is 0.
807 */
808 ret = gxio_trio_init_pio_region_aux(trio_context,
809 trio_context->pio_cfg_index[mac],
810 mac, 0, HV_TRIO_PIO_FLAG_CONFIG_SPACE);
811 if (ret < 0) {
812 pr_err("PCI: PCI CFG PIO init failure for mac %d "
813 "on TRIO %d, give up\n", mac, trio_index);
814
815 continue;
816 }
817
818 offset = HV_TRIO_PIO_OFFSET(trio_context->pio_cfg_index[mac]) |
819 (((unsigned long long)mac) <<
820 TRIO_TILE_PIO_REGION_SETUP_CFG_ADDR__MAC_SHIFT);
821
822#endif
823
824 trio_context->mmio_base_pio_cfg[mac] =
825 iorpc_ioremap(trio_context->fd, offset,
826 (1 << TRIO_TILE_PIO_REGION_SETUP_CFG_ADDR__MAC_SHIFT));
827 if (trio_context->mmio_base_pio_cfg[mac] == NULL) {
828 pr_err("PCI: PIO map failure for mac %d on TRIO %d\n",
829 mac, trio_index);
830
831 continue;
832 }
833
834 /*
835 * Initialize the PCIe interrupts.
836 */
837 if (tile_init_irqs(controller)) {
838 pr_err("PCI: IRQs init failure for mac %d on TRIO %d\n",
839 mac, trio_index);
840
841 continue;
842 }
843
844 /*
845 * The PCI memory resource is located above the PA space.
846 * The memory range for the PCI root bus should not overlap
847 * with the physical RAM
848 */
849 pci_add_resource_offset(&resources, &controller->mem_space,
850 controller->mem_offset);
851
852 controller->first_busno = next_busno;
853 bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
854 controller, &resources);
855 controller->root_bus = bus;
856 next_busno = bus->busn_res.end + 1;
857
858 }
859
860 /* Do machine dependent PCI interrupt routing */
861 pci_fixup_irqs(pci_common_swizzle, tile_map_irq);
862
863 /*
864 * This comes from the generic Linux PCI driver.
865 *
866 * It allocates all of the resources (I/O memory, etc)
867 * associated with the devices read in above.
868 */
869
870 pci_assign_unassigned_resources();
871
872 /* Record the I/O resources in the PCI controller structure. */
873 for (i = 0; i < num_rc_controllers; i++) {
874 struct pci_controller *controller = &pci_controllers[i];
875 gxio_trio_context_t *trio_context = controller->trio;
876 struct pci_bus *root_bus = pci_controllers[i].root_bus;
877 struct pci_bus *next_bus;
878 uint32_t bus_address_hi;
879 struct pci_dev *dev;
880 int ret;
881 int j;
882
883 /*
884 * Skip controllers that are not properly initialized or
885 * have down links.
886 */
887 if (root_bus == NULL)
888 continue;
889
890 /* Configure the max_payload_size values for this domain. */
891 fixup_read_and_payload_sizes(controller);
892
893 list_for_each_entry(dev, &root_bus->devices, bus_list) {
894 /* Find the PCI host controller, ie. the 1st bridge. */
895 if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI &&
896 (PCI_SLOT(dev->devfn) == 0)) {
897 next_bus = dev->subordinate;
898 pci_controllers[i].mem_resources[0] =
899 *next_bus->resource[0];
900 pci_controllers[i].mem_resources[1] =
901 *next_bus->resource[1];
902 pci_controllers[i].mem_resources[2] =
903 *next_bus->resource[2];
904
905 break;
906 }
907 }
908
909 if (pci_controllers[i].mem_resources[1].flags & IORESOURCE_MEM)
910 bus_address_hi =
911 pci_controllers[i].mem_resources[1].start >> 32;
912 else if (pci_controllers[i].mem_resources[2].flags & IORESOURCE_PREFETCH)
913 bus_address_hi =
914 pci_controllers[i].mem_resources[2].start >> 32;
915 else {
916 /* This is unlikely. */
917 pr_err("PCI: no memory resources on TRIO %d mac %d\n",
918 controller->trio_index, controller->mac);
919 continue;
920 }
921
922 /*
923 * Alloc a PIO region for PCI memory access for each RC port.
924 */
925 ret = gxio_trio_alloc_pio_regions(trio_context, 1, 0, 0);
926 if (ret < 0) {
927 pr_err("PCI: MEM PIO alloc failure on TRIO %d mac %d, "
928 "give up\n", controller->trio_index,
929 controller->mac);
930
931 continue;
932 }
933
934 controller->pio_mem_index = ret;
935
936 /*
937 * For PIO MEM, the bus_address_hi parameter is hard-coded 0
938 * because we always assign 32-bit PCI bus BAR ranges.
939 */
940 ret = gxio_trio_init_pio_region_aux(trio_context,
941 controller->pio_mem_index,
942 controller->mac,
943 0,
944 0);
945 if (ret < 0) {
946 pr_err("PCI: MEM PIO init failure on TRIO %d mac %d, "
947 "give up\n", controller->trio_index,
948 controller->mac);
949
950 continue;
951 }
952
953 /*
954 * Configure a Mem-Map region for each memory controller so
955 * that Linux can map all of its PA space to the PCI bus.
956 * Use the IOMMU to handle hash-for-home memory.
957 */
958 for_each_online_node(j) {
959 unsigned long start_pfn = node_start_pfn[j];
960 unsigned long end_pfn = node_end_pfn[j];
961 unsigned long nr_pages = end_pfn - start_pfn;
962
963 ret = gxio_trio_alloc_memory_maps(trio_context, 1, 0,
964 0);
965 if (ret < 0) {
966 pr_err("PCI: Mem-Map alloc failure on TRIO %d "
967 "mac %d for MC %d, give up\n",
968 controller->trio_index,
969 controller->mac, j);
970
971 goto alloc_mem_map_failed;
972 }
973
974 controller->mem_maps[j] = ret;
975
976 /*
977 * Initialize the Mem-Map and the I/O MMU so that all
978 * the physical memory can be accessed by the endpoint
979 * devices. The base bus address is set to the base CPA
980 * of this memory controller plus an offset (see pci.h).
981 * The region's base VA is set to the base CPA. The
982 * I/O MMU table essentially translates the CPA to
983 * the real PA. Implicitly, for node 0, we create
984 * a separate Mem-Map region that serves as the inbound
985 * window for legacy 32-bit devices. This is a direct
986 * map of the low 4GB CPA space.
987 */
988 ret = gxio_trio_init_memory_map_mmu_aux(trio_context,
989 controller->mem_maps[j],
990 start_pfn << PAGE_SHIFT,
991 nr_pages << PAGE_SHIFT,
992 trio_context->asid,
993 controller->mac,
994 (start_pfn << PAGE_SHIFT) +
995 TILE_PCI_MEM_MAP_BASE_OFFSET,
996 j,
997 GXIO_TRIO_ORDER_MODE_UNORDERED);
998 if (ret < 0) {
999 pr_err("PCI: Mem-Map init failure on TRIO %d "
1000 "mac %d for MC %d, give up\n",
1001 controller->trio_index,
1002 controller->mac, j);
1003
1004 goto alloc_mem_map_failed;
1005 }
1006 continue;
1007
1008alloc_mem_map_failed:
1009 break;
1010 }
1011
1012 }
1013
1014 return 0;
1015}
1016subsys_initcall(pcibios_init);
1017
1018/* Note: to be deleted after Linux 3.6 merge. */
1019void __devinit pcibios_fixup_bus(struct pci_bus *bus)
1020{
1021}
1022
1023/*
1024 * This can be called from the generic PCI layer, but doesn't need to
1025 * do anything.
1026 */
1027char __devinit *pcibios_setup(char *str)
1028{
1029 if (!strcmp(str, "off")) {
1030 pci_probe = 0;
1031 return NULL;
1032 }
1033 return str;
1034}
1035
1036/*
1037 * This is called from the generic Linux layer.
1038 */
1039void __devinit pcibios_update_irq(struct pci_dev *dev, int irq)
1040{
1041 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
1042}
1043
1044/*
1045 * Enable memory address decoding, as appropriate, for the
1046 * device described by the 'dev' struct. The I/O decoding
1047 * is disabled, though the TILE-Gx supports I/O addressing.
1048 *
1049 * This is called from the generic PCI layer, and can be called
1050 * for bridges or endpoints.
1051 */
1052int pcibios_enable_device(struct pci_dev *dev, int mask)
1053{
1054 return pci_enable_resources(dev, mask);
1055}
1056
1057/* Called for each device after PCI setup is done. */
1058static void __init
1059pcibios_fixup_final(struct pci_dev *pdev)
1060{
1061 set_dma_ops(&pdev->dev, gx_pci_dma_map_ops);
1062 set_dma_offset(&pdev->dev, TILE_PCI_MEM_MAP_BASE_OFFSET);
1063 pdev->dev.archdata.max_direct_dma_addr =
1064 TILE_PCI_MAX_DIRECT_DMA_ADDRESS;
1065}
1066DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_final);
1067
1068/* Map a PCI MMIO bus address into VA space. */
1069void __iomem *ioremap(resource_size_t phys_addr, unsigned long size)
1070{
1071 struct pci_controller *controller = NULL;
1072 resource_size_t bar_start;
1073 resource_size_t bar_end;
1074 resource_size_t offset;
1075 resource_size_t start;
1076 resource_size_t end;
1077 int trio_fd;
1078 int i, j;
1079
1080 start = phys_addr;
1081 end = phys_addr + size - 1;
1082
1083 /*
1084 * In the following, each PCI controller's mem_resources[1]
1085 * represents its (non-prefetchable) PCI memory resource and
1086 * mem_resources[2] refers to its prefetchable PCI memory resource.
1087 * By searching phys_addr in each controller's mem_resources[], we can
1088 * determine the controller that should accept the PCI memory access.
1089 */
1090
1091 for (i = 0; i < num_rc_controllers; i++) {
1092 /*
1093 * Skip controllers that are not properly initialized or
1094 * have down links.
1095 */
1096 if (pci_controllers[i].root_bus == NULL)
1097 continue;
1098
1099 for (j = 1; j < 3; j++) {
1100 bar_start =
1101 pci_controllers[i].mem_resources[j].start;
1102 bar_end =
1103 pci_controllers[i].mem_resources[j].end;
1104
1105 if ((start >= bar_start) && (end <= bar_end)) {
1106
1107 controller = &pci_controllers[i];
1108
1109 goto got_it;
1110 }
1111 }
1112 }
1113
1114 if (controller == NULL)
1115 return NULL;
1116
1117got_it:
1118 trio_fd = controller->trio->fd;
1119
1120 /* Convert the resource start to the bus address offset. */
1121 start = phys_addr - controller->mem_offset;
1122
1123 offset = HV_TRIO_PIO_OFFSET(controller->pio_mem_index) + start;
1124
1125 /*
1126 * We need to keep the PCI bus address's in-page offset in the VA.
1127 */
1128 return iorpc_ioremap(trio_fd, offset, size) +
1129 (phys_addr & (PAGE_SIZE - 1));
1130}
1131EXPORT_SYMBOL(ioremap);
1132
1133void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
1134{
1135 iounmap(addr);
1136}
1137EXPORT_SYMBOL(pci_iounmap);
1138
1139/****************************************************************
1140 *
1141 * Tile PCI config space read/write routines
1142 *
1143 ****************************************************************/
1144
1145/*
1146 * These are the normal read and write ops
1147 * These are expanded with macros from pci_bus_read_config_byte() etc.
1148 *
1149 * devfn is the combined PCI device & function.
1150 *
1151 * offset is in bytes, from the start of config space for the
1152 * specified bus & device.
1153 */
1154
1155static int __devinit tile_cfg_read(struct pci_bus *bus,
1156 unsigned int devfn,
1157 int offset,
1158 int size,
1159 u32 *val)
1160{
1161 struct pci_controller *controller = bus->sysdata;
1162 gxio_trio_context_t *trio_context = controller->trio;
1163 int busnum = bus->number & 0xff;
1164 int device = PCI_SLOT(devfn);
1165 int function = PCI_FUNC(devfn);
1166 int config_type = 1;
1167 TRIO_TILE_PIO_REGION_SETUP_CFG_ADDR_t cfg_addr;
1168 void *mmio_addr;
1169
1170 /*
1171 * Map all accesses to the local device on root bus into the
1172 * MMIO space of the MAC. Accesses to the downstream devices
1173 * go to the PIO space.
1174 */
1175 if (pci_is_root_bus(bus)) {
1176 if (device == 0) {
1177 /*
1178 * This is the internal downstream P2P bridge,
1179 * access directly.
1180 */
1181 unsigned int reg_offset;
1182
1183 reg_offset = ((offset & 0xFFF) <<
1184 TRIO_CFG_REGION_ADDR__REG_SHIFT) |
1185 (TRIO_CFG_REGION_ADDR__INTFC_VAL_MAC_PROTECTED
1186 << TRIO_CFG_REGION_ADDR__INTFC_SHIFT ) |
1187 (controller->mac <<
1188 TRIO_CFG_REGION_ADDR__MAC_SEL_SHIFT);
1189
1190 mmio_addr = trio_context->mmio_base_mac + reg_offset;
1191
1192 goto valid_device;
1193
1194 } else {
1195 /*
1196 * We fake an empty device for (device > 0),
1197 * since there is only one device on bus 0.
1198 */
1199 goto invalid_device;
1200 }
1201 }
1202
1203 /*
1204 * Accesses to the directly attached device have to be
1205 * sent as type-0 configs.
1206 */
1207
1208 if (busnum == (controller->first_busno + 1)) {
1209 /*
1210 * There is only one device off of our built-in P2P bridge.
1211 */
1212 if (device != 0)
1213 goto invalid_device;
1214
1215 config_type = 0;
1216 }
1217
1218 cfg_addr.word = 0;
1219 cfg_addr.reg_addr = (offset & 0xFFF);
1220 cfg_addr.fn = function;
1221 cfg_addr.dev = device;
1222 cfg_addr.bus = busnum;
1223 cfg_addr.type = config_type;
1224
1225 /*
1226 * Note that we don't set the mac field in cfg_addr because the
1227 * mapping is per port.
1228 */
1229
1230 mmio_addr = trio_context->mmio_base_pio_cfg[controller->mac] +
1231 cfg_addr.word;
1232
1233valid_device:
1234
1235 switch (size) {
1236 case 4:
1237 *val = __gxio_mmio_read32(mmio_addr);
1238 break;
1239
1240 case 2:
1241 *val = __gxio_mmio_read16(mmio_addr);
1242 break;
1243
1244 case 1:
1245 *val = __gxio_mmio_read8(mmio_addr);
1246 break;
1247
1248 default:
1249 return PCIBIOS_FUNC_NOT_SUPPORTED;
1250 }
1251
1252 TRACE_CFG_RD(size, *val, busnum, device, function, offset);
1253
1254 return 0;
1255
1256invalid_device:
1257
1258 switch (size) {
1259 case 4:
1260 *val = 0xFFFFFFFF;
1261 break;
1262
1263 case 2:
1264 *val = 0xFFFF;
1265 break;
1266
1267 case 1:
1268 *val = 0xFF;
1269 break;
1270
1271 default:
1272 return PCIBIOS_FUNC_NOT_SUPPORTED;
1273 }
1274
1275 return 0;
1276}
1277
1278
1279/*
1280 * See tile_cfg_read() for relevent comments.
1281 * Note that "val" is the value to write, not a pointer to that value.
1282 */
1283static int __devinit tile_cfg_write(struct pci_bus *bus,
1284 unsigned int devfn,
1285 int offset,
1286 int size,
1287 u32 val)
1288{
1289 struct pci_controller *controller = bus->sysdata;
1290 gxio_trio_context_t *trio_context = controller->trio;
1291 int busnum = bus->number & 0xff;
1292 int device = PCI_SLOT(devfn);
1293 int function = PCI_FUNC(devfn);
1294 int config_type = 1;
1295 TRIO_TILE_PIO_REGION_SETUP_CFG_ADDR_t cfg_addr;
1296 void *mmio_addr;
1297 u32 val_32 = (u32)val;
1298 u16 val_16 = (u16)val;
1299 u8 val_8 = (u8)val;
1300
1301 /*
1302 * Map all accesses to the local device on root bus into the
1303 * MMIO space of the MAC. Accesses to the downstream devices
1304 * go to the PIO space.
1305 */
1306 if (pci_is_root_bus(bus)) {
1307 if (device == 0) {
1308 /*
1309 * This is the internal downstream P2P bridge,
1310 * access directly.
1311 */
1312 unsigned int reg_offset;
1313
1314 reg_offset = ((offset & 0xFFF) <<
1315 TRIO_CFG_REGION_ADDR__REG_SHIFT) |
1316 (TRIO_CFG_REGION_ADDR__INTFC_VAL_MAC_PROTECTED
1317 << TRIO_CFG_REGION_ADDR__INTFC_SHIFT ) |
1318 (controller->mac <<
1319 TRIO_CFG_REGION_ADDR__MAC_SEL_SHIFT);
1320
1321 mmio_addr = trio_context->mmio_base_mac + reg_offset;
1322
1323 goto valid_device;
1324
1325 } else {
1326 /*
1327 * We fake an empty device for (device > 0),
1328 * since there is only one device on bus 0.
1329 */
1330 goto invalid_device;
1331 }
1332 }
1333
1334 /*
1335 * Accesses to the directly attached device have to be
1336 * sent as type-0 configs.
1337 */
1338
1339 if (busnum == (controller->first_busno + 1)) {
1340 /*
1341 * There is only one device off of our built-in P2P bridge.
1342 */
1343 if (device != 0)
1344 goto invalid_device;
1345
1346 config_type = 0;
1347 }
1348
1349 cfg_addr.word = 0;
1350 cfg_addr.reg_addr = (offset & 0xFFF);
1351 cfg_addr.fn = function;
1352 cfg_addr.dev = device;
1353 cfg_addr.bus = busnum;
1354 cfg_addr.type = config_type;
1355
1356 /*
1357 * Note that we don't set the mac field in cfg_addr because the
1358 * mapping is per port.
1359 */
1360
1361 mmio_addr = trio_context->mmio_base_pio_cfg[controller->mac] +
1362 cfg_addr.word;
1363
1364valid_device:
1365
1366 switch (size) {
1367 case 4:
1368 __gxio_mmio_write32(mmio_addr, val_32);
1369 TRACE_CFG_WR(size, val_32, busnum, device, function, offset);
1370 break;
1371
1372 case 2:
1373 __gxio_mmio_write16(mmio_addr, val_16);
1374 TRACE_CFG_WR(size, val_16, busnum, device, function, offset);
1375 break;
1376
1377 case 1:
1378 __gxio_mmio_write8(mmio_addr, val_8);
1379 TRACE_CFG_WR(size, val_8, busnum, device, function, offset);
1380 break;
1381
1382 default:
1383 return PCIBIOS_FUNC_NOT_SUPPORTED;
1384 }
1385
1386invalid_device:
1387
1388 return 0;
1389}
1390
1391
1392static struct pci_ops tile_cfg_ops = {
1393 .read = tile_cfg_read,
1394 .write = tile_cfg_write,
1395};
1396
1397
1398/*
1399 * MSI support starts here.
1400 */
1401static unsigned int
1402tilegx_msi_startup(struct irq_data *d)
1403{
1404 if (d->msi_desc)
1405 unmask_msi_irq(d);
1406
1407 return 0;
1408}
1409
1410static void
1411tilegx_msi_ack(struct irq_data *d)
1412{
1413 __insn_mtspr(SPR_IPI_EVENT_RESET_K, 1UL << d->irq);
1414}
1415
1416static void
1417tilegx_msi_mask(struct irq_data *d)
1418{
1419 mask_msi_irq(d);
1420 __insn_mtspr(SPR_IPI_MASK_SET_K, 1UL << d->irq);
1421}
1422
1423static void
1424tilegx_msi_unmask(struct irq_data *d)
1425{
1426 __insn_mtspr(SPR_IPI_MASK_RESET_K, 1UL << d->irq);
1427 unmask_msi_irq(d);
1428}
1429
1430static struct irq_chip tilegx_msi_chip = {
1431 .name = "tilegx_msi",
1432 .irq_startup = tilegx_msi_startup,
1433 .irq_ack = tilegx_msi_ack,
1434 .irq_mask = tilegx_msi_mask,
1435 .irq_unmask = tilegx_msi_unmask,
1436
1437 /* TBD: support set_affinity. */
1438};
1439
1440int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
1441{
1442 struct pci_controller *controller;
1443 gxio_trio_context_t *trio_context;
1444 struct msi_msg msg;
1445 int default_irq;
1446 uint64_t mem_map_base;
1447 uint64_t mem_map_limit;
1448 u64 msi_addr;
1449 int mem_map;
1450 int cpu;
1451 int irq;
1452 int ret;
1453
1454 irq = create_irq();
1455 if (irq < 0)
1456 return irq;
1457
1458 /*
1459 * Since we use a 64-bit Mem-Map to accept the MSI write, we fail
1460 * devices that are not capable of generating a 64-bit message address.
1461 * These devices will fall back to using the legacy interrupts.
1462 * Most PCIe endpoint devices do support 64-bit message addressing.
1463 */
1464 if (desc->msi_attrib.is_64 == 0) {
1465 dev_printk(KERN_INFO, &pdev->dev,
1466 "64-bit MSI message address not supported, "
1467 "falling back to legacy interrupts.\n");
1468
1469 ret = -ENOMEM;
1470 goto is_64_failure;
1471 }
1472
1473 default_irq = desc->msi_attrib.default_irq;
1474 controller = irq_get_handler_data(default_irq);
1475
1476 BUG_ON(!controller);
1477
1478 trio_context = controller->trio;
1479
1480 /*
1481 * Allocate the Mem-Map that will accept the MSI write and
1482 * trigger the TILE-side interrupts.
1483 */
1484 mem_map = gxio_trio_alloc_memory_maps(trio_context, 1, 0, 0);
1485 if (mem_map < 0) {
1486 dev_printk(KERN_INFO, &pdev->dev,
1487 "%s Mem-Map alloc failure. "
1488 "Failed to initialize MSI interrupts. "
1489 "Falling back to legacy interrupts.\n",
1490 desc->msi_attrib.is_msix ? "MSI-X" : "MSI");
1491
1492 ret = -ENOMEM;
1493 goto msi_mem_map_alloc_failure;
1494 }
1495
1496 /* We try to distribute different IRQs to different tiles. */
1497 cpu = tile_irq_cpu(irq);
1498
1499 /*
1500 * Now call up to the HV to configure the Mem-Map interrupt and
1501 * set up the IPI binding.
1502 */
1503 mem_map_base = MEM_MAP_INTR_REGIONS_BASE +
1504 mem_map * MEM_MAP_INTR_REGION_SIZE;
1505 mem_map_limit = mem_map_base + MEM_MAP_INTR_REGION_SIZE - 1;
1506
1507 ret = gxio_trio_config_msi_intr(trio_context, cpu_x(cpu), cpu_y(cpu),
1508 KERNEL_PL, irq, controller->mac,
1509 mem_map, mem_map_base, mem_map_limit,
1510 trio_context->asid);
1511 if (ret < 0) {
1512 dev_printk(KERN_INFO, &pdev->dev, "HV MSI config failed.\n");
1513
1514 goto hv_msi_config_failure;
1515 }
1516
1517 irq_set_msi_desc(irq, desc);
1518
1519 msi_addr = mem_map_base + TRIO_MAP_MEM_REG_INT3 - TRIO_MAP_MEM_REG_INT0;
1520
1521 msg.address_hi = msi_addr >> 32;
1522 msg.address_lo = msi_addr & 0xffffffff;
1523
1524 msg.data = mem_map;
1525
1526 write_msi_msg(irq, &msg);
1527 irq_set_chip_and_handler(irq, &tilegx_msi_chip, handle_level_irq);
1528 irq_set_handler_data(irq, controller);
1529
1530 return 0;
1531
1532hv_msi_config_failure:
1533 /* Free mem-map */
1534msi_mem_map_alloc_failure:
1535is_64_failure:
1536 destroy_irq(irq);
1537 return ret;
1538}
1539
1540void arch_teardown_msi_irq(unsigned int irq)
1541{
1542 destroy_irq(irq);
1543}
diff --git a/arch/tile/kernel/setup.c b/arch/tile/kernel/setup.c
index dd87f342039..6a649a4462d 100644
--- a/arch/tile/kernel/setup.c
+++ b/arch/tile/kernel/setup.c
@@ -23,6 +23,7 @@
23#include <linux/irq.h> 23#include <linux/irq.h>
24#include <linux/kexec.h> 24#include <linux/kexec.h>
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/swiotlb.h>
26#include <linux/initrd.h> 27#include <linux/initrd.h>
27#include <linux/io.h> 28#include <linux/io.h>
28#include <linux/highmem.h> 29#include <linux/highmem.h>
@@ -109,7 +110,7 @@ static unsigned int __initdata maxnodemem_pfn[MAX_NUMNODES] = {
109}; 110};
110static nodemask_t __initdata isolnodes; 111static nodemask_t __initdata isolnodes;
111 112
112#ifdef CONFIG_PCI 113#if defined(CONFIG_PCI) && !defined(__tilegx__)
113enum { DEFAULT_PCI_RESERVE_MB = 64 }; 114enum { DEFAULT_PCI_RESERVE_MB = 64 };
114static unsigned int __initdata pci_reserve_mb = DEFAULT_PCI_RESERVE_MB; 115static unsigned int __initdata pci_reserve_mb = DEFAULT_PCI_RESERVE_MB;
115unsigned long __initdata pci_reserve_start_pfn = -1U; 116unsigned long __initdata pci_reserve_start_pfn = -1U;
@@ -160,7 +161,7 @@ static int __init setup_isolnodes(char *str)
160} 161}
161early_param("isolnodes", setup_isolnodes); 162early_param("isolnodes", setup_isolnodes);
162 163
163#ifdef CONFIG_PCI 164#if defined(CONFIG_PCI) && !defined(__tilegx__)
164static int __init setup_pci_reserve(char* str) 165static int __init setup_pci_reserve(char* str)
165{ 166{
166 unsigned long mb; 167 unsigned long mb;
@@ -171,7 +172,7 @@ static int __init setup_pci_reserve(char* str)
171 172
172 pci_reserve_mb = mb; 173 pci_reserve_mb = mb;
173 pr_info("Reserving %dMB for PCIE root complex mappings\n", 174 pr_info("Reserving %dMB for PCIE root complex mappings\n",
174 pci_reserve_mb); 175 pci_reserve_mb);
175 return 0; 176 return 0;
176} 177}
177early_param("pci_reserve", setup_pci_reserve); 178early_param("pci_reserve", setup_pci_reserve);
@@ -411,7 +412,7 @@ static void __init setup_memory(void)
411 continue; 412 continue;
412 } 413 }
413#endif 414#endif
414#ifdef CONFIG_PCI 415#if defined(CONFIG_PCI) && !defined(__tilegx__)
415 /* 416 /*
416 * Blocks that overlap the pci reserved region must 417 * Blocks that overlap the pci reserved region must
417 * have enough space to hold the maximum percpu data 418 * have enough space to hold the maximum percpu data
@@ -604,11 +605,9 @@ static void __init setup_bootmem_allocator_node(int i)
604 /* Free all the space back into the allocator. */ 605 /* Free all the space back into the allocator. */
605 free_bootmem(PFN_PHYS(start), PFN_PHYS(end - start)); 606 free_bootmem(PFN_PHYS(start), PFN_PHYS(end - start));
606 607
607#if defined(CONFIG_PCI) 608#if defined(CONFIG_PCI) && !defined(__tilegx__)
608 /* 609 /*
609 * Throw away any memory aliased by the PCI region. FIXME: this 610 * Throw away any memory aliased by the PCI region.
610 * is a temporary hack to work around bug 10502, and needs to be
611 * fixed properly.
612 */ 611 */
613 if (pci_reserve_start_pfn < end && pci_reserve_end_pfn > start) 612 if (pci_reserve_start_pfn < end && pci_reserve_end_pfn > start)
614 reserve_bootmem(PFN_PHYS(pci_reserve_start_pfn), 613 reserve_bootmem(PFN_PHYS(pci_reserve_start_pfn),
@@ -658,6 +657,8 @@ static void __init zone_sizes_init(void)
658 unsigned long zones_size[MAX_NR_ZONES] = { 0 }; 657 unsigned long zones_size[MAX_NR_ZONES] = { 0 };
659 int size = percpu_size(); 658 int size = percpu_size();
660 int num_cpus = smp_height * smp_width; 659 int num_cpus = smp_height * smp_width;
660 const unsigned long dma_end = (1UL << (32 - PAGE_SHIFT));
661
661 int i; 662 int i;
662 663
663 for (i = 0; i < num_cpus; ++i) 664 for (i = 0; i < num_cpus; ++i)
@@ -729,6 +730,14 @@ static void __init zone_sizes_init(void)
729 zones_size[ZONE_NORMAL] = end - start; 730 zones_size[ZONE_NORMAL] = end - start;
730#endif 731#endif
731 732
733 if (start < dma_end) {
734 zones_size[ZONE_DMA] = min(zones_size[ZONE_NORMAL],
735 dma_end - start);
736 zones_size[ZONE_NORMAL] -= zones_size[ZONE_DMA];
737 } else {
738 zones_size[ZONE_DMA] = 0;
739 }
740
732 /* Take zone metadata from controller 0 if we're isolnode. */ 741 /* Take zone metadata from controller 0 if we're isolnode. */
733 if (node_isset(i, isolnodes)) 742 if (node_isset(i, isolnodes))
734 NODE_DATA(i)->bdata = &bootmem_node_data[0]; 743 NODE_DATA(i)->bdata = &bootmem_node_data[0];
@@ -738,7 +747,7 @@ static void __init zone_sizes_init(void)
738 PFN_UP(node_percpu[i])); 747 PFN_UP(node_percpu[i]));
739 748
740 /* Track the type of memory on each node */ 749 /* Track the type of memory on each node */
741 if (zones_size[ZONE_NORMAL]) 750 if (zones_size[ZONE_NORMAL] || zones_size[ZONE_DMA])
742 node_set_state(i, N_NORMAL_MEMORY); 751 node_set_state(i, N_NORMAL_MEMORY);
743#ifdef CONFIG_HIGHMEM 752#ifdef CONFIG_HIGHMEM
744 if (end != start) 753 if (end != start)
@@ -1343,7 +1352,7 @@ void __init setup_arch(char **cmdline_p)
1343 setup_cpu_maps(); 1352 setup_cpu_maps();
1344 1353
1345 1354
1346#ifdef CONFIG_PCI 1355#if defined(CONFIG_PCI) && !defined(__tilegx__)
1347 /* 1356 /*
1348 * Initialize the PCI structures. This is done before memory 1357 * Initialize the PCI structures. This is done before memory
1349 * setup so that we know whether or not a pci_reserve region 1358 * setup so that we know whether or not a pci_reserve region
@@ -1372,6 +1381,10 @@ void __init setup_arch(char **cmdline_p)
1372 * any memory using the bootmem allocator. 1381 * any memory using the bootmem allocator.
1373 */ 1382 */
1374 1383
1384#ifdef CONFIG_SWIOTLB
1385 swiotlb_init(0);
1386#endif
1387
1375 paging_init(); 1388 paging_init();
1376 setup_numa_mapping(); 1389 setup_numa_mapping();
1377 zone_sizes_init(); 1390 zone_sizes_init();
@@ -1522,11 +1535,10 @@ static struct resource code_resource = {
1522}; 1535};
1523 1536
1524/* 1537/*
1525 * We reserve all resources above 4GB so that PCI won't try to put 1538 * On Pro, we reserve all resources above 4GB so that PCI won't try to put
1526 * mappings above 4GB; the standard allows that for some devices but 1539 * mappings above 4GB.
1527 * the probing code trunates values to 32 bits.
1528 */ 1540 */
1529#ifdef CONFIG_PCI 1541#if defined(CONFIG_PCI) && !defined(__tilegx__)
1530static struct resource* __init 1542static struct resource* __init
1531insert_non_bus_resource(void) 1543insert_non_bus_resource(void)
1532{ 1544{
@@ -1571,8 +1583,7 @@ static int __init request_standard_resources(void)
1571 int i; 1583 int i;
1572 enum { CODE_DELTA = MEM_SV_INTRPT - PAGE_OFFSET }; 1584 enum { CODE_DELTA = MEM_SV_INTRPT - PAGE_OFFSET };
1573 1585
1574 iomem_resource.end = -1LL; 1586#if defined(CONFIG_PCI) && !defined(__tilegx__)
1575#ifdef CONFIG_PCI
1576 insert_non_bus_resource(); 1587 insert_non_bus_resource();
1577#endif 1588#endif
1578 1589
@@ -1580,7 +1591,7 @@ static int __init request_standard_resources(void)
1580 u64 start_pfn = node_start_pfn[i]; 1591 u64 start_pfn = node_start_pfn[i];
1581 u64 end_pfn = node_end_pfn[i]; 1592 u64 end_pfn = node_end_pfn[i];
1582 1593
1583#ifdef CONFIG_PCI 1594#if defined(CONFIG_PCI) && !defined(__tilegx__)
1584 if (start_pfn <= pci_reserve_start_pfn && 1595 if (start_pfn <= pci_reserve_start_pfn &&
1585 end_pfn > pci_reserve_start_pfn) { 1596 end_pfn > pci_reserve_start_pfn) {
1586 if (end_pfn > pci_reserve_end_pfn) 1597 if (end_pfn > pci_reserve_end_pfn)
diff --git a/arch/tile/kernel/smpboot.c b/arch/tile/kernel/smpboot.c
index 84873fbe8f2..e686c5ac90b 100644
--- a/arch/tile/kernel/smpboot.c
+++ b/arch/tile/kernel/smpboot.c
@@ -198,17 +198,7 @@ void __cpuinit online_secondary(void)
198 198
199 notify_cpu_starting(smp_processor_id()); 199 notify_cpu_starting(smp_processor_id());
200 200
201 /*
202 * We need to hold call_lock, so there is no inconsistency
203 * between the time smp_call_function() determines number of
204 * IPI recipients, and the time when the determination is made
205 * for which cpus receive the IPI. Holding this
206 * lock helps us to not include this cpu in a currently in progress
207 * smp_call_function().
208 */
209 ipi_call_lock();
210 set_cpu_online(smp_processor_id(), 1); 201 set_cpu_online(smp_processor_id(), 1);
211 ipi_call_unlock();
212 __get_cpu_var(cpu_state) = CPU_ONLINE; 202 __get_cpu_var(cpu_state) = CPU_ONLINE;
213 203
214 /* Set up tile-specific state for this cpu. */ 204 /* Set up tile-specific state for this cpu. */
diff --git a/arch/tile/kernel/usb.c b/arch/tile/kernel/usb.c
new file mode 100644
index 00000000000..5af8debc6a7
--- /dev/null
+++ b/arch/tile/kernel/usb.c
@@ -0,0 +1,69 @@
1/*
2 * Copyright 2012 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 * Register the Tile-Gx USB interfaces as platform devices.
15 *
16 * The actual USB driver is just some glue (in
17 * drivers/usb/host/[eo]hci-tilegx.c) which makes the registers available
18 * to the standard kernel EHCI and OHCI drivers.
19 */
20
21#include <linux/dma-mapping.h>
22#include <linux/platform_device.h>
23#include <linux/usb/tilegx.h>
24#include <linux/types.h>
25
26static u64 ehci_dmamask = DMA_BIT_MASK(32);
27
28#define USB_HOST_DEF(unit, type, dmamask) \
29 static struct \
30 tilegx_usb_platform_data tilegx_usb_platform_data_ ## type ## \
31 hci ## unit = { \
32 .dev_index = unit, \
33 }; \
34 \
35 static struct platform_device tilegx_usb_ ## type ## hci ## unit = { \
36 .name = "tilegx-" #type "hci", \
37 .id = unit, \
38 .dev = { \
39 .dma_mask = dmamask, \
40 .coherent_dma_mask = DMA_BIT_MASK(32), \
41 .platform_data = \
42 &tilegx_usb_platform_data_ ## type ## hci ## \
43 unit, \
44 }, \
45 };
46
47USB_HOST_DEF(0, e, &ehci_dmamask)
48USB_HOST_DEF(0, o, NULL)
49USB_HOST_DEF(1, e, &ehci_dmamask)
50USB_HOST_DEF(1, o, NULL)
51
52#undef USB_HOST_DEF
53
54static struct platform_device *tilegx_usb_devices[] __initdata = {
55 &tilegx_usb_ehci0,
56 &tilegx_usb_ehci1,
57 &tilegx_usb_ohci0,
58 &tilegx_usb_ohci1,
59};
60
61/** Add our set of possible USB devices. */
62static int __init tilegx_usb_init(void)
63{
64 platform_add_devices(tilegx_usb_devices,
65 ARRAY_SIZE(tilegx_usb_devices));
66
67 return 0;
68}
69arch_initcall(tilegx_usb_init);
diff --git a/arch/tile/lib/checksum.c b/arch/tile/lib/checksum.c
index e4bab5bd3f3..c3ca3e64d9d 100644
--- a/arch/tile/lib/checksum.c
+++ b/arch/tile/lib/checksum.c
@@ -16,19 +16,6 @@
16#include <net/checksum.h> 16#include <net/checksum.h>
17#include <linux/module.h> 17#include <linux/module.h>
18 18
19static inline unsigned int longto16(unsigned long x)
20{
21 unsigned long ret;
22#ifdef __tilegx__
23 ret = __insn_v2sadu(x, 0);
24 ret = __insn_v2sadu(ret, 0);
25#else
26 ret = __insn_sadh_u(x, 0);
27 ret = __insn_sadh_u(ret, 0);
28#endif
29 return ret;
30}
31
32__wsum do_csum(const unsigned char *buff, int len) 19__wsum do_csum(const unsigned char *buff, int len)
33{ 20{
34 int odd, count; 21 int odd, count;
@@ -94,7 +81,7 @@ __wsum do_csum(const unsigned char *buff, int len)
94 } 81 }
95 if (len & 1) 82 if (len & 1)
96 result += *buff; 83 result += *buff;
97 result = longto16(result); 84 result = csum_long(result);
98 if (odd) 85 if (odd)
99 result = swab16(result); 86 result = swab16(result);
100out: 87out:
diff --git a/arch/tile/mm/highmem.c b/arch/tile/mm/highmem.c
index ef8e5a62b6e..347d123b14b 100644
--- a/arch/tile/mm/highmem.c
+++ b/arch/tile/mm/highmem.c
@@ -93,7 +93,7 @@ static DEFINE_PER_CPU(struct kmap_amps, amps);
93 * If we examine it earlier we are exposed to a race where it looks 93 * If we examine it earlier we are exposed to a race where it looks
94 * writable earlier, but becomes immutable before we write the PTE. 94 * writable earlier, but becomes immutable before we write the PTE.
95 */ 95 */
96static void kmap_atomic_register(struct page *page, enum km_type type, 96static void kmap_atomic_register(struct page *page, int type,
97 unsigned long va, pte_t *ptep, pte_t pteval) 97 unsigned long va, pte_t *ptep, pte_t pteval)
98{ 98{
99 unsigned long flags; 99 unsigned long flags;
diff --git a/arch/tile/mm/homecache.c b/arch/tile/mm/homecache.c
index dbcbdf7b8aa..5f7868dcd6d 100644
--- a/arch/tile/mm/homecache.c
+++ b/arch/tile/mm/homecache.c
@@ -64,10 +64,6 @@ early_param("noallocl2", set_noallocl2);
64 64
65#endif 65#endif
66 66
67/* Provide no-op versions of these routines to keep flush_remote() cleaner. */
68#define mark_caches_evicted_start() 0
69#define mark_caches_evicted_finish(mask, timestamp) do {} while (0)
70
71 67
72/* 68/*
73 * Update the irq_stat for cpus that we are going to interrupt 69 * Update the irq_stat for cpus that we are going to interrupt
@@ -107,7 +103,6 @@ static void hv_flush_update(const struct cpumask *cache_cpumask,
107 * there's never any good reason for hv_flush_remote() to fail. 103 * there's never any good reason for hv_flush_remote() to fail.
108 * - Accepts a 32-bit PFN rather than a 64-bit PA, which generally 104 * - Accepts a 32-bit PFN rather than a 64-bit PA, which generally
109 * is the type that Linux wants to pass around anyway. 105 * is the type that Linux wants to pass around anyway.
110 * - Centralizes the mark_caches_evicted() handling.
111 * - Canonicalizes that lengths of zero make cpumasks NULL. 106 * - Canonicalizes that lengths of zero make cpumasks NULL.
112 * - Handles deferring TLB flushes for dataplane tiles. 107 * - Handles deferring TLB flushes for dataplane tiles.
113 * - Tracks remote interrupts in the per-cpu irq_cpustat_t. 108 * - Tracks remote interrupts in the per-cpu irq_cpustat_t.
@@ -126,7 +121,6 @@ void flush_remote(unsigned long cache_pfn, unsigned long cache_control,
126 HV_Remote_ASID *asids, int asidcount) 121 HV_Remote_ASID *asids, int asidcount)
127{ 122{
128 int rc; 123 int rc;
129 int timestamp = 0; /* happy compiler */
130 struct cpumask cache_cpumask_copy, tlb_cpumask_copy; 124 struct cpumask cache_cpumask_copy, tlb_cpumask_copy;
131 struct cpumask *cache_cpumask, *tlb_cpumask; 125 struct cpumask *cache_cpumask, *tlb_cpumask;
132 HV_PhysAddr cache_pa; 126 HV_PhysAddr cache_pa;
@@ -157,15 +151,11 @@ void flush_remote(unsigned long cache_pfn, unsigned long cache_control,
157 hv_flush_update(cache_cpumask, tlb_cpumask, tlb_va, tlb_length, 151 hv_flush_update(cache_cpumask, tlb_cpumask, tlb_va, tlb_length,
158 asids, asidcount); 152 asids, asidcount);
159 cache_pa = (HV_PhysAddr)cache_pfn << PAGE_SHIFT; 153 cache_pa = (HV_PhysAddr)cache_pfn << PAGE_SHIFT;
160 if (cache_control & HV_FLUSH_EVICT_L2)
161 timestamp = mark_caches_evicted_start();
162 rc = hv_flush_remote(cache_pa, cache_control, 154 rc = hv_flush_remote(cache_pa, cache_control,
163 cpumask_bits(cache_cpumask), 155 cpumask_bits(cache_cpumask),
164 tlb_va, tlb_length, tlb_pgsize, 156 tlb_va, tlb_length, tlb_pgsize,
165 cpumask_bits(tlb_cpumask), 157 cpumask_bits(tlb_cpumask),
166 asids, asidcount); 158 asids, asidcount);
167 if (cache_control & HV_FLUSH_EVICT_L2)
168 mark_caches_evicted_finish(cache_cpumask, timestamp);
169 if (rc == 0) 159 if (rc == 0)
170 return; 160 return;
171 cpumask_scnprintf(cache_buf, sizeof(cache_buf), &cache_cpumask_copy); 161 cpumask_scnprintf(cache_buf, sizeof(cache_buf), &cache_cpumask_copy);
@@ -180,85 +170,86 @@ void flush_remote(unsigned long cache_pfn, unsigned long cache_control,
180 panic("Unsafe to continue."); 170 panic("Unsafe to continue.");
181} 171}
182 172
183void flush_remote_page(struct page *page, int order) 173static void homecache_finv_page_va(void* va, int home)
184{ 174{
185 int i, pages = (1 << order); 175 if (home == smp_processor_id()) {
186 for (i = 0; i < pages; ++i, ++page) { 176 finv_buffer_local(va, PAGE_SIZE);
187 void *p = kmap_atomic(page); 177 } else if (home == PAGE_HOME_HASH) {
188 int hfh = 0; 178 finv_buffer_remote(va, PAGE_SIZE, 1);
189 int home = page_home(page); 179 } else {
190#if CHIP_HAS_CBOX_HOME_MAP() 180 BUG_ON(home < 0 || home >= NR_CPUS);
191 if (home == PAGE_HOME_HASH) 181 finv_buffer_remote(va, PAGE_SIZE, 0);
192 hfh = 1;
193 else
194#endif
195 BUG_ON(home < 0 || home >= NR_CPUS);
196 finv_buffer_remote(p, PAGE_SIZE, hfh);
197 kunmap_atomic(p);
198 } 182 }
199} 183}
200 184
201void homecache_evict(const struct cpumask *mask) 185void homecache_finv_map_page(struct page *page, int home)
202{ 186{
203 flush_remote(0, HV_FLUSH_EVICT_L2, mask, 0, 0, 0, NULL, NULL, 0); 187 unsigned long flags;
188 unsigned long va;
189 pte_t *ptep;
190 pte_t pte;
191
192 if (home == PAGE_HOME_UNCACHED)
193 return;
194 local_irq_save(flags);
195#ifdef CONFIG_HIGHMEM
196 va = __fix_to_virt(FIX_KMAP_BEGIN + kmap_atomic_idx_push() +
197 (KM_TYPE_NR * smp_processor_id()));
198#else
199 va = __fix_to_virt(FIX_HOMECACHE_BEGIN + smp_processor_id());
200#endif
201 ptep = virt_to_pte(NULL, (unsigned long)va);
202 pte = pfn_pte(page_to_pfn(page), PAGE_KERNEL);
203 __set_pte(ptep, pte_set_home(pte, home));
204 homecache_finv_page_va((void *)va, home);
205 __pte_clear(ptep);
206 hv_flush_page(va, PAGE_SIZE);
207#ifdef CONFIG_HIGHMEM
208 kmap_atomic_idx_pop();
209#endif
210 local_irq_restore(flags);
204} 211}
205 212
206/* 213static void homecache_finv_page_home(struct page *page, int home)
207 * Return a mask of the cpus whose caches currently own these pages.
208 * The return value is whether the pages are all coherently cached
209 * (i.e. none are immutable, incoherent, or uncached).
210 */
211static int homecache_mask(struct page *page, int pages,
212 struct cpumask *home_mask)
213{ 214{
214 int i; 215 if (!PageHighMem(page) && home == page_home(page))
215 int cached_coherently = 1; 216 homecache_finv_page_va(page_address(page), home);
216 cpumask_clear(home_mask); 217 else
217 for (i = 0; i < pages; ++i) { 218 homecache_finv_map_page(page, home);
218 int home = page_home(&page[i]);
219 if (home == PAGE_HOME_IMMUTABLE ||
220 home == PAGE_HOME_INCOHERENT) {
221 cpumask_copy(home_mask, cpu_possible_mask);
222 return 0;
223 }
224#if CHIP_HAS_CBOX_HOME_MAP()
225 if (home == PAGE_HOME_HASH) {
226 cpumask_or(home_mask, home_mask, &hash_for_home_map);
227 continue;
228 }
229#endif
230 if (home == PAGE_HOME_UNCACHED) {
231 cached_coherently = 0;
232 continue;
233 }
234 BUG_ON(home < 0 || home >= NR_CPUS);
235 cpumask_set_cpu(home, home_mask);
236 }
237 return cached_coherently;
238} 219}
239 220
240/* 221static inline bool incoherent_home(int home)
241 * Return the passed length, or zero if it's long enough that we
242 * believe we should evict the whole L2 cache.
243 */
244static unsigned long cache_flush_length(unsigned long length)
245{ 222{
246 return (length >= CHIP_L2_CACHE_SIZE()) ? HV_FLUSH_EVICT_L2 : length; 223 return home == PAGE_HOME_IMMUTABLE || home == PAGE_HOME_INCOHERENT;
247} 224}
248 225
249/* Flush a page out of whatever cache(s) it is in. */ 226static void homecache_finv_page_internal(struct page *page, int force_map)
250void homecache_flush_cache(struct page *page, int order)
251{ 227{
252 int pages = 1 << order; 228 int home = page_home(page);
253 int length = cache_flush_length(pages * PAGE_SIZE); 229 if (home == PAGE_HOME_UNCACHED)
254 unsigned long pfn = page_to_pfn(page); 230 return;
255 struct cpumask home_mask; 231 if (incoherent_home(home)) {
256 232 int cpu;
257 homecache_mask(page, pages, &home_mask); 233 for_each_cpu(cpu, &cpu_cacheable_map)
258 flush_remote(pfn, length, &home_mask, 0, 0, 0, NULL, NULL, 0); 234 homecache_finv_map_page(page, cpu);
259 sim_validate_lines_evicted(PFN_PHYS(pfn), pages * PAGE_SIZE); 235 } else if (force_map) {
236 /* Force if, e.g., the normal mapping is migrating. */
237 homecache_finv_map_page(page, home);
238 } else {
239 homecache_finv_page_home(page, home);
240 }
241 sim_validate_lines_evicted(PFN_PHYS(page_to_pfn(page)), PAGE_SIZE);
260} 242}
261 243
244void homecache_finv_page(struct page *page)
245{
246 homecache_finv_page_internal(page, 0);
247}
248
249void homecache_evict(const struct cpumask *mask)
250{
251 flush_remote(0, HV_FLUSH_EVICT_L2, mask, 0, 0, 0, NULL, NULL, 0);
252}
262 253
263/* Report the home corresponding to a given PTE. */ 254/* Report the home corresponding to a given PTE. */
264static int pte_to_home(pte_t pte) 255static int pte_to_home(pte_t pte)
@@ -441,15 +432,8 @@ struct page *homecache_alloc_pages_node(int nid, gfp_t gfp_mask,
441 return page; 432 return page;
442} 433}
443 434
444void homecache_free_pages(unsigned long addr, unsigned int order) 435void __homecache_free_pages(struct page *page, unsigned int order)
445{ 436{
446 struct page *page;
447
448 if (addr == 0)
449 return;
450
451 VM_BUG_ON(!virt_addr_valid((void *)addr));
452 page = virt_to_page((void *)addr);
453 if (put_page_testzero(page)) { 437 if (put_page_testzero(page)) {
454 homecache_change_page_home(page, order, initial_page_home()); 438 homecache_change_page_home(page, order, initial_page_home());
455 if (order == 0) { 439 if (order == 0) {
@@ -460,3 +444,13 @@ void homecache_free_pages(unsigned long addr, unsigned int order)
460 } 444 }
461 } 445 }
462} 446}
447EXPORT_SYMBOL(__homecache_free_pages);
448
449void homecache_free_pages(unsigned long addr, unsigned int order)
450{
451 if (addr != 0) {
452 VM_BUG_ON(!virt_addr_valid((void *)addr));
453 __homecache_free_pages(virt_to_page((void *)addr), order);
454 }
455}
456EXPORT_SYMBOL(homecache_free_pages);
diff --git a/arch/tile/mm/init.c b/arch/tile/mm/init.c
index 630dd2ce2af..ef29d6c5e10 100644
--- a/arch/tile/mm/init.c
+++ b/arch/tile/mm/init.c
@@ -150,7 +150,21 @@ void __init shatter_pmd(pmd_t *pmd)
150 assign_pte(pmd, pte); 150 assign_pte(pmd, pte);
151} 151}
152 152
153#ifdef CONFIG_HIGHMEM 153#ifdef __tilegx__
154static pmd_t *__init get_pmd(pgd_t pgtables[], unsigned long va)
155{
156 pud_t *pud = pud_offset(&pgtables[pgd_index(va)], va);
157 if (pud_none(*pud))
158 assign_pmd(pud, alloc_pmd());
159 return pmd_offset(pud, va);
160}
161#else
162static pmd_t *__init get_pmd(pgd_t pgtables[], unsigned long va)
163{
164 return pmd_offset(pud_offset(&pgtables[pgd_index(va)], va), va);
165}
166#endif
167
154/* 168/*
155 * This function initializes a certain range of kernel virtual memory 169 * This function initializes a certain range of kernel virtual memory
156 * with new bootmem page tables, everywhere page tables are missing in 170 * with new bootmem page tables, everywhere page tables are missing in
@@ -163,24 +177,17 @@ void __init shatter_pmd(pmd_t *pmd)
163 * checking the pgd every time. 177 * checking the pgd every time.
164 */ 178 */
165static void __init page_table_range_init(unsigned long start, 179static void __init page_table_range_init(unsigned long start,
166 unsigned long end, pgd_t *pgd_base) 180 unsigned long end, pgd_t *pgd)
167{ 181{
168 pgd_t *pgd;
169 int pgd_idx;
170 unsigned long vaddr; 182 unsigned long vaddr;
171 183 start = round_down(start, PMD_SIZE);
172 vaddr = start; 184 end = round_up(end, PMD_SIZE);
173 pgd_idx = pgd_index(vaddr); 185 for (vaddr = start; vaddr < end; vaddr += PMD_SIZE) {
174 pgd = pgd_base + pgd_idx; 186 pmd_t *pmd = get_pmd(pgd, vaddr);
175
176 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
177 pmd_t *pmd = pmd_offset(pud_offset(pgd, vaddr), vaddr);
178 if (pmd_none(*pmd)) 187 if (pmd_none(*pmd))
179 assign_pte(pmd, alloc_pte()); 188 assign_pte(pmd, alloc_pte());
180 vaddr += PMD_SIZE;
181 } 189 }
182} 190}
183#endif /* CONFIG_HIGHMEM */
184 191
185 192
186#if CHIP_HAS_CBOX_HOME_MAP() 193#if CHIP_HAS_CBOX_HOME_MAP()
@@ -404,21 +411,6 @@ static inline pgprot_t ktext_set_nocache(pgprot_t prot)
404 return prot; 411 return prot;
405} 412}
406 413
407#ifndef __tilegx__
408static pmd_t *__init get_pmd(pgd_t pgtables[], unsigned long va)
409{
410 return pmd_offset(pud_offset(&pgtables[pgd_index(va)], va), va);
411}
412#else
413static pmd_t *__init get_pmd(pgd_t pgtables[], unsigned long va)
414{
415 pud_t *pud = pud_offset(&pgtables[pgd_index(va)], va);
416 if (pud_none(*pud))
417 assign_pmd(pud, alloc_pmd());
418 return pmd_offset(pud, va);
419}
420#endif
421
422/* Temporary page table we use for staging. */ 414/* Temporary page table we use for staging. */
423static pgd_t pgtables[PTRS_PER_PGD] 415static pgd_t pgtables[PTRS_PER_PGD]
424 __attribute__((aligned(HV_PAGE_TABLE_ALIGN))); 416 __attribute__((aligned(HV_PAGE_TABLE_ALIGN)));
@@ -741,16 +733,15 @@ static void __init set_non_bootmem_pages_init(void)
741 for_each_zone(z) { 733 for_each_zone(z) {
742 unsigned long start, end; 734 unsigned long start, end;
743 int nid = z->zone_pgdat->node_id; 735 int nid = z->zone_pgdat->node_id;
736#ifdef CONFIG_HIGHMEM
744 int idx = zone_idx(z); 737 int idx = zone_idx(z);
738#endif
745 739
746 start = z->zone_start_pfn; 740 start = z->zone_start_pfn;
747 if (start == 0)
748 continue; /* bootmem */
749 end = start + z->spanned_pages; 741 end = start + z->spanned_pages;
750 if (idx == ZONE_NORMAL) { 742 start = max(start, node_free_pfn[nid]);
751 BUG_ON(start != node_start_pfn[nid]); 743 start = max(start, max_low_pfn);
752 start = node_free_pfn[nid]; 744
753 }
754#ifdef CONFIG_HIGHMEM 745#ifdef CONFIG_HIGHMEM
755 if (idx == ZONE_HIGHMEM) 746 if (idx == ZONE_HIGHMEM)
756 totalhigh_pages += z->spanned_pages; 747 totalhigh_pages += z->spanned_pages;
@@ -779,9 +770,6 @@ static void __init set_non_bootmem_pages_init(void)
779 */ 770 */
780void __init paging_init(void) 771void __init paging_init(void)
781{ 772{
782#ifdef CONFIG_HIGHMEM
783 unsigned long vaddr, end;
784#endif
785#ifdef __tilegx__ 773#ifdef __tilegx__
786 pud_t *pud; 774 pud_t *pud;
787#endif 775#endif
@@ -789,14 +777,14 @@ void __init paging_init(void)
789 777
790 kernel_physical_mapping_init(pgd_base); 778 kernel_physical_mapping_init(pgd_base);
791 779
792#ifdef CONFIG_HIGHMEM
793 /* 780 /*
794 * Fixed mappings, only the page table structure has to be 781 * Fixed mappings, only the page table structure has to be
795 * created - mappings will be set by set_fixmap(): 782 * created - mappings will be set by set_fixmap():
796 */ 783 */
797 vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK; 784 page_table_range_init(fix_to_virt(__end_of_fixed_addresses - 1),
798 end = (FIXADDR_TOP + PMD_SIZE - 1) & PMD_MASK; 785 FIXADDR_TOP, pgd_base);
799 page_table_range_init(vaddr, end, pgd_base); 786
787#ifdef CONFIG_HIGHMEM
800 permanent_kmaps_init(pgd_base); 788 permanent_kmaps_init(pgd_base);
801#endif 789#endif
802 790
diff --git a/arch/tile/mm/pgtable.c b/arch/tile/mm/pgtable.c
index 345edfed9fc..de0de0c0e8a 100644
--- a/arch/tile/mm/pgtable.c
+++ b/arch/tile/mm/pgtable.c
@@ -575,13 +575,6 @@ void __iomem *ioremap_prot(resource_size_t phys_addr, unsigned long size,
575} 575}
576EXPORT_SYMBOL(ioremap_prot); 576EXPORT_SYMBOL(ioremap_prot);
577 577
578/* Map a PCI MMIO bus address into VA space. */
579void __iomem *ioremap(resource_size_t phys_addr, unsigned long size)
580{
581 panic("ioremap for PCI MMIO is not supported");
582}
583EXPORT_SYMBOL(ioremap);
584
585/* Unmap an MMIO VA mapping. */ 578/* Unmap an MMIO VA mapping. */
586void iounmap(volatile void __iomem *addr_in) 579void iounmap(volatile void __iomem *addr_in)
587{ 580{
diff --git a/arch/um/defconfig b/arch/um/defconfig
index 7823ab12e6a..08107a79506 100644
--- a/arch/um/defconfig
+++ b/arch/um/defconfig
@@ -155,15 +155,15 @@ CONFIG_CPUSETS=y
155CONFIG_PROC_PID_CPUSET=y 155CONFIG_PROC_PID_CPUSET=y
156CONFIG_CGROUP_CPUACCT=y 156CONFIG_CGROUP_CPUACCT=y
157CONFIG_RESOURCE_COUNTERS=y 157CONFIG_RESOURCE_COUNTERS=y
158CONFIG_CGROUP_MEM_RES_CTLR=y 158CONFIG_CGROUP_MEMCG=y
159CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y 159CONFIG_CGROUP_MEMCG_SWAP=y
160# CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED is not set 160# CONFIG_CGROUP_MEMCG_SWAP_ENABLED is not set
161# CONFIG_CGROUP_MEM_RES_CTLR_KMEM is not set 161# CONFIG_CGROUP_MEMCG_KMEM is not set
162CONFIG_CGROUP_SCHED=y 162CONFIG_CGROUP_SCHED=y
163CONFIG_FAIR_GROUP_SCHED=y 163CONFIG_FAIR_GROUP_SCHED=y
164# CONFIG_CFS_BANDWIDTH is not set 164# CONFIG_CFS_BANDWIDTH is not set
165# CONFIG_RT_GROUP_SCHED is not set 165# CONFIG_RT_GROUP_SCHED is not set
166CONFIG_BLK_CGROUP=m 166CONFIG_BLK_CGROUP=y
167# CONFIG_DEBUG_BLK_CGROUP is not set 167# CONFIG_DEBUG_BLK_CGROUP is not set
168# CONFIG_CHECKPOINT_RESTORE is not set 168# CONFIG_CHECKPOINT_RESTORE is not set
169CONFIG_NAMESPACES=y 169CONFIG_NAMESPACES=y
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index 45e248c2f43..87eebfe03c6 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -150,9 +150,11 @@ void chan_enable_winch(struct chan *chan, struct tty_struct *tty)
150static void line_timer_cb(struct work_struct *work) 150static void line_timer_cb(struct work_struct *work)
151{ 151{
152 struct line *line = container_of(work, struct line, task.work); 152 struct line *line = container_of(work, struct line, task.work);
153 struct tty_struct *tty = tty_port_tty_get(&line->port);
153 154
154 if (!line->throttled) 155 if (!line->throttled)
155 chan_interrupt(line, line->tty, line->driver->read_irq); 156 chan_interrupt(line, tty, line->driver->read_irq);
157 tty_kref_put(tty);
156} 158}
157 159
158int enable_chan(struct line *line) 160int enable_chan(struct line *line)
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index acfd0e0fd0c..bbaf2c59830 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -19,9 +19,11 @@ static irqreturn_t line_interrupt(int irq, void *data)
19{ 19{
20 struct chan *chan = data; 20 struct chan *chan = data;
21 struct line *line = chan->line; 21 struct line *line = chan->line;
22 struct tty_struct *tty = tty_port_tty_get(&line->port);
22 23
23 if (line) 24 if (line)
24 chan_interrupt(line, line->tty, irq); 25 chan_interrupt(line, tty, irq);
26 tty_kref_put(tty);
25 return IRQ_HANDLED; 27 return IRQ_HANDLED;
26} 28}
27 29
@@ -219,92 +221,6 @@ void line_set_termios(struct tty_struct *tty, struct ktermios * old)
219 /* nothing */ 221 /* nothing */
220} 222}
221 223
222static const struct {
223 int cmd;
224 char *level;
225 char *name;
226} tty_ioctls[] = {
227 /* don't print these, they flood the log ... */
228 { TCGETS, NULL, "TCGETS" },
229 { TCSETS, NULL, "TCSETS" },
230 { TCSETSW, NULL, "TCSETSW" },
231 { TCFLSH, NULL, "TCFLSH" },
232 { TCSBRK, NULL, "TCSBRK" },
233
234 /* general tty stuff */
235 { TCSETSF, KERN_DEBUG, "TCSETSF" },
236 { TCGETA, KERN_DEBUG, "TCGETA" },
237 { TIOCMGET, KERN_DEBUG, "TIOCMGET" },
238 { TCSBRKP, KERN_DEBUG, "TCSBRKP" },
239 { TIOCMSET, KERN_DEBUG, "TIOCMSET" },
240
241 /* linux-specific ones */
242 { TIOCLINUX, KERN_INFO, "TIOCLINUX" },
243 { KDGKBMODE, KERN_INFO, "KDGKBMODE" },
244 { KDGKBTYPE, KERN_INFO, "KDGKBTYPE" },
245 { KDSIGACCEPT, KERN_INFO, "KDSIGACCEPT" },
246};
247
248int line_ioctl(struct tty_struct *tty, unsigned int cmd,
249 unsigned long arg)
250{
251 int ret;
252 int i;
253
254 ret = 0;
255 switch(cmd) {
256#ifdef TIOCGETP
257 case TIOCGETP:
258 case TIOCSETP:
259 case TIOCSETN:
260#endif
261#ifdef TIOCGETC
262 case TIOCGETC:
263 case TIOCSETC:
264#endif
265#ifdef TIOCGLTC
266 case TIOCGLTC:
267 case TIOCSLTC:
268#endif
269 /* Note: these are out of date as we now have TCGETS2 etc but this
270 whole lot should probably go away */
271 case TCGETS:
272 case TCSETSF:
273 case TCSETSW:
274 case TCSETS:
275 case TCGETA:
276 case TCSETAF:
277 case TCSETAW:
278 case TCSETA:
279 case TCXONC:
280 case TCFLSH:
281 case TIOCOUTQ:
282 case TIOCINQ:
283 case TIOCGLCKTRMIOS:
284 case TIOCSLCKTRMIOS:
285 case TIOCPKT:
286 case TIOCGSOFTCAR:
287 case TIOCSSOFTCAR:
288 return -ENOIOCTLCMD;
289#if 0
290 case TCwhatever:
291 /* do something */
292 break;
293#endif
294 default:
295 for (i = 0; i < ARRAY_SIZE(tty_ioctls); i++)
296 if (cmd == tty_ioctls[i].cmd)
297 break;
298 if (i == ARRAY_SIZE(tty_ioctls)) {
299 printk(KERN_ERR "%s: %s: unknown ioctl: 0x%x\n",
300 __func__, tty->name, cmd);
301 }
302 ret = -ENOIOCTLCMD;
303 break;
304 }
305 return ret;
306}
307
308void line_throttle(struct tty_struct *tty) 224void line_throttle(struct tty_struct *tty)
309{ 225{
310 struct line *line = tty->driver_data; 226 struct line *line = tty->driver_data;
@@ -333,7 +249,7 @@ static irqreturn_t line_write_interrupt(int irq, void *data)
333{ 249{
334 struct chan *chan = data; 250 struct chan *chan = data;
335 struct line *line = chan->line; 251 struct line *line = chan->line;
336 struct tty_struct *tty = line->tty; 252 struct tty_struct *tty;
337 int err; 253 int err;
338 254
339 /* 255 /*
@@ -352,68 +268,42 @@ static irqreturn_t line_write_interrupt(int irq, void *data)
352 } 268 }
353 spin_unlock(&line->lock); 269 spin_unlock(&line->lock);
354 270
271 tty = tty_port_tty_get(&line->port);
355 if (tty == NULL) 272 if (tty == NULL)
356 return IRQ_NONE; 273 return IRQ_NONE;
357 274
358 tty_wakeup(tty); 275 tty_wakeup(tty);
276 tty_kref_put(tty);
277
359 return IRQ_HANDLED; 278 return IRQ_HANDLED;
360} 279}
361 280
362int line_setup_irq(int fd, int input, int output, struct line *line, void *data) 281int line_setup_irq(int fd, int input, int output, struct line *line, void *data)
363{ 282{
364 const struct line_driver *driver = line->driver; 283 const struct line_driver *driver = line->driver;
365 int err = 0, flags = IRQF_SHARED | IRQF_SAMPLE_RANDOM; 284 int err = 0;
366 285
367 if (input) 286 if (input)
368 err = um_request_irq(driver->read_irq, fd, IRQ_READ, 287 err = um_request_irq(driver->read_irq, fd, IRQ_READ,
369 line_interrupt, flags, 288 line_interrupt, IRQF_SHARED,
370 driver->read_irq_name, data); 289 driver->read_irq_name, data);
371 if (err) 290 if (err)
372 return err; 291 return err;
373 if (output) 292 if (output)
374 err = um_request_irq(driver->write_irq, fd, IRQ_WRITE, 293 err = um_request_irq(driver->write_irq, fd, IRQ_WRITE,
375 line_write_interrupt, flags, 294 line_write_interrupt, IRQF_SHARED,
376 driver->write_irq_name, data); 295 driver->write_irq_name, data);
377 return err; 296 return err;
378} 297}
379 298
380/* 299static int line_activate(struct tty_port *port, struct tty_struct *tty)
381 * Normally, a driver like this can rely mostly on the tty layer
382 * locking, particularly when it comes to the driver structure.
383 * However, in this case, mconsole requests can come in "from the
384 * side", and race with opens and closes.
385 *
386 * mconsole config requests will want to be sure the device isn't in
387 * use, and get_config, open, and close will want a stable
388 * configuration. The checking and modification of the configuration
389 * is done under a spinlock. Checking whether the device is in use is
390 * line->tty->count > 1, also under the spinlock.
391 *
392 * line->count serves to decide whether the device should be enabled or
393 * disabled on the host. If it's equal to 0, then we are doing the
394 * first open or last close. Otherwise, open and close just return.
395 */
396
397int line_open(struct line *lines, struct tty_struct *tty)
398{ 300{
399 struct line *line = &lines[tty->index]; 301 int ret;
400 int err = -ENODEV; 302 struct line *line = tty->driver_data;
401
402 mutex_lock(&line->count_lock);
403 if (!line->valid)
404 goto out_unlock;
405
406 err = 0;
407 if (line->count++)
408 goto out_unlock;
409
410 BUG_ON(tty->driver_data);
411 tty->driver_data = line;
412 line->tty = tty;
413 303
414 err = enable_chan(line); 304 ret = enable_chan(line);
415 if (err) /* line_close() will be called by our caller */ 305 if (ret)
416 goto out_unlock; 306 return ret;
417 307
418 if (!line->sigio) { 308 if (!line->sigio) {
419 chan_enable_winch(line->chan_out, tty); 309 chan_enable_winch(line->chan_out, tty);
@@ -421,44 +311,60 @@ int line_open(struct line *lines, struct tty_struct *tty)
421 } 311 }
422 312
423 chan_window_size(line, &tty->winsize.ws_row, 313 chan_window_size(line, &tty->winsize.ws_row,
424 &tty->winsize.ws_col); 314 &tty->winsize.ws_col);
425out_unlock: 315
426 mutex_unlock(&line->count_lock); 316 return 0;
427 return err;
428} 317}
429 318
430static void unregister_winch(struct tty_struct *tty); 319static const struct tty_port_operations line_port_ops = {
320 .activate = line_activate,
321};
431 322
432void line_close(struct tty_struct *tty, struct file * filp) 323int line_open(struct tty_struct *tty, struct file *filp)
433{ 324{
434 struct line *line = tty->driver_data; 325 struct line *line = tty->driver_data;
435 326
436 /* 327 return tty_port_open(&line->port, tty, filp);
437 * If line_open fails (and tty->driver_data is never set), 328}
438 * tty_open will call line_close. So just return in this case.
439 */
440 if (line == NULL)
441 return;
442 329
443 /* We ignore the error anyway! */ 330int line_install(struct tty_driver *driver, struct tty_struct *tty,
444 flush_buffer(line); 331 struct line *line)
332{
333 int ret;
445 334
446 mutex_lock(&line->count_lock); 335 ret = tty_standard_install(driver, tty);
447 BUG_ON(!line->valid); 336 if (ret)
337 return ret;
448 338
449 if (--line->count) 339 tty->driver_data = line;
450 goto out_unlock;
451 340
452 line->tty = NULL; 341 return 0;
453 tty->driver_data = NULL; 342}
343
344static void unregister_winch(struct tty_struct *tty);
345
346void line_cleanup(struct tty_struct *tty)
347{
348 struct line *line = tty->driver_data;
454 349
455 if (line->sigio) { 350 if (line->sigio) {
456 unregister_winch(tty); 351 unregister_winch(tty);
457 line->sigio = 0; 352 line->sigio = 0;
458 } 353 }
354}
355
356void line_close(struct tty_struct *tty, struct file * filp)
357{
358 struct line *line = tty->driver_data;
459 359
460out_unlock: 360 tty_port_close(&line->port, tty, filp);
461 mutex_unlock(&line->count_lock); 361}
362
363void line_hangup(struct tty_struct *tty)
364{
365 struct line *line = tty->driver_data;
366
367 tty_port_hangup(&line->port);
462} 368}
463 369
464void close_lines(struct line *lines, int nlines) 370void close_lines(struct line *lines, int nlines)
@@ -476,9 +382,7 @@ int setup_one_line(struct line *lines, int n, char *init,
476 struct tty_driver *driver = line->driver->driver; 382 struct tty_driver *driver = line->driver->driver;
477 int err = -EINVAL; 383 int err = -EINVAL;
478 384
479 mutex_lock(&line->count_lock); 385 if (line->port.count) {
480
481 if (line->count) {
482 *error_out = "Device is already open"; 386 *error_out = "Device is already open";
483 goto out; 387 goto out;
484 } 388 }
@@ -519,7 +423,6 @@ int setup_one_line(struct line *lines, int n, char *init,
519 } 423 }
520 } 424 }
521out: 425out:
522 mutex_unlock(&line->count_lock);
523 return err; 426 return err;
524} 427}
525 428
@@ -607,13 +510,17 @@ int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
607 510
608 line = &lines[dev]; 511 line = &lines[dev];
609 512
610 mutex_lock(&line->count_lock);
611 if (!line->valid) 513 if (!line->valid)
612 CONFIG_CHUNK(str, size, n, "none", 1); 514 CONFIG_CHUNK(str, size, n, "none", 1);
613 else if (line->tty == NULL) 515 else {
614 CONFIG_CHUNK(str, size, n, line->init_str, 1); 516 struct tty_struct *tty = tty_port_tty_get(&line->port);
615 else n = chan_config_string(line, str, size, error_out); 517 if (tty == NULL) {
616 mutex_unlock(&line->count_lock); 518 CONFIG_CHUNK(str, size, n, line->init_str, 1);
519 } else {
520 n = chan_config_string(line, str, size, error_out);
521 tty_kref_put(tty);
522 }
523 }
617 524
618 return n; 525 return n;
619} 526}
@@ -663,8 +570,9 @@ int register_lines(struct line_driver *line_driver,
663 driver->init_termios = tty_std_termios; 570 driver->init_termios = tty_std_termios;
664 571
665 for (i = 0; i < nlines; i++) { 572 for (i = 0; i < nlines; i++) {
573 tty_port_init(&lines[i].port);
574 lines[i].port.ops = &line_port_ops;
666 spin_lock_init(&lines[i].lock); 575 spin_lock_init(&lines[i].lock);
667 mutex_init(&lines[i].count_lock);
668 lines[i].driver = line_driver; 576 lines[i].driver = line_driver;
669 INIT_LIST_HEAD(&lines[i].chan_list); 577 INIT_LIST_HEAD(&lines[i].chan_list);
670 } 578 }
@@ -779,8 +687,7 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty,
779 .stack = stack }); 687 .stack = stack });
780 688
781 if (um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt, 689 if (um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt,
782 IRQF_SHARED | IRQF_SAMPLE_RANDOM, 690 IRQF_SHARED, "winch", winch) < 0) {
783 "winch", winch) < 0) {
784 printk(KERN_ERR "register_winch_irq - failed to register " 691 printk(KERN_ERR "register_winch_irq - failed to register "
785 "IRQ\n"); 692 "IRQ\n");
786 goto out_free; 693 goto out_free;
diff --git a/arch/um/drivers/line.h b/arch/um/drivers/line.h
index 0a1834719db..bae95611e7a 100644
--- a/arch/um/drivers/line.h
+++ b/arch/um/drivers/line.h
@@ -32,9 +32,7 @@ struct line_driver {
32}; 32};
33 33
34struct line { 34struct line {
35 struct tty_struct *tty; 35 struct tty_port port;
36 struct mutex count_lock;
37 unsigned long count;
38 int valid; 36 int valid;
39 37
40 char *init_str; 38 char *init_str;
@@ -59,7 +57,11 @@ struct line {
59}; 57};
60 58
61extern void line_close(struct tty_struct *tty, struct file * filp); 59extern void line_close(struct tty_struct *tty, struct file * filp);
62extern int line_open(struct line *lines, struct tty_struct *tty); 60extern int line_open(struct tty_struct *tty, struct file *filp);
61extern int line_install(struct tty_driver *driver, struct tty_struct *tty,
62 struct line *line);
63extern void line_cleanup(struct tty_struct *tty);
64extern void line_hangup(struct tty_struct *tty);
63extern int line_setup(char **conf, unsigned nlines, char **def, 65extern int line_setup(char **conf, unsigned nlines, char **def,
64 char *init, char *name); 66 char *init, char *name);
65extern int line_write(struct tty_struct *tty, const unsigned char *buf, 67extern int line_write(struct tty_struct *tty, const unsigned char *buf,
@@ -70,8 +72,6 @@ extern int line_chars_in_buffer(struct tty_struct *tty);
70extern void line_flush_buffer(struct tty_struct *tty); 72extern void line_flush_buffer(struct tty_struct *tty);
71extern void line_flush_chars(struct tty_struct *tty); 73extern void line_flush_chars(struct tty_struct *tty);
72extern int line_write_room(struct tty_struct *tty); 74extern int line_write_room(struct tty_struct *tty);
73extern int line_ioctl(struct tty_struct *tty, unsigned int cmd,
74 unsigned long arg);
75extern void line_throttle(struct tty_struct *tty); 75extern void line_throttle(struct tty_struct *tty);
76extern void line_unthrottle(struct tty_struct *tty); 76extern void line_unthrottle(struct tty_struct *tty);
77 77
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 43b39d61b53..664a60e8dfb 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -774,8 +774,7 @@ static int __init mconsole_init(void)
774 register_reboot_notifier(&reboot_notifier); 774 register_reboot_notifier(&reboot_notifier);
775 775
776 err = um_request_irq(MCONSOLE_IRQ, sock, IRQ_READ, mconsole_interrupt, 776 err = um_request_irq(MCONSOLE_IRQ, sock, IRQ_READ, mconsole_interrupt,
777 IRQF_SHARED | IRQF_SAMPLE_RANDOM, 777 IRQF_SHARED, "mconsole", (void *)sock);
778 "mconsole", (void *)sock);
779 if (err) { 778 if (err) {
780 printk(KERN_ERR "Failed to get IRQ for management console\n"); 779 printk(KERN_ERR "Failed to get IRQ for management console\n");
781 goto out; 780 goto out;
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index 0d60c5685c2..458d324f062 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -339,7 +339,7 @@ static int setup_etheraddr(char *str, unsigned char *addr, char *name)
339random: 339random:
340 printk(KERN_INFO 340 printk(KERN_INFO
341 "Choosing a random ethernet address for device %s\n", name); 341 "Choosing a random ethernet address for device %s\n", name);
342 random_ether_addr(addr); 342 eth_random_addr(addr);
343 return 1; 343 return 1;
344} 344}
345 345
diff --git a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c
index 11866ffd45a..1d83d50236e 100644
--- a/arch/um/drivers/port_kern.c
+++ b/arch/um/drivers/port_kern.c
@@ -100,8 +100,7 @@ static int port_accept(struct port_list *port)
100 .port = port }); 100 .port = port });
101 101
102 if (um_request_irq(TELNETD_IRQ, socket[0], IRQ_READ, pipe_interrupt, 102 if (um_request_irq(TELNETD_IRQ, socket[0], IRQ_READ, pipe_interrupt,
103 IRQF_SHARED | IRQF_SAMPLE_RANDOM, 103 IRQF_SHARED, "telnetd", conn)) {
104 "telnetd", conn)) {
105 printk(KERN_ERR "port_accept : failed to get IRQ for " 104 printk(KERN_ERR "port_accept : failed to get IRQ for "
106 "telnetd\n"); 105 "telnetd\n");
107 goto out_free; 106 goto out_free;
@@ -184,8 +183,7 @@ void *port_data(int port_num)
184 } 183 }
185 184
186 if (um_request_irq(ACCEPT_IRQ, fd, IRQ_READ, port_interrupt, 185 if (um_request_irq(ACCEPT_IRQ, fd, IRQ_READ, port_interrupt,
187 IRQF_SHARED | IRQF_SAMPLE_RANDOM, 186 IRQF_SHARED, "port", port)) {
188 "port", port)) {
189 printk(KERN_ERR "Failed to get IRQ for port %d\n", port_num); 187 printk(KERN_ERR "Failed to get IRQ for port %d\n", port_num);
190 goto out_close; 188 goto out_close;
191 } 189 }
diff --git a/arch/um/drivers/random.c b/arch/um/drivers/random.c
index b25296e6218..e32c6aa6396 100644
--- a/arch/um/drivers/random.c
+++ b/arch/um/drivers/random.c
@@ -131,8 +131,7 @@ static int __init rng_init (void)
131 random_fd = err; 131 random_fd = err;
132 132
133 err = um_request_irq(RANDOM_IRQ, random_fd, IRQ_READ, random_interrupt, 133 err = um_request_irq(RANDOM_IRQ, random_fd, IRQ_READ, random_interrupt,
134 IRQF_SAMPLE_RANDOM, "random", 134 0, "random", NULL);
135 NULL);
136 if (err) 135 if (err)
137 goto err_out_cleanup_hw; 136 goto err_out_cleanup_hw;
138 137
diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c
index e09801a1327..7e86f007012 100644
--- a/arch/um/drivers/ssl.c
+++ b/arch/um/drivers/ssl.c
@@ -87,40 +87,13 @@ static int ssl_remove(int n, char **error_out)
87 error_out); 87 error_out);
88} 88}
89 89
90static int ssl_open(struct tty_struct *tty, struct file *filp) 90static int ssl_install(struct tty_driver *driver, struct tty_struct *tty)
91{
92 int err = line_open(serial_lines, tty);
93
94 if (err)
95 printk(KERN_ERR "Failed to open serial line %d, err = %d\n",
96 tty->index, err);
97
98 return err;
99}
100
101#if 0
102static void ssl_flush_buffer(struct tty_struct *tty)
103{
104 return;
105}
106
107static void ssl_stop(struct tty_struct *tty)
108{
109 printk(KERN_ERR "Someone should implement ssl_stop\n");
110}
111
112static void ssl_start(struct tty_struct *tty)
113{
114 printk(KERN_ERR "Someone should implement ssl_start\n");
115}
116
117void ssl_hangup(struct tty_struct *tty)
118{ 91{
92 return line_install(driver, tty, &serial_lines[tty->index]);
119} 93}
120#endif
121 94
122static const struct tty_operations ssl_ops = { 95static const struct tty_operations ssl_ops = {
123 .open = ssl_open, 96 .open = line_open,
124 .close = line_close, 97 .close = line_close,
125 .write = line_write, 98 .write = line_write,
126 .put_char = line_put_char, 99 .put_char = line_put_char,
@@ -129,14 +102,11 @@ static const struct tty_operations ssl_ops = {
129 .flush_buffer = line_flush_buffer, 102 .flush_buffer = line_flush_buffer,
130 .flush_chars = line_flush_chars, 103 .flush_chars = line_flush_chars,
131 .set_termios = line_set_termios, 104 .set_termios = line_set_termios,
132 .ioctl = line_ioctl,
133 .throttle = line_throttle, 105 .throttle = line_throttle,
134 .unthrottle = line_unthrottle, 106 .unthrottle = line_unthrottle,
135#if 0 107 .install = ssl_install,
136 .stop = ssl_stop, 108 .cleanup = line_cleanup,
137 .start = ssl_start, 109 .hangup = line_hangup,
138 .hangup = ssl_hangup,
139#endif
140}; 110};
141 111
142/* Changed by ssl_init and referenced by ssl_exit, which are both serialized 112/* Changed by ssl_init and referenced by ssl_exit, which are both serialized
diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c
index 7663541c372..929b99a261f 100644
--- a/arch/um/drivers/stdio_console.c
+++ b/arch/um/drivers/stdio_console.c
@@ -89,21 +89,17 @@ static int con_remove(int n, char **error_out)
89 return line_remove(vts, ARRAY_SIZE(vts), n, error_out); 89 return line_remove(vts, ARRAY_SIZE(vts), n, error_out);
90} 90}
91 91
92static int con_open(struct tty_struct *tty, struct file *filp)
93{
94 int err = line_open(vts, tty);
95 if (err)
96 printk(KERN_ERR "Failed to open console %d, err = %d\n",
97 tty->index, err);
98
99 return err;
100}
101
102/* Set in an initcall, checked in an exitcall */ 92/* Set in an initcall, checked in an exitcall */
103static int con_init_done = 0; 93static int con_init_done = 0;
104 94
95static int con_install(struct tty_driver *driver, struct tty_struct *tty)
96{
97 return line_install(driver, tty, &vts[tty->index]);
98}
99
105static const struct tty_operations console_ops = { 100static const struct tty_operations console_ops = {
106 .open = con_open, 101 .open = line_open,
102 .install = con_install,
107 .close = line_close, 103 .close = line_close,
108 .write = line_write, 104 .write = line_write,
109 .put_char = line_put_char, 105 .put_char = line_put_char,
@@ -112,9 +108,10 @@ static const struct tty_operations console_ops = {
112 .flush_buffer = line_flush_buffer, 108 .flush_buffer = line_flush_buffer,
113 .flush_chars = line_flush_chars, 109 .flush_chars = line_flush_chars,
114 .set_termios = line_set_termios, 110 .set_termios = line_set_termios,
115 .ioctl = line_ioctl,
116 .throttle = line_throttle, 111 .throttle = line_throttle,
117 .unthrottle = line_unthrottle, 112 .unthrottle = line_unthrottle,
113 .cleanup = line_cleanup,
114 .hangup = line_hangup,
118}; 115};
119 116
120static void uml_console_write(struct console *console, const char *string, 117static void uml_console_write(struct console *console, const char *string,
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 20505cafa29..0643e5bc9f4 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -514,7 +514,7 @@ static inline int ubd_file_size(struct ubd *ubd_dev, __u64 *size_out)
514 goto out; 514 goto out;
515 } 515 }
516 516
517 fd = os_open_file(ubd_dev->file, global_openflags, 0); 517 fd = os_open_file(ubd_dev->file, of_read(OPENFLAGS()), 0);
518 if (fd < 0) 518 if (fd < 0)
519 return fd; 519 return fd;
520 520
diff --git a/arch/um/drivers/xterm_kern.c b/arch/um/drivers/xterm_kern.c
index b68bbe269e0..e3031e69445 100644
--- a/arch/um/drivers/xterm_kern.c
+++ b/arch/um/drivers/xterm_kern.c
@@ -50,8 +50,7 @@ int xterm_fd(int socket, int *pid_out)
50 init_completion(&data->ready); 50 init_completion(&data->ready);
51 51
52 err = um_request_irq(XTERM_IRQ, socket, IRQ_READ, xterm_interrupt, 52 err = um_request_irq(XTERM_IRQ, socket, IRQ_READ, xterm_interrupt,
53 IRQF_SHARED | IRQF_SAMPLE_RANDOM, 53 IRQF_SHARED, "xterm", data);
54 "xterm", data);
55 if (err) { 54 if (err) {
56 printk(KERN_ERR "xterm_fd : failed to get IRQ for xterm, " 55 printk(KERN_ERR "xterm_fd : failed to get IRQ for xterm, "
57 "err = %d\n", err); 56 "err = %d\n", err);
diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
index 6c03acdb440..2e0a6b1d830 100644
--- a/arch/um/include/asm/kmap_types.h
+++ b/arch/um/include/asm/kmap_types.h
@@ -8,22 +8,6 @@
8 8
9/* No more #include "asm/arch/kmap_types.h" ! */ 9/* No more #include "asm/arch/kmap_types.h" ! */
10 10
11enum km_type { 11#define KM_TYPE_NR 14
12 KM_BOUNCE_READ,
13 KM_SKB_SUNRPC_DATA,
14 KM_SKB_DATA_SOFTIRQ,
15 KM_USER0,
16 KM_USER1,
17 KM_UML_USERCOPY, /* UML specific, for copy_*_user - used in do_op_one_page */
18 KM_BIO_SRC_IRQ,
19 KM_BIO_DST_IRQ,
20 KM_PTE0,
21 KM_PTE1,
22 KM_IRQ0,
23 KM_IRQ1,
24 KM_SOFTIRQ0,
25 KM_SOFTIRQ1,
26 KM_TYPE_NR
27};
28 12
29#endif 13#endif
diff --git a/arch/um/include/asm/ptrace-generic.h b/arch/um/include/asm/ptrace-generic.h
index e786a6a3ec5..442f1d025dc 100644
--- a/arch/um/include/asm/ptrace-generic.h
+++ b/arch/um/include/asm/ptrace-generic.h
@@ -37,6 +37,8 @@ extern int putreg(struct task_struct *child, int regno, unsigned long value);
37 37
38extern int arch_copy_tls(struct task_struct *new); 38extern int arch_copy_tls(struct task_struct *new);
39extern void clear_flushed_tls(struct task_struct *task); 39extern void clear_flushed_tls(struct task_struct *task);
40extern void syscall_trace_enter(struct pt_regs *regs);
41extern void syscall_trace_leave(struct pt_regs *regs);
40 42
41#endif 43#endif
42 44
diff --git a/arch/um/include/shared/as-layout.h b/arch/um/include/shared/as-layout.h
index 896e1660217..86daa546181 100644
--- a/arch/um/include/shared/as-layout.h
+++ b/arch/um/include/shared/as-layout.h
@@ -60,7 +60,8 @@ extern unsigned long host_task_size;
60 60
61extern int linux_main(int argc, char **argv); 61extern int linux_main(int argc, char **argv);
62 62
63extern void (*sig_info[])(int, struct uml_pt_regs *); 63struct siginfo;
64extern void (*sig_info[])(int, struct siginfo *si, struct uml_pt_regs *);
64 65
65#endif 66#endif
66 67
diff --git a/arch/um/include/shared/irq_user.h b/arch/um/include/shared/irq_user.h
index c6c784df267..2b6d703925b 100644
--- a/arch/um/include/shared/irq_user.h
+++ b/arch/um/include/shared/irq_user.h
@@ -20,7 +20,8 @@ struct irq_fd {
20 20
21enum { IRQ_READ, IRQ_WRITE }; 21enum { IRQ_READ, IRQ_WRITE };
22 22
23extern void sigio_handler(int sig, struct uml_pt_regs *regs); 23struct siginfo;
24extern void sigio_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs);
24extern void free_irq_by_fd(int fd); 25extern void free_irq_by_fd(int fd);
25extern void reactivate_fd(int fd, int irqnum); 26extern void reactivate_fd(int fd, int irqnum);
26extern void deactivate_fd(int fd, int irqnum); 27extern void deactivate_fd(int fd, int irqnum);
diff --git a/arch/um/include/shared/kern_util.h b/arch/um/include/shared/kern_util.h
index 00965d06d2c..af6b6dc868b 100644
--- a/arch/um/include/shared/kern_util.h
+++ b/arch/um/include/shared/kern_util.h
@@ -9,6 +9,8 @@
9#include "sysdep/ptrace.h" 9#include "sysdep/ptrace.h"
10#include "sysdep/faultinfo.h" 10#include "sysdep/faultinfo.h"
11 11
12struct siginfo;
13
12extern int uml_exitcode; 14extern int uml_exitcode;
13 15
14extern int ncpus; 16extern int ncpus;
@@ -22,7 +24,7 @@ extern void free_stack(unsigned long stack, int order);
22 24
23extern int do_signal(void); 25extern int do_signal(void);
24extern void interrupt_end(void); 26extern void interrupt_end(void);
25extern void relay_signal(int sig, struct uml_pt_regs *regs); 27extern void relay_signal(int sig, struct siginfo *si, struct uml_pt_regs *regs);
26 28
27extern unsigned long segv(struct faultinfo fi, unsigned long ip, 29extern unsigned long segv(struct faultinfo fi, unsigned long ip,
28 int is_user, struct uml_pt_regs *regs); 30 int is_user, struct uml_pt_regs *regs);
@@ -33,9 +35,8 @@ extern unsigned int do_IRQ(int irq, struct uml_pt_regs *regs);
33extern int smp_sigio_handler(void); 35extern int smp_sigio_handler(void);
34extern void initial_thread_cb(void (*proc)(void *), void *arg); 36extern void initial_thread_cb(void (*proc)(void *), void *arg);
35extern int is_syscall(unsigned long addr); 37extern int is_syscall(unsigned long addr);
36extern void timer_handler(int sig, struct uml_pt_regs *regs);
37 38
38extern void timer_handler(int sig, struct uml_pt_regs *regs); 39extern void timer_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs);
39 40
40extern int start_uml(void); 41extern int start_uml(void);
41extern void paging_init(void); 42extern void paging_init(void);
@@ -59,9 +60,9 @@ extern unsigned long from_irq_stack(int nested);
59extern void syscall_trace(struct uml_pt_regs *regs, int entryexit); 60extern void syscall_trace(struct uml_pt_regs *regs, int entryexit);
60extern int singlestepping(void *t); 61extern int singlestepping(void *t);
61 62
62extern void segv_handler(int sig, struct uml_pt_regs *regs); 63extern void segv_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs);
63extern void bus_handler(int sig, struct uml_pt_regs *regs); 64extern void bus_handler(int sig, struct siginfo *si, struct uml_pt_regs *regs);
64extern void winch(int sig, struct uml_pt_regs *regs); 65extern void winch(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs);
65extern void fatal_sigsegv(void) __attribute__ ((noreturn)); 66extern void fatal_sigsegv(void) __attribute__ ((noreturn));
66 67
67 68
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index 00506c3d5d6..9883026f073 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -30,7 +30,7 @@ static struct irq_fd **last_irq_ptr = &active_fds;
30 30
31extern void free_irqs(void); 31extern void free_irqs(void);
32 32
33void sigio_handler(int sig, struct uml_pt_regs *regs) 33void sigio_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs)
34{ 34{
35 struct irq_fd *irq_fd; 35 struct irq_fd *irq_fd;
36 int n; 36 int n;
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index ccb9a9d283f..57fc7028714 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -151,12 +151,10 @@ void new_thread_handler(void)
151 * 0 if it just exits 151 * 0 if it just exits
152 */ 152 */
153 n = run_kernel_thread(fn, arg, &current->thread.exec_buf); 153 n = run_kernel_thread(fn, arg, &current->thread.exec_buf);
154 if (n == 1) { 154 if (n == 1)
155 /* Handle any immediate reschedules or signals */
156 interrupt_end();
157 userspace(&current->thread.regs.regs); 155 userspace(&current->thread.regs.regs);
158 } 156 else
159 else do_exit(0); 157 do_exit(0);
160} 158}
161 159
162/* Called magically, see new_thread_handler above */ 160/* Called magically, see new_thread_handler above */
@@ -175,9 +173,6 @@ void fork_handler(void)
175 173
176 current->thread.prev_sched = NULL; 174 current->thread.prev_sched = NULL;
177 175
178 /* Handle any immediate reschedules or signals */
179 interrupt_end();
180
181 userspace(&current->thread.regs.regs); 176 userspace(&current->thread.regs.regs);
182} 177}
183 178
@@ -193,7 +188,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
193 if (current->thread.forking) { 188 if (current->thread.forking) {
194 memcpy(&p->thread.regs.regs, &regs->regs, 189 memcpy(&p->thread.regs.regs, &regs->regs,
195 sizeof(p->thread.regs.regs)); 190 sizeof(p->thread.regs.regs));
196 UPT_SET_SYSCALL_RETURN(&p->thread.regs.regs, 0); 191 PT_REGS_SET_SYSCALL_RETURN(&p->thread.regs, 0);
197 if (sp != 0) 192 if (sp != 0)
198 REGS_SP(p->thread.regs.regs.gp) = sp; 193 REGS_SP(p->thread.regs.regs.gp) = sp;
199 194
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
index 06b19039050..694d551c889 100644
--- a/arch/um/kernel/ptrace.c
+++ b/arch/um/kernel/ptrace.c
@@ -3,11 +3,12 @@
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include "linux/audit.h" 6#include <linux/audit.h>
7#include "linux/ptrace.h" 7#include <linux/ptrace.h>
8#include "linux/sched.h" 8#include <linux/sched.h>
9#include "asm/uaccess.h" 9#include <linux/tracehook.h>
10#include "skas_ptrace.h" 10#include <asm/uaccess.h>
11#include <skas_ptrace.h>
11 12
12 13
13 14
@@ -162,48 +163,36 @@ static void send_sigtrap(struct task_struct *tsk, struct uml_pt_regs *regs,
162 * XXX Check PT_DTRACE vs TIF_SINGLESTEP for singlestepping check and 163 * XXX Check PT_DTRACE vs TIF_SINGLESTEP for singlestepping check and
163 * PT_PTRACED vs TIF_SYSCALL_TRACE for syscall tracing check 164 * PT_PTRACED vs TIF_SYSCALL_TRACE for syscall tracing check
164 */ 165 */
165void syscall_trace(struct uml_pt_regs *regs, int entryexit) 166void syscall_trace_enter(struct pt_regs *regs)
166{ 167{
167 int is_singlestep = (current->ptrace & PT_DTRACE) && entryexit; 168 audit_syscall_entry(HOST_AUDIT_ARCH,
168 int tracesysgood; 169 UPT_SYSCALL_NR(&regs->regs),
169 170 UPT_SYSCALL_ARG1(&regs->regs),
170 if (!entryexit) 171 UPT_SYSCALL_ARG2(&regs->regs),
171 audit_syscall_entry(HOST_AUDIT_ARCH, 172 UPT_SYSCALL_ARG3(&regs->regs),
172 UPT_SYSCALL_NR(regs), 173 UPT_SYSCALL_ARG4(&regs->regs));
173 UPT_SYSCALL_ARG1(regs),
174 UPT_SYSCALL_ARG2(regs),
175 UPT_SYSCALL_ARG3(regs),
176 UPT_SYSCALL_ARG4(regs));
177 else
178 audit_syscall_exit(regs);
179
180 /* Fake a debug trap */
181 if (is_singlestep)
182 send_sigtrap(current, regs, 0);
183 174
184 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 175 if (!test_thread_flag(TIF_SYSCALL_TRACE))
185 return; 176 return;
186 177
187 if (!(current->ptrace & PT_PTRACED)) 178 tracehook_report_syscall_entry(regs);
188 return; 179}
189 180
190 /* 181void syscall_trace_leave(struct pt_regs *regs)
191 * the 0x80 provides a way for the tracing parent to distinguish 182{
192 * between a syscall stop and SIGTRAP delivery 183 int ptraced = current->ptrace;
193 */
194 tracesysgood = (current->ptrace & PT_TRACESYSGOOD);
195 ptrace_notify(SIGTRAP | (tracesysgood ? 0x80 : 0));
196 184
197 if (entryexit) /* force do_signal() --> is_syscall() */ 185 audit_syscall_exit(regs);
198 set_thread_flag(TIF_SIGPENDING);
199 186
200 /* 187 /* Fake a debug trap */
201 * this isn't the same as continuing with a signal, but it will do 188 if (ptraced & PT_DTRACE)
202 * for normal use. strace only continues with a signal if the 189 send_sigtrap(current, &regs->regs, 0);
203 * stopping signal is not SIGTRAP. -brl 190
204 */ 191 if (!test_thread_flag(TIF_SYSCALL_TRACE))
205 if (current->exit_code) { 192 return;
206 send_sig(current->exit_code, current, 1); 193
207 current->exit_code = 0; 194 tracehook_report_syscall_exit(regs, 0);
208 } 195 /* force do_signal() --> is_syscall() */
196 if (ptraced & PT_PTRACED)
197 set_thread_flag(TIF_SIGPENDING);
209} 198}
diff --git a/arch/um/kernel/sigio.c b/arch/um/kernel/sigio.c
index 2a163925576..c88211139a5 100644
--- a/arch/um/kernel/sigio.c
+++ b/arch/um/kernel/sigio.c
@@ -25,8 +25,7 @@ int write_sigio_irq(int fd)
25 int err; 25 int err;
26 26
27 err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt, 27 err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt,
28 IRQF_SAMPLE_RANDOM, "write sigio", 28 0, "write sigio", NULL);
29 NULL);
30 if (err) { 29 if (err) {
31 printk(KERN_ERR "write_sigio_irq : um_request_irq failed, " 30 printk(KERN_ERR "write_sigio_irq : um_request_irq failed, "
32 "err = %d\n", err); 31 "err = %d\n", err);
diff --git a/arch/um/kernel/skas/syscall.c b/arch/um/kernel/skas/syscall.c
index 05fbeb480e0..86368a025a9 100644
--- a/arch/um/kernel/skas/syscall.c
+++ b/arch/um/kernel/skas/syscall.c
@@ -18,7 +18,7 @@ void handle_syscall(struct uml_pt_regs *r)
18 long result; 18 long result;
19 int syscall; 19 int syscall;
20 20
21 syscall_trace(r, 0); 21 syscall_trace_enter(regs);
22 22
23 /* 23 /*
24 * This should go in the declaration of syscall, but when I do that, 24 * This should go in the declaration of syscall, but when I do that,
@@ -34,7 +34,7 @@ void handle_syscall(struct uml_pt_regs *r)
34 result = -ENOSYS; 34 result = -ENOSYS;
35 else result = EXECUTE_SYSCALL(syscall, regs); 35 else result = EXECUTE_SYSCALL(syscall, regs);
36 36
37 UPT_SET_SYSCALL_RETURN(r, result); 37 PT_REGS_SET_SYSCALL_RETURN(regs, result);
38 38
39 syscall_trace(r, 1); 39 syscall_trace_leave(regs);
40} 40}
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c
index d1a23fb3190..5f76d4ba151 100644
--- a/arch/um/kernel/time.c
+++ b/arch/um/kernel/time.c
@@ -13,7 +13,7 @@
13#include "kern_util.h" 13#include "kern_util.h"
14#include "os.h" 14#include "os.h"
15 15
16void timer_handler(int sig, struct uml_pt_regs *regs) 16void timer_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs)
17{ 17{
18 unsigned long flags; 18 unsigned long flags;
19 19
diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c
index 3be60765c0e..0353b98ae35 100644
--- a/arch/um/kernel/trap.c
+++ b/arch/um/kernel/trap.c
@@ -172,7 +172,7 @@ void fatal_sigsegv(void)
172 os_dump_core(); 172 os_dump_core();
173} 173}
174 174
175void segv_handler(int sig, struct uml_pt_regs *regs) 175void segv_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs)
176{ 176{
177 struct faultinfo * fi = UPT_FAULTINFO(regs); 177 struct faultinfo * fi = UPT_FAULTINFO(regs);
178 178
@@ -258,8 +258,11 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user,
258 return 0; 258 return 0;
259} 259}
260 260
261void relay_signal(int sig, struct uml_pt_regs *regs) 261void relay_signal(int sig, struct siginfo *si, struct uml_pt_regs *regs)
262{ 262{
263 struct faultinfo *fi;
264 struct siginfo clean_si;
265
263 if (!UPT_IS_USER(regs)) { 266 if (!UPT_IS_USER(regs)) {
264 if (sig == SIGBUS) 267 if (sig == SIGBUS)
265 printk(KERN_ERR "Bus error - the host /dev/shm or /tmp " 268 printk(KERN_ERR "Bus error - the host /dev/shm or /tmp "
@@ -269,18 +272,40 @@ void relay_signal(int sig, struct uml_pt_regs *regs)
269 272
270 arch_examine_signal(sig, regs); 273 arch_examine_signal(sig, regs);
271 274
272 current->thread.arch.faultinfo = *UPT_FAULTINFO(regs); 275 memset(&clean_si, 0, sizeof(clean_si));
273 force_sig(sig, current); 276 clean_si.si_signo = si->si_signo;
277 clean_si.si_errno = si->si_errno;
278 clean_si.si_code = si->si_code;
279 switch (sig) {
280 case SIGILL:
281 case SIGFPE:
282 case SIGSEGV:
283 case SIGBUS:
284 case SIGTRAP:
285 fi = UPT_FAULTINFO(regs);
286 clean_si.si_addr = (void __user *) FAULT_ADDRESS(*fi);
287 current->thread.arch.faultinfo = *fi;
288#ifdef __ARCH_SI_TRAPNO
289 clean_si.si_trapno = si->si_trapno;
290#endif
291 break;
292 default:
293 printk(KERN_ERR "Attempted to relay unknown signal %d (si_code = %d)\n",
294 sig, si->si_code);
295 }
296
297 force_sig_info(sig, &clean_si, current);
274} 298}
275 299
276void bus_handler(int sig, struct uml_pt_regs *regs) 300void bus_handler(int sig, struct siginfo *si, struct uml_pt_regs *regs)
277{ 301{
278 if (current->thread.fault_catcher != NULL) 302 if (current->thread.fault_catcher != NULL)
279 UML_LONGJMP(current->thread.fault_catcher, 1); 303 UML_LONGJMP(current->thread.fault_catcher, 1);
280 else relay_signal(sig, regs); 304 else
305 relay_signal(sig, si, regs);
281} 306}
282 307
283void winch(int sig, struct uml_pt_regs *regs) 308void winch(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs)
284{ 309{
285 do_IRQ(WINCH_IRQ, regs); 310 do_IRQ(WINCH_IRQ, regs);
286} 311}
diff --git a/arch/um/os-Linux/internal.h b/arch/um/os-Linux/internal.h
index 2c3c3ecd8c0..0dc2c9f135f 100644
--- a/arch/um/os-Linux/internal.h
+++ b/arch/um/os-Linux/internal.h
@@ -1 +1 @@
void alarm_handler(int, mcontext_t *); void alarm_handler(int sig, struct siginfo *unused_si, mcontext_t *mc);
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index 2d22f1fcd8e..6366ce904b9 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
@@ -13,8 +13,9 @@
13#include "kern_util.h" 13#include "kern_util.h"
14#include "os.h" 14#include "os.h"
15#include "sysdep/mcontext.h" 15#include "sysdep/mcontext.h"
16#include "internal.h"
16 17
17void (*sig_info[NSIG])(int, struct uml_pt_regs *) = { 18void (*sig_info[NSIG])(int, siginfo_t *, struct uml_pt_regs *) = {
18 [SIGTRAP] = relay_signal, 19 [SIGTRAP] = relay_signal,
19 [SIGFPE] = relay_signal, 20 [SIGFPE] = relay_signal,
20 [SIGILL] = relay_signal, 21 [SIGILL] = relay_signal,
@@ -24,7 +25,7 @@ void (*sig_info[NSIG])(int, struct uml_pt_regs *) = {
24 [SIGIO] = sigio_handler, 25 [SIGIO] = sigio_handler,
25 [SIGVTALRM] = timer_handler }; 26 [SIGVTALRM] = timer_handler };
26 27
27static void sig_handler_common(int sig, mcontext_t *mc) 28static void sig_handler_common(int sig, siginfo_t *si, mcontext_t *mc)
28{ 29{
29 struct uml_pt_regs r; 30 struct uml_pt_regs r;
30 int save_errno = errno; 31 int save_errno = errno;
@@ -40,7 +41,7 @@ static void sig_handler_common(int sig, mcontext_t *mc)
40 if ((sig != SIGIO) && (sig != SIGWINCH) && (sig != SIGVTALRM)) 41 if ((sig != SIGIO) && (sig != SIGWINCH) && (sig != SIGVTALRM))
41 unblock_signals(); 42 unblock_signals();
42 43
43 (*sig_info[sig])(sig, &r); 44 (*sig_info[sig])(sig, si, &r);
44 45
45 errno = save_errno; 46 errno = save_errno;
46} 47}
@@ -60,7 +61,7 @@ static void sig_handler_common(int sig, mcontext_t *mc)
60static int signals_enabled; 61static int signals_enabled;
61static unsigned int signals_pending; 62static unsigned int signals_pending;
62 63
63void sig_handler(int sig, mcontext_t *mc) 64void sig_handler(int sig, siginfo_t *si, mcontext_t *mc)
64{ 65{
65 int enabled; 66 int enabled;
66 67
@@ -72,7 +73,7 @@ void sig_handler(int sig, mcontext_t *mc)
72 73
73 block_signals(); 74 block_signals();
74 75
75 sig_handler_common(sig, mc); 76 sig_handler_common(sig, si, mc);
76 77
77 set_signals(enabled); 78 set_signals(enabled);
78} 79}
@@ -85,10 +86,10 @@ static void real_alarm_handler(mcontext_t *mc)
85 get_regs_from_mc(&regs, mc); 86 get_regs_from_mc(&regs, mc);
86 regs.is_user = 0; 87 regs.is_user = 0;
87 unblock_signals(); 88 unblock_signals();
88 timer_handler(SIGVTALRM, &regs); 89 timer_handler(SIGVTALRM, NULL, &regs);
89} 90}
90 91
91void alarm_handler(int sig, mcontext_t *mc) 92void alarm_handler(int sig, struct siginfo *unused_si, mcontext_t *mc)
92{ 93{
93 int enabled; 94 int enabled;
94 95
@@ -119,7 +120,7 @@ void set_sigstack(void *sig_stack, int size)
119 panic("enabling signal stack failed, errno = %d\n", errno); 120 panic("enabling signal stack failed, errno = %d\n", errno);
120} 121}
121 122
122static void (*handlers[_NSIG])(int sig, mcontext_t *mc) = { 123static void (*handlers[_NSIG])(int sig, siginfo_t *si, mcontext_t *mc) = {
123 [SIGSEGV] = sig_handler, 124 [SIGSEGV] = sig_handler,
124 [SIGBUS] = sig_handler, 125 [SIGBUS] = sig_handler,
125 [SIGILL] = sig_handler, 126 [SIGILL] = sig_handler,
@@ -132,7 +133,7 @@ static void (*handlers[_NSIG])(int sig, mcontext_t *mc) = {
132}; 133};
133 134
134 135
135static void hard_handler(int sig, siginfo_t *info, void *p) 136static void hard_handler(int sig, siginfo_t *si, void *p)
136{ 137{
137 struct ucontext *uc = p; 138 struct ucontext *uc = p;
138 mcontext_t *mc = &uc->uc_mcontext; 139 mcontext_t *mc = &uc->uc_mcontext;
@@ -161,7 +162,7 @@ static void hard_handler(int sig, siginfo_t *info, void *p)
161 while ((sig = ffs(pending)) != 0){ 162 while ((sig = ffs(pending)) != 0){
162 sig--; 163 sig--;
163 pending &= ~(1 << sig); 164 pending &= ~(1 << sig);
164 (*handlers[sig])(sig, mc); 165 (*handlers[sig])(sig, si, mc);
165 } 166 }
166 167
167 /* 168 /*
@@ -273,9 +274,12 @@ void unblock_signals(void)
273 * Deal with SIGIO first because the alarm handler might 274 * Deal with SIGIO first because the alarm handler might
274 * schedule, leaving the pending SIGIO stranded until we come 275 * schedule, leaving the pending SIGIO stranded until we come
275 * back here. 276 * back here.
277 *
278 * SIGIO's handler doesn't use siginfo or mcontext,
279 * so they can be NULL.
276 */ 280 */
277 if (save_pending & SIGIO_MASK) 281 if (save_pending & SIGIO_MASK)
278 sig_handler_common(SIGIO, NULL); 282 sig_handler_common(SIGIO, NULL, NULL);
279 283
280 if (save_pending & SIGVTALRM_MASK) 284 if (save_pending & SIGVTALRM_MASK)
281 real_alarm_handler(NULL); 285 real_alarm_handler(NULL);
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index cd65727854e..d93bb40499f 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -346,6 +346,10 @@ void userspace(struct uml_pt_regs *regs)
346 int err, status, op, pid = userspace_pid[0]; 346 int err, status, op, pid = userspace_pid[0];
347 /* To prevent races if using_sysemu changes under us.*/ 347 /* To prevent races if using_sysemu changes under us.*/
348 int local_using_sysemu; 348 int local_using_sysemu;
349 siginfo_t si;
350
351 /* Handle any immediate reschedules or signals */
352 interrupt_end();
349 353
350 if (getitimer(ITIMER_VIRTUAL, &timer)) 354 if (getitimer(ITIMER_VIRTUAL, &timer))
351 printk(UM_KERN_ERR "Failed to get itimer, errno = %d\n", errno); 355 printk(UM_KERN_ERR "Failed to get itimer, errno = %d\n", errno);
@@ -404,13 +408,17 @@ void userspace(struct uml_pt_regs *regs)
404 408
405 if (WIFSTOPPED(status)) { 409 if (WIFSTOPPED(status)) {
406 int sig = WSTOPSIG(status); 410 int sig = WSTOPSIG(status);
411
412 ptrace(PTRACE_GETSIGINFO, pid, 0, &si);
413
407 switch (sig) { 414 switch (sig) {
408 case SIGSEGV: 415 case SIGSEGV:
409 if (PTRACE_FULL_FAULTINFO || 416 if (PTRACE_FULL_FAULTINFO ||
410 !ptrace_faultinfo) { 417 !ptrace_faultinfo) {
411 get_skas_faultinfo(pid, 418 get_skas_faultinfo(pid,
412 &regs->faultinfo); 419 &regs->faultinfo);
413 (*sig_info[SIGSEGV])(SIGSEGV, regs); 420 (*sig_info[SIGSEGV])(SIGSEGV, &si,
421 regs);
414 } 422 }
415 else handle_segv(pid, regs); 423 else handle_segv(pid, regs);
416 break; 424 break;
@@ -418,14 +426,14 @@ void userspace(struct uml_pt_regs *regs)
418 handle_trap(pid, regs, local_using_sysemu); 426 handle_trap(pid, regs, local_using_sysemu);
419 break; 427 break;
420 case SIGTRAP: 428 case SIGTRAP:
421 relay_signal(SIGTRAP, regs); 429 relay_signal(SIGTRAP, &si, regs);
422 break; 430 break;
423 case SIGVTALRM: 431 case SIGVTALRM:
424 now = os_nsecs(); 432 now = os_nsecs();
425 if (now < nsecs) 433 if (now < nsecs)
426 break; 434 break;
427 block_signals(); 435 block_signals();
428 (*sig_info[sig])(sig, regs); 436 (*sig_info[sig])(sig, &si, regs);
429 unblock_signals(); 437 unblock_signals();
430 nsecs = timer.it_value.tv_sec * 438 nsecs = timer.it_value.tv_sec *
431 UM_NSEC_PER_SEC + 439 UM_NSEC_PER_SEC +
@@ -439,7 +447,7 @@ void userspace(struct uml_pt_regs *regs)
439 case SIGFPE: 447 case SIGFPE:
440 case SIGWINCH: 448 case SIGWINCH:
441 block_signals(); 449 block_signals();
442 (*sig_info[sig])(sig, regs); 450 (*sig_info[sig])(sig, &si, regs);
443 unblock_signals(); 451 unblock_signals();
444 break; 452 break;
445 default: 453 default:
diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c
index 910499d76a6..0748fe0c8a7 100644
--- a/arch/um/os-Linux/time.c
+++ b/arch/um/os-Linux/time.c
@@ -87,7 +87,7 @@ static int after_sleep_interval(struct timespec *ts)
87 87
88static void deliver_alarm(void) 88static void deliver_alarm(void)
89{ 89{
90 alarm_handler(SIGVTALRM, NULL); 90 alarm_handler(SIGVTALRM, NULL, NULL);
91} 91}
92 92
93static unsigned long long sleep_time(unsigned long long nsecs) 93static unsigned long long sleep_time(unsigned long long nsecs)
@@ -114,7 +114,7 @@ static void deliver_alarm(void)
114 skew += this_tick - last_tick; 114 skew += this_tick - last_tick;
115 115
116 while (skew >= one_tick) { 116 while (skew >= one_tick) {
117 alarm_handler(SIGVTALRM, NULL); 117 alarm_handler(SIGVTALRM, NULL, NULL);
118 skew -= one_tick; 118 skew -= one_tick;
119 } 119 }
120 120
diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig
index 03c9ff808b5..b0a47433341 100644
--- a/arch/unicore32/Kconfig
+++ b/arch/unicore32/Kconfig
@@ -238,7 +238,6 @@ config I2C_BATTERY_BQ27200
238config I2C_EEPROM_AT24 238config I2C_EEPROM_AT24
239 tristate "I2C EEPROMs AT24 support" 239 tristate "I2C EEPROMs AT24 support"
240 select I2C_PUV3 240 select I2C_PUV3
241 select MISC_DEVICES
242 select EEPROM_AT24 241 select EEPROM_AT24
243 242
244config LCD_BACKLIGHT 243config LCD_BACKLIGHT
diff --git a/arch/unicore32/kernel/pci.c b/arch/unicore32/kernel/pci.c
index 2fc2b1ba825..46cb6c9de6c 100644
--- a/arch/unicore32/kernel/pci.c
+++ b/arch/unicore32/kernel/pci.c
@@ -296,7 +296,7 @@ static int __init pci_common_init(void)
296} 296}
297subsys_initcall(pci_common_init); 297subsys_initcall(pci_common_init);
298 298
299char * __devinit pcibios_setup(char *str) 299char * __init pcibios_setup(char *str)
300{ 300{
301 if (!strcmp(str, "debug")) { 301 if (!strcmp(str, "debug")) {
302 debug_pci = 1; 302 debug_pci = 1;
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index c70684f859e..8ec3a1aa4ab 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -70,6 +70,7 @@ config X86
70 select HAVE_ARCH_JUMP_LABEL 70 select HAVE_ARCH_JUMP_LABEL
71 select HAVE_TEXT_POKE_SMP 71 select HAVE_TEXT_POKE_SMP
72 select HAVE_GENERIC_HARDIRQS 72 select HAVE_GENERIC_HARDIRQS
73 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
73 select SPARSE_IRQ 74 select SPARSE_IRQ
74 select GENERIC_FIND_FIRST_BIT 75 select GENERIC_FIND_FIRST_BIT
75 select GENERIC_IRQ_PROBE 76 select GENERIC_IRQ_PROBE
@@ -84,6 +85,7 @@ config X86
84 select GENERIC_IOMAP 85 select GENERIC_IOMAP
85 select DCACHE_WORD_ACCESS 86 select DCACHE_WORD_ACCESS
86 select GENERIC_SMP_IDLE_THREAD 87 select GENERIC_SMP_IDLE_THREAD
88 select ARCH_WANT_IPC_PARSE_VERSION if X86_32
87 select HAVE_ARCH_SECCOMP_FILTER 89 select HAVE_ARCH_SECCOMP_FILTER
88 select BUILDTIME_EXTABLE_SORT 90 select BUILDTIME_EXTABLE_SORT
89 select GENERIC_CMOS_UPDATE 91 select GENERIC_CMOS_UPDATE
@@ -1525,7 +1527,7 @@ config SECCOMP
1525 If unsure, say Y. Only embedded should say N here. 1527 If unsure, say Y. Only embedded should say N here.
1526 1528
1527config CC_STACKPROTECTOR 1529config CC_STACKPROTECTOR
1528 bool "Enable -fstack-protector buffer overflow detection (EXPERIMENTAL)" 1530 bool "Enable -fstack-protector buffer overflow detection"
1529 ---help--- 1531 ---help---
1530 This option turns on the -fstack-protector GCC feature. This 1532 This option turns on the -fstack-protector GCC feature. This
1531 feature puts, at the beginning of functions, a canary value on 1533 feature puts, at the beginning of functions, a canary value on
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index e46c2147397..b322f124ee3 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -129,6 +129,25 @@ config DOUBLEFAULT
129 option saves about 4k and might cause you much additional grey 129 option saves about 4k and might cause you much additional grey
130 hair. 130 hair.
131 131
132config DEBUG_TLBFLUSH
133 bool "Set upper limit of TLB entries to flush one-by-one"
134 depends on DEBUG_KERNEL && (X86_64 || X86_INVLPG)
135 ---help---
136
137 X86-only for now.
138
139 This option allows the user to tune the amount of TLB entries the
140 kernel flushes one-by-one instead of doing a full TLB flush. In
141 certain situations, the former is cheaper. This is controlled by the
142 tlb_flushall_shift knob under /sys/kernel/debug/x86. If you set it
143 to -1, the code flushes the whole TLB unconditionally. Otherwise,
144 for positive values of it, the kernel will use single TLB entry
145 invalidating instructions according to the following formula:
146
147 flush_entries <= active_tlb_entries / 2^tlb_flushall_shift
148
149 If in doubt, say "N".
150
132config IOMMU_DEBUG 151config IOMMU_DEBUG
133 bool "Enable IOMMU debugging" 152 bool "Enable IOMMU debugging"
134 depends on GART_IOMMU && DEBUG_KERNEL 153 depends on GART_IOMMU && DEBUG_KERNEL
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 1f252143455..682e9c210ba 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -27,6 +27,10 @@ ifeq ($(CONFIG_X86_32),y)
27 27
28 KBUILD_CFLAGS += -msoft-float -mregparm=3 -freg-struct-return 28 KBUILD_CFLAGS += -msoft-float -mregparm=3 -freg-struct-return
29 29
30 # Never want PIC in a 32-bit kernel, prevent breakage with GCC built
31 # with nonstandard options
32 KBUILD_CFLAGS += -fno-pic
33
30 # prevent gcc from keeping the stack 16 byte aligned 34 # prevent gcc from keeping the stack 16 byte aligned
31 KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2) 35 KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2)
32 36
@@ -49,6 +53,9 @@ else
49 KBUILD_AFLAGS += -m64 53 KBUILD_AFLAGS += -m64
50 KBUILD_CFLAGS += -m64 54 KBUILD_CFLAGS += -m64
51 55
56 # Use -mpreferred-stack-boundary=3 if supported.
57 KBUILD_CFLAGS += $(call cc-option,-mno-sse -mpreferred-stack-boundary=3)
58
52 # FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu) 59 # FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
53 cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8) 60 cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
54 cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona) 61 cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
index 5a747dd884d..f7535bedc33 100644
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -57,7 +57,7 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
57 -Wall -Wstrict-prototypes \ 57 -Wall -Wstrict-prototypes \
58 -march=i386 -mregparm=3 \ 58 -march=i386 -mregparm=3 \
59 -include $(srctree)/$(src)/code16gcc.h \ 59 -include $(srctree)/$(src)/code16gcc.h \
60 -fno-strict-aliasing -fomit-frame-pointer \ 60 -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
61 $(call cc-option, -ffreestanding) \ 61 $(call cc-option, -ffreestanding) \
62 $(call cc-option, -fno-toplevel-reorder,\ 62 $(call cc-option, -fno-toplevel-reorder,\
63 $(call cc-option, -fno-unit-at-a-time)) \ 63 $(call cc-option, -fno-unit-at-a-time)) \
diff --git a/arch/x86/boot/compressed/cmdline.c b/arch/x86/boot/compressed/cmdline.c
index cb62f786990..10f6b1178c6 100644
--- a/arch/x86/boot/compressed/cmdline.c
+++ b/arch/x86/boot/compressed/cmdline.c
@@ -1,5 +1,7 @@
1#include "misc.h" 1#include "misc.h"
2 2
3#ifdef CONFIG_EARLY_PRINTK
4
3static unsigned long fs; 5static unsigned long fs;
4static inline void set_fs(unsigned long seg) 6static inline void set_fs(unsigned long seg)
5{ 7{
@@ -19,3 +21,5 @@ int cmdline_find_option_bool(const char *option)
19{ 21{
20 return __cmdline_find_option_bool(real_mode->hdr.cmd_line_ptr, option); 22 return __cmdline_find_option_bool(real_mode->hdr.cmd_line_ptr, option);
21} 23}
24
25#endif
diff --git a/arch/x86/boot/compressed/early_serial_console.c b/arch/x86/boot/compressed/early_serial_console.c
index 261e81fb958..d3d003cb548 100644
--- a/arch/x86/boot/compressed/early_serial_console.c
+++ b/arch/x86/boot/compressed/early_serial_console.c
@@ -1,5 +1,9 @@
1#include "misc.h" 1#include "misc.h"
2 2
3#ifdef CONFIG_EARLY_PRINTK
4
3int early_serial_base; 5int early_serial_base;
4 6
5#include "../early_serial_console.c" 7#include "../early_serial_console.c"
8
9#endif
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index 4e85f5f8583..b3e0227df2c 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -729,32 +729,68 @@ fail:
729 * need to create one ourselves (usually the bootloader would create 729 * need to create one ourselves (usually the bootloader would create
730 * one for us). 730 * one for us).
731 */ 731 */
732static efi_status_t make_boot_params(struct boot_params *boot_params, 732struct boot_params *make_boot_params(void *handle, efi_system_table_t *_table)
733 efi_loaded_image_t *image,
734 void *handle)
735{ 733{
736 struct efi_info *efi = &boot_params->efi_info; 734 struct boot_params *boot_params;
737 struct apm_bios_info *bi = &boot_params->apm_bios_info; 735 struct sys_desc_table *sdt;
738 struct sys_desc_table *sdt = &boot_params->sys_desc_table; 736 struct apm_bios_info *bi;
739 struct e820entry *e820_map = &boot_params->e820_map[0]; 737 struct setup_header *hdr;
740 struct e820entry *prev = NULL; 738 struct efi_info *efi;
741 struct setup_header *hdr = &boot_params->hdr; 739 efi_loaded_image_t *image;
742 unsigned long size, key, desc_size, _size; 740 void *options;
743 efi_memory_desc_t *mem_map; 741 u32 load_options_size;
744 void *options = image->load_options; 742 efi_guid_t proto = LOADED_IMAGE_PROTOCOL_GUID;
745 u32 load_options_size = image->load_options_size / 2; /* ASCII */
746 int options_size = 0; 743 int options_size = 0;
747 efi_status_t status; 744 efi_status_t status;
748 __u32 desc_version;
749 unsigned long cmdline; 745 unsigned long cmdline;
750 u8 nr_entries;
751 u16 *s2; 746 u16 *s2;
752 u8 *s1; 747 u8 *s1;
753 int i; 748 int i;
754 749
750 sys_table = _table;
751
752 /* Check if we were booted by the EFI firmware */
753 if (sys_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE)
754 return NULL;
755
756 status = efi_call_phys3(sys_table->boottime->handle_protocol,
757 handle, &proto, (void *)&image);
758 if (status != EFI_SUCCESS) {
759 efi_printk("Failed to get handle for LOADED_IMAGE_PROTOCOL\n");
760 return NULL;
761 }
762
763 status = low_alloc(0x4000, 1, (unsigned long *)&boot_params);
764 if (status != EFI_SUCCESS) {
765 efi_printk("Failed to alloc lowmem for boot params\n");
766 return NULL;
767 }
768
769 memset(boot_params, 0x0, 0x4000);
770
771 hdr = &boot_params->hdr;
772 efi = &boot_params->efi_info;
773 bi = &boot_params->apm_bios_info;
774 sdt = &boot_params->sys_desc_table;
775
776 /* Copy the second sector to boot_params */
777 memcpy(&hdr->jump, image->image_base + 512, 512);
778
779 /*
780 * Fill out some of the header fields ourselves because the
781 * EFI firmware loader doesn't load the first sector.
782 */
783 hdr->root_flags = 1;
784 hdr->vid_mode = 0xffff;
785 hdr->boot_flag = 0xAA55;
786
787 hdr->code32_start = (__u64)(unsigned long)image->image_base;
788
755 hdr->type_of_loader = 0x21; 789 hdr->type_of_loader = 0x21;
756 790
757 /* Convert unicode cmdline to ascii */ 791 /* Convert unicode cmdline to ascii */
792 options = image->load_options;
793 load_options_size = image->load_options_size / 2; /* ASCII */
758 cmdline = 0; 794 cmdline = 0;
759 s2 = (u16 *)options; 795 s2 = (u16 *)options;
760 796
@@ -791,18 +827,36 @@ static efi_status_t make_boot_params(struct boot_params *boot_params,
791 hdr->ramdisk_image = 0; 827 hdr->ramdisk_image = 0;
792 hdr->ramdisk_size = 0; 828 hdr->ramdisk_size = 0;
793 829
794 status = handle_ramdisks(image, hdr);
795 if (status != EFI_SUCCESS)
796 goto free_cmdline;
797
798 setup_graphics(boot_params);
799
800 /* Clear APM BIOS info */ 830 /* Clear APM BIOS info */
801 memset(bi, 0, sizeof(*bi)); 831 memset(bi, 0, sizeof(*bi));
802 832
803 memset(sdt, 0, sizeof(*sdt)); 833 memset(sdt, 0, sizeof(*sdt));
804 834
805 memcpy(&efi->efi_loader_signature, EFI_LOADER_SIGNATURE, sizeof(__u32)); 835 status = handle_ramdisks(image, hdr);
836 if (status != EFI_SUCCESS)
837 goto fail2;
838
839 return boot_params;
840fail2:
841 if (options_size)
842 low_free(options_size, hdr->cmd_line_ptr);
843fail:
844 low_free(0x4000, (unsigned long)boot_params);
845 return NULL;
846}
847
848static efi_status_t exit_boot(struct boot_params *boot_params,
849 void *handle)
850{
851 struct efi_info *efi = &boot_params->efi_info;
852 struct e820entry *e820_map = &boot_params->e820_map[0];
853 struct e820entry *prev = NULL;
854 unsigned long size, key, desc_size, _size;
855 efi_memory_desc_t *mem_map;
856 efi_status_t status;
857 __u32 desc_version;
858 u8 nr_entries;
859 int i;
806 860
807 size = sizeof(*mem_map) * 32; 861 size = sizeof(*mem_map) * 32;
808 862
@@ -811,7 +865,7 @@ again:
811 _size = size; 865 _size = size;
812 status = low_alloc(size, 1, (unsigned long *)&mem_map); 866 status = low_alloc(size, 1, (unsigned long *)&mem_map);
813 if (status != EFI_SUCCESS) 867 if (status != EFI_SUCCESS)
814 goto free_cmdline; 868 return status;
815 869
816 status = efi_call_phys5(sys_table->boottime->get_memory_map, &size, 870 status = efi_call_phys5(sys_table->boottime->get_memory_map, &size,
817 mem_map, &key, &desc_size, &desc_version); 871 mem_map, &key, &desc_size, &desc_version);
@@ -823,6 +877,7 @@ again:
823 if (status != EFI_SUCCESS) 877 if (status != EFI_SUCCESS)
824 goto free_mem_map; 878 goto free_mem_map;
825 879
880 memcpy(&efi->efi_loader_signature, EFI_LOADER_SIGNATURE, sizeof(__u32));
826 efi->efi_systab = (unsigned long)sys_table; 881 efi->efi_systab = (unsigned long)sys_table;
827 efi->efi_memdesc_size = desc_size; 882 efi->efi_memdesc_size = desc_size;
828 efi->efi_memdesc_version = desc_version; 883 efi->efi_memdesc_version = desc_version;
@@ -906,61 +961,13 @@ again:
906 961
907free_mem_map: 962free_mem_map:
908 low_free(_size, (unsigned long)mem_map); 963 low_free(_size, (unsigned long)mem_map);
909free_cmdline:
910 if (options_size)
911 low_free(options_size, hdr->cmd_line_ptr);
912fail:
913 return status; 964 return status;
914} 965}
915 966
916/* 967static efi_status_t relocate_kernel(struct setup_header *hdr)
917 * On success we return a pointer to a boot_params structure, and NULL
918 * on failure.
919 */
920struct boot_params *efi_main(void *handle, efi_system_table_t *_table)
921{ 968{
922 struct boot_params *boot_params;
923 unsigned long start, nr_pages; 969 unsigned long start, nr_pages;
924 struct desc_ptr *gdt, *idt;
925 efi_loaded_image_t *image;
926 struct setup_header *hdr;
927 efi_status_t status; 970 efi_status_t status;
928 efi_guid_t proto = LOADED_IMAGE_PROTOCOL_GUID;
929 struct desc_struct *desc;
930
931 sys_table = _table;
932
933 /* Check if we were booted by the EFI firmware */
934 if (sys_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE)
935 goto fail;
936
937 status = efi_call_phys3(sys_table->boottime->handle_protocol,
938 handle, &proto, (void *)&image);
939 if (status != EFI_SUCCESS) {
940 efi_printk("Failed to get handle for LOADED_IMAGE_PROTOCOL\n");
941 goto fail;
942 }
943
944 status = low_alloc(0x4000, 1, (unsigned long *)&boot_params);
945 if (status != EFI_SUCCESS) {
946 efi_printk("Failed to alloc lowmem for boot params\n");
947 goto fail;
948 }
949
950 memset(boot_params, 0x0, 0x4000);
951
952 hdr = &boot_params->hdr;
953
954 /* Copy the second sector to boot_params */
955 memcpy(&hdr->jump, image->image_base + 512, 512);
956
957 /*
958 * Fill out some of the header fields ourselves because the
959 * EFI firmware loader doesn't load the first sector.
960 */
961 hdr->root_flags = 1;
962 hdr->vid_mode = 0xffff;
963 hdr->boot_flag = 0xAA55;
964 971
965 /* 972 /*
966 * The EFI firmware loader could have placed the kernel image 973 * The EFI firmware loader could have placed the kernel image
@@ -978,16 +985,40 @@ struct boot_params *efi_main(void *handle, efi_system_table_t *_table)
978 if (status != EFI_SUCCESS) { 985 if (status != EFI_SUCCESS) {
979 status = low_alloc(hdr->init_size, hdr->kernel_alignment, 986 status = low_alloc(hdr->init_size, hdr->kernel_alignment,
980 &start); 987 &start);
981 if (status != EFI_SUCCESS) { 988 if (status != EFI_SUCCESS)
982 efi_printk("Failed to alloc mem for kernel\n"); 989 efi_printk("Failed to alloc mem for kernel\n");
983 goto fail;
984 }
985 } 990 }
986 991
992 if (status == EFI_SUCCESS)
993 memcpy((void *)start, (void *)(unsigned long)hdr->code32_start,
994 hdr->init_size);
995
996 hdr->pref_address = hdr->code32_start;
987 hdr->code32_start = (__u32)start; 997 hdr->code32_start = (__u32)start;
988 hdr->pref_address = (__u64)(unsigned long)image->image_base;
989 998
990 memcpy((void *)start, image->image_base, image->image_size); 999 return status;
1000}
1001
1002/*
1003 * On success we return a pointer to a boot_params structure, and NULL
1004 * on failure.
1005 */
1006struct boot_params *efi_main(void *handle, efi_system_table_t *_table,
1007 struct boot_params *boot_params)
1008{
1009 struct desc_ptr *gdt, *idt;
1010 efi_loaded_image_t *image;
1011 struct setup_header *hdr = &boot_params->hdr;
1012 efi_status_t status;
1013 struct desc_struct *desc;
1014
1015 sys_table = _table;
1016
1017 /* Check if we were booted by the EFI firmware */
1018 if (sys_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE)
1019 goto fail;
1020
1021 setup_graphics(boot_params);
991 1022
992 status = efi_call_phys3(sys_table->boottime->allocate_pool, 1023 status = efi_call_phys3(sys_table->boottime->allocate_pool,
993 EFI_LOADER_DATA, sizeof(*gdt), 1024 EFI_LOADER_DATA, sizeof(*gdt),
@@ -1015,7 +1046,18 @@ struct boot_params *efi_main(void *handle, efi_system_table_t *_table)
1015 idt->size = 0; 1046 idt->size = 0;
1016 idt->address = 0; 1047 idt->address = 0;
1017 1048
1018 status = make_boot_params(boot_params, image, handle); 1049 /*
1050 * If the kernel isn't already loaded at the preferred load
1051 * address, relocate it.
1052 */
1053 if (hdr->pref_address != hdr->code32_start) {
1054 status = relocate_kernel(hdr);
1055
1056 if (status != EFI_SUCCESS)
1057 goto fail;
1058 }
1059
1060 status = exit_boot(boot_params, handle);
1019 if (status != EFI_SUCCESS) 1061 if (status != EFI_SUCCESS)
1020 goto fail; 1062 goto fail;
1021 1063
diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
index c85e3ac99bb..aa4aaf1b238 100644
--- a/arch/x86/boot/compressed/head_32.S
+++ b/arch/x86/boot/compressed/head_32.S
@@ -42,6 +42,16 @@ ENTRY(startup_32)
42 */ 42 */
43 add $0x4, %esp 43 add $0x4, %esp
44 44
45 call make_boot_params
46 cmpl $0, %eax
47 je 1f
48 movl 0x4(%esp), %esi
49 movl (%esp), %ecx
50 pushl %eax
51 pushl %esi
52 pushl %ecx
53
54 .org 0x30,0x90
45 call efi_main 55 call efi_main
46 cmpl $0, %eax 56 cmpl $0, %eax
47 movl %eax, %esi 57 movl %eax, %esi
diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index 87e03a13d8e..2c4b171eec3 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -209,6 +209,16 @@ ENTRY(startup_64)
209 .org 0x210 209 .org 0x210
210 mov %rcx, %rdi 210 mov %rcx, %rdi
211 mov %rdx, %rsi 211 mov %rdx, %rsi
212 pushq %rdi
213 pushq %rsi
214 call make_boot_params
215 cmpq $0,%rax
216 je 1f
217 mov %rax, %rdx
218 popq %rsi
219 popq %rdi
220
221 .org 0x230,0x90
212 call efi_main 222 call efi_main
213 movq %rax,%rsi 223 movq %rax,%rsi
214 cmpq $0,%rax 224 cmpq $0,%rax
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 7116dcba0c9..88f7ff6da40 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -108,8 +108,6 @@ static void error(char *m);
108 * This is set up by the setup-routine at boot-time 108 * This is set up by the setup-routine at boot-time
109 */ 109 */
110struct boot_params *real_mode; /* Pointer to real-mode data */ 110struct boot_params *real_mode; /* Pointer to real-mode data */
111static int quiet;
112static int debug;
113 111
114void *memset(void *s, int c, size_t n); 112void *memset(void *s, int c, size_t n);
115void *memcpy(void *dest, const void *src, size_t n); 113void *memcpy(void *dest, const void *src, size_t n);
@@ -170,15 +168,11 @@ static void serial_putchar(int ch)
170 outb(ch, early_serial_base + TXR); 168 outb(ch, early_serial_base + TXR);
171} 169}
172 170
173void __putstr(int error, const char *s) 171void __putstr(const char *s)
174{ 172{
175 int x, y, pos; 173 int x, y, pos;
176 char c; 174 char c;
177 175
178#ifndef CONFIG_X86_VERBOSE_BOOTUP
179 if (!error)
180 return;
181#endif
182 if (early_serial_base) { 176 if (early_serial_base) {
183 const char *str = s; 177 const char *str = s;
184 while (*str) { 178 while (*str) {
@@ -265,9 +259,9 @@ void *memcpy(void *dest, const void *src, size_t n)
265 259
266static void error(char *x) 260static void error(char *x)
267{ 261{
268 __putstr(1, "\n\n"); 262 error_putstr("\n\n");
269 __putstr(1, x); 263 error_putstr(x);
270 __putstr(1, "\n\n -- System halted"); 264 error_putstr("\n\n -- System halted");
271 265
272 while (1) 266 while (1)
273 asm("hlt"); 267 asm("hlt");
@@ -294,8 +288,7 @@ static void parse_elf(void *output)
294 return; 288 return;
295 } 289 }
296 290
297 if (!quiet) 291 debug_putstr("Parsing ELF... ");
298 putstr("Parsing ELF... ");
299 292
300 phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum); 293 phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum);
301 if (!phdrs) 294 if (!phdrs)
@@ -332,11 +325,6 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
332{ 325{
333 real_mode = rmode; 326 real_mode = rmode;
334 327
335 if (cmdline_find_option_bool("quiet"))
336 quiet = 1;
337 if (cmdline_find_option_bool("debug"))
338 debug = 1;
339
340 if (real_mode->screen_info.orig_video_mode == 7) { 328 if (real_mode->screen_info.orig_video_mode == 7) {
341 vidmem = (char *) 0xb0000; 329 vidmem = (char *) 0xb0000;
342 vidport = 0x3b4; 330 vidport = 0x3b4;
@@ -349,8 +337,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
349 cols = real_mode->screen_info.orig_video_cols; 337 cols = real_mode->screen_info.orig_video_cols;
350 338
351 console_init(); 339 console_init();
352 if (debug) 340 debug_putstr("early console in decompress_kernel\n");
353 putstr("early console in decompress_kernel\n");
354 341
355 free_mem_ptr = heap; /* Heap */ 342 free_mem_ptr = heap; /* Heap */
356 free_mem_end_ptr = heap + BOOT_HEAP_SIZE; 343 free_mem_end_ptr = heap + BOOT_HEAP_SIZE;
@@ -369,11 +356,9 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
369 error("Wrong destination address"); 356 error("Wrong destination address");
370#endif 357#endif
371 358
372 if (!quiet) 359 debug_putstr("\nDecompressing Linux... ");
373 putstr("\nDecompressing Linux... ");
374 decompress(input_data, input_len, NULL, NULL, output, NULL, error); 360 decompress(input_data, input_len, NULL, NULL, output, NULL, error);
375 parse_elf(output); 361 parse_elf(output);
376 if (!quiet) 362 debug_putstr("done.\nBooting the kernel.\n");
377 putstr("done.\nBooting the kernel.\n");
378 return; 363 return;
379} 364}
diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
index 3f19c81a620..0e6dc0ee0ee 100644
--- a/arch/x86/boot/compressed/misc.h
+++ b/arch/x86/boot/compressed/misc.h
@@ -24,9 +24,21 @@
24 24
25/* misc.c */ 25/* misc.c */
26extern struct boot_params *real_mode; /* Pointer to real-mode data */ 26extern struct boot_params *real_mode; /* Pointer to real-mode data */
27void __putstr(int error, const char *s); 27void __putstr(const char *s);
28#define putstr(__x) __putstr(0, __x) 28#define error_putstr(__x) __putstr(__x)
29#define puts(__x) __putstr(0, __x) 29
30#ifdef CONFIG_X86_VERBOSE_BOOTUP
31
32#define debug_putstr(__x) __putstr(__x)
33
34#else
35
36static inline void debug_putstr(const char *s)
37{ }
38
39#endif
40
41#ifdef CONFIG_EARLY_PRINTK
30 42
31/* cmdline.c */ 43/* cmdline.c */
32int cmdline_find_option(const char *option, char *buffer, int bufsize); 44int cmdline_find_option(const char *option, char *buffer, int bufsize);
@@ -36,4 +48,13 @@ int cmdline_find_option_bool(const char *option);
36extern int early_serial_base; 48extern int early_serial_base;
37void console_init(void); 49void console_init(void);
38 50
51#else
52
53/* early_serial_console.c */
54static const int early_serial_base;
55static inline void console_init(void)
56{ }
57
58#endif
59
39#endif 60#endif
diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index efe5acfc79c..b4e15dd6786 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -283,7 +283,7 @@ _start:
283 # Part 2 of the header, from the old setup.S 283 # Part 2 of the header, from the old setup.S
284 284
285 .ascii "HdrS" # header signature 285 .ascii "HdrS" # header signature
286 .word 0x020a # header version number (>= 0x0105) 286 .word 0x020b # header version number (>= 0x0105)
287 # or else old loadlin-1.5 will fail) 287 # or else old loadlin-1.5 will fail)
288 .globl realmode_swtch 288 .globl realmode_swtch
289realmode_swtch: .word 0, 0 # default_switch, SETUPSEG 289realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
@@ -401,18 +401,13 @@ pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
401#define INIT_SIZE VO_INIT_SIZE 401#define INIT_SIZE VO_INIT_SIZE
402#endif 402#endif
403init_size: .long INIT_SIZE # kernel initialization size 403init_size: .long INIT_SIZE # kernel initialization size
404handover_offset: .long 0x30 # offset to the handover
405 # protocol entry point
404 406
405# End of setup header ##################################################### 407# End of setup header #####################################################
406 408
407 .section ".entrytext", "ax" 409 .section ".entrytext", "ax"
408start_of_setup: 410start_of_setup:
409#ifdef SAFE_RESET_DISK_CONTROLLER
410# Reset the disk controller.
411 movw $0x0000, %ax # Reset disk controller
412 movb $0x80, %dl # All disks
413 int $0x13
414#endif
415
416# Force %es = %ds 411# Force %es = %ds
417 movw %ds, %ax 412 movw %ds, %ax
418 movw %ax, %es 413 movw %ax, %es
diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile
index e191ac048b5..e908e5de82d 100644
--- a/arch/x86/crypto/Makefile
+++ b/arch/x86/crypto/Makefile
@@ -2,6 +2,9 @@
2# Arch-specific CryptoAPI modules. 2# Arch-specific CryptoAPI modules.
3# 3#
4 4
5obj-$(CONFIG_CRYPTO_ABLK_HELPER_X86) += ablk_helper.o
6obj-$(CONFIG_CRYPTO_GLUE_HELPER_X86) += glue_helper.o
7
5obj-$(CONFIG_CRYPTO_AES_586) += aes-i586.o 8obj-$(CONFIG_CRYPTO_AES_586) += aes-i586.o
6obj-$(CONFIG_CRYPTO_TWOFISH_586) += twofish-i586.o 9obj-$(CONFIG_CRYPTO_TWOFISH_586) += twofish-i586.o
7obj-$(CONFIG_CRYPTO_SALSA20_586) += salsa20-i586.o 10obj-$(CONFIG_CRYPTO_SALSA20_586) += salsa20-i586.o
@@ -12,8 +15,10 @@ obj-$(CONFIG_CRYPTO_CAMELLIA_X86_64) += camellia-x86_64.o
12obj-$(CONFIG_CRYPTO_BLOWFISH_X86_64) += blowfish-x86_64.o 15obj-$(CONFIG_CRYPTO_BLOWFISH_X86_64) += blowfish-x86_64.o
13obj-$(CONFIG_CRYPTO_TWOFISH_X86_64) += twofish-x86_64.o 16obj-$(CONFIG_CRYPTO_TWOFISH_X86_64) += twofish-x86_64.o
14obj-$(CONFIG_CRYPTO_TWOFISH_X86_64_3WAY) += twofish-x86_64-3way.o 17obj-$(CONFIG_CRYPTO_TWOFISH_X86_64_3WAY) += twofish-x86_64-3way.o
18obj-$(CONFIG_CRYPTO_TWOFISH_AVX_X86_64) += twofish-avx-x86_64.o
15obj-$(CONFIG_CRYPTO_SALSA20_X86_64) += salsa20-x86_64.o 19obj-$(CONFIG_CRYPTO_SALSA20_X86_64) += salsa20-x86_64.o
16obj-$(CONFIG_CRYPTO_SERPENT_SSE2_X86_64) += serpent-sse2-x86_64.o 20obj-$(CONFIG_CRYPTO_SERPENT_SSE2_X86_64) += serpent-sse2-x86_64.o
21obj-$(CONFIG_CRYPTO_SERPENT_AVX_X86_64) += serpent-avx-x86_64.o
17obj-$(CONFIG_CRYPTO_AES_NI_INTEL) += aesni-intel.o 22obj-$(CONFIG_CRYPTO_AES_NI_INTEL) += aesni-intel.o
18obj-$(CONFIG_CRYPTO_GHASH_CLMUL_NI_INTEL) += ghash-clmulni-intel.o 23obj-$(CONFIG_CRYPTO_GHASH_CLMUL_NI_INTEL) += ghash-clmulni-intel.o
19 24
@@ -30,16 +35,11 @@ camellia-x86_64-y := camellia-x86_64-asm_64.o camellia_glue.o
30blowfish-x86_64-y := blowfish-x86_64-asm_64.o blowfish_glue.o 35blowfish-x86_64-y := blowfish-x86_64-asm_64.o blowfish_glue.o
31twofish-x86_64-y := twofish-x86_64-asm_64.o twofish_glue.o 36twofish-x86_64-y := twofish-x86_64-asm_64.o twofish_glue.o
32twofish-x86_64-3way-y := twofish-x86_64-asm_64-3way.o twofish_glue_3way.o 37twofish-x86_64-3way-y := twofish-x86_64-asm_64-3way.o twofish_glue_3way.o
38twofish-avx-x86_64-y := twofish-avx-x86_64-asm_64.o twofish_avx_glue.o
33salsa20-x86_64-y := salsa20-x86_64-asm_64.o salsa20_glue.o 39salsa20-x86_64-y := salsa20-x86_64-asm_64.o salsa20_glue.o
34serpent-sse2-x86_64-y := serpent-sse2-x86_64-asm_64.o serpent_sse2_glue.o 40serpent-sse2-x86_64-y := serpent-sse2-x86_64-asm_64.o serpent_sse2_glue.o
41serpent-avx-x86_64-y := serpent-avx-x86_64-asm_64.o serpent_avx_glue.o
35 42
36aesni-intel-y := aesni-intel_asm.o aesni-intel_glue.o fpu.o 43aesni-intel-y := aesni-intel_asm.o aesni-intel_glue.o fpu.o
37
38ghash-clmulni-intel-y := ghash-clmulni-intel_asm.o ghash-clmulni-intel_glue.o 44ghash-clmulni-intel-y := ghash-clmulni-intel_asm.o ghash-clmulni-intel_glue.o
39
40# enable AVX support only when $(AS) can actually assemble the instructions
41ifeq ($(call as-instr,vpxor %xmm0$(comma)%xmm1$(comma)%xmm2,yes,no),yes)
42AFLAGS_sha1_ssse3_asm.o += -DSHA1_ENABLE_AVX_SUPPORT
43CFLAGS_sha1_ssse3_glue.o += -DSHA1_ENABLE_AVX_SUPPORT
44endif
45sha1-ssse3-y := sha1_ssse3_asm.o sha1_ssse3_glue.o 45sha1-ssse3-y := sha1_ssse3_asm.o sha1_ssse3_glue.o
diff --git a/arch/x86/crypto/ablk_helper.c b/arch/x86/crypto/ablk_helper.c
new file mode 100644
index 00000000000..43282fe04a8
--- /dev/null
+++ b/arch/x86/crypto/ablk_helper.c
@@ -0,0 +1,149 @@
1/*
2 * Shared async block cipher helpers
3 *
4 * Copyright (c) 2012 Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
5 *
6 * Based on aesni-intel_glue.c by:
7 * Copyright (C) 2008, Intel Corp.
8 * Author: Huang Ying <ying.huang@intel.com>
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 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
25 */
26
27#include <linux/kernel.h>
28#include <linux/crypto.h>
29#include <linux/init.h>
30#include <linux/module.h>
31#include <crypto/algapi.h>
32#include <crypto/cryptd.h>
33#include <asm/i387.h>
34#include <asm/crypto/ablk_helper.h>
35
36int ablk_set_key(struct crypto_ablkcipher *tfm, const u8 *key,
37 unsigned int key_len)
38{
39 struct async_helper_ctx *ctx = crypto_ablkcipher_ctx(tfm);
40 struct crypto_ablkcipher *child = &ctx->cryptd_tfm->base;
41 int err;
42
43 crypto_ablkcipher_clear_flags(child, CRYPTO_TFM_REQ_MASK);
44 crypto_ablkcipher_set_flags(child, crypto_ablkcipher_get_flags(tfm)
45 & CRYPTO_TFM_REQ_MASK);
46 err = crypto_ablkcipher_setkey(child, key, key_len);
47 crypto_ablkcipher_set_flags(tfm, crypto_ablkcipher_get_flags(child)
48 & CRYPTO_TFM_RES_MASK);
49 return err;
50}
51EXPORT_SYMBOL_GPL(ablk_set_key);
52
53int __ablk_encrypt(struct ablkcipher_request *req)
54{
55 struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req);
56 struct async_helper_ctx *ctx = crypto_ablkcipher_ctx(tfm);
57 struct blkcipher_desc desc;
58
59 desc.tfm = cryptd_ablkcipher_child(ctx->cryptd_tfm);
60 desc.info = req->info;
61 desc.flags = 0;
62
63 return crypto_blkcipher_crt(desc.tfm)->encrypt(
64 &desc, req->dst, req->src, req->nbytes);
65}
66EXPORT_SYMBOL_GPL(__ablk_encrypt);
67
68int ablk_encrypt(struct ablkcipher_request *req)
69{
70 struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req);
71 struct async_helper_ctx *ctx = crypto_ablkcipher_ctx(tfm);
72
73 if (!irq_fpu_usable()) {
74 struct ablkcipher_request *cryptd_req =
75 ablkcipher_request_ctx(req);
76
77 memcpy(cryptd_req, req, sizeof(*req));
78 ablkcipher_request_set_tfm(cryptd_req, &ctx->cryptd_tfm->base);
79
80 return crypto_ablkcipher_encrypt(cryptd_req);
81 } else {
82 return __ablk_encrypt(req);
83 }
84}
85EXPORT_SYMBOL_GPL(ablk_encrypt);
86
87int ablk_decrypt(struct ablkcipher_request *req)
88{
89 struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req);
90 struct async_helper_ctx *ctx = crypto_ablkcipher_ctx(tfm);
91
92 if (!irq_fpu_usable()) {
93 struct ablkcipher_request *cryptd_req =
94 ablkcipher_request_ctx(req);
95
96 memcpy(cryptd_req, req, sizeof(*req));
97 ablkcipher_request_set_tfm(cryptd_req, &ctx->cryptd_tfm->base);
98
99 return crypto_ablkcipher_decrypt(cryptd_req);
100 } else {
101 struct blkcipher_desc desc;
102
103 desc.tfm = cryptd_ablkcipher_child(ctx->cryptd_tfm);
104 desc.info = req->info;
105 desc.flags = 0;
106
107 return crypto_blkcipher_crt(desc.tfm)->decrypt(
108 &desc, req->dst, req->src, req->nbytes);
109 }
110}
111EXPORT_SYMBOL_GPL(ablk_decrypt);
112
113void ablk_exit(struct crypto_tfm *tfm)
114{
115 struct async_helper_ctx *ctx = crypto_tfm_ctx(tfm);
116
117 cryptd_free_ablkcipher(ctx->cryptd_tfm);
118}
119EXPORT_SYMBOL_GPL(ablk_exit);
120
121int ablk_init_common(struct crypto_tfm *tfm, const char *drv_name)
122{
123 struct async_helper_ctx *ctx = crypto_tfm_ctx(tfm);
124 struct cryptd_ablkcipher *cryptd_tfm;
125
126 cryptd_tfm = cryptd_alloc_ablkcipher(drv_name, 0, 0);
127 if (IS_ERR(cryptd_tfm))
128 return PTR_ERR(cryptd_tfm);
129
130 ctx->cryptd_tfm = cryptd_tfm;
131 tfm->crt_ablkcipher.reqsize = sizeof(struct ablkcipher_request) +
132 crypto_ablkcipher_reqsize(&cryptd_tfm->base);
133
134 return 0;
135}
136EXPORT_SYMBOL_GPL(ablk_init_common);
137
138int ablk_init(struct crypto_tfm *tfm)
139{
140 char drv_name[CRYPTO_MAX_ALG_NAME];
141
142 snprintf(drv_name, sizeof(drv_name), "__driver-%s",
143 crypto_tfm_alg_driver_name(tfm));
144
145 return ablk_init_common(tfm, drv_name);
146}
147EXPORT_SYMBOL_GPL(ablk_init);
148
149MODULE_LICENSE("GPL");
diff --git a/arch/x86/crypto/aes_glue.c b/arch/x86/crypto/aes_glue.c
index 8efcf42a9d7..59b37deb8c8 100644
--- a/arch/x86/crypto/aes_glue.c
+++ b/arch/x86/crypto/aes_glue.c
@@ -5,7 +5,7 @@
5 5
6#include <linux/module.h> 6#include <linux/module.h>
7#include <crypto/aes.h> 7#include <crypto/aes.h>
8#include <asm/aes.h> 8#include <asm/crypto/aes.h>
9 9
10asmlinkage void aes_enc_blk(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in); 10asmlinkage void aes_enc_blk(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in);
11asmlinkage void aes_dec_blk(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in); 11asmlinkage void aes_dec_blk(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in);
diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
index ac7f5cd019e..34fdcff4d2c 100644
--- a/arch/x86/crypto/aesni-intel_glue.c
+++ b/arch/x86/crypto/aesni-intel_glue.c
@@ -30,7 +30,8 @@
30#include <crypto/ctr.h> 30#include <crypto/ctr.h>
31#include <asm/cpu_device_id.h> 31#include <asm/cpu_device_id.h>
32#include <asm/i387.h> 32#include <asm/i387.h>
33#include <asm/aes.h> 33#include <asm/crypto/aes.h>
34#include <asm/crypto/ablk_helper.h>
34#include <crypto/scatterwalk.h> 35#include <crypto/scatterwalk.h>
35#include <crypto/internal/aead.h> 36#include <crypto/internal/aead.h>
36#include <linux/workqueue.h> 37#include <linux/workqueue.h>
@@ -52,10 +53,6 @@
52#define HAS_XTS 53#define HAS_XTS
53#endif 54#endif
54 55
55struct async_aes_ctx {
56 struct cryptd_ablkcipher *cryptd_tfm;
57};
58
59/* This data is stored at the end of the crypto_tfm struct. 56/* This data is stored at the end of the crypto_tfm struct.
60 * It's a type of per "session" data storage location. 57 * It's a type of per "session" data storage location.
61 * This needs to be 16 byte aligned. 58 * This needs to be 16 byte aligned.
@@ -377,87 +374,6 @@ static int ctr_crypt(struct blkcipher_desc *desc,
377} 374}
378#endif 375#endif
379 376
380static int ablk_set_key(struct crypto_ablkcipher *tfm, const u8 *key,
381 unsigned int key_len)
382{
383 struct async_aes_ctx *ctx = crypto_ablkcipher_ctx(tfm);
384 struct crypto_ablkcipher *child = &ctx->cryptd_tfm->base;
385 int err;
386
387 crypto_ablkcipher_clear_flags(child, CRYPTO_TFM_REQ_MASK);
388 crypto_ablkcipher_set_flags(child, crypto_ablkcipher_get_flags(tfm)
389 & CRYPTO_TFM_REQ_MASK);
390 err = crypto_ablkcipher_setkey(child, key, key_len);
391 crypto_ablkcipher_set_flags(tfm, crypto_ablkcipher_get_flags(child)
392 & CRYPTO_TFM_RES_MASK);
393 return err;
394}
395
396static int ablk_encrypt(struct ablkcipher_request *req)
397{
398 struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req);
399 struct async_aes_ctx *ctx = crypto_ablkcipher_ctx(tfm);
400
401 if (!irq_fpu_usable()) {
402 struct ablkcipher_request *cryptd_req =
403 ablkcipher_request_ctx(req);
404 memcpy(cryptd_req, req, sizeof(*req));
405 ablkcipher_request_set_tfm(cryptd_req, &ctx->cryptd_tfm->base);
406 return crypto_ablkcipher_encrypt(cryptd_req);
407 } else {
408 struct blkcipher_desc desc;
409 desc.tfm = cryptd_ablkcipher_child(ctx->cryptd_tfm);
410 desc.info = req->info;
411 desc.flags = 0;
412 return crypto_blkcipher_crt(desc.tfm)->encrypt(
413 &desc, req->dst, req->src, req->nbytes);
414 }
415}
416
417static int ablk_decrypt(struct ablkcipher_request *req)
418{
419 struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req);
420 struct async_aes_ctx *ctx = crypto_ablkcipher_ctx(tfm);
421
422 if (!irq_fpu_usable()) {
423 struct ablkcipher_request *cryptd_req =
424 ablkcipher_request_ctx(req);
425 memcpy(cryptd_req, req, sizeof(*req));
426 ablkcipher_request_set_tfm(cryptd_req, &ctx->cryptd_tfm->base);
427 return crypto_ablkcipher_decrypt(cryptd_req);
428 } else {
429 struct blkcipher_desc desc;
430 desc.tfm = cryptd_ablkcipher_child(ctx->cryptd_tfm);
431 desc.info = req->info;
432 desc.flags = 0;
433 return crypto_blkcipher_crt(desc.tfm)->decrypt(
434 &desc, req->dst, req->src, req->nbytes);
435 }
436}
437
438static void ablk_exit(struct crypto_tfm *tfm)
439{
440 struct async_aes_ctx *ctx = crypto_tfm_ctx(tfm);
441
442 cryptd_free_ablkcipher(ctx->cryptd_tfm);
443}
444
445static int ablk_init_common(struct crypto_tfm *tfm, const char *drv_name)
446{
447 struct async_aes_ctx *ctx = crypto_tfm_ctx(tfm);
448 struct cryptd_ablkcipher *cryptd_tfm;
449
450 cryptd_tfm = cryptd_alloc_ablkcipher(drv_name, 0, 0);
451 if (IS_ERR(cryptd_tfm))
452 return PTR_ERR(cryptd_tfm);
453
454 ctx->cryptd_tfm = cryptd_tfm;
455 tfm->crt_ablkcipher.reqsize = sizeof(struct ablkcipher_request) +
456 crypto_ablkcipher_reqsize(&cryptd_tfm->base);
457
458 return 0;
459}
460
461static int ablk_ecb_init(struct crypto_tfm *tfm) 377static int ablk_ecb_init(struct crypto_tfm *tfm)
462{ 378{
463 return ablk_init_common(tfm, "__driver-ecb-aes-aesni"); 379 return ablk_init_common(tfm, "__driver-ecb-aes-aesni");
@@ -613,7 +529,7 @@ static int rfc4106_set_key(struct crypto_aead *parent, const u8 *key,
613 struct crypto_aead *cryptd_child = cryptd_aead_child(ctx->cryptd_tfm); 529 struct crypto_aead *cryptd_child = cryptd_aead_child(ctx->cryptd_tfm);
614 struct aesni_rfc4106_gcm_ctx *child_ctx = 530 struct aesni_rfc4106_gcm_ctx *child_ctx =
615 aesni_rfc4106_gcm_ctx_get(cryptd_child); 531 aesni_rfc4106_gcm_ctx_get(cryptd_child);
616 u8 *new_key_mem = NULL; 532 u8 *new_key_align, *new_key_mem = NULL;
617 533
618 if (key_len < 4) { 534 if (key_len < 4) {
619 crypto_tfm_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); 535 crypto_tfm_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
@@ -637,9 +553,9 @@ static int rfc4106_set_key(struct crypto_aead *parent, const u8 *key,
637 if (!new_key_mem) 553 if (!new_key_mem)
638 return -ENOMEM; 554 return -ENOMEM;
639 555
640 new_key_mem = PTR_ALIGN(new_key_mem, AESNI_ALIGN); 556 new_key_align = PTR_ALIGN(new_key_mem, AESNI_ALIGN);
641 memcpy(new_key_mem, key, key_len); 557 memcpy(new_key_align, key, key_len);
642 key = new_key_mem; 558 key = new_key_align;
643 } 559 }
644 560
645 if (!irq_fpu_usable()) 561 if (!irq_fpu_usable())
@@ -968,7 +884,7 @@ static struct crypto_alg aesni_algs[] = { {
968 .cra_priority = 400, 884 .cra_priority = 400,
969 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, 885 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
970 .cra_blocksize = AES_BLOCK_SIZE, 886 .cra_blocksize = AES_BLOCK_SIZE,
971 .cra_ctxsize = sizeof(struct async_aes_ctx), 887 .cra_ctxsize = sizeof(struct async_helper_ctx),
972 .cra_alignmask = 0, 888 .cra_alignmask = 0,
973 .cra_type = &crypto_ablkcipher_type, 889 .cra_type = &crypto_ablkcipher_type,
974 .cra_module = THIS_MODULE, 890 .cra_module = THIS_MODULE,
@@ -989,7 +905,7 @@ static struct crypto_alg aesni_algs[] = { {
989 .cra_priority = 400, 905 .cra_priority = 400,
990 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, 906 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
991 .cra_blocksize = AES_BLOCK_SIZE, 907 .cra_blocksize = AES_BLOCK_SIZE,
992 .cra_ctxsize = sizeof(struct async_aes_ctx), 908 .cra_ctxsize = sizeof(struct async_helper_ctx),
993 .cra_alignmask = 0, 909 .cra_alignmask = 0,
994 .cra_type = &crypto_ablkcipher_type, 910 .cra_type = &crypto_ablkcipher_type,
995 .cra_module = THIS_MODULE, 911 .cra_module = THIS_MODULE,
@@ -1033,7 +949,7 @@ static struct crypto_alg aesni_algs[] = { {
1033 .cra_priority = 400, 949 .cra_priority = 400,
1034 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, 950 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
1035 .cra_blocksize = 1, 951 .cra_blocksize = 1,
1036 .cra_ctxsize = sizeof(struct async_aes_ctx), 952 .cra_ctxsize = sizeof(struct async_helper_ctx),
1037 .cra_alignmask = 0, 953 .cra_alignmask = 0,
1038 .cra_type = &crypto_ablkcipher_type, 954 .cra_type = &crypto_ablkcipher_type,
1039 .cra_module = THIS_MODULE, 955 .cra_module = THIS_MODULE,
@@ -1098,7 +1014,7 @@ static struct crypto_alg aesni_algs[] = { {
1098 .cra_priority = 400, 1014 .cra_priority = 400,
1099 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, 1015 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
1100 .cra_blocksize = 1, 1016 .cra_blocksize = 1,
1101 .cra_ctxsize = sizeof(struct async_aes_ctx), 1017 .cra_ctxsize = sizeof(struct async_helper_ctx),
1102 .cra_alignmask = 0, 1018 .cra_alignmask = 0,
1103 .cra_type = &crypto_ablkcipher_type, 1019 .cra_type = &crypto_ablkcipher_type,
1104 .cra_module = THIS_MODULE, 1020 .cra_module = THIS_MODULE,
@@ -1126,7 +1042,7 @@ static struct crypto_alg aesni_algs[] = { {
1126 .cra_priority = 400, 1042 .cra_priority = 400,
1127 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, 1043 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
1128 .cra_blocksize = AES_BLOCK_SIZE, 1044 .cra_blocksize = AES_BLOCK_SIZE,
1129 .cra_ctxsize = sizeof(struct async_aes_ctx), 1045 .cra_ctxsize = sizeof(struct async_helper_ctx),
1130 .cra_alignmask = 0, 1046 .cra_alignmask = 0,
1131 .cra_type = &crypto_ablkcipher_type, 1047 .cra_type = &crypto_ablkcipher_type,
1132 .cra_module = THIS_MODULE, 1048 .cra_module = THIS_MODULE,
@@ -1150,7 +1066,7 @@ static struct crypto_alg aesni_algs[] = { {
1150 .cra_priority = 400, 1066 .cra_priority = 400,
1151 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, 1067 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
1152 .cra_blocksize = AES_BLOCK_SIZE, 1068 .cra_blocksize = AES_BLOCK_SIZE,
1153 .cra_ctxsize = sizeof(struct async_aes_ctx), 1069 .cra_ctxsize = sizeof(struct async_helper_ctx),
1154 .cra_alignmask = 0, 1070 .cra_alignmask = 0,
1155 .cra_type = &crypto_ablkcipher_type, 1071 .cra_type = &crypto_ablkcipher_type,
1156 .cra_module = THIS_MODULE, 1072 .cra_module = THIS_MODULE,
@@ -1174,7 +1090,7 @@ static struct crypto_alg aesni_algs[] = { {
1174 .cra_priority = 400, 1090 .cra_priority = 400,
1175 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, 1091 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
1176 .cra_blocksize = AES_BLOCK_SIZE, 1092 .cra_blocksize = AES_BLOCK_SIZE,
1177 .cra_ctxsize = sizeof(struct async_aes_ctx), 1093 .cra_ctxsize = sizeof(struct async_helper_ctx),
1178 .cra_alignmask = 0, 1094 .cra_alignmask = 0,
1179 .cra_type = &crypto_ablkcipher_type, 1095 .cra_type = &crypto_ablkcipher_type,
1180 .cra_module = THIS_MODULE, 1096 .cra_module = THIS_MODULE,
diff --git a/arch/x86/crypto/camellia_glue.c b/arch/x86/crypto/camellia_glue.c
index 3306dc0b139..eeb2b3b743e 100644
--- a/arch/x86/crypto/camellia_glue.c
+++ b/arch/x86/crypto/camellia_glue.c
@@ -5,10 +5,6 @@
5 * 5 *
6 * Camellia parts based on code by: 6 * Camellia parts based on code by:
7 * Copyright (C) 2006 NTT (Nippon Telegraph and Telephone Corporation) 7 * Copyright (C) 2006 NTT (Nippon Telegraph and Telephone Corporation)
8 * CBC & ECB parts based on code (crypto/cbc.c,ecb.c) by:
9 * Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au>
10 * CTR part based on code (crypto/ctr.c) by:
11 * (C) Copyright IBM Corp. 2007 - Joy Latten <latten@us.ibm.com>
12 * 8 *
13 * 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
14 * 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
@@ -34,9 +30,9 @@
34#include <linux/module.h> 30#include <linux/module.h>
35#include <linux/types.h> 31#include <linux/types.h>
36#include <crypto/algapi.h> 32#include <crypto/algapi.h>
37#include <crypto/b128ops.h>
38#include <crypto/lrw.h> 33#include <crypto/lrw.h>
39#include <crypto/xts.h> 34#include <crypto/xts.h>
35#include <asm/crypto/glue_helper.h>
40 36
41#define CAMELLIA_MIN_KEY_SIZE 16 37#define CAMELLIA_MIN_KEY_SIZE 16
42#define CAMELLIA_MAX_KEY_SIZE 32 38#define CAMELLIA_MAX_KEY_SIZE 32
@@ -1312,307 +1308,128 @@ static int camellia_setkey(struct crypto_tfm *tfm, const u8 *in_key,
1312 &tfm->crt_flags); 1308 &tfm->crt_flags);
1313} 1309}
1314 1310
1315static int ecb_crypt(struct blkcipher_desc *desc, struct blkcipher_walk *walk, 1311static void camellia_decrypt_cbc_2way(void *ctx, u128 *dst, const u128 *src)
1316 void (*fn)(struct camellia_ctx *, u8 *, const u8 *),
1317 void (*fn_2way)(struct camellia_ctx *, u8 *, const u8 *))
1318{ 1312{
1319 struct camellia_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); 1313 u128 iv = *src;
1320 unsigned int bsize = CAMELLIA_BLOCK_SIZE;
1321 unsigned int nbytes;
1322 int err;
1323
1324 err = blkcipher_walk_virt(desc, walk);
1325
1326 while ((nbytes = walk->nbytes)) {
1327 u8 *wsrc = walk->src.virt.addr;
1328 u8 *wdst = walk->dst.virt.addr;
1329
1330 /* Process two block batch */
1331 if (nbytes >= bsize * 2) {
1332 do {
1333 fn_2way(ctx, wdst, wsrc);
1334
1335 wsrc += bsize * 2;
1336 wdst += bsize * 2;
1337 nbytes -= bsize * 2;
1338 } while (nbytes >= bsize * 2);
1339
1340 if (nbytes < bsize)
1341 goto done;
1342 }
1343
1344 /* Handle leftovers */
1345 do {
1346 fn(ctx, wdst, wsrc);
1347
1348 wsrc += bsize;
1349 wdst += bsize;
1350 nbytes -= bsize;
1351 } while (nbytes >= bsize);
1352
1353done:
1354 err = blkcipher_walk_done(desc, walk, nbytes);
1355 }
1356
1357 return err;
1358}
1359
1360static int ecb_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
1361 struct scatterlist *src, unsigned int nbytes)
1362{
1363 struct blkcipher_walk walk;
1364
1365 blkcipher_walk_init(&walk, dst, src, nbytes);
1366 return ecb_crypt(desc, &walk, camellia_enc_blk, camellia_enc_blk_2way);
1367}
1368 1314
1369static int ecb_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, 1315 camellia_dec_blk_2way(ctx, (u8 *)dst, (u8 *)src);
1370 struct scatterlist *src, unsigned int nbytes)
1371{
1372 struct blkcipher_walk walk;
1373
1374 blkcipher_walk_init(&walk, dst, src, nbytes);
1375 return ecb_crypt(desc, &walk, camellia_dec_blk, camellia_dec_blk_2way);
1376}
1377 1316
1378static unsigned int __cbc_encrypt(struct blkcipher_desc *desc, 1317 u128_xor(&dst[1], &dst[1], &iv);
1379 struct blkcipher_walk *walk)
1380{
1381 struct camellia_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
1382 unsigned int bsize = CAMELLIA_BLOCK_SIZE;
1383 unsigned int nbytes = walk->nbytes;
1384 u128 *src = (u128 *)walk->src.virt.addr;
1385 u128 *dst = (u128 *)walk->dst.virt.addr;
1386 u128 *iv = (u128 *)walk->iv;
1387
1388 do {
1389 u128_xor(dst, src, iv);
1390 camellia_enc_blk(ctx, (u8 *)dst, (u8 *)dst);
1391 iv = dst;
1392
1393 src += 1;
1394 dst += 1;
1395 nbytes -= bsize;
1396 } while (nbytes >= bsize);
1397
1398 u128_xor((u128 *)walk->iv, (u128 *)walk->iv, iv);
1399 return nbytes;
1400} 1318}
1401 1319
1402static int cbc_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, 1320static void camellia_crypt_ctr(void *ctx, u128 *dst, const u128 *src, u128 *iv)
1403 struct scatterlist *src, unsigned int nbytes)
1404{ 1321{
1405 struct blkcipher_walk walk; 1322 be128 ctrblk;
1406 int err;
1407 1323
1408 blkcipher_walk_init(&walk, dst, src, nbytes); 1324 if (dst != src)
1409 err = blkcipher_walk_virt(desc, &walk); 1325 *dst = *src;
1410 1326
1411 while ((nbytes = walk.nbytes)) { 1327 u128_to_be128(&ctrblk, iv);
1412 nbytes = __cbc_encrypt(desc, &walk); 1328 u128_inc(iv);
1413 err = blkcipher_walk_done(desc, &walk, nbytes);
1414 }
1415 1329
1416 return err; 1330 camellia_enc_blk_xor(ctx, (u8 *)dst, (u8 *)&ctrblk);
1417} 1331}
1418 1332
1419static unsigned int __cbc_decrypt(struct blkcipher_desc *desc, 1333static void camellia_crypt_ctr_2way(void *ctx, u128 *dst, const u128 *src,
1420 struct blkcipher_walk *walk) 1334 u128 *iv)
1421{ 1335{
1422 struct camellia_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); 1336 be128 ctrblks[2];
1423 unsigned int bsize = CAMELLIA_BLOCK_SIZE;
1424 unsigned int nbytes = walk->nbytes;
1425 u128 *src = (u128 *)walk->src.virt.addr;
1426 u128 *dst = (u128 *)walk->dst.virt.addr;
1427 u128 ivs[2 - 1];
1428 u128 last_iv;
1429 1337
1430 /* Start of the last block. */ 1338 if (dst != src) {
1431 src += nbytes / bsize - 1; 1339 dst[0] = src[0];
1432 dst += nbytes / bsize - 1; 1340 dst[1] = src[1];
1433
1434 last_iv = *src;
1435
1436 /* Process two block batch */
1437 if (nbytes >= bsize * 2) {
1438 do {
1439 nbytes -= bsize * (2 - 1);
1440 src -= 2 - 1;
1441 dst -= 2 - 1;
1442
1443 ivs[0] = src[0];
1444
1445 camellia_dec_blk_2way(ctx, (u8 *)dst, (u8 *)src);
1446
1447 u128_xor(dst + 1, dst + 1, ivs + 0);
1448
1449 nbytes -= bsize;
1450 if (nbytes < bsize)
1451 goto done;
1452
1453 u128_xor(dst, dst, src - 1);
1454 src -= 1;
1455 dst -= 1;
1456 } while (nbytes >= bsize * 2);
1457
1458 if (nbytes < bsize)
1459 goto done;
1460 } 1341 }
1461 1342
1462 /* Handle leftovers */ 1343 u128_to_be128(&ctrblks[0], iv);
1463 for (;;) { 1344 u128_inc(iv);
1464 camellia_dec_blk(ctx, (u8 *)dst, (u8 *)src); 1345 u128_to_be128(&ctrblks[1], iv);
1465 1346 u128_inc(iv);
1466 nbytes -= bsize;
1467 if (nbytes < bsize)
1468 break;
1469 1347
1470 u128_xor(dst, dst, src - 1); 1348 camellia_enc_blk_xor_2way(ctx, (u8 *)dst, (u8 *)ctrblks);
1471 src -= 1;
1472 dst -= 1;
1473 }
1474
1475done:
1476 u128_xor(dst, dst, (u128 *)walk->iv);
1477 *(u128 *)walk->iv = last_iv;
1478
1479 return nbytes;
1480} 1349}
1481 1350
1482static int cbc_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, 1351static const struct common_glue_ctx camellia_enc = {
1483 struct scatterlist *src, unsigned int nbytes) 1352 .num_funcs = 2,
1484{ 1353 .fpu_blocks_limit = -1,
1485 struct blkcipher_walk walk; 1354
1486 int err; 1355 .funcs = { {
1487 1356 .num_blocks = 2,
1488 blkcipher_walk_init(&walk, dst, src, nbytes); 1357 .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_enc_blk_2way) }
1489 err = blkcipher_walk_virt(desc, &walk); 1358 }, {
1359 .num_blocks = 1,
1360 .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_enc_blk) }
1361 } }
1362};
1490 1363
1491 while ((nbytes = walk.nbytes)) { 1364static const struct common_glue_ctx camellia_ctr = {
1492 nbytes = __cbc_decrypt(desc, &walk); 1365 .num_funcs = 2,
1493 err = blkcipher_walk_done(desc, &walk, nbytes); 1366 .fpu_blocks_limit = -1,
1494 } 1367
1368 .funcs = { {
1369 .num_blocks = 2,
1370 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(camellia_crypt_ctr_2way) }
1371 }, {
1372 .num_blocks = 1,
1373 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(camellia_crypt_ctr) }
1374 } }
1375};
1495 1376
1496 return err; 1377static const struct common_glue_ctx camellia_dec = {
1497} 1378 .num_funcs = 2,
1379 .fpu_blocks_limit = -1,
1380
1381 .funcs = { {
1382 .num_blocks = 2,
1383 .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_dec_blk_2way) }
1384 }, {
1385 .num_blocks = 1,
1386 .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_dec_blk) }
1387 } }
1388};
1498 1389
1499static inline void u128_to_be128(be128 *dst, const u128 *src) 1390static const struct common_glue_ctx camellia_dec_cbc = {
1500{ 1391 .num_funcs = 2,
1501 dst->a = cpu_to_be64(src->a); 1392 .fpu_blocks_limit = -1,
1502 dst->b = cpu_to_be64(src->b); 1393
1503} 1394 .funcs = { {
1395 .num_blocks = 2,
1396 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(camellia_decrypt_cbc_2way) }
1397 }, {
1398 .num_blocks = 1,
1399 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(camellia_dec_blk) }
1400 } }
1401};
1504 1402
1505static inline void be128_to_u128(u128 *dst, const be128 *src) 1403static int ecb_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
1404 struct scatterlist *src, unsigned int nbytes)
1506{ 1405{
1507 dst->a = be64_to_cpu(src->a); 1406 return glue_ecb_crypt_128bit(&camellia_enc, desc, dst, src, nbytes);
1508 dst->b = be64_to_cpu(src->b);
1509} 1407}
1510 1408
1511static inline void u128_inc(u128 *i) 1409static int ecb_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
1410 struct scatterlist *src, unsigned int nbytes)
1512{ 1411{
1513 i->b++; 1412 return glue_ecb_crypt_128bit(&camellia_dec, desc, dst, src, nbytes);
1514 if (!i->b)
1515 i->a++;
1516} 1413}
1517 1414
1518static void ctr_crypt_final(struct blkcipher_desc *desc, 1415static int cbc_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
1519 struct blkcipher_walk *walk) 1416 struct scatterlist *src, unsigned int nbytes)
1520{ 1417{
1521 struct camellia_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); 1418 return glue_cbc_encrypt_128bit(GLUE_FUNC_CAST(camellia_enc_blk), desc,
1522 u8 keystream[CAMELLIA_BLOCK_SIZE]; 1419 dst, src, nbytes);
1523 u8 *src = walk->src.virt.addr;
1524 u8 *dst = walk->dst.virt.addr;
1525 unsigned int nbytes = walk->nbytes;
1526 u128 ctrblk;
1527
1528 memcpy(keystream, src, nbytes);
1529 camellia_enc_blk_xor(ctx, keystream, walk->iv);
1530 memcpy(dst, keystream, nbytes);
1531
1532 be128_to_u128(&ctrblk, (be128 *)walk->iv);
1533 u128_inc(&ctrblk);
1534 u128_to_be128((be128 *)walk->iv, &ctrblk);
1535} 1420}
1536 1421
1537static unsigned int __ctr_crypt(struct blkcipher_desc *desc, 1422static int cbc_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
1538 struct blkcipher_walk *walk) 1423 struct scatterlist *src, unsigned int nbytes)
1539{ 1424{
1540 struct camellia_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); 1425 return glue_cbc_decrypt_128bit(&camellia_dec_cbc, desc, dst, src,
1541 unsigned int bsize = CAMELLIA_BLOCK_SIZE; 1426 nbytes);
1542 unsigned int nbytes = walk->nbytes;
1543 u128 *src = (u128 *)walk->src.virt.addr;
1544 u128 *dst = (u128 *)walk->dst.virt.addr;
1545 u128 ctrblk;
1546 be128 ctrblocks[2];
1547
1548 be128_to_u128(&ctrblk, (be128 *)walk->iv);
1549
1550 /* Process two block batch */
1551 if (nbytes >= bsize * 2) {
1552 do {
1553 if (dst != src) {
1554 dst[0] = src[0];
1555 dst[1] = src[1];
1556 }
1557
1558 /* create ctrblks for parallel encrypt */
1559 u128_to_be128(&ctrblocks[0], &ctrblk);
1560 u128_inc(&ctrblk);
1561 u128_to_be128(&ctrblocks[1], &ctrblk);
1562 u128_inc(&ctrblk);
1563
1564 camellia_enc_blk_xor_2way(ctx, (u8 *)dst,
1565 (u8 *)ctrblocks);
1566
1567 src += 2;
1568 dst += 2;
1569 nbytes -= bsize * 2;
1570 } while (nbytes >= bsize * 2);
1571
1572 if (nbytes < bsize)
1573 goto done;
1574 }
1575
1576 /* Handle leftovers */
1577 do {
1578 if (dst != src)
1579 *dst = *src;
1580
1581 u128_to_be128(&ctrblocks[0], &ctrblk);
1582 u128_inc(&ctrblk);
1583
1584 camellia_enc_blk_xor(ctx, (u8 *)dst, (u8 *)ctrblocks);
1585
1586 src += 1;
1587 dst += 1;
1588 nbytes -= bsize;
1589 } while (nbytes >= bsize);
1590
1591done:
1592 u128_to_be128((be128 *)walk->iv, &ctrblk);
1593 return nbytes;
1594} 1427}
1595 1428
1596static int ctr_crypt(struct blkcipher_desc *desc, struct scatterlist *dst, 1429static int ctr_crypt(struct blkcipher_desc *desc, struct scatterlist *dst,
1597 struct scatterlist *src, unsigned int nbytes) 1430 struct scatterlist *src, unsigned int nbytes)
1598{ 1431{
1599 struct blkcipher_walk walk; 1432 return glue_ctr_crypt_128bit(&camellia_ctr, desc, dst, src, nbytes);
1600 int err;
1601
1602 blkcipher_walk_init(&walk, dst, src, nbytes);
1603 err = blkcipher_walk_virt_block(desc, &walk, CAMELLIA_BLOCK_SIZE);
1604
1605 while ((nbytes = walk.nbytes) >= CAMELLIA_BLOCK_SIZE) {
1606 nbytes = __ctr_crypt(desc, &walk);
1607 err = blkcipher_walk_done(desc, &walk, nbytes);
1608 }
1609
1610 if (walk.nbytes) {
1611 ctr_crypt_final(desc, &walk);
1612 err = blkcipher_walk_done(desc, &walk, 0);
1613 }
1614
1615 return err;
1616} 1433}
1617 1434
1618static void encrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes) 1435static void encrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
diff --git a/arch/x86/crypto/glue_helper.c b/arch/x86/crypto/glue_helper.c
new file mode 100644
index 00000000000..4854f0f31e4
--- /dev/null
+++ b/arch/x86/crypto/glue_helper.c
@@ -0,0 +1,307 @@
1/*
2 * Shared glue code for 128bit block ciphers
3 *
4 * Copyright (c) 2012 Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
5 *
6 * CBC & ECB parts based on code (crypto/cbc.c,ecb.c) by:
7 * Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au>
8 * CTR part based on code (crypto/ctr.c) by:
9 * (C) Copyright IBM Corp. 2007 - Joy Latten <latten@us.ibm.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 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 * USA
25 *
26 */
27
28#include <linux/module.h>
29#include <crypto/b128ops.h>
30#include <crypto/lrw.h>
31#include <crypto/xts.h>
32#include <asm/crypto/glue_helper.h>
33#include <crypto/scatterwalk.h>
34
35static int __glue_ecb_crypt_128bit(const struct common_glue_ctx *gctx,
36 struct blkcipher_desc *desc,
37 struct blkcipher_walk *walk)
38{
39 void *ctx = crypto_blkcipher_ctx(desc->tfm);
40 const unsigned int bsize = 128 / 8;
41 unsigned int nbytes, i, func_bytes;
42 bool fpu_enabled = false;
43 int err;
44
45 err = blkcipher_walk_virt(desc, walk);
46
47 while ((nbytes = walk->nbytes)) {
48 u8 *wsrc = walk->src.virt.addr;
49 u8 *wdst = walk->dst.virt.addr;
50
51 fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
52 desc, fpu_enabled, nbytes);
53
54 for (i = 0; i < gctx->num_funcs; i++) {
55 func_bytes = bsize * gctx->funcs[i].num_blocks;
56
57 /* Process multi-block batch */
58 if (nbytes >= func_bytes) {
59 do {
60 gctx->funcs[i].fn_u.ecb(ctx, wdst,
61 wsrc);
62
63 wsrc += func_bytes;
64 wdst += func_bytes;
65 nbytes -= func_bytes;
66 } while (nbytes >= func_bytes);
67
68 if (nbytes < bsize)
69 goto done;
70 }
71 }
72
73done:
74 err = blkcipher_walk_done(desc, walk, nbytes);
75 }
76
77 glue_fpu_end(fpu_enabled);
78 return err;
79}
80
81int glue_ecb_crypt_128bit(const struct common_glue_ctx *gctx,
82 struct blkcipher_desc *desc, struct scatterlist *dst,
83 struct scatterlist *src, unsigned int nbytes)
84{
85 struct blkcipher_walk walk;
86
87 blkcipher_walk_init(&walk, dst, src, nbytes);
88 return __glue_ecb_crypt_128bit(gctx, desc, &walk);
89}
90EXPORT_SYMBOL_GPL(glue_ecb_crypt_128bit);
91
92static unsigned int __glue_cbc_encrypt_128bit(const common_glue_func_t fn,
93 struct blkcipher_desc *desc,
94 struct blkcipher_walk *walk)
95{
96 void *ctx = crypto_blkcipher_ctx(desc->tfm);
97 const unsigned int bsize = 128 / 8;
98 unsigned int nbytes = walk->nbytes;
99 u128 *src = (u128 *)walk->src.virt.addr;
100 u128 *dst = (u128 *)walk->dst.virt.addr;
101 u128 *iv = (u128 *)walk->iv;
102
103 do {
104 u128_xor(dst, src, iv);
105 fn(ctx, (u8 *)dst, (u8 *)dst);
106 iv = dst;
107
108 src += 1;
109 dst += 1;
110 nbytes -= bsize;
111 } while (nbytes >= bsize);
112
113 u128_xor((u128 *)walk->iv, (u128 *)walk->iv, iv);
114 return nbytes;
115}
116
117int glue_cbc_encrypt_128bit(const common_glue_func_t fn,
118 struct blkcipher_desc *desc,
119 struct scatterlist *dst,
120 struct scatterlist *src, unsigned int nbytes)
121{
122 struct blkcipher_walk walk;
123 int err;
124
125 blkcipher_walk_init(&walk, dst, src, nbytes);
126 err = blkcipher_walk_virt(desc, &walk);
127
128 while ((nbytes = walk.nbytes)) {
129 nbytes = __glue_cbc_encrypt_128bit(fn, desc, &walk);
130 err = blkcipher_walk_done(desc, &walk, nbytes);
131 }
132
133 return err;
134}
135EXPORT_SYMBOL_GPL(glue_cbc_encrypt_128bit);
136
137static unsigned int
138__glue_cbc_decrypt_128bit(const struct common_glue_ctx *gctx,
139 struct blkcipher_desc *desc,
140 struct blkcipher_walk *walk)
141{
142 void *ctx = crypto_blkcipher_ctx(desc->tfm);
143 const unsigned int bsize = 128 / 8;
144 unsigned int nbytes = walk->nbytes;
145 u128 *src = (u128 *)walk->src.virt.addr;
146 u128 *dst = (u128 *)walk->dst.virt.addr;
147 u128 last_iv;
148 unsigned int num_blocks, func_bytes;
149 unsigned int i;
150
151 /* Start of the last block. */
152 src += nbytes / bsize - 1;
153 dst += nbytes / bsize - 1;
154
155 last_iv = *src;
156
157 for (i = 0; i < gctx->num_funcs; i++) {
158 num_blocks = gctx->funcs[i].num_blocks;
159 func_bytes = bsize * num_blocks;
160
161 /* Process multi-block batch */
162 if (nbytes >= func_bytes) {
163 do {
164 nbytes -= func_bytes - bsize;
165 src -= num_blocks - 1;
166 dst -= num_blocks - 1;
167
168 gctx->funcs[i].fn_u.cbc(ctx, dst, src);
169
170 nbytes -= bsize;
171 if (nbytes < bsize)
172 goto done;
173
174 u128_xor(dst, dst, src - 1);
175 src -= 1;
176 dst -= 1;
177 } while (nbytes >= func_bytes);
178
179 if (nbytes < bsize)
180 goto done;
181 }
182 }
183
184done:
185 u128_xor(dst, dst, (u128 *)walk->iv);
186 *(u128 *)walk->iv = last_iv;
187
188 return nbytes;
189}
190
191int glue_cbc_decrypt_128bit(const struct common_glue_ctx *gctx,
192 struct blkcipher_desc *desc,
193 struct scatterlist *dst,
194 struct scatterlist *src, unsigned int nbytes)
195{
196 const unsigned int bsize = 128 / 8;
197 bool fpu_enabled = false;
198 struct blkcipher_walk walk;
199 int err;
200
201 blkcipher_walk_init(&walk, dst, src, nbytes);
202 err = blkcipher_walk_virt(desc, &walk);
203
204 while ((nbytes = walk.nbytes)) {
205 fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
206 desc, fpu_enabled, nbytes);
207 nbytes = __glue_cbc_decrypt_128bit(gctx, desc, &walk);
208 err = blkcipher_walk_done(desc, &walk, nbytes);
209 }
210
211 glue_fpu_end(fpu_enabled);
212 return err;
213}
214EXPORT_SYMBOL_GPL(glue_cbc_decrypt_128bit);
215
216static void glue_ctr_crypt_final_128bit(const common_glue_ctr_func_t fn_ctr,
217 struct blkcipher_desc *desc,
218 struct blkcipher_walk *walk)
219{
220 void *ctx = crypto_blkcipher_ctx(desc->tfm);
221 u8 *src = (u8 *)walk->src.virt.addr;
222 u8 *dst = (u8 *)walk->dst.virt.addr;
223 unsigned int nbytes = walk->nbytes;
224 u128 ctrblk;
225 u128 tmp;
226
227 be128_to_u128(&ctrblk, (be128 *)walk->iv);
228
229 memcpy(&tmp, src, nbytes);
230 fn_ctr(ctx, &tmp, &tmp, &ctrblk);
231 memcpy(dst, &tmp, nbytes);
232
233 u128_to_be128((be128 *)walk->iv, &ctrblk);
234}
235EXPORT_SYMBOL_GPL(glue_ctr_crypt_final_128bit);
236
237static unsigned int __glue_ctr_crypt_128bit(const struct common_glue_ctx *gctx,
238 struct blkcipher_desc *desc,
239 struct blkcipher_walk *walk)
240{
241 const unsigned int bsize = 128 / 8;
242 void *ctx = crypto_blkcipher_ctx(desc->tfm);
243 unsigned int nbytes = walk->nbytes;
244 u128 *src = (u128 *)walk->src.virt.addr;
245 u128 *dst = (u128 *)walk->dst.virt.addr;
246 u128 ctrblk;
247 unsigned int num_blocks, func_bytes;
248 unsigned int i;
249
250 be128_to_u128(&ctrblk, (be128 *)walk->iv);
251
252 /* Process multi-block batch */
253 for (i = 0; i < gctx->num_funcs; i++) {
254 num_blocks = gctx->funcs[i].num_blocks;
255 func_bytes = bsize * num_blocks;
256
257 if (nbytes >= func_bytes) {
258 do {
259 gctx->funcs[i].fn_u.ctr(ctx, dst, src, &ctrblk);
260
261 src += num_blocks;
262 dst += num_blocks;
263 nbytes -= func_bytes;
264 } while (nbytes >= func_bytes);
265
266 if (nbytes < bsize)
267 goto done;
268 }
269 }
270
271done:
272 u128_to_be128((be128 *)walk->iv, &ctrblk);
273 return nbytes;
274}
275
276int glue_ctr_crypt_128bit(const struct common_glue_ctx *gctx,
277 struct blkcipher_desc *desc, struct scatterlist *dst,
278 struct scatterlist *src, unsigned int nbytes)
279{
280 const unsigned int bsize = 128 / 8;
281 bool fpu_enabled = false;
282 struct blkcipher_walk walk;
283 int err;
284
285 blkcipher_walk_init(&walk, dst, src, nbytes);
286 err = blkcipher_walk_virt_block(desc, &walk, bsize);
287
288 while ((nbytes = walk.nbytes) >= bsize) {
289 fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
290 desc, fpu_enabled, nbytes);
291 nbytes = __glue_ctr_crypt_128bit(gctx, desc, &walk);
292 err = blkcipher_walk_done(desc, &walk, nbytes);
293 }
294
295 glue_fpu_end(fpu_enabled);
296
297 if (walk.nbytes) {
298 glue_ctr_crypt_final_128bit(
299 gctx->funcs[gctx->num_funcs - 1].fn_u.ctr, desc, &walk);
300 err = blkcipher_walk_done(desc, &walk, 0);
301 }
302
303 return err;
304}
305EXPORT_SYMBOL_GPL(glue_ctr_crypt_128bit);
306
307MODULE_LICENSE("GPL");
diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
new file mode 100644
index 00000000000..504106bf04a
--- /dev/null
+++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
@@ -0,0 +1,704 @@
1/*
2 * Serpent Cipher 8-way parallel algorithm (x86_64/AVX)
3 *
4 * Copyright (C) 2012 Johannes Goetzfried
5 * <Johannes.Goetzfried@informatik.stud.uni-erlangen.de>
6 *
7 * Based on arch/x86/crypto/serpent-sse2-x86_64-asm_64.S by
8 * Copyright (C) 2011 Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
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 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
25 */
26
27.file "serpent-avx-x86_64-asm_64.S"
28.text
29
30#define CTX %rdi
31
32/**********************************************************************
33 8-way AVX serpent
34 **********************************************************************/
35#define RA1 %xmm0
36#define RB1 %xmm1
37#define RC1 %xmm2
38#define RD1 %xmm3
39#define RE1 %xmm4
40
41#define tp %xmm5
42
43#define RA2 %xmm6
44#define RB2 %xmm7
45#define RC2 %xmm8
46#define RD2 %xmm9
47#define RE2 %xmm10
48
49#define RNOT %xmm11
50
51#define RK0 %xmm12
52#define RK1 %xmm13
53#define RK2 %xmm14
54#define RK3 %xmm15
55
56
57#define S0_1(x0, x1, x2, x3, x4) \
58 vpor x0, x3, tp; \
59 vpxor x3, x0, x0; \
60 vpxor x2, x3, x4; \
61 vpxor RNOT, x4, x4; \
62 vpxor x1, tp, x3; \
63 vpand x0, x1, x1; \
64 vpxor x4, x1, x1; \
65 vpxor x0, x2, x2;
66#define S0_2(x0, x1, x2, x3, x4) \
67 vpxor x3, x0, x0; \
68 vpor x0, x4, x4; \
69 vpxor x2, x0, x0; \
70 vpand x1, x2, x2; \
71 vpxor x2, x3, x3; \
72 vpxor RNOT, x1, x1; \
73 vpxor x4, x2, x2; \
74 vpxor x2, x1, x1;
75
76#define S1_1(x0, x1, x2, x3, x4) \
77 vpxor x0, x1, tp; \
78 vpxor x3, x0, x0; \
79 vpxor RNOT, x3, x3; \
80 vpand tp, x1, x4; \
81 vpor tp, x0, x0; \
82 vpxor x2, x3, x3; \
83 vpxor x3, x0, x0; \
84 vpxor x3, tp, x1;
85#define S1_2(x0, x1, x2, x3, x4) \
86 vpxor x4, x3, x3; \
87 vpor x4, x1, x1; \
88 vpxor x2, x4, x4; \
89 vpand x0, x2, x2; \
90 vpxor x1, x2, x2; \
91 vpor x0, x1, x1; \
92 vpxor RNOT, x0, x0; \
93 vpxor x2, x0, x0; \
94 vpxor x1, x4, x4;
95
96#define S2_1(x0, x1, x2, x3, x4) \
97 vpxor RNOT, x3, x3; \
98 vpxor x0, x1, x1; \
99 vpand x2, x0, tp; \
100 vpxor x3, tp, tp; \
101 vpor x0, x3, x3; \
102 vpxor x1, x2, x2; \
103 vpxor x1, x3, x3; \
104 vpand tp, x1, x1;
105#define S2_2(x0, x1, x2, x3, x4) \
106 vpxor x2, tp, tp; \
107 vpand x3, x2, x2; \
108 vpor x1, x3, x3; \
109 vpxor RNOT, tp, tp; \
110 vpxor tp, x3, x3; \
111 vpxor tp, x0, x4; \
112 vpxor x2, tp, x0; \
113 vpor x2, x1, x1;
114
115#define S3_1(x0, x1, x2, x3, x4) \
116 vpxor x3, x1, tp; \
117 vpor x0, x3, x3; \
118 vpand x0, x1, x4; \
119 vpxor x2, x0, x0; \
120 vpxor tp, x2, x2; \
121 vpand x3, tp, x1; \
122 vpxor x3, x2, x2; \
123 vpor x4, x0, x0; \
124 vpxor x3, x4, x4;
125#define S3_2(x0, x1, x2, x3, x4) \
126 vpxor x0, x1, x1; \
127 vpand x3, x0, x0; \
128 vpand x4, x3, x3; \
129 vpxor x2, x3, x3; \
130 vpor x1, x4, x4; \
131 vpand x1, x2, x2; \
132 vpxor x3, x4, x4; \
133 vpxor x3, x0, x0; \
134 vpxor x2, x3, x3;
135
136#define S4_1(x0, x1, x2, x3, x4) \
137 vpand x0, x3, tp; \
138 vpxor x3, x0, x0; \
139 vpxor x2, tp, tp; \
140 vpor x3, x2, x2; \
141 vpxor x1, x0, x0; \
142 vpxor tp, x3, x4; \
143 vpor x0, x2, x2; \
144 vpxor x1, x2, x2;
145#define S4_2(x0, x1, x2, x3, x4) \
146 vpand x0, x1, x1; \
147 vpxor x4, x1, x1; \
148 vpand x2, x4, x4; \
149 vpxor tp, x2, x2; \
150 vpxor x0, x4, x4; \
151 vpor x1, tp, x3; \
152 vpxor RNOT, x1, x1; \
153 vpxor x0, x3, x3;
154
155#define S5_1(x0, x1, x2, x3, x4) \
156 vpor x0, x1, tp; \
157 vpxor tp, x2, x2; \
158 vpxor RNOT, x3, x3; \
159 vpxor x0, x1, x4; \
160 vpxor x2, x0, x0; \
161 vpand x4, tp, x1; \
162 vpor x3, x4, x4; \
163 vpxor x0, x4, x4;
164#define S5_2(x0, x1, x2, x3, x4) \
165 vpand x3, x0, x0; \
166 vpxor x3, x1, x1; \
167 vpxor x2, x3, x3; \
168 vpxor x1, x0, x0; \
169 vpand x4, x2, x2; \
170 vpxor x2, x1, x1; \
171 vpand x0, x2, x2; \
172 vpxor x2, x3, x3;
173
174#define S6_1(x0, x1, x2, x3, x4) \
175 vpxor x0, x3, x3; \
176 vpxor x2, x1, tp; \
177 vpxor x0, x2, x2; \
178 vpand x3, x0, x0; \
179 vpor x3, tp, tp; \
180 vpxor RNOT, x1, x4; \
181 vpxor tp, x0, x0; \
182 vpxor x2, tp, x1;
183#define S6_2(x0, x1, x2, x3, x4) \
184 vpxor x4, x3, x3; \
185 vpxor x0, x4, x4; \
186 vpand x0, x2, x2; \
187 vpxor x1, x4, x4; \
188 vpxor x3, x2, x2; \
189 vpand x1, x3, x3; \
190 vpxor x0, x3, x3; \
191 vpxor x2, x1, x1;
192
193#define S7_1(x0, x1, x2, x3, x4) \
194 vpxor RNOT, x1, tp; \
195 vpxor RNOT, x0, x0; \
196 vpand x2, tp, x1; \
197 vpxor x3, x1, x1; \
198 vpor tp, x3, x3; \
199 vpxor x2, tp, x4; \
200 vpxor x3, x2, x2; \
201 vpxor x0, x3, x3; \
202 vpor x1, x0, x0;
203#define S7_2(x0, x1, x2, x3, x4) \
204 vpand x0, x2, x2; \
205 vpxor x4, x0, x0; \
206 vpxor x3, x4, x4; \
207 vpand x0, x3, x3; \
208 vpxor x1, x4, x4; \
209 vpxor x4, x2, x2; \
210 vpxor x1, x3, x3; \
211 vpor x0, x4, x4; \
212 vpxor x1, x4, x4;
213
214#define SI0_1(x0, x1, x2, x3, x4) \
215 vpxor x0, x1, x1; \
216 vpor x1, x3, tp; \
217 vpxor x1, x3, x4; \
218 vpxor RNOT, x0, x0; \
219 vpxor tp, x2, x2; \
220 vpxor x0, tp, x3; \
221 vpand x1, x0, x0; \
222 vpxor x2, x0, x0;
223#define SI0_2(x0, x1, x2, x3, x4) \
224 vpand x3, x2, x2; \
225 vpxor x4, x3, x3; \
226 vpxor x3, x2, x2; \
227 vpxor x3, x1, x1; \
228 vpand x0, x3, x3; \
229 vpxor x0, x1, x1; \
230 vpxor x2, x0, x0; \
231 vpxor x3, x4, x4;
232
233#define SI1_1(x0, x1, x2, x3, x4) \
234 vpxor x3, x1, x1; \
235 vpxor x2, x0, tp; \
236 vpxor RNOT, x2, x2; \
237 vpor x1, x0, x4; \
238 vpxor x3, x4, x4; \
239 vpand x1, x3, x3; \
240 vpxor x2, x1, x1; \
241 vpand x4, x2, x2;
242#define SI1_2(x0, x1, x2, x3, x4) \
243 vpxor x1, x4, x4; \
244 vpor x3, x1, x1; \
245 vpxor tp, x3, x3; \
246 vpxor tp, x2, x2; \
247 vpor x4, tp, x0; \
248 vpxor x4, x2, x2; \
249 vpxor x0, x1, x1; \
250 vpxor x1, x4, x4;
251
252#define SI2_1(x0, x1, x2, x3, x4) \
253 vpxor x1, x2, x2; \
254 vpxor RNOT, x3, tp; \
255 vpor x2, tp, tp; \
256 vpxor x3, x2, x2; \
257 vpxor x0, x3, x4; \
258 vpxor x1, tp, x3; \
259 vpor x2, x1, x1; \
260 vpxor x0, x2, x2;
261#define SI2_2(x0, x1, x2, x3, x4) \
262 vpxor x4, x1, x1; \
263 vpor x3, x4, x4; \
264 vpxor x3, x2, x2; \
265 vpxor x2, x4, x4; \
266 vpand x1, x2, x2; \
267 vpxor x3, x2, x2; \
268 vpxor x4, x3, x3; \
269 vpxor x0, x4, x4;
270
271#define SI3_1(x0, x1, x2, x3, x4) \
272 vpxor x1, x2, x2; \
273 vpand x2, x1, tp; \
274 vpxor x0, tp, tp; \
275 vpor x1, x0, x0; \
276 vpxor x3, x1, x4; \
277 vpxor x3, x0, x0; \
278 vpor tp, x3, x3; \
279 vpxor x2, tp, x1;
280#define SI3_2(x0, x1, x2, x3, x4) \
281 vpxor x3, x1, x1; \
282 vpxor x2, x0, x0; \
283 vpxor x3, x2, x2; \
284 vpand x1, x3, x3; \
285 vpxor x0, x1, x1; \
286 vpand x2, x0, x0; \
287 vpxor x3, x4, x4; \
288 vpxor x0, x3, x3; \
289 vpxor x1, x0, x0;
290
291#define SI4_1(x0, x1, x2, x3, x4) \
292 vpxor x3, x2, x2; \
293 vpand x1, x0, tp; \
294 vpxor x2, tp, tp; \
295 vpor x3, x2, x2; \
296 vpxor RNOT, x0, x4; \
297 vpxor tp, x1, x1; \
298 vpxor x2, tp, x0; \
299 vpand x4, x2, x2;
300#define SI4_2(x0, x1, x2, x3, x4) \
301 vpxor x0, x2, x2; \
302 vpor x4, x0, x0; \
303 vpxor x3, x0, x0; \
304 vpand x2, x3, x3; \
305 vpxor x3, x4, x4; \
306 vpxor x1, x3, x3; \
307 vpand x0, x1, x1; \
308 vpxor x1, x4, x4; \
309 vpxor x3, x0, x0;
310
311#define SI5_1(x0, x1, x2, x3, x4) \
312 vpor x2, x1, tp; \
313 vpxor x1, x2, x2; \
314 vpxor x3, tp, tp; \
315 vpand x1, x3, x3; \
316 vpxor x3, x2, x2; \
317 vpor x0, x3, x3; \
318 vpxor RNOT, x0, x0; \
319 vpxor x2, x3, x3; \
320 vpor x0, x2, x2;
321#define SI5_2(x0, x1, x2, x3, x4) \
322 vpxor tp, x1, x4; \
323 vpxor x4, x2, x2; \
324 vpand x0, x4, x4; \
325 vpxor tp, x0, x0; \
326 vpxor x3, tp, x1; \
327 vpand x2, x0, x0; \
328 vpxor x3, x2, x2; \
329 vpxor x2, x0, x0; \
330 vpxor x4, x2, x2; \
331 vpxor x3, x4, x4;
332
333#define SI6_1(x0, x1, x2, x3, x4) \
334 vpxor x2, x0, x0; \
335 vpand x3, x0, tp; \
336 vpxor x3, x2, x2; \
337 vpxor x2, tp, tp; \
338 vpxor x1, x3, x3; \
339 vpor x0, x2, x2; \
340 vpxor x3, x2, x2; \
341 vpand tp, x3, x3;
342#define SI6_2(x0, x1, x2, x3, x4) \
343 vpxor RNOT, tp, tp; \
344 vpxor x1, x3, x3; \
345 vpand x2, x1, x1; \
346 vpxor tp, x0, x4; \
347 vpxor x4, x3, x3; \
348 vpxor x2, x4, x4; \
349 vpxor x1, tp, x0; \
350 vpxor x0, x2, x2;
351
352#define SI7_1(x0, x1, x2, x3, x4) \
353 vpand x0, x3, tp; \
354 vpxor x2, x0, x0; \
355 vpor x3, x2, x2; \
356 vpxor x1, x3, x4; \
357 vpxor RNOT, x0, x0; \
358 vpor tp, x1, x1; \
359 vpxor x0, x4, x4; \
360 vpand x2, x0, x0; \
361 vpxor x1, x0, x0;
362#define SI7_2(x0, x1, x2, x3, x4) \
363 vpand x2, x1, x1; \
364 vpxor x2, tp, x3; \
365 vpxor x3, x4, x4; \
366 vpand x3, x2, x2; \
367 vpor x0, x3, x3; \
368 vpxor x4, x1, x1; \
369 vpxor x4, x3, x3; \
370 vpand x0, x4, x4; \
371 vpxor x2, x4, x4;
372
373#define get_key(i, j, t) \
374 vbroadcastss (4*(i)+(j))*4(CTX), t;
375
376#define K2(x0, x1, x2, x3, x4, i) \
377 get_key(i, 0, RK0); \
378 get_key(i, 1, RK1); \
379 get_key(i, 2, RK2); \
380 get_key(i, 3, RK3); \
381 vpxor RK0, x0 ## 1, x0 ## 1; \
382 vpxor RK1, x1 ## 1, x1 ## 1; \
383 vpxor RK2, x2 ## 1, x2 ## 1; \
384 vpxor RK3, x3 ## 1, x3 ## 1; \
385 vpxor RK0, x0 ## 2, x0 ## 2; \
386 vpxor RK1, x1 ## 2, x1 ## 2; \
387 vpxor RK2, x2 ## 2, x2 ## 2; \
388 vpxor RK3, x3 ## 2, x3 ## 2;
389
390#define LK2(x0, x1, x2, x3, x4, i) \
391 vpslld $13, x0 ## 1, x4 ## 1; \
392 vpsrld $(32 - 13), x0 ## 1, x0 ## 1; \
393 vpor x4 ## 1, x0 ## 1, x0 ## 1; \
394 vpxor x0 ## 1, x1 ## 1, x1 ## 1; \
395 vpslld $3, x2 ## 1, x4 ## 1; \
396 vpsrld $(32 - 3), x2 ## 1, x2 ## 1; \
397 vpor x4 ## 1, x2 ## 1, x2 ## 1; \
398 vpxor x2 ## 1, x1 ## 1, x1 ## 1; \
399 vpslld $13, x0 ## 2, x4 ## 2; \
400 vpsrld $(32 - 13), x0 ## 2, x0 ## 2; \
401 vpor x4 ## 2, x0 ## 2, x0 ## 2; \
402 vpxor x0 ## 2, x1 ## 2, x1 ## 2; \
403 vpslld $3, x2 ## 2, x4 ## 2; \
404 vpsrld $(32 - 3), x2 ## 2, x2 ## 2; \
405 vpor x4 ## 2, x2 ## 2, x2 ## 2; \
406 vpxor x2 ## 2, x1 ## 2, x1 ## 2; \
407 vpslld $1, x1 ## 1, x4 ## 1; \
408 vpsrld $(32 - 1), x1 ## 1, x1 ## 1; \
409 vpor x4 ## 1, x1 ## 1, x1 ## 1; \
410 vpslld $3, x0 ## 1, x4 ## 1; \
411 vpxor x2 ## 1, x3 ## 1, x3 ## 1; \
412 vpxor x4 ## 1, x3 ## 1, x3 ## 1; \
413 get_key(i, 1, RK1); \
414 vpslld $1, x1 ## 2, x4 ## 2; \
415 vpsrld $(32 - 1), x1 ## 2, x1 ## 2; \
416 vpor x4 ## 2, x1 ## 2, x1 ## 2; \
417 vpslld $3, x0 ## 2, x4 ## 2; \
418 vpxor x2 ## 2, x3 ## 2, x3 ## 2; \
419 vpxor x4 ## 2, x3 ## 2, x3 ## 2; \
420 get_key(i, 3, RK3); \
421 vpslld $7, x3 ## 1, x4 ## 1; \
422 vpsrld $(32 - 7), x3 ## 1, x3 ## 1; \
423 vpor x4 ## 1, x3 ## 1, x3 ## 1; \
424 vpslld $7, x1 ## 1, x4 ## 1; \
425 vpxor x1 ## 1, x0 ## 1, x0 ## 1; \
426 vpxor x3 ## 1, x0 ## 1, x0 ## 1; \
427 vpxor x3 ## 1, x2 ## 1, x2 ## 1; \
428 vpxor x4 ## 1, x2 ## 1, x2 ## 1; \
429 get_key(i, 0, RK0); \
430 vpslld $7, x3 ## 2, x4 ## 2; \
431 vpsrld $(32 - 7), x3 ## 2, x3 ## 2; \
432 vpor x4 ## 2, x3 ## 2, x3 ## 2; \
433 vpslld $7, x1 ## 2, x4 ## 2; \
434 vpxor x1 ## 2, x0 ## 2, x0 ## 2; \
435 vpxor x3 ## 2, x0 ## 2, x0 ## 2; \
436 vpxor x3 ## 2, x2 ## 2, x2 ## 2; \
437 vpxor x4 ## 2, x2 ## 2, x2 ## 2; \
438 get_key(i, 2, RK2); \
439 vpxor RK1, x1 ## 1, x1 ## 1; \
440 vpxor RK3, x3 ## 1, x3 ## 1; \
441 vpslld $5, x0 ## 1, x4 ## 1; \
442 vpsrld $(32 - 5), x0 ## 1, x0 ## 1; \
443 vpor x4 ## 1, x0 ## 1, x0 ## 1; \
444 vpslld $22, x2 ## 1, x4 ## 1; \
445 vpsrld $(32 - 22), x2 ## 1, x2 ## 1; \
446 vpor x4 ## 1, x2 ## 1, x2 ## 1; \
447 vpxor RK0, x0 ## 1, x0 ## 1; \
448 vpxor RK2, x2 ## 1, x2 ## 1; \
449 vpxor RK1, x1 ## 2, x1 ## 2; \
450 vpxor RK3, x3 ## 2, x3 ## 2; \
451 vpslld $5, x0 ## 2, x4 ## 2; \
452 vpsrld $(32 - 5), x0 ## 2, x0 ## 2; \
453 vpor x4 ## 2, x0 ## 2, x0 ## 2; \
454 vpslld $22, x2 ## 2, x4 ## 2; \
455 vpsrld $(32 - 22), x2 ## 2, x2 ## 2; \
456 vpor x4 ## 2, x2 ## 2, x2 ## 2; \
457 vpxor RK0, x0 ## 2, x0 ## 2; \
458 vpxor RK2, x2 ## 2, x2 ## 2;
459
460#define KL2(x0, x1, x2, x3, x4, i) \
461 vpxor RK0, x0 ## 1, x0 ## 1; \
462 vpxor RK2, x2 ## 1, x2 ## 1; \
463 vpsrld $5, x0 ## 1, x4 ## 1; \
464 vpslld $(32 - 5), x0 ## 1, x0 ## 1; \
465 vpor x4 ## 1, x0 ## 1, x0 ## 1; \
466 vpxor RK3, x3 ## 1, x3 ## 1; \
467 vpxor RK1, x1 ## 1, x1 ## 1; \
468 vpsrld $22, x2 ## 1, x4 ## 1; \
469 vpslld $(32 - 22), x2 ## 1, x2 ## 1; \
470 vpor x4 ## 1, x2 ## 1, x2 ## 1; \
471 vpxor x3 ## 1, x2 ## 1, x2 ## 1; \
472 vpxor RK0, x0 ## 2, x0 ## 2; \
473 vpxor RK2, x2 ## 2, x2 ## 2; \
474 vpsrld $5, x0 ## 2, x4 ## 2; \
475 vpslld $(32 - 5), x0 ## 2, x0 ## 2; \
476 vpor x4 ## 2, x0 ## 2, x0 ## 2; \
477 vpxor RK3, x3 ## 2, x3 ## 2; \
478 vpxor RK1, x1 ## 2, x1 ## 2; \
479 vpsrld $22, x2 ## 2, x4 ## 2; \
480 vpslld $(32 - 22), x2 ## 2, x2 ## 2; \
481 vpor x4 ## 2, x2 ## 2, x2 ## 2; \
482 vpxor x3 ## 2, x2 ## 2, x2 ## 2; \
483 vpxor x3 ## 1, x0 ## 1, x0 ## 1; \
484 vpslld $7, x1 ## 1, x4 ## 1; \
485 vpxor x1 ## 1, x0 ## 1, x0 ## 1; \
486 vpxor x4 ## 1, x2 ## 1, x2 ## 1; \
487 vpsrld $1, x1 ## 1, x4 ## 1; \
488 vpslld $(32 - 1), x1 ## 1, x1 ## 1; \
489 vpor x4 ## 1, x1 ## 1, x1 ## 1; \
490 vpxor x3 ## 2, x0 ## 2, x0 ## 2; \
491 vpslld $7, x1 ## 2, x4 ## 2; \
492 vpxor x1 ## 2, x0 ## 2, x0 ## 2; \
493 vpxor x4 ## 2, x2 ## 2, x2 ## 2; \
494 vpsrld $1, x1 ## 2, x4 ## 2; \
495 vpslld $(32 - 1), x1 ## 2, x1 ## 2; \
496 vpor x4 ## 2, x1 ## 2, x1 ## 2; \
497 vpsrld $7, x3 ## 1, x4 ## 1; \
498 vpslld $(32 - 7), x3 ## 1, x3 ## 1; \
499 vpor x4 ## 1, x3 ## 1, x3 ## 1; \
500 vpxor x0 ## 1, x1 ## 1, x1 ## 1; \
501 vpslld $3, x0 ## 1, x4 ## 1; \
502 vpxor x4 ## 1, x3 ## 1, x3 ## 1; \
503 vpsrld $7, x3 ## 2, x4 ## 2; \
504 vpslld $(32 - 7), x3 ## 2, x3 ## 2; \
505 vpor x4 ## 2, x3 ## 2, x3 ## 2; \
506 vpxor x0 ## 2, x1 ## 2, x1 ## 2; \
507 vpslld $3, x0 ## 2, x4 ## 2; \
508 vpxor x4 ## 2, x3 ## 2, x3 ## 2; \
509 vpsrld $13, x0 ## 1, x4 ## 1; \
510 vpslld $(32 - 13), x0 ## 1, x0 ## 1; \
511 vpor x4 ## 1, x0 ## 1, x0 ## 1; \
512 vpxor x2 ## 1, x1 ## 1, x1 ## 1; \
513 vpxor x2 ## 1, x3 ## 1, x3 ## 1; \
514 vpsrld $3, x2 ## 1, x4 ## 1; \
515 vpslld $(32 - 3), x2 ## 1, x2 ## 1; \
516 vpor x4 ## 1, x2 ## 1, x2 ## 1; \
517 vpsrld $13, x0 ## 2, x4 ## 2; \
518 vpslld $(32 - 13), x0 ## 2, x0 ## 2; \
519 vpor x4 ## 2, x0 ## 2, x0 ## 2; \
520 vpxor x2 ## 2, x1 ## 2, x1 ## 2; \
521 vpxor x2 ## 2, x3 ## 2, x3 ## 2; \
522 vpsrld $3, x2 ## 2, x4 ## 2; \
523 vpslld $(32 - 3), x2 ## 2, x2 ## 2; \
524 vpor x4 ## 2, x2 ## 2, x2 ## 2;
525
526#define S(SBOX, x0, x1, x2, x3, x4) \
527 SBOX ## _1(x0 ## 1, x1 ## 1, x2 ## 1, x3 ## 1, x4 ## 1); \
528 SBOX ## _2(x0 ## 1, x1 ## 1, x2 ## 1, x3 ## 1, x4 ## 1); \
529 SBOX ## _1(x0 ## 2, x1 ## 2, x2 ## 2, x3 ## 2, x4 ## 2); \
530 SBOX ## _2(x0 ## 2, x1 ## 2, x2 ## 2, x3 ## 2, x4 ## 2);
531
532#define SP(SBOX, x0, x1, x2, x3, x4, i) \
533 get_key(i, 0, RK0); \
534 SBOX ## _1(x0 ## 1, x1 ## 1, x2 ## 1, x3 ## 1, x4 ## 1); \
535 get_key(i, 2, RK2); \
536 SBOX ## _2(x0 ## 1, x1 ## 1, x2 ## 1, x3 ## 1, x4 ## 1); \
537 get_key(i, 3, RK3); \
538 SBOX ## _1(x0 ## 2, x1 ## 2, x2 ## 2, x3 ## 2, x4 ## 2); \
539 get_key(i, 1, RK1); \
540 SBOX ## _2(x0 ## 2, x1 ## 2, x2 ## 2, x3 ## 2, x4 ## 2); \
541
542#define transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \
543 vpunpckldq x1, x0, t0; \
544 vpunpckhdq x1, x0, t2; \
545 vpunpckldq x3, x2, t1; \
546 vpunpckhdq x3, x2, x3; \
547 \
548 vpunpcklqdq t1, t0, x0; \
549 vpunpckhqdq t1, t0, x1; \
550 vpunpcklqdq x3, t2, x2; \
551 vpunpckhqdq x3, t2, x3;
552
553#define read_blocks(in, x0, x1, x2, x3, t0, t1, t2) \
554 vmovdqu (0*4*4)(in), x0; \
555 vmovdqu (1*4*4)(in), x1; \
556 vmovdqu (2*4*4)(in), x2; \
557 vmovdqu (3*4*4)(in), x3; \
558 \
559 transpose_4x4(x0, x1, x2, x3, t0, t1, t2)
560
561#define write_blocks(out, x0, x1, x2, x3, t0, t1, t2) \
562 transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \
563 \
564 vmovdqu x0, (0*4*4)(out); \
565 vmovdqu x1, (1*4*4)(out); \
566 vmovdqu x2, (2*4*4)(out); \
567 vmovdqu x3, (3*4*4)(out);
568
569#define xor_blocks(out, x0, x1, x2, x3, t0, t1, t2) \
570 transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \
571 \
572 vpxor (0*4*4)(out), x0, x0; \
573 vmovdqu x0, (0*4*4)(out); \
574 vpxor (1*4*4)(out), x1, x1; \
575 vmovdqu x1, (1*4*4)(out); \
576 vpxor (2*4*4)(out), x2, x2; \
577 vmovdqu x2, (2*4*4)(out); \
578 vpxor (3*4*4)(out), x3, x3; \
579 vmovdqu x3, (3*4*4)(out);
580
581.align 8
582.global __serpent_enc_blk_8way_avx
583.type __serpent_enc_blk_8way_avx,@function;
584
585__serpent_enc_blk_8way_avx:
586 /* input:
587 * %rdi: ctx, CTX
588 * %rsi: dst
589 * %rdx: src
590 * %rcx: bool, if true: xor output
591 */
592
593 vpcmpeqd RNOT, RNOT, RNOT;
594
595 leaq (4*4*4)(%rdx), %rax;
596 read_blocks(%rdx, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
597 read_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
598
599 K2(RA, RB, RC, RD, RE, 0);
600 S(S0, RA, RB, RC, RD, RE); LK2(RC, RB, RD, RA, RE, 1);
601 S(S1, RC, RB, RD, RA, RE); LK2(RE, RD, RA, RC, RB, 2);
602 S(S2, RE, RD, RA, RC, RB); LK2(RB, RD, RE, RC, RA, 3);
603 S(S3, RB, RD, RE, RC, RA); LK2(RC, RA, RD, RB, RE, 4);
604 S(S4, RC, RA, RD, RB, RE); LK2(RA, RD, RB, RE, RC, 5);
605 S(S5, RA, RD, RB, RE, RC); LK2(RC, RA, RD, RE, RB, 6);
606 S(S6, RC, RA, RD, RE, RB); LK2(RD, RB, RA, RE, RC, 7);
607 S(S7, RD, RB, RA, RE, RC); LK2(RC, RA, RE, RD, RB, 8);
608 S(S0, RC, RA, RE, RD, RB); LK2(RE, RA, RD, RC, RB, 9);
609 S(S1, RE, RA, RD, RC, RB); LK2(RB, RD, RC, RE, RA, 10);
610 S(S2, RB, RD, RC, RE, RA); LK2(RA, RD, RB, RE, RC, 11);
611 S(S3, RA, RD, RB, RE, RC); LK2(RE, RC, RD, RA, RB, 12);
612 S(S4, RE, RC, RD, RA, RB); LK2(RC, RD, RA, RB, RE, 13);
613 S(S5, RC, RD, RA, RB, RE); LK2(RE, RC, RD, RB, RA, 14);
614 S(S6, RE, RC, RD, RB, RA); LK2(RD, RA, RC, RB, RE, 15);
615 S(S7, RD, RA, RC, RB, RE); LK2(RE, RC, RB, RD, RA, 16);
616 S(S0, RE, RC, RB, RD, RA); LK2(RB, RC, RD, RE, RA, 17);
617 S(S1, RB, RC, RD, RE, RA); LK2(RA, RD, RE, RB, RC, 18);
618 S(S2, RA, RD, RE, RB, RC); LK2(RC, RD, RA, RB, RE, 19);
619 S(S3, RC, RD, RA, RB, RE); LK2(RB, RE, RD, RC, RA, 20);
620 S(S4, RB, RE, RD, RC, RA); LK2(RE, RD, RC, RA, RB, 21);
621 S(S5, RE, RD, RC, RA, RB); LK2(RB, RE, RD, RA, RC, 22);
622 S(S6, RB, RE, RD, RA, RC); LK2(RD, RC, RE, RA, RB, 23);
623 S(S7, RD, RC, RE, RA, RB); LK2(RB, RE, RA, RD, RC, 24);
624 S(S0, RB, RE, RA, RD, RC); LK2(RA, RE, RD, RB, RC, 25);
625 S(S1, RA, RE, RD, RB, RC); LK2(RC, RD, RB, RA, RE, 26);
626 S(S2, RC, RD, RB, RA, RE); LK2(RE, RD, RC, RA, RB, 27);
627 S(S3, RE, RD, RC, RA, RB); LK2(RA, RB, RD, RE, RC, 28);
628 S(S4, RA, RB, RD, RE, RC); LK2(RB, RD, RE, RC, RA, 29);
629 S(S5, RB, RD, RE, RC, RA); LK2(RA, RB, RD, RC, RE, 30);
630 S(S6, RA, RB, RD, RC, RE); LK2(RD, RE, RB, RC, RA, 31);
631 S(S7, RD, RE, RB, RC, RA); K2(RA, RB, RC, RD, RE, 32);
632
633 leaq (4*4*4)(%rsi), %rax;
634
635 testb %cl, %cl;
636 jnz __enc_xor8;
637
638 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
639 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
640
641 ret;
642
643__enc_xor8:
644 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
645 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
646
647 ret;
648
649.align 8
650.global serpent_dec_blk_8way_avx
651.type serpent_dec_blk_8way_avx,@function;
652
653serpent_dec_blk_8way_avx:
654 /* input:
655 * %rdi: ctx, CTX
656 * %rsi: dst
657 * %rdx: src
658 */
659
660 vpcmpeqd RNOT, RNOT, RNOT;
661
662 leaq (4*4*4)(%rdx), %rax;
663 read_blocks(%rdx, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
664 read_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
665
666 K2(RA, RB, RC, RD, RE, 32);
667 SP(SI7, RA, RB, RC, RD, RE, 31); KL2(RB, RD, RA, RE, RC, 31);
668 SP(SI6, RB, RD, RA, RE, RC, 30); KL2(RA, RC, RE, RB, RD, 30);
669 SP(SI5, RA, RC, RE, RB, RD, 29); KL2(RC, RD, RA, RE, RB, 29);
670 SP(SI4, RC, RD, RA, RE, RB, 28); KL2(RC, RA, RB, RE, RD, 28);
671 SP(SI3, RC, RA, RB, RE, RD, 27); KL2(RB, RC, RD, RE, RA, 27);
672 SP(SI2, RB, RC, RD, RE, RA, 26); KL2(RC, RA, RE, RD, RB, 26);
673 SP(SI1, RC, RA, RE, RD, RB, 25); KL2(RB, RA, RE, RD, RC, 25);
674 SP(SI0, RB, RA, RE, RD, RC, 24); KL2(RE, RC, RA, RB, RD, 24);
675 SP(SI7, RE, RC, RA, RB, RD, 23); KL2(RC, RB, RE, RD, RA, 23);
676 SP(SI6, RC, RB, RE, RD, RA, 22); KL2(RE, RA, RD, RC, RB, 22);
677 SP(SI5, RE, RA, RD, RC, RB, 21); KL2(RA, RB, RE, RD, RC, 21);
678 SP(SI4, RA, RB, RE, RD, RC, 20); KL2(RA, RE, RC, RD, RB, 20);
679 SP(SI3, RA, RE, RC, RD, RB, 19); KL2(RC, RA, RB, RD, RE, 19);
680 SP(SI2, RC, RA, RB, RD, RE, 18); KL2(RA, RE, RD, RB, RC, 18);
681 SP(SI1, RA, RE, RD, RB, RC, 17); KL2(RC, RE, RD, RB, RA, 17);
682 SP(SI0, RC, RE, RD, RB, RA, 16); KL2(RD, RA, RE, RC, RB, 16);
683 SP(SI7, RD, RA, RE, RC, RB, 15); KL2(RA, RC, RD, RB, RE, 15);
684 SP(SI6, RA, RC, RD, RB, RE, 14); KL2(RD, RE, RB, RA, RC, 14);
685 SP(SI5, RD, RE, RB, RA, RC, 13); KL2(RE, RC, RD, RB, RA, 13);
686 SP(SI4, RE, RC, RD, RB, RA, 12); KL2(RE, RD, RA, RB, RC, 12);
687 SP(SI3, RE, RD, RA, RB, RC, 11); KL2(RA, RE, RC, RB, RD, 11);
688 SP(SI2, RA, RE, RC, RB, RD, 10); KL2(RE, RD, RB, RC, RA, 10);
689 SP(SI1, RE, RD, RB, RC, RA, 9); KL2(RA, RD, RB, RC, RE, 9);
690 SP(SI0, RA, RD, RB, RC, RE, 8); KL2(RB, RE, RD, RA, RC, 8);
691 SP(SI7, RB, RE, RD, RA, RC, 7); KL2(RE, RA, RB, RC, RD, 7);
692 SP(SI6, RE, RA, RB, RC, RD, 6); KL2(RB, RD, RC, RE, RA, 6);
693 SP(SI5, RB, RD, RC, RE, RA, 5); KL2(RD, RA, RB, RC, RE, 5);
694 SP(SI4, RD, RA, RB, RC, RE, 4); KL2(RD, RB, RE, RC, RA, 4);
695 SP(SI3, RD, RB, RE, RC, RA, 3); KL2(RE, RD, RA, RC, RB, 3);
696 SP(SI2, RE, RD, RA, RC, RB, 2); KL2(RD, RB, RC, RA, RE, 2);
697 SP(SI1, RD, RB, RC, RA, RE, 1); KL2(RE, RB, RC, RA, RD, 1);
698 S(SI0, RE, RB, RC, RA, RD); K2(RC, RD, RB, RE, RA, 0);
699
700 leaq (4*4*4)(%rsi), %rax;
701 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
702 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
703
704 ret;
diff --git a/arch/x86/crypto/serpent_avx_glue.c b/arch/x86/crypto/serpent_avx_glue.c
new file mode 100644
index 00000000000..b36bdac237e
--- /dev/null
+++ b/arch/x86/crypto/serpent_avx_glue.c
@@ -0,0 +1,636 @@
1/*
2 * Glue Code for AVX assembler versions of Serpent Cipher
3 *
4 * Copyright (C) 2012 Johannes Goetzfried
5 * <Johannes.Goetzfried@informatik.stud.uni-erlangen.de>
6 *
7 * Glue code based on serpent_sse2_glue.c by:
8 * Copyright (C) 2011 Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
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 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
25 */
26
27#include <linux/module.h>
28#include <linux/hardirq.h>
29#include <linux/types.h>
30#include <linux/crypto.h>
31#include <linux/err.h>
32#include <crypto/algapi.h>
33#include <crypto/serpent.h>
34#include <crypto/cryptd.h>
35#include <crypto/b128ops.h>
36#include <crypto/ctr.h>
37#include <crypto/lrw.h>
38#include <crypto/xts.h>
39#include <asm/xcr.h>
40#include <asm/xsave.h>
41#include <asm/crypto/serpent-avx.h>
42#include <asm/crypto/ablk_helper.h>
43#include <asm/crypto/glue_helper.h>
44
45static void serpent_decrypt_cbc_xway(void *ctx, u128 *dst, const u128 *src)
46{
47 u128 ivs[SERPENT_PARALLEL_BLOCKS - 1];
48 unsigned int j;
49
50 for (j = 0; j < SERPENT_PARALLEL_BLOCKS - 1; j++)
51 ivs[j] = src[j];
52
53 serpent_dec_blk_xway(ctx, (u8 *)dst, (u8 *)src);
54
55 for (j = 0; j < SERPENT_PARALLEL_BLOCKS - 1; j++)
56 u128_xor(dst + (j + 1), dst + (j + 1), ivs + j);
57}
58
59static void serpent_crypt_ctr(void *ctx, u128 *dst, const u128 *src, u128 *iv)
60{
61 be128 ctrblk;
62
63 u128_to_be128(&ctrblk, iv);
64 u128_inc(iv);
65
66 __serpent_encrypt(ctx, (u8 *)&ctrblk, (u8 *)&ctrblk);
67 u128_xor(dst, src, (u128 *)&ctrblk);
68}
69
70static void serpent_crypt_ctr_xway(void *ctx, u128 *dst, const u128 *src,
71 u128 *iv)
72{
73 be128 ctrblks[SERPENT_PARALLEL_BLOCKS];
74 unsigned int i;
75
76 for (i = 0; i < SERPENT_PARALLEL_BLOCKS; i++) {
77 if (dst != src)
78 dst[i] = src[i];
79
80 u128_to_be128(&ctrblks[i], iv);
81 u128_inc(iv);
82 }
83
84 serpent_enc_blk_xway_xor(ctx, (u8 *)dst, (u8 *)ctrblks);
85}
86
87static const struct common_glue_ctx serpent_enc = {
88 .num_funcs = 2,
89 .fpu_blocks_limit = SERPENT_PARALLEL_BLOCKS,
90
91 .funcs = { {
92 .num_blocks = SERPENT_PARALLEL_BLOCKS,
93 .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_enc_blk_xway) }
94 }, {
95 .num_blocks = 1,
96 .fn_u = { .ecb = GLUE_FUNC_CAST(__serpent_encrypt) }
97 } }
98};
99
100static const struct common_glue_ctx serpent_ctr = {
101 .num_funcs = 2,
102 .fpu_blocks_limit = SERPENT_PARALLEL_BLOCKS,
103
104 .funcs = { {
105 .num_blocks = SERPENT_PARALLEL_BLOCKS,
106 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(serpent_crypt_ctr_xway) }
107 }, {
108 .num_blocks = 1,
109 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(serpent_crypt_ctr) }
110 } }
111};
112
113static const struct common_glue_ctx serpent_dec = {
114 .num_funcs = 2,
115 .fpu_blocks_limit = SERPENT_PARALLEL_BLOCKS,
116
117 .funcs = { {
118 .num_blocks = SERPENT_PARALLEL_BLOCKS,
119 .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_dec_blk_xway) }
120 }, {
121 .num_blocks = 1,
122 .fn_u = { .ecb = GLUE_FUNC_CAST(__serpent_decrypt) }
123 } }
124};
125
126static const struct common_glue_ctx serpent_dec_cbc = {
127 .num_funcs = 2,
128 .fpu_blocks_limit = SERPENT_PARALLEL_BLOCKS,
129
130 .funcs = { {
131 .num_blocks = SERPENT_PARALLEL_BLOCKS,
132 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(serpent_decrypt_cbc_xway) }
133 }, {
134 .num_blocks = 1,
135 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(__serpent_decrypt) }
136 } }
137};
138
139static int ecb_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
140 struct scatterlist *src, unsigned int nbytes)
141{
142 return glue_ecb_crypt_128bit(&serpent_enc, desc, dst, src, nbytes);
143}
144
145static int ecb_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
146 struct scatterlist *src, unsigned int nbytes)
147{
148 return glue_ecb_crypt_128bit(&serpent_dec, desc, dst, src, nbytes);
149}
150
151static int cbc_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
152 struct scatterlist *src, unsigned int nbytes)
153{
154 return glue_cbc_encrypt_128bit(GLUE_FUNC_CAST(__serpent_encrypt), desc,
155 dst, src, nbytes);
156}
157
158static int cbc_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
159 struct scatterlist *src, unsigned int nbytes)
160{
161 return glue_cbc_decrypt_128bit(&serpent_dec_cbc, desc, dst, src,
162 nbytes);
163}
164
165static int ctr_crypt(struct blkcipher_desc *desc, struct scatterlist *dst,
166 struct scatterlist *src, unsigned int nbytes)
167{
168 return glue_ctr_crypt_128bit(&serpent_ctr, desc, dst, src, nbytes);
169}
170
171static inline bool serpent_fpu_begin(bool fpu_enabled, unsigned int nbytes)
172{
173 return glue_fpu_begin(SERPENT_BLOCK_SIZE, SERPENT_PARALLEL_BLOCKS,
174 NULL, fpu_enabled, nbytes);
175}
176
177static inline void serpent_fpu_end(bool fpu_enabled)
178{
179 glue_fpu_end(fpu_enabled);
180}
181
182struct crypt_priv {
183 struct serpent_ctx *ctx;
184 bool fpu_enabled;
185};
186
187static void encrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
188{
189 const unsigned int bsize = SERPENT_BLOCK_SIZE;
190 struct crypt_priv *ctx = priv;
191 int i;
192
193 ctx->fpu_enabled = serpent_fpu_begin(ctx->fpu_enabled, nbytes);
194
195 if (nbytes == bsize * SERPENT_PARALLEL_BLOCKS) {
196 serpent_enc_blk_xway(ctx->ctx, srcdst, srcdst);
197 return;
198 }
199
200 for (i = 0; i < nbytes / bsize; i++, srcdst += bsize)
201 __serpent_encrypt(ctx->ctx, srcdst, srcdst);
202}
203
204static void decrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
205{
206 const unsigned int bsize = SERPENT_BLOCK_SIZE;
207 struct crypt_priv *ctx = priv;
208 int i;
209
210 ctx->fpu_enabled = serpent_fpu_begin(ctx->fpu_enabled, nbytes);
211
212 if (nbytes == bsize * SERPENT_PARALLEL_BLOCKS) {
213 serpent_dec_blk_xway(ctx->ctx, srcdst, srcdst);
214 return;
215 }
216
217 for (i = 0; i < nbytes / bsize; i++, srcdst += bsize)
218 __serpent_decrypt(ctx->ctx, srcdst, srcdst);
219}
220
221struct serpent_lrw_ctx {
222 struct lrw_table_ctx lrw_table;
223 struct serpent_ctx serpent_ctx;
224};
225
226static int lrw_serpent_setkey(struct crypto_tfm *tfm, const u8 *key,
227 unsigned int keylen)
228{
229 struct serpent_lrw_ctx *ctx = crypto_tfm_ctx(tfm);
230 int err;
231
232 err = __serpent_setkey(&ctx->serpent_ctx, key, keylen -
233 SERPENT_BLOCK_SIZE);
234 if (err)
235 return err;
236
237 return lrw_init_table(&ctx->lrw_table, key + keylen -
238 SERPENT_BLOCK_SIZE);
239}
240
241static int lrw_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
242 struct scatterlist *src, unsigned int nbytes)
243{
244 struct serpent_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
245 be128 buf[SERPENT_PARALLEL_BLOCKS];
246 struct crypt_priv crypt_ctx = {
247 .ctx = &ctx->serpent_ctx,
248 .fpu_enabled = false,
249 };
250 struct lrw_crypt_req req = {
251 .tbuf = buf,
252 .tbuflen = sizeof(buf),
253
254 .table_ctx = &ctx->lrw_table,
255 .crypt_ctx = &crypt_ctx,
256 .crypt_fn = encrypt_callback,
257 };
258 int ret;
259
260 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
261 ret = lrw_crypt(desc, dst, src, nbytes, &req);
262 serpent_fpu_end(crypt_ctx.fpu_enabled);
263
264 return ret;
265}
266
267static int lrw_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
268 struct scatterlist *src, unsigned int nbytes)
269{
270 struct serpent_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
271 be128 buf[SERPENT_PARALLEL_BLOCKS];
272 struct crypt_priv crypt_ctx = {
273 .ctx = &ctx->serpent_ctx,
274 .fpu_enabled = false,
275 };
276 struct lrw_crypt_req req = {
277 .tbuf = buf,
278 .tbuflen = sizeof(buf),
279
280 .table_ctx = &ctx->lrw_table,
281 .crypt_ctx = &crypt_ctx,
282 .crypt_fn = decrypt_callback,
283 };
284 int ret;
285
286 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
287 ret = lrw_crypt(desc, dst, src, nbytes, &req);
288 serpent_fpu_end(crypt_ctx.fpu_enabled);
289
290 return ret;
291}
292
293static void lrw_exit_tfm(struct crypto_tfm *tfm)
294{
295 struct serpent_lrw_ctx *ctx = crypto_tfm_ctx(tfm);
296
297 lrw_free_table(&ctx->lrw_table);
298}
299
300struct serpent_xts_ctx {
301 struct serpent_ctx tweak_ctx;
302 struct serpent_ctx crypt_ctx;
303};
304
305static int xts_serpent_setkey(struct crypto_tfm *tfm, const u8 *key,
306 unsigned int keylen)
307{
308 struct serpent_xts_ctx *ctx = crypto_tfm_ctx(tfm);
309 u32 *flags = &tfm->crt_flags;
310 int err;
311
312 /* key consists of keys of equal size concatenated, therefore
313 * the length must be even
314 */
315 if (keylen % 2) {
316 *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
317 return -EINVAL;
318 }
319
320 /* first half of xts-key is for crypt */
321 err = __serpent_setkey(&ctx->crypt_ctx, key, keylen / 2);
322 if (err)
323 return err;
324
325 /* second half of xts-key is for tweak */
326 return __serpent_setkey(&ctx->tweak_ctx, key + keylen / 2, keylen / 2);
327}
328
329static int xts_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
330 struct scatterlist *src, unsigned int nbytes)
331{
332 struct serpent_xts_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
333 be128 buf[SERPENT_PARALLEL_BLOCKS];
334 struct crypt_priv crypt_ctx = {
335 .ctx = &ctx->crypt_ctx,
336 .fpu_enabled = false,
337 };
338 struct xts_crypt_req req = {
339 .tbuf = buf,
340 .tbuflen = sizeof(buf),
341
342 .tweak_ctx = &ctx->tweak_ctx,
343 .tweak_fn = XTS_TWEAK_CAST(__serpent_encrypt),
344 .crypt_ctx = &crypt_ctx,
345 .crypt_fn = encrypt_callback,
346 };
347 int ret;
348
349 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
350 ret = xts_crypt(desc, dst, src, nbytes, &req);
351 serpent_fpu_end(crypt_ctx.fpu_enabled);
352
353 return ret;
354}
355
356static int xts_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
357 struct scatterlist *src, unsigned int nbytes)
358{
359 struct serpent_xts_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
360 be128 buf[SERPENT_PARALLEL_BLOCKS];
361 struct crypt_priv crypt_ctx = {
362 .ctx = &ctx->crypt_ctx,
363 .fpu_enabled = false,
364 };
365 struct xts_crypt_req req = {
366 .tbuf = buf,
367 .tbuflen = sizeof(buf),
368
369 .tweak_ctx = &ctx->tweak_ctx,
370 .tweak_fn = XTS_TWEAK_CAST(__serpent_encrypt),
371 .crypt_ctx = &crypt_ctx,
372 .crypt_fn = decrypt_callback,
373 };
374 int ret;
375
376 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
377 ret = xts_crypt(desc, dst, src, nbytes, &req);
378 serpent_fpu_end(crypt_ctx.fpu_enabled);
379
380 return ret;
381}
382
383static struct crypto_alg serpent_algs[10] = { {
384 .cra_name = "__ecb-serpent-avx",
385 .cra_driver_name = "__driver-ecb-serpent-avx",
386 .cra_priority = 0,
387 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
388 .cra_blocksize = SERPENT_BLOCK_SIZE,
389 .cra_ctxsize = sizeof(struct serpent_ctx),
390 .cra_alignmask = 0,
391 .cra_type = &crypto_blkcipher_type,
392 .cra_module = THIS_MODULE,
393 .cra_list = LIST_HEAD_INIT(serpent_algs[0].cra_list),
394 .cra_u = {
395 .blkcipher = {
396 .min_keysize = SERPENT_MIN_KEY_SIZE,
397 .max_keysize = SERPENT_MAX_KEY_SIZE,
398 .setkey = serpent_setkey,
399 .encrypt = ecb_encrypt,
400 .decrypt = ecb_decrypt,
401 },
402 },
403}, {
404 .cra_name = "__cbc-serpent-avx",
405 .cra_driver_name = "__driver-cbc-serpent-avx",
406 .cra_priority = 0,
407 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
408 .cra_blocksize = SERPENT_BLOCK_SIZE,
409 .cra_ctxsize = sizeof(struct serpent_ctx),
410 .cra_alignmask = 0,
411 .cra_type = &crypto_blkcipher_type,
412 .cra_module = THIS_MODULE,
413 .cra_list = LIST_HEAD_INIT(serpent_algs[1].cra_list),
414 .cra_u = {
415 .blkcipher = {
416 .min_keysize = SERPENT_MIN_KEY_SIZE,
417 .max_keysize = SERPENT_MAX_KEY_SIZE,
418 .setkey = serpent_setkey,
419 .encrypt = cbc_encrypt,
420 .decrypt = cbc_decrypt,
421 },
422 },
423}, {
424 .cra_name = "__ctr-serpent-avx",
425 .cra_driver_name = "__driver-ctr-serpent-avx",
426 .cra_priority = 0,
427 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
428 .cra_blocksize = 1,
429 .cra_ctxsize = sizeof(struct serpent_ctx),
430 .cra_alignmask = 0,
431 .cra_type = &crypto_blkcipher_type,
432 .cra_module = THIS_MODULE,
433 .cra_list = LIST_HEAD_INIT(serpent_algs[2].cra_list),
434 .cra_u = {
435 .blkcipher = {
436 .min_keysize = SERPENT_MIN_KEY_SIZE,
437 .max_keysize = SERPENT_MAX_KEY_SIZE,
438 .ivsize = SERPENT_BLOCK_SIZE,
439 .setkey = serpent_setkey,
440 .encrypt = ctr_crypt,
441 .decrypt = ctr_crypt,
442 },
443 },
444}, {
445 .cra_name = "__lrw-serpent-avx",
446 .cra_driver_name = "__driver-lrw-serpent-avx",
447 .cra_priority = 0,
448 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
449 .cra_blocksize = SERPENT_BLOCK_SIZE,
450 .cra_ctxsize = sizeof(struct serpent_lrw_ctx),
451 .cra_alignmask = 0,
452 .cra_type = &crypto_blkcipher_type,
453 .cra_module = THIS_MODULE,
454 .cra_list = LIST_HEAD_INIT(serpent_algs[3].cra_list),
455 .cra_exit = lrw_exit_tfm,
456 .cra_u = {
457 .blkcipher = {
458 .min_keysize = SERPENT_MIN_KEY_SIZE +
459 SERPENT_BLOCK_SIZE,
460 .max_keysize = SERPENT_MAX_KEY_SIZE +
461 SERPENT_BLOCK_SIZE,
462 .ivsize = SERPENT_BLOCK_SIZE,
463 .setkey = lrw_serpent_setkey,
464 .encrypt = lrw_encrypt,
465 .decrypt = lrw_decrypt,
466 },
467 },
468}, {
469 .cra_name = "__xts-serpent-avx",
470 .cra_driver_name = "__driver-xts-serpent-avx",
471 .cra_priority = 0,
472 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
473 .cra_blocksize = SERPENT_BLOCK_SIZE,
474 .cra_ctxsize = sizeof(struct serpent_xts_ctx),
475 .cra_alignmask = 0,
476 .cra_type = &crypto_blkcipher_type,
477 .cra_module = THIS_MODULE,
478 .cra_list = LIST_HEAD_INIT(serpent_algs[4].cra_list),
479 .cra_u = {
480 .blkcipher = {
481 .min_keysize = SERPENT_MIN_KEY_SIZE * 2,
482 .max_keysize = SERPENT_MAX_KEY_SIZE * 2,
483 .ivsize = SERPENT_BLOCK_SIZE,
484 .setkey = xts_serpent_setkey,
485 .encrypt = xts_encrypt,
486 .decrypt = xts_decrypt,
487 },
488 },
489}, {
490 .cra_name = "ecb(serpent)",
491 .cra_driver_name = "ecb-serpent-avx",
492 .cra_priority = 500,
493 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
494 .cra_blocksize = SERPENT_BLOCK_SIZE,
495 .cra_ctxsize = sizeof(struct async_helper_ctx),
496 .cra_alignmask = 0,
497 .cra_type = &crypto_ablkcipher_type,
498 .cra_module = THIS_MODULE,
499 .cra_list = LIST_HEAD_INIT(serpent_algs[5].cra_list),
500 .cra_init = ablk_init,
501 .cra_exit = ablk_exit,
502 .cra_u = {
503 .ablkcipher = {
504 .min_keysize = SERPENT_MIN_KEY_SIZE,
505 .max_keysize = SERPENT_MAX_KEY_SIZE,
506 .setkey = ablk_set_key,
507 .encrypt = ablk_encrypt,
508 .decrypt = ablk_decrypt,
509 },
510 },
511}, {
512 .cra_name = "cbc(serpent)",
513 .cra_driver_name = "cbc-serpent-avx",
514 .cra_priority = 500,
515 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
516 .cra_blocksize = SERPENT_BLOCK_SIZE,
517 .cra_ctxsize = sizeof(struct async_helper_ctx),
518 .cra_alignmask = 0,
519 .cra_type = &crypto_ablkcipher_type,
520 .cra_module = THIS_MODULE,
521 .cra_list = LIST_HEAD_INIT(serpent_algs[6].cra_list),
522 .cra_init = ablk_init,
523 .cra_exit = ablk_exit,
524 .cra_u = {
525 .ablkcipher = {
526 .min_keysize = SERPENT_MIN_KEY_SIZE,
527 .max_keysize = SERPENT_MAX_KEY_SIZE,
528 .ivsize = SERPENT_BLOCK_SIZE,
529 .setkey = ablk_set_key,
530 .encrypt = __ablk_encrypt,
531 .decrypt = ablk_decrypt,
532 },
533 },
534}, {
535 .cra_name = "ctr(serpent)",
536 .cra_driver_name = "ctr-serpent-avx",
537 .cra_priority = 500,
538 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
539 .cra_blocksize = 1,
540 .cra_ctxsize = sizeof(struct async_helper_ctx),
541 .cra_alignmask = 0,
542 .cra_type = &crypto_ablkcipher_type,
543 .cra_module = THIS_MODULE,
544 .cra_list = LIST_HEAD_INIT(serpent_algs[7].cra_list),
545 .cra_init = ablk_init,
546 .cra_exit = ablk_exit,
547 .cra_u = {
548 .ablkcipher = {
549 .min_keysize = SERPENT_MIN_KEY_SIZE,
550 .max_keysize = SERPENT_MAX_KEY_SIZE,
551 .ivsize = SERPENT_BLOCK_SIZE,
552 .setkey = ablk_set_key,
553 .encrypt = ablk_encrypt,
554 .decrypt = ablk_encrypt,
555 .geniv = "chainiv",
556 },
557 },
558}, {
559 .cra_name = "lrw(serpent)",
560 .cra_driver_name = "lrw-serpent-avx",
561 .cra_priority = 500,
562 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
563 .cra_blocksize = SERPENT_BLOCK_SIZE,
564 .cra_ctxsize = sizeof(struct async_helper_ctx),
565 .cra_alignmask = 0,
566 .cra_type = &crypto_ablkcipher_type,
567 .cra_module = THIS_MODULE,
568 .cra_list = LIST_HEAD_INIT(serpent_algs[8].cra_list),
569 .cra_init = ablk_init,
570 .cra_exit = ablk_exit,
571 .cra_u = {
572 .ablkcipher = {
573 .min_keysize = SERPENT_MIN_KEY_SIZE +
574 SERPENT_BLOCK_SIZE,
575 .max_keysize = SERPENT_MAX_KEY_SIZE +
576 SERPENT_BLOCK_SIZE,
577 .ivsize = SERPENT_BLOCK_SIZE,
578 .setkey = ablk_set_key,
579 .encrypt = ablk_encrypt,
580 .decrypt = ablk_decrypt,
581 },
582 },
583}, {
584 .cra_name = "xts(serpent)",
585 .cra_driver_name = "xts-serpent-avx",
586 .cra_priority = 500,
587 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
588 .cra_blocksize = SERPENT_BLOCK_SIZE,
589 .cra_ctxsize = sizeof(struct async_helper_ctx),
590 .cra_alignmask = 0,
591 .cra_type = &crypto_ablkcipher_type,
592 .cra_module = THIS_MODULE,
593 .cra_list = LIST_HEAD_INIT(serpent_algs[9].cra_list),
594 .cra_init = ablk_init,
595 .cra_exit = ablk_exit,
596 .cra_u = {
597 .ablkcipher = {
598 .min_keysize = SERPENT_MIN_KEY_SIZE * 2,
599 .max_keysize = SERPENT_MAX_KEY_SIZE * 2,
600 .ivsize = SERPENT_BLOCK_SIZE,
601 .setkey = ablk_set_key,
602 .encrypt = ablk_encrypt,
603 .decrypt = ablk_decrypt,
604 },
605 },
606} };
607
608static int __init serpent_init(void)
609{
610 u64 xcr0;
611
612 if (!cpu_has_avx || !cpu_has_osxsave) {
613 printk(KERN_INFO "AVX instructions are not detected.\n");
614 return -ENODEV;
615 }
616
617 xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK);
618 if ((xcr0 & (XSTATE_SSE | XSTATE_YMM)) != (XSTATE_SSE | XSTATE_YMM)) {
619 printk(KERN_INFO "AVX detected but unusable.\n");
620 return -ENODEV;
621 }
622
623 return crypto_register_algs(serpent_algs, ARRAY_SIZE(serpent_algs));
624}
625
626static void __exit serpent_exit(void)
627{
628 crypto_unregister_algs(serpent_algs, ARRAY_SIZE(serpent_algs));
629}
630
631module_init(serpent_init);
632module_exit(serpent_exit);
633
634MODULE_DESCRIPTION("Serpent Cipher Algorithm, AVX optimized");
635MODULE_LICENSE("GPL");
636MODULE_ALIAS("serpent");
diff --git a/arch/x86/crypto/serpent_sse2_glue.c b/arch/x86/crypto/serpent_sse2_glue.c
index 4b21be85e0a..d679c8675f4 100644
--- a/arch/x86/crypto/serpent_sse2_glue.c
+++ b/arch/x86/crypto/serpent_sse2_glue.c
@@ -41,358 +41,145 @@
41#include <crypto/ctr.h> 41#include <crypto/ctr.h>
42#include <crypto/lrw.h> 42#include <crypto/lrw.h>
43#include <crypto/xts.h> 43#include <crypto/xts.h>
44#include <asm/i387.h> 44#include <asm/crypto/serpent-sse2.h>
45#include <asm/serpent.h> 45#include <asm/crypto/ablk_helper.h>
46#include <crypto/scatterwalk.h> 46#include <asm/crypto/glue_helper.h>
47#include <linux/workqueue.h>
48#include <linux/spinlock.h>
49
50struct async_serpent_ctx {
51 struct cryptd_ablkcipher *cryptd_tfm;
52};
53 47
54static inline bool serpent_fpu_begin(bool fpu_enabled, unsigned int nbytes) 48static void serpent_decrypt_cbc_xway(void *ctx, u128 *dst, const u128 *src)
55{
56 if (fpu_enabled)
57 return true;
58
59 /* SSE2 is only used when chunk to be processed is large enough, so
60 * do not enable FPU until it is necessary.
61 */
62 if (nbytes < SERPENT_BLOCK_SIZE * SERPENT_PARALLEL_BLOCKS)
63 return false;
64
65 kernel_fpu_begin();
66 return true;
67}
68
69static inline void serpent_fpu_end(bool fpu_enabled)
70{ 49{
71 if (fpu_enabled) 50 u128 ivs[SERPENT_PARALLEL_BLOCKS - 1];
72 kernel_fpu_end(); 51 unsigned int j;
73}
74
75static int ecb_crypt(struct blkcipher_desc *desc, struct blkcipher_walk *walk,
76 bool enc)
77{
78 bool fpu_enabled = false;
79 struct serpent_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
80 const unsigned int bsize = SERPENT_BLOCK_SIZE;
81 unsigned int nbytes;
82 int err;
83
84 err = blkcipher_walk_virt(desc, walk);
85 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
86
87 while ((nbytes = walk->nbytes)) {
88 u8 *wsrc = walk->src.virt.addr;
89 u8 *wdst = walk->dst.virt.addr;
90
91 fpu_enabled = serpent_fpu_begin(fpu_enabled, nbytes);
92
93 /* Process multi-block batch */
94 if (nbytes >= bsize * SERPENT_PARALLEL_BLOCKS) {
95 do {
96 if (enc)
97 serpent_enc_blk_xway(ctx, wdst, wsrc);
98 else
99 serpent_dec_blk_xway(ctx, wdst, wsrc);
100
101 wsrc += bsize * SERPENT_PARALLEL_BLOCKS;
102 wdst += bsize * SERPENT_PARALLEL_BLOCKS;
103 nbytes -= bsize * SERPENT_PARALLEL_BLOCKS;
104 } while (nbytes >= bsize * SERPENT_PARALLEL_BLOCKS);
105
106 if (nbytes < bsize)
107 goto done;
108 }
109
110 /* Handle leftovers */
111 do {
112 if (enc)
113 __serpent_encrypt(ctx, wdst, wsrc);
114 else
115 __serpent_decrypt(ctx, wdst, wsrc);
116
117 wsrc += bsize;
118 wdst += bsize;
119 nbytes -= bsize;
120 } while (nbytes >= bsize);
121
122done:
123 err = blkcipher_walk_done(desc, walk, nbytes);
124 }
125 52
126 serpent_fpu_end(fpu_enabled); 53 for (j = 0; j < SERPENT_PARALLEL_BLOCKS - 1; j++)
127 return err; 54 ivs[j] = src[j];
128}
129 55
130static int ecb_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, 56 serpent_dec_blk_xway(ctx, (u8 *)dst, (u8 *)src);
131 struct scatterlist *src, unsigned int nbytes)
132{
133 struct blkcipher_walk walk;
134 57
135 blkcipher_walk_init(&walk, dst, src, nbytes); 58 for (j = 0; j < SERPENT_PARALLEL_BLOCKS - 1; j++)
136 return ecb_crypt(desc, &walk, true); 59 u128_xor(dst + (j + 1), dst + (j + 1), ivs + j);
137} 60}
138 61
139static int ecb_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, 62static void serpent_crypt_ctr(void *ctx, u128 *dst, const u128 *src, u128 *iv)
140 struct scatterlist *src, unsigned int nbytes)
141{ 63{
142 struct blkcipher_walk walk; 64 be128 ctrblk;
143 65
144 blkcipher_walk_init(&walk, dst, src, nbytes); 66 u128_to_be128(&ctrblk, iv);
145 return ecb_crypt(desc, &walk, false); 67 u128_inc(iv);
146}
147 68
148static unsigned int __cbc_encrypt(struct blkcipher_desc *desc, 69 __serpent_encrypt(ctx, (u8 *)&ctrblk, (u8 *)&ctrblk);
149 struct blkcipher_walk *walk) 70 u128_xor(dst, src, (u128 *)&ctrblk);
150{
151 struct serpent_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
152 const unsigned int bsize = SERPENT_BLOCK_SIZE;
153 unsigned int nbytes = walk->nbytes;
154 u128 *src = (u128 *)walk->src.virt.addr;
155 u128 *dst = (u128 *)walk->dst.virt.addr;
156 u128 *iv = (u128 *)walk->iv;
157
158 do {
159 u128_xor(dst, src, iv);
160 __serpent_encrypt(ctx, (u8 *)dst, (u8 *)dst);
161 iv = dst;
162
163 src += 1;
164 dst += 1;
165 nbytes -= bsize;
166 } while (nbytes >= bsize);
167
168 u128_xor((u128 *)walk->iv, (u128 *)walk->iv, iv);
169 return nbytes;
170} 71}
171 72
172static int cbc_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, 73static void serpent_crypt_ctr_xway(void *ctx, u128 *dst, const u128 *src,
173 struct scatterlist *src, unsigned int nbytes) 74 u128 *iv)
174{ 75{
175 struct blkcipher_walk walk; 76 be128 ctrblks[SERPENT_PARALLEL_BLOCKS];
176 int err; 77 unsigned int i;
177 78
178 blkcipher_walk_init(&walk, dst, src, nbytes); 79 for (i = 0; i < SERPENT_PARALLEL_BLOCKS; i++) {
179 err = blkcipher_walk_virt(desc, &walk); 80 if (dst != src)
81 dst[i] = src[i];
180 82
181 while ((nbytes = walk.nbytes)) { 83 u128_to_be128(&ctrblks[i], iv);
182 nbytes = __cbc_encrypt(desc, &walk); 84 u128_inc(iv);
183 err = blkcipher_walk_done(desc, &walk, nbytes);
184 } 85 }
185 86
186 return err; 87 serpent_enc_blk_xway_xor(ctx, (u8 *)dst, (u8 *)ctrblks);
187} 88}
188 89
189static unsigned int __cbc_decrypt(struct blkcipher_desc *desc, 90static const struct common_glue_ctx serpent_enc = {
190 struct blkcipher_walk *walk) 91 .num_funcs = 2,
191{ 92 .fpu_blocks_limit = SERPENT_PARALLEL_BLOCKS,
192 struct serpent_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
193 const unsigned int bsize = SERPENT_BLOCK_SIZE;
194 unsigned int nbytes = walk->nbytes;
195 u128 *src = (u128 *)walk->src.virt.addr;
196 u128 *dst = (u128 *)walk->dst.virt.addr;
197 u128 ivs[SERPENT_PARALLEL_BLOCKS - 1];
198 u128 last_iv;
199 int i;
200
201 /* Start of the last block. */
202 src += nbytes / bsize - 1;
203 dst += nbytes / bsize - 1;
204
205 last_iv = *src;
206
207 /* Process multi-block batch */
208 if (nbytes >= bsize * SERPENT_PARALLEL_BLOCKS) {
209 do {
210 nbytes -= bsize * (SERPENT_PARALLEL_BLOCKS - 1);
211 src -= SERPENT_PARALLEL_BLOCKS - 1;
212 dst -= SERPENT_PARALLEL_BLOCKS - 1;
213
214 for (i = 0; i < SERPENT_PARALLEL_BLOCKS - 1; i++)
215 ivs[i] = src[i];
216
217 serpent_dec_blk_xway(ctx, (u8 *)dst, (u8 *)src);
218
219 for (i = 0; i < SERPENT_PARALLEL_BLOCKS - 1; i++)
220 u128_xor(dst + (i + 1), dst + (i + 1), ivs + i);
221
222 nbytes -= bsize;
223 if (nbytes < bsize)
224 goto done;
225 93
226 u128_xor(dst, dst, src - 1); 94 .funcs = { {
227 src -= 1; 95 .num_blocks = SERPENT_PARALLEL_BLOCKS,
228 dst -= 1; 96 .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_enc_blk_xway) }
229 } while (nbytes >= bsize * SERPENT_PARALLEL_BLOCKS); 97 }, {
230 98 .num_blocks = 1,
231 if (nbytes < bsize) 99 .fn_u = { .ecb = GLUE_FUNC_CAST(__serpent_encrypt) }
232 goto done; 100 } }
233 } 101};
234
235 /* Handle leftovers */
236 for (;;) {
237 __serpent_decrypt(ctx, (u8 *)dst, (u8 *)src);
238
239 nbytes -= bsize;
240 if (nbytes < bsize)
241 break;
242 102
243 u128_xor(dst, dst, src - 1); 103static const struct common_glue_ctx serpent_ctr = {
244 src -= 1; 104 .num_funcs = 2,
245 dst -= 1; 105 .fpu_blocks_limit = SERPENT_PARALLEL_BLOCKS,
246 } 106
107 .funcs = { {
108 .num_blocks = SERPENT_PARALLEL_BLOCKS,
109 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(serpent_crypt_ctr_xway) }
110 }, {
111 .num_blocks = 1,
112 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(serpent_crypt_ctr) }
113 } }
114};
247 115
248done: 116static const struct common_glue_ctx serpent_dec = {
249 u128_xor(dst, dst, (u128 *)walk->iv); 117 .num_funcs = 2,
250 *(u128 *)walk->iv = last_iv; 118 .fpu_blocks_limit = SERPENT_PARALLEL_BLOCKS,
119
120 .funcs = { {
121 .num_blocks = SERPENT_PARALLEL_BLOCKS,
122 .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_dec_blk_xway) }
123 }, {
124 .num_blocks = 1,
125 .fn_u = { .ecb = GLUE_FUNC_CAST(__serpent_decrypt) }
126 } }
127};
251 128
252 return nbytes; 129static const struct common_glue_ctx serpent_dec_cbc = {
253} 130 .num_funcs = 2,
131 .fpu_blocks_limit = SERPENT_PARALLEL_BLOCKS,
132
133 .funcs = { {
134 .num_blocks = SERPENT_PARALLEL_BLOCKS,
135 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(serpent_decrypt_cbc_xway) }
136 }, {
137 .num_blocks = 1,
138 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(__serpent_decrypt) }
139 } }
140};
254 141
255static int cbc_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, 142static int ecb_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
256 struct scatterlist *src, unsigned int nbytes) 143 struct scatterlist *src, unsigned int nbytes)
257{ 144{
258 bool fpu_enabled = false; 145 return glue_ecb_crypt_128bit(&serpent_enc, desc, dst, src, nbytes);
259 struct blkcipher_walk walk;
260 int err;
261
262 blkcipher_walk_init(&walk, dst, src, nbytes);
263 err = blkcipher_walk_virt(desc, &walk);
264 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
265
266 while ((nbytes = walk.nbytes)) {
267 fpu_enabled = serpent_fpu_begin(fpu_enabled, nbytes);
268 nbytes = __cbc_decrypt(desc, &walk);
269 err = blkcipher_walk_done(desc, &walk, nbytes);
270 }
271
272 serpent_fpu_end(fpu_enabled);
273 return err;
274} 146}
275 147
276static inline void u128_to_be128(be128 *dst, const u128 *src) 148static int ecb_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
149 struct scatterlist *src, unsigned int nbytes)
277{ 150{
278 dst->a = cpu_to_be64(src->a); 151 return glue_ecb_crypt_128bit(&serpent_dec, desc, dst, src, nbytes);
279 dst->b = cpu_to_be64(src->b);
280} 152}
281 153
282static inline void be128_to_u128(u128 *dst, const be128 *src) 154static int cbc_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
155 struct scatterlist *src, unsigned int nbytes)
283{ 156{
284 dst->a = be64_to_cpu(src->a); 157 return glue_cbc_encrypt_128bit(GLUE_FUNC_CAST(__serpent_encrypt), desc,
285 dst->b = be64_to_cpu(src->b); 158 dst, src, nbytes);
286} 159}
287 160
288static inline void u128_inc(u128 *i) 161static int cbc_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
162 struct scatterlist *src, unsigned int nbytes)
289{ 163{
290 i->b++; 164 return glue_cbc_decrypt_128bit(&serpent_dec_cbc, desc, dst, src,
291 if (!i->b) 165 nbytes);
292 i->a++;
293} 166}
294 167
295static void ctr_crypt_final(struct blkcipher_desc *desc, 168static int ctr_crypt(struct blkcipher_desc *desc, struct scatterlist *dst,
296 struct blkcipher_walk *walk) 169 struct scatterlist *src, unsigned int nbytes)
297{ 170{
298 struct serpent_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); 171 return glue_ctr_crypt_128bit(&serpent_ctr, desc, dst, src, nbytes);
299 u8 *ctrblk = walk->iv;
300 u8 keystream[SERPENT_BLOCK_SIZE];
301 u8 *src = walk->src.virt.addr;
302 u8 *dst = walk->dst.virt.addr;
303 unsigned int nbytes = walk->nbytes;
304
305 __serpent_encrypt(ctx, keystream, ctrblk);
306 crypto_xor(keystream, src, nbytes);
307 memcpy(dst, keystream, nbytes);
308
309 crypto_inc(ctrblk, SERPENT_BLOCK_SIZE);
310} 172}
311 173
312static unsigned int __ctr_crypt(struct blkcipher_desc *desc, 174static inline bool serpent_fpu_begin(bool fpu_enabled, unsigned int nbytes)
313 struct blkcipher_walk *walk)
314{ 175{
315 struct serpent_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); 176 return glue_fpu_begin(SERPENT_BLOCK_SIZE, SERPENT_PARALLEL_BLOCKS,
316 const unsigned int bsize = SERPENT_BLOCK_SIZE; 177 NULL, fpu_enabled, nbytes);
317 unsigned int nbytes = walk->nbytes;
318 u128 *src = (u128 *)walk->src.virt.addr;
319 u128 *dst = (u128 *)walk->dst.virt.addr;
320 u128 ctrblk;
321 be128 ctrblocks[SERPENT_PARALLEL_BLOCKS];
322 int i;
323
324 be128_to_u128(&ctrblk, (be128 *)walk->iv);
325
326 /* Process multi-block batch */
327 if (nbytes >= bsize * SERPENT_PARALLEL_BLOCKS) {
328 do {
329 /* create ctrblks for parallel encrypt */
330 for (i = 0; i < SERPENT_PARALLEL_BLOCKS; i++) {
331 if (dst != src)
332 dst[i] = src[i];
333
334 u128_to_be128(&ctrblocks[i], &ctrblk);
335 u128_inc(&ctrblk);
336 }
337
338 serpent_enc_blk_xway_xor(ctx, (u8 *)dst,
339 (u8 *)ctrblocks);
340
341 src += SERPENT_PARALLEL_BLOCKS;
342 dst += SERPENT_PARALLEL_BLOCKS;
343 nbytes -= bsize * SERPENT_PARALLEL_BLOCKS;
344 } while (nbytes >= bsize * SERPENT_PARALLEL_BLOCKS);
345
346 if (nbytes < bsize)
347 goto done;
348 }
349
350 /* Handle leftovers */
351 do {
352 if (dst != src)
353 *dst = *src;
354
355 u128_to_be128(&ctrblocks[0], &ctrblk);
356 u128_inc(&ctrblk);
357
358 __serpent_encrypt(ctx, (u8 *)ctrblocks, (u8 *)ctrblocks);
359 u128_xor(dst, dst, (u128 *)ctrblocks);
360
361 src += 1;
362 dst += 1;
363 nbytes -= bsize;
364 } while (nbytes >= bsize);
365
366done:
367 u128_to_be128((be128 *)walk->iv, &ctrblk);
368 return nbytes;
369} 178}
370 179
371static int ctr_crypt(struct blkcipher_desc *desc, struct scatterlist *dst, 180static inline void serpent_fpu_end(bool fpu_enabled)
372 struct scatterlist *src, unsigned int nbytes)
373{ 181{
374 bool fpu_enabled = false; 182 glue_fpu_end(fpu_enabled);
375 struct blkcipher_walk walk;
376 int err;
377
378 blkcipher_walk_init(&walk, dst, src, nbytes);
379 err = blkcipher_walk_virt_block(desc, &walk, SERPENT_BLOCK_SIZE);
380 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
381
382 while ((nbytes = walk.nbytes) >= SERPENT_BLOCK_SIZE) {
383 fpu_enabled = serpent_fpu_begin(fpu_enabled, nbytes);
384 nbytes = __ctr_crypt(desc, &walk);
385 err = blkcipher_walk_done(desc, &walk, nbytes);
386 }
387
388 serpent_fpu_end(fpu_enabled);
389
390 if (walk.nbytes) {
391 ctr_crypt_final(desc, &walk);
392 err = blkcipher_walk_done(desc, &walk, 0);
393 }
394
395 return err;
396} 183}
397 184
398struct crypt_priv { 185struct crypt_priv {
@@ -596,106 +383,6 @@ static int xts_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
596 return ret; 383 return ret;
597} 384}
598 385
599static int ablk_set_key(struct crypto_ablkcipher *tfm, const u8 *key,
600 unsigned int key_len)
601{
602 struct async_serpent_ctx *ctx = crypto_ablkcipher_ctx(tfm);
603 struct crypto_ablkcipher *child = &ctx->cryptd_tfm->base;
604 int err;
605
606 crypto_ablkcipher_clear_flags(child, CRYPTO_TFM_REQ_MASK);
607 crypto_ablkcipher_set_flags(child, crypto_ablkcipher_get_flags(tfm)
608 & CRYPTO_TFM_REQ_MASK);
609 err = crypto_ablkcipher_setkey(child, key, key_len);
610 crypto_ablkcipher_set_flags(tfm, crypto_ablkcipher_get_flags(child)
611 & CRYPTO_TFM_RES_MASK);
612 return err;
613}
614
615static int __ablk_encrypt(struct ablkcipher_request *req)
616{
617 struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req);
618 struct async_serpent_ctx *ctx = crypto_ablkcipher_ctx(tfm);
619 struct blkcipher_desc desc;
620
621 desc.tfm = cryptd_ablkcipher_child(ctx->cryptd_tfm);
622 desc.info = req->info;
623 desc.flags = 0;
624
625 return crypto_blkcipher_crt(desc.tfm)->encrypt(
626 &desc, req->dst, req->src, req->nbytes);
627}
628
629static int ablk_encrypt(struct ablkcipher_request *req)
630{
631 struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req);
632 struct async_serpent_ctx *ctx = crypto_ablkcipher_ctx(tfm);
633
634 if (!irq_fpu_usable()) {
635 struct ablkcipher_request *cryptd_req =
636 ablkcipher_request_ctx(req);
637
638 memcpy(cryptd_req, req, sizeof(*req));
639 ablkcipher_request_set_tfm(cryptd_req, &ctx->cryptd_tfm->base);
640
641 return crypto_ablkcipher_encrypt(cryptd_req);
642 } else {
643 return __ablk_encrypt(req);
644 }
645}
646
647static int ablk_decrypt(struct ablkcipher_request *req)
648{
649 struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req);
650 struct async_serpent_ctx *ctx = crypto_ablkcipher_ctx(tfm);
651
652 if (!irq_fpu_usable()) {
653 struct ablkcipher_request *cryptd_req =
654 ablkcipher_request_ctx(req);
655
656 memcpy(cryptd_req, req, sizeof(*req));
657 ablkcipher_request_set_tfm(cryptd_req, &ctx->cryptd_tfm->base);
658
659 return crypto_ablkcipher_decrypt(cryptd_req);
660 } else {
661 struct blkcipher_desc desc;
662
663 desc.tfm = cryptd_ablkcipher_child(ctx->cryptd_tfm);
664 desc.info = req->info;
665 desc.flags = 0;
666
667 return crypto_blkcipher_crt(desc.tfm)->decrypt(
668 &desc, req->dst, req->src, req->nbytes);
669 }
670}
671
672static void ablk_exit(struct crypto_tfm *tfm)
673{
674 struct async_serpent_ctx *ctx = crypto_tfm_ctx(tfm);
675
676 cryptd_free_ablkcipher(ctx->cryptd_tfm);
677}
678
679static int ablk_init(struct crypto_tfm *tfm)
680{
681 struct async_serpent_ctx *ctx = crypto_tfm_ctx(tfm);
682 struct cryptd_ablkcipher *cryptd_tfm;
683 char drv_name[CRYPTO_MAX_ALG_NAME];
684
685 snprintf(drv_name, sizeof(drv_name), "__driver-%s",
686 crypto_tfm_alg_driver_name(tfm));
687
688 cryptd_tfm = cryptd_alloc_ablkcipher(drv_name, 0, 0);
689 if (IS_ERR(cryptd_tfm))
690 return PTR_ERR(cryptd_tfm);
691
692 ctx->cryptd_tfm = cryptd_tfm;
693 tfm->crt_ablkcipher.reqsize = sizeof(struct ablkcipher_request) +
694 crypto_ablkcipher_reqsize(&cryptd_tfm->base);
695
696 return 0;
697}
698
699static struct crypto_alg serpent_algs[10] = { { 386static struct crypto_alg serpent_algs[10] = { {
700 .cra_name = "__ecb-serpent-sse2", 387 .cra_name = "__ecb-serpent-sse2",
701 .cra_driver_name = "__driver-ecb-serpent-sse2", 388 .cra_driver_name = "__driver-ecb-serpent-sse2",
@@ -808,7 +495,7 @@ static struct crypto_alg serpent_algs[10] = { {
808 .cra_priority = 400, 495 .cra_priority = 400,
809 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, 496 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
810 .cra_blocksize = SERPENT_BLOCK_SIZE, 497 .cra_blocksize = SERPENT_BLOCK_SIZE,
811 .cra_ctxsize = sizeof(struct async_serpent_ctx), 498 .cra_ctxsize = sizeof(struct async_helper_ctx),
812 .cra_alignmask = 0, 499 .cra_alignmask = 0,
813 .cra_type = &crypto_ablkcipher_type, 500 .cra_type = &crypto_ablkcipher_type,
814 .cra_module = THIS_MODULE, 501 .cra_module = THIS_MODULE,
@@ -830,7 +517,7 @@ static struct crypto_alg serpent_algs[10] = { {
830 .cra_priority = 400, 517 .cra_priority = 400,
831 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, 518 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
832 .cra_blocksize = SERPENT_BLOCK_SIZE, 519 .cra_blocksize = SERPENT_BLOCK_SIZE,
833 .cra_ctxsize = sizeof(struct async_serpent_ctx), 520 .cra_ctxsize = sizeof(struct async_helper_ctx),
834 .cra_alignmask = 0, 521 .cra_alignmask = 0,
835 .cra_type = &crypto_ablkcipher_type, 522 .cra_type = &crypto_ablkcipher_type,
836 .cra_module = THIS_MODULE, 523 .cra_module = THIS_MODULE,
@@ -853,7 +540,7 @@ static struct crypto_alg serpent_algs[10] = { {
853 .cra_priority = 400, 540 .cra_priority = 400,
854 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, 541 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
855 .cra_blocksize = 1, 542 .cra_blocksize = 1,
856 .cra_ctxsize = sizeof(struct async_serpent_ctx), 543 .cra_ctxsize = sizeof(struct async_helper_ctx),
857 .cra_alignmask = 0, 544 .cra_alignmask = 0,
858 .cra_type = &crypto_ablkcipher_type, 545 .cra_type = &crypto_ablkcipher_type,
859 .cra_module = THIS_MODULE, 546 .cra_module = THIS_MODULE,
@@ -877,7 +564,7 @@ static struct crypto_alg serpent_algs[10] = { {
877 .cra_priority = 400, 564 .cra_priority = 400,
878 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, 565 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
879 .cra_blocksize = SERPENT_BLOCK_SIZE, 566 .cra_blocksize = SERPENT_BLOCK_SIZE,
880 .cra_ctxsize = sizeof(struct async_serpent_ctx), 567 .cra_ctxsize = sizeof(struct async_helper_ctx),
881 .cra_alignmask = 0, 568 .cra_alignmask = 0,
882 .cra_type = &crypto_ablkcipher_type, 569 .cra_type = &crypto_ablkcipher_type,
883 .cra_module = THIS_MODULE, 570 .cra_module = THIS_MODULE,
@@ -902,7 +589,7 @@ static struct crypto_alg serpent_algs[10] = { {
902 .cra_priority = 400, 589 .cra_priority = 400,
903 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, 590 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
904 .cra_blocksize = SERPENT_BLOCK_SIZE, 591 .cra_blocksize = SERPENT_BLOCK_SIZE,
905 .cra_ctxsize = sizeof(struct async_serpent_ctx), 592 .cra_ctxsize = sizeof(struct async_helper_ctx),
906 .cra_alignmask = 0, 593 .cra_alignmask = 0,
907 .cra_type = &crypto_ablkcipher_type, 594 .cra_type = &crypto_ablkcipher_type,
908 .cra_module = THIS_MODULE, 595 .cra_module = THIS_MODULE,
diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
index b2c2f57d70e..49d6987a73d 100644
--- a/arch/x86/crypto/sha1_ssse3_asm.S
+++ b/arch/x86/crypto/sha1_ssse3_asm.S
@@ -468,7 +468,7 @@ W_PRECALC_SSSE3
468 */ 468 */
469SHA1_VECTOR_ASM sha1_transform_ssse3 469SHA1_VECTOR_ASM sha1_transform_ssse3
470 470
471#ifdef SHA1_ENABLE_AVX_SUPPORT 471#ifdef CONFIG_AS_AVX
472 472
473.macro W_PRECALC_AVX 473.macro W_PRECALC_AVX
474 474
diff --git a/arch/x86/crypto/sha1_ssse3_glue.c b/arch/x86/crypto/sha1_ssse3_glue.c
index f916499d0ab..4a11a9d7245 100644
--- a/arch/x86/crypto/sha1_ssse3_glue.c
+++ b/arch/x86/crypto/sha1_ssse3_glue.c
@@ -35,7 +35,7 @@
35 35
36asmlinkage void sha1_transform_ssse3(u32 *digest, const char *data, 36asmlinkage void sha1_transform_ssse3(u32 *digest, const char *data,
37 unsigned int rounds); 37 unsigned int rounds);
38#ifdef SHA1_ENABLE_AVX_SUPPORT 38#ifdef CONFIG_AS_AVX
39asmlinkage void sha1_transform_avx(u32 *digest, const char *data, 39asmlinkage void sha1_transform_avx(u32 *digest, const char *data,
40 unsigned int rounds); 40 unsigned int rounds);
41#endif 41#endif
@@ -184,7 +184,7 @@ static struct shash_alg alg = {
184 } 184 }
185}; 185};
186 186
187#ifdef SHA1_ENABLE_AVX_SUPPORT 187#ifdef CONFIG_AS_AVX
188static bool __init avx_usable(void) 188static bool __init avx_usable(void)
189{ 189{
190 u64 xcr0; 190 u64 xcr0;
@@ -209,7 +209,7 @@ static int __init sha1_ssse3_mod_init(void)
209 if (cpu_has_ssse3) 209 if (cpu_has_ssse3)
210 sha1_transform_asm = sha1_transform_ssse3; 210 sha1_transform_asm = sha1_transform_ssse3;
211 211
212#ifdef SHA1_ENABLE_AVX_SUPPORT 212#ifdef CONFIG_AS_AVX
213 /* allow AVX to override SSSE3, it's a little faster */ 213 /* allow AVX to override SSSE3, it's a little faster */
214 if (avx_usable()) 214 if (avx_usable())
215 sha1_transform_asm = sha1_transform_avx; 215 sha1_transform_asm = sha1_transform_avx;
diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
new file mode 100644
index 00000000000..35f45574390
--- /dev/null
+++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
@@ -0,0 +1,300 @@
1/*
2 * Twofish Cipher 8-way parallel algorithm (AVX/x86_64)
3 *
4 * Copyright (C) 2012 Johannes Goetzfried
5 * <Johannes.Goetzfried@informatik.stud.uni-erlangen.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 as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 */
23
24.file "twofish-avx-x86_64-asm_64.S"
25.text
26
27/* structure of crypto context */
28#define s0 0
29#define s1 1024
30#define s2 2048
31#define s3 3072
32#define w 4096
33#define k 4128
34
35/**********************************************************************
36 8-way AVX twofish
37 **********************************************************************/
38#define CTX %rdi
39
40#define RA1 %xmm0
41#define RB1 %xmm1
42#define RC1 %xmm2
43#define RD1 %xmm3
44
45#define RA2 %xmm4
46#define RB2 %xmm5
47#define RC2 %xmm6
48#define RD2 %xmm7
49
50#define RX %xmm8
51#define RY %xmm9
52
53#define RK1 %xmm10
54#define RK2 %xmm11
55
56#define RID1 %rax
57#define RID1b %al
58#define RID2 %rbx
59#define RID2b %bl
60
61#define RGI1 %rdx
62#define RGI1bl %dl
63#define RGI1bh %dh
64#define RGI2 %rcx
65#define RGI2bl %cl
66#define RGI2bh %ch
67
68#define RGS1 %r8
69#define RGS1d %r8d
70#define RGS2 %r9
71#define RGS2d %r9d
72#define RGS3 %r10
73#define RGS3d %r10d
74
75
76#define lookup_32bit(t0, t1, t2, t3, src, dst) \
77 movb src ## bl, RID1b; \
78 movb src ## bh, RID2b; \
79 movl t0(CTX, RID1, 4), dst ## d; \
80 xorl t1(CTX, RID2, 4), dst ## d; \
81 shrq $16, src; \
82 movb src ## bl, RID1b; \
83 movb src ## bh, RID2b; \
84 xorl t2(CTX, RID1, 4), dst ## d; \
85 xorl t3(CTX, RID2, 4), dst ## d;
86
87#define G(a, x, t0, t1, t2, t3) \
88 vmovq a, RGI1; \
89 vpsrldq $8, a, x; \
90 vmovq x, RGI2; \
91 \
92 lookup_32bit(t0, t1, t2, t3, RGI1, RGS1); \
93 shrq $16, RGI1; \
94 lookup_32bit(t0, t1, t2, t3, RGI1, RGS2); \
95 shlq $32, RGS2; \
96 orq RGS1, RGS2; \
97 \
98 lookup_32bit(t0, t1, t2, t3, RGI2, RGS1); \
99 shrq $16, RGI2; \
100 lookup_32bit(t0, t1, t2, t3, RGI2, RGS3); \
101 shlq $32, RGS3; \
102 orq RGS1, RGS3; \
103 \
104 vmovq RGS2, x; \
105 vpinsrq $1, RGS3, x, x;
106
107#define encround(a, b, c, d, x, y) \
108 G(a, x, s0, s1, s2, s3); \
109 G(b, y, s1, s2, s3, s0); \
110 vpaddd x, y, x; \
111 vpaddd y, x, y; \
112 vpaddd x, RK1, x; \
113 vpaddd y, RK2, y; \
114 vpxor x, c, c; \
115 vpsrld $1, c, x; \
116 vpslld $(32 - 1), c, c; \
117 vpor c, x, c; \
118 vpslld $1, d, x; \
119 vpsrld $(32 - 1), d, d; \
120 vpor d, x, d; \
121 vpxor d, y, d;
122
123#define decround(a, b, c, d, x, y) \
124 G(a, x, s0, s1, s2, s3); \
125 G(b, y, s1, s2, s3, s0); \
126 vpaddd x, y, x; \
127 vpaddd y, x, y; \
128 vpaddd y, RK2, y; \
129 vpxor d, y, d; \
130 vpsrld $1, d, y; \
131 vpslld $(32 - 1), d, d; \
132 vpor d, y, d; \
133 vpslld $1, c, y; \
134 vpsrld $(32 - 1), c, c; \
135 vpor c, y, c; \
136 vpaddd x, RK1, x; \
137 vpxor x, c, c;
138
139#define encrypt_round(n, a, b, c, d) \
140 vbroadcastss (k+4*(2*(n)))(CTX), RK1; \
141 vbroadcastss (k+4*(2*(n)+1))(CTX), RK2; \
142 encround(a ## 1, b ## 1, c ## 1, d ## 1, RX, RY); \
143 encround(a ## 2, b ## 2, c ## 2, d ## 2, RX, RY);
144
145#define decrypt_round(n, a, b, c, d) \
146 vbroadcastss (k+4*(2*(n)))(CTX), RK1; \
147 vbroadcastss (k+4*(2*(n)+1))(CTX), RK2; \
148 decround(a ## 1, b ## 1, c ## 1, d ## 1, RX, RY); \
149 decround(a ## 2, b ## 2, c ## 2, d ## 2, RX, RY);
150
151#define encrypt_cycle(n) \
152 encrypt_round((2*n), RA, RB, RC, RD); \
153 encrypt_round(((2*n) + 1), RC, RD, RA, RB);
154
155#define decrypt_cycle(n) \
156 decrypt_round(((2*n) + 1), RC, RD, RA, RB); \
157 decrypt_round((2*n), RA, RB, RC, RD);
158
159
160#define transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \
161 vpunpckldq x1, x0, t0; \
162 vpunpckhdq x1, x0, t2; \
163 vpunpckldq x3, x2, t1; \
164 vpunpckhdq x3, x2, x3; \
165 \
166 vpunpcklqdq t1, t0, x0; \
167 vpunpckhqdq t1, t0, x1; \
168 vpunpcklqdq x3, t2, x2; \
169 vpunpckhqdq x3, t2, x3;
170
171#define inpack_blocks(in, x0, x1, x2, x3, wkey, t0, t1, t2) \
172 vpxor (0*4*4)(in), wkey, x0; \
173 vpxor (1*4*4)(in), wkey, x1; \
174 vpxor (2*4*4)(in), wkey, x2; \
175 vpxor (3*4*4)(in), wkey, x3; \
176 \
177 transpose_4x4(x0, x1, x2, x3, t0, t1, t2)
178
179#define outunpack_blocks(out, x0, x1, x2, x3, wkey, t0, t1, t2) \
180 transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \
181 \
182 vpxor x0, wkey, x0; \
183 vmovdqu x0, (0*4*4)(out); \
184 vpxor x1, wkey, x1; \
185 vmovdqu x1, (1*4*4)(out); \
186 vpxor x2, wkey, x2; \
187 vmovdqu x2, (2*4*4)(out); \
188 vpxor x3, wkey, x3; \
189 vmovdqu x3, (3*4*4)(out);
190
191#define outunpack_xor_blocks(out, x0, x1, x2, x3, wkey, t0, t1, t2) \
192 transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \
193 \
194 vpxor x0, wkey, x0; \
195 vpxor (0*4*4)(out), x0, x0; \
196 vmovdqu x0, (0*4*4)(out); \
197 vpxor x1, wkey, x1; \
198 vpxor (1*4*4)(out), x1, x1; \
199 vmovdqu x1, (1*4*4)(out); \
200 vpxor x2, wkey, x2; \
201 vpxor (2*4*4)(out), x2, x2; \
202 vmovdqu x2, (2*4*4)(out); \
203 vpxor x3, wkey, x3; \
204 vpxor (3*4*4)(out), x3, x3; \
205 vmovdqu x3, (3*4*4)(out);
206
207.align 8
208.global __twofish_enc_blk_8way
209.type __twofish_enc_blk_8way,@function;
210
211__twofish_enc_blk_8way:
212 /* input:
213 * %rdi: ctx, CTX
214 * %rsi: dst
215 * %rdx: src
216 * %rcx: bool, if true: xor output
217 */
218
219 pushq %rbx;
220 pushq %rcx;
221
222 vmovdqu w(CTX), RK1;
223
224 leaq (4*4*4)(%rdx), %rax;
225 inpack_blocks(%rdx, RA1, RB1, RC1, RD1, RK1, RX, RY, RK2);
226 inpack_blocks(%rax, RA2, RB2, RC2, RD2, RK1, RX, RY, RK2);
227
228 xorq RID1, RID1;
229 xorq RID2, RID2;
230
231 encrypt_cycle(0);
232 encrypt_cycle(1);
233 encrypt_cycle(2);
234 encrypt_cycle(3);
235 encrypt_cycle(4);
236 encrypt_cycle(5);
237 encrypt_cycle(6);
238 encrypt_cycle(7);
239
240 vmovdqu (w+4*4)(CTX), RK1;
241
242 popq %rcx;
243 popq %rbx;
244
245 leaq (4*4*4)(%rsi), %rax;
246
247 testb %cl, %cl;
248 jnz __enc_xor8;
249
250 outunpack_blocks(%rsi, RC1, RD1, RA1, RB1, RK1, RX, RY, RK2);
251 outunpack_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX, RY, RK2);
252
253 ret;
254
255__enc_xor8:
256 outunpack_xor_blocks(%rsi, RC1, RD1, RA1, RB1, RK1, RX, RY, RK2);
257 outunpack_xor_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX, RY, RK2);
258
259 ret;
260
261.align 8
262.global twofish_dec_blk_8way
263.type twofish_dec_blk_8way,@function;
264
265twofish_dec_blk_8way:
266 /* input:
267 * %rdi: ctx, CTX
268 * %rsi: dst
269 * %rdx: src
270 */
271
272 pushq %rbx;
273
274 vmovdqu (w+4*4)(CTX), RK1;
275
276 leaq (4*4*4)(%rdx), %rax;
277 inpack_blocks(%rdx, RC1, RD1, RA1, RB1, RK1, RX, RY, RK2);
278 inpack_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX, RY, RK2);
279
280 xorq RID1, RID1;
281 xorq RID2, RID2;
282
283 decrypt_cycle(7);
284 decrypt_cycle(6);
285 decrypt_cycle(5);
286 decrypt_cycle(4);
287 decrypt_cycle(3);
288 decrypt_cycle(2);
289 decrypt_cycle(1);
290 decrypt_cycle(0);
291
292 vmovdqu (w)(CTX), RK1;
293
294 popq %rbx;
295
296 leaq (4*4*4)(%rsi), %rax;
297 outunpack_blocks(%rsi, RA1, RB1, RC1, RD1, RK1, RX, RY, RK2);
298 outunpack_blocks(%rax, RA2, RB2, RC2, RD2, RK1, RX, RY, RK2);
299
300 ret;
diff --git a/arch/x86/crypto/twofish_avx_glue.c b/arch/x86/crypto/twofish_avx_glue.c
new file mode 100644
index 00000000000..782b67ddaf6
--- /dev/null
+++ b/arch/x86/crypto/twofish_avx_glue.c
@@ -0,0 +1,624 @@
1/*
2 * Glue Code for AVX assembler version of Twofish Cipher
3 *
4 * Copyright (C) 2012 Johannes Goetzfried
5 * <Johannes.Goetzfried@informatik.stud.uni-erlangen.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 as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 */
23
24#include <linux/module.h>
25#include <linux/hardirq.h>
26#include <linux/types.h>
27#include <linux/crypto.h>
28#include <linux/err.h>
29#include <crypto/algapi.h>
30#include <crypto/twofish.h>
31#include <crypto/cryptd.h>
32#include <crypto/b128ops.h>
33#include <crypto/ctr.h>
34#include <crypto/lrw.h>
35#include <crypto/xts.h>
36#include <asm/i387.h>
37#include <asm/xcr.h>
38#include <asm/xsave.h>
39#include <asm/crypto/twofish.h>
40#include <asm/crypto/ablk_helper.h>
41#include <asm/crypto/glue_helper.h>
42#include <crypto/scatterwalk.h>
43#include <linux/workqueue.h>
44#include <linux/spinlock.h>
45
46#define TWOFISH_PARALLEL_BLOCKS 8
47
48static inline void twofish_enc_blk_3way(struct twofish_ctx *ctx, u8 *dst,
49 const u8 *src)
50{
51 __twofish_enc_blk_3way(ctx, dst, src, false);
52}
53
54/* 8-way parallel cipher functions */
55asmlinkage void __twofish_enc_blk_8way(struct twofish_ctx *ctx, u8 *dst,
56 const u8 *src, bool xor);
57asmlinkage void twofish_dec_blk_8way(struct twofish_ctx *ctx, u8 *dst,
58 const u8 *src);
59
60static inline void twofish_enc_blk_xway(struct twofish_ctx *ctx, u8 *dst,
61 const u8 *src)
62{
63 __twofish_enc_blk_8way(ctx, dst, src, false);
64}
65
66static inline void twofish_enc_blk_xway_xor(struct twofish_ctx *ctx, u8 *dst,
67 const u8 *src)
68{
69 __twofish_enc_blk_8way(ctx, dst, src, true);
70}
71
72static inline void twofish_dec_blk_xway(struct twofish_ctx *ctx, u8 *dst,
73 const u8 *src)
74{
75 twofish_dec_blk_8way(ctx, dst, src);
76}
77
78static void twofish_dec_blk_cbc_xway(void *ctx, u128 *dst, const u128 *src)
79{
80 u128 ivs[TWOFISH_PARALLEL_BLOCKS - 1];
81 unsigned int j;
82
83 for (j = 0; j < TWOFISH_PARALLEL_BLOCKS - 1; j++)
84 ivs[j] = src[j];
85
86 twofish_dec_blk_xway(ctx, (u8 *)dst, (u8 *)src);
87
88 for (j = 0; j < TWOFISH_PARALLEL_BLOCKS - 1; j++)
89 u128_xor(dst + (j + 1), dst + (j + 1), ivs + j);
90}
91
92static void twofish_enc_blk_ctr_xway(void *ctx, u128 *dst, const u128 *src,
93 u128 *iv)
94{
95 be128 ctrblks[TWOFISH_PARALLEL_BLOCKS];
96 unsigned int i;
97
98 for (i = 0; i < TWOFISH_PARALLEL_BLOCKS; i++) {
99 if (dst != src)
100 dst[i] = src[i];
101
102 u128_to_be128(&ctrblks[i], iv);
103 u128_inc(iv);
104 }
105
106 twofish_enc_blk_xway_xor(ctx, (u8 *)dst, (u8 *)ctrblks);
107}
108
109static const struct common_glue_ctx twofish_enc = {
110 .num_funcs = 3,
111 .fpu_blocks_limit = TWOFISH_PARALLEL_BLOCKS,
112
113 .funcs = { {
114 .num_blocks = TWOFISH_PARALLEL_BLOCKS,
115 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_xway) }
116 }, {
117 .num_blocks = 3,
118 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_3way) }
119 }, {
120 .num_blocks = 1,
121 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk) }
122 } }
123};
124
125static const struct common_glue_ctx twofish_ctr = {
126 .num_funcs = 3,
127 .fpu_blocks_limit = TWOFISH_PARALLEL_BLOCKS,
128
129 .funcs = { {
130 .num_blocks = TWOFISH_PARALLEL_BLOCKS,
131 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(twofish_enc_blk_ctr_xway) }
132 }, {
133 .num_blocks = 3,
134 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(twofish_enc_blk_ctr_3way) }
135 }, {
136 .num_blocks = 1,
137 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(twofish_enc_blk_ctr) }
138 } }
139};
140
141static const struct common_glue_ctx twofish_dec = {
142 .num_funcs = 3,
143 .fpu_blocks_limit = TWOFISH_PARALLEL_BLOCKS,
144
145 .funcs = { {
146 .num_blocks = TWOFISH_PARALLEL_BLOCKS,
147 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_dec_blk_xway) }
148 }, {
149 .num_blocks = 3,
150 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_dec_blk_3way) }
151 }, {
152 .num_blocks = 1,
153 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_dec_blk) }
154 } }
155};
156
157static const struct common_glue_ctx twofish_dec_cbc = {
158 .num_funcs = 3,
159 .fpu_blocks_limit = TWOFISH_PARALLEL_BLOCKS,
160
161 .funcs = { {
162 .num_blocks = TWOFISH_PARALLEL_BLOCKS,
163 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_dec_blk_cbc_xway) }
164 }, {
165 .num_blocks = 3,
166 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_dec_blk_cbc_3way) }
167 }, {
168 .num_blocks = 1,
169 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_dec_blk) }
170 } }
171};
172
173static int ecb_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
174 struct scatterlist *src, unsigned int nbytes)
175{
176 return glue_ecb_crypt_128bit(&twofish_enc, desc, dst, src, nbytes);
177}
178
179static int ecb_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
180 struct scatterlist *src, unsigned int nbytes)
181{
182 return glue_ecb_crypt_128bit(&twofish_dec, desc, dst, src, nbytes);
183}
184
185static int cbc_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
186 struct scatterlist *src, unsigned int nbytes)
187{
188 return glue_cbc_encrypt_128bit(GLUE_FUNC_CAST(twofish_enc_blk), desc,
189 dst, src, nbytes);
190}
191
192static int cbc_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
193 struct scatterlist *src, unsigned int nbytes)
194{
195 return glue_cbc_decrypt_128bit(&twofish_dec_cbc, desc, dst, src,
196 nbytes);
197}
198
199static int ctr_crypt(struct blkcipher_desc *desc, struct scatterlist *dst,
200 struct scatterlist *src, unsigned int nbytes)
201{
202 return glue_ctr_crypt_128bit(&twofish_ctr, desc, dst, src, nbytes);
203}
204
205static inline bool twofish_fpu_begin(bool fpu_enabled, unsigned int nbytes)
206{
207 return glue_fpu_begin(TF_BLOCK_SIZE, TWOFISH_PARALLEL_BLOCKS, NULL,
208 fpu_enabled, nbytes);
209}
210
211static inline void twofish_fpu_end(bool fpu_enabled)
212{
213 glue_fpu_end(fpu_enabled);
214}
215
216struct crypt_priv {
217 struct twofish_ctx *ctx;
218 bool fpu_enabled;
219};
220
221static void encrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
222{
223 const unsigned int bsize = TF_BLOCK_SIZE;
224 struct crypt_priv *ctx = priv;
225 int i;
226
227 ctx->fpu_enabled = twofish_fpu_begin(ctx->fpu_enabled, nbytes);
228
229 if (nbytes == bsize * TWOFISH_PARALLEL_BLOCKS) {
230 twofish_enc_blk_xway(ctx->ctx, srcdst, srcdst);
231 return;
232 }
233
234 for (i = 0; i < nbytes / (bsize * 3); i++, srcdst += bsize * 3)
235 twofish_enc_blk_3way(ctx->ctx, srcdst, srcdst);
236
237 nbytes %= bsize * 3;
238
239 for (i = 0; i < nbytes / bsize; i++, srcdst += bsize)
240 twofish_enc_blk(ctx->ctx, srcdst, srcdst);
241}
242
243static void decrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
244{
245 const unsigned int bsize = TF_BLOCK_SIZE;
246 struct crypt_priv *ctx = priv;
247 int i;
248
249 ctx->fpu_enabled = twofish_fpu_begin(ctx->fpu_enabled, nbytes);
250
251 if (nbytes == bsize * TWOFISH_PARALLEL_BLOCKS) {
252 twofish_dec_blk_xway(ctx->ctx, srcdst, srcdst);
253 return;
254 }
255
256 for (i = 0; i < nbytes / (bsize * 3); i++, srcdst += bsize * 3)
257 twofish_dec_blk_3way(ctx->ctx, srcdst, srcdst);
258
259 nbytes %= bsize * 3;
260
261 for (i = 0; i < nbytes / bsize; i++, srcdst += bsize)
262 twofish_dec_blk(ctx->ctx, srcdst, srcdst);
263}
264
265static int lrw_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
266 struct scatterlist *src, unsigned int nbytes)
267{
268 struct twofish_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
269 be128 buf[TWOFISH_PARALLEL_BLOCKS];
270 struct crypt_priv crypt_ctx = {
271 .ctx = &ctx->twofish_ctx,
272 .fpu_enabled = false,
273 };
274 struct lrw_crypt_req req = {
275 .tbuf = buf,
276 .tbuflen = sizeof(buf),
277
278 .table_ctx = &ctx->lrw_table,
279 .crypt_ctx = &crypt_ctx,
280 .crypt_fn = encrypt_callback,
281 };
282 int ret;
283
284 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
285 ret = lrw_crypt(desc, dst, src, nbytes, &req);
286 twofish_fpu_end(crypt_ctx.fpu_enabled);
287
288 return ret;
289}
290
291static int lrw_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
292 struct scatterlist *src, unsigned int nbytes)
293{
294 struct twofish_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
295 be128 buf[TWOFISH_PARALLEL_BLOCKS];
296 struct crypt_priv crypt_ctx = {
297 .ctx = &ctx->twofish_ctx,
298 .fpu_enabled = false,
299 };
300 struct lrw_crypt_req req = {
301 .tbuf = buf,
302 .tbuflen = sizeof(buf),
303
304 .table_ctx = &ctx->lrw_table,
305 .crypt_ctx = &crypt_ctx,
306 .crypt_fn = decrypt_callback,
307 };
308 int ret;
309
310 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
311 ret = lrw_crypt(desc, dst, src, nbytes, &req);
312 twofish_fpu_end(crypt_ctx.fpu_enabled);
313
314 return ret;
315}
316
317static int xts_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
318 struct scatterlist *src, unsigned int nbytes)
319{
320 struct twofish_xts_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
321 be128 buf[TWOFISH_PARALLEL_BLOCKS];
322 struct crypt_priv crypt_ctx = {
323 .ctx = &ctx->crypt_ctx,
324 .fpu_enabled = false,
325 };
326 struct xts_crypt_req req = {
327 .tbuf = buf,
328 .tbuflen = sizeof(buf),
329
330 .tweak_ctx = &ctx->tweak_ctx,
331 .tweak_fn = XTS_TWEAK_CAST(twofish_enc_blk),
332 .crypt_ctx = &crypt_ctx,
333 .crypt_fn = encrypt_callback,
334 };
335 int ret;
336
337 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
338 ret = xts_crypt(desc, dst, src, nbytes, &req);
339 twofish_fpu_end(crypt_ctx.fpu_enabled);
340
341 return ret;
342}
343
344static int xts_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
345 struct scatterlist *src, unsigned int nbytes)
346{
347 struct twofish_xts_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
348 be128 buf[TWOFISH_PARALLEL_BLOCKS];
349 struct crypt_priv crypt_ctx = {
350 .ctx = &ctx->crypt_ctx,
351 .fpu_enabled = false,
352 };
353 struct xts_crypt_req req = {
354 .tbuf = buf,
355 .tbuflen = sizeof(buf),
356
357 .tweak_ctx = &ctx->tweak_ctx,
358 .tweak_fn = XTS_TWEAK_CAST(twofish_enc_blk),
359 .crypt_ctx = &crypt_ctx,
360 .crypt_fn = decrypt_callback,
361 };
362 int ret;
363
364 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
365 ret = xts_crypt(desc, dst, src, nbytes, &req);
366 twofish_fpu_end(crypt_ctx.fpu_enabled);
367
368 return ret;
369}
370
371static struct crypto_alg twofish_algs[10] = { {
372 .cra_name = "__ecb-twofish-avx",
373 .cra_driver_name = "__driver-ecb-twofish-avx",
374 .cra_priority = 0,
375 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
376 .cra_blocksize = TF_BLOCK_SIZE,
377 .cra_ctxsize = sizeof(struct twofish_ctx),
378 .cra_alignmask = 0,
379 .cra_type = &crypto_blkcipher_type,
380 .cra_module = THIS_MODULE,
381 .cra_list = LIST_HEAD_INIT(twofish_algs[0].cra_list),
382 .cra_u = {
383 .blkcipher = {
384 .min_keysize = TF_MIN_KEY_SIZE,
385 .max_keysize = TF_MAX_KEY_SIZE,
386 .setkey = twofish_setkey,
387 .encrypt = ecb_encrypt,
388 .decrypt = ecb_decrypt,
389 },
390 },
391}, {
392 .cra_name = "__cbc-twofish-avx",
393 .cra_driver_name = "__driver-cbc-twofish-avx",
394 .cra_priority = 0,
395 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
396 .cra_blocksize = TF_BLOCK_SIZE,
397 .cra_ctxsize = sizeof(struct twofish_ctx),
398 .cra_alignmask = 0,
399 .cra_type = &crypto_blkcipher_type,
400 .cra_module = THIS_MODULE,
401 .cra_list = LIST_HEAD_INIT(twofish_algs[1].cra_list),
402 .cra_u = {
403 .blkcipher = {
404 .min_keysize = TF_MIN_KEY_SIZE,
405 .max_keysize = TF_MAX_KEY_SIZE,
406 .setkey = twofish_setkey,
407 .encrypt = cbc_encrypt,
408 .decrypt = cbc_decrypt,
409 },
410 },
411}, {
412 .cra_name = "__ctr-twofish-avx",
413 .cra_driver_name = "__driver-ctr-twofish-avx",
414 .cra_priority = 0,
415 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
416 .cra_blocksize = 1,
417 .cra_ctxsize = sizeof(struct twofish_ctx),
418 .cra_alignmask = 0,
419 .cra_type = &crypto_blkcipher_type,
420 .cra_module = THIS_MODULE,
421 .cra_list = LIST_HEAD_INIT(twofish_algs[2].cra_list),
422 .cra_u = {
423 .blkcipher = {
424 .min_keysize = TF_MIN_KEY_SIZE,
425 .max_keysize = TF_MAX_KEY_SIZE,
426 .ivsize = TF_BLOCK_SIZE,
427 .setkey = twofish_setkey,
428 .encrypt = ctr_crypt,
429 .decrypt = ctr_crypt,
430 },
431 },
432}, {
433 .cra_name = "__lrw-twofish-avx",
434 .cra_driver_name = "__driver-lrw-twofish-avx",
435 .cra_priority = 0,
436 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
437 .cra_blocksize = TF_BLOCK_SIZE,
438 .cra_ctxsize = sizeof(struct twofish_lrw_ctx),
439 .cra_alignmask = 0,
440 .cra_type = &crypto_blkcipher_type,
441 .cra_module = THIS_MODULE,
442 .cra_list = LIST_HEAD_INIT(twofish_algs[3].cra_list),
443 .cra_exit = lrw_twofish_exit_tfm,
444 .cra_u = {
445 .blkcipher = {
446 .min_keysize = TF_MIN_KEY_SIZE +
447 TF_BLOCK_SIZE,
448 .max_keysize = TF_MAX_KEY_SIZE +
449 TF_BLOCK_SIZE,
450 .ivsize = TF_BLOCK_SIZE,
451 .setkey = lrw_twofish_setkey,
452 .encrypt = lrw_encrypt,
453 .decrypt = lrw_decrypt,
454 },
455 },
456}, {
457 .cra_name = "__xts-twofish-avx",
458 .cra_driver_name = "__driver-xts-twofish-avx",
459 .cra_priority = 0,
460 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
461 .cra_blocksize = TF_BLOCK_SIZE,
462 .cra_ctxsize = sizeof(struct twofish_xts_ctx),
463 .cra_alignmask = 0,
464 .cra_type = &crypto_blkcipher_type,
465 .cra_module = THIS_MODULE,
466 .cra_list = LIST_HEAD_INIT(twofish_algs[4].cra_list),
467 .cra_u = {
468 .blkcipher = {
469 .min_keysize = TF_MIN_KEY_SIZE * 2,
470 .max_keysize = TF_MAX_KEY_SIZE * 2,
471 .ivsize = TF_BLOCK_SIZE,
472 .setkey = xts_twofish_setkey,
473 .encrypt = xts_encrypt,
474 .decrypt = xts_decrypt,
475 },
476 },
477}, {
478 .cra_name = "ecb(twofish)",
479 .cra_driver_name = "ecb-twofish-avx",
480 .cra_priority = 400,
481 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
482 .cra_blocksize = TF_BLOCK_SIZE,
483 .cra_ctxsize = sizeof(struct async_helper_ctx),
484 .cra_alignmask = 0,
485 .cra_type = &crypto_ablkcipher_type,
486 .cra_module = THIS_MODULE,
487 .cra_list = LIST_HEAD_INIT(twofish_algs[5].cra_list),
488 .cra_init = ablk_init,
489 .cra_exit = ablk_exit,
490 .cra_u = {
491 .ablkcipher = {
492 .min_keysize = TF_MIN_KEY_SIZE,
493 .max_keysize = TF_MAX_KEY_SIZE,
494 .setkey = ablk_set_key,
495 .encrypt = ablk_encrypt,
496 .decrypt = ablk_decrypt,
497 },
498 },
499}, {
500 .cra_name = "cbc(twofish)",
501 .cra_driver_name = "cbc-twofish-avx",
502 .cra_priority = 400,
503 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
504 .cra_blocksize = TF_BLOCK_SIZE,
505 .cra_ctxsize = sizeof(struct async_helper_ctx),
506 .cra_alignmask = 0,
507 .cra_type = &crypto_ablkcipher_type,
508 .cra_module = THIS_MODULE,
509 .cra_list = LIST_HEAD_INIT(twofish_algs[6].cra_list),
510 .cra_init = ablk_init,
511 .cra_exit = ablk_exit,
512 .cra_u = {
513 .ablkcipher = {
514 .min_keysize = TF_MIN_KEY_SIZE,
515 .max_keysize = TF_MAX_KEY_SIZE,
516 .ivsize = TF_BLOCK_SIZE,
517 .setkey = ablk_set_key,
518 .encrypt = __ablk_encrypt,
519 .decrypt = ablk_decrypt,
520 },
521 },
522}, {
523 .cra_name = "ctr(twofish)",
524 .cra_driver_name = "ctr-twofish-avx",
525 .cra_priority = 400,
526 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
527 .cra_blocksize = 1,
528 .cra_ctxsize = sizeof(struct async_helper_ctx),
529 .cra_alignmask = 0,
530 .cra_type = &crypto_ablkcipher_type,
531 .cra_module = THIS_MODULE,
532 .cra_list = LIST_HEAD_INIT(twofish_algs[7].cra_list),
533 .cra_init = ablk_init,
534 .cra_exit = ablk_exit,
535 .cra_u = {
536 .ablkcipher = {
537 .min_keysize = TF_MIN_KEY_SIZE,
538 .max_keysize = TF_MAX_KEY_SIZE,
539 .ivsize = TF_BLOCK_SIZE,
540 .setkey = ablk_set_key,
541 .encrypt = ablk_encrypt,
542 .decrypt = ablk_encrypt,
543 .geniv = "chainiv",
544 },
545 },
546}, {
547 .cra_name = "lrw(twofish)",
548 .cra_driver_name = "lrw-twofish-avx",
549 .cra_priority = 400,
550 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
551 .cra_blocksize = TF_BLOCK_SIZE,
552 .cra_ctxsize = sizeof(struct async_helper_ctx),
553 .cra_alignmask = 0,
554 .cra_type = &crypto_ablkcipher_type,
555 .cra_module = THIS_MODULE,
556 .cra_list = LIST_HEAD_INIT(twofish_algs[8].cra_list),
557 .cra_init = ablk_init,
558 .cra_exit = ablk_exit,
559 .cra_u = {
560 .ablkcipher = {
561 .min_keysize = TF_MIN_KEY_SIZE +
562 TF_BLOCK_SIZE,
563 .max_keysize = TF_MAX_KEY_SIZE +
564 TF_BLOCK_SIZE,
565 .ivsize = TF_BLOCK_SIZE,
566 .setkey = ablk_set_key,
567 .encrypt = ablk_encrypt,
568 .decrypt = ablk_decrypt,
569 },
570 },
571}, {
572 .cra_name = "xts(twofish)",
573 .cra_driver_name = "xts-twofish-avx",
574 .cra_priority = 400,
575 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
576 .cra_blocksize = TF_BLOCK_SIZE,
577 .cra_ctxsize = sizeof(struct async_helper_ctx),
578 .cra_alignmask = 0,
579 .cra_type = &crypto_ablkcipher_type,
580 .cra_module = THIS_MODULE,
581 .cra_list = LIST_HEAD_INIT(twofish_algs[9].cra_list),
582 .cra_init = ablk_init,
583 .cra_exit = ablk_exit,
584 .cra_u = {
585 .ablkcipher = {
586 .min_keysize = TF_MIN_KEY_SIZE * 2,
587 .max_keysize = TF_MAX_KEY_SIZE * 2,
588 .ivsize = TF_BLOCK_SIZE,
589 .setkey = ablk_set_key,
590 .encrypt = ablk_encrypt,
591 .decrypt = ablk_decrypt,
592 },
593 },
594} };
595
596static int __init twofish_init(void)
597{
598 u64 xcr0;
599
600 if (!cpu_has_avx || !cpu_has_osxsave) {
601 printk(KERN_INFO "AVX instructions are not detected.\n");
602 return -ENODEV;
603 }
604
605 xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK);
606 if ((xcr0 & (XSTATE_SSE | XSTATE_YMM)) != (XSTATE_SSE | XSTATE_YMM)) {
607 printk(KERN_INFO "AVX detected but unusable.\n");
608 return -ENODEV;
609 }
610
611 return crypto_register_algs(twofish_algs, ARRAY_SIZE(twofish_algs));
612}
613
614static void __exit twofish_exit(void)
615{
616 crypto_unregister_algs(twofish_algs, ARRAY_SIZE(twofish_algs));
617}
618
619module_init(twofish_init);
620module_exit(twofish_exit);
621
622MODULE_DESCRIPTION("Twofish Cipher Algorithm, AVX optimized");
623MODULE_LICENSE("GPL");
624MODULE_ALIAS("twofish");
diff --git a/arch/x86/crypto/twofish_glue_3way.c b/arch/x86/crypto/twofish_glue_3way.c
index 922ab24cce3..15f9347316c 100644
--- a/arch/x86/crypto/twofish_glue_3way.c
+++ b/arch/x86/crypto/twofish_glue_3way.c
@@ -3,11 +3,6 @@
3 * 3 *
4 * Copyright (c) 2011 Jussi Kivilinna <jussi.kivilinna@mbnet.fi> 4 * Copyright (c) 2011 Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
5 * 5 *
6 * CBC & ECB parts based on code (crypto/cbc.c,ecb.c) by:
7 * Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au>
8 * CTR part based on code (crypto/ctr.c) by:
9 * (C) Copyright IBM Corp. 2007 - Joy Latten <latten@us.ibm.com>
10 *
11 * 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
12 * 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
13 * the Free Software Foundation; either version 2 of the License, or 8 * the Free Software Foundation; either version 2 of the License, or
@@ -33,20 +28,13 @@
33#include <crypto/algapi.h> 28#include <crypto/algapi.h>
34#include <crypto/twofish.h> 29#include <crypto/twofish.h>
35#include <crypto/b128ops.h> 30#include <crypto/b128ops.h>
31#include <asm/crypto/twofish.h>
32#include <asm/crypto/glue_helper.h>
36#include <crypto/lrw.h> 33#include <crypto/lrw.h>
37#include <crypto/xts.h> 34#include <crypto/xts.h>
38 35
39/* regular block cipher functions from twofish_x86_64 module */ 36EXPORT_SYMBOL_GPL(__twofish_enc_blk_3way);
40asmlinkage void twofish_enc_blk(struct twofish_ctx *ctx, u8 *dst, 37EXPORT_SYMBOL_GPL(twofish_dec_blk_3way);
41 const u8 *src);
42asmlinkage void twofish_dec_blk(struct twofish_ctx *ctx, u8 *dst,
43 const u8 *src);
44
45/* 3-way parallel cipher functions */
46asmlinkage void __twofish_enc_blk_3way(struct twofish_ctx *ctx, u8 *dst,
47 const u8 *src, bool xor);
48asmlinkage void twofish_dec_blk_3way(struct twofish_ctx *ctx, u8 *dst,
49 const u8 *src);
50 38
51static inline void twofish_enc_blk_3way(struct twofish_ctx *ctx, u8 *dst, 39static inline void twofish_enc_blk_3way(struct twofish_ctx *ctx, u8 *dst,
52 const u8 *src) 40 const u8 *src)
@@ -60,311 +48,139 @@ static inline void twofish_enc_blk_xor_3way(struct twofish_ctx *ctx, u8 *dst,
60 __twofish_enc_blk_3way(ctx, dst, src, true); 48 __twofish_enc_blk_3way(ctx, dst, src, true);
61} 49}
62 50
63static int ecb_crypt(struct blkcipher_desc *desc, struct blkcipher_walk *walk, 51void twofish_dec_blk_cbc_3way(void *ctx, u128 *dst, const u128 *src)
64 void (*fn)(struct twofish_ctx *, u8 *, const u8 *),
65 void (*fn_3way)(struct twofish_ctx *, u8 *, const u8 *))
66{
67 struct twofish_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
68 unsigned int bsize = TF_BLOCK_SIZE;
69 unsigned int nbytes;
70 int err;
71
72 err = blkcipher_walk_virt(desc, walk);
73
74 while ((nbytes = walk->nbytes)) {
75 u8 *wsrc = walk->src.virt.addr;
76 u8 *wdst = walk->dst.virt.addr;
77
78 /* Process three block batch */
79 if (nbytes >= bsize * 3) {
80 do {
81 fn_3way(ctx, wdst, wsrc);
82
83 wsrc += bsize * 3;
84 wdst += bsize * 3;
85 nbytes -= bsize * 3;
86 } while (nbytes >= bsize * 3);
87
88 if (nbytes < bsize)
89 goto done;
90 }
91
92 /* Handle leftovers */
93 do {
94 fn(ctx, wdst, wsrc);
95
96 wsrc += bsize;
97 wdst += bsize;
98 nbytes -= bsize;
99 } while (nbytes >= bsize);
100
101done:
102 err = blkcipher_walk_done(desc, walk, nbytes);
103 }
104
105 return err;
106}
107
108static int ecb_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
109 struct scatterlist *src, unsigned int nbytes)
110{ 52{
111 struct blkcipher_walk walk; 53 u128 ivs[2];
112 54
113 blkcipher_walk_init(&walk, dst, src, nbytes); 55 ivs[0] = src[0];
114 return ecb_crypt(desc, &walk, twofish_enc_blk, twofish_enc_blk_3way); 56 ivs[1] = src[1];
115}
116 57
117static int ecb_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, 58 twofish_dec_blk_3way(ctx, (u8 *)dst, (u8 *)src);
118 struct scatterlist *src, unsigned int nbytes)
119{
120 struct blkcipher_walk walk;
121 59
122 blkcipher_walk_init(&walk, dst, src, nbytes); 60 u128_xor(&dst[1], &dst[1], &ivs[0]);
123 return ecb_crypt(desc, &walk, twofish_dec_blk, twofish_dec_blk_3way); 61 u128_xor(&dst[2], &dst[2], &ivs[1]);
124} 62}
63EXPORT_SYMBOL_GPL(twofish_dec_blk_cbc_3way);
125 64
126static unsigned int __cbc_encrypt(struct blkcipher_desc *desc, 65void twofish_enc_blk_ctr(void *ctx, u128 *dst, const u128 *src, u128 *iv)
127 struct blkcipher_walk *walk)
128{
129 struct twofish_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
130 unsigned int bsize = TF_BLOCK_SIZE;
131 unsigned int nbytes = walk->nbytes;
132 u128 *src = (u128 *)walk->src.virt.addr;
133 u128 *dst = (u128 *)walk->dst.virt.addr;
134 u128 *iv = (u128 *)walk->iv;
135
136 do {
137 u128_xor(dst, src, iv);
138 twofish_enc_blk(ctx, (u8 *)dst, (u8 *)dst);
139 iv = dst;
140
141 src += 1;
142 dst += 1;
143 nbytes -= bsize;
144 } while (nbytes >= bsize);
145
146 u128_xor((u128 *)walk->iv, (u128 *)walk->iv, iv);
147 return nbytes;
148}
149
150static int cbc_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
151 struct scatterlist *src, unsigned int nbytes)
152{ 66{
153 struct blkcipher_walk walk; 67 be128 ctrblk;
154 int err;
155 68
156 blkcipher_walk_init(&walk, dst, src, nbytes); 69 if (dst != src)
157 err = blkcipher_walk_virt(desc, &walk); 70 *dst = *src;
158 71
159 while ((nbytes = walk.nbytes)) { 72 u128_to_be128(&ctrblk, iv);
160 nbytes = __cbc_encrypt(desc, &walk); 73 u128_inc(iv);
161 err = blkcipher_walk_done(desc, &walk, nbytes);
162 }
163 74
164 return err; 75 twofish_enc_blk(ctx, (u8 *)&ctrblk, (u8 *)&ctrblk);
76 u128_xor(dst, dst, (u128 *)&ctrblk);
165} 77}
78EXPORT_SYMBOL_GPL(twofish_enc_blk_ctr);
166 79
167static unsigned int __cbc_decrypt(struct blkcipher_desc *desc, 80void twofish_enc_blk_ctr_3way(void *ctx, u128 *dst, const u128 *src,
168 struct blkcipher_walk *walk) 81 u128 *iv)
169{ 82{
170 struct twofish_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); 83 be128 ctrblks[3];
171 unsigned int bsize = TF_BLOCK_SIZE;
172 unsigned int nbytes = walk->nbytes;
173 u128 *src = (u128 *)walk->src.virt.addr;
174 u128 *dst = (u128 *)walk->dst.virt.addr;
175 u128 ivs[3 - 1];
176 u128 last_iv;
177
178 /* Start of the last block. */
179 src += nbytes / bsize - 1;
180 dst += nbytes / bsize - 1;
181
182 last_iv = *src;
183
184 /* Process three block batch */
185 if (nbytes >= bsize * 3) {
186 do {
187 nbytes -= bsize * (3 - 1);
188 src -= 3 - 1;
189 dst -= 3 - 1;
190
191 ivs[0] = src[0];
192 ivs[1] = src[1];
193
194 twofish_dec_blk_3way(ctx, (u8 *)dst, (u8 *)src);
195
196 u128_xor(dst + 1, dst + 1, ivs + 0);
197 u128_xor(dst + 2, dst + 2, ivs + 1);
198
199 nbytes -= bsize;
200 if (nbytes < bsize)
201 goto done;
202
203 u128_xor(dst, dst, src - 1);
204 src -= 1;
205 dst -= 1;
206 } while (nbytes >= bsize * 3);
207
208 if (nbytes < bsize)
209 goto done;
210 }
211
212 /* Handle leftovers */
213 for (;;) {
214 twofish_dec_blk(ctx, (u8 *)dst, (u8 *)src);
215
216 nbytes -= bsize;
217 if (nbytes < bsize)
218 break;
219 84
220 u128_xor(dst, dst, src - 1); 85 if (dst != src) {
221 src -= 1; 86 dst[0] = src[0];
222 dst -= 1; 87 dst[1] = src[1];
88 dst[2] = src[2];
223 } 89 }
224 90
225done: 91 u128_to_be128(&ctrblks[0], iv);
226 u128_xor(dst, dst, (u128 *)walk->iv); 92 u128_inc(iv);
227 *(u128 *)walk->iv = last_iv; 93 u128_to_be128(&ctrblks[1], iv);
94 u128_inc(iv);
95 u128_to_be128(&ctrblks[2], iv);
96 u128_inc(iv);
228 97
229 return nbytes; 98 twofish_enc_blk_xor_3way(ctx, (u8 *)dst, (u8 *)ctrblks);
230} 99}
100EXPORT_SYMBOL_GPL(twofish_enc_blk_ctr_3way);
101
102static const struct common_glue_ctx twofish_enc = {
103 .num_funcs = 2,
104 .fpu_blocks_limit = -1,
105
106 .funcs = { {
107 .num_blocks = 3,
108 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_3way) }
109 }, {
110 .num_blocks = 1,
111 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk) }
112 } }
113};
231 114
232static int cbc_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, 115static const struct common_glue_ctx twofish_ctr = {
233 struct scatterlist *src, unsigned int nbytes) 116 .num_funcs = 2,
234{ 117 .fpu_blocks_limit = -1,
235 struct blkcipher_walk walk; 118
236 int err; 119 .funcs = { {
237 120 .num_blocks = 3,
238 blkcipher_walk_init(&walk, dst, src, nbytes); 121 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_ctr_3way) }
239 err = blkcipher_walk_virt(desc, &walk); 122 }, {
123 .num_blocks = 1,
124 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_ctr) }
125 } }
126};
240 127
241 while ((nbytes = walk.nbytes)) { 128static const struct common_glue_ctx twofish_dec = {
242 nbytes = __cbc_decrypt(desc, &walk); 129 .num_funcs = 2,
243 err = blkcipher_walk_done(desc, &walk, nbytes); 130 .fpu_blocks_limit = -1,
244 } 131
132 .funcs = { {
133 .num_blocks = 3,
134 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_dec_blk_3way) }
135 }, {
136 .num_blocks = 1,
137 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_dec_blk) }
138 } }
139};
245 140
246 return err; 141static const struct common_glue_ctx twofish_dec_cbc = {
247} 142 .num_funcs = 2,
143 .fpu_blocks_limit = -1,
144
145 .funcs = { {
146 .num_blocks = 3,
147 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_dec_blk_cbc_3way) }
148 }, {
149 .num_blocks = 1,
150 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_dec_blk) }
151 } }
152};
248 153
249static inline void u128_to_be128(be128 *dst, const u128 *src) 154static int ecb_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
155 struct scatterlist *src, unsigned int nbytes)
250{ 156{
251 dst->a = cpu_to_be64(src->a); 157 return glue_ecb_crypt_128bit(&twofish_enc, desc, dst, src, nbytes);
252 dst->b = cpu_to_be64(src->b);
253} 158}
254 159
255static inline void be128_to_u128(u128 *dst, const be128 *src) 160static int ecb_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
161 struct scatterlist *src, unsigned int nbytes)
256{ 162{
257 dst->a = be64_to_cpu(src->a); 163 return glue_ecb_crypt_128bit(&twofish_dec, desc, dst, src, nbytes);
258 dst->b = be64_to_cpu(src->b);
259} 164}
260 165
261static inline void u128_inc(u128 *i) 166static int cbc_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
167 struct scatterlist *src, unsigned int nbytes)
262{ 168{
263 i->b++; 169 return glue_cbc_encrypt_128bit(GLUE_FUNC_CAST(twofish_enc_blk), desc,
264 if (!i->b) 170 dst, src, nbytes);
265 i->a++;
266} 171}
267 172
268static void ctr_crypt_final(struct blkcipher_desc *desc, 173static int cbc_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
269 struct blkcipher_walk *walk) 174 struct scatterlist *src, unsigned int nbytes)
270{ 175{
271 struct twofish_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); 176 return glue_cbc_decrypt_128bit(&twofish_dec_cbc, desc, dst, src,
272 u8 *ctrblk = walk->iv; 177 nbytes);
273 u8 keystream[TF_BLOCK_SIZE];
274 u8 *src = walk->src.virt.addr;
275 u8 *dst = walk->dst.virt.addr;
276 unsigned int nbytes = walk->nbytes;
277
278 twofish_enc_blk(ctx, keystream, ctrblk);
279 crypto_xor(keystream, src, nbytes);
280 memcpy(dst, keystream, nbytes);
281
282 crypto_inc(ctrblk, TF_BLOCK_SIZE);
283}
284
285static unsigned int __ctr_crypt(struct blkcipher_desc *desc,
286 struct blkcipher_walk *walk)
287{
288 struct twofish_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
289 unsigned int bsize = TF_BLOCK_SIZE;
290 unsigned int nbytes = walk->nbytes;
291 u128 *src = (u128 *)walk->src.virt.addr;
292 u128 *dst = (u128 *)walk->dst.virt.addr;
293 u128 ctrblk;
294 be128 ctrblocks[3];
295
296 be128_to_u128(&ctrblk, (be128 *)walk->iv);
297
298 /* Process three block batch */
299 if (nbytes >= bsize * 3) {
300 do {
301 if (dst != src) {
302 dst[0] = src[0];
303 dst[1] = src[1];
304 dst[2] = src[2];
305 }
306
307 /* create ctrblks for parallel encrypt */
308 u128_to_be128(&ctrblocks[0], &ctrblk);
309 u128_inc(&ctrblk);
310 u128_to_be128(&ctrblocks[1], &ctrblk);
311 u128_inc(&ctrblk);
312 u128_to_be128(&ctrblocks[2], &ctrblk);
313 u128_inc(&ctrblk);
314
315 twofish_enc_blk_xor_3way(ctx, (u8 *)dst,
316 (u8 *)ctrblocks);
317
318 src += 3;
319 dst += 3;
320 nbytes -= bsize * 3;
321 } while (nbytes >= bsize * 3);
322
323 if (nbytes < bsize)
324 goto done;
325 }
326
327 /* Handle leftovers */
328 do {
329 if (dst != src)
330 *dst = *src;
331
332 u128_to_be128(&ctrblocks[0], &ctrblk);
333 u128_inc(&ctrblk);
334
335 twofish_enc_blk(ctx, (u8 *)ctrblocks, (u8 *)ctrblocks);
336 u128_xor(dst, dst, (u128 *)ctrblocks);
337
338 src += 1;
339 dst += 1;
340 nbytes -= bsize;
341 } while (nbytes >= bsize);
342
343done:
344 u128_to_be128((be128 *)walk->iv, &ctrblk);
345 return nbytes;
346} 178}
347 179
348static int ctr_crypt(struct blkcipher_desc *desc, struct scatterlist *dst, 180static int ctr_crypt(struct blkcipher_desc *desc, struct scatterlist *dst,
349 struct scatterlist *src, unsigned int nbytes) 181 struct scatterlist *src, unsigned int nbytes)
350{ 182{
351 struct blkcipher_walk walk; 183 return glue_ctr_crypt_128bit(&twofish_ctr, desc, dst, src, nbytes);
352 int err;
353
354 blkcipher_walk_init(&walk, dst, src, nbytes);
355 err = blkcipher_walk_virt_block(desc, &walk, TF_BLOCK_SIZE);
356
357 while ((nbytes = walk.nbytes) >= TF_BLOCK_SIZE) {
358 nbytes = __ctr_crypt(desc, &walk);
359 err = blkcipher_walk_done(desc, &walk, nbytes);
360 }
361
362 if (walk.nbytes) {
363 ctr_crypt_final(desc, &walk);
364 err = blkcipher_walk_done(desc, &walk, 0);
365 }
366
367 return err;
368} 184}
369 185
370static void encrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes) 186static void encrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
@@ -397,13 +213,8 @@ static void decrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
397 twofish_dec_blk(ctx, srcdst, srcdst); 213 twofish_dec_blk(ctx, srcdst, srcdst);
398} 214}
399 215
400struct twofish_lrw_ctx { 216int lrw_twofish_setkey(struct crypto_tfm *tfm, const u8 *key,
401 struct lrw_table_ctx lrw_table; 217 unsigned int keylen)
402 struct twofish_ctx twofish_ctx;
403};
404
405static int lrw_twofish_setkey(struct crypto_tfm *tfm, const u8 *key,
406 unsigned int keylen)
407{ 218{
408 struct twofish_lrw_ctx *ctx = crypto_tfm_ctx(tfm); 219 struct twofish_lrw_ctx *ctx = crypto_tfm_ctx(tfm);
409 int err; 220 int err;
@@ -415,6 +226,7 @@ static int lrw_twofish_setkey(struct crypto_tfm *tfm, const u8 *key,
415 226
416 return lrw_init_table(&ctx->lrw_table, key + keylen - TF_BLOCK_SIZE); 227 return lrw_init_table(&ctx->lrw_table, key + keylen - TF_BLOCK_SIZE);
417} 228}
229EXPORT_SYMBOL_GPL(lrw_twofish_setkey);
418 230
419static int lrw_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, 231static int lrw_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
420 struct scatterlist *src, unsigned int nbytes) 232 struct scatterlist *src, unsigned int nbytes)
@@ -450,20 +262,16 @@ static int lrw_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
450 return lrw_crypt(desc, dst, src, nbytes, &req); 262 return lrw_crypt(desc, dst, src, nbytes, &req);
451} 263}
452 264
453static void lrw_exit_tfm(struct crypto_tfm *tfm) 265void lrw_twofish_exit_tfm(struct crypto_tfm *tfm)
454{ 266{
455 struct twofish_lrw_ctx *ctx = crypto_tfm_ctx(tfm); 267 struct twofish_lrw_ctx *ctx = crypto_tfm_ctx(tfm);
456 268
457 lrw_free_table(&ctx->lrw_table); 269 lrw_free_table(&ctx->lrw_table);
458} 270}
271EXPORT_SYMBOL_GPL(lrw_twofish_exit_tfm);
459 272
460struct twofish_xts_ctx { 273int xts_twofish_setkey(struct crypto_tfm *tfm, const u8 *key,
461 struct twofish_ctx tweak_ctx; 274 unsigned int keylen)
462 struct twofish_ctx crypt_ctx;
463};
464
465static int xts_twofish_setkey(struct crypto_tfm *tfm, const u8 *key,
466 unsigned int keylen)
467{ 275{
468 struct twofish_xts_ctx *ctx = crypto_tfm_ctx(tfm); 276 struct twofish_xts_ctx *ctx = crypto_tfm_ctx(tfm);
469 u32 *flags = &tfm->crt_flags; 277 u32 *flags = &tfm->crt_flags;
@@ -486,6 +294,7 @@ static int xts_twofish_setkey(struct crypto_tfm *tfm, const u8 *key,
486 return __twofish_setkey(&ctx->tweak_ctx, key + keylen / 2, keylen / 2, 294 return __twofish_setkey(&ctx->tweak_ctx, key + keylen / 2, keylen / 2,
487 flags); 295 flags);
488} 296}
297EXPORT_SYMBOL_GPL(xts_twofish_setkey);
489 298
490static int xts_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, 299static int xts_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
491 struct scatterlist *src, unsigned int nbytes) 300 struct scatterlist *src, unsigned int nbytes)
@@ -596,7 +405,7 @@ static struct crypto_alg tf_algs[5] = { {
596 .cra_type = &crypto_blkcipher_type, 405 .cra_type = &crypto_blkcipher_type,
597 .cra_module = THIS_MODULE, 406 .cra_module = THIS_MODULE,
598 .cra_list = LIST_HEAD_INIT(tf_algs[3].cra_list), 407 .cra_list = LIST_HEAD_INIT(tf_algs[3].cra_list),
599 .cra_exit = lrw_exit_tfm, 408 .cra_exit = lrw_twofish_exit_tfm,
600 .cra_u = { 409 .cra_u = {
601 .blkcipher = { 410 .blkcipher = {
602 .min_keysize = TF_MIN_KEY_SIZE + TF_BLOCK_SIZE, 411 .min_keysize = TF_MIN_KEY_SIZE + TF_BLOCK_SIZE,
diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
index 49331bedc15..70780689599 100644
--- a/arch/x86/include/asm/alternative.h
+++ b/arch/x86/include/asm/alternative.h
@@ -75,23 +75,54 @@ static inline int alternatives_text_reserved(void *start, void *end)
75} 75}
76#endif /* CONFIG_SMP */ 76#endif /* CONFIG_SMP */
77 77
78#define OLDINSTR(oldinstr) "661:\n\t" oldinstr "\n662:\n"
79
80#define b_replacement(number) "663"#number
81#define e_replacement(number) "664"#number
82
83#define alt_slen "662b-661b"
84#define alt_rlen(number) e_replacement(number)"f-"b_replacement(number)"f"
85
86#define ALTINSTR_ENTRY(feature, number) \
87 " .long 661b - .\n" /* label */ \
88 " .long " b_replacement(number)"f - .\n" /* new instruction */ \
89 " .word " __stringify(feature) "\n" /* feature bit */ \
90 " .byte " alt_slen "\n" /* source len */ \
91 " .byte " alt_rlen(number) "\n" /* replacement len */
92
93#define DISCARD_ENTRY(number) /* rlen <= slen */ \
94 " .byte 0xff + (" alt_rlen(number) ") - (" alt_slen ")\n"
95
96#define ALTINSTR_REPLACEMENT(newinstr, feature, number) /* replacement */ \
97 b_replacement(number)":\n\t" newinstr "\n" e_replacement(number) ":\n\t"
98
78/* alternative assembly primitive: */ 99/* alternative assembly primitive: */
79#define ALTERNATIVE(oldinstr, newinstr, feature) \ 100#define ALTERNATIVE(oldinstr, newinstr, feature) \
80 \ 101 OLDINSTR(oldinstr) \
81 "661:\n\t" oldinstr "\n662:\n" \ 102 ".section .altinstructions,\"a\"\n" \
82 ".section .altinstructions,\"a\"\n" \ 103 ALTINSTR_ENTRY(feature, 1) \
83 " .long 661b - .\n" /* label */ \ 104 ".previous\n" \
84 " .long 663f - .\n" /* new instruction */ \ 105 ".section .discard,\"aw\",@progbits\n" \
85 " .word " __stringify(feature) "\n" /* feature bit */ \ 106 DISCARD_ENTRY(1) \
86 " .byte 662b-661b\n" /* sourcelen */ \ 107 ".previous\n" \
87 " .byte 664f-663f\n" /* replacementlen */ \ 108 ".section .altinstr_replacement, \"ax\"\n" \
88 ".previous\n" \ 109 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
89 ".section .discard,\"aw\",@progbits\n" \ 110 ".previous"
90 " .byte 0xff + (664f-663f) - (662b-661b)\n" /* rlen <= slen */ \ 111
91 ".previous\n" \ 112#define ALTERNATIVE_2(oldinstr, newinstr1, feature1, newinstr2, feature2)\
92 ".section .altinstr_replacement, \"ax\"\n" \ 113 OLDINSTR(oldinstr) \
93 "663:\n\t" newinstr "\n664:\n" /* replacement */ \ 114 ".section .altinstructions,\"a\"\n" \
94 ".previous" 115 ALTINSTR_ENTRY(feature1, 1) \
116 ALTINSTR_ENTRY(feature2, 2) \
117 ".previous\n" \
118 ".section .discard,\"aw\",@progbits\n" \
119 DISCARD_ENTRY(1) \
120 DISCARD_ENTRY(2) \
121 ".previous\n" \
122 ".section .altinstr_replacement, \"ax\"\n" \
123 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
124 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
125 ".previous"
95 126
96/* 127/*
97 * This must be included *after* the definition of ALTERNATIVE due to 128 * This must be included *after* the definition of ALTERNATIVE due to
@@ -140,6 +171,19 @@ static inline int alternatives_text_reserved(void *start, void *end)
140 : output : [old] "i" (oldfunc), [new] "i" (newfunc), ## input) 171 : output : [old] "i" (oldfunc), [new] "i" (newfunc), ## input)
141 172
142/* 173/*
174 * Like alternative_call, but there are two features and respective functions.
175 * If CPU has feature2, function2 is used.
176 * Otherwise, if CPU has feature1, function1 is used.
177 * Otherwise, old function is used.
178 */
179#define alternative_call_2(oldfunc, newfunc1, feature1, newfunc2, feature2, \
180 output, input...) \
181 asm volatile (ALTERNATIVE_2("call %P[old]", "call %P[new1]", feature1,\
182 "call %P[new2]", feature2) \
183 : output : [old] "i" (oldfunc), [new1] "i" (newfunc1), \
184 [new2] "i" (newfunc2), ## input)
185
186/*
143 * use this macro(s) if you need more than one output parameter 187 * use this macro(s) if you need more than one output parameter
144 * in alternative_io 188 * in alternative_io
145 */ 189 */
diff --git a/arch/x86/include/asm/amd_nb.h b/arch/x86/include/asm/amd_nb.h
index 49ad773f4b9..b3341e9cd8f 100644
--- a/arch/x86/include/asm/amd_nb.h
+++ b/arch/x86/include/asm/amd_nb.h
@@ -26,10 +26,31 @@ struct amd_l3_cache {
26 u8 subcaches[4]; 26 u8 subcaches[4];
27}; 27};
28 28
29struct threshold_block {
30 unsigned int block;
31 unsigned int bank;
32 unsigned int cpu;
33 u32 address;
34 u16 interrupt_enable;
35 bool interrupt_capable;
36 u16 threshold_limit;
37 struct kobject kobj;
38 struct list_head miscj;
39};
40
41struct threshold_bank {
42 struct kobject *kobj;
43 struct threshold_block *blocks;
44
45 /* initialized to the number of CPUs on the node sharing this bank */
46 atomic_t cpus;
47};
48
29struct amd_northbridge { 49struct amd_northbridge {
30 struct pci_dev *misc; 50 struct pci_dev *misc;
31 struct pci_dev *link; 51 struct pci_dev *link;
32 struct amd_l3_cache l3_cache; 52 struct amd_l3_cache l3_cache;
53 struct threshold_bank *bank4;
33}; 54};
34 55
35struct amd_northbridge_info { 56struct amd_northbridge_info {
diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index eaff4790ed9..f34261296ff 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -306,7 +306,8 @@ struct apic {
306 unsigned long (*check_apicid_used)(physid_mask_t *map, int apicid); 306 unsigned long (*check_apicid_used)(physid_mask_t *map, int apicid);
307 unsigned long (*check_apicid_present)(int apicid); 307 unsigned long (*check_apicid_present)(int apicid);
308 308
309 void (*vector_allocation_domain)(int cpu, struct cpumask *retmask); 309 void (*vector_allocation_domain)(int cpu, struct cpumask *retmask,
310 const struct cpumask *mask);
310 void (*init_apic_ldr)(void); 311 void (*init_apic_ldr)(void);
311 312
312 void (*ioapic_phys_id_map)(physid_mask_t *phys_map, physid_mask_t *retmap); 313 void (*ioapic_phys_id_map)(physid_mask_t *phys_map, physid_mask_t *retmap);
@@ -331,9 +332,9 @@ struct apic {
331 unsigned long (*set_apic_id)(unsigned int id); 332 unsigned long (*set_apic_id)(unsigned int id);
332 unsigned long apic_id_mask; 333 unsigned long apic_id_mask;
333 334
334 unsigned int (*cpu_mask_to_apicid)(const struct cpumask *cpumask); 335 int (*cpu_mask_to_apicid_and)(const struct cpumask *cpumask,
335 unsigned int (*cpu_mask_to_apicid_and)(const struct cpumask *cpumask, 336 const struct cpumask *andmask,
336 const struct cpumask *andmask); 337 unsigned int *apicid);
337 338
338 /* ipi */ 339 /* ipi */
339 void (*send_IPI_mask)(const struct cpumask *mask, int vector); 340 void (*send_IPI_mask)(const struct cpumask *mask, int vector);
@@ -464,6 +465,8 @@ static inline u32 safe_apic_wait_icr_idle(void)
464 return apic->safe_wait_icr_idle(); 465 return apic->safe_wait_icr_idle();
465} 466}
466 467
468extern void __init apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v));
469
467#else /* CONFIG_X86_LOCAL_APIC */ 470#else /* CONFIG_X86_LOCAL_APIC */
468 471
469static inline u32 apic_read(u32 reg) { return 0; } 472static inline u32 apic_read(u32 reg) { return 0; }
@@ -473,6 +476,7 @@ static inline u64 apic_icr_read(void) { return 0; }
473static inline void apic_icr_write(u32 low, u32 high) { } 476static inline void apic_icr_write(u32 low, u32 high) { }
474static inline void apic_wait_icr_idle(void) { } 477static inline void apic_wait_icr_idle(void) { }
475static inline u32 safe_apic_wait_icr_idle(void) { return 0; } 478static inline u32 safe_apic_wait_icr_idle(void) { return 0; }
479static inline void apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v)) {}
476 480
477#endif /* CONFIG_X86_LOCAL_APIC */ 481#endif /* CONFIG_X86_LOCAL_APIC */
478 482
@@ -537,7 +541,12 @@ static inline const struct cpumask *default_target_cpus(void)
537#endif 541#endif
538} 542}
539 543
540DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid); 544static inline const struct cpumask *online_target_cpus(void)
545{
546 return cpu_online_mask;
547}
548
549DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_bios_cpu_apicid);
541 550
542 551
543static inline unsigned int read_apic_id(void) 552static inline unsigned int read_apic_id(void)
@@ -586,21 +595,50 @@ static inline int default_phys_pkg_id(int cpuid_apic, int index_msb)
586 595
587#endif 596#endif
588 597
589static inline unsigned int 598static inline int
590default_cpu_mask_to_apicid(const struct cpumask *cpumask) 599flat_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
600 const struct cpumask *andmask,
601 unsigned int *apicid)
591{ 602{
592 return cpumask_bits(cpumask)[0] & APIC_ALL_CPUS; 603 unsigned long cpu_mask = cpumask_bits(cpumask)[0] &
604 cpumask_bits(andmask)[0] &
605 cpumask_bits(cpu_online_mask)[0] &
606 APIC_ALL_CPUS;
607
608 if (likely(cpu_mask)) {
609 *apicid = (unsigned int)cpu_mask;
610 return 0;
611 } else {
612 return -EINVAL;
613 }
593} 614}
594 615
595static inline unsigned int 616extern int
596default_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 617default_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
597 const struct cpumask *andmask) 618 const struct cpumask *andmask,
619 unsigned int *apicid);
620
621static inline void
622flat_vector_allocation_domain(int cpu, struct cpumask *retmask,
623 const struct cpumask *mask)
598{ 624{
599 unsigned long mask1 = cpumask_bits(cpumask)[0]; 625 /* Careful. Some cpus do not strictly honor the set of cpus
600 unsigned long mask2 = cpumask_bits(andmask)[0]; 626 * specified in the interrupt destination when using lowest
601 unsigned long mask3 = cpumask_bits(cpu_online_mask)[0]; 627 * priority interrupt delivery mode.
628 *
629 * In particular there was a hyperthreading cpu observed to
630 * deliver interrupts to the wrong hyperthread when only one
631 * hyperthread was specified in the interrupt desitination.
632 */
633 cpumask_clear(retmask);
634 cpumask_bits(retmask)[0] = APIC_ALL_CPUS;
635}
602 636
603 return (unsigned int)(mask1 & mask2 & mask3); 637static inline void
638default_vector_allocation_domain(int cpu, struct cpumask *retmask,
639 const struct cpumask *mask)
640{
641 cpumask_copy(retmask, cpumask_of(cpu));
604} 642}
605 643
606static inline unsigned long default_check_apicid_used(physid_mask_t *map, int apicid) 644static inline unsigned long default_check_apicid_used(physid_mask_t *map, int apicid)
diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
index a6983b27722..72f5009deb5 100644
--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -264,6 +264,13 @@ static inline int test_and_clear_bit(int nr, volatile unsigned long *addr)
264 * This operation is non-atomic and can be reordered. 264 * This operation is non-atomic and can be reordered.
265 * If two examples of this operation race, one can appear to succeed 265 * If two examples of this operation race, one can appear to succeed
266 * but actually fail. You must protect multiple accesses with a lock. 266 * but actually fail. You must protect multiple accesses with a lock.
267 *
268 * Note: the operation is performed atomically with respect to
269 * the local CPU, but not other CPUs. Portable code should not
270 * rely on this behaviour.
271 * KVM relies on this behaviour on x86 for modifying memory that is also
272 * accessed from a hypervisor on the same CPU if running in a VM: don't change
273 * this without also updating arch/x86/kernel/kvm.c
267 */ 274 */
268static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr) 275static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr)
269{ 276{
diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h
index eb45aa6b1f2..2ad874cb661 100644
--- a/arch/x86/include/asm/bootparam.h
+++ b/arch/x86/include/asm/bootparam.h
@@ -66,6 +66,7 @@ struct setup_header {
66 __u64 setup_data; 66 __u64 setup_data;
67 __u64 pref_address; 67 __u64 pref_address;
68 __u32 init_size; 68 __u32 init_size;
69 __u32 handover_offset;
69} __attribute__((packed)); 70} __attribute__((packed));
70 71
71struct sys_desc_table { 72struct sys_desc_table {
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index f91e80f4f18..6b7ee5ff682 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -207,6 +207,8 @@
207#define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */ 207#define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
208#define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */ 208#define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
209#define X86_FEATURE_RTM (9*32+11) /* Restricted Transactional Memory */ 209#define X86_FEATURE_RTM (9*32+11) /* Restricted Transactional Memory */
210#define X86_FEATURE_RDSEED (9*32+18) /* The RDSEED instruction */
211#define X86_FEATURE_ADX (9*32+19) /* The ADCX and ADOX instructions */
210 212
211#if defined(__KERNEL__) && !defined(__ASSEMBLY__) 213#if defined(__KERNEL__) && !defined(__ASSEMBLY__)
212 214
diff --git a/arch/x86/include/asm/crypto/ablk_helper.h b/arch/x86/include/asm/crypto/ablk_helper.h
new file mode 100644
index 00000000000..4f93df50c23
--- /dev/null
+++ b/arch/x86/include/asm/crypto/ablk_helper.h
@@ -0,0 +1,31 @@
1/*
2 * Shared async block cipher helpers
3 */
4
5#ifndef _CRYPTO_ABLK_HELPER_H
6#define _CRYPTO_ABLK_HELPER_H
7
8#include <linux/crypto.h>
9#include <linux/kernel.h>
10#include <crypto/cryptd.h>
11
12struct async_helper_ctx {
13 struct cryptd_ablkcipher *cryptd_tfm;
14};
15
16extern int ablk_set_key(struct crypto_ablkcipher *tfm, const u8 *key,
17 unsigned int key_len);
18
19extern int __ablk_encrypt(struct ablkcipher_request *req);
20
21extern int ablk_encrypt(struct ablkcipher_request *req);
22
23extern int ablk_decrypt(struct ablkcipher_request *req);
24
25extern void ablk_exit(struct crypto_tfm *tfm);
26
27extern int ablk_init_common(struct crypto_tfm *tfm, const char *drv_name);
28
29extern int ablk_init(struct crypto_tfm *tfm);
30
31#endif /* _CRYPTO_ABLK_HELPER_H */
diff --git a/arch/x86/include/asm/aes.h b/arch/x86/include/asm/crypto/aes.h
index 80545a1cbe3..80545a1cbe3 100644
--- a/arch/x86/include/asm/aes.h
+++ b/arch/x86/include/asm/crypto/aes.h
diff --git a/arch/x86/include/asm/crypto/glue_helper.h b/arch/x86/include/asm/crypto/glue_helper.h
new file mode 100644
index 00000000000..3e408bddc96
--- /dev/null
+++ b/arch/x86/include/asm/crypto/glue_helper.h
@@ -0,0 +1,115 @@
1/*
2 * Shared glue code for 128bit block ciphers
3 */
4
5#ifndef _CRYPTO_GLUE_HELPER_H
6#define _CRYPTO_GLUE_HELPER_H
7
8#include <linux/kernel.h>
9#include <linux/crypto.h>
10#include <asm/i387.h>
11#include <crypto/b128ops.h>
12
13typedef void (*common_glue_func_t)(void *ctx, u8 *dst, const u8 *src);
14typedef void (*common_glue_cbc_func_t)(void *ctx, u128 *dst, const u128 *src);
15typedef void (*common_glue_ctr_func_t)(void *ctx, u128 *dst, const u128 *src,
16 u128 *iv);
17
18#define GLUE_FUNC_CAST(fn) ((common_glue_func_t)(fn))
19#define GLUE_CBC_FUNC_CAST(fn) ((common_glue_cbc_func_t)(fn))
20#define GLUE_CTR_FUNC_CAST(fn) ((common_glue_ctr_func_t)(fn))
21
22struct common_glue_func_entry {
23 unsigned int num_blocks; /* number of blocks that @fn will process */
24 union {
25 common_glue_func_t ecb;
26 common_glue_cbc_func_t cbc;
27 common_glue_ctr_func_t ctr;
28 } fn_u;
29};
30
31struct common_glue_ctx {
32 unsigned int num_funcs;
33 int fpu_blocks_limit; /* -1 means fpu not needed at all */
34
35 /*
36 * First funcs entry must have largest num_blocks and last funcs entry
37 * must have num_blocks == 1!
38 */
39 struct common_glue_func_entry funcs[];
40};
41
42static inline bool glue_fpu_begin(unsigned int bsize, int fpu_blocks_limit,
43 struct blkcipher_desc *desc,
44 bool fpu_enabled, unsigned int nbytes)
45{
46 if (likely(fpu_blocks_limit < 0))
47 return false;
48
49 if (fpu_enabled)
50 return true;
51
52 /*
53 * Vector-registers are only used when chunk to be processed is large
54 * enough, so do not enable FPU until it is necessary.
55 */
56 if (nbytes < bsize * (unsigned int)fpu_blocks_limit)
57 return false;
58
59 if (desc) {
60 /* prevent sleeping if FPU is in use */
61 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
62 }
63
64 kernel_fpu_begin();
65 return true;
66}
67
68static inline void glue_fpu_end(bool fpu_enabled)
69{
70 if (fpu_enabled)
71 kernel_fpu_end();
72}
73
74static inline void u128_to_be128(be128 *dst, const u128 *src)
75{
76 dst->a = cpu_to_be64(src->a);
77 dst->b = cpu_to_be64(src->b);
78}
79
80static inline void be128_to_u128(u128 *dst, const be128 *src)
81{
82 dst->a = be64_to_cpu(src->a);
83 dst->b = be64_to_cpu(src->b);
84}
85
86static inline void u128_inc(u128 *i)
87{
88 i->b++;
89 if (!i->b)
90 i->a++;
91}
92
93extern int glue_ecb_crypt_128bit(const struct common_glue_ctx *gctx,
94 struct blkcipher_desc *desc,
95 struct scatterlist *dst,
96 struct scatterlist *src, unsigned int nbytes);
97
98extern int glue_cbc_encrypt_128bit(const common_glue_func_t fn,
99 struct blkcipher_desc *desc,
100 struct scatterlist *dst,
101 struct scatterlist *src,
102 unsigned int nbytes);
103
104extern int glue_cbc_decrypt_128bit(const struct common_glue_ctx *gctx,
105 struct blkcipher_desc *desc,
106 struct scatterlist *dst,
107 struct scatterlist *src,
108 unsigned int nbytes);
109
110extern int glue_ctr_crypt_128bit(const struct common_glue_ctx *gctx,
111 struct blkcipher_desc *desc,
112 struct scatterlist *dst,
113 struct scatterlist *src, unsigned int nbytes);
114
115#endif /* _CRYPTO_GLUE_HELPER_H */
diff --git a/arch/x86/include/asm/crypto/serpent-avx.h b/arch/x86/include/asm/crypto/serpent-avx.h
new file mode 100644
index 00000000000..432deedd294
--- /dev/null
+++ b/arch/x86/include/asm/crypto/serpent-avx.h
@@ -0,0 +1,32 @@
1#ifndef ASM_X86_SERPENT_AVX_H
2#define ASM_X86_SERPENT_AVX_H
3
4#include <linux/crypto.h>
5#include <crypto/serpent.h>
6
7#define SERPENT_PARALLEL_BLOCKS 8
8
9asmlinkage void __serpent_enc_blk_8way_avx(struct serpent_ctx *ctx, u8 *dst,
10 const u8 *src, bool xor);
11asmlinkage void serpent_dec_blk_8way_avx(struct serpent_ctx *ctx, u8 *dst,
12 const u8 *src);
13
14static inline void serpent_enc_blk_xway(struct serpent_ctx *ctx, u8 *dst,
15 const u8 *src)
16{
17 __serpent_enc_blk_8way_avx(ctx, dst, src, false);
18}
19
20static inline void serpent_enc_blk_xway_xor(struct serpent_ctx *ctx, u8 *dst,
21 const u8 *src)
22{
23 __serpent_enc_blk_8way_avx(ctx, dst, src, true);
24}
25
26static inline void serpent_dec_blk_xway(struct serpent_ctx *ctx, u8 *dst,
27 const u8 *src)
28{
29 serpent_dec_blk_8way_avx(ctx, dst, src);
30}
31
32#endif
diff --git a/arch/x86/include/asm/serpent.h b/arch/x86/include/asm/crypto/serpent-sse2.h
index d3ef63fe0c8..e6e77dffbda 100644
--- a/arch/x86/include/asm/serpent.h
+++ b/arch/x86/include/asm/crypto/serpent-sse2.h
@@ -1,5 +1,5 @@
1#ifndef ASM_X86_SERPENT_H 1#ifndef ASM_X86_SERPENT_SSE2_H
2#define ASM_X86_SERPENT_H 2#define ASM_X86_SERPENT_SSE2_H
3 3
4#include <linux/crypto.h> 4#include <linux/crypto.h>
5#include <crypto/serpent.h> 5#include <crypto/serpent.h>
diff --git a/arch/x86/include/asm/crypto/twofish.h b/arch/x86/include/asm/crypto/twofish.h
new file mode 100644
index 00000000000..9d2c514bd5f
--- /dev/null
+++ b/arch/x86/include/asm/crypto/twofish.h
@@ -0,0 +1,46 @@
1#ifndef ASM_X86_TWOFISH_H
2#define ASM_X86_TWOFISH_H
3
4#include <linux/crypto.h>
5#include <crypto/twofish.h>
6#include <crypto/lrw.h>
7#include <crypto/b128ops.h>
8
9struct twofish_lrw_ctx {
10 struct lrw_table_ctx lrw_table;
11 struct twofish_ctx twofish_ctx;
12};
13
14struct twofish_xts_ctx {
15 struct twofish_ctx tweak_ctx;
16 struct twofish_ctx crypt_ctx;
17};
18
19/* regular block cipher functions from twofish_x86_64 module */
20asmlinkage void twofish_enc_blk(struct twofish_ctx *ctx, u8 *dst,
21 const u8 *src);
22asmlinkage void twofish_dec_blk(struct twofish_ctx *ctx, u8 *dst,
23 const u8 *src);
24
25/* 3-way parallel cipher functions */
26asmlinkage void __twofish_enc_blk_3way(struct twofish_ctx *ctx, u8 *dst,
27 const u8 *src, bool xor);
28asmlinkage void twofish_dec_blk_3way(struct twofish_ctx *ctx, u8 *dst,
29 const u8 *src);
30
31/* helpers from twofish_x86_64-3way module */
32extern void twofish_dec_blk_cbc_3way(void *ctx, u128 *dst, const u128 *src);
33extern void twofish_enc_blk_ctr(void *ctx, u128 *dst, const u128 *src,
34 u128 *iv);
35extern void twofish_enc_blk_ctr_3way(void *ctx, u128 *dst, const u128 *src,
36 u128 *iv);
37
38extern int lrw_twofish_setkey(struct crypto_tfm *tfm, const u8 *key,
39 unsigned int keylen);
40
41extern void lrw_twofish_exit_tfm(struct crypto_tfm *tfm);
42
43extern int xts_twofish_setkey(struct crypto_tfm *tfm, const u8 *key,
44 unsigned int keylen);
45
46#endif /* ASM_X86_TWOFISH_H */
diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
index cc70c1c78ca..75ce3f47d20 100644
--- a/arch/x86/include/asm/emergency-restart.h
+++ b/arch/x86/include/asm/emergency-restart.h
@@ -4,9 +4,7 @@
4enum reboot_type { 4enum reboot_type {
5 BOOT_TRIPLE = 't', 5 BOOT_TRIPLE = 't',
6 BOOT_KBD = 'k', 6 BOOT_KBD = 'k',
7#ifdef CONFIG_X86_32
8 BOOT_BIOS = 'b', 7 BOOT_BIOS = 'b',
9#endif
10 BOOT_ACPI = 'a', 8 BOOT_ACPI = 'a',
11 BOOT_EFI = 'e', 9 BOOT_EFI = 'e',
12 BOOT_CF9 = 'p', 10 BOOT_CF9 = 'p',
diff --git a/arch/x86/include/asm/entry_arch.h b/arch/x86/include/asm/entry_arch.h
index 0baa628e330..40afa0005c6 100644
--- a/arch/x86/include/asm/entry_arch.h
+++ b/arch/x86/include/asm/entry_arch.h
@@ -15,15 +15,6 @@ BUILD_INTERRUPT(call_function_interrupt,CALL_FUNCTION_VECTOR)
15BUILD_INTERRUPT(call_function_single_interrupt,CALL_FUNCTION_SINGLE_VECTOR) 15BUILD_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
19.irp idx,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, \
20 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
21.if NUM_INVALIDATE_TLB_VECTORS > \idx
22BUILD_INTERRUPT3(invalidate_interrupt\idx,
23 (INVALIDATE_TLB_VECTOR_START)+\idx,
24 smp_invalidate_interrupt)
25.endif
26.endr
27#endif 18#endif
28 19
29BUILD_INTERRUPT(x86_platform_ipi, X86_PLATFORM_IPI_VECTOR) 20BUILD_INTERRUPT(x86_platform_ipi, X86_PLATFORM_IPI_VECTOR)
diff --git a/arch/x86/include/asm/floppy.h b/arch/x86/include/asm/floppy.h
index dbe82a5c5ea..d3d74698dce 100644
--- a/arch/x86/include/asm/floppy.h
+++ b/arch/x86/include/asm/floppy.h
@@ -99,7 +99,7 @@ static irqreturn_t floppy_hardint(int irq, void *dev_id)
99 virtual_dma_residue += virtual_dma_count; 99 virtual_dma_residue += virtual_dma_count;
100 virtual_dma_count = 0; 100 virtual_dma_count = 0;
101#ifdef TRACE_FLPY_INT 101#ifdef TRACE_FLPY_INT
102 printk("count=%x, residue=%x calls=%d bytes=%d dma_wait=%d\n", 102 printk(KERN_DEBUG "count=%x, residue=%x calls=%d bytes=%d dma_wait=%d\n",
103 virtual_dma_count, virtual_dma_residue, calls, bytes, 103 virtual_dma_count, virtual_dma_residue, calls, bytes,
104 dma_wait); 104 dma_wait);
105 calls = 0; 105 calls = 0;
diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h
index 7a15153c675..b518c750993 100644
--- a/arch/x86/include/asm/hypervisor.h
+++ b/arch/x86/include/asm/hypervisor.h
@@ -49,6 +49,7 @@ extern const struct hypervisor_x86 *x86_hyper;
49extern const struct hypervisor_x86 x86_hyper_vmware; 49extern const struct hypervisor_x86 x86_hyper_vmware;
50extern const struct hypervisor_x86 x86_hyper_ms_hyperv; 50extern const struct hypervisor_x86 x86_hyper_ms_hyperv;
51extern const struct hypervisor_x86 x86_hyper_xen_hvm; 51extern const struct hypervisor_x86 x86_hyper_xen_hvm;
52extern const struct hypervisor_x86 x86_hyper_kvm;
52 53
53static inline bool hypervisor_x2apic_available(void) 54static inline bool hypervisor_x2apic_available(void)
54{ 55{
diff --git a/arch/x86/include/asm/iommu.h b/arch/x86/include/asm/iommu.h
index dffc38ee625..345c99cef15 100644
--- a/arch/x86/include/asm/iommu.h
+++ b/arch/x86/include/asm/iommu.h
@@ -5,7 +5,6 @@ extern struct dma_map_ops nommu_dma_ops;
5extern int force_iommu, no_iommu; 5extern int force_iommu, no_iommu;
6extern int iommu_detected; 6extern int iommu_detected;
7extern int iommu_pass_through; 7extern int iommu_pass_through;
8extern int iommu_group_mf;
9 8
10/* 10 seconds */ 9/* 10 seconds */
11#define DMAR_OPERATION_TIMEOUT ((cycles_t) tsc_khz*10*1000) 10#define DMAR_OPERATION_TIMEOUT ((cycles_t) tsc_khz*10*1000)
diff --git a/arch/x86/include/asm/irq_vectors.h b/arch/x86/include/asm/irq_vectors.h
index 4b4448761e8..1508e518c7e 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -119,17 +119,6 @@
119 */ 119 */
120#define LOCAL_TIMER_VECTOR 0xef 120#define LOCAL_TIMER_VECTOR 0xef
121 121
122/* up to 32 vectors used for spreading out TLB flushes: */
123#if NR_CPUS <= 32
124# define NUM_INVALIDATE_TLB_VECTORS (NR_CPUS)
125#else
126# define NUM_INVALIDATE_TLB_VECTORS (32)
127#endif
128
129#define INVALIDATE_TLB_VECTOR_END (0xee)
130#define INVALIDATE_TLB_VECTOR_START \
131 (INVALIDATE_TLB_VECTOR_END-NUM_INVALIDATE_TLB_VECTORS+1)
132
133#define NR_VECTORS 256 122#define NR_VECTORS 256
134 123
135#define FPU_IRQ 13 124#define FPU_IRQ 13
diff --git a/arch/x86/include/asm/kvm.h b/arch/x86/include/asm/kvm.h
index e7d1c194d27..246617efd67 100644
--- a/arch/x86/include/asm/kvm.h
+++ b/arch/x86/include/asm/kvm.h
@@ -12,6 +12,7 @@
12/* Select x86 specific features in <linux/kvm.h> */ 12/* Select x86 specific features in <linux/kvm.h> */
13#define __KVM_HAVE_PIT 13#define __KVM_HAVE_PIT
14#define __KVM_HAVE_IOAPIC 14#define __KVM_HAVE_IOAPIC
15#define __KVM_HAVE_IRQ_LINE
15#define __KVM_HAVE_DEVICE_ASSIGNMENT 16#define __KVM_HAVE_DEVICE_ASSIGNMENT
16#define __KVM_HAVE_MSI 17#define __KVM_HAVE_MSI
17#define __KVM_HAVE_USER_NMI 18#define __KVM_HAVE_USER_NMI
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h
index 1ac46c22dd5..c764f43b71c 100644
--- a/arch/x86/include/asm/kvm_emulate.h
+++ b/arch/x86/include/asm/kvm_emulate.h
@@ -192,8 +192,8 @@ struct x86_emulate_ops {
192 struct x86_instruction_info *info, 192 struct x86_instruction_info *info,
193 enum x86_intercept_stage stage); 193 enum x86_intercept_stage stage);
194 194
195 bool (*get_cpuid)(struct x86_emulate_ctxt *ctxt, 195 void (*get_cpuid)(struct x86_emulate_ctxt *ctxt,
196 u32 *eax, u32 *ebx, u32 *ecx, u32 *edx); 196 u32 *eax, u32 *ebx, u32 *ecx, u32 *edx);
197}; 197};
198 198
199typedef u32 __attribute__((vector_size(16))) sse128_t; 199typedef u32 __attribute__((vector_size(16))) sse128_t;
@@ -280,9 +280,9 @@ struct x86_emulate_ctxt {
280 u8 modrm_seg; 280 u8 modrm_seg;
281 bool rip_relative; 281 bool rip_relative;
282 unsigned long _eip; 282 unsigned long _eip;
283 struct operand memop;
283 /* Fields above regs are cleared together. */ 284 /* Fields above regs are cleared together. */
284 unsigned long regs[NR_VCPU_REGS]; 285 unsigned long regs[NR_VCPU_REGS];
285 struct operand memop;
286 struct operand *memopp; 286 struct operand *memopp;
287 struct fetch_cache fetch; 287 struct fetch_cache fetch;
288 struct read_cache io_read; 288 struct read_cache io_read;
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index db7c1f2709a..09155d64cf7 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -48,12 +48,13 @@
48 48
49#define CR3_PAE_RESERVED_BITS ((X86_CR3_PWT | X86_CR3_PCD) - 1) 49#define CR3_PAE_RESERVED_BITS ((X86_CR3_PWT | X86_CR3_PCD) - 1)
50#define CR3_NONPAE_RESERVED_BITS ((PAGE_SIZE-1) & ~(X86_CR3_PWT | X86_CR3_PCD)) 50#define CR3_NONPAE_RESERVED_BITS ((PAGE_SIZE-1) & ~(X86_CR3_PWT | X86_CR3_PCD))
51#define CR3_PCID_ENABLED_RESERVED_BITS 0xFFFFFF0000000000ULL
51#define CR3_L_MODE_RESERVED_BITS (CR3_NONPAE_RESERVED_BITS | \ 52#define CR3_L_MODE_RESERVED_BITS (CR3_NONPAE_RESERVED_BITS | \
52 0xFFFFFF0000000000ULL) 53 0xFFFFFF0000000000ULL)
53#define CR4_RESERVED_BITS \ 54#define CR4_RESERVED_BITS \
54 (~(unsigned long)(X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD | X86_CR4_DE\ 55 (~(unsigned long)(X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD | X86_CR4_DE\
55 | X86_CR4_PSE | X86_CR4_PAE | X86_CR4_MCE \ 56 | X86_CR4_PSE | X86_CR4_PAE | X86_CR4_MCE \
56 | X86_CR4_PGE | X86_CR4_PCE | X86_CR4_OSFXSR \ 57 | X86_CR4_PGE | X86_CR4_PCE | X86_CR4_OSFXSR | X86_CR4_PCIDE \
57 | X86_CR4_OSXSAVE | X86_CR4_SMEP | X86_CR4_RDWRGSFS \ 58 | X86_CR4_OSXSAVE | X86_CR4_SMEP | X86_CR4_RDWRGSFS \
58 | X86_CR4_OSXMMEXCPT | X86_CR4_VMXE)) 59 | X86_CR4_OSXMMEXCPT | X86_CR4_VMXE))
59 60
@@ -175,6 +176,13 @@ enum {
175 176
176/* apic attention bits */ 177/* apic attention bits */
177#define KVM_APIC_CHECK_VAPIC 0 178#define KVM_APIC_CHECK_VAPIC 0
179/*
180 * The following bit is set with PV-EOI, unset on EOI.
181 * We detect PV-EOI changes by guest by comparing
182 * this bit with PV-EOI in guest memory.
183 * See the implementation in apic_update_pv_eoi.
184 */
185#define KVM_APIC_PV_EOI_PENDING 1
178 186
179/* 187/*
180 * We don't want allocation failures within the mmu code, so we preallocate 188 * We don't want allocation failures within the mmu code, so we preallocate
@@ -313,8 +321,8 @@ struct kvm_pmu {
313 u64 counter_bitmask[2]; 321 u64 counter_bitmask[2];
314 u64 global_ctrl_mask; 322 u64 global_ctrl_mask;
315 u8 version; 323 u8 version;
316 struct kvm_pmc gp_counters[X86_PMC_MAX_GENERIC]; 324 struct kvm_pmc gp_counters[INTEL_PMC_MAX_GENERIC];
317 struct kvm_pmc fixed_counters[X86_PMC_MAX_FIXED]; 325 struct kvm_pmc fixed_counters[INTEL_PMC_MAX_FIXED];
318 struct irq_work irq_work; 326 struct irq_work irq_work;
319 u64 reprogram_pmi; 327 u64 reprogram_pmi;
320}; 328};
@@ -484,6 +492,11 @@ struct kvm_vcpu_arch {
484 u64 length; 492 u64 length;
485 u64 status; 493 u64 status;
486 } osvw; 494 } osvw;
495
496 struct {
497 u64 msr_val;
498 struct gfn_to_hva_cache data;
499 } pv_eoi;
487}; 500};
488 501
489struct kvm_lpage_info { 502struct kvm_lpage_info {
@@ -661,6 +674,7 @@ struct kvm_x86_ops {
661 u64 (*get_mt_mask)(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio); 674 u64 (*get_mt_mask)(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio);
662 int (*get_lpage_level)(void); 675 int (*get_lpage_level)(void);
663 bool (*rdtscp_supported)(void); 676 bool (*rdtscp_supported)(void);
677 bool (*invpcid_supported)(void);
664 void (*adjust_tsc_offset)(struct kvm_vcpu *vcpu, s64 adjustment, bool host); 678 void (*adjust_tsc_offset)(struct kvm_vcpu *vcpu, s64 adjustment, bool host);
665 679
666 void (*set_tdp_cr3)(struct kvm_vcpu *vcpu, unsigned long cr3); 680 void (*set_tdp_cr3)(struct kvm_vcpu *vcpu, unsigned long cr3);
@@ -802,7 +816,20 @@ int kvm_read_guest_page_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,
802void kvm_propagate_fault(struct kvm_vcpu *vcpu, struct x86_exception *fault); 816void kvm_propagate_fault(struct kvm_vcpu *vcpu, struct x86_exception *fault);
803bool kvm_require_cpl(struct kvm_vcpu *vcpu, int required_cpl); 817bool kvm_require_cpl(struct kvm_vcpu *vcpu, int required_cpl);
804 818
805int kvm_pic_set_irq(void *opaque, int irq, int level); 819static inline int __kvm_irq_line_state(unsigned long *irq_state,
820 int irq_source_id, int level)
821{
822 /* Logical OR for level trig interrupt */
823 if (level)
824 __set_bit(irq_source_id, irq_state);
825 else
826 __clear_bit(irq_source_id, irq_state);
827
828 return !!(*irq_state);
829}
830
831int kvm_pic_set_irq(struct kvm_pic *pic, int irq, int irq_source_id, int level);
832void kvm_pic_clear_all(struct kvm_pic *pic, int irq_source_id);
806 833
807void kvm_inject_nmi(struct kvm_vcpu *vcpu); 834void kvm_inject_nmi(struct kvm_vcpu *vcpu);
808 835
diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h
index 63ab1661d00..2f7712e08b1 100644
--- a/arch/x86/include/asm/kvm_para.h
+++ b/arch/x86/include/asm/kvm_para.h
@@ -22,6 +22,7 @@
22#define KVM_FEATURE_CLOCKSOURCE2 3 22#define KVM_FEATURE_CLOCKSOURCE2 3
23#define KVM_FEATURE_ASYNC_PF 4 23#define KVM_FEATURE_ASYNC_PF 4
24#define KVM_FEATURE_STEAL_TIME 5 24#define KVM_FEATURE_STEAL_TIME 5
25#define KVM_FEATURE_PV_EOI 6
25 26
26/* The last 8 bits are used to indicate how to interpret the flags field 27/* The last 8 bits are used to indicate how to interpret the flags field
27 * in pvclock structure. If no bits are set, all flags are ignored. 28 * in pvclock structure. If no bits are set, all flags are ignored.
@@ -37,6 +38,7 @@
37#define MSR_KVM_SYSTEM_TIME_NEW 0x4b564d01 38#define MSR_KVM_SYSTEM_TIME_NEW 0x4b564d01
38#define MSR_KVM_ASYNC_PF_EN 0x4b564d02 39#define MSR_KVM_ASYNC_PF_EN 0x4b564d02
39#define MSR_KVM_STEAL_TIME 0x4b564d03 40#define MSR_KVM_STEAL_TIME 0x4b564d03
41#define MSR_KVM_PV_EOI_EN 0x4b564d04
40 42
41struct kvm_steal_time { 43struct kvm_steal_time {
42 __u64 steal; 44 __u64 steal;
@@ -89,6 +91,11 @@ struct kvm_vcpu_pv_apf_data {
89 __u32 enabled; 91 __u32 enabled;
90}; 92};
91 93
94#define KVM_PV_EOI_BIT 0
95#define KVM_PV_EOI_MASK (0x1 << KVM_PV_EOI_BIT)
96#define KVM_PV_EOI_ENABLED KVM_PV_EOI_MASK
97#define KVM_PV_EOI_DISABLED 0x0
98
92#ifdef __KERNEL__ 99#ifdef __KERNEL__
93#include <asm/processor.h> 100#include <asm/processor.h>
94 101
diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index 441520e4174..a3ac52b29cb 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -33,6 +33,14 @@
33#define MCI_STATUS_PCC (1ULL<<57) /* processor context corrupt */ 33#define MCI_STATUS_PCC (1ULL<<57) /* processor context corrupt */
34#define MCI_STATUS_S (1ULL<<56) /* Signaled machine check */ 34#define MCI_STATUS_S (1ULL<<56) /* Signaled machine check */
35#define MCI_STATUS_AR (1ULL<<55) /* Action required */ 35#define MCI_STATUS_AR (1ULL<<55) /* Action required */
36#define MCACOD 0xffff /* MCA Error Code */
37
38/* Architecturally defined codes from SDM Vol. 3B Chapter 15 */
39#define MCACOD_SCRUB 0x00C0 /* 0xC0-0xCF Memory Scrubbing */
40#define MCACOD_SCRUBMSK 0xfff0
41#define MCACOD_L3WB 0x017A /* L3 Explicit Writeback */
42#define MCACOD_DATA 0x0134 /* Data Load */
43#define MCACOD_INSTR 0x0150 /* Instruction Fetch */
36 44
37/* MCi_MISC register defines */ 45/* MCi_MISC register defines */
38#define MCI_MISC_ADDR_LSB(m) ((m) & 0x3f) 46#define MCI_MISC_ADDR_LSB(m) ((m) & 0x3f)
diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index 084ef95274c..813ed103f45 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h
@@ -115,8 +115,8 @@ notrace static inline int native_write_msr_safe(unsigned int msr,
115 115
116extern unsigned long long native_read_tsc(void); 116extern unsigned long long native_read_tsc(void);
117 117
118extern int native_rdmsr_safe_regs(u32 regs[8]); 118extern int rdmsr_safe_regs(u32 regs[8]);
119extern int native_wrmsr_safe_regs(u32 regs[8]); 119extern int wrmsr_safe_regs(u32 regs[8]);
120 120
121static __always_inline unsigned long long __native_read_tsc(void) 121static __always_inline unsigned long long __native_read_tsc(void)
122{ 122{
@@ -187,43 +187,6 @@ static inline int rdmsrl_safe(unsigned msr, unsigned long long *p)
187 return err; 187 return err;
188} 188}
189 189
190static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p)
191{
192 u32 gprs[8] = { 0 };
193 int err;
194
195 gprs[1] = msr;
196 gprs[7] = 0x9c5a203a;
197
198 err = native_rdmsr_safe_regs(gprs);
199
200 *p = gprs[0] | ((u64)gprs[2] << 32);
201
202 return err;
203}
204
205static inline int wrmsrl_amd_safe(unsigned msr, unsigned long long val)
206{
207 u32 gprs[8] = { 0 };
208
209 gprs[0] = (u32)val;
210 gprs[1] = msr;
211 gprs[2] = val >> 32;
212 gprs[7] = 0x9c5a203a;
213
214 return native_wrmsr_safe_regs(gprs);
215}
216
217static inline int rdmsr_safe_regs(u32 regs[8])
218{
219 return native_rdmsr_safe_regs(regs);
220}
221
222static inline int wrmsr_safe_regs(u32 regs[8])
223{
224 return native_wrmsr_safe_regs(regs);
225}
226
227#define rdtscl(low) \ 190#define rdtscl(low) \
228 ((low) = (u32)__native_read_tsc()) 191 ((low) = (u32)__native_read_tsc())
229 192
@@ -237,6 +200,8 @@ do { \
237 (high) = (u32)(_l >> 32); \ 200 (high) = (u32)(_l >> 32); \
238} while (0) 201} while (0)
239 202
203#define rdpmcl(counter, val) ((val) = native_read_pmc(counter))
204
240#define rdtscp(low, high, aux) \ 205#define rdtscp(low, high, aux) \
241do { \ 206do { \
242 unsigned long long _val = native_read_tscp(&(aux)); \ 207 unsigned long long _val = native_read_tscp(&(aux)); \
@@ -248,8 +213,7 @@ do { \
248 213
249#endif /* !CONFIG_PARAVIRT */ 214#endif /* !CONFIG_PARAVIRT */
250 215
251 216#define wrmsrl_safe(msr, val) wrmsr_safe((msr), (u32)(val), \
252#define checking_wrmsrl(msr, val) wrmsr_safe((msr), (u32)(val), \
253 (u32)((val) >> 32)) 217 (u32)((val) >> 32))
254 218
255#define write_tsc(val1, val2) wrmsr(MSR_IA32_TSC, (val1), (val2)) 219#define write_tsc(val1, val2) wrmsr(MSR_IA32_TSC, (val1), (val2))
diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
index dc580c42851..c0fa356e90d 100644
--- a/arch/x86/include/asm/nmi.h
+++ b/arch/x86/include/asm/nmi.h
@@ -44,28 +44,14 @@ struct nmiaction {
44 const char *name; 44 const char *name;
45}; 45};
46 46
47#define register_nmi_handler(t, fn, fg, n) \ 47#define register_nmi_handler(t, fn, fg, n, init...) \
48({ \ 48({ \
49 static struct nmiaction fn##_na = { \ 49 static struct nmiaction init fn##_na = { \
50 .handler = (fn), \ 50 .handler = (fn), \
51 .name = (n), \ 51 .name = (n), \
52 .flags = (fg), \ 52 .flags = (fg), \
53 }; \ 53 }; \
54 __register_nmi_handler((t), &fn##_na); \ 54 __register_nmi_handler((t), &fn##_na); \
55})
56
57/*
58 * For special handlers that register/unregister in the
59 * init section only. This should be considered rare.
60 */
61#define register_nmi_handler_initonly(t, fn, fg, n) \
62({ \
63 static struct nmiaction fn##_na __initdata = { \
64 .handler = (fn), \
65 .name = (n), \
66 .flags = (fg), \
67 }; \
68 __register_nmi_handler((t), &fn##_na); \
69}) 55})
70 56
71int __register_nmi_handler(unsigned int, struct nmiaction *); 57int __register_nmi_handler(unsigned int, struct nmiaction *);
diff --git a/arch/x86/include/asm/olpc.h b/arch/x86/include/asm/olpc.h
index 87bdbca72f9..72f9adf6eca 100644
--- a/arch/x86/include/asm/olpc.h
+++ b/arch/x86/include/asm/olpc.h
@@ -100,25 +100,6 @@ extern void olpc_xo1_pm_wakeup_clear(u16 value);
100 100
101extern int pci_olpc_init(void); 101extern int pci_olpc_init(void);
102 102
103/* EC related functions */
104
105extern int olpc_ec_cmd(unsigned char cmd, unsigned char *inbuf, size_t inlen,
106 unsigned char *outbuf, size_t outlen);
107
108/* EC commands */
109
110#define EC_FIRMWARE_REV 0x08
111#define EC_WRITE_SCI_MASK 0x1b
112#define EC_WAKE_UP_WLAN 0x24
113#define EC_WLAN_LEAVE_RESET 0x25
114#define EC_READ_EB_MODE 0x2a
115#define EC_SET_SCI_INHIBIT 0x32
116#define EC_SET_SCI_INHIBIT_RELEASE 0x34
117#define EC_WLAN_ENTER_RESET 0x35
118#define EC_WRITE_EXT_SCI_MASK 0x38
119#define EC_SCI_QUERY 0x84
120#define EC_EXT_SCI_QUERY 0x85
121
122/* SCI source values */ 103/* SCI source values */
123 104
124#define EC_SCI_SRC_EMPTY 0x00 105#define EC_SCI_SRC_EMPTY 0x00
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 6cbbabf5270..a0facf3908d 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -128,21 +128,11 @@ static inline u64 paravirt_read_msr(unsigned msr, int *err)
128 return PVOP_CALL2(u64, pv_cpu_ops.read_msr, msr, err); 128 return PVOP_CALL2(u64, pv_cpu_ops.read_msr, msr, err);
129} 129}
130 130
131static inline int paravirt_rdmsr_regs(u32 *regs)
132{
133 return PVOP_CALL1(int, pv_cpu_ops.rdmsr_regs, regs);
134}
135
136static inline int paravirt_write_msr(unsigned msr, unsigned low, unsigned high) 131static inline int paravirt_write_msr(unsigned msr, unsigned low, unsigned high)
137{ 132{
138 return PVOP_CALL3(int, pv_cpu_ops.write_msr, msr, low, high); 133 return PVOP_CALL3(int, pv_cpu_ops.write_msr, msr, low, high);
139} 134}
140 135
141static inline int paravirt_wrmsr_regs(u32 *regs)
142{
143 return PVOP_CALL1(int, pv_cpu_ops.wrmsr_regs, regs);
144}
145
146/* These should all do BUG_ON(_err), but our headers are too tangled. */ 136/* These should all do BUG_ON(_err), but our headers are too tangled. */
147#define rdmsr(msr, val1, val2) \ 137#define rdmsr(msr, val1, val2) \
148do { \ 138do { \
@@ -176,9 +166,6 @@ do { \
176 _err; \ 166 _err; \
177}) 167})
178 168
179#define rdmsr_safe_regs(regs) paravirt_rdmsr_regs(regs)
180#define wrmsr_safe_regs(regs) paravirt_wrmsr_regs(regs)
181
182static inline int rdmsrl_safe(unsigned msr, unsigned long long *p) 169static inline int rdmsrl_safe(unsigned msr, unsigned long long *p)
183{ 170{
184 int err; 171 int err;
@@ -186,32 +173,6 @@ static inline int rdmsrl_safe(unsigned msr, unsigned long long *p)
186 *p = paravirt_read_msr(msr, &err); 173 *p = paravirt_read_msr(msr, &err);
187 return err; 174 return err;
188} 175}
189static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p)
190{
191 u32 gprs[8] = { 0 };
192 int err;
193
194 gprs[1] = msr;
195 gprs[7] = 0x9c5a203a;
196
197 err = paravirt_rdmsr_regs(gprs);
198
199 *p = gprs[0] | ((u64)gprs[2] << 32);
200
201 return err;
202}
203
204static inline int wrmsrl_amd_safe(unsigned msr, unsigned long long val)
205{
206 u32 gprs[8] = { 0 };
207
208 gprs[0] = (u32)val;
209 gprs[1] = msr;
210 gprs[2] = val >> 32;
211 gprs[7] = 0x9c5a203a;
212
213 return paravirt_wrmsr_regs(gprs);
214}
215 176
216static inline u64 paravirt_read_tsc(void) 177static inline u64 paravirt_read_tsc(void)
217{ 178{
@@ -252,6 +213,8 @@ do { \
252 high = _l >> 32; \ 213 high = _l >> 32; \
253} while (0) 214} while (0)
254 215
216#define rdpmcl(counter, val) ((val) = paravirt_read_pmc(counter))
217
255static inline unsigned long long paravirt_rdtscp(unsigned int *aux) 218static inline unsigned long long paravirt_rdtscp(unsigned int *aux)
256{ 219{
257 return PVOP_CALL1(u64, pv_cpu_ops.read_tscp, aux); 220 return PVOP_CALL1(u64, pv_cpu_ops.read_tscp, aux);
@@ -397,9 +360,10 @@ static inline void __flush_tlb_single(unsigned long addr)
397 360
398static inline void flush_tlb_others(const struct cpumask *cpumask, 361static inline void flush_tlb_others(const struct cpumask *cpumask,
399 struct mm_struct *mm, 362 struct mm_struct *mm,
400 unsigned long va) 363 unsigned long start,
364 unsigned long end)
401{ 365{
402 PVOP_VCALL3(pv_mmu_ops.flush_tlb_others, cpumask, mm, va); 366 PVOP_VCALL4(pv_mmu_ops.flush_tlb_others, cpumask, mm, start, end);
403} 367}
404 368
405static inline int paravirt_pgd_alloc(struct mm_struct *mm) 369static inline int paravirt_pgd_alloc(struct mm_struct *mm)
diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
index 8e8b9a4987e..142236ed83a 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -153,9 +153,7 @@ struct pv_cpu_ops {
153 /* MSR, PMC and TSR operations. 153 /* MSR, PMC and TSR operations.
154 err = 0/-EFAULT. wrmsr returns 0/-EFAULT. */ 154 err = 0/-EFAULT. wrmsr returns 0/-EFAULT. */
155 u64 (*read_msr)(unsigned int msr, int *err); 155 u64 (*read_msr)(unsigned int msr, int *err);
156 int (*rdmsr_regs)(u32 *regs);
157 int (*write_msr)(unsigned int msr, unsigned low, unsigned high); 156 int (*write_msr)(unsigned int msr, unsigned low, unsigned high);
158 int (*wrmsr_regs)(u32 *regs);
159 157
160 u64 (*read_tsc)(void); 158 u64 (*read_tsc)(void);
161 u64 (*read_pmc)(int counter); 159 u64 (*read_pmc)(int counter);
@@ -250,7 +248,8 @@ struct pv_mmu_ops {
250 void (*flush_tlb_single)(unsigned long addr); 248 void (*flush_tlb_single)(unsigned long addr);
251 void (*flush_tlb_others)(const struct cpumask *cpus, 249 void (*flush_tlb_others)(const struct cpumask *cpus,
252 struct mm_struct *mm, 250 struct mm_struct *mm,
253 unsigned long va); 251 unsigned long start,
252 unsigned long end);
254 253
255 /* Hooks for allocating and freeing a pagetable top-level */ 254 /* Hooks for allocating and freeing a pagetable top-level */
256 int (*pgd_alloc)(struct mm_struct *mm); 255 int (*pgd_alloc)(struct mm_struct *mm);
diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h
index b3a53174602..73e8eeff22e 100644
--- a/arch/x86/include/asm/pci_x86.h
+++ b/arch/x86/include/asm/pci_x86.h
@@ -7,9 +7,13 @@
7#undef DEBUG 7#undef DEBUG
8 8
9#ifdef DEBUG 9#ifdef DEBUG
10#define DBG(x...) printk(x) 10#define DBG(fmt, ...) printk(fmt, ##__VA_ARGS__)
11#else 11#else
12#define DBG(x...) 12#define DBG(fmt, ...) \
13do { \
14 if (0) \
15 printk(fmt, ##__VA_ARGS__); \
16} while (0)
13#endif 17#endif
14 18
15#define PCI_PROBE_BIOS 0x0001 19#define PCI_PROBE_BIOS 0x0001
@@ -100,6 +104,7 @@ struct pci_raw_ops {
100extern const struct pci_raw_ops *raw_pci_ops; 104extern const struct pci_raw_ops *raw_pci_ops;
101extern const struct pci_raw_ops *raw_pci_ext_ops; 105extern const struct pci_raw_ops *raw_pci_ext_ops;
102 106
107extern const struct pci_raw_ops pci_mmcfg;
103extern const struct pci_raw_ops pci_direct_conf1; 108extern const struct pci_raw_ops pci_direct_conf1;
104extern bool port_cf9_safe; 109extern bool port_cf9_safe;
105 110
@@ -135,6 +140,12 @@ struct pci_mmcfg_region {
135 140
136extern int __init pci_mmcfg_arch_init(void); 141extern int __init pci_mmcfg_arch_init(void);
137extern void __init pci_mmcfg_arch_free(void); 142extern void __init pci_mmcfg_arch_free(void);
143extern int __devinit pci_mmcfg_arch_map(struct pci_mmcfg_region *cfg);
144extern void pci_mmcfg_arch_unmap(struct pci_mmcfg_region *cfg);
145extern int __devinit pci_mmconfig_insert(struct device *dev,
146 u16 seg, u8 start,
147 u8 end, phys_addr_t addr);
148extern int pci_mmconfig_delete(u16 seg, u8 start, u8 end);
138extern struct pci_mmcfg_region *pci_mmconfig_lookup(int segment, int bus); 149extern struct pci_mmcfg_region *pci_mmconfig_lookup(int segment, int bus);
139 150
140extern struct list_head pci_mmcfg_list; 151extern struct list_head pci_mmcfg_list;
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index d9b8e3f7f42..1104afaba52 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -551,6 +551,12 @@ DECLARE_PER_CPU(unsigned long, this_cpu_off);
551 { [0 ... NR_CPUS-1] = _initvalue }; \ 551 { [0 ... NR_CPUS-1] = _initvalue }; \
552 __typeof__(_type) *_name##_early_ptr __refdata = _name##_early_map 552 __typeof__(_type) *_name##_early_ptr __refdata = _name##_early_map
553 553
554#define DEFINE_EARLY_PER_CPU_READ_MOSTLY(_type, _name, _initvalue) \
555 DEFINE_PER_CPU_READ_MOSTLY(_type, _name) = _initvalue; \
556 __typeof__(_type) _name##_early_map[NR_CPUS] __initdata = \
557 { [0 ... NR_CPUS-1] = _initvalue }; \
558 __typeof__(_type) *_name##_early_ptr __refdata = _name##_early_map
559
554#define EXPORT_EARLY_PER_CPU_SYMBOL(_name) \ 560#define EXPORT_EARLY_PER_CPU_SYMBOL(_name) \
555 EXPORT_PER_CPU_SYMBOL(_name) 561 EXPORT_PER_CPU_SYMBOL(_name)
556 562
@@ -559,6 +565,11 @@ DECLARE_PER_CPU(unsigned long, this_cpu_off);
559 extern __typeof__(_type) *_name##_early_ptr; \ 565 extern __typeof__(_type) *_name##_early_ptr; \
560 extern __typeof__(_type) _name##_early_map[] 566 extern __typeof__(_type) _name##_early_map[]
561 567
568#define DECLARE_EARLY_PER_CPU_READ_MOSTLY(_type, _name) \
569 DECLARE_PER_CPU_READ_MOSTLY(_type, _name); \
570 extern __typeof__(_type) *_name##_early_ptr; \
571 extern __typeof__(_type) _name##_early_map[]
572
562#define early_per_cpu_ptr(_name) (_name##_early_ptr) 573#define early_per_cpu_ptr(_name) (_name##_early_ptr)
563#define early_per_cpu_map(_name, _idx) (_name##_early_map[_idx]) 574#define early_per_cpu_map(_name, _idx) (_name##_early_map[_idx])
564#define early_per_cpu(_name, _cpu) \ 575#define early_per_cpu(_name, _cpu) \
@@ -570,12 +581,18 @@ DECLARE_PER_CPU(unsigned long, this_cpu_off);
570#define DEFINE_EARLY_PER_CPU(_type, _name, _initvalue) \ 581#define DEFINE_EARLY_PER_CPU(_type, _name, _initvalue) \
571 DEFINE_PER_CPU(_type, _name) = _initvalue 582 DEFINE_PER_CPU(_type, _name) = _initvalue
572 583
584#define DEFINE_EARLY_PER_CPU_READ_MOSTLY(_type, _name, _initvalue) \
585 DEFINE_PER_CPU_READ_MOSTLY(_type, _name) = _initvalue
586
573#define EXPORT_EARLY_PER_CPU_SYMBOL(_name) \ 587#define EXPORT_EARLY_PER_CPU_SYMBOL(_name) \
574 EXPORT_PER_CPU_SYMBOL(_name) 588 EXPORT_PER_CPU_SYMBOL(_name)
575 589
576#define DECLARE_EARLY_PER_CPU(_type, _name) \ 590#define DECLARE_EARLY_PER_CPU(_type, _name) \
577 DECLARE_PER_CPU(_type, _name) 591 DECLARE_PER_CPU(_type, _name)
578 592
593#define DECLARE_EARLY_PER_CPU_READ_MOSTLY(_type, _name) \
594 DECLARE_PER_CPU_READ_MOSTLY(_type, _name)
595
579#define early_per_cpu(_name, _cpu) per_cpu(_name, _cpu) 596#define early_per_cpu(_name, _cpu) per_cpu(_name, _cpu)
580#define early_per_cpu_ptr(_name) NULL 597#define early_per_cpu_ptr(_name) NULL
581/* no early_per_cpu_map() */ 598/* no early_per_cpu_map() */
diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h
index 588f52ea810..cb4e43bce98 100644
--- a/arch/x86/include/asm/perf_event.h
+++ b/arch/x86/include/asm/perf_event.h
@@ -5,11 +5,10 @@
5 * Performance event hw details: 5 * Performance event hw details:
6 */ 6 */
7 7
8#define X86_PMC_MAX_GENERIC 32 8#define INTEL_PMC_MAX_GENERIC 32
9#define X86_PMC_MAX_FIXED 3 9#define INTEL_PMC_MAX_FIXED 3
10#define INTEL_PMC_IDX_FIXED 32
10 11
11#define X86_PMC_IDX_GENERIC 0
12#define X86_PMC_IDX_FIXED 32
13#define X86_PMC_IDX_MAX 64 12#define X86_PMC_IDX_MAX 64
14 13
15#define MSR_ARCH_PERFMON_PERFCTR0 0xc1 14#define MSR_ARCH_PERFMON_PERFCTR0 0xc1
@@ -48,8 +47,7 @@
48 (X86_RAW_EVENT_MASK | \ 47 (X86_RAW_EVENT_MASK | \
49 AMD64_EVENTSEL_EVENT) 48 AMD64_EVENTSEL_EVENT)
50#define AMD64_NUM_COUNTERS 4 49#define AMD64_NUM_COUNTERS 4
51#define AMD64_NUM_COUNTERS_F15H 6 50#define AMD64_NUM_COUNTERS_CORE 6
52#define AMD64_NUM_COUNTERS_MAX AMD64_NUM_COUNTERS_F15H
53 51
54#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL 0x3c 52#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL 0x3c
55#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK (0x00 << 8) 53#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK (0x00 << 8)
@@ -121,16 +119,16 @@ struct x86_pmu_capability {
121 119
122/* Instr_Retired.Any: */ 120/* Instr_Retired.Any: */
123#define MSR_ARCH_PERFMON_FIXED_CTR0 0x309 121#define MSR_ARCH_PERFMON_FIXED_CTR0 0x309
124#define X86_PMC_IDX_FIXED_INSTRUCTIONS (X86_PMC_IDX_FIXED + 0) 122#define INTEL_PMC_IDX_FIXED_INSTRUCTIONS (INTEL_PMC_IDX_FIXED + 0)
125 123
126/* CPU_CLK_Unhalted.Core: */ 124/* CPU_CLK_Unhalted.Core: */
127#define MSR_ARCH_PERFMON_FIXED_CTR1 0x30a 125#define MSR_ARCH_PERFMON_FIXED_CTR1 0x30a
128#define X86_PMC_IDX_FIXED_CPU_CYCLES (X86_PMC_IDX_FIXED + 1) 126#define INTEL_PMC_IDX_FIXED_CPU_CYCLES (INTEL_PMC_IDX_FIXED + 1)
129 127
130/* CPU_CLK_Unhalted.Ref: */ 128/* CPU_CLK_Unhalted.Ref: */
131#define MSR_ARCH_PERFMON_FIXED_CTR2 0x30b 129#define MSR_ARCH_PERFMON_FIXED_CTR2 0x30b
132#define X86_PMC_IDX_FIXED_REF_CYCLES (X86_PMC_IDX_FIXED + 2) 130#define INTEL_PMC_IDX_FIXED_REF_CYCLES (INTEL_PMC_IDX_FIXED + 2)
133#define X86_PMC_MSK_FIXED_REF_CYCLES (1ULL << X86_PMC_IDX_FIXED_REF_CYCLES) 131#define INTEL_PMC_MSK_FIXED_REF_CYCLES (1ULL << INTEL_PMC_IDX_FIXED_REF_CYCLES)
134 132
135/* 133/*
136 * We model BTS tracing as another fixed-mode PMC. 134 * We model BTS tracing as another fixed-mode PMC.
@@ -139,7 +137,7 @@ struct x86_pmu_capability {
139 * values are used by actual fixed events and higher values are used 137 * values are used by actual fixed events and higher values are used
140 * to indicate other overflow conditions in the PERF_GLOBAL_STATUS msr. 138 * to indicate other overflow conditions in the PERF_GLOBAL_STATUS msr.
141 */ 139 */
142#define X86_PMC_IDX_FIXED_BTS (X86_PMC_IDX_FIXED + 16) 140#define INTEL_PMC_IDX_FIXED_BTS (INTEL_PMC_IDX_FIXED + 16)
143 141
144/* 142/*
145 * IBS cpuid feature detection 143 * IBS cpuid feature detection
@@ -198,11 +196,16 @@ static inline u32 get_ibs_caps(void) { return 0; }
198extern void perf_events_lapic_init(void); 196extern void perf_events_lapic_init(void);
199 197
200/* 198/*
201 * Abuse bit 3 of the cpu eflags register to indicate proper PEBS IP fixups. 199 * Abuse bits {3,5} of the cpu eflags register. These flags are otherwise
202 * This flag is otherwise unused and ABI specified to be 0, so nobody should 200 * unused and ABI specified to be 0, so nobody should care what we do with
203 * care what we do with it. 201 * them.
202 *
203 * EXACT - the IP points to the exact instruction that triggered the
204 * event (HW bugs exempt).
205 * VM - original X86_VM_MASK; see set_linear_ip().
204 */ 206 */
205#define PERF_EFLAGS_EXACT (1UL << 3) 207#define PERF_EFLAGS_EXACT (1UL << 3)
208#define PERF_EFLAGS_VM (1UL << 5)
206 209
207struct pt_regs; 210struct pt_regs;
208extern unsigned long perf_instruction_pointer(struct pt_regs *regs); 211extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
@@ -234,8 +237,9 @@ struct perf_guest_switch_msr {
234 237
235extern struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr); 238extern struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr);
236extern void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap); 239extern void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap);
240extern void perf_check_microcode(void);
237#else 241#else
238static inline perf_guest_switch_msr *perf_guest_get_msrs(int *nr) 242static inline struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
239{ 243{
240 *nr = 0; 244 *nr = 0;
241 return NULL; 245 return NULL;
@@ -247,6 +251,7 @@ static inline void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap)
247} 251}
248 252
249static inline void perf_events_lapic_init(void) { } 253static inline void perf_events_lapic_init(void) { }
254static inline void perf_check_microcode(void) { }
250#endif 255#endif
251 256
252#if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_AMD) 257#if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_AMD)
diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
index 98391db840c..f2b489cf160 100644
--- a/arch/x86/include/asm/pgtable-2level.h
+++ b/arch/x86/include/asm/pgtable-2level.h
@@ -2,9 +2,9 @@
2#define _ASM_X86_PGTABLE_2LEVEL_H 2#define _ASM_X86_PGTABLE_2LEVEL_H
3 3
4#define pte_ERROR(e) \ 4#define pte_ERROR(e) \
5 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, (e).pte_low) 5 pr_err("%s:%d: bad pte %08lx\n", __FILE__, __LINE__, (e).pte_low)
6#define pgd_ERROR(e) \ 6#define pgd_ERROR(e) \
7 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e)) 7 pr_err("%s:%d: bad pgd %08lx\n", __FILE__, __LINE__, pgd_val(e))
8 8
9/* 9/*
10 * Certain architectures need to do special things when PTEs 10 * Certain architectures need to do special things when PTEs
diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
index cb00ccc7d57..4cc9f2b7cdc 100644
--- a/arch/x86/include/asm/pgtable-3level.h
+++ b/arch/x86/include/asm/pgtable-3level.h
@@ -9,13 +9,13 @@
9 */ 9 */
10 10
11#define pte_ERROR(e) \ 11#define pte_ERROR(e) \
12 printk("%s:%d: bad pte %p(%08lx%08lx).\n", \ 12 pr_err("%s:%d: bad pte %p(%08lx%08lx)\n", \
13 __FILE__, __LINE__, &(e), (e).pte_high, (e).pte_low) 13 __FILE__, __LINE__, &(e), (e).pte_high, (e).pte_low)
14#define pmd_ERROR(e) \ 14#define pmd_ERROR(e) \
15 printk("%s:%d: bad pmd %p(%016Lx).\n", \ 15 pr_err("%s:%d: bad pmd %p(%016Lx)\n", \
16 __FILE__, __LINE__, &(e), pmd_val(e)) 16 __FILE__, __LINE__, &(e), pmd_val(e))
17#define pgd_ERROR(e) \ 17#define pgd_ERROR(e) \
18 printk("%s:%d: bad pgd %p(%016Lx).\n", \ 18 pr_err("%s:%d: bad pgd %p(%016Lx)\n", \
19 __FILE__, __LINE__, &(e), pgd_val(e)) 19 __FILE__, __LINE__, &(e), pgd_val(e))
20 20
21/* Rules for using set_pte: the pte being assigned *must* be 21/* Rules for using set_pte: the pte being assigned *must* be
diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index 975f709e09a..8251be02301 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -26,16 +26,16 @@ extern pgd_t init_level4_pgt[];
26extern void paging_init(void); 26extern void paging_init(void);
27 27
28#define pte_ERROR(e) \ 28#define pte_ERROR(e) \
29 printk("%s:%d: bad pte %p(%016lx).\n", \ 29 pr_err("%s:%d: bad pte %p(%016lx)\n", \
30 __FILE__, __LINE__, &(e), pte_val(e)) 30 __FILE__, __LINE__, &(e), pte_val(e))
31#define pmd_ERROR(e) \ 31#define pmd_ERROR(e) \
32 printk("%s:%d: bad pmd %p(%016lx).\n", \ 32 pr_err("%s:%d: bad pmd %p(%016lx)\n", \
33 __FILE__, __LINE__, &(e), pmd_val(e)) 33 __FILE__, __LINE__, &(e), pmd_val(e))
34#define pud_ERROR(e) \ 34#define pud_ERROR(e) \
35 printk("%s:%d: bad pud %p(%016lx).\n", \ 35 pr_err("%s:%d: bad pud %p(%016lx)\n", \
36 __FILE__, __LINE__, &(e), pud_val(e)) 36 __FILE__, __LINE__, &(e), pud_val(e))
37#define pgd_ERROR(e) \ 37#define pgd_ERROR(e) \
38 printk("%s:%d: bad pgd %p(%016lx).\n", \ 38 pr_err("%s:%d: bad pgd %p(%016lx)\n", \
39 __FILE__, __LINE__, &(e), pgd_val(e)) 39 __FILE__, __LINE__, &(e), pgd_val(e))
40 40
41struct mm_struct; 41struct mm_struct;
diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
index 013286a10c2..db8fec6d295 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -303,11 +303,9 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pte);
303 303
304extern void native_pagetable_reserve(u64 start, u64 end); 304extern void native_pagetable_reserve(u64 start, u64 end);
305#ifdef CONFIG_X86_32 305#ifdef CONFIG_X86_32
306extern void native_pagetable_setup_start(pgd_t *base); 306extern void native_pagetable_init(void);
307extern void native_pagetable_setup_done(pgd_t *base);
308#else 307#else
309#define native_pagetable_setup_start x86_init_pgd_noop 308#define native_pagetable_init paging_init
310#define native_pagetable_setup_done x86_init_pgd_noop
311#endif 309#endif
312 310
313struct seq_file; 311struct seq_file;
diff --git a/arch/x86/include/asm/processor-flags.h b/arch/x86/include/asm/processor-flags.h
index f8ab3eaad12..aea1d1d848c 100644
--- a/arch/x86/include/asm/processor-flags.h
+++ b/arch/x86/include/asm/processor-flags.h
@@ -44,6 +44,7 @@
44 */ 44 */
45#define X86_CR3_PWT 0x00000008 /* Page Write Through */ 45#define X86_CR3_PWT 0x00000008 /* Page Write Through */
46#define X86_CR3_PCD 0x00000010 /* Page Cache Disable */ 46#define X86_CR3_PCD 0x00000010 /* Page Cache Disable */
47#define X86_CR3_PCID_MASK 0x00000fff /* PCID Mask */
47 48
48/* 49/*
49 * Intel CPU features in CR4 50 * Intel CPU features in CR4
@@ -61,6 +62,7 @@
61#define X86_CR4_OSXMMEXCPT 0x00000400 /* enable unmasked SSE exceptions */ 62#define X86_CR4_OSXMMEXCPT 0x00000400 /* enable unmasked SSE exceptions */
62#define X86_CR4_VMXE 0x00002000 /* enable VMX virtualization */ 63#define X86_CR4_VMXE 0x00002000 /* enable VMX virtualization */
63#define X86_CR4_RDWRGSFS 0x00010000 /* enable RDWRGSFS support */ 64#define X86_CR4_RDWRGSFS 0x00010000 /* enable RDWRGSFS support */
65#define X86_CR4_PCIDE 0x00020000 /* enable PCID support */
64#define X86_CR4_OSXSAVE 0x00040000 /* enable xsave and xrestore */ 66#define X86_CR4_OSXSAVE 0x00040000 /* enable xsave and xrestore */
65#define X86_CR4_SMEP 0x00100000 /* enable SMEP support */ 67#define X86_CR4_SMEP 0x00100000 /* enable SMEP support */
66 68
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 39bc5777211..d048cad9bca 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -61,6 +61,19 @@ static inline void *current_text_addr(void)
61# define ARCH_MIN_MMSTRUCT_ALIGN 0 61# define ARCH_MIN_MMSTRUCT_ALIGN 0
62#endif 62#endif
63 63
64enum tlb_infos {
65 ENTRIES,
66 NR_INFO
67};
68
69extern u16 __read_mostly tlb_lli_4k[NR_INFO];
70extern u16 __read_mostly tlb_lli_2m[NR_INFO];
71extern u16 __read_mostly tlb_lli_4m[NR_INFO];
72extern u16 __read_mostly tlb_lld_4k[NR_INFO];
73extern u16 __read_mostly tlb_lld_2m[NR_INFO];
74extern u16 __read_mostly tlb_lld_4m[NR_INFO];
75extern s8 __read_mostly tlb_flushall_shift;
76
64/* 77/*
65 * CPU type and hardware bug flags. Kept separately for each CPU. 78 * CPU type and hardware bug flags. Kept separately for each CPU.
66 * Members of this structure are referenced in head.S, so think twice 79 * Members of this structure are referenced in head.S, so think twice
diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
index fce3f4ae5bd..fe1ec5bcd84 100644
--- a/arch/x86/include/asm/realmode.h
+++ b/arch/x86/include/asm/realmode.h
@@ -21,8 +21,9 @@ struct real_mode_header {
21 u32 wakeup_header; 21 u32 wakeup_header;
22#endif 22#endif
23 /* APM/BIOS reboot */ 23 /* APM/BIOS reboot */
24#ifdef CONFIG_X86_32
25 u32 machine_real_restart_asm; 24 u32 machine_real_restart_asm;
25#ifdef CONFIG_X86_64
26 u32 machine_real_restart_seg;
26#endif 27#endif
27}; 28};
28 29
diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
index 92f297069e8..a82c4f1b4d8 100644
--- a/arch/x86/include/asm/reboot.h
+++ b/arch/x86/include/asm/reboot.h
@@ -18,8 +18,8 @@ extern struct machine_ops machine_ops;
18 18
19void native_machine_crash_shutdown(struct pt_regs *regs); 19void native_machine_crash_shutdown(struct pt_regs *regs);
20void native_machine_shutdown(void); 20void native_machine_shutdown(void);
21void machine_real_restart(unsigned int type); 21void __noreturn machine_real_restart(unsigned int type);
22/* These must match dispatch_table in reboot_32.S */ 22/* These must match dispatch in arch/x86/realmore/rm/reboot.S */
23#define MRR_BIOS 0 23#define MRR_BIOS 0
24#define MRR_APM 1 24#define MRR_APM 1
25 25
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index f48394513c3..4f19a152603 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -31,12 +31,12 @@ static inline bool cpu_has_ht_siblings(void)
31 return has_siblings; 31 return has_siblings;
32} 32}
33 33
34DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_map); 34DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_map);
35DECLARE_PER_CPU(cpumask_var_t, cpu_core_map); 35DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
36/* cpus sharing the last level cache: */ 36/* cpus sharing the last level cache: */
37DECLARE_PER_CPU(cpumask_var_t, cpu_llc_shared_map); 37DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
38DECLARE_PER_CPU(u16, cpu_llc_id); 38DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
39DECLARE_PER_CPU(int, cpu_number); 39DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
40 40
41static inline struct cpumask *cpu_sibling_mask(int cpu) 41static inline struct cpumask *cpu_sibling_mask(int cpu)
42{ 42{
@@ -53,10 +53,10 @@ static inline struct cpumask *cpu_llc_shared_mask(int cpu)
53 return per_cpu(cpu_llc_shared_map, cpu); 53 return per_cpu(cpu_llc_shared_map, cpu);
54} 54}
55 55
56DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid); 56DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_cpu_to_apicid);
57DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid); 57DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_bios_cpu_apicid);
58#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32) 58#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32)
59DECLARE_EARLY_PER_CPU(int, x86_cpu_to_logical_apicid); 59DECLARE_EARLY_PER_CPU_READ_MOSTLY(int, x86_cpu_to_logical_apicid);
60#endif 60#endif
61 61
62/* Static state in head.S used to set up a CPU */ 62/* Static state in head.S used to set up a CPU */
@@ -169,11 +169,6 @@ void x86_idle_thread_init(unsigned int cpu, struct task_struct *idle);
169void smp_store_cpu_info(int id); 169void smp_store_cpu_info(int id);
170#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu) 170#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
171 171
172/* We don't mark CPUs online until __cpu_up(), so we need another measure */
173static inline int num_booting_cpus(void)
174{
175 return cpumask_weight(cpu_callout_mask);
176}
177#else /* !CONFIG_SMP */ 172#else /* !CONFIG_SMP */
178#define wbinvd_on_cpu(cpu) wbinvd() 173#define wbinvd_on_cpu(cpu) wbinvd()
179static inline int wbinvd_on_all_cpus(void) 174static inline int wbinvd_on_all_cpus(void)
diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
index b315a33867f..33692eaabab 100644
--- a/arch/x86/include/asm/spinlock.h
+++ b/arch/x86/include/asm/spinlock.h
@@ -12,8 +12,7 @@
12 * Simple spin lock operations. There are two variants, one clears IRQ's 12 * Simple spin lock operations. There are two variants, one clears IRQ's
13 * on the local processor, one does not. 13 * on the local processor, one does not.
14 * 14 *
15 * These are fair FIFO ticket locks, which are currently limited to 256 15 * These are fair FIFO ticket locks, which support up to 2^16 CPUs.
16 * CPUs.
17 * 16 *
18 * (the type definitions are in asm/spinlock_types.h) 17 * (the type definitions are in asm/spinlock_types.h)
19 */ 18 */
diff --git a/arch/x86/include/asm/tlb.h b/arch/x86/include/asm/tlb.h
index 829215fef9e..4fef20773b8 100644
--- a/arch/x86/include/asm/tlb.h
+++ b/arch/x86/include/asm/tlb.h
@@ -4,7 +4,14 @@
4#define tlb_start_vma(tlb, vma) do { } while (0) 4#define tlb_start_vma(tlb, vma) do { } while (0)
5#define tlb_end_vma(tlb, vma) do { } while (0) 5#define tlb_end_vma(tlb, vma) do { } while (0)
6#define __tlb_remove_tlb_entry(tlb, ptep, address) do { } while (0) 6#define __tlb_remove_tlb_entry(tlb, ptep, address) do { } while (0)
7#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm) 7
8#define tlb_flush(tlb) \
9{ \
10 if (tlb->fullmm == 0) \
11 flush_tlb_mm_range(tlb->mm, tlb->start, tlb->end, 0UL); \
12 else \
13 flush_tlb_mm_range(tlb->mm, 0UL, TLB_FLUSH_ALL, 0UL); \
14}
8 15
9#include <asm-generic/tlb.h> 16#include <asm-generic/tlb.h>
10 17
diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
index 36a1a2ab87d..74a44333545 100644
--- a/arch/x86/include/asm/tlbflush.h
+++ b/arch/x86/include/asm/tlbflush.h
@@ -73,14 +73,10 @@ static inline void __flush_tlb_one(unsigned long addr)
73 * - flush_tlb_page(vma, vmaddr) flushes one page 73 * - flush_tlb_page(vma, vmaddr) flushes one page
74 * - flush_tlb_range(vma, start, end) flushes a range of pages 74 * - flush_tlb_range(vma, start, end) flushes a range of pages
75 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages 75 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
76 * - flush_tlb_others(cpumask, mm, va) flushes TLBs on other cpus 76 * - flush_tlb_others(cpumask, mm, start, end) flushes TLBs on other cpus
77 * 77 *
78 * ..but the i386 has somewhat limited tlb flushing capabilities, 78 * ..but the i386 has somewhat limited tlb flushing capabilities,
79 * and page-granular flushes are available only on i486 and up. 79 * and page-granular flushes are available only on i486 and up.
80 *
81 * x86-64 can only flush individual pages or full VMs. For a range flush
82 * we always do the full VM. Might be worth trying if for a small
83 * range a few INVLPGs in a row are a win.
84 */ 80 */
85 81
86#ifndef CONFIG_SMP 82#ifndef CONFIG_SMP
@@ -109,9 +105,17 @@ static inline void flush_tlb_range(struct vm_area_struct *vma,
109 __flush_tlb(); 105 __flush_tlb();
110} 106}
111 107
108static inline void flush_tlb_mm_range(struct mm_struct *mm,
109 unsigned long start, unsigned long end, unsigned long vmflag)
110{
111 if (mm == current->active_mm)
112 __flush_tlb();
113}
114
112static inline void native_flush_tlb_others(const struct cpumask *cpumask, 115static inline void native_flush_tlb_others(const struct cpumask *cpumask,
113 struct mm_struct *mm, 116 struct mm_struct *mm,
114 unsigned long va) 117 unsigned long start,
118 unsigned long end)
115{ 119{
116} 120}
117 121
@@ -119,27 +123,35 @@ static inline void reset_lazy_tlbstate(void)
119{ 123{
120} 124}
121 125
126static inline void flush_tlb_kernel_range(unsigned long start,
127 unsigned long end)
128{
129 flush_tlb_all();
130}
131
122#else /* SMP */ 132#else /* SMP */
123 133
124#include <asm/smp.h> 134#include <asm/smp.h>
125 135
126#define local_flush_tlb() __flush_tlb() 136#define local_flush_tlb() __flush_tlb()
127 137
138#define flush_tlb_mm(mm) flush_tlb_mm_range(mm, 0UL, TLB_FLUSH_ALL, 0UL)
139
140#define flush_tlb_range(vma, start, end) \
141 flush_tlb_mm_range(vma->vm_mm, start, end, vma->vm_flags)
142
128extern void flush_tlb_all(void); 143extern void flush_tlb_all(void);
129extern void flush_tlb_current_task(void); 144extern void flush_tlb_current_task(void);
130extern void flush_tlb_mm(struct mm_struct *);
131extern void flush_tlb_page(struct vm_area_struct *, unsigned long); 145extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
146extern void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,
147 unsigned long end, unsigned long vmflag);
148extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
132 149
133#define flush_tlb() flush_tlb_current_task() 150#define flush_tlb() flush_tlb_current_task()
134 151
135static inline void flush_tlb_range(struct vm_area_struct *vma,
136 unsigned long start, unsigned long end)
137{
138 flush_tlb_mm(vma->vm_mm);
139}
140
141void native_flush_tlb_others(const struct cpumask *cpumask, 152void native_flush_tlb_others(const struct cpumask *cpumask,
142 struct mm_struct *mm, unsigned long va); 153 struct mm_struct *mm,
154 unsigned long start, unsigned long end);
143 155
144#define TLBSTATE_OK 1 156#define TLBSTATE_OK 1
145#define TLBSTATE_LAZY 2 157#define TLBSTATE_LAZY 2
@@ -159,13 +171,8 @@ static inline void reset_lazy_tlbstate(void)
159#endif /* SMP */ 171#endif /* SMP */
160 172
161#ifndef CONFIG_PARAVIRT 173#ifndef CONFIG_PARAVIRT
162#define flush_tlb_others(mask, mm, va) native_flush_tlb_others(mask, mm, va) 174#define flush_tlb_others(mask, mm, start, end) \
175 native_flush_tlb_others(mask, mm, start, end)
163#endif 176#endif
164 177
165static inline void flush_tlb_kernel_range(unsigned long start,
166 unsigned long end)
167{
168 flush_tlb_all();
169}
170
171#endif /* _ASM_X86_TLBFLUSH_H */ 178#endif /* _ASM_X86_TLBFLUSH_H */
diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
index 8e796fbbf9c..d8def8b3dba 100644
--- a/arch/x86/include/asm/uaccess_64.h
+++ b/arch/x86/include/asm/uaccess_64.h
@@ -17,6 +17,8 @@
17 17
18/* Handles exceptions in both to and from, but doesn't do access_ok */ 18/* Handles exceptions in both to and from, but doesn't do access_ok */
19__must_check unsigned long 19__must_check unsigned long
20copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
21__must_check unsigned long
20copy_user_generic_string(void *to, const void *from, unsigned len); 22copy_user_generic_string(void *to, const void *from, unsigned len);
21__must_check unsigned long 23__must_check unsigned long
22copy_user_generic_unrolled(void *to, const void *from, unsigned len); 24copy_user_generic_unrolled(void *to, const void *from, unsigned len);
@@ -26,9 +28,16 @@ copy_user_generic(void *to, const void *from, unsigned len)
26{ 28{
27 unsigned ret; 29 unsigned ret;
28 30
29 alternative_call(copy_user_generic_unrolled, 31 /*
32 * If CPU has ERMS feature, use copy_user_enhanced_fast_string.
33 * Otherwise, if CPU has rep_good feature, use copy_user_generic_string.
34 * Otherwise, use copy_user_generic_unrolled.
35 */
36 alternative_call_2(copy_user_generic_unrolled,
30 copy_user_generic_string, 37 copy_user_generic_string,
31 X86_FEATURE_REP_GOOD, 38 X86_FEATURE_REP_GOOD,
39 copy_user_enhanced_fast_string,
40 X86_FEATURE_ERMS,
32 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from), 41 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
33 "=d" (len)), 42 "=d" (len)),
34 "1" (to), "2" (from), "3" (len) 43 "1" (to), "2" (from), "3" (len)
diff --git a/arch/x86/include/asm/unistd.h b/arch/x86/include/asm/unistd.h
index 4437001d8e3..0d9776e9e2d 100644
--- a/arch/x86/include/asm/unistd.h
+++ b/arch/x86/include/asm/unistd.h
@@ -15,7 +15,6 @@
15# ifdef CONFIG_X86_32 15# ifdef CONFIG_X86_32
16 16
17# include <asm/unistd_32.h> 17# include <asm/unistd_32.h>
18# define __ARCH_WANT_IPC_PARSE_VERSION
19# define __ARCH_WANT_STAT64 18# define __ARCH_WANT_STAT64
20# define __ARCH_WANT_SYS_IPC 19# define __ARCH_WANT_SYS_IPC
21# define __ARCH_WANT_SYS_OLD_MMAP 20# define __ARCH_WANT_SYS_OLD_MMAP
diff --git a/arch/x86/include/asm/uprobes.h b/arch/x86/include/asm/uprobes.h
index 1e9bed14f7a..f3971bbcd1d 100644
--- a/arch/x86/include/asm/uprobes.h
+++ b/arch/x86/include/asm/uprobes.h
@@ -48,7 +48,7 @@ struct arch_uprobe_task {
48#endif 48#endif
49}; 49};
50 50
51extern int arch_uprobe_analyze_insn(struct arch_uprobe *aup, struct mm_struct *mm); 51extern int arch_uprobe_analyze_insn(struct arch_uprobe *aup, struct mm_struct *mm, unsigned long addr);
52extern int arch_uprobe_pre_xol(struct arch_uprobe *aup, struct pt_regs *regs); 52extern int arch_uprobe_pre_xol(struct arch_uprobe *aup, struct pt_regs *regs);
53extern int arch_uprobe_post_xol(struct arch_uprobe *aup, struct pt_regs *regs); 53extern int arch_uprobe_post_xol(struct arch_uprobe *aup, struct pt_regs *regs);
54extern bool arch_uprobe_xol_was_trapped(struct task_struct *tsk); 54extern bool arch_uprobe_xol_was_trapped(struct task_struct *tsk);
diff --git a/arch/x86/include/asm/uv/uv.h b/arch/x86/include/asm/uv/uv.h
index 3bb9491b765..b47c2a82ff1 100644
--- a/arch/x86/include/asm/uv/uv.h
+++ b/arch/x86/include/asm/uv/uv.h
@@ -15,7 +15,8 @@ extern void uv_nmi_init(void);
15extern void uv_system_init(void); 15extern void uv_system_init(void);
16extern const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask, 16extern const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask,
17 struct mm_struct *mm, 17 struct mm_struct *mm,
18 unsigned long va, 18 unsigned long start,
19 unsigned end,
19 unsigned int cpu); 20 unsigned int cpu);
20 21
21#else /* X86_UV */ 22#else /* X86_UV */
@@ -26,7 +27,7 @@ static inline void uv_cpu_init(void) { }
26static inline void uv_system_init(void) { } 27static inline void uv_system_init(void) { }
27static inline const struct cpumask * 28static inline const struct cpumask *
28uv_flush_tlb_others(const struct cpumask *cpumask, struct mm_struct *mm, 29uv_flush_tlb_others(const struct cpumask *cpumask, struct mm_struct *mm,
29 unsigned long va, unsigned int cpu) 30 unsigned long start, unsigned long end, unsigned int cpu)
30{ return cpumask; } 31{ return cpumask; }
31 32
32#endif /* X86_UV */ 33#endif /* X86_UV */
diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
index 6149b476d9d..a06983cdc12 100644
--- a/arch/x86/include/asm/uv/uv_bau.h
+++ b/arch/x86/include/asm/uv/uv_bau.h
@@ -140,6 +140,9 @@
140#define IPI_RESET_LIMIT 1 140#define IPI_RESET_LIMIT 1
141/* after this # consecutive successes, bump up the throttle if it was lowered */ 141/* after this # consecutive successes, bump up the throttle if it was lowered */
142#define COMPLETE_THRESHOLD 5 142#define COMPLETE_THRESHOLD 5
143/* after this # of giveups (fall back to kernel IPI's) disable the use of
144 the BAU for a period of time */
145#define GIVEUP_LIMIT 100
143 146
144#define UV_LB_SUBNODEID 0x10 147#define UV_LB_SUBNODEID 0x10
145 148
@@ -166,7 +169,6 @@
166#define FLUSH_RETRY_TIMEOUT 2 169#define FLUSH_RETRY_TIMEOUT 2
167#define FLUSH_GIVEUP 3 170#define FLUSH_GIVEUP 3
168#define FLUSH_COMPLETE 4 171#define FLUSH_COMPLETE 4
169#define FLUSH_RETRY_BUSYBUG 5
170 172
171/* 173/*
172 * tuning the action when the numalink network is extremely delayed 174 * tuning the action when the numalink network is extremely delayed
@@ -175,7 +177,7 @@
175 microseconds */ 177 microseconds */
176#define CONGESTED_REPS 10 /* long delays averaged over 178#define CONGESTED_REPS 10 /* long delays averaged over
177 this many broadcasts */ 179 this many broadcasts */
178#define CONGESTED_PERIOD 30 /* time for the bau to be 180#define DISABLED_PERIOD 10 /* time for the bau to be
179 disabled, in seconds */ 181 disabled, in seconds */
180/* see msg_type: */ 182/* see msg_type: */
181#define MSG_NOOP 0 183#define MSG_NOOP 0
@@ -520,6 +522,12 @@ struct ptc_stats {
520 unsigned long s_uv2_wars; /* uv2 workaround, perm. busy */ 522 unsigned long s_uv2_wars; /* uv2 workaround, perm. busy */
521 unsigned long s_uv2_wars_hw; /* uv2 workaround, hiwater */ 523 unsigned long s_uv2_wars_hw; /* uv2 workaround, hiwater */
522 unsigned long s_uv2_war_waits; /* uv2 workaround, long waits */ 524 unsigned long s_uv2_war_waits; /* uv2 workaround, long waits */
525 unsigned long s_overipilimit; /* over the ipi reset limit */
526 unsigned long s_giveuplimit; /* disables, over giveup limit*/
527 unsigned long s_enters; /* entries to the driver */
528 unsigned long s_ipifordisabled; /* fall back to IPI; disabled */
529 unsigned long s_plugged; /* plugged by h/w bug*/
530 unsigned long s_congested; /* giveup on long wait */
523 /* destination statistics */ 531 /* destination statistics */
524 unsigned long d_alltlb; /* times all tlb's on this 532 unsigned long d_alltlb; /* times all tlb's on this
525 cpu were flushed */ 533 cpu were flushed */
@@ -586,8 +594,8 @@ struct bau_control {
586 int timeout_tries; 594 int timeout_tries;
587 int ipi_attempts; 595 int ipi_attempts;
588 int conseccompletes; 596 int conseccompletes;
589 int baudisabled; 597 short nobau;
590 int set_bau_off; 598 short baudisabled;
591 short cpu; 599 short cpu;
592 short osnode; 600 short osnode;
593 short uvhub_cpu; 601 short uvhub_cpu;
@@ -596,14 +604,16 @@ struct bau_control {
596 short cpus_in_socket; 604 short cpus_in_socket;
597 short cpus_in_uvhub; 605 short cpus_in_uvhub;
598 short partition_base_pnode; 606 short partition_base_pnode;
599 short using_desc; /* an index, like uvhub_cpu */ 607 short busy; /* all were busy (war) */
600 unsigned int inuse_map;
601 unsigned short message_number; 608 unsigned short message_number;
602 unsigned short uvhub_quiesce; 609 unsigned short uvhub_quiesce;
603 short socket_acknowledge_count[DEST_Q_SIZE]; 610 short socket_acknowledge_count[DEST_Q_SIZE];
604 cycles_t send_message; 611 cycles_t send_message;
612 cycles_t period_end;
613 cycles_t period_time;
605 spinlock_t uvhub_lock; 614 spinlock_t uvhub_lock;
606 spinlock_t queue_lock; 615 spinlock_t queue_lock;
616 spinlock_t disable_lock;
607 /* tunables */ 617 /* tunables */
608 int max_concurr; 618 int max_concurr;
609 int max_concurr_const; 619 int max_concurr_const;
@@ -614,9 +624,9 @@ struct bau_control {
614 int complete_threshold; 624 int complete_threshold;
615 int cong_response_us; 625 int cong_response_us;
616 int cong_reps; 626 int cong_reps;
617 int cong_period; 627 cycles_t disabled_period;
618 unsigned long clocks_per_100_usec; 628 int period_giveups;
619 cycles_t period_time; 629 int giveup_limit;
620 long period_requests; 630 long period_requests;
621 struct hub_and_pnode *thp; 631 struct hub_and_pnode *thp;
622}; 632};
diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
index 31f180c21ce..74fcb963595 100644
--- a/arch/x86/include/asm/vmx.h
+++ b/arch/x86/include/asm/vmx.h
@@ -60,6 +60,7 @@
60#define SECONDARY_EXEC_WBINVD_EXITING 0x00000040 60#define SECONDARY_EXEC_WBINVD_EXITING 0x00000040
61#define SECONDARY_EXEC_UNRESTRICTED_GUEST 0x00000080 61#define SECONDARY_EXEC_UNRESTRICTED_GUEST 0x00000080
62#define SECONDARY_EXEC_PAUSE_LOOP_EXITING 0x00000400 62#define SECONDARY_EXEC_PAUSE_LOOP_EXITING 0x00000400
63#define SECONDARY_EXEC_ENABLE_INVPCID 0x00001000
63 64
64 65
65#define PIN_BASED_EXT_INTR_MASK 0x00000001 66#define PIN_BASED_EXT_INTR_MASK 0x00000001
@@ -281,6 +282,7 @@ enum vmcs_field {
281#define EXIT_REASON_EPT_MISCONFIG 49 282#define EXIT_REASON_EPT_MISCONFIG 49
282#define EXIT_REASON_WBINVD 54 283#define EXIT_REASON_WBINVD 54
283#define EXIT_REASON_XSETBV 55 284#define EXIT_REASON_XSETBV 55
285#define EXIT_REASON_INVPCID 58
284 286
285/* 287/*
286 * Interruption-information format 288 * Interruption-information format
@@ -404,6 +406,7 @@ enum vmcs_field {
404#define VMX_EPTP_WB_BIT (1ull << 14) 406#define VMX_EPTP_WB_BIT (1ull << 14)
405#define VMX_EPT_2MB_PAGE_BIT (1ull << 16) 407#define VMX_EPT_2MB_PAGE_BIT (1ull << 16)
406#define VMX_EPT_1GB_PAGE_BIT (1ull << 17) 408#define VMX_EPT_1GB_PAGE_BIT (1ull << 17)
409#define VMX_EPT_AD_BIT (1ull << 21)
407#define VMX_EPT_EXTENT_INDIVIDUAL_BIT (1ull << 24) 410#define VMX_EPT_EXTENT_INDIVIDUAL_BIT (1ull << 24)
408#define VMX_EPT_EXTENT_CONTEXT_BIT (1ull << 25) 411#define VMX_EPT_EXTENT_CONTEXT_BIT (1ull << 25)
409#define VMX_EPT_EXTENT_GLOBAL_BIT (1ull << 26) 412#define VMX_EPT_EXTENT_GLOBAL_BIT (1ull << 26)
@@ -415,11 +418,14 @@ enum vmcs_field {
415#define VMX_EPT_MAX_GAW 0x4 418#define VMX_EPT_MAX_GAW 0x4
416#define VMX_EPT_MT_EPTE_SHIFT 3 419#define VMX_EPT_MT_EPTE_SHIFT 3
417#define VMX_EPT_GAW_EPTP_SHIFT 3 420#define VMX_EPT_GAW_EPTP_SHIFT 3
421#define VMX_EPT_AD_ENABLE_BIT (1ull << 6)
418#define VMX_EPT_DEFAULT_MT 0x6ull 422#define VMX_EPT_DEFAULT_MT 0x6ull
419#define VMX_EPT_READABLE_MASK 0x1ull 423#define VMX_EPT_READABLE_MASK 0x1ull
420#define VMX_EPT_WRITABLE_MASK 0x2ull 424#define VMX_EPT_WRITABLE_MASK 0x2ull
421#define VMX_EPT_EXECUTABLE_MASK 0x4ull 425#define VMX_EPT_EXECUTABLE_MASK 0x4ull
422#define VMX_EPT_IPAT_BIT (1ull << 6) 426#define VMX_EPT_IPAT_BIT (1ull << 6)
427#define VMX_EPT_ACCESS_BIT (1ull << 8)
428#define VMX_EPT_DIRTY_BIT (1ull << 9)
423 429
424#define VMX_EPT_IDENTITY_PAGETABLE_ADDR 0xfffbc000ul 430#define VMX_EPT_IDENTITY_PAGETABLE_ADDR 0xfffbc000ul
425 431
diff --git a/arch/x86/include/asm/x2apic.h b/arch/x86/include/asm/x2apic.h
index 92e54abf89e..f90f0a587c6 100644
--- a/arch/x86/include/asm/x2apic.h
+++ b/arch/x86/include/asm/x2apic.h
@@ -9,15 +9,6 @@
9#include <asm/ipi.h> 9#include <asm/ipi.h>
10#include <linux/cpumask.h> 10#include <linux/cpumask.h>
11 11
12/*
13 * Need to use more than cpu 0, because we need more vectors
14 * when MSI-X are used.
15 */
16static const struct cpumask *x2apic_target_cpus(void)
17{
18 return cpu_online_mask;
19}
20
21static int x2apic_apic_id_valid(int apicid) 12static int x2apic_apic_id_valid(int apicid)
22{ 13{
23 return 1; 14 return 1;
@@ -28,15 +19,6 @@ static int x2apic_apic_id_registered(void)
28 return 1; 19 return 1;
29} 20}
30 21
31/*
32 * For now each logical cpu is in its own vector allocation domain.
33 */
34static void x2apic_vector_allocation_domain(int cpu, struct cpumask *retmask)
35{
36 cpumask_clear(retmask);
37 cpumask_set_cpu(cpu, retmask);
38}
39
40static void 22static void
41__x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest) 23__x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest)
42{ 24{
diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
index c090af10ac7..57693498519 100644
--- a/arch/x86/include/asm/x86_init.h
+++ b/arch/x86/include/asm/x86_init.h
@@ -81,12 +81,13 @@ struct x86_init_mapping {
81 81
82/** 82/**
83 * struct x86_init_paging - platform specific paging functions 83 * struct x86_init_paging - platform specific paging functions
84 * @pagetable_setup_start: platform specific pre paging_init() call 84 * @pagetable_init: platform specific paging initialization call to setup
85 * @pagetable_setup_done: platform specific post paging_init() call 85 * the kernel pagetables and prepare accessors functions.
86 * Callback must call paging_init(). Called once after the
87 * direct mapping for phys memory is available.
86 */ 88 */
87struct x86_init_paging { 89struct x86_init_paging {
88 void (*pagetable_setup_start)(pgd_t *base); 90 void (*pagetable_init)(void);
89 void (*pagetable_setup_done)(pgd_t *base);
90}; 91};
91 92
92/** 93/**
@@ -156,7 +157,6 @@ struct x86_cpuinit_ops {
156/** 157/**
157 * struct x86_platform_ops - platform specific runtime functions 158 * struct x86_platform_ops - platform specific runtime functions
158 * @calibrate_tsc: calibrate TSC 159 * @calibrate_tsc: calibrate TSC
159 * @wallclock_init: init the wallclock device
160 * @get_wallclock: get time from HW clock like RTC etc. 160 * @get_wallclock: get time from HW clock like RTC etc.
161 * @set_wallclock: set time back to HW clock 161 * @set_wallclock: set time back to HW clock
162 * @is_untracked_pat_range exclude from PAT logic 162 * @is_untracked_pat_range exclude from PAT logic
@@ -164,10 +164,10 @@ struct x86_cpuinit_ops {
164 * @i8042_detect pre-detect if i8042 controller exists 164 * @i8042_detect pre-detect if i8042 controller exists
165 * @save_sched_clock_state: save state for sched_clock() on suspend 165 * @save_sched_clock_state: save state for sched_clock() on suspend
166 * @restore_sched_clock_state: restore state for sched_clock() on resume 166 * @restore_sched_clock_state: restore state for sched_clock() on resume
167 * @apic_post_init: adjust apic if neeeded
167 */ 168 */
168struct x86_platform_ops { 169struct x86_platform_ops {
169 unsigned long (*calibrate_tsc)(void); 170 unsigned long (*calibrate_tsc)(void);
170 void (*wallclock_init)(void);
171 unsigned long (*get_wallclock)(void); 171 unsigned long (*get_wallclock)(void);
172 int (*set_wallclock)(unsigned long nowtime); 172 int (*set_wallclock)(unsigned long nowtime);
173 void (*iommu_shutdown)(void); 173 void (*iommu_shutdown)(void);
@@ -177,6 +177,7 @@ struct x86_platform_ops {
177 int (*i8042_detect)(void); 177 int (*i8042_detect)(void);
178 void (*save_sched_clock_state)(void); 178 void (*save_sched_clock_state)(void);
179 void (*restore_sched_clock_state)(void); 179 void (*restore_sched_clock_state)(void);
180 void (*apic_post_init)(void);
180}; 181};
181 182
182struct pci_dev; 183struct pci_dev;
diff --git a/arch/x86/include/asm/xen/hypercall.h b/arch/x86/include/asm/xen/hypercall.h
index 5728852fb90..59c226d120c 100644
--- a/arch/x86/include/asm/xen/hypercall.h
+++ b/arch/x86/include/asm/xen/hypercall.h
@@ -48,6 +48,7 @@
48#include <xen/interface/sched.h> 48#include <xen/interface/sched.h>
49#include <xen/interface/physdev.h> 49#include <xen/interface/physdev.h>
50#include <xen/interface/platform.h> 50#include <xen/interface/platform.h>
51#include <xen/interface/xen-mca.h>
51 52
52/* 53/*
53 * The hypercall asms have to meet several constraints: 54 * The hypercall asms have to meet several constraints:
@@ -302,6 +303,13 @@ HYPERVISOR_set_timer_op(u64 timeout)
302} 303}
303 304
304static inline int 305static inline int
306HYPERVISOR_mca(struct xen_mc *mc_op)
307{
308 mc_op->interface_version = XEN_MCA_INTERFACE_VERSION;
309 return _hypercall1(int, mca, mc_op);
310}
311
312static inline int
305HYPERVISOR_dom0_op(struct xen_platform_op *platform_op) 313HYPERVISOR_dom0_op(struct xen_platform_op *platform_op)
306{ 314{
307 platform_op->interface_version = XENPF_INTERFACE_VERSION; 315 platform_op->interface_version = XENPF_INTERFACE_VERSION;
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
index 95bf99de905..1b8e5a03d94 100644
--- a/arch/x86/kernel/acpi/sleep.c
+++ b/arch/x86/kernel/acpi/sleep.c
@@ -25,10 +25,6 @@ unsigned long acpi_realmode_flags;
25static char temp_stack[4096]; 25static char temp_stack[4096];
26#endif 26#endif
27 27
28asmlinkage void acpi_enter_s3(void)
29{
30 acpi_enter_sleep_state(3, wake_sleep_flags);
31}
32/** 28/**
33 * acpi_suspend_lowlevel - save kernel state 29 * acpi_suspend_lowlevel - save kernel state
34 * 30 *
diff --git a/arch/x86/kernel/acpi/sleep.h b/arch/x86/kernel/acpi/sleep.h
index 5653a5791ec..67f59f8c695 100644
--- a/arch/x86/kernel/acpi/sleep.h
+++ b/arch/x86/kernel/acpi/sleep.h
@@ -2,7 +2,6 @@
2 * Variables and functions used by the code in sleep.c 2 * Variables and functions used by the code in sleep.c
3 */ 3 */
4 4
5#include <linux/linkage.h>
6#include <asm/realmode.h> 5#include <asm/realmode.h>
7 6
8extern unsigned long saved_video_mode; 7extern unsigned long saved_video_mode;
@@ -11,7 +10,6 @@ extern long saved_magic;
11extern int wakeup_pmode_return; 10extern int wakeup_pmode_return;
12 11
13extern u8 wake_sleep_flags; 12extern u8 wake_sleep_flags;
14extern asmlinkage void acpi_enter_s3(void);
15 13
16extern unsigned long acpi_copy_wakeup_routine(unsigned long); 14extern unsigned long acpi_copy_wakeup_routine(unsigned long);
17extern void wakeup_long64(void); 15extern void wakeup_long64(void);
diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
index 72610839f03..13ab720573e 100644
--- a/arch/x86/kernel/acpi/wakeup_32.S
+++ b/arch/x86/kernel/acpi/wakeup_32.S
@@ -74,7 +74,9 @@ restore_registers:
74ENTRY(do_suspend_lowlevel) 74ENTRY(do_suspend_lowlevel)
75 call save_processor_state 75 call save_processor_state
76 call save_registers 76 call save_registers
77 call acpi_enter_s3 77 pushl $3
78 call acpi_enter_sleep_state
79 addl $4, %esp
78 80
79# In case of S3 failure, we'll emerge here. Jump 81# In case of S3 failure, we'll emerge here. Jump
80# to ret_point to recover 82# to ret_point to recover
diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S
index 014d1d28c39..8ea5164cbd0 100644
--- a/arch/x86/kernel/acpi/wakeup_64.S
+++ b/arch/x86/kernel/acpi/wakeup_64.S
@@ -71,7 +71,9 @@ ENTRY(do_suspend_lowlevel)
71 movq %rsi, saved_rsi 71 movq %rsi, saved_rsi
72 72
73 addq $8, %rsp 73 addq $8, %rsp
74 call acpi_enter_s3 74 movl $3, %edi
75 xorl %eax, %eax
76 call acpi_enter_sleep_state
75 /* in case something went wrong, restore the machine status and go on */ 77 /* in case something went wrong, restore the machine status and go on */
76 jmp resume_point 78 jmp resume_point
77 79
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 1f84794f075..ced4534baed 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -1,3 +1,5 @@
1#define pr_fmt(fmt) "SMP alternatives: " fmt
2
1#include <linux/module.h> 3#include <linux/module.h>
2#include <linux/sched.h> 4#include <linux/sched.h>
3#include <linux/mutex.h> 5#include <linux/mutex.h>
@@ -63,8 +65,11 @@ static int __init setup_noreplace_paravirt(char *str)
63__setup("noreplace-paravirt", setup_noreplace_paravirt); 65__setup("noreplace-paravirt", setup_noreplace_paravirt);
64#endif 66#endif
65 67
66#define DPRINTK(fmt, args...) if (debug_alternative) \ 68#define DPRINTK(fmt, ...) \
67 printk(KERN_DEBUG fmt, args) 69do { \
70 if (debug_alternative) \
71 printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
72} while (0)
68 73
69/* 74/*
70 * Each GENERIC_NOPX is of X bytes, and defined as an array of bytes 75 * Each GENERIC_NOPX is of X bytes, and defined as an array of bytes
@@ -160,7 +165,7 @@ static const unsigned char * const k7_nops[ASM_NOP_MAX+2] =
160#endif 165#endif
161 166
162#ifdef P6_NOP1 167#ifdef P6_NOP1
163static const unsigned char __initconst_or_module p6nops[] = 168static const unsigned char p6nops[] =
164{ 169{
165 P6_NOP1, 170 P6_NOP1,
166 P6_NOP2, 171 P6_NOP2,
@@ -219,7 +224,7 @@ void __init arch_init_ideal_nops(void)
219 ideal_nops = intel_nops; 224 ideal_nops = intel_nops;
220#endif 225#endif
221 } 226 }
222 227 break;
223 default: 228 default:
224#ifdef CONFIG_X86_64 229#ifdef CONFIG_X86_64
225 ideal_nops = k8_nops; 230 ideal_nops = k8_nops;
@@ -428,7 +433,7 @@ void alternatives_smp_switch(int smp)
428 * If this still occurs then you should see a hang 433 * If this still occurs then you should see a hang
429 * or crash shortly after this line: 434 * or crash shortly after this line:
430 */ 435 */
431 printk("lockdep: fixing up alternatives.\n"); 436 pr_info("lockdep: fixing up alternatives\n");
432#endif 437#endif
433 438
434 if (noreplace_smp || smp_alt_once || skip_smp_alternatives) 439 if (noreplace_smp || smp_alt_once || skip_smp_alternatives)
@@ -444,14 +449,14 @@ void alternatives_smp_switch(int smp)
444 if (smp == smp_mode) { 449 if (smp == smp_mode) {
445 /* nothing */ 450 /* nothing */
446 } else if (smp) { 451 } else if (smp) {
447 printk(KERN_INFO "SMP alternatives: switching to SMP code\n"); 452 pr_info("switching to SMP code\n");
448 clear_cpu_cap(&boot_cpu_data, X86_FEATURE_UP); 453 clear_cpu_cap(&boot_cpu_data, X86_FEATURE_UP);
449 clear_cpu_cap(&cpu_data(0), X86_FEATURE_UP); 454 clear_cpu_cap(&cpu_data(0), X86_FEATURE_UP);
450 list_for_each_entry(mod, &smp_alt_modules, next) 455 list_for_each_entry(mod, &smp_alt_modules, next)
451 alternatives_smp_lock(mod->locks, mod->locks_end, 456 alternatives_smp_lock(mod->locks, mod->locks_end,
452 mod->text, mod->text_end); 457 mod->text, mod->text_end);
453 } else { 458 } else {
454 printk(KERN_INFO "SMP alternatives: switching to UP code\n"); 459 pr_info("switching to UP code\n");
455 set_cpu_cap(&boot_cpu_data, X86_FEATURE_UP); 460 set_cpu_cap(&boot_cpu_data, X86_FEATURE_UP);
456 set_cpu_cap(&cpu_data(0), X86_FEATURE_UP); 461 set_cpu_cap(&cpu_data(0), X86_FEATURE_UP);
457 list_for_each_entry(mod, &smp_alt_modules, next) 462 list_for_each_entry(mod, &smp_alt_modules, next)
@@ -546,7 +551,7 @@ void __init alternative_instructions(void)
546#ifdef CONFIG_SMP 551#ifdef CONFIG_SMP
547 if (smp_alt_once) { 552 if (smp_alt_once) {
548 if (1 == num_possible_cpus()) { 553 if (1 == num_possible_cpus()) {
549 printk(KERN_INFO "SMP alternatives: switching to UP code\n"); 554 pr_info("switching to UP code\n");
550 set_cpu_cap(&boot_cpu_data, X86_FEATURE_UP); 555 set_cpu_cap(&boot_cpu_data, X86_FEATURE_UP);
551 set_cpu_cap(&cpu_data(0), X86_FEATURE_UP); 556 set_cpu_cap(&cpu_data(0), X86_FEATURE_UP);
552 557
@@ -664,7 +669,7 @@ static int __kprobes stop_machine_text_poke(void *data)
664 struct text_poke_param *p; 669 struct text_poke_param *p;
665 int i; 670 int i;
666 671
667 if (atomic_dec_and_test(&stop_machine_first)) { 672 if (atomic_xchg(&stop_machine_first, 0)) {
668 for (i = 0; i < tpp->nparams; i++) { 673 for (i = 0; i < tpp->nparams; i++) {
669 p = &tpp->params[i]; 674 p = &tpp->params[i];
670 text_poke(p->addr, p->opcode, p->len); 675 text_poke(p->addr, p->opcode, p->len);
diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c
index be16854591c..aadf3359e2a 100644
--- a/arch/x86/kernel/amd_nb.c
+++ b/arch/x86/kernel/amd_nb.c
@@ -2,6 +2,9 @@
2 * Shared support code for AMD K8 northbridges and derivates. 2 * Shared support code for AMD K8 northbridges and derivates.
3 * Copyright 2006 Andi Kleen, SUSE Labs. Subject to GPLv2. 3 * Copyright 2006 Andi Kleen, SUSE Labs. Subject to GPLv2.
4 */ 4 */
5
6#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
7
5#include <linux/types.h> 8#include <linux/types.h>
6#include <linux/slab.h> 9#include <linux/slab.h>
7#include <linux/init.h> 10#include <linux/init.h>
@@ -16,6 +19,7 @@ const struct pci_device_id amd_nb_misc_ids[] = {
16 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) }, 19 { 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) }, 20 { 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_F3) }, 21 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F3) },
22 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_M10H_F3) },
19 {} 23 {}
20}; 24};
21EXPORT_SYMBOL(amd_nb_misc_ids); 25EXPORT_SYMBOL(amd_nb_misc_ids);
@@ -258,7 +262,7 @@ void amd_flush_garts(void)
258 } 262 }
259 spin_unlock_irqrestore(&gart_lock, flags); 263 spin_unlock_irqrestore(&gart_lock, flags);
260 if (!flushed) 264 if (!flushed)
261 printk("nothing to flush?\n"); 265 pr_notice("nothing to flush?\n");
262} 266}
263EXPORT_SYMBOL_GPL(amd_flush_garts); 267EXPORT_SYMBOL_GPL(amd_flush_garts);
264 268
@@ -269,11 +273,10 @@ static __init int init_amd_nbs(void)
269 err = amd_cache_northbridges(); 273 err = amd_cache_northbridges();
270 274
271 if (err < 0) 275 if (err < 0)
272 printk(KERN_NOTICE "AMD NB: Cannot enumerate AMD northbridges.\n"); 276 pr_notice("Cannot enumerate AMD northbridges\n");
273 277
274 if (amd_cache_gart() < 0) 278 if (amd_cache_gart() < 0)
275 printk(KERN_NOTICE "AMD NB: Cannot initialize GART flush words, " 279 pr_notice("Cannot initialize GART flush words, GART support disabled\n");
276 "GART support disabled.\n");
277 280
278 return err; 281 return err;
279} 282}
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 39a222e094a..24deb308232 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -75,8 +75,8 @@ physid_mask_t phys_cpu_present_map;
75/* 75/*
76 * Map cpu index to physical APIC ID 76 * Map cpu index to physical APIC ID
77 */ 77 */
78DEFINE_EARLY_PER_CPU(u16, x86_cpu_to_apicid, BAD_APICID); 78DEFINE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_cpu_to_apicid, BAD_APICID);
79DEFINE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid, BAD_APICID); 79DEFINE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_bios_cpu_apicid, BAD_APICID);
80EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_apicid); 80EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_apicid);
81EXPORT_EARLY_PER_CPU_SYMBOL(x86_bios_cpu_apicid); 81EXPORT_EARLY_PER_CPU_SYMBOL(x86_bios_cpu_apicid);
82 82
@@ -88,7 +88,7 @@ EXPORT_EARLY_PER_CPU_SYMBOL(x86_bios_cpu_apicid);
88 * used for the mapping. This is where the behaviors of x86_64 and 32 88 * used for the mapping. This is where the behaviors of x86_64 and 32
89 * actually diverge. Let's keep it ugly for now. 89 * actually diverge. Let's keep it ugly for now.
90 */ 90 */
91DEFINE_EARLY_PER_CPU(int, x86_cpu_to_logical_apicid, BAD_APICID); 91DEFINE_EARLY_PER_CPU_READ_MOSTLY(int, x86_cpu_to_logical_apicid, BAD_APICID);
92 92
93/* 93/*
94 * Knob to control our willingness to enable the local APIC. 94 * Knob to control our willingness to enable the local APIC.
@@ -2123,6 +2123,42 @@ void default_init_apic_ldr(void)
2123 apic_write(APIC_LDR, val); 2123 apic_write(APIC_LDR, val);
2124} 2124}
2125 2125
2126int default_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
2127 const struct cpumask *andmask,
2128 unsigned int *apicid)
2129{
2130 unsigned int cpu;
2131
2132 for_each_cpu_and(cpu, cpumask, andmask) {
2133 if (cpumask_test_cpu(cpu, cpu_online_mask))
2134 break;
2135 }
2136
2137 if (likely(cpu < nr_cpu_ids)) {
2138 *apicid = per_cpu(x86_cpu_to_apicid, cpu);
2139 return 0;
2140 }
2141
2142 return -EINVAL;
2143}
2144
2145/*
2146 * Override the generic EOI implementation with an optimized version.
2147 * Only called during early boot when only one CPU is active and with
2148 * interrupts disabled, so we know this does not race with actual APIC driver
2149 * use.
2150 */
2151void __init apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v))
2152{
2153 struct apic **drv;
2154
2155 for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) {
2156 /* Should happen once for each apic */
2157 WARN_ON((*drv)->eoi_write == eoi_write);
2158 (*drv)->eoi_write = eoi_write;
2159 }
2160}
2161
2126/* 2162/*
2127 * Power management 2163 * Power management
2128 */ 2164 */
diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
index 0e881c46e8c..00c77cf78e9 100644
--- a/arch/x86/kernel/apic/apic_flat_64.c
+++ b/arch/x86/kernel/apic/apic_flat_64.c
@@ -36,25 +36,6 @@ static int flat_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
36 return 1; 36 return 1;
37} 37}
38 38
39static const struct cpumask *flat_target_cpus(void)
40{
41 return cpu_online_mask;
42}
43
44static void flat_vector_allocation_domain(int cpu, struct cpumask *retmask)
45{
46 /* Careful. Some cpus do not strictly honor the set of cpus
47 * specified in the interrupt destination when using lowest
48 * priority interrupt delivery mode.
49 *
50 * In particular there was a hyperthreading cpu observed to
51 * deliver interrupts to the wrong hyperthread when only one
52 * hyperthread was specified in the interrupt desitination.
53 */
54 cpumask_clear(retmask);
55 cpumask_bits(retmask)[0] = APIC_ALL_CPUS;
56}
57
58/* 39/*
59 * Set up the logical destination ID. 40 * Set up the logical destination ID.
60 * 41 *
@@ -92,7 +73,7 @@ static void flat_send_IPI_mask(const struct cpumask *cpumask, int vector)
92} 73}
93 74
94static void 75static void
95 flat_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector) 76flat_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector)
96{ 77{
97 unsigned long mask = cpumask_bits(cpumask)[0]; 78 unsigned long mask = cpumask_bits(cpumask)[0];
98 int cpu = smp_processor_id(); 79 int cpu = smp_processor_id();
@@ -186,7 +167,7 @@ static struct apic apic_flat = {
186 .irq_delivery_mode = dest_LowestPrio, 167 .irq_delivery_mode = dest_LowestPrio,
187 .irq_dest_mode = 1, /* logical */ 168 .irq_dest_mode = 1, /* logical */
188 169
189 .target_cpus = flat_target_cpus, 170 .target_cpus = online_target_cpus,
190 .disable_esr = 0, 171 .disable_esr = 0,
191 .dest_logical = APIC_DEST_LOGICAL, 172 .dest_logical = APIC_DEST_LOGICAL,
192 .check_apicid_used = NULL, 173 .check_apicid_used = NULL,
@@ -210,8 +191,7 @@ static struct apic apic_flat = {
210 .set_apic_id = set_apic_id, 191 .set_apic_id = set_apic_id,
211 .apic_id_mask = 0xFFu << 24, 192 .apic_id_mask = 0xFFu << 24,
212 193
213 .cpu_mask_to_apicid = default_cpu_mask_to_apicid, 194 .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and,
214 .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
215 195
216 .send_IPI_mask = flat_send_IPI_mask, 196 .send_IPI_mask = flat_send_IPI_mask,
217 .send_IPI_mask_allbutself = flat_send_IPI_mask_allbutself, 197 .send_IPI_mask_allbutself = flat_send_IPI_mask_allbutself,
@@ -262,17 +242,6 @@ static int physflat_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
262 return 0; 242 return 0;
263} 243}
264 244
265static const struct cpumask *physflat_target_cpus(void)
266{
267 return cpu_online_mask;
268}
269
270static void physflat_vector_allocation_domain(int cpu, struct cpumask *retmask)
271{
272 cpumask_clear(retmask);
273 cpumask_set_cpu(cpu, retmask);
274}
275
276static void physflat_send_IPI_mask(const struct cpumask *cpumask, int vector) 245static void physflat_send_IPI_mask(const struct cpumask *cpumask, int vector)
277{ 246{
278 default_send_IPI_mask_sequence_phys(cpumask, vector); 247 default_send_IPI_mask_sequence_phys(cpumask, vector);
@@ -294,38 +263,6 @@ static void physflat_send_IPI_all(int vector)
294 physflat_send_IPI_mask(cpu_online_mask, vector); 263 physflat_send_IPI_mask(cpu_online_mask, vector);
295} 264}
296 265
297static unsigned int physflat_cpu_mask_to_apicid(const struct cpumask *cpumask)
298{
299 int cpu;
300
301 /*
302 * We're using fixed IRQ delivery, can only return one phys APIC ID.
303 * May as well be the first.
304 */
305 cpu = cpumask_first(cpumask);
306 if ((unsigned)cpu < nr_cpu_ids)
307 return per_cpu(x86_cpu_to_apicid, cpu);
308 else
309 return BAD_APICID;
310}
311
312static unsigned int
313physflat_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
314 const struct cpumask *andmask)
315{
316 int cpu;
317
318 /*
319 * We're using fixed IRQ delivery, can only return one phys APIC ID.
320 * May as well be the first.
321 */
322 for_each_cpu_and(cpu, cpumask, andmask) {
323 if (cpumask_test_cpu(cpu, cpu_online_mask))
324 break;
325 }
326 return per_cpu(x86_cpu_to_apicid, cpu);
327}
328
329static int physflat_probe(void) 266static int physflat_probe(void)
330{ 267{
331 if (apic == &apic_physflat || num_possible_cpus() > 8) 268 if (apic == &apic_physflat || num_possible_cpus() > 8)
@@ -345,13 +282,13 @@ static struct apic apic_physflat = {
345 .irq_delivery_mode = dest_Fixed, 282 .irq_delivery_mode = dest_Fixed,
346 .irq_dest_mode = 0, /* physical */ 283 .irq_dest_mode = 0, /* physical */
347 284
348 .target_cpus = physflat_target_cpus, 285 .target_cpus = online_target_cpus,
349 .disable_esr = 0, 286 .disable_esr = 0,
350 .dest_logical = 0, 287 .dest_logical = 0,
351 .check_apicid_used = NULL, 288 .check_apicid_used = NULL,
352 .check_apicid_present = NULL, 289 .check_apicid_present = NULL,
353 290
354 .vector_allocation_domain = physflat_vector_allocation_domain, 291 .vector_allocation_domain = default_vector_allocation_domain,
355 /* not needed, but shouldn't hurt: */ 292 /* not needed, but shouldn't hurt: */
356 .init_apic_ldr = flat_init_apic_ldr, 293 .init_apic_ldr = flat_init_apic_ldr,
357 294
@@ -370,8 +307,7 @@ static struct apic apic_physflat = {
370 .set_apic_id = set_apic_id, 307 .set_apic_id = set_apic_id,
371 .apic_id_mask = 0xFFu << 24, 308 .apic_id_mask = 0xFFu << 24,
372 309
373 .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid, 310 .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
374 .cpu_mask_to_apicid_and = physflat_cpu_mask_to_apicid_and,
375 311
376 .send_IPI_mask = physflat_send_IPI_mask, 312 .send_IPI_mask = physflat_send_IPI_mask,
377 .send_IPI_mask_allbutself = physflat_send_IPI_mask_allbutself, 313 .send_IPI_mask_allbutself = physflat_send_IPI_mask_allbutself,
diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
index a6e4c6e06c0..e145f28b409 100644
--- a/arch/x86/kernel/apic/apic_noop.c
+++ b/arch/x86/kernel/apic/apic_noop.c
@@ -100,12 +100,12 @@ static unsigned long noop_check_apicid_present(int bit)
100 return physid_isset(bit, phys_cpu_present_map); 100 return physid_isset(bit, phys_cpu_present_map);
101} 101}
102 102
103static void noop_vector_allocation_domain(int cpu, struct cpumask *retmask) 103static void noop_vector_allocation_domain(int cpu, struct cpumask *retmask,
104 const struct cpumask *mask)
104{ 105{
105 if (cpu != 0) 106 if (cpu != 0)
106 pr_warning("APIC: Vector allocated for non-BSP cpu\n"); 107 pr_warning("APIC: Vector allocated for non-BSP cpu\n");
107 cpumask_clear(retmask); 108 cpumask_copy(retmask, cpumask_of(cpu));
108 cpumask_set_cpu(cpu, retmask);
109} 109}
110 110
111static u32 noop_apic_read(u32 reg) 111static u32 noop_apic_read(u32 reg)
@@ -159,8 +159,7 @@ struct apic apic_noop = {
159 .set_apic_id = NULL, 159 .set_apic_id = NULL,
160 .apic_id_mask = 0x0F << 24, 160 .apic_id_mask = 0x0F << 24,
161 161
162 .cpu_mask_to_apicid = default_cpu_mask_to_apicid, 162 .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and,
163 .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
164 163
165 .send_IPI_mask = noop_send_IPI_mask, 164 .send_IPI_mask = noop_send_IPI_mask,
166 .send_IPI_mask_allbutself = noop_send_IPI_mask_allbutself, 165 .send_IPI_mask_allbutself = noop_send_IPI_mask_allbutself,
diff --git a/arch/x86/kernel/apic/apic_numachip.c b/arch/x86/kernel/apic/apic_numachip.c
index 6ec6d5d297c..bc552cff257 100644
--- a/arch/x86/kernel/apic/apic_numachip.c
+++ b/arch/x86/kernel/apic/apic_numachip.c
@@ -72,17 +72,6 @@ static int numachip_phys_pkg_id(int initial_apic_id, int index_msb)
72 return initial_apic_id >> index_msb; 72 return initial_apic_id >> index_msb;
73} 73}
74 74
75static const struct cpumask *numachip_target_cpus(void)
76{
77 return cpu_online_mask;
78}
79
80static void numachip_vector_allocation_domain(int cpu, struct cpumask *retmask)
81{
82 cpumask_clear(retmask);
83 cpumask_set_cpu(cpu, retmask);
84}
85
86static int __cpuinit numachip_wakeup_secondary(int phys_apicid, unsigned long start_rip) 75static int __cpuinit numachip_wakeup_secondary(int phys_apicid, unsigned long start_rip)
87{ 76{
88 union numachip_csr_g3_ext_irq_gen int_gen; 77 union numachip_csr_g3_ext_irq_gen int_gen;
@@ -157,38 +146,6 @@ static void numachip_send_IPI_self(int vector)
157 __default_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL); 146 __default_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
158} 147}
159 148
160static unsigned int numachip_cpu_mask_to_apicid(const struct cpumask *cpumask)
161{
162 int cpu;
163
164 /*
165 * We're using fixed IRQ delivery, can only return one phys APIC ID.
166 * May as well be the first.
167 */
168 cpu = cpumask_first(cpumask);
169 if (likely((unsigned)cpu < nr_cpu_ids))
170 return per_cpu(x86_cpu_to_apicid, cpu);
171
172 return BAD_APICID;
173}
174
175static unsigned int
176numachip_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
177 const struct cpumask *andmask)
178{
179 int cpu;
180
181 /*
182 * We're using fixed IRQ delivery, can only return one phys APIC ID.
183 * May as well be the first.
184 */
185 for_each_cpu_and(cpu, cpumask, andmask) {
186 if (cpumask_test_cpu(cpu, cpu_online_mask))
187 break;
188 }
189 return per_cpu(x86_cpu_to_apicid, cpu);
190}
191
192static int __init numachip_probe(void) 149static int __init numachip_probe(void)
193{ 150{
194 return apic == &apic_numachip; 151 return apic == &apic_numachip;
@@ -253,13 +210,13 @@ static struct apic apic_numachip __refconst = {
253 .irq_delivery_mode = dest_Fixed, 210 .irq_delivery_mode = dest_Fixed,
254 .irq_dest_mode = 0, /* physical */ 211 .irq_dest_mode = 0, /* physical */
255 212
256 .target_cpus = numachip_target_cpus, 213 .target_cpus = online_target_cpus,
257 .disable_esr = 0, 214 .disable_esr = 0,
258 .dest_logical = 0, 215 .dest_logical = 0,
259 .check_apicid_used = NULL, 216 .check_apicid_used = NULL,
260 .check_apicid_present = NULL, 217 .check_apicid_present = NULL,
261 218
262 .vector_allocation_domain = numachip_vector_allocation_domain, 219 .vector_allocation_domain = default_vector_allocation_domain,
263 .init_apic_ldr = flat_init_apic_ldr, 220 .init_apic_ldr = flat_init_apic_ldr,
264 221
265 .ioapic_phys_id_map = NULL, 222 .ioapic_phys_id_map = NULL,
@@ -277,8 +234,7 @@ static struct apic apic_numachip __refconst = {
277 .set_apic_id = set_apic_id, 234 .set_apic_id = set_apic_id,
278 .apic_id_mask = 0xffU << 24, 235 .apic_id_mask = 0xffU << 24,
279 236
280 .cpu_mask_to_apicid = numachip_cpu_mask_to_apicid, 237 .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
281 .cpu_mask_to_apicid_and = numachip_cpu_mask_to_apicid_and,
282 238
283 .send_IPI_mask = numachip_send_IPI_mask, 239 .send_IPI_mask = numachip_send_IPI_mask,
284 .send_IPI_mask_allbutself = numachip_send_IPI_mask_allbutself, 240 .send_IPI_mask_allbutself = numachip_send_IPI_mask_allbutself,
diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
index 31fbdbfbf96..d50e3640d5a 100644
--- a/arch/x86/kernel/apic/bigsmp_32.c
+++ b/arch/x86/kernel/apic/bigsmp_32.c
@@ -26,15 +26,6 @@ static int bigsmp_apic_id_registered(void)
26 return 1; 26 return 1;
27} 27}
28 28
29static const struct cpumask *bigsmp_target_cpus(void)
30{
31#ifdef CONFIG_SMP
32 return cpu_online_mask;
33#else
34 return cpumask_of(0);
35#endif
36}
37
38static unsigned long bigsmp_check_apicid_used(physid_mask_t *map, int apicid) 29static unsigned long bigsmp_check_apicid_used(physid_mask_t *map, int apicid)
39{ 30{
40 return 0; 31 return 0;
@@ -105,32 +96,6 @@ static int bigsmp_check_phys_apicid_present(int phys_apicid)
105 return 1; 96 return 1;
106} 97}
107 98
108/* As we are using single CPU as destination, pick only one CPU here */
109static unsigned int bigsmp_cpu_mask_to_apicid(const struct cpumask *cpumask)
110{
111 int cpu = cpumask_first(cpumask);
112
113 if (cpu < nr_cpu_ids)
114 return cpu_physical_id(cpu);
115 return BAD_APICID;
116}
117
118static unsigned int bigsmp_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
119 const struct cpumask *andmask)
120{
121 int cpu;
122
123 /*
124 * We're using fixed IRQ delivery, can only return one phys APIC ID.
125 * May as well be the first.
126 */
127 for_each_cpu_and(cpu, cpumask, andmask) {
128 if (cpumask_test_cpu(cpu, cpu_online_mask))
129 return cpu_physical_id(cpu);
130 }
131 return BAD_APICID;
132}
133
134static int bigsmp_phys_pkg_id(int cpuid_apic, int index_msb) 99static int bigsmp_phys_pkg_id(int cpuid_apic, int index_msb)
135{ 100{
136 return cpuid_apic >> index_msb; 101 return cpuid_apic >> index_msb;
@@ -177,12 +142,6 @@ static const struct dmi_system_id bigsmp_dmi_table[] = {
177 { } /* NULL entry stops DMI scanning */ 142 { } /* NULL entry stops DMI scanning */
178}; 143};
179 144
180static void bigsmp_vector_allocation_domain(int cpu, struct cpumask *retmask)
181{
182 cpumask_clear(retmask);
183 cpumask_set_cpu(cpu, retmask);
184}
185
186static int probe_bigsmp(void) 145static int probe_bigsmp(void)
187{ 146{
188 if (def_to_bigsmp) 147 if (def_to_bigsmp)
@@ -205,13 +164,13 @@ static struct apic apic_bigsmp = {
205 /* phys delivery to target CPU: */ 164 /* phys delivery to target CPU: */
206 .irq_dest_mode = 0, 165 .irq_dest_mode = 0,
207 166
208 .target_cpus = bigsmp_target_cpus, 167 .target_cpus = default_target_cpus,
209 .disable_esr = 1, 168 .disable_esr = 1,
210 .dest_logical = 0, 169 .dest_logical = 0,
211 .check_apicid_used = bigsmp_check_apicid_used, 170 .check_apicid_used = bigsmp_check_apicid_used,
212 .check_apicid_present = bigsmp_check_apicid_present, 171 .check_apicid_present = bigsmp_check_apicid_present,
213 172
214 .vector_allocation_domain = bigsmp_vector_allocation_domain, 173 .vector_allocation_domain = default_vector_allocation_domain,
215 .init_apic_ldr = bigsmp_init_apic_ldr, 174 .init_apic_ldr = bigsmp_init_apic_ldr,
216 175
217 .ioapic_phys_id_map = bigsmp_ioapic_phys_id_map, 176 .ioapic_phys_id_map = bigsmp_ioapic_phys_id_map,
@@ -229,8 +188,7 @@ static struct apic apic_bigsmp = {
229 .set_apic_id = NULL, 188 .set_apic_id = NULL,
230 .apic_id_mask = 0xFF << 24, 189 .apic_id_mask = 0xFF << 24,
231 190
232 .cpu_mask_to_apicid = bigsmp_cpu_mask_to_apicid, 191 .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
233 .cpu_mask_to_apicid_and = bigsmp_cpu_mask_to_apicid_and,
234 192
235 .send_IPI_mask = bigsmp_send_IPI_mask, 193 .send_IPI_mask = bigsmp_send_IPI_mask,
236 .send_IPI_mask_allbutself = NULL, 194 .send_IPI_mask_allbutself = NULL,
diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
index db4ab1be3c7..0874799a98c 100644
--- a/arch/x86/kernel/apic/es7000_32.c
+++ b/arch/x86/kernel/apic/es7000_32.c
@@ -394,21 +394,6 @@ static void es7000_enable_apic_mode(void)
394 WARN(1, "Command failed, status = %x\n", mip_status); 394 WARN(1, "Command failed, status = %x\n", mip_status);
395} 395}
396 396
397static void es7000_vector_allocation_domain(int cpu, struct cpumask *retmask)
398{
399 /* Careful. Some cpus do not strictly honor the set of cpus
400 * specified in the interrupt destination when using lowest
401 * priority interrupt delivery mode.
402 *
403 * In particular there was a hyperthreading cpu observed to
404 * deliver interrupts to the wrong hyperthread when only one
405 * hyperthread was specified in the interrupt desitination.
406 */
407 cpumask_clear(retmask);
408 cpumask_bits(retmask)[0] = APIC_ALL_CPUS;
409}
410
411
412static void es7000_wait_for_init_deassert(atomic_t *deassert) 397static void es7000_wait_for_init_deassert(atomic_t *deassert)
413{ 398{
414 while (!atomic_read(deassert)) 399 while (!atomic_read(deassert))
@@ -540,45 +525,49 @@ static int es7000_check_phys_apicid_present(int cpu_physical_apicid)
540 return 1; 525 return 1;
541} 526}
542 527
543static unsigned int es7000_cpu_mask_to_apicid(const struct cpumask *cpumask) 528static inline int
529es7000_cpu_mask_to_apicid(const struct cpumask *cpumask, unsigned int *dest_id)
544{ 530{
545 unsigned int round = 0; 531 unsigned int round = 0;
546 int cpu, uninitialized_var(apicid); 532 unsigned int cpu, uninitialized_var(apicid);
547 533
548 /* 534 /*
549 * The cpus in the mask must all be on the apic cluster. 535 * The cpus in the mask must all be on the apic cluster.
550 */ 536 */
551 for_each_cpu(cpu, cpumask) { 537 for_each_cpu_and(cpu, cpumask, cpu_online_mask) {
552 int new_apicid = early_per_cpu(x86_cpu_to_logical_apicid, cpu); 538 int new_apicid = early_per_cpu(x86_cpu_to_logical_apicid, cpu);
553 539
554 if (round && APIC_CLUSTER(apicid) != APIC_CLUSTER(new_apicid)) { 540 if (round && APIC_CLUSTER(apicid) != APIC_CLUSTER(new_apicid)) {
555 WARN(1, "Not a valid mask!"); 541 WARN(1, "Not a valid mask!");
556 542
557 return BAD_APICID; 543 return -EINVAL;
558 } 544 }
559 apicid = new_apicid; 545 apicid |= new_apicid;
560 round++; 546 round++;
561 } 547 }
562 return apicid; 548 if (!round)
549 return -EINVAL;
550 *dest_id = apicid;
551 return 0;
563} 552}
564 553
565static unsigned int 554static int
566es7000_cpu_mask_to_apicid_and(const struct cpumask *inmask, 555es7000_cpu_mask_to_apicid_and(const struct cpumask *inmask,
567 const struct cpumask *andmask) 556 const struct cpumask *andmask,
557 unsigned int *apicid)
568{ 558{
569 int apicid = early_per_cpu(x86_cpu_to_logical_apicid, 0);
570 cpumask_var_t cpumask; 559 cpumask_var_t cpumask;
560 *apicid = early_per_cpu(x86_cpu_to_logical_apicid, 0);
571 561
572 if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC)) 562 if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC))
573 return apicid; 563 return 0;
574 564
575 cpumask_and(cpumask, inmask, andmask); 565 cpumask_and(cpumask, inmask, andmask);
576 cpumask_and(cpumask, cpumask, cpu_online_mask); 566 es7000_cpu_mask_to_apicid(cpumask, apicid);
577 apicid = es7000_cpu_mask_to_apicid(cpumask);
578 567
579 free_cpumask_var(cpumask); 568 free_cpumask_var(cpumask);
580 569
581 return apicid; 570 return 0;
582} 571}
583 572
584static int es7000_phys_pkg_id(int cpuid_apic, int index_msb) 573static int es7000_phys_pkg_id(int cpuid_apic, int index_msb)
@@ -638,7 +627,7 @@ static struct apic __refdata apic_es7000_cluster = {
638 .check_apicid_used = es7000_check_apicid_used, 627 .check_apicid_used = es7000_check_apicid_used,
639 .check_apicid_present = es7000_check_apicid_present, 628 .check_apicid_present = es7000_check_apicid_present,
640 629
641 .vector_allocation_domain = es7000_vector_allocation_domain, 630 .vector_allocation_domain = flat_vector_allocation_domain,
642 .init_apic_ldr = es7000_init_apic_ldr_cluster, 631 .init_apic_ldr = es7000_init_apic_ldr_cluster,
643 632
644 .ioapic_phys_id_map = es7000_ioapic_phys_id_map, 633 .ioapic_phys_id_map = es7000_ioapic_phys_id_map,
@@ -656,7 +645,6 @@ static struct apic __refdata apic_es7000_cluster = {
656 .set_apic_id = NULL, 645 .set_apic_id = NULL,
657 .apic_id_mask = 0xFF << 24, 646 .apic_id_mask = 0xFF << 24,
658 647
659 .cpu_mask_to_apicid = es7000_cpu_mask_to_apicid,
660 .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and, 648 .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and,
661 649
662 .send_IPI_mask = es7000_send_IPI_mask, 650 .send_IPI_mask = es7000_send_IPI_mask,
@@ -705,7 +693,7 @@ static struct apic __refdata apic_es7000 = {
705 .check_apicid_used = es7000_check_apicid_used, 693 .check_apicid_used = es7000_check_apicid_used,
706 .check_apicid_present = es7000_check_apicid_present, 694 .check_apicid_present = es7000_check_apicid_present,
707 695
708 .vector_allocation_domain = es7000_vector_allocation_domain, 696 .vector_allocation_domain = flat_vector_allocation_domain,
709 .init_apic_ldr = es7000_init_apic_ldr, 697 .init_apic_ldr = es7000_init_apic_ldr,
710 698
711 .ioapic_phys_id_map = es7000_ioapic_phys_id_map, 699 .ioapic_phys_id_map = es7000_ioapic_phys_id_map,
@@ -723,7 +711,6 @@ static struct apic __refdata apic_es7000 = {
723 .set_apic_id = NULL, 711 .set_apic_id = NULL,
724 .apic_id_mask = 0xFF << 24, 712 .apic_id_mask = 0xFF << 24,
725 713
726 .cpu_mask_to_apicid = es7000_cpu_mask_to_apicid,
727 .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and, 714 .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and,
728 715
729 .send_IPI_mask = es7000_send_IPI_mask, 716 .send_IPI_mask = es7000_send_IPI_mask,
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 5f0ff597437..c265593ec2c 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -448,8 +448,8 @@ static int __add_pin_to_irq_node(struct irq_cfg *cfg, int node, int apic, int pi
448 448
449 entry = alloc_irq_pin_list(node); 449 entry = alloc_irq_pin_list(node);
450 if (!entry) { 450 if (!entry) {
451 printk(KERN_ERR "can not alloc irq_pin_list (%d,%d,%d)\n", 451 pr_err("can not alloc irq_pin_list (%d,%d,%d)\n",
452 node, apic, pin); 452 node, apic, pin);
453 return -ENOMEM; 453 return -ENOMEM;
454 } 454 }
455 entry->apic = apic; 455 entry->apic = apic;
@@ -661,7 +661,7 @@ static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin)
661 ioapic_mask_entry(apic, pin); 661 ioapic_mask_entry(apic, pin);
662 entry = ioapic_read_entry(apic, pin); 662 entry = ioapic_read_entry(apic, pin);
663 if (entry.irr) 663 if (entry.irr)
664 printk(KERN_ERR "Unable to reset IRR for apic: %d, pin :%d\n", 664 pr_err("Unable to reset IRR for apic: %d, pin :%d\n",
665 mpc_ioapic_id(apic), pin); 665 mpc_ioapic_id(apic), pin);
666} 666}
667 667
@@ -895,7 +895,7 @@ static int irq_polarity(int idx)
895 } 895 }
896 case 2: /* reserved */ 896 case 2: /* reserved */
897 { 897 {
898 printk(KERN_WARNING "broken BIOS!!\n"); 898 pr_warn("broken BIOS!!\n");
899 polarity = 1; 899 polarity = 1;
900 break; 900 break;
901 } 901 }
@@ -906,7 +906,7 @@ static int irq_polarity(int idx)
906 } 906 }
907 default: /* invalid */ 907 default: /* invalid */
908 { 908 {
909 printk(KERN_WARNING "broken BIOS!!\n"); 909 pr_warn("broken BIOS!!\n");
910 polarity = 1; 910 polarity = 1;
911 break; 911 break;
912 } 912 }
@@ -948,7 +948,7 @@ static int irq_trigger(int idx)
948 } 948 }
949 default: 949 default:
950 { 950 {
951 printk(KERN_WARNING "broken BIOS!!\n"); 951 pr_warn("broken BIOS!!\n");
952 trigger = 1; 952 trigger = 1;
953 break; 953 break;
954 } 954 }
@@ -962,7 +962,7 @@ static int irq_trigger(int idx)
962 } 962 }
963 case 2: /* reserved */ 963 case 2: /* reserved */
964 { 964 {
965 printk(KERN_WARNING "broken BIOS!!\n"); 965 pr_warn("broken BIOS!!\n");
966 trigger = 1; 966 trigger = 1;
967 break; 967 break;
968 } 968 }
@@ -973,7 +973,7 @@ static int irq_trigger(int idx)
973 } 973 }
974 default: /* invalid */ 974 default: /* invalid */
975 { 975 {
976 printk(KERN_WARNING "broken BIOS!!\n"); 976 pr_warn("broken BIOS!!\n");
977 trigger = 0; 977 trigger = 0;
978 break; 978 break;
979 } 979 }
@@ -991,7 +991,7 @@ static int pin_2_irq(int idx, int apic, int pin)
991 * Debugging check, we are in big trouble if this message pops up! 991 * Debugging check, we are in big trouble if this message pops up!
992 */ 992 */
993 if (mp_irqs[idx].dstirq != pin) 993 if (mp_irqs[idx].dstirq != pin)
994 printk(KERN_ERR "broken BIOS or MPTABLE parser, ayiee!!\n"); 994 pr_err("broken BIOS or MPTABLE parser, ayiee!!\n");
995 995
996 if (test_bit(bus, mp_bus_not_pci)) { 996 if (test_bit(bus, mp_bus_not_pci)) {
997 irq = mp_irqs[idx].srcbusirq; 997 irq = mp_irqs[idx].srcbusirq;
@@ -1112,8 +1112,7 @@ __assign_irq_vector(int irq, struct irq_cfg *cfg, const struct cpumask *mask)
1112 * 0x80, because int 0x80 is hm, kind of importantish. ;) 1112 * 0x80, because int 0x80 is hm, kind of importantish. ;)
1113 */ 1113 */
1114 static int current_vector = FIRST_EXTERNAL_VECTOR + VECTOR_OFFSET_START; 1114 static int current_vector = FIRST_EXTERNAL_VECTOR + VECTOR_OFFSET_START;
1115 static int current_offset = VECTOR_OFFSET_START % 8; 1115 static int current_offset = VECTOR_OFFSET_START % 16;
1116 unsigned int old_vector;
1117 int cpu, err; 1116 int cpu, err;
1118 cpumask_var_t tmp_mask; 1117 cpumask_var_t tmp_mask;
1119 1118
@@ -1123,35 +1122,45 @@ __assign_irq_vector(int irq, struct irq_cfg *cfg, const struct cpumask *mask)
1123 if (!alloc_cpumask_var(&tmp_mask, GFP_ATOMIC)) 1122 if (!alloc_cpumask_var(&tmp_mask, GFP_ATOMIC))
1124 return -ENOMEM; 1123 return -ENOMEM;
1125 1124
1126 old_vector = cfg->vector;
1127 if (old_vector) {
1128 cpumask_and(tmp_mask, mask, cpu_online_mask);
1129 cpumask_and(tmp_mask, cfg->domain, tmp_mask);
1130 if (!cpumask_empty(tmp_mask)) {
1131 free_cpumask_var(tmp_mask);
1132 return 0;
1133 }
1134 }
1135
1136 /* Only try and allocate irqs on cpus that are present */ 1125 /* Only try and allocate irqs on cpus that are present */
1137 err = -ENOSPC; 1126 err = -ENOSPC;
1138 for_each_cpu_and(cpu, mask, cpu_online_mask) { 1127 cpumask_clear(cfg->old_domain);
1139 int new_cpu; 1128 cpu = cpumask_first_and(mask, cpu_online_mask);
1140 int vector, offset; 1129 while (cpu < nr_cpu_ids) {
1130 int new_cpu, vector, offset;
1141 1131
1142 apic->vector_allocation_domain(cpu, tmp_mask); 1132 apic->vector_allocation_domain(cpu, tmp_mask, mask);
1133
1134 if (cpumask_subset(tmp_mask, cfg->domain)) {
1135 err = 0;
1136 if (cpumask_equal(tmp_mask, cfg->domain))
1137 break;
1138 /*
1139 * New cpumask using the vector is a proper subset of
1140 * the current in use mask. So cleanup the vector
1141 * allocation for the members that are not used anymore.
1142 */
1143 cpumask_andnot(cfg->old_domain, cfg->domain, tmp_mask);
1144 cfg->move_in_progress = 1;
1145 cpumask_and(cfg->domain, cfg->domain, tmp_mask);
1146 break;
1147 }
1143 1148
1144 vector = current_vector; 1149 vector = current_vector;
1145 offset = current_offset; 1150 offset = current_offset;
1146next: 1151next:
1147 vector += 8; 1152 vector += 16;
1148 if (vector >= first_system_vector) { 1153 if (vector >= first_system_vector) {
1149 /* If out of vectors on large boxen, must share them. */ 1154 offset = (offset + 1) % 16;
1150 offset = (offset + 1) % 8;
1151 vector = FIRST_EXTERNAL_VECTOR + offset; 1155 vector = FIRST_EXTERNAL_VECTOR + offset;
1152 } 1156 }
1153 if (unlikely(current_vector == vector)) 1157
1158 if (unlikely(current_vector == vector)) {
1159 cpumask_or(cfg->old_domain, cfg->old_domain, tmp_mask);
1160 cpumask_andnot(tmp_mask, mask, cfg->old_domain);
1161 cpu = cpumask_first_and(tmp_mask, cpu_online_mask);
1154 continue; 1162 continue;
1163 }
1155 1164
1156 if (test_bit(vector, used_vectors)) 1165 if (test_bit(vector, used_vectors))
1157 goto next; 1166 goto next;
@@ -1162,7 +1171,7 @@ next:
1162 /* Found one! */ 1171 /* Found one! */
1163 current_vector = vector; 1172 current_vector = vector;
1164 current_offset = offset; 1173 current_offset = offset;
1165 if (old_vector) { 1174 if (cfg->vector) {
1166 cfg->move_in_progress = 1; 1175 cfg->move_in_progress = 1;
1167 cpumask_copy(cfg->old_domain, cfg->domain); 1176 cpumask_copy(cfg->old_domain, cfg->domain);
1168 } 1177 }
@@ -1195,7 +1204,7 @@ static void __clear_irq_vector(int irq, struct irq_cfg *cfg)
1195 BUG_ON(!cfg->vector); 1204 BUG_ON(!cfg->vector);
1196 1205
1197 vector = cfg->vector; 1206 vector = cfg->vector;
1198 for_each_cpu(cpu, cfg->domain) 1207 for_each_cpu_and(cpu, cfg->domain, cpu_online_mask)
1199 per_cpu(vector_irq, cpu)[vector] = -1; 1208 per_cpu(vector_irq, cpu)[vector] = -1;
1200 1209
1201 cfg->vector = 0; 1210 cfg->vector = 0;
@@ -1203,7 +1212,7 @@ static void __clear_irq_vector(int irq, struct irq_cfg *cfg)
1203 1212
1204 if (likely(!cfg->move_in_progress)) 1213 if (likely(!cfg->move_in_progress))
1205 return; 1214 return;
1206 for_each_cpu(cpu, cfg->old_domain) { 1215 for_each_cpu_and(cpu, cfg->old_domain, cpu_online_mask) {
1207 for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS; 1216 for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS;
1208 vector++) { 1217 vector++) {
1209 if (per_cpu(vector_irq, cpu)[vector] != irq) 1218 if (per_cpu(vector_irq, cpu)[vector] != irq)
@@ -1346,18 +1355,28 @@ static void setup_ioapic_irq(unsigned int irq, struct irq_cfg *cfg,
1346 1355
1347 if (!IO_APIC_IRQ(irq)) 1356 if (!IO_APIC_IRQ(irq))
1348 return; 1357 return;
1358
1349 /* 1359 /*
1350 * For legacy irqs, cfg->domain starts with cpu 0 for legacy 1360 * For legacy irqs, cfg->domain starts with cpu 0. Now that IO-APIC
1351 * controllers like 8259. Now that IO-APIC can handle this irq, update 1361 * can handle this irq and the apic driver is finialized at this point,
1352 * the cfg->domain. 1362 * update the cfg->domain.
1353 */ 1363 */
1354 if (irq < legacy_pic->nr_legacy_irqs && cpumask_test_cpu(0, cfg->domain)) 1364 if (irq < legacy_pic->nr_legacy_irqs &&
1355 apic->vector_allocation_domain(0, cfg->domain); 1365 cpumask_equal(cfg->domain, cpumask_of(0)))
1366 apic->vector_allocation_domain(0, cfg->domain,
1367 apic->target_cpus());
1356 1368
1357 if (assign_irq_vector(irq, cfg, apic->target_cpus())) 1369 if (assign_irq_vector(irq, cfg, apic->target_cpus()))
1358 return; 1370 return;
1359 1371
1360 dest = apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus()); 1372 if (apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus(),
1373 &dest)) {
1374 pr_warn("Failed to obtain apicid for ioapic %d, pin %d\n",
1375 mpc_ioapic_id(attr->ioapic), attr->ioapic_pin);
1376 __clear_irq_vector(irq, cfg);
1377
1378 return;
1379 }
1361 1380
1362 apic_printk(APIC_VERBOSE,KERN_DEBUG 1381 apic_printk(APIC_VERBOSE,KERN_DEBUG
1363 "IOAPIC[%d]: Set routing entry (%d-%d -> 0x%x -> " 1382 "IOAPIC[%d]: Set routing entry (%d-%d -> 0x%x -> "
@@ -1366,7 +1385,7 @@ static void setup_ioapic_irq(unsigned int irq, struct irq_cfg *cfg,
1366 cfg->vector, irq, attr->trigger, attr->polarity, dest); 1385 cfg->vector, irq, attr->trigger, attr->polarity, dest);
1367 1386
1368 if (setup_ioapic_entry(irq, &entry, dest, cfg->vector, attr)) { 1387 if (setup_ioapic_entry(irq, &entry, dest, cfg->vector, attr)) {
1369 pr_warn("Failed to setup ioapic entry for ioapic %d, pin %d\n", 1388 pr_warn("Failed to setup ioapic entry for ioapic %d, pin %d\n",
1370 mpc_ioapic_id(attr->ioapic), attr->ioapic_pin); 1389 mpc_ioapic_id(attr->ioapic), attr->ioapic_pin);
1371 __clear_irq_vector(irq, cfg); 1390 __clear_irq_vector(irq, cfg);
1372 1391
@@ -1469,9 +1488,10 @@ void setup_IO_APIC_irq_extra(u32 gsi)
1469 * Set up the timer pin, possibly with the 8259A-master behind. 1488 * Set up the timer pin, possibly with the 8259A-master behind.
1470 */ 1489 */
1471static void __init setup_timer_IRQ0_pin(unsigned int ioapic_idx, 1490static void __init setup_timer_IRQ0_pin(unsigned int ioapic_idx,
1472 unsigned int pin, int vector) 1491 unsigned int pin, int vector)
1473{ 1492{
1474 struct IO_APIC_route_entry entry; 1493 struct IO_APIC_route_entry entry;
1494 unsigned int dest;
1475 1495
1476 if (irq_remapping_enabled) 1496 if (irq_remapping_enabled)
1477 return; 1497 return;
@@ -1482,9 +1502,13 @@ static void __init setup_timer_IRQ0_pin(unsigned int ioapic_idx,
1482 * We use logical delivery to get the timer IRQ 1502 * We use logical delivery to get the timer IRQ
1483 * to the first CPU. 1503 * to the first CPU.
1484 */ 1504 */
1505 if (unlikely(apic->cpu_mask_to_apicid_and(apic->target_cpus(),
1506 apic->target_cpus(), &dest)))
1507 dest = BAD_APICID;
1508
1485 entry.dest_mode = apic->irq_dest_mode; 1509 entry.dest_mode = apic->irq_dest_mode;
1486 entry.mask = 0; /* don't mask IRQ for edge */ 1510 entry.mask = 0; /* don't mask IRQ for edge */
1487 entry.dest = apic->cpu_mask_to_apicid(apic->target_cpus()); 1511 entry.dest = dest;
1488 entry.delivery_mode = apic->irq_delivery_mode; 1512 entry.delivery_mode = apic->irq_delivery_mode;
1489 entry.polarity = 0; 1513 entry.polarity = 0;
1490 entry.trigger = 0; 1514 entry.trigger = 0;
@@ -1521,7 +1545,6 @@ __apicdebuginit(void) print_IO_APIC(int ioapic_idx)
1521 reg_03.raw = io_apic_read(ioapic_idx, 3); 1545 reg_03.raw = io_apic_read(ioapic_idx, 3);
1522 raw_spin_unlock_irqrestore(&ioapic_lock, flags); 1546 raw_spin_unlock_irqrestore(&ioapic_lock, flags);
1523 1547
1524 printk("\n");
1525 printk(KERN_DEBUG "IO APIC #%d......\n", mpc_ioapic_id(ioapic_idx)); 1548 printk(KERN_DEBUG "IO APIC #%d......\n", mpc_ioapic_id(ioapic_idx));
1526 printk(KERN_DEBUG ".... register #00: %08X\n", reg_00.raw); 1549 printk(KERN_DEBUG ".... register #00: %08X\n", reg_00.raw);
1527 printk(KERN_DEBUG "....... : physical APIC id: %02X\n", reg_00.bits.ID); 1550 printk(KERN_DEBUG "....... : physical APIC id: %02X\n", reg_00.bits.ID);
@@ -1578,7 +1601,7 @@ __apicdebuginit(void) print_IO_APIC(int ioapic_idx)
1578 i, 1601 i,
1579 ir_entry->index 1602 ir_entry->index
1580 ); 1603 );
1581 printk("%1d %1d %1d %1d %1d " 1604 pr_cont("%1d %1d %1d %1d %1d "
1582 "%1d %1d %X %02X\n", 1605 "%1d %1d %X %02X\n",
1583 ir_entry->format, 1606 ir_entry->format,
1584 ir_entry->mask, 1607 ir_entry->mask,
@@ -1598,7 +1621,7 @@ __apicdebuginit(void) print_IO_APIC(int ioapic_idx)
1598 i, 1621 i,
1599 entry.dest 1622 entry.dest
1600 ); 1623 );
1601 printk("%1d %1d %1d %1d %1d " 1624 pr_cont("%1d %1d %1d %1d %1d "
1602 "%1d %1d %02X\n", 1625 "%1d %1d %02X\n",
1603 entry.mask, 1626 entry.mask,
1604 entry.trigger, 1627 entry.trigger,
@@ -1651,8 +1674,8 @@ __apicdebuginit(void) print_IO_APICs(void)
1651 continue; 1674 continue;
1652 printk(KERN_DEBUG "IRQ%d ", irq); 1675 printk(KERN_DEBUG "IRQ%d ", irq);
1653 for_each_irq_pin(entry, cfg->irq_2_pin) 1676 for_each_irq_pin(entry, cfg->irq_2_pin)
1654 printk("-> %d:%d", entry->apic, entry->pin); 1677 pr_cont("-> %d:%d", entry->apic, entry->pin);
1655 printk("\n"); 1678 pr_cont("\n");
1656 } 1679 }
1657 1680
1658 printk(KERN_INFO ".................................... done.\n"); 1681 printk(KERN_INFO ".................................... done.\n");
@@ -1665,9 +1688,9 @@ __apicdebuginit(void) print_APIC_field(int base)
1665 printk(KERN_DEBUG); 1688 printk(KERN_DEBUG);
1666 1689
1667 for (i = 0; i < 8; i++) 1690 for (i = 0; i < 8; i++)
1668 printk(KERN_CONT "%08x", apic_read(base + i*0x10)); 1691 pr_cont("%08x", apic_read(base + i*0x10));
1669 1692
1670 printk(KERN_CONT "\n"); 1693 pr_cont("\n");
1671} 1694}
1672 1695
1673__apicdebuginit(void) print_local_APIC(void *dummy) 1696__apicdebuginit(void) print_local_APIC(void *dummy)
@@ -1769,7 +1792,7 @@ __apicdebuginit(void) print_local_APIC(void *dummy)
1769 printk(KERN_DEBUG "... APIC EILVT%d: %08x\n", i, v); 1792 printk(KERN_DEBUG "... APIC EILVT%d: %08x\n", i, v);
1770 } 1793 }
1771 } 1794 }
1772 printk("\n"); 1795 pr_cont("\n");
1773} 1796}
1774 1797
1775__apicdebuginit(void) print_local_APICs(int maxcpu) 1798__apicdebuginit(void) print_local_APICs(int maxcpu)
@@ -2065,7 +2088,7 @@ void __init setup_ioapic_ids_from_mpc_nocheck(void)
2065 reg_00.raw = io_apic_read(ioapic_idx, 0); 2088 reg_00.raw = io_apic_read(ioapic_idx, 0);
2066 raw_spin_unlock_irqrestore(&ioapic_lock, flags); 2089 raw_spin_unlock_irqrestore(&ioapic_lock, flags);
2067 if (reg_00.bits.ID != mpc_ioapic_id(ioapic_idx)) 2090 if (reg_00.bits.ID != mpc_ioapic_id(ioapic_idx))
2068 printk("could not set ID!\n"); 2091 pr_cont("could not set ID!\n");
2069 else 2092 else
2070 apic_printk(APIC_VERBOSE, " ok.\n"); 2093 apic_printk(APIC_VERBOSE, " ok.\n");
2071 } 2094 }
@@ -2210,71 +2233,6 @@ void send_cleanup_vector(struct irq_cfg *cfg)
2210 cfg->move_in_progress = 0; 2233 cfg->move_in_progress = 0;
2211} 2234}
2212 2235
2213static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, struct irq_cfg *cfg)
2214{
2215 int apic, pin;
2216 struct irq_pin_list *entry;
2217 u8 vector = cfg->vector;
2218
2219 for_each_irq_pin(entry, cfg->irq_2_pin) {
2220 unsigned int reg;
2221
2222 apic = entry->apic;
2223 pin = entry->pin;
2224 /*
2225 * With interrupt-remapping, destination information comes
2226 * from interrupt-remapping table entry.
2227 */
2228 if (!irq_remapped(cfg))
2229 io_apic_write(apic, 0x11 + pin*2, dest);
2230 reg = io_apic_read(apic, 0x10 + pin*2);
2231 reg &= ~IO_APIC_REDIR_VECTOR_MASK;
2232 reg |= vector;
2233 io_apic_modify(apic, 0x10 + pin*2, reg);
2234 }
2235}
2236
2237/*
2238 * Either sets data->affinity to a valid value, and returns
2239 * ->cpu_mask_to_apicid of that in dest_id, or returns -1 and
2240 * leaves data->affinity untouched.
2241 */
2242int __ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask,
2243 unsigned int *dest_id)
2244{
2245 struct irq_cfg *cfg = data->chip_data;
2246
2247 if (!cpumask_intersects(mask, cpu_online_mask))
2248 return -1;
2249
2250 if (assign_irq_vector(data->irq, data->chip_data, mask))
2251 return -1;
2252
2253 cpumask_copy(data->affinity, mask);
2254
2255 *dest_id = apic->cpu_mask_to_apicid_and(mask, cfg->domain);
2256 return 0;
2257}
2258
2259static int
2260ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask,
2261 bool force)
2262{
2263 unsigned int dest, irq = data->irq;
2264 unsigned long flags;
2265 int ret;
2266
2267 raw_spin_lock_irqsave(&ioapic_lock, flags);
2268 ret = __ioapic_set_affinity(data, mask, &dest);
2269 if (!ret) {
2270 /* Only the high 8 bits are valid. */
2271 dest = SET_APIC_LOGICAL_ID(dest);
2272 __target_IO_APIC_irq(irq, dest, data->chip_data);
2273 }
2274 raw_spin_unlock_irqrestore(&ioapic_lock, flags);
2275 return ret;
2276}
2277
2278asmlinkage void smp_irq_move_cleanup_interrupt(void) 2236asmlinkage void smp_irq_move_cleanup_interrupt(void)
2279{ 2237{
2280 unsigned vector, me; 2238 unsigned vector, me;
@@ -2362,6 +2320,87 @@ void irq_force_complete_move(int irq)
2362static inline void irq_complete_move(struct irq_cfg *cfg) { } 2320static inline void irq_complete_move(struct irq_cfg *cfg) { }
2363#endif 2321#endif
2364 2322
2323static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, struct irq_cfg *cfg)
2324{
2325 int apic, pin;
2326 struct irq_pin_list *entry;
2327 u8 vector = cfg->vector;
2328
2329 for_each_irq_pin(entry, cfg->irq_2_pin) {
2330 unsigned int reg;
2331
2332 apic = entry->apic;
2333 pin = entry->pin;
2334 /*
2335 * With interrupt-remapping, destination information comes
2336 * from interrupt-remapping table entry.
2337 */
2338 if (!irq_remapped(cfg))
2339 io_apic_write(apic, 0x11 + pin*2, dest);
2340 reg = io_apic_read(apic, 0x10 + pin*2);
2341 reg &= ~IO_APIC_REDIR_VECTOR_MASK;
2342 reg |= vector;
2343 io_apic_modify(apic, 0x10 + pin*2, reg);
2344 }
2345}
2346
2347/*
2348 * Either sets data->affinity to a valid value, and returns
2349 * ->cpu_mask_to_apicid of that in dest_id, or returns -1 and
2350 * leaves data->affinity untouched.
2351 */
2352int __ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask,
2353 unsigned int *dest_id)
2354{
2355 struct irq_cfg *cfg = data->chip_data;
2356 unsigned int irq = data->irq;
2357 int err;
2358
2359 if (!config_enabled(CONFIG_SMP))
2360 return -1;
2361
2362 if (!cpumask_intersects(mask, cpu_online_mask))
2363 return -EINVAL;
2364
2365 err = assign_irq_vector(irq, cfg, mask);
2366 if (err)
2367 return err;
2368
2369 err = apic->cpu_mask_to_apicid_and(mask, cfg->domain, dest_id);
2370 if (err) {
2371 if (assign_irq_vector(irq, cfg, data->affinity))
2372 pr_err("Failed to recover vector for irq %d\n", irq);
2373 return err;
2374 }
2375
2376 cpumask_copy(data->affinity, mask);
2377
2378 return 0;
2379}
2380
2381static int
2382ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask,
2383 bool force)
2384{
2385 unsigned int dest, irq = data->irq;
2386 unsigned long flags;
2387 int ret;
2388
2389 if (!config_enabled(CONFIG_SMP))
2390 return -1;
2391
2392 raw_spin_lock_irqsave(&ioapic_lock, flags);
2393 ret = __ioapic_set_affinity(data, mask, &dest);
2394 if (!ret) {
2395 /* Only the high 8 bits are valid. */
2396 dest = SET_APIC_LOGICAL_ID(dest);
2397 __target_IO_APIC_irq(irq, dest, data->chip_data);
2398 ret = IRQ_SET_MASK_OK_NOCOPY;
2399 }
2400 raw_spin_unlock_irqrestore(&ioapic_lock, flags);
2401 return ret;
2402}
2403
2365static void ack_apic_edge(struct irq_data *data) 2404static void ack_apic_edge(struct irq_data *data)
2366{ 2405{
2367 irq_complete_move(data->chip_data); 2406 irq_complete_move(data->chip_data);
@@ -2541,9 +2580,7 @@ static void irq_remap_modify_chip_defaults(struct irq_chip *chip)
2541 chip->irq_ack = ir_ack_apic_edge; 2580 chip->irq_ack = ir_ack_apic_edge;
2542 chip->irq_eoi = ir_ack_apic_level; 2581 chip->irq_eoi = ir_ack_apic_level;
2543 2582
2544#ifdef CONFIG_SMP
2545 chip->irq_set_affinity = set_remapped_irq_affinity; 2583 chip->irq_set_affinity = set_remapped_irq_affinity;
2546#endif
2547} 2584}
2548#endif /* CONFIG_IRQ_REMAP */ 2585#endif /* CONFIG_IRQ_REMAP */
2549 2586
@@ -2554,9 +2591,7 @@ static struct irq_chip ioapic_chip __read_mostly = {
2554 .irq_unmask = unmask_ioapic_irq, 2591 .irq_unmask = unmask_ioapic_irq,
2555 .irq_ack = ack_apic_edge, 2592 .irq_ack = ack_apic_edge,
2556 .irq_eoi = ack_apic_level, 2593 .irq_eoi = ack_apic_level,
2557#ifdef CONFIG_SMP
2558 .irq_set_affinity = ioapic_set_affinity, 2594 .irq_set_affinity = ioapic_set_affinity,
2559#endif
2560 .irq_retrigger = ioapic_retrigger_irq, 2595 .irq_retrigger = ioapic_retrigger_irq,
2561}; 2596};
2562 2597
@@ -3038,7 +3073,10 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq,
3038 if (err) 3073 if (err)
3039 return err; 3074 return err;
3040 3075
3041 dest = apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus()); 3076 err = apic->cpu_mask_to_apicid_and(cfg->domain,
3077 apic->target_cpus(), &dest);
3078 if (err)
3079 return err;
3042 3080
3043 if (irq_remapped(cfg)) { 3081 if (irq_remapped(cfg)) {
3044 compose_remapped_msi_msg(pdev, irq, dest, msg, hpet_id); 3082 compose_remapped_msi_msg(pdev, irq, dest, msg, hpet_id);
@@ -3072,7 +3110,6 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq,
3072 return err; 3110 return err;
3073} 3111}
3074 3112
3075#ifdef CONFIG_SMP
3076static int 3113static int
3077msi_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force) 3114msi_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force)
3078{ 3115{
@@ -3092,9 +3129,8 @@ msi_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force)
3092 3129
3093 __write_msi_msg(data->msi_desc, &msg); 3130 __write_msi_msg(data->msi_desc, &msg);
3094 3131
3095 return 0; 3132 return IRQ_SET_MASK_OK_NOCOPY;
3096} 3133}
3097#endif /* CONFIG_SMP */
3098 3134
3099/* 3135/*
3100 * IRQ Chip for MSI PCI/PCI-X/PCI-Express Devices, 3136 * IRQ Chip for MSI PCI/PCI-X/PCI-Express Devices,
@@ -3105,9 +3141,7 @@ static struct irq_chip msi_chip = {
3105 .irq_unmask = unmask_msi_irq, 3141 .irq_unmask = unmask_msi_irq,
3106 .irq_mask = mask_msi_irq, 3142 .irq_mask = mask_msi_irq,
3107 .irq_ack = ack_apic_edge, 3143 .irq_ack = ack_apic_edge,
3108#ifdef CONFIG_SMP
3109 .irq_set_affinity = msi_set_affinity, 3144 .irq_set_affinity = msi_set_affinity,
3110#endif
3111 .irq_retrigger = ioapic_retrigger_irq, 3145 .irq_retrigger = ioapic_retrigger_irq,
3112}; 3146};
3113 3147
@@ -3192,7 +3226,6 @@ void native_teardown_msi_irq(unsigned int irq)
3192} 3226}
3193 3227
3194#ifdef CONFIG_DMAR_TABLE 3228#ifdef CONFIG_DMAR_TABLE
3195#ifdef CONFIG_SMP
3196static int 3229static int
3197dmar_msi_set_affinity(struct irq_data *data, const struct cpumask *mask, 3230dmar_msi_set_affinity(struct irq_data *data, const struct cpumask *mask,
3198 bool force) 3231 bool force)
@@ -3214,19 +3247,15 @@ dmar_msi_set_affinity(struct irq_data *data, const struct cpumask *mask,
3214 3247
3215 dmar_msi_write(irq, &msg); 3248 dmar_msi_write(irq, &msg);
3216 3249
3217 return 0; 3250 return IRQ_SET_MASK_OK_NOCOPY;
3218} 3251}
3219 3252
3220#endif /* CONFIG_SMP */
3221
3222static struct irq_chip dmar_msi_type = { 3253static struct irq_chip dmar_msi_type = {
3223 .name = "DMAR_MSI", 3254 .name = "DMAR_MSI",
3224 .irq_unmask = dmar_msi_unmask, 3255 .irq_unmask = dmar_msi_unmask,
3225 .irq_mask = dmar_msi_mask, 3256 .irq_mask = dmar_msi_mask,
3226 .irq_ack = ack_apic_edge, 3257 .irq_ack = ack_apic_edge,
3227#ifdef CONFIG_SMP
3228 .irq_set_affinity = dmar_msi_set_affinity, 3258 .irq_set_affinity = dmar_msi_set_affinity,
3229#endif
3230 .irq_retrigger = ioapic_retrigger_irq, 3259 .irq_retrigger = ioapic_retrigger_irq,
3231}; 3260};
3232 3261
@@ -3247,7 +3276,6 @@ int arch_setup_dmar_msi(unsigned int irq)
3247 3276
3248#ifdef CONFIG_HPET_TIMER 3277#ifdef CONFIG_HPET_TIMER
3249 3278
3250#ifdef CONFIG_SMP
3251static int hpet_msi_set_affinity(struct irq_data *data, 3279static int hpet_msi_set_affinity(struct irq_data *data,
3252 const struct cpumask *mask, bool force) 3280 const struct cpumask *mask, bool force)
3253{ 3281{
@@ -3267,19 +3295,15 @@ static int hpet_msi_set_affinity(struct irq_data *data,
3267 3295
3268 hpet_msi_write(data->handler_data, &msg); 3296 hpet_msi_write(data->handler_data, &msg);
3269 3297
3270 return 0; 3298 return IRQ_SET_MASK_OK_NOCOPY;
3271} 3299}
3272 3300
3273#endif /* CONFIG_SMP */
3274
3275static struct irq_chip hpet_msi_type = { 3301static struct irq_chip hpet_msi_type = {
3276 .name = "HPET_MSI", 3302 .name = "HPET_MSI",
3277 .irq_unmask = hpet_msi_unmask, 3303 .irq_unmask = hpet_msi_unmask,
3278 .irq_mask = hpet_msi_mask, 3304 .irq_mask = hpet_msi_mask,
3279 .irq_ack = ack_apic_edge, 3305 .irq_ack = ack_apic_edge,
3280#ifdef CONFIG_SMP
3281 .irq_set_affinity = hpet_msi_set_affinity, 3306 .irq_set_affinity = hpet_msi_set_affinity,
3282#endif
3283 .irq_retrigger = ioapic_retrigger_irq, 3307 .irq_retrigger = ioapic_retrigger_irq,
3284}; 3308};
3285 3309
@@ -3314,8 +3338,6 @@ int arch_setup_hpet_msi(unsigned int irq, unsigned int id)
3314 */ 3338 */
3315#ifdef CONFIG_HT_IRQ 3339#ifdef CONFIG_HT_IRQ
3316 3340
3317#ifdef CONFIG_SMP
3318
3319static void target_ht_irq(unsigned int irq, unsigned int dest, u8 vector) 3341static void target_ht_irq(unsigned int irq, unsigned int dest, u8 vector)
3320{ 3342{
3321 struct ht_irq_msg msg; 3343 struct ht_irq_msg msg;
@@ -3340,25 +3362,23 @@ ht_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force)
3340 return -1; 3362 return -1;
3341 3363
3342 target_ht_irq(data->irq, dest, cfg->vector); 3364 target_ht_irq(data->irq, dest, cfg->vector);
3343 return 0; 3365 return IRQ_SET_MASK_OK_NOCOPY;
3344} 3366}
3345 3367
3346#endif
3347
3348static struct irq_chip ht_irq_chip = { 3368static struct irq_chip ht_irq_chip = {
3349 .name = "PCI-HT", 3369 .name = "PCI-HT",
3350 .irq_mask = mask_ht_irq, 3370 .irq_mask = mask_ht_irq,
3351 .irq_unmask = unmask_ht_irq, 3371 .irq_unmask = unmask_ht_irq,
3352 .irq_ack = ack_apic_edge, 3372 .irq_ack = ack_apic_edge,
3353#ifdef CONFIG_SMP
3354 .irq_set_affinity = ht_set_affinity, 3373 .irq_set_affinity = ht_set_affinity,
3355#endif
3356 .irq_retrigger = ioapic_retrigger_irq, 3374 .irq_retrigger = ioapic_retrigger_irq,
3357}; 3375};
3358 3376
3359int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev) 3377int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev)
3360{ 3378{
3361 struct irq_cfg *cfg; 3379 struct irq_cfg *cfg;
3380 struct ht_irq_msg msg;
3381 unsigned dest;
3362 int err; 3382 int err;
3363 3383
3364 if (disable_apic) 3384 if (disable_apic)
@@ -3366,36 +3386,37 @@ int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev)
3366 3386
3367 cfg = irq_cfg(irq); 3387 cfg = irq_cfg(irq);
3368 err = assign_irq_vector(irq, cfg, apic->target_cpus()); 3388 err = assign_irq_vector(irq, cfg, apic->target_cpus());
3369 if (!err) { 3389 if (err)
3370 struct ht_irq_msg msg; 3390 return err;
3371 unsigned dest; 3391
3392 err = apic->cpu_mask_to_apicid_and(cfg->domain,
3393 apic->target_cpus(), &dest);
3394 if (err)
3395 return err;
3372 3396
3373 dest = apic->cpu_mask_to_apicid_and(cfg->domain, 3397 msg.address_hi = HT_IRQ_HIGH_DEST_ID(dest);
3374 apic->target_cpus());
3375 3398
3376 msg.address_hi = HT_IRQ_HIGH_DEST_ID(dest); 3399 msg.address_lo =
3400 HT_IRQ_LOW_BASE |
3401 HT_IRQ_LOW_DEST_ID(dest) |
3402 HT_IRQ_LOW_VECTOR(cfg->vector) |
3403 ((apic->irq_dest_mode == 0) ?
3404 HT_IRQ_LOW_DM_PHYSICAL :
3405 HT_IRQ_LOW_DM_LOGICAL) |
3406 HT_IRQ_LOW_RQEOI_EDGE |
3407 ((apic->irq_delivery_mode != dest_LowestPrio) ?
3408 HT_IRQ_LOW_MT_FIXED :
3409 HT_IRQ_LOW_MT_ARBITRATED) |
3410 HT_IRQ_LOW_IRQ_MASKED;
3377 3411
3378 msg.address_lo = 3412 write_ht_irq_msg(irq, &msg);
3379 HT_IRQ_LOW_BASE |
3380 HT_IRQ_LOW_DEST_ID(dest) |
3381 HT_IRQ_LOW_VECTOR(cfg->vector) |
3382 ((apic->irq_dest_mode == 0) ?
3383 HT_IRQ_LOW_DM_PHYSICAL :
3384 HT_IRQ_LOW_DM_LOGICAL) |
3385 HT_IRQ_LOW_RQEOI_EDGE |
3386 ((apic->irq_delivery_mode != dest_LowestPrio) ?
3387 HT_IRQ_LOW_MT_FIXED :
3388 HT_IRQ_LOW_MT_ARBITRATED) |
3389 HT_IRQ_LOW_IRQ_MASKED;
3390 3413
3391 write_ht_irq_msg(irq, &msg); 3414 irq_set_chip_and_handler_name(irq, &ht_irq_chip,
3415 handle_edge_irq, "edge");
3392 3416
3393 irq_set_chip_and_handler_name(irq, &ht_irq_chip, 3417 dev_printk(KERN_DEBUG, &dev->dev, "irq %d for HT\n", irq);
3394 handle_edge_irq, "edge");
3395 3418
3396 dev_printk(KERN_DEBUG, &dev->dev, "irq %d for HT\n", irq); 3419 return 0;
3397 }
3398 return err;
3399} 3420}
3400#endif /* CONFIG_HT_IRQ */ 3421#endif /* CONFIG_HT_IRQ */
3401 3422
@@ -3563,7 +3584,8 @@ static int __init io_apic_get_unique_id(int ioapic, int apic_id)
3563 3584
3564 /* Sanity check */ 3585 /* Sanity check */
3565 if (reg_00.bits.ID != apic_id) { 3586 if (reg_00.bits.ID != apic_id) {
3566 printk("IOAPIC[%d]: Unable to change apic_id!\n", ioapic); 3587 pr_err("IOAPIC[%d]: Unable to change apic_id!\n",
3588 ioapic);
3567 return -1; 3589 return -1;
3568 } 3590 }
3569 } 3591 }
diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
index f00a68cca37..d661ee95cab 100644
--- a/arch/x86/kernel/apic/numaq_32.c
+++ b/arch/x86/kernel/apic/numaq_32.c
@@ -406,16 +406,13 @@ static inline int numaq_check_phys_apicid_present(int phys_apicid)
406 * We use physical apicids here, not logical, so just return the default 406 * We use physical apicids here, not logical, so just return the default
407 * physical broadcast to stop people from breaking us 407 * physical broadcast to stop people from breaking us
408 */ 408 */
409static unsigned int numaq_cpu_mask_to_apicid(const struct cpumask *cpumask) 409static int
410{
411 return 0x0F;
412}
413
414static inline unsigned int
415numaq_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 410numaq_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
416 const struct cpumask *andmask) 411 const struct cpumask *andmask,
412 unsigned int *apicid)
417{ 413{
418 return 0x0F; 414 *apicid = 0x0F;
415 return 0;
419} 416}
420 417
421/* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */ 418/* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */
@@ -441,20 +438,6 @@ static int probe_numaq(void)
441 return found_numaq; 438 return found_numaq;
442} 439}
443 440
444static void numaq_vector_allocation_domain(int cpu, struct cpumask *retmask)
445{
446 /* Careful. Some cpus do not strictly honor the set of cpus
447 * specified in the interrupt destination when using lowest
448 * priority interrupt delivery mode.
449 *
450 * In particular there was a hyperthreading cpu observed to
451 * deliver interrupts to the wrong hyperthread when only one
452 * hyperthread was specified in the interrupt desitination.
453 */
454 cpumask_clear(retmask);
455 cpumask_bits(retmask)[0] = APIC_ALL_CPUS;
456}
457
458static void numaq_setup_portio_remap(void) 441static void numaq_setup_portio_remap(void)
459{ 442{
460 int num_quads = num_online_nodes(); 443 int num_quads = num_online_nodes();
@@ -491,7 +474,7 @@ static struct apic __refdata apic_numaq = {
491 .check_apicid_used = numaq_check_apicid_used, 474 .check_apicid_used = numaq_check_apicid_used,
492 .check_apicid_present = numaq_check_apicid_present, 475 .check_apicid_present = numaq_check_apicid_present,
493 476
494 .vector_allocation_domain = numaq_vector_allocation_domain, 477 .vector_allocation_domain = flat_vector_allocation_domain,
495 .init_apic_ldr = numaq_init_apic_ldr, 478 .init_apic_ldr = numaq_init_apic_ldr,
496 479
497 .ioapic_phys_id_map = numaq_ioapic_phys_id_map, 480 .ioapic_phys_id_map = numaq_ioapic_phys_id_map,
@@ -509,7 +492,6 @@ static struct apic __refdata apic_numaq = {
509 .set_apic_id = NULL, 492 .set_apic_id = NULL,
510 .apic_id_mask = 0x0F << 24, 493 .apic_id_mask = 0x0F << 24,
511 494
512 .cpu_mask_to_apicid = numaq_cpu_mask_to_apicid,
513 .cpu_mask_to_apicid_and = numaq_cpu_mask_to_apicid_and, 495 .cpu_mask_to_apicid_and = numaq_cpu_mask_to_apicid_and,
514 496
515 .send_IPI_mask = numaq_send_IPI_mask, 497 .send_IPI_mask = numaq_send_IPI_mask,
diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
index 1b291da09e6..eb35ef9ee63 100644
--- a/arch/x86/kernel/apic/probe_32.c
+++ b/arch/x86/kernel/apic/probe_32.c
@@ -66,21 +66,6 @@ static void setup_apic_flat_routing(void)
66#endif 66#endif
67} 67}
68 68
69static void default_vector_allocation_domain(int cpu, struct cpumask *retmask)
70{
71 /*
72 * Careful. Some cpus do not strictly honor the set of cpus
73 * specified in the interrupt destination when using lowest
74 * priority interrupt delivery mode.
75 *
76 * In particular there was a hyperthreading cpu observed to
77 * deliver interrupts to the wrong hyperthread when only one
78 * hyperthread was specified in the interrupt desitination.
79 */
80 cpumask_clear(retmask);
81 cpumask_bits(retmask)[0] = APIC_ALL_CPUS;
82}
83
84/* should be called last. */ 69/* should be called last. */
85static int probe_default(void) 70static int probe_default(void)
86{ 71{
@@ -105,7 +90,7 @@ static struct apic apic_default = {
105 .check_apicid_used = default_check_apicid_used, 90 .check_apicid_used = default_check_apicid_used,
106 .check_apicid_present = default_check_apicid_present, 91 .check_apicid_present = default_check_apicid_present,
107 92
108 .vector_allocation_domain = default_vector_allocation_domain, 93 .vector_allocation_domain = flat_vector_allocation_domain,
109 .init_apic_ldr = default_init_apic_ldr, 94 .init_apic_ldr = default_init_apic_ldr,
110 95
111 .ioapic_phys_id_map = default_ioapic_phys_id_map, 96 .ioapic_phys_id_map = default_ioapic_phys_id_map,
@@ -123,8 +108,7 @@ static struct apic apic_default = {
123 .set_apic_id = NULL, 108 .set_apic_id = NULL,
124 .apic_id_mask = 0x0F << 24, 109 .apic_id_mask = 0x0F << 24,
125 110
126 .cpu_mask_to_apicid = default_cpu_mask_to_apicid, 111 .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and,
127 .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
128 112
129 .send_IPI_mask = default_send_IPI_mask_logical, 113 .send_IPI_mask = default_send_IPI_mask_logical,
130 .send_IPI_mask_allbutself = default_send_IPI_mask_allbutself_logical, 114 .send_IPI_mask_allbutself = default_send_IPI_mask_allbutself_logical,
@@ -208,6 +192,9 @@ void __init default_setup_apic_routing(void)
208 192
209 if (apic->setup_apic_routing) 193 if (apic->setup_apic_routing)
210 apic->setup_apic_routing(); 194 apic->setup_apic_routing();
195
196 if (x86_platform.apic_post_init)
197 x86_platform.apic_post_init();
211} 198}
212 199
213void __init generic_apic_probe(void) 200void __init generic_apic_probe(void)
diff --git a/arch/x86/kernel/apic/probe_64.c b/arch/x86/kernel/apic/probe_64.c
index 3fe98669892..1793dba7a74 100644
--- a/arch/x86/kernel/apic/probe_64.c
+++ b/arch/x86/kernel/apic/probe_64.c
@@ -23,11 +23,6 @@
23#include <asm/ipi.h> 23#include <asm/ipi.h>
24#include <asm/setup.h> 24#include <asm/setup.h>
25 25
26static int apicid_phys_pkg_id(int initial_apic_id, int index_msb)
27{
28 return hard_smp_processor_id() >> index_msb;
29}
30
31/* 26/*
32 * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode. 27 * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
33 */ 28 */
@@ -48,10 +43,8 @@ void __init default_setup_apic_routing(void)
48 } 43 }
49 } 44 }
50 45
51 if (is_vsmp_box()) { 46 if (x86_platform.apic_post_init)
52 /* need to update phys_pkg_id */ 47 x86_platform.apic_post_init();
53 apic->phys_pkg_id = apicid_phys_pkg_id;
54 }
55} 48}
56 49
57/* Same for both flat and physical. */ 50/* Same for both flat and physical. */
diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
index 659897c0075..77c95c0e1bf 100644
--- a/arch/x86/kernel/apic/summit_32.c
+++ b/arch/x86/kernel/apic/summit_32.c
@@ -26,6 +26,8 @@
26 * 26 *
27 */ 27 */
28 28
29#define pr_fmt(fmt) "summit: %s: " fmt, __func__
30
29#include <linux/mm.h> 31#include <linux/mm.h>
30#include <linux/init.h> 32#include <linux/init.h>
31#include <asm/io.h> 33#include <asm/io.h>
@@ -235,8 +237,8 @@ static int summit_apic_id_registered(void)
235 237
236static void summit_setup_apic_routing(void) 238static void summit_setup_apic_routing(void)
237{ 239{
238 printk("Enabling APIC mode: Summit. Using %d I/O APICs\n", 240 pr_info("Enabling APIC mode: Summit. Using %d I/O APICs\n",
239 nr_ioapics); 241 nr_ioapics);
240} 242}
241 243
242static int summit_cpu_present_to_apicid(int mps_cpu) 244static int summit_cpu_present_to_apicid(int mps_cpu)
@@ -263,43 +265,48 @@ static int summit_check_phys_apicid_present(int physical_apicid)
263 return 1; 265 return 1;
264} 266}
265 267
266static unsigned int summit_cpu_mask_to_apicid(const struct cpumask *cpumask) 268static inline int
269summit_cpu_mask_to_apicid(const struct cpumask *cpumask, unsigned int *dest_id)
267{ 270{
268 unsigned int round = 0; 271 unsigned int round = 0;
269 int cpu, apicid = 0; 272 unsigned int cpu, apicid = 0;
270 273
271 /* 274 /*
272 * The cpus in the mask must all be on the apic cluster. 275 * The cpus in the mask must all be on the apic cluster.
273 */ 276 */
274 for_each_cpu(cpu, cpumask) { 277 for_each_cpu_and(cpu, cpumask, cpu_online_mask) {
275 int new_apicid = early_per_cpu(x86_cpu_to_logical_apicid, cpu); 278 int new_apicid = early_per_cpu(x86_cpu_to_logical_apicid, cpu);
276 279
277 if (round && APIC_CLUSTER(apicid) != APIC_CLUSTER(new_apicid)) { 280 if (round && APIC_CLUSTER(apicid) != APIC_CLUSTER(new_apicid)) {
278 printk("%s: Not a valid mask!\n", __func__); 281 pr_err("Not a valid mask!\n");
279 return BAD_APICID; 282 return -EINVAL;
280 } 283 }
281 apicid |= new_apicid; 284 apicid |= new_apicid;
282 round++; 285 round++;
283 } 286 }
284 return apicid; 287 if (!round)
288 return -EINVAL;
289 *dest_id = apicid;
290 return 0;
285} 291}
286 292
287static unsigned int summit_cpu_mask_to_apicid_and(const struct cpumask *inmask, 293static int
288 const struct cpumask *andmask) 294summit_cpu_mask_to_apicid_and(const struct cpumask *inmask,
295 const struct cpumask *andmask,
296 unsigned int *apicid)
289{ 297{
290 int apicid = early_per_cpu(x86_cpu_to_logical_apicid, 0);
291 cpumask_var_t cpumask; 298 cpumask_var_t cpumask;
299 *apicid = early_per_cpu(x86_cpu_to_logical_apicid, 0);
292 300
293 if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC)) 301 if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC))
294 return apicid; 302 return 0;
295 303
296 cpumask_and(cpumask, inmask, andmask); 304 cpumask_and(cpumask, inmask, andmask);
297 cpumask_and(cpumask, cpumask, cpu_online_mask); 305 summit_cpu_mask_to_apicid(cpumask, apicid);
298 apicid = summit_cpu_mask_to_apicid(cpumask);
299 306
300 free_cpumask_var(cpumask); 307 free_cpumask_var(cpumask);
301 308
302 return apicid; 309 return 0;
303} 310}
304 311
305/* 312/*
@@ -320,20 +327,6 @@ static int probe_summit(void)
320 return 0; 327 return 0;
321} 328}
322 329
323static void summit_vector_allocation_domain(int cpu, struct cpumask *retmask)
324{
325 /* Careful. Some cpus do not strictly honor the set of cpus
326 * specified in the interrupt destination when using lowest
327 * priority interrupt delivery mode.
328 *
329 * In particular there was a hyperthreading cpu observed to
330 * deliver interrupts to the wrong hyperthread when only one
331 * hyperthread was specified in the interrupt desitination.
332 */
333 cpumask_clear(retmask);
334 cpumask_bits(retmask)[0] = APIC_ALL_CPUS;
335}
336
337#ifdef CONFIG_X86_SUMMIT_NUMA 330#ifdef CONFIG_X86_SUMMIT_NUMA
338static struct rio_table_hdr *rio_table_hdr; 331static struct rio_table_hdr *rio_table_hdr;
339static struct scal_detail *scal_devs[MAX_NUMNODES]; 332static struct scal_detail *scal_devs[MAX_NUMNODES];
@@ -355,7 +348,7 @@ static int setup_pci_node_map_for_wpeg(int wpeg_num, int last_bus)
355 } 348 }
356 } 349 }
357 if (i == rio_table_hdr->num_rio_dev) { 350 if (i == rio_table_hdr->num_rio_dev) {
358 printk(KERN_ERR "%s: Couldn't find owner Cyclone for Winnipeg!\n", __func__); 351 pr_err("Couldn't find owner Cyclone for Winnipeg!\n");
359 return last_bus; 352 return last_bus;
360 } 353 }
361 354
@@ -366,7 +359,7 @@ static int setup_pci_node_map_for_wpeg(int wpeg_num, int last_bus)
366 } 359 }
367 } 360 }
368 if (i == rio_table_hdr->num_scal_dev) { 361 if (i == rio_table_hdr->num_scal_dev) {
369 printk(KERN_ERR "%s: Couldn't find owner Twister for Cyclone!\n", __func__); 362 pr_err("Couldn't find owner Twister for Cyclone!\n");
370 return last_bus; 363 return last_bus;
371 } 364 }
372 365
@@ -396,7 +389,7 @@ static int setup_pci_node_map_for_wpeg(int wpeg_num, int last_bus)
396 num_buses = 9; 389 num_buses = 9;
397 break; 390 break;
398 default: 391 default:
399 printk(KERN_INFO "%s: Unsupported Winnipeg type!\n", __func__); 392 pr_info("Unsupported Winnipeg type!\n");
400 return last_bus; 393 return last_bus;
401 } 394 }
402 395
@@ -411,13 +404,15 @@ static int build_detail_arrays(void)
411 int i, scal_detail_size, rio_detail_size; 404 int i, scal_detail_size, rio_detail_size;
412 405
413 if (rio_table_hdr->num_scal_dev > MAX_NUMNODES) { 406 if (rio_table_hdr->num_scal_dev > MAX_NUMNODES) {
414 printk(KERN_WARNING "%s: MAX_NUMNODES too low! Defined as %d, but system has %d nodes.\n", __func__, MAX_NUMNODES, rio_table_hdr->num_scal_dev); 407 pr_warn("MAX_NUMNODES too low! Defined as %d, but system has %d nodes\n",
408 MAX_NUMNODES, rio_table_hdr->num_scal_dev);
415 return 0; 409 return 0;
416 } 410 }
417 411
418 switch (rio_table_hdr->version) { 412 switch (rio_table_hdr->version) {
419 default: 413 default:
420 printk(KERN_WARNING "%s: Invalid Rio Grande Table Version: %d\n", __func__, rio_table_hdr->version); 414 pr_warn("Invalid Rio Grande Table Version: %d\n",
415 rio_table_hdr->version);
421 return 0; 416 return 0;
422 case 2: 417 case 2:
423 scal_detail_size = 11; 418 scal_detail_size = 11;
@@ -462,7 +457,7 @@ void setup_summit(void)
462 offset = *((unsigned short *)(ptr + offset)); 457 offset = *((unsigned short *)(ptr + offset));
463 } 458 }
464 if (!rio_table_hdr) { 459 if (!rio_table_hdr) {
465 printk(KERN_ERR "%s: Unable to locate Rio Grande Table in EBDA - bailing!\n", __func__); 460 pr_err("Unable to locate Rio Grande Table in EBDA - bailing!\n");
466 return; 461 return;
467 } 462 }
468 463
@@ -509,7 +504,7 @@ static struct apic apic_summit = {
509 .check_apicid_used = summit_check_apicid_used, 504 .check_apicid_used = summit_check_apicid_used,
510 .check_apicid_present = summit_check_apicid_present, 505 .check_apicid_present = summit_check_apicid_present,
511 506
512 .vector_allocation_domain = summit_vector_allocation_domain, 507 .vector_allocation_domain = flat_vector_allocation_domain,
513 .init_apic_ldr = summit_init_apic_ldr, 508 .init_apic_ldr = summit_init_apic_ldr,
514 509
515 .ioapic_phys_id_map = summit_ioapic_phys_id_map, 510 .ioapic_phys_id_map = summit_ioapic_phys_id_map,
@@ -527,7 +522,6 @@ static struct apic apic_summit = {
527 .set_apic_id = NULL, 522 .set_apic_id = NULL,
528 .apic_id_mask = 0xFF << 24, 523 .apic_id_mask = 0xFF << 24,
529 524
530 .cpu_mask_to_apicid = summit_cpu_mask_to_apicid,
531 .cpu_mask_to_apicid_and = summit_cpu_mask_to_apicid_and, 525 .cpu_mask_to_apicid_and = summit_cpu_mask_to_apicid_and,
532 526
533 .send_IPI_mask = summit_send_IPI_mask, 527 .send_IPI_mask = summit_send_IPI_mask,
diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
index ff35cff0e1a..c88baa4ff0e 100644
--- a/arch/x86/kernel/apic/x2apic_cluster.c
+++ b/arch/x86/kernel/apic/x2apic_cluster.c
@@ -81,7 +81,7 @@ static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector)
81} 81}
82 82
83static void 83static void
84 x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector) 84x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector)
85{ 85{
86 __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLBUT); 86 __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLBUT);
87} 87}
@@ -96,36 +96,37 @@ static void x2apic_send_IPI_all(int vector)
96 __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC); 96 __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC);
97} 97}
98 98
99static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask) 99static int
100x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
101 const struct cpumask *andmask,
102 unsigned int *apicid)
100{ 103{
101 /* 104 u32 dest = 0;
102 * We're using fixed IRQ delivery, can only return one logical APIC ID. 105 u16 cluster;
103 * May as well be the first. 106 int i;
104 */
105 int cpu = cpumask_first(cpumask);
106 107
107 if ((unsigned)cpu < nr_cpu_ids) 108 for_each_cpu_and(i, cpumask, andmask) {
108 return per_cpu(x86_cpu_to_logical_apicid, cpu); 109 if (!cpumask_test_cpu(i, cpu_online_mask))
109 else 110 continue;
110 return BAD_APICID; 111 dest = per_cpu(x86_cpu_to_logical_apicid, i);
111} 112 cluster = x2apic_cluster(i);
113 break;
114 }
112 115
113static unsigned int 116 if (!dest)
114x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 117 return -EINVAL;
115 const struct cpumask *andmask)
116{
117 int cpu;
118 118
119 /* 119 for_each_cpu_and(i, cpumask, andmask) {
120 * We're using fixed IRQ delivery, can only return one logical APIC ID. 120 if (!cpumask_test_cpu(i, cpu_online_mask))
121 * May as well be the first. 121 continue;
122 */ 122 if (cluster != x2apic_cluster(i))
123 for_each_cpu_and(cpu, cpumask, andmask) { 123 continue;
124 if (cpumask_test_cpu(cpu, cpu_online_mask)) 124 dest |= per_cpu(x86_cpu_to_logical_apicid, i);
125 break;
126 } 125 }
127 126
128 return per_cpu(x86_cpu_to_logical_apicid, cpu); 127 *apicid = dest;
128
129 return 0;
129} 130}
130 131
131static void init_x2apic_ldr(void) 132static void init_x2apic_ldr(void)
@@ -208,6 +209,32 @@ static int x2apic_cluster_probe(void)
208 return 0; 209 return 0;
209} 210}
210 211
212static const struct cpumask *x2apic_cluster_target_cpus(void)
213{
214 return cpu_all_mask;
215}
216
217/*
218 * Each x2apic cluster is an allocation domain.
219 */
220static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
221 const struct cpumask *mask)
222{
223 /*
224 * To minimize vector pressure, default case of boot, device bringup
225 * etc will use a single cpu for the interrupt destination.
226 *
227 * On explicit migration requests coming from irqbalance etc,
228 * interrupts will be routed to the x2apic cluster (cluster-id
229 * derived from the first cpu in the mask) members specified
230 * in the mask.
231 */
232 if (mask == x2apic_cluster_target_cpus())
233 cpumask_copy(retmask, cpumask_of(cpu));
234 else
235 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
236}
237
211static struct apic apic_x2apic_cluster = { 238static struct apic apic_x2apic_cluster = {
212 239
213 .name = "cluster x2apic", 240 .name = "cluster x2apic",
@@ -219,13 +246,13 @@ static struct apic apic_x2apic_cluster = {
219 .irq_delivery_mode = dest_LowestPrio, 246 .irq_delivery_mode = dest_LowestPrio,
220 .irq_dest_mode = 1, /* logical */ 247 .irq_dest_mode = 1, /* logical */
221 248
222 .target_cpus = x2apic_target_cpus, 249 .target_cpus = x2apic_cluster_target_cpus,
223 .disable_esr = 0, 250 .disable_esr = 0,
224 .dest_logical = APIC_DEST_LOGICAL, 251 .dest_logical = APIC_DEST_LOGICAL,
225 .check_apicid_used = NULL, 252 .check_apicid_used = NULL,
226 .check_apicid_present = NULL, 253 .check_apicid_present = NULL,
227 254
228 .vector_allocation_domain = x2apic_vector_allocation_domain, 255 .vector_allocation_domain = cluster_vector_allocation_domain,
229 .init_apic_ldr = init_x2apic_ldr, 256 .init_apic_ldr = init_x2apic_ldr,
230 257
231 .ioapic_phys_id_map = NULL, 258 .ioapic_phys_id_map = NULL,
@@ -243,7 +270,6 @@ static struct apic apic_x2apic_cluster = {
243 .set_apic_id = x2apic_set_apic_id, 270 .set_apic_id = x2apic_set_apic_id,
244 .apic_id_mask = 0xFFFFFFFFu, 271 .apic_id_mask = 0xFFFFFFFFu,
245 272
246 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
247 .cpu_mask_to_apicid_and = x2apic_cpu_mask_to_apicid_and, 273 .cpu_mask_to_apicid_and = x2apic_cpu_mask_to_apicid_and,
248 274
249 .send_IPI_mask = x2apic_send_IPI_mask, 275 .send_IPI_mask = x2apic_send_IPI_mask,
diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
index c17e982db27..e03a1e180e8 100644
--- a/arch/x86/kernel/apic/x2apic_phys.c
+++ b/arch/x86/kernel/apic/x2apic_phys.c
@@ -76,38 +76,6 @@ static void x2apic_send_IPI_all(int vector)
76 __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC); 76 __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC);
77} 77}
78 78
79static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask)
80{
81 /*
82 * We're using fixed IRQ delivery, can only return one phys APIC ID.
83 * May as well be the first.
84 */
85 int cpu = cpumask_first(cpumask);
86
87 if ((unsigned)cpu < nr_cpu_ids)
88 return per_cpu(x86_cpu_to_apicid, cpu);
89 else
90 return BAD_APICID;
91}
92
93static unsigned int
94x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
95 const struct cpumask *andmask)
96{
97 int cpu;
98
99 /*
100 * We're using fixed IRQ delivery, can only return one phys APIC ID.
101 * May as well be the first.
102 */
103 for_each_cpu_and(cpu, cpumask, andmask) {
104 if (cpumask_test_cpu(cpu, cpu_online_mask))
105 break;
106 }
107
108 return per_cpu(x86_cpu_to_apicid, cpu);
109}
110
111static void init_x2apic_ldr(void) 79static void init_x2apic_ldr(void)
112{ 80{
113} 81}
@@ -131,13 +99,13 @@ static struct apic apic_x2apic_phys = {
131 .irq_delivery_mode = dest_Fixed, 99 .irq_delivery_mode = dest_Fixed,
132 .irq_dest_mode = 0, /* physical */ 100 .irq_dest_mode = 0, /* physical */
133 101
134 .target_cpus = x2apic_target_cpus, 102 .target_cpus = online_target_cpus,
135 .disable_esr = 0, 103 .disable_esr = 0,
136 .dest_logical = 0, 104 .dest_logical = 0,
137 .check_apicid_used = NULL, 105 .check_apicid_used = NULL,
138 .check_apicid_present = NULL, 106 .check_apicid_present = NULL,
139 107
140 .vector_allocation_domain = x2apic_vector_allocation_domain, 108 .vector_allocation_domain = default_vector_allocation_domain,
141 .init_apic_ldr = init_x2apic_ldr, 109 .init_apic_ldr = init_x2apic_ldr,
142 110
143 .ioapic_phys_id_map = NULL, 111 .ioapic_phys_id_map = NULL,
@@ -155,8 +123,7 @@ static struct apic apic_x2apic_phys = {
155 .set_apic_id = x2apic_set_apic_id, 123 .set_apic_id = x2apic_set_apic_id,
156 .apic_id_mask = 0xFFFFFFFFu, 124 .apic_id_mask = 0xFFFFFFFFu,
157 125
158 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, 126 .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
159 .cpu_mask_to_apicid_and = x2apic_cpu_mask_to_apicid_and,
160 127
161 .send_IPI_mask = x2apic_send_IPI_mask, 128 .send_IPI_mask = x2apic_send_IPI_mask,
162 .send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself, 129 .send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself,
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index c6d03f7a440..8cfade9510a 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -185,17 +185,6 @@ EXPORT_SYMBOL_GPL(uv_possible_blades);
185unsigned long sn_rtc_cycles_per_second; 185unsigned long sn_rtc_cycles_per_second;
186EXPORT_SYMBOL(sn_rtc_cycles_per_second); 186EXPORT_SYMBOL(sn_rtc_cycles_per_second);
187 187
188static const struct cpumask *uv_target_cpus(void)
189{
190 return cpu_online_mask;
191}
192
193static void uv_vector_allocation_domain(int cpu, struct cpumask *retmask)
194{
195 cpumask_clear(retmask);
196 cpumask_set_cpu(cpu, retmask);
197}
198
199static int __cpuinit uv_wakeup_secondary(int phys_apicid, unsigned long start_rip) 188static int __cpuinit uv_wakeup_secondary(int phys_apicid, unsigned long start_rip)
200{ 189{
201#ifdef CONFIG_SMP 190#ifdef CONFIG_SMP
@@ -280,25 +269,12 @@ static void uv_init_apic_ldr(void)
280{ 269{
281} 270}
282 271
283static unsigned int uv_cpu_mask_to_apicid(const struct cpumask *cpumask) 272static int
284{
285 /*
286 * We're using fixed IRQ delivery, can only return one phys APIC ID.
287 * May as well be the first.
288 */
289 int cpu = cpumask_first(cpumask);
290
291 if ((unsigned)cpu < nr_cpu_ids)
292 return per_cpu(x86_cpu_to_apicid, cpu) | uv_apicid_hibits;
293 else
294 return BAD_APICID;
295}
296
297static unsigned int
298uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 273uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
299 const struct cpumask *andmask) 274 const struct cpumask *andmask,
275 unsigned int *apicid)
300{ 276{
301 int cpu; 277 int unsigned cpu;
302 278
303 /* 279 /*
304 * We're using fixed IRQ delivery, can only return one phys APIC ID. 280 * We're using fixed IRQ delivery, can only return one phys APIC ID.
@@ -308,7 +284,13 @@ uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
308 if (cpumask_test_cpu(cpu, cpu_online_mask)) 284 if (cpumask_test_cpu(cpu, cpu_online_mask))
309 break; 285 break;
310 } 286 }
311 return per_cpu(x86_cpu_to_apicid, cpu) | uv_apicid_hibits; 287
288 if (likely(cpu < nr_cpu_ids)) {
289 *apicid = per_cpu(x86_cpu_to_apicid, cpu) | uv_apicid_hibits;
290 return 0;
291 }
292
293 return -EINVAL;
312} 294}
313 295
314static unsigned int x2apic_get_apic_id(unsigned long x) 296static unsigned int x2apic_get_apic_id(unsigned long x)
@@ -362,13 +344,13 @@ static struct apic __refdata apic_x2apic_uv_x = {
362 .irq_delivery_mode = dest_Fixed, 344 .irq_delivery_mode = dest_Fixed,
363 .irq_dest_mode = 0, /* physical */ 345 .irq_dest_mode = 0, /* physical */
364 346
365 .target_cpus = uv_target_cpus, 347 .target_cpus = online_target_cpus,
366 .disable_esr = 0, 348 .disable_esr = 0,
367 .dest_logical = APIC_DEST_LOGICAL, 349 .dest_logical = APIC_DEST_LOGICAL,
368 .check_apicid_used = NULL, 350 .check_apicid_used = NULL,
369 .check_apicid_present = NULL, 351 .check_apicid_present = NULL,
370 352
371 .vector_allocation_domain = uv_vector_allocation_domain, 353 .vector_allocation_domain = default_vector_allocation_domain,
372 .init_apic_ldr = uv_init_apic_ldr, 354 .init_apic_ldr = uv_init_apic_ldr,
373 355
374 .ioapic_phys_id_map = NULL, 356 .ioapic_phys_id_map = NULL,
@@ -386,7 +368,6 @@ static struct apic __refdata apic_x2apic_uv_x = {
386 .set_apic_id = set_apic_id, 368 .set_apic_id = set_apic_id,
387 .apic_id_mask = 0xFFFFFFFFu, 369 .apic_id_mask = 0xFFFFFFFFu,
388 370
389 .cpu_mask_to_apicid = uv_cpu_mask_to_apicid,
390 .cpu_mask_to_apicid_and = uv_cpu_mask_to_apicid_and, 371 .cpu_mask_to_apicid_and = uv_cpu_mask_to_apicid_and,
391 372
392 .send_IPI_mask = uv_send_IPI_mask, 373 .send_IPI_mask = uv_send_IPI_mask,
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 07b0c0db466..d65464e4350 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -201,6 +201,8 @@
201 * http://www.microsoft.com/whdc/archive/amp_12.mspx] 201 * http://www.microsoft.com/whdc/archive/amp_12.mspx]
202 */ 202 */
203 203
204#define pr_fmt(fmt) "apm: " fmt
205
204#include <linux/module.h> 206#include <linux/module.h>
205 207
206#include <linux/poll.h> 208#include <linux/poll.h>
@@ -485,11 +487,11 @@ static void apm_error(char *str, int err)
485 if (error_table[i].key == err) 487 if (error_table[i].key == err)
486 break; 488 break;
487 if (i < ERROR_COUNT) 489 if (i < ERROR_COUNT)
488 printk(KERN_NOTICE "apm: %s: %s\n", str, error_table[i].msg); 490 pr_notice("%s: %s\n", str, error_table[i].msg);
489 else if (err < 0) 491 else if (err < 0)
490 printk(KERN_NOTICE "apm: %s: linux error code %i\n", str, err); 492 pr_notice("%s: linux error code %i\n", str, err);
491 else 493 else
492 printk(KERN_NOTICE "apm: %s: unknown error code %#2.2x\n", 494 pr_notice("%s: unknown error code %#2.2x\n",
493 str, err); 495 str, err);
494} 496}
495 497
@@ -1184,7 +1186,7 @@ static void queue_event(apm_event_t event, struct apm_user *sender)
1184 static int notified; 1186 static int notified;
1185 1187
1186 if (notified++ == 0) 1188 if (notified++ == 0)
1187 printk(KERN_ERR "apm: an event queue overflowed\n"); 1189 pr_err("an event queue overflowed\n");
1188 if (++as->event_tail >= APM_MAX_EVENTS) 1190 if (++as->event_tail >= APM_MAX_EVENTS)
1189 as->event_tail = 0; 1191 as->event_tail = 0;
1190 } 1192 }
@@ -1447,7 +1449,7 @@ static void apm_mainloop(void)
1447static int check_apm_user(struct apm_user *as, const char *func) 1449static int check_apm_user(struct apm_user *as, const char *func)
1448{ 1450{
1449 if (as == NULL || as->magic != APM_BIOS_MAGIC) { 1451 if (as == NULL || as->magic != APM_BIOS_MAGIC) {
1450 printk(KERN_ERR "apm: %s passed bad filp\n", func); 1452 pr_err("%s passed bad filp\n", func);
1451 return 1; 1453 return 1;
1452 } 1454 }
1453 return 0; 1455 return 0;
@@ -1586,7 +1588,7 @@ static int do_release(struct inode *inode, struct file *filp)
1586 as1 = as1->next) 1588 as1 = as1->next)
1587 ; 1589 ;
1588 if (as1 == NULL) 1590 if (as1 == NULL)
1589 printk(KERN_ERR "apm: filp not in user list\n"); 1591 pr_err("filp not in user list\n");
1590 else 1592 else
1591 as1->next = as->next; 1593 as1->next = as->next;
1592 } 1594 }
@@ -1600,11 +1602,9 @@ static int do_open(struct inode *inode, struct file *filp)
1600 struct apm_user *as; 1602 struct apm_user *as;
1601 1603
1602 as = kmalloc(sizeof(*as), GFP_KERNEL); 1604 as = kmalloc(sizeof(*as), GFP_KERNEL);
1603 if (as == NULL) { 1605 if (as == NULL)
1604 printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n",
1605 sizeof(*as));
1606 return -ENOMEM; 1606 return -ENOMEM;
1607 } 1607
1608 as->magic = APM_BIOS_MAGIC; 1608 as->magic = APM_BIOS_MAGIC;
1609 as->event_tail = as->event_head = 0; 1609 as->event_tail = as->event_head = 0;
1610 as->suspends_pending = as->standbys_pending = 0; 1610 as->suspends_pending = as->standbys_pending = 0;
@@ -2313,16 +2313,16 @@ static int __init apm_init(void)
2313 } 2313 }
2314 2314
2315 if (apm_info.disabled) { 2315 if (apm_info.disabled) {
2316 printk(KERN_NOTICE "apm: disabled on user request.\n"); 2316 pr_notice("disabled on user request.\n");
2317 return -ENODEV; 2317 return -ENODEV;
2318 } 2318 }
2319 if ((num_online_cpus() > 1) && !power_off && !smp) { 2319 if ((num_online_cpus() > 1) && !power_off && !smp) {
2320 printk(KERN_NOTICE "apm: disabled - APM is not SMP safe.\n"); 2320 pr_notice("disabled - APM is not SMP safe.\n");
2321 apm_info.disabled = 1; 2321 apm_info.disabled = 1;
2322 return -ENODEV; 2322 return -ENODEV;
2323 } 2323 }
2324 if (!acpi_disabled) { 2324 if (!acpi_disabled) {
2325 printk(KERN_NOTICE "apm: overridden by ACPI.\n"); 2325 pr_notice("overridden by ACPI.\n");
2326 apm_info.disabled = 1; 2326 apm_info.disabled = 1;
2327 return -ENODEV; 2327 return -ENODEV;
2328 } 2328 }
@@ -2356,8 +2356,7 @@ static int __init apm_init(void)
2356 2356
2357 kapmd_task = kthread_create(apm, NULL, "kapmd"); 2357 kapmd_task = kthread_create(apm, NULL, "kapmd");
2358 if (IS_ERR(kapmd_task)) { 2358 if (IS_ERR(kapmd_task)) {
2359 printk(KERN_ERR "apm: disabled - Unable to start kernel " 2359 pr_err("disabled - Unable to start kernel thread\n");
2360 "thread.\n");
2361 err = PTR_ERR(kapmd_task); 2360 err = PTR_ERR(kapmd_task);
2362 kapmd_task = NULL; 2361 kapmd_task = NULL;
2363 remove_proc_entry("apm", NULL); 2362 remove_proc_entry("apm", NULL);
diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
index 6ab6aa2fdfd..d30a6a9a012 100644
--- a/arch/x86/kernel/cpu/Makefile
+++ b/arch/x86/kernel/cpu/Makefile
@@ -14,7 +14,7 @@ CFLAGS_common.o := $(nostackp)
14 14
15obj-y := intel_cacheinfo.o scattered.o topology.o 15obj-y := intel_cacheinfo.o scattered.o topology.o
16obj-y += proc.o capflags.o powerflags.o common.o 16obj-y += proc.o capflags.o powerflags.o common.o
17obj-y += vmware.o hypervisor.o sched.o mshyperv.o 17obj-y += vmware.o hypervisor.o mshyperv.o
18obj-y += rdrand.o 18obj-y += rdrand.o
19obj-y += match.o 19obj-y += match.o
20 20
@@ -32,7 +32,9 @@ obj-$(CONFIG_PERF_EVENTS) += perf_event.o
32 32
33ifdef CONFIG_PERF_EVENTS 33ifdef CONFIG_PERF_EVENTS
34obj-$(CONFIG_CPU_SUP_AMD) += perf_event_amd.o 34obj-$(CONFIG_CPU_SUP_AMD) += perf_event_amd.o
35obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_p6.o perf_event_p4.o perf_event_intel_lbr.o perf_event_intel_ds.o perf_event_intel.o 35obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_p6.o perf_event_p4.o
36obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_lbr.o perf_event_intel_ds.o perf_event_intel.o
37obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_uncore.o
36endif 38endif
37 39
38obj-$(CONFIG_X86_MCE) += mcheck/ 40obj-$(CONFIG_X86_MCE) += mcheck/
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 146bb6218ee..9d92e19039f 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -19,6 +19,39 @@
19 19
20#include "cpu.h" 20#include "cpu.h"
21 21
22static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p)
23{
24 struct cpuinfo_x86 *c = &cpu_data(smp_processor_id());
25 u32 gprs[8] = { 0 };
26 int err;
27
28 WARN_ONCE((c->x86 != 0xf), "%s should only be used on K8!\n", __func__);
29
30 gprs[1] = msr;
31 gprs[7] = 0x9c5a203a;
32
33 err = rdmsr_safe_regs(gprs);
34
35 *p = gprs[0] | ((u64)gprs[2] << 32);
36
37 return err;
38}
39
40static inline int wrmsrl_amd_safe(unsigned msr, unsigned long long val)
41{
42 struct cpuinfo_x86 *c = &cpu_data(smp_processor_id());
43 u32 gprs[8] = { 0 };
44
45 WARN_ONCE((c->x86 != 0xf), "%s should only be used on K8!\n", __func__);
46
47 gprs[0] = (u32)val;
48 gprs[1] = msr;
49 gprs[2] = val >> 32;
50 gprs[7] = 0x9c5a203a;
51
52 return wrmsr_safe_regs(gprs);
53}
54
22#ifdef CONFIG_X86_32 55#ifdef CONFIG_X86_32
23/* 56/*
24 * B step AMD K6 before B 9730xxxx have hardware bugs that can cause 57 * B step AMD K6 before B 9730xxxx have hardware bugs that can cause
@@ -586,9 +619,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
586 !cpu_has(c, X86_FEATURE_TOPOEXT)) { 619 !cpu_has(c, X86_FEATURE_TOPOEXT)) {
587 u64 val; 620 u64 val;
588 621
589 if (!rdmsrl_amd_safe(0xc0011005, &val)) { 622 if (!rdmsrl_safe(0xc0011005, &val)) {
590 val |= 1ULL << 54; 623 val |= 1ULL << 54;
591 wrmsrl_amd_safe(0xc0011005, val); 624 wrmsrl_safe(0xc0011005, val);
592 rdmsrl(0xc0011005, val); 625 rdmsrl(0xc0011005, val);
593 if (val & (1ULL << 54)) { 626 if (val & (1ULL << 54)) {
594 set_cpu_cap(c, X86_FEATURE_TOPOEXT); 627 set_cpu_cap(c, X86_FEATURE_TOPOEXT);
@@ -679,7 +712,7 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
679 err = rdmsrl_safe(MSR_AMD64_MCx_MASK(4), &mask); 712 err = rdmsrl_safe(MSR_AMD64_MCx_MASK(4), &mask);
680 if (err == 0) { 713 if (err == 0) {
681 mask |= (1 << 10); 714 mask |= (1 << 10);
682 checking_wrmsrl(MSR_AMD64_MCx_MASK(4), mask); 715 wrmsrl_safe(MSR_AMD64_MCx_MASK(4), mask);
683 } 716 }
684 } 717 }
685 718
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 46674fbb62b..c97bb7b5a9f 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -55,8 +55,8 @@ static void __init check_fpu(void)
55 55
56 if (!boot_cpu_data.hard_math) { 56 if (!boot_cpu_data.hard_math) {
57#ifndef CONFIG_MATH_EMULATION 57#ifndef CONFIG_MATH_EMULATION
58 printk(KERN_EMERG "No coprocessor found and no math emulation present.\n"); 58 pr_emerg("No coprocessor found and no math emulation present\n");
59 printk(KERN_EMERG "Giving up.\n"); 59 pr_emerg("Giving up\n");
60 for (;;) ; 60 for (;;) ;
61#endif 61#endif
62 return; 62 return;
@@ -86,7 +86,7 @@ static void __init check_fpu(void)
86 86
87 boot_cpu_data.fdiv_bug = fdiv_bug; 87 boot_cpu_data.fdiv_bug = fdiv_bug;
88 if (boot_cpu_data.fdiv_bug) 88 if (boot_cpu_data.fdiv_bug)
89 printk(KERN_WARNING "Hmm, FPU with FDIV bug.\n"); 89 pr_warn("Hmm, FPU with FDIV bug\n");
90} 90}
91 91
92static void __init check_hlt(void) 92static void __init check_hlt(void)
@@ -94,16 +94,16 @@ static void __init check_hlt(void)
94 if (boot_cpu_data.x86 >= 5 || paravirt_enabled()) 94 if (boot_cpu_data.x86 >= 5 || paravirt_enabled())
95 return; 95 return;
96 96
97 printk(KERN_INFO "Checking 'hlt' instruction... "); 97 pr_info("Checking 'hlt' instruction... ");
98 if (!boot_cpu_data.hlt_works_ok) { 98 if (!boot_cpu_data.hlt_works_ok) {
99 printk("disabled\n"); 99 pr_cont("disabled\n");
100 return; 100 return;
101 } 101 }
102 halt(); 102 halt();
103 halt(); 103 halt();
104 halt(); 104 halt();
105 halt(); 105 halt();
106 printk(KERN_CONT "OK.\n"); 106 pr_cont("OK\n");
107} 107}
108 108
109/* 109/*
@@ -116,7 +116,7 @@ static void __init check_popad(void)
116#ifndef CONFIG_X86_POPAD_OK 116#ifndef CONFIG_X86_POPAD_OK
117 int res, inp = (int) &res; 117 int res, inp = (int) &res;
118 118
119 printk(KERN_INFO "Checking for popad bug... "); 119 pr_info("Checking for popad bug... ");
120 __asm__ __volatile__( 120 __asm__ __volatile__(
121 "movl $12345678,%%eax; movl $0,%%edi; pusha; popa; movl (%%edx,%%edi),%%ecx " 121 "movl $12345678,%%eax; movl $0,%%edi; pusha; popa; movl (%%edx,%%edi),%%ecx "
122 : "=&a" (res) 122 : "=&a" (res)
@@ -127,9 +127,9 @@ static void __init check_popad(void)
127 * CPU hard. Too bad. 127 * CPU hard. Too bad.
128 */ 128 */
129 if (res != 12345678) 129 if (res != 12345678)
130 printk(KERN_CONT "Buggy.\n"); 130 pr_cont("Buggy\n");
131 else 131 else
132 printk(KERN_CONT "OK.\n"); 132 pr_cont("OK\n");
133#endif 133#endif
134} 134}
135 135
@@ -161,7 +161,7 @@ void __init check_bugs(void)
161{ 161{
162 identify_boot_cpu(); 162 identify_boot_cpu();
163#ifndef CONFIG_SMP 163#ifndef CONFIG_SMP
164 printk(KERN_INFO "CPU: "); 164 pr_info("CPU: ");
165 print_cpu_info(&boot_cpu_data); 165 print_cpu_info(&boot_cpu_data);
166#endif 166#endif
167 check_config(); 167 check_config();
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 6b9333b429b..a5fbc3c5fcc 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -144,6 +144,8 @@ static int __init x86_xsave_setup(char *s)
144{ 144{
145 setup_clear_cpu_cap(X86_FEATURE_XSAVE); 145 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
146 setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT); 146 setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
147 setup_clear_cpu_cap(X86_FEATURE_AVX);
148 setup_clear_cpu_cap(X86_FEATURE_AVX2);
147 return 1; 149 return 1;
148} 150}
149__setup("noxsave", x86_xsave_setup); 151__setup("noxsave", x86_xsave_setup);
@@ -452,6 +454,35 @@ void __cpuinit cpu_detect_cache_sizes(struct cpuinfo_x86 *c)
452 c->x86_cache_size = l2size; 454 c->x86_cache_size = l2size;
453} 455}
454 456
457u16 __read_mostly tlb_lli_4k[NR_INFO];
458u16 __read_mostly tlb_lli_2m[NR_INFO];
459u16 __read_mostly tlb_lli_4m[NR_INFO];
460u16 __read_mostly tlb_lld_4k[NR_INFO];
461u16 __read_mostly tlb_lld_2m[NR_INFO];
462u16 __read_mostly tlb_lld_4m[NR_INFO];
463
464/*
465 * tlb_flushall_shift shows the balance point in replacing cr3 write
466 * with multiple 'invlpg'. It will do this replacement when
467 * flush_tlb_lines <= active_lines/2^tlb_flushall_shift.
468 * If tlb_flushall_shift is -1, means the replacement will be disabled.
469 */
470s8 __read_mostly tlb_flushall_shift = -1;
471
472void __cpuinit cpu_detect_tlb(struct cpuinfo_x86 *c)
473{
474 if (this_cpu->c_detect_tlb)
475 this_cpu->c_detect_tlb(c);
476
477 printk(KERN_INFO "Last level iTLB entries: 4KB %d, 2MB %d, 4MB %d\n" \
478 "Last level dTLB entries: 4KB %d, 2MB %d, 4MB %d\n" \
479 "tlb_flushall_shift is 0x%x\n",
480 tlb_lli_4k[ENTRIES], tlb_lli_2m[ENTRIES],
481 tlb_lli_4m[ENTRIES], tlb_lld_4k[ENTRIES],
482 tlb_lld_2m[ENTRIES], tlb_lld_4m[ENTRIES],
483 tlb_flushall_shift);
484}
485
455void __cpuinit detect_ht(struct cpuinfo_x86 *c) 486void __cpuinit detect_ht(struct cpuinfo_x86 *c)
456{ 487{
457#ifdef CONFIG_X86_HT 488#ifdef CONFIG_X86_HT
@@ -911,6 +942,8 @@ void __init identify_boot_cpu(void)
911#else 942#else
912 vgetcpu_set_mode(); 943 vgetcpu_set_mode();
913#endif 944#endif
945 if (boot_cpu_data.cpuid_level >= 2)
946 cpu_detect_tlb(&boot_cpu_data);
914} 947}
915 948
916void __cpuinit identify_secondary_cpu(struct cpuinfo_x86 *c) 949void __cpuinit identify_secondary_cpu(struct cpuinfo_x86 *c)
@@ -947,7 +980,7 @@ static void __cpuinit __print_cpu_msr(void)
947 index_max = msr_range_array[i].max; 980 index_max = msr_range_array[i].max;
948 981
949 for (index = index_min; index < index_max; index++) { 982 for (index = index_min; index < index_max; index++) {
950 if (rdmsrl_amd_safe(index, &val)) 983 if (rdmsrl_safe(index, &val))
951 continue; 984 continue;
952 printk(KERN_INFO " MSR%08x: %016llx\n", index, val); 985 printk(KERN_INFO " MSR%08x: %016llx\n", index, val);
953 } 986 }
diff --git a/arch/x86/kernel/cpu/cpu.h b/arch/x86/kernel/cpu/cpu.h
index 8bacc7826fb..4041c24ae7d 100644
--- a/arch/x86/kernel/cpu/cpu.h
+++ b/arch/x86/kernel/cpu/cpu.h
@@ -20,10 +20,19 @@ struct cpu_dev {
20 void (*c_bsp_init)(struct cpuinfo_x86 *); 20 void (*c_bsp_init)(struct cpuinfo_x86 *);
21 void (*c_init)(struct cpuinfo_x86 *); 21 void (*c_init)(struct cpuinfo_x86 *);
22 void (*c_identify)(struct cpuinfo_x86 *); 22 void (*c_identify)(struct cpuinfo_x86 *);
23 void (*c_detect_tlb)(struct cpuinfo_x86 *);
23 unsigned int (*c_size_cache)(struct cpuinfo_x86 *, unsigned int); 24 unsigned int (*c_size_cache)(struct cpuinfo_x86 *, unsigned int);
24 int c_x86_vendor; 25 int c_x86_vendor;
25}; 26};
26 27
28struct _tlb_table {
29 unsigned char descriptor;
30 char tlb_type;
31 unsigned int entries;
32 /* unsigned int ways; */
33 char info[128];
34};
35
27#define cpu_dev_register(cpu_devX) \ 36#define cpu_dev_register(cpu_devX) \
28 static const struct cpu_dev *const __cpu_dev_##cpu_devX __used \ 37 static const struct cpu_dev *const __cpu_dev_##cpu_devX __used \
29 __attribute__((__section__(".x86_cpu_dev.init"))) = \ 38 __attribute__((__section__(".x86_cpu_dev.init"))) = \
diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
index 755f64fb074..a8f8fa9769d 100644
--- a/arch/x86/kernel/cpu/hypervisor.c
+++ b/arch/x86/kernel/cpu/hypervisor.c
@@ -37,6 +37,9 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =
37#endif 37#endif
38 &x86_hyper_vmware, 38 &x86_hyper_vmware,
39 &x86_hyper_ms_hyperv, 39 &x86_hyper_ms_hyperv,
40#ifdef CONFIG_KVM_GUEST
41 &x86_hyper_kvm,
42#endif
40}; 43};
41 44
42const struct hypervisor_x86 *x86_hyper; 45const struct hypervisor_x86 *x86_hyper;
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 3e6ff6cbf42..0a4ce2980a5 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -491,6 +491,181 @@ static unsigned int __cpuinit intel_size_cache(struct cpuinfo_x86 *c, unsigned i
491} 491}
492#endif 492#endif
493 493
494#define TLB_INST_4K 0x01
495#define TLB_INST_4M 0x02
496#define TLB_INST_2M_4M 0x03
497
498#define TLB_INST_ALL 0x05
499#define TLB_INST_1G 0x06
500
501#define TLB_DATA_4K 0x11
502#define TLB_DATA_4M 0x12
503#define TLB_DATA_2M_4M 0x13
504#define TLB_DATA_4K_4M 0x14
505
506#define TLB_DATA_1G 0x16
507
508#define TLB_DATA0_4K 0x21
509#define TLB_DATA0_4M 0x22
510#define TLB_DATA0_2M_4M 0x23
511
512#define STLB_4K 0x41
513
514static const struct _tlb_table intel_tlb_table[] __cpuinitconst = {
515 { 0x01, TLB_INST_4K, 32, " TLB_INST 4 KByte pages, 4-way set associative" },
516 { 0x02, TLB_INST_4M, 2, " TLB_INST 4 MByte pages, full associative" },
517 { 0x03, TLB_DATA_4K, 64, " TLB_DATA 4 KByte pages, 4-way set associative" },
518 { 0x04, TLB_DATA_4M, 8, " TLB_DATA 4 MByte pages, 4-way set associative" },
519 { 0x05, TLB_DATA_4M, 32, " TLB_DATA 4 MByte pages, 4-way set associative" },
520 { 0x0b, TLB_INST_4M, 4, " TLB_INST 4 MByte pages, 4-way set associative" },
521 { 0x4f, TLB_INST_4K, 32, " TLB_INST 4 KByte pages */" },
522 { 0x50, TLB_INST_ALL, 64, " TLB_INST 4 KByte and 2-MByte or 4-MByte pages" },
523 { 0x51, TLB_INST_ALL, 128, " TLB_INST 4 KByte and 2-MByte or 4-MByte pages" },
524 { 0x52, TLB_INST_ALL, 256, " TLB_INST 4 KByte and 2-MByte or 4-MByte pages" },
525 { 0x55, TLB_INST_2M_4M, 7, " TLB_INST 2-MByte or 4-MByte pages, fully associative" },
526 { 0x56, TLB_DATA0_4M, 16, " TLB_DATA0 4 MByte pages, 4-way set associative" },
527 { 0x57, TLB_DATA0_4K, 16, " TLB_DATA0 4 KByte pages, 4-way associative" },
528 { 0x59, TLB_DATA0_4K, 16, " TLB_DATA0 4 KByte pages, fully associative" },
529 { 0x5a, TLB_DATA0_2M_4M, 32, " TLB_DATA0 2-MByte or 4 MByte pages, 4-way set associative" },
530 { 0x5b, TLB_DATA_4K_4M, 64, " TLB_DATA 4 KByte and 4 MByte pages" },
531 { 0x5c, TLB_DATA_4K_4M, 128, " TLB_DATA 4 KByte and 4 MByte pages" },
532 { 0x5d, TLB_DATA_4K_4M, 256, " TLB_DATA 4 KByte and 4 MByte pages" },
533 { 0xb0, TLB_INST_4K, 128, " TLB_INST 4 KByte pages, 4-way set associative" },
534 { 0xb1, TLB_INST_2M_4M, 4, " TLB_INST 2M pages, 4-way, 8 entries or 4M pages, 4-way entries" },
535 { 0xb2, TLB_INST_4K, 64, " TLB_INST 4KByte pages, 4-way set associative" },
536 { 0xb3, TLB_DATA_4K, 128, " TLB_DATA 4 KByte pages, 4-way set associative" },
537 { 0xb4, TLB_DATA_4K, 256, " TLB_DATA 4 KByte pages, 4-way associative" },
538 { 0xba, TLB_DATA_4K, 64, " TLB_DATA 4 KByte pages, 4-way associative" },
539 { 0xc0, TLB_DATA_4K_4M, 8, " TLB_DATA 4 KByte and 4 MByte pages, 4-way associative" },
540 { 0xca, STLB_4K, 512, " STLB 4 KByte pages, 4-way associative" },
541 { 0x00, 0, 0 }
542};
543
544static void __cpuinit intel_tlb_lookup(const unsigned char desc)
545{
546 unsigned char k;
547 if (desc == 0)
548 return;
549
550 /* look up this descriptor in the table */
551 for (k = 0; intel_tlb_table[k].descriptor != desc && \
552 intel_tlb_table[k].descriptor != 0; k++)
553 ;
554
555 if (intel_tlb_table[k].tlb_type == 0)
556 return;
557
558 switch (intel_tlb_table[k].tlb_type) {
559 case STLB_4K:
560 if (tlb_lli_4k[ENTRIES] < intel_tlb_table[k].entries)
561 tlb_lli_4k[ENTRIES] = intel_tlb_table[k].entries;
562 if (tlb_lld_4k[ENTRIES] < intel_tlb_table[k].entries)
563 tlb_lld_4k[ENTRIES] = intel_tlb_table[k].entries;
564 break;
565 case TLB_INST_ALL:
566 if (tlb_lli_4k[ENTRIES] < intel_tlb_table[k].entries)
567 tlb_lli_4k[ENTRIES] = intel_tlb_table[k].entries;
568 if (tlb_lli_2m[ENTRIES] < intel_tlb_table[k].entries)
569 tlb_lli_2m[ENTRIES] = intel_tlb_table[k].entries;
570 if (tlb_lli_4m[ENTRIES] < intel_tlb_table[k].entries)
571 tlb_lli_4m[ENTRIES] = intel_tlb_table[k].entries;
572 break;
573 case TLB_INST_4K:
574 if (tlb_lli_4k[ENTRIES] < intel_tlb_table[k].entries)
575 tlb_lli_4k[ENTRIES] = intel_tlb_table[k].entries;
576 break;
577 case TLB_INST_4M:
578 if (tlb_lli_4m[ENTRIES] < intel_tlb_table[k].entries)
579 tlb_lli_4m[ENTRIES] = intel_tlb_table[k].entries;
580 break;
581 case TLB_INST_2M_4M:
582 if (tlb_lli_2m[ENTRIES] < intel_tlb_table[k].entries)
583 tlb_lli_2m[ENTRIES] = intel_tlb_table[k].entries;
584 if (tlb_lli_4m[ENTRIES] < intel_tlb_table[k].entries)
585 tlb_lli_4m[ENTRIES] = intel_tlb_table[k].entries;
586 break;
587 case TLB_DATA_4K:
588 case TLB_DATA0_4K:
589 if (tlb_lld_4k[ENTRIES] < intel_tlb_table[k].entries)
590 tlb_lld_4k[ENTRIES] = intel_tlb_table[k].entries;
591 break;
592 case TLB_DATA_4M:
593 case TLB_DATA0_4M:
594 if (tlb_lld_4m[ENTRIES] < intel_tlb_table[k].entries)
595 tlb_lld_4m[ENTRIES] = intel_tlb_table[k].entries;
596 break;
597 case TLB_DATA_2M_4M:
598 case TLB_DATA0_2M_4M:
599 if (tlb_lld_2m[ENTRIES] < intel_tlb_table[k].entries)
600 tlb_lld_2m[ENTRIES] = intel_tlb_table[k].entries;
601 if (tlb_lld_4m[ENTRIES] < intel_tlb_table[k].entries)
602 tlb_lld_4m[ENTRIES] = intel_tlb_table[k].entries;
603 break;
604 case TLB_DATA_4K_4M:
605 if (tlb_lld_4k[ENTRIES] < intel_tlb_table[k].entries)
606 tlb_lld_4k[ENTRIES] = intel_tlb_table[k].entries;
607 if (tlb_lld_4m[ENTRIES] < intel_tlb_table[k].entries)
608 tlb_lld_4m[ENTRIES] = intel_tlb_table[k].entries;
609 break;
610 }
611}
612
613static void __cpuinit intel_tlb_flushall_shift_set(struct cpuinfo_x86 *c)
614{
615 if (!cpu_has_invlpg) {
616 tlb_flushall_shift = -1;
617 return;
618 }
619 switch ((c->x86 << 8) + c->x86_model) {
620 case 0x60f: /* original 65 nm celeron/pentium/core2/xeon, "Merom"/"Conroe" */
621 case 0x616: /* single-core 65 nm celeron/core2solo "Merom-L"/"Conroe-L" */
622 case 0x617: /* current 45 nm celeron/core2/xeon "Penryn"/"Wolfdale" */
623 case 0x61d: /* six-core 45 nm xeon "Dunnington" */
624 tlb_flushall_shift = -1;
625 break;
626 case 0x61a: /* 45 nm nehalem, "Bloomfield" */
627 case 0x61e: /* 45 nm nehalem, "Lynnfield" */
628 case 0x625: /* 32 nm nehalem, "Clarkdale" */
629 case 0x62c: /* 32 nm nehalem, "Gulftown" */
630 case 0x62e: /* 45 nm nehalem-ex, "Beckton" */
631 case 0x62f: /* 32 nm Xeon E7 */
632 tlb_flushall_shift = 6;
633 break;
634 case 0x62a: /* SandyBridge */
635 case 0x62d: /* SandyBridge, "Romely-EP" */
636 tlb_flushall_shift = 5;
637 break;
638 case 0x63a: /* Ivybridge */
639 tlb_flushall_shift = 1;
640 break;
641 default:
642 tlb_flushall_shift = 6;
643 }
644}
645
646static void __cpuinit intel_detect_tlb(struct cpuinfo_x86 *c)
647{
648 int i, j, n;
649 unsigned int regs[4];
650 unsigned char *desc = (unsigned char *)regs;
651 /* Number of times to iterate */
652 n = cpuid_eax(2) & 0xFF;
653
654 for (i = 0 ; i < n ; i++) {
655 cpuid(2, &regs[0], &regs[1], &regs[2], &regs[3]);
656
657 /* If bit 31 is set, this is an unknown format */
658 for (j = 0 ; j < 3 ; j++)
659 if (regs[j] & (1 << 31))
660 regs[j] = 0;
661
662 /* Byte 0 is level count, not a descriptor */
663 for (j = 1 ; j < 16 ; j++)
664 intel_tlb_lookup(desc[j]);
665 }
666 intel_tlb_flushall_shift_set(c);
667}
668
494static const struct cpu_dev __cpuinitconst intel_cpu_dev = { 669static const struct cpu_dev __cpuinitconst intel_cpu_dev = {
495 .c_vendor = "Intel", 670 .c_vendor = "Intel",
496 .c_ident = { "GenuineIntel" }, 671 .c_ident = { "GenuineIntel" },
@@ -546,6 +721,7 @@ static const struct cpu_dev __cpuinitconst intel_cpu_dev = {
546 }, 721 },
547 .c_size_cache = intel_size_cache, 722 .c_size_cache = intel_size_cache,
548#endif 723#endif
724 .c_detect_tlb = intel_detect_tlb,
549 .c_early_init = early_init_intel, 725 .c_early_init = early_init_intel,
550 .c_init = init_intel, 726 .c_init = init_intel,
551 .c_x86_vendor = X86_VENDOR_INTEL, 727 .c_x86_vendor = X86_VENDOR_INTEL,
diff --git a/arch/x86/kernel/cpu/mcheck/mce-severity.c b/arch/x86/kernel/cpu/mcheck/mce-severity.c
index 413c2ced887..13017626f9a 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-severity.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-severity.c
@@ -55,13 +55,6 @@ static struct severity {
55#define MCI_UC_S (MCI_STATUS_UC|MCI_STATUS_S) 55#define MCI_UC_S (MCI_STATUS_UC|MCI_STATUS_S)
56#define MCI_UC_SAR (MCI_STATUS_UC|MCI_STATUS_S|MCI_STATUS_AR) 56#define MCI_UC_SAR (MCI_STATUS_UC|MCI_STATUS_S|MCI_STATUS_AR)
57#define MCI_ADDR (MCI_STATUS_ADDRV|MCI_STATUS_MISCV) 57#define MCI_ADDR (MCI_STATUS_ADDRV|MCI_STATUS_MISCV)
58#define MCACOD 0xffff
59/* Architecturally defined codes from SDM Vol. 3B Chapter 15 */
60#define MCACOD_SCRUB 0x00C0 /* 0xC0-0xCF Memory Scrubbing */
61#define MCACOD_SCRUBMSK 0xfff0
62#define MCACOD_L3WB 0x017A /* L3 Explicit Writeback */
63#define MCACOD_DATA 0x0134 /* Data Load */
64#define MCACOD_INSTR 0x0150 /* Instruction Fetch */
65 58
66 MCESEV( 59 MCESEV(
67 NO, "Invalid", 60 NO, "Invalid",
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index da27c5d2168..292d0258311 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -7,6 +7,9 @@
7 * Copyright 2008 Intel Corporation 7 * Copyright 2008 Intel Corporation
8 * Author: Andi Kleen 8 * Author: Andi Kleen
9 */ 9 */
10
11#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
12
10#include <linux/thread_info.h> 13#include <linux/thread_info.h>
11#include <linux/capability.h> 14#include <linux/capability.h>
12#include <linux/miscdevice.h> 15#include <linux/miscdevice.h>
@@ -57,8 +60,6 @@ static DEFINE_MUTEX(mce_chrdev_read_mutex);
57 60
58int mce_disabled __read_mostly; 61int mce_disabled __read_mostly;
59 62
60#define MISC_MCELOG_MINOR 227
61
62#define SPINUNIT 100 /* 100ns */ 63#define SPINUNIT 100 /* 100ns */
63 64
64atomic_t mce_entry; 65atomic_t mce_entry;
@@ -102,6 +103,8 @@ DEFINE_PER_CPU(mce_banks_t, mce_poll_banks) = {
102 103
103static DEFINE_PER_CPU(struct work_struct, mce_work); 104static DEFINE_PER_CPU(struct work_struct, mce_work);
104 105
106static void (*quirk_no_way_out)(int bank, struct mce *m, struct pt_regs *regs);
107
105/* 108/*
106 * CPU/chipset specific EDAC code can register a notifier call here to print 109 * CPU/chipset specific EDAC code can register a notifier call here to print
107 * MCE errors in a human-readable form. 110 * MCE errors in a human-readable form.
@@ -210,7 +213,7 @@ static void drain_mcelog_buffer(void)
210 cpu_relax(); 213 cpu_relax();
211 214
212 if (!m->finished && retries >= 4) { 215 if (!m->finished && retries >= 4) {
213 pr_err("MCE: skipping error being logged currently!\n"); 216 pr_err("skipping error being logged currently!\n");
214 break; 217 break;
215 } 218 }
216 } 219 }
@@ -649,14 +652,18 @@ EXPORT_SYMBOL_GPL(machine_check_poll);
649 * Do a quick check if any of the events requires a panic. 652 * Do a quick check if any of the events requires a panic.
650 * This decides if we keep the events around or clear them. 653 * This decides if we keep the events around or clear them.
651 */ 654 */
652static int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp) 655static int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp,
656 struct pt_regs *regs)
653{ 657{
654 int i, ret = 0; 658 int i, ret = 0;
655 659
656 for (i = 0; i < banks; i++) { 660 for (i = 0; i < banks; i++) {
657 m->status = mce_rdmsrl(MSR_IA32_MCx_STATUS(i)); 661 m->status = mce_rdmsrl(MSR_IA32_MCx_STATUS(i));
658 if (m->status & MCI_STATUS_VAL) 662 if (m->status & MCI_STATUS_VAL) {
659 __set_bit(i, validp); 663 __set_bit(i, validp);
664 if (quirk_no_way_out)
665 quirk_no_way_out(i, m, regs);
666 }
660 if (mce_severity(m, tolerant, msg) >= MCE_PANIC_SEVERITY) 667 if (mce_severity(m, tolerant, msg) >= MCE_PANIC_SEVERITY)
661 ret = 1; 668 ret = 1;
662 } 669 }
@@ -1039,7 +1046,7 @@ void do_machine_check(struct pt_regs *regs, long error_code)
1039 *final = m; 1046 *final = m;
1040 1047
1041 memset(valid_banks, 0, sizeof(valid_banks)); 1048 memset(valid_banks, 0, sizeof(valid_banks));
1042 no_way_out = mce_no_way_out(&m, &msg, valid_banks); 1049 no_way_out = mce_no_way_out(&m, &msg, valid_banks, regs);
1043 1050
1044 barrier(); 1051 barrier();
1045 1052
@@ -1167,8 +1174,9 @@ int memory_failure(unsigned long pfn, int vector, int flags)
1167{ 1174{
1168 /* mce_severity() should not hand us an ACTION_REQUIRED error */ 1175 /* mce_severity() should not hand us an ACTION_REQUIRED error */
1169 BUG_ON(flags & MF_ACTION_REQUIRED); 1176 BUG_ON(flags & MF_ACTION_REQUIRED);
1170 printk(KERN_ERR "Uncorrected memory error in page 0x%lx ignored\n" 1177 pr_err("Uncorrected memory error in page 0x%lx ignored\n"
1171 "Rebuild kernel with CONFIG_MEMORY_FAILURE=y for smarter handling\n", pfn); 1178 "Rebuild kernel with CONFIG_MEMORY_FAILURE=y for smarter handling\n",
1179 pfn);
1172 1180
1173 return 0; 1181 return 0;
1174} 1182}
@@ -1186,6 +1194,7 @@ void mce_notify_process(void)
1186{ 1194{
1187 unsigned long pfn; 1195 unsigned long pfn;
1188 struct mce_info *mi = mce_find_info(); 1196 struct mce_info *mi = mce_find_info();
1197 int flags = MF_ACTION_REQUIRED;
1189 1198
1190 if (!mi) 1199 if (!mi)
1191 mce_panic("Lost physical address for unconsumed uncorrectable error", NULL, NULL); 1200 mce_panic("Lost physical address for unconsumed uncorrectable error", NULL, NULL);
@@ -1200,8 +1209,9 @@ void mce_notify_process(void)
1200 * doomed. We still need to mark the page as poisoned and alert any 1209 * doomed. We still need to mark the page as poisoned and alert any
1201 * other users of the page. 1210 * other users of the page.
1202 */ 1211 */
1203 if (memory_failure(pfn, MCE_VECTOR, MF_ACTION_REQUIRED) < 0 || 1212 if (!mi->restartable)
1204 mi->restartable == 0) { 1213 flags |= MF_MUST_KILL;
1214 if (memory_failure(pfn, MCE_VECTOR, flags) < 0) {
1205 pr_err("Memory error not recovered"); 1215 pr_err("Memory error not recovered");
1206 force_sig(SIGBUS, current); 1216 force_sig(SIGBUS, current);
1207 } 1217 }
@@ -1358,11 +1368,10 @@ static int __cpuinit __mcheck_cpu_cap_init(void)
1358 1368
1359 b = cap & MCG_BANKCNT_MASK; 1369 b = cap & MCG_BANKCNT_MASK;
1360 if (!banks) 1370 if (!banks)
1361 printk(KERN_INFO "mce: CPU supports %d MCE banks\n", b); 1371 pr_info("CPU supports %d MCE banks\n", b);
1362 1372
1363 if (b > MAX_NR_BANKS) { 1373 if (b > MAX_NR_BANKS) {
1364 printk(KERN_WARNING 1374 pr_warn("Using only %u machine check banks out of %u\n",
1365 "MCE: Using only %u machine check banks out of %u\n",
1366 MAX_NR_BANKS, b); 1375 MAX_NR_BANKS, b);
1367 b = MAX_NR_BANKS; 1376 b = MAX_NR_BANKS;
1368 } 1377 }
@@ -1415,11 +1424,39 @@ static void __mcheck_cpu_init_generic(void)
1415 } 1424 }
1416} 1425}
1417 1426
1427/*
1428 * During IFU recovery Sandy Bridge -EP4S processors set the RIPV and
1429 * EIPV bits in MCG_STATUS to zero on the affected logical processor (SDM
1430 * Vol 3B Table 15-20). But this confuses both the code that determines
1431 * whether the machine check occurred in kernel or user mode, and also
1432 * the severity assessment code. Pretend that EIPV was set, and take the
1433 * ip/cs values from the pt_regs that mce_gather_info() ignored earlier.
1434 */
1435static void quirk_sandybridge_ifu(int bank, struct mce *m, struct pt_regs *regs)
1436{
1437 if (bank != 0)
1438 return;
1439 if ((m->mcgstatus & (MCG_STATUS_EIPV|MCG_STATUS_RIPV)) != 0)
1440 return;
1441 if ((m->status & (MCI_STATUS_OVER|MCI_STATUS_UC|
1442 MCI_STATUS_EN|MCI_STATUS_MISCV|MCI_STATUS_ADDRV|
1443 MCI_STATUS_PCC|MCI_STATUS_S|MCI_STATUS_AR|
1444 MCACOD)) !=
1445 (MCI_STATUS_UC|MCI_STATUS_EN|
1446 MCI_STATUS_MISCV|MCI_STATUS_ADDRV|MCI_STATUS_S|
1447 MCI_STATUS_AR|MCACOD_INSTR))
1448 return;
1449
1450 m->mcgstatus |= MCG_STATUS_EIPV;
1451 m->ip = regs->ip;
1452 m->cs = regs->cs;
1453}
1454
1418/* Add per CPU specific workarounds here */ 1455/* Add per CPU specific workarounds here */
1419static int __cpuinit __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c) 1456static int __cpuinit __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
1420{ 1457{
1421 if (c->x86_vendor == X86_VENDOR_UNKNOWN) { 1458 if (c->x86_vendor == X86_VENDOR_UNKNOWN) {
1422 pr_info("MCE: unknown CPU type - not enabling MCE support.\n"); 1459 pr_info("unknown CPU type - not enabling MCE support\n");
1423 return -EOPNOTSUPP; 1460 return -EOPNOTSUPP;
1424 } 1461 }
1425 1462
@@ -1512,6 +1549,9 @@ static int __cpuinit __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
1512 */ 1549 */
1513 if (c->x86 == 6 && c->x86_model <= 13 && mce_bootlog < 0) 1550 if (c->x86 == 6 && c->x86_model <= 13 && mce_bootlog < 0)
1514 mce_bootlog = 0; 1551 mce_bootlog = 0;
1552
1553 if (c->x86 == 6 && c->x86_model == 45)
1554 quirk_no_way_out = quirk_sandybridge_ifu;
1515 } 1555 }
1516 if (monarch_timeout < 0) 1556 if (monarch_timeout < 0)
1517 monarch_timeout = 0; 1557 monarch_timeout = 0;
@@ -1574,7 +1614,7 @@ static void __mcheck_cpu_init_timer(void)
1574/* Handle unconfigured int18 (should never happen) */ 1614/* Handle unconfigured int18 (should never happen) */
1575static void unexpected_machine_check(struct pt_regs *regs, long error_code) 1615static void unexpected_machine_check(struct pt_regs *regs, long error_code)
1576{ 1616{
1577 printk(KERN_ERR "CPU#%d: Unexpected int18 (Machine Check).\n", 1617 pr_err("CPU#%d: Unexpected int18 (Machine Check)\n",
1578 smp_processor_id()); 1618 smp_processor_id());
1579} 1619}
1580 1620
@@ -1893,8 +1933,7 @@ static int __init mcheck_enable(char *str)
1893 get_option(&str, &monarch_timeout); 1933 get_option(&str, &monarch_timeout);
1894 } 1934 }
1895 } else { 1935 } else {
1896 printk(KERN_INFO "mce argument %s ignored. Please use /sys\n", 1936 pr_info("mce argument %s ignored. Please use /sys\n", str);
1897 str);
1898 return 0; 1937 return 0;
1899 } 1938 }
1900 return 1; 1939 return 1;
@@ -2342,7 +2381,7 @@ static __init int mcheck_init_device(void)
2342 2381
2343 return err; 2382 return err;
2344} 2383}
2345device_initcall(mcheck_init_device); 2384device_initcall_sync(mcheck_init_device);
2346 2385
2347/* 2386/*
2348 * Old style boot options parsing. Only for compatibility. 2387 * Old style boot options parsing. Only for compatibility.
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
index f4873a64f46..c4e916d7737 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -1,15 +1,17 @@
1/* 1/*
2 * (c) 2005, 2006 Advanced Micro Devices, Inc. 2 * (c) 2005-2012 Advanced Micro Devices, Inc.
3 * Your use of this code is subject to the terms and conditions of the 3 * Your use of this code is subject to the terms and conditions of the
4 * GNU general public license version 2. See "COPYING" or 4 * GNU general public license version 2. See "COPYING" or
5 * http://www.gnu.org/licenses/gpl.html 5 * http://www.gnu.org/licenses/gpl.html
6 * 6 *
7 * Written by Jacob Shin - AMD, Inc. 7 * Written by Jacob Shin - AMD, Inc.
8 * 8 *
9 * Support : jacob.shin@amd.com 9 * Support: borislav.petkov@amd.com
10 * 10 *
11 * April 2006 11 * April 2006
12 * - added support for AMD Family 0x10 processors 12 * - added support for AMD Family 0x10 processors
13 * May 2012
14 * - major scrubbing
13 * 15 *
14 * All MC4_MISCi registers are shared between multi-cores 16 * All MC4_MISCi registers are shared between multi-cores
15 */ 17 */
@@ -25,6 +27,7 @@
25#include <linux/cpu.h> 27#include <linux/cpu.h>
26#include <linux/smp.h> 28#include <linux/smp.h>
27 29
30#include <asm/amd_nb.h>
28#include <asm/apic.h> 31#include <asm/apic.h>
29#include <asm/idle.h> 32#include <asm/idle.h>
30#include <asm/mce.h> 33#include <asm/mce.h>
@@ -45,23 +48,15 @@
45#define MASK_BLKPTR_LO 0xFF000000 48#define MASK_BLKPTR_LO 0xFF000000
46#define MCG_XBLK_ADDR 0xC0000400 49#define MCG_XBLK_ADDR 0xC0000400
47 50
48struct threshold_block { 51static const char * const th_names[] = {
49 unsigned int block; 52 "load_store",
50 unsigned int bank; 53 "insn_fetch",
51 unsigned int cpu; 54 "combined_unit",
52 u32 address; 55 "",
53 u16 interrupt_enable; 56 "northbridge",
54 bool interrupt_capable; 57 "execution_unit",
55 u16 threshold_limit;
56 struct kobject kobj;
57 struct list_head miscj;
58}; 58};
59 59
60struct threshold_bank {
61 struct kobject *kobj;
62 struct threshold_block *blocks;
63 cpumask_var_t cpus;
64};
65static DEFINE_PER_CPU(struct threshold_bank * [NR_BANKS], threshold_banks); 60static DEFINE_PER_CPU(struct threshold_bank * [NR_BANKS], threshold_banks);
66 61
67static unsigned char shared_bank[NR_BANKS] = { 62static unsigned char shared_bank[NR_BANKS] = {
@@ -84,6 +79,26 @@ struct thresh_restart {
84 u16 old_limit; 79 u16 old_limit;
85}; 80};
86 81
82static const char * const bank4_names(struct threshold_block *b)
83{
84 switch (b->address) {
85 /* MSR4_MISC0 */
86 case 0x00000413:
87 return "dram";
88
89 case 0xc0000408:
90 return "ht_links";
91
92 case 0xc0000409:
93 return "l3_cache";
94
95 default:
96 WARN(1, "Funny MSR: 0x%08x\n", b->address);
97 return "";
98 }
99};
100
101
87static bool lvt_interrupt_supported(unsigned int bank, u32 msr_high_bits) 102static bool lvt_interrupt_supported(unsigned int bank, u32 msr_high_bits)
88{ 103{
89 /* 104 /*
@@ -224,8 +239,6 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c)
224 239
225 if (!block) 240 if (!block)
226 per_cpu(bank_map, cpu) |= (1 << bank); 241 per_cpu(bank_map, cpu) |= (1 << bank);
227 if (shared_bank[bank] && c->cpu_core_id)
228 break;
229 242
230 memset(&b, 0, sizeof(b)); 243 memset(&b, 0, sizeof(b));
231 b.cpu = cpu; 244 b.cpu = cpu;
@@ -326,7 +339,7 @@ struct threshold_attr {
326#define SHOW_FIELDS(name) \ 339#define SHOW_FIELDS(name) \
327static ssize_t show_ ## name(struct threshold_block *b, char *buf) \ 340static ssize_t show_ ## name(struct threshold_block *b, char *buf) \
328{ \ 341{ \
329 return sprintf(buf, "%lx\n", (unsigned long) b->name); \ 342 return sprintf(buf, "%lu\n", (unsigned long) b->name); \
330} 343}
331SHOW_FIELDS(interrupt_enable) 344SHOW_FIELDS(interrupt_enable)
332SHOW_FIELDS(threshold_limit) 345SHOW_FIELDS(threshold_limit)
@@ -377,38 +390,21 @@ store_threshold_limit(struct threshold_block *b, const char *buf, size_t size)
377 return size; 390 return size;
378} 391}
379 392
380struct threshold_block_cross_cpu {
381 struct threshold_block *tb;
382 long retval;
383};
384
385static void local_error_count_handler(void *_tbcc)
386{
387 struct threshold_block_cross_cpu *tbcc = _tbcc;
388 struct threshold_block *b = tbcc->tb;
389 u32 low, high;
390
391 rdmsr(b->address, low, high);
392 tbcc->retval = (high & 0xFFF) - (THRESHOLD_MAX - b->threshold_limit);
393}
394
395static ssize_t show_error_count(struct threshold_block *b, char *buf) 393static ssize_t show_error_count(struct threshold_block *b, char *buf)
396{ 394{
397 struct threshold_block_cross_cpu tbcc = { .tb = b, }; 395 u32 lo, hi;
398 396
399 smp_call_function_single(b->cpu, local_error_count_handler, &tbcc, 1); 397 rdmsr_on_cpu(b->cpu, b->address, &lo, &hi);
400 return sprintf(buf, "%lx\n", tbcc.retval);
401}
402
403static ssize_t store_error_count(struct threshold_block *b,
404 const char *buf, size_t count)
405{
406 struct thresh_restart tr = { .b = b, .reset = 1, .old_limit = 0 };
407 398
408 smp_call_function_single(b->cpu, threshold_restart_bank, &tr, 1); 399 return sprintf(buf, "%u\n", ((hi & THRESHOLD_MAX) -
409 return 1; 400 (THRESHOLD_MAX - b->threshold_limit)));
410} 401}
411 402
403static struct threshold_attr error_count = {
404 .attr = {.name = __stringify(error_count), .mode = 0444 },
405 .show = show_error_count,
406};
407
412#define RW_ATTR(val) \ 408#define RW_ATTR(val) \
413static struct threshold_attr val = { \ 409static struct threshold_attr val = { \
414 .attr = {.name = __stringify(val), .mode = 0644 }, \ 410 .attr = {.name = __stringify(val), .mode = 0644 }, \
@@ -418,7 +414,6 @@ static struct threshold_attr val = { \
418 414
419RW_ATTR(interrupt_enable); 415RW_ATTR(interrupt_enable);
420RW_ATTR(threshold_limit); 416RW_ATTR(threshold_limit);
421RW_ATTR(error_count);
422 417
423static struct attribute *default_attrs[] = { 418static struct attribute *default_attrs[] = {
424 &threshold_limit.attr, 419 &threshold_limit.attr,
@@ -517,7 +512,7 @@ static __cpuinit int allocate_threshold_blocks(unsigned int cpu,
517 512
518 err = kobject_init_and_add(&b->kobj, &threshold_ktype, 513 err = kobject_init_and_add(&b->kobj, &threshold_ktype,
519 per_cpu(threshold_banks, cpu)[bank]->kobj, 514 per_cpu(threshold_banks, cpu)[bank]->kobj,
520 "misc%i", block); 515 (bank == 4 ? bank4_names(b) : th_names[bank]));
521 if (err) 516 if (err)
522 goto out_free; 517 goto out_free;
523recurse: 518recurse:
@@ -548,98 +543,91 @@ out_free:
548 return err; 543 return err;
549} 544}
550 545
551static __cpuinit long 546static __cpuinit int __threshold_add_blocks(struct threshold_bank *b)
552local_allocate_threshold_blocks(int cpu, unsigned int bank)
553{ 547{
554 return allocate_threshold_blocks(cpu, bank, 0, 548 struct list_head *head = &b->blocks->miscj;
555 MSR_IA32_MC0_MISC + bank * 4); 549 struct threshold_block *pos = NULL;
550 struct threshold_block *tmp = NULL;
551 int err = 0;
552
553 err = kobject_add(&b->blocks->kobj, b->kobj, b->blocks->kobj.name);
554 if (err)
555 return err;
556
557 list_for_each_entry_safe(pos, tmp, head, miscj) {
558
559 err = kobject_add(&pos->kobj, b->kobj, pos->kobj.name);
560 if (err) {
561 list_for_each_entry_safe_reverse(pos, tmp, head, miscj)
562 kobject_del(&pos->kobj);
563
564 return err;
565 }
566 }
567 return err;
556} 568}
557 569
558/* symlinks sibling shared banks to first core. first core owns dir/files. */
559static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) 570static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
560{ 571{
561 int i, err = 0;
562 struct threshold_bank *b = NULL;
563 struct device *dev = per_cpu(mce_device, cpu); 572 struct device *dev = per_cpu(mce_device, cpu);
564 char name[32]; 573 struct amd_northbridge *nb = NULL;
574 struct threshold_bank *b = NULL;
575 const char *name = th_names[bank];
576 int err = 0;
565 577
566 sprintf(name, "threshold_bank%i", bank); 578 if (shared_bank[bank]) {
567 579
568#ifdef CONFIG_SMP 580 nb = node_to_amd_nb(amd_get_nb_id(cpu));
569 if (cpu_data(cpu).cpu_core_id && shared_bank[bank]) { /* symlink */ 581 WARN_ON(!nb);
570 i = cpumask_first(cpu_llc_shared_mask(cpu));
571 582
572 /* first core not up yet */ 583 /* threshold descriptor already initialized on this node? */
573 if (cpu_data(i).cpu_core_id) 584 if (nb->bank4) {
574 goto out; 585 /* yes, use it */
586 b = nb->bank4;
587 err = kobject_add(b->kobj, &dev->kobj, name);
588 if (err)
589 goto out;
575 590
576 /* already linked */ 591 per_cpu(threshold_banks, cpu)[bank] = b;
577 if (per_cpu(threshold_banks, cpu)[bank]) 592 atomic_inc(&b->cpus);
578 goto out;
579 593
580 b = per_cpu(threshold_banks, i)[bank]; 594 err = __threshold_add_blocks(b);
581 595
582 if (!b)
583 goto out; 596 goto out;
584 597 }
585 err = sysfs_create_link(&dev->kobj, b->kobj, name);
586 if (err)
587 goto out;
588
589 cpumask_copy(b->cpus, cpu_llc_shared_mask(cpu));
590 per_cpu(threshold_banks, cpu)[bank] = b;
591
592 goto out;
593 } 598 }
594#endif
595 599
596 b = kzalloc(sizeof(struct threshold_bank), GFP_KERNEL); 600 b = kzalloc(sizeof(struct threshold_bank), GFP_KERNEL);
597 if (!b) { 601 if (!b) {
598 err = -ENOMEM; 602 err = -ENOMEM;
599 goto out; 603 goto out;
600 } 604 }
601 if (!zalloc_cpumask_var(&b->cpus, GFP_KERNEL)) {
602 kfree(b);
603 err = -ENOMEM;
604 goto out;
605 }
606 605
607 b->kobj = kobject_create_and_add(name, &dev->kobj); 606 b->kobj = kobject_create_and_add(name, &dev->kobj);
608 if (!b->kobj) 607 if (!b->kobj) {
608 err = -EINVAL;
609 goto out_free; 609 goto out_free;
610 610 }
611#ifndef CONFIG_SMP
612 cpumask_setall(b->cpus);
613#else
614 cpumask_set_cpu(cpu, b->cpus);
615#endif
616 611
617 per_cpu(threshold_banks, cpu)[bank] = b; 612 per_cpu(threshold_banks, cpu)[bank] = b;
618 613
619 err = local_allocate_threshold_blocks(cpu, bank); 614 if (shared_bank[bank]) {
620 if (err) 615 atomic_set(&b->cpus, 1);
621 goto out_free;
622
623 for_each_cpu(i, b->cpus) {
624 if (i == cpu)
625 continue;
626
627 dev = per_cpu(mce_device, i);
628 if (dev)
629 err = sysfs_create_link(&dev->kobj,b->kobj, name);
630 if (err)
631 goto out;
632 616
633 per_cpu(threshold_banks, i)[bank] = b; 617 /* nb is already initialized, see above */
618 WARN_ON(nb->bank4);
619 nb->bank4 = b;
634 } 620 }
635 621
636 goto out; 622 err = allocate_threshold_blocks(cpu, bank, 0,
623 MSR_IA32_MC0_MISC + bank * 4);
624 if (!err)
625 goto out;
637 626
638out_free: 627 out_free:
639 per_cpu(threshold_banks, cpu)[bank] = NULL;
640 free_cpumask_var(b->cpus);
641 kfree(b); 628 kfree(b);
642out: 629
630 out:
643 return err; 631 return err;
644} 632}
645 633
@@ -660,12 +648,6 @@ static __cpuinit int threshold_create_device(unsigned int cpu)
660 return err; 648 return err;
661} 649}
662 650
663/*
664 * let's be hotplug friendly.
665 * in case of multiple core processors, the first core always takes ownership
666 * of shared sysfs dir/files, and rest of the cores will be symlinked to it.
667 */
668
669static void deallocate_threshold_block(unsigned int cpu, 651static void deallocate_threshold_block(unsigned int cpu,
670 unsigned int bank) 652 unsigned int bank)
671{ 653{
@@ -686,41 +668,42 @@ static void deallocate_threshold_block(unsigned int cpu,
686 per_cpu(threshold_banks, cpu)[bank]->blocks = NULL; 668 per_cpu(threshold_banks, cpu)[bank]->blocks = NULL;
687} 669}
688 670
671static void __threshold_remove_blocks(struct threshold_bank *b)
672{
673 struct threshold_block *pos = NULL;
674 struct threshold_block *tmp = NULL;
675
676 kobject_del(b->kobj);
677
678 list_for_each_entry_safe(pos, tmp, &b->blocks->miscj, miscj)
679 kobject_del(&pos->kobj);
680}
681
689static void threshold_remove_bank(unsigned int cpu, int bank) 682static void threshold_remove_bank(unsigned int cpu, int bank)
690{ 683{
684 struct amd_northbridge *nb;
691 struct threshold_bank *b; 685 struct threshold_bank *b;
692 struct device *dev;
693 char name[32];
694 int i = 0;
695 686
696 b = per_cpu(threshold_banks, cpu)[bank]; 687 b = per_cpu(threshold_banks, cpu)[bank];
697 if (!b) 688 if (!b)
698 return; 689 return;
690
699 if (!b->blocks) 691 if (!b->blocks)
700 goto free_out; 692 goto free_out;
701 693
702 sprintf(name, "threshold_bank%i", bank); 694 if (shared_bank[bank]) {
703 695 if (!atomic_dec_and_test(&b->cpus)) {
704#ifdef CONFIG_SMP 696 __threshold_remove_blocks(b);
705 /* sibling symlink */ 697 per_cpu(threshold_banks, cpu)[bank] = NULL;
706 if (shared_bank[bank] && b->blocks->cpu != cpu) { 698 return;
707 dev = per_cpu(mce_device, cpu); 699 } else {
708 sysfs_remove_link(&dev->kobj, name); 700 /*
709 per_cpu(threshold_banks, cpu)[bank] = NULL; 701 * the last CPU on this node using the shared bank is
710 702 * going away, remove that bank now.
711 return; 703 */
712 } 704 nb = node_to_amd_nb(amd_get_nb_id(cpu));
713#endif 705 nb->bank4 = NULL;
714 706 }
715 /* remove all sibling symlinks before unregistering */
716 for_each_cpu(i, b->cpus) {
717 if (i == cpu)
718 continue;
719
720 dev = per_cpu(mce_device, i);
721 if (dev)
722 sysfs_remove_link(&dev->kobj, name);
723 per_cpu(threshold_banks, i)[bank] = NULL;
724 } 707 }
725 708
726 deallocate_threshold_block(cpu, bank); 709 deallocate_threshold_block(cpu, bank);
@@ -728,7 +711,6 @@ static void threshold_remove_bank(unsigned int cpu, int bank)
728free_out: 711free_out:
729 kobject_del(b->kobj); 712 kobject_del(b->kobj);
730 kobject_put(b->kobj); 713 kobject_put(b->kobj);
731 free_cpumask_var(b->cpus);
732 kfree(b); 714 kfree(b);
733 per_cpu(threshold_banks, cpu)[bank] = NULL; 715 per_cpu(threshold_banks, cpu)[bank] = NULL;
734} 716}
@@ -777,4 +759,24 @@ static __init int threshold_init_device(void)
777 759
778 return 0; 760 return 0;
779} 761}
780device_initcall(threshold_init_device); 762/*
763 * there are 3 funcs which need to be _initcalled in a logic sequence:
764 * 1. xen_late_init_mcelog
765 * 2. mcheck_init_device
766 * 3. threshold_init_device
767 *
768 * xen_late_init_mcelog must register xen_mce_chrdev_device before
769 * native mce_chrdev_device registration if running under xen platform;
770 *
771 * mcheck_init_device should be inited before threshold_init_device to
772 * initialize mce_device, otherwise a NULL ptr dereference will cause panic.
773 *
774 * so we use following _initcalls
775 * 1. device_initcall(xen_late_init_mcelog);
776 * 2. device_initcall_sync(mcheck_init_device);
777 * 3. late_initcall(threshold_init_device);
778 *
779 * when running under xen, the initcall order is 1,2,3;
780 * on baremetal, we skip 1 and we do only 2 and 3.
781 */
782late_initcall(threshold_init_device);
diff --git a/arch/x86/kernel/cpu/mtrr/cleanup.c b/arch/x86/kernel/cpu/mtrr/cleanup.c
index bdda2e6c673..35ffda5d072 100644
--- a/arch/x86/kernel/cpu/mtrr/cleanup.c
+++ b/arch/x86/kernel/cpu/mtrr/cleanup.c
@@ -258,11 +258,11 @@ range_to_mtrr(unsigned int reg, unsigned long range_startk,
258 258
259 /* Compute the maximum size with which we can make a range: */ 259 /* Compute the maximum size with which we can make a range: */
260 if (range_startk) 260 if (range_startk)
261 max_align = ffs(range_startk) - 1; 261 max_align = __ffs(range_startk);
262 else 262 else
263 max_align = 32; 263 max_align = BITS_PER_LONG - 1;
264 264
265 align = fls(range_sizek) - 1; 265 align = __fls(range_sizek);
266 if (align > max_align) 266 if (align > max_align)
267 align = max_align; 267 align = max_align;
268 268
diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c
index 75772ae6c65..e9fe907cd24 100644
--- a/arch/x86/kernel/cpu/mtrr/generic.c
+++ b/arch/x86/kernel/cpu/mtrr/generic.c
@@ -361,11 +361,7 @@ static void __init print_mtrr_state(void)
361 } 361 }
362 pr_debug("MTRR variable ranges %sabled:\n", 362 pr_debug("MTRR variable ranges %sabled:\n",
363 mtrr_state.enabled & 2 ? "en" : "dis"); 363 mtrr_state.enabled & 2 ? "en" : "dis");
364 if (size_or_mask & 0xffffffffUL) 364 high_width = (__ffs64(size_or_mask) - (32 - PAGE_SHIFT) + 3) / 4;
365 high_width = ffs(size_or_mask & 0xffffffffUL) - 1;
366 else
367 high_width = ffs(size_or_mask>>32) + 32 - 1;
368 high_width = (high_width - (32 - PAGE_SHIFT) + 3) / 4;
369 365
370 for (i = 0; i < num_var_ranges; ++i) { 366 for (i = 0; i < num_var_ranges; ++i) {
371 if (mtrr_state.var_ranges[i].mask_lo & (1 << 11)) 367 if (mtrr_state.var_ranges[i].mask_lo & (1 << 11))
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index c4706cf9c01..915b876edd1 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -32,20 +32,11 @@
32#include <asm/smp.h> 32#include <asm/smp.h>
33#include <asm/alternative.h> 33#include <asm/alternative.h>
34#include <asm/timer.h> 34#include <asm/timer.h>
35#include <asm/desc.h>
36#include <asm/ldt.h>
35 37
36#include "perf_event.h" 38#include "perf_event.h"
37 39
38#if 0
39#undef wrmsrl
40#define wrmsrl(msr, val) \
41do { \
42 trace_printk("wrmsrl(%lx, %lx)\n", (unsigned long)(msr),\
43 (unsigned long)(val)); \
44 native_write_msr((msr), (u32)((u64)(val)), \
45 (u32)((u64)(val) >> 32)); \
46} while (0)
47#endif
48
49struct x86_pmu x86_pmu __read_mostly; 40struct x86_pmu x86_pmu __read_mostly;
50 41
51DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = { 42DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = {
@@ -74,7 +65,7 @@ u64 x86_perf_event_update(struct perf_event *event)
74 int idx = hwc->idx; 65 int idx = hwc->idx;
75 s64 delta; 66 s64 delta;
76 67
77 if (idx == X86_PMC_IDX_FIXED_BTS) 68 if (idx == INTEL_PMC_IDX_FIXED_BTS)
78 return 0; 69 return 0;
79 70
80 /* 71 /*
@@ -86,7 +77,7 @@ u64 x86_perf_event_update(struct perf_event *event)
86 */ 77 */
87again: 78again:
88 prev_raw_count = local64_read(&hwc->prev_count); 79 prev_raw_count = local64_read(&hwc->prev_count);
89 rdmsrl(hwc->event_base, new_raw_count); 80 rdpmcl(hwc->event_base_rdpmc, new_raw_count);
90 81
91 if (local64_cmpxchg(&hwc->prev_count, prev_raw_count, 82 if (local64_cmpxchg(&hwc->prev_count, prev_raw_count,
92 new_raw_count) != prev_raw_count) 83 new_raw_count) != prev_raw_count)
@@ -189,7 +180,7 @@ static void release_pmc_hardware(void) {}
189 180
190static bool check_hw_exists(void) 181static bool check_hw_exists(void)
191{ 182{
192 u64 val, val_new = 0; 183 u64 val, val_new = ~0;
193 int i, reg, ret = 0; 184 int i, reg, ret = 0;
194 185
195 /* 186 /*
@@ -222,8 +213,9 @@ static bool check_hw_exists(void)
222 * that don't trap on the MSR access and always return 0s. 213 * that don't trap on the MSR access and always return 0s.
223 */ 214 */
224 val = 0xabcdUL; 215 val = 0xabcdUL;
225 ret = checking_wrmsrl(x86_pmu_event_addr(0), val); 216 reg = x86_pmu_event_addr(0);
226 ret |= rdmsrl_safe(x86_pmu_event_addr(0), &val_new); 217 ret = wrmsrl_safe(reg, val);
218 ret |= rdmsrl_safe(reg, &val_new);
227 if (ret || val != val_new) 219 if (ret || val != val_new)
228 goto msr_fail; 220 goto msr_fail;
229 221
@@ -240,6 +232,7 @@ bios_fail:
240 232
241msr_fail: 233msr_fail:
242 printk(KERN_CONT "Broken PMU hardware detected, using software events only.\n"); 234 printk(KERN_CONT "Broken PMU hardware detected, using software events only.\n");
235 printk(KERN_ERR "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new);
243 236
244 return false; 237 return false;
245} 238}
@@ -388,7 +381,7 @@ int x86_pmu_hw_config(struct perf_event *event)
388 int precise = 0; 381 int precise = 0;
389 382
390 /* Support for constant skid */ 383 /* Support for constant skid */
391 if (x86_pmu.pebs_active) { 384 if (x86_pmu.pebs_active && !x86_pmu.pebs_broken) {
392 precise++; 385 precise++;
393 386
394 /* Support for IP fixup */ 387 /* Support for IP fixup */
@@ -637,8 +630,8 @@ static bool __perf_sched_find_counter(struct perf_sched *sched)
637 c = sched->constraints[sched->state.event]; 630 c = sched->constraints[sched->state.event];
638 631
639 /* Prefer fixed purpose counters */ 632 /* Prefer fixed purpose counters */
640 if (x86_pmu.num_counters_fixed) { 633 if (c->idxmsk64 & (~0ULL << INTEL_PMC_IDX_FIXED)) {
641 idx = X86_PMC_IDX_FIXED; 634 idx = INTEL_PMC_IDX_FIXED;
642 for_each_set_bit_from(idx, c->idxmsk, X86_PMC_IDX_MAX) { 635 for_each_set_bit_from(idx, c->idxmsk, X86_PMC_IDX_MAX) {
643 if (!__test_and_set_bit(idx, sched->state.used)) 636 if (!__test_and_set_bit(idx, sched->state.used))
644 goto done; 637 goto done;
@@ -646,7 +639,7 @@ static bool __perf_sched_find_counter(struct perf_sched *sched)
646 } 639 }
647 /* Grab the first unused counter starting with idx */ 640 /* Grab the first unused counter starting with idx */
648 idx = sched->state.counter; 641 idx = sched->state.counter;
649 for_each_set_bit_from(idx, c->idxmsk, X86_PMC_IDX_FIXED) { 642 for_each_set_bit_from(idx, c->idxmsk, INTEL_PMC_IDX_FIXED) {
650 if (!__test_and_set_bit(idx, sched->state.used)) 643 if (!__test_and_set_bit(idx, sched->state.used))
651 goto done; 644 goto done;
652 } 645 }
@@ -704,8 +697,8 @@ static bool perf_sched_next_event(struct perf_sched *sched)
704/* 697/*
705 * Assign a counter for each event. 698 * Assign a counter for each event.
706 */ 699 */
707static int perf_assign_events(struct event_constraint **constraints, int n, 700int perf_assign_events(struct event_constraint **constraints, int n,
708 int wmin, int wmax, int *assign) 701 int wmin, int wmax, int *assign)
709{ 702{
710 struct perf_sched sched; 703 struct perf_sched sched;
711 704
@@ -824,15 +817,17 @@ static inline void x86_assign_hw_event(struct perf_event *event,
824 hwc->last_cpu = smp_processor_id(); 817 hwc->last_cpu = smp_processor_id();
825 hwc->last_tag = ++cpuc->tags[i]; 818 hwc->last_tag = ++cpuc->tags[i];
826 819
827 if (hwc->idx == X86_PMC_IDX_FIXED_BTS) { 820 if (hwc->idx == INTEL_PMC_IDX_FIXED_BTS) {
828 hwc->config_base = 0; 821 hwc->config_base = 0;
829 hwc->event_base = 0; 822 hwc->event_base = 0;
830 } else if (hwc->idx >= X86_PMC_IDX_FIXED) { 823 } else if (hwc->idx >= INTEL_PMC_IDX_FIXED) {
831 hwc->config_base = MSR_ARCH_PERFMON_FIXED_CTR_CTRL; 824 hwc->config_base = MSR_ARCH_PERFMON_FIXED_CTR_CTRL;
832 hwc->event_base = MSR_ARCH_PERFMON_FIXED_CTR0 + (hwc->idx - X86_PMC_IDX_FIXED); 825 hwc->event_base = MSR_ARCH_PERFMON_FIXED_CTR0 + (hwc->idx - INTEL_PMC_IDX_FIXED);
826 hwc->event_base_rdpmc = (hwc->idx - INTEL_PMC_IDX_FIXED) | 1<<30;
833 } else { 827 } else {
834 hwc->config_base = x86_pmu_config_addr(hwc->idx); 828 hwc->config_base = x86_pmu_config_addr(hwc->idx);
835 hwc->event_base = x86_pmu_event_addr(hwc->idx); 829 hwc->event_base = x86_pmu_event_addr(hwc->idx);
830 hwc->event_base_rdpmc = hwc->idx;
836 } 831 }
837} 832}
838 833
@@ -930,7 +925,7 @@ int x86_perf_event_set_period(struct perf_event *event)
930 s64 period = hwc->sample_period; 925 s64 period = hwc->sample_period;
931 int ret = 0, idx = hwc->idx; 926 int ret = 0, idx = hwc->idx;
932 927
933 if (idx == X86_PMC_IDX_FIXED_BTS) 928 if (idx == INTEL_PMC_IDX_FIXED_BTS)
934 return 0; 929 return 0;
935 930
936 /* 931 /*
@@ -1316,7 +1311,6 @@ static struct attribute_group x86_pmu_format_group = {
1316static int __init init_hw_perf_events(void) 1311static int __init init_hw_perf_events(void)
1317{ 1312{
1318 struct x86_pmu_quirk *quirk; 1313 struct x86_pmu_quirk *quirk;
1319 struct event_constraint *c;
1320 int err; 1314 int err;
1321 1315
1322 pr_info("Performance Events: "); 1316 pr_info("Performance Events: ");
@@ -1347,21 +1341,8 @@ static int __init init_hw_perf_events(void)
1347 for (quirk = x86_pmu.quirks; quirk; quirk = quirk->next) 1341 for (quirk = x86_pmu.quirks; quirk; quirk = quirk->next)
1348 quirk->func(); 1342 quirk->func();
1349 1343
1350 if (x86_pmu.num_counters > X86_PMC_MAX_GENERIC) { 1344 if (!x86_pmu.intel_ctrl)
1351 WARN(1, KERN_ERR "hw perf events %d > max(%d), clipping!", 1345 x86_pmu.intel_ctrl = (1 << x86_pmu.num_counters) - 1;
1352 x86_pmu.num_counters, X86_PMC_MAX_GENERIC);
1353 x86_pmu.num_counters = X86_PMC_MAX_GENERIC;
1354 }
1355 x86_pmu.intel_ctrl = (1 << x86_pmu.num_counters) - 1;
1356
1357 if (x86_pmu.num_counters_fixed > X86_PMC_MAX_FIXED) {
1358 WARN(1, KERN_ERR "hw perf events fixed %d > max(%d), clipping!",
1359 x86_pmu.num_counters_fixed, X86_PMC_MAX_FIXED);
1360 x86_pmu.num_counters_fixed = X86_PMC_MAX_FIXED;
1361 }
1362
1363 x86_pmu.intel_ctrl |=
1364 ((1LL << x86_pmu.num_counters_fixed)-1) << X86_PMC_IDX_FIXED;
1365 1346
1366 perf_events_lapic_init(); 1347 perf_events_lapic_init();
1367 register_nmi_handler(NMI_LOCAL, perf_event_nmi_handler, 0, "PMI"); 1348 register_nmi_handler(NMI_LOCAL, perf_event_nmi_handler, 0, "PMI");
@@ -1370,22 +1351,6 @@ static int __init init_hw_perf_events(void)
1370 __EVENT_CONSTRAINT(0, (1ULL << x86_pmu.num_counters) - 1, 1351 __EVENT_CONSTRAINT(0, (1ULL << x86_pmu.num_counters) - 1,
1371 0, x86_pmu.num_counters, 0); 1352 0, x86_pmu.num_counters, 0);
1372 1353
1373 if (x86_pmu.event_constraints) {
1374 /*
1375 * event on fixed counter2 (REF_CYCLES) only works on this
1376 * counter, so do not extend mask to generic counters
1377 */
1378 for_each_event_constraint(c, x86_pmu.event_constraints) {
1379 if (c->cmask != X86_RAW_EVENT_MASK
1380 || c->idxmsk64 == X86_PMC_MSK_FIXED_REF_CYCLES) {
1381 continue;
1382 }
1383
1384 c->idxmsk64 |= (1ULL << x86_pmu.num_counters) - 1;
1385 c->weight += x86_pmu.num_counters;
1386 }
1387 }
1388
1389 x86_pmu.attr_rdpmc = 1; /* enable userspace RDPMC usage by default */ 1354 x86_pmu.attr_rdpmc = 1; /* enable userspace RDPMC usage by default */
1390 x86_pmu_format_group.attrs = x86_pmu.format_attrs; 1355 x86_pmu_format_group.attrs = x86_pmu.format_attrs;
1391 1356
@@ -1620,8 +1585,8 @@ static int x86_pmu_event_idx(struct perf_event *event)
1620 if (!x86_pmu.attr_rdpmc) 1585 if (!x86_pmu.attr_rdpmc)
1621 return 0; 1586 return 0;
1622 1587
1623 if (x86_pmu.num_counters_fixed && idx >= X86_PMC_IDX_FIXED) { 1588 if (x86_pmu.num_counters_fixed && idx >= INTEL_PMC_IDX_FIXED) {
1624 idx -= X86_PMC_IDX_FIXED; 1589 idx -= INTEL_PMC_IDX_FIXED;
1625 idx |= 1 << 30; 1590 idx |= 1 << 30;
1626 } 1591 }
1627 1592
@@ -1649,7 +1614,12 @@ static ssize_t set_attr_rdpmc(struct device *cdev,
1649 struct device_attribute *attr, 1614 struct device_attribute *attr,
1650 const char *buf, size_t count) 1615 const char *buf, size_t count)
1651{ 1616{
1652 unsigned long val = simple_strtoul(buf, NULL, 0); 1617 unsigned long val;
1618 ssize_t ret;
1619
1620 ret = kstrtoul(buf, 0, &val);
1621 if (ret)
1622 return ret;
1653 1623
1654 if (!!val != !!x86_pmu.attr_rdpmc) { 1624 if (!!val != !!x86_pmu.attr_rdpmc) {
1655 x86_pmu.attr_rdpmc = !!val; 1625 x86_pmu.attr_rdpmc = !!val;
@@ -1682,13 +1652,20 @@ static void x86_pmu_flush_branch_stack(void)
1682 x86_pmu.flush_branch_stack(); 1652 x86_pmu.flush_branch_stack();
1683} 1653}
1684 1654
1655void perf_check_microcode(void)
1656{
1657 if (x86_pmu.check_microcode)
1658 x86_pmu.check_microcode();
1659}
1660EXPORT_SYMBOL_GPL(perf_check_microcode);
1661
1685static struct pmu pmu = { 1662static struct pmu pmu = {
1686 .pmu_enable = x86_pmu_enable, 1663 .pmu_enable = x86_pmu_enable,
1687 .pmu_disable = x86_pmu_disable, 1664 .pmu_disable = x86_pmu_disable,
1688 1665
1689 .attr_groups = x86_pmu_attr_groups, 1666 .attr_groups = x86_pmu_attr_groups,
1690 1667
1691 .event_init = x86_pmu_event_init, 1668 .event_init = x86_pmu_event_init,
1692 1669
1693 .add = x86_pmu_add, 1670 .add = x86_pmu_add,
1694 .del = x86_pmu_del, 1671 .del = x86_pmu_del,
@@ -1696,11 +1673,11 @@ static struct pmu pmu = {
1696 .stop = x86_pmu_stop, 1673 .stop = x86_pmu_stop,
1697 .read = x86_pmu_read, 1674 .read = x86_pmu_read,
1698 1675
1699 .start_txn = x86_pmu_start_txn, 1676 .start_txn = x86_pmu_start_txn,
1700 .cancel_txn = x86_pmu_cancel_txn, 1677 .cancel_txn = x86_pmu_cancel_txn,
1701 .commit_txn = x86_pmu_commit_txn, 1678 .commit_txn = x86_pmu_commit_txn,
1702 1679
1703 .event_idx = x86_pmu_event_idx, 1680 .event_idx = x86_pmu_event_idx,
1704 .flush_branch_stack = x86_pmu_flush_branch_stack, 1681 .flush_branch_stack = x86_pmu_flush_branch_stack,
1705}; 1682};
1706 1683
@@ -1763,6 +1740,29 @@ valid_user_frame(const void __user *fp, unsigned long size)
1763 return (__range_not_ok(fp, size, TASK_SIZE) == 0); 1740 return (__range_not_ok(fp, size, TASK_SIZE) == 0);
1764} 1741}
1765 1742
1743static unsigned long get_segment_base(unsigned int segment)
1744{
1745 struct desc_struct *desc;
1746 int idx = segment >> 3;
1747
1748 if ((segment & SEGMENT_TI_MASK) == SEGMENT_LDT) {
1749 if (idx > LDT_ENTRIES)
1750 return 0;
1751
1752 if (idx > current->active_mm->context.size)
1753 return 0;
1754
1755 desc = current->active_mm->context.ldt;
1756 } else {
1757 if (idx > GDT_ENTRIES)
1758 return 0;
1759
1760 desc = __this_cpu_ptr(&gdt_page.gdt[0]);
1761 }
1762
1763 return get_desc_base(desc + idx);
1764}
1765
1766#ifdef CONFIG_COMPAT 1766#ifdef CONFIG_COMPAT
1767 1767
1768#include <asm/compat.h> 1768#include <asm/compat.h>
@@ -1771,13 +1771,17 @@ static inline int
1771perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry *entry) 1771perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry *entry)
1772{ 1772{
1773 /* 32-bit process in 64-bit kernel. */ 1773 /* 32-bit process in 64-bit kernel. */
1774 unsigned long ss_base, cs_base;
1774 struct stack_frame_ia32 frame; 1775 struct stack_frame_ia32 frame;
1775 const void __user *fp; 1776 const void __user *fp;
1776 1777
1777 if (!test_thread_flag(TIF_IA32)) 1778 if (!test_thread_flag(TIF_IA32))
1778 return 0; 1779 return 0;
1779 1780
1780 fp = compat_ptr(regs->bp); 1781 cs_base = get_segment_base(regs->cs);
1782 ss_base = get_segment_base(regs->ss);
1783
1784 fp = compat_ptr(ss_base + regs->bp);
1781 while (entry->nr < PERF_MAX_STACK_DEPTH) { 1785 while (entry->nr < PERF_MAX_STACK_DEPTH) {
1782 unsigned long bytes; 1786 unsigned long bytes;
1783 frame.next_frame = 0; 1787 frame.next_frame = 0;
@@ -1790,8 +1794,8 @@ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry *entry)
1790 if (!valid_user_frame(fp, sizeof(frame))) 1794 if (!valid_user_frame(fp, sizeof(frame)))
1791 break; 1795 break;
1792 1796
1793 perf_callchain_store(entry, frame.return_address); 1797 perf_callchain_store(entry, cs_base + frame.return_address);
1794 fp = compat_ptr(frame.next_frame); 1798 fp = compat_ptr(ss_base + frame.next_frame);
1795 } 1799 }
1796 return 1; 1800 return 1;
1797} 1801}
@@ -1814,6 +1818,12 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
1814 return; 1818 return;
1815 } 1819 }
1816 1820
1821 /*
1822 * We don't know what to do with VM86 stacks.. ignore them for now.
1823 */
1824 if (regs->flags & (X86_VM_MASK | PERF_EFLAGS_VM))
1825 return;
1826
1817 fp = (void __user *)regs->bp; 1827 fp = (void __user *)regs->bp;
1818 1828
1819 perf_callchain_store(entry, regs->ip); 1829 perf_callchain_store(entry, regs->ip);
@@ -1841,16 +1851,50 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
1841 } 1851 }
1842} 1852}
1843 1853
1844unsigned long perf_instruction_pointer(struct pt_regs *regs) 1854/*
1855 * Deal with code segment offsets for the various execution modes:
1856 *
1857 * VM86 - the good olde 16 bit days, where the linear address is
1858 * 20 bits and we use regs->ip + 0x10 * regs->cs.
1859 *
1860 * IA32 - Where we need to look at GDT/LDT segment descriptor tables
1861 * to figure out what the 32bit base address is.
1862 *
1863 * X32 - has TIF_X32 set, but is running in x86_64
1864 *
1865 * X86_64 - CS,DS,SS,ES are all zero based.
1866 */
1867static unsigned long code_segment_base(struct pt_regs *regs)
1845{ 1868{
1846 unsigned long ip; 1869 /*
1870 * If we are in VM86 mode, add the segment offset to convert to a
1871 * linear address.
1872 */
1873 if (regs->flags & X86_VM_MASK)
1874 return 0x10 * regs->cs;
1875
1876 /*
1877 * For IA32 we look at the GDT/LDT segment base to convert the
1878 * effective IP to a linear address.
1879 */
1880#ifdef CONFIG_X86_32
1881 if (user_mode(regs) && regs->cs != __USER_CS)
1882 return get_segment_base(regs->cs);
1883#else
1884 if (test_thread_flag(TIF_IA32)) {
1885 if (user_mode(regs) && regs->cs != __USER32_CS)
1886 return get_segment_base(regs->cs);
1887 }
1888#endif
1889 return 0;
1890}
1847 1891
1892unsigned long perf_instruction_pointer(struct pt_regs *regs)
1893{
1848 if (perf_guest_cbs && perf_guest_cbs->is_in_guest()) 1894 if (perf_guest_cbs && perf_guest_cbs->is_in_guest())
1849 ip = perf_guest_cbs->get_guest_ip(); 1895 return perf_guest_cbs->get_guest_ip();
1850 else
1851 ip = instruction_pointer(regs);
1852 1896
1853 return ip; 1897 return regs->ip + code_segment_base(regs);
1854} 1898}
1855 1899
1856unsigned long perf_misc_flags(struct pt_regs *regs) 1900unsigned long perf_misc_flags(struct pt_regs *regs)
diff --git a/arch/x86/kernel/cpu/perf_event.h b/arch/x86/kernel/cpu/perf_event.h
index 7241e2fc3c1..6605a81ba33 100644
--- a/arch/x86/kernel/cpu/perf_event.h
+++ b/arch/x86/kernel/cpu/perf_event.h
@@ -14,6 +14,18 @@
14 14
15#include <linux/perf_event.h> 15#include <linux/perf_event.h>
16 16
17#if 0
18#undef wrmsrl
19#define wrmsrl(msr, val) \
20do { \
21 unsigned int _msr = (msr); \
22 u64 _val = (val); \
23 trace_printk("wrmsrl(%x, %Lx)\n", (unsigned int)(_msr), \
24 (unsigned long long)(_val)); \
25 native_write_msr((_msr), (u32)(_val), (u32)(_val >> 32)); \
26} while (0)
27#endif
28
17/* 29/*
18 * | NHM/WSM | SNB | 30 * | NHM/WSM | SNB |
19 * register ------------------------------- 31 * register -------------------------------
@@ -57,7 +69,7 @@ struct amd_nb {
57}; 69};
58 70
59/* The maximal number of PEBS events: */ 71/* The maximal number of PEBS events: */
60#define MAX_PEBS_EVENTS 4 72#define MAX_PEBS_EVENTS 8
61 73
62/* 74/*
63 * A debug store configuration. 75 * A debug store configuration.
@@ -349,6 +361,8 @@ struct x86_pmu {
349 void (*cpu_starting)(int cpu); 361 void (*cpu_starting)(int cpu);
350 void (*cpu_dying)(int cpu); 362 void (*cpu_dying)(int cpu);
351 void (*cpu_dead)(int cpu); 363 void (*cpu_dead)(int cpu);
364
365 void (*check_microcode)(void);
352 void (*flush_branch_stack)(void); 366 void (*flush_branch_stack)(void);
353 367
354 /* 368 /*
@@ -360,12 +374,16 @@ struct x86_pmu {
360 /* 374 /*
361 * Intel DebugStore bits 375 * Intel DebugStore bits
362 */ 376 */
363 int bts, pebs; 377 unsigned int bts :1,
364 int bts_active, pebs_active; 378 bts_active :1,
379 pebs :1,
380 pebs_active :1,
381 pebs_broken :1;
365 int pebs_record_size; 382 int pebs_record_size;
366 void (*drain_pebs)(struct pt_regs *regs); 383 void (*drain_pebs)(struct pt_regs *regs);
367 struct event_constraint *pebs_constraints; 384 struct event_constraint *pebs_constraints;
368 void (*pebs_aliases)(struct perf_event *event); 385 void (*pebs_aliases)(struct perf_event *event);
386 int max_pebs_events;
369 387
370 /* 388 /*
371 * Intel LBR 389 * Intel LBR
@@ -468,6 +486,8 @@ static inline void __x86_pmu_enable_event(struct hw_perf_event *hwc,
468 486
469void x86_pmu_enable_all(int added); 487void x86_pmu_enable_all(int added);
470 488
489int perf_assign_events(struct event_constraint **constraints, int n,
490 int wmin, int wmax, int *assign);
471int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign); 491int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign);
472 492
473void x86_pmu_stop(struct perf_event *event, int flags); 493void x86_pmu_stop(struct perf_event *event, int flags);
@@ -496,6 +516,26 @@ static inline bool kernel_ip(unsigned long ip)
496#endif 516#endif
497} 517}
498 518
519/*
520 * Not all PMUs provide the right context information to place the reported IP
521 * into full context. Specifically segment registers are typically not
522 * supplied.
523 *
524 * Assuming the address is a linear address (it is for IBS), we fake the CS and
525 * vm86 mode using the known zero-based code segment and 'fix up' the registers
526 * to reflect this.
527 *
528 * Intel PEBS/LBR appear to typically provide the effective address, nothing
529 * much we can do about that but pray and treat it like a linear address.
530 */
531static inline void set_linear_ip(struct pt_regs *regs, unsigned long ip)
532{
533 regs->cs = kernel_ip(ip) ? __KERNEL_CS : __USER_CS;
534 if (regs->flags & X86_VM_MASK)
535 regs->flags ^= (PERF_EFLAGS_VM | X86_VM_MASK);
536 regs->ip = ip;
537}
538
499#ifdef CONFIG_CPU_SUP_AMD 539#ifdef CONFIG_CPU_SUP_AMD
500 540
501int amd_pmu_init(void); 541int amd_pmu_init(void);
diff --git a/arch/x86/kernel/cpu/perf_event_amd.c b/arch/x86/kernel/cpu/perf_event_amd.c
index 11a4eb9131d..4528ae7b6ec 100644
--- a/arch/x86/kernel/cpu/perf_event_amd.c
+++ b/arch/x86/kernel/cpu/perf_event_amd.c
@@ -366,7 +366,7 @@ static void amd_pmu_cpu_starting(int cpu)
366 366
367 cpuc->perf_ctr_virt_mask = AMD_PERFMON_EVENTSEL_HOSTONLY; 367 cpuc->perf_ctr_virt_mask = AMD_PERFMON_EVENTSEL_HOSTONLY;
368 368
369 if (boot_cpu_data.x86_max_cores < 2 || boot_cpu_data.x86 == 0x15) 369 if (boot_cpu_data.x86_max_cores < 2)
370 return; 370 return;
371 371
372 nb_id = amd_get_nb_id(cpu); 372 nb_id = amd_get_nb_id(cpu);
@@ -422,35 +422,6 @@ static struct attribute *amd_format_attr[] = {
422 NULL, 422 NULL,
423}; 423};
424 424
425static __initconst const struct x86_pmu amd_pmu = {
426 .name = "AMD",
427 .handle_irq = x86_pmu_handle_irq,
428 .disable_all = x86_pmu_disable_all,
429 .enable_all = x86_pmu_enable_all,
430 .enable = x86_pmu_enable_event,
431 .disable = x86_pmu_disable_event,
432 .hw_config = amd_pmu_hw_config,
433 .schedule_events = x86_schedule_events,
434 .eventsel = MSR_K7_EVNTSEL0,
435 .perfctr = MSR_K7_PERFCTR0,
436 .event_map = amd_pmu_event_map,
437 .max_events = ARRAY_SIZE(amd_perfmon_event_map),
438 .num_counters = AMD64_NUM_COUNTERS,
439 .cntval_bits = 48,
440 .cntval_mask = (1ULL << 48) - 1,
441 .apic = 1,
442 /* use highest bit to detect overflow */
443 .max_period = (1ULL << 47) - 1,
444 .get_event_constraints = amd_get_event_constraints,
445 .put_event_constraints = amd_put_event_constraints,
446
447 .format_attrs = amd_format_attr,
448
449 .cpu_prepare = amd_pmu_cpu_prepare,
450 .cpu_starting = amd_pmu_cpu_starting,
451 .cpu_dead = amd_pmu_cpu_dead,
452};
453
454/* AMD Family 15h */ 425/* AMD Family 15h */
455 426
456#define AMD_EVENT_TYPE_MASK 0x000000F0ULL 427#define AMD_EVENT_TYPE_MASK 0x000000F0ULL
@@ -597,8 +568,8 @@ amd_get_event_constraints_f15h(struct cpu_hw_events *cpuc, struct perf_event *ev
597 } 568 }
598} 569}
599 570
600static __initconst const struct x86_pmu amd_pmu_f15h = { 571static __initconst const struct x86_pmu amd_pmu = {
601 .name = "AMD Family 15h", 572 .name = "AMD",
602 .handle_irq = x86_pmu_handle_irq, 573 .handle_irq = x86_pmu_handle_irq,
603 .disable_all = x86_pmu_disable_all, 574 .disable_all = x86_pmu_disable_all,
604 .enable_all = x86_pmu_enable_all, 575 .enable_all = x86_pmu_enable_all,
@@ -606,50 +577,68 @@ static __initconst const struct x86_pmu amd_pmu_f15h = {
606 .disable = x86_pmu_disable_event, 577 .disable = x86_pmu_disable_event,
607 .hw_config = amd_pmu_hw_config, 578 .hw_config = amd_pmu_hw_config,
608 .schedule_events = x86_schedule_events, 579 .schedule_events = x86_schedule_events,
609 .eventsel = MSR_F15H_PERF_CTL, 580 .eventsel = MSR_K7_EVNTSEL0,
610 .perfctr = MSR_F15H_PERF_CTR, 581 .perfctr = MSR_K7_PERFCTR0,
611 .event_map = amd_pmu_event_map, 582 .event_map = amd_pmu_event_map,
612 .max_events = ARRAY_SIZE(amd_perfmon_event_map), 583 .max_events = ARRAY_SIZE(amd_perfmon_event_map),
613 .num_counters = AMD64_NUM_COUNTERS_F15H, 584 .num_counters = AMD64_NUM_COUNTERS,
614 .cntval_bits = 48, 585 .cntval_bits = 48,
615 .cntval_mask = (1ULL << 48) - 1, 586 .cntval_mask = (1ULL << 48) - 1,
616 .apic = 1, 587 .apic = 1,
617 /* use highest bit to detect overflow */ 588 /* use highest bit to detect overflow */
618 .max_period = (1ULL << 47) - 1, 589 .max_period = (1ULL << 47) - 1,
619 .get_event_constraints = amd_get_event_constraints_f15h, 590 .get_event_constraints = amd_get_event_constraints,
620 /* nortbridge counters not yet implemented: */
621#if 0
622 .put_event_constraints = amd_put_event_constraints, 591 .put_event_constraints = amd_put_event_constraints,
623 592
593 .format_attrs = amd_format_attr,
594
624 .cpu_prepare = amd_pmu_cpu_prepare, 595 .cpu_prepare = amd_pmu_cpu_prepare,
625 .cpu_dead = amd_pmu_cpu_dead,
626#endif
627 .cpu_starting = amd_pmu_cpu_starting, 596 .cpu_starting = amd_pmu_cpu_starting,
628 .format_attrs = amd_format_attr, 597 .cpu_dead = amd_pmu_cpu_dead,
629}; 598};
630 599
600static int setup_event_constraints(void)
601{
602 if (boot_cpu_data.x86 >= 0x15)
603 x86_pmu.get_event_constraints = amd_get_event_constraints_f15h;
604 return 0;
605}
606
607static int setup_perfctr_core(void)
608{
609 if (!cpu_has_perfctr_core) {
610 WARN(x86_pmu.get_event_constraints == amd_get_event_constraints_f15h,
611 KERN_ERR "Odd, counter constraints enabled but no core perfctrs detected!");
612 return -ENODEV;
613 }
614
615 WARN(x86_pmu.get_event_constraints == amd_get_event_constraints,
616 KERN_ERR "hw perf events core counters need constraints handler!");
617
618 /*
619 * If core performance counter extensions exists, we must use
620 * MSR_F15H_PERF_CTL/MSR_F15H_PERF_CTR msrs. See also
621 * x86_pmu_addr_offset().
622 */
623 x86_pmu.eventsel = MSR_F15H_PERF_CTL;
624 x86_pmu.perfctr = MSR_F15H_PERF_CTR;
625 x86_pmu.num_counters = AMD64_NUM_COUNTERS_CORE;
626
627 printk(KERN_INFO "perf: AMD core performance counters detected\n");
628
629 return 0;
630}
631
631__init int amd_pmu_init(void) 632__init int amd_pmu_init(void)
632{ 633{
633 /* Performance-monitoring supported from K7 and later: */ 634 /* Performance-monitoring supported from K7 and later: */
634 if (boot_cpu_data.x86 < 6) 635 if (boot_cpu_data.x86 < 6)
635 return -ENODEV; 636 return -ENODEV;
636 637
637 /* 638 x86_pmu = amd_pmu;
638 * If core performance counter extensions exists, it must be 639
639 * family 15h, otherwise fail. See x86_pmu_addr_offset(). 640 setup_event_constraints();
640 */ 641 setup_perfctr_core();
641 switch (boot_cpu_data.x86) {
642 case 0x15:
643 if (!cpu_has_perfctr_core)
644 return -ENODEV;
645 x86_pmu = amd_pmu_f15h;
646 break;
647 default:
648 if (cpu_has_perfctr_core)
649 return -ENODEV;
650 x86_pmu = amd_pmu;
651 break;
652 }
653 642
654 /* Events are common for all AMDs */ 643 /* Events are common for all AMDs */
655 memcpy(hw_cache_event_ids, amd_hw_cache_event_ids, 644 memcpy(hw_cache_event_ids, amd_hw_cache_event_ids,
diff --git a/arch/x86/kernel/cpu/perf_event_amd_ibs.c b/arch/x86/kernel/cpu/perf_event_amd_ibs.c
index da9bcdcd985..7bfb5bec863 100644
--- a/arch/x86/kernel/cpu/perf_event_amd_ibs.c
+++ b/arch/x86/kernel/cpu/perf_event_amd_ibs.c
@@ -13,6 +13,8 @@
13 13
14#include <asm/apic.h> 14#include <asm/apic.h>
15 15
16#include "perf_event.h"
17
16static u32 ibs_caps; 18static u32 ibs_caps;
17 19
18#if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_AMD) 20#if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_AMD)
@@ -536,7 +538,7 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)
536 if (check_rip && (ibs_data.regs[2] & IBS_RIP_INVALID)) { 538 if (check_rip && (ibs_data.regs[2] & IBS_RIP_INVALID)) {
537 regs.flags &= ~PERF_EFLAGS_EXACT; 539 regs.flags &= ~PERF_EFLAGS_EXACT;
538 } else { 540 } else {
539 instruction_pointer_set(&regs, ibs_data.regs[1]); 541 set_linear_ip(&regs, ibs_data.regs[1]);
540 regs.flags |= PERF_EFLAGS_EXACT; 542 regs.flags |= PERF_EFLAGS_EXACT;
541 } 543 }
542 544
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index 187c294bc65..7f2739e03e7 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -5,6 +5,8 @@
5 * among events on a single PMU. 5 * among events on a single PMU.
6 */ 6 */
7 7
8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9
8#include <linux/stddef.h> 10#include <linux/stddef.h>
9#include <linux/types.h> 11#include <linux/types.h>
10#include <linux/init.h> 12#include <linux/init.h>
@@ -21,14 +23,14 @@
21 */ 23 */
22static u64 intel_perfmon_event_map[PERF_COUNT_HW_MAX] __read_mostly = 24static u64 intel_perfmon_event_map[PERF_COUNT_HW_MAX] __read_mostly =
23{ 25{
24 [PERF_COUNT_HW_CPU_CYCLES] = 0x003c, 26 [PERF_COUNT_HW_CPU_CYCLES] = 0x003c,
25 [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0, 27 [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0,
26 [PERF_COUNT_HW_CACHE_REFERENCES] = 0x4f2e, 28 [PERF_COUNT_HW_CACHE_REFERENCES] = 0x4f2e,
27 [PERF_COUNT_HW_CACHE_MISSES] = 0x412e, 29 [PERF_COUNT_HW_CACHE_MISSES] = 0x412e,
28 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c4, 30 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c4,
29 [PERF_COUNT_HW_BRANCH_MISSES] = 0x00c5, 31 [PERF_COUNT_HW_BRANCH_MISSES] = 0x00c5,
30 [PERF_COUNT_HW_BUS_CYCLES] = 0x013c, 32 [PERF_COUNT_HW_BUS_CYCLES] = 0x013c,
31 [PERF_COUNT_HW_REF_CPU_CYCLES] = 0x0300, /* pseudo-encoding */ 33 [PERF_COUNT_HW_REF_CPU_CYCLES] = 0x0300, /* pseudo-encoding */
32}; 34};
33 35
34static struct event_constraint intel_core_event_constraints[] __read_mostly = 36static struct event_constraint intel_core_event_constraints[] __read_mostly =
@@ -136,6 +138,84 @@ static u64 intel_pmu_event_map(int hw_event)
136 return intel_perfmon_event_map[hw_event]; 138 return intel_perfmon_event_map[hw_event];
137} 139}
138 140
141#define SNB_DMND_DATA_RD (1ULL << 0)
142#define SNB_DMND_RFO (1ULL << 1)
143#define SNB_DMND_IFETCH (1ULL << 2)
144#define SNB_DMND_WB (1ULL << 3)
145#define SNB_PF_DATA_RD (1ULL << 4)
146#define SNB_PF_RFO (1ULL << 5)
147#define SNB_PF_IFETCH (1ULL << 6)
148#define SNB_LLC_DATA_RD (1ULL << 7)
149#define SNB_LLC_RFO (1ULL << 8)
150#define SNB_LLC_IFETCH (1ULL << 9)
151#define SNB_BUS_LOCKS (1ULL << 10)
152#define SNB_STRM_ST (1ULL << 11)
153#define SNB_OTHER (1ULL << 15)
154#define SNB_RESP_ANY (1ULL << 16)
155#define SNB_NO_SUPP (1ULL << 17)
156#define SNB_LLC_HITM (1ULL << 18)
157#define SNB_LLC_HITE (1ULL << 19)
158#define SNB_LLC_HITS (1ULL << 20)
159#define SNB_LLC_HITF (1ULL << 21)
160#define SNB_LOCAL (1ULL << 22)
161#define SNB_REMOTE (0xffULL << 23)
162#define SNB_SNP_NONE (1ULL << 31)
163#define SNB_SNP_NOT_NEEDED (1ULL << 32)
164#define SNB_SNP_MISS (1ULL << 33)
165#define SNB_NO_FWD (1ULL << 34)
166#define SNB_SNP_FWD (1ULL << 35)
167#define SNB_HITM (1ULL << 36)
168#define SNB_NON_DRAM (1ULL << 37)
169
170#define SNB_DMND_READ (SNB_DMND_DATA_RD|SNB_LLC_DATA_RD)
171#define SNB_DMND_WRITE (SNB_DMND_RFO|SNB_LLC_RFO)
172#define SNB_DMND_PREFETCH (SNB_PF_DATA_RD|SNB_PF_RFO)
173
174#define SNB_SNP_ANY (SNB_SNP_NONE|SNB_SNP_NOT_NEEDED| \
175 SNB_SNP_MISS|SNB_NO_FWD|SNB_SNP_FWD| \
176 SNB_HITM)
177
178#define SNB_DRAM_ANY (SNB_LOCAL|SNB_REMOTE|SNB_SNP_ANY)
179#define SNB_DRAM_REMOTE (SNB_REMOTE|SNB_SNP_ANY)
180
181#define SNB_L3_ACCESS SNB_RESP_ANY
182#define SNB_L3_MISS (SNB_DRAM_ANY|SNB_NON_DRAM)
183
184static __initconst const u64 snb_hw_cache_extra_regs
185 [PERF_COUNT_HW_CACHE_MAX]
186 [PERF_COUNT_HW_CACHE_OP_MAX]
187 [PERF_COUNT_HW_CACHE_RESULT_MAX] =
188{
189 [ C(LL ) ] = {
190 [ C(OP_READ) ] = {
191 [ C(RESULT_ACCESS) ] = SNB_DMND_READ|SNB_L3_ACCESS,
192 [ C(RESULT_MISS) ] = SNB_DMND_READ|SNB_L3_MISS,
193 },
194 [ C(OP_WRITE) ] = {
195 [ C(RESULT_ACCESS) ] = SNB_DMND_WRITE|SNB_L3_ACCESS,
196 [ C(RESULT_MISS) ] = SNB_DMND_WRITE|SNB_L3_MISS,
197 },
198 [ C(OP_PREFETCH) ] = {
199 [ C(RESULT_ACCESS) ] = SNB_DMND_PREFETCH|SNB_L3_ACCESS,
200 [ C(RESULT_MISS) ] = SNB_DMND_PREFETCH|SNB_L3_MISS,
201 },
202 },
203 [ C(NODE) ] = {
204 [ C(OP_READ) ] = {
205 [ C(RESULT_ACCESS) ] = SNB_DMND_READ|SNB_DRAM_ANY,
206 [ C(RESULT_MISS) ] = SNB_DMND_READ|SNB_DRAM_REMOTE,
207 },
208 [ C(OP_WRITE) ] = {
209 [ C(RESULT_ACCESS) ] = SNB_DMND_WRITE|SNB_DRAM_ANY,
210 [ C(RESULT_MISS) ] = SNB_DMND_WRITE|SNB_DRAM_REMOTE,
211 },
212 [ C(OP_PREFETCH) ] = {
213 [ C(RESULT_ACCESS) ] = SNB_DMND_PREFETCH|SNB_DRAM_ANY,
214 [ C(RESULT_MISS) ] = SNB_DMND_PREFETCH|SNB_DRAM_REMOTE,
215 },
216 },
217};
218
139static __initconst const u64 snb_hw_cache_event_ids 219static __initconst const u64 snb_hw_cache_event_ids
140 [PERF_COUNT_HW_CACHE_MAX] 220 [PERF_COUNT_HW_CACHE_MAX]
141 [PERF_COUNT_HW_CACHE_OP_MAX] 221 [PERF_COUNT_HW_CACHE_OP_MAX]
@@ -233,16 +313,16 @@ static __initconst const u64 snb_hw_cache_event_ids
233 }, 313 },
234 [ C(NODE) ] = { 314 [ C(NODE) ] = {
235 [ C(OP_READ) ] = { 315 [ C(OP_READ) ] = {
236 [ C(RESULT_ACCESS) ] = -1, 316 [ C(RESULT_ACCESS) ] = 0x01b7,
237 [ C(RESULT_MISS) ] = -1, 317 [ C(RESULT_MISS) ] = 0x01b7,
238 }, 318 },
239 [ C(OP_WRITE) ] = { 319 [ C(OP_WRITE) ] = {
240 [ C(RESULT_ACCESS) ] = -1, 320 [ C(RESULT_ACCESS) ] = 0x01b7,
241 [ C(RESULT_MISS) ] = -1, 321 [ C(RESULT_MISS) ] = 0x01b7,
242 }, 322 },
243 [ C(OP_PREFETCH) ] = { 323 [ C(OP_PREFETCH) ] = {
244 [ C(RESULT_ACCESS) ] = -1, 324 [ C(RESULT_ACCESS) ] = 0x01b7,
245 [ C(RESULT_MISS) ] = -1, 325 [ C(RESULT_MISS) ] = 0x01b7,
246 }, 326 },
247 }, 327 },
248 328
@@ -747,7 +827,7 @@ static void intel_pmu_disable_all(void)
747 827
748 wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, 0); 828 wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, 0);
749 829
750 if (test_bit(X86_PMC_IDX_FIXED_BTS, cpuc->active_mask)) 830 if (test_bit(INTEL_PMC_IDX_FIXED_BTS, cpuc->active_mask))
751 intel_pmu_disable_bts(); 831 intel_pmu_disable_bts();
752 832
753 intel_pmu_pebs_disable_all(); 833 intel_pmu_pebs_disable_all();
@@ -763,9 +843,9 @@ static void intel_pmu_enable_all(int added)
763 wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, 843 wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL,
764 x86_pmu.intel_ctrl & ~cpuc->intel_ctrl_guest_mask); 844 x86_pmu.intel_ctrl & ~cpuc->intel_ctrl_guest_mask);
765 845
766 if (test_bit(X86_PMC_IDX_FIXED_BTS, cpuc->active_mask)) { 846 if (test_bit(INTEL_PMC_IDX_FIXED_BTS, cpuc->active_mask)) {
767 struct perf_event *event = 847 struct perf_event *event =
768 cpuc->events[X86_PMC_IDX_FIXED_BTS]; 848 cpuc->events[INTEL_PMC_IDX_FIXED_BTS];
769 849
770 if (WARN_ON_ONCE(!event)) 850 if (WARN_ON_ONCE(!event))
771 return; 851 return;
@@ -871,7 +951,7 @@ static inline void intel_pmu_ack_status(u64 ack)
871 951
872static void intel_pmu_disable_fixed(struct hw_perf_event *hwc) 952static void intel_pmu_disable_fixed(struct hw_perf_event *hwc)
873{ 953{
874 int idx = hwc->idx - X86_PMC_IDX_FIXED; 954 int idx = hwc->idx - INTEL_PMC_IDX_FIXED;
875 u64 ctrl_val, mask; 955 u64 ctrl_val, mask;
876 956
877 mask = 0xfULL << (idx * 4); 957 mask = 0xfULL << (idx * 4);
@@ -886,7 +966,7 @@ static void intel_pmu_disable_event(struct perf_event *event)
886 struct hw_perf_event *hwc = &event->hw; 966 struct hw_perf_event *hwc = &event->hw;
887 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 967 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
888 968
889 if (unlikely(hwc->idx == X86_PMC_IDX_FIXED_BTS)) { 969 if (unlikely(hwc->idx == INTEL_PMC_IDX_FIXED_BTS)) {
890 intel_pmu_disable_bts(); 970 intel_pmu_disable_bts();
891 intel_pmu_drain_bts_buffer(); 971 intel_pmu_drain_bts_buffer();
892 return; 972 return;
@@ -915,7 +995,7 @@ static void intel_pmu_disable_event(struct perf_event *event)
915 995
916static void intel_pmu_enable_fixed(struct hw_perf_event *hwc) 996static void intel_pmu_enable_fixed(struct hw_perf_event *hwc)
917{ 997{
918 int idx = hwc->idx - X86_PMC_IDX_FIXED; 998 int idx = hwc->idx - INTEL_PMC_IDX_FIXED;
919 u64 ctrl_val, bits, mask; 999 u64 ctrl_val, bits, mask;
920 1000
921 /* 1001 /*
@@ -949,7 +1029,7 @@ static void intel_pmu_enable_event(struct perf_event *event)
949 struct hw_perf_event *hwc = &event->hw; 1029 struct hw_perf_event *hwc = &event->hw;
950 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 1030 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
951 1031
952 if (unlikely(hwc->idx == X86_PMC_IDX_FIXED_BTS)) { 1032 if (unlikely(hwc->idx == INTEL_PMC_IDX_FIXED_BTS)) {
953 if (!__this_cpu_read(cpu_hw_events.enabled)) 1033 if (!__this_cpu_read(cpu_hw_events.enabled))
954 return; 1034 return;
955 1035
@@ -1000,14 +1080,14 @@ static void intel_pmu_reset(void)
1000 1080
1001 local_irq_save(flags); 1081 local_irq_save(flags);
1002 1082
1003 printk("clearing PMU state on CPU#%d\n", smp_processor_id()); 1083 pr_info("clearing PMU state on CPU#%d\n", smp_processor_id());
1004 1084
1005 for (idx = 0; idx < x86_pmu.num_counters; idx++) { 1085 for (idx = 0; idx < x86_pmu.num_counters; idx++) {
1006 checking_wrmsrl(x86_pmu_config_addr(idx), 0ull); 1086 wrmsrl_safe(x86_pmu_config_addr(idx), 0ull);
1007 checking_wrmsrl(x86_pmu_event_addr(idx), 0ull); 1087 wrmsrl_safe(x86_pmu_event_addr(idx), 0ull);
1008 } 1088 }
1009 for (idx = 0; idx < x86_pmu.num_counters_fixed; idx++) 1089 for (idx = 0; idx < x86_pmu.num_counters_fixed; idx++)
1010 checking_wrmsrl(MSR_ARCH_PERFMON_FIXED_CTR0 + idx, 0ull); 1090 wrmsrl_safe(MSR_ARCH_PERFMON_FIXED_CTR0 + idx, 0ull);
1011 1091
1012 if (ds) 1092 if (ds)
1013 ds->bts_index = ds->bts_buffer_base; 1093 ds->bts_index = ds->bts_buffer_base;
@@ -1442,8 +1522,16 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr)
1442 arr[0].msr = MSR_CORE_PERF_GLOBAL_CTRL; 1522 arr[0].msr = MSR_CORE_PERF_GLOBAL_CTRL;
1443 arr[0].host = x86_pmu.intel_ctrl & ~cpuc->intel_ctrl_guest_mask; 1523 arr[0].host = x86_pmu.intel_ctrl & ~cpuc->intel_ctrl_guest_mask;
1444 arr[0].guest = x86_pmu.intel_ctrl & ~cpuc->intel_ctrl_host_mask; 1524 arr[0].guest = x86_pmu.intel_ctrl & ~cpuc->intel_ctrl_host_mask;
1525 /*
1526 * If PMU counter has PEBS enabled it is not enough to disable counter
1527 * on a guest entry since PEBS memory write can overshoot guest entry
1528 * and corrupt guest memory. Disabling PEBS solves the problem.
1529 */
1530 arr[1].msr = MSR_IA32_PEBS_ENABLE;
1531 arr[1].host = cpuc->pebs_enabled;
1532 arr[1].guest = 0;
1445 1533
1446 *nr = 1; 1534 *nr = 2;
1447 return arr; 1535 return arr;
1448} 1536}
1449 1537
@@ -1707,16 +1795,61 @@ static __init void intel_clovertown_quirk(void)
1707 * But taken together it might just make sense to not enable PEBS on 1795 * But taken together it might just make sense to not enable PEBS on
1708 * these chips. 1796 * these chips.
1709 */ 1797 */
1710 printk(KERN_WARNING "PEBS disabled due to CPU errata.\n"); 1798 pr_warn("PEBS disabled due to CPU errata\n");
1711 x86_pmu.pebs = 0; 1799 x86_pmu.pebs = 0;
1712 x86_pmu.pebs_constraints = NULL; 1800 x86_pmu.pebs_constraints = NULL;
1713} 1801}
1714 1802
1803static int intel_snb_pebs_broken(int cpu)
1804{
1805 u32 rev = UINT_MAX; /* default to broken for unknown models */
1806
1807 switch (cpu_data(cpu).x86_model) {
1808 case 42: /* SNB */
1809 rev = 0x28;
1810 break;
1811
1812 case 45: /* SNB-EP */
1813 switch (cpu_data(cpu).x86_mask) {
1814 case 6: rev = 0x618; break;
1815 case 7: rev = 0x70c; break;
1816 }
1817 }
1818
1819 return (cpu_data(cpu).microcode < rev);
1820}
1821
1822static void intel_snb_check_microcode(void)
1823{
1824 int pebs_broken = 0;
1825 int cpu;
1826
1827 get_online_cpus();
1828 for_each_online_cpu(cpu) {
1829 if ((pebs_broken = intel_snb_pebs_broken(cpu)))
1830 break;
1831 }
1832 put_online_cpus();
1833
1834 if (pebs_broken == x86_pmu.pebs_broken)
1835 return;
1836
1837 /*
1838 * Serialized by the microcode lock..
1839 */
1840 if (x86_pmu.pebs_broken) {
1841 pr_info("PEBS enabled due to microcode update\n");
1842 x86_pmu.pebs_broken = 0;
1843 } else {
1844 pr_info("PEBS disabled due to CPU errata, please upgrade microcode\n");
1845 x86_pmu.pebs_broken = 1;
1846 }
1847}
1848
1715static __init void intel_sandybridge_quirk(void) 1849static __init void intel_sandybridge_quirk(void)
1716{ 1850{
1717 printk(KERN_WARNING "PEBS disabled due to CPU errata.\n"); 1851 x86_pmu.check_microcode = intel_snb_check_microcode;
1718 x86_pmu.pebs = 0; 1852 intel_snb_check_microcode();
1719 x86_pmu.pebs_constraints = NULL;
1720} 1853}
1721 1854
1722static const struct { int id; char *name; } intel_arch_events_map[] __initconst = { 1855static const struct { int id; char *name; } intel_arch_events_map[] __initconst = {
@@ -1736,8 +1869,8 @@ static __init void intel_arch_events_quirk(void)
1736 /* disable event that reported as not presend by cpuid */ 1869 /* disable event that reported as not presend by cpuid */
1737 for_each_set_bit(bit, x86_pmu.events_mask, ARRAY_SIZE(intel_arch_events_map)) { 1870 for_each_set_bit(bit, x86_pmu.events_mask, ARRAY_SIZE(intel_arch_events_map)) {
1738 intel_perfmon_event_map[intel_arch_events_map[bit].id] = 0; 1871 intel_perfmon_event_map[intel_arch_events_map[bit].id] = 0;
1739 printk(KERN_WARNING "CPUID marked event: \'%s\' unavailable\n", 1872 pr_warn("CPUID marked event: \'%s\' unavailable\n",
1740 intel_arch_events_map[bit].name); 1873 intel_arch_events_map[bit].name);
1741 } 1874 }
1742} 1875}
1743 1876
@@ -1756,7 +1889,7 @@ static __init void intel_nehalem_quirk(void)
1756 intel_perfmon_event_map[PERF_COUNT_HW_BRANCH_MISSES] = 0x7f89; 1889 intel_perfmon_event_map[PERF_COUNT_HW_BRANCH_MISSES] = 0x7f89;
1757 ebx.split.no_branch_misses_retired = 0; 1890 ebx.split.no_branch_misses_retired = 0;
1758 x86_pmu.events_maskl = ebx.full; 1891 x86_pmu.events_maskl = ebx.full;
1759 printk(KERN_INFO "CPU erratum AAJ80 worked around\n"); 1892 pr_info("CPU erratum AAJ80 worked around\n");
1760 } 1893 }
1761} 1894}
1762 1895
@@ -1765,6 +1898,7 @@ __init int intel_pmu_init(void)
1765 union cpuid10_edx edx; 1898 union cpuid10_edx edx;
1766 union cpuid10_eax eax; 1899 union cpuid10_eax eax;
1767 union cpuid10_ebx ebx; 1900 union cpuid10_ebx ebx;
1901 struct event_constraint *c;
1768 unsigned int unused; 1902 unsigned int unused;
1769 int version; 1903 int version;
1770 1904
@@ -1800,6 +1934,8 @@ __init int intel_pmu_init(void)
1800 x86_pmu.events_maskl = ebx.full; 1934 x86_pmu.events_maskl = ebx.full;
1801 x86_pmu.events_mask_len = eax.split.mask_length; 1935 x86_pmu.events_mask_len = eax.split.mask_length;
1802 1936
1937 x86_pmu.max_pebs_events = min_t(unsigned, MAX_PEBS_EVENTS, x86_pmu.num_counters);
1938
1803 /* 1939 /*
1804 * Quirk: v2 perfmon does not report fixed-purpose events, so 1940 * Quirk: v2 perfmon does not report fixed-purpose events, so
1805 * assume at least 3 events: 1941 * assume at least 3 events:
@@ -1914,6 +2050,8 @@ __init int intel_pmu_init(void)
1914 case 58: /* IvyBridge */ 2050 case 58: /* IvyBridge */
1915 memcpy(hw_cache_event_ids, snb_hw_cache_event_ids, 2051 memcpy(hw_cache_event_ids, snb_hw_cache_event_ids,
1916 sizeof(hw_cache_event_ids)); 2052 sizeof(hw_cache_event_ids));
2053 memcpy(hw_cache_extra_regs, snb_hw_cache_extra_regs,
2054 sizeof(hw_cache_extra_regs));
1917 2055
1918 intel_pmu_lbr_init_snb(); 2056 intel_pmu_lbr_init_snb();
1919 2057
@@ -1951,5 +2089,37 @@ __init int intel_pmu_init(void)
1951 } 2089 }
1952 } 2090 }
1953 2091
2092 if (x86_pmu.num_counters > INTEL_PMC_MAX_GENERIC) {
2093 WARN(1, KERN_ERR "hw perf events %d > max(%d), clipping!",
2094 x86_pmu.num_counters, INTEL_PMC_MAX_GENERIC);
2095 x86_pmu.num_counters = INTEL_PMC_MAX_GENERIC;
2096 }
2097 x86_pmu.intel_ctrl = (1 << x86_pmu.num_counters) - 1;
2098
2099 if (x86_pmu.num_counters_fixed > INTEL_PMC_MAX_FIXED) {
2100 WARN(1, KERN_ERR "hw perf events fixed %d > max(%d), clipping!",
2101 x86_pmu.num_counters_fixed, INTEL_PMC_MAX_FIXED);
2102 x86_pmu.num_counters_fixed = INTEL_PMC_MAX_FIXED;
2103 }
2104
2105 x86_pmu.intel_ctrl |=
2106 ((1LL << x86_pmu.num_counters_fixed)-1) << INTEL_PMC_IDX_FIXED;
2107
2108 if (x86_pmu.event_constraints) {
2109 /*
2110 * event on fixed counter2 (REF_CYCLES) only works on this
2111 * counter, so do not extend mask to generic counters
2112 */
2113 for_each_event_constraint(c, x86_pmu.event_constraints) {
2114 if (c->cmask != X86_RAW_EVENT_MASK
2115 || c->idxmsk64 == INTEL_PMC_MSK_FIXED_REF_CYCLES) {
2116 continue;
2117 }
2118
2119 c->idxmsk64 |= (1ULL << x86_pmu.num_counters) - 1;
2120 c->weight += x86_pmu.num_counters;
2121 }
2122 }
2123
1954 return 0; 2124 return 0;
1955} 2125}
diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c
index 35e2192df9f..e38d97bf425 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -248,7 +248,7 @@ void reserve_ds_buffers(void)
248 */ 248 */
249 249
250struct event_constraint bts_constraint = 250struct event_constraint bts_constraint =
251 EVENT_CONSTRAINT(0, 1ULL << X86_PMC_IDX_FIXED_BTS, 0); 251 EVENT_CONSTRAINT(0, 1ULL << INTEL_PMC_IDX_FIXED_BTS, 0);
252 252
253void intel_pmu_enable_bts(u64 config) 253void intel_pmu_enable_bts(u64 config)
254{ 254{
@@ -295,7 +295,7 @@ int intel_pmu_drain_bts_buffer(void)
295 u64 to; 295 u64 to;
296 u64 flags; 296 u64 flags;
297 }; 297 };
298 struct perf_event *event = cpuc->events[X86_PMC_IDX_FIXED_BTS]; 298 struct perf_event *event = cpuc->events[INTEL_PMC_IDX_FIXED_BTS];
299 struct bts_record *at, *top; 299 struct bts_record *at, *top;
300 struct perf_output_handle handle; 300 struct perf_output_handle handle;
301 struct perf_event_header header; 301 struct perf_event_header header;
@@ -499,7 +499,7 @@ static int intel_pmu_pebs_fixup_ip(struct pt_regs *regs)
499 * We sampled a branch insn, rewind using the LBR stack 499 * We sampled a branch insn, rewind using the LBR stack
500 */ 500 */
501 if (ip == to) { 501 if (ip == to) {
502 regs->ip = from; 502 set_linear_ip(regs, from);
503 return 1; 503 return 1;
504 } 504 }
505 505
@@ -529,7 +529,7 @@ static int intel_pmu_pebs_fixup_ip(struct pt_regs *regs)
529 } while (to < ip); 529 } while (to < ip);
530 530
531 if (to == ip) { 531 if (to == ip) {
532 regs->ip = old_to; 532 set_linear_ip(regs, old_to);
533 return 1; 533 return 1;
534 } 534 }
535 535
@@ -569,7 +569,8 @@ static void __intel_pmu_pebs_event(struct perf_event *event,
569 * A possible PERF_SAMPLE_REGS will have to transfer all regs. 569 * A possible PERF_SAMPLE_REGS will have to transfer all regs.
570 */ 570 */
571 regs = *iregs; 571 regs = *iregs;
572 regs.ip = pebs->ip; 572 regs.flags = pebs->flags;
573 set_linear_ip(&regs, pebs->ip);
573 regs.bp = pebs->bp; 574 regs.bp = pebs->bp;
574 regs.sp = pebs->sp; 575 regs.sp = pebs->sp;
575 576
@@ -620,7 +621,7 @@ static void intel_pmu_drain_pebs_core(struct pt_regs *iregs)
620 * Should not happen, we program the threshold at 1 and do not 621 * Should not happen, we program the threshold at 1 and do not
621 * set a reset value. 622 * set a reset value.
622 */ 623 */
623 WARN_ON_ONCE(n > 1); 624 WARN_ONCE(n > 1, "bad leftover pebs %d\n", n);
624 at += n - 1; 625 at += n - 1;
625 626
626 __intel_pmu_pebs_event(event, iregs, at); 627 __intel_pmu_pebs_event(event, iregs, at);
@@ -651,10 +652,10 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs)
651 * Should not happen, we program the threshold at 1 and do not 652 * Should not happen, we program the threshold at 1 and do not
652 * set a reset value. 653 * set a reset value.
653 */ 654 */
654 WARN_ON_ONCE(n > MAX_PEBS_EVENTS); 655 WARN_ONCE(n > x86_pmu.max_pebs_events, "Unexpected number of pebs records %d\n", n);
655 656
656 for ( ; at < top; at++) { 657 for ( ; at < top; at++) {
657 for_each_set_bit(bit, (unsigned long *)&at->status, MAX_PEBS_EVENTS) { 658 for_each_set_bit(bit, (unsigned long *)&at->status, x86_pmu.max_pebs_events) {
658 event = cpuc->events[bit]; 659 event = cpuc->events[bit];
659 if (!test_bit(bit, cpuc->active_mask)) 660 if (!test_bit(bit, cpuc->active_mask))
660 continue; 661 continue;
@@ -670,7 +671,7 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs)
670 break; 671 break;
671 } 672 }
672 673
673 if (!event || bit >= MAX_PEBS_EVENTS) 674 if (!event || bit >= x86_pmu.max_pebs_events)
674 continue; 675 continue;
675 676
676 __intel_pmu_pebs_event(event, iregs, at); 677 __intel_pmu_pebs_event(event, iregs, at);
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
new file mode 100644
index 00000000000..0a5571080e7
--- /dev/null
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -0,0 +1,2915 @@
1#include "perf_event_intel_uncore.h"
2
3static struct intel_uncore_type *empty_uncore[] = { NULL, };
4static struct intel_uncore_type **msr_uncores = empty_uncore;
5static struct intel_uncore_type **pci_uncores = empty_uncore;
6/* pci bus to socket mapping */
7static int pcibus_to_physid[256] = { [0 ... 255] = -1, };
8
9static DEFINE_RAW_SPINLOCK(uncore_box_lock);
10
11/* mask of cpus that collect uncore events */
12static cpumask_t uncore_cpu_mask;
13
14/* constraint for the fixed counter */
15static struct event_constraint constraint_fixed =
16 EVENT_CONSTRAINT(~0ULL, 1 << UNCORE_PMC_IDX_FIXED, ~0ULL);
17static struct event_constraint constraint_empty =
18 EVENT_CONSTRAINT(0, 0, 0);
19
20DEFINE_UNCORE_FORMAT_ATTR(event, event, "config:0-7");
21DEFINE_UNCORE_FORMAT_ATTR(event_ext, event, "config:0-7,21");
22DEFINE_UNCORE_FORMAT_ATTR(umask, umask, "config:8-15");
23DEFINE_UNCORE_FORMAT_ATTR(edge, edge, "config:18");
24DEFINE_UNCORE_FORMAT_ATTR(tid_en, tid_en, "config:19");
25DEFINE_UNCORE_FORMAT_ATTR(inv, inv, "config:23");
26DEFINE_UNCORE_FORMAT_ATTR(cmask5, cmask, "config:24-28");
27DEFINE_UNCORE_FORMAT_ATTR(cmask8, cmask, "config:24-31");
28DEFINE_UNCORE_FORMAT_ATTR(thresh8, thresh, "config:24-31");
29DEFINE_UNCORE_FORMAT_ATTR(thresh5, thresh, "config:24-28");
30DEFINE_UNCORE_FORMAT_ATTR(occ_sel, occ_sel, "config:14-15");
31DEFINE_UNCORE_FORMAT_ATTR(occ_invert, occ_invert, "config:30");
32DEFINE_UNCORE_FORMAT_ATTR(occ_edge, occ_edge, "config:14-51");
33DEFINE_UNCORE_FORMAT_ATTR(filter_tid, filter_tid, "config1:0-4");
34DEFINE_UNCORE_FORMAT_ATTR(filter_nid, filter_nid, "config1:10-17");
35DEFINE_UNCORE_FORMAT_ATTR(filter_state, filter_state, "config1:18-22");
36DEFINE_UNCORE_FORMAT_ATTR(filter_opc, filter_opc, "config1:23-31");
37DEFINE_UNCORE_FORMAT_ATTR(filter_band0, filter_band0, "config1:0-7");
38DEFINE_UNCORE_FORMAT_ATTR(filter_band1, filter_band1, "config1:8-15");
39DEFINE_UNCORE_FORMAT_ATTR(filter_band2, filter_band2, "config1:16-23");
40DEFINE_UNCORE_FORMAT_ATTR(filter_band3, filter_band3, "config1:24-31");
41
42static u64 uncore_msr_read_counter(struct intel_uncore_box *box, struct perf_event *event)
43{
44 u64 count;
45
46 rdmsrl(event->hw.event_base, count);
47
48 return count;
49}
50
51/*
52 * generic get constraint function for shared match/mask registers.
53 */
54static struct event_constraint *
55uncore_get_constraint(struct intel_uncore_box *box, struct perf_event *event)
56{
57 struct intel_uncore_extra_reg *er;
58 struct hw_perf_event_extra *reg1 = &event->hw.extra_reg;
59 struct hw_perf_event_extra *reg2 = &event->hw.branch_reg;
60 unsigned long flags;
61 bool ok = false;
62
63 /*
64 * reg->alloc can be set due to existing state, so for fake box we
65 * need to ignore this, otherwise we might fail to allocate proper
66 * fake state for this extra reg constraint.
67 */
68 if (reg1->idx == EXTRA_REG_NONE ||
69 (!uncore_box_is_fake(box) && reg1->alloc))
70 return NULL;
71
72 er = &box->shared_regs[reg1->idx];
73 raw_spin_lock_irqsave(&er->lock, flags);
74 if (!atomic_read(&er->ref) ||
75 (er->config1 == reg1->config && er->config2 == reg2->config)) {
76 atomic_inc(&er->ref);
77 er->config1 = reg1->config;
78 er->config2 = reg2->config;
79 ok = true;
80 }
81 raw_spin_unlock_irqrestore(&er->lock, flags);
82
83 if (ok) {
84 if (!uncore_box_is_fake(box))
85 reg1->alloc = 1;
86 return NULL;
87 }
88
89 return &constraint_empty;
90}
91
92static void uncore_put_constraint(struct intel_uncore_box *box, struct perf_event *event)
93{
94 struct intel_uncore_extra_reg *er;
95 struct hw_perf_event_extra *reg1 = &event->hw.extra_reg;
96
97 /*
98 * Only put constraint if extra reg was actually allocated. Also
99 * takes care of event which do not use an extra shared reg.
100 *
101 * Also, if this is a fake box we shouldn't touch any event state
102 * (reg->alloc) and we don't care about leaving inconsistent box
103 * state either since it will be thrown out.
104 */
105 if (uncore_box_is_fake(box) || !reg1->alloc)
106 return;
107
108 er = &box->shared_regs[reg1->idx];
109 atomic_dec(&er->ref);
110 reg1->alloc = 0;
111}
112
113/* Sandy Bridge-EP uncore support */
114static struct intel_uncore_type snbep_uncore_cbox;
115static struct intel_uncore_type snbep_uncore_pcu;
116
117static void snbep_uncore_pci_disable_box(struct intel_uncore_box *box)
118{
119 struct pci_dev *pdev = box->pci_dev;
120 int box_ctl = uncore_pci_box_ctl(box);
121 u32 config;
122
123 pci_read_config_dword(pdev, box_ctl, &config);
124 config |= SNBEP_PMON_BOX_CTL_FRZ;
125 pci_write_config_dword(pdev, box_ctl, config);
126}
127
128static void snbep_uncore_pci_enable_box(struct intel_uncore_box *box)
129{
130 struct pci_dev *pdev = box->pci_dev;
131 int box_ctl = uncore_pci_box_ctl(box);
132 u32 config;
133
134 pci_read_config_dword(pdev, box_ctl, &config);
135 config &= ~SNBEP_PMON_BOX_CTL_FRZ;
136 pci_write_config_dword(pdev, box_ctl, config);
137}
138
139static void snbep_uncore_pci_enable_event(struct intel_uncore_box *box, struct perf_event *event)
140{
141 struct pci_dev *pdev = box->pci_dev;
142 struct hw_perf_event *hwc = &event->hw;
143
144 pci_write_config_dword(pdev, hwc->config_base, hwc->config | SNBEP_PMON_CTL_EN);
145}
146
147static void snbep_uncore_pci_disable_event(struct intel_uncore_box *box, struct perf_event *event)
148{
149 struct pci_dev *pdev = box->pci_dev;
150 struct hw_perf_event *hwc = &event->hw;
151
152 pci_write_config_dword(pdev, hwc->config_base, hwc->config);
153}
154
155static u64 snbep_uncore_pci_read_counter(struct intel_uncore_box *box, struct perf_event *event)
156{
157 struct pci_dev *pdev = box->pci_dev;
158 struct hw_perf_event *hwc = &event->hw;
159 u64 count;
160
161 pci_read_config_dword(pdev, hwc->event_base, (u32 *)&count);
162 pci_read_config_dword(pdev, hwc->event_base + 4, (u32 *)&count + 1);
163
164 return count;
165}
166
167static void snbep_uncore_pci_init_box(struct intel_uncore_box *box)
168{
169 struct pci_dev *pdev = box->pci_dev;
170
171 pci_write_config_dword(pdev, SNBEP_PCI_PMON_BOX_CTL, SNBEP_PMON_BOX_CTL_INT);
172}
173
174static void snbep_uncore_msr_disable_box(struct intel_uncore_box *box)
175{
176 u64 config;
177 unsigned msr;
178
179 msr = uncore_msr_box_ctl(box);
180 if (msr) {
181 rdmsrl(msr, config);
182 config |= SNBEP_PMON_BOX_CTL_FRZ;
183 wrmsrl(msr, config);
184 }
185}
186
187static void snbep_uncore_msr_enable_box(struct intel_uncore_box *box)
188{
189 u64 config;
190 unsigned msr;
191
192 msr = uncore_msr_box_ctl(box);
193 if (msr) {
194 rdmsrl(msr, config);
195 config &= ~SNBEP_PMON_BOX_CTL_FRZ;
196 wrmsrl(msr, config);
197 }
198}
199
200static void snbep_uncore_msr_enable_event(struct intel_uncore_box *box, struct perf_event *event)
201{
202 struct hw_perf_event *hwc = &event->hw;
203 struct hw_perf_event_extra *reg1 = &hwc->extra_reg;
204
205 if (reg1->idx != EXTRA_REG_NONE)
206 wrmsrl(reg1->reg, reg1->config);
207
208 wrmsrl(hwc->config_base, hwc->config | SNBEP_PMON_CTL_EN);
209}
210
211static void snbep_uncore_msr_disable_event(struct intel_uncore_box *box,
212 struct perf_event *event)
213{
214 struct hw_perf_event *hwc = &event->hw;
215
216 wrmsrl(hwc->config_base, hwc->config);
217}
218
219static void snbep_uncore_msr_init_box(struct intel_uncore_box *box)
220{
221 unsigned msr = uncore_msr_box_ctl(box);
222
223 if (msr)
224 wrmsrl(msr, SNBEP_PMON_BOX_CTL_INT);
225}
226
227static int snbep_uncore_hw_config(struct intel_uncore_box *box, struct perf_event *event)
228{
229 struct hw_perf_event *hwc = &event->hw;
230 struct hw_perf_event_extra *reg1 = &hwc->extra_reg;
231
232 if (box->pmu->type == &snbep_uncore_cbox) {
233 reg1->reg = SNBEP_C0_MSR_PMON_BOX_FILTER +
234 SNBEP_CBO_MSR_OFFSET * box->pmu->pmu_idx;
235 reg1->config = event->attr.config1 &
236 SNBEP_CB0_MSR_PMON_BOX_FILTER_MASK;
237 } else {
238 if (box->pmu->type == &snbep_uncore_pcu) {
239 reg1->reg = SNBEP_PCU_MSR_PMON_BOX_FILTER;
240 reg1->config = event->attr.config1 & SNBEP_PCU_MSR_PMON_BOX_FILTER_MASK;
241 } else {
242 return 0;
243 }
244 }
245 reg1->idx = 0;
246
247 return 0;
248}
249
250static struct attribute *snbep_uncore_formats_attr[] = {
251 &format_attr_event.attr,
252 &format_attr_umask.attr,
253 &format_attr_edge.attr,
254 &format_attr_inv.attr,
255 &format_attr_thresh8.attr,
256 NULL,
257};
258
259static struct attribute *snbep_uncore_ubox_formats_attr[] = {
260 &format_attr_event.attr,
261 &format_attr_umask.attr,
262 &format_attr_edge.attr,
263 &format_attr_inv.attr,
264 &format_attr_thresh5.attr,
265 NULL,
266};
267
268static struct attribute *snbep_uncore_cbox_formats_attr[] = {
269 &format_attr_event.attr,
270 &format_attr_umask.attr,
271 &format_attr_edge.attr,
272 &format_attr_tid_en.attr,
273 &format_attr_inv.attr,
274 &format_attr_thresh8.attr,
275 &format_attr_filter_tid.attr,
276 &format_attr_filter_nid.attr,
277 &format_attr_filter_state.attr,
278 &format_attr_filter_opc.attr,
279 NULL,
280};
281
282static struct attribute *snbep_uncore_pcu_formats_attr[] = {
283 &format_attr_event.attr,
284 &format_attr_occ_sel.attr,
285 &format_attr_edge.attr,
286 &format_attr_inv.attr,
287 &format_attr_thresh5.attr,
288 &format_attr_occ_invert.attr,
289 &format_attr_occ_edge.attr,
290 &format_attr_filter_band0.attr,
291 &format_attr_filter_band1.attr,
292 &format_attr_filter_band2.attr,
293 &format_attr_filter_band3.attr,
294 NULL,
295};
296
297static struct attribute *snbep_uncore_qpi_formats_attr[] = {
298 &format_attr_event_ext.attr,
299 &format_attr_umask.attr,
300 &format_attr_edge.attr,
301 &format_attr_inv.attr,
302 &format_attr_thresh8.attr,
303 NULL,
304};
305
306static struct uncore_event_desc snbep_uncore_imc_events[] = {
307 INTEL_UNCORE_EVENT_DESC(clockticks, "event=0xff,umask=0x00"),
308 INTEL_UNCORE_EVENT_DESC(cas_count_read, "event=0x04,umask=0x03"),
309 INTEL_UNCORE_EVENT_DESC(cas_count_write, "event=0x04,umask=0x0c"),
310 { /* end: all zeroes */ },
311};
312
313static struct uncore_event_desc snbep_uncore_qpi_events[] = {
314 INTEL_UNCORE_EVENT_DESC(clockticks, "event=0x14"),
315 INTEL_UNCORE_EVENT_DESC(txl_flits_active, "event=0x00,umask=0x06"),
316 INTEL_UNCORE_EVENT_DESC(drs_data, "event=0x02,umask=0x08"),
317 INTEL_UNCORE_EVENT_DESC(ncb_data, "event=0x03,umask=0x04"),
318 { /* end: all zeroes */ },
319};
320
321static struct attribute_group snbep_uncore_format_group = {
322 .name = "format",
323 .attrs = snbep_uncore_formats_attr,
324};
325
326static struct attribute_group snbep_uncore_ubox_format_group = {
327 .name = "format",
328 .attrs = snbep_uncore_ubox_formats_attr,
329};
330
331static struct attribute_group snbep_uncore_cbox_format_group = {
332 .name = "format",
333 .attrs = snbep_uncore_cbox_formats_attr,
334};
335
336static struct attribute_group snbep_uncore_pcu_format_group = {
337 .name = "format",
338 .attrs = snbep_uncore_pcu_formats_attr,
339};
340
341static struct attribute_group snbep_uncore_qpi_format_group = {
342 .name = "format",
343 .attrs = snbep_uncore_qpi_formats_attr,
344};
345
346static struct intel_uncore_ops snbep_uncore_msr_ops = {
347 .init_box = snbep_uncore_msr_init_box,
348 .disable_box = snbep_uncore_msr_disable_box,
349 .enable_box = snbep_uncore_msr_enable_box,
350 .disable_event = snbep_uncore_msr_disable_event,
351 .enable_event = snbep_uncore_msr_enable_event,
352 .read_counter = uncore_msr_read_counter,
353 .get_constraint = uncore_get_constraint,
354 .put_constraint = uncore_put_constraint,
355 .hw_config = snbep_uncore_hw_config,
356};
357
358static struct intel_uncore_ops snbep_uncore_pci_ops = {
359 .init_box = snbep_uncore_pci_init_box,
360 .disable_box = snbep_uncore_pci_disable_box,
361 .enable_box = snbep_uncore_pci_enable_box,
362 .disable_event = snbep_uncore_pci_disable_event,
363 .enable_event = snbep_uncore_pci_enable_event,
364 .read_counter = snbep_uncore_pci_read_counter,
365};
366
367static struct event_constraint snbep_uncore_cbox_constraints[] = {
368 UNCORE_EVENT_CONSTRAINT(0x01, 0x1),
369 UNCORE_EVENT_CONSTRAINT(0x02, 0x3),
370 UNCORE_EVENT_CONSTRAINT(0x04, 0x3),
371 UNCORE_EVENT_CONSTRAINT(0x05, 0x3),
372 UNCORE_EVENT_CONSTRAINT(0x07, 0x3),
373 UNCORE_EVENT_CONSTRAINT(0x11, 0x1),
374 UNCORE_EVENT_CONSTRAINT(0x12, 0x3),
375 UNCORE_EVENT_CONSTRAINT(0x13, 0x3),
376 UNCORE_EVENT_CONSTRAINT(0x1b, 0xc),
377 UNCORE_EVENT_CONSTRAINT(0x1c, 0xc),
378 UNCORE_EVENT_CONSTRAINT(0x1d, 0xc),
379 UNCORE_EVENT_CONSTRAINT(0x1e, 0xc),
380 EVENT_CONSTRAINT_OVERLAP(0x1f, 0xe, 0xff),
381 UNCORE_EVENT_CONSTRAINT(0x21, 0x3),
382 UNCORE_EVENT_CONSTRAINT(0x23, 0x3),
383 UNCORE_EVENT_CONSTRAINT(0x31, 0x3),
384 UNCORE_EVENT_CONSTRAINT(0x32, 0x3),
385 UNCORE_EVENT_CONSTRAINT(0x33, 0x3),
386 UNCORE_EVENT_CONSTRAINT(0x34, 0x3),
387 UNCORE_EVENT_CONSTRAINT(0x35, 0x3),
388 UNCORE_EVENT_CONSTRAINT(0x36, 0x1),
389 UNCORE_EVENT_CONSTRAINT(0x37, 0x3),
390 UNCORE_EVENT_CONSTRAINT(0x38, 0x3),
391 UNCORE_EVENT_CONSTRAINT(0x39, 0x3),
392 UNCORE_EVENT_CONSTRAINT(0x3b, 0x1),
393 EVENT_CONSTRAINT_END
394};
395
396static struct event_constraint snbep_uncore_r2pcie_constraints[] = {
397 UNCORE_EVENT_CONSTRAINT(0x10, 0x3),
398 UNCORE_EVENT_CONSTRAINT(0x11, 0x3),
399 UNCORE_EVENT_CONSTRAINT(0x12, 0x1),
400 UNCORE_EVENT_CONSTRAINT(0x23, 0x3),
401 UNCORE_EVENT_CONSTRAINT(0x24, 0x3),
402 UNCORE_EVENT_CONSTRAINT(0x25, 0x3),
403 UNCORE_EVENT_CONSTRAINT(0x26, 0x3),
404 UNCORE_EVENT_CONSTRAINT(0x32, 0x3),
405 UNCORE_EVENT_CONSTRAINT(0x33, 0x3),
406 UNCORE_EVENT_CONSTRAINT(0x34, 0x3),
407 EVENT_CONSTRAINT_END
408};
409
410static struct event_constraint snbep_uncore_r3qpi_constraints[] = {
411 UNCORE_EVENT_CONSTRAINT(0x10, 0x3),
412 UNCORE_EVENT_CONSTRAINT(0x11, 0x3),
413 UNCORE_EVENT_CONSTRAINT(0x12, 0x3),
414 UNCORE_EVENT_CONSTRAINT(0x13, 0x1),
415 UNCORE_EVENT_CONSTRAINT(0x20, 0x3),
416 UNCORE_EVENT_CONSTRAINT(0x21, 0x3),
417 UNCORE_EVENT_CONSTRAINT(0x22, 0x3),
418 UNCORE_EVENT_CONSTRAINT(0x23, 0x3),
419 UNCORE_EVENT_CONSTRAINT(0x24, 0x3),
420 UNCORE_EVENT_CONSTRAINT(0x25, 0x3),
421 UNCORE_EVENT_CONSTRAINT(0x26, 0x3),
422 UNCORE_EVENT_CONSTRAINT(0x30, 0x3),
423 UNCORE_EVENT_CONSTRAINT(0x31, 0x3),
424 UNCORE_EVENT_CONSTRAINT(0x32, 0x3),
425 UNCORE_EVENT_CONSTRAINT(0x33, 0x3),
426 UNCORE_EVENT_CONSTRAINT(0x34, 0x3),
427 UNCORE_EVENT_CONSTRAINT(0x36, 0x3),
428 UNCORE_EVENT_CONSTRAINT(0x37, 0x3),
429 EVENT_CONSTRAINT_END
430};
431
432static struct intel_uncore_type snbep_uncore_ubox = {
433 .name = "ubox",
434 .num_counters = 2,
435 .num_boxes = 1,
436 .perf_ctr_bits = 44,
437 .fixed_ctr_bits = 48,
438 .perf_ctr = SNBEP_U_MSR_PMON_CTR0,
439 .event_ctl = SNBEP_U_MSR_PMON_CTL0,
440 .event_mask = SNBEP_U_MSR_PMON_RAW_EVENT_MASK,
441 .fixed_ctr = SNBEP_U_MSR_PMON_UCLK_FIXED_CTR,
442 .fixed_ctl = SNBEP_U_MSR_PMON_UCLK_FIXED_CTL,
443 .ops = &snbep_uncore_msr_ops,
444 .format_group = &snbep_uncore_ubox_format_group,
445};
446
447static struct intel_uncore_type snbep_uncore_cbox = {
448 .name = "cbox",
449 .num_counters = 4,
450 .num_boxes = 8,
451 .perf_ctr_bits = 44,
452 .event_ctl = SNBEP_C0_MSR_PMON_CTL0,
453 .perf_ctr = SNBEP_C0_MSR_PMON_CTR0,
454 .event_mask = SNBEP_CBO_MSR_PMON_RAW_EVENT_MASK,
455 .box_ctl = SNBEP_C0_MSR_PMON_BOX_CTL,
456 .msr_offset = SNBEP_CBO_MSR_OFFSET,
457 .num_shared_regs = 1,
458 .constraints = snbep_uncore_cbox_constraints,
459 .ops = &snbep_uncore_msr_ops,
460 .format_group = &snbep_uncore_cbox_format_group,
461};
462
463static struct intel_uncore_type snbep_uncore_pcu = {
464 .name = "pcu",
465 .num_counters = 4,
466 .num_boxes = 1,
467 .perf_ctr_bits = 48,
468 .perf_ctr = SNBEP_PCU_MSR_PMON_CTR0,
469 .event_ctl = SNBEP_PCU_MSR_PMON_CTL0,
470 .event_mask = SNBEP_PCU_MSR_PMON_RAW_EVENT_MASK,
471 .box_ctl = SNBEP_PCU_MSR_PMON_BOX_CTL,
472 .num_shared_regs = 1,
473 .ops = &snbep_uncore_msr_ops,
474 .format_group = &snbep_uncore_pcu_format_group,
475};
476
477static struct intel_uncore_type *snbep_msr_uncores[] = {
478 &snbep_uncore_ubox,
479 &snbep_uncore_cbox,
480 &snbep_uncore_pcu,
481 NULL,
482};
483
484#define SNBEP_UNCORE_PCI_COMMON_INIT() \
485 .perf_ctr = SNBEP_PCI_PMON_CTR0, \
486 .event_ctl = SNBEP_PCI_PMON_CTL0, \
487 .event_mask = SNBEP_PMON_RAW_EVENT_MASK, \
488 .box_ctl = SNBEP_PCI_PMON_BOX_CTL, \
489 .ops = &snbep_uncore_pci_ops, \
490 .format_group = &snbep_uncore_format_group
491
492static struct intel_uncore_type snbep_uncore_ha = {
493 .name = "ha",
494 .num_counters = 4,
495 .num_boxes = 1,
496 .perf_ctr_bits = 48,
497 SNBEP_UNCORE_PCI_COMMON_INIT(),
498};
499
500static struct intel_uncore_type snbep_uncore_imc = {
501 .name = "imc",
502 .num_counters = 4,
503 .num_boxes = 4,
504 .perf_ctr_bits = 48,
505 .fixed_ctr_bits = 48,
506 .fixed_ctr = SNBEP_MC_CHy_PCI_PMON_FIXED_CTR,
507 .fixed_ctl = SNBEP_MC_CHy_PCI_PMON_FIXED_CTL,
508 .event_descs = snbep_uncore_imc_events,
509 SNBEP_UNCORE_PCI_COMMON_INIT(),
510};
511
512static struct intel_uncore_type snbep_uncore_qpi = {
513 .name = "qpi",
514 .num_counters = 4,
515 .num_boxes = 2,
516 .perf_ctr_bits = 48,
517 .perf_ctr = SNBEP_PCI_PMON_CTR0,
518 .event_ctl = SNBEP_PCI_PMON_CTL0,
519 .event_mask = SNBEP_QPI_PCI_PMON_RAW_EVENT_MASK,
520 .box_ctl = SNBEP_PCI_PMON_BOX_CTL,
521 .ops = &snbep_uncore_pci_ops,
522 .event_descs = snbep_uncore_qpi_events,
523 .format_group = &snbep_uncore_qpi_format_group,
524};
525
526
527static struct intel_uncore_type snbep_uncore_r2pcie = {
528 .name = "r2pcie",
529 .num_counters = 4,
530 .num_boxes = 1,
531 .perf_ctr_bits = 44,
532 .constraints = snbep_uncore_r2pcie_constraints,
533 SNBEP_UNCORE_PCI_COMMON_INIT(),
534};
535
536static struct intel_uncore_type snbep_uncore_r3qpi = {
537 .name = "r3qpi",
538 .num_counters = 3,
539 .num_boxes = 2,
540 .perf_ctr_bits = 44,
541 .constraints = snbep_uncore_r3qpi_constraints,
542 SNBEP_UNCORE_PCI_COMMON_INIT(),
543};
544
545static struct intel_uncore_type *snbep_pci_uncores[] = {
546 &snbep_uncore_ha,
547 &snbep_uncore_imc,
548 &snbep_uncore_qpi,
549 &snbep_uncore_r2pcie,
550 &snbep_uncore_r3qpi,
551 NULL,
552};
553
554static DEFINE_PCI_DEVICE_TABLE(snbep_uncore_pci_ids) = {
555 { /* Home Agent */
556 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_HA),
557 .driver_data = (unsigned long)&snbep_uncore_ha,
558 },
559 { /* MC Channel 0 */
560 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_IMC0),
561 .driver_data = (unsigned long)&snbep_uncore_imc,
562 },
563 { /* MC Channel 1 */
564 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_IMC1),
565 .driver_data = (unsigned long)&snbep_uncore_imc,
566 },
567 { /* MC Channel 2 */
568 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_IMC2),
569 .driver_data = (unsigned long)&snbep_uncore_imc,
570 },
571 { /* MC Channel 3 */
572 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_IMC3),
573 .driver_data = (unsigned long)&snbep_uncore_imc,
574 },
575 { /* QPI Port 0 */
576 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_QPI0),
577 .driver_data = (unsigned long)&snbep_uncore_qpi,
578 },
579 { /* QPI Port 1 */
580 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_QPI1),
581 .driver_data = (unsigned long)&snbep_uncore_qpi,
582 },
583 { /* P2PCIe */
584 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_R2PCIE),
585 .driver_data = (unsigned long)&snbep_uncore_r2pcie,
586 },
587 { /* R3QPI Link 0 */
588 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_R3QPI0),
589 .driver_data = (unsigned long)&snbep_uncore_r3qpi,
590 },
591 { /* R3QPI Link 1 */
592 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_R3QPI1),
593 .driver_data = (unsigned long)&snbep_uncore_r3qpi,
594 },
595 { /* end: all zeroes */ }
596};
597
598static struct pci_driver snbep_uncore_pci_driver = {
599 .name = "snbep_uncore",
600 .id_table = snbep_uncore_pci_ids,
601};
602
603/*
604 * build pci bus to socket mapping
605 */
606static void snbep_pci2phy_map_init(void)
607{
608 struct pci_dev *ubox_dev = NULL;
609 int i, bus, nodeid;
610 u32 config;
611
612 while (1) {
613 /* find the UBOX device */
614 ubox_dev = pci_get_device(PCI_VENDOR_ID_INTEL,
615 PCI_DEVICE_ID_INTEL_JAKETOWN_UBOX,
616 ubox_dev);
617 if (!ubox_dev)
618 break;
619 bus = ubox_dev->bus->number;
620 /* get the Node ID of the local register */
621 pci_read_config_dword(ubox_dev, 0x40, &config);
622 nodeid = config;
623 /* get the Node ID mapping */
624 pci_read_config_dword(ubox_dev, 0x54, &config);
625 /*
626 * every three bits in the Node ID mapping register maps
627 * to a particular node.
628 */
629 for (i = 0; i < 8; i++) {
630 if (nodeid == ((config >> (3 * i)) & 0x7)) {
631 pcibus_to_physid[bus] = i;
632 break;
633 }
634 }
635 };
636 return;
637}
638/* end of Sandy Bridge-EP uncore support */
639
640/* Sandy Bridge uncore support */
641static void snb_uncore_msr_enable_event(struct intel_uncore_box *box, struct perf_event *event)
642{
643 struct hw_perf_event *hwc = &event->hw;
644
645 if (hwc->idx < UNCORE_PMC_IDX_FIXED)
646 wrmsrl(hwc->config_base, hwc->config | SNB_UNC_CTL_EN);
647 else
648 wrmsrl(hwc->config_base, SNB_UNC_CTL_EN);
649}
650
651static void snb_uncore_msr_disable_event(struct intel_uncore_box *box, struct perf_event *event)
652{
653 wrmsrl(event->hw.config_base, 0);
654}
655
656static void snb_uncore_msr_init_box(struct intel_uncore_box *box)
657{
658 if (box->pmu->pmu_idx == 0) {
659 wrmsrl(SNB_UNC_PERF_GLOBAL_CTL,
660 SNB_UNC_GLOBAL_CTL_EN | SNB_UNC_GLOBAL_CTL_CORE_ALL);
661 }
662}
663
664static struct attribute *snb_uncore_formats_attr[] = {
665 &format_attr_event.attr,
666 &format_attr_umask.attr,
667 &format_attr_edge.attr,
668 &format_attr_inv.attr,
669 &format_attr_cmask5.attr,
670 NULL,
671};
672
673static struct attribute_group snb_uncore_format_group = {
674 .name = "format",
675 .attrs = snb_uncore_formats_attr,
676};
677
678static struct intel_uncore_ops snb_uncore_msr_ops = {
679 .init_box = snb_uncore_msr_init_box,
680 .disable_event = snb_uncore_msr_disable_event,
681 .enable_event = snb_uncore_msr_enable_event,
682 .read_counter = uncore_msr_read_counter,
683};
684
685static struct event_constraint snb_uncore_cbox_constraints[] = {
686 UNCORE_EVENT_CONSTRAINT(0x80, 0x1),
687 UNCORE_EVENT_CONSTRAINT(0x83, 0x1),
688 EVENT_CONSTRAINT_END
689};
690
691static struct intel_uncore_type snb_uncore_cbox = {
692 .name = "cbox",
693 .num_counters = 2,
694 .num_boxes = 4,
695 .perf_ctr_bits = 44,
696 .fixed_ctr_bits = 48,
697 .perf_ctr = SNB_UNC_CBO_0_PER_CTR0,
698 .event_ctl = SNB_UNC_CBO_0_PERFEVTSEL0,
699 .fixed_ctr = SNB_UNC_FIXED_CTR,
700 .fixed_ctl = SNB_UNC_FIXED_CTR_CTRL,
701 .single_fixed = 1,
702 .event_mask = SNB_UNC_RAW_EVENT_MASK,
703 .msr_offset = SNB_UNC_CBO_MSR_OFFSET,
704 .constraints = snb_uncore_cbox_constraints,
705 .ops = &snb_uncore_msr_ops,
706 .format_group = &snb_uncore_format_group,
707};
708
709static struct intel_uncore_type *snb_msr_uncores[] = {
710 &snb_uncore_cbox,
711 NULL,
712};
713/* end of Sandy Bridge uncore support */
714
715/* Nehalem uncore support */
716static void nhm_uncore_msr_disable_box(struct intel_uncore_box *box)
717{
718 wrmsrl(NHM_UNC_PERF_GLOBAL_CTL, 0);
719}
720
721static void nhm_uncore_msr_enable_box(struct intel_uncore_box *box)
722{
723 wrmsrl(NHM_UNC_PERF_GLOBAL_CTL, NHM_UNC_GLOBAL_CTL_EN_PC_ALL | NHM_UNC_GLOBAL_CTL_EN_FC);
724}
725
726static void nhm_uncore_msr_enable_event(struct intel_uncore_box *box, struct perf_event *event)
727{
728 struct hw_perf_event *hwc = &event->hw;
729
730 if (hwc->idx < UNCORE_PMC_IDX_FIXED)
731 wrmsrl(hwc->config_base, hwc->config | SNB_UNC_CTL_EN);
732 else
733 wrmsrl(hwc->config_base, NHM_UNC_FIXED_CTR_CTL_EN);
734}
735
736static struct attribute *nhm_uncore_formats_attr[] = {
737 &format_attr_event.attr,
738 &format_attr_umask.attr,
739 &format_attr_edge.attr,
740 &format_attr_inv.attr,
741 &format_attr_cmask8.attr,
742 NULL,
743};
744
745static struct attribute_group nhm_uncore_format_group = {
746 .name = "format",
747 .attrs = nhm_uncore_formats_attr,
748};
749
750static struct uncore_event_desc nhm_uncore_events[] = {
751 INTEL_UNCORE_EVENT_DESC(clockticks, "event=0xff,umask=0x00"),
752 INTEL_UNCORE_EVENT_DESC(qmc_writes_full_any, "event=0x2f,umask=0x0f"),
753 INTEL_UNCORE_EVENT_DESC(qmc_normal_reads_any, "event=0x2c,umask=0x0f"),
754 INTEL_UNCORE_EVENT_DESC(qhl_request_ioh_reads, "event=0x20,umask=0x01"),
755 INTEL_UNCORE_EVENT_DESC(qhl_request_ioh_writes, "event=0x20,umask=0x02"),
756 INTEL_UNCORE_EVENT_DESC(qhl_request_remote_reads, "event=0x20,umask=0x04"),
757 INTEL_UNCORE_EVENT_DESC(qhl_request_remote_writes, "event=0x20,umask=0x08"),
758 INTEL_UNCORE_EVENT_DESC(qhl_request_local_reads, "event=0x20,umask=0x10"),
759 INTEL_UNCORE_EVENT_DESC(qhl_request_local_writes, "event=0x20,umask=0x20"),
760 { /* end: all zeroes */ },
761};
762
763static struct intel_uncore_ops nhm_uncore_msr_ops = {
764 .disable_box = nhm_uncore_msr_disable_box,
765 .enable_box = nhm_uncore_msr_enable_box,
766 .disable_event = snb_uncore_msr_disable_event,
767 .enable_event = nhm_uncore_msr_enable_event,
768 .read_counter = uncore_msr_read_counter,
769};
770
771static struct intel_uncore_type nhm_uncore = {
772 .name = "",
773 .num_counters = 8,
774 .num_boxes = 1,
775 .perf_ctr_bits = 48,
776 .fixed_ctr_bits = 48,
777 .event_ctl = NHM_UNC_PERFEVTSEL0,
778 .perf_ctr = NHM_UNC_UNCORE_PMC0,
779 .fixed_ctr = NHM_UNC_FIXED_CTR,
780 .fixed_ctl = NHM_UNC_FIXED_CTR_CTRL,
781 .event_mask = NHM_UNC_RAW_EVENT_MASK,
782 .event_descs = nhm_uncore_events,
783 .ops = &nhm_uncore_msr_ops,
784 .format_group = &nhm_uncore_format_group,
785};
786
787static struct intel_uncore_type *nhm_msr_uncores[] = {
788 &nhm_uncore,
789 NULL,
790};
791/* end of Nehalem uncore support */
792
793/* Nehalem-EX uncore support */
794#define __BITS_VALUE(x, i, n) ((typeof(x))(((x) >> ((i) * (n))) & \
795 ((1ULL << (n)) - 1)))
796
797DEFINE_UNCORE_FORMAT_ATTR(event5, event, "config:1-5");
798DEFINE_UNCORE_FORMAT_ATTR(counter, counter, "config:6-7");
799DEFINE_UNCORE_FORMAT_ATTR(match, match, "config1:0-63");
800DEFINE_UNCORE_FORMAT_ATTR(mask, mask, "config2:0-63");
801
802static void nhmex_uncore_msr_init_box(struct intel_uncore_box *box)
803{
804 wrmsrl(NHMEX_U_MSR_PMON_GLOBAL_CTL, NHMEX_U_PMON_GLOBAL_EN_ALL);
805}
806
807static void nhmex_uncore_msr_disable_box(struct intel_uncore_box *box)
808{
809 unsigned msr = uncore_msr_box_ctl(box);
810 u64 config;
811
812 if (msr) {
813 rdmsrl(msr, config);
814 config &= ~((1ULL << uncore_num_counters(box)) - 1);
815 /* WBox has a fixed counter */
816 if (uncore_msr_fixed_ctl(box))
817 config &= ~NHMEX_W_PMON_GLOBAL_FIXED_EN;
818 wrmsrl(msr, config);
819 }
820}
821
822static void nhmex_uncore_msr_enable_box(struct intel_uncore_box *box)
823{
824 unsigned msr = uncore_msr_box_ctl(box);
825 u64 config;
826
827 if (msr) {
828 rdmsrl(msr, config);
829 config |= (1ULL << uncore_num_counters(box)) - 1;
830 /* WBox has a fixed counter */
831 if (uncore_msr_fixed_ctl(box))
832 config |= NHMEX_W_PMON_GLOBAL_FIXED_EN;
833 wrmsrl(msr, config);
834 }
835}
836
837static void nhmex_uncore_msr_disable_event(struct intel_uncore_box *box, struct perf_event *event)
838{
839 wrmsrl(event->hw.config_base, 0);
840}
841
842static void nhmex_uncore_msr_enable_event(struct intel_uncore_box *box, struct perf_event *event)
843{
844 struct hw_perf_event *hwc = &event->hw;
845
846 if (hwc->idx >= UNCORE_PMC_IDX_FIXED)
847 wrmsrl(hwc->config_base, NHMEX_PMON_CTL_EN_BIT0);
848 else if (box->pmu->type->event_mask & NHMEX_PMON_CTL_EN_BIT0)
849 wrmsrl(hwc->config_base, hwc->config | NHMEX_PMON_CTL_EN_BIT22);
850 else
851 wrmsrl(hwc->config_base, hwc->config | NHMEX_PMON_CTL_EN_BIT0);
852}
853
854#define NHMEX_UNCORE_OPS_COMMON_INIT() \
855 .init_box = nhmex_uncore_msr_init_box, \
856 .disable_box = nhmex_uncore_msr_disable_box, \
857 .enable_box = nhmex_uncore_msr_enable_box, \
858 .disable_event = nhmex_uncore_msr_disable_event, \
859 .read_counter = uncore_msr_read_counter
860
861static struct intel_uncore_ops nhmex_uncore_ops = {
862 NHMEX_UNCORE_OPS_COMMON_INIT(),
863 .enable_event = nhmex_uncore_msr_enable_event,
864};
865
866static struct attribute *nhmex_uncore_ubox_formats_attr[] = {
867 &format_attr_event.attr,
868 &format_attr_edge.attr,
869 NULL,
870};
871
872static struct attribute_group nhmex_uncore_ubox_format_group = {
873 .name = "format",
874 .attrs = nhmex_uncore_ubox_formats_attr,
875};
876
877static struct intel_uncore_type nhmex_uncore_ubox = {
878 .name = "ubox",
879 .num_counters = 1,
880 .num_boxes = 1,
881 .perf_ctr_bits = 48,
882 .event_ctl = NHMEX_U_MSR_PMON_EV_SEL,
883 .perf_ctr = NHMEX_U_MSR_PMON_CTR,
884 .event_mask = NHMEX_U_PMON_RAW_EVENT_MASK,
885 .box_ctl = NHMEX_U_MSR_PMON_GLOBAL_CTL,
886 .ops = &nhmex_uncore_ops,
887 .format_group = &nhmex_uncore_ubox_format_group
888};
889
890static struct attribute *nhmex_uncore_cbox_formats_attr[] = {
891 &format_attr_event.attr,
892 &format_attr_umask.attr,
893 &format_attr_edge.attr,
894 &format_attr_inv.attr,
895 &format_attr_thresh8.attr,
896 NULL,
897};
898
899static struct attribute_group nhmex_uncore_cbox_format_group = {
900 .name = "format",
901 .attrs = nhmex_uncore_cbox_formats_attr,
902};
903
904/* msr offset for each instance of cbox */
905static unsigned nhmex_cbox_msr_offsets[] = {
906 0x0, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x240, 0x2c0,
907};
908
909static struct intel_uncore_type nhmex_uncore_cbox = {
910 .name = "cbox",
911 .num_counters = 6,
912 .num_boxes = 10,
913 .perf_ctr_bits = 48,
914 .event_ctl = NHMEX_C0_MSR_PMON_EV_SEL0,
915 .perf_ctr = NHMEX_C0_MSR_PMON_CTR0,
916 .event_mask = NHMEX_PMON_RAW_EVENT_MASK,
917 .box_ctl = NHMEX_C0_MSR_PMON_GLOBAL_CTL,
918 .msr_offsets = nhmex_cbox_msr_offsets,
919 .pair_ctr_ctl = 1,
920 .ops = &nhmex_uncore_ops,
921 .format_group = &nhmex_uncore_cbox_format_group
922};
923
924static struct uncore_event_desc nhmex_uncore_wbox_events[] = {
925 INTEL_UNCORE_EVENT_DESC(clockticks, "event=0xff,umask=0"),
926 { /* end: all zeroes */ },
927};
928
929static struct intel_uncore_type nhmex_uncore_wbox = {
930 .name = "wbox",
931 .num_counters = 4,
932 .num_boxes = 1,
933 .perf_ctr_bits = 48,
934 .event_ctl = NHMEX_W_MSR_PMON_CNT0,
935 .perf_ctr = NHMEX_W_MSR_PMON_EVT_SEL0,
936 .fixed_ctr = NHMEX_W_MSR_PMON_FIXED_CTR,
937 .fixed_ctl = NHMEX_W_MSR_PMON_FIXED_CTL,
938 .event_mask = NHMEX_PMON_RAW_EVENT_MASK,
939 .box_ctl = NHMEX_W_MSR_GLOBAL_CTL,
940 .pair_ctr_ctl = 1,
941 .event_descs = nhmex_uncore_wbox_events,
942 .ops = &nhmex_uncore_ops,
943 .format_group = &nhmex_uncore_cbox_format_group
944};
945
946static int nhmex_bbox_hw_config(struct intel_uncore_box *box, struct perf_event *event)
947{
948 struct hw_perf_event *hwc = &event->hw;
949 struct hw_perf_event_extra *reg1 = &hwc->extra_reg;
950 struct hw_perf_event_extra *reg2 = &hwc->branch_reg;
951 int ctr, ev_sel;
952
953 ctr = (hwc->config & NHMEX_B_PMON_CTR_MASK) >>
954 NHMEX_B_PMON_CTR_SHIFT;
955 ev_sel = (hwc->config & NHMEX_B_PMON_CTL_EV_SEL_MASK) >>
956 NHMEX_B_PMON_CTL_EV_SEL_SHIFT;
957
958 /* events that do not use the match/mask registers */
959 if ((ctr == 0 && ev_sel > 0x3) || (ctr == 1 && ev_sel > 0x6) ||
960 (ctr == 2 && ev_sel != 0x4) || ctr == 3)
961 return 0;
962
963 if (box->pmu->pmu_idx == 0)
964 reg1->reg = NHMEX_B0_MSR_MATCH;
965 else
966 reg1->reg = NHMEX_B1_MSR_MATCH;
967 reg1->idx = 0;
968 reg1->config = event->attr.config1;
969 reg2->config = event->attr.config2;
970 return 0;
971}
972
973static void nhmex_bbox_msr_enable_event(struct intel_uncore_box *box, struct perf_event *event)
974{
975 struct hw_perf_event *hwc = &event->hw;
976 struct hw_perf_event_extra *reg1 = &hwc->extra_reg;
977 struct hw_perf_event_extra *reg2 = &hwc->branch_reg;
978
979 if (reg1->idx != EXTRA_REG_NONE) {
980 wrmsrl(reg1->reg, reg1->config);
981 wrmsrl(reg1->reg + 1, reg2->config);
982 }
983 wrmsrl(hwc->config_base, NHMEX_PMON_CTL_EN_BIT0 |
984 (hwc->config & NHMEX_B_PMON_CTL_EV_SEL_MASK));
985}
986
987/*
988 * The Bbox has 4 counters, but each counter monitors different events.
989 * Use bits 6-7 in the event config to select counter.
990 */
991static struct event_constraint nhmex_uncore_bbox_constraints[] = {
992 EVENT_CONSTRAINT(0 , 1, 0xc0),
993 EVENT_CONSTRAINT(0x40, 2, 0xc0),
994 EVENT_CONSTRAINT(0x80, 4, 0xc0),
995 EVENT_CONSTRAINT(0xc0, 8, 0xc0),
996 EVENT_CONSTRAINT_END,
997};
998
999static struct attribute *nhmex_uncore_bbox_formats_attr[] = {
1000 &format_attr_event5.attr,
1001 &format_attr_counter.attr,
1002 &format_attr_match.attr,
1003 &format_attr_mask.attr,
1004 NULL,
1005};
1006
1007static struct attribute_group nhmex_uncore_bbox_format_group = {
1008 .name = "format",
1009 .attrs = nhmex_uncore_bbox_formats_attr,
1010};
1011
1012static struct intel_uncore_ops nhmex_uncore_bbox_ops = {
1013 NHMEX_UNCORE_OPS_COMMON_INIT(),
1014 .enable_event = nhmex_bbox_msr_enable_event,
1015 .hw_config = nhmex_bbox_hw_config,
1016 .get_constraint = uncore_get_constraint,
1017 .put_constraint = uncore_put_constraint,
1018};
1019
1020static struct intel_uncore_type nhmex_uncore_bbox = {
1021 .name = "bbox",
1022 .num_counters = 4,
1023 .num_boxes = 2,
1024 .perf_ctr_bits = 48,
1025 .event_ctl = NHMEX_B0_MSR_PMON_CTL0,
1026 .perf_ctr = NHMEX_B0_MSR_PMON_CTR0,
1027 .event_mask = NHMEX_B_PMON_RAW_EVENT_MASK,
1028 .box_ctl = NHMEX_B0_MSR_PMON_GLOBAL_CTL,
1029 .msr_offset = NHMEX_B_MSR_OFFSET,
1030 .pair_ctr_ctl = 1,
1031 .num_shared_regs = 1,
1032 .constraints = nhmex_uncore_bbox_constraints,
1033 .ops = &nhmex_uncore_bbox_ops,
1034 .format_group = &nhmex_uncore_bbox_format_group
1035};
1036
1037static int nhmex_sbox_hw_config(struct intel_uncore_box *box, struct perf_event *event)
1038{
1039 struct hw_perf_event *hwc = &event->hw;
1040 struct hw_perf_event_extra *reg1 = &hwc->extra_reg;
1041 struct hw_perf_event_extra *reg2 = &hwc->branch_reg;
1042
1043 /* only TO_R_PROG_EV event uses the match/mask register */
1044 if ((hwc->config & NHMEX_PMON_CTL_EV_SEL_MASK) !=
1045 NHMEX_S_EVENT_TO_R_PROG_EV)
1046 return 0;
1047
1048 if (box->pmu->pmu_idx == 0)
1049 reg1->reg = NHMEX_S0_MSR_MM_CFG;
1050 else
1051 reg1->reg = NHMEX_S1_MSR_MM_CFG;
1052 reg1->idx = 0;
1053 reg1->config = event->attr.config1;
1054 reg2->config = event->attr.config2;
1055 return 0;
1056}
1057
1058static void nhmex_sbox_msr_enable_event(struct intel_uncore_box *box, struct perf_event *event)
1059{
1060 struct hw_perf_event *hwc = &event->hw;
1061 struct hw_perf_event_extra *reg1 = &hwc->extra_reg;
1062 struct hw_perf_event_extra *reg2 = &hwc->branch_reg;
1063
1064 if (reg1->idx != EXTRA_REG_NONE) {
1065 wrmsrl(reg1->reg, 0);
1066 wrmsrl(reg1->reg + 1, reg1->config);
1067 wrmsrl(reg1->reg + 2, reg2->config);
1068 wrmsrl(reg1->reg, NHMEX_S_PMON_MM_CFG_EN);
1069 }
1070 wrmsrl(hwc->config_base, hwc->config | NHMEX_PMON_CTL_EN_BIT22);
1071}
1072
1073static struct attribute *nhmex_uncore_sbox_formats_attr[] = {
1074 &format_attr_event.attr,
1075 &format_attr_umask.attr,
1076 &format_attr_edge.attr,
1077 &format_attr_inv.attr,
1078 &format_attr_thresh8.attr,
1079 &format_attr_match.attr,
1080 &format_attr_mask.attr,
1081 NULL,
1082};
1083
1084static struct attribute_group nhmex_uncore_sbox_format_group = {
1085 .name = "format",
1086 .attrs = nhmex_uncore_sbox_formats_attr,
1087};
1088
1089static struct intel_uncore_ops nhmex_uncore_sbox_ops = {
1090 NHMEX_UNCORE_OPS_COMMON_INIT(),
1091 .enable_event = nhmex_sbox_msr_enable_event,
1092 .hw_config = nhmex_sbox_hw_config,
1093 .get_constraint = uncore_get_constraint,
1094 .put_constraint = uncore_put_constraint,
1095};
1096
1097static struct intel_uncore_type nhmex_uncore_sbox = {
1098 .name = "sbox",
1099 .num_counters = 4,
1100 .num_boxes = 2,
1101 .perf_ctr_bits = 48,
1102 .event_ctl = NHMEX_S0_MSR_PMON_CTL0,
1103 .perf_ctr = NHMEX_S0_MSR_PMON_CTR0,
1104 .event_mask = NHMEX_PMON_RAW_EVENT_MASK,
1105 .box_ctl = NHMEX_S0_MSR_PMON_GLOBAL_CTL,
1106 .msr_offset = NHMEX_S_MSR_OFFSET,
1107 .pair_ctr_ctl = 1,
1108 .num_shared_regs = 1,
1109 .ops = &nhmex_uncore_sbox_ops,
1110 .format_group = &nhmex_uncore_sbox_format_group
1111};
1112
1113enum {
1114 EXTRA_REG_NHMEX_M_FILTER,
1115 EXTRA_REG_NHMEX_M_DSP,
1116 EXTRA_REG_NHMEX_M_ISS,
1117 EXTRA_REG_NHMEX_M_MAP,
1118 EXTRA_REG_NHMEX_M_MSC_THR,
1119 EXTRA_REG_NHMEX_M_PGT,
1120 EXTRA_REG_NHMEX_M_PLD,
1121 EXTRA_REG_NHMEX_M_ZDP_CTL_FVC,
1122};
1123
1124static struct extra_reg nhmex_uncore_mbox_extra_regs[] = {
1125 MBOX_INC_SEL_EXTAR_REG(0x0, DSP),
1126 MBOX_INC_SEL_EXTAR_REG(0x4, MSC_THR),
1127 MBOX_INC_SEL_EXTAR_REG(0x5, MSC_THR),
1128 MBOX_INC_SEL_EXTAR_REG(0x9, ISS),
1129 /* event 0xa uses two extra registers */
1130 MBOX_INC_SEL_EXTAR_REG(0xa, ISS),
1131 MBOX_INC_SEL_EXTAR_REG(0xa, PLD),
1132 MBOX_INC_SEL_EXTAR_REG(0xb, PLD),
1133 /* events 0xd ~ 0x10 use the same extra register */
1134 MBOX_INC_SEL_EXTAR_REG(0xd, ZDP_CTL_FVC),
1135 MBOX_INC_SEL_EXTAR_REG(0xe, ZDP_CTL_FVC),
1136 MBOX_INC_SEL_EXTAR_REG(0xf, ZDP_CTL_FVC),
1137 MBOX_INC_SEL_EXTAR_REG(0x10, ZDP_CTL_FVC),
1138 MBOX_INC_SEL_EXTAR_REG(0x16, PGT),
1139 MBOX_SET_FLAG_SEL_EXTRA_REG(0x0, DSP),
1140 MBOX_SET_FLAG_SEL_EXTRA_REG(0x1, ISS),
1141 MBOX_SET_FLAG_SEL_EXTRA_REG(0x5, PGT),
1142 MBOX_SET_FLAG_SEL_EXTRA_REG(0x6, MAP),
1143 EVENT_EXTRA_END
1144};
1145
1146/* Nehalem-EX or Westmere-EX ? */
1147bool uncore_nhmex;
1148
1149static bool nhmex_mbox_get_shared_reg(struct intel_uncore_box *box, int idx, u64 config)
1150{
1151 struct intel_uncore_extra_reg *er;
1152 unsigned long flags;
1153 bool ret = false;
1154 u64 mask;
1155
1156 if (idx < EXTRA_REG_NHMEX_M_ZDP_CTL_FVC) {
1157 er = &box->shared_regs[idx];
1158 raw_spin_lock_irqsave(&er->lock, flags);
1159 if (!atomic_read(&er->ref) || er->config == config) {
1160 atomic_inc(&er->ref);
1161 er->config = config;
1162 ret = true;
1163 }
1164 raw_spin_unlock_irqrestore(&er->lock, flags);
1165
1166 return ret;
1167 }
1168 /*
1169 * The ZDP_CTL_FVC MSR has 4 fields which are used to control
1170 * events 0xd ~ 0x10. Besides these 4 fields, there are additional
1171 * fields which are shared.
1172 */
1173 idx -= EXTRA_REG_NHMEX_M_ZDP_CTL_FVC;
1174 if (WARN_ON_ONCE(idx >= 4))
1175 return false;
1176
1177 /* mask of the shared fields */
1178 if (uncore_nhmex)
1179 mask = NHMEX_M_PMON_ZDP_CTL_FVC_MASK;
1180 else
1181 mask = WSMEX_M_PMON_ZDP_CTL_FVC_MASK;
1182 er = &box->shared_regs[EXTRA_REG_NHMEX_M_ZDP_CTL_FVC];
1183
1184 raw_spin_lock_irqsave(&er->lock, flags);
1185 /* add mask of the non-shared field if it's in use */
1186 if (__BITS_VALUE(atomic_read(&er->ref), idx, 8)) {
1187 if (uncore_nhmex)
1188 mask |= NHMEX_M_PMON_ZDP_CTL_FVC_EVENT_MASK(idx);
1189 else
1190 mask |= WSMEX_M_PMON_ZDP_CTL_FVC_EVENT_MASK(idx);
1191 }
1192
1193 if (!atomic_read(&er->ref) || !((er->config ^ config) & mask)) {
1194 atomic_add(1 << (idx * 8), &er->ref);
1195 if (uncore_nhmex)
1196 mask = NHMEX_M_PMON_ZDP_CTL_FVC_MASK |
1197 NHMEX_M_PMON_ZDP_CTL_FVC_EVENT_MASK(idx);
1198 else
1199 mask = WSMEX_M_PMON_ZDP_CTL_FVC_MASK |
1200 WSMEX_M_PMON_ZDP_CTL_FVC_EVENT_MASK(idx);
1201 er->config &= ~mask;
1202 er->config |= (config & mask);
1203 ret = true;
1204 }
1205 raw_spin_unlock_irqrestore(&er->lock, flags);
1206
1207 return ret;
1208}
1209
1210static void nhmex_mbox_put_shared_reg(struct intel_uncore_box *box, int idx)
1211{
1212 struct intel_uncore_extra_reg *er;
1213
1214 if (idx < EXTRA_REG_NHMEX_M_ZDP_CTL_FVC) {
1215 er = &box->shared_regs[idx];
1216 atomic_dec(&er->ref);
1217 return;
1218 }
1219
1220 idx -= EXTRA_REG_NHMEX_M_ZDP_CTL_FVC;
1221 er = &box->shared_regs[EXTRA_REG_NHMEX_M_ZDP_CTL_FVC];
1222 atomic_sub(1 << (idx * 8), &er->ref);
1223}
1224
1225u64 nhmex_mbox_alter_er(struct perf_event *event, int new_idx, bool modify)
1226{
1227 struct hw_perf_event *hwc = &event->hw;
1228 struct hw_perf_event_extra *reg1 = &hwc->extra_reg;
1229 int idx, orig_idx = __BITS_VALUE(reg1->idx, 0, 8);
1230 u64 config = reg1->config;
1231
1232 /* get the non-shared control bits and shift them */
1233 idx = orig_idx - EXTRA_REG_NHMEX_M_ZDP_CTL_FVC;
1234 if (uncore_nhmex)
1235 config &= NHMEX_M_PMON_ZDP_CTL_FVC_EVENT_MASK(idx);
1236 else
1237 config &= WSMEX_M_PMON_ZDP_CTL_FVC_EVENT_MASK(idx);
1238 if (new_idx > orig_idx) {
1239 idx = new_idx - orig_idx;
1240 config <<= 3 * idx;
1241 } else {
1242 idx = orig_idx - new_idx;
1243 config >>= 3 * idx;
1244 }
1245
1246 /* add the shared control bits back */
1247 if (uncore_nhmex)
1248 config |= NHMEX_M_PMON_ZDP_CTL_FVC_MASK & reg1->config;
1249 else
1250 config |= WSMEX_M_PMON_ZDP_CTL_FVC_MASK & reg1->config;
1251 config |= NHMEX_M_PMON_ZDP_CTL_FVC_MASK & reg1->config;
1252 if (modify) {
1253 /* adjust the main event selector */
1254 if (new_idx > orig_idx)
1255 hwc->config += idx << NHMEX_M_PMON_CTL_INC_SEL_SHIFT;
1256 else
1257 hwc->config -= idx << NHMEX_M_PMON_CTL_INC_SEL_SHIFT;
1258 reg1->config = config;
1259 reg1->idx = ~0xff | new_idx;
1260 }
1261 return config;
1262}
1263
1264static struct event_constraint *
1265nhmex_mbox_get_constraint(struct intel_uncore_box *box, struct perf_event *event)
1266{
1267 struct hw_perf_event_extra *reg1 = &event->hw.extra_reg;
1268 struct hw_perf_event_extra *reg2 = &event->hw.branch_reg;
1269 int i, idx[2], alloc = 0;
1270 u64 config1 = reg1->config;
1271
1272 idx[0] = __BITS_VALUE(reg1->idx, 0, 8);
1273 idx[1] = __BITS_VALUE(reg1->idx, 1, 8);
1274again:
1275 for (i = 0; i < 2; i++) {
1276 if (!uncore_box_is_fake(box) && (reg1->alloc & (0x1 << i)))
1277 idx[i] = 0xff;
1278
1279 if (idx[i] == 0xff)
1280 continue;
1281
1282 if (!nhmex_mbox_get_shared_reg(box, idx[i],
1283 __BITS_VALUE(config1, i, 32)))
1284 goto fail;
1285 alloc |= (0x1 << i);
1286 }
1287
1288 /* for the match/mask registers */
1289 if (reg2->idx != EXTRA_REG_NONE &&
1290 (uncore_box_is_fake(box) || !reg2->alloc) &&
1291 !nhmex_mbox_get_shared_reg(box, reg2->idx, reg2->config))
1292 goto fail;
1293
1294 /*
1295 * If it's a fake box -- as per validate_{group,event}() we
1296 * shouldn't touch event state and we can avoid doing so
1297 * since both will only call get_event_constraints() once
1298 * on each event, this avoids the need for reg->alloc.
1299 */
1300 if (!uncore_box_is_fake(box)) {
1301 if (idx[0] != 0xff && idx[0] != __BITS_VALUE(reg1->idx, 0, 8))
1302 nhmex_mbox_alter_er(event, idx[0], true);
1303 reg1->alloc |= alloc;
1304 if (reg2->idx != EXTRA_REG_NONE)
1305 reg2->alloc = 1;
1306 }
1307 return NULL;
1308fail:
1309 if (idx[0] != 0xff && !(alloc & 0x1) &&
1310 idx[0] >= EXTRA_REG_NHMEX_M_ZDP_CTL_FVC) {
1311 /*
1312 * events 0xd ~ 0x10 are functional identical, but are
1313 * controlled by different fields in the ZDP_CTL_FVC
1314 * register. If we failed to take one field, try the
1315 * rest 3 choices.
1316 */
1317 BUG_ON(__BITS_VALUE(reg1->idx, 1, 8) != 0xff);
1318 idx[0] -= EXTRA_REG_NHMEX_M_ZDP_CTL_FVC;
1319 idx[0] = (idx[0] + 1) % 4;
1320 idx[0] += EXTRA_REG_NHMEX_M_ZDP_CTL_FVC;
1321 if (idx[0] != __BITS_VALUE(reg1->idx, 0, 8)) {
1322 config1 = nhmex_mbox_alter_er(event, idx[0], false);
1323 goto again;
1324 }
1325 }
1326
1327 if (alloc & 0x1)
1328 nhmex_mbox_put_shared_reg(box, idx[0]);
1329 if (alloc & 0x2)
1330 nhmex_mbox_put_shared_reg(box, idx[1]);
1331 return &constraint_empty;
1332}
1333
1334static void nhmex_mbox_put_constraint(struct intel_uncore_box *box, struct perf_event *event)
1335{
1336 struct hw_perf_event_extra *reg1 = &event->hw.extra_reg;
1337 struct hw_perf_event_extra *reg2 = &event->hw.branch_reg;
1338
1339 if (uncore_box_is_fake(box))
1340 return;
1341
1342 if (reg1->alloc & 0x1)
1343 nhmex_mbox_put_shared_reg(box, __BITS_VALUE(reg1->idx, 0, 8));
1344 if (reg1->alloc & 0x2)
1345 nhmex_mbox_put_shared_reg(box, __BITS_VALUE(reg1->idx, 1, 8));
1346 reg1->alloc = 0;
1347
1348 if (reg2->alloc) {
1349 nhmex_mbox_put_shared_reg(box, reg2->idx);
1350 reg2->alloc = 0;
1351 }
1352}
1353
1354static int nhmex_mbox_extra_reg_idx(struct extra_reg *er)
1355{
1356 if (er->idx < EXTRA_REG_NHMEX_M_ZDP_CTL_FVC)
1357 return er->idx;
1358 return er->idx + (er->event >> NHMEX_M_PMON_CTL_INC_SEL_SHIFT) - 0xd;
1359}
1360
1361static int nhmex_mbox_hw_config(struct intel_uncore_box *box, struct perf_event *event)
1362{
1363 struct intel_uncore_type *type = box->pmu->type;
1364 struct hw_perf_event_extra *reg1 = &event->hw.extra_reg;
1365 struct hw_perf_event_extra *reg2 = &event->hw.branch_reg;
1366 struct extra_reg *er;
1367 unsigned msr;
1368 int reg_idx = 0;
1369 /*
1370 * The mbox events may require 2 extra MSRs at the most. But only
1371 * the lower 32 bits in these MSRs are significant, so we can use
1372 * config1 to pass two MSRs' config.
1373 */
1374 for (er = nhmex_uncore_mbox_extra_regs; er->msr; er++) {
1375 if (er->event != (event->hw.config & er->config_mask))
1376 continue;
1377 if (event->attr.config1 & ~er->valid_mask)
1378 return -EINVAL;
1379
1380 msr = er->msr + type->msr_offset * box->pmu->pmu_idx;
1381 if (WARN_ON_ONCE(msr >= 0xffff || er->idx >= 0xff))
1382 return -EINVAL;
1383
1384 /* always use the 32~63 bits to pass the PLD config */
1385 if (er->idx == EXTRA_REG_NHMEX_M_PLD)
1386 reg_idx = 1;
1387 else if (WARN_ON_ONCE(reg_idx > 0))
1388 return -EINVAL;
1389
1390 reg1->idx &= ~(0xff << (reg_idx * 8));
1391 reg1->reg &= ~(0xffff << (reg_idx * 16));
1392 reg1->idx |= nhmex_mbox_extra_reg_idx(er) << (reg_idx * 8);
1393 reg1->reg |= msr << (reg_idx * 16);
1394 reg1->config = event->attr.config1;
1395 reg_idx++;
1396 }
1397 /*
1398 * The mbox only provides ability to perform address matching
1399 * for the PLD events.
1400 */
1401 if (reg_idx == 2) {
1402 reg2->idx = EXTRA_REG_NHMEX_M_FILTER;
1403 if (event->attr.config2 & NHMEX_M_PMON_MM_CFG_EN)
1404 reg2->config = event->attr.config2;
1405 else
1406 reg2->config = ~0ULL;
1407 if (box->pmu->pmu_idx == 0)
1408 reg2->reg = NHMEX_M0_MSR_PMU_MM_CFG;
1409 else
1410 reg2->reg = NHMEX_M1_MSR_PMU_MM_CFG;
1411 }
1412 return 0;
1413}
1414
1415static u64 nhmex_mbox_shared_reg_config(struct intel_uncore_box *box, int idx)
1416{
1417 struct intel_uncore_extra_reg *er;
1418 unsigned long flags;
1419 u64 config;
1420
1421 if (idx < EXTRA_REG_NHMEX_M_ZDP_CTL_FVC)
1422 return box->shared_regs[idx].config;
1423
1424 er = &box->shared_regs[EXTRA_REG_NHMEX_M_ZDP_CTL_FVC];
1425 raw_spin_lock_irqsave(&er->lock, flags);
1426 config = er->config;
1427 raw_spin_unlock_irqrestore(&er->lock, flags);
1428 return config;
1429}
1430
1431static void nhmex_mbox_msr_enable_event(struct intel_uncore_box *box, struct perf_event *event)
1432{
1433 struct hw_perf_event *hwc = &event->hw;
1434 struct hw_perf_event_extra *reg1 = &hwc->extra_reg;
1435 struct hw_perf_event_extra *reg2 = &hwc->branch_reg;
1436 int idx;
1437
1438 idx = __BITS_VALUE(reg1->idx, 0, 8);
1439 if (idx != 0xff)
1440 wrmsrl(__BITS_VALUE(reg1->reg, 0, 16),
1441 nhmex_mbox_shared_reg_config(box, idx));
1442 idx = __BITS_VALUE(reg1->idx, 1, 8);
1443 if (idx != 0xff)
1444 wrmsrl(__BITS_VALUE(reg1->reg, 1, 16),
1445 nhmex_mbox_shared_reg_config(box, idx));
1446
1447 if (reg2->idx != EXTRA_REG_NONE) {
1448 wrmsrl(reg2->reg, 0);
1449 if (reg2->config != ~0ULL) {
1450 wrmsrl(reg2->reg + 1,
1451 reg2->config & NHMEX_M_PMON_ADDR_MATCH_MASK);
1452 wrmsrl(reg2->reg + 2, NHMEX_M_PMON_ADDR_MASK_MASK &
1453 (reg2->config >> NHMEX_M_PMON_ADDR_MASK_SHIFT));
1454 wrmsrl(reg2->reg, NHMEX_M_PMON_MM_CFG_EN);
1455 }
1456 }
1457
1458 wrmsrl(hwc->config_base, hwc->config | NHMEX_PMON_CTL_EN_BIT0);
1459}
1460
1461DEFINE_UNCORE_FORMAT_ATTR(count_mode, count_mode, "config:2-3");
1462DEFINE_UNCORE_FORMAT_ATTR(storage_mode, storage_mode, "config:4-5");
1463DEFINE_UNCORE_FORMAT_ATTR(wrap_mode, wrap_mode, "config:6");
1464DEFINE_UNCORE_FORMAT_ATTR(flag_mode, flag_mode, "config:7");
1465DEFINE_UNCORE_FORMAT_ATTR(inc_sel, inc_sel, "config:9-13");
1466DEFINE_UNCORE_FORMAT_ATTR(set_flag_sel, set_flag_sel, "config:19-21");
1467DEFINE_UNCORE_FORMAT_ATTR(filter_cfg_en, filter_cfg_en, "config2:63");
1468DEFINE_UNCORE_FORMAT_ATTR(filter_match, filter_match, "config2:0-33");
1469DEFINE_UNCORE_FORMAT_ATTR(filter_mask, filter_mask, "config2:34-61");
1470DEFINE_UNCORE_FORMAT_ATTR(dsp, dsp, "config1:0-31");
1471DEFINE_UNCORE_FORMAT_ATTR(thr, thr, "config1:0-31");
1472DEFINE_UNCORE_FORMAT_ATTR(fvc, fvc, "config1:0-31");
1473DEFINE_UNCORE_FORMAT_ATTR(pgt, pgt, "config1:0-31");
1474DEFINE_UNCORE_FORMAT_ATTR(map, map, "config1:0-31");
1475DEFINE_UNCORE_FORMAT_ATTR(iss, iss, "config1:0-31");
1476DEFINE_UNCORE_FORMAT_ATTR(pld, pld, "config1:32-63");
1477
1478static struct attribute *nhmex_uncore_mbox_formats_attr[] = {
1479 &format_attr_count_mode.attr,
1480 &format_attr_storage_mode.attr,
1481 &format_attr_wrap_mode.attr,
1482 &format_attr_flag_mode.attr,
1483 &format_attr_inc_sel.attr,
1484 &format_attr_set_flag_sel.attr,
1485 &format_attr_filter_cfg_en.attr,
1486 &format_attr_filter_match.attr,
1487 &format_attr_filter_mask.attr,
1488 &format_attr_dsp.attr,
1489 &format_attr_thr.attr,
1490 &format_attr_fvc.attr,
1491 &format_attr_pgt.attr,
1492 &format_attr_map.attr,
1493 &format_attr_iss.attr,
1494 &format_attr_pld.attr,
1495 NULL,
1496};
1497
1498static struct attribute_group nhmex_uncore_mbox_format_group = {
1499 .name = "format",
1500 .attrs = nhmex_uncore_mbox_formats_attr,
1501};
1502
1503static struct uncore_event_desc nhmex_uncore_mbox_events[] = {
1504 INTEL_UNCORE_EVENT_DESC(bbox_cmds_read, "inc_sel=0xd,fvc=0x2800"),
1505 INTEL_UNCORE_EVENT_DESC(bbox_cmds_write, "inc_sel=0xd,fvc=0x2820"),
1506 { /* end: all zeroes */ },
1507};
1508
1509static struct uncore_event_desc wsmex_uncore_mbox_events[] = {
1510 INTEL_UNCORE_EVENT_DESC(bbox_cmds_read, "inc_sel=0xd,fvc=0x5000"),
1511 INTEL_UNCORE_EVENT_DESC(bbox_cmds_write, "inc_sel=0xd,fvc=0x5040"),
1512 { /* end: all zeroes */ },
1513};
1514
1515static struct intel_uncore_ops nhmex_uncore_mbox_ops = {
1516 NHMEX_UNCORE_OPS_COMMON_INIT(),
1517 .enable_event = nhmex_mbox_msr_enable_event,
1518 .hw_config = nhmex_mbox_hw_config,
1519 .get_constraint = nhmex_mbox_get_constraint,
1520 .put_constraint = nhmex_mbox_put_constraint,
1521};
1522
1523static struct intel_uncore_type nhmex_uncore_mbox = {
1524 .name = "mbox",
1525 .num_counters = 6,
1526 .num_boxes = 2,
1527 .perf_ctr_bits = 48,
1528 .event_ctl = NHMEX_M0_MSR_PMU_CTL0,
1529 .perf_ctr = NHMEX_M0_MSR_PMU_CNT0,
1530 .event_mask = NHMEX_M_PMON_RAW_EVENT_MASK,
1531 .box_ctl = NHMEX_M0_MSR_GLOBAL_CTL,
1532 .msr_offset = NHMEX_M_MSR_OFFSET,
1533 .pair_ctr_ctl = 1,
1534 .num_shared_regs = 8,
1535 .event_descs = nhmex_uncore_mbox_events,
1536 .ops = &nhmex_uncore_mbox_ops,
1537 .format_group = &nhmex_uncore_mbox_format_group,
1538};
1539
1540void nhmex_rbox_alter_er(struct intel_uncore_box *box, struct perf_event *event)
1541{
1542 struct hw_perf_event *hwc = &event->hw;
1543 struct hw_perf_event_extra *reg1 = &hwc->extra_reg;
1544 int port;
1545
1546 /* adjust the main event selector and extra register index */
1547 if (reg1->idx % 2) {
1548 reg1->idx--;
1549 hwc->config -= 1 << NHMEX_R_PMON_CTL_EV_SEL_SHIFT;
1550 } else {
1551 reg1->idx++;
1552 hwc->config += 1 << NHMEX_R_PMON_CTL_EV_SEL_SHIFT;
1553 }
1554
1555 /* adjust extra register config */
1556 port = reg1->idx / 6 + box->pmu->pmu_idx * 4;
1557 switch (reg1->idx % 6) {
1558 case 2:
1559 /* shift the 8~15 bits to the 0~7 bits */
1560 reg1->config >>= 8;
1561 break;
1562 case 3:
1563 /* shift the 0~7 bits to the 8~15 bits */
1564 reg1->config <<= 8;
1565 break;
1566 };
1567}
1568
1569/*
1570 * Each rbox has 4 event set which monitor PQI port 0~3 or 4~7.
1571 * An event set consists of 6 events, the 3rd and 4th events in
1572 * an event set use the same extra register. So an event set uses
1573 * 5 extra registers.
1574 */
1575static struct event_constraint *
1576nhmex_rbox_get_constraint(struct intel_uncore_box *box, struct perf_event *event)
1577{
1578 struct hw_perf_event *hwc = &event->hw;
1579 struct hw_perf_event_extra *reg1 = &hwc->extra_reg;
1580 struct hw_perf_event_extra *reg2 = &hwc->branch_reg;
1581 struct intel_uncore_extra_reg *er;
1582 unsigned long flags;
1583 int idx, er_idx;
1584 u64 config1;
1585 bool ok = false;
1586
1587 if (!uncore_box_is_fake(box) && reg1->alloc)
1588 return NULL;
1589
1590 idx = reg1->idx % 6;
1591 config1 = reg1->config;
1592again:
1593 er_idx = idx;
1594 /* the 3rd and 4th events use the same extra register */
1595 if (er_idx > 2)
1596 er_idx--;
1597 er_idx += (reg1->idx / 6) * 5;
1598
1599 er = &box->shared_regs[er_idx];
1600 raw_spin_lock_irqsave(&er->lock, flags);
1601 if (idx < 2) {
1602 if (!atomic_read(&er->ref) || er->config == reg1->config) {
1603 atomic_inc(&er->ref);
1604 er->config = reg1->config;
1605 ok = true;
1606 }
1607 } else if (idx == 2 || idx == 3) {
1608 /*
1609 * these two events use different fields in a extra register,
1610 * the 0~7 bits and the 8~15 bits respectively.
1611 */
1612 u64 mask = 0xff << ((idx - 2) * 8);
1613 if (!__BITS_VALUE(atomic_read(&er->ref), idx - 2, 8) ||
1614 !((er->config ^ config1) & mask)) {
1615 atomic_add(1 << ((idx - 2) * 8), &er->ref);
1616 er->config &= ~mask;
1617 er->config |= config1 & mask;
1618 ok = true;
1619 }
1620 } else {
1621 if (!atomic_read(&er->ref) ||
1622 (er->config == (hwc->config >> 32) &&
1623 er->config1 == reg1->config &&
1624 er->config2 == reg2->config)) {
1625 atomic_inc(&er->ref);
1626 er->config = (hwc->config >> 32);
1627 er->config1 = reg1->config;
1628 er->config2 = reg2->config;
1629 ok = true;
1630 }
1631 }
1632 raw_spin_unlock_irqrestore(&er->lock, flags);
1633
1634 if (!ok) {
1635 /*
1636 * The Rbox events are always in pairs. The paired
1637 * events are functional identical, but use different
1638 * extra registers. If we failed to take an extra
1639 * register, try the alternative.
1640 */
1641 if (idx % 2)
1642 idx--;
1643 else
1644 idx++;
1645 if (idx != reg1->idx % 6) {
1646 if (idx == 2)
1647 config1 >>= 8;
1648 else if (idx == 3)
1649 config1 <<= 8;
1650 goto again;
1651 }
1652 } else {
1653 if (!uncore_box_is_fake(box)) {
1654 if (idx != reg1->idx % 6)
1655 nhmex_rbox_alter_er(box, event);
1656 reg1->alloc = 1;
1657 }
1658 return NULL;
1659 }
1660 return &constraint_empty;
1661}
1662
1663static void nhmex_rbox_put_constraint(struct intel_uncore_box *box, struct perf_event *event)
1664{
1665 struct intel_uncore_extra_reg *er;
1666 struct hw_perf_event_extra *reg1 = &event->hw.extra_reg;
1667 int idx, er_idx;
1668
1669 if (uncore_box_is_fake(box) || !reg1->alloc)
1670 return;
1671
1672 idx = reg1->idx % 6;
1673 er_idx = idx;
1674 if (er_idx > 2)
1675 er_idx--;
1676 er_idx += (reg1->idx / 6) * 5;
1677
1678 er = &box->shared_regs[er_idx];
1679 if (idx == 2 || idx == 3)
1680 atomic_sub(1 << ((idx - 2) * 8), &er->ref);
1681 else
1682 atomic_dec(&er->ref);
1683
1684 reg1->alloc = 0;
1685}
1686
1687static int nhmex_rbox_hw_config(struct intel_uncore_box *box, struct perf_event *event)
1688{
1689 struct hw_perf_event *hwc = &event->hw;
1690 struct hw_perf_event_extra *reg1 = &event->hw.extra_reg;
1691 struct hw_perf_event_extra *reg2 = &event->hw.branch_reg;
1692 int idx;
1693
1694 idx = (event->hw.config & NHMEX_R_PMON_CTL_EV_SEL_MASK) >>
1695 NHMEX_R_PMON_CTL_EV_SEL_SHIFT;
1696 if (idx >= 0x18)
1697 return -EINVAL;
1698
1699 reg1->idx = idx;
1700 reg1->config = event->attr.config1;
1701
1702 switch (idx % 6) {
1703 case 4:
1704 case 5:
1705 hwc->config |= event->attr.config & (~0ULL << 32);
1706 reg2->config = event->attr.config2;
1707 break;
1708 };
1709 return 0;
1710}
1711
1712static u64 nhmex_rbox_shared_reg_config(struct intel_uncore_box *box, int idx)
1713{
1714 struct intel_uncore_extra_reg *er;
1715 unsigned long flags;
1716 u64 config;
1717
1718 er = &box->shared_regs[idx];
1719
1720 raw_spin_lock_irqsave(&er->lock, flags);
1721 config = er->config;
1722 raw_spin_unlock_irqrestore(&er->lock, flags);
1723
1724 return config;
1725}
1726
1727static void nhmex_rbox_msr_enable_event(struct intel_uncore_box *box, struct perf_event *event)
1728{
1729 struct hw_perf_event *hwc = &event->hw;
1730 struct hw_perf_event_extra *reg1 = &hwc->extra_reg;
1731 struct hw_perf_event_extra *reg2 = &hwc->branch_reg;
1732 int idx, port;
1733
1734 idx = reg1->idx;
1735 port = idx / 6 + box->pmu->pmu_idx * 4;
1736
1737 switch (idx % 6) {
1738 case 0:
1739 wrmsrl(NHMEX_R_MSR_PORTN_IPERF_CFG0(port), reg1->config);
1740 break;
1741 case 1:
1742 wrmsrl(NHMEX_R_MSR_PORTN_IPERF_CFG1(port), reg1->config);
1743 break;
1744 case 2:
1745 case 3:
1746 wrmsrl(NHMEX_R_MSR_PORTN_QLX_CFG(port),
1747 nhmex_rbox_shared_reg_config(box, 2 + (idx / 6) * 5));
1748 break;
1749 case 4:
1750 wrmsrl(NHMEX_R_MSR_PORTN_XBR_SET1_MM_CFG(port),
1751 hwc->config >> 32);
1752 wrmsrl(NHMEX_R_MSR_PORTN_XBR_SET1_MATCH(port), reg1->config);
1753 wrmsrl(NHMEX_R_MSR_PORTN_XBR_SET1_MASK(port), reg2->config);
1754 break;
1755 case 5:
1756 wrmsrl(NHMEX_R_MSR_PORTN_XBR_SET2_MM_CFG(port),
1757 hwc->config >> 32);
1758 wrmsrl(NHMEX_R_MSR_PORTN_XBR_SET2_MATCH(port), reg1->config);
1759 wrmsrl(NHMEX_R_MSR_PORTN_XBR_SET2_MASK(port), reg2->config);
1760 break;
1761 };
1762
1763 wrmsrl(hwc->config_base, NHMEX_PMON_CTL_EN_BIT0 |
1764 (hwc->config & NHMEX_R_PMON_CTL_EV_SEL_MASK));
1765}
1766
1767DEFINE_UNCORE_FORMAT_ATTR(xbr_mm_cfg, xbr_mm_cfg, "config:32-63");
1768DEFINE_UNCORE_FORMAT_ATTR(xbr_match, xbr_match, "config1:0-63");
1769DEFINE_UNCORE_FORMAT_ATTR(xbr_mask, xbr_mask, "config2:0-63");
1770DEFINE_UNCORE_FORMAT_ATTR(qlx_cfg, qlx_cfg, "config1:0-15");
1771DEFINE_UNCORE_FORMAT_ATTR(iperf_cfg, iperf_cfg, "config1:0-31");
1772
1773static struct attribute *nhmex_uncore_rbox_formats_attr[] = {
1774 &format_attr_event5.attr,
1775 &format_attr_xbr_mm_cfg.attr,
1776 &format_attr_xbr_match.attr,
1777 &format_attr_xbr_mask.attr,
1778 &format_attr_qlx_cfg.attr,
1779 &format_attr_iperf_cfg.attr,
1780 NULL,
1781};
1782
1783static struct attribute_group nhmex_uncore_rbox_format_group = {
1784 .name = "format",
1785 .attrs = nhmex_uncore_rbox_formats_attr,
1786};
1787
1788static struct uncore_event_desc nhmex_uncore_rbox_events[] = {
1789 INTEL_UNCORE_EVENT_DESC(qpi0_flit_send, "event=0x0,iperf_cfg=0x80000000"),
1790 INTEL_UNCORE_EVENT_DESC(qpi1_filt_send, "event=0x6,iperf_cfg=0x80000000"),
1791 INTEL_UNCORE_EVENT_DESC(qpi0_idle_filt, "event=0x0,iperf_cfg=0x40000000"),
1792 INTEL_UNCORE_EVENT_DESC(qpi1_idle_filt, "event=0x6,iperf_cfg=0x40000000"),
1793 INTEL_UNCORE_EVENT_DESC(qpi0_date_response, "event=0x0,iperf_cfg=0xc4"),
1794 INTEL_UNCORE_EVENT_DESC(qpi1_date_response, "event=0x6,iperf_cfg=0xc4"),
1795 { /* end: all zeroes */ },
1796};
1797
1798static struct intel_uncore_ops nhmex_uncore_rbox_ops = {
1799 NHMEX_UNCORE_OPS_COMMON_INIT(),
1800 .enable_event = nhmex_rbox_msr_enable_event,
1801 .hw_config = nhmex_rbox_hw_config,
1802 .get_constraint = nhmex_rbox_get_constraint,
1803 .put_constraint = nhmex_rbox_put_constraint,
1804};
1805
1806static struct intel_uncore_type nhmex_uncore_rbox = {
1807 .name = "rbox",
1808 .num_counters = 8,
1809 .num_boxes = 2,
1810 .perf_ctr_bits = 48,
1811 .event_ctl = NHMEX_R_MSR_PMON_CTL0,
1812 .perf_ctr = NHMEX_R_MSR_PMON_CNT0,
1813 .event_mask = NHMEX_R_PMON_RAW_EVENT_MASK,
1814 .box_ctl = NHMEX_R_MSR_GLOBAL_CTL,
1815 .msr_offset = NHMEX_R_MSR_OFFSET,
1816 .pair_ctr_ctl = 1,
1817 .num_shared_regs = 20,
1818 .event_descs = nhmex_uncore_rbox_events,
1819 .ops = &nhmex_uncore_rbox_ops,
1820 .format_group = &nhmex_uncore_rbox_format_group
1821};
1822
1823static struct intel_uncore_type *nhmex_msr_uncores[] = {
1824 &nhmex_uncore_ubox,
1825 &nhmex_uncore_cbox,
1826 &nhmex_uncore_bbox,
1827 &nhmex_uncore_sbox,
1828 &nhmex_uncore_mbox,
1829 &nhmex_uncore_rbox,
1830 &nhmex_uncore_wbox,
1831 NULL,
1832};
1833/* end of Nehalem-EX uncore support */
1834
1835static void uncore_assign_hw_event(struct intel_uncore_box *box, struct perf_event *event, int idx)
1836{
1837 struct hw_perf_event *hwc = &event->hw;
1838
1839 hwc->idx = idx;
1840 hwc->last_tag = ++box->tags[idx];
1841
1842 if (hwc->idx == UNCORE_PMC_IDX_FIXED) {
1843 hwc->event_base = uncore_fixed_ctr(box);
1844 hwc->config_base = uncore_fixed_ctl(box);
1845 return;
1846 }
1847
1848 hwc->config_base = uncore_event_ctl(box, hwc->idx);
1849 hwc->event_base = uncore_perf_ctr(box, hwc->idx);
1850}
1851
1852static void uncore_perf_event_update(struct intel_uncore_box *box, struct perf_event *event)
1853{
1854 u64 prev_count, new_count, delta;
1855 int shift;
1856
1857 if (event->hw.idx >= UNCORE_PMC_IDX_FIXED)
1858 shift = 64 - uncore_fixed_ctr_bits(box);
1859 else
1860 shift = 64 - uncore_perf_ctr_bits(box);
1861
1862 /* the hrtimer might modify the previous event value */
1863again:
1864 prev_count = local64_read(&event->hw.prev_count);
1865 new_count = uncore_read_counter(box, event);
1866 if (local64_xchg(&event->hw.prev_count, new_count) != prev_count)
1867 goto again;
1868
1869 delta = (new_count << shift) - (prev_count << shift);
1870 delta >>= shift;
1871
1872 local64_add(delta, &event->count);
1873}
1874
1875/*
1876 * The overflow interrupt is unavailable for SandyBridge-EP, is broken
1877 * for SandyBridge. So we use hrtimer to periodically poll the counter
1878 * to avoid overflow.
1879 */
1880static enum hrtimer_restart uncore_pmu_hrtimer(struct hrtimer *hrtimer)
1881{
1882 struct intel_uncore_box *box;
1883 unsigned long flags;
1884 int bit;
1885
1886 box = container_of(hrtimer, struct intel_uncore_box, hrtimer);
1887 if (!box->n_active || box->cpu != smp_processor_id())
1888 return HRTIMER_NORESTART;
1889 /*
1890 * disable local interrupt to prevent uncore_pmu_event_start/stop
1891 * to interrupt the update process
1892 */
1893 local_irq_save(flags);
1894
1895 for_each_set_bit(bit, box->active_mask, UNCORE_PMC_IDX_MAX)
1896 uncore_perf_event_update(box, box->events[bit]);
1897
1898 local_irq_restore(flags);
1899
1900 hrtimer_forward_now(hrtimer, ns_to_ktime(UNCORE_PMU_HRTIMER_INTERVAL));
1901 return HRTIMER_RESTART;
1902}
1903
1904static void uncore_pmu_start_hrtimer(struct intel_uncore_box *box)
1905{
1906 __hrtimer_start_range_ns(&box->hrtimer,
1907 ns_to_ktime(UNCORE_PMU_HRTIMER_INTERVAL), 0,
1908 HRTIMER_MODE_REL_PINNED, 0);
1909}
1910
1911static void uncore_pmu_cancel_hrtimer(struct intel_uncore_box *box)
1912{
1913 hrtimer_cancel(&box->hrtimer);
1914}
1915
1916static void uncore_pmu_init_hrtimer(struct intel_uncore_box *box)
1917{
1918 hrtimer_init(&box->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
1919 box->hrtimer.function = uncore_pmu_hrtimer;
1920}
1921
1922struct intel_uncore_box *uncore_alloc_box(struct intel_uncore_type *type, int cpu)
1923{
1924 struct intel_uncore_box *box;
1925 int i, size;
1926
1927 size = sizeof(*box) + type->num_shared_regs * sizeof(struct intel_uncore_extra_reg);
1928
1929 box = kmalloc_node(size, GFP_KERNEL | __GFP_ZERO, cpu_to_node(cpu));
1930 if (!box)
1931 return NULL;
1932
1933 for (i = 0; i < type->num_shared_regs; i++)
1934 raw_spin_lock_init(&box->shared_regs[i].lock);
1935
1936 uncore_pmu_init_hrtimer(box);
1937 atomic_set(&box->refcnt, 1);
1938 box->cpu = -1;
1939 box->phys_id = -1;
1940
1941 return box;
1942}
1943
1944static struct intel_uncore_box *
1945uncore_pmu_to_box(struct intel_uncore_pmu *pmu, int cpu)
1946{
1947 static struct intel_uncore_box *box;
1948
1949 box = *per_cpu_ptr(pmu->box, cpu);
1950 if (box)
1951 return box;
1952
1953 raw_spin_lock(&uncore_box_lock);
1954 list_for_each_entry(box, &pmu->box_list, list) {
1955 if (box->phys_id == topology_physical_package_id(cpu)) {
1956 atomic_inc(&box->refcnt);
1957 *per_cpu_ptr(pmu->box, cpu) = box;
1958 break;
1959 }
1960 }
1961 raw_spin_unlock(&uncore_box_lock);
1962
1963 return *per_cpu_ptr(pmu->box, cpu);
1964}
1965
1966static struct intel_uncore_pmu *uncore_event_to_pmu(struct perf_event *event)
1967{
1968 return container_of(event->pmu, struct intel_uncore_pmu, pmu);
1969}
1970
1971static struct intel_uncore_box *uncore_event_to_box(struct perf_event *event)
1972{
1973 /*
1974 * perf core schedules event on the basis of cpu, uncore events are
1975 * collected by one of the cpus inside a physical package.
1976 */
1977 return uncore_pmu_to_box(uncore_event_to_pmu(event), smp_processor_id());
1978}
1979
1980static int
1981uncore_collect_events(struct intel_uncore_box *box, struct perf_event *leader, bool dogrp)
1982{
1983 struct perf_event *event;
1984 int n, max_count;
1985
1986 max_count = box->pmu->type->num_counters;
1987 if (box->pmu->type->fixed_ctl)
1988 max_count++;
1989
1990 if (box->n_events >= max_count)
1991 return -EINVAL;
1992
1993 n = box->n_events;
1994 box->event_list[n] = leader;
1995 n++;
1996 if (!dogrp)
1997 return n;
1998
1999 list_for_each_entry(event, &leader->sibling_list, group_entry) {
2000 if (event->state <= PERF_EVENT_STATE_OFF)
2001 continue;
2002
2003 if (n >= max_count)
2004 return -EINVAL;
2005
2006 box->event_list[n] = event;
2007 n++;
2008 }
2009 return n;
2010}
2011
2012static struct event_constraint *
2013uncore_get_event_constraint(struct intel_uncore_box *box, struct perf_event *event)
2014{
2015 struct intel_uncore_type *type = box->pmu->type;
2016 struct event_constraint *c;
2017
2018 if (type->ops->get_constraint) {
2019 c = type->ops->get_constraint(box, event);
2020 if (c)
2021 return c;
2022 }
2023
2024 if (event->hw.config == ~0ULL)
2025 return &constraint_fixed;
2026
2027 if (type->constraints) {
2028 for_each_event_constraint(c, type->constraints) {
2029 if ((event->hw.config & c->cmask) == c->code)
2030 return c;
2031 }
2032 }
2033
2034 return &type->unconstrainted;
2035}
2036
2037static void uncore_put_event_constraint(struct intel_uncore_box *box, struct perf_event *event)
2038{
2039 if (box->pmu->type->ops->put_constraint)
2040 box->pmu->type->ops->put_constraint(box, event);
2041}
2042
2043static int uncore_assign_events(struct intel_uncore_box *box, int assign[], int n)
2044{
2045 unsigned long used_mask[BITS_TO_LONGS(UNCORE_PMC_IDX_MAX)];
2046 struct event_constraint *c, *constraints[UNCORE_PMC_IDX_MAX];
2047 int i, wmin, wmax, ret = 0;
2048 struct hw_perf_event *hwc;
2049
2050 bitmap_zero(used_mask, UNCORE_PMC_IDX_MAX);
2051
2052 for (i = 0, wmin = UNCORE_PMC_IDX_MAX, wmax = 0; i < n; i++) {
2053 c = uncore_get_event_constraint(box, box->event_list[i]);
2054 constraints[i] = c;
2055 wmin = min(wmin, c->weight);
2056 wmax = max(wmax, c->weight);
2057 }
2058
2059 /* fastpath, try to reuse previous register */
2060 for (i = 0; i < n; i++) {
2061 hwc = &box->event_list[i]->hw;
2062 c = constraints[i];
2063
2064 /* never assigned */
2065 if (hwc->idx == -1)
2066 break;
2067
2068 /* constraint still honored */
2069 if (!test_bit(hwc->idx, c->idxmsk))
2070 break;
2071
2072 /* not already used */
2073 if (test_bit(hwc->idx, used_mask))
2074 break;
2075
2076 __set_bit(hwc->idx, used_mask);
2077 if (assign)
2078 assign[i] = hwc->idx;
2079 }
2080 /* slow path */
2081 if (i != n)
2082 ret = perf_assign_events(constraints, n, wmin, wmax, assign);
2083
2084 if (!assign || ret) {
2085 for (i = 0; i < n; i++)
2086 uncore_put_event_constraint(box, box->event_list[i]);
2087 }
2088 return ret ? -EINVAL : 0;
2089}
2090
2091static void uncore_pmu_event_start(struct perf_event *event, int flags)
2092{
2093 struct intel_uncore_box *box = uncore_event_to_box(event);
2094 int idx = event->hw.idx;
2095
2096 if (WARN_ON_ONCE(!(event->hw.state & PERF_HES_STOPPED)))
2097 return;
2098
2099 if (WARN_ON_ONCE(idx == -1 || idx >= UNCORE_PMC_IDX_MAX))
2100 return;
2101
2102 event->hw.state = 0;
2103 box->events[idx] = event;
2104 box->n_active++;
2105 __set_bit(idx, box->active_mask);
2106
2107 local64_set(&event->hw.prev_count, uncore_read_counter(box, event));
2108 uncore_enable_event(box, event);
2109
2110 if (box->n_active == 1) {
2111 uncore_enable_box(box);
2112 uncore_pmu_start_hrtimer(box);
2113 }
2114}
2115
2116static void uncore_pmu_event_stop(struct perf_event *event, int flags)
2117{
2118 struct intel_uncore_box *box = uncore_event_to_box(event);
2119 struct hw_perf_event *hwc = &event->hw;
2120
2121 if (__test_and_clear_bit(hwc->idx, box->active_mask)) {
2122 uncore_disable_event(box, event);
2123 box->n_active--;
2124 box->events[hwc->idx] = NULL;
2125 WARN_ON_ONCE(hwc->state & PERF_HES_STOPPED);
2126 hwc->state |= PERF_HES_STOPPED;
2127
2128 if (box->n_active == 0) {
2129 uncore_disable_box(box);
2130 uncore_pmu_cancel_hrtimer(box);
2131 }
2132 }
2133
2134 if ((flags & PERF_EF_UPDATE) && !(hwc->state & PERF_HES_UPTODATE)) {
2135 /*
2136 * Drain the remaining delta count out of a event
2137 * that we are disabling:
2138 */
2139 uncore_perf_event_update(box, event);
2140 hwc->state |= PERF_HES_UPTODATE;
2141 }
2142}
2143
2144static int uncore_pmu_event_add(struct perf_event *event, int flags)
2145{
2146 struct intel_uncore_box *box = uncore_event_to_box(event);
2147 struct hw_perf_event *hwc = &event->hw;
2148 int assign[UNCORE_PMC_IDX_MAX];
2149 int i, n, ret;
2150
2151 if (!box)
2152 return -ENODEV;
2153
2154 ret = n = uncore_collect_events(box, event, false);
2155 if (ret < 0)
2156 return ret;
2157
2158 hwc->state = PERF_HES_UPTODATE | PERF_HES_STOPPED;
2159 if (!(flags & PERF_EF_START))
2160 hwc->state |= PERF_HES_ARCH;
2161
2162 ret = uncore_assign_events(box, assign, n);
2163 if (ret)
2164 return ret;
2165
2166 /* save events moving to new counters */
2167 for (i = 0; i < box->n_events; i++) {
2168 event = box->event_list[i];
2169 hwc = &event->hw;
2170
2171 if (hwc->idx == assign[i] &&
2172 hwc->last_tag == box->tags[assign[i]])
2173 continue;
2174 /*
2175 * Ensure we don't accidentally enable a stopped
2176 * counter simply because we rescheduled.
2177 */
2178 if (hwc->state & PERF_HES_STOPPED)
2179 hwc->state |= PERF_HES_ARCH;
2180
2181 uncore_pmu_event_stop(event, PERF_EF_UPDATE);
2182 }
2183
2184 /* reprogram moved events into new counters */
2185 for (i = 0; i < n; i++) {
2186 event = box->event_list[i];
2187 hwc = &event->hw;
2188
2189 if (hwc->idx != assign[i] ||
2190 hwc->last_tag != box->tags[assign[i]])
2191 uncore_assign_hw_event(box, event, assign[i]);
2192 else if (i < box->n_events)
2193 continue;
2194
2195 if (hwc->state & PERF_HES_ARCH)
2196 continue;
2197
2198 uncore_pmu_event_start(event, 0);
2199 }
2200 box->n_events = n;
2201
2202 return 0;
2203}
2204
2205static void uncore_pmu_event_del(struct perf_event *event, int flags)
2206{
2207 struct intel_uncore_box *box = uncore_event_to_box(event);
2208 int i;
2209
2210 uncore_pmu_event_stop(event, PERF_EF_UPDATE);
2211
2212 for (i = 0; i < box->n_events; i++) {
2213 if (event == box->event_list[i]) {
2214 uncore_put_event_constraint(box, event);
2215
2216 while (++i < box->n_events)
2217 box->event_list[i - 1] = box->event_list[i];
2218
2219 --box->n_events;
2220 break;
2221 }
2222 }
2223
2224 event->hw.idx = -1;
2225 event->hw.last_tag = ~0ULL;
2226}
2227
2228static void uncore_pmu_event_read(struct perf_event *event)
2229{
2230 struct intel_uncore_box *box = uncore_event_to_box(event);
2231 uncore_perf_event_update(box, event);
2232}
2233
2234/*
2235 * validation ensures the group can be loaded onto the
2236 * PMU if it was the only group available.
2237 */
2238static int uncore_validate_group(struct intel_uncore_pmu *pmu,
2239 struct perf_event *event)
2240{
2241 struct perf_event *leader = event->group_leader;
2242 struct intel_uncore_box *fake_box;
2243 int ret = -EINVAL, n;
2244
2245 fake_box = uncore_alloc_box(pmu->type, smp_processor_id());
2246 if (!fake_box)
2247 return -ENOMEM;
2248
2249 fake_box->pmu = pmu;
2250 /*
2251 * the event is not yet connected with its
2252 * siblings therefore we must first collect
2253 * existing siblings, then add the new event
2254 * before we can simulate the scheduling
2255 */
2256 n = uncore_collect_events(fake_box, leader, true);
2257 if (n < 0)
2258 goto out;
2259
2260 fake_box->n_events = n;
2261 n = uncore_collect_events(fake_box, event, false);
2262 if (n < 0)
2263 goto out;
2264
2265 fake_box->n_events = n;
2266
2267 ret = uncore_assign_events(fake_box, NULL, n);
2268out:
2269 kfree(fake_box);
2270 return ret;
2271}
2272
2273int uncore_pmu_event_init(struct perf_event *event)
2274{
2275 struct intel_uncore_pmu *pmu;
2276 struct intel_uncore_box *box;
2277 struct hw_perf_event *hwc = &event->hw;
2278 int ret;
2279
2280 if (event->attr.type != event->pmu->type)
2281 return -ENOENT;
2282
2283 pmu = uncore_event_to_pmu(event);
2284 /* no device found for this pmu */
2285 if (pmu->func_id < 0)
2286 return -ENOENT;
2287
2288 /*
2289 * Uncore PMU does measure at all privilege level all the time.
2290 * So it doesn't make sense to specify any exclude bits.
2291 */
2292 if (event->attr.exclude_user || event->attr.exclude_kernel ||
2293 event->attr.exclude_hv || event->attr.exclude_idle)
2294 return -EINVAL;
2295
2296 /* Sampling not supported yet */
2297 if (hwc->sample_period)
2298 return -EINVAL;
2299
2300 /*
2301 * Place all uncore events for a particular physical package
2302 * onto a single cpu
2303 */
2304 if (event->cpu < 0)
2305 return -EINVAL;
2306 box = uncore_pmu_to_box(pmu, event->cpu);
2307 if (!box || box->cpu < 0)
2308 return -EINVAL;
2309 event->cpu = box->cpu;
2310
2311 event->hw.idx = -1;
2312 event->hw.last_tag = ~0ULL;
2313 event->hw.extra_reg.idx = EXTRA_REG_NONE;
2314 event->hw.branch_reg.idx = EXTRA_REG_NONE;
2315
2316 if (event->attr.config == UNCORE_FIXED_EVENT) {
2317 /* no fixed counter */
2318 if (!pmu->type->fixed_ctl)
2319 return -EINVAL;
2320 /*
2321 * if there is only one fixed counter, only the first pmu
2322 * can access the fixed counter
2323 */
2324 if (pmu->type->single_fixed && pmu->pmu_idx > 0)
2325 return -EINVAL;
2326 hwc->config = ~0ULL;
2327 } else {
2328 hwc->config = event->attr.config & pmu->type->event_mask;
2329 if (pmu->type->ops->hw_config) {
2330 ret = pmu->type->ops->hw_config(box, event);
2331 if (ret)
2332 return ret;
2333 }
2334 }
2335
2336 if (event->group_leader != event)
2337 ret = uncore_validate_group(pmu, event);
2338 else
2339 ret = 0;
2340
2341 return ret;
2342}
2343
2344static int __init uncore_pmu_register(struct intel_uncore_pmu *pmu)
2345{
2346 int ret;
2347
2348 pmu->pmu = (struct pmu) {
2349 .attr_groups = pmu->type->attr_groups,
2350 .task_ctx_nr = perf_invalid_context,
2351 .event_init = uncore_pmu_event_init,
2352 .add = uncore_pmu_event_add,
2353 .del = uncore_pmu_event_del,
2354 .start = uncore_pmu_event_start,
2355 .stop = uncore_pmu_event_stop,
2356 .read = uncore_pmu_event_read,
2357 };
2358
2359 if (pmu->type->num_boxes == 1) {
2360 if (strlen(pmu->type->name) > 0)
2361 sprintf(pmu->name, "uncore_%s", pmu->type->name);
2362 else
2363 sprintf(pmu->name, "uncore");
2364 } else {
2365 sprintf(pmu->name, "uncore_%s_%d", pmu->type->name,
2366 pmu->pmu_idx);
2367 }
2368
2369 ret = perf_pmu_register(&pmu->pmu, pmu->name, -1);
2370 return ret;
2371}
2372
2373static void __init uncore_type_exit(struct intel_uncore_type *type)
2374{
2375 int i;
2376
2377 for (i = 0; i < type->num_boxes; i++)
2378 free_percpu(type->pmus[i].box);
2379 kfree(type->pmus);
2380 type->pmus = NULL;
2381 kfree(type->attr_groups[1]);
2382 type->attr_groups[1] = NULL;
2383}
2384
2385static void __init uncore_types_exit(struct intel_uncore_type **types)
2386{
2387 int i;
2388 for (i = 0; types[i]; i++)
2389 uncore_type_exit(types[i]);
2390}
2391
2392static int __init uncore_type_init(struct intel_uncore_type *type)
2393{
2394 struct intel_uncore_pmu *pmus;
2395 struct attribute_group *events_group;
2396 struct attribute **attrs;
2397 int i, j;
2398
2399 pmus = kzalloc(sizeof(*pmus) * type->num_boxes, GFP_KERNEL);
2400 if (!pmus)
2401 return -ENOMEM;
2402
2403 type->unconstrainted = (struct event_constraint)
2404 __EVENT_CONSTRAINT(0, (1ULL << type->num_counters) - 1,
2405 0, type->num_counters, 0);
2406
2407 for (i = 0; i < type->num_boxes; i++) {
2408 pmus[i].func_id = -1;
2409 pmus[i].pmu_idx = i;
2410 pmus[i].type = type;
2411 INIT_LIST_HEAD(&pmus[i].box_list);
2412 pmus[i].box = alloc_percpu(struct intel_uncore_box *);
2413 if (!pmus[i].box)
2414 goto fail;
2415 }
2416
2417 if (type->event_descs) {
2418 i = 0;
2419 while (type->event_descs[i].attr.attr.name)
2420 i++;
2421
2422 events_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
2423 sizeof(*events_group), GFP_KERNEL);
2424 if (!events_group)
2425 goto fail;
2426
2427 attrs = (struct attribute **)(events_group + 1);
2428 events_group->name = "events";
2429 events_group->attrs = attrs;
2430
2431 for (j = 0; j < i; j++)
2432 attrs[j] = &type->event_descs[j].attr.attr;
2433
2434 type->attr_groups[1] = events_group;
2435 }
2436
2437 type->pmus = pmus;
2438 return 0;
2439fail:
2440 uncore_type_exit(type);
2441 return -ENOMEM;
2442}
2443
2444static int __init uncore_types_init(struct intel_uncore_type **types)
2445{
2446 int i, ret;
2447
2448 for (i = 0; types[i]; i++) {
2449 ret = uncore_type_init(types[i]);
2450 if (ret)
2451 goto fail;
2452 }
2453 return 0;
2454fail:
2455 while (--i >= 0)
2456 uncore_type_exit(types[i]);
2457 return ret;
2458}
2459
2460static struct pci_driver *uncore_pci_driver;
2461static bool pcidrv_registered;
2462
2463/*
2464 * add a pci uncore device
2465 */
2466static int __devinit uncore_pci_add(struct intel_uncore_type *type, struct pci_dev *pdev)
2467{
2468 struct intel_uncore_pmu *pmu;
2469 struct intel_uncore_box *box;
2470 int i, phys_id;
2471
2472 phys_id = pcibus_to_physid[pdev->bus->number];
2473 if (phys_id < 0)
2474 return -ENODEV;
2475
2476 box = uncore_alloc_box(type, 0);
2477 if (!box)
2478 return -ENOMEM;
2479
2480 /*
2481 * for performance monitoring unit with multiple boxes,
2482 * each box has a different function id.
2483 */
2484 for (i = 0; i < type->num_boxes; i++) {
2485 pmu = &type->pmus[i];
2486 if (pmu->func_id == pdev->devfn)
2487 break;
2488 if (pmu->func_id < 0) {
2489 pmu->func_id = pdev->devfn;
2490 break;
2491 }
2492 pmu = NULL;
2493 }
2494
2495 if (!pmu) {
2496 kfree(box);
2497 return -EINVAL;
2498 }
2499
2500 box->phys_id = phys_id;
2501 box->pci_dev = pdev;
2502 box->pmu = pmu;
2503 uncore_box_init(box);
2504 pci_set_drvdata(pdev, box);
2505
2506 raw_spin_lock(&uncore_box_lock);
2507 list_add_tail(&box->list, &pmu->box_list);
2508 raw_spin_unlock(&uncore_box_lock);
2509
2510 return 0;
2511}
2512
2513static void uncore_pci_remove(struct pci_dev *pdev)
2514{
2515 struct intel_uncore_box *box = pci_get_drvdata(pdev);
2516 struct intel_uncore_pmu *pmu = box->pmu;
2517 int cpu, phys_id = pcibus_to_physid[pdev->bus->number];
2518
2519 if (WARN_ON_ONCE(phys_id != box->phys_id))
2520 return;
2521
2522 raw_spin_lock(&uncore_box_lock);
2523 list_del(&box->list);
2524 raw_spin_unlock(&uncore_box_lock);
2525
2526 for_each_possible_cpu(cpu) {
2527 if (*per_cpu_ptr(pmu->box, cpu) == box) {
2528 *per_cpu_ptr(pmu->box, cpu) = NULL;
2529 atomic_dec(&box->refcnt);
2530 }
2531 }
2532
2533 WARN_ON_ONCE(atomic_read(&box->refcnt) != 1);
2534 kfree(box);
2535}
2536
2537static int __devinit uncore_pci_probe(struct pci_dev *pdev,
2538 const struct pci_device_id *id)
2539{
2540 struct intel_uncore_type *type;
2541
2542 type = (struct intel_uncore_type *)id->driver_data;
2543
2544 return uncore_pci_add(type, pdev);
2545}
2546
2547static int __init uncore_pci_init(void)
2548{
2549 int ret;
2550
2551 switch (boot_cpu_data.x86_model) {
2552 case 45: /* Sandy Bridge-EP */
2553 pci_uncores = snbep_pci_uncores;
2554 uncore_pci_driver = &snbep_uncore_pci_driver;
2555 snbep_pci2phy_map_init();
2556 break;
2557 default:
2558 return 0;
2559 }
2560
2561 ret = uncore_types_init(pci_uncores);
2562 if (ret)
2563 return ret;
2564
2565 uncore_pci_driver->probe = uncore_pci_probe;
2566 uncore_pci_driver->remove = uncore_pci_remove;
2567
2568 ret = pci_register_driver(uncore_pci_driver);
2569 if (ret == 0)
2570 pcidrv_registered = true;
2571 else
2572 uncore_types_exit(pci_uncores);
2573
2574 return ret;
2575}
2576
2577static void __init uncore_pci_exit(void)
2578{
2579 if (pcidrv_registered) {
2580 pcidrv_registered = false;
2581 pci_unregister_driver(uncore_pci_driver);
2582 uncore_types_exit(pci_uncores);
2583 }
2584}
2585
2586static void __cpuinit uncore_cpu_dying(int cpu)
2587{
2588 struct intel_uncore_type *type;
2589 struct intel_uncore_pmu *pmu;
2590 struct intel_uncore_box *box;
2591 int i, j;
2592
2593 for (i = 0; msr_uncores[i]; i++) {
2594 type = msr_uncores[i];
2595 for (j = 0; j < type->num_boxes; j++) {
2596 pmu = &type->pmus[j];
2597 box = *per_cpu_ptr(pmu->box, cpu);
2598 *per_cpu_ptr(pmu->box, cpu) = NULL;
2599 if (box && atomic_dec_and_test(&box->refcnt))
2600 kfree(box);
2601 }
2602 }
2603}
2604
2605static int __cpuinit uncore_cpu_starting(int cpu)
2606{
2607 struct intel_uncore_type *type;
2608 struct intel_uncore_pmu *pmu;
2609 struct intel_uncore_box *box, *exist;
2610 int i, j, k, phys_id;
2611
2612 phys_id = topology_physical_package_id(cpu);
2613
2614 for (i = 0; msr_uncores[i]; i++) {
2615 type = msr_uncores[i];
2616 for (j = 0; j < type->num_boxes; j++) {
2617 pmu = &type->pmus[j];
2618 box = *per_cpu_ptr(pmu->box, cpu);
2619 /* called by uncore_cpu_init? */
2620 if (box && box->phys_id >= 0) {
2621 uncore_box_init(box);
2622 continue;
2623 }
2624
2625 for_each_online_cpu(k) {
2626 exist = *per_cpu_ptr(pmu->box, k);
2627 if (exist && exist->phys_id == phys_id) {
2628 atomic_inc(&exist->refcnt);
2629 *per_cpu_ptr(pmu->box, cpu) = exist;
2630 kfree(box);
2631 box = NULL;
2632 break;
2633 }
2634 }
2635
2636 if (box) {
2637 box->phys_id = phys_id;
2638 uncore_box_init(box);
2639 }
2640 }
2641 }
2642 return 0;
2643}
2644
2645static int __cpuinit uncore_cpu_prepare(int cpu, int phys_id)
2646{
2647 struct intel_uncore_type *type;
2648 struct intel_uncore_pmu *pmu;
2649 struct intel_uncore_box *box;
2650 int i, j;
2651
2652 for (i = 0; msr_uncores[i]; i++) {
2653 type = msr_uncores[i];
2654 for (j = 0; j < type->num_boxes; j++) {
2655 pmu = &type->pmus[j];
2656 if (pmu->func_id < 0)
2657 pmu->func_id = j;
2658
2659 box = uncore_alloc_box(type, cpu);
2660 if (!box)
2661 return -ENOMEM;
2662
2663 box->pmu = pmu;
2664 box->phys_id = phys_id;
2665 *per_cpu_ptr(pmu->box, cpu) = box;
2666 }
2667 }
2668 return 0;
2669}
2670
2671static void __cpuinit
2672uncore_change_context(struct intel_uncore_type **uncores, int old_cpu, int new_cpu)
2673{
2674 struct intel_uncore_type *type;
2675 struct intel_uncore_pmu *pmu;
2676 struct intel_uncore_box *box;
2677 int i, j;
2678
2679 for (i = 0; uncores[i]; i++) {
2680 type = uncores[i];
2681 for (j = 0; j < type->num_boxes; j++) {
2682 pmu = &type->pmus[j];
2683 if (old_cpu < 0)
2684 box = uncore_pmu_to_box(pmu, new_cpu);
2685 else
2686 box = uncore_pmu_to_box(pmu, old_cpu);
2687 if (!box)
2688 continue;
2689
2690 if (old_cpu < 0) {
2691 WARN_ON_ONCE(box->cpu != -1);
2692 box->cpu = new_cpu;
2693 continue;
2694 }
2695
2696 WARN_ON_ONCE(box->cpu != old_cpu);
2697 if (new_cpu >= 0) {
2698 uncore_pmu_cancel_hrtimer(box);
2699 perf_pmu_migrate_context(&pmu->pmu,
2700 old_cpu, new_cpu);
2701 box->cpu = new_cpu;
2702 } else {
2703 box->cpu = -1;
2704 }
2705 }
2706 }
2707}
2708
2709static void __cpuinit uncore_event_exit_cpu(int cpu)
2710{
2711 int i, phys_id, target;
2712
2713 /* if exiting cpu is used for collecting uncore events */
2714 if (!cpumask_test_and_clear_cpu(cpu, &uncore_cpu_mask))
2715 return;
2716
2717 /* find a new cpu to collect uncore events */
2718 phys_id = topology_physical_package_id(cpu);
2719 target = -1;
2720 for_each_online_cpu(i) {
2721 if (i == cpu)
2722 continue;
2723 if (phys_id == topology_physical_package_id(i)) {
2724 target = i;
2725 break;
2726 }
2727 }
2728
2729 /* migrate uncore events to the new cpu */
2730 if (target >= 0)
2731 cpumask_set_cpu(target, &uncore_cpu_mask);
2732
2733 uncore_change_context(msr_uncores, cpu, target);
2734 uncore_change_context(pci_uncores, cpu, target);
2735}
2736
2737static void __cpuinit uncore_event_init_cpu(int cpu)
2738{
2739 int i, phys_id;
2740
2741 phys_id = topology_physical_package_id(cpu);
2742 for_each_cpu(i, &uncore_cpu_mask) {
2743 if (phys_id == topology_physical_package_id(i))
2744 return;
2745 }
2746
2747 cpumask_set_cpu(cpu, &uncore_cpu_mask);
2748
2749 uncore_change_context(msr_uncores, -1, cpu);
2750 uncore_change_context(pci_uncores, -1, cpu);
2751}
2752
2753static int
2754 __cpuinit uncore_cpu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
2755{
2756 unsigned int cpu = (long)hcpu;
2757
2758 /* allocate/free data structure for uncore box */
2759 switch (action & ~CPU_TASKS_FROZEN) {
2760 case CPU_UP_PREPARE:
2761 uncore_cpu_prepare(cpu, -1);
2762 break;
2763 case CPU_STARTING:
2764 uncore_cpu_starting(cpu);
2765 break;
2766 case CPU_UP_CANCELED:
2767 case CPU_DYING:
2768 uncore_cpu_dying(cpu);
2769 break;
2770 default:
2771 break;
2772 }
2773
2774 /* select the cpu that collects uncore events */
2775 switch (action & ~CPU_TASKS_FROZEN) {
2776 case CPU_DOWN_FAILED:
2777 case CPU_STARTING:
2778 uncore_event_init_cpu(cpu);
2779 break;
2780 case CPU_DOWN_PREPARE:
2781 uncore_event_exit_cpu(cpu);
2782 break;
2783 default:
2784 break;
2785 }
2786
2787 return NOTIFY_OK;
2788}
2789
2790static struct notifier_block uncore_cpu_nb __cpuinitdata = {
2791 .notifier_call = uncore_cpu_notifier,
2792 /*
2793 * to migrate uncore events, our notifier should be executed
2794 * before perf core's notifier.
2795 */
2796 .priority = CPU_PRI_PERF + 1,
2797};
2798
2799static void __init uncore_cpu_setup(void *dummy)
2800{
2801 uncore_cpu_starting(smp_processor_id());
2802}
2803
2804static int __init uncore_cpu_init(void)
2805{
2806 int ret, cpu, max_cores;
2807
2808 max_cores = boot_cpu_data.x86_max_cores;
2809 switch (boot_cpu_data.x86_model) {
2810 case 26: /* Nehalem */
2811 case 30:
2812 case 37: /* Westmere */
2813 case 44:
2814 msr_uncores = nhm_msr_uncores;
2815 break;
2816 case 42: /* Sandy Bridge */
2817 if (snb_uncore_cbox.num_boxes > max_cores)
2818 snb_uncore_cbox.num_boxes = max_cores;
2819 msr_uncores = snb_msr_uncores;
2820 break;
2821 case 45: /* Sandy Birdge-EP */
2822 if (snbep_uncore_cbox.num_boxes > max_cores)
2823 snbep_uncore_cbox.num_boxes = max_cores;
2824 msr_uncores = snbep_msr_uncores;
2825 break;
2826 case 46: /* Nehalem-EX */
2827 uncore_nhmex = true;
2828 case 47: /* Westmere-EX aka. Xeon E7 */
2829 if (!uncore_nhmex)
2830 nhmex_uncore_mbox.event_descs = wsmex_uncore_mbox_events;
2831 if (nhmex_uncore_cbox.num_boxes > max_cores)
2832 nhmex_uncore_cbox.num_boxes = max_cores;
2833 msr_uncores = nhmex_msr_uncores;
2834 break;
2835 default:
2836 return 0;
2837 }
2838
2839 ret = uncore_types_init(msr_uncores);
2840 if (ret)
2841 return ret;
2842
2843 get_online_cpus();
2844
2845 for_each_online_cpu(cpu) {
2846 int i, phys_id = topology_physical_package_id(cpu);
2847
2848 for_each_cpu(i, &uncore_cpu_mask) {
2849 if (phys_id == topology_physical_package_id(i)) {
2850 phys_id = -1;
2851 break;
2852 }
2853 }
2854 if (phys_id < 0)
2855 continue;
2856
2857 uncore_cpu_prepare(cpu, phys_id);
2858 uncore_event_init_cpu(cpu);
2859 }
2860 on_each_cpu(uncore_cpu_setup, NULL, 1);
2861
2862 register_cpu_notifier(&uncore_cpu_nb);
2863
2864 put_online_cpus();
2865
2866 return 0;
2867}
2868
2869static int __init uncore_pmus_register(void)
2870{
2871 struct intel_uncore_pmu *pmu;
2872 struct intel_uncore_type *type;
2873 int i, j;
2874
2875 for (i = 0; msr_uncores[i]; i++) {
2876 type = msr_uncores[i];
2877 for (j = 0; j < type->num_boxes; j++) {
2878 pmu = &type->pmus[j];
2879 uncore_pmu_register(pmu);
2880 }
2881 }
2882
2883 for (i = 0; pci_uncores[i]; i++) {
2884 type = pci_uncores[i];
2885 for (j = 0; j < type->num_boxes; j++) {
2886 pmu = &type->pmus[j];
2887 uncore_pmu_register(pmu);
2888 }
2889 }
2890
2891 return 0;
2892}
2893
2894static int __init intel_uncore_init(void)
2895{
2896 int ret;
2897
2898 if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
2899 return -ENODEV;
2900
2901 ret = uncore_pci_init();
2902 if (ret)
2903 goto fail;
2904 ret = uncore_cpu_init();
2905 if (ret) {
2906 uncore_pci_exit();
2907 goto fail;
2908 }
2909
2910 uncore_pmus_register();
2911 return 0;
2912fail:
2913 return ret;
2914}
2915device_initcall(intel_uncore_init);
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
new file mode 100644
index 00000000000..5b81c1856aa
--- /dev/null
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
@@ -0,0 +1,619 @@
1#include <linux/module.h>
2#include <linux/slab.h>
3#include <linux/pci.h>
4#include <linux/perf_event.h>
5#include "perf_event.h"
6
7#define UNCORE_PMU_NAME_LEN 32
8#define UNCORE_PMU_HRTIMER_INTERVAL (60LL * NSEC_PER_SEC)
9
10#define UNCORE_FIXED_EVENT 0xff
11#define UNCORE_PMC_IDX_MAX_GENERIC 8
12#define UNCORE_PMC_IDX_FIXED UNCORE_PMC_IDX_MAX_GENERIC
13#define UNCORE_PMC_IDX_MAX (UNCORE_PMC_IDX_FIXED + 1)
14
15#define UNCORE_EVENT_CONSTRAINT(c, n) EVENT_CONSTRAINT(c, n, 0xff)
16
17/* SNB event control */
18#define SNB_UNC_CTL_EV_SEL_MASK 0x000000ff
19#define SNB_UNC_CTL_UMASK_MASK 0x0000ff00
20#define SNB_UNC_CTL_EDGE_DET (1 << 18)
21#define SNB_UNC_CTL_EN (1 << 22)
22#define SNB_UNC_CTL_INVERT (1 << 23)
23#define SNB_UNC_CTL_CMASK_MASK 0x1f000000
24#define NHM_UNC_CTL_CMASK_MASK 0xff000000
25#define NHM_UNC_FIXED_CTR_CTL_EN (1 << 0)
26
27#define SNB_UNC_RAW_EVENT_MASK (SNB_UNC_CTL_EV_SEL_MASK | \
28 SNB_UNC_CTL_UMASK_MASK | \
29 SNB_UNC_CTL_EDGE_DET | \
30 SNB_UNC_CTL_INVERT | \
31 SNB_UNC_CTL_CMASK_MASK)
32
33#define NHM_UNC_RAW_EVENT_MASK (SNB_UNC_CTL_EV_SEL_MASK | \
34 SNB_UNC_CTL_UMASK_MASK | \
35 SNB_UNC_CTL_EDGE_DET | \
36 SNB_UNC_CTL_INVERT | \
37 NHM_UNC_CTL_CMASK_MASK)
38
39/* SNB global control register */
40#define SNB_UNC_PERF_GLOBAL_CTL 0x391
41#define SNB_UNC_FIXED_CTR_CTRL 0x394
42#define SNB_UNC_FIXED_CTR 0x395
43
44/* SNB uncore global control */
45#define SNB_UNC_GLOBAL_CTL_CORE_ALL ((1 << 4) - 1)
46#define SNB_UNC_GLOBAL_CTL_EN (1 << 29)
47
48/* SNB Cbo register */
49#define SNB_UNC_CBO_0_PERFEVTSEL0 0x700
50#define SNB_UNC_CBO_0_PER_CTR0 0x706
51#define SNB_UNC_CBO_MSR_OFFSET 0x10
52
53/* NHM global control register */
54#define NHM_UNC_PERF_GLOBAL_CTL 0x391
55#define NHM_UNC_FIXED_CTR 0x394
56#define NHM_UNC_FIXED_CTR_CTRL 0x395
57
58/* NHM uncore global control */
59#define NHM_UNC_GLOBAL_CTL_EN_PC_ALL ((1ULL << 8) - 1)
60#define NHM_UNC_GLOBAL_CTL_EN_FC (1ULL << 32)
61
62/* NHM uncore register */
63#define NHM_UNC_PERFEVTSEL0 0x3c0
64#define NHM_UNC_UNCORE_PMC0 0x3b0
65
66/* SNB-EP Box level control */
67#define SNBEP_PMON_BOX_CTL_RST_CTRL (1 << 0)
68#define SNBEP_PMON_BOX_CTL_RST_CTRS (1 << 1)
69#define SNBEP_PMON_BOX_CTL_FRZ (1 << 8)
70#define SNBEP_PMON_BOX_CTL_FRZ_EN (1 << 16)
71#define SNBEP_PMON_BOX_CTL_INT (SNBEP_PMON_BOX_CTL_RST_CTRL | \
72 SNBEP_PMON_BOX_CTL_RST_CTRS | \
73 SNBEP_PMON_BOX_CTL_FRZ_EN)
74/* SNB-EP event control */
75#define SNBEP_PMON_CTL_EV_SEL_MASK 0x000000ff
76#define SNBEP_PMON_CTL_UMASK_MASK 0x0000ff00
77#define SNBEP_PMON_CTL_RST (1 << 17)
78#define SNBEP_PMON_CTL_EDGE_DET (1 << 18)
79#define SNBEP_PMON_CTL_EV_SEL_EXT (1 << 21) /* only for QPI */
80#define SNBEP_PMON_CTL_EN (1 << 22)
81#define SNBEP_PMON_CTL_INVERT (1 << 23)
82#define SNBEP_PMON_CTL_TRESH_MASK 0xff000000
83#define SNBEP_PMON_RAW_EVENT_MASK (SNBEP_PMON_CTL_EV_SEL_MASK | \
84 SNBEP_PMON_CTL_UMASK_MASK | \
85 SNBEP_PMON_CTL_EDGE_DET | \
86 SNBEP_PMON_CTL_INVERT | \
87 SNBEP_PMON_CTL_TRESH_MASK)
88
89/* SNB-EP Ubox event control */
90#define SNBEP_U_MSR_PMON_CTL_TRESH_MASK 0x1f000000
91#define SNBEP_U_MSR_PMON_RAW_EVENT_MASK \
92 (SNBEP_PMON_CTL_EV_SEL_MASK | \
93 SNBEP_PMON_CTL_UMASK_MASK | \
94 SNBEP_PMON_CTL_EDGE_DET | \
95 SNBEP_PMON_CTL_INVERT | \
96 SNBEP_U_MSR_PMON_CTL_TRESH_MASK)
97
98#define SNBEP_CBO_PMON_CTL_TID_EN (1 << 19)
99#define SNBEP_CBO_MSR_PMON_RAW_EVENT_MASK (SNBEP_PMON_RAW_EVENT_MASK | \
100 SNBEP_CBO_PMON_CTL_TID_EN)
101
102/* SNB-EP PCU event control */
103#define SNBEP_PCU_MSR_PMON_CTL_OCC_SEL_MASK 0x0000c000
104#define SNBEP_PCU_MSR_PMON_CTL_TRESH_MASK 0x1f000000
105#define SNBEP_PCU_MSR_PMON_CTL_OCC_INVERT (1 << 30)
106#define SNBEP_PCU_MSR_PMON_CTL_OCC_EDGE_DET (1 << 31)
107#define SNBEP_PCU_MSR_PMON_RAW_EVENT_MASK \
108 (SNBEP_PMON_CTL_EV_SEL_MASK | \
109 SNBEP_PCU_MSR_PMON_CTL_OCC_SEL_MASK | \
110 SNBEP_PMON_CTL_EDGE_DET | \
111 SNBEP_PMON_CTL_INVERT | \
112 SNBEP_PCU_MSR_PMON_CTL_TRESH_MASK | \
113 SNBEP_PCU_MSR_PMON_CTL_OCC_INVERT | \
114 SNBEP_PCU_MSR_PMON_CTL_OCC_EDGE_DET)
115
116#define SNBEP_QPI_PCI_PMON_RAW_EVENT_MASK \
117 (SNBEP_PMON_RAW_EVENT_MASK | \
118 SNBEP_PMON_CTL_EV_SEL_EXT)
119
120/* SNB-EP pci control register */
121#define SNBEP_PCI_PMON_BOX_CTL 0xf4
122#define SNBEP_PCI_PMON_CTL0 0xd8
123/* SNB-EP pci counter register */
124#define SNBEP_PCI_PMON_CTR0 0xa0
125
126/* SNB-EP home agent register */
127#define SNBEP_HA_PCI_PMON_BOX_ADDRMATCH0 0x40
128#define SNBEP_HA_PCI_PMON_BOX_ADDRMATCH1 0x44
129#define SNBEP_HA_PCI_PMON_BOX_OPCODEMATCH 0x48
130/* SNB-EP memory controller register */
131#define SNBEP_MC_CHy_PCI_PMON_FIXED_CTL 0xf0
132#define SNBEP_MC_CHy_PCI_PMON_FIXED_CTR 0xd0
133/* SNB-EP QPI register */
134#define SNBEP_Q_Py_PCI_PMON_PKT_MATCH0 0x228
135#define SNBEP_Q_Py_PCI_PMON_PKT_MATCH1 0x22c
136#define SNBEP_Q_Py_PCI_PMON_PKT_MASK0 0x238
137#define SNBEP_Q_Py_PCI_PMON_PKT_MASK1 0x23c
138
139/* SNB-EP Ubox register */
140#define SNBEP_U_MSR_PMON_CTR0 0xc16
141#define SNBEP_U_MSR_PMON_CTL0 0xc10
142
143#define SNBEP_U_MSR_PMON_UCLK_FIXED_CTL 0xc08
144#define SNBEP_U_MSR_PMON_UCLK_FIXED_CTR 0xc09
145
146/* SNB-EP Cbo register */
147#define SNBEP_C0_MSR_PMON_CTR0 0xd16
148#define SNBEP_C0_MSR_PMON_CTL0 0xd10
149#define SNBEP_C0_MSR_PMON_BOX_CTL 0xd04
150#define SNBEP_C0_MSR_PMON_BOX_FILTER 0xd14
151#define SNBEP_CB0_MSR_PMON_BOX_FILTER_MASK 0xfffffc1f
152#define SNBEP_CBO_MSR_OFFSET 0x20
153
154/* SNB-EP PCU register */
155#define SNBEP_PCU_MSR_PMON_CTR0 0xc36
156#define SNBEP_PCU_MSR_PMON_CTL0 0xc30
157#define SNBEP_PCU_MSR_PMON_BOX_CTL 0xc24
158#define SNBEP_PCU_MSR_PMON_BOX_FILTER 0xc34
159#define SNBEP_PCU_MSR_PMON_BOX_FILTER_MASK 0xffffffff
160#define SNBEP_PCU_MSR_CORE_C3_CTR 0x3fc
161#define SNBEP_PCU_MSR_CORE_C6_CTR 0x3fd
162
163/* NHM-EX event control */
164#define NHMEX_PMON_CTL_EV_SEL_MASK 0x000000ff
165#define NHMEX_PMON_CTL_UMASK_MASK 0x0000ff00
166#define NHMEX_PMON_CTL_EN_BIT0 (1 << 0)
167#define NHMEX_PMON_CTL_EDGE_DET (1 << 18)
168#define NHMEX_PMON_CTL_PMI_EN (1 << 20)
169#define NHMEX_PMON_CTL_EN_BIT22 (1 << 22)
170#define NHMEX_PMON_CTL_INVERT (1 << 23)
171#define NHMEX_PMON_CTL_TRESH_MASK 0xff000000
172#define NHMEX_PMON_RAW_EVENT_MASK (NHMEX_PMON_CTL_EV_SEL_MASK | \
173 NHMEX_PMON_CTL_UMASK_MASK | \
174 NHMEX_PMON_CTL_EDGE_DET | \
175 NHMEX_PMON_CTL_INVERT | \
176 NHMEX_PMON_CTL_TRESH_MASK)
177
178/* NHM-EX Ubox */
179#define NHMEX_U_MSR_PMON_GLOBAL_CTL 0xc00
180#define NHMEX_U_MSR_PMON_CTR 0xc11
181#define NHMEX_U_MSR_PMON_EV_SEL 0xc10
182
183#define NHMEX_U_PMON_GLOBAL_EN (1 << 0)
184#define NHMEX_U_PMON_GLOBAL_PMI_CORE_SEL 0x0000001e
185#define NHMEX_U_PMON_GLOBAL_EN_ALL (1 << 28)
186#define NHMEX_U_PMON_GLOBAL_RST_ALL (1 << 29)
187#define NHMEX_U_PMON_GLOBAL_FRZ_ALL (1 << 31)
188
189#define NHMEX_U_PMON_RAW_EVENT_MASK \
190 (NHMEX_PMON_CTL_EV_SEL_MASK | \
191 NHMEX_PMON_CTL_EDGE_DET)
192
193/* NHM-EX Cbox */
194#define NHMEX_C0_MSR_PMON_GLOBAL_CTL 0xd00
195#define NHMEX_C0_MSR_PMON_CTR0 0xd11
196#define NHMEX_C0_MSR_PMON_EV_SEL0 0xd10
197#define NHMEX_C_MSR_OFFSET 0x20
198
199/* NHM-EX Bbox */
200#define NHMEX_B0_MSR_PMON_GLOBAL_CTL 0xc20
201#define NHMEX_B0_MSR_PMON_CTR0 0xc31
202#define NHMEX_B0_MSR_PMON_CTL0 0xc30
203#define NHMEX_B_MSR_OFFSET 0x40
204#define NHMEX_B0_MSR_MATCH 0xe45
205#define NHMEX_B0_MSR_MASK 0xe46
206#define NHMEX_B1_MSR_MATCH 0xe4d
207#define NHMEX_B1_MSR_MASK 0xe4e
208
209#define NHMEX_B_PMON_CTL_EN (1 << 0)
210#define NHMEX_B_PMON_CTL_EV_SEL_SHIFT 1
211#define NHMEX_B_PMON_CTL_EV_SEL_MASK \
212 (0x1f << NHMEX_B_PMON_CTL_EV_SEL_SHIFT)
213#define NHMEX_B_PMON_CTR_SHIFT 6
214#define NHMEX_B_PMON_CTR_MASK \
215 (0x3 << NHMEX_B_PMON_CTR_SHIFT)
216#define NHMEX_B_PMON_RAW_EVENT_MASK \
217 (NHMEX_B_PMON_CTL_EV_SEL_MASK | \
218 NHMEX_B_PMON_CTR_MASK)
219
220/* NHM-EX Sbox */
221#define NHMEX_S0_MSR_PMON_GLOBAL_CTL 0xc40
222#define NHMEX_S0_MSR_PMON_CTR0 0xc51
223#define NHMEX_S0_MSR_PMON_CTL0 0xc50
224#define NHMEX_S_MSR_OFFSET 0x80
225#define NHMEX_S0_MSR_MM_CFG 0xe48
226#define NHMEX_S0_MSR_MATCH 0xe49
227#define NHMEX_S0_MSR_MASK 0xe4a
228#define NHMEX_S1_MSR_MM_CFG 0xe58
229#define NHMEX_S1_MSR_MATCH 0xe59
230#define NHMEX_S1_MSR_MASK 0xe5a
231
232#define NHMEX_S_PMON_MM_CFG_EN (0x1ULL << 63)
233#define NHMEX_S_EVENT_TO_R_PROG_EV 0
234
235/* NHM-EX Mbox */
236#define NHMEX_M0_MSR_GLOBAL_CTL 0xca0
237#define NHMEX_M0_MSR_PMU_DSP 0xca5
238#define NHMEX_M0_MSR_PMU_ISS 0xca6
239#define NHMEX_M0_MSR_PMU_MAP 0xca7
240#define NHMEX_M0_MSR_PMU_MSC_THR 0xca8
241#define NHMEX_M0_MSR_PMU_PGT 0xca9
242#define NHMEX_M0_MSR_PMU_PLD 0xcaa
243#define NHMEX_M0_MSR_PMU_ZDP_CTL_FVC 0xcab
244#define NHMEX_M0_MSR_PMU_CTL0 0xcb0
245#define NHMEX_M0_MSR_PMU_CNT0 0xcb1
246#define NHMEX_M_MSR_OFFSET 0x40
247#define NHMEX_M0_MSR_PMU_MM_CFG 0xe54
248#define NHMEX_M1_MSR_PMU_MM_CFG 0xe5c
249
250#define NHMEX_M_PMON_MM_CFG_EN (1ULL << 63)
251#define NHMEX_M_PMON_ADDR_MATCH_MASK 0x3ffffffffULL
252#define NHMEX_M_PMON_ADDR_MASK_MASK 0x7ffffffULL
253#define NHMEX_M_PMON_ADDR_MASK_SHIFT 34
254
255#define NHMEX_M_PMON_CTL_EN (1 << 0)
256#define NHMEX_M_PMON_CTL_PMI_EN (1 << 1)
257#define NHMEX_M_PMON_CTL_COUNT_MODE_SHIFT 2
258#define NHMEX_M_PMON_CTL_COUNT_MODE_MASK \
259 (0x3 << NHMEX_M_PMON_CTL_COUNT_MODE_SHIFT)
260#define NHMEX_M_PMON_CTL_STORAGE_MODE_SHIFT 4
261#define NHMEX_M_PMON_CTL_STORAGE_MODE_MASK \
262 (0x3 << NHMEX_M_PMON_CTL_STORAGE_MODE_SHIFT)
263#define NHMEX_M_PMON_CTL_WRAP_MODE (1 << 6)
264#define NHMEX_M_PMON_CTL_FLAG_MODE (1 << 7)
265#define NHMEX_M_PMON_CTL_INC_SEL_SHIFT 9
266#define NHMEX_M_PMON_CTL_INC_SEL_MASK \
267 (0x1f << NHMEX_M_PMON_CTL_INC_SEL_SHIFT)
268#define NHMEX_M_PMON_CTL_SET_FLAG_SEL_SHIFT 19
269#define NHMEX_M_PMON_CTL_SET_FLAG_SEL_MASK \
270 (0x7 << NHMEX_M_PMON_CTL_SET_FLAG_SEL_SHIFT)
271#define NHMEX_M_PMON_RAW_EVENT_MASK \
272 (NHMEX_M_PMON_CTL_COUNT_MODE_MASK | \
273 NHMEX_M_PMON_CTL_STORAGE_MODE_MASK | \
274 NHMEX_M_PMON_CTL_WRAP_MODE | \
275 NHMEX_M_PMON_CTL_FLAG_MODE | \
276 NHMEX_M_PMON_CTL_INC_SEL_MASK | \
277 NHMEX_M_PMON_CTL_SET_FLAG_SEL_MASK)
278
279#define NHMEX_M_PMON_ZDP_CTL_FVC_MASK (((1 << 11) - 1) | (1 << 23))
280#define NHMEX_M_PMON_ZDP_CTL_FVC_EVENT_MASK(n) (0x7 << (11 + 3 * (n)))
281
282#define WSMEX_M_PMON_ZDP_CTL_FVC_MASK (((1 << 12) - 1) | (1 << 24))
283#define WSMEX_M_PMON_ZDP_CTL_FVC_EVENT_MASK(n) (0x7 << (12 + 3 * (n)))
284
285/*
286 * use the 9~13 bits to select event If the 7th bit is not set,
287 * otherwise use the 19~21 bits to select event.
288 */
289#define MBOX_INC_SEL(x) ((x) << NHMEX_M_PMON_CTL_INC_SEL_SHIFT)
290#define MBOX_SET_FLAG_SEL(x) (((x) << NHMEX_M_PMON_CTL_SET_FLAG_SEL_SHIFT) | \
291 NHMEX_M_PMON_CTL_FLAG_MODE)
292#define MBOX_INC_SEL_MASK (NHMEX_M_PMON_CTL_INC_SEL_MASK | \
293 NHMEX_M_PMON_CTL_FLAG_MODE)
294#define MBOX_SET_FLAG_SEL_MASK (NHMEX_M_PMON_CTL_SET_FLAG_SEL_MASK | \
295 NHMEX_M_PMON_CTL_FLAG_MODE)
296#define MBOX_INC_SEL_EXTAR_REG(c, r) \
297 EVENT_EXTRA_REG(MBOX_INC_SEL(c), NHMEX_M0_MSR_PMU_##r, \
298 MBOX_INC_SEL_MASK, (u64)-1, NHMEX_M_##r)
299#define MBOX_SET_FLAG_SEL_EXTRA_REG(c, r) \
300 EVENT_EXTRA_REG(MBOX_SET_FLAG_SEL(c), NHMEX_M0_MSR_PMU_##r, \
301 MBOX_SET_FLAG_SEL_MASK, \
302 (u64)-1, NHMEX_M_##r)
303
304/* NHM-EX Rbox */
305#define NHMEX_R_MSR_GLOBAL_CTL 0xe00
306#define NHMEX_R_MSR_PMON_CTL0 0xe10
307#define NHMEX_R_MSR_PMON_CNT0 0xe11
308#define NHMEX_R_MSR_OFFSET 0x20
309
310#define NHMEX_R_MSR_PORTN_QLX_CFG(n) \
311 ((n) < 4 ? (0xe0c + (n)) : (0xe2c + (n) - 4))
312#define NHMEX_R_MSR_PORTN_IPERF_CFG0(n) (0xe04 + (n))
313#define NHMEX_R_MSR_PORTN_IPERF_CFG1(n) (0xe24 + (n))
314#define NHMEX_R_MSR_PORTN_XBR_OFFSET(n) \
315 (((n) < 4 ? 0 : 0x10) + (n) * 4)
316#define NHMEX_R_MSR_PORTN_XBR_SET1_MM_CFG(n) \
317 (0xe60 + NHMEX_R_MSR_PORTN_XBR_OFFSET(n))
318#define NHMEX_R_MSR_PORTN_XBR_SET1_MATCH(n) \
319 (NHMEX_R_MSR_PORTN_XBR_SET1_MM_CFG(n) + 1)
320#define NHMEX_R_MSR_PORTN_XBR_SET1_MASK(n) \
321 (NHMEX_R_MSR_PORTN_XBR_SET1_MM_CFG(n) + 2)
322#define NHMEX_R_MSR_PORTN_XBR_SET2_MM_CFG(n) \
323 (0xe70 + NHMEX_R_MSR_PORTN_XBR_OFFSET(n))
324#define NHMEX_R_MSR_PORTN_XBR_SET2_MATCH(n) \
325 (NHMEX_R_MSR_PORTN_XBR_SET2_MM_CFG(n) + 1)
326#define NHMEX_R_MSR_PORTN_XBR_SET2_MASK(n) \
327 (NHMEX_R_MSR_PORTN_XBR_SET2_MM_CFG(n) + 2)
328
329#define NHMEX_R_PMON_CTL_EN (1 << 0)
330#define NHMEX_R_PMON_CTL_EV_SEL_SHIFT 1
331#define NHMEX_R_PMON_CTL_EV_SEL_MASK \
332 (0x1f << NHMEX_R_PMON_CTL_EV_SEL_SHIFT)
333#define NHMEX_R_PMON_CTL_PMI_EN (1 << 6)
334#define NHMEX_R_PMON_RAW_EVENT_MASK NHMEX_R_PMON_CTL_EV_SEL_MASK
335
336/* NHM-EX Wbox */
337#define NHMEX_W_MSR_GLOBAL_CTL 0xc80
338#define NHMEX_W_MSR_PMON_CNT0 0xc90
339#define NHMEX_W_MSR_PMON_EVT_SEL0 0xc91
340#define NHMEX_W_MSR_PMON_FIXED_CTR 0x394
341#define NHMEX_W_MSR_PMON_FIXED_CTL 0x395
342
343#define NHMEX_W_PMON_GLOBAL_FIXED_EN (1ULL << 31)
344
345struct intel_uncore_ops;
346struct intel_uncore_pmu;
347struct intel_uncore_box;
348struct uncore_event_desc;
349
350struct intel_uncore_type {
351 const char *name;
352 int num_counters;
353 int num_boxes;
354 int perf_ctr_bits;
355 int fixed_ctr_bits;
356 unsigned perf_ctr;
357 unsigned event_ctl;
358 unsigned event_mask;
359 unsigned fixed_ctr;
360 unsigned fixed_ctl;
361 unsigned box_ctl;
362 unsigned msr_offset;
363 unsigned num_shared_regs:8;
364 unsigned single_fixed:1;
365 unsigned pair_ctr_ctl:1;
366 unsigned *msr_offsets;
367 struct event_constraint unconstrainted;
368 struct event_constraint *constraints;
369 struct intel_uncore_pmu *pmus;
370 struct intel_uncore_ops *ops;
371 struct uncore_event_desc *event_descs;
372 const struct attribute_group *attr_groups[3];
373};
374
375#define format_group attr_groups[0]
376
377struct intel_uncore_ops {
378 void (*init_box)(struct intel_uncore_box *);
379 void (*disable_box)(struct intel_uncore_box *);
380 void (*enable_box)(struct intel_uncore_box *);
381 void (*disable_event)(struct intel_uncore_box *, struct perf_event *);
382 void (*enable_event)(struct intel_uncore_box *, struct perf_event *);
383 u64 (*read_counter)(struct intel_uncore_box *, struct perf_event *);
384 int (*hw_config)(struct intel_uncore_box *, struct perf_event *);
385 struct event_constraint *(*get_constraint)(struct intel_uncore_box *,
386 struct perf_event *);
387 void (*put_constraint)(struct intel_uncore_box *, struct perf_event *);
388};
389
390struct intel_uncore_pmu {
391 struct pmu pmu;
392 char name[UNCORE_PMU_NAME_LEN];
393 int pmu_idx;
394 int func_id;
395 struct intel_uncore_type *type;
396 struct intel_uncore_box ** __percpu box;
397 struct list_head box_list;
398};
399
400struct intel_uncore_extra_reg {
401 raw_spinlock_t lock;
402 u64 config, config1, config2;
403 atomic_t ref;
404};
405
406struct intel_uncore_box {
407 int phys_id;
408 int n_active; /* number of active events */
409 int n_events;
410 int cpu; /* cpu to collect events */
411 unsigned long flags;
412 atomic_t refcnt;
413 struct perf_event *events[UNCORE_PMC_IDX_MAX];
414 struct perf_event *event_list[UNCORE_PMC_IDX_MAX];
415 unsigned long active_mask[BITS_TO_LONGS(UNCORE_PMC_IDX_MAX)];
416 u64 tags[UNCORE_PMC_IDX_MAX];
417 struct pci_dev *pci_dev;
418 struct intel_uncore_pmu *pmu;
419 struct hrtimer hrtimer;
420 struct list_head list;
421 struct intel_uncore_extra_reg shared_regs[0];
422};
423
424#define UNCORE_BOX_FLAG_INITIATED 0
425
426struct uncore_event_desc {
427 struct kobj_attribute attr;
428 const char *config;
429};
430
431#define INTEL_UNCORE_EVENT_DESC(_name, _config) \
432{ \
433 .attr = __ATTR(_name, 0444, uncore_event_show, NULL), \
434 .config = _config, \
435}
436
437#define DEFINE_UNCORE_FORMAT_ATTR(_var, _name, _format) \
438static ssize_t __uncore_##_var##_show(struct kobject *kobj, \
439 struct kobj_attribute *attr, \
440 char *page) \
441{ \
442 BUILD_BUG_ON(sizeof(_format) >= PAGE_SIZE); \
443 return sprintf(page, _format "\n"); \
444} \
445static struct kobj_attribute format_attr_##_var = \
446 __ATTR(_name, 0444, __uncore_##_var##_show, NULL)
447
448
449static ssize_t uncore_event_show(struct kobject *kobj,
450 struct kobj_attribute *attr, char *buf)
451{
452 struct uncore_event_desc *event =
453 container_of(attr, struct uncore_event_desc, attr);
454 return sprintf(buf, "%s", event->config);
455}
456
457static inline unsigned uncore_pci_box_ctl(struct intel_uncore_box *box)
458{
459 return box->pmu->type->box_ctl;
460}
461
462static inline unsigned uncore_pci_fixed_ctl(struct intel_uncore_box *box)
463{
464 return box->pmu->type->fixed_ctl;
465}
466
467static inline unsigned uncore_pci_fixed_ctr(struct intel_uncore_box *box)
468{
469 return box->pmu->type->fixed_ctr;
470}
471
472static inline
473unsigned uncore_pci_event_ctl(struct intel_uncore_box *box, int idx)
474{
475 return idx * 4 + box->pmu->type->event_ctl;
476}
477
478static inline
479unsigned uncore_pci_perf_ctr(struct intel_uncore_box *box, int idx)
480{
481 return idx * 8 + box->pmu->type->perf_ctr;
482}
483
484static inline unsigned uncore_msr_box_offset(struct intel_uncore_box *box)
485{
486 struct intel_uncore_pmu *pmu = box->pmu;
487 return pmu->type->msr_offsets ?
488 pmu->type->msr_offsets[pmu->pmu_idx] :
489 pmu->type->msr_offset * pmu->pmu_idx;
490}
491
492static inline unsigned uncore_msr_box_ctl(struct intel_uncore_box *box)
493{
494 if (!box->pmu->type->box_ctl)
495 return 0;
496 return box->pmu->type->box_ctl + uncore_msr_box_offset(box);
497}
498
499static inline unsigned uncore_msr_fixed_ctl(struct intel_uncore_box *box)
500{
501 if (!box->pmu->type->fixed_ctl)
502 return 0;
503 return box->pmu->type->fixed_ctl + uncore_msr_box_offset(box);
504}
505
506static inline unsigned uncore_msr_fixed_ctr(struct intel_uncore_box *box)
507{
508 return box->pmu->type->fixed_ctr + uncore_msr_box_offset(box);
509}
510
511static inline
512unsigned uncore_msr_event_ctl(struct intel_uncore_box *box, int idx)
513{
514 return box->pmu->type->event_ctl +
515 (box->pmu->type->pair_ctr_ctl ? 2 * idx : idx) +
516 uncore_msr_box_offset(box);
517}
518
519static inline
520unsigned uncore_msr_perf_ctr(struct intel_uncore_box *box, int idx)
521{
522 return box->pmu->type->perf_ctr +
523 (box->pmu->type->pair_ctr_ctl ? 2 * idx : idx) +
524 uncore_msr_box_offset(box);
525}
526
527static inline
528unsigned uncore_fixed_ctl(struct intel_uncore_box *box)
529{
530 if (box->pci_dev)
531 return uncore_pci_fixed_ctl(box);
532 else
533 return uncore_msr_fixed_ctl(box);
534}
535
536static inline
537unsigned uncore_fixed_ctr(struct intel_uncore_box *box)
538{
539 if (box->pci_dev)
540 return uncore_pci_fixed_ctr(box);
541 else
542 return uncore_msr_fixed_ctr(box);
543}
544
545static inline
546unsigned uncore_event_ctl(struct intel_uncore_box *box, int idx)
547{
548 if (box->pci_dev)
549 return uncore_pci_event_ctl(box, idx);
550 else
551 return uncore_msr_event_ctl(box, idx);
552}
553
554static inline
555unsigned uncore_perf_ctr(struct intel_uncore_box *box, int idx)
556{
557 if (box->pci_dev)
558 return uncore_pci_perf_ctr(box, idx);
559 else
560 return uncore_msr_perf_ctr(box, idx);
561}
562
563static inline int uncore_perf_ctr_bits(struct intel_uncore_box *box)
564{
565 return box->pmu->type->perf_ctr_bits;
566}
567
568static inline int uncore_fixed_ctr_bits(struct intel_uncore_box *box)
569{
570 return box->pmu->type->fixed_ctr_bits;
571}
572
573static inline int uncore_num_counters(struct intel_uncore_box *box)
574{
575 return box->pmu->type->num_counters;
576}
577
578static inline void uncore_disable_box(struct intel_uncore_box *box)
579{
580 if (box->pmu->type->ops->disable_box)
581 box->pmu->type->ops->disable_box(box);
582}
583
584static inline void uncore_enable_box(struct intel_uncore_box *box)
585{
586 if (box->pmu->type->ops->enable_box)
587 box->pmu->type->ops->enable_box(box);
588}
589
590static inline void uncore_disable_event(struct intel_uncore_box *box,
591 struct perf_event *event)
592{
593 box->pmu->type->ops->disable_event(box, event);
594}
595
596static inline void uncore_enable_event(struct intel_uncore_box *box,
597 struct perf_event *event)
598{
599 box->pmu->type->ops->enable_event(box, event);
600}
601
602static inline u64 uncore_read_counter(struct intel_uncore_box *box,
603 struct perf_event *event)
604{
605 return box->pmu->type->ops->read_counter(box, event);
606}
607
608static inline void uncore_box_init(struct intel_uncore_box *box)
609{
610 if (!test_and_set_bit(UNCORE_BOX_FLAG_INITIATED, &box->flags)) {
611 if (box->pmu->type->ops->init_box)
612 box->pmu->type->ops->init_box(box);
613 }
614}
615
616static inline bool uncore_box_is_fake(struct intel_uncore_box *box)
617{
618 return (box->phys_id < 0);
619}
diff --git a/arch/x86/kernel/cpu/perf_event_p4.c b/arch/x86/kernel/cpu/perf_event_p4.c
index 47124a73dd7..92c7e39a079 100644
--- a/arch/x86/kernel/cpu/perf_event_p4.c
+++ b/arch/x86/kernel/cpu/perf_event_p4.c
@@ -895,8 +895,8 @@ static void p4_pmu_disable_pebs(void)
895 * So at moment let leave metrics turned on forever -- it's 895 * So at moment let leave metrics turned on forever -- it's
896 * ok for now but need to be revisited! 896 * ok for now but need to be revisited!
897 * 897 *
898 * (void)checking_wrmsrl(MSR_IA32_PEBS_ENABLE, (u64)0); 898 * (void)wrmsrl_safe(MSR_IA32_PEBS_ENABLE, (u64)0);
899 * (void)checking_wrmsrl(MSR_P4_PEBS_MATRIX_VERT, (u64)0); 899 * (void)wrmsrl_safe(MSR_P4_PEBS_MATRIX_VERT, (u64)0);
900 */ 900 */
901} 901}
902 902
@@ -909,7 +909,7 @@ static inline void p4_pmu_disable_event(struct perf_event *event)
909 * state we need to clear P4_CCCR_OVF, otherwise interrupt get 909 * state we need to clear P4_CCCR_OVF, otherwise interrupt get
910 * asserted again and again 910 * asserted again and again
911 */ 911 */
912 (void)checking_wrmsrl(hwc->config_base, 912 (void)wrmsrl_safe(hwc->config_base,
913 (u64)(p4_config_unpack_cccr(hwc->config)) & 913 (u64)(p4_config_unpack_cccr(hwc->config)) &
914 ~P4_CCCR_ENABLE & ~P4_CCCR_OVF & ~P4_CCCR_RESERVED); 914 ~P4_CCCR_ENABLE & ~P4_CCCR_OVF & ~P4_CCCR_RESERVED);
915} 915}
@@ -943,8 +943,8 @@ static void p4_pmu_enable_pebs(u64 config)
943 943
944 bind = &p4_pebs_bind_map[idx]; 944 bind = &p4_pebs_bind_map[idx];
945 945
946 (void)checking_wrmsrl(MSR_IA32_PEBS_ENABLE, (u64)bind->metric_pebs); 946 (void)wrmsrl_safe(MSR_IA32_PEBS_ENABLE, (u64)bind->metric_pebs);
947 (void)checking_wrmsrl(MSR_P4_PEBS_MATRIX_VERT, (u64)bind->metric_vert); 947 (void)wrmsrl_safe(MSR_P4_PEBS_MATRIX_VERT, (u64)bind->metric_vert);
948} 948}
949 949
950static void p4_pmu_enable_event(struct perf_event *event) 950static void p4_pmu_enable_event(struct perf_event *event)
@@ -978,8 +978,8 @@ static void p4_pmu_enable_event(struct perf_event *event)
978 */ 978 */
979 p4_pmu_enable_pebs(hwc->config); 979 p4_pmu_enable_pebs(hwc->config);
980 980
981 (void)checking_wrmsrl(escr_addr, escr_conf); 981 (void)wrmsrl_safe(escr_addr, escr_conf);
982 (void)checking_wrmsrl(hwc->config_base, 982 (void)wrmsrl_safe(hwc->config_base,
983 (cccr & ~P4_CCCR_RESERVED) | P4_CCCR_ENABLE); 983 (cccr & ~P4_CCCR_RESERVED) | P4_CCCR_ENABLE);
984} 984}
985 985
@@ -1325,7 +1325,7 @@ __init int p4_pmu_init(void)
1325 unsigned int low, high; 1325 unsigned int low, high;
1326 1326
1327 /* If we get stripped -- indexing fails */ 1327 /* If we get stripped -- indexing fails */
1328 BUILD_BUG_ON(ARCH_P4_MAX_CCCR > X86_PMC_MAX_GENERIC); 1328 BUILD_BUG_ON(ARCH_P4_MAX_CCCR > INTEL_PMC_MAX_GENERIC);
1329 1329
1330 rdmsr(MSR_IA32_MISC_ENABLE, low, high); 1330 rdmsr(MSR_IA32_MISC_ENABLE, low, high);
1331 if (!(low & (1 << 7))) { 1331 if (!(low & (1 << 7))) {
diff --git a/arch/x86/kernel/cpu/perf_event_p6.c b/arch/x86/kernel/cpu/perf_event_p6.c
index 32bcfc7dd23..e4dd0f7a045 100644
--- a/arch/x86/kernel/cpu/perf_event_p6.c
+++ b/arch/x86/kernel/cpu/perf_event_p6.c
@@ -71,7 +71,7 @@ p6_pmu_disable_event(struct perf_event *event)
71 if (cpuc->enabled) 71 if (cpuc->enabled)
72 val |= ARCH_PERFMON_EVENTSEL_ENABLE; 72 val |= ARCH_PERFMON_EVENTSEL_ENABLE;
73 73
74 (void)checking_wrmsrl(hwc->config_base, val); 74 (void)wrmsrl_safe(hwc->config_base, val);
75} 75}
76 76
77static void p6_pmu_enable_event(struct perf_event *event) 77static void p6_pmu_enable_event(struct perf_event *event)
@@ -84,7 +84,7 @@ static void p6_pmu_enable_event(struct perf_event *event)
84 if (cpuc->enabled) 84 if (cpuc->enabled)
85 val |= ARCH_PERFMON_EVENTSEL_ENABLE; 85 val |= ARCH_PERFMON_EVENTSEL_ENABLE;
86 86
87 (void)checking_wrmsrl(hwc->config_base, val); 87 (void)wrmsrl_safe(hwc->config_base, val);
88} 88}
89 89
90PMU_FORMAT_ATTR(event, "config:0-7" ); 90PMU_FORMAT_ATTR(event, "config:0-7" );
diff --git a/arch/x86/kernel/cpu/sched.c b/arch/x86/kernel/cpu/sched.c
deleted file mode 100644
index a640ae5ad20..00000000000
--- a/arch/x86/kernel/cpu/sched.c
+++ /dev/null
@@ -1,55 +0,0 @@
1#include <linux/sched.h>
2#include <linux/math64.h>
3#include <linux/percpu.h>
4#include <linux/irqflags.h>
5
6#include <asm/cpufeature.h>
7#include <asm/processor.h>
8
9#ifdef CONFIG_SMP
10
11static DEFINE_PER_CPU(struct aperfmperf, old_perf_sched);
12
13static unsigned long scale_aperfmperf(void)
14{
15 struct aperfmperf val, *old = &__get_cpu_var(old_perf_sched);
16 unsigned long ratio, flags;
17
18 local_irq_save(flags);
19 get_aperfmperf(&val);
20 local_irq_restore(flags);
21
22 ratio = calc_aperfmperf_ratio(old, &val);
23 *old = val;
24
25 return ratio;
26}
27
28unsigned long arch_scale_freq_power(struct sched_domain *sd, int cpu)
29{
30 /*
31 * do aperf/mperf on the cpu level because it includes things
32 * like turbo mode, which are relevant to full cores.
33 */
34 if (boot_cpu_has(X86_FEATURE_APERFMPERF))
35 return scale_aperfmperf();
36
37 /*
38 * maybe have something cpufreq here
39 */
40
41 return default_scale_freq_power(sd, cpu);
42}
43
44unsigned long arch_scale_smt_power(struct sched_domain *sd, int cpu)
45{
46 /*
47 * aperf/mperf already includes the smt gain
48 */
49 if (boot_cpu_has(X86_FEATURE_APERFMPERF))
50 return SCHED_LOAD_SCALE;
51
52 return default_scale_smt_power(sd, cpu);
53}
54
55#endif
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index 571246d81ed..ae42418bc50 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -27,8 +27,8 @@ static int die_counter;
27 27
28void printk_address(unsigned long address, int reliable) 28void printk_address(unsigned long address, int reliable)
29{ 29{
30 printk(" [<%p>] %s%pB\n", (void *) address, 30 pr_cont(" [<%p>] %s%pB\n",
31 reliable ? "" : "? ", (void *) address); 31 (void *)address, reliable ? "" : "? ", (void *)address);
32} 32}
33 33
34#ifdef CONFIG_FUNCTION_GRAPH_TRACER 34#ifdef CONFIG_FUNCTION_GRAPH_TRACER
@@ -271,6 +271,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
271 current->thread.trap_nr, SIGSEGV) == NOTIFY_STOP) 271 current->thread.trap_nr, SIGSEGV) == NOTIFY_STOP)
272 return 1; 272 return 1;
273 273
274 print_modules();
274 show_regs(regs); 275 show_regs(regs);
275#ifdef CONFIG_X86_32 276#ifdef CONFIG_X86_32
276 if (user_mode_vm(regs)) { 277 if (user_mode_vm(regs)) {
diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
index e0b1d783daa..1038a417ea5 100644
--- a/arch/x86/kernel/dumpstack_32.c
+++ b/arch/x86/kernel/dumpstack_32.c
@@ -73,11 +73,11 @@ show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
73 if (kstack_end(stack)) 73 if (kstack_end(stack))
74 break; 74 break;
75 if (i && ((i % STACKSLOTS_PER_LINE) == 0)) 75 if (i && ((i % STACKSLOTS_PER_LINE) == 0))
76 printk(KERN_CONT "\n"); 76 pr_cont("\n");
77 printk(KERN_CONT " %08lx", *stack++); 77 pr_cont(" %08lx", *stack++);
78 touch_nmi_watchdog(); 78 touch_nmi_watchdog();
79 } 79 }
80 printk(KERN_CONT "\n"); 80 pr_cont("\n");
81 show_trace_log_lvl(task, regs, sp, bp, log_lvl); 81 show_trace_log_lvl(task, regs, sp, bp, log_lvl);
82} 82}
83 83
@@ -86,12 +86,11 @@ void show_regs(struct pt_regs *regs)
86{ 86{
87 int i; 87 int i;
88 88
89 print_modules();
90 __show_regs(regs, !user_mode_vm(regs)); 89 __show_regs(regs, !user_mode_vm(regs));
91 90
92 printk(KERN_EMERG "Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n", 91 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
93 TASK_COMM_LEN, current->comm, task_pid_nr(current), 92 TASK_COMM_LEN, current->comm, task_pid_nr(current),
94 current_thread_info(), current, task_thread_info(current)); 93 current_thread_info(), current, task_thread_info(current));
95 /* 94 /*
96 * When in-kernel, we also print out the stack and code at the 95 * When in-kernel, we also print out the stack and code at the
97 * time of the fault.. 96 * time of the fault..
@@ -102,10 +101,10 @@ void show_regs(struct pt_regs *regs)
102 unsigned char c; 101 unsigned char c;
103 u8 *ip; 102 u8 *ip;
104 103
105 printk(KERN_EMERG "Stack:\n"); 104 pr_emerg("Stack:\n");
106 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG); 105 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
107 106
108 printk(KERN_EMERG "Code: "); 107 pr_emerg("Code:");
109 108
110 ip = (u8 *)regs->ip - code_prologue; 109 ip = (u8 *)regs->ip - code_prologue;
111 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) { 110 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
@@ -116,16 +115,16 @@ void show_regs(struct pt_regs *regs)
116 for (i = 0; i < code_len; i++, ip++) { 115 for (i = 0; i < code_len; i++, ip++) {
117 if (ip < (u8 *)PAGE_OFFSET || 116 if (ip < (u8 *)PAGE_OFFSET ||
118 probe_kernel_address(ip, c)) { 117 probe_kernel_address(ip, c)) {
119 printk(KERN_CONT " Bad EIP value."); 118 pr_cont(" Bad EIP value.");
120 break; 119 break;
121 } 120 }
122 if (ip == (u8 *)regs->ip) 121 if (ip == (u8 *)regs->ip)
123 printk(KERN_CONT "<%02x> ", c); 122 pr_cont(" <%02x>", c);
124 else 123 else
125 printk(KERN_CONT "%02x ", c); 124 pr_cont(" %02x", c);
126 } 125 }
127 } 126 }
128 printk(KERN_CONT "\n"); 127 pr_cont("\n");
129} 128}
130 129
131int is_valid_bugaddr(unsigned long ip) 130int is_valid_bugaddr(unsigned long ip)
diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
index 791b76122aa..b653675d528 100644
--- a/arch/x86/kernel/dumpstack_64.c
+++ b/arch/x86/kernel/dumpstack_64.c
@@ -228,20 +228,20 @@ show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
228 if (stack >= irq_stack && stack <= irq_stack_end) { 228 if (stack >= irq_stack && stack <= irq_stack_end) {
229 if (stack == irq_stack_end) { 229 if (stack == irq_stack_end) {
230 stack = (unsigned long *) (irq_stack_end[-1]); 230 stack = (unsigned long *) (irq_stack_end[-1]);
231 printk(KERN_CONT " <EOI> "); 231 pr_cont(" <EOI> ");
232 } 232 }
233 } else { 233 } else {
234 if (((long) stack & (THREAD_SIZE-1)) == 0) 234 if (((long) stack & (THREAD_SIZE-1)) == 0)
235 break; 235 break;
236 } 236 }
237 if (i && ((i % STACKSLOTS_PER_LINE) == 0)) 237 if (i && ((i % STACKSLOTS_PER_LINE) == 0))
238 printk(KERN_CONT "\n"); 238 pr_cont("\n");
239 printk(KERN_CONT " %016lx", *stack++); 239 pr_cont(" %016lx", *stack++);
240 touch_nmi_watchdog(); 240 touch_nmi_watchdog();
241 } 241 }
242 preempt_enable(); 242 preempt_enable();
243 243
244 printk(KERN_CONT "\n"); 244 pr_cont("\n");
245 show_trace_log_lvl(task, regs, sp, bp, log_lvl); 245 show_trace_log_lvl(task, regs, sp, bp, log_lvl);
246} 246}
247 247
@@ -254,10 +254,9 @@ void show_regs(struct pt_regs *regs)
254 254
255 sp = regs->sp; 255 sp = regs->sp;
256 printk("CPU %d ", cpu); 256 printk("CPU %d ", cpu);
257 print_modules();
258 __show_regs(regs, 1); 257 __show_regs(regs, 1);
259 printk("Process %s (pid: %d, threadinfo %p, task %p)\n", 258 printk(KERN_DEFAULT "Process %s (pid: %d, threadinfo %p, task %p)\n",
260 cur->comm, cur->pid, task_thread_info(cur), cur); 259 cur->comm, cur->pid, task_thread_info(cur), cur);
261 260
262 /* 261 /*
263 * When in-kernel, we also print out the stack and code at the 262 * When in-kernel, we also print out the stack and code at the
@@ -284,16 +283,16 @@ void show_regs(struct pt_regs *regs)
284 for (i = 0; i < code_len; i++, ip++) { 283 for (i = 0; i < code_len; i++, ip++) {
285 if (ip < (u8 *)PAGE_OFFSET || 284 if (ip < (u8 *)PAGE_OFFSET ||
286 probe_kernel_address(ip, c)) { 285 probe_kernel_address(ip, c)) {
287 printk(KERN_CONT " Bad RIP value."); 286 pr_cont(" Bad RIP value.");
288 break; 287 break;
289 } 288 }
290 if (ip == (u8 *)regs->ip) 289 if (ip == (u8 *)regs->ip)
291 printk(KERN_CONT "<%02x> ", c); 290 pr_cont("<%02x> ", c);
292 else 291 else
293 printk(KERN_CONT "%02x ", c); 292 pr_cont("%02x ", c);
294 } 293 }
295 } 294 }
296 printk(KERN_CONT "\n"); 295 pr_cont("\n");
297} 296}
298 297
299int is_valid_bugaddr(unsigned long ip) 298int is_valid_bugaddr(unsigned long ip)
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 41857970517..ed858e9e9a7 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -944,7 +944,7 @@ void __init e820_reserve_resources(void)
944 for (i = 0; i < e820_saved.nr_map; i++) { 944 for (i = 0; i < e820_saved.nr_map; i++) {
945 struct e820entry *entry = &e820_saved.map[i]; 945 struct e820entry *entry = &e820_saved.map[i];
946 firmware_map_add_early(entry->addr, 946 firmware_map_add_early(entry->addr,
947 entry->addr + entry->size - 1, 947 entry->addr + entry->size,
948 e820_type_to_string(entry->type)); 948 e820_type_to_string(entry->type));
949 } 949 }
950} 950}
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 7d65133b51b..69babd8c834 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -1048,24 +1048,6 @@ apicinterrupt LOCAL_TIMER_VECTOR \
1048apicinterrupt X86_PLATFORM_IPI_VECTOR \ 1048apicinterrupt X86_PLATFORM_IPI_VECTOR \
1049 x86_platform_ipi smp_x86_platform_ipi 1049 x86_platform_ipi smp_x86_platform_ipi
1050 1050
1051#ifdef CONFIG_SMP
1052 ALIGN
1053 INTR_FRAME
1054.irp idx,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, \
1055 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
1056.if NUM_INVALIDATE_TLB_VECTORS > \idx
1057ENTRY(invalidate_interrupt\idx)
1058 pushq_cfi $~(INVALIDATE_TLB_VECTOR_START+\idx)
1059 jmp .Lcommon_invalidate_interrupt0
1060 CFI_ADJUST_CFA_OFFSET -8
1061END(invalidate_interrupt\idx)
1062.endif
1063.endr
1064 CFI_ENDPROC
1065apicinterrupt INVALIDATE_TLB_VECTOR_START, \
1066 invalidate_interrupt0, smp_invalidate_interrupt
1067#endif
1068
1069apicinterrupt THRESHOLD_APIC_VECTOR \ 1051apicinterrupt THRESHOLD_APIC_VECTOR \
1070 threshold_interrupt smp_threshold_interrupt 1052 threshold_interrupt smp_threshold_interrupt
1071apicinterrupt THERMAL_APIC_VECTOR \ 1053apicinterrupt THERMAL_APIC_VECTOR \
@@ -1758,10 +1740,30 @@ end_repeat_nmi:
1758 */ 1740 */
1759 call save_paranoid 1741 call save_paranoid
1760 DEFAULT_FRAME 0 1742 DEFAULT_FRAME 0
1743
1744 /*
1745 * Save off the CR2 register. If we take a page fault in the NMI then
1746 * it could corrupt the CR2 value. If the NMI preempts a page fault
1747 * handler before it was able to read the CR2 register, and then the
1748 * NMI itself takes a page fault, the page fault that was preempted
1749 * will read the information from the NMI page fault and not the
1750 * origin fault. Save it off and restore it if it changes.
1751 * Use the r12 callee-saved register.
1752 */
1753 movq %cr2, %r12
1754
1761 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */ 1755 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
1762 movq %rsp,%rdi 1756 movq %rsp,%rdi
1763 movq $-1,%rsi 1757 movq $-1,%rsi
1764 call do_nmi 1758 call do_nmi
1759
1760 /* Did the NMI take a page fault? Restore cr2 if it did */
1761 movq %cr2, %rcx
1762 cmpq %rcx, %r12
1763 je 1f
1764 movq %r12, %cr2
17651:
1766
1765 testl %ebx,%ebx /* swapgs needed? */ 1767 testl %ebx,%ebx /* swapgs needed? */
1766 jnz nmi_restore 1768 jnz nmi_restore
1767nmi_swapgs: 1769nmi_swapgs:
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index 3dafc6003b7..d44f7829968 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -270,7 +270,7 @@ void fixup_irqs(void)
270 270
271 if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) { 271 if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) {
272 break_affinity = 1; 272 break_affinity = 1;
273 affinity = cpu_all_mask; 273 affinity = cpu_online_mask;
274 } 274 }
275 275
276 chip = irq_data_get_irq_chip(data); 276 chip = irq_data_get_irq_chip(data);
@@ -294,9 +294,9 @@ void fixup_irqs(void)
294 raw_spin_unlock(&desc->lock); 294 raw_spin_unlock(&desc->lock);
295 295
296 if (break_affinity && set_affinity) 296 if (break_affinity && set_affinity)
297 printk("Broke affinity for irq %i\n", irq); 297 pr_notice("Broke affinity for irq %i\n", irq);
298 else if (!set_affinity) 298 else if (!set_affinity)
299 printk("Cannot set affinity for irq %i\n", irq); 299 pr_notice("Cannot set affinity for irq %i\n", irq);
300 } 300 }
301 301
302 /* 302 /*
@@ -328,6 +328,7 @@ void fixup_irqs(void)
328 chip->irq_retrigger(data); 328 chip->irq_retrigger(data);
329 raw_spin_unlock(&desc->lock); 329 raw_spin_unlock(&desc->lock);
330 } 330 }
331 __this_cpu_write(vector_irq[vector], -1);
331 } 332 }
332} 333}
333#endif 334#endif
diff --git a/arch/x86/kernel/irqinit.c b/arch/x86/kernel/irqinit.c
index 252981afd6c..6e03b0d6913 100644
--- a/arch/x86/kernel/irqinit.c
+++ b/arch/x86/kernel/irqinit.c
@@ -171,79 +171,6 @@ static void __init smp_intr_init(void)
171 */ 171 */
172 alloc_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt); 172 alloc_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt);
173 173
174 /* IPIs for invalidation */
175#define ALLOC_INVTLB_VEC(NR) \
176 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+NR, \
177 invalidate_interrupt##NR)
178
179 switch (NUM_INVALIDATE_TLB_VECTORS) {
180 default:
181 ALLOC_INVTLB_VEC(31);
182 case 31:
183 ALLOC_INVTLB_VEC(30);
184 case 30:
185 ALLOC_INVTLB_VEC(29);
186 case 29:
187 ALLOC_INVTLB_VEC(28);
188 case 28:
189 ALLOC_INVTLB_VEC(27);
190 case 27:
191 ALLOC_INVTLB_VEC(26);
192 case 26:
193 ALLOC_INVTLB_VEC(25);
194 case 25:
195 ALLOC_INVTLB_VEC(24);
196 case 24:
197 ALLOC_INVTLB_VEC(23);
198 case 23:
199 ALLOC_INVTLB_VEC(22);
200 case 22:
201 ALLOC_INVTLB_VEC(21);
202 case 21:
203 ALLOC_INVTLB_VEC(20);
204 case 20:
205 ALLOC_INVTLB_VEC(19);
206 case 19:
207 ALLOC_INVTLB_VEC(18);
208 case 18:
209 ALLOC_INVTLB_VEC(17);
210 case 17:
211 ALLOC_INVTLB_VEC(16);
212 case 16:
213 ALLOC_INVTLB_VEC(15);
214 case 15:
215 ALLOC_INVTLB_VEC(14);
216 case 14:
217 ALLOC_INVTLB_VEC(13);
218 case 13:
219 ALLOC_INVTLB_VEC(12);
220 case 12:
221 ALLOC_INVTLB_VEC(11);
222 case 11:
223 ALLOC_INVTLB_VEC(10);
224 case 10:
225 ALLOC_INVTLB_VEC(9);
226 case 9:
227 ALLOC_INVTLB_VEC(8);
228 case 8:
229 ALLOC_INVTLB_VEC(7);
230 case 7:
231 ALLOC_INVTLB_VEC(6);
232 case 6:
233 ALLOC_INVTLB_VEC(5);
234 case 5:
235 ALLOC_INVTLB_VEC(4);
236 case 4:
237 ALLOC_INVTLB_VEC(3);
238 case 3:
239 ALLOC_INVTLB_VEC(2);
240 case 2:
241 ALLOC_INVTLB_VEC(1);
242 case 1:
243 ALLOC_INVTLB_VEC(0);
244 break;
245 }
246
247 /* IPI for generic function call */ 174 /* IPI for generic function call */
248 alloc_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt); 175 alloc_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt);
249 176
diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
index 1d5d31ea686..dc1404bf8e4 100644
--- a/arch/x86/kernel/kdebugfs.c
+++ b/arch/x86/kernel/kdebugfs.c
@@ -107,7 +107,7 @@ static int __init create_setup_data_nodes(struct dentry *parent)
107{ 107{
108 struct setup_data_node *node; 108 struct setup_data_node *node;
109 struct setup_data *data; 109 struct setup_data *data;
110 int error = -ENOMEM; 110 int error;
111 struct dentry *d; 111 struct dentry *d;
112 struct page *pg; 112 struct page *pg;
113 u64 pa_data; 113 u64 pa_data;
@@ -121,8 +121,10 @@ static int __init create_setup_data_nodes(struct dentry *parent)
121 121
122 while (pa_data) { 122 while (pa_data) {
123 node = kmalloc(sizeof(*node), GFP_KERNEL); 123 node = kmalloc(sizeof(*node), GFP_KERNEL);
124 if (!node) 124 if (!node) {
125 error = -ENOMEM;
125 goto err_dir; 126 goto err_dir;
127 }
126 128
127 pg = pfn_to_page((pa_data+sizeof(*data)-1) >> PAGE_SHIFT); 129 pg = pfn_to_page((pa_data+sizeof(*data)-1) >> PAGE_SHIFT);
128 if (PageHighMem(pg)) { 130 if (PageHighMem(pg)) {
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index e554e5ad2fe..c1d61ee4b4f 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -39,6 +39,9 @@
39#include <asm/desc.h> 39#include <asm/desc.h>
40#include <asm/tlbflush.h> 40#include <asm/tlbflush.h>
41#include <asm/idle.h> 41#include <asm/idle.h>
42#include <asm/apic.h>
43#include <asm/apicdef.h>
44#include <asm/hypervisor.h>
42 45
43static int kvmapf = 1; 46static int kvmapf = 1;
44 47
@@ -283,6 +286,22 @@ static void kvm_register_steal_time(void)
283 cpu, __pa(st)); 286 cpu, __pa(st));
284} 287}
285 288
289static DEFINE_PER_CPU(unsigned long, kvm_apic_eoi) = KVM_PV_EOI_DISABLED;
290
291static void kvm_guest_apic_eoi_write(u32 reg, u32 val)
292{
293 /**
294 * This relies on __test_and_clear_bit to modify the memory
295 * in a way that is atomic with respect to the local CPU.
296 * The hypervisor only accesses this memory from the local CPU so
297 * there's no need for lock or memory barriers.
298 * An optimization barrier is implied in apic write.
299 */
300 if (__test_and_clear_bit(KVM_PV_EOI_BIT, &__get_cpu_var(kvm_apic_eoi)))
301 return;
302 apic_write(APIC_EOI, APIC_EOI_ACK);
303}
304
286void __cpuinit kvm_guest_cpu_init(void) 305void __cpuinit kvm_guest_cpu_init(void)
287{ 306{
288 if (!kvm_para_available()) 307 if (!kvm_para_available())
@@ -300,11 +319,20 @@ void __cpuinit kvm_guest_cpu_init(void)
300 smp_processor_id()); 319 smp_processor_id());
301 } 320 }
302 321
322 if (kvm_para_has_feature(KVM_FEATURE_PV_EOI)) {
323 unsigned long pa;
324 /* Size alignment is implied but just to make it explicit. */
325 BUILD_BUG_ON(__alignof__(kvm_apic_eoi) < 4);
326 __get_cpu_var(kvm_apic_eoi) = 0;
327 pa = __pa(&__get_cpu_var(kvm_apic_eoi)) | KVM_MSR_ENABLED;
328 wrmsrl(MSR_KVM_PV_EOI_EN, pa);
329 }
330
303 if (has_steal_clock) 331 if (has_steal_clock)
304 kvm_register_steal_time(); 332 kvm_register_steal_time();
305} 333}
306 334
307static void kvm_pv_disable_apf(void *unused) 335static void kvm_pv_disable_apf(void)
308{ 336{
309 if (!__get_cpu_var(apf_reason).enabled) 337 if (!__get_cpu_var(apf_reason).enabled)
310 return; 338 return;
@@ -316,11 +344,23 @@ static void kvm_pv_disable_apf(void *unused)
316 smp_processor_id()); 344 smp_processor_id());
317} 345}
318 346
347static void kvm_pv_guest_cpu_reboot(void *unused)
348{
349 /*
350 * We disable PV EOI before we load a new kernel by kexec,
351 * since MSR_KVM_PV_EOI_EN stores a pointer into old kernel's memory.
352 * New kernel can re-enable when it boots.
353 */
354 if (kvm_para_has_feature(KVM_FEATURE_PV_EOI))
355 wrmsrl(MSR_KVM_PV_EOI_EN, 0);
356 kvm_pv_disable_apf();
357}
358
319static int kvm_pv_reboot_notify(struct notifier_block *nb, 359static int kvm_pv_reboot_notify(struct notifier_block *nb,
320 unsigned long code, void *unused) 360 unsigned long code, void *unused)
321{ 361{
322 if (code == SYS_RESTART) 362 if (code == SYS_RESTART)
323 on_each_cpu(kvm_pv_disable_apf, NULL, 1); 363 on_each_cpu(kvm_pv_guest_cpu_reboot, NULL, 1);
324 return NOTIFY_DONE; 364 return NOTIFY_DONE;
325} 365}
326 366
@@ -371,7 +411,9 @@ static void __cpuinit kvm_guest_cpu_online(void *dummy)
371static void kvm_guest_cpu_offline(void *dummy) 411static void kvm_guest_cpu_offline(void *dummy)
372{ 412{
373 kvm_disable_steal_time(); 413 kvm_disable_steal_time();
374 kvm_pv_disable_apf(NULL); 414 if (kvm_para_has_feature(KVM_FEATURE_PV_EOI))
415 wrmsrl(MSR_KVM_PV_EOI_EN, 0);
416 kvm_pv_disable_apf();
375 apf_task_wake_all(); 417 apf_task_wake_all();
376} 418}
377 419
@@ -424,6 +466,9 @@ void __init kvm_guest_init(void)
424 pv_time_ops.steal_clock = kvm_steal_clock; 466 pv_time_ops.steal_clock = kvm_steal_clock;
425 } 467 }
426 468
469 if (kvm_para_has_feature(KVM_FEATURE_PV_EOI))
470 apic_set_eoi_write(kvm_guest_apic_eoi_write);
471
427#ifdef CONFIG_SMP 472#ifdef CONFIG_SMP
428 smp_ops.smp_prepare_boot_cpu = kvm_smp_prepare_boot_cpu; 473 smp_ops.smp_prepare_boot_cpu = kvm_smp_prepare_boot_cpu;
429 register_cpu_notifier(&kvm_cpu_notifier); 474 register_cpu_notifier(&kvm_cpu_notifier);
@@ -432,6 +477,19 @@ void __init kvm_guest_init(void)
432#endif 477#endif
433} 478}
434 479
480static bool __init kvm_detect(void)
481{
482 if (!kvm_para_available())
483 return false;
484 return true;
485}
486
487const struct hypervisor_x86 x86_hyper_kvm __refconst = {
488 .name = "KVM",
489 .detect = kvm_detect,
490};
491EXPORT_SYMBOL_GPL(x86_hyper_kvm);
492
435static __init int activate_jump_labels(void) 493static __init int activate_jump_labels(void)
436{ 494{
437 if (has_steal_clock) { 495 if (has_steal_clock) {
diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
index 8a2ce8fd41c..82746f942cd 100644
--- a/arch/x86/kernel/microcode_amd.c
+++ b/arch/x86/kernel/microcode_amd.c
@@ -143,11 +143,12 @@ static int get_matching_microcode(int cpu, const u8 *ucode_ptr,
143 unsigned int *current_size) 143 unsigned int *current_size)
144{ 144{
145 struct microcode_header_amd *mc_hdr; 145 struct microcode_header_amd *mc_hdr;
146 unsigned int actual_size; 146 unsigned int actual_size, patch_size;
147 u16 equiv_cpu_id; 147 u16 equiv_cpu_id;
148 148
149 /* size of the current patch we're staring at */ 149 /* size of the current patch we're staring at */
150 *current_size = *(u32 *)(ucode_ptr + 4) + SECTION_HDR_SIZE; 150 patch_size = *(u32 *)(ucode_ptr + 4);
151 *current_size = patch_size + SECTION_HDR_SIZE;
151 152
152 equiv_cpu_id = find_equiv_id(); 153 equiv_cpu_id = find_equiv_id();
153 if (!equiv_cpu_id) 154 if (!equiv_cpu_id)
@@ -174,7 +175,7 @@ static int get_matching_microcode(int cpu, const u8 *ucode_ptr,
174 /* 175 /*
175 * now that the header looks sane, verify its size 176 * now that the header looks sane, verify its size
176 */ 177 */
177 actual_size = verify_ucode_size(cpu, *current_size, leftover_size); 178 actual_size = verify_ucode_size(cpu, patch_size, leftover_size);
178 if (!actual_size) 179 if (!actual_size)
179 return 0; 180 return 0;
180 181
diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
index fbdfc691718..4873e62db6a 100644
--- a/arch/x86/kernel/microcode_core.c
+++ b/arch/x86/kernel/microcode_core.c
@@ -87,6 +87,7 @@
87#include <asm/microcode.h> 87#include <asm/microcode.h>
88#include <asm/processor.h> 88#include <asm/processor.h>
89#include <asm/cpu_device_id.h> 89#include <asm/cpu_device_id.h>
90#include <asm/perf_event.h>
90 91
91MODULE_DESCRIPTION("Microcode Update Driver"); 92MODULE_DESCRIPTION("Microcode Update Driver");
92MODULE_AUTHOR("Tigran Aivazian <tigran@aivazian.fsnet.co.uk>"); 93MODULE_AUTHOR("Tigran Aivazian <tigran@aivazian.fsnet.co.uk>");
@@ -277,7 +278,6 @@ static int reload_for_cpu(int cpu)
277 struct ucode_cpu_info *uci = ucode_cpu_info + cpu; 278 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
278 int err = 0; 279 int err = 0;
279 280
280 mutex_lock(&microcode_mutex);
281 if (uci->valid) { 281 if (uci->valid) {
282 enum ucode_state ustate; 282 enum ucode_state ustate;
283 283
@@ -288,7 +288,6 @@ static int reload_for_cpu(int cpu)
288 if (ustate == UCODE_ERROR) 288 if (ustate == UCODE_ERROR)
289 err = -EINVAL; 289 err = -EINVAL;
290 } 290 }
291 mutex_unlock(&microcode_mutex);
292 291
293 return err; 292 return err;
294} 293}
@@ -298,19 +297,31 @@ static ssize_t reload_store(struct device *dev,
298 const char *buf, size_t size) 297 const char *buf, size_t size)
299{ 298{
300 unsigned long val; 299 unsigned long val;
301 int cpu = dev->id; 300 int cpu;
302 ssize_t ret = 0; 301 ssize_t ret = 0, tmp_ret;
303 302
304 ret = kstrtoul(buf, 0, &val); 303 ret = kstrtoul(buf, 0, &val);
305 if (ret) 304 if (ret)
306 return ret; 305 return ret;
307 306
308 if (val == 1) { 307 if (val != 1)
309 get_online_cpus(); 308 return size;
310 if (cpu_online(cpu)) 309
311 ret = reload_for_cpu(cpu); 310 get_online_cpus();
312 put_online_cpus(); 311 mutex_lock(&microcode_mutex);
312 for_each_online_cpu(cpu) {
313 tmp_ret = reload_for_cpu(cpu);
314 if (tmp_ret != 0)
315 pr_warn("Error reloading microcode on CPU %d\n", cpu);
316
317 /* save retval of the first encountered reload error */
318 if (!ret)
319 ret = tmp_ret;
313 } 320 }
321 if (!ret)
322 perf_check_microcode();
323 mutex_unlock(&microcode_mutex);
324 put_online_cpus();
314 325
315 if (!ret) 326 if (!ret)
316 ret = size; 327 ret = size;
@@ -339,7 +350,6 @@ static DEVICE_ATTR(version, 0400, version_show, NULL);
339static DEVICE_ATTR(processor_flags, 0400, pf_show, NULL); 350static DEVICE_ATTR(processor_flags, 0400, pf_show, NULL);
340 351
341static struct attribute *mc_default_attrs[] = { 352static struct attribute *mc_default_attrs[] = {
342 &dev_attr_reload.attr,
343 &dev_attr_version.attr, 353 &dev_attr_version.attr,
344 &dev_attr_processor_flags.attr, 354 &dev_attr_processor_flags.attr,
345 NULL 355 NULL
@@ -504,7 +514,7 @@ static struct notifier_block __refdata mc_cpu_notifier = {
504 514
505#ifdef MODULE 515#ifdef MODULE
506/* Autoload on Intel and AMD systems */ 516/* Autoload on Intel and AMD systems */
507static const struct x86_cpu_id microcode_id[] = { 517static const struct x86_cpu_id __initconst microcode_id[] = {
508#ifdef CONFIG_MICROCODE_INTEL 518#ifdef CONFIG_MICROCODE_INTEL
509 { X86_VENDOR_INTEL, X86_FAMILY_ANY, X86_MODEL_ANY, }, 519 { X86_VENDOR_INTEL, X86_FAMILY_ANY, X86_MODEL_ANY, },
510#endif 520#endif
@@ -516,6 +526,16 @@ static const struct x86_cpu_id microcode_id[] = {
516MODULE_DEVICE_TABLE(x86cpu, microcode_id); 526MODULE_DEVICE_TABLE(x86cpu, microcode_id);
517#endif 527#endif
518 528
529static struct attribute *cpu_root_microcode_attrs[] = {
530 &dev_attr_reload.attr,
531 NULL
532};
533
534static struct attribute_group cpu_root_microcode_group = {
535 .name = "microcode",
536 .attrs = cpu_root_microcode_attrs,
537};
538
519static int __init microcode_init(void) 539static int __init microcode_init(void)
520{ 540{
521 struct cpuinfo_x86 *c = &cpu_data(0); 541 struct cpuinfo_x86 *c = &cpu_data(0);
@@ -540,16 +560,25 @@ static int __init microcode_init(void)
540 mutex_lock(&microcode_mutex); 560 mutex_lock(&microcode_mutex);
541 561
542 error = subsys_interface_register(&mc_cpu_interface); 562 error = subsys_interface_register(&mc_cpu_interface);
543 563 if (!error)
564 perf_check_microcode();
544 mutex_unlock(&microcode_mutex); 565 mutex_unlock(&microcode_mutex);
545 put_online_cpus(); 566 put_online_cpus();
546 567
547 if (error) 568 if (error)
548 goto out_pdev; 569 goto out_pdev;
549 570
571 error = sysfs_create_group(&cpu_subsys.dev_root->kobj,
572 &cpu_root_microcode_group);
573
574 if (error) {
575 pr_err("Error creating microcode group!\n");
576 goto out_driver;
577 }
578
550 error = microcode_dev_init(); 579 error = microcode_dev_init();
551 if (error) 580 if (error)
552 goto out_driver; 581 goto out_ucode_group;
553 582
554 register_syscore_ops(&mc_syscore_ops); 583 register_syscore_ops(&mc_syscore_ops);
555 register_hotcpu_notifier(&mc_cpu_notifier); 584 register_hotcpu_notifier(&mc_cpu_notifier);
@@ -559,7 +588,11 @@ static int __init microcode_init(void)
559 588
560 return 0; 589 return 0;
561 590
562out_driver: 591 out_ucode_group:
592 sysfs_remove_group(&cpu_subsys.dev_root->kobj,
593 &cpu_root_microcode_group);
594
595 out_driver:
563 get_online_cpus(); 596 get_online_cpus();
564 mutex_lock(&microcode_mutex); 597 mutex_lock(&microcode_mutex);
565 598
@@ -568,7 +601,7 @@ out_driver:
568 mutex_unlock(&microcode_mutex); 601 mutex_unlock(&microcode_mutex);
569 put_online_cpus(); 602 put_online_cpus();
570 603
571out_pdev: 604 out_pdev:
572 platform_device_unregister(microcode_pdev); 605 platform_device_unregister(microcode_pdev);
573 return error; 606 return error;
574 607
@@ -584,6 +617,9 @@ static void __exit microcode_exit(void)
584 unregister_hotcpu_notifier(&mc_cpu_notifier); 617 unregister_hotcpu_notifier(&mc_cpu_notifier);
585 unregister_syscore_ops(&mc_syscore_ops); 618 unregister_syscore_ops(&mc_syscore_ops);
586 619
620 sysfs_remove_group(&cpu_subsys.dev_root->kobj,
621 &cpu_root_microcode_group);
622
587 get_online_cpus(); 623 get_online_cpus();
588 mutex_lock(&microcode_mutex); 624 mutex_lock(&microcode_mutex);
589 625
diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
index f21fd94ac89..216a4d754b0 100644
--- a/arch/x86/kernel/module.c
+++ b/arch/x86/kernel/module.c
@@ -15,6 +15,9 @@
15 along with this program; if not, write to the Free Software 15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/ 17*/
18
19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20
18#include <linux/moduleloader.h> 21#include <linux/moduleloader.h>
19#include <linux/elf.h> 22#include <linux/elf.h>
20#include <linux/vmalloc.h> 23#include <linux/vmalloc.h>
@@ -30,9 +33,14 @@
30#include <asm/pgtable.h> 33#include <asm/pgtable.h>
31 34
32#if 0 35#if 0
33#define DEBUGP printk 36#define DEBUGP(fmt, ...) \
37 printk(KERN_DEBUG fmt, ##__VA_ARGS__)
34#else 38#else
35#define DEBUGP(fmt...) 39#define DEBUGP(fmt, ...) \
40do { \
41 if (0) \
42 printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
43} while (0)
36#endif 44#endif
37 45
38void *module_alloc(unsigned long size) 46void *module_alloc(unsigned long size)
@@ -56,8 +64,8 @@ int apply_relocate(Elf32_Shdr *sechdrs,
56 Elf32_Sym *sym; 64 Elf32_Sym *sym;
57 uint32_t *location; 65 uint32_t *location;
58 66
59 DEBUGP("Applying relocate section %u to %u\n", relsec, 67 DEBUGP("Applying relocate section %u to %u\n",
60 sechdrs[relsec].sh_info); 68 relsec, sechdrs[relsec].sh_info);
61 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { 69 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
62 /* This is where to make the change */ 70 /* This is where to make the change */
63 location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr 71 location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
@@ -73,11 +81,11 @@ int apply_relocate(Elf32_Shdr *sechdrs,
73 *location += sym->st_value; 81 *location += sym->st_value;
74 break; 82 break;
75 case R_386_PC32: 83 case R_386_PC32:
76 /* Add the value, subtract its postition */ 84 /* Add the value, subtract its position */
77 *location += sym->st_value - (uint32_t)location; 85 *location += sym->st_value - (uint32_t)location;
78 break; 86 break;
79 default: 87 default:
80 printk(KERN_ERR "module %s: Unknown relocation: %u\n", 88 pr_err("%s: Unknown relocation: %u\n",
81 me->name, ELF32_R_TYPE(rel[i].r_info)); 89 me->name, ELF32_R_TYPE(rel[i].r_info));
82 return -ENOEXEC; 90 return -ENOEXEC;
83 } 91 }
@@ -97,8 +105,8 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
97 void *loc; 105 void *loc;
98 u64 val; 106 u64 val;
99 107
100 DEBUGP("Applying relocate section %u to %u\n", relsec, 108 DEBUGP("Applying relocate section %u to %u\n",
101 sechdrs[relsec].sh_info); 109 relsec, sechdrs[relsec].sh_info);
102 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { 110 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
103 /* This is where to make the change */ 111 /* This is where to make the change */
104 loc = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr 112 loc = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
@@ -110,8 +118,8 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
110 + ELF64_R_SYM(rel[i].r_info); 118 + ELF64_R_SYM(rel[i].r_info);
111 119
112 DEBUGP("type %d st_value %Lx r_addend %Lx loc %Lx\n", 120 DEBUGP("type %d st_value %Lx r_addend %Lx loc %Lx\n",
113 (int)ELF64_R_TYPE(rel[i].r_info), 121 (int)ELF64_R_TYPE(rel[i].r_info),
114 sym->st_value, rel[i].r_addend, (u64)loc); 122 sym->st_value, rel[i].r_addend, (u64)loc);
115 123
116 val = sym->st_value + rel[i].r_addend; 124 val = sym->st_value + rel[i].r_addend;
117 125
@@ -140,7 +148,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
140#endif 148#endif
141 break; 149 break;
142 default: 150 default:
143 printk(KERN_ERR "module %s: Unknown rela relocation: %llu\n", 151 pr_err("%s: Unknown rela relocation: %llu\n",
144 me->name, ELF64_R_TYPE(rel[i].r_info)); 152 me->name, ELF64_R_TYPE(rel[i].r_info));
145 return -ENOEXEC; 153 return -ENOEXEC;
146 } 154 }
@@ -148,9 +156,9 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
148 return 0; 156 return 0;
149 157
150overflow: 158overflow:
151 printk(KERN_ERR "overflow in relocation type %d val %Lx\n", 159 pr_err("overflow in relocation type %d val %Lx\n",
152 (int)ELF64_R_TYPE(rel[i].r_info), val); 160 (int)ELF64_R_TYPE(rel[i].r_info), val);
153 printk(KERN_ERR "`%s' likely not compiled with -mcmodel=kernel\n", 161 pr_err("`%s' likely not compiled with -mcmodel=kernel\n",
154 me->name); 162 me->name);
155 return -ENOEXEC; 163 return -ENOEXEC;
156} 164}
diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index a0b2f84457b..f84f5c57de3 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -365,8 +365,9 @@ static __kprobes void default_do_nmi(struct pt_regs *regs)
365#ifdef CONFIG_X86_32 365#ifdef CONFIG_X86_32
366/* 366/*
367 * For i386, NMIs use the same stack as the kernel, and we can 367 * For i386, NMIs use the same stack as the kernel, and we can
368 * add a workaround to the iret problem in C. Simply have 3 states 368 * add a workaround to the iret problem in C (preventing nested
369 * the NMI can be in. 369 * NMIs if an NMI takes a trap). Simply have 3 states the NMI
370 * can be in:
370 * 371 *
371 * 1) not running 372 * 1) not running
372 * 2) executing 373 * 2) executing
@@ -383,32 +384,50 @@ static __kprobes void default_do_nmi(struct pt_regs *regs)
383 * If an NMI hits a breakpoint that executes an iret, another 384 * If an NMI hits a breakpoint that executes an iret, another
384 * NMI can preempt it. We do not want to allow this new NMI 385 * NMI can preempt it. We do not want to allow this new NMI
385 * to run, but we want to execute it when the first one finishes. 386 * to run, but we want to execute it when the first one finishes.
386 * We set the state to "latched", and the first NMI will perform 387 * We set the state to "latched", and the exit of the first NMI will
387 * an cmpxchg on the state, and if it doesn't successfully 388 * perform a dec_return, if the result is zero (NOT_RUNNING), then
388 * reset the state to "not running" it will restart the next 389 * it will simply exit the NMI handler. If not, the dec_return
389 * NMI. 390 * would have set the state to NMI_EXECUTING (what we want it to
391 * be when we are running). In this case, we simply jump back
392 * to rerun the NMI handler again, and restart the 'latched' NMI.
393 *
394 * No trap (breakpoint or page fault) should be hit before nmi_restart,
395 * thus there is no race between the first check of state for NOT_RUNNING
396 * and setting it to NMI_EXECUTING. The HW will prevent nested NMIs
397 * at this point.
398 *
399 * In case the NMI takes a page fault, we need to save off the CR2
400 * because the NMI could have preempted another page fault and corrupt
401 * the CR2 that is about to be read. As nested NMIs must be restarted
402 * and they can not take breakpoints or page faults, the update of the
403 * CR2 must be done before converting the nmi state back to NOT_RUNNING.
404 * Otherwise, there would be a race of another nested NMI coming in
405 * after setting state to NOT_RUNNING but before updating the nmi_cr2.
390 */ 406 */
391enum nmi_states { 407enum nmi_states {
392 NMI_NOT_RUNNING, 408 NMI_NOT_RUNNING = 0,
393 NMI_EXECUTING, 409 NMI_EXECUTING,
394 NMI_LATCHED, 410 NMI_LATCHED,
395}; 411};
396static DEFINE_PER_CPU(enum nmi_states, nmi_state); 412static DEFINE_PER_CPU(enum nmi_states, nmi_state);
413static DEFINE_PER_CPU(unsigned long, nmi_cr2);
397 414
398#define nmi_nesting_preprocess(regs) \ 415#define nmi_nesting_preprocess(regs) \
399 do { \ 416 do { \
400 if (__get_cpu_var(nmi_state) != NMI_NOT_RUNNING) { \ 417 if (this_cpu_read(nmi_state) != NMI_NOT_RUNNING) { \
401 __get_cpu_var(nmi_state) = NMI_LATCHED; \ 418 this_cpu_write(nmi_state, NMI_LATCHED); \
402 return; \ 419 return; \
403 } \ 420 } \
404 nmi_restart: \ 421 this_cpu_write(nmi_state, NMI_EXECUTING); \
405 __get_cpu_var(nmi_state) = NMI_EXECUTING; \ 422 this_cpu_write(nmi_cr2, read_cr2()); \
406 } while (0) 423 } while (0); \
424 nmi_restart:
407 425
408#define nmi_nesting_postprocess() \ 426#define nmi_nesting_postprocess() \
409 do { \ 427 do { \
410 if (cmpxchg(&__get_cpu_var(nmi_state), \ 428 if (unlikely(this_cpu_read(nmi_cr2) != read_cr2())) \
411 NMI_EXECUTING, NMI_NOT_RUNNING) != NMI_EXECUTING) \ 429 write_cr2(this_cpu_read(nmi_cr2)); \
430 if (this_cpu_dec_return(nmi_state)) \
412 goto nmi_restart; \ 431 goto nmi_restart; \
413 } while (0) 432 } while (0)
414#else /* x86_64 */ 433#else /* x86_64 */
diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
index 149b8d9c6ad..6d9582ec032 100644
--- a/arch/x86/kernel/nmi_selftest.c
+++ b/arch/x86/kernel/nmi_selftest.c
@@ -42,7 +42,8 @@ static int __init nmi_unk_cb(unsigned int val, struct pt_regs *regs)
42static void __init init_nmi_testsuite(void) 42static void __init init_nmi_testsuite(void)
43{ 43{
44 /* trap all the unknown NMIs we may generate */ 44 /* trap all the unknown NMIs we may generate */
45 register_nmi_handler_initonly(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk"); 45 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
46 __initdata);
46} 47}
47 48
48static void __init cleanup_nmi_testsuite(void) 49static void __init cleanup_nmi_testsuite(void)
@@ -64,8 +65,8 @@ static void __init test_nmi_ipi(struct cpumask *mask)
64{ 65{
65 unsigned long timeout; 66 unsigned long timeout;
66 67
67 if (register_nmi_handler_initonly(NMI_LOCAL, test_nmi_ipi_callback, 68 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
68 NMI_FLAG_FIRST, "nmi_selftest")) { 69 NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
69 nmi_fail = FAILURE; 70 nmi_fail = FAILURE;
70 return; 71 return;
71 } 72 }
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index 9ce885996fd..17fff18a103 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -352,9 +352,7 @@ struct pv_cpu_ops pv_cpu_ops = {
352#endif 352#endif
353 .wbinvd = native_wbinvd, 353 .wbinvd = native_wbinvd,
354 .read_msr = native_read_msr_safe, 354 .read_msr = native_read_msr_safe,
355 .rdmsr_regs = native_rdmsr_safe_regs,
356 .write_msr = native_write_msr_safe, 355 .write_msr = native_write_msr_safe,
357 .wrmsr_regs = native_wrmsr_safe_regs,
358 .read_tsc = native_read_tsc, 356 .read_tsc = native_read_tsc,
359 .read_pmc = native_read_pmc, 357 .read_pmc = native_read_pmc,
360 .read_tscp = native_read_tscp, 358 .read_tscp = native_read_tscp,
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index b72838bae64..299d49302e7 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -22,6 +22,8 @@
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */ 23 */
24 24
25#define pr_fmt(fmt) "Calgary: " fmt
26
25#include <linux/kernel.h> 27#include <linux/kernel.h>
26#include <linux/init.h> 28#include <linux/init.h>
27#include <linux/types.h> 29#include <linux/types.h>
@@ -245,7 +247,7 @@ static unsigned long iommu_range_alloc(struct device *dev,
245 offset = iommu_area_alloc(tbl->it_map, tbl->it_size, 0, 247 offset = iommu_area_alloc(tbl->it_map, tbl->it_size, 0,
246 npages, 0, boundary_size, 0); 248 npages, 0, boundary_size, 0);
247 if (offset == ~0UL) { 249 if (offset == ~0UL) {
248 printk(KERN_WARNING "Calgary: IOMMU full.\n"); 250 pr_warn("IOMMU full\n");
249 spin_unlock_irqrestore(&tbl->it_lock, flags); 251 spin_unlock_irqrestore(&tbl->it_lock, flags);
250 if (panic_on_overflow) 252 if (panic_on_overflow)
251 panic("Calgary: fix the allocator.\n"); 253 panic("Calgary: fix the allocator.\n");
@@ -271,8 +273,8 @@ static dma_addr_t iommu_alloc(struct device *dev, struct iommu_table *tbl,
271 entry = iommu_range_alloc(dev, tbl, npages); 273 entry = iommu_range_alloc(dev, tbl, npages);
272 274
273 if (unlikely(entry == DMA_ERROR_CODE)) { 275 if (unlikely(entry == DMA_ERROR_CODE)) {
274 printk(KERN_WARNING "Calgary: failed to allocate %u pages in " 276 pr_warn("failed to allocate %u pages in iommu %p\n",
275 "iommu %p\n", npages, tbl); 277 npages, tbl);
276 return DMA_ERROR_CODE; 278 return DMA_ERROR_CODE;
277 } 279 }
278 280
@@ -561,8 +563,7 @@ static void calgary_tce_cache_blast(struct iommu_table *tbl)
561 i++; 563 i++;
562 } while ((val & 0xff) != 0xff && i < 100); 564 } while ((val & 0xff) != 0xff && i < 100);
563 if (i == 100) 565 if (i == 100)
564 printk(KERN_WARNING "Calgary: PCI bus not quiesced, " 566 pr_warn("PCI bus not quiesced, continuing anyway\n");
565 "continuing anyway\n");
566 567
567 /* invalidate TCE cache */ 568 /* invalidate TCE cache */
568 target = calgary_reg(bbar, tar_offset(tbl->it_busno)); 569 target = calgary_reg(bbar, tar_offset(tbl->it_busno));
@@ -604,8 +605,7 @@ begin:
604 i++; 605 i++;
605 } while ((val64 & 0xff) != 0xff && i < 100); 606 } while ((val64 & 0xff) != 0xff && i < 100);
606 if (i == 100) 607 if (i == 100)
607 printk(KERN_WARNING "CalIOC2: PCI bus not quiesced, " 608 pr_warn("CalIOC2: PCI bus not quiesced, continuing anyway\n");
608 "continuing anyway\n");
609 609
610 /* 3. poll Page Migration DEBUG for SoftStopFault */ 610 /* 3. poll Page Migration DEBUG for SoftStopFault */
611 target = calgary_reg(bbar, phb_offset(bus) | PHB_PAGE_MIG_DEBUG); 611 target = calgary_reg(bbar, phb_offset(bus) | PHB_PAGE_MIG_DEBUG);
@@ -617,8 +617,7 @@ begin:
617 if (++count < 100) 617 if (++count < 100)
618 goto begin; 618 goto begin;
619 else { 619 else {
620 printk(KERN_WARNING "CalIOC2: too many SoftStopFaults, " 620 pr_warn("CalIOC2: too many SoftStopFaults, aborting TCE cache flush sequence!\n");
621 "aborting TCE cache flush sequence!\n");
622 return; /* pray for the best */ 621 return; /* pray for the best */
623 } 622 }
624 } 623 }
@@ -840,8 +839,8 @@ static void calgary_dump_error_regs(struct iommu_table *tbl)
840 plssr = be32_to_cpu(readl(target)); 839 plssr = be32_to_cpu(readl(target));
841 840
842 /* If no error, the agent ID in the CSR is not valid */ 841 /* If no error, the agent ID in the CSR is not valid */
843 printk(KERN_EMERG "Calgary: DMA error on Calgary PHB 0x%x, " 842 pr_emerg("DMA error on Calgary PHB 0x%x, 0x%08x@CSR 0x%08x@PLSSR\n",
844 "0x%08x@CSR 0x%08x@PLSSR\n", tbl->it_busno, csr, plssr); 843 tbl->it_busno, csr, plssr);
845} 844}
846 845
847static void calioc2_dump_error_regs(struct iommu_table *tbl) 846static void calioc2_dump_error_regs(struct iommu_table *tbl)
@@ -867,22 +866,21 @@ static void calioc2_dump_error_regs(struct iommu_table *tbl)
867 target = calgary_reg(bbar, phboff | 0x800); 866 target = calgary_reg(bbar, phboff | 0x800);
868 mck = be32_to_cpu(readl(target)); 867 mck = be32_to_cpu(readl(target));
869 868
870 printk(KERN_EMERG "Calgary: DMA error on CalIOC2 PHB 0x%x\n", 869 pr_emerg("DMA error on CalIOC2 PHB 0x%x\n", tbl->it_busno);
871 tbl->it_busno);
872 870
873 printk(KERN_EMERG "Calgary: 0x%08x@CSR 0x%08x@PLSSR 0x%08x@CSMR 0x%08x@MCK\n", 871 pr_emerg("0x%08x@CSR 0x%08x@PLSSR 0x%08x@CSMR 0x%08x@MCK\n",
874 csr, plssr, csmr, mck); 872 csr, plssr, csmr, mck);
875 873
876 /* dump rest of error regs */ 874 /* dump rest of error regs */
877 printk(KERN_EMERG "Calgary: "); 875 pr_emerg("");
878 for (i = 0; i < ARRAY_SIZE(errregs); i++) { 876 for (i = 0; i < ARRAY_SIZE(errregs); i++) {
879 /* err regs are at 0x810 - 0x870 */ 877 /* err regs are at 0x810 - 0x870 */
880 erroff = (0x810 + (i * 0x10)); 878 erroff = (0x810 + (i * 0x10));
881 target = calgary_reg(bbar, phboff | erroff); 879 target = calgary_reg(bbar, phboff | erroff);
882 errregs[i] = be32_to_cpu(readl(target)); 880 errregs[i] = be32_to_cpu(readl(target));
883 printk("0x%08x@0x%lx ", errregs[i], erroff); 881 pr_cont("0x%08x@0x%lx ", errregs[i], erroff);
884 } 882 }
885 printk("\n"); 883 pr_cont("\n");
886 884
887 /* root complex status */ 885 /* root complex status */
888 target = calgary_reg(bbar, phboff | PHB_ROOT_COMPLEX_STATUS); 886 target = calgary_reg(bbar, phboff | PHB_ROOT_COMPLEX_STATUS);
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index c0f420f76cd..de2b7ad7027 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -45,15 +45,6 @@ int iommu_detected __read_mostly = 0;
45 */ 45 */
46int iommu_pass_through __read_mostly; 46int iommu_pass_through __read_mostly;
47 47
48/*
49 * Group multi-function PCI devices into a single device-group for the
50 * iommu_device_group interface. This tells the iommu driver to pretend
51 * it cannot distinguish between functions of a device, exposing only one
52 * group for the device. Useful for disallowing use of individual PCI
53 * functions from userspace drivers.
54 */
55int iommu_group_mf __read_mostly;
56
57extern struct iommu_table_entry __iommu_table[], __iommu_table_end[]; 48extern struct iommu_table_entry __iommu_table[], __iommu_table_end[];
58 49
59/* Dummy device used for NULL arguments (normally ISA). */ 50/* Dummy device used for NULL arguments (normally ISA). */
@@ -194,8 +185,6 @@ static __init int iommu_setup(char *p)
194#endif 185#endif
195 if (!strncmp(p, "pt", 2)) 186 if (!strncmp(p, "pt", 2))
196 iommu_pass_through = 1; 187 iommu_pass_through = 1;
197 if (!strncmp(p, "group_mf", 8))
198 iommu_group_mf = 1;
199 188
200 gart_parse_options(p); 189 gart_parse_options(p);
201 190
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 735279e54e5..ef6a8456f71 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -1,3 +1,5 @@
1#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2
1#include <linux/errno.h> 3#include <linux/errno.h>
2#include <linux/kernel.h> 4#include <linux/kernel.h>
3#include <linux/mm.h> 5#include <linux/mm.h>
@@ -145,16 +147,14 @@ void show_regs_common(void)
145 /* Board Name is optional */ 147 /* Board Name is optional */
146 board = dmi_get_system_info(DMI_BOARD_NAME); 148 board = dmi_get_system_info(DMI_BOARD_NAME);
147 149
148 printk(KERN_CONT "\n"); 150 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
149 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s", 151 current->pid, current->comm, print_tainted(),
150 current->pid, current->comm, print_tainted(), 152 init_utsname()->release,
151 init_utsname()->release, 153 (int)strcspn(init_utsname()->version, " "),
152 (int)strcspn(init_utsname()->version, " "), 154 init_utsname()->version,
153 init_utsname()->version); 155 vendor, product,
154 printk(KERN_CONT " %s %s", vendor, product); 156 board ? "/" : "",
155 if (board) 157 board ? board : "");
156 printk(KERN_CONT "/%s", board);
157 printk(KERN_CONT "\n");
158} 158}
159 159
160void flush_thread(void) 160void flush_thread(void)
@@ -645,7 +645,7 @@ static void amd_e400_idle(void)
645 amd_e400_c1e_detected = true; 645 amd_e400_c1e_detected = true;
646 if (!boot_cpu_has(X86_FEATURE_NONSTOP_TSC)) 646 if (!boot_cpu_has(X86_FEATURE_NONSTOP_TSC))
647 mark_tsc_unstable("TSC halt in AMD C1E"); 647 mark_tsc_unstable("TSC halt in AMD C1E");
648 printk(KERN_INFO "System has AMD C1E enabled\n"); 648 pr_info("System has AMD C1E enabled\n");
649 } 649 }
650 } 650 }
651 651
@@ -659,8 +659,7 @@ static void amd_e400_idle(void)
659 */ 659 */
660 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_FORCE, 660 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_FORCE,
661 &cpu); 661 &cpu);
662 printk(KERN_INFO "Switch to broadcast mode on CPU%d\n", 662 pr_info("Switch to broadcast mode on CPU%d\n", cpu);
663 cpu);
664 } 663 }
665 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu); 664 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu);
666 665
@@ -681,8 +680,7 @@ void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
681{ 680{
682#ifdef CONFIG_SMP 681#ifdef CONFIG_SMP
683 if (pm_idle == poll_idle && smp_num_siblings > 1) { 682 if (pm_idle == poll_idle && smp_num_siblings > 1) {
684 printk_once(KERN_WARNING "WARNING: polling idle and HT enabled," 683 pr_warn_once("WARNING: polling idle and HT enabled, performance may degrade\n");
685 " performance may degrade.\n");
686 } 684 }
687#endif 685#endif
688 if (pm_idle) 686 if (pm_idle)
@@ -692,11 +690,11 @@ void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
692 /* 690 /*
693 * One CPU supports mwait => All CPUs supports mwait 691 * One CPU supports mwait => All CPUs supports mwait
694 */ 692 */
695 printk(KERN_INFO "using mwait in idle threads.\n"); 693 pr_info("using mwait in idle threads\n");
696 pm_idle = mwait_idle; 694 pm_idle = mwait_idle;
697 } else if (cpu_has_amd_erratum(amd_erratum_400)) { 695 } else if (cpu_has_amd_erratum(amd_erratum_400)) {
698 /* E400: APIC timer interrupt does not wake up CPU from C1e */ 696 /* E400: APIC timer interrupt does not wake up CPU from C1e */
699 printk(KERN_INFO "using AMD E400 aware idle routine\n"); 697 pr_info("using AMD E400 aware idle routine\n");
700 pm_idle = amd_e400_idle; 698 pm_idle = amd_e400_idle;
701 } else 699 } else
702 pm_idle = default_idle; 700 pm_idle = default_idle;
@@ -715,7 +713,7 @@ static int __init idle_setup(char *str)
715 return -EINVAL; 713 return -EINVAL;
716 714
717 if (!strcmp(str, "poll")) { 715 if (!strcmp(str, "poll")) {
718 printk("using polling idle threads.\n"); 716 pr_info("using polling idle threads\n");
719 pm_idle = poll_idle; 717 pm_idle = poll_idle;
720 boot_option_idle_override = IDLE_POLL; 718 boot_option_idle_override = IDLE_POLL;
721 } else if (!strcmp(str, "mwait")) { 719 } else if (!strcmp(str, "mwait")) {
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 61cdf7fdf09..0a980c9d7cb 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -117,10 +117,10 @@ void release_thread(struct task_struct *dead_task)
117{ 117{
118 if (dead_task->mm) { 118 if (dead_task->mm) {
119 if (dead_task->mm->context.size) { 119 if (dead_task->mm->context.size) {
120 printk("WARNING: dead process %8s still has LDT? <%p/%d>\n", 120 pr_warn("WARNING: dead process %8s still has LDT? <%p/%d>\n",
121 dead_task->comm, 121 dead_task->comm,
122 dead_task->mm->context.ldt, 122 dead_task->mm->context.ldt,
123 dead_task->mm->context.size); 123 dead_task->mm->context.size);
124 BUG(); 124 BUG();
125 } 125 }
126 } 126 }
@@ -466,7 +466,7 @@ long do_arch_prctl(struct task_struct *task, int code, unsigned long addr)
466 task->thread.gs = addr; 466 task->thread.gs = addr;
467 if (doit) { 467 if (doit) {
468 load_gs_index(0); 468 load_gs_index(0);
469 ret = checking_wrmsrl(MSR_KERNEL_GS_BASE, addr); 469 ret = wrmsrl_safe(MSR_KERNEL_GS_BASE, addr);
470 } 470 }
471 } 471 }
472 put_cpu(); 472 put_cpu();
@@ -494,7 +494,7 @@ long do_arch_prctl(struct task_struct *task, int code, unsigned long addr)
494 /* set the selector to 0 to not confuse 494 /* set the selector to 0 to not confuse
495 __switch_to */ 495 __switch_to */
496 loadsegment(fs, 0); 496 loadsegment(fs, 0);
497 ret = checking_wrmsrl(MSR_FS_BASE, addr); 497 ret = wrmsrl_safe(MSR_FS_BASE, addr);
498 } 498 }
499 } 499 }
500 put_cpu(); 500 put_cpu();
diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index 03920a15a63..1b27de56356 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -512,7 +512,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS,
512 512
513#if defined(CONFIG_PCI) && defined(CONFIG_NUMA) 513#if defined(CONFIG_PCI) && defined(CONFIG_NUMA)
514/* Set correct numa_node information for AMD NB functions */ 514/* Set correct numa_node information for AMD NB functions */
515static void __init quirk_amd_nb_node(struct pci_dev *dev) 515static void __devinit quirk_amd_nb_node(struct pci_dev *dev)
516{ 516{
517 struct pci_dev *nb_ht; 517 struct pci_dev *nb_ht;
518 unsigned int devfn; 518 unsigned int devfn;
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 5de92f1abd7..52190a938b4 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -1,3 +1,5 @@
1#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2
1#include <linux/module.h> 3#include <linux/module.h>
2#include <linux/reboot.h> 4#include <linux/reboot.h>
3#include <linux/init.h> 5#include <linux/init.h>
@@ -20,14 +22,12 @@
20#include <asm/virtext.h> 22#include <asm/virtext.h>
21#include <asm/cpu.h> 23#include <asm/cpu.h>
22#include <asm/nmi.h> 24#include <asm/nmi.h>
25#include <asm/smp.h>
23 26
24#ifdef CONFIG_X86_32 27#include <linux/ctype.h>
25# include <linux/ctype.h> 28#include <linux/mc146818rtc.h>
26# include <linux/mc146818rtc.h> 29#include <asm/realmode.h>
27# include <asm/realmode.h> 30#include <asm/x86_init.h>
28#else
29# include <asm/x86_init.h>
30#endif
31 31
32/* 32/*
33 * Power off function, if any 33 * Power off function, if any
@@ -49,7 +49,7 @@ int reboot_force;
49 */ 49 */
50static int reboot_default = 1; 50static int reboot_default = 1;
51 51
52#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) 52#ifdef CONFIG_SMP
53static int reboot_cpu = -1; 53static int reboot_cpu = -1;
54#endif 54#endif
55 55
@@ -67,8 +67,8 @@ bool port_cf9_safe = false;
67 * reboot=b[ios] | s[mp] | t[riple] | k[bd] | e[fi] [, [w]arm | [c]old] | p[ci] 67 * reboot=b[ios] | s[mp] | t[riple] | k[bd] | e[fi] [, [w]arm | [c]old] | p[ci]
68 * warm Don't set the cold reboot flag 68 * warm Don't set the cold reboot flag
69 * cold Set the cold reboot flag 69 * cold Set the cold reboot flag
70 * bios Reboot by jumping through the BIOS (only for X86_32) 70 * bios Reboot by jumping through the BIOS
71 * smp Reboot by executing reset on BSP or other CPU (only for X86_32) 71 * smp Reboot by executing reset on BSP or other CPU
72 * triple Force a triple fault (init) 72 * triple Force a triple fault (init)
73 * kbd Use the keyboard controller. cold reset (default) 73 * kbd Use the keyboard controller. cold reset (default)
74 * acpi Use the RESET_REG in the FADT 74 * acpi Use the RESET_REG in the FADT
@@ -95,7 +95,6 @@ static int __init reboot_setup(char *str)
95 reboot_mode = 0; 95 reboot_mode = 0;
96 break; 96 break;
97 97
98#ifdef CONFIG_X86_32
99#ifdef CONFIG_SMP 98#ifdef CONFIG_SMP
100 case 's': 99 case 's':
101 if (isdigit(*(str+1))) { 100 if (isdigit(*(str+1))) {
@@ -112,7 +111,6 @@ static int __init reboot_setup(char *str)
112#endif /* CONFIG_SMP */ 111#endif /* CONFIG_SMP */
113 112
114 case 'b': 113 case 'b':
115#endif
116 case 'a': 114 case 'a':
117 case 'k': 115 case 'k':
118 case 't': 116 case 't':
@@ -138,7 +136,6 @@ static int __init reboot_setup(char *str)
138__setup("reboot=", reboot_setup); 136__setup("reboot=", reboot_setup);
139 137
140 138
141#ifdef CONFIG_X86_32
142/* 139/*
143 * Reboot options and system auto-detection code provided by 140 * Reboot options and system auto-detection code provided by
144 * Dell Inc. so their systems "just work". :-) 141 * Dell Inc. so their systems "just work". :-)
@@ -152,16 +149,14 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
152{ 149{
153 if (reboot_type != BOOT_BIOS) { 150 if (reboot_type != BOOT_BIOS) {
154 reboot_type = BOOT_BIOS; 151 reboot_type = BOOT_BIOS;
155 printk(KERN_INFO "%s series board detected. Selecting BIOS-method for reboots.\n", d->ident); 152 pr_info("%s series board detected. Selecting %s-method for reboots.\n",
153 "BIOS", d->ident);
156 } 154 }
157 return 0; 155 return 0;
158} 156}
159 157
160void machine_real_restart(unsigned int type) 158void __noreturn machine_real_restart(unsigned int type)
161{ 159{
162 void (*restart_lowmem)(unsigned int) = (void (*)(unsigned int))
163 real_mode_header->machine_real_restart_asm;
164
165 local_irq_disable(); 160 local_irq_disable();
166 161
167 /* 162 /*
@@ -181,25 +176,28 @@ void machine_real_restart(unsigned int type)
181 /* 176 /*
182 * Switch back to the initial page table. 177 * Switch back to the initial page table.
183 */ 178 */
179#ifdef CONFIG_X86_32
184 load_cr3(initial_page_table); 180 load_cr3(initial_page_table);
185 181#else
186 /* 182 write_cr3(real_mode_header->trampoline_pgd);
187 * Write 0x1234 to absolute memory location 0x472. The BIOS reads 183#endif
188 * this on booting to tell it to "Bypass memory test (also warm
189 * boot)". This seems like a fairly standard thing that gets set by
190 * REBOOT.COM programs, and the previous reset routine did this
191 * too. */
192 *((unsigned short *)0x472) = reboot_mode;
193 184
194 /* Jump to the identity-mapped low memory code */ 185 /* Jump to the identity-mapped low memory code */
195 restart_lowmem(type); 186#ifdef CONFIG_X86_32
187 asm volatile("jmpl *%0" : :
188 "rm" (real_mode_header->machine_real_restart_asm),
189 "a" (type));
190#else
191 asm volatile("ljmpl *%0" : :
192 "m" (real_mode_header->machine_real_restart_asm),
193 "D" (type));
194#endif
195 unreachable();
196} 196}
197#ifdef CONFIG_APM_MODULE 197#ifdef CONFIG_APM_MODULE
198EXPORT_SYMBOL(machine_real_restart); 198EXPORT_SYMBOL(machine_real_restart);
199#endif 199#endif
200 200
201#endif /* CONFIG_X86_32 */
202
203/* 201/*
204 * Some Apple MacBook and MacBookPro's needs reboot=p to be able to reboot 202 * Some Apple MacBook and MacBookPro's needs reboot=p to be able to reboot
205 */ 203 */
@@ -207,8 +205,8 @@ static int __init set_pci_reboot(const struct dmi_system_id *d)
207{ 205{
208 if (reboot_type != BOOT_CF9) { 206 if (reboot_type != BOOT_CF9) {
209 reboot_type = BOOT_CF9; 207 reboot_type = BOOT_CF9;
210 printk(KERN_INFO "%s series board detected. " 208 pr_info("%s series board detected. Selecting %s-method for reboots.\n",
211 "Selecting PCI-method for reboots.\n", d->ident); 209 "PCI", d->ident);
212 } 210 }
213 return 0; 211 return 0;
214} 212}
@@ -217,17 +215,16 @@ static int __init set_kbd_reboot(const struct dmi_system_id *d)
217{ 215{
218 if (reboot_type != BOOT_KBD) { 216 if (reboot_type != BOOT_KBD) {
219 reboot_type = BOOT_KBD; 217 reboot_type = BOOT_KBD;
220 printk(KERN_INFO "%s series board detected. Selecting KBD-method for reboot.\n", d->ident); 218 pr_info("%s series board detected. Selecting %s-method for reboot.\n",
219 "KBD", d->ident);
221 } 220 }
222 return 0; 221 return 0;
223} 222}
224 223
225/* 224/*
226 * This is a single dmi_table handling all reboot quirks. Note that 225 * This is a single dmi_table handling all reboot quirks.
227 * REBOOT_BIOS is only available for 32bit
228 */ 226 */
229static struct dmi_system_id __initdata reboot_dmi_table[] = { 227static struct dmi_system_id __initdata reboot_dmi_table[] = {
230#ifdef CONFIG_X86_32
231 { /* Handle problems with rebooting on Dell E520's */ 228 { /* Handle problems with rebooting on Dell E520's */
232 .callback = set_bios_reboot, 229 .callback = set_bios_reboot,
233 .ident = "Dell E520", 230 .ident = "Dell E520",
@@ -377,7 +374,6 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
377 DMI_MATCH(DMI_BOARD_NAME, "P4S800"), 374 DMI_MATCH(DMI_BOARD_NAME, "P4S800"),
378 }, 375 },
379 }, 376 },
380#endif /* CONFIG_X86_32 */
381 377
382 { /* Handle reboot issue on Acer Aspire one */ 378 { /* Handle reboot issue on Acer Aspire one */
383 .callback = set_kbd_reboot, 379 .callback = set_kbd_reboot,
@@ -584,13 +580,11 @@ static void native_machine_emergency_restart(void)
584 reboot_type = BOOT_KBD; 580 reboot_type = BOOT_KBD;
585 break; 581 break;
586 582
587#ifdef CONFIG_X86_32
588 case BOOT_BIOS: 583 case BOOT_BIOS:
589 machine_real_restart(MRR_BIOS); 584 machine_real_restart(MRR_BIOS);
590 585
591 reboot_type = BOOT_KBD; 586 reboot_type = BOOT_KBD;
592 break; 587 break;
593#endif
594 588
595 case BOOT_ACPI: 589 case BOOT_ACPI:
596 acpi_reboot(); 590 acpi_reboot();
@@ -632,12 +626,10 @@ void native_machine_shutdown(void)
632 /* The boot cpu is always logical cpu 0 */ 626 /* The boot cpu is always logical cpu 0 */
633 int reboot_cpu_id = 0; 627 int reboot_cpu_id = 0;
634 628
635#ifdef CONFIG_X86_32
636 /* See if there has been given a command line override */ 629 /* See if there has been given a command line override */
637 if ((reboot_cpu != -1) && (reboot_cpu < nr_cpu_ids) && 630 if ((reboot_cpu != -1) && (reboot_cpu < nr_cpu_ids) &&
638 cpu_online(reboot_cpu)) 631 cpu_online(reboot_cpu))
639 reboot_cpu_id = reboot_cpu; 632 reboot_cpu_id = reboot_cpu;
640#endif
641 633
642 /* Make certain the cpu I'm about to reboot on is online */ 634 /* Make certain the cpu I'm about to reboot on is online */
643 if (!cpu_online(reboot_cpu_id)) 635 if (!cpu_online(reboot_cpu_id))
@@ -678,7 +670,7 @@ static void __machine_emergency_restart(int emergency)
678 670
679static void native_machine_restart(char *__unused) 671static void native_machine_restart(char *__unused)
680{ 672{
681 printk("machine restart\n"); 673 pr_notice("machine restart\n");
682 674
683 if (!reboot_force) 675 if (!reboot_force)
684 machine_shutdown(); 676 machine_shutdown();
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 16be6dc14db..4f165479c45 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -961,9 +961,7 @@ void __init setup_arch(char **cmdline_p)
961 kvmclock_init(); 961 kvmclock_init();
962#endif 962#endif
963 963
964 x86_init.paging.pagetable_setup_start(swapper_pg_dir); 964 x86_init.paging.pagetable_init();
965 paging_init();
966 x86_init.paging.pagetable_setup_done(swapper_pg_dir);
967 965
968 if (boot_cpu_data.cpuid_level >= 0) { 966 if (boot_cpu_data.cpuid_level >= 0) {
969 /* A CPU has %cr4 if and only if it has CPUID */ 967 /* A CPU has %cr4 if and only if it has CPUID */
@@ -1031,8 +1029,6 @@ void __init setup_arch(char **cmdline_p)
1031 1029
1032 x86_init.timers.wallclock_init(); 1030 x86_init.timers.wallclock_init();
1033 1031
1034 x86_platform.wallclock_init();
1035
1036 mcheck_init(); 1032 mcheck_init();
1037 1033
1038 arch_init_ideal_nops(); 1034 arch_init_ideal_nops();
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index 5a98aa27218..5cdff035774 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -21,7 +21,7 @@
21#include <asm/cpu.h> 21#include <asm/cpu.h>
22#include <asm/stackprotector.h> 22#include <asm/stackprotector.h>
23 23
24DEFINE_PER_CPU(int, cpu_number); 24DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25EXPORT_PER_CPU_SYMBOL(cpu_number); 25EXPORT_PER_CPU_SYMBOL(cpu_number);
26 26
27#ifdef CONFIG_X86_64 27#ifdef CONFIG_X86_64
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index 21af737053a..b280908a376 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -6,6 +6,9 @@
6 * 2000-06-20 Pentium III FXSR, SSE support by Gareth Hughes 6 * 2000-06-20 Pentium III FXSR, SSE support by Gareth Hughes
7 * 2000-2002 x86-64 support by Andi Kleen 7 * 2000-2002 x86-64 support by Andi Kleen
8 */ 8 */
9
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
9#include <linux/sched.h> 12#include <linux/sched.h>
10#include <linux/mm.h> 13#include <linux/mm.h>
11#include <linux/smp.h> 14#include <linux/smp.h>
@@ -814,7 +817,7 @@ void signal_fault(struct pt_regs *regs, void __user *frame, char *where)
814 me->comm, me->pid, where, frame, 817 me->comm, me->pid, where, frame,
815 regs->ip, regs->sp, regs->orig_ax); 818 regs->ip, regs->sp, regs->orig_ax);
816 print_vma_addr(" in ", regs->ip); 819 print_vma_addr(" in ", regs->ip);
817 printk(KERN_CONT "\n"); 820 pr_cont("\n");
818 } 821 }
819 822
820 force_sig(SIGSEGV, me); 823 force_sig(SIGSEGV, me);
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 7bd8a082365..7c5a8c314c0 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1,4 +1,4 @@
1/* 1 /*
2 * x86 SMP booting functions 2 * x86 SMP booting functions
3 * 3 *
4 * (c) 1995 Alan Cox, Building #3 <alan@lxorguk.ukuu.org.uk> 4 * (c) 1995 Alan Cox, Building #3 <alan@lxorguk.ukuu.org.uk>
@@ -39,6 +39,8 @@
39 * Glauber Costa : i386 and x86_64 integration 39 * Glauber Costa : i386 and x86_64 integration
40 */ 40 */
41 41
42#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
43
42#include <linux/init.h> 44#include <linux/init.h>
43#include <linux/smp.h> 45#include <linux/smp.h>
44#include <linux/module.h> 46#include <linux/module.h>
@@ -104,17 +106,17 @@ int smp_num_siblings = 1;
104EXPORT_SYMBOL(smp_num_siblings); 106EXPORT_SYMBOL(smp_num_siblings);
105 107
106/* Last level cache ID of each logical CPU */ 108/* Last level cache ID of each logical CPU */
107DEFINE_PER_CPU(u16, cpu_llc_id) = BAD_APICID; 109DEFINE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id) = BAD_APICID;
108 110
109/* representing HT siblings of each logical CPU */ 111/* representing HT siblings of each logical CPU */
110DEFINE_PER_CPU(cpumask_var_t, cpu_sibling_map); 112DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_map);
111EXPORT_PER_CPU_SYMBOL(cpu_sibling_map); 113EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
112 114
113/* representing HT and core siblings of each logical CPU */ 115/* representing HT and core siblings of each logical CPU */
114DEFINE_PER_CPU(cpumask_var_t, cpu_core_map); 116DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
115EXPORT_PER_CPU_SYMBOL(cpu_core_map); 117EXPORT_PER_CPU_SYMBOL(cpu_core_map);
116 118
117DEFINE_PER_CPU(cpumask_var_t, cpu_llc_shared_map); 119DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
118 120
119/* Per CPU bogomips and other parameters */ 121/* Per CPU bogomips and other parameters */
120DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info); 122DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
@@ -184,7 +186,7 @@ static void __cpuinit smp_callin(void)
184 * boards) 186 * boards)
185 */ 187 */
186 188
187 pr_debug("CALLIN, before setup_local_APIC().\n"); 189 pr_debug("CALLIN, before setup_local_APIC()\n");
188 if (apic->smp_callin_clear_local_apic) 190 if (apic->smp_callin_clear_local_apic)
189 apic->smp_callin_clear_local_apic(); 191 apic->smp_callin_clear_local_apic();
190 setup_local_APIC(); 192 setup_local_APIC();
@@ -255,22 +257,13 @@ notrace static void __cpuinit start_secondary(void *unused)
255 check_tsc_sync_target(); 257 check_tsc_sync_target();
256 258
257 /* 259 /*
258 * We need to hold call_lock, so there is no inconsistency
259 * between the time smp_call_function() determines number of
260 * IPI recipients, and the time when the determination is made
261 * for which cpus receive the IPI. Holding this
262 * lock helps us to not include this cpu in a currently in progress
263 * smp_call_function().
264 *
265 * We need to hold vector_lock so there the set of online cpus 260 * We need to hold vector_lock so there the set of online cpus
266 * does not change while we are assigning vectors to cpus. Holding 261 * does not change while we are assigning vectors to cpus. Holding
267 * this lock ensures we don't half assign or remove an irq from a cpu. 262 * this lock ensures we don't half assign or remove an irq from a cpu.
268 */ 263 */
269 ipi_call_lock();
270 lock_vector_lock(); 264 lock_vector_lock();
271 set_cpu_online(smp_processor_id(), true); 265 set_cpu_online(smp_processor_id(), true);
272 unlock_vector_lock(); 266 unlock_vector_lock();
273 ipi_call_unlock();
274 per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; 267 per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
275 x86_platform.nmi_init(); 268 x86_platform.nmi_init();
276 269
@@ -432,17 +425,16 @@ static void impress_friends(void)
432 /* 425 /*
433 * Allow the user to impress friends. 426 * Allow the user to impress friends.
434 */ 427 */
435 pr_debug("Before bogomips.\n"); 428 pr_debug("Before bogomips\n");
436 for_each_possible_cpu(cpu) 429 for_each_possible_cpu(cpu)
437 if (cpumask_test_cpu(cpu, cpu_callout_mask)) 430 if (cpumask_test_cpu(cpu, cpu_callout_mask))
438 bogosum += cpu_data(cpu).loops_per_jiffy; 431 bogosum += cpu_data(cpu).loops_per_jiffy;
439 printk(KERN_INFO 432 pr_info("Total of %d processors activated (%lu.%02lu BogoMIPS)\n",
440 "Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
441 num_online_cpus(), 433 num_online_cpus(),
442 bogosum/(500000/HZ), 434 bogosum/(500000/HZ),
443 (bogosum/(5000/HZ))%100); 435 (bogosum/(5000/HZ))%100);
444 436
445 pr_debug("Before bogocount - setting activated=1.\n"); 437 pr_debug("Before bogocount - setting activated=1\n");
446} 438}
447 439
448void __inquire_remote_apic(int apicid) 440void __inquire_remote_apic(int apicid)
@@ -452,18 +444,17 @@ void __inquire_remote_apic(int apicid)
452 int timeout; 444 int timeout;
453 u32 status; 445 u32 status;
454 446
455 printk(KERN_INFO "Inquiring remote APIC 0x%x...\n", apicid); 447 pr_info("Inquiring remote APIC 0x%x...\n", apicid);
456 448
457 for (i = 0; i < ARRAY_SIZE(regs); i++) { 449 for (i = 0; i < ARRAY_SIZE(regs); i++) {
458 printk(KERN_INFO "... APIC 0x%x %s: ", apicid, names[i]); 450 pr_info("... APIC 0x%x %s: ", apicid, names[i]);
459 451
460 /* 452 /*
461 * Wait for idle. 453 * Wait for idle.
462 */ 454 */
463 status = safe_apic_wait_icr_idle(); 455 status = safe_apic_wait_icr_idle();
464 if (status) 456 if (status)
465 printk(KERN_CONT 457 pr_cont("a previous APIC delivery may have failed\n");
466 "a previous APIC delivery may have failed\n");
467 458
468 apic_icr_write(APIC_DM_REMRD | regs[i], apicid); 459 apic_icr_write(APIC_DM_REMRD | regs[i], apicid);
469 460
@@ -476,10 +467,10 @@ void __inquire_remote_apic(int apicid)
476 switch (status) { 467 switch (status) {
477 case APIC_ICR_RR_VALID: 468 case APIC_ICR_RR_VALID:
478 status = apic_read(APIC_RRR); 469 status = apic_read(APIC_RRR);
479 printk(KERN_CONT "%08x\n", status); 470 pr_cont("%08x\n", status);
480 break; 471 break;
481 default: 472 default:
482 printk(KERN_CONT "failed\n"); 473 pr_cont("failed\n");
483 } 474 }
484 } 475 }
485} 476}
@@ -513,12 +504,12 @@ wakeup_secondary_cpu_via_nmi(int logical_apicid, unsigned long start_eip)
513 apic_write(APIC_ESR, 0); 504 apic_write(APIC_ESR, 0);
514 accept_status = (apic_read(APIC_ESR) & 0xEF); 505 accept_status = (apic_read(APIC_ESR) & 0xEF);
515 } 506 }
516 pr_debug("NMI sent.\n"); 507 pr_debug("NMI sent\n");
517 508
518 if (send_status) 509 if (send_status)
519 printk(KERN_ERR "APIC never delivered???\n"); 510 pr_err("APIC never delivered???\n");
520 if (accept_status) 511 if (accept_status)
521 printk(KERN_ERR "APIC delivery error (%lx).\n", accept_status); 512 pr_err("APIC delivery error (%lx)\n", accept_status);
522 513
523 return (send_status | accept_status); 514 return (send_status | accept_status);
524} 515}
@@ -540,7 +531,7 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
540 apic_read(APIC_ESR); 531 apic_read(APIC_ESR);
541 } 532 }
542 533
543 pr_debug("Asserting INIT.\n"); 534 pr_debug("Asserting INIT\n");
544 535
545 /* 536 /*
546 * Turn INIT on target chip 537 * Turn INIT on target chip
@@ -556,7 +547,7 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
556 547
557 mdelay(10); 548 mdelay(10);
558 549
559 pr_debug("Deasserting INIT.\n"); 550 pr_debug("Deasserting INIT\n");
560 551
561 /* Target chip */ 552 /* Target chip */
562 /* Send IPI */ 553 /* Send IPI */
@@ -589,14 +580,14 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
589 /* 580 /*
590 * Run STARTUP IPI loop. 581 * Run STARTUP IPI loop.
591 */ 582 */
592 pr_debug("#startup loops: %d.\n", num_starts); 583 pr_debug("#startup loops: %d\n", num_starts);
593 584
594 for (j = 1; j <= num_starts; j++) { 585 for (j = 1; j <= num_starts; j++) {
595 pr_debug("Sending STARTUP #%d.\n", j); 586 pr_debug("Sending STARTUP #%d\n", j);
596 if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */ 587 if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */
597 apic_write(APIC_ESR, 0); 588 apic_write(APIC_ESR, 0);
598 apic_read(APIC_ESR); 589 apic_read(APIC_ESR);
599 pr_debug("After apic_write.\n"); 590 pr_debug("After apic_write\n");
600 591
601 /* 592 /*
602 * STARTUP IPI 593 * STARTUP IPI
@@ -613,7 +604,7 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
613 */ 604 */
614 udelay(300); 605 udelay(300);
615 606
616 pr_debug("Startup point 1.\n"); 607 pr_debug("Startup point 1\n");
617 608
618 pr_debug("Waiting for send to finish...\n"); 609 pr_debug("Waiting for send to finish...\n");
619 send_status = safe_apic_wait_icr_idle(); 610 send_status = safe_apic_wait_icr_idle();
@@ -628,12 +619,12 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
628 if (send_status || accept_status) 619 if (send_status || accept_status)
629 break; 620 break;
630 } 621 }
631 pr_debug("After Startup.\n"); 622 pr_debug("After Startup\n");
632 623
633 if (send_status) 624 if (send_status)
634 printk(KERN_ERR "APIC never delivered???\n"); 625 pr_err("APIC never delivered???\n");
635 if (accept_status) 626 if (accept_status)
636 printk(KERN_ERR "APIC delivery error (%lx).\n", accept_status); 627 pr_err("APIC delivery error (%lx)\n", accept_status);
637 628
638 return (send_status | accept_status); 629 return (send_status | accept_status);
639} 630}
@@ -647,11 +638,11 @@ static void __cpuinit announce_cpu(int cpu, int apicid)
647 if (system_state == SYSTEM_BOOTING) { 638 if (system_state == SYSTEM_BOOTING) {
648 if (node != current_node) { 639 if (node != current_node) {
649 if (current_node > (-1)) 640 if (current_node > (-1))
650 pr_cont(" Ok.\n"); 641 pr_cont(" OK\n");
651 current_node = node; 642 current_node = node;
652 pr_info("Booting Node %3d, Processors ", node); 643 pr_info("Booting Node %3d, Processors ", node);
653 } 644 }
654 pr_cont(" #%d%s", cpu, cpu == (nr_cpu_ids - 1) ? " Ok.\n" : ""); 645 pr_cont(" #%d%s", cpu, cpu == (nr_cpu_ids - 1) ? " OK\n" : "");
655 return; 646 return;
656 } else 647 } else
657 pr_info("Booting Node %d Processor %d APIC 0x%x\n", 648 pr_info("Booting Node %d Processor %d APIC 0x%x\n",
@@ -731,9 +722,9 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
731 /* 722 /*
732 * allow APs to start initializing. 723 * allow APs to start initializing.
733 */ 724 */
734 pr_debug("Before Callout %d.\n", cpu); 725 pr_debug("Before Callout %d\n", cpu);
735 cpumask_set_cpu(cpu, cpu_callout_mask); 726 cpumask_set_cpu(cpu, cpu_callout_mask);
736 pr_debug("After Callout %d.\n", cpu); 727 pr_debug("After Callout %d\n", cpu);
737 728
738 /* 729 /*
739 * Wait 5s total for a response 730 * Wait 5s total for a response
@@ -761,7 +752,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
761 pr_err("CPU%d: Stuck ??\n", cpu); 752 pr_err("CPU%d: Stuck ??\n", cpu);
762 else 753 else
763 /* trampoline code not run */ 754 /* trampoline code not run */
764 pr_err("CPU%d: Not responding.\n", cpu); 755 pr_err("CPU%d: Not responding\n", cpu);
765 if (apic->inquire_remote_apic) 756 if (apic->inquire_remote_apic)
766 apic->inquire_remote_apic(apicid); 757 apic->inquire_remote_apic(apicid);
767 } 758 }
@@ -806,7 +797,7 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
806 if (apicid == BAD_APICID || apicid == boot_cpu_physical_apicid || 797 if (apicid == BAD_APICID || apicid == boot_cpu_physical_apicid ||
807 !physid_isset(apicid, phys_cpu_present_map) || 798 !physid_isset(apicid, phys_cpu_present_map) ||
808 !apic->apic_id_valid(apicid)) { 799 !apic->apic_id_valid(apicid)) {
809 printk(KERN_ERR "%s: bad cpu %d\n", __func__, cpu); 800 pr_err("%s: bad cpu %d\n", __func__, cpu);
810 return -EINVAL; 801 return -EINVAL;
811 } 802 }
812 803
@@ -887,9 +878,8 @@ static int __init smp_sanity_check(unsigned max_cpus)
887 unsigned int cpu; 878 unsigned int cpu;
888 unsigned nr; 879 unsigned nr;
889 880
890 printk(KERN_WARNING 881 pr_warn("More than 8 CPUs detected - skipping them\n"
891 "More than 8 CPUs detected - skipping them.\n" 882 "Use CONFIG_X86_BIGSMP\n");
892 "Use CONFIG_X86_BIGSMP.\n");
893 883
894 nr = 0; 884 nr = 0;
895 for_each_present_cpu(cpu) { 885 for_each_present_cpu(cpu) {
@@ -910,8 +900,7 @@ static int __init smp_sanity_check(unsigned max_cpus)
910#endif 900#endif
911 901
912 if (!physid_isset(hard_smp_processor_id(), phys_cpu_present_map)) { 902 if (!physid_isset(hard_smp_processor_id(), phys_cpu_present_map)) {
913 printk(KERN_WARNING 903 pr_warn("weird, boot CPU (#%d) not listed by the BIOS\n",
914 "weird, boot CPU (#%d) not listed by the BIOS.\n",
915 hard_smp_processor_id()); 904 hard_smp_processor_id());
916 905
917 physid_set(hard_smp_processor_id(), phys_cpu_present_map); 906 physid_set(hard_smp_processor_id(), phys_cpu_present_map);
@@ -923,11 +912,10 @@ static int __init smp_sanity_check(unsigned max_cpus)
923 */ 912 */
924 if (!smp_found_config && !acpi_lapic) { 913 if (!smp_found_config && !acpi_lapic) {
925 preempt_enable(); 914 preempt_enable();
926 printk(KERN_NOTICE "SMP motherboard not detected.\n"); 915 pr_notice("SMP motherboard not detected\n");
927 disable_smp(); 916 disable_smp();
928 if (APIC_init_uniprocessor()) 917 if (APIC_init_uniprocessor())
929 printk(KERN_NOTICE "Local APIC not detected." 918 pr_notice("Local APIC not detected. Using dummy APIC emulation.\n");
930 " Using dummy APIC emulation.\n");
931 return -1; 919 return -1;
932 } 920 }
933 921
@@ -936,9 +924,8 @@ static int __init smp_sanity_check(unsigned max_cpus)
936 * CPU too, but we do it for the sake of robustness anyway. 924 * CPU too, but we do it for the sake of robustness anyway.
937 */ 925 */
938 if (!apic->check_phys_apicid_present(boot_cpu_physical_apicid)) { 926 if (!apic->check_phys_apicid_present(boot_cpu_physical_apicid)) {
939 printk(KERN_NOTICE 927 pr_notice("weird, boot CPU (#%d) not listed by the BIOS\n",
940 "weird, boot CPU (#%d) not listed by the BIOS.\n", 928 boot_cpu_physical_apicid);
941 boot_cpu_physical_apicid);
942 physid_set(hard_smp_processor_id(), phys_cpu_present_map); 929 physid_set(hard_smp_processor_id(), phys_cpu_present_map);
943 } 930 }
944 preempt_enable(); 931 preempt_enable();
@@ -951,8 +938,7 @@ static int __init smp_sanity_check(unsigned max_cpus)
951 if (!disable_apic) { 938 if (!disable_apic) {
952 pr_err("BIOS bug, local APIC #%d not detected!...\n", 939 pr_err("BIOS bug, local APIC #%d not detected!...\n",
953 boot_cpu_physical_apicid); 940 boot_cpu_physical_apicid);
954 pr_err("... forcing use of dummy APIC emulation." 941 pr_err("... forcing use of dummy APIC emulation (tell your hw vendor)\n");
955 "(tell your hw vendor)\n");
956 } 942 }
957 smpboot_clear_io_apic(); 943 smpboot_clear_io_apic();
958 disable_ioapic_support(); 944 disable_ioapic_support();
@@ -965,7 +951,7 @@ static int __init smp_sanity_check(unsigned max_cpus)
965 * If SMP should be disabled, then really disable it! 951 * If SMP should be disabled, then really disable it!
966 */ 952 */
967 if (!max_cpus) { 953 if (!max_cpus) {
968 printk(KERN_INFO "SMP mode deactivated.\n"); 954 pr_info("SMP mode deactivated\n");
969 smpboot_clear_io_apic(); 955 smpboot_clear_io_apic();
970 956
971 connect_bsp_APIC(); 957 connect_bsp_APIC();
@@ -1017,7 +1003,7 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
1017 1003
1018 1004
1019 if (smp_sanity_check(max_cpus) < 0) { 1005 if (smp_sanity_check(max_cpus) < 0) {
1020 printk(KERN_INFO "SMP disabled\n"); 1006 pr_info("SMP disabled\n");
1021 disable_smp(); 1007 disable_smp();
1022 goto out; 1008 goto out;
1023 } 1009 }
@@ -1055,7 +1041,7 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
1055 * Set up local APIC timer on boot CPU. 1041 * Set up local APIC timer on boot CPU.
1056 */ 1042 */
1057 1043
1058 printk(KERN_INFO "CPU%d: ", 0); 1044 pr_info("CPU%d: ", 0);
1059 print_cpu_info(&cpu_data(0)); 1045 print_cpu_info(&cpu_data(0));
1060 x86_init.timers.setup_percpu_clockev(); 1046 x86_init.timers.setup_percpu_clockev();
1061 1047
@@ -1105,7 +1091,7 @@ void __init native_smp_prepare_boot_cpu(void)
1105 1091
1106void __init native_smp_cpus_done(unsigned int max_cpus) 1092void __init native_smp_cpus_done(unsigned int max_cpus)
1107{ 1093{
1108 pr_debug("Boot done.\n"); 1094 pr_debug("Boot done\n");
1109 1095
1110 nmi_selftest(); 1096 nmi_selftest();
1111 impress_friends(); 1097 impress_friends();
@@ -1166,8 +1152,7 @@ __init void prefill_possible_map(void)
1166 1152
1167 /* nr_cpu_ids could be reduced via nr_cpus= */ 1153 /* nr_cpu_ids could be reduced via nr_cpus= */
1168 if (possible > nr_cpu_ids) { 1154 if (possible > nr_cpu_ids) {
1169 printk(KERN_WARNING 1155 pr_warn("%d Processors exceeds NR_CPUS limit of %d\n",
1170 "%d Processors exceeds NR_CPUS limit of %d\n",
1171 possible, nr_cpu_ids); 1156 possible, nr_cpu_ids);
1172 possible = nr_cpu_ids; 1157 possible = nr_cpu_ids;
1173 } 1158 }
@@ -1176,13 +1161,12 @@ __init void prefill_possible_map(void)
1176 if (!setup_max_cpus) 1161 if (!setup_max_cpus)
1177#endif 1162#endif
1178 if (possible > i) { 1163 if (possible > i) {
1179 printk(KERN_WARNING 1164 pr_warn("%d Processors exceeds max_cpus limit of %u\n",
1180 "%d Processors exceeds max_cpus limit of %u\n",
1181 possible, setup_max_cpus); 1165 possible, setup_max_cpus);
1182 possible = i; 1166 possible = i;
1183 } 1167 }
1184 1168
1185 printk(KERN_INFO "SMP: Allowing %d CPUs, %d hotplug CPUs\n", 1169 pr_info("Allowing %d CPUs, %d hotplug CPUs\n",
1186 possible, max_t(int, possible - num_processors, 0)); 1170 possible, max_t(int, possible - num_processors, 0));
1187 1171
1188 for (i = 0; i < possible; i++) 1172 for (i = 0; i < possible; i++)
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 05b31d92f69..b481341c936 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -9,6 +9,9 @@
9/* 9/*
10 * Handle hardware traps and faults. 10 * Handle hardware traps and faults.
11 */ 11 */
12
13#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14
12#include <linux/interrupt.h> 15#include <linux/interrupt.h>
13#include <linux/kallsyms.h> 16#include <linux/kallsyms.h>
14#include <linux/spinlock.h> 17#include <linux/spinlock.h>
@@ -143,12 +146,11 @@ trap_signal:
143#ifdef CONFIG_X86_64 146#ifdef CONFIG_X86_64
144 if (show_unhandled_signals && unhandled_signal(tsk, signr) && 147 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
145 printk_ratelimit()) { 148 printk_ratelimit()) {
146 printk(KERN_INFO 149 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
147 "%s[%d] trap %s ip:%lx sp:%lx error:%lx", 150 tsk->comm, tsk->pid, str,
148 tsk->comm, tsk->pid, str, 151 regs->ip, regs->sp, error_code);
149 regs->ip, regs->sp, error_code);
150 print_vma_addr(" in ", regs->ip); 152 print_vma_addr(" in ", regs->ip);
151 printk("\n"); 153 pr_cont("\n");
152 } 154 }
153#endif 155#endif
154 156
@@ -269,12 +271,11 @@ do_general_protection(struct pt_regs *regs, long error_code)
269 271
270 if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) && 272 if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
271 printk_ratelimit()) { 273 printk_ratelimit()) {
272 printk(KERN_INFO 274 pr_info("%s[%d] general protection ip:%lx sp:%lx error:%lx",
273 "%s[%d] general protection ip:%lx sp:%lx error:%lx",
274 tsk->comm, task_pid_nr(tsk), 275 tsk->comm, task_pid_nr(tsk),
275 regs->ip, regs->sp, error_code); 276 regs->ip, regs->sp, error_code);
276 print_vma_addr(" in ", regs->ip); 277 print_vma_addr(" in ", regs->ip);
277 printk("\n"); 278 pr_cont("\n");
278 } 279 }
279 280
280 force_sig(SIGSEGV, tsk); 281 force_sig(SIGSEGV, tsk);
@@ -570,7 +571,7 @@ do_spurious_interrupt_bug(struct pt_regs *regs, long error_code)
570 conditional_sti(regs); 571 conditional_sti(regs);
571#if 0 572#if 0
572 /* No need to warn about this any longer. */ 573 /* No need to warn about this any longer. */
573 printk(KERN_INFO "Ignoring P6 Local APIC Spurious Interrupt Bug...\n"); 574 pr_info("Ignoring P6 Local APIC Spurious Interrupt Bug...\n");
574#endif 575#endif
575} 576}
576 577
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index fc0a147e372..cfa5d4f7ca5 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -1,3 +1,5 @@
1#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2
1#include <linux/kernel.h> 3#include <linux/kernel.h>
2#include <linux/sched.h> 4#include <linux/sched.h>
3#include <linux/init.h> 5#include <linux/init.h>
@@ -84,8 +86,7 @@ EXPORT_SYMBOL_GPL(check_tsc_unstable);
84#ifdef CONFIG_X86_TSC 86#ifdef CONFIG_X86_TSC
85int __init notsc_setup(char *str) 87int __init notsc_setup(char *str)
86{ 88{
87 printk(KERN_WARNING "notsc: Kernel compiled with CONFIG_X86_TSC, " 89 pr_warn("Kernel compiled with CONFIG_X86_TSC, cannot disable TSC completely\n");
88 "cannot disable TSC completely.\n");
89 tsc_disabled = 1; 90 tsc_disabled = 1;
90 return 1; 91 return 1;
91} 92}
@@ -373,7 +374,7 @@ static unsigned long quick_pit_calibrate(void)
373 goto success; 374 goto success;
374 } 375 }
375 } 376 }
376 printk("Fast TSC calibration failed\n"); 377 pr_err("Fast TSC calibration failed\n");
377 return 0; 378 return 0;
378 379
379success: 380success:
@@ -392,7 +393,7 @@ success:
392 */ 393 */
393 delta *= PIT_TICK_RATE; 394 delta *= PIT_TICK_RATE;
394 do_div(delta, i*256*1000); 395 do_div(delta, i*256*1000);
395 printk("Fast TSC calibration using PIT\n"); 396 pr_info("Fast TSC calibration using PIT\n");
396 return delta; 397 return delta;
397} 398}
398 399
@@ -487,9 +488,8 @@ unsigned long native_calibrate_tsc(void)
487 * use the reference value, as it is more precise. 488 * use the reference value, as it is more precise.
488 */ 489 */
489 if (delta >= 90 && delta <= 110) { 490 if (delta >= 90 && delta <= 110) {
490 printk(KERN_INFO 491 pr_info("PIT calibration matches %s. %d loops\n",
491 "TSC: PIT calibration matches %s. %d loops\n", 492 hpet ? "HPET" : "PMTIMER", i + 1);
492 hpet ? "HPET" : "PMTIMER", i + 1);
493 return tsc_ref_min; 493 return tsc_ref_min;
494 } 494 }
495 495
@@ -511,38 +511,36 @@ unsigned long native_calibrate_tsc(void)
511 */ 511 */
512 if (tsc_pit_min == ULONG_MAX) { 512 if (tsc_pit_min == ULONG_MAX) {
513 /* PIT gave no useful value */ 513 /* PIT gave no useful value */
514 printk(KERN_WARNING "TSC: Unable to calibrate against PIT\n"); 514 pr_warn("Unable to calibrate against PIT\n");
515 515
516 /* We don't have an alternative source, disable TSC */ 516 /* We don't have an alternative source, disable TSC */
517 if (!hpet && !ref1 && !ref2) { 517 if (!hpet && !ref1 && !ref2) {
518 printk("TSC: No reference (HPET/PMTIMER) available\n"); 518 pr_notice("No reference (HPET/PMTIMER) available\n");
519 return 0; 519 return 0;
520 } 520 }
521 521
522 /* The alternative source failed as well, disable TSC */ 522 /* The alternative source failed as well, disable TSC */
523 if (tsc_ref_min == ULONG_MAX) { 523 if (tsc_ref_min == ULONG_MAX) {
524 printk(KERN_WARNING "TSC: HPET/PMTIMER calibration " 524 pr_warn("HPET/PMTIMER calibration failed\n");
525 "failed.\n");
526 return 0; 525 return 0;
527 } 526 }
528 527
529 /* Use the alternative source */ 528 /* Use the alternative source */
530 printk(KERN_INFO "TSC: using %s reference calibration\n", 529 pr_info("using %s reference calibration\n",
531 hpet ? "HPET" : "PMTIMER"); 530 hpet ? "HPET" : "PMTIMER");
532 531
533 return tsc_ref_min; 532 return tsc_ref_min;
534 } 533 }
535 534
536 /* We don't have an alternative source, use the PIT calibration value */ 535 /* We don't have an alternative source, use the PIT calibration value */
537 if (!hpet && !ref1 && !ref2) { 536 if (!hpet && !ref1 && !ref2) {
538 printk(KERN_INFO "TSC: Using PIT calibration value\n"); 537 pr_info("Using PIT calibration value\n");
539 return tsc_pit_min; 538 return tsc_pit_min;
540 } 539 }
541 540
542 /* The alternative source failed, use the PIT calibration value */ 541 /* The alternative source failed, use the PIT calibration value */
543 if (tsc_ref_min == ULONG_MAX) { 542 if (tsc_ref_min == ULONG_MAX) {
544 printk(KERN_WARNING "TSC: HPET/PMTIMER calibration failed. " 543 pr_warn("HPET/PMTIMER calibration failed. Using PIT calibration.\n");
545 "Using PIT calibration\n");
546 return tsc_pit_min; 544 return tsc_pit_min;
547 } 545 }
548 546
@@ -551,9 +549,9 @@ unsigned long native_calibrate_tsc(void)
551 * the PIT value as we know that there are PMTIMERs around 549 * the PIT value as we know that there are PMTIMERs around
552 * running at double speed. At least we let the user know: 550 * running at double speed. At least we let the user know:
553 */ 551 */
554 printk(KERN_WARNING "TSC: PIT calibration deviates from %s: %lu %lu.\n", 552 pr_warn("PIT calibration deviates from %s: %lu %lu\n",
555 hpet ? "HPET" : "PMTIMER", tsc_pit_min, tsc_ref_min); 553 hpet ? "HPET" : "PMTIMER", tsc_pit_min, tsc_ref_min);
556 printk(KERN_INFO "TSC: Using PIT calibration value\n"); 554 pr_info("Using PIT calibration value\n");
557 return tsc_pit_min; 555 return tsc_pit_min;
558} 556}
559 557
@@ -785,7 +783,7 @@ void mark_tsc_unstable(char *reason)
785 tsc_unstable = 1; 783 tsc_unstable = 1;
786 sched_clock_stable = 0; 784 sched_clock_stable = 0;
787 disable_sched_clock_irqtime(); 785 disable_sched_clock_irqtime();
788 printk(KERN_INFO "Marking TSC unstable due to %s\n", reason); 786 pr_info("Marking TSC unstable due to %s\n", reason);
789 /* Change only the rating, when not registered */ 787 /* Change only the rating, when not registered */
790 if (clocksource_tsc.mult) 788 if (clocksource_tsc.mult)
791 clocksource_mark_unstable(&clocksource_tsc); 789 clocksource_mark_unstable(&clocksource_tsc);
@@ -912,9 +910,9 @@ static void tsc_refine_calibration_work(struct work_struct *work)
912 goto out; 910 goto out;
913 911
914 tsc_khz = freq; 912 tsc_khz = freq;
915 printk(KERN_INFO "Refined TSC clocksource calibration: " 913 pr_info("Refined TSC clocksource calibration: %lu.%03lu MHz\n",
916 "%lu.%03lu MHz.\n", (unsigned long)tsc_khz / 1000, 914 (unsigned long)tsc_khz / 1000,
917 (unsigned long)tsc_khz % 1000); 915 (unsigned long)tsc_khz % 1000);
918 916
919out: 917out:
920 clocksource_register_khz(&clocksource_tsc, tsc_khz); 918 clocksource_register_khz(&clocksource_tsc, tsc_khz);
@@ -970,9 +968,9 @@ void __init tsc_init(void)
970 return; 968 return;
971 } 969 }
972 970
973 printk("Detected %lu.%03lu MHz processor.\n", 971 pr_info("Detected %lu.%03lu MHz processor\n",
974 (unsigned long)cpu_khz / 1000, 972 (unsigned long)cpu_khz / 1000,
975 (unsigned long)cpu_khz % 1000); 973 (unsigned long)cpu_khz % 1000);
976 974
977 /* 975 /*
978 * Secondary CPUs do not run through tsc_init(), so set up 976 * Secondary CPUs do not run through tsc_init(), so set up
diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
index dc4e910a7d9..36fd42091fa 100644
--- a/arch/x86/kernel/uprobes.c
+++ b/arch/x86/kernel/uprobes.c
@@ -409,9 +409,10 @@ static int validate_insn_bits(struct arch_uprobe *auprobe, struct mm_struct *mm,
409 * arch_uprobe_analyze_insn - instruction analysis including validity and fixups. 409 * arch_uprobe_analyze_insn - instruction analysis including validity and fixups.
410 * @mm: the probed address space. 410 * @mm: the probed address space.
411 * @arch_uprobe: the probepoint information. 411 * @arch_uprobe: the probepoint information.
412 * @addr: virtual address at which to install the probepoint
412 * Return 0 on success or a -ve number on error. 413 * Return 0 on success or a -ve number on error.
413 */ 414 */
414int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm) 415int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long addr)
415{ 416{
416 int ret; 417 int ret;
417 struct insn insn; 418 struct insn insn;
diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
index 255f58ae71e..54abcc0baf2 100644
--- a/arch/x86/kernel/vm86_32.c
+++ b/arch/x86/kernel/vm86_32.c
@@ -28,6 +28,8 @@
28 * 28 *
29 */ 29 */
30 30
31#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
32
31#include <linux/capability.h> 33#include <linux/capability.h>
32#include <linux/errno.h> 34#include <linux/errno.h>
33#include <linux/interrupt.h> 35#include <linux/interrupt.h>
@@ -137,14 +139,14 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
137 local_irq_enable(); 139 local_irq_enable();
138 140
139 if (!current->thread.vm86_info) { 141 if (!current->thread.vm86_info) {
140 printk("no vm86_info: BAD\n"); 142 pr_alert("no vm86_info: BAD\n");
141 do_exit(SIGSEGV); 143 do_exit(SIGSEGV);
142 } 144 }
143 set_flags(regs->pt.flags, VEFLAGS, X86_EFLAGS_VIF | current->thread.v86mask); 145 set_flags(regs->pt.flags, VEFLAGS, X86_EFLAGS_VIF | current->thread.v86mask);
144 tmp = copy_vm86_regs_to_user(&current->thread.vm86_info->regs, regs); 146 tmp = copy_vm86_regs_to_user(&current->thread.vm86_info->regs, regs);
145 tmp += put_user(current->thread.screen_bitmap, &current->thread.vm86_info->screen_bitmap); 147 tmp += put_user(current->thread.screen_bitmap, &current->thread.vm86_info->screen_bitmap);
146 if (tmp) { 148 if (tmp) {
147 printk("vm86: could not access userspace vm86_info\n"); 149 pr_alert("could not access userspace vm86_info\n");
148 do_exit(SIGSEGV); 150 do_exit(SIGSEGV);
149 } 151 }
150 152
diff --git a/arch/x86/kernel/vsmp_64.c b/arch/x86/kernel/vsmp_64.c
index 8eeb55a551b..992f890283e 100644
--- a/arch/x86/kernel/vsmp_64.c
+++ b/arch/x86/kernel/vsmp_64.c
@@ -16,6 +16,7 @@
16#include <linux/pci_ids.h> 16#include <linux/pci_ids.h>
17#include <linux/pci_regs.h> 17#include <linux/pci_regs.h>
18#include <linux/smp.h> 18#include <linux/smp.h>
19#include <linux/irq.h>
19 20
20#include <asm/apic.h> 21#include <asm/apic.h>
21#include <asm/pci-direct.h> 22#include <asm/pci-direct.h>
@@ -95,6 +96,18 @@ static void __init set_vsmp_pv_ops(void)
95 ctl = readl(address + 4); 96 ctl = readl(address + 4);
96 printk(KERN_INFO "vSMP CTL: capabilities:0x%08x control:0x%08x\n", 97 printk(KERN_INFO "vSMP CTL: capabilities:0x%08x control:0x%08x\n",
97 cap, ctl); 98 cap, ctl);
99
100 /* If possible, let the vSMP foundation route the interrupt optimally */
101#ifdef CONFIG_SMP
102 if (cap & ctl & BIT(8)) {
103 ctl &= ~BIT(8);
104#ifdef CONFIG_PROC_FS
105 /* Don't let users change irq affinity via procfs */
106 no_irq_affinity = 1;
107#endif
108 }
109#endif
110
98 if (cap & ctl & (1 << 4)) { 111 if (cap & ctl & (1 << 4)) {
99 /* Setup irq ops and turn on vSMP IRQ fastpath handling */ 112 /* Setup irq ops and turn on vSMP IRQ fastpath handling */
100 pv_irq_ops.irq_disable = PV_CALLEE_SAVE(vsmp_irq_disable); 113 pv_irq_ops.irq_disable = PV_CALLEE_SAVE(vsmp_irq_disable);
@@ -102,12 +115,11 @@ static void __init set_vsmp_pv_ops(void)
102 pv_irq_ops.save_fl = PV_CALLEE_SAVE(vsmp_save_fl); 115 pv_irq_ops.save_fl = PV_CALLEE_SAVE(vsmp_save_fl);
103 pv_irq_ops.restore_fl = PV_CALLEE_SAVE(vsmp_restore_fl); 116 pv_irq_ops.restore_fl = PV_CALLEE_SAVE(vsmp_restore_fl);
104 pv_init_ops.patch = vsmp_patch; 117 pv_init_ops.patch = vsmp_patch;
105
106 ctl &= ~(1 << 4); 118 ctl &= ~(1 << 4);
107 writel(ctl, address + 4);
108 ctl = readl(address + 4);
109 printk(KERN_INFO "vSMP CTL: control set to:0x%08x\n", ctl);
110 } 119 }
120 writel(ctl, address + 4);
121 ctl = readl(address + 4);
122 pr_info("vSMP CTL: control set to:0x%08x\n", ctl);
111 123
112 early_iounmap(address, 8); 124 early_iounmap(address, 8);
113} 125}
@@ -187,12 +199,36 @@ static void __init vsmp_cap_cpus(void)
187#endif 199#endif
188} 200}
189 201
202static int apicid_phys_pkg_id(int initial_apic_id, int index_msb)
203{
204 return hard_smp_processor_id() >> index_msb;
205}
206
207/*
208 * In vSMP, all cpus should be capable of handling interrupts, regardless of
209 * the APIC used.
210 */
211static void fill_vector_allocation_domain(int cpu, struct cpumask *retmask,
212 const struct cpumask *mask)
213{
214 cpumask_setall(retmask);
215}
216
217static void vsmp_apic_post_init(void)
218{
219 /* need to update phys_pkg_id */
220 apic->phys_pkg_id = apicid_phys_pkg_id;
221 apic->vector_allocation_domain = fill_vector_allocation_domain;
222}
223
190void __init vsmp_init(void) 224void __init vsmp_init(void)
191{ 225{
192 detect_vsmp_box(); 226 detect_vsmp_box();
193 if (!is_vsmp_box()) 227 if (!is_vsmp_box())
194 return; 228 return;
195 229
230 x86_platform.apic_post_init = vsmp_apic_post_init;
231
196 vsmp_cap_cpus(); 232 vsmp_cap_cpus();
197 233
198 set_vsmp_pv_ops(); 234 set_vsmp_pv_ops();
diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index 5db36caf428..8d141b30904 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -18,6 +18,8 @@
18 * use the vDSO. 18 * use the vDSO.
19 */ 19 */
20 20
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22
21#include <linux/time.h> 23#include <linux/time.h>
22#include <linux/init.h> 24#include <linux/init.h>
23#include <linux/kernel.h> 25#include <linux/kernel.h>
@@ -111,18 +113,13 @@ void update_vsyscall(struct timespec *wall_time, struct timespec *wtm,
111static void warn_bad_vsyscall(const char *level, struct pt_regs *regs, 113static void warn_bad_vsyscall(const char *level, struct pt_regs *regs,
112 const char *message) 114 const char *message)
113{ 115{
114 static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); 116 if (!show_unhandled_signals)
115 struct task_struct *tsk;
116
117 if (!show_unhandled_signals || !__ratelimit(&rs))
118 return; 117 return;
119 118
120 tsk = current; 119 pr_notice_ratelimited("%s%s[%d] %s ip:%lx cs:%lx sp:%lx ax:%lx si:%lx di:%lx\n",
121 120 level, current->comm, task_pid_nr(current),
122 printk("%s%s[%d] %s ip:%lx cs:%lx sp:%lx ax:%lx si:%lx di:%lx\n", 121 message, regs->ip, regs->cs,
123 level, tsk->comm, task_pid_nr(tsk), 122 regs->sp, regs->ax, regs->si, regs->di);
124 message, regs->ip, regs->cs,
125 regs->sp, regs->ax, regs->si, regs->di);
126} 123}
127 124
128static int addr_to_vsyscall_nr(unsigned long addr) 125static int addr_to_vsyscall_nr(unsigned long addr)
diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
index 9796c2f3d07..6020f6f5927 100644
--- a/arch/x86/kernel/x8664_ksyms_64.c
+++ b/arch/x86/kernel/x8664_ksyms_64.c
@@ -28,6 +28,7 @@ EXPORT_SYMBOL(__put_user_8);
28 28
29EXPORT_SYMBOL(copy_user_generic_string); 29EXPORT_SYMBOL(copy_user_generic_string);
30EXPORT_SYMBOL(copy_user_generic_unrolled); 30EXPORT_SYMBOL(copy_user_generic_unrolled);
31EXPORT_SYMBOL(copy_user_enhanced_fast_string);
31EXPORT_SYMBOL(__copy_user_nocache); 32EXPORT_SYMBOL(__copy_user_nocache);
32EXPORT_SYMBOL(_copy_from_user); 33EXPORT_SYMBOL(_copy_from_user);
33EXPORT_SYMBOL(_copy_to_user); 34EXPORT_SYMBOL(_copy_to_user);
diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
index 35c5e543f55..7a3d075a814 100644
--- a/arch/x86/kernel/x86_init.c
+++ b/arch/x86/kernel/x86_init.c
@@ -26,10 +26,8 @@
26 26
27void __cpuinit x86_init_noop(void) { } 27void __cpuinit x86_init_noop(void) { }
28void __init x86_init_uint_noop(unsigned int unused) { } 28void __init x86_init_uint_noop(unsigned int unused) { }
29void __init x86_init_pgd_noop(pgd_t *unused) { }
30int __init iommu_init_noop(void) { return 0; } 29int __init iommu_init_noop(void) { return 0; }
31void iommu_shutdown_noop(void) { } 30void iommu_shutdown_noop(void) { }
32void wallclock_init_noop(void) { }
33 31
34/* 32/*
35 * The platform setup functions are preset with the default functions 33 * The platform setup functions are preset with the default functions
@@ -69,8 +67,7 @@ struct x86_init_ops x86_init __initdata = {
69 }, 67 },
70 68
71 .paging = { 69 .paging = {
72 .pagetable_setup_start = native_pagetable_setup_start, 70 .pagetable_init = native_pagetable_init,
73 .pagetable_setup_done = native_pagetable_setup_done,
74 }, 71 },
75 72
76 .timers = { 73 .timers = {
@@ -101,7 +98,6 @@ static int default_i8042_detect(void) { return 1; };
101 98
102struct x86_platform_ops x86_platform = { 99struct x86_platform_ops x86_platform = {
103 .calibrate_tsc = native_calibrate_tsc, 100 .calibrate_tsc = native_calibrate_tsc,
104 .wallclock_init = wallclock_init_noop,
105 .get_wallclock = mach_get_cmos_time, 101 .get_wallclock = mach_get_cmos_time,
106 .set_wallclock = mach_set_rtc_mmss, 102 .set_wallclock = mach_set_rtc_mmss,
107 .iommu_shutdown = iommu_shutdown_noop, 103 .iommu_shutdown = iommu_shutdown_noop,
diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
index bd18149b2b0..3d3e2070911 100644
--- a/arch/x86/kernel/xsave.c
+++ b/arch/x86/kernel/xsave.c
@@ -3,6 +3,9 @@
3 * 3 *
4 * Author: Suresh Siddha <suresh.b.siddha@intel.com> 4 * Author: Suresh Siddha <suresh.b.siddha@intel.com>
5 */ 5 */
6
7#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
8
6#include <linux/bootmem.h> 9#include <linux/bootmem.h>
7#include <linux/compat.h> 10#include <linux/compat.h>
8#include <asm/i387.h> 11#include <asm/i387.h>
@@ -162,7 +165,7 @@ int save_i387_xstate(void __user *buf)
162 BUG_ON(sig_xstate_size < xstate_size); 165 BUG_ON(sig_xstate_size < xstate_size);
163 166
164 if ((unsigned long)buf % 64) 167 if ((unsigned long)buf % 64)
165 printk("save_i387_xstate: bad fpstate %p\n", buf); 168 pr_err("%s: bad fpstate %p\n", __func__, buf);
166 169
167 if (!used_math()) 170 if (!used_math())
168 return 0; 171 return 0;
@@ -422,7 +425,7 @@ static void __init xstate_enable_boot_cpu(void)
422 pcntxt_mask = eax + ((u64)edx << 32); 425 pcntxt_mask = eax + ((u64)edx << 32);
423 426
424 if ((pcntxt_mask & XSTATE_FPSSE) != XSTATE_FPSSE) { 427 if ((pcntxt_mask & XSTATE_FPSSE) != XSTATE_FPSSE) {
425 printk(KERN_ERR "FP/SSE not shown under xsave features 0x%llx\n", 428 pr_err("FP/SSE not shown under xsave features 0x%llx\n",
426 pcntxt_mask); 429 pcntxt_mask);
427 BUG(); 430 BUG();
428 } 431 }
@@ -445,9 +448,8 @@ static void __init xstate_enable_boot_cpu(void)
445 448
446 setup_xstate_init(); 449 setup_xstate_init();
447 450
448 printk(KERN_INFO "xsave/xrstor: enabled xstate_bv 0x%llx, " 451 pr_info("enabled xstate_bv 0x%llx, cntxt size 0x%x\n",
449 "cntxt size 0x%x\n", 452 pcntxt_mask, xstate_size);
450 pcntxt_mask, xstate_size);
451} 453}
452 454
453/* 455/*
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 7df1c6d839f..0595f1397b7 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -201,6 +201,7 @@ static int do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
201 unsigned f_lm = 0; 201 unsigned f_lm = 0;
202#endif 202#endif
203 unsigned f_rdtscp = kvm_x86_ops->rdtscp_supported() ? F(RDTSCP) : 0; 203 unsigned f_rdtscp = kvm_x86_ops->rdtscp_supported() ? F(RDTSCP) : 0;
204 unsigned f_invpcid = kvm_x86_ops->invpcid_supported() ? F(INVPCID) : 0;
204 205
205 /* cpuid 1.edx */ 206 /* cpuid 1.edx */
206 const u32 kvm_supported_word0_x86_features = 207 const u32 kvm_supported_word0_x86_features =
@@ -228,7 +229,7 @@ static int do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
228 0 /* DS-CPL, VMX, SMX, EST */ | 229 0 /* DS-CPL, VMX, SMX, EST */ |
229 0 /* TM2 */ | F(SSSE3) | 0 /* CNXT-ID */ | 0 /* Reserved */ | 230 0 /* TM2 */ | F(SSSE3) | 0 /* CNXT-ID */ | 0 /* Reserved */ |
230 F(FMA) | F(CX16) | 0 /* xTPR Update, PDCM */ | 231 F(FMA) | F(CX16) | 0 /* xTPR Update, PDCM */ |
231 0 /* Reserved, DCA */ | F(XMM4_1) | 232 F(PCID) | 0 /* Reserved, DCA */ | F(XMM4_1) |
232 F(XMM4_2) | F(X2APIC) | F(MOVBE) | F(POPCNT) | 233 F(XMM4_2) | F(X2APIC) | F(MOVBE) | F(POPCNT) |
233 0 /* Reserved*/ | F(AES) | F(XSAVE) | 0 /* OSXSAVE */ | F(AVX) | 234 0 /* Reserved*/ | F(AES) | F(XSAVE) | 0 /* OSXSAVE */ | F(AVX) |
234 F(F16C) | F(RDRAND); 235 F(F16C) | F(RDRAND);
@@ -248,7 +249,7 @@ static int do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
248 /* cpuid 7.0.ebx */ 249 /* cpuid 7.0.ebx */
249 const u32 kvm_supported_word9_x86_features = 250 const u32 kvm_supported_word9_x86_features =
250 F(FSGSBASE) | F(BMI1) | F(HLE) | F(AVX2) | F(SMEP) | 251 F(FSGSBASE) | F(BMI1) | F(HLE) | F(AVX2) | F(SMEP) |
251 F(BMI2) | F(ERMS) | F(RTM); 252 F(BMI2) | F(ERMS) | f_invpcid | F(RTM);
252 253
253 /* all calls to cpuid_count() should be made on the same cpu */ 254 /* all calls to cpuid_count() should be made on the same cpu */
254 get_cpu(); 255 get_cpu();
@@ -409,6 +410,7 @@ static int do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
409 (1 << KVM_FEATURE_NOP_IO_DELAY) | 410 (1 << KVM_FEATURE_NOP_IO_DELAY) |
410 (1 << KVM_FEATURE_CLOCKSOURCE2) | 411 (1 << KVM_FEATURE_CLOCKSOURCE2) |
411 (1 << KVM_FEATURE_ASYNC_PF) | 412 (1 << KVM_FEATURE_ASYNC_PF) |
413 (1 << KVM_FEATURE_PV_EOI) |
412 (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT); 414 (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT);
413 415
414 if (sched_info_on()) 416 if (sched_info_on())
@@ -639,33 +641,37 @@ static struct kvm_cpuid_entry2* check_cpuid_limit(struct kvm_vcpu *vcpu,
639 return kvm_find_cpuid_entry(vcpu, maxlevel->eax, index); 641 return kvm_find_cpuid_entry(vcpu, maxlevel->eax, index);
640} 642}
641 643
642void kvm_emulate_cpuid(struct kvm_vcpu *vcpu) 644void kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx, u32 *ecx, u32 *edx)
643{ 645{
644 u32 function, index; 646 u32 function = *eax, index = *ecx;
645 struct kvm_cpuid_entry2 *best; 647 struct kvm_cpuid_entry2 *best;
646 648
647 function = kvm_register_read(vcpu, VCPU_REGS_RAX);
648 index = kvm_register_read(vcpu, VCPU_REGS_RCX);
649 kvm_register_write(vcpu, VCPU_REGS_RAX, 0);
650 kvm_register_write(vcpu, VCPU_REGS_RBX, 0);
651 kvm_register_write(vcpu, VCPU_REGS_RCX, 0);
652 kvm_register_write(vcpu, VCPU_REGS_RDX, 0);
653 best = kvm_find_cpuid_entry(vcpu, function, index); 649 best = kvm_find_cpuid_entry(vcpu, function, index);
654 650
655 if (!best) 651 if (!best)
656 best = check_cpuid_limit(vcpu, function, index); 652 best = check_cpuid_limit(vcpu, function, index);
657 653
658 if (best) { 654 if (best) {
659 kvm_register_write(vcpu, VCPU_REGS_RAX, best->eax); 655 *eax = best->eax;
660 kvm_register_write(vcpu, VCPU_REGS_RBX, best->ebx); 656 *ebx = best->ebx;
661 kvm_register_write(vcpu, VCPU_REGS_RCX, best->ecx); 657 *ecx = best->ecx;
662 kvm_register_write(vcpu, VCPU_REGS_RDX, best->edx); 658 *edx = best->edx;
663 } 659 } else
660 *eax = *ebx = *ecx = *edx = 0;
661}
662
663void kvm_emulate_cpuid(struct kvm_vcpu *vcpu)
664{
665 u32 function, eax, ebx, ecx, edx;
666
667 function = eax = kvm_register_read(vcpu, VCPU_REGS_RAX);
668 ecx = kvm_register_read(vcpu, VCPU_REGS_RCX);
669 kvm_cpuid(vcpu, &eax, &ebx, &ecx, &edx);
670 kvm_register_write(vcpu, VCPU_REGS_RAX, eax);
671 kvm_register_write(vcpu, VCPU_REGS_RBX, ebx);
672 kvm_register_write(vcpu, VCPU_REGS_RCX, ecx);
673 kvm_register_write(vcpu, VCPU_REGS_RDX, edx);
664 kvm_x86_ops->skip_emulated_instruction(vcpu); 674 kvm_x86_ops->skip_emulated_instruction(vcpu);
665 trace_kvm_cpuid(function, 675 trace_kvm_cpuid(function, eax, ebx, ecx, edx);
666 kvm_register_read(vcpu, VCPU_REGS_RAX),
667 kvm_register_read(vcpu, VCPU_REGS_RBX),
668 kvm_register_read(vcpu, VCPU_REGS_RCX),
669 kvm_register_read(vcpu, VCPU_REGS_RDX));
670} 676}
671EXPORT_SYMBOL_GPL(kvm_emulate_cpuid); 677EXPORT_SYMBOL_GPL(kvm_emulate_cpuid);
diff --git a/arch/x86/kvm/cpuid.h b/arch/x86/kvm/cpuid.h
index 26d1fb437eb..a10e4601685 100644
--- a/arch/x86/kvm/cpuid.h
+++ b/arch/x86/kvm/cpuid.h
@@ -17,6 +17,7 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
17int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu, 17int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
18 struct kvm_cpuid2 *cpuid, 18 struct kvm_cpuid2 *cpuid,
19 struct kvm_cpuid_entry2 __user *entries); 19 struct kvm_cpuid_entry2 __user *entries);
20void kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx, u32 *ecx, u32 *edx);
20 21
21 22
22static inline bool guest_cpuid_has_xsave(struct kvm_vcpu *vcpu) 23static inline bool guest_cpuid_has_xsave(struct kvm_vcpu *vcpu)
@@ -51,4 +52,12 @@ static inline bool guest_cpuid_has_osvw(struct kvm_vcpu *vcpu)
51 return best && (best->ecx & bit(X86_FEATURE_OSVW)); 52 return best && (best->ecx & bit(X86_FEATURE_OSVW));
52} 53}
53 54
55static inline bool guest_cpuid_has_pcid(struct kvm_vcpu *vcpu)
56{
57 struct kvm_cpuid_entry2 *best;
58
59 best = kvm_find_cpuid_entry(vcpu, 1, 0);
60 return best && (best->ecx & bit(X86_FEATURE_PCID));
61}
62
54#endif 63#endif
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index f95d242ee9f..a3b57a27be8 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -433,11 +433,32 @@ static int emulator_check_intercept(struct x86_emulate_ctxt *ctxt,
433 return ctxt->ops->intercept(ctxt, &info, stage); 433 return ctxt->ops->intercept(ctxt, &info, stage);
434} 434}
435 435
436static void assign_masked(ulong *dest, ulong src, ulong mask)
437{
438 *dest = (*dest & ~mask) | (src & mask);
439}
440
436static inline unsigned long ad_mask(struct x86_emulate_ctxt *ctxt) 441static inline unsigned long ad_mask(struct x86_emulate_ctxt *ctxt)
437{ 442{
438 return (1UL << (ctxt->ad_bytes << 3)) - 1; 443 return (1UL << (ctxt->ad_bytes << 3)) - 1;
439} 444}
440 445
446static ulong stack_mask(struct x86_emulate_ctxt *ctxt)
447{
448 u16 sel;
449 struct desc_struct ss;
450
451 if (ctxt->mode == X86EMUL_MODE_PROT64)
452 return ~0UL;
453 ctxt->ops->get_segment(ctxt, &sel, &ss, NULL, VCPU_SREG_SS);
454 return ~0U >> ((ss.d ^ 1) * 16); /* d=0: 0xffff; d=1: 0xffffffff */
455}
456
457static int stack_size(struct x86_emulate_ctxt *ctxt)
458{
459 return (__fls(stack_mask(ctxt)) + 1) >> 3;
460}
461
441/* Access/update address held in a register, based on addressing mode. */ 462/* Access/update address held in a register, based on addressing mode. */
442static inline unsigned long 463static inline unsigned long
443address_mask(struct x86_emulate_ctxt *ctxt, unsigned long reg) 464address_mask(struct x86_emulate_ctxt *ctxt, unsigned long reg)
@@ -454,13 +475,26 @@ register_address(struct x86_emulate_ctxt *ctxt, unsigned long reg)
454 return address_mask(ctxt, reg); 475 return address_mask(ctxt, reg);
455} 476}
456 477
478static void masked_increment(ulong *reg, ulong mask, int inc)
479{
480 assign_masked(reg, *reg + inc, mask);
481}
482
457static inline void 483static inline void
458register_address_increment(struct x86_emulate_ctxt *ctxt, unsigned long *reg, int inc) 484register_address_increment(struct x86_emulate_ctxt *ctxt, unsigned long *reg, int inc)
459{ 485{
486 ulong mask;
487
460 if (ctxt->ad_bytes == sizeof(unsigned long)) 488 if (ctxt->ad_bytes == sizeof(unsigned long))
461 *reg += inc; 489 mask = ~0UL;
462 else 490 else
463 *reg = (*reg & ~ad_mask(ctxt)) | ((*reg + inc) & ad_mask(ctxt)); 491 mask = ad_mask(ctxt);
492 masked_increment(reg, mask, inc);
493}
494
495static void rsp_increment(struct x86_emulate_ctxt *ctxt, int inc)
496{
497 masked_increment(&ctxt->regs[VCPU_REGS_RSP], stack_mask(ctxt), inc);
464} 498}
465 499
466static inline void jmp_rel(struct x86_emulate_ctxt *ctxt, int rel) 500static inline void jmp_rel(struct x86_emulate_ctxt *ctxt, int rel)
@@ -958,6 +992,12 @@ static void decode_register_operand(struct x86_emulate_ctxt *ctxt,
958 op->orig_val = op->val; 992 op->orig_val = op->val;
959} 993}
960 994
995static void adjust_modrm_seg(struct x86_emulate_ctxt *ctxt, int base_reg)
996{
997 if (base_reg == VCPU_REGS_RSP || base_reg == VCPU_REGS_RBP)
998 ctxt->modrm_seg = VCPU_SREG_SS;
999}
1000
961static int decode_modrm(struct x86_emulate_ctxt *ctxt, 1001static int decode_modrm(struct x86_emulate_ctxt *ctxt,
962 struct operand *op) 1002 struct operand *op)
963{ 1003{
@@ -1061,15 +1101,20 @@ static int decode_modrm(struct x86_emulate_ctxt *ctxt,
1061 1101
1062 if ((base_reg & 7) == 5 && ctxt->modrm_mod == 0) 1102 if ((base_reg & 7) == 5 && ctxt->modrm_mod == 0)
1063 modrm_ea += insn_fetch(s32, ctxt); 1103 modrm_ea += insn_fetch(s32, ctxt);
1064 else 1104 else {
1065 modrm_ea += ctxt->regs[base_reg]; 1105 modrm_ea += ctxt->regs[base_reg];
1106 adjust_modrm_seg(ctxt, base_reg);
1107 }
1066 if (index_reg != 4) 1108 if (index_reg != 4)
1067 modrm_ea += ctxt->regs[index_reg] << scale; 1109 modrm_ea += ctxt->regs[index_reg] << scale;
1068 } else if ((ctxt->modrm_rm & 7) == 5 && ctxt->modrm_mod == 0) { 1110 } else if ((ctxt->modrm_rm & 7) == 5 && ctxt->modrm_mod == 0) {
1069 if (ctxt->mode == X86EMUL_MODE_PROT64) 1111 if (ctxt->mode == X86EMUL_MODE_PROT64)
1070 ctxt->rip_relative = 1; 1112 ctxt->rip_relative = 1;
1071 } else 1113 } else {
1072 modrm_ea += ctxt->regs[ctxt->modrm_rm]; 1114 base_reg = ctxt->modrm_rm;
1115 modrm_ea += ctxt->regs[base_reg];
1116 adjust_modrm_seg(ctxt, base_reg);
1117 }
1073 switch (ctxt->modrm_mod) { 1118 switch (ctxt->modrm_mod) {
1074 case 0: 1119 case 0:
1075 if (ctxt->modrm_rm == 5) 1120 if (ctxt->modrm_rm == 5)
@@ -1264,7 +1309,8 @@ static void get_descriptor_table_ptr(struct x86_emulate_ctxt *ctxt,
1264 1309
1265/* allowed just for 8 bytes segments */ 1310/* allowed just for 8 bytes segments */
1266static int read_segment_descriptor(struct x86_emulate_ctxt *ctxt, 1311static int read_segment_descriptor(struct x86_emulate_ctxt *ctxt,
1267 u16 selector, struct desc_struct *desc) 1312 u16 selector, struct desc_struct *desc,
1313 ulong *desc_addr_p)
1268{ 1314{
1269 struct desc_ptr dt; 1315 struct desc_ptr dt;
1270 u16 index = selector >> 3; 1316 u16 index = selector >> 3;
@@ -1275,7 +1321,7 @@ static int read_segment_descriptor(struct x86_emulate_ctxt *ctxt,
1275 if (dt.size < index * 8 + 7) 1321 if (dt.size < index * 8 + 7)
1276 return emulate_gp(ctxt, selector & 0xfffc); 1322 return emulate_gp(ctxt, selector & 0xfffc);
1277 1323
1278 addr = dt.address + index * 8; 1324 *desc_addr_p = addr = dt.address + index * 8;
1279 return ctxt->ops->read_std(ctxt, addr, desc, sizeof *desc, 1325 return ctxt->ops->read_std(ctxt, addr, desc, sizeof *desc,
1280 &ctxt->exception); 1326 &ctxt->exception);
1281} 1327}
@@ -1302,11 +1348,12 @@ static int write_segment_descriptor(struct x86_emulate_ctxt *ctxt,
1302static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt, 1348static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
1303 u16 selector, int seg) 1349 u16 selector, int seg)
1304{ 1350{
1305 struct desc_struct seg_desc; 1351 struct desc_struct seg_desc, old_desc;
1306 u8 dpl, rpl, cpl; 1352 u8 dpl, rpl, cpl;
1307 unsigned err_vec = GP_VECTOR; 1353 unsigned err_vec = GP_VECTOR;
1308 u32 err_code = 0; 1354 u32 err_code = 0;
1309 bool null_selector = !(selector & ~0x3); /* 0000-0003 are null */ 1355 bool null_selector = !(selector & ~0x3); /* 0000-0003 are null */
1356 ulong desc_addr;
1310 int ret; 1357 int ret;
1311 1358
1312 memset(&seg_desc, 0, sizeof seg_desc); 1359 memset(&seg_desc, 0, sizeof seg_desc);
@@ -1324,8 +1371,14 @@ static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
1324 goto load; 1371 goto load;
1325 } 1372 }
1326 1373
1327 /* NULL selector is not valid for TR, CS and SS */ 1374 rpl = selector & 3;
1328 if ((seg == VCPU_SREG_CS || seg == VCPU_SREG_SS || seg == VCPU_SREG_TR) 1375 cpl = ctxt->ops->cpl(ctxt);
1376
1377 /* NULL selector is not valid for TR, CS and SS (except for long mode) */
1378 if ((seg == VCPU_SREG_CS
1379 || (seg == VCPU_SREG_SS
1380 && (ctxt->mode != X86EMUL_MODE_PROT64 || rpl != cpl))
1381 || seg == VCPU_SREG_TR)
1329 && null_selector) 1382 && null_selector)
1330 goto exception; 1383 goto exception;
1331 1384
@@ -1336,7 +1389,7 @@ static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
1336 if (null_selector) /* for NULL selector skip all following checks */ 1389 if (null_selector) /* for NULL selector skip all following checks */
1337 goto load; 1390 goto load;
1338 1391
1339 ret = read_segment_descriptor(ctxt, selector, &seg_desc); 1392 ret = read_segment_descriptor(ctxt, selector, &seg_desc, &desc_addr);
1340 if (ret != X86EMUL_CONTINUE) 1393 if (ret != X86EMUL_CONTINUE)
1341 return ret; 1394 return ret;
1342 1395
@@ -1352,9 +1405,7 @@ static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
1352 goto exception; 1405 goto exception;
1353 } 1406 }
1354 1407
1355 rpl = selector & 3;
1356 dpl = seg_desc.dpl; 1408 dpl = seg_desc.dpl;
1357 cpl = ctxt->ops->cpl(ctxt);
1358 1409
1359 switch (seg) { 1410 switch (seg) {
1360 case VCPU_SREG_SS: 1411 case VCPU_SREG_SS:
@@ -1384,6 +1435,12 @@ static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
1384 case VCPU_SREG_TR: 1435 case VCPU_SREG_TR:
1385 if (seg_desc.s || (seg_desc.type != 1 && seg_desc.type != 9)) 1436 if (seg_desc.s || (seg_desc.type != 1 && seg_desc.type != 9))
1386 goto exception; 1437 goto exception;
1438 old_desc = seg_desc;
1439 seg_desc.type |= 2; /* busy */
1440 ret = ctxt->ops->cmpxchg_emulated(ctxt, desc_addr, &old_desc, &seg_desc,
1441 sizeof(seg_desc), &ctxt->exception);
1442 if (ret != X86EMUL_CONTINUE)
1443 return ret;
1387 break; 1444 break;
1388 case VCPU_SREG_LDTR: 1445 case VCPU_SREG_LDTR:
1389 if (seg_desc.s || seg_desc.type != 2) 1446 if (seg_desc.s || seg_desc.type != 2)
@@ -1474,17 +1531,22 @@ static int writeback(struct x86_emulate_ctxt *ctxt)
1474 return X86EMUL_CONTINUE; 1531 return X86EMUL_CONTINUE;
1475} 1532}
1476 1533
1477static int em_push(struct x86_emulate_ctxt *ctxt) 1534static int push(struct x86_emulate_ctxt *ctxt, void *data, int bytes)
1478{ 1535{
1479 struct segmented_address addr; 1536 struct segmented_address addr;
1480 1537
1481 register_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RSP], -ctxt->op_bytes); 1538 rsp_increment(ctxt, -bytes);
1482 addr.ea = register_address(ctxt, ctxt->regs[VCPU_REGS_RSP]); 1539 addr.ea = ctxt->regs[VCPU_REGS_RSP] & stack_mask(ctxt);
1483 addr.seg = VCPU_SREG_SS; 1540 addr.seg = VCPU_SREG_SS;
1484 1541
1542 return segmented_write(ctxt, addr, data, bytes);
1543}
1544
1545static int em_push(struct x86_emulate_ctxt *ctxt)
1546{
1485 /* Disable writeback. */ 1547 /* Disable writeback. */
1486 ctxt->dst.type = OP_NONE; 1548 ctxt->dst.type = OP_NONE;
1487 return segmented_write(ctxt, addr, &ctxt->src.val, ctxt->op_bytes); 1549 return push(ctxt, &ctxt->src.val, ctxt->op_bytes);
1488} 1550}
1489 1551
1490static int emulate_pop(struct x86_emulate_ctxt *ctxt, 1552static int emulate_pop(struct x86_emulate_ctxt *ctxt,
@@ -1493,13 +1555,13 @@ static int emulate_pop(struct x86_emulate_ctxt *ctxt,
1493 int rc; 1555 int rc;
1494 struct segmented_address addr; 1556 struct segmented_address addr;
1495 1557
1496 addr.ea = register_address(ctxt, ctxt->regs[VCPU_REGS_RSP]); 1558 addr.ea = ctxt->regs[VCPU_REGS_RSP] & stack_mask(ctxt);
1497 addr.seg = VCPU_SREG_SS; 1559 addr.seg = VCPU_SREG_SS;
1498 rc = segmented_read(ctxt, addr, dest, len); 1560 rc = segmented_read(ctxt, addr, dest, len);
1499 if (rc != X86EMUL_CONTINUE) 1561 if (rc != X86EMUL_CONTINUE)
1500 return rc; 1562 return rc;
1501 1563
1502 register_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RSP], len); 1564 rsp_increment(ctxt, len);
1503 return rc; 1565 return rc;
1504} 1566}
1505 1567
@@ -1556,6 +1618,33 @@ static int em_popf(struct x86_emulate_ctxt *ctxt)
1556 return emulate_popf(ctxt, &ctxt->dst.val, ctxt->op_bytes); 1618 return emulate_popf(ctxt, &ctxt->dst.val, ctxt->op_bytes);
1557} 1619}
1558 1620
1621static int em_enter(struct x86_emulate_ctxt *ctxt)
1622{
1623 int rc;
1624 unsigned frame_size = ctxt->src.val;
1625 unsigned nesting_level = ctxt->src2.val & 31;
1626
1627 if (nesting_level)
1628 return X86EMUL_UNHANDLEABLE;
1629
1630 rc = push(ctxt, &ctxt->regs[VCPU_REGS_RBP], stack_size(ctxt));
1631 if (rc != X86EMUL_CONTINUE)
1632 return rc;
1633 assign_masked(&ctxt->regs[VCPU_REGS_RBP], ctxt->regs[VCPU_REGS_RSP],
1634 stack_mask(ctxt));
1635 assign_masked(&ctxt->regs[VCPU_REGS_RSP],
1636 ctxt->regs[VCPU_REGS_RSP] - frame_size,
1637 stack_mask(ctxt));
1638 return X86EMUL_CONTINUE;
1639}
1640
1641static int em_leave(struct x86_emulate_ctxt *ctxt)
1642{
1643 assign_masked(&ctxt->regs[VCPU_REGS_RSP], ctxt->regs[VCPU_REGS_RBP],
1644 stack_mask(ctxt));
1645 return emulate_pop(ctxt, &ctxt->regs[VCPU_REGS_RBP], ctxt->op_bytes);
1646}
1647
1559static int em_push_sreg(struct x86_emulate_ctxt *ctxt) 1648static int em_push_sreg(struct x86_emulate_ctxt *ctxt)
1560{ 1649{
1561 int seg = ctxt->src2.val; 1650 int seg = ctxt->src2.val;
@@ -1612,8 +1701,7 @@ static int em_popa(struct x86_emulate_ctxt *ctxt)
1612 1701
1613 while (reg >= VCPU_REGS_RAX) { 1702 while (reg >= VCPU_REGS_RAX) {
1614 if (reg == VCPU_REGS_RSP) { 1703 if (reg == VCPU_REGS_RSP) {
1615 register_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RSP], 1704 rsp_increment(ctxt, ctxt->op_bytes);
1616 ctxt->op_bytes);
1617 --reg; 1705 --reg;
1618 } 1706 }
1619 1707
@@ -1993,8 +2081,8 @@ static bool vendor_intel(struct x86_emulate_ctxt *ctxt)
1993 u32 eax, ebx, ecx, edx; 2081 u32 eax, ebx, ecx, edx;
1994 2082
1995 eax = ecx = 0; 2083 eax = ecx = 0;
1996 return ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx) 2084 ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx);
1997 && ebx == X86EMUL_CPUID_VENDOR_GenuineIntel_ebx 2085 return ebx == X86EMUL_CPUID_VENDOR_GenuineIntel_ebx
1998 && ecx == X86EMUL_CPUID_VENDOR_GenuineIntel_ecx 2086 && ecx == X86EMUL_CPUID_VENDOR_GenuineIntel_ecx
1999 && edx == X86EMUL_CPUID_VENDOR_GenuineIntel_edx; 2087 && edx == X86EMUL_CPUID_VENDOR_GenuineIntel_edx;
2000} 2088}
@@ -2013,32 +2101,31 @@ static bool em_syscall_is_enabled(struct x86_emulate_ctxt *ctxt)
2013 2101
2014 eax = 0x00000000; 2102 eax = 0x00000000;
2015 ecx = 0x00000000; 2103 ecx = 0x00000000;
2016 if (ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx)) { 2104 ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx);
2017 /* 2105 /*
2018 * Intel ("GenuineIntel") 2106 * Intel ("GenuineIntel")
2019 * remark: Intel CPUs only support "syscall" in 64bit 2107 * remark: Intel CPUs only support "syscall" in 64bit
2020 * longmode. Also an 64bit guest with a 2108 * longmode. Also an 64bit guest with a
2021 * 32bit compat-app running will #UD !! While this 2109 * 32bit compat-app running will #UD !! While this
2022 * behaviour can be fixed (by emulating) into AMD 2110 * behaviour can be fixed (by emulating) into AMD
2023 * response - CPUs of AMD can't behave like Intel. 2111 * response - CPUs of AMD can't behave like Intel.
2024 */ 2112 */
2025 if (ebx == X86EMUL_CPUID_VENDOR_GenuineIntel_ebx && 2113 if (ebx == X86EMUL_CPUID_VENDOR_GenuineIntel_ebx &&
2026 ecx == X86EMUL_CPUID_VENDOR_GenuineIntel_ecx && 2114 ecx == X86EMUL_CPUID_VENDOR_GenuineIntel_ecx &&
2027 edx == X86EMUL_CPUID_VENDOR_GenuineIntel_edx) 2115 edx == X86EMUL_CPUID_VENDOR_GenuineIntel_edx)
2028 return false; 2116 return false;
2029 2117
2030 /* AMD ("AuthenticAMD") */ 2118 /* AMD ("AuthenticAMD") */
2031 if (ebx == X86EMUL_CPUID_VENDOR_AuthenticAMD_ebx && 2119 if (ebx == X86EMUL_CPUID_VENDOR_AuthenticAMD_ebx &&
2032 ecx == X86EMUL_CPUID_VENDOR_AuthenticAMD_ecx && 2120 ecx == X86EMUL_CPUID_VENDOR_AuthenticAMD_ecx &&
2033 edx == X86EMUL_CPUID_VENDOR_AuthenticAMD_edx) 2121 edx == X86EMUL_CPUID_VENDOR_AuthenticAMD_edx)
2034 return true; 2122 return true;
2035 2123
2036 /* AMD ("AMDisbetter!") */ 2124 /* AMD ("AMDisbetter!") */
2037 if (ebx == X86EMUL_CPUID_VENDOR_AMDisbetterI_ebx && 2125 if (ebx == X86EMUL_CPUID_VENDOR_AMDisbetterI_ebx &&
2038 ecx == X86EMUL_CPUID_VENDOR_AMDisbetterI_ecx && 2126 ecx == X86EMUL_CPUID_VENDOR_AMDisbetterI_ecx &&
2039 edx == X86EMUL_CPUID_VENDOR_AMDisbetterI_edx) 2127 edx == X86EMUL_CPUID_VENDOR_AMDisbetterI_edx)
2040 return true; 2128 return true;
2041 }
2042 2129
2043 /* default: (not Intel, not AMD), apply Intel's stricter rules... */ 2130 /* default: (not Intel, not AMD), apply Intel's stricter rules... */
2044 return false; 2131 return false;
@@ -2547,13 +2634,14 @@ static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt,
2547 ulong old_tss_base = 2634 ulong old_tss_base =
2548 ops->get_cached_segment_base(ctxt, VCPU_SREG_TR); 2635 ops->get_cached_segment_base(ctxt, VCPU_SREG_TR);
2549 u32 desc_limit; 2636 u32 desc_limit;
2637 ulong desc_addr;
2550 2638
2551 /* FIXME: old_tss_base == ~0 ? */ 2639 /* FIXME: old_tss_base == ~0 ? */
2552 2640
2553 ret = read_segment_descriptor(ctxt, tss_selector, &next_tss_desc); 2641 ret = read_segment_descriptor(ctxt, tss_selector, &next_tss_desc, &desc_addr);
2554 if (ret != X86EMUL_CONTINUE) 2642 if (ret != X86EMUL_CONTINUE)
2555 return ret; 2643 return ret;
2556 ret = read_segment_descriptor(ctxt, old_tss_sel, &curr_tss_desc); 2644 ret = read_segment_descriptor(ctxt, old_tss_sel, &curr_tss_desc, &desc_addr);
2557 if (ret != X86EMUL_CONTINUE) 2645 if (ret != X86EMUL_CONTINUE)
2558 return ret; 2646 return ret;
2559 2647
@@ -2749,7 +2837,7 @@ static int em_ret_near_imm(struct x86_emulate_ctxt *ctxt)
2749 rc = emulate_pop(ctxt, &ctxt->dst.val, ctxt->op_bytes); 2837 rc = emulate_pop(ctxt, &ctxt->dst.val, ctxt->op_bytes);
2750 if (rc != X86EMUL_CONTINUE) 2838 if (rc != X86EMUL_CONTINUE)
2751 return rc; 2839 return rc;
2752 register_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RSP], ctxt->src.val); 2840 rsp_increment(ctxt, ctxt->src.val);
2753 return X86EMUL_CONTINUE; 2841 return X86EMUL_CONTINUE;
2754} 2842}
2755 2843
@@ -2948,6 +3036,24 @@ static int em_mov_sreg_rm(struct x86_emulate_ctxt *ctxt)
2948 return load_segment_descriptor(ctxt, sel, ctxt->modrm_reg); 3036 return load_segment_descriptor(ctxt, sel, ctxt->modrm_reg);
2949} 3037}
2950 3038
3039static int em_lldt(struct x86_emulate_ctxt *ctxt)
3040{
3041 u16 sel = ctxt->src.val;
3042
3043 /* Disable writeback. */
3044 ctxt->dst.type = OP_NONE;
3045 return load_segment_descriptor(ctxt, sel, VCPU_SREG_LDTR);
3046}
3047
3048static int em_ltr(struct x86_emulate_ctxt *ctxt)
3049{
3050 u16 sel = ctxt->src.val;
3051
3052 /* Disable writeback. */
3053 ctxt->dst.type = OP_NONE;
3054 return load_segment_descriptor(ctxt, sel, VCPU_SREG_TR);
3055}
3056
2951static int em_invlpg(struct x86_emulate_ctxt *ctxt) 3057static int em_invlpg(struct x86_emulate_ctxt *ctxt)
2952{ 3058{
2953 int rc; 3059 int rc;
@@ -2989,11 +3095,42 @@ static int em_vmcall(struct x86_emulate_ctxt *ctxt)
2989 return X86EMUL_CONTINUE; 3095 return X86EMUL_CONTINUE;
2990} 3096}
2991 3097
3098static int emulate_store_desc_ptr(struct x86_emulate_ctxt *ctxt,
3099 void (*get)(struct x86_emulate_ctxt *ctxt,
3100 struct desc_ptr *ptr))
3101{
3102 struct desc_ptr desc_ptr;
3103
3104 if (ctxt->mode == X86EMUL_MODE_PROT64)
3105 ctxt->op_bytes = 8;
3106 get(ctxt, &desc_ptr);
3107 if (ctxt->op_bytes == 2) {
3108 ctxt->op_bytes = 4;
3109 desc_ptr.address &= 0x00ffffff;
3110 }
3111 /* Disable writeback. */
3112 ctxt->dst.type = OP_NONE;
3113 return segmented_write(ctxt, ctxt->dst.addr.mem,
3114 &desc_ptr, 2 + ctxt->op_bytes);
3115}
3116
3117static int em_sgdt(struct x86_emulate_ctxt *ctxt)
3118{
3119 return emulate_store_desc_ptr(ctxt, ctxt->ops->get_gdt);
3120}
3121
3122static int em_sidt(struct x86_emulate_ctxt *ctxt)
3123{
3124 return emulate_store_desc_ptr(ctxt, ctxt->ops->get_idt);
3125}
3126
2992static int em_lgdt(struct x86_emulate_ctxt *ctxt) 3127static int em_lgdt(struct x86_emulate_ctxt *ctxt)
2993{ 3128{
2994 struct desc_ptr desc_ptr; 3129 struct desc_ptr desc_ptr;
2995 int rc; 3130 int rc;
2996 3131
3132 if (ctxt->mode == X86EMUL_MODE_PROT64)
3133 ctxt->op_bytes = 8;
2997 rc = read_descriptor(ctxt, ctxt->src.addr.mem, 3134 rc = read_descriptor(ctxt, ctxt->src.addr.mem,
2998 &desc_ptr.size, &desc_ptr.address, 3135 &desc_ptr.size, &desc_ptr.address,
2999 ctxt->op_bytes); 3136 ctxt->op_bytes);
@@ -3021,6 +3158,8 @@ static int em_lidt(struct x86_emulate_ctxt *ctxt)
3021 struct desc_ptr desc_ptr; 3158 struct desc_ptr desc_ptr;
3022 int rc; 3159 int rc;
3023 3160
3161 if (ctxt->mode == X86EMUL_MODE_PROT64)
3162 ctxt->op_bytes = 8;
3024 rc = read_descriptor(ctxt, ctxt->src.addr.mem, 3163 rc = read_descriptor(ctxt, ctxt->src.addr.mem,
3025 &desc_ptr.size, &desc_ptr.address, 3164 &desc_ptr.size, &desc_ptr.address,
3026 ctxt->op_bytes); 3165 ctxt->op_bytes);
@@ -3143,6 +3282,42 @@ static int em_bsr(struct x86_emulate_ctxt *ctxt)
3143 return X86EMUL_CONTINUE; 3282 return X86EMUL_CONTINUE;
3144} 3283}
3145 3284
3285static int em_cpuid(struct x86_emulate_ctxt *ctxt)
3286{
3287 u32 eax, ebx, ecx, edx;
3288
3289 eax = ctxt->regs[VCPU_REGS_RAX];
3290 ecx = ctxt->regs[VCPU_REGS_RCX];
3291 ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx);
3292 ctxt->regs[VCPU_REGS_RAX] = eax;
3293 ctxt->regs[VCPU_REGS_RBX] = ebx;
3294 ctxt->regs[VCPU_REGS_RCX] = ecx;
3295 ctxt->regs[VCPU_REGS_RDX] = edx;
3296 return X86EMUL_CONTINUE;
3297}
3298
3299static int em_lahf(struct x86_emulate_ctxt *ctxt)
3300{
3301 ctxt->regs[VCPU_REGS_RAX] &= ~0xff00UL;
3302 ctxt->regs[VCPU_REGS_RAX] |= (ctxt->eflags & 0xff) << 8;
3303 return X86EMUL_CONTINUE;
3304}
3305
3306static int em_bswap(struct x86_emulate_ctxt *ctxt)
3307{
3308 switch (ctxt->op_bytes) {
3309#ifdef CONFIG_X86_64
3310 case 8:
3311 asm("bswap %0" : "+r"(ctxt->dst.val));
3312 break;
3313#endif
3314 default:
3315 asm("bswap %0" : "+r"(*(u32 *)&ctxt->dst.val));
3316 break;
3317 }
3318 return X86EMUL_CONTINUE;
3319}
3320
3146static bool valid_cr(int nr) 3321static bool valid_cr(int nr)
3147{ 3322{
3148 switch (nr) { 3323 switch (nr) {
@@ -3424,14 +3599,14 @@ static struct opcode group5[] = {
3424static struct opcode group6[] = { 3599static struct opcode group6[] = {
3425 DI(Prot, sldt), 3600 DI(Prot, sldt),
3426 DI(Prot, str), 3601 DI(Prot, str),
3427 DI(Prot | Priv, lldt), 3602 II(Prot | Priv | SrcMem16, em_lldt, lldt),
3428 DI(Prot | Priv, ltr), 3603 II(Prot | Priv | SrcMem16, em_ltr, ltr),
3429 N, N, N, N, 3604 N, N, N, N,
3430}; 3605};
3431 3606
3432static struct group_dual group7 = { { 3607static struct group_dual group7 = { {
3433 DI(Mov | DstMem | Priv, sgdt), 3608 II(Mov | DstMem | Priv, em_sgdt, sgdt),
3434 DI(Mov | DstMem | Priv, sidt), 3609 II(Mov | DstMem | Priv, em_sidt, sidt),
3435 II(SrcMem | Priv, em_lgdt, lgdt), 3610 II(SrcMem | Priv, em_lgdt, lgdt),
3436 II(SrcMem | Priv, em_lidt, lidt), 3611 II(SrcMem | Priv, em_lidt, lidt),
3437 II(SrcNone | DstMem | Mov, em_smsw, smsw), N, 3612 II(SrcNone | DstMem | Mov, em_smsw, smsw), N,
@@ -3538,7 +3713,7 @@ static struct opcode opcode_table[256] = {
3538 D(DstAcc | SrcNone), I(ImplicitOps | SrcAcc, em_cwd), 3713 D(DstAcc | SrcNone), I(ImplicitOps | SrcAcc, em_cwd),
3539 I(SrcImmFAddr | No64, em_call_far), N, 3714 I(SrcImmFAddr | No64, em_call_far), N,
3540 II(ImplicitOps | Stack, em_pushf, pushf), 3715 II(ImplicitOps | Stack, em_pushf, pushf),
3541 II(ImplicitOps | Stack, em_popf, popf), N, N, 3716 II(ImplicitOps | Stack, em_popf, popf), N, I(ImplicitOps, em_lahf),
3542 /* 0xA0 - 0xA7 */ 3717 /* 0xA0 - 0xA7 */
3543 I2bv(DstAcc | SrcMem | Mov | MemAbs, em_mov), 3718 I2bv(DstAcc | SrcMem | Mov | MemAbs, em_mov),
3544 I2bv(DstMem | SrcAcc | Mov | MemAbs | PageTable, em_mov), 3719 I2bv(DstMem | SrcAcc | Mov | MemAbs | PageTable, em_mov),
@@ -3561,7 +3736,8 @@ static struct opcode opcode_table[256] = {
3561 I(DstReg | SrcMemFAddr | ModRM | No64 | Src2DS, em_lseg), 3736 I(DstReg | SrcMemFAddr | ModRM | No64 | Src2DS, em_lseg),
3562 G(ByteOp, group11), G(0, group11), 3737 G(ByteOp, group11), G(0, group11),
3563 /* 0xC8 - 0xCF */ 3738 /* 0xC8 - 0xCF */
3564 N, N, N, I(ImplicitOps | Stack, em_ret_far), 3739 I(Stack | SrcImmU16 | Src2ImmByte, em_enter), I(Stack, em_leave),
3740 N, I(ImplicitOps | Stack, em_ret_far),
3565 D(ImplicitOps), DI(SrcImmByte, intn), 3741 D(ImplicitOps), DI(SrcImmByte, intn),
3566 D(ImplicitOps | No64), II(ImplicitOps, em_iret, iret), 3742 D(ImplicitOps | No64), II(ImplicitOps, em_iret, iret),
3567 /* 0xD0 - 0xD7 */ 3743 /* 0xD0 - 0xD7 */
@@ -3635,7 +3811,7 @@ static struct opcode twobyte_table[256] = {
3635 X16(D(ByteOp | DstMem | SrcNone | ModRM| Mov)), 3811 X16(D(ByteOp | DstMem | SrcNone | ModRM| Mov)),
3636 /* 0xA0 - 0xA7 */ 3812 /* 0xA0 - 0xA7 */
3637 I(Stack | Src2FS, em_push_sreg), I(Stack | Src2FS, em_pop_sreg), 3813 I(Stack | Src2FS, em_push_sreg), I(Stack | Src2FS, em_pop_sreg),
3638 DI(ImplicitOps, cpuid), I(DstMem | SrcReg | ModRM | BitOp, em_bt), 3814 II(ImplicitOps, em_cpuid, cpuid), I(DstMem | SrcReg | ModRM | BitOp, em_bt),
3639 D(DstMem | SrcReg | Src2ImmByte | ModRM), 3815 D(DstMem | SrcReg | Src2ImmByte | ModRM),
3640 D(DstMem | SrcReg | Src2CL | ModRM), N, N, 3816 D(DstMem | SrcReg | Src2CL | ModRM), N, N,
3641 /* 0xA8 - 0xAF */ 3817 /* 0xA8 - 0xAF */
@@ -3658,11 +3834,12 @@ static struct opcode twobyte_table[256] = {
3658 I(DstMem | SrcReg | ModRM | BitOp | Lock | PageTable, em_btc), 3834 I(DstMem | SrcReg | ModRM | BitOp | Lock | PageTable, em_btc),
3659 I(DstReg | SrcMem | ModRM, em_bsf), I(DstReg | SrcMem | ModRM, em_bsr), 3835 I(DstReg | SrcMem | ModRM, em_bsf), I(DstReg | SrcMem | ModRM, em_bsr),
3660 D(DstReg | SrcMem8 | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov), 3836 D(DstReg | SrcMem8 | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov),
3661 /* 0xC0 - 0xCF */ 3837 /* 0xC0 - 0xC7 */
3662 D2bv(DstMem | SrcReg | ModRM | Lock), 3838 D2bv(DstMem | SrcReg | ModRM | Lock),
3663 N, D(DstMem | SrcReg | ModRM | Mov), 3839 N, D(DstMem | SrcReg | ModRM | Mov),
3664 N, N, N, GD(0, &group9), 3840 N, N, N, GD(0, &group9),
3665 N, N, N, N, N, N, N, N, 3841 /* 0xC8 - 0xCF */
3842 X8(I(DstReg, em_bswap)),
3666 /* 0xD0 - 0xDF */ 3843 /* 0xD0 - 0xDF */
3667 N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, 3844 N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N,
3668 /* 0xE0 - 0xEF */ 3845 /* 0xE0 - 0xEF */
@@ -4426,12 +4603,12 @@ twobyte_insn:
4426 break; 4603 break;
4427 case 0xb6 ... 0xb7: /* movzx */ 4604 case 0xb6 ... 0xb7: /* movzx */
4428 ctxt->dst.bytes = ctxt->op_bytes; 4605 ctxt->dst.bytes = ctxt->op_bytes;
4429 ctxt->dst.val = (ctxt->d & ByteOp) ? (u8) ctxt->src.val 4606 ctxt->dst.val = (ctxt->src.bytes == 1) ? (u8) ctxt->src.val
4430 : (u16) ctxt->src.val; 4607 : (u16) ctxt->src.val;
4431 break; 4608 break;
4432 case 0xbe ... 0xbf: /* movsx */ 4609 case 0xbe ... 0xbf: /* movsx */
4433 ctxt->dst.bytes = ctxt->op_bytes; 4610 ctxt->dst.bytes = ctxt->op_bytes;
4434 ctxt->dst.val = (ctxt->d & ByteOp) ? (s8) ctxt->src.val : 4611 ctxt->dst.val = (ctxt->src.bytes == 1) ? (s8) ctxt->src.val :
4435 (s16) ctxt->src.val; 4612 (s16) ctxt->src.val;
4436 break; 4613 break;
4437 case 0xc0 ... 0xc1: /* xadd */ 4614 case 0xc0 ... 0xc1: /* xadd */
diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index 81cf4fa4a2b..e498b18f010 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -188,14 +188,15 @@ void kvm_pic_update_irq(struct kvm_pic *s)
188 pic_unlock(s); 188 pic_unlock(s);
189} 189}
190 190
191int kvm_pic_set_irq(void *opaque, int irq, int level) 191int kvm_pic_set_irq(struct kvm_pic *s, int irq, int irq_source_id, int level)
192{ 192{
193 struct kvm_pic *s = opaque;
194 int ret = -1; 193 int ret = -1;
195 194
196 pic_lock(s); 195 pic_lock(s);
197 if (irq >= 0 && irq < PIC_NUM_PINS) { 196 if (irq >= 0 && irq < PIC_NUM_PINS) {
198 ret = pic_set_irq1(&s->pics[irq >> 3], irq & 7, level); 197 int irq_level = __kvm_irq_line_state(&s->irq_states[irq],
198 irq_source_id, level);
199 ret = pic_set_irq1(&s->pics[irq >> 3], irq & 7, irq_level);
199 pic_update_irq(s); 200 pic_update_irq(s);
200 trace_kvm_pic_set_irq(irq >> 3, irq & 7, s->pics[irq >> 3].elcr, 201 trace_kvm_pic_set_irq(irq >> 3, irq & 7, s->pics[irq >> 3].elcr,
201 s->pics[irq >> 3].imr, ret == 0); 202 s->pics[irq >> 3].imr, ret == 0);
@@ -205,6 +206,16 @@ int kvm_pic_set_irq(void *opaque, int irq, int level)
205 return ret; 206 return ret;
206} 207}
207 208
209void kvm_pic_clear_all(struct kvm_pic *s, int irq_source_id)
210{
211 int i;
212
213 pic_lock(s);
214 for (i = 0; i < PIC_NUM_PINS; i++)
215 __clear_bit(irq_source_id, &s->irq_states[i]);
216 pic_unlock(s);
217}
218
208/* 219/*
209 * acknowledge interrupt 'irq' 220 * acknowledge interrupt 'irq'
210 */ 221 */
@@ -305,6 +316,11 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
305 addr &= 1; 316 addr &= 1;
306 if (addr == 0) { 317 if (addr == 0) {
307 if (val & 0x10) { 318 if (val & 0x10) {
319 u8 edge_irr = s->irr & ~s->elcr;
320 int i;
321 bool found;
322 struct kvm_vcpu *vcpu;
323
308 s->init4 = val & 1; 324 s->init4 = val & 1;
309 s->last_irr = 0; 325 s->last_irr = 0;
310 s->irr &= s->elcr; 326 s->irr &= s->elcr;
@@ -322,6 +338,18 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
322 if (val & 0x08) 338 if (val & 0x08)
323 pr_pic_unimpl( 339 pr_pic_unimpl(
324 "level sensitive irq not supported"); 340 "level sensitive irq not supported");
341
342 kvm_for_each_vcpu(i, vcpu, s->pics_state->kvm)
343 if (kvm_apic_accept_pic_intr(vcpu)) {
344 found = true;
345 break;
346 }
347
348
349 if (found)
350 for (irq = 0; irq < PIC_NUM_PINS/2; irq++)
351 if (edge_irr & (1 << irq))
352 pic_clear_isr(s, irq);
325 } else if (val & 0x08) { 353 } else if (val & 0x08) {
326 if (val & 0x04) 354 if (val & 0x04)
327 s->poll = 1; 355 s->poll = 1;
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 93c15743f1e..ce878788a39 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -107,6 +107,16 @@ static inline void apic_clear_vector(int vec, void *bitmap)
107 clear_bit(VEC_POS(vec), (bitmap) + REG_POS(vec)); 107 clear_bit(VEC_POS(vec), (bitmap) + REG_POS(vec));
108} 108}
109 109
110static inline int __apic_test_and_set_vector(int vec, void *bitmap)
111{
112 return __test_and_set_bit(VEC_POS(vec), (bitmap) + REG_POS(vec));
113}
114
115static inline int __apic_test_and_clear_vector(int vec, void *bitmap)
116{
117 return __test_and_clear_bit(VEC_POS(vec), (bitmap) + REG_POS(vec));
118}
119
110static inline int apic_hw_enabled(struct kvm_lapic *apic) 120static inline int apic_hw_enabled(struct kvm_lapic *apic)
111{ 121{
112 return (apic)->vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE; 122 return (apic)->vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE;
@@ -210,6 +220,16 @@ static int find_highest_vector(void *bitmap)
210 return fls(word[word_offset << 2]) - 1 + (word_offset << 5); 220 return fls(word[word_offset << 2]) - 1 + (word_offset << 5);
211} 221}
212 222
223static u8 count_vectors(void *bitmap)
224{
225 u32 *word = bitmap;
226 int word_offset;
227 u8 count = 0;
228 for (word_offset = 0; word_offset < MAX_APIC_VECTOR >> 5; ++word_offset)
229 count += hweight32(word[word_offset << 2]);
230 return count;
231}
232
213static inline int apic_test_and_set_irr(int vec, struct kvm_lapic *apic) 233static inline int apic_test_and_set_irr(int vec, struct kvm_lapic *apic)
214{ 234{
215 apic->irr_pending = true; 235 apic->irr_pending = true;
@@ -242,6 +262,27 @@ static inline void apic_clear_irr(int vec, struct kvm_lapic *apic)
242 apic->irr_pending = true; 262 apic->irr_pending = true;
243} 263}
244 264
265static inline void apic_set_isr(int vec, struct kvm_lapic *apic)
266{
267 if (!__apic_test_and_set_vector(vec, apic->regs + APIC_ISR))
268 ++apic->isr_count;
269 BUG_ON(apic->isr_count > MAX_APIC_VECTOR);
270 /*
271 * ISR (in service register) bit is set when injecting an interrupt.
272 * The highest vector is injected. Thus the latest bit set matches
273 * the highest bit in ISR.
274 */
275 apic->highest_isr_cache = vec;
276}
277
278static inline void apic_clear_isr(int vec, struct kvm_lapic *apic)
279{
280 if (__apic_test_and_clear_vector(vec, apic->regs + APIC_ISR))
281 --apic->isr_count;
282 BUG_ON(apic->isr_count < 0);
283 apic->highest_isr_cache = -1;
284}
285
245int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu) 286int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu)
246{ 287{
247 struct kvm_lapic *apic = vcpu->arch.apic; 288 struct kvm_lapic *apic = vcpu->arch.apic;
@@ -270,9 +311,61 @@ int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq)
270 irq->level, irq->trig_mode); 311 irq->level, irq->trig_mode);
271} 312}
272 313
314static int pv_eoi_put_user(struct kvm_vcpu *vcpu, u8 val)
315{
316
317 return kvm_write_guest_cached(vcpu->kvm, &vcpu->arch.pv_eoi.data, &val,
318 sizeof(val));
319}
320
321static int pv_eoi_get_user(struct kvm_vcpu *vcpu, u8 *val)
322{
323
324 return kvm_read_guest_cached(vcpu->kvm, &vcpu->arch.pv_eoi.data, val,
325 sizeof(*val));
326}
327
328static inline bool pv_eoi_enabled(struct kvm_vcpu *vcpu)
329{
330 return vcpu->arch.pv_eoi.msr_val & KVM_MSR_ENABLED;
331}
332
333static bool pv_eoi_get_pending(struct kvm_vcpu *vcpu)
334{
335 u8 val;
336 if (pv_eoi_get_user(vcpu, &val) < 0)
337 apic_debug("Can't read EOI MSR value: 0x%llx\n",
338 (unsigned long long)vcpi->arch.pv_eoi.msr_val);
339 return val & 0x1;
340}
341
342static void pv_eoi_set_pending(struct kvm_vcpu *vcpu)
343{
344 if (pv_eoi_put_user(vcpu, KVM_PV_EOI_ENABLED) < 0) {
345 apic_debug("Can't set EOI MSR value: 0x%llx\n",
346 (unsigned long long)vcpi->arch.pv_eoi.msr_val);
347 return;
348 }
349 __set_bit(KVM_APIC_PV_EOI_PENDING, &vcpu->arch.apic_attention);
350}
351
352static void pv_eoi_clr_pending(struct kvm_vcpu *vcpu)
353{
354 if (pv_eoi_put_user(vcpu, KVM_PV_EOI_DISABLED) < 0) {
355 apic_debug("Can't clear EOI MSR value: 0x%llx\n",
356 (unsigned long long)vcpi->arch.pv_eoi.msr_val);
357 return;
358 }
359 __clear_bit(KVM_APIC_PV_EOI_PENDING, &vcpu->arch.apic_attention);
360}
361
273static inline int apic_find_highest_isr(struct kvm_lapic *apic) 362static inline int apic_find_highest_isr(struct kvm_lapic *apic)
274{ 363{
275 int result; 364 int result;
365 if (!apic->isr_count)
366 return -1;
367 if (likely(apic->highest_isr_cache != -1))
368 return apic->highest_isr_cache;
276 369
277 result = find_highest_vector(apic->regs + APIC_ISR); 370 result = find_highest_vector(apic->regs + APIC_ISR);
278 ASSERT(result == -1 || result >= 16); 371 ASSERT(result == -1 || result >= 16);
@@ -482,17 +575,20 @@ int kvm_apic_compare_prio(struct kvm_vcpu *vcpu1, struct kvm_vcpu *vcpu2)
482 return vcpu1->arch.apic_arb_prio - vcpu2->arch.apic_arb_prio; 575 return vcpu1->arch.apic_arb_prio - vcpu2->arch.apic_arb_prio;
483} 576}
484 577
485static void apic_set_eoi(struct kvm_lapic *apic) 578static int apic_set_eoi(struct kvm_lapic *apic)
486{ 579{
487 int vector = apic_find_highest_isr(apic); 580 int vector = apic_find_highest_isr(apic);
581
582 trace_kvm_eoi(apic, vector);
583
488 /* 584 /*
489 * Not every write EOI will has corresponding ISR, 585 * Not every write EOI will has corresponding ISR,
490 * one example is when Kernel check timer on setup_IO_APIC 586 * one example is when Kernel check timer on setup_IO_APIC
491 */ 587 */
492 if (vector == -1) 588 if (vector == -1)
493 return; 589 return vector;
494 590
495 apic_clear_vector(vector, apic->regs + APIC_ISR); 591 apic_clear_isr(vector, apic);
496 apic_update_ppr(apic); 592 apic_update_ppr(apic);
497 593
498 if (!(apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI) && 594 if (!(apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI) &&
@@ -505,6 +601,7 @@ static void apic_set_eoi(struct kvm_lapic *apic)
505 kvm_ioapic_update_eoi(apic->vcpu->kvm, vector, trigger_mode); 601 kvm_ioapic_update_eoi(apic->vcpu->kvm, vector, trigger_mode);
506 } 602 }
507 kvm_make_request(KVM_REQ_EVENT, apic->vcpu); 603 kvm_make_request(KVM_REQ_EVENT, apic->vcpu);
604 return vector;
508} 605}
509 606
510static void apic_send_ipi(struct kvm_lapic *apic) 607static void apic_send_ipi(struct kvm_lapic *apic)
@@ -1081,10 +1178,13 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu)
1081 apic_set_reg(apic, APIC_TMR + 0x10 * i, 0); 1178 apic_set_reg(apic, APIC_TMR + 0x10 * i, 0);
1082 } 1179 }
1083 apic->irr_pending = false; 1180 apic->irr_pending = false;
1181 apic->isr_count = 0;
1182 apic->highest_isr_cache = -1;
1084 update_divide_count(apic); 1183 update_divide_count(apic);
1085 atomic_set(&apic->lapic_timer.pending, 0); 1184 atomic_set(&apic->lapic_timer.pending, 0);
1086 if (kvm_vcpu_is_bsp(vcpu)) 1185 if (kvm_vcpu_is_bsp(vcpu))
1087 vcpu->arch.apic_base |= MSR_IA32_APICBASE_BSP; 1186 vcpu->arch.apic_base |= MSR_IA32_APICBASE_BSP;
1187 vcpu->arch.pv_eoi.msr_val = 0;
1088 apic_update_ppr(apic); 1188 apic_update_ppr(apic);
1089 1189
1090 vcpu->arch.apic_arb_prio = 0; 1190 vcpu->arch.apic_arb_prio = 0;
@@ -1248,7 +1348,7 @@ int kvm_get_apic_interrupt(struct kvm_vcpu *vcpu)
1248 if (vector == -1) 1348 if (vector == -1)
1249 return -1; 1349 return -1;
1250 1350
1251 apic_set_vector(vector, apic->regs + APIC_ISR); 1351 apic_set_isr(vector, apic);
1252 apic_update_ppr(apic); 1352 apic_update_ppr(apic);
1253 apic_clear_irr(vector, apic); 1353 apic_clear_irr(vector, apic);
1254 return vector; 1354 return vector;
@@ -1267,6 +1367,8 @@ void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu)
1267 update_divide_count(apic); 1367 update_divide_count(apic);
1268 start_apic_timer(apic); 1368 start_apic_timer(apic);
1269 apic->irr_pending = true; 1369 apic->irr_pending = true;
1370 apic->isr_count = count_vectors(apic->regs + APIC_ISR);
1371 apic->highest_isr_cache = -1;
1270 kvm_make_request(KVM_REQ_EVENT, vcpu); 1372 kvm_make_request(KVM_REQ_EVENT, vcpu);
1271} 1373}
1272 1374
@@ -1283,11 +1385,51 @@ void __kvm_migrate_apic_timer(struct kvm_vcpu *vcpu)
1283 hrtimer_start_expires(timer, HRTIMER_MODE_ABS); 1385 hrtimer_start_expires(timer, HRTIMER_MODE_ABS);
1284} 1386}
1285 1387
1388/*
1389 * apic_sync_pv_eoi_from_guest - called on vmexit or cancel interrupt
1390 *
1391 * Detect whether guest triggered PV EOI since the
1392 * last entry. If yes, set EOI on guests's behalf.
1393 * Clear PV EOI in guest memory in any case.
1394 */
1395static void apic_sync_pv_eoi_from_guest(struct kvm_vcpu *vcpu,
1396 struct kvm_lapic *apic)
1397{
1398 bool pending;
1399 int vector;
1400 /*
1401 * PV EOI state is derived from KVM_APIC_PV_EOI_PENDING in host
1402 * and KVM_PV_EOI_ENABLED in guest memory as follows:
1403 *
1404 * KVM_APIC_PV_EOI_PENDING is unset:
1405 * -> host disabled PV EOI.
1406 * KVM_APIC_PV_EOI_PENDING is set, KVM_PV_EOI_ENABLED is set:
1407 * -> host enabled PV EOI, guest did not execute EOI yet.
1408 * KVM_APIC_PV_EOI_PENDING is set, KVM_PV_EOI_ENABLED is unset:
1409 * -> host enabled PV EOI, guest executed EOI.
1410 */
1411 BUG_ON(!pv_eoi_enabled(vcpu));
1412 pending = pv_eoi_get_pending(vcpu);
1413 /*
1414 * Clear pending bit in any case: it will be set again on vmentry.
1415 * While this might not be ideal from performance point of view,
1416 * this makes sure pv eoi is only enabled when we know it's safe.
1417 */
1418 pv_eoi_clr_pending(vcpu);
1419 if (pending)
1420 return;
1421 vector = apic_set_eoi(apic);
1422 trace_kvm_pv_eoi(apic, vector);
1423}
1424
1286void kvm_lapic_sync_from_vapic(struct kvm_vcpu *vcpu) 1425void kvm_lapic_sync_from_vapic(struct kvm_vcpu *vcpu)
1287{ 1426{
1288 u32 data; 1427 u32 data;
1289 void *vapic; 1428 void *vapic;
1290 1429
1430 if (test_bit(KVM_APIC_PV_EOI_PENDING, &vcpu->arch.apic_attention))
1431 apic_sync_pv_eoi_from_guest(vcpu, vcpu->arch.apic);
1432
1291 if (!test_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention)) 1433 if (!test_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention))
1292 return; 1434 return;
1293 1435
@@ -1298,17 +1440,44 @@ void kvm_lapic_sync_from_vapic(struct kvm_vcpu *vcpu)
1298 apic_set_tpr(vcpu->arch.apic, data & 0xff); 1440 apic_set_tpr(vcpu->arch.apic, data & 0xff);
1299} 1441}
1300 1442
1443/*
1444 * apic_sync_pv_eoi_to_guest - called before vmentry
1445 *
1446 * Detect whether it's safe to enable PV EOI and
1447 * if yes do so.
1448 */
1449static void apic_sync_pv_eoi_to_guest(struct kvm_vcpu *vcpu,
1450 struct kvm_lapic *apic)
1451{
1452 if (!pv_eoi_enabled(vcpu) ||
1453 /* IRR set or many bits in ISR: could be nested. */
1454 apic->irr_pending ||
1455 /* Cache not set: could be safe but we don't bother. */
1456 apic->highest_isr_cache == -1 ||
1457 /* Need EOI to update ioapic. */
1458 kvm_ioapic_handles_vector(vcpu->kvm, apic->highest_isr_cache)) {
1459 /*
1460 * PV EOI was disabled by apic_sync_pv_eoi_from_guest
1461 * so we need not do anything here.
1462 */
1463 return;
1464 }
1465
1466 pv_eoi_set_pending(apic->vcpu);
1467}
1468
1301void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu) 1469void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu)
1302{ 1470{
1303 u32 data, tpr; 1471 u32 data, tpr;
1304 int max_irr, max_isr; 1472 int max_irr, max_isr;
1305 struct kvm_lapic *apic; 1473 struct kvm_lapic *apic = vcpu->arch.apic;
1306 void *vapic; 1474 void *vapic;
1307 1475
1476 apic_sync_pv_eoi_to_guest(vcpu, apic);
1477
1308 if (!test_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention)) 1478 if (!test_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention))
1309 return; 1479 return;
1310 1480
1311 apic = vcpu->arch.apic;
1312 tpr = apic_get_reg(apic, APIC_TASKPRI) & 0xff; 1481 tpr = apic_get_reg(apic, APIC_TASKPRI) & 0xff;
1313 max_irr = apic_find_highest_irr(apic); 1482 max_irr = apic_find_highest_irr(apic);
1314 if (max_irr < 0) 1483 if (max_irr < 0)
@@ -1394,3 +1563,16 @@ int kvm_hv_vapic_msr_read(struct kvm_vcpu *vcpu, u32 reg, u64 *data)
1394 1563
1395 return 0; 1564 return 0;
1396} 1565}
1566
1567int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data)
1568{
1569 u64 addr = data & ~KVM_MSR_ENABLED;
1570 if (!IS_ALIGNED(addr, 4))
1571 return 1;
1572
1573 vcpu->arch.pv_eoi.msr_val = data;
1574 if (!pv_eoi_enabled(vcpu))
1575 return 0;
1576 return kvm_gfn_to_hva_cache_init(vcpu->kvm, &vcpu->arch.pv_eoi.data,
1577 addr);
1578}
diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
index 6f4ce2575d0..4af5405ae1e 100644
--- a/arch/x86/kvm/lapic.h
+++ b/arch/x86/kvm/lapic.h
@@ -13,6 +13,15 @@ struct kvm_lapic {
13 u32 divide_count; 13 u32 divide_count;
14 struct kvm_vcpu *vcpu; 14 struct kvm_vcpu *vcpu;
15 bool irr_pending; 15 bool irr_pending;
16 /* Number of bits set in ISR. */
17 s16 isr_count;
18 /* The highest vector set in ISR; if -1 - invalid, must scan ISR. */
19 int highest_isr_cache;
20 /**
21 * APIC register page. The layout matches the register layout seen by
22 * the guest 1:1, because it is accessed by the vmx microcode.
23 * Note: Only one register, the TPR, is used by the microcode.
24 */
16 void *regs; 25 void *regs;
17 gpa_t vapic_addr; 26 gpa_t vapic_addr;
18 struct page *vapic_page; 27 struct page *vapic_page;
@@ -60,4 +69,6 @@ static inline bool kvm_hv_vapic_assist_page_enabled(struct kvm_vcpu *vcpu)
60{ 69{
61 return vcpu->arch.hv_vapic & HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE; 70 return vcpu->arch.hv_vapic & HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE;
62} 71}
72
73int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data);
63#endif 74#endif
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 57e168e27b5..7fbd0d273ea 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -90,7 +90,7 @@ module_param(dbg, bool, 0644);
90 90
91#define PTE_PREFETCH_NUM 8 91#define PTE_PREFETCH_NUM 8
92 92
93#define PT_FIRST_AVAIL_BITS_SHIFT 9 93#define PT_FIRST_AVAIL_BITS_SHIFT 10
94#define PT64_SECOND_AVAIL_BITS_SHIFT 52 94#define PT64_SECOND_AVAIL_BITS_SHIFT 52
95 95
96#define PT64_LEVEL_BITS 9 96#define PT64_LEVEL_BITS 9
@@ -145,7 +145,8 @@ module_param(dbg, bool, 0644);
145#define CREATE_TRACE_POINTS 145#define CREATE_TRACE_POINTS
146#include "mmutrace.h" 146#include "mmutrace.h"
147 147
148#define SPTE_HOST_WRITEABLE (1ULL << PT_FIRST_AVAIL_BITS_SHIFT) 148#define SPTE_HOST_WRITEABLE (1ULL << PT_FIRST_AVAIL_BITS_SHIFT)
149#define SPTE_MMU_WRITEABLE (1ULL << (PT_FIRST_AVAIL_BITS_SHIFT + 1))
149 150
150#define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level) 151#define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level)
151 152
@@ -188,6 +189,7 @@ static u64 __read_mostly shadow_dirty_mask;
188static u64 __read_mostly shadow_mmio_mask; 189static u64 __read_mostly shadow_mmio_mask;
189 190
190static void mmu_spte_set(u64 *sptep, u64 spte); 191static void mmu_spte_set(u64 *sptep, u64 spte);
192static void mmu_free_roots(struct kvm_vcpu *vcpu);
191 193
192void kvm_mmu_set_mmio_spte_mask(u64 mmio_mask) 194void kvm_mmu_set_mmio_spte_mask(u64 mmio_mask)
193{ 195{
@@ -444,8 +446,22 @@ static bool __check_direct_spte_mmio_pf(u64 spte)
444} 446}
445#endif 447#endif
446 448
449static bool spte_is_locklessly_modifiable(u64 spte)
450{
451 return !(~spte & (SPTE_HOST_WRITEABLE | SPTE_MMU_WRITEABLE));
452}
453
447static bool spte_has_volatile_bits(u64 spte) 454static bool spte_has_volatile_bits(u64 spte)
448{ 455{
456 /*
457 * Always atomicly update spte if it can be updated
458 * out of mmu-lock, it can ensure dirty bit is not lost,
459 * also, it can help us to get a stable is_writable_pte()
460 * to ensure tlb flush is not missed.
461 */
462 if (spte_is_locklessly_modifiable(spte))
463 return true;
464
449 if (!shadow_accessed_mask) 465 if (!shadow_accessed_mask)
450 return false; 466 return false;
451 467
@@ -478,34 +494,47 @@ static void mmu_spte_set(u64 *sptep, u64 new_spte)
478 494
479/* Rules for using mmu_spte_update: 495/* Rules for using mmu_spte_update:
480 * Update the state bits, it means the mapped pfn is not changged. 496 * Update the state bits, it means the mapped pfn is not changged.
497 *
498 * Whenever we overwrite a writable spte with a read-only one we
499 * should flush remote TLBs. Otherwise rmap_write_protect
500 * will find a read-only spte, even though the writable spte
501 * might be cached on a CPU's TLB, the return value indicates this
502 * case.
481 */ 503 */
482static void mmu_spte_update(u64 *sptep, u64 new_spte) 504static bool mmu_spte_update(u64 *sptep, u64 new_spte)
483{ 505{
484 u64 mask, old_spte = *sptep; 506 u64 old_spte = *sptep;
507 bool ret = false;
485 508
486 WARN_ON(!is_rmap_spte(new_spte)); 509 WARN_ON(!is_rmap_spte(new_spte));
487 510
488 if (!is_shadow_present_pte(old_spte)) 511 if (!is_shadow_present_pte(old_spte)) {
489 return mmu_spte_set(sptep, new_spte); 512 mmu_spte_set(sptep, new_spte);
490 513 return ret;
491 new_spte |= old_spte & shadow_dirty_mask; 514 }
492
493 mask = shadow_accessed_mask;
494 if (is_writable_pte(old_spte))
495 mask |= shadow_dirty_mask;
496 515
497 if (!spte_has_volatile_bits(old_spte) || (new_spte & mask) == mask) 516 if (!spte_has_volatile_bits(old_spte))
498 __update_clear_spte_fast(sptep, new_spte); 517 __update_clear_spte_fast(sptep, new_spte);
499 else 518 else
500 old_spte = __update_clear_spte_slow(sptep, new_spte); 519 old_spte = __update_clear_spte_slow(sptep, new_spte);
501 520
521 /*
522 * For the spte updated out of mmu-lock is safe, since
523 * we always atomicly update it, see the comments in
524 * spte_has_volatile_bits().
525 */
526 if (is_writable_pte(old_spte) && !is_writable_pte(new_spte))
527 ret = true;
528
502 if (!shadow_accessed_mask) 529 if (!shadow_accessed_mask)
503 return; 530 return ret;
504 531
505 if (spte_is_bit_cleared(old_spte, new_spte, shadow_accessed_mask)) 532 if (spte_is_bit_cleared(old_spte, new_spte, shadow_accessed_mask))
506 kvm_set_pfn_accessed(spte_to_pfn(old_spte)); 533 kvm_set_pfn_accessed(spte_to_pfn(old_spte));
507 if (spte_is_bit_cleared(old_spte, new_spte, shadow_dirty_mask)) 534 if (spte_is_bit_cleared(old_spte, new_spte, shadow_dirty_mask))
508 kvm_set_pfn_dirty(spte_to_pfn(old_spte)); 535 kvm_set_pfn_dirty(spte_to_pfn(old_spte));
536
537 return ret;
509} 538}
510 539
511/* 540/*
@@ -652,8 +681,7 @@ static void mmu_free_memory_caches(struct kvm_vcpu *vcpu)
652 mmu_page_header_cache); 681 mmu_page_header_cache);
653} 682}
654 683
655static void *mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc, 684static void *mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc)
656 size_t size)
657{ 685{
658 void *p; 686 void *p;
659 687
@@ -664,8 +692,7 @@ static void *mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc,
664 692
665static struct pte_list_desc *mmu_alloc_pte_list_desc(struct kvm_vcpu *vcpu) 693static struct pte_list_desc *mmu_alloc_pte_list_desc(struct kvm_vcpu *vcpu)
666{ 694{
667 return mmu_memory_cache_alloc(&vcpu->arch.mmu_pte_list_desc_cache, 695 return mmu_memory_cache_alloc(&vcpu->arch.mmu_pte_list_desc_cache);
668 sizeof(struct pte_list_desc));
669} 696}
670 697
671static void mmu_free_pte_list_desc(struct pte_list_desc *pte_list_desc) 698static void mmu_free_pte_list_desc(struct pte_list_desc *pte_list_desc)
@@ -1051,35 +1078,82 @@ static void drop_spte(struct kvm *kvm, u64 *sptep)
1051 rmap_remove(kvm, sptep); 1078 rmap_remove(kvm, sptep);
1052} 1079}
1053 1080
1054static int __rmap_write_protect(struct kvm *kvm, unsigned long *rmapp, int level) 1081
1082static bool __drop_large_spte(struct kvm *kvm, u64 *sptep)
1083{
1084 if (is_large_pte(*sptep)) {
1085 WARN_ON(page_header(__pa(sptep))->role.level ==
1086 PT_PAGE_TABLE_LEVEL);
1087 drop_spte(kvm, sptep);
1088 --kvm->stat.lpages;
1089 return true;
1090 }
1091
1092 return false;
1093}
1094
1095static void drop_large_spte(struct kvm_vcpu *vcpu, u64 *sptep)
1096{
1097 if (__drop_large_spte(vcpu->kvm, sptep))
1098 kvm_flush_remote_tlbs(vcpu->kvm);
1099}
1100
1101/*
1102 * Write-protect on the specified @sptep, @pt_protect indicates whether
1103 * spte writ-protection is caused by protecting shadow page table.
1104 * @flush indicates whether tlb need be flushed.
1105 *
1106 * Note: write protection is difference between drity logging and spte
1107 * protection:
1108 * - for dirty logging, the spte can be set to writable at anytime if
1109 * its dirty bitmap is properly set.
1110 * - for spte protection, the spte can be writable only after unsync-ing
1111 * shadow page.
1112 *
1113 * Return true if the spte is dropped.
1114 */
1115static bool
1116spte_write_protect(struct kvm *kvm, u64 *sptep, bool *flush, bool pt_protect)
1117{
1118 u64 spte = *sptep;
1119
1120 if (!is_writable_pte(spte) &&
1121 !(pt_protect && spte_is_locklessly_modifiable(spte)))
1122 return false;
1123
1124 rmap_printk("rmap_write_protect: spte %p %llx\n", sptep, *sptep);
1125
1126 if (__drop_large_spte(kvm, sptep)) {
1127 *flush |= true;
1128 return true;
1129 }
1130
1131 if (pt_protect)
1132 spte &= ~SPTE_MMU_WRITEABLE;
1133 spte = spte & ~PT_WRITABLE_MASK;
1134
1135 *flush |= mmu_spte_update(sptep, spte);
1136 return false;
1137}
1138
1139static bool __rmap_write_protect(struct kvm *kvm, unsigned long *rmapp,
1140 int level, bool pt_protect)
1055{ 1141{
1056 u64 *sptep; 1142 u64 *sptep;
1057 struct rmap_iterator iter; 1143 struct rmap_iterator iter;
1058 int write_protected = 0; 1144 bool flush = false;
1059 1145
1060 for (sptep = rmap_get_first(*rmapp, &iter); sptep;) { 1146 for (sptep = rmap_get_first(*rmapp, &iter); sptep;) {
1061 BUG_ON(!(*sptep & PT_PRESENT_MASK)); 1147 BUG_ON(!(*sptep & PT_PRESENT_MASK));
1062 rmap_printk("rmap_write_protect: spte %p %llx\n", sptep, *sptep); 1148 if (spte_write_protect(kvm, sptep, &flush, pt_protect)) {
1063
1064 if (!is_writable_pte(*sptep)) {
1065 sptep = rmap_get_next(&iter);
1066 continue;
1067 }
1068
1069 if (level == PT_PAGE_TABLE_LEVEL) {
1070 mmu_spte_update(sptep, *sptep & ~PT_WRITABLE_MASK);
1071 sptep = rmap_get_next(&iter);
1072 } else {
1073 BUG_ON(!is_large_pte(*sptep));
1074 drop_spte(kvm, sptep);
1075 --kvm->stat.lpages;
1076 sptep = rmap_get_first(*rmapp, &iter); 1149 sptep = rmap_get_first(*rmapp, &iter);
1150 continue;
1077 } 1151 }
1078 1152
1079 write_protected = 1; 1153 sptep = rmap_get_next(&iter);
1080 } 1154 }
1081 1155
1082 return write_protected; 1156 return flush;
1083} 1157}
1084 1158
1085/** 1159/**
@@ -1100,26 +1174,26 @@ void kvm_mmu_write_protect_pt_masked(struct kvm *kvm,
1100 1174
1101 while (mask) { 1175 while (mask) {
1102 rmapp = &slot->rmap[gfn_offset + __ffs(mask)]; 1176 rmapp = &slot->rmap[gfn_offset + __ffs(mask)];
1103 __rmap_write_protect(kvm, rmapp, PT_PAGE_TABLE_LEVEL); 1177 __rmap_write_protect(kvm, rmapp, PT_PAGE_TABLE_LEVEL, false);
1104 1178
1105 /* clear the first set bit */ 1179 /* clear the first set bit */
1106 mask &= mask - 1; 1180 mask &= mask - 1;
1107 } 1181 }
1108} 1182}
1109 1183
1110static int rmap_write_protect(struct kvm *kvm, u64 gfn) 1184static bool rmap_write_protect(struct kvm *kvm, u64 gfn)
1111{ 1185{
1112 struct kvm_memory_slot *slot; 1186 struct kvm_memory_slot *slot;
1113 unsigned long *rmapp; 1187 unsigned long *rmapp;
1114 int i; 1188 int i;
1115 int write_protected = 0; 1189 bool write_protected = false;
1116 1190
1117 slot = gfn_to_memslot(kvm, gfn); 1191 slot = gfn_to_memslot(kvm, gfn);
1118 1192
1119 for (i = PT_PAGE_TABLE_LEVEL; 1193 for (i = PT_PAGE_TABLE_LEVEL;
1120 i < PT_PAGE_TABLE_LEVEL + KVM_NR_PAGE_SIZES; ++i) { 1194 i < PT_PAGE_TABLE_LEVEL + KVM_NR_PAGE_SIZES; ++i) {
1121 rmapp = __gfn_to_rmap(gfn, i, slot); 1195 rmapp = __gfn_to_rmap(gfn, i, slot);
1122 write_protected |= __rmap_write_protect(kvm, rmapp, i); 1196 write_protected |= __rmap_write_protect(kvm, rmapp, i, true);
1123 } 1197 }
1124 1198
1125 return write_protected; 1199 return write_protected;
@@ -1238,11 +1312,12 @@ static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
1238 unsigned long data) 1312 unsigned long data)
1239{ 1313{
1240 u64 *sptep; 1314 u64 *sptep;
1241 struct rmap_iterator iter; 1315 struct rmap_iterator uninitialized_var(iter);
1242 int young = 0; 1316 int young = 0;
1243 1317
1244 /* 1318 /*
1245 * Emulate the accessed bit for EPT, by checking if this page has 1319 * In case of absence of EPT Access and Dirty Bits supports,
1320 * emulate the accessed bit for EPT, by checking if this page has
1246 * an EPT mapping, and clearing it if it does. On the next access, 1321 * an EPT mapping, and clearing it if it does. On the next access,
1247 * a new EPT mapping will be established. 1322 * a new EPT mapping will be established.
1248 * This has some overhead, but not as much as the cost of swapping 1323 * This has some overhead, but not as much as the cost of swapping
@@ -1253,11 +1328,12 @@ static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
1253 1328
1254 for (sptep = rmap_get_first(*rmapp, &iter); sptep; 1329 for (sptep = rmap_get_first(*rmapp, &iter); sptep;
1255 sptep = rmap_get_next(&iter)) { 1330 sptep = rmap_get_next(&iter)) {
1256 BUG_ON(!(*sptep & PT_PRESENT_MASK)); 1331 BUG_ON(!is_shadow_present_pte(*sptep));
1257 1332
1258 if (*sptep & PT_ACCESSED_MASK) { 1333 if (*sptep & shadow_accessed_mask) {
1259 young = 1; 1334 young = 1;
1260 clear_bit(PT_ACCESSED_SHIFT, (unsigned long *)sptep); 1335 clear_bit((ffs(shadow_accessed_mask) - 1),
1336 (unsigned long *)sptep);
1261 } 1337 }
1262 } 1338 }
1263 1339
@@ -1281,9 +1357,9 @@ static int kvm_test_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
1281 1357
1282 for (sptep = rmap_get_first(*rmapp, &iter); sptep; 1358 for (sptep = rmap_get_first(*rmapp, &iter); sptep;
1283 sptep = rmap_get_next(&iter)) { 1359 sptep = rmap_get_next(&iter)) {
1284 BUG_ON(!(*sptep & PT_PRESENT_MASK)); 1360 BUG_ON(!is_shadow_present_pte(*sptep));
1285 1361
1286 if (*sptep & PT_ACCESSED_MASK) { 1362 if (*sptep & shadow_accessed_mask) {
1287 young = 1; 1363 young = 1;
1288 break; 1364 break;
1289 } 1365 }
@@ -1401,12 +1477,10 @@ static struct kvm_mmu_page *kvm_mmu_alloc_page(struct kvm_vcpu *vcpu,
1401 u64 *parent_pte, int direct) 1477 u64 *parent_pte, int direct)
1402{ 1478{
1403 struct kvm_mmu_page *sp; 1479 struct kvm_mmu_page *sp;
1404 sp = mmu_memory_cache_alloc(&vcpu->arch.mmu_page_header_cache, 1480 sp = mmu_memory_cache_alloc(&vcpu->arch.mmu_page_header_cache);
1405 sizeof *sp); 1481 sp->spt = mmu_memory_cache_alloc(&vcpu->arch.mmu_page_cache);
1406 sp->spt = mmu_memory_cache_alloc(&vcpu->arch.mmu_page_cache, PAGE_SIZE);
1407 if (!direct) 1482 if (!direct)
1408 sp->gfns = mmu_memory_cache_alloc(&vcpu->arch.mmu_page_cache, 1483 sp->gfns = mmu_memory_cache_alloc(&vcpu->arch.mmu_page_cache);
1409 PAGE_SIZE);
1410 set_page_private(virt_to_page(sp->spt), (unsigned long)sp); 1484 set_page_private(virt_to_page(sp->spt), (unsigned long)sp);
1411 list_add(&sp->link, &vcpu->kvm->arch.active_mmu_pages); 1485 list_add(&sp->link, &vcpu->kvm->arch.active_mmu_pages);
1412 bitmap_zero(sp->slot_bitmap, KVM_MEM_SLOTS_NUM); 1486 bitmap_zero(sp->slot_bitmap, KVM_MEM_SLOTS_NUM);
@@ -1701,7 +1775,7 @@ static void mmu_sync_children(struct kvm_vcpu *vcpu,
1701 1775
1702 kvm_mmu_pages_init(parent, &parents, &pages); 1776 kvm_mmu_pages_init(parent, &parents, &pages);
1703 while (mmu_unsync_walk(parent, &pages)) { 1777 while (mmu_unsync_walk(parent, &pages)) {
1704 int protected = 0; 1778 bool protected = false;
1705 1779
1706 for_each_sp(pages, sp, parents, i) 1780 for_each_sp(pages, sp, parents, i)
1707 protected |= rmap_write_protect(vcpu->kvm, sp->gfn); 1781 protected |= rmap_write_protect(vcpu->kvm, sp->gfn);
@@ -1866,15 +1940,6 @@ static void link_shadow_page(u64 *sptep, struct kvm_mmu_page *sp)
1866 mmu_spte_set(sptep, spte); 1940 mmu_spte_set(sptep, spte);
1867} 1941}
1868 1942
1869static void drop_large_spte(struct kvm_vcpu *vcpu, u64 *sptep)
1870{
1871 if (is_large_pte(*sptep)) {
1872 drop_spte(vcpu->kvm, sptep);
1873 --vcpu->kvm->stat.lpages;
1874 kvm_flush_remote_tlbs(vcpu->kvm);
1875 }
1876}
1877
1878static void validate_direct_spte(struct kvm_vcpu *vcpu, u64 *sptep, 1943static void validate_direct_spte(struct kvm_vcpu *vcpu, u64 *sptep,
1879 unsigned direct_access) 1944 unsigned direct_access)
1880{ 1945{
@@ -2243,7 +2308,7 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
2243 gfn_t gfn, pfn_t pfn, bool speculative, 2308 gfn_t gfn, pfn_t pfn, bool speculative,
2244 bool can_unsync, bool host_writable) 2309 bool can_unsync, bool host_writable)
2245{ 2310{
2246 u64 spte, entry = *sptep; 2311 u64 spte;
2247 int ret = 0; 2312 int ret = 0;
2248 2313
2249 if (set_mmio_spte(sptep, gfn, pfn, pte_access)) 2314 if (set_mmio_spte(sptep, gfn, pfn, pte_access))
@@ -2257,8 +2322,10 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
2257 spte |= shadow_x_mask; 2322 spte |= shadow_x_mask;
2258 else 2323 else
2259 spte |= shadow_nx_mask; 2324 spte |= shadow_nx_mask;
2325
2260 if (pte_access & ACC_USER_MASK) 2326 if (pte_access & ACC_USER_MASK)
2261 spte |= shadow_user_mask; 2327 spte |= shadow_user_mask;
2328
2262 if (level > PT_PAGE_TABLE_LEVEL) 2329 if (level > PT_PAGE_TABLE_LEVEL)
2263 spte |= PT_PAGE_SIZE_MASK; 2330 spte |= PT_PAGE_SIZE_MASK;
2264 if (tdp_enabled) 2331 if (tdp_enabled)
@@ -2283,7 +2350,7 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
2283 goto done; 2350 goto done;
2284 } 2351 }
2285 2352
2286 spte |= PT_WRITABLE_MASK; 2353 spte |= PT_WRITABLE_MASK | SPTE_MMU_WRITEABLE;
2287 2354
2288 if (!vcpu->arch.mmu.direct_map 2355 if (!vcpu->arch.mmu.direct_map
2289 && !(pte_access & ACC_WRITE_MASK)) { 2356 && !(pte_access & ACC_WRITE_MASK)) {
@@ -2312,8 +2379,7 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
2312 __func__, gfn); 2379 __func__, gfn);
2313 ret = 1; 2380 ret = 1;
2314 pte_access &= ~ACC_WRITE_MASK; 2381 pte_access &= ~ACC_WRITE_MASK;
2315 if (is_writable_pte(spte)) 2382 spte &= ~(PT_WRITABLE_MASK | SPTE_MMU_WRITEABLE);
2316 spte &= ~PT_WRITABLE_MASK;
2317 } 2383 }
2318 } 2384 }
2319 2385
@@ -2321,14 +2387,7 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
2321 mark_page_dirty(vcpu->kvm, gfn); 2387 mark_page_dirty(vcpu->kvm, gfn);
2322 2388
2323set_pte: 2389set_pte:
2324 mmu_spte_update(sptep, spte); 2390 if (mmu_spte_update(sptep, spte))
2325 /*
2326 * If we overwrite a writable spte with a read-only one we
2327 * should flush remote TLBs. Otherwise rmap_write_protect
2328 * will find a read-only spte, even though the writable spte
2329 * might be cached on a CPU's TLB.
2330 */
2331 if (is_writable_pte(entry) && !is_writable_pte(*sptep))
2332 kvm_flush_remote_tlbs(vcpu->kvm); 2391 kvm_flush_remote_tlbs(vcpu->kvm);
2333done: 2392done:
2334 return ret; 2393 return ret;
@@ -2403,6 +2462,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
2403 2462
2404static void nonpaging_new_cr3(struct kvm_vcpu *vcpu) 2463static void nonpaging_new_cr3(struct kvm_vcpu *vcpu)
2405{ 2464{
2465 mmu_free_roots(vcpu);
2406} 2466}
2407 2467
2408static pfn_t pte_prefetch_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn, 2468static pfn_t pte_prefetch_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn,
@@ -2625,18 +2685,116 @@ exit:
2625 return ret; 2685 return ret;
2626} 2686}
2627 2687
2688static bool page_fault_can_be_fast(struct kvm_vcpu *vcpu, u32 error_code)
2689{
2690 /*
2691 * #PF can be fast only if the shadow page table is present and it
2692 * is caused by write-protect, that means we just need change the
2693 * W bit of the spte which can be done out of mmu-lock.
2694 */
2695 if (!(error_code & PFERR_PRESENT_MASK) ||
2696 !(error_code & PFERR_WRITE_MASK))
2697 return false;
2698
2699 return true;
2700}
2701
2702static bool
2703fast_pf_fix_direct_spte(struct kvm_vcpu *vcpu, u64 *sptep, u64 spte)
2704{
2705 struct kvm_mmu_page *sp = page_header(__pa(sptep));
2706 gfn_t gfn;
2707
2708 WARN_ON(!sp->role.direct);
2709
2710 /*
2711 * The gfn of direct spte is stable since it is calculated
2712 * by sp->gfn.
2713 */
2714 gfn = kvm_mmu_page_get_gfn(sp, sptep - sp->spt);
2715
2716 if (cmpxchg64(sptep, spte, spte | PT_WRITABLE_MASK) == spte)
2717 mark_page_dirty(vcpu->kvm, gfn);
2718
2719 return true;
2720}
2721
2722/*
2723 * Return value:
2724 * - true: let the vcpu to access on the same address again.
2725 * - false: let the real page fault path to fix it.
2726 */
2727static bool fast_page_fault(struct kvm_vcpu *vcpu, gva_t gva, int level,
2728 u32 error_code)
2729{
2730 struct kvm_shadow_walk_iterator iterator;
2731 bool ret = false;
2732 u64 spte = 0ull;
2733
2734 if (!page_fault_can_be_fast(vcpu, error_code))
2735 return false;
2736
2737 walk_shadow_page_lockless_begin(vcpu);
2738 for_each_shadow_entry_lockless(vcpu, gva, iterator, spte)
2739 if (!is_shadow_present_pte(spte) || iterator.level < level)
2740 break;
2741
2742 /*
2743 * If the mapping has been changed, let the vcpu fault on the
2744 * same address again.
2745 */
2746 if (!is_rmap_spte(spte)) {
2747 ret = true;
2748 goto exit;
2749 }
2750
2751 if (!is_last_spte(spte, level))
2752 goto exit;
2753
2754 /*
2755 * Check if it is a spurious fault caused by TLB lazily flushed.
2756 *
2757 * Need not check the access of upper level table entries since
2758 * they are always ACC_ALL.
2759 */
2760 if (is_writable_pte(spte)) {
2761 ret = true;
2762 goto exit;
2763 }
2764
2765 /*
2766 * Currently, to simplify the code, only the spte write-protected
2767 * by dirty-log can be fast fixed.
2768 */
2769 if (!spte_is_locklessly_modifiable(spte))
2770 goto exit;
2771
2772 /*
2773 * Currently, fast page fault only works for direct mapping since
2774 * the gfn is not stable for indirect shadow page.
2775 * See Documentation/virtual/kvm/locking.txt to get more detail.
2776 */
2777 ret = fast_pf_fix_direct_spte(vcpu, iterator.sptep, spte);
2778exit:
2779 trace_fast_page_fault(vcpu, gva, error_code, iterator.sptep,
2780 spte, ret);
2781 walk_shadow_page_lockless_end(vcpu);
2782
2783 return ret;
2784}
2785
2628static bool try_async_pf(struct kvm_vcpu *vcpu, bool prefault, gfn_t gfn, 2786static bool try_async_pf(struct kvm_vcpu *vcpu, bool prefault, gfn_t gfn,
2629 gva_t gva, pfn_t *pfn, bool write, bool *writable); 2787 gva_t gva, pfn_t *pfn, bool write, bool *writable);
2630 2788
2631static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, int write, gfn_t gfn, 2789static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, u32 error_code,
2632 bool prefault) 2790 gfn_t gfn, bool prefault)
2633{ 2791{
2634 int r; 2792 int r;
2635 int level; 2793 int level;
2636 int force_pt_level; 2794 int force_pt_level;
2637 pfn_t pfn; 2795 pfn_t pfn;
2638 unsigned long mmu_seq; 2796 unsigned long mmu_seq;
2639 bool map_writable; 2797 bool map_writable, write = error_code & PFERR_WRITE_MASK;
2640 2798
2641 force_pt_level = mapping_level_dirty_bitmap(vcpu, gfn); 2799 force_pt_level = mapping_level_dirty_bitmap(vcpu, gfn);
2642 if (likely(!force_pt_level)) { 2800 if (likely(!force_pt_level)) {
@@ -2653,6 +2811,9 @@ static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, int write, gfn_t gfn,
2653 } else 2811 } else
2654 level = PT_PAGE_TABLE_LEVEL; 2812 level = PT_PAGE_TABLE_LEVEL;
2655 2813
2814 if (fast_page_fault(vcpu, v, level, error_code))
2815 return 0;
2816
2656 mmu_seq = vcpu->kvm->mmu_notifier_seq; 2817 mmu_seq = vcpu->kvm->mmu_notifier_seq;
2657 smp_rmb(); 2818 smp_rmb();
2658 2819
@@ -3041,7 +3202,7 @@ static int nonpaging_page_fault(struct kvm_vcpu *vcpu, gva_t gva,
3041 gfn = gva >> PAGE_SHIFT; 3202 gfn = gva >> PAGE_SHIFT;
3042 3203
3043 return nonpaging_map(vcpu, gva & PAGE_MASK, 3204 return nonpaging_map(vcpu, gva & PAGE_MASK,
3044 error_code & PFERR_WRITE_MASK, gfn, prefault); 3205 error_code, gfn, prefault);
3045} 3206}
3046 3207
3047static int kvm_arch_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn) 3208static int kvm_arch_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn)
@@ -3121,6 +3282,9 @@ static int tdp_page_fault(struct kvm_vcpu *vcpu, gva_t gpa, u32 error_code,
3121 } else 3282 } else
3122 level = PT_PAGE_TABLE_LEVEL; 3283 level = PT_PAGE_TABLE_LEVEL;
3123 3284
3285 if (fast_page_fault(vcpu, gpa, level, error_code))
3286 return 0;
3287
3124 mmu_seq = vcpu->kvm->mmu_notifier_seq; 3288 mmu_seq = vcpu->kvm->mmu_notifier_seq;
3125 smp_rmb(); 3289 smp_rmb();
3126 3290
@@ -3885,6 +4049,7 @@ int kvm_mmu_setup(struct kvm_vcpu *vcpu)
3885void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot) 4049void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
3886{ 4050{
3887 struct kvm_mmu_page *sp; 4051 struct kvm_mmu_page *sp;
4052 bool flush = false;
3888 4053
3889 list_for_each_entry(sp, &kvm->arch.active_mmu_pages, link) { 4054 list_for_each_entry(sp, &kvm->arch.active_mmu_pages, link) {
3890 int i; 4055 int i;
@@ -3899,16 +4064,7 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
3899 !is_last_spte(pt[i], sp->role.level)) 4064 !is_last_spte(pt[i], sp->role.level))
3900 continue; 4065 continue;
3901 4066
3902 if (is_large_pte(pt[i])) { 4067 spte_write_protect(kvm, &pt[i], &flush, false);
3903 drop_spte(kvm, &pt[i]);
3904 --kvm->stat.lpages;
3905 continue;
3906 }
3907
3908 /* avoid RMW */
3909 if (is_writable_pte(pt[i]))
3910 mmu_spte_update(&pt[i],
3911 pt[i] & ~PT_WRITABLE_MASK);
3912 } 4068 }
3913 } 4069 }
3914 kvm_flush_remote_tlbs(kvm); 4070 kvm_flush_remote_tlbs(kvm);
@@ -3945,7 +4101,6 @@ static void kvm_mmu_remove_some_alloc_mmu_pages(struct kvm *kvm,
3945static int mmu_shrink(struct shrinker *shrink, struct shrink_control *sc) 4101static int mmu_shrink(struct shrinker *shrink, struct shrink_control *sc)
3946{ 4102{
3947 struct kvm *kvm; 4103 struct kvm *kvm;
3948 struct kvm *kvm_freed = NULL;
3949 int nr_to_scan = sc->nr_to_scan; 4104 int nr_to_scan = sc->nr_to_scan;
3950 4105
3951 if (nr_to_scan == 0) 4106 if (nr_to_scan == 0)
@@ -3957,22 +4112,35 @@ static int mmu_shrink(struct shrinker *shrink, struct shrink_control *sc)
3957 int idx; 4112 int idx;
3958 LIST_HEAD(invalid_list); 4113 LIST_HEAD(invalid_list);
3959 4114
4115 /*
4116 * Never scan more than sc->nr_to_scan VM instances.
4117 * Will not hit this condition practically since we do not try
4118 * to shrink more than one VM and it is very unlikely to see
4119 * !n_used_mmu_pages so many times.
4120 */
4121 if (!nr_to_scan--)
4122 break;
4123 /*
4124 * n_used_mmu_pages is accessed without holding kvm->mmu_lock
4125 * here. We may skip a VM instance errorneosly, but we do not
4126 * want to shrink a VM that only started to populate its MMU
4127 * anyway.
4128 */
4129 if (!kvm->arch.n_used_mmu_pages)
4130 continue;
4131
3960 idx = srcu_read_lock(&kvm->srcu); 4132 idx = srcu_read_lock(&kvm->srcu);
3961 spin_lock(&kvm->mmu_lock); 4133 spin_lock(&kvm->mmu_lock);
3962 if (!kvm_freed && nr_to_scan > 0 &&
3963 kvm->arch.n_used_mmu_pages > 0) {
3964 kvm_mmu_remove_some_alloc_mmu_pages(kvm,
3965 &invalid_list);
3966 kvm_freed = kvm;
3967 }
3968 nr_to_scan--;
3969 4134
4135 kvm_mmu_remove_some_alloc_mmu_pages(kvm, &invalid_list);
3970 kvm_mmu_commit_zap_page(kvm, &invalid_list); 4136 kvm_mmu_commit_zap_page(kvm, &invalid_list);
4137
3971 spin_unlock(&kvm->mmu_lock); 4138 spin_unlock(&kvm->mmu_lock);
3972 srcu_read_unlock(&kvm->srcu, idx); 4139 srcu_read_unlock(&kvm->srcu, idx);
4140
4141 list_move_tail(&kvm->vm_list, &vm_list);
4142 break;
3973 } 4143 }
3974 if (kvm_freed)
3975 list_move_tail(&kvm_freed->vm_list, &vm_list);
3976 4144
3977 raw_spin_unlock(&kvm_lock); 4145 raw_spin_unlock(&kvm_lock);
3978 4146
diff --git a/arch/x86/kvm/mmutrace.h b/arch/x86/kvm/mmutrace.h
index 89fb0e81322..cd6e98333ba 100644
--- a/arch/x86/kvm/mmutrace.h
+++ b/arch/x86/kvm/mmutrace.h
@@ -54,8 +54,8 @@
54 */ 54 */
55TRACE_EVENT( 55TRACE_EVENT(
56 kvm_mmu_pagetable_walk, 56 kvm_mmu_pagetable_walk,
57 TP_PROTO(u64 addr, int write_fault, int user_fault, int fetch_fault), 57 TP_PROTO(u64 addr, u32 pferr),
58 TP_ARGS(addr, write_fault, user_fault, fetch_fault), 58 TP_ARGS(addr, pferr),
59 59
60 TP_STRUCT__entry( 60 TP_STRUCT__entry(
61 __field(__u64, addr) 61 __field(__u64, addr)
@@ -64,8 +64,7 @@ TRACE_EVENT(
64 64
65 TP_fast_assign( 65 TP_fast_assign(
66 __entry->addr = addr; 66 __entry->addr = addr;
67 __entry->pferr = (!!write_fault << 1) | (!!user_fault << 2) 67 __entry->pferr = pferr;
68 | (!!fetch_fault << 4);
69 ), 68 ),
70 69
71 TP_printk("addr %llx pferr %x %s", __entry->addr, __entry->pferr, 70 TP_printk("addr %llx pferr %x %s", __entry->addr, __entry->pferr,
@@ -243,6 +242,44 @@ TRACE_EVENT(
243 TP_printk("addr:%llx gfn %llx access %x", __entry->addr, __entry->gfn, 242 TP_printk("addr:%llx gfn %llx access %x", __entry->addr, __entry->gfn,
244 __entry->access) 243 __entry->access)
245); 244);
245
246#define __spte_satisfied(__spte) \
247 (__entry->retry && is_writable_pte(__entry->__spte))
248
249TRACE_EVENT(
250 fast_page_fault,
251 TP_PROTO(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code,
252 u64 *sptep, u64 old_spte, bool retry),
253 TP_ARGS(vcpu, gva, error_code, sptep, old_spte, retry),
254
255 TP_STRUCT__entry(
256 __field(int, vcpu_id)
257 __field(gva_t, gva)
258 __field(u32, error_code)
259 __field(u64 *, sptep)
260 __field(u64, old_spte)
261 __field(u64, new_spte)
262 __field(bool, retry)
263 ),
264
265 TP_fast_assign(
266 __entry->vcpu_id = vcpu->vcpu_id;
267 __entry->gva = gva;
268 __entry->error_code = error_code;
269 __entry->sptep = sptep;
270 __entry->old_spte = old_spte;
271 __entry->new_spte = *sptep;
272 __entry->retry = retry;
273 ),
274
275 TP_printk("vcpu %d gva %lx error_code %s sptep %p old %#llx"
276 " new %llx spurious %d fixed %d", __entry->vcpu_id,
277 __entry->gva, __print_flags(__entry->error_code, "|",
278 kvm_mmu_trace_pferr_flags), __entry->sptep,
279 __entry->old_spte, __entry->new_spte,
280 __spte_satisfied(old_spte), __spte_satisfied(new_spte)
281 )
282);
246#endif /* _TRACE_KVMMMU_H */ 283#endif /* _TRACE_KVMMMU_H */
247 284
248#undef TRACE_INCLUDE_PATH 285#undef TRACE_INCLUDE_PATH
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 34f970937ef..bb7cf01cae7 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -154,8 +154,7 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker,
154 const int fetch_fault = access & PFERR_FETCH_MASK; 154 const int fetch_fault = access & PFERR_FETCH_MASK;
155 u16 errcode = 0; 155 u16 errcode = 0;
156 156
157 trace_kvm_mmu_pagetable_walk(addr, write_fault, user_fault, 157 trace_kvm_mmu_pagetable_walk(addr, access);
158 fetch_fault);
159retry_walk: 158retry_walk:
160 eperm = false; 159 eperm = false;
161 walker->level = mmu->root_level; 160 walker->level = mmu->root_level;
diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
index 2e88438ffd8..9b7ec1150ab 100644
--- a/arch/x86/kvm/pmu.c
+++ b/arch/x86/kvm/pmu.c
@@ -80,10 +80,10 @@ static inline struct kvm_pmc *get_fixed_pmc_idx(struct kvm_pmu *pmu, int idx)
80 80
81static struct kvm_pmc *global_idx_to_pmc(struct kvm_pmu *pmu, int idx) 81static struct kvm_pmc *global_idx_to_pmc(struct kvm_pmu *pmu, int idx)
82{ 82{
83 if (idx < X86_PMC_IDX_FIXED) 83 if (idx < INTEL_PMC_IDX_FIXED)
84 return get_gp_pmc(pmu, MSR_P6_EVNTSEL0 + idx, MSR_P6_EVNTSEL0); 84 return get_gp_pmc(pmu, MSR_P6_EVNTSEL0 + idx, MSR_P6_EVNTSEL0);
85 else 85 else
86 return get_fixed_pmc_idx(pmu, idx - X86_PMC_IDX_FIXED); 86 return get_fixed_pmc_idx(pmu, idx - INTEL_PMC_IDX_FIXED);
87} 87}
88 88
89void kvm_deliver_pmi(struct kvm_vcpu *vcpu) 89void kvm_deliver_pmi(struct kvm_vcpu *vcpu)
@@ -291,7 +291,7 @@ static void reprogram_idx(struct kvm_pmu *pmu, int idx)
291 if (pmc_is_gp(pmc)) 291 if (pmc_is_gp(pmc))
292 reprogram_gp_counter(pmc, pmc->eventsel); 292 reprogram_gp_counter(pmc, pmc->eventsel);
293 else { 293 else {
294 int fidx = idx - X86_PMC_IDX_FIXED; 294 int fidx = idx - INTEL_PMC_IDX_FIXED;
295 reprogram_fixed_counter(pmc, 295 reprogram_fixed_counter(pmc,
296 fixed_en_pmi(pmu->fixed_ctr_ctrl, fidx), fidx); 296 fixed_en_pmi(pmu->fixed_ctr_ctrl, fidx), fidx);
297 } 297 }
@@ -452,7 +452,7 @@ void kvm_pmu_cpuid_update(struct kvm_vcpu *vcpu)
452 return; 452 return;
453 453
454 pmu->nr_arch_gp_counters = min((int)(entry->eax >> 8) & 0xff, 454 pmu->nr_arch_gp_counters = min((int)(entry->eax >> 8) & 0xff,
455 X86_PMC_MAX_GENERIC); 455 INTEL_PMC_MAX_GENERIC);
456 pmu->counter_bitmask[KVM_PMC_GP] = 456 pmu->counter_bitmask[KVM_PMC_GP] =
457 ((u64)1 << ((entry->eax >> 16) & 0xff)) - 1; 457 ((u64)1 << ((entry->eax >> 16) & 0xff)) - 1;
458 bitmap_len = (entry->eax >> 24) & 0xff; 458 bitmap_len = (entry->eax >> 24) & 0xff;
@@ -462,13 +462,13 @@ void kvm_pmu_cpuid_update(struct kvm_vcpu *vcpu)
462 pmu->nr_arch_fixed_counters = 0; 462 pmu->nr_arch_fixed_counters = 0;
463 } else { 463 } else {
464 pmu->nr_arch_fixed_counters = min((int)(entry->edx & 0x1f), 464 pmu->nr_arch_fixed_counters = min((int)(entry->edx & 0x1f),
465 X86_PMC_MAX_FIXED); 465 INTEL_PMC_MAX_FIXED);
466 pmu->counter_bitmask[KVM_PMC_FIXED] = 466 pmu->counter_bitmask[KVM_PMC_FIXED] =
467 ((u64)1 << ((entry->edx >> 5) & 0xff)) - 1; 467 ((u64)1 << ((entry->edx >> 5) & 0xff)) - 1;
468 } 468 }
469 469
470 pmu->global_ctrl = ((1 << pmu->nr_arch_gp_counters) - 1) | 470 pmu->global_ctrl = ((1 << pmu->nr_arch_gp_counters) - 1) |
471 (((1ull << pmu->nr_arch_fixed_counters) - 1) << X86_PMC_IDX_FIXED); 471 (((1ull << pmu->nr_arch_fixed_counters) - 1) << INTEL_PMC_IDX_FIXED);
472 pmu->global_ctrl_mask = ~pmu->global_ctrl; 472 pmu->global_ctrl_mask = ~pmu->global_ctrl;
473} 473}
474 474
@@ -478,15 +478,15 @@ void kvm_pmu_init(struct kvm_vcpu *vcpu)
478 struct kvm_pmu *pmu = &vcpu->arch.pmu; 478 struct kvm_pmu *pmu = &vcpu->arch.pmu;
479 479
480 memset(pmu, 0, sizeof(*pmu)); 480 memset(pmu, 0, sizeof(*pmu));
481 for (i = 0; i < X86_PMC_MAX_GENERIC; i++) { 481 for (i = 0; i < INTEL_PMC_MAX_GENERIC; i++) {
482 pmu->gp_counters[i].type = KVM_PMC_GP; 482 pmu->gp_counters[i].type = KVM_PMC_GP;
483 pmu->gp_counters[i].vcpu = vcpu; 483 pmu->gp_counters[i].vcpu = vcpu;
484 pmu->gp_counters[i].idx = i; 484 pmu->gp_counters[i].idx = i;
485 } 485 }
486 for (i = 0; i < X86_PMC_MAX_FIXED; i++) { 486 for (i = 0; i < INTEL_PMC_MAX_FIXED; i++) {
487 pmu->fixed_counters[i].type = KVM_PMC_FIXED; 487 pmu->fixed_counters[i].type = KVM_PMC_FIXED;
488 pmu->fixed_counters[i].vcpu = vcpu; 488 pmu->fixed_counters[i].vcpu = vcpu;
489 pmu->fixed_counters[i].idx = i + X86_PMC_IDX_FIXED; 489 pmu->fixed_counters[i].idx = i + INTEL_PMC_IDX_FIXED;
490 } 490 }
491 init_irq_work(&pmu->irq_work, trigger_pmi); 491 init_irq_work(&pmu->irq_work, trigger_pmi);
492 kvm_pmu_cpuid_update(vcpu); 492 kvm_pmu_cpuid_update(vcpu);
@@ -498,13 +498,13 @@ void kvm_pmu_reset(struct kvm_vcpu *vcpu)
498 int i; 498 int i;
499 499
500 irq_work_sync(&pmu->irq_work); 500 irq_work_sync(&pmu->irq_work);
501 for (i = 0; i < X86_PMC_MAX_GENERIC; i++) { 501 for (i = 0; i < INTEL_PMC_MAX_GENERIC; i++) {
502 struct kvm_pmc *pmc = &pmu->gp_counters[i]; 502 struct kvm_pmc *pmc = &pmu->gp_counters[i];
503 stop_counter(pmc); 503 stop_counter(pmc);
504 pmc->counter = pmc->eventsel = 0; 504 pmc->counter = pmc->eventsel = 0;
505 } 505 }
506 506
507 for (i = 0; i < X86_PMC_MAX_FIXED; i++) 507 for (i = 0; i < INTEL_PMC_MAX_FIXED; i++)
508 stop_counter(&pmu->fixed_counters[i]); 508 stop_counter(&pmu->fixed_counters[i]);
509 509
510 pmu->fixed_ctr_ctrl = pmu->global_ctrl = pmu->global_status = 510 pmu->fixed_ctr_ctrl = pmu->global_ctrl = pmu->global_status =
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index f75af406b26..baead950d6c 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -3185,8 +3185,8 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
3185 break; 3185 break;
3186 case MSR_IA32_DEBUGCTLMSR: 3186 case MSR_IA32_DEBUGCTLMSR:
3187 if (!boot_cpu_has(X86_FEATURE_LBRV)) { 3187 if (!boot_cpu_has(X86_FEATURE_LBRV)) {
3188 pr_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTL 0x%llx, nop\n", 3188 vcpu_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTL 0x%llx, nop\n",
3189 __func__, data); 3189 __func__, data);
3190 break; 3190 break;
3191 } 3191 }
3192 if (data & DEBUGCTL_RESERVED_BITS) 3192 if (data & DEBUGCTL_RESERVED_BITS)
@@ -3205,7 +3205,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
3205 case MSR_VM_CR: 3205 case MSR_VM_CR:
3206 return svm_set_vm_cr(vcpu, data); 3206 return svm_set_vm_cr(vcpu, data);
3207 case MSR_VM_IGNNE: 3207 case MSR_VM_IGNNE:
3208 pr_unimpl(vcpu, "unimplemented wrmsr: 0x%x data 0x%llx\n", ecx, data); 3208 vcpu_unimpl(vcpu, "unimplemented wrmsr: 0x%x data 0x%llx\n", ecx, data);
3209 break; 3209 break;
3210 default: 3210 default:
3211 return kvm_set_msr_common(vcpu, ecx, data); 3211 return kvm_set_msr_common(vcpu, ecx, data);
@@ -4044,6 +4044,11 @@ static bool svm_rdtscp_supported(void)
4044 return false; 4044 return false;
4045} 4045}
4046 4046
4047static bool svm_invpcid_supported(void)
4048{
4049 return false;
4050}
4051
4047static bool svm_has_wbinvd_exit(void) 4052static bool svm_has_wbinvd_exit(void)
4048{ 4053{
4049 return true; 4054 return true;
@@ -4312,6 +4317,7 @@ static struct kvm_x86_ops svm_x86_ops = {
4312 .cpuid_update = svm_cpuid_update, 4317 .cpuid_update = svm_cpuid_update,
4313 4318
4314 .rdtscp_supported = svm_rdtscp_supported, 4319 .rdtscp_supported = svm_rdtscp_supported,
4320 .invpcid_supported = svm_invpcid_supported,
4315 4321
4316 .set_supported_cpuid = svm_set_supported_cpuid, 4322 .set_supported_cpuid = svm_set_supported_cpuid,
4317 4323
diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
index 911d2641f14..a71faf727ff 100644
--- a/arch/x86/kvm/trace.h
+++ b/arch/x86/kvm/trace.h
@@ -517,6 +517,40 @@ TRACE_EVENT(kvm_apic_accept_irq,
517 __entry->coalesced ? " (coalesced)" : "") 517 __entry->coalesced ? " (coalesced)" : "")
518); 518);
519 519
520TRACE_EVENT(kvm_eoi,
521 TP_PROTO(struct kvm_lapic *apic, int vector),
522 TP_ARGS(apic, vector),
523
524 TP_STRUCT__entry(
525 __field( __u32, apicid )
526 __field( int, vector )
527 ),
528
529 TP_fast_assign(
530 __entry->apicid = apic->vcpu->vcpu_id;
531 __entry->vector = vector;
532 ),
533
534 TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
535);
536
537TRACE_EVENT(kvm_pv_eoi,
538 TP_PROTO(struct kvm_lapic *apic, int vector),
539 TP_ARGS(apic, vector),
540
541 TP_STRUCT__entry(
542 __field( __u32, apicid )
543 __field( int, vector )
544 ),
545
546 TP_fast_assign(
547 __entry->apicid = apic->vcpu->vcpu_id;
548 __entry->vector = vector;
549 ),
550
551 TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
552);
553
520/* 554/*
521 * Tracepoint for nested VMRUN 555 * Tracepoint for nested VMRUN
522 */ 556 */
@@ -710,16 +744,6 @@ TRACE_EVENT(kvm_skinit,
710 __entry->rip, __entry->slb) 744 __entry->rip, __entry->slb)
711); 745);
712 746
713#define __print_insn(insn, ilen) ({ \
714 int i; \
715 const char *ret = p->buffer + p->len; \
716 \
717 for (i = 0; i < ilen; ++i) \
718 trace_seq_printf(p, " %02x", insn[i]); \
719 trace_seq_printf(p, "%c", 0); \
720 ret; \
721 })
722
723#define KVM_EMUL_INSN_F_CR0_PE (1 << 0) 747#define KVM_EMUL_INSN_F_CR0_PE (1 << 0)
724#define KVM_EMUL_INSN_F_EFL_VM (1 << 1) 748#define KVM_EMUL_INSN_F_EFL_VM (1 << 1)
725#define KVM_EMUL_INSN_F_CS_D (1 << 2) 749#define KVM_EMUL_INSN_F_CS_D (1 << 2)
@@ -786,7 +810,7 @@ TRACE_EVENT(kvm_emulate_insn,
786 810
787 TP_printk("%x:%llx:%s (%s)%s", 811 TP_printk("%x:%llx:%s (%s)%s",
788 __entry->csbase, __entry->rip, 812 __entry->csbase, __entry->rip,
789 __print_insn(__entry->insn, __entry->len), 813 __print_hex(__entry->insn, __entry->len),
790 __print_symbolic(__entry->flags, 814 __print_symbolic(__entry->flags,
791 kvm_trace_symbol_emul_flags), 815 kvm_trace_symbol_emul_flags),
792 __entry->failed ? " failed" : "" 816 __entry->failed ? " failed" : ""
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 32eb5886629..c00f03de1b7 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -71,7 +71,10 @@ static bool __read_mostly enable_unrestricted_guest = 1;
71module_param_named(unrestricted_guest, 71module_param_named(unrestricted_guest,
72 enable_unrestricted_guest, bool, S_IRUGO); 72 enable_unrestricted_guest, bool, S_IRUGO);
73 73
74static bool __read_mostly emulate_invalid_guest_state = 0; 74static bool __read_mostly enable_ept_ad_bits = 1;
75module_param_named(eptad, enable_ept_ad_bits, bool, S_IRUGO);
76
77static bool __read_mostly emulate_invalid_guest_state = true;
75module_param(emulate_invalid_guest_state, bool, S_IRUGO); 78module_param(emulate_invalid_guest_state, bool, S_IRUGO);
76 79
77static bool __read_mostly vmm_exclusive = 1; 80static bool __read_mostly vmm_exclusive = 1;
@@ -615,6 +618,10 @@ static void kvm_cpu_vmxon(u64 addr);
615static void kvm_cpu_vmxoff(void); 618static void kvm_cpu_vmxoff(void);
616static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3); 619static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3);
617static int vmx_set_tss_addr(struct kvm *kvm, unsigned int addr); 620static int vmx_set_tss_addr(struct kvm *kvm, unsigned int addr);
621static void vmx_set_segment(struct kvm_vcpu *vcpu,
622 struct kvm_segment *var, int seg);
623static void vmx_get_segment(struct kvm_vcpu *vcpu,
624 struct kvm_segment *var, int seg);
618 625
619static DEFINE_PER_CPU(struct vmcs *, vmxarea); 626static DEFINE_PER_CPU(struct vmcs *, vmxarea);
620static DEFINE_PER_CPU(struct vmcs *, current_vmcs); 627static DEFINE_PER_CPU(struct vmcs *, current_vmcs);
@@ -789,6 +796,11 @@ static inline bool cpu_has_vmx_ept_4levels(void)
789 return vmx_capability.ept & VMX_EPT_PAGE_WALK_4_BIT; 796 return vmx_capability.ept & VMX_EPT_PAGE_WALK_4_BIT;
790} 797}
791 798
799static inline bool cpu_has_vmx_ept_ad_bits(void)
800{
801 return vmx_capability.ept & VMX_EPT_AD_BIT;
802}
803
792static inline bool cpu_has_vmx_invept_individual_addr(void) 804static inline bool cpu_has_vmx_invept_individual_addr(void)
793{ 805{
794 return vmx_capability.ept & VMX_EPT_EXTENT_INDIVIDUAL_BIT; 806 return vmx_capability.ept & VMX_EPT_EXTENT_INDIVIDUAL_BIT;
@@ -849,6 +861,12 @@ static inline bool cpu_has_vmx_rdtscp(void)
849 SECONDARY_EXEC_RDTSCP; 861 SECONDARY_EXEC_RDTSCP;
850} 862}
851 863
864static inline bool cpu_has_vmx_invpcid(void)
865{
866 return vmcs_config.cpu_based_2nd_exec_ctrl &
867 SECONDARY_EXEC_ENABLE_INVPCID;
868}
869
852static inline bool cpu_has_virtual_nmis(void) 870static inline bool cpu_has_virtual_nmis(void)
853{ 871{
854 return vmcs_config.pin_based_exec_ctrl & PIN_BASED_VIRTUAL_NMIS; 872 return vmcs_config.pin_based_exec_ctrl & PIN_BASED_VIRTUAL_NMIS;
@@ -1470,13 +1488,6 @@ static void __vmx_load_host_state(struct vcpu_vmx *vmx)
1470 loadsegment(ds, vmx->host_state.ds_sel); 1488 loadsegment(ds, vmx->host_state.ds_sel);
1471 loadsegment(es, vmx->host_state.es_sel); 1489 loadsegment(es, vmx->host_state.es_sel);
1472 } 1490 }
1473#else
1474 /*
1475 * The sysexit path does not restore ds/es, so we must set them to
1476 * a reasonable value ourselves.
1477 */
1478 loadsegment(ds, __USER_DS);
1479 loadsegment(es, __USER_DS);
1480#endif 1491#endif
1481 reload_tss(); 1492 reload_tss();
1482#ifdef CONFIG_X86_64 1493#ifdef CONFIG_X86_64
@@ -1739,6 +1750,11 @@ static bool vmx_rdtscp_supported(void)
1739 return cpu_has_vmx_rdtscp(); 1750 return cpu_has_vmx_rdtscp();
1740} 1751}
1741 1752
1753static bool vmx_invpcid_supported(void)
1754{
1755 return cpu_has_vmx_invpcid() && enable_ept;
1756}
1757
1742/* 1758/*
1743 * Swap MSR entry in host/guest MSR entry array. 1759 * Swap MSR entry in host/guest MSR entry array.
1744 */ 1760 */
@@ -2458,7 +2474,8 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)
2458 SECONDARY_EXEC_ENABLE_EPT | 2474 SECONDARY_EXEC_ENABLE_EPT |
2459 SECONDARY_EXEC_UNRESTRICTED_GUEST | 2475 SECONDARY_EXEC_UNRESTRICTED_GUEST |
2460 SECONDARY_EXEC_PAUSE_LOOP_EXITING | 2476 SECONDARY_EXEC_PAUSE_LOOP_EXITING |
2461 SECONDARY_EXEC_RDTSCP; 2477 SECONDARY_EXEC_RDTSCP |
2478 SECONDARY_EXEC_ENABLE_INVPCID;
2462 if (adjust_vmx_controls(min2, opt2, 2479 if (adjust_vmx_controls(min2, opt2,
2463 MSR_IA32_VMX_PROCBASED_CTLS2, 2480 MSR_IA32_VMX_PROCBASED_CTLS2,
2464 &_cpu_based_2nd_exec_control) < 0) 2481 &_cpu_based_2nd_exec_control) < 0)
@@ -2645,8 +2662,12 @@ static __init int hardware_setup(void)
2645 !cpu_has_vmx_ept_4levels()) { 2662 !cpu_has_vmx_ept_4levels()) {
2646 enable_ept = 0; 2663 enable_ept = 0;
2647 enable_unrestricted_guest = 0; 2664 enable_unrestricted_guest = 0;
2665 enable_ept_ad_bits = 0;
2648 } 2666 }
2649 2667
2668 if (!cpu_has_vmx_ept_ad_bits())
2669 enable_ept_ad_bits = 0;
2670
2650 if (!cpu_has_vmx_unrestricted_guest()) 2671 if (!cpu_has_vmx_unrestricted_guest())
2651 enable_unrestricted_guest = 0; 2672 enable_unrestricted_guest = 0;
2652 2673
@@ -2770,6 +2791,7 @@ static void enter_rmode(struct kvm_vcpu *vcpu)
2770{ 2791{
2771 unsigned long flags; 2792 unsigned long flags;
2772 struct vcpu_vmx *vmx = to_vmx(vcpu); 2793 struct vcpu_vmx *vmx = to_vmx(vcpu);
2794 struct kvm_segment var;
2773 2795
2774 if (enable_unrestricted_guest) 2796 if (enable_unrestricted_guest)
2775 return; 2797 return;
@@ -2813,20 +2835,23 @@ static void enter_rmode(struct kvm_vcpu *vcpu)
2813 if (emulate_invalid_guest_state) 2835 if (emulate_invalid_guest_state)
2814 goto continue_rmode; 2836 goto continue_rmode;
2815 2837
2816 vmcs_write16(GUEST_SS_SELECTOR, vmcs_readl(GUEST_SS_BASE) >> 4); 2838 vmx_get_segment(vcpu, &var, VCPU_SREG_SS);
2817 vmcs_write32(GUEST_SS_LIMIT, 0xffff); 2839 vmx_set_segment(vcpu, &var, VCPU_SREG_SS);
2818 vmcs_write32(GUEST_SS_AR_BYTES, 0xf3); 2840
2841 vmx_get_segment(vcpu, &var, VCPU_SREG_CS);
2842 vmx_set_segment(vcpu, &var, VCPU_SREG_CS);
2819 2843
2820 vmcs_write32(GUEST_CS_AR_BYTES, 0xf3); 2844 vmx_get_segment(vcpu, &var, VCPU_SREG_ES);
2821 vmcs_write32(GUEST_CS_LIMIT, 0xffff); 2845 vmx_set_segment(vcpu, &var, VCPU_SREG_ES);
2822 if (vmcs_readl(GUEST_CS_BASE) == 0xffff0000)
2823 vmcs_writel(GUEST_CS_BASE, 0xf0000);
2824 vmcs_write16(GUEST_CS_SELECTOR, vmcs_readl(GUEST_CS_BASE) >> 4);
2825 2846
2826 fix_rmode_seg(VCPU_SREG_ES, &vmx->rmode.es); 2847 vmx_get_segment(vcpu, &var, VCPU_SREG_DS);
2827 fix_rmode_seg(VCPU_SREG_DS, &vmx->rmode.ds); 2848 vmx_set_segment(vcpu, &var, VCPU_SREG_DS);
2828 fix_rmode_seg(VCPU_SREG_GS, &vmx->rmode.gs); 2849
2829 fix_rmode_seg(VCPU_SREG_FS, &vmx->rmode.fs); 2850 vmx_get_segment(vcpu, &var, VCPU_SREG_GS);
2851 vmx_set_segment(vcpu, &var, VCPU_SREG_GS);
2852
2853 vmx_get_segment(vcpu, &var, VCPU_SREG_FS);
2854 vmx_set_segment(vcpu, &var, VCPU_SREG_FS);
2830 2855
2831continue_rmode: 2856continue_rmode:
2832 kvm_mmu_reset_context(vcpu); 2857 kvm_mmu_reset_context(vcpu);
@@ -3027,6 +3052,8 @@ static u64 construct_eptp(unsigned long root_hpa)
3027 /* TODO write the value reading from MSR */ 3052 /* TODO write the value reading from MSR */
3028 eptp = VMX_EPT_DEFAULT_MT | 3053 eptp = VMX_EPT_DEFAULT_MT |
3029 VMX_EPT_DEFAULT_GAW << VMX_EPT_GAW_EPTP_SHIFT; 3054 VMX_EPT_DEFAULT_GAW << VMX_EPT_GAW_EPTP_SHIFT;
3055 if (enable_ept_ad_bits)
3056 eptp |= VMX_EPT_AD_ENABLE_BIT;
3030 eptp |= (root_hpa & PAGE_MASK); 3057 eptp |= (root_hpa & PAGE_MASK);
3031 3058
3032 return eptp; 3059 return eptp;
@@ -3153,11 +3180,22 @@ static int __vmx_get_cpl(struct kvm_vcpu *vcpu)
3153 3180
3154static int vmx_get_cpl(struct kvm_vcpu *vcpu) 3181static int vmx_get_cpl(struct kvm_vcpu *vcpu)
3155{ 3182{
3183 struct vcpu_vmx *vmx = to_vmx(vcpu);
3184
3185 /*
3186 * If we enter real mode with cs.sel & 3 != 0, the normal CPL calculations
3187 * fail; use the cache instead.
3188 */
3189 if (unlikely(vmx->emulation_required && emulate_invalid_guest_state)) {
3190 return vmx->cpl;
3191 }
3192
3156 if (!test_bit(VCPU_EXREG_CPL, (ulong *)&vcpu->arch.regs_avail)) { 3193 if (!test_bit(VCPU_EXREG_CPL, (ulong *)&vcpu->arch.regs_avail)) {
3157 __set_bit(VCPU_EXREG_CPL, (ulong *)&vcpu->arch.regs_avail); 3194 __set_bit(VCPU_EXREG_CPL, (ulong *)&vcpu->arch.regs_avail);
3158 to_vmx(vcpu)->cpl = __vmx_get_cpl(vcpu); 3195 vmx->cpl = __vmx_get_cpl(vcpu);
3159 } 3196 }
3160 return to_vmx(vcpu)->cpl; 3197
3198 return vmx->cpl;
3161} 3199}
3162 3200
3163 3201
@@ -3165,7 +3203,7 @@ static u32 vmx_segment_access_rights(struct kvm_segment *var)
3165{ 3203{
3166 u32 ar; 3204 u32 ar;
3167 3205
3168 if (var->unusable) 3206 if (var->unusable || !var->present)
3169 ar = 1 << 16; 3207 ar = 1 << 16;
3170 else { 3208 else {
3171 ar = var->type & 15; 3209 ar = var->type & 15;
@@ -3177,8 +3215,6 @@ static u32 vmx_segment_access_rights(struct kvm_segment *var)
3177 ar |= (var->db & 1) << 14; 3215 ar |= (var->db & 1) << 14;
3178 ar |= (var->g & 1) << 15; 3216 ar |= (var->g & 1) << 15;
3179 } 3217 }
3180 if (ar == 0) /* a 0 value means unusable */
3181 ar = AR_UNUSABLE_MASK;
3182 3218
3183 return ar; 3219 return ar;
3184} 3220}
@@ -3229,6 +3265,44 @@ static void vmx_set_segment(struct kvm_vcpu *vcpu,
3229 3265
3230 vmcs_write32(sf->ar_bytes, ar); 3266 vmcs_write32(sf->ar_bytes, ar);
3231 __clear_bit(VCPU_EXREG_CPL, (ulong *)&vcpu->arch.regs_avail); 3267 __clear_bit(VCPU_EXREG_CPL, (ulong *)&vcpu->arch.regs_avail);
3268
3269 /*
3270 * Fix segments for real mode guest in hosts that don't have
3271 * "unrestricted_mode" or it was disabled.
3272 * This is done to allow migration of the guests from hosts with
3273 * unrestricted guest like Westmere to older host that don't have
3274 * unrestricted guest like Nehelem.
3275 */
3276 if (!enable_unrestricted_guest && vmx->rmode.vm86_active) {
3277 switch (seg) {
3278 case VCPU_SREG_CS:
3279 vmcs_write32(GUEST_CS_AR_BYTES, 0xf3);
3280 vmcs_write32(GUEST_CS_LIMIT, 0xffff);
3281 if (vmcs_readl(GUEST_CS_BASE) == 0xffff0000)
3282 vmcs_writel(GUEST_CS_BASE, 0xf0000);
3283 vmcs_write16(GUEST_CS_SELECTOR,
3284 vmcs_readl(GUEST_CS_BASE) >> 4);
3285 break;
3286 case VCPU_SREG_ES:
3287 fix_rmode_seg(VCPU_SREG_ES, &vmx->rmode.es);
3288 break;
3289 case VCPU_SREG_DS:
3290 fix_rmode_seg(VCPU_SREG_DS, &vmx->rmode.ds);
3291 break;
3292 case VCPU_SREG_GS:
3293 fix_rmode_seg(VCPU_SREG_GS, &vmx->rmode.gs);
3294 break;
3295 case VCPU_SREG_FS:
3296 fix_rmode_seg(VCPU_SREG_FS, &vmx->rmode.fs);
3297 break;
3298 case VCPU_SREG_SS:
3299 vmcs_write16(GUEST_SS_SELECTOR,
3300 vmcs_readl(GUEST_SS_BASE) >> 4);
3301 vmcs_write32(GUEST_SS_LIMIT, 0xffff);
3302 vmcs_write32(GUEST_SS_AR_BYTES, 0xf3);
3303 break;
3304 }
3305 }
3232} 3306}
3233 3307
3234static void vmx_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l) 3308static void vmx_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l)
@@ -3731,6 +3805,8 @@ static u32 vmx_secondary_exec_control(struct vcpu_vmx *vmx)
3731 if (!enable_ept) { 3805 if (!enable_ept) {
3732 exec_control &= ~SECONDARY_EXEC_ENABLE_EPT; 3806 exec_control &= ~SECONDARY_EXEC_ENABLE_EPT;
3733 enable_unrestricted_guest = 0; 3807 enable_unrestricted_guest = 0;
3808 /* Enable INVPCID for non-ept guests may cause performance regression. */
3809 exec_control &= ~SECONDARY_EXEC_ENABLE_INVPCID;
3734 } 3810 }
3735 if (!enable_unrestricted_guest) 3811 if (!enable_unrestricted_guest)
3736 exec_control &= ~SECONDARY_EXEC_UNRESTRICTED_GUEST; 3812 exec_control &= ~SECONDARY_EXEC_UNRESTRICTED_GUEST;
@@ -4489,7 +4565,7 @@ static int handle_cr(struct kvm_vcpu *vcpu)
4489 break; 4565 break;
4490 } 4566 }
4491 vcpu->run->exit_reason = 0; 4567 vcpu->run->exit_reason = 0;
4492 pr_unimpl(vcpu, "unhandled control register: op %d cr %d\n", 4568 vcpu_unimpl(vcpu, "unhandled control register: op %d cr %d\n",
4493 (int)(exit_qualification >> 4) & 3, cr); 4569 (int)(exit_qualification >> 4) & 3, cr);
4494 return 0; 4570 return 0;
4495} 4571}
@@ -4769,6 +4845,7 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu)
4769{ 4845{
4770 unsigned long exit_qualification; 4846 unsigned long exit_qualification;
4771 gpa_t gpa; 4847 gpa_t gpa;
4848 u32 error_code;
4772 int gla_validity; 4849 int gla_validity;
4773 4850
4774 exit_qualification = vmcs_readl(EXIT_QUALIFICATION); 4851 exit_qualification = vmcs_readl(EXIT_QUALIFICATION);
@@ -4793,7 +4870,13 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu)
4793 4870
4794 gpa = vmcs_read64(GUEST_PHYSICAL_ADDRESS); 4871 gpa = vmcs_read64(GUEST_PHYSICAL_ADDRESS);
4795 trace_kvm_page_fault(gpa, exit_qualification); 4872 trace_kvm_page_fault(gpa, exit_qualification);
4796 return kvm_mmu_page_fault(vcpu, gpa, exit_qualification & 0x3, NULL, 0); 4873
4874 /* It is a write fault? */
4875 error_code = exit_qualification & (1U << 1);
4876 /* ept page table is present? */
4877 error_code |= (exit_qualification >> 3) & 0x1;
4878
4879 return kvm_mmu_page_fault(vcpu, gpa, error_code, NULL, 0);
4797} 4880}
4798 4881
4799static u64 ept_rsvd_mask(u64 spte, int level) 4882static u64 ept_rsvd_mask(u64 spte, int level)
@@ -4908,15 +4991,18 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)
4908 int ret = 1; 4991 int ret = 1;
4909 u32 cpu_exec_ctrl; 4992 u32 cpu_exec_ctrl;
4910 bool intr_window_requested; 4993 bool intr_window_requested;
4994 unsigned count = 130;
4911 4995
4912 cpu_exec_ctrl = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL); 4996 cpu_exec_ctrl = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);
4913 intr_window_requested = cpu_exec_ctrl & CPU_BASED_VIRTUAL_INTR_PENDING; 4997 intr_window_requested = cpu_exec_ctrl & CPU_BASED_VIRTUAL_INTR_PENDING;
4914 4998
4915 while (!guest_state_valid(vcpu)) { 4999 while (!guest_state_valid(vcpu) && count-- != 0) {
4916 if (intr_window_requested 5000 if (intr_window_requested && vmx_interrupt_allowed(vcpu))
4917 && (kvm_get_rflags(&vmx->vcpu) & X86_EFLAGS_IF))
4918 return handle_interrupt_window(&vmx->vcpu); 5001 return handle_interrupt_window(&vmx->vcpu);
4919 5002
5003 if (test_bit(KVM_REQ_EVENT, &vcpu->requests))
5004 return 1;
5005
4920 err = emulate_instruction(vcpu, 0); 5006 err = emulate_instruction(vcpu, 0);
4921 5007
4922 if (err == EMULATE_DO_MMIO) { 5008 if (err == EMULATE_DO_MMIO) {
@@ -4924,8 +5010,12 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)
4924 goto out; 5010 goto out;
4925 } 5011 }
4926 5012
4927 if (err != EMULATE_DONE) 5013 if (err != EMULATE_DONE) {
5014 vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
5015 vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
5016 vcpu->run->internal.ndata = 0;
4928 return 0; 5017 return 0;
5018 }
4929 5019
4930 if (signal_pending(current)) 5020 if (signal_pending(current))
4931 goto out; 5021 goto out;
@@ -4933,7 +5023,7 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)
4933 schedule(); 5023 schedule();
4934 } 5024 }
4935 5025
4936 vmx->emulation_required = 0; 5026 vmx->emulation_required = !guest_state_valid(vcpu);
4937out: 5027out:
4938 return ret; 5028 return ret;
4939} 5029}
@@ -6273,6 +6363,19 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
6273#endif 6363#endif
6274 ); 6364 );
6275 6365
6366#ifndef CONFIG_X86_64
6367 /*
6368 * The sysexit path does not restore ds/es, so we must set them to
6369 * a reasonable value ourselves.
6370 *
6371 * We can't defer this to vmx_load_host_state() since that function
6372 * may be executed in interrupt context, which saves and restore segments
6373 * around it, nullifying its effect.
6374 */
6375 loadsegment(ds, __USER_DS);
6376 loadsegment(es, __USER_DS);
6377#endif
6378
6276 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP) 6379 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
6277 | (1 << VCPU_EXREG_RFLAGS) 6380 | (1 << VCPU_EXREG_RFLAGS)
6278 | (1 << VCPU_EXREG_CPL) 6381 | (1 << VCPU_EXREG_CPL)
@@ -6467,6 +6570,23 @@ static void vmx_cpuid_update(struct kvm_vcpu *vcpu)
6467 } 6570 }
6468 } 6571 }
6469 } 6572 }
6573
6574 exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL);
6575 /* Exposing INVPCID only when PCID is exposed */
6576 best = kvm_find_cpuid_entry(vcpu, 0x7, 0);
6577 if (vmx_invpcid_supported() &&
6578 best && (best->ecx & bit(X86_FEATURE_INVPCID)) &&
6579 guest_cpuid_has_pcid(vcpu)) {
6580 exec_control |= SECONDARY_EXEC_ENABLE_INVPCID;
6581 vmcs_write32(SECONDARY_VM_EXEC_CONTROL,
6582 exec_control);
6583 } else {
6584 exec_control &= ~SECONDARY_EXEC_ENABLE_INVPCID;
6585 vmcs_write32(SECONDARY_VM_EXEC_CONTROL,
6586 exec_control);
6587 if (best)
6588 best->ecx &= ~bit(X86_FEATURE_INVPCID);
6589 }
6470} 6590}
6471 6591
6472static void vmx_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry) 6592static void vmx_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry)
@@ -7201,6 +7321,7 @@ static struct kvm_x86_ops vmx_x86_ops = {
7201 .cpuid_update = vmx_cpuid_update, 7321 .cpuid_update = vmx_cpuid_update,
7202 7322
7203 .rdtscp_supported = vmx_rdtscp_supported, 7323 .rdtscp_supported = vmx_rdtscp_supported,
7324 .invpcid_supported = vmx_invpcid_supported,
7204 7325
7205 .set_supported_cpuid = vmx_set_supported_cpuid, 7326 .set_supported_cpuid = vmx_set_supported_cpuid,
7206 7327
@@ -7230,23 +7351,21 @@ static int __init vmx_init(void)
7230 if (!vmx_io_bitmap_a) 7351 if (!vmx_io_bitmap_a)
7231 return -ENOMEM; 7352 return -ENOMEM;
7232 7353
7354 r = -ENOMEM;
7355
7233 vmx_io_bitmap_b = (unsigned long *)__get_free_page(GFP_KERNEL); 7356 vmx_io_bitmap_b = (unsigned long *)__get_free_page(GFP_KERNEL);
7234 if (!vmx_io_bitmap_b) { 7357 if (!vmx_io_bitmap_b)
7235 r = -ENOMEM;
7236 goto out; 7358 goto out;
7237 }
7238 7359
7239 vmx_msr_bitmap_legacy = (unsigned long *)__get_free_page(GFP_KERNEL); 7360 vmx_msr_bitmap_legacy = (unsigned long *)__get_free_page(GFP_KERNEL);
7240 if (!vmx_msr_bitmap_legacy) { 7361 if (!vmx_msr_bitmap_legacy)
7241 r = -ENOMEM;
7242 goto out1; 7362 goto out1;
7243 } 7363
7244 7364
7245 vmx_msr_bitmap_longmode = (unsigned long *)__get_free_page(GFP_KERNEL); 7365 vmx_msr_bitmap_longmode = (unsigned long *)__get_free_page(GFP_KERNEL);
7246 if (!vmx_msr_bitmap_longmode) { 7366 if (!vmx_msr_bitmap_longmode)
7247 r = -ENOMEM;
7248 goto out2; 7367 goto out2;
7249 } 7368
7250 7369
7251 /* 7370 /*
7252 * Allow direct access to the PC debug port (it is often used for I/O 7371 * Allow direct access to the PC debug port (it is often used for I/O
@@ -7275,8 +7394,10 @@ static int __init vmx_init(void)
7275 vmx_disable_intercept_for_msr(MSR_IA32_SYSENTER_EIP, false); 7394 vmx_disable_intercept_for_msr(MSR_IA32_SYSENTER_EIP, false);
7276 7395
7277 if (enable_ept) { 7396 if (enable_ept) {
7278 kvm_mmu_set_mask_ptes(0ull, 0ull, 0ull, 0ull, 7397 kvm_mmu_set_mask_ptes(0ull,
7279 VMX_EPT_EXECUTABLE_MASK); 7398 (enable_ept_ad_bits) ? VMX_EPT_ACCESS_BIT : 0ull,
7399 (enable_ept_ad_bits) ? VMX_EPT_DIRTY_BIT : 0ull,
7400 0ull, VMX_EPT_EXECUTABLE_MASK);
7280 ept_set_mmio_spte_mask(); 7401 ept_set_mmio_spte_mask();
7281 kvm_enable_tdp(); 7402 kvm_enable_tdp();
7282 } else 7403 } else
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index be6d54929fa..148ed666e31 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -528,6 +528,9 @@ int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
528 return 1; 528 return 1;
529 } 529 }
530 530
531 if (!(cr0 & X86_CR0_PG) && kvm_read_cr4_bits(vcpu, X86_CR4_PCIDE))
532 return 1;
533
531 kvm_x86_ops->set_cr0(vcpu, cr0); 534 kvm_x86_ops->set_cr0(vcpu, cr0);
532 535
533 if ((cr0 ^ old_cr0) & X86_CR0_PG) { 536 if ((cr0 ^ old_cr0) & X86_CR0_PG) {
@@ -604,10 +607,20 @@ int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
604 kvm_read_cr3(vcpu))) 607 kvm_read_cr3(vcpu)))
605 return 1; 608 return 1;
606 609
610 if ((cr4 & X86_CR4_PCIDE) && !(old_cr4 & X86_CR4_PCIDE)) {
611 if (!guest_cpuid_has_pcid(vcpu))
612 return 1;
613
614 /* PCID can not be enabled when cr3[11:0]!=000H or EFER.LMA=0 */
615 if ((kvm_read_cr3(vcpu) & X86_CR3_PCID_MASK) || !is_long_mode(vcpu))
616 return 1;
617 }
618
607 if (kvm_x86_ops->set_cr4(vcpu, cr4)) 619 if (kvm_x86_ops->set_cr4(vcpu, cr4))
608 return 1; 620 return 1;
609 621
610 if ((cr4 ^ old_cr4) & pdptr_bits) 622 if (((cr4 ^ old_cr4) & pdptr_bits) ||
623 (!(cr4 & X86_CR4_PCIDE) && (old_cr4 & X86_CR4_PCIDE)))
611 kvm_mmu_reset_context(vcpu); 624 kvm_mmu_reset_context(vcpu);
612 625
613 if ((cr4 ^ old_cr4) & X86_CR4_OSXSAVE) 626 if ((cr4 ^ old_cr4) & X86_CR4_OSXSAVE)
@@ -626,8 +639,12 @@ int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
626 } 639 }
627 640
628 if (is_long_mode(vcpu)) { 641 if (is_long_mode(vcpu)) {
629 if (cr3 & CR3_L_MODE_RESERVED_BITS) 642 if (kvm_read_cr4(vcpu) & X86_CR4_PCIDE) {
630 return 1; 643 if (cr3 & CR3_PCID_ENABLED_RESERVED_BITS)
644 return 1;
645 } else
646 if (cr3 & CR3_L_MODE_RESERVED_BITS)
647 return 1;
631 } else { 648 } else {
632 if (is_pae(vcpu)) { 649 if (is_pae(vcpu)) {
633 if (cr3 & CR3_PAE_RESERVED_BITS) 650 if (cr3 & CR3_PAE_RESERVED_BITS)
@@ -789,12 +806,13 @@ EXPORT_SYMBOL_GPL(kvm_rdpmc);
789 * kvm-specific. Those are put in the beginning of the list. 806 * kvm-specific. Those are put in the beginning of the list.
790 */ 807 */
791 808
792#define KVM_SAVE_MSRS_BEGIN 9 809#define KVM_SAVE_MSRS_BEGIN 10
793static u32 msrs_to_save[] = { 810static u32 msrs_to_save[] = {
794 MSR_KVM_SYSTEM_TIME, MSR_KVM_WALL_CLOCK, 811 MSR_KVM_SYSTEM_TIME, MSR_KVM_WALL_CLOCK,
795 MSR_KVM_SYSTEM_TIME_NEW, MSR_KVM_WALL_CLOCK_NEW, 812 MSR_KVM_SYSTEM_TIME_NEW, MSR_KVM_WALL_CLOCK_NEW,
796 HV_X64_MSR_GUEST_OS_ID, HV_X64_MSR_HYPERCALL, 813 HV_X64_MSR_GUEST_OS_ID, HV_X64_MSR_HYPERCALL,
797 HV_X64_MSR_APIC_ASSIST_PAGE, MSR_KVM_ASYNC_PF_EN, MSR_KVM_STEAL_TIME, 814 HV_X64_MSR_APIC_ASSIST_PAGE, MSR_KVM_ASYNC_PF_EN, MSR_KVM_STEAL_TIME,
815 MSR_KVM_PV_EOI_EN,
798 MSR_IA32_SYSENTER_CS, MSR_IA32_SYSENTER_ESP, MSR_IA32_SYSENTER_EIP, 816 MSR_IA32_SYSENTER_CS, MSR_IA32_SYSENTER_ESP, MSR_IA32_SYSENTER_EIP,
799 MSR_STAR, 817 MSR_STAR,
800#ifdef CONFIG_X86_64 818#ifdef CONFIG_X86_64
@@ -907,6 +925,10 @@ static void kvm_write_wall_clock(struct kvm *kvm, gpa_t wall_clock)
907 */ 925 */
908 getboottime(&boot); 926 getboottime(&boot);
909 927
928 if (kvm->arch.kvmclock_offset) {
929 struct timespec ts = ns_to_timespec(kvm->arch.kvmclock_offset);
930 boot = timespec_sub(boot, ts);
931 }
910 wc.sec = boot.tv_sec; 932 wc.sec = boot.tv_sec;
911 wc.nsec = boot.tv_nsec; 933 wc.nsec = boot.tv_nsec;
912 wc.version = version; 934 wc.version = version;
@@ -1437,8 +1459,8 @@ static int set_msr_hyperv_pw(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1437 break; 1459 break;
1438 } 1460 }
1439 default: 1461 default:
1440 pr_unimpl(vcpu, "HYPER-V unimplemented wrmsr: 0x%x " 1462 vcpu_unimpl(vcpu, "HYPER-V unimplemented wrmsr: 0x%x "
1441 "data 0x%llx\n", msr, data); 1463 "data 0x%llx\n", msr, data);
1442 return 1; 1464 return 1;
1443 } 1465 }
1444 return 0; 1466 return 0;
@@ -1470,8 +1492,8 @@ static int set_msr_hyperv(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1470 case HV_X64_MSR_TPR: 1492 case HV_X64_MSR_TPR:
1471 return kvm_hv_vapic_msr_write(vcpu, APIC_TASKPRI, data); 1493 return kvm_hv_vapic_msr_write(vcpu, APIC_TASKPRI, data);
1472 default: 1494 default:
1473 pr_unimpl(vcpu, "HYPER-V unimplemented wrmsr: 0x%x " 1495 vcpu_unimpl(vcpu, "HYPER-V unimplemented wrmsr: 0x%x "
1474 "data 0x%llx\n", msr, data); 1496 "data 0x%llx\n", msr, data);
1475 return 1; 1497 return 1;
1476 } 1498 }
1477 1499
@@ -1551,15 +1573,15 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1551 data &= ~(u64)0x100; /* ignore ignne emulation enable */ 1573 data &= ~(u64)0x100; /* ignore ignne emulation enable */
1552 data &= ~(u64)0x8; /* ignore TLB cache disable */ 1574 data &= ~(u64)0x8; /* ignore TLB cache disable */
1553 if (data != 0) { 1575 if (data != 0) {
1554 pr_unimpl(vcpu, "unimplemented HWCR wrmsr: 0x%llx\n", 1576 vcpu_unimpl(vcpu, "unimplemented HWCR wrmsr: 0x%llx\n",
1555 data); 1577 data);
1556 return 1; 1578 return 1;
1557 } 1579 }
1558 break; 1580 break;
1559 case MSR_FAM10H_MMIO_CONF_BASE: 1581 case MSR_FAM10H_MMIO_CONF_BASE:
1560 if (data != 0) { 1582 if (data != 0) {
1561 pr_unimpl(vcpu, "unimplemented MMIO_CONF_BASE wrmsr: " 1583 vcpu_unimpl(vcpu, "unimplemented MMIO_CONF_BASE wrmsr: "
1562 "0x%llx\n", data); 1584 "0x%llx\n", data);
1563 return 1; 1585 return 1;
1564 } 1586 }
1565 break; 1587 break;
@@ -1574,8 +1596,8 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1574 thus reserved and should throw a #GP */ 1596 thus reserved and should throw a #GP */
1575 return 1; 1597 return 1;
1576 } 1598 }
1577 pr_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTLMSR 0x%llx, nop\n", 1599 vcpu_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTLMSR 0x%llx, nop\n",
1578 __func__, data); 1600 __func__, data);
1579 break; 1601 break;
1580 case MSR_IA32_UCODE_REV: 1602 case MSR_IA32_UCODE_REV:
1581 case MSR_IA32_UCODE_WRITE: 1603 case MSR_IA32_UCODE_WRITE:
@@ -1653,6 +1675,10 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1653 kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu); 1675 kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu);
1654 1676
1655 break; 1677 break;
1678 case MSR_KVM_PV_EOI_EN:
1679 if (kvm_lapic_enable_pv_eoi(vcpu, data))
1680 return 1;
1681 break;
1656 1682
1657 case MSR_IA32_MCG_CTL: 1683 case MSR_IA32_MCG_CTL:
1658 case MSR_IA32_MCG_STATUS: 1684 case MSR_IA32_MCG_STATUS:
@@ -1671,8 +1697,8 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1671 case MSR_K7_EVNTSEL2: 1697 case MSR_K7_EVNTSEL2:
1672 case MSR_K7_EVNTSEL3: 1698 case MSR_K7_EVNTSEL3:
1673 if (data != 0) 1699 if (data != 0)
1674 pr_unimpl(vcpu, "unimplemented perfctr wrmsr: " 1700 vcpu_unimpl(vcpu, "unimplemented perfctr wrmsr: "
1675 "0x%x data 0x%llx\n", msr, data); 1701 "0x%x data 0x%llx\n", msr, data);
1676 break; 1702 break;
1677 /* at least RHEL 4 unconditionally writes to the perfctr registers, 1703 /* at least RHEL 4 unconditionally writes to the perfctr registers,
1678 * so we ignore writes to make it happy. 1704 * so we ignore writes to make it happy.
@@ -1681,8 +1707,8 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1681 case MSR_K7_PERFCTR1: 1707 case MSR_K7_PERFCTR1:
1682 case MSR_K7_PERFCTR2: 1708 case MSR_K7_PERFCTR2:
1683 case MSR_K7_PERFCTR3: 1709 case MSR_K7_PERFCTR3:
1684 pr_unimpl(vcpu, "unimplemented perfctr wrmsr: " 1710 vcpu_unimpl(vcpu, "unimplemented perfctr wrmsr: "
1685 "0x%x data 0x%llx\n", msr, data); 1711 "0x%x data 0x%llx\n", msr, data);
1686 break; 1712 break;
1687 case MSR_P6_PERFCTR0: 1713 case MSR_P6_PERFCTR0:
1688 case MSR_P6_PERFCTR1: 1714 case MSR_P6_PERFCTR1:
@@ -1693,8 +1719,8 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1693 return kvm_pmu_set_msr(vcpu, msr, data); 1719 return kvm_pmu_set_msr(vcpu, msr, data);
1694 1720
1695 if (pr || data != 0) 1721 if (pr || data != 0)
1696 pr_unimpl(vcpu, "disabled perfctr wrmsr: " 1722 vcpu_unimpl(vcpu, "disabled perfctr wrmsr: "
1697 "0x%x data 0x%llx\n", msr, data); 1723 "0x%x data 0x%llx\n", msr, data);
1698 break; 1724 break;
1699 case MSR_K7_CLK_CTL: 1725 case MSR_K7_CLK_CTL:
1700 /* 1726 /*
@@ -1720,7 +1746,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1720 /* Drop writes to this legacy MSR -- see rdmsr 1746 /* Drop writes to this legacy MSR -- see rdmsr
1721 * counterpart for further detail. 1747 * counterpart for further detail.
1722 */ 1748 */
1723 pr_unimpl(vcpu, "ignored wrmsr: 0x%x data %llx\n", msr, data); 1749 vcpu_unimpl(vcpu, "ignored wrmsr: 0x%x data %llx\n", msr, data);
1724 break; 1750 break;
1725 case MSR_AMD64_OSVW_ID_LENGTH: 1751 case MSR_AMD64_OSVW_ID_LENGTH:
1726 if (!guest_cpuid_has_osvw(vcpu)) 1752 if (!guest_cpuid_has_osvw(vcpu))
@@ -1738,12 +1764,12 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1738 if (kvm_pmu_msr(vcpu, msr)) 1764 if (kvm_pmu_msr(vcpu, msr))
1739 return kvm_pmu_set_msr(vcpu, msr, data); 1765 return kvm_pmu_set_msr(vcpu, msr, data);
1740 if (!ignore_msrs) { 1766 if (!ignore_msrs) {
1741 pr_unimpl(vcpu, "unhandled wrmsr: 0x%x data %llx\n", 1767 vcpu_unimpl(vcpu, "unhandled wrmsr: 0x%x data %llx\n",
1742 msr, data); 1768 msr, data);
1743 return 1; 1769 return 1;
1744 } else { 1770 } else {
1745 pr_unimpl(vcpu, "ignored wrmsr: 0x%x data %llx\n", 1771 vcpu_unimpl(vcpu, "ignored wrmsr: 0x%x data %llx\n",
1746 msr, data); 1772 msr, data);
1747 break; 1773 break;
1748 } 1774 }
1749 } 1775 }
@@ -1846,7 +1872,7 @@ static int get_msr_hyperv_pw(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
1846 data = kvm->arch.hv_hypercall; 1872 data = kvm->arch.hv_hypercall;
1847 break; 1873 break;
1848 default: 1874 default:
1849 pr_unimpl(vcpu, "Hyper-V unhandled rdmsr: 0x%x\n", msr); 1875 vcpu_unimpl(vcpu, "Hyper-V unhandled rdmsr: 0x%x\n", msr);
1850 return 1; 1876 return 1;
1851 } 1877 }
1852 1878
@@ -1877,7 +1903,7 @@ static int get_msr_hyperv(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
1877 data = vcpu->arch.hv_vapic; 1903 data = vcpu->arch.hv_vapic;
1878 break; 1904 break;
1879 default: 1905 default:
1880 pr_unimpl(vcpu, "Hyper-V unhandled rdmsr: 0x%x\n", msr); 1906 vcpu_unimpl(vcpu, "Hyper-V unhandled rdmsr: 0x%x\n", msr);
1881 return 1; 1907 return 1;
1882 } 1908 }
1883 *pdata = data; 1909 *pdata = data;
@@ -1974,6 +2000,9 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
1974 case MSR_KVM_STEAL_TIME: 2000 case MSR_KVM_STEAL_TIME:
1975 data = vcpu->arch.st.msr_val; 2001 data = vcpu->arch.st.msr_val;
1976 break; 2002 break;
2003 case MSR_KVM_PV_EOI_EN:
2004 data = vcpu->arch.pv_eoi.msr_val;
2005 break;
1977 case MSR_IA32_P5_MC_ADDR: 2006 case MSR_IA32_P5_MC_ADDR:
1978 case MSR_IA32_P5_MC_TYPE: 2007 case MSR_IA32_P5_MC_TYPE:
1979 case MSR_IA32_MCG_CAP: 2008 case MSR_IA32_MCG_CAP:
@@ -2030,10 +2059,10 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
2030 if (kvm_pmu_msr(vcpu, msr)) 2059 if (kvm_pmu_msr(vcpu, msr))
2031 return kvm_pmu_get_msr(vcpu, msr, pdata); 2060 return kvm_pmu_get_msr(vcpu, msr, pdata);
2032 if (!ignore_msrs) { 2061 if (!ignore_msrs) {
2033 pr_unimpl(vcpu, "unhandled rdmsr: 0x%x\n", msr); 2062 vcpu_unimpl(vcpu, "unhandled rdmsr: 0x%x\n", msr);
2034 return 1; 2063 return 1;
2035 } else { 2064 } else {
2036 pr_unimpl(vcpu, "ignored rdmsr: 0x%x\n", msr); 2065 vcpu_unimpl(vcpu, "ignored rdmsr: 0x%x\n", msr);
2037 data = 0; 2066 data = 0;
2038 } 2067 }
2039 break; 2068 break;
@@ -4116,7 +4145,7 @@ static unsigned long emulator_get_cr(struct x86_emulate_ctxt *ctxt, int cr)
4116 value = kvm_get_cr8(vcpu); 4145 value = kvm_get_cr8(vcpu);
4117 break; 4146 break;
4118 default: 4147 default:
4119 vcpu_printf(vcpu, "%s: unexpected cr %u\n", __func__, cr); 4148 kvm_err("%s: unexpected cr %u\n", __func__, cr);
4120 return 0; 4149 return 0;
4121 } 4150 }
4122 4151
@@ -4145,7 +4174,7 @@ static int emulator_set_cr(struct x86_emulate_ctxt *ctxt, int cr, ulong val)
4145 res = kvm_set_cr8(vcpu, val); 4174 res = kvm_set_cr8(vcpu, val);
4146 break; 4175 break;
4147 default: 4176 default:
4148 vcpu_printf(vcpu, "%s: unexpected cr %u\n", __func__, cr); 4177 kvm_err("%s: unexpected cr %u\n", __func__, cr);
4149 res = -1; 4178 res = -1;
4150 } 4179 }
4151 4180
@@ -4297,26 +4326,10 @@ static int emulator_intercept(struct x86_emulate_ctxt *ctxt,
4297 return kvm_x86_ops->check_intercept(emul_to_vcpu(ctxt), info, stage); 4326 return kvm_x86_ops->check_intercept(emul_to_vcpu(ctxt), info, stage);
4298} 4327}
4299 4328
4300static bool emulator_get_cpuid(struct x86_emulate_ctxt *ctxt, 4329static void emulator_get_cpuid(struct x86_emulate_ctxt *ctxt,
4301 u32 *eax, u32 *ebx, u32 *ecx, u32 *edx) 4330 u32 *eax, u32 *ebx, u32 *ecx, u32 *edx)
4302{ 4331{
4303 struct kvm_cpuid_entry2 *cpuid = NULL; 4332 kvm_cpuid(emul_to_vcpu(ctxt), eax, ebx, ecx, edx);
4304
4305 if (eax && ecx)
4306 cpuid = kvm_find_cpuid_entry(emul_to_vcpu(ctxt),
4307 *eax, *ecx);
4308
4309 if (cpuid) {
4310 *eax = cpuid->eax;
4311 *ecx = cpuid->ecx;
4312 if (ebx)
4313 *ebx = cpuid->ebx;
4314 if (edx)
4315 *edx = cpuid->edx;
4316 return true;
4317 }
4318
4319 return false;
4320} 4333}
4321 4334
4322static struct x86_emulate_ops emulate_ops = { 4335static struct x86_emulate_ops emulate_ops = {
@@ -5296,8 +5309,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
5296 5309
5297 r = kvm_mmu_reload(vcpu); 5310 r = kvm_mmu_reload(vcpu);
5298 if (unlikely(r)) { 5311 if (unlikely(r)) {
5299 kvm_x86_ops->cancel_injection(vcpu); 5312 goto cancel_injection;
5300 goto out;
5301 } 5313 }
5302 5314
5303 preempt_disable(); 5315 preempt_disable();
@@ -5322,9 +5334,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
5322 smp_wmb(); 5334 smp_wmb();
5323 local_irq_enable(); 5335 local_irq_enable();
5324 preempt_enable(); 5336 preempt_enable();
5325 kvm_x86_ops->cancel_injection(vcpu);
5326 r = 1; 5337 r = 1;
5327 goto out; 5338 goto cancel_injection;
5328 } 5339 }
5329 5340
5330 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); 5341 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
@@ -5388,9 +5399,16 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
5388 if (unlikely(vcpu->arch.tsc_always_catchup)) 5399 if (unlikely(vcpu->arch.tsc_always_catchup))
5389 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu); 5400 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
5390 5401
5391 kvm_lapic_sync_from_vapic(vcpu); 5402 if (vcpu->arch.apic_attention)
5403 kvm_lapic_sync_from_vapic(vcpu);
5392 5404
5393 r = kvm_x86_ops->handle_exit(vcpu); 5405 r = kvm_x86_ops->handle_exit(vcpu);
5406 return r;
5407
5408cancel_injection:
5409 kvm_x86_ops->cancel_injection(vcpu);
5410 if (unlikely(vcpu->arch.apic_attention))
5411 kvm_lapic_sync_from_vapic(vcpu);
5394out: 5412out:
5395 return r; 5413 return r;
5396} 5414}
@@ -6304,7 +6322,7 @@ void kvm_arch_free_memslot(struct kvm_memory_slot *free,
6304 6322
6305 for (i = 0; i < KVM_NR_PAGE_SIZES - 1; ++i) { 6323 for (i = 0; i < KVM_NR_PAGE_SIZES - 1; ++i) {
6306 if (!dont || free->arch.lpage_info[i] != dont->arch.lpage_info[i]) { 6324 if (!dont || free->arch.lpage_info[i] != dont->arch.lpage_info[i]) {
6307 vfree(free->arch.lpage_info[i]); 6325 kvm_kvfree(free->arch.lpage_info[i]);
6308 free->arch.lpage_info[i] = NULL; 6326 free->arch.lpage_info[i] = NULL;
6309 } 6327 }
6310 } 6328 }
@@ -6323,7 +6341,7 @@ int kvm_arch_create_memslot(struct kvm_memory_slot *slot, unsigned long npages)
6323 slot->base_gfn, level) + 1; 6341 slot->base_gfn, level) + 1;
6324 6342
6325 slot->arch.lpage_info[i] = 6343 slot->arch.lpage_info[i] =
6326 vzalloc(lpages * sizeof(*slot->arch.lpage_info[i])); 6344 kvm_kvzalloc(lpages * sizeof(*slot->arch.lpage_info[i]));
6327 if (!slot->arch.lpage_info[i]) 6345 if (!slot->arch.lpage_info[i])
6328 goto out_free; 6346 goto out_free;
6329 6347
@@ -6350,7 +6368,7 @@ int kvm_arch_create_memslot(struct kvm_memory_slot *slot, unsigned long npages)
6350 6368
6351out_free: 6369out_free:
6352 for (i = 0; i < KVM_NR_PAGE_SIZES - 1; ++i) { 6370 for (i = 0; i < KVM_NR_PAGE_SIZES - 1; ++i) {
6353 vfree(slot->arch.lpage_info[i]); 6371 kvm_kvfree(slot->arch.lpage_info[i]);
6354 slot->arch.lpage_info[i] = NULL; 6372 slot->arch.lpage_info[i] = NULL;
6355 } 6373 }
6356 return -ENOMEM; 6374 return -ENOMEM;
diff --git a/arch/x86/lib/msr-reg-export.c b/arch/x86/lib/msr-reg-export.c
index a311cc59b65..8d6ef78b5d0 100644
--- a/arch/x86/lib/msr-reg-export.c
+++ b/arch/x86/lib/msr-reg-export.c
@@ -1,5 +1,5 @@
1#include <linux/module.h> 1#include <linux/module.h>
2#include <asm/msr.h> 2#include <asm/msr.h>
3 3
4EXPORT_SYMBOL(native_rdmsr_safe_regs); 4EXPORT_SYMBOL(rdmsr_safe_regs);
5EXPORT_SYMBOL(native_wrmsr_safe_regs); 5EXPORT_SYMBOL(wrmsr_safe_regs);
diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
index 69fa10623f2..f6d13eefad1 100644
--- a/arch/x86/lib/msr-reg.S
+++ b/arch/x86/lib/msr-reg.S
@@ -6,13 +6,13 @@
6 6
7#ifdef CONFIG_X86_64 7#ifdef CONFIG_X86_64
8/* 8/*
9 * int native_{rdmsr,wrmsr}_safe_regs(u32 gprs[8]); 9 * int {rdmsr,wrmsr}_safe_regs(u32 gprs[8]);
10 * 10 *
11 * reg layout: u32 gprs[eax, ecx, edx, ebx, esp, ebp, esi, edi] 11 * reg layout: u32 gprs[eax, ecx, edx, ebx, esp, ebp, esi, edi]
12 * 12 *
13 */ 13 */
14.macro op_safe_regs op 14.macro op_safe_regs op
15ENTRY(native_\op\()_safe_regs) 15ENTRY(\op\()_safe_regs)
16 CFI_STARTPROC 16 CFI_STARTPROC
17 pushq_cfi %rbx 17 pushq_cfi %rbx
18 pushq_cfi %rbp 18 pushq_cfi %rbp
@@ -45,13 +45,13 @@ ENTRY(native_\op\()_safe_regs)
45 45
46 _ASM_EXTABLE(1b, 3b) 46 _ASM_EXTABLE(1b, 3b)
47 CFI_ENDPROC 47 CFI_ENDPROC
48ENDPROC(native_\op\()_safe_regs) 48ENDPROC(\op\()_safe_regs)
49.endm 49.endm
50 50
51#else /* X86_32 */ 51#else /* X86_32 */
52 52
53.macro op_safe_regs op 53.macro op_safe_regs op
54ENTRY(native_\op\()_safe_regs) 54ENTRY(\op\()_safe_regs)
55 CFI_STARTPROC 55 CFI_STARTPROC
56 pushl_cfi %ebx 56 pushl_cfi %ebx
57 pushl_cfi %ebp 57 pushl_cfi %ebp
@@ -92,7 +92,7 @@ ENTRY(native_\op\()_safe_regs)
92 92
93 _ASM_EXTABLE(1b, 3b) 93 _ASM_EXTABLE(1b, 3b)
94 CFI_ENDPROC 94 CFI_ENDPROC
95ENDPROC(native_\op\()_safe_regs) 95ENDPROC(\op\()_safe_regs)
96.endm 96.endm
97 97
98#endif 98#endif
diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
index f6679a7fb8c..b91e4851242 100644
--- a/arch/x86/mm/hugetlbpage.c
+++ b/arch/x86/mm/hugetlbpage.c
@@ -56,9 +56,16 @@ static int vma_shareable(struct vm_area_struct *vma, unsigned long addr)
56} 56}
57 57
58/* 58/*
59 * search for a shareable pmd page for hugetlb. 59 * Search for a shareable pmd page for hugetlb. In any case calls pmd_alloc()
60 * and returns the corresponding pte. While this is not necessary for the
61 * !shared pmd case because we can allocate the pmd later as well, it makes the
62 * code much cleaner. pmd allocation is essential for the shared case because
63 * pud has to be populated inside the same i_mmap_mutex section - otherwise
64 * racing tasks could either miss the sharing (see huge_pte_offset) or select a
65 * bad pmd for sharing.
60 */ 66 */
61static void huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud) 67static pte_t *
68huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
62{ 69{
63 struct vm_area_struct *vma = find_vma(mm, addr); 70 struct vm_area_struct *vma = find_vma(mm, addr);
64 struct address_space *mapping = vma->vm_file->f_mapping; 71 struct address_space *mapping = vma->vm_file->f_mapping;
@@ -68,9 +75,10 @@ static void huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
68 struct vm_area_struct *svma; 75 struct vm_area_struct *svma;
69 unsigned long saddr; 76 unsigned long saddr;
70 pte_t *spte = NULL; 77 pte_t *spte = NULL;
78 pte_t *pte;
71 79
72 if (!vma_shareable(vma, addr)) 80 if (!vma_shareable(vma, addr))
73 return; 81 return (pte_t *)pmd_alloc(mm, pud, addr);
74 82
75 mutex_lock(&mapping->i_mmap_mutex); 83 mutex_lock(&mapping->i_mmap_mutex);
76 vma_prio_tree_foreach(svma, &iter, &mapping->i_mmap, idx, idx) { 84 vma_prio_tree_foreach(svma, &iter, &mapping->i_mmap, idx, idx) {
@@ -97,7 +105,9 @@ static void huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
97 put_page(virt_to_page(spte)); 105 put_page(virt_to_page(spte));
98 spin_unlock(&mm->page_table_lock); 106 spin_unlock(&mm->page_table_lock);
99out: 107out:
108 pte = (pte_t *)pmd_alloc(mm, pud, addr);
100 mutex_unlock(&mapping->i_mmap_mutex); 109 mutex_unlock(&mapping->i_mmap_mutex);
110 return pte;
101} 111}
102 112
103/* 113/*
@@ -142,8 +152,9 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,
142 } else { 152 } else {
143 BUG_ON(sz != PMD_SIZE); 153 BUG_ON(sz != PMD_SIZE);
144 if (pud_none(*pud)) 154 if (pud_none(*pud))
145 huge_pmd_share(mm, addr, pud); 155 pte = huge_pmd_share(mm, addr, pud);
146 pte = (pte_t *) pmd_alloc(mm, pud, addr); 156 else
157 pte = (pte_t *)pmd_alloc(mm, pud, addr);
147 } 158 }
148 } 159 }
149 BUG_ON(pte && !pte_none(*pte) && !pte_huge(*pte)); 160 BUG_ON(pte && !pte_none(*pte) && !pte_huge(*pte));
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index bc4e9d84157..e0e6990723e 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -385,7 +385,7 @@ void free_initmem(void)
385} 385}
386 386
387#ifdef CONFIG_BLK_DEV_INITRD 387#ifdef CONFIG_BLK_DEV_INITRD
388void free_initrd_mem(unsigned long start, unsigned long end) 388void __init free_initrd_mem(unsigned long start, unsigned long end)
389{ 389{
390 /* 390 /*
391 * end could be not aligned, and We can not align that, 391 * end could be not aligned, and We can not align that,
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 575d86f85ce..4f04db15002 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -445,10 +445,10 @@ static inline void permanent_kmaps_init(pgd_t *pgd_base)
445} 445}
446#endif /* CONFIG_HIGHMEM */ 446#endif /* CONFIG_HIGHMEM */
447 447
448void __init native_pagetable_setup_start(pgd_t *base) 448void __init native_pagetable_init(void)
449{ 449{
450 unsigned long pfn, va; 450 unsigned long pfn, va;
451 pgd_t *pgd; 451 pgd_t *pgd, *base = swapper_pg_dir;
452 pud_t *pud; 452 pud_t *pud;
453 pmd_t *pmd; 453 pmd_t *pmd;
454 pte_t *pte; 454 pte_t *pte;
@@ -475,10 +475,7 @@ void __init native_pagetable_setup_start(pgd_t *base)
475 pte_clear(NULL, va, pte); 475 pte_clear(NULL, va, pte);
476 } 476 }
477 paravirt_alloc_pmd(&init_mm, __pa(base) >> PAGE_SHIFT); 477 paravirt_alloc_pmd(&init_mm, __pa(base) >> PAGE_SHIFT);
478} 478 paging_init();
479
480void __init native_pagetable_setup_done(pgd_t *base)
481{
482} 479}
483 480
484/* 481/*
@@ -493,7 +490,7 @@ void __init native_pagetable_setup_done(pgd_t *base)
493 * If we're booting paravirtualized under a hypervisor, then there are 490 * If we're booting paravirtualized under a hypervisor, then there are
494 * more options: we may already be running PAE, and the pagetable may 491 * more options: we may already be running PAE, and the pagetable may
495 * or may not be based in swapper_pg_dir. In any case, 492 * or may not be based in swapper_pg_dir. In any case,
496 * paravirt_pagetable_setup_start() will set up swapper_pg_dir 493 * paravirt_pagetable_init() will set up swapper_pg_dir
497 * appropriately for the rest of the initialization to work. 494 * appropriately for the rest of the initialization to work.
498 * 495 *
499 * In general, pagetable_init() assumes that the pagetable may already 496 * In general, pagetable_init() assumes that the pagetable may already
diff --git a/arch/x86/mm/srat.c b/arch/x86/mm/srat.c
index 4599c3e8bcb..4ddf497ca65 100644
--- a/arch/x86/mm/srat.c
+++ b/arch/x86/mm/srat.c
@@ -142,23 +142,23 @@ static inline int save_add_info(void) {return 0;}
142#endif 142#endif
143 143
144/* Callback for parsing of the Proximity Domain <-> Memory Area mappings */ 144/* Callback for parsing of the Proximity Domain <-> Memory Area mappings */
145void __init 145int __init
146acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) 146acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
147{ 147{
148 u64 start, end; 148 u64 start, end;
149 int node, pxm; 149 int node, pxm;
150 150
151 if (srat_disabled()) 151 if (srat_disabled())
152 return; 152 return -1;
153 if (ma->header.length != sizeof(struct acpi_srat_mem_affinity)) { 153 if (ma->header.length != sizeof(struct acpi_srat_mem_affinity)) {
154 bad_srat(); 154 bad_srat();
155 return; 155 return -1;
156 } 156 }
157 if ((ma->flags & ACPI_SRAT_MEM_ENABLED) == 0) 157 if ((ma->flags & ACPI_SRAT_MEM_ENABLED) == 0)
158 return; 158 return -1;
159 159
160 if ((ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) && !save_add_info()) 160 if ((ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) && !save_add_info())
161 return; 161 return -1;
162 start = ma->base_address; 162 start = ma->base_address;
163 end = start + ma->length; 163 end = start + ma->length;
164 pxm = ma->proximity_domain; 164 pxm = ma->proximity_domain;
@@ -168,12 +168,12 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
168 if (node < 0) { 168 if (node < 0) {
169 printk(KERN_ERR "SRAT: Too many proximity domains.\n"); 169 printk(KERN_ERR "SRAT: Too many proximity domains.\n");
170 bad_srat(); 170 bad_srat();
171 return; 171 return -1;
172 } 172 }
173 173
174 if (numa_add_memblk(node, start, end) < 0) { 174 if (numa_add_memblk(node, start, end) < 0) {
175 bad_srat(); 175 bad_srat();
176 return; 176 return -1;
177 } 177 }
178 178
179 node_set(node, numa_nodes_parsed); 179 node_set(node, numa_nodes_parsed);
@@ -181,6 +181,7 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
181 printk(KERN_INFO "SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]\n", 181 printk(KERN_INFO "SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]\n",
182 node, pxm, 182 node, pxm,
183 (unsigned long long) start, (unsigned long long) end - 1); 183 (unsigned long long) start, (unsigned long long) end - 1);
184 return 0;
184} 185}
185 186
186void __init acpi_numa_arch_fixup(void) {} 187void __init acpi_numa_arch_fixup(void) {}
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index 5e57e113b72..613cd83e8c0 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -12,6 +12,7 @@
12#include <asm/cache.h> 12#include <asm/cache.h>
13#include <asm/apic.h> 13#include <asm/apic.h>
14#include <asm/uv/uv.h> 14#include <asm/uv/uv.h>
15#include <linux/debugfs.h>
15 16
16DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate) 17DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate)
17 = { &init_mm, 0, }; 18 = { &init_mm, 0, };
@@ -27,33 +28,14 @@ DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate)
27 * 28 *
28 * More scalable flush, from Andi Kleen 29 * More scalable flush, from Andi Kleen
29 * 30 *
30 * To avoid global state use 8 different call vectors. 31 * Implement flush IPI by CALL_FUNCTION_VECTOR, Alex Shi
31 * Each CPU uses a specific vector to trigger flushes on other
32 * CPUs. Depending on the received vector the target CPUs look into
33 * the right array slot for the flush data.
34 *
35 * With more than 8 CPUs they are hashed to the 8 available
36 * vectors. The limited global vector space forces us to this right now.
37 * In future when interrupts are split into per CPU domains this could be
38 * fixed, at the cost of triggering multiple IPIs in some cases.
39 */ 32 */
40 33
41union smp_flush_state { 34struct flush_tlb_info {
42 struct { 35 struct mm_struct *flush_mm;
43 struct mm_struct *flush_mm; 36 unsigned long flush_start;
44 unsigned long flush_va; 37 unsigned long flush_end;
45 raw_spinlock_t tlbstate_lock; 38};
46 DECLARE_BITMAP(flush_cpumask, NR_CPUS);
47 };
48 char pad[INTERNODE_CACHE_BYTES];
49} ____cacheline_internodealigned_in_smp;
50
51/* State is put into the per CPU data section, but padded
52 to a full cache line because other CPUs can access it and we don't
53 want false sharing in the per cpu data segment. */
54static union smp_flush_state flush_state[NUM_INVALIDATE_TLB_VECTORS];
55
56static DEFINE_PER_CPU_READ_MOSTLY(int, tlb_vector_offset);
57 39
58/* 40/*
59 * We cannot call mmdrop() because we are in interrupt context, 41 * We cannot call mmdrop() because we are in interrupt context,
@@ -72,28 +54,25 @@ void leave_mm(int cpu)
72EXPORT_SYMBOL_GPL(leave_mm); 54EXPORT_SYMBOL_GPL(leave_mm);
73 55
74/* 56/*
75 *
76 * The flush IPI assumes that a thread switch happens in this order: 57 * The flush IPI assumes that a thread switch happens in this order:
77 * [cpu0: the cpu that switches] 58 * [cpu0: the cpu that switches]
78 * 1) switch_mm() either 1a) or 1b) 59 * 1) switch_mm() either 1a) or 1b)
79 * 1a) thread switch to a different mm 60 * 1a) thread switch to a different mm
80 * 1a1) cpu_clear(cpu, old_mm->cpu_vm_mask); 61 * 1a1) set cpu_tlbstate to TLBSTATE_OK
81 * Stop ipi delivery for the old mm. This is not synchronized with 62 * Now the tlb flush NMI handler flush_tlb_func won't call leave_mm
82 * the other cpus, but smp_invalidate_interrupt ignore flush ipis 63 * if cpu0 was in lazy tlb mode.
83 * for the wrong mm, and in the worst case we perform a superfluous 64 * 1a2) update cpu active_mm
84 * tlb flush.
85 * 1a2) set cpu mmu_state to TLBSTATE_OK
86 * Now the smp_invalidate_interrupt won't call leave_mm if cpu0
87 * was in lazy tlb mode.
88 * 1a3) update cpu active_mm
89 * Now cpu0 accepts tlb flushes for the new mm. 65 * Now cpu0 accepts tlb flushes for the new mm.
90 * 1a4) cpu_set(cpu, new_mm->cpu_vm_mask); 66 * 1a3) cpu_set(cpu, new_mm->cpu_vm_mask);
91 * Now the other cpus will send tlb flush ipis. 67 * Now the other cpus will send tlb flush ipis.
92 * 1a4) change cr3. 68 * 1a4) change cr3.
69 * 1a5) cpu_clear(cpu, old_mm->cpu_vm_mask);
70 * Stop ipi delivery for the old mm. This is not synchronized with
71 * the other cpus, but flush_tlb_func ignore flush ipis for the wrong
72 * mm, and in the worst case we perform a superfluous tlb flush.
93 * 1b) thread switch without mm change 73 * 1b) thread switch without mm change
94 * cpu active_mm is correct, cpu0 already handles 74 * cpu active_mm is correct, cpu0 already handles flush ipis.
95 * flush ipis. 75 * 1b1) set cpu_tlbstate to TLBSTATE_OK
96 * 1b1) set cpu mmu_state to TLBSTATE_OK
97 * 1b2) test_and_set the cpu bit in cpu_vm_mask. 76 * 1b2) test_and_set the cpu bit in cpu_vm_mask.
98 * Atomically set the bit [other cpus will start sending flush ipis], 77 * Atomically set the bit [other cpus will start sending flush ipis],
99 * and test the bit. 78 * and test the bit.
@@ -106,174 +85,62 @@ EXPORT_SYMBOL_GPL(leave_mm);
106 * runs in kernel space, the cpu could load tlb entries for user space 85 * runs in kernel space, the cpu could load tlb entries for user space
107 * pages. 86 * pages.
108 * 87 *
109 * The good news is that cpu mmu_state is local to each cpu, no 88 * The good news is that cpu_tlbstate is local to each cpu, no
110 * write/read ordering problems. 89 * write/read ordering problems.
111 */ 90 */
112 91
113/* 92/*
114 * TLB flush IPI: 93 * TLB flush funcation:
115 *
116 * 1) Flush the tlb entries if the cpu uses the mm that's being flushed. 94 * 1) Flush the tlb entries if the cpu uses the mm that's being flushed.
117 * 2) Leave the mm if we are in the lazy tlb mode. 95 * 2) Leave the mm if we are in the lazy tlb mode.
118 *
119 * Interrupts are disabled.
120 */
121
122/*
123 * FIXME: use of asmlinkage is not consistent. On x86_64 it's noop
124 * but still used for documentation purpose but the usage is slightly
125 * inconsistent. On x86_32, asmlinkage is regparm(0) but interrupt
126 * entry calls in with the first parameter in %eax. Maybe define
127 * intrlinkage?
128 */ 96 */
129#ifdef CONFIG_X86_64 97static void flush_tlb_func(void *info)
130asmlinkage
131#endif
132void smp_invalidate_interrupt(struct pt_regs *regs)
133{ 98{
134 unsigned int cpu; 99 struct flush_tlb_info *f = info;
135 unsigned int sender;
136 union smp_flush_state *f;
137
138 cpu = smp_processor_id();
139 /*
140 * orig_rax contains the negated interrupt vector.
141 * Use that to determine where the sender put the data.
142 */
143 sender = ~regs->orig_ax - INVALIDATE_TLB_VECTOR_START;
144 f = &flush_state[sender];
145
146 if (!cpumask_test_cpu(cpu, to_cpumask(f->flush_cpumask)))
147 goto out;
148 /*
149 * This was a BUG() but until someone can quote me the
150 * line from the intel manual that guarantees an IPI to
151 * multiple CPUs is retried _only_ on the erroring CPUs
152 * its staying as a return
153 *
154 * BUG();
155 */
156
157 if (f->flush_mm == this_cpu_read(cpu_tlbstate.active_mm)) {
158 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK) {
159 if (f->flush_va == TLB_FLUSH_ALL)
160 local_flush_tlb();
161 else
162 __flush_tlb_one(f->flush_va);
163 } else
164 leave_mm(cpu);
165 }
166out:
167 ack_APIC_irq();
168 smp_mb__before_clear_bit();
169 cpumask_clear_cpu(cpu, to_cpumask(f->flush_cpumask));
170 smp_mb__after_clear_bit();
171 inc_irq_stat(irq_tlb_count);
172}
173 100
174static void flush_tlb_others_ipi(const struct cpumask *cpumask, 101 if (f->flush_mm != this_cpu_read(cpu_tlbstate.active_mm))
175 struct mm_struct *mm, unsigned long va) 102 return;
176{ 103
177 unsigned int sender; 104 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK) {
178 union smp_flush_state *f; 105 if (f->flush_end == TLB_FLUSH_ALL || !cpu_has_invlpg)
179 106 local_flush_tlb();
180 /* Caller has disabled preemption */ 107 else if (!f->flush_end)
181 sender = this_cpu_read(tlb_vector_offset); 108 __flush_tlb_single(f->flush_start);
182 f = &flush_state[sender]; 109 else {
183 110 unsigned long addr;
184 if (nr_cpu_ids > NUM_INVALIDATE_TLB_VECTORS) 111 addr = f->flush_start;
185 raw_spin_lock(&f->tlbstate_lock); 112 while (addr < f->flush_end) {
186 113 __flush_tlb_single(addr);
187 f->flush_mm = mm; 114 addr += PAGE_SIZE;
188 f->flush_va = va; 115 }
189 if (cpumask_andnot(to_cpumask(f->flush_cpumask), cpumask, cpumask_of(smp_processor_id()))) { 116 }
190 /* 117 } else
191 * We have to send the IPI only to 118 leave_mm(smp_processor_id());
192 * CPUs affected.
193 */
194 apic->send_IPI_mask(to_cpumask(f->flush_cpumask),
195 INVALIDATE_TLB_VECTOR_START + sender);
196
197 while (!cpumask_empty(to_cpumask(f->flush_cpumask)))
198 cpu_relax();
199 }
200 119
201 f->flush_mm = NULL;
202 f->flush_va = 0;
203 if (nr_cpu_ids > NUM_INVALIDATE_TLB_VECTORS)
204 raw_spin_unlock(&f->tlbstate_lock);
205} 120}
206 121
207void native_flush_tlb_others(const struct cpumask *cpumask, 122void native_flush_tlb_others(const struct cpumask *cpumask,
208 struct mm_struct *mm, unsigned long va) 123 struct mm_struct *mm, unsigned long start,
124 unsigned long end)
209{ 125{
126 struct flush_tlb_info info;
127 info.flush_mm = mm;
128 info.flush_start = start;
129 info.flush_end = end;
130
210 if (is_uv_system()) { 131 if (is_uv_system()) {
211 unsigned int cpu; 132 unsigned int cpu;
212 133
213 cpu = smp_processor_id(); 134 cpu = smp_processor_id();
214 cpumask = uv_flush_tlb_others(cpumask, mm, va, cpu); 135 cpumask = uv_flush_tlb_others(cpumask, mm, start, end, cpu);
215 if (cpumask) 136 if (cpumask)
216 flush_tlb_others_ipi(cpumask, mm, va); 137 smp_call_function_many(cpumask, flush_tlb_func,
138 &info, 1);
217 return; 139 return;
218 } 140 }
219 flush_tlb_others_ipi(cpumask, mm, va); 141 smp_call_function_many(cpumask, flush_tlb_func, &info, 1);
220} 142}
221 143
222static void __cpuinit calculate_tlb_offset(void)
223{
224 int cpu, node, nr_node_vecs, idx = 0;
225 /*
226 * we are changing tlb_vector_offset for each CPU in runtime, but this
227 * will not cause inconsistency, as the write is atomic under X86. we
228 * might see more lock contentions in a short time, but after all CPU's
229 * tlb_vector_offset are changed, everything should go normal
230 *
231 * Note: if NUM_INVALIDATE_TLB_VECTORS % nr_online_nodes !=0, we might
232 * waste some vectors.
233 **/
234 if (nr_online_nodes > NUM_INVALIDATE_TLB_VECTORS)
235 nr_node_vecs = 1;
236 else
237 nr_node_vecs = NUM_INVALIDATE_TLB_VECTORS/nr_online_nodes;
238
239 for_each_online_node(node) {
240 int node_offset = (idx % NUM_INVALIDATE_TLB_VECTORS) *
241 nr_node_vecs;
242 int cpu_offset = 0;
243 for_each_cpu(cpu, cpumask_of_node(node)) {
244 per_cpu(tlb_vector_offset, cpu) = node_offset +
245 cpu_offset;
246 cpu_offset++;
247 cpu_offset = cpu_offset % nr_node_vecs;
248 }
249 idx++;
250 }
251}
252
253static int __cpuinit tlb_cpuhp_notify(struct notifier_block *n,
254 unsigned long action, void *hcpu)
255{
256 switch (action & 0xf) {
257 case CPU_ONLINE:
258 case CPU_DEAD:
259 calculate_tlb_offset();
260 }
261 return NOTIFY_OK;
262}
263
264static int __cpuinit init_smp_flush(void)
265{
266 int i;
267
268 for (i = 0; i < ARRAY_SIZE(flush_state); i++)
269 raw_spin_lock_init(&flush_state[i].tlbstate_lock);
270
271 calculate_tlb_offset();
272 hotcpu_notifier(tlb_cpuhp_notify, 0);
273 return 0;
274}
275core_initcall(init_smp_flush);
276
277void flush_tlb_current_task(void) 144void flush_tlb_current_task(void)
278{ 145{
279 struct mm_struct *mm = current->mm; 146 struct mm_struct *mm = current->mm;
@@ -282,27 +149,91 @@ void flush_tlb_current_task(void)
282 149
283 local_flush_tlb(); 150 local_flush_tlb();
284 if (cpumask_any_but(mm_cpumask(mm), smp_processor_id()) < nr_cpu_ids) 151 if (cpumask_any_but(mm_cpumask(mm), smp_processor_id()) < nr_cpu_ids)
285 flush_tlb_others(mm_cpumask(mm), mm, TLB_FLUSH_ALL); 152 flush_tlb_others(mm_cpumask(mm), mm, 0UL, TLB_FLUSH_ALL);
286 preempt_enable(); 153 preempt_enable();
287} 154}
288 155
289void flush_tlb_mm(struct mm_struct *mm) 156/*
157 * It can find out the THP large page, or
158 * HUGETLB page in tlb_flush when THP disabled
159 */
160static inline unsigned long has_large_page(struct mm_struct *mm,
161 unsigned long start, unsigned long end)
162{
163 pgd_t *pgd;
164 pud_t *pud;
165 pmd_t *pmd;
166 unsigned long addr = ALIGN(start, HPAGE_SIZE);
167 for (; addr < end; addr += HPAGE_SIZE) {
168 pgd = pgd_offset(mm, addr);
169 if (likely(!pgd_none(*pgd))) {
170 pud = pud_offset(pgd, addr);
171 if (likely(!pud_none(*pud))) {
172 pmd = pmd_offset(pud, addr);
173 if (likely(!pmd_none(*pmd)))
174 if (pmd_large(*pmd))
175 return addr;
176 }
177 }
178 }
179 return 0;
180}
181
182void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,
183 unsigned long end, unsigned long vmflag)
290{ 184{
185 unsigned long addr;
186 unsigned act_entries, tlb_entries = 0;
187
291 preempt_disable(); 188 preempt_disable();
189 if (current->active_mm != mm)
190 goto flush_all;
292 191
293 if (current->active_mm == mm) { 192 if (!current->mm) {
294 if (current->mm) 193 leave_mm(smp_processor_id());
194 goto flush_all;
195 }
196
197 if (end == TLB_FLUSH_ALL || tlb_flushall_shift == -1
198 || vmflag == VM_HUGETLB) {
199 local_flush_tlb();
200 goto flush_all;
201 }
202
203 /* In modern CPU, last level tlb used for both data/ins */
204 if (vmflag & VM_EXEC)
205 tlb_entries = tlb_lli_4k[ENTRIES];
206 else
207 tlb_entries = tlb_lld_4k[ENTRIES];
208 /* Assume all of TLB entries was occupied by this task */
209 act_entries = mm->total_vm > tlb_entries ? tlb_entries : mm->total_vm;
210
211 /* tlb_flushall_shift is on balance point, details in commit log */
212 if ((end - start) >> PAGE_SHIFT > act_entries >> tlb_flushall_shift)
213 local_flush_tlb();
214 else {
215 if (has_large_page(mm, start, end)) {
295 local_flush_tlb(); 216 local_flush_tlb();
296 else 217 goto flush_all;
297 leave_mm(smp_processor_id()); 218 }
219 /* flush range by one by one 'invlpg' */
220 for (addr = start; addr < end; addr += PAGE_SIZE)
221 __flush_tlb_single(addr);
222
223 if (cpumask_any_but(mm_cpumask(mm),
224 smp_processor_id()) < nr_cpu_ids)
225 flush_tlb_others(mm_cpumask(mm), mm, start, end);
226 preempt_enable();
227 return;
298 } 228 }
299 if (cpumask_any_but(mm_cpumask(mm), smp_processor_id()) < nr_cpu_ids)
300 flush_tlb_others(mm_cpumask(mm), mm, TLB_FLUSH_ALL);
301 229
230flush_all:
231 if (cpumask_any_but(mm_cpumask(mm), smp_processor_id()) < nr_cpu_ids)
232 flush_tlb_others(mm_cpumask(mm), mm, 0UL, TLB_FLUSH_ALL);
302 preempt_enable(); 233 preempt_enable();
303} 234}
304 235
305void flush_tlb_page(struct vm_area_struct *vma, unsigned long va) 236void flush_tlb_page(struct vm_area_struct *vma, unsigned long start)
306{ 237{
307 struct mm_struct *mm = vma->vm_mm; 238 struct mm_struct *mm = vma->vm_mm;
308 239
@@ -310,13 +241,13 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long va)
310 241
311 if (current->active_mm == mm) { 242 if (current->active_mm == mm) {
312 if (current->mm) 243 if (current->mm)
313 __flush_tlb_one(va); 244 __flush_tlb_one(start);
314 else 245 else
315 leave_mm(smp_processor_id()); 246 leave_mm(smp_processor_id());
316 } 247 }
317 248
318 if (cpumask_any_but(mm_cpumask(mm), smp_processor_id()) < nr_cpu_ids) 249 if (cpumask_any_but(mm_cpumask(mm), smp_processor_id()) < nr_cpu_ids)
319 flush_tlb_others(mm_cpumask(mm), mm, va); 250 flush_tlb_others(mm_cpumask(mm), mm, start, 0UL);
320 251
321 preempt_enable(); 252 preempt_enable();
322} 253}
@@ -332,3 +263,83 @@ void flush_tlb_all(void)
332{ 263{
333 on_each_cpu(do_flush_tlb_all, NULL, 1); 264 on_each_cpu(do_flush_tlb_all, NULL, 1);
334} 265}
266
267static void do_kernel_range_flush(void *info)
268{
269 struct flush_tlb_info *f = info;
270 unsigned long addr;
271
272 /* flush range by one by one 'invlpg' */
273 for (addr = f->flush_start; addr < f->flush_end; addr += PAGE_SIZE)
274 __flush_tlb_single(addr);
275}
276
277void flush_tlb_kernel_range(unsigned long start, unsigned long end)
278{
279 unsigned act_entries;
280 struct flush_tlb_info info;
281
282 /* In modern CPU, last level tlb used for both data/ins */
283 act_entries = tlb_lld_4k[ENTRIES];
284
285 /* Balance as user space task's flush, a bit conservative */
286 if (end == TLB_FLUSH_ALL || tlb_flushall_shift == -1 ||
287 (end - start) >> PAGE_SHIFT > act_entries >> tlb_flushall_shift)
288
289 on_each_cpu(do_flush_tlb_all, NULL, 1);
290 else {
291 info.flush_start = start;
292 info.flush_end = end;
293 on_each_cpu(do_kernel_range_flush, &info, 1);
294 }
295}
296
297#ifdef CONFIG_DEBUG_TLBFLUSH
298static ssize_t tlbflush_read_file(struct file *file, char __user *user_buf,
299 size_t count, loff_t *ppos)
300{
301 char buf[32];
302 unsigned int len;
303
304 len = sprintf(buf, "%hd\n", tlb_flushall_shift);
305 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
306}
307
308static ssize_t tlbflush_write_file(struct file *file,
309 const char __user *user_buf, size_t count, loff_t *ppos)
310{
311 char buf[32];
312 ssize_t len;
313 s8 shift;
314
315 len = min(count, sizeof(buf) - 1);
316 if (copy_from_user(buf, user_buf, len))
317 return -EFAULT;
318
319 buf[len] = '\0';
320 if (kstrtos8(buf, 0, &shift))
321 return -EINVAL;
322
323 if (shift > 64)
324 return -EINVAL;
325
326 tlb_flushall_shift = shift;
327 return count;
328}
329
330static const struct file_operations fops_tlbflush = {
331 .read = tlbflush_read_file,
332 .write = tlbflush_write_file,
333 .llseek = default_llseek,
334};
335
336static int __cpuinit create_tlb_flushall_shift(void)
337{
338 if (cpu_has_invlpg) {
339 debugfs_create_file("tlb_flushall_shift", S_IRUSR | S_IWUSR,
340 arch_debugfs_dir, NULL, &fops_tlbflush);
341 }
342 return 0;
343}
344late_initcall(create_tlb_flushall_shift);
345#endif
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 0597f95b6da..33643a8bcbb 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -309,6 +309,10 @@ void bpf_jit_compile(struct sk_filter *fp)
309 else 309 else
310 EMIT1_off32(0x0d, K); /* or imm32,%eax */ 310 EMIT1_off32(0x0d, K); /* or imm32,%eax */
311 break; 311 break;
312 case BPF_S_ANC_ALU_XOR_X: /* A ^= X; */
313 seen |= SEEN_XREG;
314 EMIT2(0x31, 0xd8); /* xor %ebx,%eax */
315 break;
312 case BPF_S_ALU_LSH_X: /* A <<= X; */ 316 case BPF_S_ALU_LSH_X: /* A <<= X; */
313 seen |= SEEN_XREG; 317 seen |= SEEN_XREG;
314 EMIT4(0x89, 0xd9, 0xd3, 0xe0); /* mov %ebx,%ecx; shl %cl,%eax */ 318 EMIT4(0x89, 0xd9, 0xd3, 0xe0); /* mov %ebx,%ecx; shl %cl,%eax */
diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
index 303f0863782..b2b94438ff0 100644
--- a/arch/x86/oprofile/op_model_amd.c
+++ b/arch/x86/oprofile/op_model_amd.c
@@ -312,7 +312,7 @@ static int op_amd_fill_in_addresses(struct op_msrs * const msrs)
312 goto fail; 312 goto fail;
313 } 313 }
314 /* both registers must be reserved */ 314 /* both registers must be reserved */
315 if (num_counters == AMD64_NUM_COUNTERS_F15H) { 315 if (num_counters == AMD64_NUM_COUNTERS_CORE) {
316 msrs->counters[i].addr = MSR_F15H_PERF_CTR + (i << 1); 316 msrs->counters[i].addr = MSR_F15H_PERF_CTR + (i << 1);
317 msrs->controls[i].addr = MSR_F15H_PERF_CTL + (i << 1); 317 msrs->controls[i].addr = MSR_F15H_PERF_CTL + (i << 1);
318 } else { 318 } else {
@@ -514,7 +514,7 @@ static int op_amd_init(struct oprofile_operations *ops)
514 ops->create_files = setup_ibs_files; 514 ops->create_files = setup_ibs_files;
515 515
516 if (boot_cpu_data.x86 == 0x15) { 516 if (boot_cpu_data.x86 == 0x15) {
517 num_counters = AMD64_NUM_COUNTERS_F15H; 517 num_counters = AMD64_NUM_COUNTERS_CORE;
518 } else { 518 } else {
519 num_counters = AMD64_NUM_COUNTERS; 519 num_counters = AMD64_NUM_COUNTERS;
520 } 520 }
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index fc09c2754e0..505acdd6d60 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -12,8 +12,13 @@ struct pci_root_info {
12 char name[16]; 12 char name[16];
13 unsigned int res_num; 13 unsigned int res_num;
14 struct resource *res; 14 struct resource *res;
15 int busnum;
16 struct pci_sysdata sd; 15 struct pci_sysdata sd;
16#ifdef CONFIG_PCI_MMCONFIG
17 bool mcfg_added;
18 u16 segment;
19 u8 start_bus;
20 u8 end_bus;
21#endif
17}; 22};
18 23
19static bool pci_use_crs = true; 24static bool pci_use_crs = true;
@@ -120,6 +125,81 @@ void __init pci_acpi_crs_quirks(void)
120 pci_use_crs ? "nocrs" : "use_crs"); 125 pci_use_crs ? "nocrs" : "use_crs");
121} 126}
122 127
128#ifdef CONFIG_PCI_MMCONFIG
129static int __devinit check_segment(u16 seg, struct device *dev, char *estr)
130{
131 if (seg) {
132 dev_err(dev,
133 "%s can't access PCI configuration "
134 "space under this host bridge.\n",
135 estr);
136 return -EIO;
137 }
138
139 /*
140 * Failure in adding MMCFG information is not fatal,
141 * just can't access extended configuration space of
142 * devices under this host bridge.
143 */
144 dev_warn(dev,
145 "%s can't access extended PCI configuration "
146 "space under this bridge.\n",
147 estr);
148
149 return 0;
150}
151
152static int __devinit setup_mcfg_map(struct pci_root_info *info,
153 u16 seg, u8 start, u8 end,
154 phys_addr_t addr)
155{
156 int result;
157 struct device *dev = &info->bridge->dev;
158
159 info->start_bus = start;
160 info->end_bus = end;
161 info->mcfg_added = false;
162
163 /* return success if MMCFG is not in use */
164 if (raw_pci_ext_ops && raw_pci_ext_ops != &pci_mmcfg)
165 return 0;
166
167 if (!(pci_probe & PCI_PROBE_MMCONF))
168 return check_segment(seg, dev, "MMCONFIG is disabled,");
169
170 result = pci_mmconfig_insert(dev, seg, start, end, addr);
171 if (result == 0) {
172 /* enable MMCFG if it hasn't been enabled yet */
173 if (raw_pci_ext_ops == NULL)
174 raw_pci_ext_ops = &pci_mmcfg;
175 info->mcfg_added = true;
176 } else if (result != -EEXIST)
177 return check_segment(seg, dev,
178 "fail to add MMCONFIG information,");
179
180 return 0;
181}
182
183static void teardown_mcfg_map(struct pci_root_info *info)
184{
185 if (info->mcfg_added) {
186 pci_mmconfig_delete(info->segment, info->start_bus,
187 info->end_bus);
188 info->mcfg_added = false;
189 }
190}
191#else
192static int __devinit setup_mcfg_map(struct pci_root_info *info,
193 u16 seg, u8 start, u8 end,
194 phys_addr_t addr)
195{
196 return 0;
197}
198static void teardown_mcfg_map(struct pci_root_info *info)
199{
200}
201#endif
202
123static acpi_status 203static acpi_status
124resource_to_addr(struct acpi_resource *resource, 204resource_to_addr(struct acpi_resource *resource,
125 struct acpi_resource_address64 *addr) 205 struct acpi_resource_address64 *addr)
@@ -234,13 +314,6 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
234 } 314 }
235 315
236 info->res_num++; 316 info->res_num++;
237 if (addr.translation_offset)
238 dev_info(&info->bridge->dev, "host bridge window %pR "
239 "(PCI address [%#llx-%#llx])\n",
240 res, res->start - addr.translation_offset,
241 res->end - addr.translation_offset);
242 else
243 dev_info(&info->bridge->dev, "host bridge window %pR\n", res);
244 317
245 return AE_OK; 318 return AE_OK;
246} 319}
@@ -332,8 +405,11 @@ static void __release_pci_root_info(struct pci_root_info *info)
332 405
333 free_pci_root_info_res(info); 406 free_pci_root_info_res(info);
334 407
408 teardown_mcfg_map(info);
409
335 kfree(info); 410 kfree(info);
336} 411}
412
337static void release_pci_root_info(struct pci_host_bridge *bridge) 413static void release_pci_root_info(struct pci_host_bridge *bridge)
338{ 414{
339 struct pci_root_info *info = bridge->release_data; 415 struct pci_root_info *info = bridge->release_data;
@@ -347,7 +423,9 @@ probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device,
347{ 423{
348 size_t size; 424 size_t size;
349 425
426 sprintf(info->name, "PCI Bus %04x:%02x", domain, busnum);
350 info->bridge = device; 427 info->bridge = device;
428
351 info->res_num = 0; 429 info->res_num = 0;
352 acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource, 430 acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource,
353 info); 431 info);
@@ -360,8 +438,6 @@ probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device,
360 if (!info->res) 438 if (!info->res)
361 return; 439 return;
362 440
363 sprintf(info->name, "PCI Bus %04x:%02x", domain, busnum);
364
365 acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource, 441 acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource,
366 info); 442 info);
367} 443}
@@ -373,7 +449,7 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
373 int domain = root->segment; 449 int domain = root->segment;
374 int busnum = root->secondary.start; 450 int busnum = root->secondary.start;
375 LIST_HEAD(resources); 451 LIST_HEAD(resources);
376 struct pci_bus *bus; 452 struct pci_bus *bus = NULL;
377 struct pci_sysdata *sd; 453 struct pci_sysdata *sd;
378 int node; 454 int node;
379#ifdef CONFIG_ACPI_NUMA 455#ifdef CONFIG_ACPI_NUMA
@@ -426,6 +502,8 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
426 } else { 502 } else {
427 probe_pci_root_info(info, device, busnum, domain); 503 probe_pci_root_info(info, device, busnum, domain);
428 504
505 /* insert busn res at first */
506 pci_add_resource(&resources, &root->secondary);
429 /* 507 /*
430 * _CRS with no apertures is normal, so only fall back to 508 * _CRS with no apertures is normal, so only fall back to
431 * defaults or native bridge info if we're ignoring _CRS. 509 * defaults or native bridge info if we're ignoring _CRS.
@@ -437,10 +515,13 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
437 x86_pci_root_bus_resources(busnum, &resources); 515 x86_pci_root_bus_resources(busnum, &resources);
438 } 516 }
439 517
440 bus = pci_create_root_bus(NULL, busnum, &pci_root_ops, sd, 518 if (!setup_mcfg_map(info, domain, (u8)root->secondary.start,
441 &resources); 519 (u8)root->secondary.end, root->mcfg_addr))
520 bus = pci_create_root_bus(NULL, busnum, &pci_root_ops,
521 sd, &resources);
522
442 if (bus) { 523 if (bus) {
443 bus->subordinate = pci_scan_child_bus(bus); 524 pci_scan_child_bus(bus);
444 pci_set_host_bridge_release( 525 pci_set_host_bridge_release(
445 to_pci_host_bridge(bus->bridge), 526 to_pci_host_bridge(bus->bridge),
446 release_pci_root_info, info); 527 release_pci_root_info, info);
diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
index 5aed49bff05..e9e6ed5cdf9 100644
--- a/arch/x86/pci/amd_bus.c
+++ b/arch/x86/pci/amd_bus.c
@@ -121,7 +121,6 @@ static int __init early_fill_mp_bus_info(void)
121 link = (reg >> 8) & 0x03; 121 link = (reg >> 8) & 0x03;
122 122
123 info = alloc_pci_root_info(min_bus, max_bus, node, link); 123 info = alloc_pci_root_info(min_bus, max_bus, node, link);
124 sprintf(info->name, "PCI Bus #%02x", min_bus);
125 } 124 }
126 125
127 /* get the default node and link for left over res */ 126 /* get the default node and link for left over res */
@@ -300,9 +299,9 @@ static int __init early_fill_mp_bus_info(void)
300 int busnum; 299 int busnum;
301 struct pci_root_res *root_res; 300 struct pci_root_res *root_res;
302 301
303 busnum = info->bus_min; 302 busnum = info->busn.start;
304 printk(KERN_DEBUG "bus: [%02x, %02x] on node %x link %x\n", 303 printk(KERN_DEBUG "bus: %pR on node %x link %x\n",
305 info->bus_min, info->bus_max, info->node, info->link); 304 &info->busn, info->node, info->link);
306 list_for_each_entry(root_res, &info->resources, list) 305 list_for_each_entry(root_res, &info->resources, list)
307 printk(KERN_DEBUG "bus: %02x %pR\n", 306 printk(KERN_DEBUG "bus: %02x %pR\n",
308 busnum, &root_res->res); 307 busnum, &root_res->res);
diff --git a/arch/x86/pci/bus_numa.c b/arch/x86/pci/bus_numa.c
index 306579f7d0f..d37e2fec97e 100644
--- a/arch/x86/pci/bus_numa.c
+++ b/arch/x86/pci/bus_numa.c
@@ -14,7 +14,7 @@ static struct pci_root_info *x86_find_pci_root_info(int bus)
14 return NULL; 14 return NULL;
15 15
16 list_for_each_entry(info, &pci_root_infos, list) 16 list_for_each_entry(info, &pci_root_infos, list)
17 if (info->bus_min == bus) 17 if (info->busn.start == bus)
18 return info; 18 return info;
19 19
20 return NULL; 20 return NULL;
@@ -24,6 +24,8 @@ void x86_pci_root_bus_resources(int bus, struct list_head *resources)
24{ 24{
25 struct pci_root_info *info = x86_find_pci_root_info(bus); 25 struct pci_root_info *info = x86_find_pci_root_info(bus);
26 struct pci_root_res *root_res; 26 struct pci_root_res *root_res;
27 struct pci_host_bridge_window *window;
28 bool found = false;
27 29
28 if (!info) 30 if (!info)
29 goto default_resources; 31 goto default_resources;
@@ -31,6 +33,16 @@ void x86_pci_root_bus_resources(int bus, struct list_head *resources)
31 printk(KERN_DEBUG "PCI: root bus %02x: hardware-probed resources\n", 33 printk(KERN_DEBUG "PCI: root bus %02x: hardware-probed resources\n",
32 bus); 34 bus);
33 35
36 /* already added by acpi ? */
37 list_for_each_entry(window, resources, list)
38 if (window->res->flags & IORESOURCE_BUS) {
39 found = true;
40 break;
41 }
42
43 if (!found)
44 pci_add_resource(resources, &info->busn);
45
34 list_for_each_entry(root_res, &info->resources, list) { 46 list_for_each_entry(root_res, &info->resources, list) {
35 struct resource *res; 47 struct resource *res;
36 struct resource *root; 48 struct resource *root;
@@ -66,9 +78,13 @@ struct pci_root_info __init *alloc_pci_root_info(int bus_min, int bus_max,
66 if (!info) 78 if (!info)
67 return info; 79 return info;
68 80
81 sprintf(info->name, "PCI Bus #%02x", bus_min);
82
69 INIT_LIST_HEAD(&info->resources); 83 INIT_LIST_HEAD(&info->resources);
70 info->bus_min = bus_min; 84 info->busn.name = info->name;
71 info->bus_max = bus_max; 85 info->busn.start = bus_min;
86 info->busn.end = bus_max;
87 info->busn.flags = IORESOURCE_BUS;
72 info->node = node; 88 info->node = node;
73 info->link = link; 89 info->link = link;
74 90
diff --git a/arch/x86/pci/bus_numa.h b/arch/x86/pci/bus_numa.h
index 226a466b2b2..ff8f65b0457 100644
--- a/arch/x86/pci/bus_numa.h
+++ b/arch/x86/pci/bus_numa.h
@@ -13,8 +13,7 @@ struct pci_root_info {
13 struct list_head list; 13 struct list_head list;
14 char name[12]; 14 char name[12];
15 struct list_head resources; 15 struct list_head resources;
16 int bus_min; 16 struct resource busn;
17 int bus_max;
18 int node; 17 int node;
19 int link; 18 int link;
20}; 19};
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 0ad990a20d4..720e973fc34 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -494,7 +494,7 @@ int __init pcibios_init(void)
494 return 0; 494 return 0;
495} 495}
496 496
497char * __devinit pcibios_setup(char *str) 497char * __init pcibios_setup(char *str)
498{ 498{
499 if (!strcmp(str, "off")) { 499 if (!strcmp(str, "off")) {
500 pci_probe = 0; 500 pci_probe = 0;
diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c
index 301e325992f..937bcece700 100644
--- a/arch/x86/pci/mmconfig-shared.c
+++ b/arch/x86/pci/mmconfig-shared.c
@@ -17,6 +17,8 @@
17#include <linux/bitmap.h> 17#include <linux/bitmap.h>
18#include <linux/dmi.h> 18#include <linux/dmi.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/mutex.h>
21#include <linux/rculist.h>
20#include <asm/e820.h> 22#include <asm/e820.h>
21#include <asm/pci_x86.h> 23#include <asm/pci_x86.h>
22#include <asm/acpi.h> 24#include <asm/acpi.h>
@@ -24,7 +26,9 @@
24#define PREFIX "PCI: " 26#define PREFIX "PCI: "
25 27
26/* Indicate if the mmcfg resources have been placed into the resource table. */ 28/* Indicate if the mmcfg resources have been placed into the resource table. */
27static int __initdata pci_mmcfg_resources_inserted; 29static bool pci_mmcfg_running_state;
30static bool pci_mmcfg_arch_init_failed;
31static DEFINE_MUTEX(pci_mmcfg_lock);
28 32
29LIST_HEAD(pci_mmcfg_list); 33LIST_HEAD(pci_mmcfg_list);
30 34
@@ -45,24 +49,25 @@ static __init void free_all_mmcfg(void)
45 pci_mmconfig_remove(cfg); 49 pci_mmconfig_remove(cfg);
46} 50}
47 51
48static __init void list_add_sorted(struct pci_mmcfg_region *new) 52static __devinit void list_add_sorted(struct pci_mmcfg_region *new)
49{ 53{
50 struct pci_mmcfg_region *cfg; 54 struct pci_mmcfg_region *cfg;
51 55
52 /* keep list sorted by segment and starting bus number */ 56 /* keep list sorted by segment and starting bus number */
53 list_for_each_entry(cfg, &pci_mmcfg_list, list) { 57 list_for_each_entry_rcu(cfg, &pci_mmcfg_list, list) {
54 if (cfg->segment > new->segment || 58 if (cfg->segment > new->segment ||
55 (cfg->segment == new->segment && 59 (cfg->segment == new->segment &&
56 cfg->start_bus >= new->start_bus)) { 60 cfg->start_bus >= new->start_bus)) {
57 list_add_tail(&new->list, &cfg->list); 61 list_add_tail_rcu(&new->list, &cfg->list);
58 return; 62 return;
59 } 63 }
60 } 64 }
61 list_add_tail(&new->list, &pci_mmcfg_list); 65 list_add_tail_rcu(&new->list, &pci_mmcfg_list);
62} 66}
63 67
64static __init struct pci_mmcfg_region *pci_mmconfig_add(int segment, int start, 68static __devinit struct pci_mmcfg_region *pci_mmconfig_alloc(int segment,
65 int end, u64 addr) 69 int start,
70 int end, u64 addr)
66{ 71{
67 struct pci_mmcfg_region *new; 72 struct pci_mmcfg_region *new;
68 struct resource *res; 73 struct resource *res;
@@ -79,8 +84,6 @@ static __init struct pci_mmcfg_region *pci_mmconfig_add(int segment, int start,
79 new->start_bus = start; 84 new->start_bus = start;
80 new->end_bus = end; 85 new->end_bus = end;
81 86
82 list_add_sorted(new);
83
84 res = &new->res; 87 res = &new->res;
85 res->start = addr + PCI_MMCFG_BUS_OFFSET(start); 88 res->start = addr + PCI_MMCFG_BUS_OFFSET(start);
86 res->end = addr + PCI_MMCFG_BUS_OFFSET(end + 1) - 1; 89 res->end = addr + PCI_MMCFG_BUS_OFFSET(end + 1) - 1;
@@ -89,9 +92,25 @@ static __init struct pci_mmcfg_region *pci_mmconfig_add(int segment, int start,
89 "PCI MMCONFIG %04x [bus %02x-%02x]", segment, start, end); 92 "PCI MMCONFIG %04x [bus %02x-%02x]", segment, start, end);
90 res->name = new->name; 93 res->name = new->name;
91 94
92 printk(KERN_INFO PREFIX "MMCONFIG for domain %04x [bus %02x-%02x] at " 95 return new;
93 "%pR (base %#lx)\n", segment, start, end, &new->res, 96}
94 (unsigned long) addr); 97
98static __init struct pci_mmcfg_region *pci_mmconfig_add(int segment, int start,
99 int end, u64 addr)
100{
101 struct pci_mmcfg_region *new;
102
103 new = pci_mmconfig_alloc(segment, start, end, addr);
104 if (new) {
105 mutex_lock(&pci_mmcfg_lock);
106 list_add_sorted(new);
107 mutex_unlock(&pci_mmcfg_lock);
108
109 pr_info(PREFIX
110 "MMCONFIG for domain %04x [bus %02x-%02x] at %pR "
111 "(base %#lx)\n",
112 segment, start, end, &new->res, (unsigned long)addr);
113 }
95 114
96 return new; 115 return new;
97} 116}
@@ -100,7 +119,7 @@ struct pci_mmcfg_region *pci_mmconfig_lookup(int segment, int bus)
100{ 119{
101 struct pci_mmcfg_region *cfg; 120 struct pci_mmcfg_region *cfg;
102 121
103 list_for_each_entry(cfg, &pci_mmcfg_list, list) 122 list_for_each_entry_rcu(cfg, &pci_mmcfg_list, list)
104 if (cfg->segment == segment && 123 if (cfg->segment == segment &&
105 cfg->start_bus <= bus && bus <= cfg->end_bus) 124 cfg->start_bus <= bus && bus <= cfg->end_bus)
106 return cfg; 125 return cfg;
@@ -343,8 +362,7 @@ static int __init pci_mmcfg_check_hostbridge(void)
343 name = pci_mmcfg_probes[i].probe(); 362 name = pci_mmcfg_probes[i].probe();
344 363
345 if (name) 364 if (name)
346 printk(KERN_INFO PREFIX "%s with MMCONFIG support\n", 365 pr_info(PREFIX "%s with MMCONFIG support\n", name);
347 name);
348 } 366 }
349 367
350 /* some end_bus_number is crazy, fix it */ 368 /* some end_bus_number is crazy, fix it */
@@ -353,19 +371,8 @@ static int __init pci_mmcfg_check_hostbridge(void)
353 return !list_empty(&pci_mmcfg_list); 371 return !list_empty(&pci_mmcfg_list);
354} 372}
355 373
356static void __init pci_mmcfg_insert_resources(void) 374static acpi_status __devinit check_mcfg_resource(struct acpi_resource *res,
357{ 375 void *data)
358 struct pci_mmcfg_region *cfg;
359
360 list_for_each_entry(cfg, &pci_mmcfg_list, list)
361 insert_resource(&iomem_resource, &cfg->res);
362
363 /* Mark that the resources have been inserted. */
364 pci_mmcfg_resources_inserted = 1;
365}
366
367static acpi_status __init check_mcfg_resource(struct acpi_resource *res,
368 void *data)
369{ 376{
370 struct resource *mcfg_res = data; 377 struct resource *mcfg_res = data;
371 struct acpi_resource_address64 address; 378 struct acpi_resource_address64 address;
@@ -401,8 +408,8 @@ static acpi_status __init check_mcfg_resource(struct acpi_resource *res,
401 return AE_OK; 408 return AE_OK;
402} 409}
403 410
404static acpi_status __init find_mboard_resource(acpi_handle handle, u32 lvl, 411static acpi_status __devinit find_mboard_resource(acpi_handle handle, u32 lvl,
405 void *context, void **rv) 412 void *context, void **rv)
406{ 413{
407 struct resource *mcfg_res = context; 414 struct resource *mcfg_res = context;
408 415
@@ -415,7 +422,7 @@ static acpi_status __init find_mboard_resource(acpi_handle handle, u32 lvl,
415 return AE_OK; 422 return AE_OK;
416} 423}
417 424
418static int __init is_acpi_reserved(u64 start, u64 end, unsigned not_used) 425static int __devinit is_acpi_reserved(u64 start, u64 end, unsigned not_used)
419{ 426{
420 struct resource mcfg_res; 427 struct resource mcfg_res;
421 428
@@ -434,13 +441,15 @@ static int __init is_acpi_reserved(u64 start, u64 end, unsigned not_used)
434 441
435typedef int (*check_reserved_t)(u64 start, u64 end, unsigned type); 442typedef int (*check_reserved_t)(u64 start, u64 end, unsigned type);
436 443
437static int __init is_mmconf_reserved(check_reserved_t is_reserved, 444static int __ref is_mmconf_reserved(check_reserved_t is_reserved,
438 struct pci_mmcfg_region *cfg, int with_e820) 445 struct pci_mmcfg_region *cfg,
446 struct device *dev, int with_e820)
439{ 447{
440 u64 addr = cfg->res.start; 448 u64 addr = cfg->res.start;
441 u64 size = resource_size(&cfg->res); 449 u64 size = resource_size(&cfg->res);
442 u64 old_size = size; 450 u64 old_size = size;
443 int valid = 0, num_buses; 451 int num_buses;
452 char *method = with_e820 ? "E820" : "ACPI motherboard resources";
444 453
445 while (!is_reserved(addr, addr + size, E820_RESERVED)) { 454 while (!is_reserved(addr, addr + size, E820_RESERVED)) {
446 size >>= 1; 455 size >>= 1;
@@ -448,30 +457,76 @@ static int __init is_mmconf_reserved(check_reserved_t is_reserved,
448 break; 457 break;
449 } 458 }
450 459
451 if (size >= (16UL<<20) || size == old_size) { 460 if (size < (16UL<<20) && size != old_size)
452 printk(KERN_INFO PREFIX "MMCONFIG at %pR reserved in %s\n", 461 return 0;
453 &cfg->res, 462
454 with_e820 ? "E820" : "ACPI motherboard resources"); 463 if (dev)
455 valid = 1; 464 dev_info(dev, "MMCONFIG at %pR reserved in %s\n",
456 465 &cfg->res, method);
457 if (old_size != size) { 466 else
458 /* update end_bus */ 467 pr_info(PREFIX "MMCONFIG at %pR reserved in %s\n",
459 cfg->end_bus = cfg->start_bus + ((size>>20) - 1); 468 &cfg->res, method);
460 num_buses = cfg->end_bus - cfg->start_bus + 1; 469
461 cfg->res.end = cfg->res.start + 470 if (old_size != size) {
462 PCI_MMCFG_BUS_OFFSET(num_buses) - 1; 471 /* update end_bus */
463 snprintf(cfg->name, PCI_MMCFG_RESOURCE_NAME_LEN, 472 cfg->end_bus = cfg->start_bus + ((size>>20) - 1);
464 "PCI MMCONFIG %04x [bus %02x-%02x]", 473 num_buses = cfg->end_bus - cfg->start_bus + 1;
465 cfg->segment, cfg->start_bus, cfg->end_bus); 474 cfg->res.end = cfg->res.start +
466 printk(KERN_INFO PREFIX 475 PCI_MMCFG_BUS_OFFSET(num_buses) - 1;
467 "MMCONFIG for %04x [bus%02x-%02x] " 476 snprintf(cfg->name, PCI_MMCFG_RESOURCE_NAME_LEN,
468 "at %pR (base %#lx) (size reduced!)\n", 477 "PCI MMCONFIG %04x [bus %02x-%02x]",
469 cfg->segment, cfg->start_bus, cfg->end_bus, 478 cfg->segment, cfg->start_bus, cfg->end_bus);
470 &cfg->res, (unsigned long) cfg->address); 479
471 } 480 if (dev)
481 dev_info(dev,
482 "MMCONFIG "
483 "at %pR (base %#lx) (size reduced!)\n",
484 &cfg->res, (unsigned long) cfg->address);
485 else
486 pr_info(PREFIX
487 "MMCONFIG for %04x [bus%02x-%02x] "
488 "at %pR (base %#lx) (size reduced!)\n",
489 cfg->segment, cfg->start_bus, cfg->end_bus,
490 &cfg->res, (unsigned long) cfg->address);
472 } 491 }
473 492
474 return valid; 493 return 1;
494}
495
496static int __ref pci_mmcfg_check_reserved(struct device *dev,
497 struct pci_mmcfg_region *cfg, int early)
498{
499 if (!early && !acpi_disabled) {
500 if (is_mmconf_reserved(is_acpi_reserved, cfg, dev, 0))
501 return 1;
502
503 if (dev)
504 dev_info(dev, FW_INFO
505 "MMCONFIG at %pR not reserved in "
506 "ACPI motherboard resources\n",
507 &cfg->res);
508 else
509 pr_info(FW_INFO PREFIX
510 "MMCONFIG at %pR not reserved in "
511 "ACPI motherboard resources\n",
512 &cfg->res);
513 }
514
515 /*
516 * e820_all_mapped() is marked as __init.
517 * All entries from ACPI MCFG table have been checked at boot time.
518 * For MCFG information constructed from hotpluggable host bridge's
519 * _CBA method, just assume it's reserved.
520 */
521 if (pci_mmcfg_running_state)
522 return 1;
523
524 /* Don't try to do this check unless configuration
525 type 1 is available. how about type 2 ?*/
526 if (raw_pci_ops)
527 return is_mmconf_reserved(e820_all_mapped, cfg, dev, 1);
528
529 return 0;
475} 530}
476 531
477static void __init pci_mmcfg_reject_broken(int early) 532static void __init pci_mmcfg_reject_broken(int early)
@@ -479,38 +534,14 @@ static void __init pci_mmcfg_reject_broken(int early)
479 struct pci_mmcfg_region *cfg; 534 struct pci_mmcfg_region *cfg;
480 535
481 list_for_each_entry(cfg, &pci_mmcfg_list, list) { 536 list_for_each_entry(cfg, &pci_mmcfg_list, list) {
482 int valid = 0; 537 if (pci_mmcfg_check_reserved(NULL, cfg, early) == 0) {
483 538 pr_info(PREFIX "not using MMCONFIG\n");
484 if (!early && !acpi_disabled) { 539 free_all_mmcfg();
485 valid = is_mmconf_reserved(is_acpi_reserved, cfg, 0); 540 return;
486
487 if (valid)
488 continue;
489 else
490 printk(KERN_ERR FW_BUG PREFIX
491 "MMCONFIG at %pR not reserved in "
492 "ACPI motherboard resources\n",
493 &cfg->res);
494 } 541 }
495
496 /* Don't try to do this check unless configuration
497 type 1 is available. how about type 2 ?*/
498 if (raw_pci_ops)
499 valid = is_mmconf_reserved(e820_all_mapped, cfg, 1);
500
501 if (!valid)
502 goto reject;
503 } 542 }
504
505 return;
506
507reject:
508 printk(KERN_INFO PREFIX "not using MMCONFIG\n");
509 free_all_mmcfg();
510} 543}
511 544
512static int __initdata known_bridge;
513
514static int __init acpi_mcfg_check_entry(struct acpi_table_mcfg *mcfg, 545static int __init acpi_mcfg_check_entry(struct acpi_table_mcfg *mcfg,
515 struct acpi_mcfg_allocation *cfg) 546 struct acpi_mcfg_allocation *cfg)
516{ 547{
@@ -529,7 +560,7 @@ static int __init acpi_mcfg_check_entry(struct acpi_table_mcfg *mcfg,
529 return 0; 560 return 0;
530 } 561 }
531 562
532 printk(KERN_ERR PREFIX "MCFG region for %04x [bus %02x-%02x] at %#llx " 563 pr_err(PREFIX "MCFG region for %04x [bus %02x-%02x] at %#llx "
533 "is above 4GB, ignored\n", cfg->pci_segment, 564 "is above 4GB, ignored\n", cfg->pci_segment,
534 cfg->start_bus_number, cfg->end_bus_number, cfg->address); 565 cfg->start_bus_number, cfg->end_bus_number, cfg->address);
535 return -EINVAL; 566 return -EINVAL;
@@ -556,7 +587,7 @@ static int __init pci_parse_mcfg(struct acpi_table_header *header)
556 i -= sizeof(struct acpi_mcfg_allocation); 587 i -= sizeof(struct acpi_mcfg_allocation);
557 }; 588 };
558 if (entries == 0) { 589 if (entries == 0) {
559 printk(KERN_ERR PREFIX "MMCONFIG has no entries\n"); 590 pr_err(PREFIX "MMCONFIG has no entries\n");
560 return -ENODEV; 591 return -ENODEV;
561 } 592 }
562 593
@@ -570,8 +601,7 @@ static int __init pci_parse_mcfg(struct acpi_table_header *header)
570 601
571 if (pci_mmconfig_add(cfg->pci_segment, cfg->start_bus_number, 602 if (pci_mmconfig_add(cfg->pci_segment, cfg->start_bus_number,
572 cfg->end_bus_number, cfg->address) == NULL) { 603 cfg->end_bus_number, cfg->address) == NULL) {
573 printk(KERN_WARNING PREFIX 604 pr_warn(PREFIX "no memory for MCFG entries\n");
574 "no memory for MCFG entries\n");
575 free_all_mmcfg(); 605 free_all_mmcfg();
576 return -ENOMEM; 606 return -ENOMEM;
577 } 607 }
@@ -582,28 +612,7 @@ static int __init pci_parse_mcfg(struct acpi_table_header *header)
582 612
583static void __init __pci_mmcfg_init(int early) 613static void __init __pci_mmcfg_init(int early)
584{ 614{
585 /* MMCONFIG disabled */
586 if ((pci_probe & PCI_PROBE_MMCONF) == 0)
587 return;
588
589 /* MMCONFIG already enabled */
590 if (!early && !(pci_probe & PCI_PROBE_MASK & ~PCI_PROBE_MMCONF))
591 return;
592
593 /* for late to exit */
594 if (known_bridge)
595 return;
596
597 if (early) {
598 if (pci_mmcfg_check_hostbridge())
599 known_bridge = 1;
600 }
601
602 if (!known_bridge)
603 acpi_sfi_table_parse(ACPI_SIG_MCFG, pci_parse_mcfg);
604
605 pci_mmcfg_reject_broken(early); 615 pci_mmcfg_reject_broken(early);
606
607 if (list_empty(&pci_mmcfg_list)) 616 if (list_empty(&pci_mmcfg_list))
608 return; 617 return;
609 618
@@ -620,33 +629,48 @@ static void __init __pci_mmcfg_init(int early)
620 if (pci_mmcfg_arch_init()) 629 if (pci_mmcfg_arch_init())
621 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; 630 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
622 else { 631 else {
623 /* 632 free_all_mmcfg();
624 * Signal not to attempt to insert mmcfg resources because 633 pci_mmcfg_arch_init_failed = true;
625 * the architecture mmcfg setup could not initialize.
626 */
627 pci_mmcfg_resources_inserted = 1;
628 } 634 }
629} 635}
630 636
637static int __initdata known_bridge;
638
631void __init pci_mmcfg_early_init(void) 639void __init pci_mmcfg_early_init(void)
632{ 640{
633 __pci_mmcfg_init(1); 641 if (pci_probe & PCI_PROBE_MMCONF) {
642 if (pci_mmcfg_check_hostbridge())
643 known_bridge = 1;
644 else
645 acpi_sfi_table_parse(ACPI_SIG_MCFG, pci_parse_mcfg);
646 __pci_mmcfg_init(1);
647 }
634} 648}
635 649
636void __init pci_mmcfg_late_init(void) 650void __init pci_mmcfg_late_init(void)
637{ 651{
638 __pci_mmcfg_init(0); 652 /* MMCONFIG disabled */
653 if ((pci_probe & PCI_PROBE_MMCONF) == 0)
654 return;
655
656 if (known_bridge)
657 return;
658
659 /* MMCONFIG hasn't been enabled yet, try again */
660 if (pci_probe & PCI_PROBE_MASK & ~PCI_PROBE_MMCONF) {
661 acpi_sfi_table_parse(ACPI_SIG_MCFG, pci_parse_mcfg);
662 __pci_mmcfg_init(0);
663 }
639} 664}
640 665
641static int __init pci_mmcfg_late_insert_resources(void) 666static int __init pci_mmcfg_late_insert_resources(void)
642{ 667{
643 /* 668 struct pci_mmcfg_region *cfg;
644 * If resources are already inserted or we are not using MMCONFIG, 669
645 * don't insert the resources. 670 pci_mmcfg_running_state = true;
646 */ 671
647 if ((pci_mmcfg_resources_inserted == 1) || 672 /* If we are not using MMCONFIG, don't insert the resources. */
648 (pci_probe & PCI_PROBE_MMCONF) == 0 || 673 if ((pci_probe & PCI_PROBE_MMCONF) == 0)
649 list_empty(&pci_mmcfg_list))
650 return 1; 674 return 1;
651 675
652 /* 676 /*
@@ -654,7 +678,9 @@ static int __init pci_mmcfg_late_insert_resources(void)
654 * marked so it won't cause request errors when __request_region is 678 * marked so it won't cause request errors when __request_region is
655 * called. 679 * called.
656 */ 680 */
657 pci_mmcfg_insert_resources(); 681 list_for_each_entry(cfg, &pci_mmcfg_list, list)
682 if (!cfg->res.parent)
683 insert_resource(&iomem_resource, &cfg->res);
658 684
659 return 0; 685 return 0;
660} 686}
@@ -665,3 +691,101 @@ static int __init pci_mmcfg_late_insert_resources(void)
665 * with other system resources. 691 * with other system resources.
666 */ 692 */
667late_initcall(pci_mmcfg_late_insert_resources); 693late_initcall(pci_mmcfg_late_insert_resources);
694
695/* Add MMCFG information for host bridges */
696int __devinit pci_mmconfig_insert(struct device *dev,
697 u16 seg, u8 start, u8 end,
698 phys_addr_t addr)
699{
700 int rc;
701 struct resource *tmp = NULL;
702 struct pci_mmcfg_region *cfg;
703
704 if (!(pci_probe & PCI_PROBE_MMCONF) || pci_mmcfg_arch_init_failed)
705 return -ENODEV;
706
707 if (start > end)
708 return -EINVAL;
709
710 mutex_lock(&pci_mmcfg_lock);
711 cfg = pci_mmconfig_lookup(seg, start);
712 if (cfg) {
713 if (cfg->end_bus < end)
714 dev_info(dev, FW_INFO
715 "MMCONFIG for "
716 "domain %04x [bus %02x-%02x] "
717 "only partially covers this bridge\n",
718 cfg->segment, cfg->start_bus, cfg->end_bus);
719 mutex_unlock(&pci_mmcfg_lock);
720 return -EEXIST;
721 }
722
723 if (!addr) {
724 mutex_unlock(&pci_mmcfg_lock);
725 return -EINVAL;
726 }
727
728 rc = -EBUSY;
729 cfg = pci_mmconfig_alloc(seg, start, end, addr);
730 if (cfg == NULL) {
731 dev_warn(dev, "fail to add MMCONFIG (out of memory)\n");
732 rc = -ENOMEM;
733 } else if (!pci_mmcfg_check_reserved(dev, cfg, 0)) {
734 dev_warn(dev, FW_BUG "MMCONFIG %pR isn't reserved\n",
735 &cfg->res);
736 } else {
737 /* Insert resource if it's not in boot stage */
738 if (pci_mmcfg_running_state)
739 tmp = insert_resource_conflict(&iomem_resource,
740 &cfg->res);
741
742 if (tmp) {
743 dev_warn(dev,
744 "MMCONFIG %pR conflicts with "
745 "%s %pR\n",
746 &cfg->res, tmp->name, tmp);
747 } else if (pci_mmcfg_arch_map(cfg)) {
748 dev_warn(dev, "fail to map MMCONFIG %pR.\n",
749 &cfg->res);
750 } else {
751 list_add_sorted(cfg);
752 dev_info(dev, "MMCONFIG at %pR (base %#lx)\n",
753 &cfg->res, (unsigned long)addr);
754 cfg = NULL;
755 rc = 0;
756 }
757 }
758
759 if (cfg) {
760 if (cfg->res.parent)
761 release_resource(&cfg->res);
762 kfree(cfg);
763 }
764
765 mutex_unlock(&pci_mmcfg_lock);
766
767 return rc;
768}
769
770/* Delete MMCFG information for host bridges */
771int pci_mmconfig_delete(u16 seg, u8 start, u8 end)
772{
773 struct pci_mmcfg_region *cfg;
774
775 mutex_lock(&pci_mmcfg_lock);
776 list_for_each_entry_rcu(cfg, &pci_mmcfg_list, list)
777 if (cfg->segment == seg && cfg->start_bus == start &&
778 cfg->end_bus == end) {
779 list_del_rcu(&cfg->list);
780 synchronize_rcu();
781 pci_mmcfg_arch_unmap(cfg);
782 if (cfg->res.parent)
783 release_resource(&cfg->res);
784 mutex_unlock(&pci_mmcfg_lock);
785 kfree(cfg);
786 return 0;
787 }
788 mutex_unlock(&pci_mmcfg_lock);
789
790 return -ENOENT;
791}
diff --git a/arch/x86/pci/mmconfig_32.c b/arch/x86/pci/mmconfig_32.c
index 5372e86834c..db63ac23e3d 100644
--- a/arch/x86/pci/mmconfig_32.c
+++ b/arch/x86/pci/mmconfig_32.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/pci.h> 12#include <linux/pci.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/rcupdate.h>
14#include <asm/e820.h> 15#include <asm/e820.h>
15#include <asm/pci_x86.h> 16#include <asm/pci_x86.h>
16#include <acpi/acpi.h> 17#include <acpi/acpi.h>
@@ -60,9 +61,12 @@ err: *value = -1;
60 return -EINVAL; 61 return -EINVAL;
61 } 62 }
62 63
64 rcu_read_lock();
63 base = get_base_addr(seg, bus, devfn); 65 base = get_base_addr(seg, bus, devfn);
64 if (!base) 66 if (!base) {
67 rcu_read_unlock();
65 goto err; 68 goto err;
69 }
66 70
67 raw_spin_lock_irqsave(&pci_config_lock, flags); 71 raw_spin_lock_irqsave(&pci_config_lock, flags);
68 72
@@ -80,6 +84,7 @@ err: *value = -1;
80 break; 84 break;
81 } 85 }
82 raw_spin_unlock_irqrestore(&pci_config_lock, flags); 86 raw_spin_unlock_irqrestore(&pci_config_lock, flags);
87 rcu_read_unlock();
83 88
84 return 0; 89 return 0;
85} 90}
@@ -93,9 +98,12 @@ static int pci_mmcfg_write(unsigned int seg, unsigned int bus,
93 if ((bus > 255) || (devfn > 255) || (reg > 4095)) 98 if ((bus > 255) || (devfn > 255) || (reg > 4095))
94 return -EINVAL; 99 return -EINVAL;
95 100
101 rcu_read_lock();
96 base = get_base_addr(seg, bus, devfn); 102 base = get_base_addr(seg, bus, devfn);
97 if (!base) 103 if (!base) {
104 rcu_read_unlock();
98 return -EINVAL; 105 return -EINVAL;
106 }
99 107
100 raw_spin_lock_irqsave(&pci_config_lock, flags); 108 raw_spin_lock_irqsave(&pci_config_lock, flags);
101 109
@@ -113,11 +121,12 @@ static int pci_mmcfg_write(unsigned int seg, unsigned int bus,
113 break; 121 break;
114 } 122 }
115 raw_spin_unlock_irqrestore(&pci_config_lock, flags); 123 raw_spin_unlock_irqrestore(&pci_config_lock, flags);
124 rcu_read_unlock();
116 125
117 return 0; 126 return 0;
118} 127}
119 128
120static const struct pci_raw_ops pci_mmcfg = { 129const struct pci_raw_ops pci_mmcfg = {
121 .read = pci_mmcfg_read, 130 .read = pci_mmcfg_read,
122 .write = pci_mmcfg_write, 131 .write = pci_mmcfg_write,
123}; 132};
@@ -132,3 +141,18 @@ int __init pci_mmcfg_arch_init(void)
132void __init pci_mmcfg_arch_free(void) 141void __init pci_mmcfg_arch_free(void)
133{ 142{
134} 143}
144
145int __devinit pci_mmcfg_arch_map(struct pci_mmcfg_region *cfg)
146{
147 return 0;
148}
149
150void pci_mmcfg_arch_unmap(struct pci_mmcfg_region *cfg)
151{
152 unsigned long flags;
153
154 /* Invalidate the cached mmcfg map entry. */
155 raw_spin_lock_irqsave(&pci_config_lock, flags);
156 mmcfg_last_accessed_device = 0;
157 raw_spin_unlock_irqrestore(&pci_config_lock, flags);
158}
diff --git a/arch/x86/pci/mmconfig_64.c b/arch/x86/pci/mmconfig_64.c
index 915a493502c..d4ebd07c306 100644
--- a/arch/x86/pci/mmconfig_64.c
+++ b/arch/x86/pci/mmconfig_64.c
@@ -9,6 +9,7 @@
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/acpi.h> 10#include <linux/acpi.h>
11#include <linux/bitmap.h> 11#include <linux/bitmap.h>
12#include <linux/rcupdate.h>
12#include <asm/e820.h> 13#include <asm/e820.h>
13#include <asm/pci_x86.h> 14#include <asm/pci_x86.h>
14 15
@@ -34,9 +35,12 @@ err: *value = -1;
34 return -EINVAL; 35 return -EINVAL;
35 } 36 }
36 37
38 rcu_read_lock();
37 addr = pci_dev_base(seg, bus, devfn); 39 addr = pci_dev_base(seg, bus, devfn);
38 if (!addr) 40 if (!addr) {
41 rcu_read_unlock();
39 goto err; 42 goto err;
43 }
40 44
41 switch (len) { 45 switch (len) {
42 case 1: 46 case 1:
@@ -49,6 +53,7 @@ err: *value = -1;
49 *value = mmio_config_readl(addr + reg); 53 *value = mmio_config_readl(addr + reg);
50 break; 54 break;
51 } 55 }
56 rcu_read_unlock();
52 57
53 return 0; 58 return 0;
54} 59}
@@ -62,9 +67,12 @@ static int pci_mmcfg_write(unsigned int seg, unsigned int bus,
62 if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095))) 67 if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095)))
63 return -EINVAL; 68 return -EINVAL;
64 69
70 rcu_read_lock();
65 addr = pci_dev_base(seg, bus, devfn); 71 addr = pci_dev_base(seg, bus, devfn);
66 if (!addr) 72 if (!addr) {
73 rcu_read_unlock();
67 return -EINVAL; 74 return -EINVAL;
75 }
68 76
69 switch (len) { 77 switch (len) {
70 case 1: 78 case 1:
@@ -77,16 +85,17 @@ static int pci_mmcfg_write(unsigned int seg, unsigned int bus,
77 mmio_config_writel(addr + reg, value); 85 mmio_config_writel(addr + reg, value);
78 break; 86 break;
79 } 87 }
88 rcu_read_unlock();
80 89
81 return 0; 90 return 0;
82} 91}
83 92
84static const struct pci_raw_ops pci_mmcfg = { 93const struct pci_raw_ops pci_mmcfg = {
85 .read = pci_mmcfg_read, 94 .read = pci_mmcfg_read,
86 .write = pci_mmcfg_write, 95 .write = pci_mmcfg_write,
87}; 96};
88 97
89static void __iomem * __init mcfg_ioremap(struct pci_mmcfg_region *cfg) 98static void __iomem * __devinit mcfg_ioremap(struct pci_mmcfg_region *cfg)
90{ 99{
91 void __iomem *addr; 100 void __iomem *addr;
92 u64 start, size; 101 u64 start, size;
@@ -105,16 +114,14 @@ int __init pci_mmcfg_arch_init(void)
105{ 114{
106 struct pci_mmcfg_region *cfg; 115 struct pci_mmcfg_region *cfg;
107 116
108 list_for_each_entry(cfg, &pci_mmcfg_list, list) { 117 list_for_each_entry(cfg, &pci_mmcfg_list, list)
109 cfg->virt = mcfg_ioremap(cfg); 118 if (pci_mmcfg_arch_map(cfg)) {
110 if (!cfg->virt) {
111 printk(KERN_ERR PREFIX "can't map MMCONFIG at %pR\n",
112 &cfg->res);
113 pci_mmcfg_arch_free(); 119 pci_mmcfg_arch_free();
114 return 0; 120 return 0;
115 } 121 }
116 } 122
117 raw_pci_ext_ops = &pci_mmcfg; 123 raw_pci_ext_ops = &pci_mmcfg;
124
118 return 1; 125 return 1;
119} 126}
120 127
@@ -122,10 +129,25 @@ void __init pci_mmcfg_arch_free(void)
122{ 129{
123 struct pci_mmcfg_region *cfg; 130 struct pci_mmcfg_region *cfg;
124 131
125 list_for_each_entry(cfg, &pci_mmcfg_list, list) { 132 list_for_each_entry(cfg, &pci_mmcfg_list, list)
126 if (cfg->virt) { 133 pci_mmcfg_arch_unmap(cfg);
127 iounmap(cfg->virt + PCI_MMCFG_BUS_OFFSET(cfg->start_bus)); 134}
128 cfg->virt = NULL; 135
129 } 136int __devinit pci_mmcfg_arch_map(struct pci_mmcfg_region *cfg)
137{
138 cfg->virt = mcfg_ioremap(cfg);
139 if (!cfg->virt) {
140 pr_err(PREFIX "can't map MMCONFIG at %pR\n", &cfg->res);
141 return -ENOMEM;
142 }
143
144 return 0;
145}
146
147void pci_mmcfg_arch_unmap(struct pci_mmcfg_region *cfg)
148{
149 if (cfg && cfg->virt) {
150 iounmap(cfg->virt + PCI_MMCFG_BUS_OFFSET(cfg->start_bus));
151 cfg->virt = NULL;
130 } 152 }
131} 153}
diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
index 140942f66b3..e14a2ff708b 100644
--- a/arch/x86/pci/mrst.c
+++ b/arch/x86/pci/mrst.c
@@ -264,7 +264,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_d3delay_fixup);
264 264
265static void __devinit mrst_power_off_unused_dev(struct pci_dev *dev) 265static void __devinit mrst_power_off_unused_dev(struct pci_dev *dev)
266{ 266{
267 pci_set_power_state(dev, PCI_D3cold); 267 pci_set_power_state(dev, PCI_D3hot);
268} 268}
269DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0801, mrst_power_off_unused_dev); 269DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0801, mrst_power_off_unused_dev);
270DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0809, mrst_power_off_unused_dev); 270DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0809, mrst_power_off_unused_dev);
diff --git a/arch/x86/platform/olpc/olpc-xo1-pm.c b/arch/x86/platform/olpc/olpc-xo1-pm.c
index 0ce8616c88a..d75582d1aa5 100644
--- a/arch/x86/platform/olpc/olpc-xo1-pm.c
+++ b/arch/x86/platform/olpc/olpc-xo1-pm.c
@@ -18,6 +18,7 @@
18#include <linux/pm.h> 18#include <linux/pm.h>
19#include <linux/mfd/core.h> 19#include <linux/mfd/core.h>
20#include <linux/suspend.h> 20#include <linux/suspend.h>
21#include <linux/olpc-ec.h>
21 22
22#include <asm/io.h> 23#include <asm/io.h>
23#include <asm/olpc.h> 24#include <asm/olpc.h>
@@ -51,16 +52,11 @@ EXPORT_SYMBOL_GPL(olpc_xo1_pm_wakeup_clear);
51static int xo1_power_state_enter(suspend_state_t pm_state) 52static int xo1_power_state_enter(suspend_state_t pm_state)
52{ 53{
53 unsigned long saved_sci_mask; 54 unsigned long saved_sci_mask;
54 int r;
55 55
56 /* Only STR is supported */ 56 /* Only STR is supported */
57 if (pm_state != PM_SUSPEND_MEM) 57 if (pm_state != PM_SUSPEND_MEM)
58 return -EINVAL; 58 return -EINVAL;
59 59
60 r = olpc_ec_cmd(EC_SET_SCI_INHIBIT, NULL, 0, NULL, 0);
61 if (r)
62 return r;
63
64 /* 60 /*
65 * Save SCI mask (this gets lost since PM1_EN is used as a mask for 61 * Save SCI mask (this gets lost since PM1_EN is used as a mask for
66 * wakeup events, which is not necessarily the same event set) 62 * wakeup events, which is not necessarily the same event set)
@@ -76,16 +72,6 @@ static int xo1_power_state_enter(suspend_state_t pm_state)
76 /* Restore SCI mask (using dword access to CS5536_PM1_EN) */ 72 /* Restore SCI mask (using dword access to CS5536_PM1_EN) */
77 outl(saved_sci_mask, acpi_base + CS5536_PM1_STS); 73 outl(saved_sci_mask, acpi_base + CS5536_PM1_STS);
78 74
79 /* Tell the EC to stop inhibiting SCIs */
80 olpc_ec_cmd(EC_SET_SCI_INHIBIT_RELEASE, NULL, 0, NULL, 0);
81
82 /*
83 * Tell the wireless module to restart USB communication.
84 * Must be done twice.
85 */
86 olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0);
87 olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0);
88
89 return 0; 75 return 0;
90} 76}
91 77
diff --git a/arch/x86/platform/olpc/olpc-xo1-sci.c b/arch/x86/platform/olpc/olpc-xo1-sci.c
index 04b8c73659c..63d4aa40956 100644
--- a/arch/x86/platform/olpc/olpc-xo1-sci.c
+++ b/arch/x86/platform/olpc/olpc-xo1-sci.c
@@ -23,6 +23,7 @@
23#include <linux/power_supply.h> 23#include <linux/power_supply.h>
24#include <linux/suspend.h> 24#include <linux/suspend.h>
25#include <linux/workqueue.h> 25#include <linux/workqueue.h>
26#include <linux/olpc-ec.h>
26 27
27#include <asm/io.h> 28#include <asm/io.h>
28#include <asm/msr.h> 29#include <asm/msr.h>
diff --git a/arch/x86/platform/olpc/olpc-xo15-sci.c b/arch/x86/platform/olpc/olpc-xo15-sci.c
index 23e5b9d7977..2fdca25905a 100644
--- a/arch/x86/platform/olpc/olpc-xo15-sci.c
+++ b/arch/x86/platform/olpc/olpc-xo15-sci.c
@@ -13,6 +13,7 @@
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/workqueue.h> 14#include <linux/workqueue.h>
15#include <linux/power_supply.h> 15#include <linux/power_supply.h>
16#include <linux/olpc-ec.h>
16 17
17#include <acpi/acpi_bus.h> 18#include <acpi/acpi_bus.h>
18#include <acpi/acpi_drivers.h> 19#include <acpi/acpi_drivers.h>
@@ -203,7 +204,7 @@ static int xo15_sci_remove(struct acpi_device *device, int type)
203 return 0; 204 return 0;
204} 205}
205 206
206static int xo15_sci_resume(struct acpi_device *device) 207static int xo15_sci_resume(struct device *dev)
207{ 208{
208 /* Enable all EC events */ 209 /* Enable all EC events */
209 olpc_ec_mask_write(EC_SCI_SRC_ALL); 210 olpc_ec_mask_write(EC_SCI_SRC_ALL);
@@ -215,6 +216,8 @@ static int xo15_sci_resume(struct acpi_device *device)
215 return 0; 216 return 0;
216} 217}
217 218
219static SIMPLE_DEV_PM_OPS(xo15_sci_pm, NULL, xo15_sci_resume);
220
218static const struct acpi_device_id xo15_sci_device_ids[] = { 221static const struct acpi_device_id xo15_sci_device_ids[] = {
219 {"XO15EC", 0}, 222 {"XO15EC", 0},
220 {"", 0}, 223 {"", 0},
@@ -227,8 +230,8 @@ static struct acpi_driver xo15_sci_drv = {
227 .ops = { 230 .ops = {
228 .add = xo15_sci_add, 231 .add = xo15_sci_add,
229 .remove = xo15_sci_remove, 232 .remove = xo15_sci_remove,
230 .resume = xo15_sci_resume,
231 }, 233 },
234 .drv.pm = &xo15_sci_pm,
232}; 235};
233 236
234static int __init xo15_sci_init(void) 237static int __init xo15_sci_init(void)
diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c
index a4bee53c2e5..27376081dde 100644
--- a/arch/x86/platform/olpc/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
@@ -14,14 +14,13 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/spinlock.h>
18#include <linux/io.h> 17#include <linux/io.h>
19#include <linux/string.h> 18#include <linux/string.h>
20#include <linux/platform_device.h> 19#include <linux/platform_device.h>
21#include <linux/of.h> 20#include <linux/of.h>
22#include <linux/syscore_ops.h> 21#include <linux/syscore_ops.h>
23#include <linux/debugfs.h>
24#include <linux/mutex.h> 22#include <linux/mutex.h>
23#include <linux/olpc-ec.h>
25 24
26#include <asm/geode.h> 25#include <asm/geode.h>
27#include <asm/setup.h> 26#include <asm/setup.h>
@@ -31,17 +30,6 @@
31struct olpc_platform_t olpc_platform_info; 30struct olpc_platform_t olpc_platform_info;
32EXPORT_SYMBOL_GPL(olpc_platform_info); 31EXPORT_SYMBOL_GPL(olpc_platform_info);
33 32
34static DEFINE_SPINLOCK(ec_lock);
35
36/* debugfs interface to EC commands */
37#define EC_MAX_CMD_ARGS (5 + 1) /* cmd byte + 5 args */
38#define EC_MAX_CMD_REPLY (8)
39
40static struct dentry *ec_debugfs_dir;
41static DEFINE_MUTEX(ec_debugfs_cmd_lock);
42static unsigned char ec_debugfs_resp[EC_MAX_CMD_REPLY];
43static unsigned int ec_debugfs_resp_bytes;
44
45/* EC event mask to be applied during suspend (defining wakeup sources). */ 33/* EC event mask to be applied during suspend (defining wakeup sources). */
46static u16 ec_wakeup_mask; 34static u16 ec_wakeup_mask;
47 35
@@ -125,16 +113,13 @@ static int __wait_on_obf(unsigned int line, unsigned int port, int desired)
125 * <http://wiki.laptop.org/go/Ec_specification>. Unfortunately, while 113 * <http://wiki.laptop.org/go/Ec_specification>. Unfortunately, while
126 * OpenFirmware's source is available, the EC's is not. 114 * OpenFirmware's source is available, the EC's is not.
127 */ 115 */
128int olpc_ec_cmd(unsigned char cmd, unsigned char *inbuf, size_t inlen, 116static int olpc_xo1_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
129 unsigned char *outbuf, size_t outlen) 117 size_t outlen, void *arg)
130{ 118{
131 unsigned long flags;
132 int ret = -EIO; 119 int ret = -EIO;
133 int i; 120 int i;
134 int restarts = 0; 121 int restarts = 0;
135 122
136 spin_lock_irqsave(&ec_lock, flags);
137
138 /* Clear OBF */ 123 /* Clear OBF */
139 for (i = 0; i < 10 && (obf_status(0x6c) == 1); i++) 124 for (i = 0; i < 10 && (obf_status(0x6c) == 1); i++)
140 inb(0x68); 125 inb(0x68);
@@ -198,10 +183,8 @@ restart:
198 183
199 ret = 0; 184 ret = 0;
200err: 185err:
201 spin_unlock_irqrestore(&ec_lock, flags);
202 return ret; 186 return ret;
203} 187}
204EXPORT_SYMBOL_GPL(olpc_ec_cmd);
205 188
206void olpc_ec_wakeup_set(u16 value) 189void olpc_ec_wakeup_set(u16 value)
207{ 190{
@@ -280,96 +263,6 @@ int olpc_ec_sci_query(u16 *sci_value)
280} 263}
281EXPORT_SYMBOL_GPL(olpc_ec_sci_query); 264EXPORT_SYMBOL_GPL(olpc_ec_sci_query);
282 265
283static ssize_t ec_debugfs_cmd_write(struct file *file, const char __user *buf,
284 size_t size, loff_t *ppos)
285{
286 int i, m;
287 unsigned char ec_cmd[EC_MAX_CMD_ARGS];
288 unsigned int ec_cmd_int[EC_MAX_CMD_ARGS];
289 char cmdbuf[64];
290 int ec_cmd_bytes;
291
292 mutex_lock(&ec_debugfs_cmd_lock);
293
294 size = simple_write_to_buffer(cmdbuf, sizeof(cmdbuf), ppos, buf, size);
295
296 m = sscanf(cmdbuf, "%x:%u %x %x %x %x %x", &ec_cmd_int[0],
297 &ec_debugfs_resp_bytes,
298 &ec_cmd_int[1], &ec_cmd_int[2], &ec_cmd_int[3],
299 &ec_cmd_int[4], &ec_cmd_int[5]);
300 if (m < 2 || ec_debugfs_resp_bytes > EC_MAX_CMD_REPLY) {
301 /* reset to prevent overflow on read */
302 ec_debugfs_resp_bytes = 0;
303
304 printk(KERN_DEBUG "olpc-ec: bad ec cmd: "
305 "cmd:response-count [arg1 [arg2 ...]]\n");
306 size = -EINVAL;
307 goto out;
308 }
309
310 /* convert scanf'd ints to char */
311 ec_cmd_bytes = m - 2;
312 for (i = 0; i <= ec_cmd_bytes; i++)
313 ec_cmd[i] = ec_cmd_int[i];
314
315 printk(KERN_DEBUG "olpc-ec: debugfs cmd 0x%02x with %d args "
316 "%02x %02x %02x %02x %02x, want %d returns\n",
317 ec_cmd[0], ec_cmd_bytes, ec_cmd[1], ec_cmd[2], ec_cmd[3],
318 ec_cmd[4], ec_cmd[5], ec_debugfs_resp_bytes);
319
320 olpc_ec_cmd(ec_cmd[0], (ec_cmd_bytes == 0) ? NULL : &ec_cmd[1],
321 ec_cmd_bytes, ec_debugfs_resp, ec_debugfs_resp_bytes);
322
323 printk(KERN_DEBUG "olpc-ec: response "
324 "%02x %02x %02x %02x %02x %02x %02x %02x (%d bytes expected)\n",
325 ec_debugfs_resp[0], ec_debugfs_resp[1], ec_debugfs_resp[2],
326 ec_debugfs_resp[3], ec_debugfs_resp[4], ec_debugfs_resp[5],
327 ec_debugfs_resp[6], ec_debugfs_resp[7], ec_debugfs_resp_bytes);
328
329out:
330 mutex_unlock(&ec_debugfs_cmd_lock);
331 return size;
332}
333
334static ssize_t ec_debugfs_cmd_read(struct file *file, char __user *buf,
335 size_t size, loff_t *ppos)
336{
337 unsigned int i, r;
338 char *rp;
339 char respbuf[64];
340
341 mutex_lock(&ec_debugfs_cmd_lock);
342 rp = respbuf;
343 rp += sprintf(rp, "%02x", ec_debugfs_resp[0]);
344 for (i = 1; i < ec_debugfs_resp_bytes; i++)
345 rp += sprintf(rp, ", %02x", ec_debugfs_resp[i]);
346 mutex_unlock(&ec_debugfs_cmd_lock);
347 rp += sprintf(rp, "\n");
348
349 r = rp - respbuf;
350 return simple_read_from_buffer(buf, size, ppos, respbuf, r);
351}
352
353static const struct file_operations ec_debugfs_genops = {
354 .write = ec_debugfs_cmd_write,
355 .read = ec_debugfs_cmd_read,
356};
357
358static void setup_debugfs(void)
359{
360 ec_debugfs_dir = debugfs_create_dir("olpc-ec", 0);
361 if (ec_debugfs_dir == ERR_PTR(-ENODEV))
362 return;
363
364 debugfs_create_file("cmd", 0600, ec_debugfs_dir, NULL,
365 &ec_debugfs_genops);
366}
367
368static int olpc_ec_suspend(void)
369{
370 return olpc_ec_mask_write(ec_wakeup_mask);
371}
372
373static bool __init check_ofw_architecture(struct device_node *root) 266static bool __init check_ofw_architecture(struct device_node *root)
374{ 267{
375 const char *olpc_arch; 268 const char *olpc_arch;
@@ -424,8 +317,59 @@ static int __init add_xo1_platform_devices(void)
424 return 0; 317 return 0;
425} 318}
426 319
427static struct syscore_ops olpc_syscore_ops = { 320static int olpc_xo1_ec_probe(struct platform_device *pdev)
428 .suspend = olpc_ec_suspend, 321{
322 /* get the EC revision */
323 olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0,
324 (unsigned char *) &olpc_platform_info.ecver, 1);
325
326 /* EC version 0x5f adds support for wide SCI mask */
327 if (olpc_platform_info.ecver >= 0x5f)
328 olpc_platform_info.flags |= OLPC_F_EC_WIDE_SCI;
329
330 pr_info("OLPC board revision %s%X (EC=%x)\n",
331 ((olpc_platform_info.boardrev & 0xf) < 8) ? "pre" : "",
332 olpc_platform_info.boardrev >> 4,
333 olpc_platform_info.ecver);
334
335 return 0;
336}
337static int olpc_xo1_ec_suspend(struct platform_device *pdev)
338{
339 olpc_ec_mask_write(ec_wakeup_mask);
340
341 /*
342 * Squelch SCIs while suspended. This is a fix for
343 * <http://dev.laptop.org/ticket/1835>.
344 */
345 return olpc_ec_cmd(EC_SET_SCI_INHIBIT, NULL, 0, NULL, 0);
346}
347
348static int olpc_xo1_ec_resume(struct platform_device *pdev)
349{
350 /* Tell the EC to stop inhibiting SCIs */
351 olpc_ec_cmd(EC_SET_SCI_INHIBIT_RELEASE, NULL, 0, NULL, 0);
352
353 /*
354 * Tell the wireless module to restart USB communication.
355 * Must be done twice.
356 */
357 olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0);
358 olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0);
359
360 return 0;
361}
362
363static struct olpc_ec_driver ec_xo1_driver = {
364 .probe = olpc_xo1_ec_probe,
365 .suspend = olpc_xo1_ec_suspend,
366 .resume = olpc_xo1_ec_resume,
367 .ec_cmd = olpc_xo1_ec_cmd,
368};
369
370static struct olpc_ec_driver ec_xo1_5_driver = {
371 .probe = olpc_xo1_ec_probe,
372 .ec_cmd = olpc_xo1_ec_cmd,
429}; 373};
430 374
431static int __init olpc_init(void) 375static int __init olpc_init(void)
@@ -435,16 +379,17 @@ static int __init olpc_init(void)
435 if (!olpc_ofw_present() || !platform_detect()) 379 if (!olpc_ofw_present() || !platform_detect())
436 return 0; 380 return 0;
437 381
438 spin_lock_init(&ec_lock); 382 /* register the XO-1 and 1.5-specific EC handler */
383 if (olpc_platform_info.boardrev < olpc_board_pre(0xd0)) /* XO-1 */
384 olpc_ec_driver_register(&ec_xo1_driver, NULL);
385 else
386 olpc_ec_driver_register(&ec_xo1_5_driver, NULL);
387 platform_device_register_simple("olpc-ec", -1, NULL, 0);
439 388
440 /* assume B1 and above models always have a DCON */ 389 /* assume B1 and above models always have a DCON */
441 if (olpc_board_at_least(olpc_board(0xb1))) 390 if (olpc_board_at_least(olpc_board(0xb1)))
442 olpc_platform_info.flags |= OLPC_F_DCON; 391 olpc_platform_info.flags |= OLPC_F_DCON;
443 392
444 /* get the EC revision */
445 olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0,
446 (unsigned char *) &olpc_platform_info.ecver, 1);
447
448#ifdef CONFIG_PCI_OLPC 393#ifdef CONFIG_PCI_OLPC
449 /* If the VSA exists let it emulate PCI, if not emulate in kernel. 394 /* If the VSA exists let it emulate PCI, if not emulate in kernel.
450 * XO-1 only. */ 395 * XO-1 only. */
@@ -452,14 +397,6 @@ static int __init olpc_init(void)
452 !cs5535_has_vsa2()) 397 !cs5535_has_vsa2())
453 x86_init.pci.arch_init = pci_olpc_init; 398 x86_init.pci.arch_init = pci_olpc_init;
454#endif 399#endif
455 /* EC version 0x5f adds support for wide SCI mask */
456 if (olpc_platform_info.ecver >= 0x5f)
457 olpc_platform_info.flags |= OLPC_F_EC_WIDE_SCI;
458
459 printk(KERN_INFO "OLPC board revision %s%X (EC=%x)\n",
460 ((olpc_platform_info.boardrev & 0xf) < 8) ? "pre" : "",
461 olpc_platform_info.boardrev >> 4,
462 olpc_platform_info.ecver);
463 400
464 if (olpc_platform_info.boardrev < olpc_board_pre(0xd0)) { /* XO-1 */ 401 if (olpc_platform_info.boardrev < olpc_board_pre(0xd0)) { /* XO-1 */
465 r = add_xo1_platform_devices(); 402 r = add_xo1_platform_devices();
@@ -467,9 +404,6 @@ static int __init olpc_init(void)
467 return r; 404 return r;
468 } 405 }
469 406
470 register_syscore_ops(&olpc_syscore_ops);
471 setup_debugfs();
472
473 return 0; 407 return 0;
474} 408}
475 409
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 59880afa851..b8b3a37c80c 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * SGI UltraViolet TLB flush routines. 2 * SGI UltraViolet TLB flush routines.
3 * 3 *
4 * (c) 2008-2011 Cliff Wickman <cpw@sgi.com>, SGI. 4 * (c) 2008-2012 Cliff Wickman <cpw@sgi.com>, SGI.
5 * 5 *
6 * This code is released under the GNU General Public License version 2 or 6 * This code is released under the GNU General Public License version 2 or
7 * later. 7 * later.
@@ -38,8 +38,7 @@ static int timeout_base_ns[] = {
38 38
39static int timeout_us; 39static int timeout_us;
40static int nobau; 40static int nobau;
41static int baudisabled; 41static int nobau_perm;
42static spinlock_t disable_lock;
43static cycles_t congested_cycles; 42static cycles_t congested_cycles;
44 43
45/* tunables: */ 44/* tunables: */
@@ -47,12 +46,13 @@ static int max_concurr = MAX_BAU_CONCURRENT;
47static int max_concurr_const = MAX_BAU_CONCURRENT; 46static int max_concurr_const = MAX_BAU_CONCURRENT;
48static int plugged_delay = PLUGGED_DELAY; 47static int plugged_delay = PLUGGED_DELAY;
49static int plugsb4reset = PLUGSB4RESET; 48static int plugsb4reset = PLUGSB4RESET;
49static int giveup_limit = GIVEUP_LIMIT;
50static int timeoutsb4reset = TIMEOUTSB4RESET; 50static int timeoutsb4reset = TIMEOUTSB4RESET;
51static int ipi_reset_limit = IPI_RESET_LIMIT; 51static int ipi_reset_limit = IPI_RESET_LIMIT;
52static int complete_threshold = COMPLETE_THRESHOLD; 52static int complete_threshold = COMPLETE_THRESHOLD;
53static int congested_respns_us = CONGESTED_RESPONSE_US; 53static int congested_respns_us = CONGESTED_RESPONSE_US;
54static int congested_reps = CONGESTED_REPS; 54static int congested_reps = CONGESTED_REPS;
55static int congested_period = CONGESTED_PERIOD; 55static int disabled_period = DISABLED_PERIOD;
56 56
57static struct tunables tunables[] = { 57static struct tunables tunables[] = {
58 {&max_concurr, MAX_BAU_CONCURRENT}, /* must be [0] */ 58 {&max_concurr, MAX_BAU_CONCURRENT}, /* must be [0] */
@@ -63,7 +63,8 @@ static struct tunables tunables[] = {
63 {&complete_threshold, COMPLETE_THRESHOLD}, 63 {&complete_threshold, COMPLETE_THRESHOLD},
64 {&congested_respns_us, CONGESTED_RESPONSE_US}, 64 {&congested_respns_us, CONGESTED_RESPONSE_US},
65 {&congested_reps, CONGESTED_REPS}, 65 {&congested_reps, CONGESTED_REPS},
66 {&congested_period, CONGESTED_PERIOD} 66 {&disabled_period, DISABLED_PERIOD},
67 {&giveup_limit, GIVEUP_LIMIT}
67}; 68};
68 69
69static struct dentry *tunables_dir; 70static struct dentry *tunables_dir;
@@ -120,6 +121,40 @@ static DEFINE_PER_CPU(struct ptc_stats, ptcstats);
120static DEFINE_PER_CPU(struct bau_control, bau_control); 121static DEFINE_PER_CPU(struct bau_control, bau_control);
121static DEFINE_PER_CPU(cpumask_var_t, uv_flush_tlb_mask); 122static DEFINE_PER_CPU(cpumask_var_t, uv_flush_tlb_mask);
122 123
124static void
125set_bau_on(void)
126{
127 int cpu;
128 struct bau_control *bcp;
129
130 if (nobau_perm) {
131 pr_info("BAU not initialized; cannot be turned on\n");
132 return;
133 }
134 nobau = 0;
135 for_each_present_cpu(cpu) {
136 bcp = &per_cpu(bau_control, cpu);
137 bcp->nobau = 0;
138 }
139 pr_info("BAU turned on\n");
140 return;
141}
142
143static void
144set_bau_off(void)
145{
146 int cpu;
147 struct bau_control *bcp;
148
149 nobau = 1;
150 for_each_present_cpu(cpu) {
151 bcp = &per_cpu(bau_control, cpu);
152 bcp->nobau = 1;
153 }
154 pr_info("BAU turned off\n");
155 return;
156}
157
123/* 158/*
124 * Determine the first node on a uvhub. 'Nodes' are used for kernel 159 * Determine the first node on a uvhub. 'Nodes' are used for kernel
125 * memory allocation. 160 * memory allocation.
@@ -278,7 +313,7 @@ static void bau_process_message(struct msg_desc *mdp, struct bau_control *bcp,
278 * Both sockets dump their completed count total into 313 * Both sockets dump their completed count total into
279 * the message's count. 314 * the message's count.
280 */ 315 */
281 smaster->socket_acknowledge_count[mdp->msg_slot] = 0; 316 *sp = 0;
282 asp = (struct atomic_short *)&msg->acknowledge_count; 317 asp = (struct atomic_short *)&msg->acknowledge_count;
283 msg_ack_count = atom_asr(socket_ack_count, asp); 318 msg_ack_count = atom_asr(socket_ack_count, asp);
284 319
@@ -491,16 +526,15 @@ static int uv1_wait_completion(struct bau_desc *bau_desc,
491} 526}
492 527
493/* 528/*
494 * UV2 has an extra bit of status in the ACTIVATION_STATUS_2 register. 529 * UV2 could have an extra bit of status in the ACTIVATION_STATUS_2 register.
530 * But not currently used.
495 */ 531 */
496static unsigned long uv2_read_status(unsigned long offset, int rshft, int desc) 532static unsigned long uv2_read_status(unsigned long offset, int rshft, int desc)
497{ 533{
498 unsigned long descriptor_status; 534 unsigned long descriptor_status;
499 unsigned long descriptor_status2;
500 535
501 descriptor_status = ((read_lmmr(offset) >> rshft) & UV_ACT_STATUS_MASK); 536 descriptor_status =
502 descriptor_status2 = (read_mmr_uv2_status() >> desc) & 0x1UL; 537 ((read_lmmr(offset) >> rshft) & UV_ACT_STATUS_MASK) << 1;
503 descriptor_status = (descriptor_status << 1) | descriptor_status2;
504 return descriptor_status; 538 return descriptor_status;
505} 539}
506 540
@@ -531,87 +565,11 @@ int normal_busy(struct bau_control *bcp)
531 */ 565 */
532int handle_uv2_busy(struct bau_control *bcp) 566int handle_uv2_busy(struct bau_control *bcp)
533{ 567{
534 int busy_one = bcp->using_desc;
535 int normal = bcp->uvhub_cpu;
536 int selected = -1;
537 int i;
538 unsigned long descriptor_status;
539 unsigned long status;
540 int mmr_offset;
541 struct bau_desc *bau_desc_old;
542 struct bau_desc *bau_desc_new;
543 struct bau_control *hmaster = bcp->uvhub_master;
544 struct ptc_stats *stat = bcp->statp; 568 struct ptc_stats *stat = bcp->statp;
545 cycles_t ttm;
546 569
547 stat->s_uv2_wars++; 570 stat->s_uv2_wars++;
548 spin_lock(&hmaster->uvhub_lock); 571 bcp->busy = 1;
549 /* try for the original first */ 572 return FLUSH_GIVEUP;
550 if (busy_one != normal) {
551 if (!normal_busy(bcp))
552 selected = normal;
553 }
554 if (selected < 0) {
555 /* can't use the normal, select an alternate */
556 mmr_offset = UVH_LB_BAU_SB_ACTIVATION_STATUS_1;
557 descriptor_status = read_lmmr(mmr_offset);
558
559 /* scan available descriptors 32-63 */
560 for (i = 0; i < UV_CPUS_PER_AS; i++) {
561 if ((hmaster->inuse_map & (1 << i)) == 0) {
562 status = ((descriptor_status >>
563 (i * UV_ACT_STATUS_SIZE)) &
564 UV_ACT_STATUS_MASK) << 1;
565 if (status != UV2H_DESC_BUSY) {
566 selected = i + UV_CPUS_PER_AS;
567 break;
568 }
569 }
570 }
571 }
572
573 if (busy_one != normal)
574 /* mark the busy alternate as not in-use */
575 hmaster->inuse_map &= ~(1 << (busy_one - UV_CPUS_PER_AS));
576
577 if (selected >= 0) {
578 /* switch to the selected descriptor */
579 if (selected != normal) {
580 /* set the selected alternate as in-use */
581 hmaster->inuse_map |=
582 (1 << (selected - UV_CPUS_PER_AS));
583 if (selected > stat->s_uv2_wars_hw)
584 stat->s_uv2_wars_hw = selected;
585 }
586 bau_desc_old = bcp->descriptor_base;
587 bau_desc_old += (ITEMS_PER_DESC * busy_one);
588 bcp->using_desc = selected;
589 bau_desc_new = bcp->descriptor_base;
590 bau_desc_new += (ITEMS_PER_DESC * selected);
591 *bau_desc_new = *bau_desc_old;
592 } else {
593 /*
594 * All are busy. Wait for the normal one for this cpu to
595 * free up.
596 */
597 stat->s_uv2_war_waits++;
598 spin_unlock(&hmaster->uvhub_lock);
599 ttm = get_cycles();
600 do {
601 cpu_relax();
602 } while (normal_busy(bcp));
603 spin_lock(&hmaster->uvhub_lock);
604 /* switch to the original descriptor */
605 bcp->using_desc = normal;
606 bau_desc_old = bcp->descriptor_base;
607 bau_desc_old += (ITEMS_PER_DESC * bcp->using_desc);
608 bcp->using_desc = (ITEMS_PER_DESC * normal);
609 bau_desc_new = bcp->descriptor_base;
610 bau_desc_new += (ITEMS_PER_DESC * normal);
611 *bau_desc_new = *bau_desc_old; /* copy the entire descriptor */
612 }
613 spin_unlock(&hmaster->uvhub_lock);
614 return FLUSH_RETRY_BUSYBUG;
615} 573}
616 574
617static int uv2_wait_completion(struct bau_desc *bau_desc, 575static int uv2_wait_completion(struct bau_desc *bau_desc,
@@ -620,7 +578,7 @@ static int uv2_wait_completion(struct bau_desc *bau_desc,
620{ 578{
621 unsigned long descriptor_stat; 579 unsigned long descriptor_stat;
622 cycles_t ttm; 580 cycles_t ttm;
623 int desc = bcp->using_desc; 581 int desc = bcp->uvhub_cpu;
624 long busy_reps = 0; 582 long busy_reps = 0;
625 struct ptc_stats *stat = bcp->statp; 583 struct ptc_stats *stat = bcp->statp;
626 584
@@ -628,24 +586,38 @@ static int uv2_wait_completion(struct bau_desc *bau_desc,
628 586
629 /* spin on the status MMR, waiting for it to go idle */ 587 /* spin on the status MMR, waiting for it to go idle */
630 while (descriptor_stat != UV2H_DESC_IDLE) { 588 while (descriptor_stat != UV2H_DESC_IDLE) {
631 /* 589 if ((descriptor_stat == UV2H_DESC_SOURCE_TIMEOUT)) {
632 * Our software ack messages may be blocked because 590 /*
633 * there are no swack resources available. As long 591 * A h/w bug on the destination side may
634 * as none of them has timed out hardware will NACK 592 * have prevented the message being marked
635 * our message and its state will stay IDLE. 593 * pending, thus it doesn't get replied to
636 */ 594 * and gets continually nacked until it times
637 if ((descriptor_stat == UV2H_DESC_SOURCE_TIMEOUT) || 595 * out with a SOURCE_TIMEOUT.
638 (descriptor_stat == UV2H_DESC_DEST_PUT_ERR)) { 596 */
639 stat->s_stimeout++; 597 stat->s_stimeout++;
640 return FLUSH_GIVEUP; 598 return FLUSH_GIVEUP;
641 } else if (descriptor_stat == UV2H_DESC_DEST_STRONG_NACK) {
642 stat->s_strongnacks++;
643 bcp->conseccompletes = 0;
644 return FLUSH_GIVEUP;
645 } else if (descriptor_stat == UV2H_DESC_DEST_TIMEOUT) { 599 } else if (descriptor_stat == UV2H_DESC_DEST_TIMEOUT) {
600 ttm = get_cycles();
601
602 /*
603 * Our retries may be blocked by all destination
604 * swack resources being consumed, and a timeout
605 * pending. In that case hardware returns the
606 * ERROR that looks like a destination timeout.
607 * Without using the extended status we have to
608 * deduce from the short time that this was a
609 * strong nack.
610 */
611 if (cycles_2_us(ttm - bcp->send_message) < timeout_us) {
612 bcp->conseccompletes = 0;
613 stat->s_plugged++;
614 /* FLUSH_RETRY_PLUGGED causes hang on boot */
615 return FLUSH_GIVEUP;
616 }
646 stat->s_dtimeout++; 617 stat->s_dtimeout++;
647 bcp->conseccompletes = 0; 618 bcp->conseccompletes = 0;
648 return FLUSH_RETRY_TIMEOUT; 619 /* FLUSH_RETRY_TIMEOUT causes hang on boot */
620 return FLUSH_GIVEUP;
649 } else { 621 } else {
650 busy_reps++; 622 busy_reps++;
651 if (busy_reps > 1000000) { 623 if (busy_reps > 1000000) {
@@ -653,9 +625,8 @@ static int uv2_wait_completion(struct bau_desc *bau_desc,
653 busy_reps = 0; 625 busy_reps = 0;
654 ttm = get_cycles(); 626 ttm = get_cycles();
655 if ((ttm - bcp->send_message) > 627 if ((ttm - bcp->send_message) >
656 (bcp->clocks_per_100_usec)) { 628 bcp->timeout_interval)
657 return handle_uv2_busy(bcp); 629 return handle_uv2_busy(bcp);
658 }
659 } 630 }
660 /* 631 /*
661 * descriptor_stat is still BUSY 632 * descriptor_stat is still BUSY
@@ -679,7 +650,7 @@ static int wait_completion(struct bau_desc *bau_desc,
679{ 650{
680 int right_shift; 651 int right_shift;
681 unsigned long mmr_offset; 652 unsigned long mmr_offset;
682 int desc = bcp->using_desc; 653 int desc = bcp->uvhub_cpu;
683 654
684 if (desc < UV_CPUS_PER_AS) { 655 if (desc < UV_CPUS_PER_AS) {
685 mmr_offset = UVH_LB_BAU_SB_ACTIVATION_STATUS_0; 656 mmr_offset = UVH_LB_BAU_SB_ACTIVATION_STATUS_0;
@@ -758,33 +729,31 @@ static void destination_timeout(struct bau_desc *bau_desc,
758} 729}
759 730
760/* 731/*
761 * Completions are taking a very long time due to a congested numalink 732 * Stop all cpus on a uvhub from using the BAU for a period of time.
762 * network. 733 * This is reversed by check_enable.
763 */ 734 */
764static void disable_for_congestion(struct bau_control *bcp, 735static void disable_for_period(struct bau_control *bcp, struct ptc_stats *stat)
765 struct ptc_stats *stat)
766{ 736{
767 /* let only one cpu do this disabling */ 737 int tcpu;
768 spin_lock(&disable_lock); 738 struct bau_control *tbcp;
769 739 struct bau_control *hmaster;
770 if (!baudisabled && bcp->period_requests && 740 cycles_t tm1;
771 ((bcp->period_time / bcp->period_requests) > congested_cycles)) { 741
772 int tcpu; 742 hmaster = bcp->uvhub_master;
773 struct bau_control *tbcp; 743 spin_lock(&hmaster->disable_lock);
774 /* it becomes this cpu's job to turn on the use of the 744 if (!bcp->baudisabled) {
775 BAU again */
776 baudisabled = 1;
777 bcp->set_bau_off = 1;
778 bcp->set_bau_on_time = get_cycles();
779 bcp->set_bau_on_time += sec_2_cycles(bcp->cong_period);
780 stat->s_bau_disabled++; 745 stat->s_bau_disabled++;
746 tm1 = get_cycles();
781 for_each_present_cpu(tcpu) { 747 for_each_present_cpu(tcpu) {
782 tbcp = &per_cpu(bau_control, tcpu); 748 tbcp = &per_cpu(bau_control, tcpu);
783 tbcp->baudisabled = 1; 749 if (tbcp->uvhub_master == hmaster) {
750 tbcp->baudisabled = 1;
751 tbcp->set_bau_on_time =
752 tm1 + bcp->disabled_period;
753 }
784 } 754 }
785 } 755 }
786 756 spin_unlock(&hmaster->disable_lock);
787 spin_unlock(&disable_lock);
788} 757}
789 758
790static void count_max_concurr(int stat, struct bau_control *bcp, 759static void count_max_concurr(int stat, struct bau_control *bcp,
@@ -815,16 +784,30 @@ static void record_send_stats(cycles_t time1, cycles_t time2,
815 bcp->period_requests++; 784 bcp->period_requests++;
816 bcp->period_time += elapsed; 785 bcp->period_time += elapsed;
817 if ((elapsed > congested_cycles) && 786 if ((elapsed > congested_cycles) &&
818 (bcp->period_requests > bcp->cong_reps)) 787 (bcp->period_requests > bcp->cong_reps) &&
819 disable_for_congestion(bcp, stat); 788 ((bcp->period_time / bcp->period_requests) >
789 congested_cycles)) {
790 stat->s_congested++;
791 disable_for_period(bcp, stat);
792 }
820 } 793 }
821 } else 794 } else
822 stat->s_requestor--; 795 stat->s_requestor--;
823 796
824 if (completion_status == FLUSH_COMPLETE && try > 1) 797 if (completion_status == FLUSH_COMPLETE && try > 1)
825 stat->s_retriesok++; 798 stat->s_retriesok++;
826 else if (completion_status == FLUSH_GIVEUP) 799 else if (completion_status == FLUSH_GIVEUP) {
827 stat->s_giveup++; 800 stat->s_giveup++;
801 if (get_cycles() > bcp->period_end)
802 bcp->period_giveups = 0;
803 bcp->period_giveups++;
804 if (bcp->period_giveups == 1)
805 bcp->period_end = get_cycles() + bcp->disabled_period;
806 if (bcp->period_giveups > bcp->giveup_limit) {
807 disable_for_period(bcp, stat);
808 stat->s_giveuplimit++;
809 }
810 }
828} 811}
829 812
830/* 813/*
@@ -868,7 +851,8 @@ static void handle_cmplt(int completion_status, struct bau_desc *bau_desc,
868 * Returns 1 if it gives up entirely and the original cpu mask is to be 851 * Returns 1 if it gives up entirely and the original cpu mask is to be
869 * returned to the kernel. 852 * returned to the kernel.
870 */ 853 */
871int uv_flush_send_and_wait(struct cpumask *flush_mask, struct bau_control *bcp) 854int uv_flush_send_and_wait(struct cpumask *flush_mask, struct bau_control *bcp,
855 struct bau_desc *bau_desc)
872{ 856{
873 int seq_number = 0; 857 int seq_number = 0;
874 int completion_stat = 0; 858 int completion_stat = 0;
@@ -881,24 +865,23 @@ int uv_flush_send_and_wait(struct cpumask *flush_mask, struct bau_control *bcp)
881 struct bau_control *hmaster = bcp->uvhub_master; 865 struct bau_control *hmaster = bcp->uvhub_master;
882 struct uv1_bau_msg_header *uv1_hdr = NULL; 866 struct uv1_bau_msg_header *uv1_hdr = NULL;
883 struct uv2_bau_msg_header *uv2_hdr = NULL; 867 struct uv2_bau_msg_header *uv2_hdr = NULL;
884 struct bau_desc *bau_desc;
885 868
886 if (bcp->uvhub_version == 1) 869 if (bcp->uvhub_version == 1) {
870 uv1 = 1;
887 uv1_throttle(hmaster, stat); 871 uv1_throttle(hmaster, stat);
872 }
888 873
889 while (hmaster->uvhub_quiesce) 874 while (hmaster->uvhub_quiesce)
890 cpu_relax(); 875 cpu_relax();
891 876
892 time1 = get_cycles(); 877 time1 = get_cycles();
878 if (uv1)
879 uv1_hdr = &bau_desc->header.uv1_hdr;
880 else
881 uv2_hdr = &bau_desc->header.uv2_hdr;
882
893 do { 883 do {
894 bau_desc = bcp->descriptor_base; 884 if (try == 0) {
895 bau_desc += (ITEMS_PER_DESC * bcp->using_desc);
896 if (bcp->uvhub_version == 1) {
897 uv1 = 1;
898 uv1_hdr = &bau_desc->header.uv1_hdr;
899 } else
900 uv2_hdr = &bau_desc->header.uv2_hdr;
901 if ((try == 0) || (completion_stat == FLUSH_RETRY_BUSYBUG)) {
902 if (uv1) 885 if (uv1)
903 uv1_hdr->msg_type = MSG_REGULAR; 886 uv1_hdr->msg_type = MSG_REGULAR;
904 else 887 else
@@ -916,25 +899,24 @@ int uv_flush_send_and_wait(struct cpumask *flush_mask, struct bau_control *bcp)
916 uv1_hdr->sequence = seq_number; 899 uv1_hdr->sequence = seq_number;
917 else 900 else
918 uv2_hdr->sequence = seq_number; 901 uv2_hdr->sequence = seq_number;
919 index = (1UL << AS_PUSH_SHIFT) | bcp->using_desc; 902 index = (1UL << AS_PUSH_SHIFT) | bcp->uvhub_cpu;
920 bcp->send_message = get_cycles(); 903 bcp->send_message = get_cycles();
921 904
922 write_mmr_activation(index); 905 write_mmr_activation(index);
923 906
924 try++; 907 try++;
925 completion_stat = wait_completion(bau_desc, bcp, try); 908 completion_stat = wait_completion(bau_desc, bcp, try);
926 /* UV2: wait_completion() may change the bcp->using_desc */
927 909
928 handle_cmplt(completion_stat, bau_desc, bcp, hmaster, stat); 910 handle_cmplt(completion_stat, bau_desc, bcp, hmaster, stat);
929 911
930 if (bcp->ipi_attempts >= bcp->ipi_reset_limit) { 912 if (bcp->ipi_attempts >= bcp->ipi_reset_limit) {
931 bcp->ipi_attempts = 0; 913 bcp->ipi_attempts = 0;
914 stat->s_overipilimit++;
932 completion_stat = FLUSH_GIVEUP; 915 completion_stat = FLUSH_GIVEUP;
933 break; 916 break;
934 } 917 }
935 cpu_relax(); 918 cpu_relax();
936 } while ((completion_stat == FLUSH_RETRY_PLUGGED) || 919 } while ((completion_stat == FLUSH_RETRY_PLUGGED) ||
937 (completion_stat == FLUSH_RETRY_BUSYBUG) ||
938 (completion_stat == FLUSH_RETRY_TIMEOUT)); 920 (completion_stat == FLUSH_RETRY_TIMEOUT));
939 921
940 time2 = get_cycles(); 922 time2 = get_cycles();
@@ -955,28 +937,33 @@ int uv_flush_send_and_wait(struct cpumask *flush_mask, struct bau_control *bcp)
955} 937}
956 938
957/* 939/*
958 * The BAU is disabled. When the disabled time period has expired, the cpu 940 * The BAU is disabled for this uvhub. When the disabled time period has
959 * that disabled it must re-enable it. 941 * expired re-enable it.
960 * Return 0 if it is re-enabled for all cpus. 942 * Return 0 if it is re-enabled for all cpus on this uvhub.
961 */ 943 */
962static int check_enable(struct bau_control *bcp, struct ptc_stats *stat) 944static int check_enable(struct bau_control *bcp, struct ptc_stats *stat)
963{ 945{
964 int tcpu; 946 int tcpu;
965 struct bau_control *tbcp; 947 struct bau_control *tbcp;
948 struct bau_control *hmaster;
966 949
967 if (bcp->set_bau_off) { 950 hmaster = bcp->uvhub_master;
968 if (get_cycles() >= bcp->set_bau_on_time) { 951 spin_lock(&hmaster->disable_lock);
969 stat->s_bau_reenabled++; 952 if (bcp->baudisabled && (get_cycles() >= bcp->set_bau_on_time)) {
970 baudisabled = 0; 953 stat->s_bau_reenabled++;
971 for_each_present_cpu(tcpu) { 954 for_each_present_cpu(tcpu) {
972 tbcp = &per_cpu(bau_control, tcpu); 955 tbcp = &per_cpu(bau_control, tcpu);
956 if (tbcp->uvhub_master == hmaster) {
973 tbcp->baudisabled = 0; 957 tbcp->baudisabled = 0;
974 tbcp->period_requests = 0; 958 tbcp->period_requests = 0;
975 tbcp->period_time = 0; 959 tbcp->period_time = 0;
960 tbcp->period_giveups = 0;
976 } 961 }
977 return 0;
978 } 962 }
963 spin_unlock(&hmaster->disable_lock);
964 return 0;
979 } 965 }
966 spin_unlock(&hmaster->disable_lock);
980 return -1; 967 return -1;
981} 968}
982 969
@@ -1068,8 +1055,8 @@ static int set_distrib_bits(struct cpumask *flush_mask, struct bau_control *bcp,
1068 * done. The returned pointer is valid till preemption is re-enabled. 1055 * done. The returned pointer is valid till preemption is re-enabled.
1069 */ 1056 */
1070const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask, 1057const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask,
1071 struct mm_struct *mm, unsigned long va, 1058 struct mm_struct *mm, unsigned long start,
1072 unsigned int cpu) 1059 unsigned end, unsigned int cpu)
1073{ 1060{
1074 int locals = 0; 1061 int locals = 0;
1075 int remotes = 0; 1062 int remotes = 0;
@@ -1078,18 +1065,32 @@ const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask,
1078 struct cpumask *flush_mask; 1065 struct cpumask *flush_mask;
1079 struct ptc_stats *stat; 1066 struct ptc_stats *stat;
1080 struct bau_control *bcp; 1067 struct bau_control *bcp;
1081 1068 unsigned long descriptor_status;
1082 /* kernel was booted 'nobau' */ 1069 unsigned long status;
1083 if (nobau)
1084 return cpumask;
1085 1070
1086 bcp = &per_cpu(bau_control, cpu); 1071 bcp = &per_cpu(bau_control, cpu);
1087 stat = bcp->statp; 1072 stat = bcp->statp;
1073 stat->s_enters++;
1074
1075 if (bcp->nobau)
1076 return cpumask;
1077
1078 if (bcp->busy) {
1079 descriptor_status =
1080 read_lmmr(UVH_LB_BAU_SB_ACTIVATION_STATUS_0);
1081 status = ((descriptor_status >> (bcp->uvhub_cpu *
1082 UV_ACT_STATUS_SIZE)) & UV_ACT_STATUS_MASK) << 1;
1083 if (status == UV2H_DESC_BUSY)
1084 return cpumask;
1085 bcp->busy = 0;
1086 }
1088 1087
1089 /* bau was disabled due to slow response */ 1088 /* bau was disabled due to slow response */
1090 if (bcp->baudisabled) { 1089 if (bcp->baudisabled) {
1091 if (check_enable(bcp, stat)) 1090 if (check_enable(bcp, stat)) {
1091 stat->s_ipifordisabled++;
1092 return cpumask; 1092 return cpumask;
1093 }
1093 } 1094 }
1094 1095
1095 /* 1096 /*
@@ -1105,38 +1106,40 @@ const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask,
1105 stat->s_ntargself++; 1106 stat->s_ntargself++;
1106 1107
1107 bau_desc = bcp->descriptor_base; 1108 bau_desc = bcp->descriptor_base;
1108 bau_desc += (ITEMS_PER_DESC * bcp->using_desc); 1109 bau_desc += (ITEMS_PER_DESC * bcp->uvhub_cpu);
1109 bau_uvhubs_clear(&bau_desc->distribution, UV_DISTRIBUTION_SIZE); 1110 bau_uvhubs_clear(&bau_desc->distribution, UV_DISTRIBUTION_SIZE);
1110 if (set_distrib_bits(flush_mask, bcp, bau_desc, &locals, &remotes)) 1111 if (set_distrib_bits(flush_mask, bcp, bau_desc, &locals, &remotes))
1111 return NULL; 1112 return NULL;
1112 1113
1113 record_send_statistics(stat, locals, hubs, remotes, bau_desc); 1114 record_send_statistics(stat, locals, hubs, remotes, bau_desc);
1114 1115
1115 bau_desc->payload.address = va; 1116 bau_desc->payload.address = start;
1116 bau_desc->payload.sending_cpu = cpu; 1117 bau_desc->payload.sending_cpu = cpu;
1117 /* 1118 /*
1118 * uv_flush_send_and_wait returns 0 if all cpu's were messaged, 1119 * uv_flush_send_and_wait returns 0 if all cpu's were messaged,
1119 * or 1 if it gave up and the original cpumask should be returned. 1120 * or 1 if it gave up and the original cpumask should be returned.
1120 */ 1121 */
1121 if (!uv_flush_send_and_wait(flush_mask, bcp)) 1122 if (!uv_flush_send_and_wait(flush_mask, bcp, bau_desc))
1122 return NULL; 1123 return NULL;
1123 else 1124 else
1124 return cpumask; 1125 return cpumask;
1125} 1126}
1126 1127
1127/* 1128/*
1128 * Search the message queue for any 'other' message with the same software 1129 * Search the message queue for any 'other' unprocessed message with the
1129 * acknowledge resource bit vector. 1130 * same software acknowledge resource bit vector as the 'msg' message.
1130 */ 1131 */
1131struct bau_pq_entry *find_another_by_swack(struct bau_pq_entry *msg, 1132struct bau_pq_entry *find_another_by_swack(struct bau_pq_entry *msg,
1132 struct bau_control *bcp, unsigned char swack_vec) 1133 struct bau_control *bcp)
1133{ 1134{
1134 struct bau_pq_entry *msg_next = msg + 1; 1135 struct bau_pq_entry *msg_next = msg + 1;
1136 unsigned char swack_vec = msg->swack_vec;
1135 1137
1136 if (msg_next > bcp->queue_last) 1138 if (msg_next > bcp->queue_last)
1137 msg_next = bcp->queue_first; 1139 msg_next = bcp->queue_first;
1138 while ((msg_next->swack_vec != 0) && (msg_next != msg)) { 1140 while (msg_next != msg) {
1139 if (msg_next->swack_vec == swack_vec) 1141 if ((msg_next->canceled == 0) && (msg_next->replied_to == 0) &&
1142 (msg_next->swack_vec == swack_vec))
1140 return msg_next; 1143 return msg_next;
1141 msg_next++; 1144 msg_next++;
1142 if (msg_next > bcp->queue_last) 1145 if (msg_next > bcp->queue_last)
@@ -1165,32 +1168,30 @@ void process_uv2_message(struct msg_desc *mdp, struct bau_control *bcp)
1165 * This message was assigned a swack resource, but no 1168 * This message was assigned a swack resource, but no
1166 * reserved acknowlegment is pending. 1169 * reserved acknowlegment is pending.
1167 * The bug has prevented this message from setting the MMR. 1170 * The bug has prevented this message from setting the MMR.
1168 * And no other message has used the same sw_ack resource.
1169 * Do the requested shootdown but do not reply to the msg.
1170 * (the 0 means make no acknowledge)
1171 */ 1171 */
1172 bau_process_message(mdp, bcp, 0);
1173 return;
1174 }
1175
1176 /*
1177 * Some message has set the MMR 'pending' bit; it might have been
1178 * another message. Look for that message.
1179 */
1180 other_msg = find_another_by_swack(msg, bcp, msg->swack_vec);
1181 if (other_msg) {
1182 /* There is another. Do not ack the current one. */
1183 bau_process_message(mdp, bcp, 0);
1184 /* 1172 /*
1185 * Let the natural processing of that message acknowledge 1173 * Some message has set the MMR 'pending' bit; it might have
1186 * it. Don't get the processing of sw_ack's out of order. 1174 * been another message. Look for that message.
1187 */ 1175 */
1188 return; 1176 other_msg = find_another_by_swack(msg, bcp);
1177 if (other_msg) {
1178 /*
1179 * There is another. Process this one but do not
1180 * ack it.
1181 */
1182 bau_process_message(mdp, bcp, 0);
1183 /*
1184 * Let the natural processing of that other message
1185 * acknowledge it. Don't get the processing of sw_ack's
1186 * out of order.
1187 */
1188 return;
1189 }
1189 } 1190 }
1190 1191
1191 /* 1192 /*
1192 * There is no other message using this sw_ack, so it is safe to 1193 * Either the MMR shows this one pending a reply or there is no
1193 * acknowledge it. 1194 * other message using this sw_ack, so it is safe to acknowledge it.
1194 */ 1195 */
1195 bau_process_message(mdp, bcp, 1); 1196 bau_process_message(mdp, bcp, 1);
1196 1197
@@ -1295,7 +1296,8 @@ static void __init enable_timeouts(void)
1295 */ 1296 */
1296 mmr_image |= (1L << SOFTACK_MSHIFT); 1297 mmr_image |= (1L << SOFTACK_MSHIFT);
1297 if (is_uv2_hub()) { 1298 if (is_uv2_hub()) {
1298 mmr_image |= (1L << UV2_EXT_SHFT); 1299 /* hw bug workaround; do not use extended status */
1300 mmr_image &= ~(1L << UV2_EXT_SHFT);
1299 } 1301 }
1300 write_mmr_misc_control(pnode, mmr_image); 1302 write_mmr_misc_control(pnode, mmr_image);
1301 } 1303 }
@@ -1338,29 +1340,34 @@ static inline unsigned long long usec_2_cycles(unsigned long microsec)
1338static int ptc_seq_show(struct seq_file *file, void *data) 1340static int ptc_seq_show(struct seq_file *file, void *data)
1339{ 1341{
1340 struct ptc_stats *stat; 1342 struct ptc_stats *stat;
1343 struct bau_control *bcp;
1341 int cpu; 1344 int cpu;
1342 1345
1343 cpu = *(loff_t *)data; 1346 cpu = *(loff_t *)data;
1344 if (!cpu) { 1347 if (!cpu) {
1345 seq_printf(file, 1348 seq_printf(file,
1346 "# cpu sent stime self locals remotes ncpus localhub "); 1349 "# cpu bauoff sent stime self locals remotes ncpus localhub ");
1347 seq_printf(file, 1350 seq_printf(file,
1348 "remotehub numuvhubs numuvhubs16 numuvhubs8 "); 1351 "remotehub numuvhubs numuvhubs16 numuvhubs8 ");
1349 seq_printf(file, 1352 seq_printf(file,
1350 "numuvhubs4 numuvhubs2 numuvhubs1 dto snacks retries rok "); 1353 "numuvhubs4 numuvhubs2 numuvhubs1 dto snacks retries ");
1354 seq_printf(file,
1355 "rok resetp resett giveup sto bz throt disable ");
1351 seq_printf(file, 1356 seq_printf(file,
1352 "resetp resett giveup sto bz throt swack recv rtime "); 1357 "enable wars warshw warwaits enters ipidis plugged ");
1353 seq_printf(file, 1358 seq_printf(file,
1354 "all one mult none retry canc nocan reset rcan "); 1359 "ipiover glim cong swack recv rtime all one mult ");
1355 seq_printf(file, 1360 seq_printf(file,
1356 "disable enable wars warshw warwaits\n"); 1361 "none retry canc nocan reset rcan\n");
1357 } 1362 }
1358 if (cpu < num_possible_cpus() && cpu_online(cpu)) { 1363 if (cpu < num_possible_cpus() && cpu_online(cpu)) {
1359 stat = &per_cpu(ptcstats, cpu); 1364 bcp = &per_cpu(bau_control, cpu);
1365 stat = bcp->statp;
1360 /* source side statistics */ 1366 /* source side statistics */
1361 seq_printf(file, 1367 seq_printf(file,
1362 "cpu %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld ", 1368 "cpu %d %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld ",
1363 cpu, stat->s_requestor, cycles_2_us(stat->s_time), 1369 cpu, bcp->nobau, stat->s_requestor,
1370 cycles_2_us(stat->s_time),
1364 stat->s_ntargself, stat->s_ntarglocals, 1371 stat->s_ntargself, stat->s_ntarglocals,
1365 stat->s_ntargremotes, stat->s_ntargcpu, 1372 stat->s_ntargremotes, stat->s_ntargcpu,
1366 stat->s_ntarglocaluvhub, stat->s_ntargremoteuvhub, 1373 stat->s_ntarglocaluvhub, stat->s_ntargremoteuvhub,
@@ -1374,20 +1381,23 @@ static int ptc_seq_show(struct seq_file *file, void *data)
1374 stat->s_resets_plug, stat->s_resets_timeout, 1381 stat->s_resets_plug, stat->s_resets_timeout,
1375 stat->s_giveup, stat->s_stimeout, 1382 stat->s_giveup, stat->s_stimeout,
1376 stat->s_busy, stat->s_throttles); 1383 stat->s_busy, stat->s_throttles);
1384 seq_printf(file, "%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld ",
1385 stat->s_bau_disabled, stat->s_bau_reenabled,
1386 stat->s_uv2_wars, stat->s_uv2_wars_hw,
1387 stat->s_uv2_war_waits, stat->s_enters,
1388 stat->s_ipifordisabled, stat->s_plugged,
1389 stat->s_overipilimit, stat->s_giveuplimit,
1390 stat->s_congested);
1377 1391
1378 /* destination side statistics */ 1392 /* destination side statistics */
1379 seq_printf(file, 1393 seq_printf(file,
1380 "%lx %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld ", 1394 "%lx %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n",
1381 read_gmmr_sw_ack(uv_cpu_to_pnode(cpu)), 1395 read_gmmr_sw_ack(uv_cpu_to_pnode(cpu)),
1382 stat->d_requestee, cycles_2_us(stat->d_time), 1396 stat->d_requestee, cycles_2_us(stat->d_time),
1383 stat->d_alltlb, stat->d_onetlb, stat->d_multmsg, 1397 stat->d_alltlb, stat->d_onetlb, stat->d_multmsg,
1384 stat->d_nomsg, stat->d_retries, stat->d_canceled, 1398 stat->d_nomsg, stat->d_retries, stat->d_canceled,
1385 stat->d_nocanceled, stat->d_resets, 1399 stat->d_nocanceled, stat->d_resets,
1386 stat->d_rcanceled); 1400 stat->d_rcanceled);
1387 seq_printf(file, "%ld %ld %ld %ld %ld\n",
1388 stat->s_bau_disabled, stat->s_bau_reenabled,
1389 stat->s_uv2_wars, stat->s_uv2_wars_hw,
1390 stat->s_uv2_war_waits);
1391 } 1401 }
1392 return 0; 1402 return 0;
1393} 1403}
@@ -1401,13 +1411,14 @@ static ssize_t tunables_read(struct file *file, char __user *userbuf,
1401 char *buf; 1411 char *buf;
1402 int ret; 1412 int ret;
1403 1413
1404 buf = kasprintf(GFP_KERNEL, "%s %s %s\n%d %d %d %d %d %d %d %d %d\n", 1414 buf = kasprintf(GFP_KERNEL, "%s %s %s\n%d %d %d %d %d %d %d %d %d %d\n",
1405 "max_concur plugged_delay plugsb4reset", 1415 "max_concur plugged_delay plugsb4reset timeoutsb4reset",
1406 "timeoutsb4reset ipi_reset_limit complete_threshold", 1416 "ipi_reset_limit complete_threshold congested_response_us",
1407 "congested_response_us congested_reps congested_period", 1417 "congested_reps disabled_period giveup_limit",
1408 max_concurr, plugged_delay, plugsb4reset, 1418 max_concurr, plugged_delay, plugsb4reset,
1409 timeoutsb4reset, ipi_reset_limit, complete_threshold, 1419 timeoutsb4reset, ipi_reset_limit, complete_threshold,
1410 congested_respns_us, congested_reps, congested_period); 1420 congested_respns_us, congested_reps, disabled_period,
1421 giveup_limit);
1411 1422
1412 if (!buf) 1423 if (!buf)
1413 return -ENOMEM; 1424 return -ENOMEM;
@@ -1438,6 +1449,14 @@ static ssize_t ptc_proc_write(struct file *file, const char __user *user,
1438 return -EFAULT; 1449 return -EFAULT;
1439 optstr[count - 1] = '\0'; 1450 optstr[count - 1] = '\0';
1440 1451
1452 if (!strcmp(optstr, "on")) {
1453 set_bau_on();
1454 return count;
1455 } else if (!strcmp(optstr, "off")) {
1456 set_bau_off();
1457 return count;
1458 }
1459
1441 if (strict_strtol(optstr, 10, &input_arg) < 0) { 1460 if (strict_strtol(optstr, 10, &input_arg) < 0) {
1442 printk(KERN_DEBUG "%s is invalid\n", optstr); 1461 printk(KERN_DEBUG "%s is invalid\n", optstr);
1443 return -EINVAL; 1462 return -EINVAL;
@@ -1570,7 +1589,8 @@ static ssize_t tunables_write(struct file *file, const char __user *user,
1570 bcp->complete_threshold = complete_threshold; 1589 bcp->complete_threshold = complete_threshold;
1571 bcp->cong_response_us = congested_respns_us; 1590 bcp->cong_response_us = congested_respns_us;
1572 bcp->cong_reps = congested_reps; 1591 bcp->cong_reps = congested_reps;
1573 bcp->cong_period = congested_period; 1592 bcp->disabled_period = sec_2_cycles(disabled_period);
1593 bcp->giveup_limit = giveup_limit;
1574 } 1594 }
1575 return count; 1595 return count;
1576} 1596}
@@ -1699,6 +1719,10 @@ static void activation_descriptor_init(int node, int pnode, int base_pnode)
1699 * fairness chaining multilevel count replied_to 1719 * fairness chaining multilevel count replied_to
1700 */ 1720 */
1701 } else { 1721 } else {
1722 /*
1723 * BIOS uses legacy mode, but UV2 hardware always
1724 * uses native mode for selective broadcasts.
1725 */
1702 uv2_hdr = &bd2->header.uv2_hdr; 1726 uv2_hdr = &bd2->header.uv2_hdr;
1703 uv2_hdr->swack_flag = 1; 1727 uv2_hdr->swack_flag = 1;
1704 uv2_hdr->base_dest_nasid = 1728 uv2_hdr->base_dest_nasid =
@@ -1811,8 +1835,8 @@ static int calculate_destination_timeout(void)
1811 index = (mmr_image >> BAU_URGENCY_7_SHIFT) & BAU_URGENCY_7_MASK; 1835 index = (mmr_image >> BAU_URGENCY_7_SHIFT) & BAU_URGENCY_7_MASK;
1812 mmr_image = uv_read_local_mmr(UVH_TRANSACTION_TIMEOUT); 1836 mmr_image = uv_read_local_mmr(UVH_TRANSACTION_TIMEOUT);
1813 mult2 = (mmr_image >> BAU_TRANS_SHIFT) & BAU_TRANS_MASK; 1837 mult2 = (mmr_image >> BAU_TRANS_SHIFT) & BAU_TRANS_MASK;
1814 base = timeout_base_ns[index]; 1838 ts_ns = timeout_base_ns[index];
1815 ts_ns = base * mult1 * mult2; 1839 ts_ns *= (mult1 * mult2);
1816 ret = ts_ns / 1000; 1840 ret = ts_ns / 1000;
1817 } else { 1841 } else {
1818 /* 4 bits 0/1 for 10/80us base, 3 bits of multiplier */ 1842 /* 4 bits 0/1 for 10/80us base, 3 bits of multiplier */
@@ -1836,6 +1860,8 @@ static void __init init_per_cpu_tunables(void)
1836 for_each_present_cpu(cpu) { 1860 for_each_present_cpu(cpu) {
1837 bcp = &per_cpu(bau_control, cpu); 1861 bcp = &per_cpu(bau_control, cpu);
1838 bcp->baudisabled = 0; 1862 bcp->baudisabled = 0;
1863 if (nobau)
1864 bcp->nobau = 1;
1839 bcp->statp = &per_cpu(ptcstats, cpu); 1865 bcp->statp = &per_cpu(ptcstats, cpu);
1840 /* time interval to catch a hardware stay-busy bug */ 1866 /* time interval to catch a hardware stay-busy bug */
1841 bcp->timeout_interval = usec_2_cycles(2*timeout_us); 1867 bcp->timeout_interval = usec_2_cycles(2*timeout_us);
@@ -1848,10 +1874,11 @@ static void __init init_per_cpu_tunables(void)
1848 bcp->complete_threshold = complete_threshold; 1874 bcp->complete_threshold = complete_threshold;
1849 bcp->cong_response_us = congested_respns_us; 1875 bcp->cong_response_us = congested_respns_us;
1850 bcp->cong_reps = congested_reps; 1876 bcp->cong_reps = congested_reps;
1851 bcp->cong_period = congested_period; 1877 bcp->disabled_period = sec_2_cycles(disabled_period);
1852 bcp->clocks_per_100_usec = usec_2_cycles(100); 1878 bcp->giveup_limit = giveup_limit;
1853 spin_lock_init(&bcp->queue_lock); 1879 spin_lock_init(&bcp->queue_lock);
1854 spin_lock_init(&bcp->uvhub_lock); 1880 spin_lock_init(&bcp->uvhub_lock);
1881 spin_lock_init(&bcp->disable_lock);
1855 } 1882 }
1856} 1883}
1857 1884
@@ -1972,7 +1999,6 @@ static int scan_sock(struct socket_desc *sdp, struct uvhub_desc *bdp,
1972 } 1999 }
1973 bcp->uvhub_master = *hmasterp; 2000 bcp->uvhub_master = *hmasterp;
1974 bcp->uvhub_cpu = uv_cpu_hub_info(cpu)->blade_processor_id; 2001 bcp->uvhub_cpu = uv_cpu_hub_info(cpu)->blade_processor_id;
1975 bcp->using_desc = bcp->uvhub_cpu;
1976 if (bcp->uvhub_cpu >= MAX_CPUS_PER_UVHUB) { 2002 if (bcp->uvhub_cpu >= MAX_CPUS_PER_UVHUB) {
1977 printk(KERN_EMERG "%d cpus per uvhub invalid\n", 2003 printk(KERN_EMERG "%d cpus per uvhub invalid\n",
1978 bcp->uvhub_cpu); 2004 bcp->uvhub_cpu);
@@ -2069,16 +2095,12 @@ static int __init uv_bau_init(void)
2069 if (!is_uv_system()) 2095 if (!is_uv_system())
2070 return 0; 2096 return 0;
2071 2097
2072 if (nobau)
2073 return 0;
2074
2075 for_each_possible_cpu(cur_cpu) { 2098 for_each_possible_cpu(cur_cpu) {
2076 mask = &per_cpu(uv_flush_tlb_mask, cur_cpu); 2099 mask = &per_cpu(uv_flush_tlb_mask, cur_cpu);
2077 zalloc_cpumask_var_node(mask, GFP_KERNEL, cpu_to_node(cur_cpu)); 2100 zalloc_cpumask_var_node(mask, GFP_KERNEL, cpu_to_node(cur_cpu));
2078 } 2101 }
2079 2102
2080 nuvhubs = uv_num_possible_blades(); 2103 nuvhubs = uv_num_possible_blades();
2081 spin_lock_init(&disable_lock);
2082 congested_cycles = usec_2_cycles(congested_respns_us); 2104 congested_cycles = usec_2_cycles(congested_respns_us);
2083 2105
2084 uv_base_pnode = 0x7fffffff; 2106 uv_base_pnode = 0x7fffffff;
@@ -2091,7 +2113,8 @@ static int __init uv_bau_init(void)
2091 enable_timeouts(); 2113 enable_timeouts();
2092 2114
2093 if (init_per_cpu(nuvhubs, uv_base_pnode)) { 2115 if (init_per_cpu(nuvhubs, uv_base_pnode)) {
2094 nobau = 1; 2116 set_bau_off();
2117 nobau_perm = 1;
2095 return 0; 2118 return 0;
2096 } 2119 }
2097 2120
diff --git a/arch/x86/platform/uv/uv_irq.c b/arch/x86/platform/uv/uv_irq.c
index f25c2765a5c..acf7752da95 100644
--- a/arch/x86/platform/uv/uv_irq.c
+++ b/arch/x86/platform/uv/uv_irq.c
@@ -135,6 +135,7 @@ arch_enable_uv_irq(char *irq_name, unsigned int irq, int cpu, int mmr_blade,
135 unsigned long mmr_value; 135 unsigned long mmr_value;
136 struct uv_IO_APIC_route_entry *entry; 136 struct uv_IO_APIC_route_entry *entry;
137 int mmr_pnode, err; 137 int mmr_pnode, err;
138 unsigned int dest;
138 139
139 BUILD_BUG_ON(sizeof(struct uv_IO_APIC_route_entry) != 140 BUILD_BUG_ON(sizeof(struct uv_IO_APIC_route_entry) !=
140 sizeof(unsigned long)); 141 sizeof(unsigned long));
@@ -143,6 +144,10 @@ arch_enable_uv_irq(char *irq_name, unsigned int irq, int cpu, int mmr_blade,
143 if (err != 0) 144 if (err != 0)
144 return err; 145 return err;
145 146
147 err = apic->cpu_mask_to_apicid_and(eligible_cpu, eligible_cpu, &dest);
148 if (err != 0)
149 return err;
150
146 if (limit == UV_AFFINITY_CPU) 151 if (limit == UV_AFFINITY_CPU)
147 irq_set_status_flags(irq, IRQ_NO_BALANCING); 152 irq_set_status_flags(irq, IRQ_NO_BALANCING);
148 else 153 else
@@ -159,7 +164,7 @@ arch_enable_uv_irq(char *irq_name, unsigned int irq, int cpu, int mmr_blade,
159 entry->polarity = 0; 164 entry->polarity = 0;
160 entry->trigger = 0; 165 entry->trigger = 0;
161 entry->mask = 0; 166 entry->mask = 0;
162 entry->dest = apic->cpu_mask_to_apicid(eligible_cpu); 167 entry->dest = dest;
163 168
164 mmr_pnode = uv_blade_to_pnode(mmr_blade); 169 mmr_pnode = uv_blade_to_pnode(mmr_blade);
165 uv_write_global_mmr64(mmr_pnode, mmr_offset, mmr_value); 170 uv_write_global_mmr64(mmr_pnode, mmr_offset, mmr_value);
@@ -222,7 +227,7 @@ uv_set_irq_affinity(struct irq_data *data, const struct cpumask *mask,
222 if (cfg->move_in_progress) 227 if (cfg->move_in_progress)
223 send_cleanup_vector(cfg); 228 send_cleanup_vector(cfg);
224 229
225 return 0; 230 return IRQ_SET_MASK_OK_NOCOPY;
226} 231}
227 232
228/* 233/*
diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
index 5b84a2d3088..88692871823 100644
--- a/arch/x86/realmode/rm/Makefile
+++ b/arch/x86/realmode/rm/Makefile
@@ -22,7 +22,7 @@ wakeup-objs += video-bios.o
22realmode-y += header.o 22realmode-y += header.o
23realmode-y += trampoline_$(BITS).o 23realmode-y += trampoline_$(BITS).o
24realmode-y += stack.o 24realmode-y += stack.o
25realmode-$(CONFIG_X86_32) += reboot_32.o 25realmode-y += reboot.o
26realmode-$(CONFIG_ACPI_SLEEP) += $(wakeup-objs) 26realmode-$(CONFIG_ACPI_SLEEP) += $(wakeup-objs)
27 27
28targets += $(realmode-y) 28targets += $(realmode-y)
@@ -72,7 +72,7 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
72 -Wall -Wstrict-prototypes \ 72 -Wall -Wstrict-prototypes \
73 -march=i386 -mregparm=3 \ 73 -march=i386 -mregparm=3 \
74 -include $(srctree)/$(src)/../../boot/code16gcc.h \ 74 -include $(srctree)/$(src)/../../boot/code16gcc.h \
75 -fno-strict-aliasing -fomit-frame-pointer \ 75 -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
76 $(call cc-option, -ffreestanding) \ 76 $(call cc-option, -ffreestanding) \
77 $(call cc-option, -fno-toplevel-reorder,\ 77 $(call cc-option, -fno-toplevel-reorder,\
78 $(call cc-option, -fno-unit-at-a-time)) \ 78 $(call cc-option, -fno-unit-at-a-time)) \
diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
index fadf48378ad..a28221d94e6 100644
--- a/arch/x86/realmode/rm/header.S
+++ b/arch/x86/realmode/rm/header.S
@@ -6,6 +6,7 @@
6 6
7#include <linux/linkage.h> 7#include <linux/linkage.h>
8#include <asm/page_types.h> 8#include <asm/page_types.h>
9#include <asm/segment.h>
9 10
10#include "realmode.h" 11#include "realmode.h"
11 12
@@ -28,8 +29,9 @@ GLOBAL(real_mode_header)
28 .long pa_wakeup_header 29 .long pa_wakeup_header
29#endif 30#endif
30 /* APM/BIOS reboot */ 31 /* APM/BIOS reboot */
31#ifdef CONFIG_X86_32
32 .long pa_machine_real_restart_asm 32 .long pa_machine_real_restart_asm
33#ifdef CONFIG_X86_64
34 .long __KERNEL32_CS
33#endif 35#endif
34END(real_mode_header) 36END(real_mode_header)
35 37
diff --git a/arch/x86/realmode/rm/reboot_32.S b/arch/x86/realmode/rm/reboot.S
index 114044876b3..f932ea61d1c 100644
--- a/arch/x86/realmode/rm/reboot_32.S
+++ b/arch/x86/realmode/rm/reboot.S
@@ -2,6 +2,8 @@
2#include <linux/init.h> 2#include <linux/init.h>
3#include <asm/segment.h> 3#include <asm/segment.h>
4#include <asm/page_types.h> 4#include <asm/page_types.h>
5#include <asm/processor-flags.h>
6#include <asm/msr-index.h>
5#include "realmode.h" 7#include "realmode.h"
6 8
7/* 9/*
@@ -12,13 +14,35 @@
12 * doesn't work with at least one type of 486 motherboard. It is easy 14 * doesn't work with at least one type of 486 motherboard. It is easy
13 * to stop this code working; hence the copious comments. 15 * to stop this code working; hence the copious comments.
14 * 16 *
15 * This code is called with the restart type (0 = BIOS, 1 = APM) in %eax. 17 * This code is called with the restart type (0 = BIOS, 1 = APM) in
18 * the primary argument register (%eax for 32 bit, %edi for 64 bit).
16 */ 19 */
17 .section ".text32", "ax" 20 .section ".text32", "ax"
18 .code32 21 .code32
19
20 .balign 16
21ENTRY(machine_real_restart_asm) 22ENTRY(machine_real_restart_asm)
23
24#ifdef CONFIG_X86_64
25 /* Switch to trampoline GDT as it is guaranteed < 4 GiB */
26 movl $__KERNEL_DS, %eax
27 movl %eax, %ds
28 lgdtl pa_tr_gdt
29
30 /* Disable paging to drop us out of long mode */
31 movl %cr0, %eax
32 andl $~X86_CR0_PG, %eax
33 movl %eax, %cr0
34 ljmpl $__KERNEL32_CS, $pa_machine_real_restart_paging_off
35
36GLOBAL(machine_real_restart_paging_off)
37 xorl %eax, %eax
38 xorl %edx, %edx
39 movl $MSR_EFER, %ecx
40 wrmsr
41
42 movl %edi, %eax
43
44#endif /* CONFIG_X86_64 */
45
22 /* Set up the IDT for real mode. */ 46 /* Set up the IDT for real mode. */
23 lidtl pa_machine_real_restart_idt 47 lidtl pa_machine_real_restart_idt
24 48
diff --git a/arch/x86/syscalls/syscall_64.tbl b/arch/x86/syscalls/syscall_64.tbl
index 51171aeff0d..a582bfed95b 100644
--- a/arch/x86/syscalls/syscall_64.tbl
+++ b/arch/x86/syscalls/syscall_64.tbl
@@ -60,8 +60,8 @@
6051 common getsockname sys_getsockname 6051 common getsockname sys_getsockname
6152 common getpeername sys_getpeername 6152 common getpeername sys_getpeername
6253 common socketpair sys_socketpair 6253 common socketpair sys_socketpair
6354 common setsockopt sys_setsockopt 6354 64 setsockopt sys_setsockopt
6455 common getsockopt sys_getsockopt 6455 64 getsockopt sys_getsockopt
6556 common clone stub_clone 6556 common clone stub_clone
6657 common fork stub_fork 6657 common fork stub_fork
6758 common vfork stub_vfork 6758 common vfork stub_vfork
@@ -318,7 +318,7 @@
318309 common getcpu sys_getcpu 318309 common getcpu sys_getcpu
319310 64 process_vm_readv sys_process_vm_readv 319310 64 process_vm_readv sys_process_vm_readv
320311 64 process_vm_writev sys_process_vm_writev 320311 64 process_vm_writev sys_process_vm_writev
321312 64 kcmp sys_kcmp 321312 common kcmp sys_kcmp
322 322
323# 323#
324# x32-specific system call numbers start at 512 to avoid cache impact 324# x32-specific system call numbers start at 512 to avoid cache impact
@@ -353,3 +353,5 @@
353538 x32 sendmmsg compat_sys_sendmmsg 353538 x32 sendmmsg compat_sys_sendmmsg
354539 x32 process_vm_readv compat_sys_process_vm_readv 354539 x32 process_vm_readv compat_sys_process_vm_readv
355540 x32 process_vm_writev compat_sys_process_vm_writev 355540 x32 process_vm_writev compat_sys_process_vm_writev
356541 x32 setsockopt compat_sys_setsockopt
357542 x32 getsockopt compat_sys_getsockopt
diff --git a/arch/x86/um/asm/ptrace.h b/arch/x86/um/asm/ptrace.h
index 950dfb7b841..e72cd0df5ba 100644
--- a/arch/x86/um/asm/ptrace.h
+++ b/arch/x86/um/asm/ptrace.h
@@ -30,10 +30,10 @@
30#define profile_pc(regs) PT_REGS_IP(regs) 30#define profile_pc(regs) PT_REGS_IP(regs)
31 31
32#define UPT_RESTART_SYSCALL(r) (UPT_IP(r) -= 2) 32#define UPT_RESTART_SYSCALL(r) (UPT_IP(r) -= 2)
33#define UPT_SET_SYSCALL_RETURN(r, res) (UPT_AX(r) = (res)) 33#define PT_REGS_SET_SYSCALL_RETURN(r, res) (PT_REGS_AX(r) = (res))
34 34
35static inline long regs_return_value(struct uml_pt_regs *regs) 35static inline long regs_return_value(struct pt_regs *regs)
36{ 36{
37 return UPT_AX(regs); 37 return PT_REGS_AX(regs);
38} 38}
39#endif /* __UM_X86_PTRACE_H */ 39#endif /* __UM_X86_PTRACE_H */
diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
index 66e6d935982..0faad646f5f 100644
--- a/arch/x86/vdso/vdso32-setup.c
+++ b/arch/x86/vdso/vdso32-setup.c
@@ -205,9 +205,9 @@ void syscall32_cpu_init(void)
205{ 205{
206 /* Load these always in case some future AMD CPU supports 206 /* Load these always in case some future AMD CPU supports
207 SYSENTER from compat mode too. */ 207 SYSENTER from compat mode too. */
208 checking_wrmsrl(MSR_IA32_SYSENTER_CS, (u64)__KERNEL_CS); 208 wrmsrl_safe(MSR_IA32_SYSENTER_CS, (u64)__KERNEL_CS);
209 checking_wrmsrl(MSR_IA32_SYSENTER_ESP, 0ULL); 209 wrmsrl_safe(MSR_IA32_SYSENTER_ESP, 0ULL);
210 checking_wrmsrl(MSR_IA32_SYSENTER_EIP, (u64)ia32_sysenter_target); 210 wrmsrl_safe(MSR_IA32_SYSENTER_EIP, (u64)ia32_sysenter_target);
211 211
212 wrmsrl(MSR_CSTAR, ia32_cstar_target); 212 wrmsrl(MSR_CSTAR, ia32_cstar_target);
213} 213}
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index cb1b1914dbd..2766746de27 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -38,6 +38,7 @@
38#include <xen/interface/physdev.h> 38#include <xen/interface/physdev.h>
39#include <xen/interface/vcpu.h> 39#include <xen/interface/vcpu.h>
40#include <xen/interface/memory.h> 40#include <xen/interface/memory.h>
41#include <xen/interface/xen-mca.h>
41#include <xen/features.h> 42#include <xen/features.h>
42#include <xen/page.h> 43#include <xen/page.h>
43#include <xen/hvm.h> 44#include <xen/hvm.h>
@@ -109,7 +110,7 @@ EXPORT_SYMBOL_GPL(xen_have_vector_callback);
109 * Point at some empty memory to start with. We map the real shared_info 110 * Point at some empty memory to start with. We map the real shared_info
110 * page as soon as fixmap is up and running. 111 * page as soon as fixmap is up and running.
111 */ 112 */
112struct shared_info *HYPERVISOR_shared_info = (void *)&xen_dummy_shared_info; 113struct shared_info *HYPERVISOR_shared_info = &xen_dummy_shared_info;
113 114
114/* 115/*
115 * Flag to determine whether vcpu info placement is available on all 116 * Flag to determine whether vcpu info placement is available on all
@@ -126,6 +127,19 @@ struct shared_info *HYPERVISOR_shared_info = (void *)&xen_dummy_shared_info;
126 */ 127 */
127static int have_vcpu_info_placement = 1; 128static int have_vcpu_info_placement = 1;
128 129
130struct tls_descs {
131 struct desc_struct desc[3];
132};
133
134/*
135 * Updating the 3 TLS descriptors in the GDT on every task switch is
136 * surprisingly expensive so we avoid updating them if they haven't
137 * changed. Since Xen writes different descriptors than the one
138 * passed in the update_descriptor hypercall we keep shadow copies to
139 * compare against.
140 */
141static DEFINE_PER_CPU(struct tls_descs, shadow_tls_desc);
142
129static void clamp_max_cpus(void) 143static void clamp_max_cpus(void)
130{ 144{
131#ifdef CONFIG_SMP 145#ifdef CONFIG_SMP
@@ -343,9 +357,7 @@ static void __init xen_init_cpuid_mask(void)
343 unsigned int xsave_mask; 357 unsigned int xsave_mask;
344 358
345 cpuid_leaf1_edx_mask = 359 cpuid_leaf1_edx_mask =
346 ~((1 << X86_FEATURE_MCE) | /* disable MCE */ 360 ~((1 << X86_FEATURE_MTRR) | /* disable MTRR */
347 (1 << X86_FEATURE_MCA) | /* disable MCA */
348 (1 << X86_FEATURE_MTRR) | /* disable MTRR */
349 (1 << X86_FEATURE_ACC)); /* thermal monitoring */ 361 (1 << X86_FEATURE_ACC)); /* thermal monitoring */
350 362
351 if (!xen_initial_domain()) 363 if (!xen_initial_domain())
@@ -542,12 +554,28 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
542 BUG(); 554 BUG();
543} 555}
544 556
557static inline bool desc_equal(const struct desc_struct *d1,
558 const struct desc_struct *d2)
559{
560 return d1->a == d2->a && d1->b == d2->b;
561}
562
545static void load_TLS_descriptor(struct thread_struct *t, 563static void load_TLS_descriptor(struct thread_struct *t,
546 unsigned int cpu, unsigned int i) 564 unsigned int cpu, unsigned int i)
547{ 565{
548 struct desc_struct *gdt = get_cpu_gdt_table(cpu); 566 struct desc_struct *shadow = &per_cpu(shadow_tls_desc, cpu).desc[i];
549 xmaddr_t maddr = arbitrary_virt_to_machine(&gdt[GDT_ENTRY_TLS_MIN+i]); 567 struct desc_struct *gdt;
550 struct multicall_space mc = __xen_mc_entry(0); 568 xmaddr_t maddr;
569 struct multicall_space mc;
570
571 if (desc_equal(shadow, &t->tls_array[i]))
572 return;
573
574 *shadow = t->tls_array[i];
575
576 gdt = get_cpu_gdt_table(cpu);
577 maddr = arbitrary_virt_to_machine(&gdt[GDT_ENTRY_TLS_MIN+i]);
578 mc = __xen_mc_entry(0);
551 579
552 MULTI_update_descriptor(mc.mc, maddr.maddr, t->tls_array[i]); 580 MULTI_update_descriptor(mc.mc, maddr.maddr, t->tls_array[i]);
553} 581}
@@ -629,8 +657,8 @@ static int cvt_gate_to_trap(int vector, const gate_desc *val,
629 /* 657 /*
630 * Look for known traps using IST, and substitute them 658 * Look for known traps using IST, and substitute them
631 * appropriately. The debugger ones are the only ones we care 659 * appropriately. The debugger ones are the only ones we care
632 * about. Xen will handle faults like double_fault and 660 * about. Xen will handle faults like double_fault,
633 * machine_check, so we should never see them. Warn if 661 * so we should never see them. Warn if
634 * there's an unexpected IST-using fault handler. 662 * there's an unexpected IST-using fault handler.
635 */ 663 */
636 if (addr == (unsigned long)debug) 664 if (addr == (unsigned long)debug)
@@ -645,7 +673,11 @@ static int cvt_gate_to_trap(int vector, const gate_desc *val,
645 return 0; 673 return 0;
646#ifdef CONFIG_X86_MCE 674#ifdef CONFIG_X86_MCE
647 } else if (addr == (unsigned long)machine_check) { 675 } else if (addr == (unsigned long)machine_check) {
648 return 0; 676 /*
677 * when xen hypervisor inject vMCE to guest,
678 * use native mce handler to handle it
679 */
680 ;
649#endif 681#endif
650 } else { 682 } else {
651 /* Some other trap using IST? */ 683 /* Some other trap using IST? */
@@ -1126,9 +1158,7 @@ static const struct pv_cpu_ops xen_cpu_ops __initconst = {
1126 .wbinvd = native_wbinvd, 1158 .wbinvd = native_wbinvd,
1127 1159
1128 .read_msr = native_read_msr_safe, 1160 .read_msr = native_read_msr_safe,
1129 .rdmsr_regs = native_rdmsr_safe_regs,
1130 .write_msr = xen_write_msr_safe, 1161 .write_msr = xen_write_msr_safe,
1131 .wrmsr_regs = native_wrmsr_safe_regs,
1132 1162
1133 .read_tsc = native_read_tsc, 1163 .read_tsc = native_read_tsc,
1134 .read_pmc = native_read_pmc, 1164 .read_pmc = native_read_pmc,
@@ -1441,32 +1471,6 @@ asmlinkage void __init xen_start_kernel(void)
1441#endif 1471#endif
1442} 1472}
1443 1473
1444static int init_hvm_pv_info(int *major, int *minor)
1445{
1446 uint32_t eax, ebx, ecx, edx, pages, msr, base;
1447 u64 pfn;
1448
1449 base = xen_cpuid_base();
1450 cpuid(base + 1, &eax, &ebx, &ecx, &edx);
1451
1452 *major = eax >> 16;
1453 *minor = eax & 0xffff;
1454 printk(KERN_INFO "Xen version %d.%d.\n", *major, *minor);
1455
1456 cpuid(base + 2, &pages, &msr, &ecx, &edx);
1457
1458 pfn = __pa(hypercall_page);
1459 wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32));
1460
1461 xen_setup_features();
1462
1463 pv_info.name = "Xen HVM";
1464
1465 xen_domain_type = XEN_HVM_DOMAIN;
1466
1467 return 0;
1468}
1469
1470void __ref xen_hvm_init_shared_info(void) 1474void __ref xen_hvm_init_shared_info(void)
1471{ 1475{
1472 int cpu; 1476 int cpu;
@@ -1499,6 +1503,31 @@ void __ref xen_hvm_init_shared_info(void)
1499} 1503}
1500 1504
1501#ifdef CONFIG_XEN_PVHVM 1505#ifdef CONFIG_XEN_PVHVM
1506static void __init init_hvm_pv_info(void)
1507{
1508 int major, minor;
1509 uint32_t eax, ebx, ecx, edx, pages, msr, base;
1510 u64 pfn;
1511
1512 base = xen_cpuid_base();
1513 cpuid(base + 1, &eax, &ebx, &ecx, &edx);
1514
1515 major = eax >> 16;
1516 minor = eax & 0xffff;
1517 printk(KERN_INFO "Xen version %d.%d.\n", major, minor);
1518
1519 cpuid(base + 2, &pages, &msr, &ecx, &edx);
1520
1521 pfn = __pa(hypercall_page);
1522 wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32));
1523
1524 xen_setup_features();
1525
1526 pv_info.name = "Xen HVM";
1527
1528 xen_domain_type = XEN_HVM_DOMAIN;
1529}
1530
1502static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self, 1531static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
1503 unsigned long action, void *hcpu) 1532 unsigned long action, void *hcpu)
1504{ 1533{
@@ -1521,12 +1550,7 @@ static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
1521 1550
1522static void __init xen_hvm_guest_init(void) 1551static void __init xen_hvm_guest_init(void)
1523{ 1552{
1524 int r; 1553 init_hvm_pv_info();
1525 int major, minor;
1526
1527 r = init_hvm_pv_info(&major, &minor);
1528 if (r < 0)
1529 return;
1530 1554
1531 xen_hvm_init_shared_info(); 1555 xen_hvm_init_shared_info();
1532 1556
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 2d9e7c9c0e7..dfc900471ae 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -308,8 +308,20 @@ static bool xen_batched_set_pte(pte_t *ptep, pte_t pteval)
308 308
309static inline void __xen_set_pte(pte_t *ptep, pte_t pteval) 309static inline void __xen_set_pte(pte_t *ptep, pte_t pteval)
310{ 310{
311 if (!xen_batched_set_pte(ptep, pteval)) 311 if (!xen_batched_set_pte(ptep, pteval)) {
312 native_set_pte(ptep, pteval); 312 /*
313 * Could call native_set_pte() here and trap and
314 * emulate the PTE write but with 32-bit guests this
315 * needs two traps (one for each of the two 32-bit
316 * words in the PTE) so do one hypercall directly
317 * instead.
318 */
319 struct mmu_update u;
320
321 u.ptr = virt_to_machine(ptep).maddr | MMU_NORMAL_PT_UPDATE;
322 u.val = pte_val_ma(pteval);
323 HYPERVISOR_mmu_update(&u, 1, NULL, DOMID_SELF);
324 }
313} 325}
314 326
315static void xen_set_pte(pte_t *ptep, pte_t pteval) 327static void xen_set_pte(pte_t *ptep, pte_t pteval)
@@ -1162,8 +1174,13 @@ static void xen_exit_mmap(struct mm_struct *mm)
1162 spin_unlock(&mm->page_table_lock); 1174 spin_unlock(&mm->page_table_lock);
1163} 1175}
1164 1176
1165static void __init xen_pagetable_setup_start(pgd_t *base) 1177static void xen_post_allocator_init(void);
1178
1179static void __init xen_pagetable_init(void)
1166{ 1180{
1181 paging_init();
1182 xen_setup_shared_info();
1183 xen_post_allocator_init();
1167} 1184}
1168 1185
1169static __init void xen_mapping_pagetable_reserve(u64 start, u64 end) 1186static __init void xen_mapping_pagetable_reserve(u64 start, u64 end)
@@ -1180,14 +1197,6 @@ static __init void xen_mapping_pagetable_reserve(u64 start, u64 end)
1180 } 1197 }
1181} 1198}
1182 1199
1183static void xen_post_allocator_init(void);
1184
1185static void __init xen_pagetable_setup_done(pgd_t *base)
1186{
1187 xen_setup_shared_info();
1188 xen_post_allocator_init();
1189}
1190
1191static void xen_write_cr2(unsigned long cr2) 1200static void xen_write_cr2(unsigned long cr2)
1192{ 1201{
1193 this_cpu_read(xen_vcpu)->arch.cr2 = cr2; 1202 this_cpu_read(xen_vcpu)->arch.cr2 = cr2;
@@ -1244,7 +1253,8 @@ static void xen_flush_tlb_single(unsigned long addr)
1244} 1253}
1245 1254
1246static void xen_flush_tlb_others(const struct cpumask *cpus, 1255static void xen_flush_tlb_others(const struct cpumask *cpus,
1247 struct mm_struct *mm, unsigned long va) 1256 struct mm_struct *mm, unsigned long start,
1257 unsigned long end)
1248{ 1258{
1249 struct { 1259 struct {
1250 struct mmuext_op op; 1260 struct mmuext_op op;
@@ -1256,7 +1266,7 @@ static void xen_flush_tlb_others(const struct cpumask *cpus,
1256 } *args; 1266 } *args;
1257 struct multicall_space mcs; 1267 struct multicall_space mcs;
1258 1268
1259 trace_xen_mmu_flush_tlb_others(cpus, mm, va); 1269 trace_xen_mmu_flush_tlb_others(cpus, mm, start, end);
1260 1270
1261 if (cpumask_empty(cpus)) 1271 if (cpumask_empty(cpus))
1262 return; /* nothing to do */ 1272 return; /* nothing to do */
@@ -1269,11 +1279,10 @@ static void xen_flush_tlb_others(const struct cpumask *cpus,
1269 cpumask_and(to_cpumask(args->mask), cpus, cpu_online_mask); 1279 cpumask_and(to_cpumask(args->mask), cpus, cpu_online_mask);
1270 cpumask_clear_cpu(smp_processor_id(), to_cpumask(args->mask)); 1280 cpumask_clear_cpu(smp_processor_id(), to_cpumask(args->mask));
1271 1281
1272 if (va == TLB_FLUSH_ALL) { 1282 args->op.cmd = MMUEXT_TLB_FLUSH_MULTI;
1273 args->op.cmd = MMUEXT_TLB_FLUSH_MULTI; 1283 if (end != TLB_FLUSH_ALL && (end - start) <= PAGE_SIZE) {
1274 } else {
1275 args->op.cmd = MMUEXT_INVLPG_MULTI; 1284 args->op.cmd = MMUEXT_INVLPG_MULTI;
1276 args->op.arg1.linear_addr = va; 1285 args->op.arg1.linear_addr = start;
1277 } 1286 }
1278 1287
1279 MULTI_mmuext_op(mcs.mc, &args->op, 1, NULL, DOMID_SELF); 1288 MULTI_mmuext_op(mcs.mc, &args->op, 1, NULL, DOMID_SELF);
@@ -1416,13 +1425,28 @@ static pte_t __init mask_rw_pte(pte_t *ptep, pte_t pte)
1416} 1425}
1417#endif /* CONFIG_X86_64 */ 1426#endif /* CONFIG_X86_64 */
1418 1427
1419/* Init-time set_pte while constructing initial pagetables, which 1428/*
1420 doesn't allow RO pagetable pages to be remapped RW */ 1429 * Init-time set_pte while constructing initial pagetables, which
1430 * doesn't allow RO page table pages to be remapped RW.
1431 *
1432 * If there is no MFN for this PFN then this page is initially
1433 * ballooned out so clear the PTE (as in decrease_reservation() in
1434 * drivers/xen/balloon.c).
1435 *
1436 * Many of these PTE updates are done on unpinned and writable pages
1437 * and doing a hypercall for these is unnecessary and expensive. At
1438 * this point it is not possible to tell if a page is pinned or not,
1439 * so always write the PTE directly and rely on Xen trapping and
1440 * emulating any updates as necessary.
1441 */
1421static void __init xen_set_pte_init(pte_t *ptep, pte_t pte) 1442static void __init xen_set_pte_init(pte_t *ptep, pte_t pte)
1422{ 1443{
1423 pte = mask_rw_pte(ptep, pte); 1444 if (pte_mfn(pte) != INVALID_P2M_ENTRY)
1445 pte = mask_rw_pte(ptep, pte);
1446 else
1447 pte = __pte_ma(0);
1424 1448
1425 xen_set_pte(ptep, pte); 1449 native_set_pte(ptep, pte);
1426} 1450}
1427 1451
1428static void pin_pagetable_pfn(unsigned cmd, unsigned long pfn) 1452static void pin_pagetable_pfn(unsigned cmd, unsigned long pfn)
@@ -2041,8 +2065,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
2041void __init xen_init_mmu_ops(void) 2065void __init xen_init_mmu_ops(void)
2042{ 2066{
2043 x86_init.mapping.pagetable_reserve = xen_mapping_pagetable_reserve; 2067 x86_init.mapping.pagetable_reserve = xen_mapping_pagetable_reserve;
2044 x86_init.paging.pagetable_setup_start = xen_pagetable_setup_start; 2068 x86_init.paging.pagetable_init = xen_pagetable_init;
2045 x86_init.paging.pagetable_setup_done = xen_pagetable_setup_done;
2046 pv_mmu_ops = xen_mmu_ops; 2069 pv_mmu_ops = xen_mmu_ops;
2047 2070
2048 memset(dummy_mapping, 0xff, PAGE_SIZE); 2071 memset(dummy_mapping, 0xff, PAGE_SIZE);
diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index 64effdc6da9..76ba0e97e53 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -194,6 +194,13 @@ RESERVE_BRK(p2m_mid_mfn, PAGE_SIZE * (MAX_DOMAIN_PAGES / (P2M_PER_PAGE * P2M_MID
194 * boundary violation will require three middle nodes. */ 194 * boundary violation will require three middle nodes. */
195RESERVE_BRK(p2m_mid_identity, PAGE_SIZE * 2 * 3); 195RESERVE_BRK(p2m_mid_identity, PAGE_SIZE * 2 * 3);
196 196
197/* When we populate back during bootup, the amount of pages can vary. The
198 * max we have is seen is 395979, but that does not mean it can't be more.
199 * Some machines can have 3GB I/O holes even. With early_can_reuse_p2m_middle
200 * it can re-use Xen provided mfn_list array, so we only need to allocate at
201 * most three P2M top nodes. */
202RESERVE_BRK(p2m_populated, PAGE_SIZE * 3);
203
197static inline unsigned p2m_top_index(unsigned long pfn) 204static inline unsigned p2m_top_index(unsigned long pfn)
198{ 205{
199 BUG_ON(pfn >= MAX_P2M_PFN); 206 BUG_ON(pfn >= MAX_P2M_PFN);
@@ -570,12 +577,99 @@ static bool __init early_alloc_p2m(unsigned long pfn)
570 } 577 }
571 return true; 578 return true;
572} 579}
580
581/*
582 * Skim over the P2M tree looking at pages that are either filled with
583 * INVALID_P2M_ENTRY or with 1:1 PFNs. If found, re-use that page and
584 * replace the P2M leaf with a p2m_missing or p2m_identity.
585 * Stick the old page in the new P2M tree location.
586 */
587bool __init early_can_reuse_p2m_middle(unsigned long set_pfn, unsigned long set_mfn)
588{
589 unsigned topidx;
590 unsigned mididx;
591 unsigned ident_pfns;
592 unsigned inv_pfns;
593 unsigned long *p2m;
594 unsigned long *mid_mfn_p;
595 unsigned idx;
596 unsigned long pfn;
597
598 /* We only look when this entails a P2M middle layer */
599 if (p2m_index(set_pfn))
600 return false;
601
602 for (pfn = 0; pfn < MAX_DOMAIN_PAGES; pfn += P2M_PER_PAGE) {
603 topidx = p2m_top_index(pfn);
604
605 if (!p2m_top[topidx])
606 continue;
607
608 if (p2m_top[topidx] == p2m_mid_missing)
609 continue;
610
611 mididx = p2m_mid_index(pfn);
612 p2m = p2m_top[topidx][mididx];
613 if (!p2m)
614 continue;
615
616 if ((p2m == p2m_missing) || (p2m == p2m_identity))
617 continue;
618
619 if ((unsigned long)p2m == INVALID_P2M_ENTRY)
620 continue;
621
622 ident_pfns = 0;
623 inv_pfns = 0;
624 for (idx = 0; idx < P2M_PER_PAGE; idx++) {
625 /* IDENTITY_PFNs are 1:1 */
626 if (p2m[idx] == IDENTITY_FRAME(pfn + idx))
627 ident_pfns++;
628 else if (p2m[idx] == INVALID_P2M_ENTRY)
629 inv_pfns++;
630 else
631 break;
632 }
633 if ((ident_pfns == P2M_PER_PAGE) || (inv_pfns == P2M_PER_PAGE))
634 goto found;
635 }
636 return false;
637found:
638 /* Found one, replace old with p2m_identity or p2m_missing */
639 p2m_top[topidx][mididx] = (ident_pfns ? p2m_identity : p2m_missing);
640 /* And the other for save/restore.. */
641 mid_mfn_p = p2m_top_mfn_p[topidx];
642 /* NOTE: Even if it is a p2m_identity it should still be point to
643 * a page filled with INVALID_P2M_ENTRY entries. */
644 mid_mfn_p[mididx] = virt_to_mfn(p2m_missing);
645
646 /* Reset where we want to stick the old page in. */
647 topidx = p2m_top_index(set_pfn);
648 mididx = p2m_mid_index(set_pfn);
649
650 /* This shouldn't happen */
651 if (WARN_ON(p2m_top[topidx] == p2m_mid_missing))
652 early_alloc_p2m(set_pfn);
653
654 if (WARN_ON(p2m_top[topidx][mididx] != p2m_missing))
655 return false;
656
657 p2m_init(p2m);
658 p2m_top[topidx][mididx] = p2m;
659 mid_mfn_p = p2m_top_mfn_p[topidx];
660 mid_mfn_p[mididx] = virt_to_mfn(p2m);
661
662 return true;
663}
573bool __init early_set_phys_to_machine(unsigned long pfn, unsigned long mfn) 664bool __init early_set_phys_to_machine(unsigned long pfn, unsigned long mfn)
574{ 665{
575 if (unlikely(!__set_phys_to_machine(pfn, mfn))) { 666 if (unlikely(!__set_phys_to_machine(pfn, mfn))) {
576 if (!early_alloc_p2m(pfn)) 667 if (!early_alloc_p2m(pfn))
577 return false; 668 return false;
578 669
670 if (early_can_reuse_p2m_middle(pfn, mfn))
671 return __set_phys_to_machine(pfn, mfn);
672
579 if (!early_alloc_p2m_middle(pfn, false /* boundary crossover OK!*/)) 673 if (!early_alloc_p2m_middle(pfn, false /* boundary crossover OK!*/))
580 return false; 674 return false;
581 675
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index a4790bf22c5..d11ca11d14f 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -78,9 +78,16 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
78 memblock_reserve(start, size); 78 memblock_reserve(start, size);
79 79
80 xen_max_p2m_pfn = PFN_DOWN(start + size); 80 xen_max_p2m_pfn = PFN_DOWN(start + size);
81 for (pfn = PFN_DOWN(start); pfn < xen_max_p2m_pfn; pfn++) {
82 unsigned long mfn = pfn_to_mfn(pfn);
83
84 if (WARN(mfn == pfn, "Trying to over-write 1-1 mapping (pfn: %lx)\n", pfn))
85 continue;
86 WARN(mfn != INVALID_P2M_ENTRY, "Trying to remove %lx which has %lx mfn!\n",
87 pfn, mfn);
81 88
82 for (pfn = PFN_DOWN(start); pfn <= xen_max_p2m_pfn; pfn++)
83 __set_phys_to_machine(pfn, INVALID_P2M_ENTRY); 89 __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
90 }
84} 91}
85 92
86static unsigned long __init xen_do_chunk(unsigned long start, 93static unsigned long __init xen_do_chunk(unsigned long start,
@@ -157,25 +164,24 @@ static unsigned long __init xen_populate_chunk(
157 unsigned long dest_pfn; 164 unsigned long dest_pfn;
158 165
159 for (i = 0, entry = list; i < map_size; i++, entry++) { 166 for (i = 0, entry = list; i < map_size; i++, entry++) {
160 unsigned long credits = credits_left;
161 unsigned long s_pfn; 167 unsigned long s_pfn;
162 unsigned long e_pfn; 168 unsigned long e_pfn;
163 unsigned long pfns; 169 unsigned long pfns;
164 long capacity; 170 long capacity;
165 171
166 if (credits <= 0) 172 if (credits_left <= 0)
167 break; 173 break;
168 174
169 if (entry->type != E820_RAM) 175 if (entry->type != E820_RAM)
170 continue; 176 continue;
171 177
172 e_pfn = PFN_UP(entry->addr + entry->size); 178 e_pfn = PFN_DOWN(entry->addr + entry->size);
173 179
174 /* We only care about E820 after the xen_start_info->nr_pages */ 180 /* We only care about E820 after the xen_start_info->nr_pages */
175 if (e_pfn <= max_pfn) 181 if (e_pfn <= max_pfn)
176 continue; 182 continue;
177 183
178 s_pfn = PFN_DOWN(entry->addr); 184 s_pfn = PFN_UP(entry->addr);
179 /* If the E820 falls within the nr_pages, we want to start 185 /* If the E820 falls within the nr_pages, we want to start
180 * at the nr_pages PFN. 186 * at the nr_pages PFN.
181 * If that would mean going past the E820 entry, skip it 187 * If that would mean going past the E820 entry, skip it
@@ -184,23 +190,19 @@ static unsigned long __init xen_populate_chunk(
184 capacity = e_pfn - max_pfn; 190 capacity = e_pfn - max_pfn;
185 dest_pfn = max_pfn; 191 dest_pfn = max_pfn;
186 } else { 192 } else {
187 /* last_pfn MUST be within E820_RAM regions */
188 if (*last_pfn && e_pfn >= *last_pfn)
189 s_pfn = *last_pfn;
190 capacity = e_pfn - s_pfn; 193 capacity = e_pfn - s_pfn;
191 dest_pfn = s_pfn; 194 dest_pfn = s_pfn;
192 } 195 }
193 /* If we had filled this E820_RAM entry, go to the next one. */
194 if (capacity <= 0)
195 continue;
196 196
197 if (credits > capacity) 197 if (credits_left < capacity)
198 credits = capacity; 198 capacity = credits_left;
199 199
200 pfns = xen_do_chunk(dest_pfn, dest_pfn + credits, false); 200 pfns = xen_do_chunk(dest_pfn, dest_pfn + capacity, false);
201 done += pfns; 201 done += pfns;
202 credits_left -= pfns;
203 *last_pfn = (dest_pfn + pfns); 202 *last_pfn = (dest_pfn + pfns);
203 if (pfns < capacity)
204 break;
205 credits_left -= pfns;
204 } 206 }
205 return done; 207 return done;
206} 208}
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index afb250d22a6..f58dca7a6e5 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -80,9 +80,7 @@ static void __cpuinit cpu_bringup(void)
80 80
81 notify_cpu_starting(cpu); 81 notify_cpu_starting(cpu);
82 82
83 ipi_call_lock();
84 set_cpu_online(cpu, true); 83 set_cpu_online(cpu, true);
85 ipi_call_unlock();
86 84
87 this_cpu_write(cpu_state, CPU_ONLINE); 85 this_cpu_write(cpu_state, CPU_ONLINE);
88 86
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 8a3f8351f43..8ed64cfae4f 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -7,6 +7,7 @@ config ZONE_DMA
7config XTENSA 7config XTENSA
8 def_bool y 8 def_bool y
9 select HAVE_IDE 9 select HAVE_IDE
10 select GENERIC_ATOMIC64
10 select HAVE_GENERIC_HARDIRQS 11 select HAVE_GENERIC_HARDIRQS
11 select GENERIC_IRQ_SHOW 12 select GENERIC_IRQ_SHOW
12 select GENERIC_CPU_DEVICES 13 select GENERIC_CPU_DEVICES
diff --git a/arch/xtensa/include/asm/cpumask.h b/arch/xtensa/include/asm/cpumask.h
deleted file mode 100644
index ebeede397db..00000000000
--- a/arch/xtensa/include/asm/cpumask.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * include/asm-xtensa/cpumask.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_CPUMASK_H
12#define _XTENSA_CPUMASK_H
13
14#include <asm-generic/cpumask.h>
15
16#endif /* _XTENSA_CPUMASK_H */
diff --git a/arch/xtensa/include/asm/rmap.h b/arch/xtensa/include/asm/rmap.h
deleted file mode 100644
index 649588b7e9a..00000000000
--- a/arch/xtensa/include/asm/rmap.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * include/asm-xtensa/rmap.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_RMAP_H
12#define _XTENSA_RMAP_H
13
14#include <asm-generic/rmap.h>
15
16#endif
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c
index eb30e356f5b..69759e9cb3e 100644
--- a/arch/xtensa/kernel/pci.c
+++ b/arch/xtensa/kernel/pci.c
@@ -46,7 +46,6 @@
46 * pcibios_fixups 46 * pcibios_fixups
47 * pcibios_align_resource 47 * pcibios_align_resource
48 * pcibios_fixup_bus 48 * pcibios_fixup_bus
49 * pcibios_setup
50 * pci_bus_add_device 49 * pci_bus_add_device
51 * pci_mmap_page_range 50 * pci_mmap_page_range
52 */ 51 */
@@ -187,7 +186,7 @@ static int __init pcibios_init(void)
187 bus = pci_scan_root_bus(NULL, pci_ctrl->first_busno, 186 bus = pci_scan_root_bus(NULL, pci_ctrl->first_busno,
188 pci_ctrl->ops, pci_ctrl, &resources); 187 pci_ctrl->ops, pci_ctrl, &resources);
189 pci_ctrl->bus = bus; 188 pci_ctrl->bus = bus;
190 pci_ctrl->last_busno = bus->subordinate; 189 pci_ctrl->last_busno = bus->busn_res.end;
191 if (next_busno <= pci_ctrl->last_busno) 190 if (next_busno <= pci_ctrl->last_busno)
192 next_busno = pci_ctrl->last_busno+1; 191 next_busno = pci_ctrl->last_busno+1;
193 } 192 }
@@ -206,11 +205,6 @@ void __init pcibios_fixup_bus(struct pci_bus *bus)
206 } 205 }
207} 206}
208 207
209char __init *pcibios_setup(char *str)
210{
211 return str;
212}
213
214void pcibios_set_master(struct pci_dev *dev) 208void pcibios_set_master(struct pci_dev *dev)
215{ 209{
216 /* No special bus mastering setup handling */ 210 /* No special bus mastering setup handling */
diff --git a/arch/xtensa/kernel/syscall.c b/arch/xtensa/kernel/syscall.c
index 816e6d0d686..05b3f093d5d 100644
--- a/arch/xtensa/kernel/syscall.c
+++ b/arch/xtensa/kernel/syscall.c
@@ -44,7 +44,7 @@ asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg)
44 unsigned long ret; 44 unsigned long ret;
45 long err; 45 long err;
46 46
47 err = do_shmat(shmid, shmaddr, shmflg, &ret); 47 err = do_shmat(shmid, shmaddr, shmflg, &ret, SHMLBA);
48 if (err) 48 if (err)
49 return err; 49 return err;
50 return (long)ret; 50 return (long)ret;
diff --git a/arch/xtensa/mm/fault.c b/arch/xtensa/mm/fault.c
index b17885a0b50..5a74c53bc69 100644
--- a/arch/xtensa/mm/fault.c
+++ b/arch/xtensa/mm/fault.c
@@ -44,6 +44,7 @@ void do_page_fault(struct pt_regs *regs)
44 44
45 int is_write, is_exec; 45 int is_write, is_exec;
46 int fault; 46 int fault;
47 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
47 48
48 info.si_code = SEGV_MAPERR; 49 info.si_code = SEGV_MAPERR;
49 50
@@ -71,6 +72,7 @@ void do_page_fault(struct pt_regs *regs)
71 address, exccause, regs->pc, is_write? "w":"", is_exec? "x":""); 72 address, exccause, regs->pc, is_write? "w":"", is_exec? "x":"");
72#endif 73#endif
73 74
75retry:
74 down_read(&mm->mmap_sem); 76 down_read(&mm->mmap_sem);
75 vma = find_vma(mm, address); 77 vma = find_vma(mm, address);
76 78
@@ -93,6 +95,7 @@ good_area:
93 if (is_write) { 95 if (is_write) {
94 if (!(vma->vm_flags & VM_WRITE)) 96 if (!(vma->vm_flags & VM_WRITE))
95 goto bad_area; 97 goto bad_area;
98 flags |= FAULT_FLAG_WRITE;
96 } else if (is_exec) { 99 } else if (is_exec) {
97 if (!(vma->vm_flags & VM_EXEC)) 100 if (!(vma->vm_flags & VM_EXEC))
98 goto bad_area; 101 goto bad_area;
@@ -104,7 +107,11 @@ good_area:
104 * make sure we exit gracefully rather than endlessly redo 107 * make sure we exit gracefully rather than endlessly redo
105 * the fault. 108 * the fault.
106 */ 109 */
107 fault = handle_mm_fault(mm, vma, address, is_write ? FAULT_FLAG_WRITE : 0); 110 fault = handle_mm_fault(mm, vma, address, flags);
111
112 if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
113 return;
114
108 if (unlikely(fault & VM_FAULT_ERROR)) { 115 if (unlikely(fault & VM_FAULT_ERROR)) {
109 if (fault & VM_FAULT_OOM) 116 if (fault & VM_FAULT_OOM)
110 goto out_of_memory; 117 goto out_of_memory;
@@ -112,10 +119,22 @@ good_area:
112 goto do_sigbus; 119 goto do_sigbus;
113 BUG(); 120 BUG();
114 } 121 }
115 if (fault & VM_FAULT_MAJOR) 122 if (flags & FAULT_FLAG_ALLOW_RETRY) {
116 current->maj_flt++; 123 if (fault & VM_FAULT_MAJOR)
117 else 124 current->maj_flt++;
118 current->min_flt++; 125 else
126 current->min_flt++;
127 if (fault & VM_FAULT_RETRY) {
128 flags &= ~FAULT_FLAG_ALLOW_RETRY;
129
130 /* No need to up_read(&mm->mmap_sem) as we would
131 * have already released it in __lock_page_or_retry
132 * in mm/filemap.c.
133 */
134
135 goto retry;
136 }
137 }
119 138
120 up_read(&mm->mmap_sem); 139 up_read(&mm->mmap_sem);
121 return; 140 return;